static function getRidesInfo() { $date = $_POST['date']; $weekday = $_POST['weekday']; $language = $_POST['language']; $hours_morning = DateHours::get("morning", "getBooking"); $hours_evening = DateHours::get("evening", "getBooking"); $reserve_type = $_POST['reserve_type']; $weekdayInfo = MainController::getWeekdayInfo($weekday); $directions = MainController::getDirectionsInfo($language); $hours_morning = self::getResevationsByDate($date, $hours_morning); $hours_evening = self::getResevationsByDate($date, $hours_evening); $tmpHoursMorning = array(); $tmpHoursEvening = array(); for ($i = 0; $i < count($hours_morning); $i++) { if ($hours_morning[$i]['reserve_type'] == $_POST['reserve_type']) { if ($reserve_type == "slevomat") { if ($hours_morning[$i]['during_type'] == $_POST['during_type']) { $tmpHoursMorning[] = $hours_morning[$i]; } } else { if ($reserve_type == "tourists") { $tmpHoursMorning[] = $hours_morning[$i]; } } } } for ($i = 0; $i < count($hours_evening); $i++) { if ($hours_evening[$i]['reserve_type'] == $_POST['reserve_type']) { if ($reserve_type == "slevomat") { if ($hours_evening[$i]['during_type'] == $_POST['during_type']) { $tmpHoursEvening[] = $hours_evening[$i]; } } else { if ($reserve_type == "tourists") { $tmpHoursEvening[] = $hours_evening[$i]; } } } } $hours_morning = $tmpHoursMorning; $hours_evening = $tmpHoursEvening; echo json_encode(array("hours_morning" => $hours_morning, "hours_evening" => $hours_evening, "weekday" => $weekdayInfo, "date" => $date, "directions" => $directions, "reserve_type" => $reserve_type)); }
static function booking_get_reservations() { $dateArray = $_POST['dateArray']; $language = $_POST['language']; $directionID = "directions_" . $language . "_id"; $result = array(); $instructors = array(); $resultIndex = 0; for ($i = 0; $i < count($dateArray); $i++) { $date = $dateArray[$i]; $_POST['date'] = $date; $_POST['weekday'] = strtoupper(date('D', strtotime($date))); $result[$resultIndex]['hoursInfo']['morning'] = DateHours::get("morning", "get_timetable"); $result[$resultIndex]['hoursInfo']['evening'] = DateHours::get("evening", "get_timetable"); $reservationCursor = Dispatcher::$mysqli->query("select * from reservation_has_hours where reservation_has_hours.`date`='{$date}'"); if ($reservationCursor->num_rows > 0) { $result[$resultIndex]['date'] = $date; $result[$resultIndex]['eventExist'] = 1; $resIndex = 0; while ($reservationRow = $reservationCursor->fetch_assoc()) { $client_id = $reservationRow['Person_id']; $hours_id = $reservationRow['hours_id']; $directions_id = $reservationRow['directions_en_id']; $clientCursor = Dispatcher::$mysqli->query("select name, telefone, email, `permission` from person where id={$client_id}"); $clientRow = $clientCursor->fetch_assoc(); $hoursCursor = Dispatcher::$mysqli->query("select * from hours_to_display where id={$hours_id}"); $hoursRow = $hoursCursor->fetch_assoc(); $hourType = $hoursRow['type']; for ($hourIndex = 0; $hourIndex < count($result[$resultIndex]['hoursInfo']["{$hourType}"]); $hourIndex++) { if ($result[$resultIndex]['hoursInfo']["{$hourType}"][$hourIndex]['hour_from'] == $hoursRow['hour_from'] && $result[$resultIndex]['hoursInfo']["{$hourType}"][$hourIndex]['hour_to'] == $hoursRow['hour_to']) { $hoursRow['id'] = $result[$resultIndex]['hoursInfo']["{$hourType}"][$hourIndex]['hourID']; $hoursRow['hour_from'] = $result[$resultIndex]['hoursInfo']["{$hourType}"][$hourIndex]['hour_from']; $hoursRow['hour_to'] = $result[$resultIndex]['hoursInfo']["{$hourType}"][$hourIndex]['hour_to']; $hoursRow['hours'] = $result[$resultIndex]['hoursInfo']["{$hourType}"][$hourIndex]['hours']; $hoursRow['type'] = $hourType; $hoursRow['reserve_type'] = $result[$resultIndex]['hoursInfo']["{$hourType}"][$hourIndex]['reserve_type']; $hoursRow['during_type'] = $result[$resultIndex]['hoursInfo']["{$hourType}"][$hourIndex]['during_type']; $hoursRow['create_type'] = $result[$resultIndex]['hoursInfo']["{$hourType}"][$hourIndex]['create_type']; $hoursRow['max_places'] = $result[$resultIndex]['hoursInfo']["{$hourType}"][$hourIndex]['max_places']; $hoursRow['state'] = $result[$resultIndex]['hoursInfo']["{$hourType}"][$hourIndex]['state']; $hoursRow['display'] = $result[$resultIndex]['hoursInfo']["{$hourType}"][$hourIndex]['display']; $hoursRow['date'] = $result[$resultIndex]['hoursInfo']["{$hourType}"][$hourIndex]['date']; $hoursRow['weekday'] = $result[$resultIndex]['hoursInfo']["{$hourType}"][$hourIndex]['weekday']; $hoursRow['has_changes'] = $result[$resultIndex]['hoursInfo']["{$hourType}"][$hourIndex]['has_changes']; $hours_id = $hoursRow['id']; break; } } // MainController::printArray($hoursRow); $instructorCursor = Dispatcher::$mysqli->query("select instructor.`Person_id` as instructor_id, " . " person.`name`, person.email, person.`permission`, person.telefone," . " instructor.color, instructor.calendar_id, instructor.status from instructor_has_hours " . "join hours_to_display on instructor_has_hours.hours_id=hours_to_display.id " . "join instructor on instructor_has_hours.instructor_id=instructor.`Person_id` " . "join person on instructor.`Person_id`=person.id where hours_id={$hours_id}"); $instructorRow = $instructorCursor->fetch_assoc(); $customInstructorCursor = Dispatcher::$mysqli->query("select custom_intsructor.hours_id, custom_intsructor.instructor_id, " . "person.name, person.email, person.`permission`, person.telefone, instructor.color, " . "instructor.calendar_id, instructor.status from custom_intsructor " . "join instructor on custom_intsructor.instructor_id=instructor.`Person_id` " . "join person on instructor.`Person_id`=person.id " . "where custom_intsructor.`date`='{$date}' and custom_intsructor.hours_id={$hours_id}"); if ($customInstructorCursor->num_rows > 0) { $customInstructorRow = $customInstructorCursor->fetch_assoc(); $instructorRow = $customInstructorRow; } $instructorExist = 0; if (isset($result[$resultIndex]['instructorsInfo']["{$hourType}"])) { for ($insIndex = 0; $insIndex < count($result[$resultIndex]['instructorsInfo']["{$hourType}"]); $insIndex++) { if ($result[$resultIndex]['instructorsInfo']["{$hourType}"][$insIndex]['instructor_id'] == $instructorRow['instructor_id']) { $instructorExist = 1; break; } } } if ($instructorExist == 0) { $result[$resultIndex]['instructorsInfo']["{$hourType}"][] = $instructorRow; } $directionCursor = Dispatcher::$mysqli->query("select name from directions_en where id={$directions_id}"); $directionRow = $directionCursor->fetch_assoc(); $during_type = $hoursRow['during_type']; $vouchersInfoCursor = Dispatcher::$mysqli->query("select * from voucher_info where `type`='{$during_type}'"); $vouchersInfoRow = $vouchersInfoCursor->fetch_assoc(); $result[$resultIndex]['reservationInfo'][$resIndex]['date'] = $date; $result[$resultIndex]['reservationInfo'][$resIndex]['choosen_places'] = $reservationRow['choosen_places']; $result[$resultIndex]['reservationInfo'][$resIndex]['clientInfo'] = $clientRow; $result[$resultIndex]['reservationInfo'][$resIndex]['hoursInfo'] = $hoursRow; $result[$resultIndex]['reservationInfo'][$resIndex]['hour_from'] = $hoursRow['hour_from']; $result[$resultIndex]['reservationInfo'][$resIndex]['state'] = $hoursRow['state']; $result[$resultIndex]['reservationInfo'][$resIndex]['has_changes'] = $hoursRow['has_changes']; $result[$resultIndex]['reservationInfo'][$resIndex]['instructorsInfo'] = $instructorRow; $result[$resultIndex]['reservationInfo'][$resIndex]['directionsInfo'] = $directionRow; $result[$resultIndex]['reservationInfo'][$resIndex]['voucherInfo'] = $vouchersInfoRow; HoursController::sortHours($result[$resultIndex]['reservationInfo']); $resIndex++; } // MainController::printArray($reservationRow); } else { $result[$resultIndex]['date'] = $date; $result[$resultIndex]['eventExist'] = 0; } $resultIndex++; } echo json_encode($result); }