Example #1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     // controllo campo overbooking -- inserimento predisposto per user Ortopedia
     $value = array('class' => 'form-control', 'required');
     if (!Auth::user()->admin) {
         $value = array('class' => 'form-control', 'readonly');
     }
     // Campo ricerca --- recupera prenotazioni per Cognome
     if (isset($_GET['search']) && $_GET['search'] != '') {
         $query = Input::get('search');
         $tasks = Task::where('cognome', 'LIKE', $query . '%')->orderBy('cognome', 'asc')->get();
         $overbooking = Overbooking::where('cognome', 'LIKE', $query . '%')->get();
         // controllo esistenza record cercato
         if ($tasks->count() > 0) {
             $string = '<h3> Risultato della ricerca: ' . $query . ' </h3><hr>';
             return view('tasks.search', compact('tasks', 'query', 'overbooking', 'none', 'string'));
         } else {
             $none = '<h3> Nessun Risultato Trovato per: ' . $query . ' </h3><hr>';
             return view('tasks.search', compact('tasks', 'query', 'overbooking', 'none', 'string'));
         }
     }
     //conta righe table
     $counter = 1;
     //variabile OGGI index
     $day = Carbon::now('Europe/Rome')->format('d/m/Y');
     //Query OGGI -- Formattazione per inserimento data nel DB
     $today1 = Carbon::now('Europe/Rome')->format('Y-m-d');
     //query prenotazioni odierne
     $tasks = Task::where('data', '=', $today1)->orderBy('cognome', 'asc')->get();
     //query prenotazioni di overbooking odierne
     $overbooking = Overbooking::where('data', '=', $today1)->get();
     // DATEPICKER --- recupera prenotazioni dal calendario
     if (isset($_GET['data']) && $_GET['data'] != '') {
         $query = Input::get('data');
         $data = date_format(date_create_from_format('d/m/Y', $query), 'Y-m-d');
         $tasks = Task::where('data', 'LIKE', '%' . $data . '%')->get();
         $overbooking = Overbooking::where('data', 'LIKE', '%' . $data . '%')->get();
         $day = Input::get('data');
         return view('tasks.index', compact('tasks', 'today', 'day', 'yesterday', 'tomorrow', 'counter', 'overbooking', 'value'));
     }
     // view predefinita - INDEX
     return view('tasks.index', compact('tasks', 'day', 'yesterday', 'tomorrow', 'counter', 'today', 'overbooking', 'value'));
 }