Example #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Dcajachica();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Dcajachica'])) {
         $model->attributes = $_POST['Dcajachica'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function actionCreadetallecaja($id)
 {
     //el modelo padre es le registro del detalle caja chica que genero la deuda
     $modelopadre = Dcajachica::model()->findbypk($id);
     if (is_null($modelopadre)) {
         throw new CHttpException(500, 'No existe estaregistrop con este id');
     } else {
         //verificar que no sea otro usuario
         $codigotra = Yii::app()->user->um->getFieldValue(Yii::app()->user->id, 'codtra');
         if (is_null($codigotra)) {
             throw new CHttpException(500, ' Eres usuario pero no estas registrado como trabajador  ');
             //yii::app()->user->setFlash('notice'," Eres usuario pero no estas registrado como trabajador  ");
             //yii::app()->end();
         } else {
             if (!$modelopadre->codtra == $codigotra) {
                 throw new CHttpException(500, ' Estas intentando rendir una cuenta que no es la tuya  ');
                 //yii::app()->user->setFlash('error'," Estas intentando rendir una cuenta que no es la tuya  ");
                 //yii::app()->end();
             } else {
                 $model = new Dcajachica();
                 $model->setScenario('ins_rendiciontrabajador');
                 $model->codtra = $codigotra;
                 $model->hidcaja = $modelopadre->hidcaja;
                 $model->hidcargo = $modelopadre->id;
                 if (isset($_POST['Dcajachica'])) {
                     $model->attributes = $_POST['Dcajachica'];
                     if ($model->save()) {
                         if (!empty($_GET['asDialog'])) {
                             //Close the dialog, reset the iframe and update the grid
                             echo CHtml::script("window.parent.\$('#cru-dialogdetalle').dialog('close');\n\t\t\t\t\t\t\t\t\t\t\t\t\t                    window.parent.\$('#cru-detalle').attr('src','');\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twindow.parent.\$.fn.yiiGridView.update('detalle-grid');\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
                             Yii::app()->end();
                         }
                     }
                 }
                 // if (!empty($_GET['asDialog']))
                 $this->layout = '//layouts/iframe';
                 $this->render('_form_detalle', array('model' => $model, 'idcabeza' => $model->hidcaja));
             }
         }
     }
 }
Example #3
0
 public function actionCreadetalle($idcabeza)
 {
     $modelocabeza = Cajachica::model()->findByPk($_GET['idcabeza']);
     //VERIFICANDO QUE NO EXCEDA EL % DE TOLERNACIA
     if (is_null($modelocabeza)) {
         throw new CHttpException(500, 'No existe esta solicitud con este ID    ' . $_GET['idcabeza'] . '    ');
     }
     $model = new Dcajachica();
     $model->valorespordefecto($this->documento);
     $model->{$this->campoestado} = ESTADO_CREADO;
     $model->coddocu = $this->documentohijo;
     // Uncomment the following line if AJAX validation is needed
     //$this->performAjaxValidation($model);
     if (isset($_POST['Dcajachica'])) {
         $model->attributes = $_POST['Dcajachica'];
         if ($model->save()) {
             if (!empty($_GET['asDialog'])) {
                 //Close the dialog, reset the iframe and update the grid
                 echo CHtml::script("window.parent.\$('#cru-dialog3').dialog('close');\n\t\t\t\t\t\t\t\t\t\t\t\t\t                    window.parent.\$('#cru-frame3').attr('src','');\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twindow.parent.\$.fn.yiiGridView.update('detalle-grid');\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
                 Yii::app()->end();
             }
         }
     }
     // if (!empty($_GET['asDialog']))
     $this->layout = '//layouts/iframe';
     $this->render('_form_detalle', array('model' => $model, 'idcabeza' => $idcabeza));
 }