363 lines
21 KiB
PHP
363 lines
21 KiB
PHP
<?php
|
|
|
|
$today = date("Y-m");
|
|
if (!empty($_GET['date'])) {
|
|
$today = $_GET['date'];
|
|
if (DateTime::createFromFormat('Y-m', $today) == false) {
|
|
$today = date("Y-m");
|
|
}
|
|
}
|
|
|
|
|
|
$frist_day = date('Y-m-d', strtotime($today));
|
|
$last_day = date("Y-m-t", strtotime($frist_day));
|
|
$Previous_day = date('Y-m-d', strtotime('-1 day', strtotime($frist_day)));
|
|
$Next_day = date('Y-m-d', strtotime('+1 day', strtotime($last_day)));
|
|
|
|
$Next = date('Y-m', strtotime('+1 month', strtotime($today)));
|
|
$Previous = date('Y-m', strtotime('-1 month', 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();
|
|
|
|
// $get_invoices_sql = mysqli_query($db,
|
|
// "SELECT
|
|
// `invoices`.`id`,
|
|
// `invoices`.`number_style`,
|
|
// `invoices`.`price`,
|
|
// `invoices`.`date_time`
|
|
|
|
|
|
// FROM `invoices`
|
|
// LEFT JOIN `invoices_details` AS `dd` ON `dd`.`invoices_id` = `invoices`.`id`
|
|
// LEFT JOIN `branch` ON `dd`.`branch_id` = `branch`.`id`
|
|
|
|
// WHERE `branch`.`id` $branch_sql
|
|
// AND `invoices`.`date_time` LIKE '$today%'
|
|
// AND `dd`.`id` IN (SELECT MIN(`id`) FROM `invoices_details` WHERE `invoices_id` = `dd`.`invoices_id`)
|
|
|
|
// ORDER BY `invoices`.`date_time` ASC
|
|
// ");
|
|
|
|
$error = 0;
|
|
$data = array();
|
|
|
|
|
|
$get_invoices_sql = mysqli_query(
|
|
$db,
|
|
"SELECT
|
|
`invoices`.`number_style` AS `number_style`,
|
|
`invoices_details_has_how_pay`.`pay` AS `pay`,
|
|
`invoices_details`.`invoices_status_id` AS `invoices_status`,
|
|
`invoices_details`.`id` AS `invoices_details_id`,
|
|
`invoices_details`.`date_time` AS `date_time`,
|
|
`user`.`name` AS `user_name_active`,
|
|
`invoices_details_has_how_pay`.`how_pay_id` AS `how_pay_id`,
|
|
`services`.`name` AS `services_name`,
|
|
`book_user`.`name` AS `user_name_book`,
|
|
`emplyee`.`name` AS `emplyee_name`,
|
|
`branch`.`branch_name` AS `branch_name`,
|
|
`book`.`id` AS `book_id`
|
|
|
|
FROM `invoices_details_has_how_pay`
|
|
INNER JOIN `invoices_details` ON `invoices_details_has_how_pay`.`invoices_details_id` = `invoices_details`.`id`
|
|
INNER JOIN `invoices` ON `invoices_details`.`invoices_id` = `invoices`.`id`
|
|
INNER JOIN `user` ON `invoices_details_has_how_pay`.`user_id` = `user`.`id`
|
|
INNER JOIN `branch` ON `invoices_details`.`branch_id` = `branch`.`id`
|
|
INNER JOIN `invoices_has_book` ON `invoices_has_book`.`invoices_id` = `invoices`.`id`
|
|
INNER JOIN `book` ON `book`.`id` = `invoices_has_book`.`book_id`
|
|
INNER JOIN `book_details` ON `book_details`.`book_id` = `invoices_has_book`.`book_id` AND `book_details`.`id` = (SELECT MAX(`id`) FROM `book_details` WHERE `book_id` = `invoices_has_book`.`book_id`)
|
|
INNER JOIN `services` ON `book_details`.`services_id` = `services`.`id`
|
|
INNER JOIN `emplyee` ON `book_details`.`emplyee_id` = `emplyee`.`id`
|
|
INNER JOIN `user` AS `book_user` ON `book`.`user_id` = `book_user`.`id`
|
|
|
|
WHERE ((`invoices_details_has_how_pay`.`date_time` >= '$frist_day 03:00:00') AND (`invoices_details_has_how_pay`.`date_time` < '$Next_day 03:00:00'))
|
|
AND `invoices_details`.`branch_id` $branch_sql
|
|
ORDER BY `invoices`.`date_time` ASC
|
|
");
|
|
|
|
// if (mysqli_num_rows($get_invoices_sql) > 0) {
|
|
// while ($get_invoices = mysqli_fetch_assoc($get_invoices_sql)) {
|
|
// switch ($get_invoices['invoices_status_id']) {
|
|
// case '1':
|
|
// switch ($get_invoices['how_pay_id']) {
|
|
// case '1':
|
|
// $data[$get_invoices['number_style']][$get_invoices['id']]['cash'] = $get_invoices['pay'];
|
|
// break;
|
|
// case '2':
|
|
// $data[$get_invoices['number_style']][$get_invoices['id']]['card'] = $get_invoices['pay'];
|
|
// break;
|
|
// case '3':
|
|
// $data[$get_invoices['number_style']][$get_invoices['id']]['stuck'] = $get_invoices['pay'];
|
|
// break;
|
|
// default:
|
|
// $error++;
|
|
// break;
|
|
// }
|
|
// break;
|
|
// case '2':
|
|
// switch ($get_invoices['how_pay_id']) {
|
|
// case '1':
|
|
// $data[$get_invoices['number_style']][$get_invoices['id']]['cash'] = $get_invoices['pay'];
|
|
// break;
|
|
// case '2':
|
|
// $data[$get_invoices['number_style']][$get_invoices['id']]['card'] = $get_invoices['pay'];
|
|
// break;
|
|
// case '3':
|
|
// $data[$get_invoices['number_style']][$get_invoices['id']]['stuck'] = $get_invoices['pay'];
|
|
// break;
|
|
// default:
|
|
// $error++;
|
|
// break;
|
|
// }
|
|
// break;
|
|
// case '3':
|
|
// switch ($get_invoices['how_pay_id']) {
|
|
// case '1':
|
|
// $data[$get_invoices['number_style']][$get_invoices['id']]['cash'] = $get_invoices['pay'];
|
|
// break;
|
|
// case '2':
|
|
// $data[$get_invoices['number_style']][$get_invoices['id']]['card'] = $get_invoices['pay'];
|
|
// break;
|
|
// case '3':
|
|
// $data[$get_invoices['number_style']][$get_invoices['id']]['stuck'] = $get_invoices['pay'];
|
|
// break;
|
|
// default:
|
|
// $error++;
|
|
// break;
|
|
// }
|
|
// break;
|
|
// default:
|
|
// $error++;
|
|
// break;
|
|
// }
|
|
// }
|
|
// }
|
|
?>
|
|
|
|
<!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'); ?>
|
|
<div class="page-wrapper" id="pageWrapper">
|
|
<?php require_once('fixed/header/go.php'); ?>
|
|
<div class="page-body-wrapper">
|
|
<?php require_once('fixed/sidebar/go.php'); ?>
|
|
<div class="page-body">
|
|
<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-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`"
|
|
);
|
|
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='all_invoices?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="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="all_invoices?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="all_invoices?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">#</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>
|
|
<th scope="col">السعر</th>
|
|
<th scope="col">الاجمالي</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$count = 1;
|
|
while ($get_invoices = mysqli_fetch_assoc($get_invoices_sql)) {
|
|
?>
|
|
<tr>
|
|
<td>
|
|
<?= $count ?>
|
|
</td>
|
|
<td>
|
|
<?= $get_invoices['number_style']?>
|
|
</td>
|
|
<td>
|
|
<?= $get_invoices['date_time']?>
|
|
</td>
|
|
<td>
|
|
<?= $get_invoices['user_name_book']?>
|
|
</td>
|
|
<td>
|
|
<?= $get_invoices['book_id']?>
|
|
</td>
|
|
<td>
|
|
<?= $get_invoices['user_name_active']?>
|
|
</td>
|
|
<td>
|
|
<?= $get_invoices['emplyee_name']?>
|
|
</td>
|
|
<td>
|
|
<?= $get_invoices['branch_name']?>
|
|
</td>
|
|
<td>
|
|
<?= $get_invoices['services_name']?>
|
|
</td>
|
|
<td>
|
|
<?= 1?>
|
|
</td>
|
|
<td>
|
|
<?= $get_invoices['pay']?>
|
|
</td>
|
|
<td>
|
|
<?= $get_invoices['pay']?>
|
|
</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 = 'all_invoices?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>
|