Example #1
0
 /**
  * @param $id
  */
 public function actionDelete($id)
 {
     Yii::log("actionDelete ContextController called", "trace", self::LOG_CAT);
     $record = FrameworkContext::model()->findByPk($id);
     if (!$record->delete()) {
         Yii::log("Error deleting context: " . $id, "warning", self::LOG_CAT);
         //echo $errorMessage;
         echo Yii::t("translation", "A problem occurred when deleting the surveillance system ");
     } else {
         // remove the default selected design from session
         unset($_SESSION['surDesign']);
         echo Yii::t("translation", "The surveillance system ") . Yii::t("translation", " has been successfully deleted");
     }
     return;
 }
Example #2
0
 /**
  * actionListComponents
  * @access public
  * @return void
  */
 public function actionListComponents($getComponents = null)
 {
     Yii::log("actionListComponents DesignController called", "trace", self::LOG_CAT);
     //$model = new ComponentHead;
     $dataArray = [];
     $dataArray['componentList'] = json_encode([]);
     $dataArray['dtHeader'] = "Components List";
     $componentListArray = [];
     $formDetailsArray = [];
     if (!empty(Yii::app()->session['surDesign'])) {
         $componentData = self::getComponentData();
         $componentListArray = $componentData['componentListArray'];
         $formDetailsArray = $componentData['formDetailsArray'];
     }
     //print_r($componentListArray); die();
     $dataArray['componentList'] = json_encode($componentListArray);
     // return ajax json data
     if (isset($getComponents)) {
         $jsonData = json_encode(["aaData" => $componentListArray]);
         echo $jsonData;
         return;
     }
     $surveillanceSystems = CHtml::listData(FrameworkContext::model()->findAll(['condition' => 'userId=:userId', 'select' => 'frameworkId, name', 'params' => [':userId' => Yii::app()->user->id]]), 'frameworkId', 'name');
     $this->render('componentList', ['dataArray' => $dataArray, 'columnsArray' => $formDetailsArray, 'surveillanceSystems' => $surveillanceSystems]);
 }
 /**
  * getElementsAndDynamicAttributes
  * @param array $componentData
  * @access public
  * @return array
  */
 public function getElementsAndDynamicAttributes($componentData = [])
 {
     $elements = [];
     $attributeArray = [];
     $dynamicDataAttributes = [];
     //$getFormCondition = 't.formId=:formId';
     //$getFormParams = array(':formId' => 1);
     $getForm = EvaluationElements::model()->findAll();
     //$elements['title'] = "Components Form";
     $elements['showErrorSummary'] = true;
     $elements['showErrors'] = true;
     $elements['errorSummaryHeader'] = Yii::app()->params['headerErrorSummary'];
     $elements['errorSummaryFooter'] = Yii::app()->params['footerErrorSummary'];
     $elements['activeForm']['id'] = "EvalForm";
     $elements['activeForm']['enableClientValidation'] = true;
     $elements['activeForm']['clientOptions'] = ['validateOnSubmit' => true];
     //$elements['activeForm']['enableAjaxValidation'] = false;
     $elements['activeForm']['class'] = 'CActiveForm';
     //print_r($getForm); die();
     $evalElements = $getForm;
     $dataArray['getForm'] = $elements;
     $inputType = 'text';
     //$dynamicDataAttributes['frameworkId'] = 'frameworkId';
     //$rules[] = ['frameworkId', 'required'];
     $designData = FrameworkContext::model()->findAll(['condition' => 'userId=:userId', 'params' => [':userId' => Yii::app()->user->id]]);
     $designItems = [];
     // process the dropdown data into an array
     foreach ($designData as $params) {
         $designItems[$params->frameworkId] = $params->name;
     }
     $elements['elements'] = EvaluationHeader::getElements();
     // add the dropdown items to the element
     //$elements['elements']['frameworkId']['items'] = $designItems;
     $elements['elements']['evaContext']['type'] = 'form';
     //$elements['elements']['evaluationName']['layout'] = '{label} {input} {hint} {error}';
     $rules = [];
     $labels = [];
     foreach ($evalElements as $element) {
         //set the model attribute array
         $attributeId = $element->inputName . "_" . $element->evalElementsId;
         $dynamicDataAttributes[$attributeId] = '';
         $validation = $element->required ? 'required' : 'safe';
         $rules[] = [$attributeId, $validation];
         if ($element->inputName == 'componentNo') {
             $rules[] = [$attributeId, 'numerical'];
         }
         $highlightClass = "";
         if (isset($attributeArray[$element->evalElementsId])) {
             $highlightClass = "attributeHighlight";
         }
         $labels[$attributeId] = $element->label;
         // add the elements to the CForm array
         $elements['elements']['evaContext']['elements'][$attributeId] = ['label' => $element->label, 'required' => $element->required, 'type' => $element->inputType, 'class' => $highlightClass, 'title' => UtilModel::urlToLink($element->elementMetaData), 'data-field' => $element->evalElementsId];
         // Add an image icon that will be displayed on the ui to show more info
         $button = CHtml::image('', '', ['id' => 'moreInfoButton' . $element->evalElementsId, 'style' => 'cursor:pointer', 'class' => 'ui-icon ui-icon-info', 'title' => 'More Information', 'onClick' => '$("#moreInfoDialog").html($("#popupData' . $element->evalElementsId . '").html());$("#moreInfoDialog").dialog("open")']);
         // Add the image icon and information to the layout/ui
         //			if (!empty($element->moreInfo) && !empty($element->url) && !empty($element->description)) {
         //				$elements['elements']['evaContext']['elements'][$attributeId]['layout'] = '{label}<div class="componentImagePopup">' . $button .
         //					'</div>{hint} {input}' . '<div id="popupData' . $element->evalElementsId . '" style="display:none">' . $element->moreInfo . '</div>' .
         //					'<div class="componentDataPopup">' . $element->description .
         //					' <br/> <a href=' . $element->url . ' target=_blank>' . $element->url . '</a></div> {error}';
         //			}
         // add the values to the form
         if (!empty($componentData[$attributeId])) {
             $elements['elements']['evaContext']['elements'][$attributeId]['value'] = $componentData[$attributeId]['value'];
         }
         // add the component name element value
         if (!empty($componentData['evaluationName'])) {
             $elements['elements']['evaContext']['elements']['evaluationName']['value'] = $componentData['evaluationName'];
         }
         // add the frameworkId element value
         if (!empty($componentData['frameworkId'])) {
             $elements['elements']['evaContext']['elements']['frameworkId']['value'] = $componentData['frameworkId'];
         }
         //add the dropdown parameters
         if ($element->inputType == 'dropdownlist') {
             $items = CHtml::listData(Options::model()->findAll(['condition' => 'elementId=:elementId', 'params' => [':elementId' => $element->evalElementsId]]), 'optionId', 'label');
             // add the dropdown items to the element
             $elements['elements']['evaContext']['elements'][$attributeId]['items'] = $items;
             $elements['elements']['evaContext']['elements'][$attributeId]['prompt'] = 'Choose one';
         }
         if ($element->inputName == 'currentCost' || $element->inputName == 'budgetLimit') {
             $elements['elements']['evaContext']['elements'][$attributeId]['class'] = 'update-able';
         }
     }
     $elements['buttons'] = ['newEvaluation' => ['type' => 'submit', 'label' => 'Create evaluation context']];
     $returnArray = ['elements' => $elements, 'dynamicDataAttributes' => $dynamicDataAttributes, 'labels' => $labels, 'rules' => $rules];
     return $returnArray;
 }
