예제 #1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $plan = Plan::find($id);
     $profesores = Profesor::orderBy('apellido', 'asc')->get();
     $sele = $plan->profesores_id;
     return view('planes.edit', ['plan' => $plan, 'profesores' => $profesores, 'sele' => $sele]);
 }
예제 #2
0
 function nombreResponsable()
 {
     $bec = Becario::where('cve_uaslp', $this->cve_responsable)->first();
     if ($bec) {
         return $bec->alumno()->nombreCompleto();
     }
     $prof = Profesor::where('rpe', $this->cve_responsable)->first();
     if ($prof) {
         return $prof->nombreCompleto();
     }
     return "";
 }
예제 #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Profesor::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, 'edad' => $this->edad]);
     $query->andFilterWhere(['like', 'Nombre', $this->Nombre]);
     return $dataProvider;
 }
예제 #4
0
 public function getShowProfesor($profesor_id)
 {
     $user = User::fromToken();
     $year = Year::datos_basicos($user->year_id);
     $asignaturas = Profesor::asignaturas($user->year_id, $profesor_id);
     $periodos = Periodo::where('year_id', '=', $user->year_id)->get();
     $year->periodos = $periodos;
     $profesor = Profesor::detallado($profesor_id);
     foreach ($asignaturas as $keyAsig => $asignatura) {
         $alumnos = Grupo::alumnos($asignatura->grupo_id);
         $asignatura->nombres_profesor = $profesor->nombres_profesor;
         $asignatura->apellidos_profesor = $profesor->apellidos_profesor;
         $asignatura->foto_nombre = $profesor->foto_nombre;
         $asignatura->foto_id = $profesor->foto_id;
         $asignatura->sexo = $profesor->sexo;
         $asignatura->periodosProm = Periodo::where('year_id', '=', $user->year_id)->get();
         // A cada alumno le daremos los periodos y la definitiva de cada periodo
         foreach ($alumnos as $keyAl => $alumno) {
             $periodosTemp = Periodo::where('year_id', '=', $user->year_id)->get();
             foreach ($periodosTemp as $keyPer => $periodo) {
                 // Unidades y subunidades de la asignatura en el periodo
                 $asignaturaTemp = Asignatura::find($asignatura->asignatura_id);
                 $asignaturaTemp->unidades = Unidad::deAsignatura($asignaturaTemp->id, $periodo->id);
                 foreach ($asignaturaTemp->unidades as $unidad) {
                     $unidad->subunidades = Subunidad::deUnidad($unidad->unidad_id);
                 }
                 // Traemos las notas de esta asignatura segun las unidades y subunidades calculadas arriba
                 Asignatura::calculoAlumnoNotas($asignaturaTemp, $alumno->alumno_id);
                 $periodo->nota_asignatura = $asignaturaTemp->nota_asignatura;
                 unset($asignaturaTemp);
             }
             $alumno->periodos = $periodosTemp;
             unset($periodosTemp);
             foreach ($asignatura->periodosProm as $keyPer => $periodo) {
                 if (!$periodo->sumatoria) {
                     $periodo->sumatoria = 0;
                 }
                 foreach ($alumno->periodos as $keyPerAl => $periodo_alum) {
                     if ($periodo_alum->id == $periodo->id) {
                         $periodo->sumatoria += $periodo_alum->nota_asignatura;
                     }
                 }
             }
         }
         $asignatura->alumnos = $alumnos;
     }
     return array($year, $asignaturas);
 }
