booking/r_active_book_emp.php

228 lines
11 KiB
PHP
Executable File

<?php
require_once('fixed/config/go_con.php');
access(46);
$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)));
$branch_id = $_GET['b'];
if (!empty($_GET['b'])) {
$branch_id = $_GET['b'];
if (!is_numeric($branch_id)) {
$branch_id = 1;
}
} else {
$branch_id = 1;
}
$branch_sql = '='.$branch_id;
if ($branch_id == 1) {
$branch_sql = '<>'.$branch_id;
}
?>
<!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">
<style>
a.active {
background-color: #e6edef;
}
h1 {
background: #24695c;
padding-right: 10px;
color: white;
margin-left: 10px;
font-weight: bold;
}
</style>
<?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="email-wrap bookmark-wrap">
<div class="row">
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
<div class="card">
<div class="tab-content" id="profile-tabContent">
<div class="tab-pane fade show active" id="all">
<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>
تفعيل الجلسات للمدلكين
<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="r_active_book_emp?date=<?= $Previous ?>&b=<?= $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="r_active_book_emp?date=<?= $Next ?>&b=<?= $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>
<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">
<table id="employee_data" class="table table-bordered text-center" style="vertical-align: middle;">
<thead class="table-primary" style="vertical-align: middle;">
<tr>
<th scope="col" rowspan="2">#</th>
<th scope="col" rowspan="2">اسم الموظف</th>
<th scope="col" rowspan="2">الخدمة</th>
<th scope="col" rowspan="2">وقت الجلسة</th>
<th scope="col" rowspan="2">وقت الدفع</th>
<th scope="col" rowspan="2">وقت التفعيل</th>
<th scope="col" rowspan="2"></th>
<th scope="col" colspan="4">الوقت المتأخر</th>
<!--<th scope="col">الباقة الذهبية</th>-->
<!--<th scope="col">الباقة الالماسية</th>-->
<!--<th scope="col">المبلغ</th>-->
</tr>
<tr>
<th scope="col">ايام</th>
<th scope="col">ساعات</th>
<th scope="col">دثائق</th>
<th scope="col">ثواني</th>
</tr>
</thead>
<tbody>
<?php
$query = mysqli_query($db, "SELECT
`emplyee`.`name` AS `name`,
`book_details`.`day_date`,
`book_details`.`day_time`,
`book_details`.`date_time`,
`book_details`.`book_id`,
`services`.`name` AS `services_name`,
`invoices_has_book`.`date_time` AS `inv_date_time`
FROM `book_details`
INNER JOIN `emplyee` ON `book_details`.`emplyee_id` = `emplyee`.`id`
INNER JOIN `services` ON `services`.`id` = `book_details`.`services_id`
INNER JOIN `invoices_has_book` ON `invoices_has_book`.`book_id` = `book_details`.`book_id`
WHERE `book_details`.`status_id` = 14
AND `invoices_has_book`.`date_time` LIKE '$today%'
ORDER BY `book_details`.`date_time` DESC");
$count = 1;
while($row = mysqli_fetch_assoc($query)) {
$book_day_time = $row['day_date'] . ' ' . $row['day_time'];
$inv_date_time = $row['inv_date_time'];
$date_time = $row['date_time'];
?>
<tr>
<td><?=$count?></td>
<td><?=$row['name']?></td>
<td><?=$row['services_name']?></td>
<td><?=$book_day_time?></td>
<td><?=$inv_date_time?></td>
<td><?=$date_time?></td>
<?php
if(strtotime($date_time) > strtotime("$book_day_time + 30 minute")) {
?>
<td class="bg-danger">
متأخر
</td>
<?php } else { ?>
<td></td>
<?php } ?>
<?php
$datetime_1 = $book_day_time;
$datetime_2 = $date_time;
$start_datetime = new DateTime($datetime_1);
$diff = $start_datetime->diff(new DateTime($datetime_2));
// echo $diff->days.' Days total<br>';
// echo $diff->y.' Years<br>';
// echo $diff->m.' Months<br>';
// echo $diff->d.' Days<br>';
// echo $diff->h.' Hours<br>';
// echo $diff->i.' Minutes<br>';
// echo $diff->s.' Seconds<br>';
?>
<td><?=$diff->d?></td>
<td><?=$diff->h?></td>
<td><?=$diff->i?></td>
<td><?=$diff->s?></td>
</tr>
<?php $count++; } ?>
</tbody>
</table>
<button type="button" id="export_button" class="btn btn-success btn-sm">ملف excel</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Container-fluid Ends-->
</div>
<?php require_once('fixed/footer/go.php'); ?>
</div>
</div>
<div id="get_data"></div>
<?php require_once('fixed/js/go.php'); ?>
<script type="text/javascript" src="https://unpkg.com/xlsx@0.15.1/dist/xlsx.full.min.js"></script>
<script>
$("#Select-date").change(function() {
var SelectedDate = $(this).val();
window.location = 'r_active_book_emp?b=<?=$branch_id?>&date=' + SelectedDate
});
function html_table_to_excel(type)
{
var data = document.getElementById('employee_data');
var file = XLSX.utils.table_to_book(data, {sheet: "sheet1"});
XLSX.write(file, { bookType: type, bookSST: true, type: 'base64' });
XLSX.writeFile(file, 'تقرير تفعيل الجلسات .' + type);
}
const export_button = document.getElementById('export_button');
export_button.addEventListener('click', () => {
html_table_to_excel('xlsx');
});
</script>
<?php require_once('fixed/waiting_ajax/go.php'); ?>
</body>
</html>