/**
  * GET /bookings/new
  */
 public function form()
 {
     self::authorize_user();
     $doctors = User::doctors();
     $polyclinics = Polyclinic::all();
     $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : null;
     $time__date = isset($_REQUEST['time__date']) ? $_REQUEST['time__date'] : null;
     $doctor_id = isset($_REQUEST['doctor_id']) ? $_REQUEST['doctor_id'] : null;
     $polyclinic_id = isset($_REQUEST['polyclinic_id']) ? $_REQUEST['polyclinic_id'] : null;
     if ($type == 'doctor') {
         $doctor = User::find($_REQUEST['doctor_id']);
         $polyclinic = Polyclinic::find($doctor->getPolyclinicId());
     } else {
         if ($type == 'polyclinic') {
             if ($doctor_id) {
                 $doctor = User::find($_REQUEST['doctor_id']);
             }
             $polyclinic = Polyclinic::find($polyclinic_id);
             $doctors_by_polyclinic = User::findByPolyclinicId($polyclinic_id);
         }
     }
     if (isset($doctor) && $time__date) {
         $bookings = Booking::findByDoctorIdAndDate($doctor->getId(), $time__date);
     }
     if ($this->currentUser()->isAdmin()) {
         $patients = User::patients();
     }
     // La funcion render esta declarada en la clase padre ApplicationController.
     require 'app/views/bookings/form.php';
 }
 public function index()
 {
     self::authorize_user();
     $bookings = Booking::all();
     $doctors = User::doctors();
     $polyclinics = Polyclinic::all();
     $patients = User::patients();
     $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : null;
     $doctor_id = isset($_REQUEST['doctor_id']) ? $_REQUEST['doctor_id'] : null;
     $polyclinic_id = isset($_REQUEST['polyclinic_id']) ? $_REQUEST['polyclinic_id'] : null;
     $patient_id = isset($_REQUEST['patient_id']) ? $_REQUEST['patient_id'] : null;
     // La funcion render esta declarada en la clase padre ApplicationController.
     require 'app/views/reports/report.php';
 }