예제 #5
0
 function dameNombre(Request $r)
 {
     $clave = $r->input('clave_profesor');
     $res = ['success' => false];
     try {
         $profesor = Profesor::find($clave);
         $res['nombre'] = "";
         if ($profesor != null) {
             $res['nombre'] = $profesor->nombreCompleto();
             $res['success'] = true;
         }
     } catch (Exception $e) {
         $res['msj'] = $e->getMessage();
     }
     return response()->json($res);
 }
 public function postInscribirProfesores()
 {
     $user = User::fromToken();
     $votacion = VtVotacion::actual($user);
     $profesores = Profesor::fromyear($user->year_id);
     $participantes = [];
     for ($i = 0; $i < count($profesores); $i++) {
         $partic = VtParticipante::where('user_id', $profesores[$i]->user_id)->where('votacion_id', $votacion->id)->first();
         if (!$partic) {
             if (!$profesores[$i]->user_id) {
                 $dirtyName = $profesores[$i]->nombres;
                 $name = preg_replace('/\\s+/', '', $dirtyName);
                 $usuario = new User();
                 $usuario->username = $name;
                 $usuario->password = '******';
                 $usuario->is_superuser = false;
                 $usuario->is_active = true;
                 $usuario->save();
                 $profe = Profesor::find($profesores[$i]->id);
                 $profe->user_id = $usuario->id;
                 $profe->save();
                 $profesores[$i]->user_id = $profe->user_id;
             }
             $partic_trash = VtParticipante::onlyTrashed()->where('user_id', $profesores[$i]->user_id)->where('votacion_id', $votacion->id)->first();
             if ($partic_trash) {
                 $participante = $partic_trash;
                 $participante->restore();
             } else {
                 $participante = new VtParticipante();
                 $participante->user_id = $profesores[$i]->user_id;
                 $participante->votacion_id = $votacion->id;
                 $participante->locked = false;
                 $participante->intentos = 0;
                 $participante->save();
             }
             array_push($participantes, $participante);
         }
     }
     return $participantes;
 }
예제 #7
0
 public function actionModificar()
 {
     $msg = null;
     $model = new ValidarCategoria();
     if (isset($_REQUEST['id_categoria'])) {
         $model->id_categoria = $_REQUEST['id_categoria'];
         $table = Categoria::findOne($model->id_categoria);
         $model->nombre = $table->nombre;
         $model->edad_min = $table->edad_minima;
         $model->edad_max = $table->edad_maxima;
         $model->deporte = $table->id_deporte;
         $model->profesor_suplente = $table->id_profesor_suplente;
         $model->profesor_titular = $table->id_profesor_titular;
     }
     if ($model->load(Yii::$app->request->post()) && Yii::$app->request->isAjax) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             $table = Categoria::findOne($model->id_categoria);
             $table->nombre = $model->nombre;
             $table->edad_maxima = $model->edad_max;
             $table->edad_minima = $model->edad_min;
             $table->id_deporte = $model->deporte;
             $table->id_profesor_suplente = $model->profesor_suplente;
             $table->id_profesor_titular = $model->profesor_titular;
             if ($table->update()) {
                 $msg = "modificado con exito";
                 $model->nombre = NULL;
                 $model->edad_min = NULL;
                 $model->edad_max = NULL;
                 $model->deporte = NULL;
                 $model->profesor_suplente = NULL;
                 $model->profesor_titular = NULL;
                 $this->redirect(["categoria/buscar", 'msg' => $msg]);
             }
         }
     }
     $deporte = ArrayHelper::map(Deporte::find()->all(), 'id_deporte', 'nombre');
     $profesor = ArrayHelper::map(Profesor::find()->all(), 'dni', 'nombre');
     return $this->render("modificar_categoria", ['msg' => $msg, 'model' => $model, 'profesor' => $profesor, 'deporte' => $deporte]);
 }
