diff --git a/application/controllers/admin/quotas.php b/application/controllers/admin/quotas.php index ed963c229f6..22b9bf54f03 100644 --- a/application/controllers/admin/quotas.php +++ b/application/controllers/admin/quotas.php @@ -126,18 +126,26 @@ function index($iSurveyId, $quickreport = false) $aData['completed'] = $completed; $aData['totalquotas'] = $totalquotas; $aData['totalcompleted'] = $totalcompleted; + $aResults2 = QuotaMember::model()->findAllByAttributes(array('quota_id' => $aQuotaListing['id'])); + $aData['totalquestion'] = count($aResults2); $aViewUrls['output'] .= $this->getController()->renderPartial("/admin/quotas/viewquotasrow_view", $aData, true); //check how many sub-elements exist for a certain quota - $aResults2 = QuotaMember::model()->findAllByAttributes(array('quota_id' => $aQuotaListing['id'])); - //loop through all sub-parts - foreach ($aResults2 as $aQuotaQuestions) + if(count($aResults2)==0) + { + $aViewUrls['output'] .= $this->getController()->renderPartial('/admin/quotas/viewemptyquotasrowsub_view', $aData, true); + } + else { - $aQuestionAnswers = self::getQuotaAnswers($aQuotaQuestions['qid'], $iSurveyId, $aQuotaListing['id']); - $aData['question_answers'] = $aQuestionAnswers; - $aData['quota_questions'] = $aQuotaQuestions; - $aViewUrls['output'] .= $this->getController()->renderPartial('/admin/quotas/viewquotasrowsub_view', $aData, true); + //loop through all sub-parts + foreach ($aResults2 as $aQuotaQuestions) + { + $aQuestionAnswers = self::getQuotaAnswers($aQuotaQuestions['qid'], $iSurveyId, $aQuotaListing['id']); + $aData['question_answers'] = $aQuestionAnswers; + $aData['quota_questions'] = $aQuotaQuestions; + $aViewUrls['output'] .= $this->getController()->renderPartial('/admin/quotas/viewquotasrowsub_view', $aData, true); + } } } } @@ -182,6 +190,7 @@ function insertquota($iSurveyId) $oQuota->qlimit = Yii::app()->request->getPost('quota_limit'); $oQuota->action = Yii::app()->request->getPost('quota_action'); $oQuota->autoload_url = Yii::app()->request->getPost('autoload_url'); + $oQuota->active = Yii::app()->request->getPost('active',0); $oQuota->save(); $iQuotaId = $oQuota->id; @@ -236,6 +245,7 @@ function modifyquota($iSurveyId) $oQuota->qlimit = Yii::app()->request->getPost('quota_limit'); $oQuota->action = Yii::app()->request->getPost('quota_action'); $oQuota->autoload_url = Yii::app()->request->getPost('autoload_url'); + $oQuota->active = Yii::app()->request->getPost('active',0); $oQuota->save(); //Iterate through each language posted, and make sure there is a quota message for it @@ -265,9 +275,9 @@ function modifyquota($iSurveyId) $oQuotaLanguageSettings = QuotaLanguageSetting::model()->findByAttributes(array('quotals_quota_id' => Yii::app()->request->getPost('quota_id'), 'quotals_language' => $sLang)); $oQuotaLanguageSettings->quotals_name = Yii::app()->request->getPost('quota_name'); - $oQuotaLanguageSettings->quotals_message = $_POST['quotals_message_' . $sLang]; - $oQuotaLanguageSettings->quotals_url = $_POST['quotals_url_' . $sLang]; - $oQuotaLanguageSettings->quotals_urldescrip = $_POST['quotals_urldescrip_' . $sLang]; + $oQuotaLanguageSettings->quotals_message = Yii::app()->request->getPost('quotals_message_' . $sLang); + $oQuotaLanguageSettings->quotals_url = Yii::app()->request->getPost('quotals_url_' . $sLang); + $oQuotaLanguageSettings->quotals_urldescrip = Yii::app()->request->getPost('quotals_urldescrip_' . $sLang); $oQuotaLanguageSettings->save(); } } //End insert language based components diff --git a/application/helpers/common_helper.php b/application/helpers/common_helper.php index 3b1c16e186c..c1c59de71fe 100644 --- a/application/helpers/common_helper.php +++ b/application/helpers/common_helper.php @@ -5423,8 +5423,7 @@ function getQuotaCompletedCount($iSurveyId, $quotaid) $aColumnName=SurveyDynamic::model($iSurveyId)->getTableSchema()->getColumnNames(); $aQuotas = getQuotaInformation($iSurveyId, Survey::model()->findByPk($iSurveyId)->language, $quotaid); $aQuota = $aQuotas[0]; - if (Yii::app()->db->schema->getTable('{{survey_' . $iSurveyId . '}}') && - count($aQuota['members']) > 0) + if (Yii::app()->db->schema->getTable('{{survey_' . $iSurveyId . '}}') ) { // Keep a list of fields for easy reference $aQuotaColumns = array(); diff --git a/application/helpers/frontend_helper.php b/application/helpers/frontend_helper.php index a487899511e..ed177134b89 100644 --- a/application/helpers/frontend_helper.php +++ b/application/helpers/frontend_helper.php @@ -1926,8 +1926,9 @@ function checkCompletedQuota($surveyid,$return=false) $aPostedFields = explode("|",Yii::app()->request->getPost('fieldnames','')); // Needed for quota allowing update foreach ($aQuotasInfo as $aQuotaInfo) { - if(count($aQuotaInfo['members'])===0) + if(!$aQuotaInfo['active']) // Maybe add || ($aQuotaInfo['qlimit'] == 0 && count($aQuotaInfo['members'])==0) : this is a broken quota or not ? continue; + $iMatchedAnswers=0; $bPostedField=false; // Array of field with quota array value diff --git a/application/views/admin/quotas/editquota_view.php b/application/views/admin/quotas/editquota_view.php index f9e17277a9f..84da4d19781 100644 --- a/application/views/admin/quotas/editquota_view.php +++ b/application/views/admin/quotas/editquota_view.php @@ -8,6 +8,7 @@
  • />
  • +
  • />