199 lines
9.3 KiB
PHP
Executable File

<?php
require_once('fixed/config/go_con.php');
$page_name = "custom_reports?s=40&";
$page_title = "عملاء 15 لم يستفيدوا من ال qr كود";
$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");
}
}
$Next = date('Y-m-d', strtotime('+1 day', strtotime($today)));
$Previous = date('Y-m-d', strtotime('-1 day', strtotime($today)));
$sql_date_req = "DATE_FORMAT(`bd`.`day_date`, '%Y-%m')";
$data = array();
$error = 0;
$start_today_time_sql = "08:00:00";
$end_today_time_sql = "23:59:59";
$how_many_left = "04:59:59";
$get_invoices_sql = 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`,
`services`.`name`,
`book`.`tretment_id`,
`book`.`notes`,
`book`.`date_time` AS `user_date`,
`user`.`name` AS `user_book`,
`tretment`.`name` AS `tr_name`,
`tretment`.`number`
FROM `book_details` AS `bd`
LEFT JOIN `book` ON `bd`.`book_id` = `book`.`id`
LEFT JOIN `tretment` ON `book`.`tretment_id` = `tretment`.`id`
LEFT JOIN `user` ON `book`.`user_id` = `user`.`id`
LEFT JOIN `services` ON `bd`.`services_id` = `services`.`id`
LEFT JOIN `emplyee` ON `bd`.`emplyee_id` = `emplyee`.`id`
JOIN (
SELECT `book_id`, MAX(`id`) AS `max_id`
FROM `book_details`
GROUP BY `book_id`
) `t1_max`
ON `bd`.`book_id` = `t1_max`.`book_id` AND `bd`.`id` = `t1_max`.`max_id`
WHERE `emplyee`.`activation_id` = 2
AND `bd`.`day_date` > '2024-03-18'
AND ((`bd`.`day_date`='$today' AND `bd`.`day_time` >= '$start_today_time_sql' AND `bd`.`day_time` <= '$end_today_time_sql')
OR (`bd`.`day_date` = '$Next' AND `bd`.`day_time` <= '$how_many_left'))
AND `bd`.`branch_id` = 2
AND `bd`.`status_id` IN (6,8,12,13,14,15)
AND `book`.`tretment_id` NOT IN (SELECT `tretment_id` FROM `tretment_has_coupons` WHERE `coupons_id` = 11)
ORDER BY `bd`.`day_time`, `bd`.`date_time`
");
if (mysqli_num_rows($get_invoices_sql) > 0) {
while ($get_invoices = mysqli_fetch_assoc($get_invoices_sql)) {
array_push($data, $get_invoices);
}
}
?>
<!DOCTYPE html>
<html lang="en" dir="rtl">
<?php require_once('fixed/head/go.php'); ?>
<body class="rtl">
<style>
tr {
border-color: #bfbbbb !important;
}
.table-bordered td,
.table-bordered th {
border-color: #bfbbbb !important;
}
</style>
<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">
<div class="container-fluid">
<div class="row">
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-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">
</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>
<?= $page_title ?>
<br />
<?= $today ?>
</h4>
</div>
<div class="col-12 col-sm-12 col-md-3 col-lg-4 col-xl-4">
</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="<?=$page_name?>t=<?= $r_type ?>&date=<?= $Previous ?>&b=<?= $branch_id ?>&c=<?= $c_r_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="<?=$page_name?>t=<?= $r_type ?>&date=<?= $Next ?>&b=<?= $branch_id ?>&c=<?= $c_r_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>
<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">
عدد الأخطاء
<?= $error ?>
<table class="table table-bordered text-center"
style="vertical-align: middle;">
<thead class="table-primary" style="vertical-align: middle;">
<tr>
<th scope="col">#</th>
<th scope="col">الاسم</th>
<th scope="col">الرقم</th>
<th scope="col">وقت الجلسة</th>
</tr>
</thead>
<tbody>
<?php
$count = 1;
foreach ($data as $key => $value) {
?>
<tr>
<td><?=$count?></td>
<td><?=$data[$key]['tr_name']?></td>
<td><?=$data[$key]['number']?></td>
<td><?=$data[$key]['day_time']?></td>
</tr>
<?php
$count++;
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php require_once('fixed/footer/go.php'); ?>
</div>
<div id="get_data"></div>
</div>
<?php require_once('fixed/js/go.php'); ?>
<script>
$("#Select-date").change(function () {
var SelectedDate = $(this).val();
window.location = '<?=$page_name?>t=<?= $r_type ?>&c=<?= $c_r_id ?>&b=<?= $branch_id ?>&date=' + SelectedDate
});
</script>
</body>
</html>