예제 #8
0
 /**
  * Finds the Profesor model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Profesor the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Profesor::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #9
0
 public function deleteDestroy($id)
 {
     $img = ImageModel::findOrFail($id);
     $filename = 'images/perfil/' . $img->nombre;
     // Debería crear un código que impida borrar si la imagen es usada.
     if (File::exists($filename)) {
         File::delete($filename);
         $img->delete();
     } else {
         return 'No se encuentra la imagen a eliminar. ' . $img->nombre;
     }
     // Elimino cualquier referencia que otros tengan a esa imagen borrada.
     $alumnos = Alumno::where('foto_id', $id)->get();
     foreach ($alumnos as $alum) {
         $alum->foto_id = null;
         $alum->save();
     }
     $profesores = Profesor::where('foto_id', $id)->get();
     foreach ($profesores as $prof) {
         $prof->foto_id = null;
         $prof->save();
     }
     $acudientes = Acudiente::where('foto_id', $id)->get();
     foreach ($acudientes as $acud) {
         $acud->foto_id = null;
         $acud->save();
     }
     $users = User::where('imagen_id', $id)->get();
     foreach ($users as $user) {
         $user->imagen_id = null;
         $user->save();
     }
     $years = Year::where('logo_id', $id)->get();
     foreach ($years as $year) {
         $year->logo_id = null;
         $year->save();
     }
     $asks = ChangeAsked::where('oficial_image_id', $id)->destroy();
     return $img;
 }
예제 #10
0
 public function putRestore($id)
 {
     $user = User::fromToken();
     $profesor = Profesor::onlyTrashed()->findOrFail($id);
     if ($profesor) {
         $profesor->restore();
     } else {
         return abort(400, 'Profesor no encontrado en la Papelera.');
     }
     return $profesor;
 }
예제 #11
0
 public function getShow($id)
 {
     $grupo = Grupo::findOrFail($id);
     $profesor = Profesor::find($grupo->titular_id);
     $grupo->titular = $profesor;
     $grado = Grado::findOrFail($grupo->grado_id);
     $grupo->grado = $grado;
     return $grupo;
 }
예제 #12
0
 public function actionModificar()
 {
     $this->menu();
     $model = new ValidarEvento();
     $msg = null;
     if (isset($_REQUEST['id_evento'])) {
         if ($_REQUEST['id_evento']) {
             $model->id_evento = $_REQUEST['id_evento'];
             $tabla = Evento::findOne($model->id_evento);
             $model->nombre = $tabla->nombre;
             $model->condicion = $tabla->condicion;
             $model->fecha = $tabla->fecha;
             $model->id_profesor_titular = $tabla->id_profesor_titular;
             $model->id_profesor_suplente = $tabla->id_profesor_suplente;
             $model->id_deporte = $tabla->id_deporte;
             $model->convocados = 1;
         }
     }
     if ($model->load(Yii::$app->request->post()) && Yii::$app->request->isAjax) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post())) {
         $msg = "askdjla";
         if ($model->validate()) {
             $tabla = Evento::findOne($model->id_evento);
             $tabla->nombre = $model->nombre;
             $tabla->condicion = $model->condicion;
             $tabla->fecha = $model->fecha;
             $tabla->id_profesor_titular = $model->id_profesor_titular;
             $tabla->id_profesor_suplente = $model->id_profesor_suplente;
             $tabla->id_deporte = $model->id_deporte;
             if ($tabla->update()) {
                 $msg = "Evento registrado con exito!";
                 $model->nombre = null;
                 $model->condicion = null;
                 $model->fecha = null;
                 $model->id_profesor_titular = null;
                 $model->id_profesor_suplente = null;
                 $model->id_deporte = null;
                 $this->redirect(["evento/buscar", 'msg' => $msg]);
             } else {
                 $msg = "no se pudo actualizar";
             }
         } else {
             $model->getErrors();
         }
     }
     $deporte = ArrayHelper::map(Deporte::find()->all(), 'id_deporte', 'nombre_deporte');
     $profesor = ArrayHelper::map(Profesor::find()->all(), 'dni', 'nombre');
     $categoria = ArrayHelper::map(Categoria::find()->all(), 'id_categoria', 'nombre_categoria');
     $convocados = ArrayHelper::map(Convocados::find()->all(), 'id_lista', 'nombre');
     return $this->render("modificar", ['model' => $model, 'msg' => $msg, "profesor" => $profesor, "categoria" => $categoria, "deporte" => $deporte, "convocados" => $convocados]);
 }
예제 #13
0
 public function getListasignaturasyear($profesor_id, $periodo_id)
 {
     $user = User::fromToken();
     $year = Year::de_un_periodo($periodo_id);
     $asignaturas = Profesor::asignaturas($year->id, $profesor_id);
     foreach ($asignaturas as $asignatura) {
         $asignatura->unidades = Unidad::informacionAsignatura($asignatura->asignatura_id, $periodo_id);
     }
     return $asignaturas;
 }
예제 #14
0
 public function putCambiarfirmaunprofe($profeElegido)
 {
     $profesor = Profesor::findOrFail($profeElegido);
     $profesor->firma_id = Request::input('imgFirmaProfe');
     $profesor->save();
     return $profesor;
 }
예제 #15
0
 public function imprimirSociosxProfesor($plan, $profesor)
 {
     $plan = Plan::find($plan);
     $profesor = Profesor::find($profesor);
     $vista = \View::make('profesores.sociosxprofesorpdf', ['plan' => $plan, 'profesor' => $profesor])->render();
     $pdf = \App::make('dompdf.wrapper');
     $pdf->loadHTML($vista);
     return $pdf->stream('sociosxprofesorpdf');
 }