/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = AccionCentralizadaVariableEjecucion::find(); // add conditions that should always apply here $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; } // grid filtering conditions $query->andFilterWhere(['id' => $this->id, 'id_programacion' => $this->id_programacion, 'id_usuario' => $this->id_usuario, 'fecha' => $this->fecha, 'enero' => $this->enero, 'febrero' => $this->febrero, 'marzo' => $this->marzo, 'abril' => $this->abril, 'mayo' => $this->mayo, 'junio' => $this->junio, 'julio' => $this->julio, 'agosto' => $this->agosto, 'septiembre' => $this->septiembre, 'octubre' => $this->octubre, 'noviembre' => $this->noviembre, 'diciembre' => $this->diciembre]); return $dataProvider; }
/** * Lists all AccionCentralizadaDesbloqueoMes models. * @return mixed */ public function actionIndex($id) { $searchModel = new AccionCentralizadaDesbloqueoMesSearch(); $ejecucion = AccionCentralizadaVariableEjecucion::find()->innerjoin('accion_centralizada_variable_programacion', 'accion_centralizada_variable_programacion.id=accion_centralizada_variable_ejecucion.id_programacion')->where(['accion_centralizada_variable_programacion.id_localizacion' => $id])->one(); //print_r($programacion); exit(); $model = AccionCentralizadaDesbloqueoMes::find(); if ($ejecucion != null) { $model->andFilterWhere(['id_ejecucion' => $ejecucion->id]); } else { $model->andFilterWhere(['id' => -1]); } $dataProvider = new ActiveDataProvider(['query' => $model]); $searchModel = ''; // return $dataProvider; //$dataProvider = $searchModel->search(Yii::$app->request->queryParams); Yii::$app->response->format = Response::FORMAT_JSON; return ['title' => "Desbloqueo Por Mes Variables", 'content' => $this->renderAjax('index', ['searchModel' => $searchModel, 'id_ejecucion' => $ejecucion, 'dataProvider' => $dataProvider])]; }
/** * Creates a new AccionCentralizadaVariableEjecucion model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($id, $id_localizacion) { $desbloqueo = ""; $total_cargado = 0; $model = new AccionCentralizadaVariableEjecucion(); $model_programacion = AccionCentralizadaVariableProgramacion::find()->where(['id_localizacion' => $id_localizacion])->All(); $total = $model_programacion[0]['enero'] + $model_programacion[0]['febrero'] + $model_programacion[0]['marzo'] + $model_programacion[0]['abril'] + $model_programacion[0]['mayo'] + $model_programacion[0]['junio'] + $model_programacion[0]['julio'] + $model_programacion[0]['agosto'] + $model_programacion[0]['septiembre'] + $model_programacion[0]['octubre'] + $model_programacion[0]['noviembre'] + $model_programacion[0]['diciembre']; $model_inicial = AccionCentralizadaVariableEjecucion::find()->where(['id_programacion' => $model_programacion[0]['id']])->asArray()->One(); $model->id_programacion = $model_programacion[0]['id']; $model->id_usuario = Yii::$app->user->getId(); $hoy = getdate(); $fecha = $hoy['year'] . "/" . $hoy['mon'] . "/" . $hoy['mday'] . " " . $hoy['hours'] . ":" . $hoy['minutes'] . ":" . $hoy['seconds']; $model->fecha = $fecha; $desbloqueo[0] = 0; //verificar campos bloqueado if ($model_inicial == NULL) { //primera vez que carga, deberia habilitarse solamente enero $desbloqueo[0] = 1; } else { //verificar mes pendiente con la fecha o ultima carga realizada y fecha if ($model_inicial['diciembre'] == NULL && ($hoy['mon'] == 12 && $hoy['mday'] >= 5 || $hoy['mon'] > 12)) { $desbloqueo[0] = 12; } if ($model_inicial['noviembre'] == NULL && ($hoy['mon'] == 11 && $hoy['mday'] >= 5 || $hoy['mon'] > 11)) { $desbloqueo[0] = 11; } if ($model_inicial['octubre'] == NULL && ($hoy['mon'] == 10 && $hoy['mday'] >= 5 || $hoy['mon'] > 10)) { $desbloqueo[0] = 10; } if ($model_inicial['septiembre'] == NULL && ($hoy['mon'] == 9 && $hoy['mday'] >= 5 || $hoy['mon'] > 9)) { $desbloqueo[0] = 9; } if ($model_inicial['agosto'] == NULL && ($hoy['mon'] == 8 && $hoy['mday'] >= 5 || $hoy['mon'] > 8)) { $desbloqueo[0] = 8; } if ($model_inicial['julio'] == NULL && ($hoy['mon'] == 7 && $hoy['mday'] >= 5 || $hoy['mon'] > 7)) { $desbloqueo[0] = 7; } if ($model_inicial['junio'] == NULL && ($hoy['mon'] == 6 && $hoy['mday'] >= 5 || $hoy['mon'] > 6)) { $desbloqueo[0] = 6; } if ($model_inicial['mayo'] == NULL && ($hoy['mon'] == 5 && $hoy['mday'] >= 5 || $hoy['mon'] > 5)) { $desbloqueo[0] = 5; } if ($model_inicial['abril'] == NULL && ($hoy['mon'] == 4 && $hoy['mday'] >= 5 || $hoy['mon'] > 4)) { $desbloqueo[0] = 4; } if ($model_inicial['marzo'] == NULL && ($hoy['mon'] == 3 && $hoy['mday'] >= 5 || $hoy['mon'] > 3)) { $desbloqueo[0] = 3; } if ($model_inicial['febrero'] == NULL && ($hoy['mon'] == 2 && $hoy['mday'] >= 5 || $hoy['mon'] > 2)) { $desbloqueo[0] = 2; } //verificamos si desde el backend se le dio permiso para habilitar campos $permisos_espe = AccionCentralizadaDesbloqueoMes::find()->where(['id_ejecucion' => $model_inicial['id']])->asArray()->All(); if ($permisos_espe != "") { foreach ($permisos_espe as $key) { // se cargan los meses que se le dio permiso de carga $desbloqueo[$key['mes']] = '1'; } } $model = $this->findModel($model_inicial['id']); $total_cargado = $model->enero + $model->febrero + $model->marzo + $model->abril + $model->mayo + $model->junio + $model->julio + $model->agosto + $model->septiembre + $model->octubre + $model->noviembre + $model->diciembre; } //fin else modelo con datos if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['create', 'id' => $id, 'id_localizacion' => $id_localizacion]); } else { return $this->render('create', ['model' => $model, 'model_programacion' => $model_programacion, 'total' => $total, 'desbloqueo' => $desbloqueo, 'total_cargado' => $total_cargado]); } }