Esempio n. 1
0
function getResults()
{
    $search = new ReservationSearch(new ReservationSearchDB());
    $results = array();
    if (isset($_GET['resid'])) {
        $results = $search->getReservation(htmlspecialchars($_GET['resid']));
    } else {
        $start = null;
        $end = null;
        $userid = Auth::getCurrentID();
        if (isset($_GET['start_date']) && !empty($_GET['start_date'])) {
            $start_date = htmlspecialchars($_GET['start_date']);
            $dates = explode(INTERNAL_DATE_SEPERATOR, $start_date);
            $start = mktime(0, 0, 0, $dates[0], $dates[1], $dates[2]);
        }
        if (isset($_GET['end_date']) && !empty($_GET['end_date'])) {
            $end_date = htmlspecialchars($_GET['end_date']);
            $dates = explode(INTERNAL_DATE_SEPERATOR, $end_date);
            $end = mktime(0, 0, 0, $dates[0], $dates[1], $dates[2]);
        }
        $results = $search->getReservations($userid, $start, $end);
    }
    return $results;
}
Esempio n. 2
0
 /** AK:
  * Controls total number of reservation per day per user. Data is taken from the config file.
  * @param none
  */
 function check_total_quantity()
 {
     global $conf;
     if ($this->adminMode) {
         // Admin always has permission
         return true;
     }
     $is_valid = true;
     $number_of_reservations = 0;
     $max_reservations_per_day = $conf['app']['max_reservations_per_day_per_user'];
     $reservation_search = new ReservationSearch(new ReservationSearchDB());
     $reservations = $reservation_search->getReservations($this->user->get_id(), $this->start_date, $this->end_date);
     if ($max_reservations_per_day != '' && sizeof($reservations) >= $max_reservations_per_day) {
         $is_valid = false;
     }
     if (!$is_valid) {
         $this->add_error('Total number of reservations per day exceeded.' . '<br /><br >' . 'Total number of reservations per day is' . ' ' . $max_reservations_per_day);
     }
     return $is_valid;
 }