booking/work/order/ajax/book_v5.php

1067 lines
89 KiB
PHP
Executable File

<?php
require_once('fixed/config/go_con.php');
access(10002);
$today = date("Y-m-d");
if (!empty($_GET['date'])) {
$today = $_GET['date'];
if (DateTime::createFromFormat('Y-m-d', $today) == false) {
$today = date("Y-m-d");
}
}
$branch_id = $_SESSION['branch'];
if (!empty($_GET['branch'])) {
$branch_id = $_GET['branch'];
if (!is_numeric($branch_id)) {
$branch_id = $_SESSION['branch'];
} else {
if ($branch_id == 1) {
$branch_id = $_SESSION['branch'];
}
}
}
$branch_sql = '`branch_id`='.$branch_id;
if ($branch_id == 1) {
$branch_sql = '`branch_id`<>'.$branch_id;
}
// work time
$commercial_register_sql = mysqli_query($db, "SELECT `commercial_register`.`start_work`, `commercial_register`.`start_work_fri`, `commercial_register`.`end_work`
FROM `branch`
LEFT JOIN `commercial_register` ON `branch`.`commercial_register_id` = `commercial_register`.`id`
WHERE `branch`.`id` = $branch_id"
);
$commercial_register = mysqli_fetch_assoc($commercial_register_sql);
$Next = date('Y-m-d', strtotime('+1 day', strtotime($today)));
$Previous = date('Y-m-d', strtotime('-1 day', strtotime($today)));
$Day = date('D', strtotime($today));
function Day_ar()
{
global $Day;
$find = array("Sat", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri");
$replace = array("السبت", "الأحد", "الإثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة");
$ar_day_format = $Day;
$Day_ar = str_replace($find, $replace, $ar_day_format);
return $Day_ar;
}
function Today_ar()
{
global $today;
$Today_ar = date('d-m-Y', strtotime($today));
return $Today_ar;
}
$tabs = $_SESSION['tab'];
if (empty($tabs)) {
$tabs = 1;
}
$not_eq = "=";
if ($tabs == 1) {
$not_eq = "<>";
}
$start_today_time_static = $commercial_register['start_work'];
if ($Day == "Fri") {
$start_today_time_static = $commercial_register['start_work_fri'];
}
$end_today_time_static = $commercial_register['end_work'];
$archives = false;
if (strtotime($today) <= strtotime(date('Y-m-d', strtotime('-1 month', strtotime(date('Y-m-d')))))) {
$archives = true;
}
if (strtotime($today) <= strtotime(date('Y-m-d', "2022-09-30"))) {
$archives = true;
}
?>
<!DOCTYPE html>
<html lang="en" dir="rtl">
<?php require_once('fixed/head/go.php'); ?>
<body class="rtl">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/@mdi/font@6.5.95/css/materialdesignicons.min.css">
<?php require_once('fixed/loader/go.php'); ?>
<!-- page-wrapper Start-->
<div class="page-wrapper" id="pageWrapper">
<?php require_once('fixed/header/go.php'); ?>
<!-- Page Body Start-->
<div class="page-body-wrapper">
<?php require_once('fixed/sidebar/go.php'); ?>
<div class="page-body">
<!-- Container-fluid starts-->
<div class="container-fluid">
<div class="row">
<style>
.mo-home-table {
box-shadow: 3px 3px 3px 3px rgba(0, 0, 0, 0.1);
}
.mo-home-table thead th { position: sticky; top: 0; background: #f0f3f5; border:#dadada solid 1px !important;}
.mo-home-table td { border:#dadada solid 1px; min-width: 125px !important; overflow: hidden; height: 150px !important; padding: 0px !important; }
/*
width: 6.25% !important;
height: 85px !important;
padding: 5px !important;
*/
td:hover .before { display: none;}
td:hover .after { display: block; }
.modal-header h5 { font-weight: bold;}
.modal-body table { border:#eff2f4 solid 1px; width: 100%;}
span.mdi {
cursor: pointer;
}
.table-responsive {
height: 90vh;
overflow-y: scroll;
}
table.mo-home-table tbody {
overflow: scroll;
height: 200px;
}
table thead th {
z-index: 100;
}
table thead th:first-child {
position: sticky;
left: 0;
z-index: 100;
}
tr > :first-child {
position: -webkit-sticky;
position: sticky;
background: rgba(255, 255, 255, .5);
right: 0;
z-index: 100;
}
.bg-gradient7 {
background-image: linear-gradient(120deg, #56ff00 0, #00e09e 100%) !important;
}
/* for buttons */
.frame-1 button {
outline: none;
}
.frame-1 .custom-btn {
height: 40px;
padding: 10px 25px;
border: 2px solid #000;
font-family: 'Lato', sans-serif;
font-weight: 500;
background: transparent;
cursor: pointer;
transition: all 0.3s ease;
position: relative;
display: inline-block;
}
/* 7 */
.frame-1 .btn-7 {
background: #afec08;
font-weight: bold;
color: #000;
line-height: 42px;
padding: 0;
border: none;
z-index: 1;
-webkit-transition: all 0.3s linear;
transition: all 0.3s linear;
}
.frame-1 .btn-8 {
background: #000 !important;
}
.frame-1 .btn-7:hover {
background: transparent;
color: #afec08;
}
.frame-1 .btn-8:hover {
color: #f93b7a !important;
}
.frame-1 .btn-7:before,
.frame-1 .btn-7:after {
position: absolute;
content: "";
left: 0;
width: 100%;
height: 50%;
right: 0;
z-index: -1;
background: #afec08;
transition: all 0.3s ease;
}
.frame-1 .btn-8:before,
.frame-1 .btn-8:after {
background: #f93b7a !important;
}
.frame-1 .btn-7:before {
top: 0;
}
.frame-1 .btn-7:after {
bottom: 0;
}
.frame-1 .btn-7:hover:before,
.frame-1 .btn-7:hover:after {
height: 0;
background-color: #afec08;
}
.frame-1 .btn-8:hover:before,
.frame-1 .btn-8:hover:after {
background-color: #f93b7a !important;
}
thead th { position: sticky; top: 0; }
/*https://css-tricks.com/position-sticky-and-table-headers/*/
</style>
<div class="col-12">
<div class="card">
<div class="card-body new-user order-list text-center">
<div class="row">
<div class="col-12 col-sm-12 col-md-3 col-lg-4 col-xl-4">
<a href="book.php">
<img src="../assets/images/cp/01.png" style="width: 100%;">
</a>
</div>
<div class="page-title mb-3 col-12 col-sm-12 col-md-6 col-lg-4 col-xl-4">
<i class="mdi mdi-monitor mr-2">
</i>
<h4>
حجوزات يوم
<?= Day_ar() ?>
<br />
<?= Today_ar() ?>
</h4>
</div>
<div class="col-12 col-sm-12 col-md-3 col-lg-4 col-xl-4">
<?php
if ($commercial_register_id == 2) {
?>
<a href="book.php?branch=2&date=<?=$today?>">
<button class="btn btn-primary" type="button">15</button>
</a>
<a href="book.php?branch=3&date=<?=$today?>">
<button class="btn btn-primary" type="button">7</button>
</a>
<a href="book.php?branch=4&date=<?=$today?>">
<button class="btn btn-primary" type="button">29</button>
</a>
<?php
}
?>
</div>
</div>
<div class="row">
<div class="col-12 col-sm-12 col-md-2 col-lg-3 col-xl-3">
</div>
<div class="col-2 col-sm-2 col-md-1 col-lg-1 col-xl-1">
<a class="btn btn-danger btn-round waves-effect waves-light col-12" href="book.php?date=<?= $Previous ?>&branch=<?= $branch_id ?>" style="padding: 0.375rem 0.75rem;">-</a>
</div>
<div class="col-8 col-sm-8 col-md-6 col-lg-4 col-xl-4">
<input id="Select-date" class="form-control" type="date" value="" style="text-align: center !important;">
</div>
<div class="col-2 col-sm-2 col-md-1 col-lg-1 col-xl-1">
<a class="btn btn-primary btn-round waves-effect waves-light col-12" href="book.php?date=<?= $Next ?>&branch=<?= $branch_id ?>" style="padding: 0.375rem 0.75rem;">+</a>
</div>
<div class="col-12 col-sm-12 col-md-2 col-lg-3 col-xl-3">
</div>
</div>
</div>
<?php
$type_of_services_sql = mysqli_query($db, "SELECT `id`, `name`
FROM `type_of_services`
WHERE `show_in_table_id` = 2 AND `activation_id` = 2"
);
if (mysqli_num_rows($type_of_services_sql) > 0) {
?>
<div class="card-body">
<ul class="nav nav-pills nav-justified" role="tablist">
<?php
if (mysqli_num_rows($type_of_services_sql) > 1) {
?>
<li class="nav-item waves-effect waves-light">
<a class="nav-link <?php if($tabs == 1 ) {echo "active";} ?>" data-toggle="tab" onclick="window.location='work/order/php/tabs.php?num=1'" role="tab" aria-selected="true">الكل</a>
</li>
<?php
}
?>
<?php
while ($type_of_services = mysqli_fetch_assoc($type_of_services_sql)) {
?>
<li class="nav-item waves-effect waves-light">
<a class="nav-link <?php if($tabs == $type_of_services['id'] ) {echo "active";} ?>" data-toggle="tab" onclick="window.location='work/order/php/tabs.php?num=<?=$type_of_services['id']?>'" role="tab" aria-selected="false"><?=$type_of_services['name']?></a>
</li>
<?php
}
?>
</ul>
</div>
<?php
}
?>
<div class="tab-content">
<div class="tab-pane p-3 active" id="tab<?=$tabs?>" role="tabpanel">
<div class="card-body new-user order-list">
<div class="table-responsive" style="zoom:0.<?=$table_size?>;">
<table style="width: 0 !important; margin: 0 auto !important;" class="table table-hover mb-3 text-center mo-home-table">
<thead class="thead-light">
<tr>
<th></th>
<?php
$start_today_time = $start_today_time_static;
$end_today_time = $end_today_time_static;
for ($start_today_time; $start_today_time <= $end_today_time; $start_today_time++) {
$restart_temp = $start_today_time;
if ($start_today_time > 23) {
$restart_temp = $start_today_time - 24;
}
if ($restart_temp < 10) {
$start_today_time_temp = "0" . $restart_temp . ":00:00";
} else {
$start_today_time_temp = $restart_temp . ":00:00";
}
$today_temp = $today;
if ($start_today_time > 23) {
$today_temp = $Next;
}
?>
<th><?=date((date("H", strtotime($start_today_time_temp)) > 11) ? 'h:i \م' : 'h:i \ص', strtotime($start_today_time_temp))?><a href="work/php/one_clock_close.php?date=<?=$today_temp?>&time=<?=$start_today_time_temp?>&branch=<?=$branch_id?>"> <span style="float: right;font-size: 15px;height: 100%;" class="mdi mdi-close-outline"></span></a></th>
<?php
}
?>
</tr>
</thead>
<tbody>
<?php
$booking_state_1 = array();
$tretment_details_state = array();
$pray_time = array('12:00:00','15:00:00','18:00:00','20:00:00');
// العمالة
$get_emplyee_sql = mysqli_query($db, "SELECT
`emplyee`.`id`,
`emplyee`.`name`,
`holi_days`.`day`,
`emplyee`.`branch_id`
FROM `occupation`
LEFT JOIN `emplyee` ON `emplyee`.`occupation_id` = `occupation`.`id`
LEFT JOIN `branch` ON `emplyee`.`branch_id` = `branch`.`id`
LEFT JOIN `holi_days` ON `emplyee`.`holi_days_id` = `holi_days`.`id`
LEFT JOIN `table_postion` ON `emplyee`.`id` = `table_postion`.`emplyee_id`
WHERE `occupation`.`show_in_table_id` = 2
AND `emplyee`.$branch_sql
AND `occupation`.`type_of_services_id` $not_eq $tabs
AND `emplyee`.`activation_id` = 2
AND `branch`.`commercial_register_id` = $commercial_register_id
ORDER BY -`table_postion`.`postion` DESC, `emplyee`.`id` ASC
");
while ($get_emplyee = mysqli_fetch_assoc($get_emplyee_sql)) {
$start_today_time = $start_today_time_static;
$end_today_time = $end_today_time_static;
$start_today_time_sql = $start_today_time . ":00:00";
$end_today_time_sql = $end_today_time . ":59:59";
$emp_id = $get_emplyee['id'];
$emp_neme = $get_emplyee['name'];
?>
<tr>
<td class="sorting_1" style ="padding: 15px !important;">
<div style="height:120px; overflow:revert">
<img class="rounded-circle" src="uploads/emplyee/user/1.png" alt="user" data-bs-toggle="modal" data-animation="bounce" data-bs-target=".emp_<?=$get_emplyee['id']?>" style="width: 90px !important;height: 90px !important;">
<div style="margin-top: 10px;">
<?= $get_emplyee['name'] ?>
</div>
</div>
</td>
<?php
$get_emplyee_time_work = mysqli_query($db, "SELECT TIME(`work_time_table`.`from_date_time`) AS fromTime,TIME(`work_time_table`.`to_date_time`) AS toTime FROM `work_time_table`
WHERE `work_time_table`.`emplyee_id` = $emp_id AND `work_time_table`.`to_date_time` > '$today' AND `work_time_table`.`from_date_time` < '$Next' AND `work_time_table`.`activation_id` = 2");
$time_work = array();
while ($get_time_work = mysqli_fetch_assoc($get_emplyee_time_work)) {
$from = $get_time_work['fromTime'][0] . $get_time_work['fromTime'][1];
$to = $get_time_work['toTime'][0] . $get_time_work['toTime'][1];
for ($from; $from <= $to; $from++) {
$push_time_work = $from . ":00:00";
array_push($time_work, $push_time_work);
}
}
if ($archives) {
include('work/files/book/archives.php');
} else {
$get_tretment_details_sql_state = mysqli_query($db,
"SELECT
`bd`.`day_date`,
`bd`.`day_time`,
`bd`.`branch_id`,
`bd`.`emplyee_id`,
`bd`.`status_id`,
`bd`.`date_time`,
`bd`.`book_id` AS `book_id`,
`bd`.`name`,
`bd`.`tretment_id`,
`bd`.`notes`,
`bd`.`date_time` AS `user_date`,
`bd`.`user_book`,
`bd`.`tr_name`,
`bd`.`number`
FROM `book_temp` AS `bd`
WHERE `bd`.`day_date`='$today'
AND (`bd`.`day_time` >= '$start_today_time_sql' AND `bd`.`day_time` <= '$end_today_time_sql')
AND `bd`.`emplyee_id`='$emp_id'
AND `bd`.$branch_sql
AND `bd`.`status_id` != 25
GROUP BY `bd`.`day_time`
ORDER BY `bd`.`day_time`, `bd`.`date_time`
");
}
$tretment_details_state_temp = array();
while ($get_tretment_details_state = mysqli_fetch_assoc($get_tretment_details_sql_state)) {
array_push($tretment_details_state, $get_tretment_details_state);
array_push($tretment_details_state_temp, $get_tretment_details_state);
}
$get_table_sql_state = mysqli_query($db,
"SELECT
`user`.`id`,
`user`.`name`,
`table`.`day_date`,
`table`.`day_time`,
`table`.`notes`,
`table`.`branch_id`,
`table`.`emplyee_id`,
`table`.`status_id`,
`table`.`date_time` AS `time`
FROM `table`
LEFT JOIN `user` ON `user`.`id` = `table`.`user_id`
WHERE `table`.`day_date` = '$today'
AND (`table`.`day_time` >= '$start_today_time_sql' AND `table`.`day_time` <= '$end_today_time_sql')
AND `table`.$branch_sql AND `table`.`emplyee_id` = '$emp_id'
AND `table`.`id` IN (SELECT MAX(`tb`.`id`) FROM `table` AS `tb` WHERE `tb`.`day_date` = '$today'
AND `tb`.`emplyee_id` = '$emp_id' GROUP BY `tb`.`day_time`)
ORDER BY `table`.`day_time` ASC"
);
$open_close_temp = array();
while ($get_table_state = mysqli_fetch_assoc($get_table_sql_state)) {
array_push($open_close_temp, $get_table_state);
}
if ($end_today_time > 23) { // greter than 24 hour
$end_today_time_sql = "23:59:59";
$how_many_left = ($end_today_time - 23) - 1 . ":59:59";
if ($archives) {
include('work/files/book/archives_above_23.php');
} else {
$get_tretment_details_sql_state2 = mysqli_query($db,
"SELECT
`bd`.`day_date`,
`bd`.`day_time`,
`bd`.`branch_id`,
`bd`.`emplyee_id`,
`bd`.`status_id`,
`bd`.`date_time`,
`bd`.`book_id` AS `book_id`,
`bd`.`name`,
`bd`.`tretment_id`,
`bd`.`notes`,
`bd`.`user_date`,
`bd`.`user_book`,
`bd`.`tr_name`,
`bd`.`number`
FROM `book_temp` AS `bd`
WHERE `bd`.`day_date` = '$Next'
AND `bd`.`day_time` <= '$how_many_left'
AND `bd`.`emplyee_id`='$emp_id'
AND `bd`.$branch_sql
AND `bd`.`status_id` != 25
GROUP BY `bd`.`day_time`
ORDER BY `bd`.`day_time`, `bd`.`date_time`
");
}
while ($get_tretment_details_state2 = mysqli_fetch_assoc($get_tretment_details_sql_state2)) {
array_push($tretment_details_state, $get_tretment_details_state2);
array_push($tretment_details_state_temp, $get_tretment_details_state2);
}
$get_table_sql_state2 = mysqli_query($db,
"SELECT
`user`.`id`,
`user`.`name`,
`table`.`day_date`,
`table`.`day_time`,
`table`.`notes`,
`table`.`branch_id`,
`table`.`emplyee_id`,
`table`.`status_id`,
`table`.`date_time` AS `time`
FROM `table`
LEFT JOIN `user` ON `user`.`id` = `table`.`user_id`
WHERE `table`.`day_date` = '$Next'
AND `table`.`day_time` <= '$how_many_left'
AND `table`.$branch_sql
AND `table`.`emplyee_id` = '$emp_id'
AND `table`.`id` IN (SELECT MAX(`tb`.`id`) FROM `table` AS `tb` WHERE `tb`.`day_date` = '$Next'
AND `tb`.`emplyee_id` = '$emp_id' GROUP BY `tb`.`day_time`)
ORDER BY `table`.`day_time` ASC"
);
while ($get_table_state2 = mysqli_fetch_assoc($get_table_sql_state2)) {
array_push($open_close_temp, $get_table_state2);
}
}
$branch_id = $get_emplyee['branch_id'];
$open_close_count= 0;
$temp_count = 0;
for ($start_today_time; $start_today_time <= $end_today_time; $start_today_time++) {
$restart_temp = $start_today_time;
if ($start_today_time > 23) {
$restart_temp = $start_today_time - 24;
}
if ($restart_temp < 10) {
$start_today_time_temp = "0" . $restart_temp . ":00:00";
} else {
$start_today_time_temp = $restart_temp . ":00:00";
}
$today_temp = $today;
if ($start_today_time > 23) {
$today_temp = $Next;
}
if (($tretment_details_state_temp[$temp_count]['day_time']) == ($start_today_time_temp) && $tretment_details_state_temp[$temp_count]['emplyee_id'] == $emp_id) {
switch ($tretment_details_state_temp[$temp_count]['status_id']) {
case 4: case 5:
// انتظار
?>
<td class="bg-gradient3">
<div style="display: flex !important; flex-direction: column;">
<div style="height: 25px;">
<a style="color: white !important" href="edit_booking.php?booking_id=<?= $tretment_details_state_temp[$temp_count]['book_id'] ?>">
<span style="float: left;background: green;padding: 2px;width: 21px;height: 100%;" class="mdi mdi-book-edit"></span>
</a>
<a style="color: white !important" target="_blank" href="tel:+966<?= $tretment_details_state_temp[$temp_count]['number'] ?>">
<span style="float: left;background: blue;padding: 2px;width: 21px;height: 100%;" class="mdi mdi-phone"></span>
</a>
<a style="color: white !important" target="_blank" href="https://api.whatsapp.com/send/?phone=966<?= $tretment_details_state_temp[$temp_count]['number'] ?>&text=">
<span style="float: left;background: gray;padding: 2px;width: 21px;height: 100%;" class="mdi mdi-whatsapp"></span>
</a>
<a style="color: black !important" href="active.php?booking_id=<?= $tretment_details_state_temp[$temp_count]['book_id']?>">
<span style="float: right;background: #fff700;padding: 2px;width: 21px;height: 100%;" class="mdi mdi-arrow-top-right"></span>
</a>
<a class="booking-cancel" style="color: white !important" href="work/order/php/cancel.php?booking_id=<?= $tretment_details_state_temp[$temp_count]['book_id']?>">
<span style="float: right;background: red;padding: 2px;width: 21px;height: 100%;" class="mdi mdi-close"></span>
</a>
</div>
<div title="حجز بواسطة <?= $tretment_details_state_temp[$temp_count]['user_book'] ?>" data-bs-toggle="modal" data-animation="bounce" data-bs-target="#booking_<?= $tretment_details_state_temp[$temp_count]['book_id'] ?>"
style="color:black; min-height: 100px; display: flex; justify-content: center; align-items: center; flex-direction: column; border-bottom: 3px solid black;">
<div style="white-space: nowrap;">
<div><?= $tretment_details_state_temp[$temp_count]['tr_name'] ?></div>
</div>
<div style="white-space: nowrap;">
<div><?= $tretment_details_state_temp[$temp_count]['name'] ?></div>
</div>
</div>
<div style="color:black;height:30px;background:#c1c1c1;font-weight:bold;font-size:17px;cursor:pointer;" onclick="window.location='booking_detail.php?number=<?= $tretment_details_state_temp[$temp_count]['number'] ?>';">
<?= $tretment_details_state_temp[$temp_count]['number'] ?>
</div>
</div>
</td>
<?php
break;
case 6: case 7:
$for_pay_id = $tretment_details_state_temp[$temp_count]['book_id'];
$pay_sql = mysqli_query($db, "SELECT `user`.`name`, `invoices_has_book`.`date_time`
FROM `invoices_has_book`
LEFT JOIN `user` ON `user`.`id` = `invoices_has_book`.`user_id`
WHERE `book_id` = $for_pay_id
LIMIT 1");
$get_pay = mysqli_fetch_assoc($pay_sql);
?>
<td class="bg-gradient4">
<div style="display: flex !important; flex-direction: column;">
<div style="height: 25px;">
<a style="color: white !important" href="edit_booking.php?booking_id=<?= $tretment_details_state_temp[$temp_count]['book_id'] ?>">
<span style="float: left;background: green;padding: 2px;width: 21px;height: 100%;" class="mdi mdi-book-edit"></span>
</a>
<a style="color: white !important" target="_blank" href="tel:+966<?= $tretment_details_state_temp[$temp_count]['number'] ?>">
<span style="float: left;background: blue;padding: 2px;width: 21px;height: 100%;" class="mdi mdi-phone"></span>
</a>
<a style="color: white !important" target="_blank" href="https://api.whatsapp.com/send/?phone=966<?= $tretment_details_state_temp[$temp_count]['number'] ?>&text=">
<span style="float: left;background: gray;padding: 2px;width: 21px;height: 100%;" class="mdi mdi-whatsapp"></span>
</a>
<a style="color: black !important" href="print.php?book_id=<?= $tretment_details_state_temp[$temp_count]['book_id'] ?>&p=1">
<span style="float: right;background: white;padding: 2px;width: 21px;height: 100%;" class="mdi mdi-printer"></span>
</a>
<a style="color: white !important" href="work/php/free_cancel.php?booking_id=<?= $tretment_details_state_temp[$temp_count]['book_id']?>">
<span style="float: right;background: red;padding: 2px;width: 21px;height: 100%;" class="mdi mdi-close active-cancel"></span>
</a>
</div>
<div title="حجز بواسطة <?= $tretment_details_state_temp[$temp_count]['user_book'] ?> دفع بواسطة <?=$get_pay['name']?>" data-bs-toggle="modal" data-animation="bounce" data-bs-target="#booking_<?= $tretment_details_state_temp[$temp_count]['book_id'] ?>"
style="color:black; min-height: 100px; display: flex; justify-content: center; align-items: center; flex-direction: column; border-bottom: 3px solid black;">
<div style="white-space: nowrap;">
<div><?= $tretment_details_state_temp[$temp_count]['tr_name'] ?></div>
</div>
<div style="white-space: nowrap;">
<div><?= $tretment_details_state_temp[$temp_count]['name'] ?></div>
</div>
</div>
<div style="color:black;height:30px;background:#c1c1c1;font-weight:bold;font-size:17px;cursor:pointer;" onclick="window.open('booking_detail.php?number=<?= $tretment_details_state_temp[$temp_count]['number'] ?>', '_blank')">
<?= $tretment_details_state_temp[$temp_count]['number'] ?>
</div>
</div>
</td>
<?php
break;
case 8: case 9:
?>
<td class="bg-gradient1">
<div style="display: flex !important; flex-direction: column;">
<div style="height: 25px;">
<a style="color: white !important" href="edit_booking.php?booking_id=<?= $tretment_details_state_temp[$temp_count]['book_id'] ?>">
<span style="float: left;background: green;padding: 2px;width: 21px;height: 100%;" class="mdi mdi-book-edit"></span>
</a>
<a style="color: white !important" target="_blank" href="tel:+966<?= $tretment_details_state_temp[$temp_count]['number'] ?>">
<span style="float: left;background: blue;padding: 2px;width: 21px;height: 100%;" class="mdi mdi-phone"></span>
</a>
<a style="color: white !important" target="_blank" href="https://api.whatsapp.com/send/?phone=966<?= $tretment_details_state_temp[$temp_count]['number'] ?>&text=">
<span style="float: left;background: gray;padding: 2px;width: 21px;height: 100%;" class="mdi mdi-whatsapp"></span>
</a>
<a style="color: black !important" href="print.php?booking_id=<?= $tretment_details_state_temp[$temp_count]['book_id'] ?>&free=1">
<span style="float: right;background: white;padding: 2px;width: 21px;height: 100%;" class="mdi mdi-printer"></span>
</a>
<a style="color: white !important" href="work/php/free_cancel.php?booking_id=<?= $tretment_details_state_temp[$temp_count]['book_id']?>">
<span style="float: right;background: red;padding: 2px;width: 21px;height: 100%;" class="mdi mdi-close active-cancel"></span>
</a>
</div>
<div title="حجز بواسطة <?= $tretment_details_state_temp[$temp_count]['user_book'] ?>" data-bs-toggle="modal" data-animation="bounce" data-bs-target="#booking_<?= $tretment_details_state_temp[$temp_count]['book_id'] ?>"
style="color:black; min-height: 100px; display: flex; justify-content: center; align-items: center; flex-direction: column; border-bottom: 3px solid black;">
<div style="white-space: nowrap;">
<div><?= $tretment_details_state_temp[$temp_count]['tr_name'] ?></div>
</div>
<div style="white-space: nowrap;">
<div><?= $tretment_details_state_temp[$temp_count]['name'] ?></div>
</div>
</div>
<div style="color:black;height:30px;background:#c1c1c1;font-weight:bold;font-size:17px;cursor:pointer;" onclick="window.location='booking_detail.php?number=<?= $tretment_details_state_temp[$temp_count]['number'] ?>';">
<?= $tretment_details_state_temp[$temp_count]['number'] ?>
</div>
</div>
</td>
<?php
break;
case 10:
?>
<?php
break;
case 11:
?>
<?php
break;
case 12:
?>
<?php
break;
case 14:
$for_pay_id = $tretment_details_state_temp[$temp_count]['book_id'];
$pay_sql = mysqli_query($db, "SELECT `user`.`name`, `invoices_has_book`.`date_time`
FROM `invoices_has_book`
LEFT JOIN `user` ON `user`.`id` = `invoices_has_book`.`user_id`
WHERE `book_id` = $for_pay_id
LIMIT 1");
$get_pay = mysqli_fetch_assoc($pay_sql);
?>
<td class="bg-gradient7">
<div style="display: flex !important; flex-direction: column;">
<div style="height: 25px;">
<div class="progress sm-progress-bar">
<div class="progress-bar bg-success progress-bar-striped progress-bar-animated" role="progressbar" style="width: 100%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<a style="color: black !important" href="print.php?book_id=<?= $tretment_details_state_temp[$temp_count]['book_id'] ?>&p=1">
<span style="float: right;background: white;padding: 2px;width: 21px;height: 100%;" class="mdi mdi-printer"></span>
</a>
</div>
<div title="حجز بواسطة <?= $tretment_details_state_temp[$temp_count]['user_book'] ?> دفع بواسطة <?=$get_pay['name']?>" data-bs-toggle="modal" data-animation="bounce" data-bs-target="#booking_<?= $tretment_details_state_temp[$temp_count]['book_id'] ?>"
style="color:black; min-height: 100px; display: flex; justify-content: center; align-items: center; flex-direction: column; border-bottom: 3px solid black;">
<div style="white-space: nowrap;">
<div><?= $tretment_details_state_temp[$temp_count]['tr_name'] ?></div>
</div>
<div style="white-space: nowrap;">
<div><?= $tretment_details_state_temp[$temp_count]['name'] ?></div>
</div>
</div>
<div style="color:black;height:30px;background:#c1c1c1;font-weight:bold;font-size:17px;cursor:pointer;" onclick="window.open('booking_detail.php?number=<?= $tretment_details_state_temp[$temp_count]['number'] ?>', '_blank')">
<?= $tretment_details_state_temp[$temp_count]['number'] ?>
</div>
</div>
</td>
<?php
break;
case 15:
?>
<?php
break;
case 16:
?>
<?php
break;
case 17:
?>
<?php
break;
case 18:
?>
<?php
break;
case 19:
?>
<?php
break;
case 20:
?>
<td class="bg-gradient20">
<div style="position: relative;">
<div style="display: flex !important; flex-direction: column;">
<div style="height: 25px;">
<a style="color: white !important" href="work/order/php/close.php?booking_id=<?= $tretment_details_state_temp[$temp_count]['book_id']?>&date=<?= $today_temp ?>&time=<?= $start_today_time_temp ?>&emp_id=<?= $emp_id ?>&branch=<?=$branch_id?>&lo=<?=$today?>">
<span style="float: right;background: red;padding: 2px;width: 21px;height: 100%;" class="mdi mdi-close"></span>
</a>
</div>
<div data-bs-toggle="modal" data-animation="bounce" data-bs-target="#booking_<?= $tretment_details_state_temp[$temp_count]['book_id'] ?>"
style="color:black; min-height: 100px; display: flex; justify-content: center; align-items: center; flex-direction: column; border-bottom: 3px solid black;">
<div style="white-space: nowrap;">
<div><?= $tretment_details_state_temp[$temp_count]['tr_name'] ?></div>
</div>
<div style="white-space: nowrap;">
<div><?= $tretment_details_state_temp[$temp_count]['name'] ?></div>
</div>
</div>
<div style="height: 30px;"></div>
</div>
<div style="display: flex;position: absolute; bottom:0; width:100%;" class="frame-1">
<button onclick="location.href = 'booking.php?booking_id=<?= $tretment_details_state_temp[$temp_count]['book_id']?>&emp_id=<?= $emp_id ?>&date=<?= $today_temp ?>&time=<?= $start_today_time_temp ?>&branch=<?=$branch_id?>'" style="background-color: black; width: 100%;" class="custom-btn btn-7">حجز</button>
<button onclick="location.href = 'work/order/php/getback.php?booking_id=<?= $tretment_details_state_temp[$temp_count]['book_id']?>'" style="background-color: black; width: 100%;" class="custom-btn btn-7 btn-8">استعادة</button>
</div>
</div>
</td>
<?php
break;
}
?>
<?php
$temp_count = $temp_count + 1;
if (($open_close_temp[$open_close_count]['day_time']) == ($start_today_time_temp) && $open_close_temp[$open_close_count]['emplyee_id'] == $emp_id) {
$open_close_count = $open_close_count + 1;
}
} elseif (($open_close_temp[$open_close_count]['day_time']) == ($start_today_time_temp) && $open_close_temp[$open_close_count]['emplyee_id'] == $emp_id) {
switch ($open_close_temp[$open_close_count]['status_id']) {
case 1:
?>
<td class="bg-gradient5">
<div title="اغلق بواسطة <?=$open_close_temp[$open_close_count]['name']?>" style="display: flex !important; flex-direction: column;">
<div style="height: 25px;">
<a style="color: white !important" href="work/order/php/open.php?date=<?= $today_temp ?>&time=<?= $start_today_time_temp ?>&emp_id=<?= $emp_id ?>&branch=<?=$branch_id?>&lo=<?=$today?>">
<span style="float: right;background: red;padding: 2px;width: 21px;height: 100%;" class="mdi mdi-close"></span>
</a>
</div>
<div style="height: 100px; display: flex; justify-content: center; align-items: center;">
<div>مغلق بواسطة <?=$open_close_temp[$open_close_count]['name']?></div>
</div>
<div style="height: 30px;"></div>
</div>
</td>
<?php
break;
case 2:
?>
<td>
<div style="position: relative;">
<div style="display: flex !important; flex-direction: column;" title="<?= $emp_neme .' - '. $start_today_time_temp ?>">
<div style="height: 25px;">
<a style="color: white !important" href="work/order/php/close.php?date=<?= $today_temp ?>&time=<?= $start_today_time_temp ?>&emp_id=<?= $emp_id ?>&branch=<?=$branch_id?>&lo=<?=$today?>">
<span style="float: right;background: red;padding: 2px;width: 21px;height: 100%;" class="mdi mdi-close"></span>
</a>
</div>
<div style="height: 100px; display: flex; justify-content: center; align-items: center; flex-direction: column;">
<div>
<div>متاح</div>
</div>
</div>
<div style="height: 30px;"></div>
</div>
<div style="display: flex;position: absolute; bottom:0; width:100%;" class="frame-1">
<button onclick="location.href = 'booking.php?emp_id=<?= $emp_id ?>&date=<?= $today_temp ?>&time=<?= $start_today_time_temp ?>&branch=<?=$branch_id?>'" style="background-color: black; width: 100%;" class="custom-btn btn-7">حجز</button>
</div>
</div>
</td>
<?php
break;
case 3: //جاري الحجز
?>
<td class="bg-gradient6" style="position: relative;">
<div style="display: flex !important; flex-direction: column;">
<div style="height: 25px;">
<?php
if ($open_close_temp[$open_close_count]['id'] == $admin_id) {
?>
<a style="color: white !important" href="work/order/php/open.php?date=<?= $today_temp ?>&time=<?= $start_today_time_temp ?>&emp_id=<?= $emp_id ?>&branch=<?=$branch_id?>&lo=<?=$today?>&lo=<?=$today?>&lo=<?=$today?>">
<span style="float: right;background: red;padding: 2px;width: 21px;height: 100%;" class="mdi mdi-close"></span>
</a>
<?php
}
if ((strtotime($open_close_temp[$open_close_count]['time'])+(60*5)) < (strtotime($time))) {
$temp_day_time = $open_close_temp[$open_close_count]['day_time'];
mysqli_query($db, "INSERT INTO `table`(`day_date`, `day_time`, `notes`, `branch_id`, `emplyee_id`, `status_id`, `date_time`, `user_id`, `activation_id`)
VALUES ('$today_temp', '$temp_day_time', '', '$branch_id', '$emp_id', '2', '$date_time', '1', '2')");
}
?>
</div>
<div style="height: 100px; display: flex; justify-content: center; align-items: center;">
<div>جاري الحجز بواسطة <?=$open_close_temp[$open_close_count]['name']?></div>
</div>
<div style="display: flex;position: absolute; bottom:0; width:100%;" class="cu_timer frame-1" value="<?=date("i:s", ((strtotime($open_close_temp[$open_close_count]['time'])+(60*5)) - (strtotime($time))))?>">
<?php
if ($open_close_temp[$open_close_count]['id'] == $admin_id) {
?>
<button onclick="location.href = 'booking.php?emp_id=<?= $emp_id ?>&date=<?= $today_temp ?>&time=<?= $start_today_time_temp ?>&branch=<?=$branch_id?>'" style="background-color: black; width: 100%;" class="custom-btn btn-7">استمرار</button>
<?php
}
?>
</div>
</div>
</td>
<?php
break;
}
$open_close_count = $open_close_count + 1;
} else if ($get_emplyee['day'] == $Day) {
?>
<td class="bg-gradient5">
<div title="اغلق بواسطة النظام" style="display: flex !important; flex-direction: column;">
<div style="height: 25px;">
<button onclick="location.href = 'booking.php?emp_id=<?= $emp_id ?>&date=<?= $today_temp ?>&time=<?= $start_today_time_temp ?>&branch=<?=$branch_id?>'" class="custom-btn btn-7">OVERTIME</button>
</div>
<div style="height: 100px; display: flex; justify-content: center; align-items: center;">
<div>اجازة</div>
</div>
<div style="height: 30px;"></div>
</div>
</td>
<?php
} else if (in_array($start_today_time, $pray_time) && in_array($start_today_time, $time_work)) {
?>
<td class="bg-gradient5">
<div title="اغلق بواسطة النظام" style="display: flex !important; flex-direction: column;">
<div style="height: 25px;">
<a style="color: white !important" href="work/order/php/open.php?date=<?= $today_temp ?>&time=<?= $start_today_time_temp ?>&emp_id=<?= $emp_id ?>&branch=<?=$branch_id?>&lo=<?=$today?>">
<span style="float: right;background: red;padding: 2px;width: 21px;height: 100%;" class="mdi mdi-close"></span>
</a>
</div>
<div style="height: 100px; display: flex; justify-content: center; align-items: center;">
<div>
غير متاح
<br />
(صلاه)
</div>
</div>
<div style="height: 30px;">
</div>
</div>
</td>
<?php
} else if (in_array($start_today_time_temp, $time_work)) {
?>
<td>
<div style="position: relative;">
<div style="display: flex !important; flex-direction: column;" title="<?= $emp_neme .' - '. $start_today_time_temp ?>">
<div style="height: 25px;">
<a style="color: white !important" href="work/order/php/close.php?date=<?= $today_temp ?>&time=<?= $start_today_time_temp ?>&emp_id=<?= $emp_id ?>&branch=<?=$branch_id?>&lo=<?=$today?>">
<span style="float: right;background: red;padding: 2px;width: 21px;height: 100%;" class="mdi mdi-close"></span>
</a>
</div>
<div style="height: 100px; display: flex; justify-content: center; align-items: center; flex-direction: column;">
<div>
<div>متاح</div>
</div>
</div>
<div style="height: 30px;"></div>
</div>
<div style="display: flex;position: absolute; bottom:0; width:100%;" class="frame-1">
<button onclick="location.href = 'booking.php?emp_id=<?= $emp_id ?>&date=<?= $today_temp ?>&time=<?= $start_today_time_temp ?>&branch=<?=$branch_id?>'" style="background-color: black; width: 100%;" class="custom-btn btn-7">حجز</button>
</div>
</div>
</td>
<?php
} else {
?>
<td class="bg-gradient5">
<div title="اغلق بواسطة النظام" style="display: flex !important; flex-direction: column;">
<div style="height: 25px;">
<button onclick="location.href = 'booking.php?emp_id=<?= $emp_id ?>&date=<?= $today_temp ?>&time=<?= $start_today_time_temp ?>&branch=<?=$branch_id?>'" class="custom-btn btn-7">OVERTIME</button>
</div>
<div style="height: 100px; display: flex; justify-content: center; align-items: center;">
<div>غير متاح</div>
</div>
<div style="height: 30px;">
</div>
</div>
</td>
<?php
}
}
}
?>
</tbody>
</table>
<!--end table-->
</div>
<!--end /div-->
</div>
</div>
</div>
<!--end card-body-->
</div>
<!--end card-->
</div>
</div>
</div>
<!-- Container-fluid Ends-->
</div>
<?php require_once('fixed/footer/go.php'); ?>
</div>
</div>
<?php require_once('fixed/js/go.php'); ?>
<script>
$("#Select-date").change(function() {
var SelectedDate = $(this).val();
window.location = 'book.php?branch=<?= $branch_id ?>&date=' + SelectedDate
});
$('.booking-cancel').on('click', function(e) {
e.preventDefault();
const href = $(this).attr('href');
swal.fire({
title: 'هل أنت متأكد',
text: 'من إلغاء الحجز',
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'نعم',
cancelButtonText: 'لا'
}).then((result) => {
if (result.value) {
document.location.href = href;
}
})
})
</script>
<?php
$lastid_php_sql = mysqli_query($db, "SELECT MAX(`id`) AS `id` FROM `book_details`;");
$lastid_php = mysqli_fetch_assoc($lastid_php_sql);
?>
<script>
function refrish() {
window.location.reload(1);
}
// Check if the entire page is already loaded
$( document ).ready(function() {
// Set the interval for the window refresh
window.setInterval(function() {
// get the database information
getInfo();
add_data();
}, 1000); // Check every 30 seconds (60000 milliseconds = 60 seconds = 1 minute)
function getInfo() {
//make the ajax call
$.ajax({
url: 'work/order/ajax/book_ajax.php',
type: 'POST',
data: {lastid : <?= json_encode($lastid_php['id']) ?>},
success: function(data) {
// If data is available then reflect it to the sales container
if (data['val'] == 1) {
refrish();
}
},
error: function (request, status, error) {
//alert(request.responseText + 'يرجى اعادة تحديث الصفحة');
refrish();
}
});
}
function add_data() {
$.post("work/order/ajax/add_to_book_temp_ajax.php", {})
}
});
</script>
</body>
</html>