' . $branch_id; } $data = [ 'times' => [] ]; $get_emplyee_sql = mysqli_query($db, "SELECT `time` FROM `times` WHERE `time` LIKE '%:00:00'"); while ($get_emplyee = mysqli_fetch_assoc($get_emplyee_sql)) { if($get_emplyee['time'] == "02:00:00" || $get_emplyee['time'] == "03:00:00" || $get_emplyee['time'] == "04:00:00" || $get_emplyee['time'] == "05:00:00" || $get_emplyee['time'] == "06:00:00" || $get_emplyee['time'] == "07:00:00" || $get_emplyee['time'] == "08:00:00") { continue; } $data['times'][$get_emplyee['time']] = [ 'all_free' => [], 'free' => [], 'books' => [], ]; } // عدد المدلكين المتوفرين خلال الساعة $get_emplyee_sql = mysqli_query($db, "SELECT `e`.`id`, `e`.`name`, `hd`.`day`, `e`.`branch_id`, TIME(`wtt`.`from_date_time`) AS `fromTime`, TIME(`wtt`.`to_date_time`) AS `toTime` FROM `work_time_table` `wtt` LEFT JOIN `emplyee` `e` ON `wtt`.`emplyee_id` = `e`.`id` LEFT JOIN `branch` `b` ON `e`.`branch_id` = `b`.`id` LEFT JOIN `holi_days` `hd` ON `e`.`holi_days_id` = `hd`.`id` WHERE `e`.`branch_id` $branch_sql -- AND `b`.`commercial_register_id` = 2 AND `wtt`.`activation_id` = 2 AND `e`.`occupation_id` = 2 AND DATE(`wtt`.`to_date_time`) > '$frist_day' AND DATE(`wtt`.`from_date_time`) < '$last_day' "); while ($get_emplyee = mysqli_fetch_assoc($get_emplyee_sql)) { foreach ($data['times'] as $key => $value) { $givenTime = $key; $fromDateTime = $get_emplyee['fromTime']; $toDateTime = $get_emplyee['toTime']; $fromDateTimeObj = new DateTime($fromDateTime); $toDateTimeObj = new DateTime($toDateTime); $givenTimeObj = new DateTime($givenTime); if ($givenTimeObj >= $fromDateTimeObj && $givenTimeObj <= $toDateTimeObj) { array_push($data['times'][$key]['all_free'], $get_emplyee); $data['times'][$key]['free'][$get_emplyee['id']] += 1; } } } // عدد الجلسات المفعلة $get_emplyee_sql = mysqli_query($db, "SELECT `t1`.`day_time`, IFNULL(COUNT(`t1`.`id`),0) AS `count` FROM `book_details` AS `t1` iNNER JOIN `branch` ON `branch`.`id` = `t1`.`branch_id` iNNER JOIN `emplyee` ON `emplyee`.`id` = `t1`.`emplyee_id` JOIN ( SELECT `book_id`, MAX(`id`) AS `max_id` FROM `book_details` GROUP BY `book_id` ) `t1_max` ON `t1`.`book_id` = `t1_max`.`book_id` AND `t1`.`id` = `t1_max`.`max_id` WHERE `status_id` IN (6,8,14,15) AND ( (`t1`.`day_date` = '$frist_day' AND `t1`.`day_time` BETWEEN '09:00:00' AND '23:59:59') OR (`t1`.`day_date` = '$last_day' AND `t1`.`day_time` <= '03:00:00') ) AND `t1`.`branch_id` $branch_sql -- AND `branch`.`commercial_register_id` = 2 AND `emplyee`.`occupation_id` = 2 GROUP BY `t1`.`day_time` "); while ($get_emplyee = mysqli_fetch_assoc($get_emplyee_sql)) { array_push($data['times'][$get_emplyee['day_time']]['books'], $get_emplyee['count']); } // while ($get_emplyee = mysqli_fetch_assoc($get_emplyee_sql)) { // if (!array_key_exists($get_emplyee['id'], $data['emplyees'])) { // $data['emplyees'][$get_emplyee['id']] = array( // 'time_work' => array(), // ); // } // $from = $get_time_work['fromTime'][0] . $get_time_work['fromTime'][1]; // $to = $get_time_work['toTime'][0] . $get_time_work['toTime'][1]; // $ttx = 0; // for ($from; $from <= $to; $from++) { // $push_time_work = $from . ":00:00"; // if ($from < 10 && $ttx > 0) { // $push_time_work = "0" . $from . ":00:00"; // } // if ($Day == "Fri" && $push_time_work == '13:00:00') { // كل جمعه الساعه 1 خلية مقفل // continue; // } // array_push($data['emplyees'][$get_time_work['emplyee_id']]['time_work'], $push_time_work); // $ttx++; // } // } ?>
| الاوقات | المدلكين المتوفرين | عدد الجلسات المفعلة | النسية |
|---|---|---|---|
| = $key ?> | = $s1 ?> | = $s2 ?> | = $s3 ?>% |
| المجموع | =$t1?> | =$t2?> | =$t1 == 0 && $t2 == 0 ? 0 : round($t2/$t1*100,2);?>% |