public function actionCreate() { $model = new FormAlumnos(); $msg = null; if ($model->load(Yii::$app->request->post())) { if ($model->validate()) { $table = new Alumnos(); $table->nombre = $model->nombre; $table->apellidos = $model->apellidos; $table->clase = $model->clase; $table->nota_final = $model->nota_final; if ($table->insert()) { $msg = "registro exitoso"; $model->nombre = null; $model->apellidos = null; $model->clase = null; $model->nota_final = null; } else { $msg = "no se pudo completar el registro"; } } else { $model->getErrors(); } } return $this->render("create", ['model' => $model, 'msg' => $msg]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Alumnos::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]); $query->andFilterWhere(['like', 'p_nombre', $this->p_nombre])->andFilterWhere(['like', 's_nombre', $this->s_nombre])->andFilterWhere(['like', 'p_apellido', $this->p_apellido])->andFilterWhere(['like', 's_apellido', $this->s_apellido])->andFilterWhere(['like', 'nacimiento', $this->nacimiento])->andFilterWhere(['like', 'rut', $this->rut])->andFilterWhere(['like', 'mail', $this->mail])->andFilterWhere(['like', 't_fijo', $this->t_fijo])->andFilterWhere(['like', 't_celular', $this->t_celular])->andFilterWhere(['like', 'direccion', $this->direccion])->andFilterWhere(['like', 'comuna', $this->comuna])->andFilterWhere(['like', 'servicio', $this->servicio])->andFilterWhere(['like', 'funcion', $this->funcion])->andFilterWhere(['like', 'horario', $this->horario]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Alumnos::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_alumno' => $this->id_alumno, 'clase' => $this->clase, 'nota_final' => $this->nota_final]); $query->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'apellidos', $this->apellidos]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Alumnos::find(); $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(['idalumno' => $this->idalumno, 'apellido', $this->apellido, 'nombre', $this->nombre, 'cuil' => $this->cuil, 'fechanac' => $this->fechanac, 'idsexo' => $this->idsexo, 'idsalud' => $this->idsalud, 'nacion', $this->nacion, 'observaciones', $this->observaciones, 'discapacidad' => $this->discapacidad, 'originario' => $this->originario, 'grufam' => $this->grufam, 'idpropietario' => $this->idpropietario, 'idinstruccion' => $this->idinstruccion, 'idocupacion' => $this->idocupacion, 'montotal' => $this->montotal, 'becario' => $this->becario, 'idcarrera' => $this->idcarrera, 'anioingreso' => $this->anioingreso, 'anioingresou' => $this->anioingresou, 'asistencia' => $this->asistencia, 'promedio' => $this->promedio, 'idconvocatoria' => $this->idconvocatoria]); $query->andFilterWhere(['=', 'dni', $this->dni]); $dataProvider = new ActiveDataProvider(['query' => $query]); if ($this->dni != '') { return $dataProvider; } else { return true; } }
public function actionCreate() { $model = new FormAlumnos(); $msg = null; if ($model->load(Yii::$app->request->post())) { if ($model->validate()) { $table = new Alumnos(); $table->nombre = $model->nombre; $table->apellidos = $model->apellidos; $table->clase = $model->clase; $table->nota_final = $model->nota_final; if ($table->insert()) { $msg = "Enhorabuena registro guardado correctamente"; $model->nombre = null; $model->apellidos = null; $model->clase = null; $model->nota_final = null; } else { $msg = "Ha ocurrido un error al insertar el registro"; } } else { $model->getErrors(); } } return $this->render("create", ['model' => $model, 'msg' => $msg]); }
public function actionCreate() { $model = new FormAlumnos(); $msg = null; //Si el formulario es enviado por method post if ($model->load(Yii::$app->request->post())) { //si pasa las validaciones if ($model->validate()) { /* Con la instancia de la table alumno, en el objeto queda guardaa todas las columnas que tenga la tabla */ $table = new Alumnos(); /* Le asignamos a cada columna su valor */ $table->nombre = $model->nombre; $table->apellidos = $model->apellidos; $table->clase = $model->clase; $table->nota_final = $model->nota_final; /* Si insertamos los datos correctamente */ if ($table->insert()) { $msg = "Registro guardado correctamente"; /* Limpiamos los campos */ $model->nombre = null; $model->apellidos = null; $model->clase = null; $model->nota_final = null; } else { $msg = "En estos no se puede registrar al alumno, intentelo mas tarde"; } } else { $model->getErrors(); } } return $this->render("create", ['model' => $model, 'msg' => $msg]); }
/** * Finds the Alumnos model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Alumnos the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Alumnos::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionCreate() { $model = new FormAlumnos(); $msg = null; if ($model->load(Yii::$app->request->post())) { if ($model->validate()) { $table = new Alumnos(); $table->nombre = $model->nombre; $table->apellidos = $model->apellidos; $table->clase = $model->clase; $table->nota_final = $model->nota_final; if ($table->insert()) { $msg = "Registros guardados exitosamente!"; $model->nombre = null; $model->apellidos = null; $model->clase = null; $model->nota_final = null; \Yii::$app->getSession()->setFlash('success', $msg); } else { $msg = "Ha ocurrido un error al insertar el registro"; \Yii::$app->getSession()->setFlash('danger', $msg); } } else { $model->getErrors(); } } return $this->render('create', ['model' => $model]); }
/** * @return \yii\db\ActiveQuery */ public function getAlumnos() { return $this->hasOne(Alumnos::className(), ['id_horario' => 'horario']); }
public function actionCreate() { $model = new FormAlumnos(); $msg = null; if ($model->load(Yii::$app->request->post())) { if ($model->validate()) { $table = new Alumnos(); $table->nombre = $model->nombre; $table->apellidos = $model->apellidos; $table->clase = $model->clase; $table->note_final = $model->note_final; if ($table->insert()) { $msg = "Enhorabuena, Registro de alumno exitoso!!!"; $model->nombre = null; $model->apellidos = null; $model->clase = null; $model->note_final = null; } else { $msg = "Error, Ha ocurrido algun problema al tratar de insertar datos de alumno."; } } else { $model->getErrors(); } } return $this->render("create", ["model" => $model, "msg" => $msg]); }