コード例 #1
0
ファイル: EventController.php プロジェクト: SEODiaz/SIGA-4
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     if (Request::ajax()) {
         $response = array();
         $evento = new Evento();
         $evento->start = Input::get('fecha_hora');
         $evento->nombre = Input::get('nombre');
         $evento->descripcion = Input::get('descripcion');
         $evento->ambito_evento = Input::get('ambito_evento');
         $evento->profesores_id = Auth::user()->id;
         if ($evento->validate()) {
             if (empty(Input::get('asunto'))) {
                 $evento->save();
                 return Response::json(array('success' => true));
             } else {
                 $reunion = new Reunion();
                 $reunion->asunto = Input::get('asunto');
                 $reunion->descripcion = Input::get('descripcion_reunion');
                 if (empty(Input::get('ordinaria'))) {
                     $reunion->ordinaria = 0;
                 } else {
                     $reunion->ordinaria = 1;
                 }
                 if ($reunion->validate()) {
                     $evento->save();
                     $reunion->eventos_id = $evento->id;
                     $reunion->save();
                     return Response::json(array('success' => true));
                 } else {
                     return Response::json(array('success' => false, 'errores' => $reunion->errors()->toArray()));
                 }
             }
         } else {
             return Response::json(array('success' => false, 'errores' => $evento->errors()->toArray()));
         }
     } else {
         return Response::json(array('success' => false));
     }
 }
コード例 #2
0
ファイル: sgrEvento.php プロジェクト: juanantoniofr/sgr
 public function edit()
 {
     $result = array('error' => false, 'msgSuccess' => '', 'idsDeleted' => array(), 'msgErrors' => array());
     //Controlar errores en el formulario
     $testDataForm = new Evento();
     if (!$testDataForm->validate(Input::all())) {
         $result['error'] = true;
         $result['msgErrors'] = $testDataForm->errors();
     } else {
         //si el usuario es alumno: comprobamos req2 (MAX HORAS = 12 a la semana en cualquier espacio o medio )
         if (Auth::user()->isUser() && $this->superaHoras()) {
             $result['error'] = true;
             $error = array('hFin' => 'Se supera el máximo de horas a la semana.. (12h)');
             $result['msgErrors'] = $error;
         } else {
             $idSerie = Input::get('idSerie');
             $fechaInicio = Input::get('fInicio');
             $fechaFin = Input::get('fFin');
             //Borrar todos los eventos a modificar
             $event = Evento::find(Input::get('idEvento'));
             if (Input::get('id_recurso') == 0) {
                 Evento::where('evento_id', '=', Input::get('idSerie'))->forceDelete();
             } else {
                 Evento::where('evento_id', '=', Input::get('idSerie'))->where('recurso_id', '=', Input::get('id_recurso'))->forceDelete();
             }
             //Añadir los nuevos
             $result['idEvents'] = $this->editEvents($fechaInicio, $fechaFin, $idSerie);
             //Msg confirmación al usuario (edición de evento)
             $newEvent = Evento::Where('evento_id', '=', $idSerie)->first();
             if ($newEvent->estado == 'aprobada') {
                 $result['msgSuccess'] = '<strong class="alert alert-info" > Reserva registrada con éxito. Puede <a target="_blank" href="' . route('justificante', array('idEventos' => $newEvent->evento_id)) . '">imprimir comprobante</a> de la misma si lo desea.</strong>';
             }
             if ($newEvent->estado == 'pendiente') {
                 $result['msgSuccess'] = '<strong class="alert alert-danger" >Reserva pendiente de validación. Puede <a target="_blank" href="' . route('justificante', array('idEventos' => $newEvent->evento_id)) . '">imprimir comprobante</a> de la misma si lo desea.</strong>';
             }
             //notificar a validadores si espacio requiere validación
             if ($event->recurso->validacion()) {
                 $sgrMail = new sgrMail();
                 $sgrMail->notificaEdicionEvento($newEvent);
             }
         }
         //fin else
     }
     return $result;
 }