/** * actionIndex * @param $id string * @param $ajax bool * @return void */ public function actionIndex($id, $ajax = false) { Yii::log("actionIndex AdminController called", "trace", self::LOG_CAT); $dataArray = []; $dataArray['dtHeader'] = "Manage Options"; // Set page title when printing the datatable // Get list of options // $optionsList = Options::model()->findAll(array( // 'select' => 'optionId, label', // )); $dataArray['firstColumn'] = $this->optionsMask['relationNames'][$id]; $optionsListCriteria = new CDbCriteria(); $optionsListCriteria->select = 'optionId, label'; $optionsListCriteria->with = $this->optionsMask['relationNames'][$id]; $optionsList = ModelToArray::convertModelToArray(Options::model()->findAll($optionsListCriteria)); //print_r($optionsList); die; $optionsListArray = []; // Format datatable data. Define the Edit & Delete buttons if ($ajax) { $jsonData = json_encode(["aaData" => $optionsList]); echo $jsonData; return; } $dataArray['optionsList'] = json_encode($optionsList); $this->render('index', ['id' => $id, 'dataArray' => $dataArray]); }
/** * Lists all models. * @param $ajax bool */ public function actionIndex($ajax = false) { if ($ajax) { $dataProvider = new CActiveDataProvider('EconomicMethods', ['criteria' => ['with' => ['econMethodGroup']]]); // print_r($dataProvider->getData()); die; echo json_encode(['aaData' => ModelToArray::convertModelToArray($dataProvider->getData())]); return; } $this->render('index'); }
/** * Lists all models. * @param $ajax bool */ public function actionIndex($ajax = false) { if ($ajax) { $dataProvider = new CActiveDataProvider('EvaAttributesAssessmentMethods', ['criteria' => ['with' => ['evaAttributes']]]); //print_r(ModelToArray::convertModelToArray($dataProvider->getData())); die; echo json_encode(['aaData' => ModelToArray::convertModelToArray($dataProvider->getData())]); return; } $this->render('index'); }
/** * Lists all models. * @param bool $ajax */ public function actionIndex($ajax = false) { $dataProvider = EvaluationQuestion::model()->findAll("flag='final'"); if ($ajax) { $dataProviderJson = json_encode(['aaData' => ModelToArray::convertModelToArray($dataProvider)]); echo $dataProviderJson; return; } $this->menu = [['label' => 'Manage Evaluation Tool', 'url' => ['admineva/index']]]; $this->render('index', []); }
/** * actionIndex * @var $ajax bool * @return void */ public function actionIndex($ajax = false) { Yii::log("actionIndex AttributeController called", "trace", self::LOG_CAT); $dataArray = array(); $dataArray['dtHeader'] = "Manage Attributes"; // Set page title when printing the datatable $attributesList = ModelToArray::convertModelToArray(EvaAttributes::model()->with('attributeTypes')->findAll(['select' => 'attributeId, name, description, attributeType'])); // Format datatable data. Define the Edit & Delete buttons $dataArray['attributesList'] = json_encode($attributesList); if ($ajax) { echo json_encode(["aaData" => $attributesList]); return; } $this->render('index', array('dataArray' => $dataArray)); }
/** * Lists all models. * * @param string $ajax */ public function actionIndex($ajax = '0') { $model = ModelToArray::convertModelToArray(EvaAttributesMatrix::model()->with('objective', 'attribute')->findAll(), ['evaAttributes' => 'attributeId, name', 'options' => 'optionId, label']); if ($ajax) { echo json_encode(['aaData' => $model]); return; } $this->menu = [['label' => 'Add Attribute', 'url' => ['adminattributerelevance/create']]]; $this->render('index', ['model' => $model]); }
/** * @param $fieldId * @param $dForm * @return string */ private function generateGridElements($fieldId, &$dForm) { //$model = new DynamicFormDetails('insert', 'frameworkFieldData'); // get grid fields $gridFieldsCriteria = new CDbCriteria(); $gridFieldsCriteria->condition = 'parentId=' . $fieldId; $gridFieldsCriteria->order = '`order` ASC'; $gridFieldsNames = []; $labels = []; $properties = []; $rules = []; $inputs = ''; if ($dForm->getScenario() == 'insert') { $gridFields = FrameworkFields::model()->findAll($gridFieldsCriteria); $inputs .= '<tr class="copy' . $fieldId . '">'; foreach ($gridFields as $field) { //$el = new CFormInputElement() $attribute = $field->inputName . '_' . $field->id; $dForm->setpropertyName($attribute); // continue; //$model->setAttribute($attribute, $field->inputName); // $dForm->_dynamicLabels[$attribute] = isset($field->label) ? // $field->label : $dForm->generateAttributeLabel($field->inputName); $labels[$attribute] = isset($field->label) ? $field->label : $dForm->generateAttributeLabel($field->inputName); $validation = $field->required ? 'required' : 'safe'; $rules[] = [$attribute, $validation]; $i = 0; //print_r($dForm); die; $inputs .= '<td>'; switch ($field->inputType) { case 'text': $inputs .= CHtml::activeTextField($dForm, "[{$i}]{$attribute}"); $inputs .= CHtml::error($dForm, "[{$i}]{$attribute}"); break; case 'dropdownlist': $options = []; if ($field->multiple) { $options['multiple'] = true; } $inputs .= CHtml::activeDropDownList($dForm, "[{$i}]{$attribute}", Options::model()->getContextFieldOptions($field->id), $options); $inputs .= CHtml::error($dForm, "[{$i}]{$attribute}"); break; } $inputs .= '</td>'; //$elements['elements'][] = '</td>'; } $inputs .= '<td></td></tr>'; } else { // get id's of fields that belong to the grid //$gridFieldsCriteria->select = 'id'; $childFields = ModelToArray::convertModelToArray(FrameworkFields::model()->with('data')->findAll($gridFieldsCriteria)); // ['frameworkFields' => 'id, inputName, label, inputType, required, multiple']); //print_r($childFields); die; $gridFieldsIds = array_map(function ($item) { return $item['id']; }, $childFields); // get grid data $fieldDataCriteria = new CDbCriteria(); $fieldDataCriteria->condition = 'frameworkId=' . Yii::app()->session['surDesign']['id']; $fieldDataCriteria->addInCondition('frameworkFieldId', $gridFieldsIds); $gridFields = FrameworkFieldData::model()->findAll($fieldDataCriteria); if (empty($gridFields)) { $dForm->setScenario('insert'); //print_r($dForm); die; return self::generateGridElements($fieldId, $dForm); } $dFormGrid = []; foreach ($childFields as $child) { $elementId = $child['inputName'] . '_' . $child['id']; $gridFieldsNames[$child['id']] = $elementId; $gridParams[$elementId]['id'] = $child['id']; $labels[$elementId] = $child['label']; $gridParams[$elementId]['inputType'] = $child['inputType']; $gridParams[$elementId]['required'] = $child['required']; $gridParams[$elementId]['multiple'] = $child['multiple']; } //$dFormGrid[$k] = new DForm(); foreach ($childFields as $child) { if (isset($child['data'][0])) { foreach ($child['data'] as $key => $data) { if (!isset($dFormGrid[$key])) { $dFormGrid[$key] = new DForm(); } $elementId = $child['inputName'] . '_' . $child['id']; foreach ($gridFieldsNames as $gridElement) { if (empty($dFormGrid[$key]->attributes[$gridElement])) { //echo "new $key $gridElement \n"; //print_r($dFormGrid[$key]); // $dFormGrid[$key]->setPropertyName($gridElement); } //var_dump($dFormGrid[$key]->$gridElement); } $dFormGrid[$key]->{$elementId} = $data['value']; if (DForm::isJson($data['value'])) { $dFormGrid[$key]->{$elementId} = json_decode($data['value']); } } } } $copyClass = ''; foreach ($dFormGrid as $key => $gridItems) { $inputs .= '<tr class="copy' . $fieldId . ' ' . $copyClass . '">'; foreach ($gridItems->attributeNames() as $attr) { //var_dump($gridItems[$attr]); die; $inputs .= '<td>'; switch ($gridParams[$attr]['inputType']) { case 'text': $inputs .= CHtml::activeTextField($gridItems, "[{$key}]{$attr}"); $inputs .= CHtml::error($gridItems, "[{$key}]{$attr}"); break; case 'dropdownlist': $options = []; if ($gridParams[$attr]['multiple']) { $options['multiple'] = true; } $inputs .= CHtml::activeDropDownList($gridItems, "[{$key}]{$attr}", Options::model()->getContextFieldOptions($gridParams[$attr]['id']), $options); $inputs .= CHtml::error($gridItems, "[{$key}]{$attr}"); break; } $inputs .= '</td>'; } $inputs .= '<td><a class="remove ui-icon ui-icon-trash" href="#"' . ' onclick="$(this).parent().parent().remove(); return false">remove</a></td></tr>'; $copyClass = 'copy1'; } //echo $inputs; die; } //var_dump($data, $cols); die('lklk'); //die; $dForm->setRules($rules); $dForm->setAttributeLabels($labels); //print_r(array_values($labels)); $tableHeader = '<th>' . implode('</th><th>', array_values($labels)); $table = '<table class="jgTabular"><thead><tr>' . $tableHeader . '<th></th></tr></thead>'; $table .= '<tbody>' . $inputs . '</tbody>'; $table .= '</table>'; $table .= CHtml::htmlButton('<span class="ui-icon ui-icon-plusthick"></span>Add new row', ['id' => 'copyLink-' . $fieldId, 'rel' => '.copy' . $fieldId]); // if($fieldId == 37) { // print_r($table); //die('pop'); // } return $table; }
/** * @param bool $ajax * @return void */ public function actionListEvaContext($ajax = false) { Yii::log("actionListEvaContext called", "trace", self::LOG_CAT); $this->setPageTitle('List Evaluation Contexts'); if ($ajax) { $contextCriteria = new CDbCriteria(); $contextCriteria->select = 'evaluationName, frameworkId, questionId'; $contextCriteria->with = ['frameworks', 'question']; $contextCriteria->condition = 't.userId=' . Yii::app()->user->id . ' AND t.frameworkId=' . $this->frameworkId; $evaContextArray = ModelToArray::convertModelToArray(EvaluationHeader::model()->findAll($contextCriteria)); $evaContexts = $this->replaceNullQuestion($evaContextArray); //var_dump($evaContexts); die; echo json_encode(['aaData' => $evaContexts]); return; } if (is_null($this->frameworkId)) { Yii::log('No surveillance system selected! ', 'trace', self::LOG_CAT); Yii::app()->user->setFlash('notice', 'Please select a surveillance system above before proceeding'); $this->redirect(['evaPage']); return; } $this->docName = 'listEvaContext'; if (isset($_POST['pageId'])) { SystemController::savePage('listEvaContext'); } $page = SystemController::getPageContent($this->docName); $this->render('listEvaContext', compact('page')); }
/** * @param bool $ajax * @return void */ public function actionListEvaMethods($ajax = false) { Yii::log("actionListEvaMethods called", "trace", self::LOG_CAT); $this->setPageTitle(Yii::app()->name . ' - List Evaluation Methods'); $dataProvider = new CActiveDataProvider('EvaMethods'); //print_r(ModelToArray::convertModelToArray($dataProvider->getData())); die; if ($ajax) { $data = array('aaData' => ModelToArray::convertModelToArray($dataProvider->getData())); echo json_encode($data, JSON_UNESCAPED_SLASHES); return; } $this->render('evaMethods/list', array('dataProvider' => $dataProvider)); }