static function get($type, $action) { $date = $_POST['date']; $language = $_POST['language']; $dateHours = array(); $weekdayHours = WeekdayHours::get($type, $action); $directionsSelect = ""; $finalQuery = ""; if (isset($weekdayHours[0]['hour_from'])) { $size = count($weekdayHours); for ($i = 0; $i < $size; $i++) { $hourID = $weekdayHours[$i]['hourID']; $hoursToNotDisplayCursor = Dispatcher::$mysqli->query("select * from hours_to_not_display " . "where hours_id={$hourID} and date='{$date}'"); if ($hoursToNotDisplayCursor->num_rows > 0) { $weekdayHours[$i]['state'] = 0; } $customInstructorCursor = Dispatcher::$mysqli->query("select * 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={$hourID}"); if ($customInstructorCursor->num_rows > 0) { $customInstructorRow = $customInstructorCursor->fetch_assoc(); // MainController::printArray($customInstructorRow); $weekdayHours[$i]['status'] = $customInstructorRow['status']; $weekdayHours[$i]['instructor_id'] = $customInstructorRow['instructor_id']; $weekdayHours[$i]['instructorName'] = $customInstructorRow['name']; $weekdayHours[$i]['instructorEmail'] = $customInstructorRow['email']; $weekdayHours[$i]['color'] = $customInstructorRow['color']; $weekdayHours[$i]['calendar_id'] = $customInstructorRow['calendar_id']; } } } $result = array(); $dateHoursCursor = Dispatcher::$mysqli->query("select *, voucher_info.`name` as voucherName, " . "person.`name` as instructorName, person.email as instructorEmail, " . "hours_to_display.id as hourID, hours_to_display.`state` as hourState, " . "hours_to_display.`type` as hourType, directions_{$language}.name as dirName, " . "directions_{$language}.color as dirColor, directions_{$language}.fillColor as dirFillColor, " . "instructor.color as color " . "from hours_to_display " . "join voucher_info " . "on hours_to_display.during_type=voucher_info.type " . "join instructor_has_hours " . "on hours_to_display.id=instructor_has_hours.hours_id " . "join instructor " . "on instructor_has_hours.instructor_id=instructor.`Person_id` " . "join person " . "on person.id=instructor.`Person_id` " . "join directions_{$language} on hours_to_display.direction_id=directions_{$language}.id " . "where hours_to_display.type='{$type}' and hours_to_display.create_type='Date' " . "and hours_to_display.date='{$date}' " . "and hours_to_display.display=1 " . "and voucher_info.display='1' " . "order by hours_to_display.hour_from"); $i = 0; if ($dateHoursCursor->num_rows > 0) { while ($dateHoursRow = $dateHoursCursor->fetch_assoc()) { $hourID = $dateHoursRow['hourID']; $cursor = Dispatcher::$mysqli->query("select * from hours_to_not_display where " . "hours_id={$hourID} and `date`='{$date}'"); if ($cursor->num_rows <= 0) { foreach (array_keys($dateHoursRow) as $key) { if ($key != "password") { $dateHours[$i]["{$key}"] = $dateHoursRow["{$key}"]; } } $i++; } } if (isset($dateHours[0]['hour_from'])) { $result = HoursController::hoursMerge($weekdayHours, $dateHours, $action); } else { $result = $weekdayHours; } } else { $result = $weekdayHours; } HoursController::getFreePlacesQty($result); $size = count($result); for ($i = 0; $i < $size; $i++) { $result[$i]['date'] = $date; } $finalResult = array(); if (isset($_POST['checked_directions'])) { $checked_directions = $_POST['checked_directions']; for ($dr = 0; $dr < count($result); $dr++) { for ($i = 0; $i < count($checked_directions); $i++) { if ($result[$dr]['direction_id'] == $checked_directions[$i]) { $finalResult[] = $result[$dr]; break; } } } return $finalResult; } // MainController::printArray($result); return $result; }