public function general($request, $id)
 {
     $requestMethod = $request->method();
     switch ($requestMethod) {
         case 'PUT':
             $classroom = Classroom::find($id);
             $functionGetRules = 'getRulesUpdate';
             $code = 'e-g';
             break;
         case 'POST':
             $classroom = new Classroom();
             $functionGetRules = 'getRulesCreate';
             $code = 'c-g';
             break;
     }
     $input = Input::all();
     if ($request->ajax()) {
         $data = $this->val($classroom, $functionGetRules);
         return $data;
     } else {
         $classroom->fill($input);
         $blockSelected = Block::find($input['block_id'])->name;
         $classroom->location = explode(' ', $blockSelected)[1] . ' - ' . $input['location'];
         //$classroom->location = explode(' ', $input['block'])[1].' - '.$input['location'];
         $classroom->save();
     }
     if (Input::get('nAs') == 'true') {
         return Redirect::to('classroom/create')->with('error', $code);
     }
     return Redirect::to(URL::to('datatables', ['salones', 'see']))->with('error', $code);
 }
 public function general($request, $id)
 {
     $requestMethod = $request->method();
     switch ($requestMethod) {
         case 'PUT':
             $block = Block::find($id);
             $functionGetRules = 'getRulesUpdate';
             $code = 'e-g';
             break;
         case 'POST':
             $block = new Block();
             $functionGetRules = 'getRulesCreate';
             $code = 'c-g';
             break;
     }
     $input = Input::all();
     if ($request->ajax()) {
         $data = $this->val($block, $functionGetRules);
         return $data;
     } else {
         $this->updateClassroom($id, $input['name']);
         $block->fill($input);
         $block->save();
     }
     if (Input::get('nAs') == 'true') {
         return Redirect::to('block/create')->with('error', $code);
     }
     return Redirect::to(URL::to('datatables', ['bloques', 'see']))->with('error', $code);
 }
Esempio n. 3
0
 public function dataSelection($room, $block, $year, $month, $day, $atention, $medic)
 {
     $date = $year . "-" . $month . "-" . $day;
     $checkRoom = ReservationInfo::where('reservationDate', '=', $date)->where('block_id', '=', $block)->where('room', '=', $room)->count();
     if ($checkRoom == 0) {
         //revisar si el medico tiene ocupada esas horas
         $findMedicConflict = Reservation::where('medic_id', $medic)->where('reservationDate', $date)->get();
         $checkMedic = 0;
         foreach ($findMedicConflict as $register) {
             $checkMedic += $register->ReservationsInfo->where('block_id', $block)->count();
         }
         if ($checkMedic == 0) {
             //
             $atention = Atention::find($atention);
             $numberOfBlocks = $atention->block_numbers;
             for ($i = 1; $i < $numberOfBlocks; $i++) {
                 $nextBlock = $block + $i;
                 $checkRoom = ReservationInfo::where('reservationDate', '=', $date)->where('block_id', '=', $nextBlock)->where('room', '=', $room)->count();
                 if ($checkRoom > 0) {
                     //cortar con un return, ya que hay una hora tomada despues
                     //que impide hacer la reserva en el bloque seleccionado
                     return response()->json(['estado' => 'invalido', 'mensaje' => 'La sala esta ocupada']);
                 }
                 $checkMedic = 0;
                 foreach ($findMedicConflict as $register) {
                     $checkMedic += $register->ReservationsInfo->where('block_id', $nextBlock)->count();
                 }
                 if ($checkMedic > 0) {
                     //medico ocupado
                     return response()->json(['estado' => 'invalido', 'mensaje' => 'El medico esta ocupado en uno de los bloques']);
                 }
             }
             $initialBlock = Block::find($block);
             $lastBlockId = $block + $numberOfBlocks - 1;
             $encontro = false;
             $lastBlock;
             while ($encontro == false) {
                 if (!($lastBlock = Block::find($lastBlockId))) {
                     $lastBlockId--;
                 } else {
                     $encontro = true;
                 }
             }
             $respuesta = ['estado' => 'valido', 'inicio' => $initialBlock->startBlock, 'fin' => $lastBlock->finishBlock, 'bloques' => $numberOfBlocks, 'blolqueInicial' => $initialBlock->id, 'bloqueFinal' => $lastBlock->id];
             return response()->json($respuesta);
         } else {
             //el medico esta ocupado en ese bloque
             return response()->json(['estado' => 'invalido', 'mensaje' => 'El medico esta ocupado a esa hora']);
         }
     } else {
         //la sala esta ocupada en ese horario
         return response()->json(['estado' => 'invalido', 'mensaje' => 'La sala esta ocupada a esa hora']);
     }
 }
Esempio n. 4
0
 public function updateBlock($slug, $blockid, $value)
 {
     if ($this->lock) {
         return false;
     }
     $blocks = Block::find($blockid);
     $blocks = $this->blocks()->where('id', $blockid);
     if ($blocks->count() == 0) {
         return false;
     }
     $block = $blocks->first();
     if (alphaID($block->swatch_id) != $slug) {
         return false;
     }
     return $block->iterate($value);
 }