booking/r_free_serv.php

217 lines
11 KiB
PHP
Executable File

<?php
require_once('fixed/config/go_con.php');
access(74);
$today = date("Y-m");
if (!empty($_GET['date'])) {
$today = $_GET['date'];
if (DateTime::createFromFormat('Y-m', $today) == false) {
$today = date("Y-m");
}
}
$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;
}
?>
<!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='r_free_serv?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="r_free_serv?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_free_serv?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>
</tr>
</thead>
<tbody>
<?php
$total = 0;
$get_book_details_sql = mysqli_query($db,
"SELECT
`bd`.`day_date`,
`bd`.`day_time`,
`bd`.`branch_id`,
`emplyee`.`name` ,
`bd`.`status_id`,
`bd`.`date_time`,
`bd`.`book_id`,
`book`.`tretment_id`,
`book`.`notes`,
`book`.`date_time` AS `user_date`,
`user`.`name` AS `user_book`,
`tretment`.`name` AS `tr_name`,
`tretment`.`number`,
`services`.`price`,
`services`.`name` AS `serv_name`
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 `bd`.`user_id` = `user`.`id`
LEFT JOIN `services` ON `bd`.`services_id` = `services`.`id`
LEFT JOIN `emplyee` ON `bd`.`emplyee_id` = `emplyee`.`id`
WHERE `bd`.`status_id` IN (8,13)
AND `bd`.`id` IN (SELECT MAX(`book_details`.`id`)
FROM `book_details`
WHERE `book_details`.`book_id` = `bd`.`book_id` -- must make all like that
AND `book_details`.`status_id` IN (8,13)
GROUP BY `book_details`.`book_id`
)
AND `bd`.`day_date` LIKE '$today%'
AND `bd`.`branch_id` $branch_sql
ORDER BY `bd`.`day_time`, `bd`.`date_time`
");
$count = 1;
while ($get_book_details = mysqli_fetch_assoc($get_book_details_sql)) {
?>
<tr>
<th scope="row"><?=$count?></th>
<td><?=$get_book_details['day_date']?></td>
<td><?=$get_book_details['day_time']?></td>
<td><?=$get_book_details['name']?></td>
<td><?=$get_book_details['serv_name']?></td>
<td><?=$get_book_details['tr_name']?> <br> <?=$get_book_details['number']?></td>
<td><?=round($get_book_details['price'],2)?></td>
</tr>
<?php
$count++;
$total += round($get_book_details['price'],2);
}
?>
</tbody>
<tr>
<td colspan="6">المجموع</td>
<td><?=$total?></td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php require_once('fixed/footer/go.php'); ?>
</div>
</div>
<?php require_once('fixed/js/go.php'); ?>
<?php require_once('fixed/waiting_ajax/go.php'); ?>
<script>
$("#Select-date").change(function() {
var SelectedDate = $(this).val();
window.location = 'r_free_serv?b=<?= $branch_id ?>&date=' + SelectedDate
});
</script>
</body>
</html>