303 lines
14 KiB
PHP
Executable File

<?php
require_once('fixed/config/go_con.php');
$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;
}
$data = array();
$inv_sql = '';
$get_bonds_sql = mysqli_query($db,
"SELECT
`bd`.`day_date`,
`tretment`.`name` AS `tr_name`,
`tretment`.`number` AS `tr_number`,
`emplyee`.`name` AS `emp_name`,
`branch`.`branch_name`,
`services`.`name` AS `serv_name`,
`invoices`.`number_style`,
`invoices_details`.`invoices_status_id`,
`invoices_details_has_how_pay`.`pay`,
`how_pay`.`name` AS `how_pay`,
`drivers`.`name` AS `dr_name`
FROM
`book_has_driver_for_points`
INNER JOIN
`invoices_has_book` ON `book_has_driver_for_points`.`book_id` = `invoices_has_book`.`book_id`
INNER JOIN
`invoices` ON `invoices_has_book`.`invoices_id` = `invoices`.`id`
INNER JOIN
`invoices_details` ON `invoices_details`.`invoices_id` = `invoices`.`id`
INNER JOIN
`invoices_details_has_how_pay` ON `invoices_details_has_how_pay`.`invoices_details_id` = `invoices_details`.`id`
INNER JOIN
`how_pay` ON `how_pay`.`id` = `invoices_details_has_how_pay`.`how_pay_id`
INNER JOIN
`emplyee` AS `drivers` ON `drivers`.`id` = `book_has_driver_for_points`.`emplyee_id`
INNER JOIN
`book` ON `book`.`id` = `invoices_has_book`.`book_id`
INNER JOIN
`tretment` ON `tretment`.`id` = `book`.`tretment_id`
INNER JOIN
`book_details` AS `bd` ON `bd`.`book_id` = `book`.`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`
INNER JOIN
`emplyee` ON `bd`.`emplyee_id` = `emplyee`.`id`
INNER JOIN
`branch` ON `bd`.`branch_id` = `branch`.`id`
INNER JOIN
`services` ON `bd`.`services_id` = `services`.`id`
WHERE `invoices`.`date_time` LIKE '$today%'
AND `invoices_details`.`branch_id` $branch_sql
ORDER BY `invoices`.`number_style` ASC
");
$data = array();
if (mysqli_num_rows($get_bonds_sql) > 0) {
while ($get_bonds = mysqli_fetch_assoc($get_bonds_sql)) {
array_push($data , $get_bonds);
}
}
?>
<!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="row">
<div class="col-12 col-sm-12 col-md-12 col-lg-2 col-xl-2">
<div class="card">
<div class="card-body new-user order-list profile-nav">
<div class="nav flex-column nav-pills" id="profile-tab" aria-orientation="vertical">
<?php
$commercial_register_sql = mysqli_query($db, "SELECT `branch`.`branch_name`, `branch`.`id`
FROM `commercial_register`
LEFT JOIN `branch` ON `commercial_register`.`id` = `branch`.`commercial_register_id`
WHERE `branch`.`id` IN (1,7,8)"
);
while ($commercial_register = mysqli_fetch_assoc($commercial_register_sql)) {
?>
<a class="nav-link mb-0 <?php if($branch_id == $commercial_register['id']){echo 'active';}?> ?>" data-toggle="pill" href="#branch-<?=$commercial_register['id']?>" aria-selected="false" onclick="window.location='custom_reports?s=24&date=<?= $today ?>&b=<?=$commercial_register['id']?>'"><?=$commercial_register['branch_name']?></a>
<?php
}
?>
</div>
</div>
</div>
</div>
<div class="col-12 col-sm-12 col-md-12 col-lg-10 col-xl-10">
<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>
الزيارات يوم
<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="custom_reports?s=24&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="custom_reports?s=24&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="card-body new-user order-list">
<h6>تفاصيل التقرير</h6>
<ol>
<li>
التقرير يظهر حركات الاضافة التي حدثت في السندات الخاصة ب الخدمات
</li>
<li>
يجب ان يتطابق التقرير مع السندات بالشروط التالية
<ol>
<li>عدم حساب المرتجعات</li>
<li>دمج تقرير نوع رصيد الخدمات</li>
<li>دمج تقرير نوع رصيد الاموال</li>
</ol>
</li>
<li>
<b style="color:red">
تنبية :
</b>
عند وجود اي خطأ في (عدد الاخطاء) يرجى اشعار القسم التقني
</li>
</ol>
</div> -->
<div class="card-body new-user order-list">
عدد الاخطاء
<?= $error ?>
<div class="table-responsive">
<table id="data" 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>
<th scope="col">المدلك</th>
<th scope="col">الفرع</th>
<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) {
if($data[$key-1]['number_style'] == $data[$key]['number_style']) {
$data[$key]['pay'] = 0;
$data[$key]['how_pay'] = null;
$data[$key]['dr_name'] = null;
}
?>
<tr>
<td><?=$count?></td>
<td><?=$data[$key]['day_date']?></td>
<td><?=$data[$key]['tr_name']?></td>
<td><?=$data[$key]['tr_number']?></td>
<td><?=$data[$key]['emp_name']?></td>
<td><?=$data[$key]['branch_name']?></td>
<td><?=$data[$key]['serv_name']?></td>
<td><?=$data[$key]['pay']?></td>
<td><?=$data[$key]['how_pay']?></td>
<td><?=$data[$key]['dr_name']?></td>
</tr>
<?php
$count++;
}
?>
</tbody>
</table>
</div>
<button type="button" id="export_button" class="btn btn-success btn-sm">ملف excel</button>
</div>
</div>
</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 = 'custom_reports?s=24&b=<?= $branch_id ?>&date=' + SelectedDate
});
</script>
<script type="text/javascript" src="https://unpkg.com/xlsx@0.15.1/dist/xlsx.full.min.js"></script>
<script>
function padTo2Digits(num) {
return num.toString().padStart(2, '0');
}
function formatDate(date) {
return (
[
date.getFullYear(),
padTo2Digits(date.getMonth() + 1),
padTo2Digits(date.getDate()),
].join('') +
'' +
[
padTo2Digits(date.getHours()),
padTo2Digits(date.getMinutes()),
padTo2Digits(date.getSeconds()),
].join('')
);
}
function html_table_to_excel(type) {
var data = document.getElementById('data');
var file = XLSX.utils.table_to_book(data, { sheet: "sheet1" });
XLSX.write(file, { bookType: type, bookSST: true, type: 'base64' });
XLSX.writeFile(file, formatDate(new Date()) + 'driver_points_month.' + type);
}
const export_button = document.getElementById('export_button');
export_button.addEventListener('click', () => {
html_table_to_excel('xlsx');
});
</script>
</body>
</html>