Example #4
0
if (!Yii::app()->user->isGuest) {
    $activeDesignAction = 'Select';
    $activeSurSystem = '';
    $surSystemOptions = ['class' => 'chozen', 'empty' => 'Select one...', 'data-placeholder' => 'Select one', 'id' => 'systemSelector', 'onchange' => "if(\$(this).val() !== '') {window.location='" . Yii::app()->createUrl('context/view') . "/id/' + \$(this).val()}"];
    if (!empty(Yii::app()->session['surDesign'])) {
        $activeSurSystem = Yii::app()->session['surDesign']['id'];
        //$activeDesignAction = 'Change';
        unset($surSystemOptions['empty'], $surSystemOptions['data-placeholder']);
    }
    $surSystemCriteria = new CDbCriteria();
    $surSystemCriteria->select = 'frameworkId, name';
    $surSystemCriteria->condition = 'userId=:user';
    $surSystemCriteria->params = [':user' => Yii::app()->user->id];
    //echo "Selected surveillance system: $activeSurSystem <a href='" . Yii::app()->createUrl("context/list") . "'>$activeDesignAction</a>";
    echo CHtml::label('Current surveillance system: ', 'systemSelector');
    echo CHtml::dropDownList('systemSelector', $activeSurSystem, CHtml::listData(FrameworkContext::model()->findAll($surSystemCriteria), 'frameworkId', 'name'), $surSystemOptions);
}
?>
	</div>
	<div id="evalName">
	<?php 
if (Yii::app()->controller->id == 'evaluation') {
    $evaContext = "Current evaluation context: ";
    $evaContext .= isset(Yii::app()->session['evaContext']['name']) ? Yii::app()->session['evaContext']['name'] : "None";
    echo $evaContext;
}
?>
	</div>
	<div id="attributeSelected">
	<?php 
//		if (Yii::app()->controller->id <> 'evaluation') {