예제 #1
0
 public static function getAllQuota()
 {
     $Data = Quota::model()->findAll();
     $res = array();
     foreach ($Data as $record) {
         $res[$record->idQuota] = $record->QuotaName;
     }
     return $res;
 }
예제 #2
0
 function deleteQuota($condition = false, $recursive = true)
 {
     if ($recursive == true) {
         $oResult = Quota::model()->findAllByAttributes($condition);
         foreach ($oResult as $aRow) {
             Quota_languagesettings::model()->deleteAllByAttributes(array('quotals_quota_id' => $aRow['id']));
             Quota_members::model()->deleteAllByAttributes(array('quota_id' => $aRow['id']));
         }
     }
     Quota::model()->deleteAllByAttributes($condition);
 }
$StudentInfo = StudentInfo::model()->findByPk($student_transaction[0]->student_transaction_student_id);
$AcademicTermPeriod = AcademicTermPeriod::model()->findByPk($student_transaction[0]->student_academic_term_period_tran_id);
$AcademicTerm = AcademicTerm::model()->findByPk($student_transaction[0]->student_academic_term_name_id);
if ($student_transaction[0]->student_transaction_category_id != null) {
    $Category = Category::model()->findByPk($student_transaction[0]->student_transaction_category_id);
} else {
    $Category = new Category();
}
if ($student_transaction[0]->student_transaction_category_id != null) {
    $Nationality = Nationality::model()->findByPk($student_transaction[0]->student_transaction_nationality_id);
} else {
    $Nationality = new Nationality();
}
if ($student_transaction[0]->student_transaction_quota_id != null) {
    $Quota = Quota::model()->findByPk($student_transaction[0]->student_transaction_quota_id);
} else {
    $Quota = new Quota();
}
if ($student_transaction[0]->student_transaction_religion_id != null) {
    $Religion = Religion::model()->findByPk($student_transaction[0]->student_transaction_religion_id);
} else {
    $Religion = new Religion();
}
$Branch = Branch::model()->findByPk($student_transaction[0]->student_transaction_branch_id);
$Shift = Shift::model()->findByPk($student_transaction[0]->student_transaction_shift_id);
$Division = Division::model()->findByPk($student_transaction[0]->student_transaction_division_id);
$Batch = Batch::model()->findByPk($student_transaction[0]->student_transaction_batch_id);
$Organization = Organization::model()->findByPk($student_transaction[0]->student_transaction_organization_id);
if ($student_transaction[0]->student_transaction_languages_known_id != null) {
    $LanguagesKnown = LanguagesKnown::model()->findByPk($student_transaction[0]->student_transaction_languages_known_id);
	if(Yii::app()->controller->action->id=="certiview")
	{
		$certi= StudentCertificateDetailsTable::model()->find(array('condition'=>' 	student_certificate_details_table_student_id='.$trans->student_transaction_id.' and student_certificate_type_id='.$certificate_type,'order'=>'student_certificate_details_table_id desc'));
		$ref_no = $certi->certificate_reference_number;
	}		
	else{
	$certi = StudentCertificateDetailsTable::model()->find(array('order'=>'student_certificate_details_table_id desc'));
	$autonum = 0;
	if(!empty($certi) && $certi->certificate_reference_number!=""){
	$arr = explode('/',$certi->certificate_reference_number);
	$autonum = $arr[3];
	}
	$autonum +=1;
	$ref_no = $year."/".$branch_model->branch_code."/".date('Y').'/'.$autonum;
	}
	$quota = "<b>".Quota::model()->findByPk($trans->student_transaction_quota_id)->quota_name."</b>";
	$content = Certificate::model()->findByPk($model->certificatetype)->certificate_content;
	
	$content = str_replace('{title}',$titl,$content);
	$content = str_replace('{name}',$name,$content);
	$content = str_replace('{branch}',$branch,$content);
	$content = str_replace('{sem}',$sem,$content);	
	$content = str_replace('{division}',$div,$content);
	$content = str_replace('{enrollment}',$en_no,$content);
	$content = str_replace('{gender}',$gender,$content);
	$content = str_replace('{category}',$category,$content);
	$content = str_replace('{quota}',$quota,$content);
	$content = str_replace('{smobile}',$smobile,$content);
	$content = str_replace('{pmobile}',$pmobile,$content);
	$content = str_replace('{date}',$cdate,$content);
	$content = str_replace('{line1}',$lin1,$content);
예제 #5
0
 function new_answer($iSurveyId, $sSubAction = 'new_answer')
 {
     $iSurveyId = sanitize_int($iSurveyId);
     $this->_checkPermissions($iSurveyId, 'update');
     $aData = $this->_getData($iSurveyId);
     $sBaseLang = $aData['sBaseLang'];
     $aViewUrls = array();
     if (($sSubAction == "new_answer" || $sSubAction == "new_answer_two" && !isset($_POST['quota_qid'])) && Permission::model()->hasSurveyPermission($iSurveyId, 'quotas', 'create')) {
         $result = Quota::model()->findAllByPk(Yii::app()->request->getPost('quota_id'));
         foreach ($result as $aQuotaDetails) {
             $quota_name = $aQuotaDetails['name'];
         }
         $result = Question::model()->findAllByAttributes(array('type' => array('G', 'M', 'Y', 'A', 'B', 'I', 'L', 'O', '!'), 'sid' => $iSurveyId, 'language' => $sBaseLang, 'parent_qid' => 0));
         if (empty($result)) {
             $aViewUrls[] = 'newanswererror_view';
         } else {
             $aData['newanswer_result'] = $result;
             $aData['quota_name'] = $quota_name;
             $aViewUrls[] = 'newanswer_view';
         }
     }
     if ($sSubAction == "new_answer_two" && isset($_POST['quota_qid']) && Permission::model()->hasSurveyPermission($iSurveyId, 'quotas', 'create')) {
         $aResults = Quota::model()->findByPk(Yii::app()->request->getPost('quota_qid'));
         $sQuotaName = $aResults['name'];
         $aQuestionAnswers = self::getQuotaAnswers(Yii::app()->request->getPost('quota_qid'), $iSurveyId, Yii::app()->request->getPost('quota_id'));
         $x = 0;
         foreach ($aQuestionAnswers as $aQACheck) {
             if (isset($aQACheck['rowexists'])) {
                 $x++;
             }
         }
         reset($aQuestionAnswers);
         $aData['question_answers'] = $aQuestionAnswers;
         $aData['x'] = $x;
         $aData['quota_name'] = $sQuotaName;
         $aViewUrls[] = 'newanswertwo_view';
     }
     $aData['sidemenu']['state'] = false;
     $surveyinfo = Survey::model()->findByPk($iSurveyId)->surveyinfo;
     $aData['title_bar']['title'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $iSurveyId . ")";
     $aData['surveybar']['savebutton']['form'] = 'frmeditgroup';
     $aData['surveybar']['closebutton']['url'] = 'admin/quotas/sa/index/surveyid/' . $iSurveyId;
     // Close button
     $this->_renderWrappedTemplate('quotas', $aViewUrls, $aData);
 }
예제 #6
0
        $label = null;
        $field_value = null;
        ?>
	<!--Content div-->
	<div class="front_content">
		<div class="contentpic">
			<?php 
        echo CHtml::image(Yii::app()->baseUrl . "/college_data/stud_images/" . $studphoto, "no-images", array("width" => "60px", "height" => "60px"));
        ?>
		</div>
		<div class="contentinfo">
		
		<?php 
        foreach ($selected_list as $key => $value) {
            if ($key == 'quota_name') {
                $field_value = Quota::model()->findByPk($stud['student_transaction_quota_id'])->quota_name;
            } else {
                if ($key == 'branch_name') {
                    $field_value = Branch::model()->findByPk($stud['student_transaction_branch_id'])->branch_name;
                } else {
                    if ($key == 'division_code') {
                        $field_value = Division::model()->findByPk($stud['student_transaction_division_id'])->{$key};
                    } else {
                        if ($key == 'sem') {
                            $field_value = AcademicTerm::model()->findByPk($stud['student_academic_term_name_id'])->academic_term_name;
                        } else {
                            if ($key == 'student_first_name') {
                                $lname = $StudentInfo->student_last_name;
                                $fname = $StudentInfo->student_first_name;
                                $mname = $StudentInfo->student_middle_name;
                                $label = $value;
		</td>

		<td>
			<?php 
    echo AcademicTermPeriod::model()->findByPk($i['fees_academic_term_id'])->academic_term_period;
    ?>
		</td>

		<td>
			<?php 
    echo AcademicTerm::model()->findByPk($i['fees_academic_term_name_id'])->academic_term_name;
    ?>
		</td>
		<td>
			<?php 
    echo Quota::model()->findByPk($i['fees_quota_id'])->quota_name;
    ?>
		</td>
		<td>

		<u>
			<?php 
    echo CHtml::link($numStud[$j], array('feesPaymentTransaction/total', 'branch_id' => $i['fees_branch_id'], 'acm_id' => $i['fees_academic_term_id'], 'acm_name_id' => $i['fees_academic_term_name_id'], 'quota' => $i['fees_quota_id']));
    ?>
</u>
		</td>
		<td>
		<u>
			<?php 
    echo CHtml::link($paid_stud_count[$j], array('feesPaymentTransaction/paid', 'branch_id' => $i['fees_branch_id'], 'acm_id' => $i['fees_academic_term_id'], 'acm_name_id' => $i['fees_academic_term_name_id'], 'quota' => $i['fees_quota_id']));
    ?>
예제 #8
0
/**
* getQuotaInformation() returns quota information for the current survey
* @param string $surveyid - Survey identification number
* @param string $quotaid - Optional quotaid that restricts the result to a given quota
* @return array - nested array, Quotas->Members->Fields
*/
function getQuotaInformation($surveyid, $language, $iQuotaID = 'all')
{
    global $clienttoken;
    $baselang = Survey::model()->findByPk($surveyid)->language;
    $aAttributes = array('sid' => $surveyid);
    if ($iQuotaID != 'all') {
        $aAttributes['id'] = $iQuotaID;
    }
    $result = Quota::model()->with(array('languagesettings' => array('condition' => "quotals_language='{$language}'")))->findAllByAttributes($aAttributes);
    $quota_info = array();
    $x = 0;
    $surveyinfo = getSurveyInfo($surveyid);
    // Check all quotas for the current survey
    //if ($result->RecordCount() > 0)
    if (count($result) > 0) {
        //while ($survey_quotas = $result->FetchRow())
        foreach ($result as $_survey_quotas) {
            $survey_quotas = $_survey_quotas->attributes;
            // !!! Doubting this
            foreach ($_survey_quotas->languagesettings[0] as $k => $v) {
                $survey_quotas[$k] = $v;
            }
            //Modify the URL - thanks janokary
            $survey_quotas['quotals_url'] = str_replace("{SAVEDID}", !empty(Yii::app()->session['srid']) ? Yii::app()->session['srid'] : '', $survey_quotas['quotals_url']);
            $survey_quotas['quotals_url'] = str_replace("{SID}", $surveyid, $survey_quotas['quotals_url']);
            $survey_quotas['quotals_url'] = str_replace("{LANG}", Yii::app()->lang->getlangcode(), $survey_quotas['quotals_url']);
            $survey_quotas['quotals_url'] = str_replace("{TOKEN}", $clienttoken, $survey_quotas['quotals_url']);
            array_push($quota_info, array('Name' => $survey_quotas['name'], 'Limit' => $survey_quotas['qlimit'], 'Action' => $survey_quotas['action'], 'Message' => $survey_quotas['quotals_message'], 'Url' => $survey_quotas['quotals_url'], 'UrlDescrip' => $survey_quotas['quotals_urldescrip'], 'AutoloadUrl' => $survey_quotas['autoload_url']));
            $result_qe = Quota_members::model()->findAllByAttributes(array('quota_id' => $survey_quotas['id']));
            $quota_info[$x]['members'] = array();
            if (count($result_qe) > 0) {
                foreach ($result_qe as $quota_entry) {
                    $quota_entry = $quota_entry->attributes;
                    $result_quest = Questions::model()->findByAttributes(array('qid' => $quota_entry['qid'], 'language' => $baselang));
                    $qtype = $result_quest->attributes;
                    $fieldnames = "0";
                    if ($qtype['type'] == "I" || $qtype['type'] == "G" || $qtype['type'] == "Y") {
                        $fieldnames = array(0 => $surveyid . 'X' . $qtype['gid'] . 'X' . $quota_entry['qid']);
                        $value = $quota_entry['code'];
                    }
                    if ($qtype['type'] == "L" || $qtype['type'] == "O" || $qtype['type'] == "!") {
                        $fieldnames = array(0 => $surveyid . 'X' . $qtype['gid'] . 'X' . $quota_entry['qid']);
                        $value = $quota_entry['code'];
                    }
                    if ($qtype['type'] == "M") {
                        $fieldnames = array(0 => $surveyid . 'X' . $qtype['gid'] . 'X' . $quota_entry['qid'] . $quota_entry['code']);
                        $value = "Y";
                    }
                    if ($qtype['type'] == "A" || $qtype['type'] == "B") {
                        $temp = explode('-', $quota_entry['code']);
                        $fieldnames = array(0 => $surveyid . 'X' . $qtype['gid'] . 'X' . $quota_entry['qid'] . $temp[0]);
                        $value = $temp[1];
                    }
                    array_push($quota_info[$x]['members'], array('Title' => $qtype['title'], 'type' => $qtype['type'], 'code' => $quota_entry['code'], 'value' => $value, 'qid' => $quota_entry['qid'], 'fieldnames' => $fieldnames));
                }
            }
            $x++;
        }
    }
    return $quota_info;
}
    /**
     * Creates a new model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     */
    public function actionCreate()
    {
        $model = new FeesPaymentTransaction();
        $FeesMasterDetails = new FeesMaster();
        $total = 0;
        $result = $_REQUEST['id'];
        $fees_stru = Yii::app()->db->createCommand()->select('fees.fees_master_id , fees.fees_master_name , fees.fees_branch_id , stud.student_transaction_branch_id , stud.student_transaction_organization_id , fees.fees_organization_id , stud.student_transaction_quota_id , fees.fees_quota_id ,stud.student_academic_term_period_tran_id , fees.fees_academic_term_id, fees.fees_academic_term_name_id, fees.fees_master_total')->from('student_transaction stud')->join('fees_master fees', 'stud.student_transaction_branch_id = fees.fees_branch_id
		AND stud.student_academic_term_period_tran_id = fees.fees_academic_term_id
		AND stud.student_academic_term_name_id = fees.fees_academic_term_name_id 	
		AND stud.student_transaction_quota_id = fees.fees_quota_id')->where('stud.student_transaction_id=:id', array(':id' => $result))->queryRow();
        $student_fees = StudentFeesMaster::model()->findAll('fees_master_table_id = :fees_master_id AND student_fees_master_student_transaction_id = :student_id', array(':fees_master_id' => $fees_stru['fees_master_id'], ':student_id' => $result));
        //print_r($student_fees);  exit;
        foreach ($student_fees as $fees_data) {
            $total += $fees_data->fees_details_amount;
        }
        if (!$fees_stru) {
            $ourscript = "alert('No fees available for this critaria.. Please create fees with this branch, academic year and semester of student. \t');";
            Yii::app()->clientScript->registerScript('helloscript', $ourscript, CClientScript::POS_READY);
            $this->redirect(array('error', 'status' => 'nofees'));
        } else {
            $model->fees_payment_master_id = $fees_stru['fees_master_id'];
            $org = Organization::model()->findByPk($fees_stru['fees_organization_id']);
            $quota = Quota::model()->findByPk($fees_stru['fees_quota_id']);
            $branch = Branch::model()->findByPk($fees_stru['fees_branch_id']);
            $acmd = AcademicTermPeriod::model()->findByPk($fees_stru['fees_academic_term_id']);
            $acmd_name = AcademicTerm::model()->findByPk($fees_stru['fees_academic_term_name_id']);
            $FeesMasterDetails->fees_master_name = $fees_stru['fees_master_name'];
            $FeesMasterDetails->fees_organization_id = $org->organization_name;
            $FeesMasterDetails->fees_quota_id = $quota->quota_name;
            $FeesMasterDetails->fees_branch_id = $branch->branch_name;
            $FeesMasterDetails->fees_academic_term_id = $acmd->academic_term_period;
            $FeesMasterDetails->fees_academic_term_name_id = $acmd_name->academic_term_name;
            $FeesMasterDetails->fees_master_total = $total;
            $model->fees_payment_master_id = $fees_stru['fees_master_id'];
            $cash_model = new FeesPaymentTransaction('cashsearch');
            $cash_model->unsetAttributes();
            // clear any default values
            if (isset($_GET['FeesPaymentTransaction'])) {
                $cash_model->attributes = $_GET['FeesPaymentTransaction'];
            }
            $cheque_model = new FeesPaymentTransaction('chequesearch');
            $cheque_model->unsetAttributes();
            // clear any default values
            if (isset($_GET['FeesPaymentTransaction'])) {
                $cheque_model->attributes = $_GET['FeesPaymentTransaction'];
            }
            $this->render('create', array('model' => $model, 'FeesMasterDetails' => $FeesMasterDetails, 'cash_model' => $cash_model, 'cheque_model' => $cheque_model));
        }
    }
     }
 }
 echo "</tr>";
 $i = 1;
 $m = 1;
 foreach ($stud_data as $t => $sd) {
     if ($m % 2 == 0) {
         $class = "odd";
     } else {
         $class = "even";
     }
     echo "<tr class=" . $class . ">";
     echo "<td style='text-align:center;'>" . $i . "</td>";
     foreach ($selected_list as $s) {
         if ($s == 'quota_name') {
             echo "<td style='text-align:center;'>" . Quota::model()->findByPk($sd['student_transaction_quota_id'])->quota_name . "</td>";
         } else {
             if ($s == 'branch_name') {
                 echo "<td style='text-align:center;'>" . Branch::model()->findByPk($sd['student_transaction_branch_id'])->branch_name . "</td>";
             } else {
                 if ($s == 'division_code') {
                     echo "<td style='text-align:center;'>" . Division::model()->findByPk($sd['student_transaction_division_id'])->{$s} . "</td>";
                 } else {
                     if ($s == 'sem') {
                         echo "<td style='text-align:center;'>" . AcademicTerm::model()->findByPk($sd['student_academic_term_name_id'])->academic_term_name . "</td>";
                     } else {
                         if ($s == 'student_address_c_line1') {
                             if ($sd['student_transaction_student_address_id'] != 0) {
                                 echo "<td style='text-align:center;min-width:400px;'>" . StudentAddress::model()->findByPk($sd['student_transaction_student_address_id'])->student_address_c_line1 . " " . StudentAddress::model()->findByPk($sd['student_transaction_student_address_id'])->student_address_c_line2 . "</td>";
                             } else {
                                 echo "<td style='text-align:center;'>&nbsp;</td>";
<?php 
$org_id = Yii::app()->user->getState('org_id');
$data = Yii::app()->db->createCommand()->selectDistinct('fees.fees_student_id, stud.student_transaction_id,stud.student_transaction_student_id,stud.student_transaction_quota_id')->from('fees_payment_transaction fees')->join('student_transaction stud', 'fees.fees_student_id = stud.student_transaction_id')->where('stud.student_transaction_branch_id = :branch_id AND stud.student_transaction_quota_id =:quota_id AND stud.student_academic_term_period_tran_id = :acm_id AND fees.fees_academic_term_id = :acm_name_id AND stud.student_transaction_organization_id = :org_id', array(':branch_id' => $_REQUEST['branch_id'], ':acm_id' => $_REQUEST['acm_id'], ':acm_name_id' => $_REQUEST['acm_name_id'], ':org_id' => $org_id, ':quota_id' => $_REQUEST['quota']))->queryAll();
echo "<h2 align='center'>Branch : " . Branch::model()->findByPk($_REQUEST['branch_id'])->branch_name . "(" . Quota::model()->findByPk($_REQUEST['quota'])->quota_name . ")<br/>";
echo "Semester: " . AcademicTerm::model()->findByPk($_REQUEST['acm_name_id'])->academic_term_name . "(" . AcademicTermPeriod::model()->findByPk($_REQUEST['acm_id'])->academic_term_period . ")" . "</h2>";
$fees_master = FeesMaster::model()->findByAttributes(array('fees_quota_id' => $_REQUEST['quota'], 'fees_branch_id' => $_REQUEST['branch_id'], 'fees_academic_term_name_id' => $_REQUEST['acm_name_id']));
$fees_masterid = $fees_master->fees_master_id;
if ($data) {
    ?>

<table class="table_data" border="1">
<tr class="table_header">
	<th>SI.No.</th>
	<th>Enroll No.</th>
	<th>Roll No.</th>
	<th>Name</th>
	<th>Payable Amount</th>
	<th>Paid Amount</th>
	<th>Outstanding</th>
</tr>
<?php 
    $i = 0;
    $m = 1;
    $grandpayable = 0;
    $grandpaidtotal = 0;
    $grandoutstandtotal = 0;
    foreach ($data as $info) {
        if ($m % 2 == 0) {
            $class = "odd";
        } else {
예제 #12
0
 /**
  * This function checks the LimeSurvey database for logical consistency and returns an according array
  * containing all issues in the particular tables.
  * @returns Array with all found issues.
  */
 protected function _checkintegrity()
 {
     $clang = Yii::app()->lang;
     /*** Plainly delete survey permissions if the survey or user does not exist ***/
     $users = User::model()->findAll();
     $uids = array();
     foreach ($users as $user) {
         $uids[] = $user['uid'];
     }
     $oCriteria = new CDbCriteria();
     $oCriteria->addNotInCondition('uid', $uids, 'OR');
     $surveys = Survey::model()->findAll();
     $sids = array();
     foreach ($surveys as $survey) {
         $sids[] = $survey['sid'];
     }
     $oCriteria->addNotInCondition('entity_id', $sids, 'OR');
     $oCriteria->addCondition("entity='survey'");
     Permission::model()->deleteAll($oCriteria);
     // Deactivate surveys that have a missing response table
     foreach ($surveys as $survey) {
         if ($survey['active'] == 'Y' && !tableExists("{{survey_{$survey['sid']}}}")) {
             Survey::model()->updateByPk($survey['sid'], array('active' => 'N'));
         }
     }
     unset($surveys);
     // Fix subquestions
     fixSubquestions();
     /*** Check for active survey tables with missing survey entry and rename them ***/
     $sDBPrefix = Yii::app()->db->tablePrefix;
     $sQuery = dbSelectTablesLike('{{survey}}\\_%');
     $aResult = dbQueryOrFalse($sQuery);
     foreach ($aResult->readAll() as $aRow) {
         $sTableName = substr(reset($aRow), strlen($sDBPrefix));
         if ($sTableName == 'survey_links' || $sTableName == 'survey_url_parameters') {
             continue;
         }
         $aTableName = explode('_', $sTableName);
         if (isset($aTableName[1]) && ctype_digit($aTableName[1])) {
             $iSurveyID = $aTableName[1];
             if (!in_array($iSurveyID, $sids)) {
                 $sDate = date('YmdHis') . rand(1, 1000);
                 $sOldTable = "survey_{$iSurveyID}";
                 $sNewTable = "old_survey_{$iSurveyID}_{$sDate}";
                 try {
                     $deactivateresult = Yii::app()->db->createCommand()->renameTable("{{{$sOldTable}}}", "{{{$sNewTable}}}");
                 } catch (CDbException $e) {
                     die('Couldn\'t make backup of the survey table. Please try again. The database reported the following error:<br />' . htmlspecialchars($e) . '<br />');
                 }
             }
         }
     }
     /*** Check for active token tables with missing survey entry ***/
     $aResult = dbQueryOrFalse(dbSelectTablesLike('{{tokens}}\\_%'));
     foreach ($aResult->readAll() as $aRow) {
         $sTableName = substr(reset($aRow), strlen($sDBPrefix));
         $iSurveyID = substr($sTableName, strpos($sTableName, '_') + 1);
         if (!in_array($iSurveyID, $sids)) {
             $sDate = date('YmdHis') . rand(1, 1000);
             $sOldTable = "tokens_{$iSurveyID}";
             $sNewTable = "old_tokens_{$iSurveyID}_{$sDate}";
             try {
                 $deactivateresult = Yii::app()->db->createCommand()->renameTable("{{{$sOldTable}}}", "{{{$sNewTable}}}");
             } catch (CDbException $e) {
                 die('Couldn\'t make backup of the survey table. Please try again. The database reported the following error:<br />' . htmlspecialchars($e) . '<br />');
             }
         }
     }
     /**********************************************************************/
     /*     Check conditions                                               */
     /**********************************************************************/
     $okQuestion = array();
     $sQuery = 'SELECT cqid,cid,cfieldname FROM {{conditions}}';
     $aConditions = Yii::app()->db->createCommand($sQuery)->queryAll();
     foreach ($aConditions as $condition) {
         if ($condition['cqid'] != 0) {
             // skip case with cqid=0 for codnitions on {TOKEN:EMAIL} for instance
             if (!array_key_exists($condition['cqid'], $okQuestion)) {
                 $iRowCount = Question::model()->countByAttributes(array('qid' => $condition['cqid']));
                 if (Question::model()->hasErrors()) {
                     safeDie(Question::model()->getError());
                 }
                 if (!$iRowCount) {
                     $aDelete['conditions'][] = array('cid' => $condition['cid'], 'reason' => $clang->gT('No matching CQID'));
                 } else {
                     $okQuestion[$condition['cqid']] = $condition['cqid'];
                 }
             }
         }
         if ($condition['cfieldname']) {
             if (preg_match('/^\\+{0,1}[0-9]+X[0-9]+X*$/', $condition['cfieldname'])) {
                 // only if cfieldname isn't Tag such as {TOKEN:EMAIL} or any other token
                 list($surveyid, $gid, $rest) = explode('X', $condition['cfieldname']);
                 $iRowCount = count(QuestionGroup::model()->findAllByAttributes(array('gid' => $gid)));
                 if (QuestionGroup::model()->hasErrors()) {
                     safeDie(QuestionGroup::model()->getError());
                 }
                 if (!$iRowCount) {
                     $aDelete['conditions'][] = array('cid' => $condition['cid'], 'reason' => $clang->gT('No matching CFIELDNAME group!') . " ({$gid}) ({$condition['cfieldname']})");
                 }
             }
         } elseif (!$condition['cfieldname']) {
             $aDelete['conditions'][] = array('cid' => $condition['cid'], 'reason' => $clang->gT('No CFIELDNAME field set!') . " ({$condition['cfieldname']})");
         }
     }
     unset($okQuestion);
     unset($aConditions);
     /**********************************************************************/
     /*     Check question attributes                                      */
     /**********************************************************************/
     $question_attributes = QuestionAttribute::model()->findAllBySql('select qid from {{question_attributes}} where qid not in (select qid from {{questions}})');
     if (QuestionAttribute::model()->hasErrors()) {
         safeDie(QuestionAttribute::model()->getError());
     }
     foreach ($question_attributes as $question_attribute) {
         $aDelete['questionattributes'][] = array('qid' => $question_attribute['qid']);
     }
     // foreach
     /**********************************************************************/
     /*     Check default values                                           */
     /**********************************************************************/
     $oCriteria = new CDbCriteria();
     $oCriteria->join = 'LEFT JOIN {{questions}} q ON t.qid=q.qid';
     $oCriteria->condition = 'q.qid IS NULL';
     $aRecords = DefaultValue::model()->findAll($oCriteria);
     $aDelete['defaultvalues'] = count($aRecords);
     if (DefaultValue::model()->hasErrors()) {
         safeDie(DefaultValue::model()->getError());
     }
     /**********************************************************************/
     /*     Check quotas                                                   */
     /**********************************************************************/
     $surveys = Survey::model()->findAll();
     if (Survey::model()->hasErrors()) {
         safeDie(Survey::model()->getError());
     }
     $sids = array();
     foreach ($surveys as $survey) {
         $sids[] = $survey['sid'];
     }
     $oCriteria = new CDbCriteria();
     $oCriteria->addNotInCondition('sid', $sids);
     $aDelete['quotas'] = count(Quota::model()->findAll($oCriteria));
     if (Quota::model()->hasErrors()) {
         safeDie(Quota::model()->getError());
     }
     /**********************************************************************/
     /*     Check quota languagesettings                                   */
     /**********************************************************************/
     $quotas = Quota::model()->findAll();
     if (Quota::model()->hasErrors()) {
         safeDie(Quota::model()->getError());
     }
     $ids = array();
     foreach ($quotas as $quota) {
         $ids[] = $quota['id'];
     }
     $oCriteria = new CDbCriteria();
     $oCriteria->addNotInCondition('quotals_quota_id', $ids);
     $aDelete['quotals'] = count(QuotaLanguageSetting::model()->findAll($oCriteria));
     if (QuotaLanguageSetting::model()->hasErrors()) {
         safeDie(QuotaLanguageSetting::model()->getError());
     }
     /**********************************************************************/
     /*     Check quota members                                   */
     /**********************************************************************/
     $oCriteria = new CDbCriteria();
     $oCriteria->join = 'LEFT JOIN {{questions}} q ON t.qid=q.qid LEFT JOIN {{surveys}} s ON t.sid=s.sid';
     $oCriteria->condition = '(q.qid IS NULL) OR (s.sid IS NULL)';
     $aDelete['quotamembers'] = count(QuotaMember::model()->findAll($oCriteria));
     if (QuotaMember::model()->hasErrors()) {
         safeDie(QuotaMember::model()->getError());
     }
     /**********************************************************************/
     /*     Check assessments                                              */
     /**********************************************************************/
     $oCriteria = new CDbCriteria();
     $oCriteria->compare('scope', 'T');
     $assessments = Assessment::model()->findAll($oCriteria);
     if (Assessment::model()->hasErrors()) {
         safeDie(Assessment::model()->getError());
     }
     foreach ($assessments as $assessment) {
         $iAssessmentCount = count(Survey::model()->findAllByPk($assessment['sid']));
         if (Survey::model()->hasErrors()) {
             safeDie(Survey::model()->getError());
         }
         if (!$iAssessmentCount) {
             $aDelete['assessments'][] = array('id' => $assessment['id'], 'assessment' => $assessment['name'], 'reason' => $clang->gT('No matching survey'));
         }
     }
     $oCriteria = new CDbCriteria();
     $oCriteria->compare('scope', 'G');
     $assessments = Assessment::model()->findAll($oCriteria);
     if (Assessment::model()->hasErrors()) {
         safeDie(Assessment::model()->getError());
     }
     foreach ($assessments as $assessment) {
         $iAssessmentCount = count(QuestionGroup::model()->findAllByPk(array('gid' => $assessment['gid'], 'language' => $assessment['language'])));
         if (QuestionGroup::model()->hasErrors()) {
             safeDie(QuestionGroup::model()->getError());
         }
         if (!$iAssessmentCount) {
             $aDelete['assessments'][] = array('id' => $assessment['id'], 'assessment' => $assessment['name'], 'reason' => $clang->gT('No matching group'));
         }
     }
     unset($assessments);
     /**********************************************************************/
     /*     Check answers                                                  */
     /**********************************************************************/
     $oCriteria = new CDbCriteria();
     $oCriteria->join = 'LEFT JOIN {{questions}} q ON t.qid=q.qid';
     $oCriteria->condition = '(q.qid IS NULL)';
     $answers = Answer::model()->findAll($oCriteria);
     foreach ($answers as $answer) {
         $aDelete['answers'][] = array('qid' => $answer['qid'], 'code' => $answer['code'], 'reason' => $clang->gT('No matching question'));
     }
     /***************************************************************************/
     /*   Check survey languagesettings and restore them if they don't exist    */
     /***************************************************************************/
     $surveys = Survey::model()->findAll();
     foreach ($surveys as $survey) {
         $aLanguages = $survey->additionalLanguages;
         $aLanguages[] = $survey->language;
         foreach ($aLanguages as $langname) {
             if ($langname) {
                 $oLanguageSettings = SurveyLanguageSetting::model()->find('surveyls_survey_id=:surveyid AND surveyls_language=:langname', array(':surveyid' => $survey->sid, ':langname' => $langname));
                 if (!$oLanguageSettings) {
                     $oLanguageSettings = new SurveyLanguageSetting();
                     $languagedetails = getLanguageDetails($langname);
                     $insertdata = array('surveyls_survey_id' => $survey->sid, 'surveyls_language' => $langname, 'surveyls_title' => '', 'surveyls_dateformat' => $languagedetails['dateformat']);
                     foreach ($insertdata as $k => $v) {
                         $oLanguageSettings->{$k} = $v;
                     }
                     $usresult = $oLanguageSettings->save();
                 }
             }
         }
     }
     /**********************************************************************/
     /*     Check survey language settings                                 */
     /**********************************************************************/
     $surveys = Survey::model()->findAll();
     if (Survey::model()->hasErrors()) {
         safeDie(Survey::model()->getError());
     }
     $sids = array();
     foreach ($surveys as $survey) {
         $sids[] = $survey['sid'];
     }
     $oCriteria = new CDbCriteria();
     $oCriteria->addNotInCondition('surveyls_survey_id', $sids);
     $surveys_languagesettings = SurveyLanguageSetting::model()->findAll($oCriteria);
     if (SurveyLanguageSetting::model()->hasErrors()) {
         safeDie(SurveyLanguageSetting::model()->getError());
     }
     foreach ($surveys_languagesettings as $surveys_languagesetting) {
         $aDelete['surveylanguagesettings'][] = array('slid' => $surveys_languagesetting['surveyls_survey_id'], 'reason' => $clang->gT('The related survey is missing.'));
     }
     /**********************************************************************/
     /*     Check questions                                                */
     /**********************************************************************/
     $oCriteria = new CDbCriteria();
     $oCriteria->join = 'LEFT JOIN {{surveys}} s ON t.sid=s.sid LEFT JOIN {{groups}} g ON t.gid=g.gid';
     $oCriteria->condition = '(g.gid IS NULL) OR (s.sid IS NULL)';
     $questions = Question::model()->findAll($oCriteria);
     if (Question::model()->hasErrors()) {
         safeDie(Question::model()->getError());
     }
     foreach ($questions as $question) {
         $aDelete['questions'][] = array('qid' => $question['qid'], 'reason' => $clang->gT('No matching group') . " ({$question['gid']})");
     }
     /**********************************************************************/
     /*     Check groups                                                   */
     /**********************************************************************/
     $surveys = Survey::model()->findAll();
     if (Survey::model()->hasErrors()) {
         safeDie(Survey::model()->getError());
     }
     $sids = array();
     foreach ($surveys as $survey) {
         $sids[] = $survey['sid'];
     }
     $oCriteria = new CDbCriteria();
     $oCriteria->addNotInCondition('sid', $sids);
     $groups = QuestionGroup::model()->findAll($oCriteria);
     foreach ($groups as $group) {
         $aDelete['groups'][] = array('gid' => $group['gid'], 'reason' => $clang->gT('There is no matching survey.') . ' SID:' . $group['sid']);
     }
     /**********************************************************************/
     /*     Check old survey tables                                        */
     /**********************************************************************/
     //1: Get list of 'old_survey' tables and extract the survey id
     //2: Check if that survey id still exists
     //3: If it doesn't offer it for deletion
     $sQuery = dbSelectTablesLike('{{old_survey}}%');
     $aTables = Yii::app()->db->createCommand($sQuery)->queryColumn();
     $aOldSIDs = array();
     $aSIDs = array();
     foreach ($aTables as $sTable) {
         list($sOldText, $SurveyText, $iSurveyID, $sDate) = explode('_', substr($sTable, strlen($sDBPrefix)));
         $aOldSIDs[] = $iSurveyID;
         $aFullOldSIDs[$iSurveyID][] = $sTable;
     }
     $aOldSIDs = array_unique($aOldSIDs);
     //$sQuery = 'SELECT sid FROM {{surveys}} ORDER BY sid';
     //$oResult = dbExecuteAssoc($sQuery) or safeDie('Couldn\'t get unique survey ids');
     $surveys = Survey::model()->findAll();
     if (Survey::model()->hasErrors()) {
         safeDie(Survey::model()->getError());
     }
     $aSIDs = array();
     foreach ($surveys as $survey) {
         $aSIDs[] = $survey['sid'];
     }
     foreach ($aOldSIDs as $iOldSID) {
         if (!in_array($iOldSID, $aSIDs)) {
             foreach ($aFullOldSIDs[$iOldSID] as $sTableName) {
                 $aDelete['orphansurveytables'][] = $sTableName;
             }
         } else {
             foreach ($aFullOldSIDs[$iOldSID] as $sTableName) {
                 $aTableParts = explode('_', substr($sTableName, strlen($sDBPrefix)));
                 if (count($aTableParts) == 4) {
                     $sOldText = $aTableParts[0];
                     $SurveyText = $aTableParts[1];
                     $iSurveyID = $aTableParts[2];
                     $sDateTime = $aTableParts[3];
                     $sType = $clang->gT('responses');
                 } elseif (count($aTableParts) == 5) {
                     //This is a timings table (
                     $sOldText = $aTableParts[0];
                     $SurveyText = $aTableParts[1];
                     $iSurveyID = $aTableParts[2];
                     $sDateTime = $aTableParts[4];
                     $sType = $clang->gT('timings');
                 }
                 $iYear = substr($sDateTime, 0, 4);
                 $iMonth = substr($sDateTime, 4, 2);
                 $iDay = substr($sDateTime, 6, 2);
                 $iHour = substr($sDateTime, 8, 2);
                 $iMinute = substr($sDateTime, 10, 2);
                 $sDate = date('d M Y  H:i', mktime($iHour, $iMinute, 0, $iMonth, $iDay, $iYear));
                 $sQuery = 'SELECT count(*) as recordcount FROM ' . $sTableName;
                 $aFirstRow = Yii::app()->db->createCommand($sQuery)->queryRow();
                 if ($aFirstRow['recordcount'] == 0) {
                     // empty table - so add it to immediate deletion
                     $aDelete['orphansurveytables'][] = $sTableName;
                 } else {
                     $aOldSurveyTableAsk[] = array('table' => $sTableName, 'details' => sprintf($clang->gT('Survey ID %d saved at %s containing %d record(s) (%s)'), $iSurveyID, $sDate, $aFirstRow['recordcount'], $sType));
                 }
             }
         }
     }
     /**********************************************************************/
     /*     CHECK OLD TOKEN  TABLES                                        */
     /**********************************************************************/
     //1: Get list of 'old_token' tables and extract the survey id
     //2: Check if that survey id still exists
     //3: If it doesn't offer it for deletion
     $sQuery = dbSelectTablesLike('{{old_token}}%');
     $aTables = Yii::app()->db->createCommand($sQuery)->queryColumn();
     $aOldTokenSIDs = array();
     $aTokenSIDs = array();
     $aFullOldTokenSIDs = array();
     foreach ($aTables as $sTable) {
         list($sOldText, $SurveyText, $iSurveyID, $sDateTime) = explode('_', substr($sTable, strlen($sDBPrefix)));
         $aTokenSIDs[] = $iSurveyID;
         $aFullOldTokenSIDs[$iSurveyID][] = $sTable;
     }
     $aOldTokenSIDs = array_unique($aTokenSIDs);
     $surveys = Survey::model()->findAll();
     if (Survey::model()->hasErrors()) {
         safeDie(Survey::model()->getError());
     }
     $aSIDs = array();
     foreach ($surveys as $survey) {
         $aSIDs[] = $survey['sid'];
     }
     foreach ($aOldTokenSIDs as $iOldTokenSID) {
         if (!in_array($iOldTokenSID, $aOldTokenSIDs)) {
             foreach ($aFullOldTokenSIDs[$iOldTokenSID] as $sTableName) {
                 $aDelete['orphantokentables'][] = $sTableName;
             }
         } else {
             foreach ($aFullOldTokenSIDs[$iOldTokenSID] as $sTableName) {
                 list($sOldText, $sTokensText, $iSurveyID, $sDateTime) = explode('_', substr($sTableName, strlen($sDBPrefix)));
                 $iYear = substr($sDateTime, 0, 4);
                 $iMonth = substr($sDateTime, 4, 2);
                 $iDay = substr($sDateTime, 6, 2);
                 $iHour = substr($sDateTime, 8, 2);
                 $iMinute = substr($sDateTime, 10, 2);
                 $sDate = date('D, d M Y  h:i a', mktime($iHour, $iMinute, 0, $iMonth, $iDay, $iYear));
                 $sQuery = 'SELECT count(*) as recordcount FROM ' . $sTableName;
                 $aFirstRow = Yii::app()->db->createCommand($sQuery)->queryRow();
                 if ($aFirstRow['recordcount'] == 0) {
                     // empty table - so add it to immediate deletion
                     $aDelete['orphantokentables'][] = $sTableName;
                 } else {
                     $aOldTokenTableAsk[] = array('table' => $sTableName, 'details' => sprintf($clang->gT('Survey ID %d saved at %s containing %d record(s)'), $iSurveyID, $sDate, $aFirstRow['recordcount']));
                 }
             }
         }
     }
     if ($aDelete['defaultvalues'] == 0 && $aDelete['quotamembers'] == 0 && $aDelete['quotas'] == 0 && $aDelete['quotals'] == 0 && count($aDelete) == 4) {
         $aDelete['integrityok'] = true;
     } else {
         $aDelete['integrityok'] = false;
     }
     if (!isset($aOldTokenTableAsk) && !isset($aOldSurveyTableAsk)) {
         $aDelete['redundancyok'] = true;
     } else {
         $aDelete['redundancyok'] = false;
         $aDelete['redundanttokentables'] = array();
         $aDelete['redundantsurveytables'] = array();
         if (isset($aOldTokenTableAsk)) {
             $aDelete['redundanttokentables'] = $aOldTokenTableAsk;
         }
         if (isset($aOldSurveyTableAsk)) {
             $aDelete['redundantsurveytables'] = $aOldSurveyTableAsk;
         }
     }
     /**********************************************************************/
     /*     CHECK CPDB SURVEY_LINKS TABLE FOR REDUNDENT TOKEN TABLES       */
     /**********************************************************************/
     //1: Get distinct list of survey_link survey ids, check if tokens
     //   table still exists for each one, and remove if not
     /* TODO */
     /**********************************************************************/
     /*     CHECK CPDB SURVEY_LINKS TABLE FOR REDUNDENT TOKEN ENTRIES      */
     /**********************************************************************/
     //1: For each survey_link, see if the matching entry still exists in
     //   the token table and remove if it doesn't.
     /* TODO */
     return $aDelete;
 }
<?php 
$this->breadcrumbs = array('Miscellaneous Fees Payment' => array('madmin'), 'Manage');
$this->menu = array();
Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('student-transaction-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n");
?>

<h1>Select Student</h1>

<!--<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>-->
<?php 
$dataProvider = $model->search();
$pageSize = Yii::app()->params['pageSize'];
$dataProvider->getPagination()->setPageSize($pageSize);
?>



<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'student-transaction-grid', 'dataProvider' => $dataProvider, 'filter' => $model, 'columns' => array(array('header' => 'SN.', 'class' => 'IndexColumn'), array('name' => 'student_enroll_no', 'value' => '$data->Rel_Stud_Info->student_enroll_no'), array('name' => 'student_first_name', 'value' => '$data->Rel_Stud_Info->student_first_name'), array('name' => 'student_middle_name', 'value' => '$data->Rel_Stud_Info->student_middle_name'), array('name' => 'student_last_name', 'value' => '$data->Rel_Stud_Info->student_last_name'), array('name' => 'student_transaction_branch_id', 'value' => 'Branch::model()->findByPk($data->student_transaction_branch_id)->branch_name', 'filter' => CHtml::listData(Branch::model()->findAll(array('condition' => 'branch_organization_id=' . Yii::app()->user->getState('org_id'))), 'branch_id', 'branch_name')), array('name' => 'student_transaction_quota_id', 'value' => 'Quota::model()->findByPk($data->student_transaction_quota_id)->quota_name', 'filter' => CHtml::listData(Quota::model()->findAll(array('condition' => 'quota_organization_id=' . Yii::app()->user->getState('org_id'))), 'quota_id', 'quota_name')), array('name' => 'student_academic_term_period_tran_id', 'value' => 'AcademicTermPeriod::model()->findByPk($data->student_academic_term_period_tran_id)->academic_term_period', 'filter' => CHtml::listData(AcademicTermPeriod::model()->findAll(array('condition' => 'academic_terms_period_organization_id=' . Yii::app()->user->getState('org_id'))), 'academic_terms_period_id', 'academic_term_period')), array('name' => 'student_academic_term_name_id', 'value' => 'AcademicTerm::model()->findByPk($data->student_academic_term_name_id)->academic_term_name', 'filter' => CHtml::listData(AcademicTerm::model()->findAll(array('condition' => '	academic_term_organization_id=' . Yii::app()->user->getState('org_id'))), 'academic_term_id', 'academic_term_name')), array('class' => 'MyCButtonColumn', 'template' => '{Add Fees}', 'buttons' => array('Add Fees' => array('label' => 'Pay Miscellaneous Fees', 'url' => 'Yii::app()->createUrl("miscellaneousFeesPaymentTransaction/create", array("id"=>$data->student_transaction_id))', 'imageUrl' => Yii::app()->baseUrl . '/images/add.jpeg', 'options' => array('class' => 'fees'))))), 'pager' => array('class' => 'AjaxList', 'maxButtonCount' => $model->count(), 'header' => '')));
예제 #14
0
                <?php 
//echo $form->error($model,'isContact');
?>
                </div>-->

            </div> 
            <?php 
if (Yii::app()->user->checkAccess("showSpecQuota")) {
    ?>
                <div class="row-fluid">
                    <div class="span12">
                        <?php 
    echo $form->labelEx($model, 'QuotaID');
    ?>
                        <?php 
    echo $form->dropDownList($model, 'QuotaID', CHtml::listData(Quota::model()->findAll(), "idQuota", "QuotaName"), array('empty' => "", 'class' => "span12"));
    ?>
                    </div>
                </div>
            <?php 
}
?>


        </div>
        <div class="span6">
            <?php 
if (Yii::app()->user->checkAccess("showBenefits")) {
    ?>
                <div class="row-fluid">
                    <?php 
			<?php 
echo Nationality::model()->findByPk($nationid)->nationality_name;
?>
		</div>
	</div>

	<div class="row_t_v">
		<?php 
echo '<lable><b>Quota :</b></lable>';
?>
		<div class="rowm">
			<?php 
$quotaid = StudentTransaction::model()->findByPk($model->student_archive_stud_tran_id)->student_transaction_category_id;
?>
			<?php 
echo Quota::model()->findByPk($quotaid)->quota_name;
?>
		</div>
	</div>
</div>

<div class = "row_all_a">
	<div class="row_t_v">
		<?php 
echo '<lable><b>Religion :</b></lable>';
?>
		<div class="rowm">

	<?php 
//echo ($model->student_transaction_religion_id != null ? $model->Rel_Religion->religion_name : 'NA');
?>
 echo "</tr>";
 $i = 1;
 $m = 1;
 //print_r($stud_data); exit;
 foreach ($stud_data as $t => $sd) {
     //echo $sd['student_transaction_quota_id'];
     if ($m % 2 == 0) {
         $class = "odd";
     } else {
         $class = "even";
     }
     echo "<tr class=" . $class . ">";
     echo "<td>" . $i . "</td>";
     foreach ($selected_list as $s) {
         if ($s == 'quota_name') {
             echo "<td>" . Quota::model()->findByPk($sd['student_transaction_quota_id'])->quota_name . "</td>";
         } else {
             if ($s == 'branch_name') {
                 echo "<td>" . Branch::model()->findByPk($sd['student_transaction_branch_id'])->branch_name . "</td>";
             } else {
                 if ($s == 'division_code') {
                     echo "<td>" . Division::model()->findByPk($sd['student_transaction_division_id'])->{$s} . "</td>";
                 } else {
                     if ($s == 'sem') {
                         echo "<td>" . AcademicTerm::model()->findByPk($sd['student_academic_term_name_id'])->academic_term_name . "</td>";
                     } else {
                         if ($s == 'student_address_c_line1') {
                             echo "<td>" . StudentAddress::model()->findByPk($sd['student_transaction_student_address_id'])->student_address_c_line1 . " " . StudentAddress::model()->findByPk($sd['student_transaction_student_address_id'])->student_address_c_line2 . "</td>";
                         } else {
                             if ($s == 'student_address_p_line1') {
                                 echo "<td>" . StudentAddress::model()->findByPk($sd['student_transaction_student_address_id'])->student_address_p_line1 . " " . StudentAddress::model()->findByPk($sd['student_transaction_student_address_id'])->student_address_p_line2 . "</td>";
echo $stud_info->student_roll_no;
?>
</td>
</tr>	
	
<tr class="row">
	<td class="col1">
	Current/Last Semester </td> 
	<td class="col2"> <?php 
echo $semester;
?>
</td>
</tr>	
<tr class="row">	
	<td class="col1">Current/Passing Academic Year </td> 
	<td class="col2"><?php 
echo $academic_period;
?>
</td>
</tr>	
<tr class="row">
	<td class="col1">Quota </td> 
	<td class="col2"><?php 
echo Quota::model()->findByPk($stud_tran_info->student_transaction_quota_id)->quota_name;
?>
</td>
</tr>	
</table>
</br>
<?php 
echo $this->renderPartial('_form', array('model' => $model));
예제 #18
0
 /**
  * Deletes a survey and all its data
  *
  * @access public
  * @param int $iSurveyID
  * @param bool @recursive
  * @return void
  */
 public function deleteSurvey($iSurveyID, $recursive = true)
 {
     Survey::model()->deleteByPk($iSurveyID);
     if ($recursive == true) {
         if (tableExists("{{survey_" . intval($iSurveyID) . "}}")) {
             Yii::app()->db->createCommand()->dropTable("{{survey_" . intval($iSurveyID) . "}}");
         }
         if (tableExists("{{survey_" . intval($iSurveyID) . "_timings}}")) {
             Yii::app()->db->createCommand()->dropTable("{{survey_" . intval($iSurveyID) . "_timings}}");
         }
         if (tableExists("{{tokens_" . intval($iSurveyID) . "}}")) {
             Yii::app()->db->createCommand()->dropTable("{{tokens_" . intval($iSurveyID) . "}}");
         }
         /* Remove User/global settings part : need Question and QuestionGroup*/
         // Settings specific for this survey
         $oCriteria = new CDbCriteria();
         $oCriteria->compare('stg_name', 'last_%', true, 'AND', false);
         $oCriteria->compare('stg_value', $iSurveyID, false, 'AND');
         SettingGlobal::model()->deleteAll($oCriteria);
         // Settings specific for this survey, 2nd part
         $oCriteria = new CDbCriteria();
         $oCriteria->compare('stg_name', 'last_%' . $iSurveyID . '%', true, 'AND', false);
         SettingGlobal::model()->deleteAll($oCriteria);
         // All Group id from this survey for ALL users
         $aGroupId = CHtml::listData(QuestionGroup::model()->findAll(array('select' => 'gid', 'condition' => 'sid=:sid', 'params' => array(':sid' => $iSurveyID))), 'gid', 'gid');
         $oCriteria = new CDbCriteria();
         $oCriteria->compare('stg_name', 'last_question_gid_%', true, 'AND', false);
         if (Yii::app()->db->getDriverName() == 'pgsql') {
             $oCriteria->addInCondition('CAST(stg_value as ' . App()->db->schema->getColumnType("integer") . ')', $aGroupId);
         } else {
             $oCriteria->addInCondition('stg_value', $aGroupId);
         }
         SettingGlobal::model()->deleteAll($oCriteria);
         // All Question id from this survey for ALL users
         $aQuestionId = CHtml::listData(Question::model()->findAll(array('select' => 'qid', 'condition' => 'sid=:sid', 'params' => array(':sid' => $iSurveyID))), 'qid', 'qid');
         $oCriteria = new CDbCriteria();
         $oCriteria->compare('stg_name', 'last_question_%', true, 'OR', false);
         if (Yii::app()->db->getDriverName() == 'pgsql') {
             $oCriteria->addInCondition('CAST(stg_value as ' . App()->db->schema->getColumnType("integer") . ')', $aQuestionId);
         } else {
             $oCriteria->addInCondition('stg_value', $aQuestionId);
         }
         SettingGlobal::model()->deleteAll($oCriteria);
         $oResult = Question::model()->findAllByAttributes(array('sid' => $iSurveyID));
         foreach ($oResult as $aRow) {
             Answer::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
             Condition::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
             QuestionAttribute::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
             DefaultValue::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
         }
         Question::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         Assessment::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         QuestionGroup::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         SurveyLanguageSetting::model()->deleteAllByAttributes(array('surveyls_survey_id' => $iSurveyID));
         Permission::model()->deleteAllByAttributes(array('entity_id' => $iSurveyID, 'entity' => 'survey'));
         SavedControl::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         SurveyURLParameter::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         //Remove any survey_links to the CPDB
         SurveyLink::model()->deleteLinksBySurvey($iSurveyID);
         Quota::model()->deleteQuota(array('sid' => $iSurveyID), true);
     }
 }
예제 #19
0
 /**
  * Deletes a survey and all its data
  *
  * @access public
  * @param int $iSurveyID
  * @param bool @recursive
  * @return void
  */
 public function deleteSurvey($iSurveyID, $recursive = true)
 {
     Survey::model()->deleteByPk($iSurveyID);
     if ($recursive == true) {
         if (tableExists("{{survey_" . intval($iSurveyID) . "}}")) {
             Yii::app()->db->createCommand()->dropTable("{{survey_" . intval($iSurveyID) . "}}");
         }
         if (tableExists("{{survey_" . intval($iSurveyID) . "_timings}}")) {
             Yii::app()->db->createCommand()->dropTable("{{survey_" . intval($iSurveyID) . "_timings}}");
         }
         if (tableExists("{{tokens_" . intval($iSurveyID) . "}}")) {
             Yii::app()->db->createCommand()->dropTable("{{tokens_" . intval($iSurveyID) . "}}");
         }
         $oResult = Question::model()->findAllByAttributes(array('sid' => $iSurveyID));
         foreach ($oResult as $aRow) {
             Answer::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
             Condition::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
             QuestionAttribute::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
             DefaultValue::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
         }
         Question::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         Assessment::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         QuestionGroup::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         SurveyLanguageSetting::model()->deleteAllByAttributes(array('surveyls_survey_id' => $iSurveyID));
         Permission::model()->deleteAllByAttributes(array('entity_id' => $iSurveyID, 'entity' => 'survey'));
         SavedControl::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         SurveyURLParameter::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         //Remove any survey_links to the CPDB
         SurveyLink::model()->deleteLinksBySurvey($iSurveyID);
         Quota::model()->deleteQuota(array('sid' => $iSurveyID), true);
     }
 }
예제 #20
0
 function new_answer($iSurveyId, $sSubAction = 'new_answer')
 {
     $iSurveyId = sanitize_int($iSurveyId);
     $this->_checkPermissions($iSurveyId, 'update');
     $aData = $this->_getData($iSurveyId);
     $sBaseLang = $aData['sBaseLang'];
     $clang = $aData['clang'];
     $aViewUrls = array();
     if (($sSubAction == "new_answer" || $sSubAction == "new_answer_two" && !isset($_POST['quota_qid'])) && Permission::model()->hasSurveyPermission($iSurveyId, 'quotas', 'create')) {
         $result = Quota::model()->findAllByPk(Yii::app()->request->getPost('quota_id'));
         foreach ($result as $aQuotaDetails) {
             $quota_name = $aQuotaDetails['name'];
         }
         $result = Question::model()->findAllByAttributes(array('type' => array('G', 'M', 'Y', 'A', 'B', 'I', 'L', 'O', '!'), 'sid' => $iSurveyId, 'language' => $sBaseLang, 'parent_qid' => 0));
         if (empty($result)) {
             $aViewUrls[] = 'newanswererror_view';
         } else {
             $aData['newanswer_result'] = $result;
             $aData['quota_name'] = $quota_name;
             $aViewUrls[] = 'newanswer_view';
         }
     }
     if ($sSubAction == "new_answer_two" && isset($_POST['quota_qid']) && Permission::model()->hasSurveyPermission($iSurveyId, 'quotas', 'create')) {
         $aResults = Quota::model()->findByPk(Yii::app()->request->getPost('quota_qid'));
         $sQuotaName = $aResults['name'];
         $aQuestionAnswers = self::getQuotaAnswers(Yii::app()->request->getPost('quota_qid'), $iSurveyId, Yii::app()->request->getPost('quota_id'));
         $x = 0;
         foreach ($aQuestionAnswers as $aQACheck) {
             if (isset($aQACheck['rowexists'])) {
                 $x++;
             }
         }
         reset($aQuestionAnswers);
         $aData['question_answers'] = $aQuestionAnswers;
         $aData['x'] = $x;
         $aData['quota_name'] = $sQuotaName;
         $aViewUrls[] = 'newanswertwo_view';
     }
     $this->_renderWrappedTemplate('quotas', $aViewUrls, $aData);
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Quota::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
echo CHtml::link('GO BACK', Yii::app()->createUrl('feesPaymentTransaction/mis_report')) . "</br></br>";
?>

<?php 
/*$_SESSION['branch_id']=$_REQUEST['branch_id'];
$_SESSION['acm_id']=$_REQUEST['acm_id'];
$_SESSION['acm_name_id']=$_REQUEST['acm_name_id'];*/
//echo CHtml::link('Export to pdf',array('paid','paidExport'=>'paidpdf','branch_id'=>$_REQUEST['branch_id'],'acm_id'=>$_REQUEST['acm_id'],'acm_name_id'=>$_REQUEST['acm_name_id']));
if ($data) {
    ?>

<table class="table_data">
<th colspan="11"  style="font-size: 18px; color: rgb(255, 255, 255);">
		Paid/Partialy Paid Student<br/>
<?php 
    echo "Branch : " . Branch::model()->findByPk($_REQUEST['branch_id'])->branch_name . "(" . Quota::model()->findByPk($_REQUEST['quota'])->quota_name . ")<br/>";
    echo "Semester: " . AcademicTerm::model()->findByPk($_REQUEST['acm_name_id'])->academic_term_name . "(" . AcademicTermPeriod::model()->findByPk($_REQUEST['acm_id'])->academic_term_period . ")";
    ?>
        </th>
<tr class="table_header">
	<th>SI.No.</th>
	<th>Enroll No.</th>
	<th>Roll No.</th>
	<th>Name</th>
	<th>Payable Amount</th>
	<th>Paid Amount</th>
	<th>Outstanding</th>
</tr>
<?php 
    $i = 0;
    $m = 1;
예제 #23
0
</tr>	
<tr class="row">
	<td class="col1">
	<?php 
		$sem = AcademicTerm::model()->findByPk($stud_trans[0]['student_academic_term_name_id'])->academic_term_name;
		$acdm_period = AcademicTermPeriod::model()->findByPk($stud_trans[0]['student_academic_term_period_tran_id'])->academic_term_period;?>
	Current/Last Semester </td> 
	<td class="col2"> <?php echo "Sem-".$sem; ?></td>
</tr>	
<tr class="row">	
	<td class="col1">Current/Passing Academic Year </td> 
	<td class="col2"><?php echo $acdm_period ?></td>
</tr>	
<tr class="row">
	<td class="col1">Quota </td> 
	<td class="col2"><?php echo Quota::model()->findByPk($stud_trans[0]['student_transaction_quota_id'])->quota_name;?></td>
</tr>	
</table>
<div>&nbsp;</div>
<?php
if(!empty($stud_archive))
{			
?>
<table  class="table_data">
<th colspan="4" style="font-size: 18px; color: rgb(255, 255, 255);">
Student History Record
</th>
	<tr class="table_header">
		<th>SI No.</th>
		<th>Academic Year</th>
		<th>Semester</th>
    ?>
	</div>
<?php 
}
if (Yii::app()->user->hasFlash('success')) {
    ?>
	<div class="flash-success">
		<?php 
    echo Yii::app()->user->getFlash('success');
    ?>
	</div>
<?php 
}
?>

</div>

<?php 
$dataProvider = $model->search();
if (Yii::app()->user->getState("pageSize", @$_GET["pageSize"])) {
    $pageSize = Yii::app()->user->getState("pageSize", @$_GET["pageSize"]);
} else {
    $pageSize = Yii::app()->params['pageSize'];
}
$dataProvider->getPagination()->setPageSize($pageSize);
?>


<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'student-transaction-grid', 'dataProvider' => $dataProvider, 'filter' => $model, 'ajaxUpdate' => false, 'columns' => array(array('header' => 'SI No', 'class' => 'IndexColumn'), array('name' => 'student_enroll_no', 'value' => '$data->Rel_Stud_Info->student_enroll_no'), array('name' => 'student_roll_no', 'value' => '$data->Rel_Stud_Info->student_roll_no'), array('name' => 'student_first_name', 'value' => '$data->Rel_Stud_Info->student_first_name'), array('name' => 'student_last_name', 'value' => '$data->Rel_Stud_Info->student_last_name'), array('name' => 'student_transaction_branch_id', 'value' => 'Branch::model()->findByPk($data->student_transaction_branch_id)->branch_name', 'filter' => CHtml::listData(Branch::model()->findAll(array('condition' => 'branch_organization_id=' . Yii::app()->user->getState('org_id'))), 'branch_id', 'branch_name')), array('name' => 'student_transaction_quota_id', 'value' => 'Quota::model()->findByPk($data->student_transaction_quota_id)->quota_name', 'filter' => CHtml::listData(Quota::model()->findAll(array('condition' => 'quota_organization_id=' . Yii::app()->user->getState('org_id'))), 'quota_id', 'quota_name')), array('name' => 'student_academic_term_period_tran_id', 'value' => 'AcademicTermPeriod::model()->findByPk($data->student_academic_term_period_tran_id)->academic_term_period'), array('name' => 'student_academic_term_name_id', 'value' => 'AcademicTerm::model()->findByPk($data->student_academic_term_name_id)->academic_term_name', 'filter' => CHtml::listData(AcademicTerm::model()->findAll(array('condition' => 'current_sem=1 and academic_term_organization_id=' . Yii::app()->user->getState('org_id'))), 'academic_term_id', 'academic_term_name')), array('name' => 'student_dtod_regular_status', 'value' => '$data->Rel_Stud_Info->student_dtod_regular_status'), array('name' => 'status_name', 'value' => '$data->Rel_Status->status_name'), array('type' => 'raw', 'value' => 'CHtml::image("../stud_images/" . $data->Rel_Photos->student_photos_path, "No Image",array("width"=>"20px","height"=>"20px"))'), array('class' => 'MyCButtonColumn', 'template' => '{update} {delete} ', 'buttons' => array('Add Fees' => array('label' => 'Pay Fees', 'url' => 'Yii::app()->createUrl("feesPaymentTransaction/create", array("id"=>$data->student_transaction_id))', 'imageUrl' => Yii::app()->baseUrl . '/images/add.jpeg', 'options' => array('class' => 'fees'))))), 'pager' => array('class' => 'AjaxList', 'maxButtonCount' => $model->count(), 'header' => '')));
예제 #25
0
/**
* This function imports a LimeSurvey .lss survey XML file
*
* @param mixed $sFullFilePath  The full filepath of the uploaded file
*/
function XMLImportSurvey($sFullFilePath, $sXMLdata = NULL, $sNewSurveyName = NULL, $iDesiredSurveyId = NULL, $bTranslateInsertansTags = true, $bConvertInvalidQuestionCodes = true)
{
    Yii::app()->loadHelper('database');
    $clang = Yii::app()->lang;
    $aGIDReplacements = array();
    if ($sXMLdata == NULL) {
        $sXMLdata = file_get_contents($sFullFilePath);
    }
    $xml = @simplexml_load_string($sXMLdata, 'SimpleXMLElement', LIBXML_NONET);
    if (!$xml || $xml->LimeSurveyDocType != 'Survey') {
        $results['error'] = $clang->gT("This is not a valid LimeSurvey survey structure XML file.");
        return $results;
    }
    $pre_personal_characteristics = "";
    $question_groups['R'] = array();
    $question_groups['I'] = array();
    $question_groups['O'] = array();
    $iDBVersion = (int) $xml->DBVersion;
    $aQIDReplacements = array();
    $aQuestionCodeReplacements = array();
    $aQuotaReplacements = array();
    $results['defaultvalues'] = 0;
    $results['answers'] = 0;
    $results['surveys'] = 0;
    $results['questions'] = 0;
    $results['subquestions'] = 0;
    $results['question_attributes'] = 0;
    $results['groups'] = 0;
    $results['assessments'] = 0;
    $results['quota'] = 0;
    $results['quotals'] = 0;
    $results['quotamembers'] = 0;
    $results['survey_url_parameters'] = 0;
    $results['importwarnings'] = array();
    $aLanguagesSupported = array();
    foreach ($xml->languages->language as $language) {
        $aLanguagesSupported[] = (string) $language;
    }
    $results['languages'] = count($aLanguagesSupported);
    // Import surveys table ====================================================
    foreach ($xml->surveys->rows->row as $row) {
        $insertdata = array();
        foreach ($row as $key => $value) {
            $insertdata[(string) $key] = (string) $value;
        }
        $iOldSID = $results['oldsid'] = $insertdata['sid'];
        if ($iDesiredSurveyId != NULL) {
            $insertdata['wishSID'] = GetNewSurveyID($iDesiredSurveyId);
        } else {
            $insertdata['wishSID'] = $iOldSID;
        }
        if ($iDBVersion < 145) {
            if (isset($insertdata['private'])) {
                $insertdata['anonymized'] = $insertdata['private'];
            }
            unset($insertdata['private']);
            unset($insertdata['notification']);
        }
        //Make sure it is not set active
        $insertdata['active'] = 'N';
        //Set current user to be the owner
        $insertdata['owner_id'] = Yii::app()->session['loginID'];
        if (isset($insertdata['bouncetime']) && $insertdata['bouncetime'] == '') {
            $insertdata['bouncetime'] = NULL;
        }
        if (isset($insertdata['showXquestions'])) {
            $insertdata['showxquestions'] = $insertdata['showXquestions'];
            unset($insertdata['showXquestions']);
        }
        // Special code to set javascript in
        Yii::app()->loadHelper('admin/template');
        $newname = "watson_" . time();
        $newdirname = Yii::app()->getConfig('usertemplaterootdir') . "/" . $newname;
        $copydirname = getTemplatePath("watson_personal_constructs_copy_me");
        $oFileHelper = new CFileHelper();
        $mkdirresult = mkdir_p($newdirname);
        if ($mkdirresult == 1) {
            $oFileHelper->copyDirectory($copydirname, $newdirname);
            $templatename = $newname;
            //$this->index("startpage.pstpl", "welcome", $templatename);
        } elseif ($mkdirresult == 2) {
            $results['Error'] = sprintf($clang->gT("Directory with the name `%s` already exists - choose another name", "js"), $newname);
        } else {
            $results['Error'] = sprintf($clang->gT("Unable to create directory `%s`.", "js"), $newname) . " " . $clang->gT("Please check the directory permissions.", "js");
        }
        $insertdata['template'] = $newname;
        // End special copy code (taken from templates.php templatecopy() method
        if (isset($insertdata['googleAnalyticsStyle'])) {
            $insertdata['googleanalyticsstyle'] = $insertdata['googleAnalyticsStyle'];
            unset($insertdata['googleAnalyticsStyle']);
        }
        if (isset($insertdata['googleAnalyticsAPIKey'])) {
            $insertdata['googleanalyticsapikey'] = $insertdata['googleAnalyticsAPIKey'];
            unset($insertdata['googleAnalyticsAPIKey']);
        }
        if (isset($insertdata['allowjumps'])) {
            $insertdata['questionindex'] = $insertdata['allowjumps'] == "Y" ? 1 : 0;
            unset($insertdata['allowjumps']);
        }
        /* Remove unknow column */
        $aSurveyModelsColumns = Survey::model()->attributes;
        $aSurveyModelsColumns['wishSID'] = null;
        // To force a sid surely
        $aBadData = array_diff_key($insertdata, $aSurveyModelsColumns);
        $insertdata = array_intersect_key($insertdata, $aSurveyModelsColumns);
        // Fill a optionnal array of error
        foreach ($aBadData as $key => $value) {
            $results['importwarnings'][] = sprintf($clang->gT("This survey setting has not been imported: %s => %s"), $key, $value);
        }
        $iNewSID = $results['newsid'] = Survey::model()->insertNewSurvey($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data [1]<br />");
        $pre_personal_characteristics = file_get_contents($newdirname . "/question.pstpl");
        $results['surveys']++;
    }
    // Import survey languagesettings table ===================================================================================
    foreach ($xml->surveys_languagesettings->rows->row as $row) {
        $insertdata = array();
        foreach ($row as $key => $value) {
            $insertdata[(string) $key] = (string) $value;
        }
        if (!in_array($insertdata['surveyls_language'], $aLanguagesSupported)) {
            continue;
        }
        // Assign new survey ID
        $insertdata['surveyls_survey_id'] = $iNewSID;
        // Assign new survey name (if a copy)
        if ($sNewSurveyName != NULL) {
            $insertdata['surveyls_title'] = $sNewSurveyName;
        }
        if ($bTranslateInsertansTags) {
            $insertdata['surveyls_title'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['surveyls_title']);
            if (isset($insertdata['surveyls_description'])) {
                $insertdata['surveyls_description'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['surveyls_description']);
            }
            if (isset($insertdata['surveyls_welcometext'])) {
                $insertdata['surveyls_welcometext'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['surveyls_welcometext']);
            }
            if (isset($insertdata['surveyls_urldescription'])) {
                $insertdata['surveyls_urldescription'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['surveyls_urldescription']);
            }
            if (isset($insertdata['surveyls_email_invite'])) {
                $insertdata['surveyls_email_invite'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['surveyls_email_invite']);
            }
            if (isset($insertdata['surveyls_email_remind'])) {
                $insertdata['surveyls_email_remind'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['surveyls_email_remind']);
            }
            if (isset($insertdata['surveyls_email_register'])) {
                $insertdata['surveyls_email_register'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['surveyls_email_register']);
            }
            if (isset($insertdata['surveyls_email_confirm'])) {
                $insertdata['surveyls_email_confirm'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['surveyls_email_confirm']);
            }
        }
        if (isset($insertdata['surveyls_attributecaptions']) && substr($insertdata['surveyls_attributecaptions'], 0, 1) != '{') {
            unset($insertdata['surveyls_attributecaptions']);
        }
        $result = SurveyLanguageSetting::model()->insertNewSurvey($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data [2]<br />");
    }
    // Import groups table ===================================================================================
    if (isset($xml->groups->rows->row)) {
        foreach ($xml->groups->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            if (!in_array($insertdata['language'], $aLanguagesSupported)) {
                continue;
            }
            $iOldSID = $insertdata['sid'];
            $insertdata['sid'] = $iNewSID;
            $oldgid = $insertdata['gid'];
            unset($insertdata['gid']);
            // save the old qid
            // now translate any links
            if ($bTranslateInsertansTags) {
                $insertdata['group_name'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['group_name']);
                $insertdata['description'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['description']);
            }
            // Insert the new group
            if (isset($aGIDReplacements[$oldgid])) {
                switchMSSQLIdentityInsert('groups', true);
                $insertdata['gid'] = $aGIDReplacements[$oldgid];
            }
            $newgid = QuestionGroup::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data [3]<br />");
            if ($insertdata['group_name'] == 'Real Characteristics' || $insertdata['group_name'] == 'PC - Real Characteristics') {
                $question_groups['R'][] = $newgid;
            } else {
                if ($insertdata['group_name'] == 'Ideal Characteristics' || $insertdata['group_name'] == 'PC - Ideal Characteristics') {
                    $question_groups['I'][] = $newgid;
                } else {
                    if ($insertdata['group_name'] == 'Ought Characteristics' || $insertdata['group_name'] == 'PC - Ought Characteristics') {
                        $question_groups['O'][] = $newgid;
                    }
                }
            }
            $results['groups']++;
            if (!isset($aGIDReplacements[$oldgid])) {
                $aGIDReplacements[$oldgid] = $newgid;
                // add old and new qid to the mapping array
            } else {
                switchMSSQLIdentityInsert('groups', false);
            }
        }
    }
    // Import questions table ===================================================================================
    // We have to run the question table data two times - first to find all main questions
    // then for subquestions (because we need to determine the new qids for the main questions first)
    if (isset($xml->questions)) {
        foreach ($xml->questions->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            if (!in_array($insertdata['language'], $aLanguagesSupported) || $insertdata['gid'] == 0) {
                continue;
            }
            $iOldSID = $insertdata['sid'];
            $insertdata['sid'] = $iNewSID;
            $insertdata['gid'] = $aGIDReplacements[$insertdata['gid']];
            $oldqid = $insertdata['qid'];
            unset($insertdata['qid']);
            // save the old qid
            // now translate any links
            if ($bTranslateInsertansTags) {
                $insertdata['question'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['question']);
                $insertdata['help'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['help']);
            }
            // Insert the new question
            if (isset($aQIDReplacements[$oldqid])) {
                $insertdata['qid'] = $aQIDReplacements[$oldqid];
                switchMSSQLIdentityInsert('questions', true);
            }
            if ($insertdata) {
                XSSFilterArray($insertdata);
            }
            if (!$bConvertInvalidQuestionCodes) {
                $sScenario = 'archiveimport';
            } else {
                $sScenario = 'import';
            }
            $oQuestion = new Question($sScenario);
            $oQuestion->setAttributes($insertdata, false);
            // Try to fix question title for valid question code enforcement
            if (!$oQuestion->validate(array('title'))) {
                $sOldTitle = $oQuestion->title;
                $sNewTitle = preg_replace("/[^A-Za-z0-9]/", '', $sOldTitle);
                if (is_numeric(substr($sNewTitle, 0, 1))) {
                    $sNewTitle = 'q' . $sNewTitle;
                }
                $oQuestion->title = $sNewTitle;
            }
            $attempts = 0;
            // Try to fix question title for unique question code enforcement
            while (!$oQuestion->validate(array('title'))) {
                if (!isset($index)) {
                    $index = 0;
                    $rand = mt_rand(0, 1024);
                } else {
                    $index++;
                }
                $sNewTitle = 'r' . $rand . 'q' . $index;
                $oQuestion->title = $sNewTitle;
                $attempts++;
                if ($attempts > 10) {
                    safeDie($clang->gT("Error") . ": Failed to resolve question code problems after 10 attempts.<br />");
                }
            }
            if (!$oQuestion->save()) {
                // safeDie($clang->gT("Error while saving: "). print_r($oQuestion->errors, true));
                //
                // In PHP 5.2.10 a bug is triggered that resets the foreach loop when inserting a record
                // Problem is that it is the default PHP version on Ubuntu 12.04 LTS (which is currently very common in use)
                // For this reason we ignore insertion errors (because it is most likely a duplicate)
                // and continue with the next one
                continue;
            }
            // Set a warning if question title was updated
            if (isset($sNewTitle)) {
                $results['importwarnings'][] = sprintf($clang->gT("Question code %s was updated to %s."), $sOldTitle, $sNewTitle);
                $aQuestionCodeReplacements[$sOldTitle] = $sNewTitle;
                unset($sNewTitle);
                unset($sOldTitle);
            }
            $newqid = $oQuestion->qid;
            if (!isset($aQIDReplacements[$oldqid])) {
                $aQIDReplacements[$oldqid] = $newqid;
                $results['questions']++;
            } else {
                switchMSSQLIdentityInsert('questions', false);
            }
        }
    }
    // Import subquestions -------------------------------------------------------
    if (isset($xml->subquestions)) {
        foreach ($xml->subquestions->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            if (!in_array($insertdata['language'], $aLanguagesSupported) || $insertdata['gid'] == 0) {
                continue;
            }
            if (!isset($insertdata['mandatory']) || trim($insertdata['mandatory']) == '') {
                $insertdata['mandatory'] = 'N';
            }
            $insertdata['sid'] = $iNewSID;
            $insertdata['gid'] = $aGIDReplacements[(int) $insertdata['gid']];
            $oldsqid = (int) $insertdata['qid'];
            unset($insertdata['qid']);
            // save the old qid
            $insertdata['parent_qid'] = $aQIDReplacements[(int) $insertdata['parent_qid']];
            // remap the parent_qid
            // now translate any links
            if ($bTranslateInsertansTags) {
                $insertdata['question'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['question']);
                if (isset($insertdata['help'])) {
                    $insertdata['help'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['help']);
                }
            }
            if (isset($aQIDReplacements[$oldsqid])) {
                $insertdata['qid'] = $aQIDReplacements[$oldsqid];
                switchMSSQLIdentityInsert('questions', true);
            }
            if ($insertdata) {
                XSSFilterArray($insertdata);
            }
            if (!$bConvertInvalidQuestionCodes) {
                $sScenario = 'archiveimport';
            } else {
                $sScenario = 'import';
            }
            $question = new Question($sScenario);
            $question->setAttributes($insertdata, false);
            // Try to fix question title for valid question code enforcement
            if (!$question->validate(array('title'))) {
                $sOldTitle = $question->title;
                $sNewTitle = preg_replace("/[^A-Za-z0-9]/", '', $sOldTitle);
                if (is_numeric(substr($sNewTitle, 0, 1))) {
                    $sNewTitle = 'sq' . $sNewTitle;
                }
                $question->title = $sNewTitle;
            }
            $attempts = 0;
            // Try to fix question title for unique question code enforcement
            while (!$question->validate(array('title'))) {
                if (!isset($index)) {
                    $index = 0;
                    $rand = mt_rand(0, 1024);
                } else {
                    $index++;
                }
                $sNewTitle = 'r' . $rand . 'sq' . $index;
                $question->title = $sNewTitle;
                $attempts++;
                if ($attempts > 10) {
                    safeDie($clang->gT("Error") . ": Failed to resolve question code problems after 10 attempts.<br />");
                }
            }
            if (!$question->save()) {
                // safeDie($clang->gT("Error while saving: "). print_r($question->errors, true));
                //
                // In PHP 5.2.10 a bug is triggered that resets the foreach loop when inserting a record
                // Problem is that it is the default PHP version on Ubuntu 12.04 LTS (which is currently very common in use)
                // For this reason we ignore insertion errors (because it is most likely a duplicate)
                // and continue with the next one
                continue;
            }
            // Set a warning if question title was updated
            if (isset($sNewTitle)) {
                $results['importwarnings'][] = sprintf($clang->gT("Title of subquestion %s was updated to %s."), $sOldTitle, $sNewTitle);
                // Maybe add the question title ?
                $aQuestionCodeReplacements[$sOldTitle] = $sNewTitle;
                unset($sNewTitle);
                unset($sOldTitle);
            }
            $newsqid = $question->qid;
            if (!isset($insertdata['qid'])) {
                $aQIDReplacements[$oldsqid] = $newsqid;
                // add old and new qid to the mapping array
            } else {
                switchMSSQLIdentityInsert('questions', false);
            }
            $results['subquestions']++;
        }
    }
    // Import answers ------------------------------------------------------------
    if (isset($xml->answers)) {
        foreach ($xml->answers->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            if (!in_array($insertdata['language'], $aLanguagesSupported) || !isset($aQIDReplacements[(int) $insertdata['qid']])) {
                continue;
            }
            $insertdata['qid'] = $aQIDReplacements[(int) $insertdata['qid']];
            // remap the parent_qid
            // now translate any links
            if ($bTranslateInsertansTags) {
                $insertdata['answer'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['answer']);
            }
            if ($insertdata) {
                XSSFilterArray($insertdata);
            }
            if (Answer::model()->insertRecords($insertdata)) {
                $results['answers']++;
            }
        }
    }
    // Import questionattributes -------------------------------------------------
    if (isset($xml->question_attributes)) {
        $aAllAttributes = questionAttributes(true);
        foreach ($xml->question_attributes->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            // take care of renaming of date min/max adv. attributes fields
            if ($iDBVersion < 170) {
                if (isset($insertdata['attribute'])) {
                    if ($insertdata['attribute'] == 'dropdown_dates_year_max') {
                        $insertdata['attribute'] = 'date_max';
                    }
                    if ($insertdata['attribute'] == 'dropdown_dates_year_min') {
                        $insertdata['attribute'] = 'date_min';
                    }
                }
            }
            unset($insertdata['qaid']);
            if (!isset($aQIDReplacements[(int) $insertdata['qid']])) {
                continue;
            }
            $insertdata['qid'] = $aQIDReplacements[(int) $insertdata['qid']];
            // remap the qid
            if ($iDBVersion < 156 && isset($aAllAttributes[$insertdata['attribute']]['i18n']) && $aAllAttributes[$insertdata['attribute']]['i18n']) {
                foreach ($aLanguagesSupported as $sLanguage) {
                    $insertdata['language'] = $sLanguage;
                    if ($insertdata) {
                        XSSFilterArray($insertdata);
                    }
                    $result = QuestionAttribute::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data[7]<br />");
                }
            } else {
                $result = QuestionAttribute::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data[8]<br />");
            }
            $results['question_attributes']++;
        }
    }
    // Import defaultvalues ------------------------------------------------------
    if (isset($xml->defaultvalues)) {
        $results['defaultvalues'] = 0;
        foreach ($xml->defaultvalues->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            $insertdata['qid'] = $aQIDReplacements[(int) $insertdata['qid']];
            // remap the qid
            if (isset($aQIDReplacements[(int) $insertdata['sqid']])) {
                $insertdata['sqid'] = $aQIDReplacements[(int) $insertdata['sqid']];
            }
            // remap the subquestion id
            if ($insertdata) {
                XSSFilterArray($insertdata);
            }
            // now translate any links
            $result = DefaultValue::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data[9]<br />");
            $results['defaultvalues']++;
        }
    }
    $aOldNewFieldmap = reverseTranslateFieldNames($iOldSID, $iNewSID, $aGIDReplacements, $aQIDReplacements);
    // Import conditions ---------------------------------------------------------
    if (isset($xml->conditions)) {
        $results['conditions'] = 0;
        foreach ($xml->conditions->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            // replace the qid for the new one (if there is no new qid in the $aQIDReplacements array it mean that this condition is orphan -> error, skip this record)
            if (isset($aQIDReplacements[$insertdata['qid']])) {
                $insertdata['qid'] = $aQIDReplacements[$insertdata['qid']];
                // remap the qid
            } else {
                continue;
            }
            // a problem with this answer record -> don't consider
            if ($insertdata['cqid'] != 0) {
                if (isset($aQIDReplacements[$insertdata['cqid']])) {
                    $oldcqid = $insertdata['cqid'];
                    //Save for cfield transformation
                    $insertdata['cqid'] = $aQIDReplacements[$insertdata['cqid']];
                    // remap the qid
                } else {
                    continue;
                }
                // a problem with this answer record -> don't consider
                list($oldcsid, $oldcgid, $oldqidanscode) = explode("X", $insertdata["cfieldname"], 3);
                // replace the gid for the new one in the cfieldname(if there is no new gid in the $aGIDReplacements array it means that this condition is orphan -> error, skip this record)
                if (!isset($aGIDReplacements[$oldcgid])) {
                    continue;
                }
            }
            unset($insertdata["cid"]);
            // recreate the cfieldname with the new IDs
            if ($insertdata['cqid'] != 0) {
                if (preg_match("/^\\+/", $oldcsid)) {
                    $newcfieldname = '+' . $iNewSID . "X" . $aGIDReplacements[$oldcgid] . "X" . $insertdata["cqid"] . substr($oldqidanscode, strlen($oldcqid));
                } else {
                    $newcfieldname = $iNewSID . "X" . $aGIDReplacements[$oldcgid] . "X" . $insertdata["cqid"] . substr($oldqidanscode, strlen($oldcqid));
                }
            } else {
                // The cfieldname is a not a previous question cfield but a {XXXX} replacement field
                $newcfieldname = $insertdata["cfieldname"];
            }
            $insertdata["cfieldname"] = $newcfieldname;
            if (trim($insertdata["method"]) == '') {
                $insertdata["method"] = '==';
            }
            // Now process the value and replace @sgqa@ codes
            if (preg_match("/^@(.*)@\$/", $insertdata["value"], $cfieldnameInCondValue)) {
                if (isset($aOldNewFieldmap[$cfieldnameInCondValue[1]])) {
                    $newvalue = '@' . $aOldNewFieldmap[$cfieldnameInCondValue[1]] . '@';
                    $insertdata["value"] = $newvalue;
                }
            }
            // now translate any links
            $result = Condition::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data[10]<br />");
            $results['conditions']++;
        }
    }
    // TMSW Condition->Relevance:  Call  LEM->ConvertConditionsToRelevance
    // Import assessments --------------------------------------------------------
    if (isset($xml->assessments)) {
        foreach ($xml->assessments->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            if ($insertdata['gid'] > 0) {
                $insertdata['gid'] = $aGIDReplacements[(int) $insertdata['gid']];
                // remap the qid
            }
            $insertdata['sid'] = $iNewSID;
            // remap the survey id
            unset($insertdata['id']);
            // now translate any links
            $result = Assessment::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data[11]<br />");
            $results['assessments']++;
        }
    }
    // Import quota --------------------------------------------------------------
    if (isset($xml->quota)) {
        foreach ($xml->quota->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            $insertdata['sid'] = $iNewSID;
            // remap the survey id
            $oldid = $insertdata['id'];
            unset($insertdata['id']);
            // now translate any links
            $result = Quota::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data[12]<br />");
            $aQuotaReplacements[$oldid] = getLastInsertID('{{quota}}');
            $results['quota']++;
        }
    }
    // Import quota_members ------------------------------------------------------
    if (isset($xml->quota_members)) {
        foreach ($xml->quota_members->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            $insertdata['sid'] = $iNewSID;
            // remap the survey id
            $insertdata['qid'] = $aQIDReplacements[(int) $insertdata['qid']];
            // remap the qid
            $insertdata['quota_id'] = $aQuotaReplacements[(int) $insertdata['quota_id']];
            // remap the qid
            unset($insertdata['id']);
            // now translate any links
            $result = QuotaMember::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data[13]<br />");
            $results['quotamembers']++;
        }
    }
    // Import quota_languagesettings----------------------------------------------
    if (isset($xml->quota_languagesettings)) {
        foreach ($xml->quota_languagesettings->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            $insertdata['quotals_quota_id'] = $aQuotaReplacements[(int) $insertdata['quotals_quota_id']];
            // remap the qid
            unset($insertdata['quotals_id']);
            $result = QuotaLanguageSetting::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data<br />");
            $results['quotals']++;
        }
    }
    // Import survey_url_parameters ----------------------------------------------
    if (isset($xml->survey_url_parameters)) {
        foreach ($xml->survey_url_parameters->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            $insertdata['sid'] = $iNewSID;
            // remap the survey id
            if (isset($insertdata['targetsqid']) && $insertdata['targetsqid'] != '') {
                $insertdata['targetsqid'] = $aQIDReplacements[(int) $insertdata['targetsqid']];
                // remap the qid
            }
            if (isset($insertdata['targetqid']) && $insertdata['targetqid'] != '') {
                $insertdata['targetqid'] = $aQIDReplacements[(int) $insertdata['targetqid']];
                // remap the qid
            }
            unset($insertdata['id']);
            $result = SurveyURLParameter::model()->insertRecord($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data[14]<br />");
            $results['survey_url_parameters']++;
        }
    }
    // Set survey rights
    Permission::model()->giveAllSurveyPermissions(Yii::app()->session['loginID'], $iNewSID);
    $aOldNewFieldmap = reverseTranslateFieldNames($iOldSID, $iNewSID, $aGIDReplacements, $aQIDReplacements);
    $results['FieldReMap'] = $aOldNewFieldmap;
    LimeExpressionManager::SetSurveyId($iNewSID);
    translateInsertansTags($iNewSID, $iOldSID, $aOldNewFieldmap);
    replaceExpressionCodes($iNewSID, $aQuestionCodeReplacements);
    if (count($aQuestionCodeReplacements)) {
        array_unshift($results['importwarnings'], "<span class='warningtitle'>" . $clang->gT('Attention: Several question codes were updated. Please check these carefully as the update  may not be perfect with customized expressions.') . '</span)>');
    }
    LimeExpressionManager::RevertUpgradeConditionsToRelevance($iNewSID);
    LimeExpressionManager::UpgradeConditionsToRelevance($iNewSID);
    $js_variables = array();
    if (!empty($question_groups['R'])) {
        $real_count = 1;
        $ideal_count = 1;
        $ought_count = 1;
        foreach ($results['FieldReMap'] as $code) {
            $value = explode('X', $code);
            if (isset($value[1]) && in_array($value[1], $question_groups['R'])) {
                if (!array_key_exists((int) $value[1], $js_variables)) {
                    $int = substr($value[2], 0, strpos($value[2], 'PC'));
                    $js_variables[$value[1]] = "var realGroupId" . $real_count . " = " . $value[1] . ";";
                    $js_variables[$value[1] . "-q"] = "var realQuestionId" . $real_count . " = " . $int . ";";
                    $real_count++;
                }
            } else {
                if (isset($value[1]) && in_array($value[1], $question_groups['I'])) {
                    if (!array_key_exists((int) $value[1], $js_variables)) {
                        $int = substr($value[2], 0, strpos($value[2], 'PC'));
                        $js_variables[$value[1]] = "var idealGroupId" . $ideal_count . " = " . $value[1] . ";";
                        $js_variables[$value[1] . "-q"] = "var idealQuestionId" . $ideal_count . " = " . $int . ";";
                        $ideal_count++;
                    }
                } else {
                    if (isset($value[1]) && in_array($value[1], $question_groups['O'])) {
                        if (!array_key_exists((int) $value[1], $js_variables)) {
                            $int = substr($value[2], 0, strpos($value[2], 'PC'));
                            $js_variables[$value[1]] = "var oughtGroupId" . $ought_count . " = " . $value[1] . ";";
                            $js_variables[$value[1] . "-q"] = "var oughtQuestionId" . $ought_count . " = " . $int . ";";
                            $ought_count++;
                        }
                    }
                }
            }
        }
        $js_variables[] = "var surveyId = " . $value[0] . ";";
    }
    if (!empty($js_variables)) {
        $pre_personal_characteristics = str_replace("[REPLACE_ME]", implode(PHP_EOL, $js_variables), $pre_personal_characteristics);
    } else {
        $pre_personal_characteristics = '<div {QUESTION_ESSENTIALS} class="{QUESTION_CLASS}{QUESTION_MAN_CLASS}{QUESTION_INPUT_ERROR_CLASS}">
          <div class="survey-question">
            <div class="survey-question-text">
                  <span class="asterisk">{QUESTION_MANDATORY}</span><span class="qnumcode"> {QUESTION_NUMBER} {QUESTION_CODE} </span>{QUESTION_TEXT}<br /><span class="questionhelp">{QUESTION_HELP}</span>
              {QUESTION_MAN_MESSAGE}
              {QUESTION_VALID_MESSAGE}
              {QUESTION_FILE_VALID_MESSAGE}
            </div>
            <div class="survey-question-answer">{ANSWER}</div>
            <div class="survey-question-help">{QUESTIONHELP}</div>
          </div>
          <div class="survey-question-space"></div>
        </div>';
    }
    file_put_contents($newdirname . "/question.pstpl", $pre_personal_characteristics);
    return $results;
}
예제 #26
0
/**
* getQuotaInformation() returns quota information for the current survey
* @param string $surveyid - Survey identification number
* @param string $language - Language of the quota
* @param string $quotaid - Optional quotaid that restricts the result to a given quota
* @return array - nested array, Quotas->Members->Fields
*/
function getQuotaInformation($surveyid, $language, $iQuotaID = 'all')
{
    Yii::log('getQuotaInformation');
    $baselang = Survey::model()->findByPk($surveyid)->language;
    $aAttributes = array('sid' => $surveyid);
    if ($iQuotaID != 'all') {
        $aAttributes['id'] = $iQuotaID;
    }
    $result = Quota::model()->with(array('languagesettings' => array('condition' => "quotals_language='{$language}'")))->findAllByAttributes($aAttributes);
    $quota_info = array();
    $x = 0;
    $surveyinfo = getSurveyInfo($surveyid, $language);
    // Check all quotas for the current survey
    //if ($result->RecordCount() > 0)
    if (count($result) > 0) {
        //while ($survey_quotas = $result->FetchRow())
        foreach ($result as $_survey_quotas) {
            $survey_quotas = array_merge($_survey_quotas->attributes, $_survey_quotas->languagesettings[0]->attributes);
            // We have only one language, then we can use first only
            array_push($quota_info, $survey_quotas);
            $result_qe = QuotaMember::model()->findAllByAttributes(array('quota_id' => $survey_quotas['id']));
            $quota_info[$x]['members'] = array();
            if (count($result_qe) > 0) {
                foreach ($result_qe as $quota_entry) {
                    $quota_entry = $quota_entry->attributes;
                    $oMemberQuestion = Question::model()->findByAttributes(array('qid' => $quota_entry['qid'], 'language' => $baselang));
                    if ($oMemberQuestion) {
                        $fieldname = "0";
                        if ($oMemberQuestion->type == "I" || $oMemberQuestion->type == "G" || $oMemberQuestion->type == "Y") {
                            $fieldname = $surveyid . 'X' . $oMemberQuestion->gid . 'X' . $quota_entry['qid'];
                            $value = $quota_entry['code'];
                        }
                        if ($oMemberQuestion->type == "L" || $oMemberQuestion->type == "O" || $oMemberQuestion->type == "!") {
                            $fieldname = $surveyid . 'X' . $oMemberQuestion->gid . 'X' . $quota_entry['qid'];
                            $value = $quota_entry['code'];
                        }
                        if ($oMemberQuestion->type == "M") {
                            // Need to remove invalid $quota_entry['code']
                            $fieldname = $surveyid . 'X' . $oMemberQuestion->gid . 'X' . $quota_entry['qid'] . $quota_entry['code'];
                            $value = "Y";
                        }
                        if ($oMemberQuestion->type == "A" || $oMemberQuestion->type == "B") {
                            $temp = explode('-', $quota_entry['code']);
                            $fieldname = $surveyid . 'X' . $oMemberQuestion->gid . 'X' . $quota_entry['qid'] . $temp[0];
                            $value = $temp[1];
                        }
                        array_push($quota_info[$x]['members'], array('Title' => $oMemberQuestion->title, 'type' => $oMemberQuestion->type, 'code' => $quota_entry['code'], 'value' => $value, 'qid' => $quota_entry['qid'], 'fieldname' => $fieldname));
                    }
                }
            }
            $x++;
        }
    }
    return $quota_info;
}
예제 #27
0
/**
* getQuotaInformation() returns quota information for the current survey
* @param string $surveyid - Survey identification number
* @param string $language - Language of the quota
* @param string $quotaid - Optional quotaid that restricts the result to a given quota
* @return array - nested array, Quotas->Members
*/
function getQuotaInformation($surveyid, $language, $iQuotaID = null)
{
    Yii::log('getQuotaInformation');
    $baselang = Survey::model()->findByPk($surveyid)->language;
    $aAttributes = array('sid' => $surveyid);
    if ((int) $iQuotaID) {
        $aAttributes['id'] = $iQuotaID;
    }
    $aQuotas = Quota::model()->with(array('languagesettings' => array('condition' => "quotals_language='{$language}'")))->findAllByAttributes($aAttributes);
    $aSurveyQuotasInfo = array();
    $x = 0;
    $surveyinfo = getSurveyInfo($surveyid, $language);
    // Check all quotas for the current survey
    if (count($aQuotas) > 0) {
        foreach ($aQuotas as $oQuota) {
            // Array for each quota
            $aQuotaInfo = array_merge($oQuota->attributes, $oQuota->languagesettings[0]->attributes);
            // We have only one language, then we can use first only
            $aQuotaMembers = QuotaMember::model()->findAllByAttributes(array('quota_id' => $oQuota->id));
            $aQuotaInfo['members'] = array();
            if (count($aQuotaMembers) > 0) {
                foreach ($aQuotaMembers as $oQuotaMember) {
                    $oMemberQuestion = Question::model()->findByAttributes(array('qid' => $oQuotaMember->qid, 'language' => $baselang));
                    if ($oMemberQuestion) {
                        $sFieldName = "0";
                        if ($oMemberQuestion->type == "I" || $oMemberQuestion->type == "G" || $oMemberQuestion->type == "Y") {
                            $sFieldName = $surveyid . 'X' . $oMemberQuestion->gid . 'X' . $oQuotaMember->qid;
                            $sValue = $oQuotaMember->code;
                        }
                        if ($oMemberQuestion->type == "L" || $oMemberQuestion->type == "O" || $oMemberQuestion->type == "!") {
                            $sFieldName = $surveyid . 'X' . $oMemberQuestion->gid . 'X' . $oQuotaMember->qid;
                            $sValue = $oQuotaMember->code;
                        }
                        if ($oMemberQuestion->type == "M") {
                            $sFieldName = $surveyid . 'X' . $oMemberQuestion->gid . 'X' . $oQuotaMember->qid . $oQuotaMember->code;
                            $sValue = "Y";
                        }
                        if ($oMemberQuestion->type == "A" || $oMemberQuestion->type == "B") {
                            $temp = explode('-', $oQuotaMember->code);
                            $sFieldName = $surveyid . 'X' . $oMemberQuestion->gid . 'X' . $oQuotaMember->qid . $temp[0];
                            $sValue = $temp[1];
                        }
                        $aQuotaInfo['members'][] = array('title' => $oMemberQuestion->title, 'type' => $oMemberQuestion->type, 'code' => $oQuotaMember->code, 'value' => $sValue, 'qid' => $oQuotaMember->qid, 'fieldname' => $sFieldName);
                    }
                }
            }
            // Push this quota Information to all survey quota
            array_push($aSurveyQuotasInfo, $aQuotaInfo);
        }
    }
    return $aSurveyQuotasInfo;
}
<h1>Previous Fees Category</h1>

<!--<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>-->

<?php 
//echo CHtml::link('Advanced Search','#',array('class'=>'search-button'));
?>
<div class="search-form" style="display:none">
<?php 
$this->renderPartial('_search', array('model' => $model));
?>
</div><!-- search-form -->

<?php 
$dataProvider = $model->search();
if (Yii::app()->user->getState("pageSize", @$_GET["pageSize"])) {
    $pageSize = Yii::app()->user->getState("pageSize", @$_GET["pageSize"]);
} else {
    $pageSize = Yii::app()->params['pageSize'];
}
$dataProvider->getPagination()->setPageSize($pageSize);
?>



<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'fees-master-grid', 'dataProvider' => $dataProvider, 'filter' => $model, 'columns' => array(array('header' => 'SI No', 'class' => 'IndexColumn'), 'fees_master_name', array('name' => 'fees_quota_id', 'value' => 'Quota::model()->findByPk($data->fees_quota_id)->quota_name', 'filter' => CHtml::listData(Quota::model()->findAll(array('condition' => 'quota_organization_id=' . Yii::app()->user->getState('org_id'))), 'quota_id', 'quota_name')), array('class' => 'MyCButtonColumn', 'template' => '{view}')), 'pager' => array('class' => 'AjaxList', 'maxButtonCount' => $model->count(), 'header' => '')));
예제 #29
0
/**
* This function imports a LimeSurvey .lss survey XML file
*
* @param mixed $sFullFilepath  The full filepath of the uploaded file
*/
function XMLImportSurvey($sFullFilepath, $sXMLdata = NULL, $sNewSurveyName = NULL, $iDesiredSurveyId = NULL, $bTranslateInsertansTags = true)
{
    Yii::app()->loadHelper('database');
    $clang = Yii::app()->lang;
    $aGIDReplacements = array();
    if ($sXMLdata == NULL) {
        $xml = simplexml_load_file($sFullFilepath);
    } else {
        $xml = simplexml_load_string($sXMLdata);
    }
    if ($xml->LimeSurveyDocType != 'Survey') {
        $results['error'] = $clang->gT("This is not a valid LimeSurvey survey structure XML file.");
        return $results;
    }
    $iDBVersion = (int) $xml->DBVersion;
    $aQIDReplacements = array();
    $aQuotaReplacements = array();
    $results['defaultvalues'] = 0;
    $results['answers'] = 0;
    $results['surveys'] = 0;
    $results['questions'] = 0;
    $results['subquestions'] = 0;
    $results['question_attributes'] = 0;
    $results['groups'] = 0;
    $results['assessments'] = 0;
    $results['quota'] = 0;
    $results['quotals'] = 0;
    $results['quotamembers'] = 0;
    $results['survey_url_parameters'] = 0;
    $results['importwarnings'] = array();
    $aLanguagesSupported = array();
    foreach ($xml->languages->language as $language) {
        $aLanguagesSupported[] = (string) $language;
    }
    $results['languages'] = count($aLanguagesSupported);
    // Import surveys table ====================================================
    foreach ($xml->surveys->rows->row as $row) {
        $insertdata = array();
        foreach ($row as $key => $value) {
            $insertdata[(string) $key] = (string) $value;
        }
        $iOldSID = $results['oldsid'] = $insertdata['sid'];
        if ($iDesiredSurveyId != NULL) {
            $insertdata['wishSID'] = GetNewSurveyID($iDesiredSurveyId);
        }
        if ($iDBVersion <= 143) {
            if (isset($insertdata['private'])) {
                $insertdata['anonymized'] = $insertdata['private'];
            }
            unset($insertdata['private']);
            unset($insertdata['notification']);
        }
        unset($insertdata['expires']);
        unset($insertdata['startdate']);
        //Make sure it is not set active
        $insertdata['active'] = 'N';
        //Set current user to be the owner
        $insertdata['owner_id'] = Yii::app()->session['loginID'];
        if (isset($insertdata['bouncetime']) && $insertdata['bouncetime'] == '') {
            $insertdata['bouncetime'] = NULL;
        }
        if (isset($insertdata['showXquestions'])) {
            $insertdata['showxquestions'] = $insertdata['showXquestions'];
            unset($insertdata['showXquestions']);
        }
        $iNewSID = $results['newsid'] = Survey::model()->insertNewSurvey($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data [1]<br />");
        $results['surveys']++;
    }
    // Import survey languagesettings table ===================================================================================
    foreach ($xml->surveys_languagesettings->rows->row as $row) {
        $insertdata = array();
        foreach ($row as $key => $value) {
            $insertdata[(string) $key] = (string) $value;
        }
        if (!in_array($insertdata['surveyls_language'], $aLanguagesSupported)) {
            continue;
        }
        $insertdata['surveyls_survey_id'] = $iNewSID;
        if ($bTranslateInsertansTags) {
            if ($sNewSurveyName == NULL) {
                $insertdata['surveyls_title'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['surveyls_title']);
            } else {
                $insertdata['surveyls_title'] = translateLinks('survey', $iOldSID, $iNewSID, $sNewSurveyName);
            }
            if (isset($insertdata['surveyls_description'])) {
                $insertdata['surveyls_description'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['surveyls_description']);
            }
            if (isset($insertdata['surveyls_welcometext'])) {
                $insertdata['surveyls_welcometext'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['surveyls_welcometext']);
            }
            if (isset($insertdata['surveyls_urldescription'])) {
                $insertdata['surveyls_urldescription'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['surveyls_urldescription']);
            }
            if (isset($insertdata['surveyls_email_invite'])) {
                $insertdata['surveyls_email_invite'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['surveyls_email_invite']);
            }
            if (isset($insertdata['surveyls_email_remind'])) {
                $insertdata['surveyls_email_remind'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['surveyls_email_remind']);
            }
            if (isset($insertdata['surveyls_email_register'])) {
                $insertdata['surveyls_email_register'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['surveyls_email_register']);
            }
            if (isset($insertdata['surveyls_email_confirm'])) {
                $insertdata['surveyls_email_confirm'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['surveyls_email_confirm']);
            }
        }
        $result = Surveys_languagesettings::model()->insertNewSurvey($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data [2]<br />");
    }
    // Import groups table ===================================================================================
    if (isset($xml->groups->rows->row)) {
        foreach ($xml->groups->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            if (!in_array($insertdata['language'], $aLanguagesSupported)) {
                continue;
            }
            $iOldSID = $insertdata['sid'];
            $insertdata['sid'] = $iNewSID;
            $oldgid = $insertdata['gid'];
            unset($insertdata['gid']);
            // save the old qid
            // now translate any links
            if ($bTranslateInsertansTags) {
                $insertdata['group_name'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['group_name']);
                $insertdata['description'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['description']);
            }
            // Insert the new group
            if (isset($aGIDReplacements[$oldgid])) {
                switchMSSQLIdentityInsert('groups', true);
                $insertdata['gid'] = $aGIDReplacements[$oldgid];
            }
            $newgid = Groups::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data [3]<br />");
            $results['groups']++;
            if (!isset($aGIDReplacements[$oldgid])) {
                $aGIDReplacements[$oldgid] = $newgid;
                // add old and new qid to the mapping array
            } else {
                switchMSSQLIdentityInsert('groups', false);
            }
        }
    }
    // Import questions table ===================================================================================
    // We have to run the question table data two times - first to find all main questions
    // then for subquestions (because we need to determine the new qids for the main questions first)
    if (isset($xml->questions)) {
        foreach ($xml->questions->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            if (!in_array($insertdata['language'], $aLanguagesSupported) || $insertdata['gid'] == 0) {
                continue;
            }
            $iOldSID = $insertdata['sid'];
            $insertdata['sid'] = $iNewSID;
            $insertdata['gid'] = $aGIDReplacements[$insertdata['gid']];
            $oldqid = $insertdata['qid'];
            unset($insertdata['qid']);
            // save the old qid
            // now translate any links
            if ($bTranslateInsertansTags) {
                $insertdata['question'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['question']);
                $insertdata['help'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['help']);
            }
            // Insert the new question
            if (isset($aQIDReplacements[$oldqid])) {
                $insertdata['qid'] = $aQIDReplacements[$oldqid];
                switchMSSQLIdentityInsert('questions', true);
            }
            if ($insertdata) {
                XSSFilterArray($insertdata);
            }
            $newqid = Questions::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data [4]<br />");
            if (!isset($aQIDReplacements[$oldqid])) {
                $aQIDReplacements[$oldqid] = $newqid;
                $results['questions']++;
            } else {
                switchMSSQLIdentityInsert('questions', false);
            }
        }
    }
    // Import subquestions -------------------------------------------------------
    if (isset($xml->subquestions)) {
        foreach ($xml->subquestions->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            if (!in_array($insertdata['language'], $aLanguagesSupported) || $insertdata['gid'] == 0) {
                continue;
            }
            if (!isset($insertdata['mandatory']) || trim($insertdata['mandatory']) == '') {
                $insertdata['mandatory'] = 'N';
            }
            $insertdata['sid'] = $iNewSID;
            $insertdata['gid'] = $aGIDReplacements[(int) $insertdata['gid']];
            $oldsqid = (int) $insertdata['qid'];
            unset($insertdata['qid']);
            // save the old qid
            $insertdata['parent_qid'] = $aQIDReplacements[(int) $insertdata['parent_qid']];
            // remap the parent_qid
            // now translate any links
            if ($bTranslateInsertansTags) {
                $insertdata['question'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['question']);
                if (isset($insertdata['help'])) {
                    $insertdata['help'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['help']);
                }
            }
            if (isset($aQIDReplacements[$oldsqid])) {
                $insertdata['qid'] = $aQIDReplacements[$oldsqid];
                switchMSSQLIdentityInsert('questions', true);
            }
            if ($insertdata) {
                XSSFilterArray($insertdata);
            }
            $newsqid = Questions::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data [5]<br />");
            if (!isset($insertdata['qid'])) {
                $aQIDReplacements[$oldsqid] = $newsqid;
                // add old and new qid to the mapping array
            } else {
                switchMSSQLIdentityInsert('questions', false);
            }
            $results['subquestions']++;
        }
    }
    // Import answers ------------------------------------------------------------
    if (isset($xml->answers)) {
        foreach ($xml->answers->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            if (!in_array($insertdata['language'], $aLanguagesSupported) || !isset($aQIDReplacements[(int) $insertdata['qid']])) {
                continue;
            }
            $insertdata['qid'] = $aQIDReplacements[(int) $insertdata['qid']];
            // remap the parent_qid
            // now translate any links
            if ($bTranslateInsertansTags) {
                $insertdata['answer'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['answer']);
            }
            if ($insertdata) {
                XSSFilterArray($insertdata);
            }
            $result = Answers::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data<br />");
            $results['answers']++;
        }
    }
    // Import questionattributes -------------------------------------------------
    if (isset($xml->question_attributes)) {
        $aAllAttributes = questionAttributes(true);
        foreach ($xml->question_attributes->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            unset($insertdata['qaid']);
            if (!isset($aQIDReplacements[(int) $insertdata['qid']])) {
                continue;
            }
            $insertdata['qid'] = $aQIDReplacements[(int) $insertdata['qid']];
            // remap the qid
            if ($iDBVersion < 148 && isset($aAllAttributes[$insertdata['attribute']]['i18n']) && $aAllAttributes[$insertdata['attribute']]['i18n']) {
                foreach ($aLanguagesSupported as $sLanguage) {
                    $insertdata['language'] = $sLanguage;
                    if ($insertdata) {
                        XSSFilterArray($insertdata);
                    }
                    $result = Question_attributes::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data<br />");
                }
            } else {
                $result = Question_attributes::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data<br />");
            }
            $results['question_attributes']++;
        }
    }
    // Import defaultvalues ------------------------------------------------------
    if (isset($xml->defaultvalues)) {
        $results['defaultvalues'] = 0;
        foreach ($xml->defaultvalues->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            $insertdata['qid'] = $aQIDReplacements[(int) $insertdata['qid']];
            // remap the qid
            if (isset($aQIDReplacements[(int) $insertdata['sqid']])) {
                $insertdata['sqid'] = $aQIDReplacements[(int) $insertdata['sqid']];
            }
            // remap the subquestion id
            if ($insertdata) {
                XSSFilterArray($insertdata);
            }
            // now translate any links
            $result = Defaultvalues::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data<br />");
            $results['defaultvalues']++;
        }
    }
    $aOldNewFieldmap = reverseTranslateFieldNames($iOldSID, $iNewSID, $aGIDReplacements, $aQIDReplacements);
    // Import conditions ---------------------------------------------------------
    if (isset($xml->conditions)) {
        $results['conditions'] = 0;
        foreach ($xml->conditions->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            // replace the qid for the new one (if there is no new qid in the $aQIDReplacements array it mean that this condition is orphan -> error, skip this record)
            if (isset($aQIDReplacements[$insertdata['qid']])) {
                $insertdata['qid'] = $aQIDReplacements[$insertdata['qid']];
                // remap the qid
            } else {
                continue;
            }
            // a problem with this answer record -> don't consider
            if ($insertdata['cqid'] != 0) {
                if (isset($aQIDReplacements[$insertdata['cqid']])) {
                    $oldcqid = $insertdata['cqid'];
                    //Save for cfield transformation
                    $insertdata['cqid'] = $aQIDReplacements[$insertdata['cqid']];
                    // remap the qid
                } else {
                    continue;
                }
                // a problem with this answer record -> don't consider
                list($oldcsid, $oldcgid, $oldqidanscode) = explode("X", $insertdata["cfieldname"], 3);
                // replace the gid for the new one in the cfieldname(if there is no new gid in the $aGIDReplacements array it means that this condition is orphan -> error, skip this record)
                if (!isset($aGIDReplacements[$oldcgid])) {
                    continue;
                }
            }
            unset($insertdata["cid"]);
            // recreate the cfieldname with the new IDs
            if ($insertdata['cqid'] != 0) {
                if (preg_match("/^\\+/", $oldcsid)) {
                    $newcfieldname = '+' . $iNewSID . "X" . $aGIDReplacements[$oldcgid] . "X" . $insertdata["cqid"] . substr($oldqidanscode, strlen($oldcqid));
                } else {
                    $newcfieldname = $iNewSID . "X" . $aGIDReplacements[$oldcgid] . "X" . $insertdata["cqid"] . substr($oldqidanscode, strlen($oldcqid));
                }
            } else {
                // The cfieldname is a not a previous question cfield but a {XXXX} replacement field
                $newcfieldname = $insertdata["cfieldname"];
            }
            $insertdata["cfieldname"] = $newcfieldname;
            if (trim($insertdata["method"]) == '') {
                $insertdata["method"] = '==';
            }
            // Now process the value and replace @sgqa@ codes
            if (preg_match("/^@(.*)@\$/", $insertdata["value"], $cfieldnameInCondValue)) {
                if (isset($aOldNewFieldmap[$cfieldnameInCondValue[1]])) {
                    $newvalue = '@' . $aOldNewFieldmap[$cfieldnameInCondValue[1]] . '@';
                    $insertdata["value"] = $newvalue;
                }
            }
            // now translate any links
            $result = Conditions::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data<br />");
            $results['conditions']++;
        }
    }
    // TMSW Conditions->Relevance:  Call  LEM->ConvertConditionsToRelevance
    // Import assessments --------------------------------------------------------
    if (isset($xml->assessments)) {
        foreach ($xml->assessments->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            if ($insertdata['gid'] > 0) {
                $insertdata['gid'] = $aGIDReplacements[(int) $insertdata['gid']];
                // remap the qid
            }
            $insertdata['sid'] = $iNewSID;
            // remap the survey id
            // now translate any links
            $result = Assessment::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data<br />");
            $results['assessments']++;
        }
    }
    // Import quota --------------------------------------------------------------
    if (isset($xml->quota)) {
        foreach ($xml->quota->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            $insertdata['sid'] = $iNewSID;
            // remap the survey id
            $oldid = $insertdata['id'];
            unset($insertdata['id']);
            // now translate any links
            $result = Quota::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data<br />");
            $aQuotaReplacements[$oldid] = Yii::app()->db->getCommandBuilder()->getLastInsertID('{{quota}}');
            $results['quota']++;
        }
    }
    // Import quota_members ------------------------------------------------------
    if (isset($xml->quota_members)) {
        foreach ($xml->quota_members->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            $insertdata['sid'] = $iNewSID;
            // remap the survey id
            $insertdata['qid'] = $aQIDReplacements[(int) $insertdata['qid']];
            // remap the qid
            $insertdata['quota_id'] = $aQuotaReplacements[(int) $insertdata['quota_id']];
            // remap the qid
            unset($insertdata['id']);
            // now translate any links
            $result = Quota_members::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data<br />");
            $results['quotamembers']++;
        }
    }
    // Import quota_languagesettings----------------------------------------------
    if (isset($xml->quota_languagesettings)) {
        foreach ($xml->quota_languagesettings->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            $insertdata['quotals_quota_id'] = $aQuotaReplacements[(int) $insertdata['quotals_quota_id']];
            // remap the qid
            unset($insertdata['quotals_id']);
            $result = Quota_languagesettings::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data<br />");
            $results['quotals']++;
        }
    }
    // Import survey_url_parameters ----------------------------------------------
    if (isset($xml->survey_url_parameters)) {
        foreach ($xml->survey_url_parameters->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            $insertdata['sid'] = $iNewSID;
            // remap the survey id
            if (isset($insertdata['targetsqid']) && $insertdata['targetsqid'] != '') {
                $insertdata['targetsqid'] = $aSQIDReplacements[(int) $insertdata['targetsqid']];
                // remap the qid
            }
            if (isset($insertdata['targetqid']) && $insertdata['targetqid'] != '') {
                $insertdata['targetqid'] = $aQIDReplacements[(int) $insertdata['targetqid']];
                // remap the qid
            }
            unset($insertdata['id']);
            $result = Survey_url_parameters::model()->insertRecord($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data<br />");
            $results['survey_url_parameters']++;
        }
    }
    // Set survey rights
    Survey_permissions::model()->giveAllSurveyPermissions(Yii::app()->session['loginID'], $iNewSID);
    $aOldNewFieldmap = reverseTranslateFieldNames($iOldSID, $iNewSID, $aGIDReplacements, $aQIDReplacements);
    $results['FieldReMap'] = $aOldNewFieldmap;
    LimeExpressionManager::SetSurveyId($iNewSID);
    translateInsertansTags($iNewSID, $iOldSID, $aOldNewFieldmap);
    LimeExpressionManager::RevertUpgradeConditionsToRelevance($iNewSID);
    LimeExpressionManager::UpgradeConditionsToRelevance($iNewSID);
    return $results;
}
예제 #30
0
 /**
  * Deletes a survey and all its data
  *
  * @access public
  * @param int $iSurveyID
  * @param bool @recursive
  * @return void
  */
 public function deleteSurvey($iSurveyID, $recursive = true)
 {
     Survey::model()->deleteByPk($iSurveyID);
     if ($recursive == true) {
         if (tableExists("{{survey_" . intval($iSurveyID) . "}}")) {
             Yii::app()->db->createCommand()->dropTable("{{survey_" . intval($iSurveyID) . "}}");
         }
         if (tableExists("{{survey_" . intval($iSurveyID) . "_timings}}")) {
             Yii::app()->db->createCommand()->dropTable("{{survey_" . intval($iSurveyID) . "_timings}}");
         }
         if (tableExists("{{tokens_" . intval($iSurveyID) . "}}")) {
             Yii::app()->db->createCommand()->dropTable("{{tokens_" . intval($iSurveyID) . "}}");
         }
         $oResult = Questions::model()->findAllByAttributes(array('sid' => $iSurveyID));
         foreach ($oResult as $aRow) {
             Answers::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
             Conditions::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
             Question_attributes::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
             Defaultvalues::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
         }
         Questions::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         Assessment::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         Groups::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         Surveys_languagesettings::model()->deleteAllByAttributes(array('surveyls_survey_id' => $iSurveyID));
         Survey_permissions::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         Saved_control::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         Survey_url_parameters::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
         Quota::model()->deleteQuota(array('sid' => $iSurveyID), true);
     }
 }