예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = AcAcEspec::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'id_ac_centr' => $this->id_ac_centr]);
     $query->andFilterWhere(['like', 'cod_ac_espe', $this->cod_ac_espe])->andFilterWhere(['like', 'nombre', $this->nombre]);
     return $dataProvider;
 }
 /**
  * Funcion de respuesta para el AJAX de
  * acciones especificas
  * @return array JSON 
  */
 public function actionAce1()
 {
     $request = Yii::$app->request;
     if ($request->isAjax) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         if ($request->isPost) {
             //Acciones Especificas
             $ace = AcAcEspec::find()->select(["accion_centralizada_accion_especifica.id", "CONCAT(accion_centralizada_accion_especifica.cod_ac_espe,' - ',accion_centralizada_accion_especifica.nombre) AS name"])->innerjoin('accion_centralizada', 'accion_centralizada.id=accion_centralizada_accion_especifica.id_ac_centr')->where(['accion_centralizada.id' => $request->post('depdrop_parents'), 'accion_centralizada_accion_especifica.estatus' => 1])->asArray()->all();
             return ['output' => $ace];
         }
     }
 }
예제 #3
0
 public function getAccionesEspecificas()
 {
     return $this->hasMany(AcAcEspec::className(), ['id_ac_centr' => 'id']);
 }
예제 #4
0
파일: AcEspUej.php 프로젝트: minpppst/rsc
 public function nombre_accion($accion)
 {
     $especifica = AcAcEspec::find()->where(['id' => $accion])->one();
     return $especifica->nombre;
 }
예제 #5
0
 /**
  * Finds the AcAcEspec model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return AcAcEspec the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = AcAcEspec::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #6
0
 /**
  * operacion para revertir algun cambio hecho al modelo
  * @param integer $id
  * @return Mixed
  */
 public function actionRevertir($id)
 {
     // buscamos los modelos
     $post1 = AuditTrail::findOne($id);
     $post = AcAcEspec::findOne($post1->model_id);
     //si esta vacio el modelo es por que fue borrado
     if ($post != null) {
         //buscamos la ultima version
         $attributes = Version::lastVersion($post->className(), $post->id);
         //cargamos los datos de la ultima version
         $post = Version::find($post->className(), $post->id, $attributes);
         //solo para el caso de modelos que tenga fecha, formatear la fecha
         $post->fecha_inicio = date_create($post->fecha_inicio);
         $post->fecha_fin = date_create($post->fecha_fin);
         $post->fecha_inicio = date_format($post->fecha_inicio, 'Y-m-d');
         $post->fecha_fin = date_format($post->fecha_fin, 'Y-m-d');
     } else {
         //en que caso que fue borrado se busca la ultima version por medio del  id almacenado en el modelo trail
         $attributes = Version::lastVersion(AcAcEspec::className(), $post1->model_id);
         //cargamos los datos
         $post = Version::find(AcAcEspec::className(), $post1->model_id, $attributes);
         //solo en caso de modelos q tengan fecha
         $post->fecha_inicio = date_create($post->fecha_inicio);
         $post->fecha_fin = date_create($post->fecha_fin);
         $post->fecha_inicio = date_format($post->fecha_inicio, 'Y-m-d');
         $post->fecha_fin = date_format($post->fecha_fin, 'Y-m-d');
     }
     if (!$post->save()) {
         return $this->redirect('index.php?r=audit/trail');
     } else {
         return $this->redirect('index.php?r=audit/trail');
     }
 }