Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $variables->getSafeVars(array_keys($_REQUEST));
- $matrix = array();
- if (empty($med_id) || empty($firstIndex) || empty($daysInMonth) || empty($month) || empty($year)) {
- echo json_encode($matrix);
- exit;
- }
- $day_index = 0;
- for ($i = $firstIndex; $i < ($daysInMonth + $firstIndex); $i++) {
- $day_index++;
- $day = get_day_name($i % 7);
- $q = "select `hours` from `hours_matrix` where `med_id`='$med_id' and `day`='$day'";
- $hours = $db->getRecord($q, false);
- if($hours) {
- $exception_date = $day_index . '-' . $month . '-' . $year;
- $q = "select `hours` from `hours_matrix_exceptions` where `med_id`='$med_id' and `exception_date`='$exception_date'";
- $exceptions = $db->getRecord($q, false);
- if($exceptions) {
- $original = json_decode($hours['hours']);
- $exc = json_decode($exceptions['hours']);
- $result['hours'] = array_diff($original, $exc);
- $diff['hours'] = json_encode(array_values($result['hours']));
- $hours = ($diff['hours'] == '[]') ? array('hours' => '["' . t("Ακυρωμένο ωράριο") . '"]') : $diff;
- }
- }
- $matrix[$day_index . '_' . $day] = $hours;
- }
- echo json_encode($matrix, JSON_UNESCAPED_UNICODE);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement