/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Solicitud::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, 'requisicion_did' => $this->requisicion_did, 'proveedor_did' => $this->proveedor_did, 'fecha_f' => $this->fecha_f, 'fechacreacion_ft' => $this->fechacreacion_ft]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { if (Yii::$app->user->identity->rol_id == 2) { $query = Solicitud::find(); } else { $query = Solicitud::find()->joinWith('idEquipo')->joinWith('idArea')->where(['Equipos.id_area' => Yii::$app->user->identity->id_departamento]); } $dataProvider = new ActiveDataProvider(['query' => $query]); //$this->load($params); $dataProvider->sort->attributes['idEquipo.nombre_equipo'] = ['asc' => ['nombre_equipo' => SORT_ASC], 'desc' => ['nombre_equipo' => SORT_DESC]]; $dataProvider->sort->attributes['idArea.nombre_area'] = ['asc' => ['nombre_area' => SORT_ASC], 'desc' => ['areas.nombre_area' => SORT_DESC]]; // 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_solicitud' => $this->id_solicitud, 'id_equipo' => $this->id_equipo, 'id_area' => $this->id_area, 'fecha' => $this->fecha, 'Equipos.nombre_equipo' => $this->idEquipo]); $query->andFilterWhere(['like', 'estado', $this->estado])->andFilterWhere(['like', 'nombre_equipo', $this->idEquipo]); return $dataProvider; }
/** * Finds the Solicitud model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Solicitud the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Solicitud::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getSolicituds() { return $this->hasMany(Solicitud::className(), ['id_equipo' => 'id_equipo']); }
/** * @return \yii\db\ActiveQuery */ public function getSolicitud() { return $this->hasMany(Solicitud::className(), ['requisicion_did' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getSolicituds() { return $this->hasMany(Solicitud::className(), ['proveedor_did' => 'id']); }
public function actionCrear() { PermisosController::permisoDocenteDirectorDecano(); $model = new SolicitudMet(); if ($model->load(Yii::$app->request->post())) { $tableviaje = new Viaje(); $tableviaje->ORIGEN_VIAJE = $model->origen; $tableviaje->FECHA_INICIO_DIRECCION = $model->anhoi . '-' . $model->mesi . '-' . $model->diai . ' ' . '00:' . '00:' . '01'; $tableviaje->FECHA_TERMINO_DIRECCION = $model->anhot . '-' . $model->mest . '-' . $model->diat . ' ' . '23:' . '59:' . '59'; $tableviaje->insert(); $ultimoidviaje = solicitudMet::ultimoID(); if ($model->check1 == 1) { $tabledestino = new Destino(); $tabledestino->ID_VIAJE = $ultimoidviaje; $tabledestino->DURACION_VIAJE_DIAS = $model->duracion1; $tabledestino->MEDIO_DE_TRANSPORTE = $model->transporte1; $tabledestino->CIUDAD_DESTINO = $model->ciudad1; $tabledestino->PAIS_DESTINO = $model->pais1; $tabledestino->insert(); } else { $viaje = Viaje::find()->where(['ID_VIAJE' => $ultimoidviaje])->one(); $viaje->delete(); $tablesolicitud = new Solicitud(); $msg = '<div class="alert alert-warning" role="alert"><strong>ERROR!</strong> No se envió la solicitud, ingrese datos válidos.</div>'; $modelsolicitud = $tablesolicitud->find()->where(['ID_USUARIO' => Yii::$app->user->identity->ID_USUARIO])->all(); return $this->render('index', ['model' => $modelsolicitud, 'msg' => $msg]); } if ($model->check2 == 1) { if ($model->duracion2 != null && $model->transporte2 != null && $model->ciudad2 != null && $model->pais2 != null) { $tabledestino2 = new Destino(); $tabledestino2->ID_VIAJE = $ultimoidviaje; $tabledestino2->DURACION_VIAJE_DIAS = $model->duracion2; $tabledestino2->MEDIO_DE_TRANSPORTE = $model->transporte2; $tabledestino2->CIUDAD_DESTINO = $model->ciudad2; $tabledestino2->PAIS_DESTINO = $model->pais2; $tabledestino2->insert(); } else { Destino::deleteAll("ID_VIAJE=" . $ultimoidviaje); $viaje = Viaje::find()->where(['ID_VIAJE' => $ultimoidviaje])->one(); $viaje->delete(); $tablesolicitud = new Solicitud(); $msg = '<div class="alert alert-danger" role="alert"><strong>ERROR!</strong> No se envió la solicitud, ingrese datos válidos.</div>'; $modelsolicitud = $tablesolicitud->find()->where(['ID_USUARIO' => Yii::$app->user->identity->ID_USUARIO])->all(); return $this->render('index', ['model' => $modelsolicitud, 'msg' => $msg]); } } if ($model->check3 == 1) { if ($model->duracion3 != null && $model->transporte3 != null && $model->ciudad3 != null && $model->pais3 != null) { $tabledestino3 = new Destino(); $tabledestino3->ID_VIAJE = $ultimoidviaje; $tabledestino3->DURACION_VIAJE_DIAS = $model->duracion3; $tabledestino3->MEDIO_DE_TRANSPORTE = $model->transporte3; $tabledestino3->CIUDAD_DESTINO = $model->ciudad3; $tabledestino3->PAIS_DESTINO = $model->pais3; $tabledestino3->insert(); } else { Destino::deleteAll("ID_VIAJE=" . $ultimoidviaje); $viaje = Viaje::find()->where(['ID_VIAJE' => $ultimoidviaje])->one(); $viaje->delete(); $tablesolicitud = new Solicitud(); $msg = '<div class="alert alert-danger" role="alert"><strong>ERROR!</strong> No se envió la solicitud, ingrese datos válidos.</div>'; $modelsolicitud = $tablesolicitud->find()->where(['ID_USUARIO' => Yii::$app->user->identity->ID_USUARIO])->all(); return $this->render('index', ['model' => $modelsolicitud, 'msg' => $msg]); } } if ($model->check4 == 1) { if ($model->duracion4 != null && $model->transporte4 != null && $model->ciudad4 != null && $model->pais4 != null) { $tabledestino4 = new Destino(); $tabledestino4->ID_VIAJE = $ultimoidviaje; $tabledestino4->DURACION_VIAJE_DIAS = $model->duracion4; $tabledestino4->MEDIO_DE_TRANSPORTE = $model->transporte4; $tabledestino4->CIUDAD_DESTINO = $model->ciudad4; $tabledestino4->PAIS_DESTINO = $model->pais4; $tabledestino4->insert(); } else { Destino::deleteAll("ID_VIAJE=" . $ultimoidviaje); $viaje = Viaje::find()->where(['ID_VIAJE' => $ultimoidviaje])->one(); $viaje->delete(); $tablesolicitud = new Solicitud(); $msg = '<div class="alert alert-danger" role="alert"><strong>ERROR!</strong> No se envió la solicitud, ingrese datos válidos.</div>'; $modelsolicitud = $tablesolicitud->find()->where(['ID_USUARIO' => Yii::$app->user->identity->ID_USUARIO])->all(); return $this->render('index', ['model' => $modelsolicitud, 'msg' => $msg]); } } if ($model->check5 == 1) { if ($model->duracion5 != null && $model->transporte5 != null && $model->ciudad5 != null && $model->pais5 != null) { $tabledestino5 = new Destino(); $tabledestino5->ID_VIAJE = $ultimoidviaje; $tabledestino5->DURACION_VIAJE_DIAS = $model->duracion5; $tabledestino5->MEDIO_DE_TRANSPORTE = $model->transporte5; $tabledestino5->CIUDAD_DESTINO = $model->ciudad5; $tabledestino5->PAIS_DESTINO = $model->pais5; $tabledestino5->insert(); } else { Destino::deleteAll("ID_VIAJE=" . $ultimoidviaje); $viaje = Viaje::find()->where(['ID_VIAJE' => $ultimoidviaje])->one(); $viaje->delete(); $tablesolicitud = new Solicitud(); $msg = '<div class="alert alert-danger" role="alert"><strong>ERROR!</strong> No se envió la solicitud, ingrese datos válidos.</div>'; $modelsolicitud = $tablesolicitud->find()->where(['ID_USUARIO' => 1])->all(); return $this->render('index', ['model' => $modelsolicitud, 'msg' => $msg]); } } $tablesolicitud = new Solicitud(); $tablesolicitud->ID_USUARIO = Yii::$app->user->identity->ID_USUARIO; $tablesolicitud->ID_TIPO_DE_VIAJE = $model->idtipoviaje; $tablesolicitud->ID_VIAJE = $ultimoidviaje; $tablesolicitud->FECHA_SOLICITUD = date("Y-m-d H:i:s"); $tablesolicitud->ID_ESTADO = 1; $tablesolicitud->CUERPO_SOLICITUD = $model->cuerpo; $tablesolicitud->insert(); $tablesolicitud = new Solicitud(); $msg = '<div class="alert alert-success" role="alert"><strong>Enviada!</strong> Solicitud enviada.</div>'; $modelsolicitud = $tablesolicitud->find()->where(['ID_USUARIO' => Yii::$app->user->identity->ID_USUARIO])->all(); return $this->render('index', ['model' => $modelsolicitud, 'msg' => $msg]); } else { $msg = null; $tablesolicitud = new TipoViaje(); $modeltipos = $tablesolicitud->find()->all(); return $this->render('crear-solicitud', ['model' => $model, 'tipos' => $modeltipos, 'msg' => $msg]); } }
/** * @return \yii\db\ActiveQuery */ public function getSolicitudD() { return $this->hasOne(Solicitud::className(), ['id' => 'solicitud_did']); }
public function addsolicitud() { //echo $_POST["tipo_solicitud"];exit; if (isset($_POST["tipo_solicitud"])) { if ($_POST["tipo_solicitud"] == 0) { $responsable = $_SESSION["id_usuario"]; $solicitante = $_POST["solicita"]; $hora_solicitud = $_POST["dtp_input3"]; $tipo_solicitud = $_POST["tipo_solicitud"]; $id_investigador = $_POST["investigador"]; $id_documento = $_POST["id_documento"]; $l_formato = $_POST["formato"]; $l_fec_entrega = $_POST["dtp_input31"]; $l_hora_entrega = $_POST["dtp_input31h"]; $l_fec_devol = $_POST["fec_devol_lectura_hidden"]; $l_hora_devol = $_POST["dtp_input32h"]; $d_fec_hora_entrega = NULL; $d_fec_hora_devol = NULL; $c_fec_hora_entrega = NULL; $c_fec_hora_devol = NULL; $e_fec_inicio = NULL; $e_fec_fin = NULL; $e_lugar = NULL; $e_motivo = NULL; $v_fec_entrega = NULL; $v_fec_devol = NULL; $v_hora_entrega = NULL; $v_hora_devol = NULL; $v_institucion = NULL; $v_cant_alumnos = NULL; } if ($_POST["tipo_solicitud"] == 1) { $responsable = $_SESSION["id_usuario"]; $solicitante = $_POST["solicita"]; $hora_solicitud = $_POST["dtp_input3"]; $tipo_solicitud = $_POST["tipo_solicitud"]; $id_investigador = NULL; $id_documento = $_POST["id_documento"]; $l_formato = NULL; $l_fec_entrega = NULL; $l_hora_entrega = NULL; $l_fec_devol = NULL; $l_hora_devol = NULL; $d_fec_hora_entrega = $_POST["dtp_input311"]; $d_fec_hora_devol = $_POST["dtp_input322"]; $c_fec_hora_entrega = NULL; $c_fec_hora_devol = NULL; $e_fec_inicio = NULL; $e_fec_fin = NULL; $e_lugar = NULL; $e_motivo = NULL; $v_fec_entrega = NULL; $v_fec_devol = NULL; $v_hora_entrega = NULL; $v_hora_devol = NULL; $v_institucion = NULL; $v_cant_alumnos = NULL; } if ($_POST["tipo_solicitud"] == 2) { $responsable = $_SESSION["id_usuario"]; $solicitante = $_POST["solicita"]; $hora_solicitud = $_POST["dtp_input3"]; $tipo_solicitud = $_POST["tipo_solicitud"]; $id_investigador = NULL; $id_documento = $_POST["id_documento"]; $l_formato = NULL; $l_fec_entrega = NULL; $l_hora_entrega = NULL; $l_fec_devol = NULL; $l_hora_devol = NULL; $d_fec_hora_entrega = NULL; $d_fec_hora_devol = NULL; $c_fec_hora_entrega = $_POST["dtp_conserva1"]; $c_fec_hora_devol = $_POST["dtp_conserva2"]; $e_fec_inicio = NULL; $e_fec_fin = NULL; $e_lugar = NULL; $e_motivo = NULL; $v_fec_entrega = NULL; $v_fec_devol = NULL; $v_hora_entrega = NULL; $v_hora_devol = NULL; $v_institucion = NULL; $v_cant_alumnos = NULL; } if ($_POST["tipo_solicitud"] == 3) { $responsable = $_SESSION["id_usuario"]; $solicitante = $_POST["solicita"]; $hora_solicitud = $_POST["dtp_input3"]; $tipo_solicitud = $_POST["tipo_solicitud"]; $id_investigador = NULL; $id_documento = $_POST["id_documento"]; $l_formato = NULL; $l_fec_entrega = NULL; $l_hora_entrega = NULL; $l_fec_devol = NULL; $l_hora_devol = NULL; $d_fec_hora_entrega = NULL; $d_fec_hora_devol = NULL; $c_fec_hora_entrega = NULL; $c_fec_hora_devol = NULL; $e_fec_inicio = $_POST["dtp_expo1"]; $e_fec_fin = $_POST["dtp_expo2"]; $e_lugar = $_POST["lugarexpo"]; $e_motivo = $_POST["motivoexpo"]; $v_fec_entrega = NULL; $v_fec_devol = NULL; $v_hora_entrega = NULL; $v_hora_devol = NULL; $v_institucion = NULL; $v_cant_alumnos = NULL; } if ($_POST["tipo_solicitud"] == 4) { $responsable = $_SESSION["id_usuario"]; $solicitante = $_POST["solicita"]; $hora_solicitud = $_POST["dtp_input3"]; $tipo_solicitud = $_POST["tipo_solicitud"]; $id_investigador = NULL; $id_documento = $_POST["id_documento"]; $l_formato = NULL; $l_fec_entrega = NULL; $l_hora_entrega = NULL; $l_fec_devol = NULL; $l_hora_devol = NULL; $d_fec_hora_entrega = NULL; $d_fec_hora_devol = NULL; $c_fec_hora_entrega = NULL; $c_fec_hora_devol = NULL; $e_fec_inicio = NULL; $e_fec_fin = NULL; $e_lugar = NULL; $e_motivo = NULL; $v_fec_entrega = $_POST["dtp_visita_fec1"]; $v_fec_devol = $_POST["dtp_visita_fec2"]; $v_hora_entrega = $_POST["dtp_visita_hora1"]; $v_hora_devol = $_POST["dtp_visita_hora2"]; $v_institucion = $_POST["institucion"]; $v_cant_alumnos = $_POST["alumnos"]; } } $solicitud = Solicitud::addSolicitud($responsable, $solicitante, $hora_solicitud, $tipo_solicitud, $id_investigador, $id_documento, $l_formato, $l_fec_devol, $l_fec_entrega, $l_hora_entrega, $l_hora_devol, $d_fec_hora_entrega, $d_fec_hora_devol, $c_fec_hora_entrega, $c_fec_hora_devol, $e_fec_inicio, $e_fec_fin, $e_lugar, $e_fec_fin, $e_lugar, $e_motivo, $v_fec_entrega, $v_fec_devol, $v_hora_entrega, $v_hora_devol, $v_institucion, $v_cant_alumnos); if ($solicitud) { View::set("mensaje", "<div id=\"mensaje-de-exito\" class=\"alert alert-success\" role=\"alert\" >\n \t\t\t\t<strong>Logrado!!</strong> Se ha guardado con exito.\n \t\t \t\t </div>"); $users = Users::getAll(); $docs = Documentos::getAll(); $invs = Investigadores::getAll(); View::set("users", $users["usuarios"]); View::set("docs", $docs["documentos"]); View::set("invs", $invs["investigador"]); View::render("salida"); } else { View::set("mensaje", "<div id=\"mensaje-de-error\" class=\"alert alert-danger\" role=\"alert\">\n <strong>Error!</strong> Se ha producido un error. Vuelva a intentarlo, asegurese de completar todos los campos, son obligatorios.<br>\n \t\t\t\t Tenga en cuenta que para Lectura y Visita Guiada la fecha de entrega y devolucion deben ser las mismas.<br>\n \t\t\t\t Las fechas y horas de entrega no pueden ser posteriores a las de devolucion.\n </div>"); $users = Users::getAll(); $docs = Documentos::getAll(); $invs = Investigadores::getAll(); View::set("users", $users["usuarios"]); View::set("docs", $docs["documentos"]); View::set("invs", $invs["investigador"]); View::render("salida"); } }