예제 #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Cargos();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Cargos'])) {
         $model->attributes = $_POST['Cargos'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->cnumcargo));
         }
     }
     $this->render('create', array('model' => $model));
 }
예제 #2
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Cargos();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Cargos'])) {
         $model->attributes = $_POST['Cargos'];
         if ($model->save()) {
             date_default_timezone_set('America/Caracas');
         }
         $auditoria = new Auditoria();
         $auditoria->id_user = Yii::app()->user->getId();
         $auditoria->accion = 2;
         $auditoria->modelo = $this->modelo;
         $auditoria->id_registro = $model->id;
         $auditoria->fecha = date("Y-m-d h:i:s");
         $auditoria->save(false);
         $this->redirect(array('view', 'id' => $model->id));
     }
     $this->render('create', array('model' => $model));
 }
예제 #3
0
 public function saveAction()
 {
     if (isset($_POST['id'])) {
         if ($_POST['id'] > 0) {
             $resul = Cargos::findFirstById($_POST['id']);
             $resul->organigrama_id = $_POST['organigrama_id'];
             if ($_POST['depende_id'] != "") {
                 $resul->depende_id = $_POST['depende_id'];
             } else {
                 $resul->depende_id = 0;
             }
             $resul->codigo = $_POST['codigo'];
             $resul->cargo = $_POST['cargo'];
             $resul->codigo_nivel = $_POST['codigo_nivel'];
             $resul->fin_partida_id = $_POST['fin_partida_id'];
             $resul->user_mod_id = $user->id;
             $resul->fecha_mod = date("Y-m-d H:i:s");
             $resul->formacion_requerida = $_POST['formacion_requerida'];
             $resul->save();
         } else {
             /* 	//$this->_registerSession($user);
                               $finpartida=Finpartidas::findFirstById($_POST['fin_partida_id']);
                               if ($finpartida != false)
                               {
             
                               $finpartida->contador=$finpartida->contador+1;
                               $finpartida->save();
                               $codigo = $finpartida->codigo.'.'.substr('0000'.$finpartida->contador,-5);
                               }
                               else{
                               $msm = array('msm' => 'Error: Generacion de codigo' );
                               }
                              */
             $resul = new Cargos();
             $resul->organigrama_id = $_POST['organigrama_id'];
             if ($_POST['depende_id'] != "") {
                 $resul->depende_id = $_POST['depende_id'];
             } else {
                 $resul->depende_id = 0;
             }
             $resul->ejecutora_id = 1;
             $resul->codigo = $_POST['codigo'];
             //generar
             $resul->cargo = $_POST['cargo'];
             $resul->codigo_nivel = $_POST['codigo_nivel'];
             $resul->cargo_estado_id = 1;
             $resul->estado = 0;
             $resul->baja_logica = 1;
             $resul->user_reg_id = $user->id;
             $resul->fecha_reg = date("Y-m-d H:i:s");
             $resul->fin_partida_id = $_POST['fin_partida_id'];
             $resul->poa_id = 1;
             $resul->formacion_requerida = $_POST['formacion_requerida'];
             //$resul->save();
             if ($resul->save()) {
                 $msm = array('msm' => 'Exito: Se guardo correctamente');
             } else {
                 $msm = array('msm' => 'Error: No se guardo el registro');
             }
         }
     }
     $this->view->disable();
     echo json_encode();
 }