booking/work/files/old/serv_come11092022.php

182 lines
11 KiB
PHP
Executable File

<?php
require_once('fixed/config/go_con.php');
access(50);
$today = date("Y-m");
if (!empty($_GET['date'])) {
$today = $_GET['date'];
if (DateTime::createFromFormat('Y-m', $today) == false) {
$today = date("Y-m");
}
}
$branch_id = $_SESSION['branch'];
if (!empty($_GET['branch'])) {
$branch_id = $_GET['branch'];
if (!is_numeric($branch_id)) {
$branch_id = $_SESSION['branch'];
}
}
$branch_sql = '`branch_id`='.$branch_id;
if ($branch_id == 1) {
$branch_sql = '`branch_id`<>'.$branch_id;
}
$Next = date('Y-m', strtotime('+1 month', strtotime($today)));
$Previous = date('Y-m', strtotime('-1 month', 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;
}
?>
<!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">
<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">
</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="emp_points.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="emp_points.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>
<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 class="table table-bordered text-center">
<thead class="table-primary" style="vertical-align: middle;">
<tr>
<th rowspan="2" scope="col">#</th>
<th rowspan="2" scope="col">اسم الخدمة</th>
<th rowspan="2" scope="col">عددها</th>
<th rowspan="2" scope="col">إيرادها بدون الضريبة</th>
</tr>
</thead>
<tbody>
<?php
$get_book_details_sql = mysqli_query($db,
"SELECT
`services`.`name`,
COUNT(`invoices_has_book`.`invoices_id`) AS `count`,
IFNULL(
(SELECT
SUM(`discount`)
FROM `invoices_discount_details`
WHERE `date_time` LIKE '2022-09-03%'
AND `services_id` = `services`.`id`
GROUP BY `services_id`
)
,0) AS `desc`,
SUM((`services`.`price`)) AS `price`
FROM `services`
LEFT JOIN `book_details` AS `dd` ON `dd`.`services_id` = `services`.`id`
LEFT JOIN `book` ON `dd`.`book_id` = `book`.`id`
LEFT JOIN `invoices_has_book` ON `invoices_has_book`.`book_id` = `book`.`id`
LEFT JOIN `invoices` ON `invoices_has_book`.`invoices_id` = `invoices`.`id`
WHERE `commercial_register_id` = 3
AND `dd`.`id` IN (SELECT MAX(`id`) FROM `book_details` WHERE `book_id` = `dd`.`book_id`)
AND `dd`.`status_id` IN (6,14,15,16)
AND `invoices`.`date_time` LIKE '$today%'
GROUP BY `services`.`id`
");
$count = 1;
while ($get_book_details = mysqli_fetch_assoc($get_book_details_sql)) {
?>
<tr>
<th scope="row"><?=$count?></th>
<td><?=$get_book_details['name']?></td>
<td><?=$get_book_details['count']?></td>
<td><?=round($get_book_details['price'] - $get_book_details['desc'],2)?></td>
</tr>
<?php
$count++;
}
?>
</tbody>
</table>
</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 = 'emp_points.php?branch=<?= $branch_id ?>&date=' + SelectedDate
});
</script>
</body>
</html>