Пример #1
0
 /**
  * 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 Asignaciones the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Asignaciones::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #2
0
 public function ingresoAsignacionE()
 {
     /**INGRESO Servicio**/
     if (!Sesion::isAdmin()) {
         return Redirect::to('administracion/logout');
     }
     $token = Input::get('token');
     if (isset($token)) {
         $data = array('fuente' => Input::get('f'), 'representante' => Input::get('r'));
         $validaciones = array('fuente' => array('required', 'regex:/^([0-9a-zA-ñÑZáéíóúñÁÉÍÓÚ\\-\\s\\,\\.\\?\\¿\\¡\\!])+$/'));
         $validator = Validator::make($data, $validaciones);
         if ($validator->fails()) {
             $respuesta;
             $mensajes = $validator->messages();
             foreach ($mensajes->all() as $mensaje) {
                 $respuesta = $mensaje;
             }
             $response = array('status' => 'ERROR F', 'message' => $respuesta);
         } else {
             $duplicado = Asignaciones::where('asiFuentes', $data['fuente'])->where('asiResponsables', $data['representante'])->where('asiPeriodos', null)->get()->toArray();
             if (count($duplicado) > 0) {
                 return Response::json(array('status' => 'Error', 'message' => 'Ya existen asignaciones para el período especificado, verifique'));
             } else {
                 $insert = Asignaciones::insert(array('asiFuentes' => trim($data['fuente']), 'asiResponsables' => trim($data['representante'])));
                 if ($insert) {
                     $response = array('status' => 'OK', 'message' => 'Asignación correcta.');
                 } else {
                     $response = array('status' => 'ERROR', 'message' => 'No se pudo realizar el registro, intente de nuevo');
                 }
             }
         }
     } else {
         $response = array('status' => 'ERROR', 'message' => 'Vuelva a intentar en un momento');
     }
     return Response::json($response);
 }
Пример #3
0
 public function actionRecibo($id)
 {
     if (Yii::app()->request->isAjaxRequest) {
         //outputProcessing = true because including css-files ...
         $a = $this->loadModel($id);
         $b = Asignaciones::model()->findByAttributes(array('id' => $a->id_asignacion));
         $c = Deducciones::model()->findByAttributes(array('id' => $a->id_deduccion));
         $this->renderPartial('recibo', array('a' => $a, 'b' => $b, 'c' => $c), false, true);
         date_default_timezone_set('America/Caracas');
         $auditoria = new Auditoria();
         $auditoria->id_user = Yii::app()->user->getId();
         $auditoria->accion = 6;
         $auditoria->modelo = $this->modelo;
         $auditoria->id_registro = $a->id;
         $auditoria->fecha = date("Y-m-d h:i:s");
         $auditoria->save(false);
         //js-code to open the dialog
         if (!empty($_GET['asDialog'])) {
             echo CHtml::script('$("#dlg-address-view").dialog("open")');
         }
         Yii::app()->end();
     } else {
         $this->render('ficha', array('model' => $this->loadModel($id)));
     }
 }