Esempio n. 1
0
 public function actionIndex()
 {
     Yii::app()->getComponent("bootstrap");
     Yii::import('ext.multimodelform.MultiModelForm');
     $sede = "";
     if (isset($_GET['sede']) && $_GET['sede'] != "") {
         $sede = CatSedes::model()->find("codigo_dane_sede=" . $_GET['sede']);
         $model = Acta::model()->find("CODIGO_DANE_SEDE='" . $_GET['sede'] . "'");
         if ($model == null) {
             $model = new Acta();
         }
         $participante = new Participante();
         $validatedMembers = array();
         //ensure an empty array
         $deleteMembers = array();
         if (isset($_POST['Acta'])) {
             $model->attributes = $_POST['Acta'];
             $imageData = $_POST['imageData'];
             $imageDecoded = base64_decode($imageData);
             $fileName = $model->CODIGO_DANE_ESTABLEDUCATIVO . "_" . $model->CODIGO_DANE_SEDE . "_" . date('Y-m-d-H-i-s') . ".png";
             $resultImageSaveProcess = file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/men19/uploads/" . $fileName, $imageDecoded);
             if ($resultImageSaveProcess) {
                 $model->FIRMA = $fileName;
             }
             $model->LLAVE = md5($model->CODIGO_DANE_SEDE . "-" . $model->FECHA_INICIAL . "-" . Parametro::model()->findByPk(1)->NO_CONTRATO);
             $model->FECHA_ACTUALIZACION = date("Y-m-d H:i:s");
             if (MultiModelForm::validate($participante, $validatedMembers, $deleteMembers) && $model->save()) {
                 //the value for the foreign key 'groupid'
                 $masterValues = array('ACTA_ID' => $model->IDACTA);
                 if (MultiModelForm::save($participante, $validatedMembers, $deleteMembers, $masterValues)) {
                     //Yii::app()->db->createCommand("CALL aud_procedimiento_desempate()")->execute();
                     $this->redirect(array('acta', 'id' => $model->IDACTA));
                 }
             }
         }
         $this->render('index', array('model' => $model, 'participante' => $participante, 'validatedMembers' => $validatedMembers, 'sede' => $sede));
     }
 }
 /**
  * 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 $id the ID of the model to be loaded
  * @return Acta the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Acta::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }