/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new EacDecision(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['EacDecision'])) { $model->attributes = $_POST['EacDecision']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function actionSaveDecisions() { if (isset($_POST['data'])) { $data = json_decode($_POST['data']); $internalScId = NULL; $eamsCentralScId = $data[0]->sectoral_council_id; if (!empty($eamsCentralScId)) { $scModel = EacLookup::model()->find('eams_central_id=:id', [':id' => $eamsCentralScId]); $internalScId = $scModel->id; } foreach ($data as $item) { $decision = new EacDecision(); $decision->eams_central_id = $item->eams_central_id; $decision->decision_reference = $item->decision_reference; $decision->decision_source_id = $item->decision_source_id; $decision->sectoral_council_id = $internalScId; $decision->decision_date = $item->decision_date; $decision->description = $item->description; $decision->budgetary_implications = $item->budgetary_implications; $decision->time_frame = $item->time_frame; $decision->performance_indicators = $item->performance_indicators; $decision->responsibility_center = $item->responsibility_center; $decision->meeting_no = $item->meeting_no; $decision->date_created = date('Y-m-d H:i:s'); $decision->create_user_id = Yii::app()->user->id; if (!$decision->decisionExists()) { $decision->save(); } //if } //foreach } }