287 lines
11 KiB
PHP
Executable File

<?php
require_once ('fixed/config/go_con.php');
require_once '../../vendor/autoload.php';
use chillerlan\QRCode\QRCode;
use chillerlan\QRCode\QROptions;
$page_name = "custom_reports?s=38&";
$page_title = " تقرير (المجاني)";
$today = date("Y-m");
if (!empty($_GET['d'])) {
$today = $_GET['d'];
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)));
$c_r_id = $_GET['c'];
if (!empty($_GET['c'])) {
$c_r_id = $_GET['c'];
if (!is_numeric($c_r_id)) {
$c_r_id = 1;
}
} else {
$c_r_id = 1;
}
$c_r_id_sql = '=' . $c_r_id;
if ($c_r_id == 1) {
$c_r_id_sql = '<>' . $c_r_id;
}
$branch_id = $_GET['b'];
if (!empty($_GET['b'])) {
$branch_id = $_GET['b'];
if (!is_numeric($branch_id)) {
$branch_id = 1;
}
} else {
$branch_id = 1;
}
if (!empty($_GET['f'])) {
if (is_numeric($c_r_id) && $_GET['f'] == 1) {
$branch_id = 1;
}
}
$branch_sql = '=' . $branch_id;
if ($branch_id == 1) {
$branch_sql = '<>' . $branch_id;
}
$error = 0;
$data = array();
$get_invoices_sql = mysqli_query(
$db,
"SELECT
`add_free_services`.`reason`,
`user_emp`.`name` AS `emp_name`,
`tretment`.`name` AS `tr_name`,
`tretment`.`number`,
`fromwho`.`name` AS `who_name`,
`services`.`name` AS `serv_name`,
`add_free_services_has_services`.`how_many`,
`services`.`price`
FROM `add_free_services`
INNER JOIN `tretment` ON `tretment`.`id` = `add_free_services`.`tretment_id`
INNER JOIN `emplyee` AS `fromwho` ON `fromwho`.`id` = `add_free_services`.`from_emplyee_id`
INNER JOIN `add_free_services_has_services` ON `add_free_services_has_services`.`add_free_services_id` = `add_free_services`.`id`
INNER JOIN `services` ON `services`.`id` = `add_free_services_has_services`.`services_id`
INNER JOIN `tretment_has_free_service` ON `tretment_has_free_service`.`done_id` IN (1,2,5) AND `tretment_has_free_service`.`table_id` = `add_free_services`.`id`
INNER JOIN `user` AS `u` ON `u`.`id` = `add_free_services`.`user_id`
INNER JOIN `emplyee` AS `user_emp` ON `user_emp`.`id` = `u`.`emplyee_id`
WHERE `tretment_has_free_service`.`date_time` LIKE '$today%'
GROUP BY `add_free_services`.`reason`, `serv_name`
"
);
if (mysqli_num_rows($get_invoices_sql) > 0) {
while ($get_invoices = mysqli_fetch_assoc($get_invoices_sql)) {
array_push($data, $get_invoices);
}
}
?>
<!DOCTYPE html>
<html lang="en" dir="rtl">
<?php require_once ('fixed/head/go.php'); ?>
<body class="rtl">
<style>
thead {
vertical-align: middle !important;
}
tr {
border-color: #bfbbbb !important;
}
.table-bordered td,
.table-bordered th {
border-color: #bfbbbb !important;
}
</style>
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/@mdi/font@6.5.95/css/materialdesignicons.min.css">
<?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="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">
<a class="nav-link mb-0 <?php if ($c_r_id == 1) {
echo 'active';
} ?> ?>" data-toggle="pill" href="#cr_1" aria-selected="false"
onclick="window.location='<?= $page_name ?>d=<?= $today ?>&b=<?= $branch_id ?>&c=1&f=1'">الكل</a>
<a class="nav-link mb-0 <?php if ($c_r_id == 2) {
echo 'active';
} ?> ?>" data-toggle="pill" href="#cr_2" aria-selected="false"
onclick="window.location='<?= $page_name ?>d=<?= $today ?>&b=<?= $branch_id ?>&c=2&f=1'">القسم
الرجالي</a>
<a class="nav-link mb-0 <?php if ($c_r_id == 3) {
echo 'active';
} ?> ?>" data-toggle="pill" href="#cr_3" aria-selected="false"
onclick="window.location='<?= $page_name ?>d=<?= $today ?>&b=<?= $branch_id ?>&c=3&f=1'">القسم
النسائي</a>
<a class="nav-link mb-0 <?php if ($c_r_id == 4) {
echo 'active';
} ?> ?>" data-toggle="pill" href="#cr_4" aria-selected="false"
onclick="window.location='<?= $page_name ?>d=<?= $today ?>&b=<?= $branch_id ?>&c=4&f=1'">القسم
الزيارات</a>
<a class="nav-link mb-0 <?php if ($c_r_id == 5) {
echo 'active';
} ?> ?>" data-toggle="pill" href="#cr_5" aria-selected="false"
onclick="window.location='<?= $page_name ?>d=<?= $today ?>&b=<?= $branch_id ?>&c=5&f=1'">القسم
الطبيعي</a>
</div>
</div>
</div>
<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 `commercial_register`.`id` $c_r_id_sql
OR `branch`.`id` = 1
");
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='<?= $page_name ?>d=<?= $today ?>&b=<?= $commercial_register['id'] ?>&c=<?= $c_r_id ?>'"><?= $commercial_register['branch_name'] ?></a>
<?php
}
?>
</div>
</div>
</div>
</div> -->
<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>
<?= $page_title ?>
<?= $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="<?= $page_name ?>d=<?= $Previous ?>" 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="<?= $page_name ?>d=<?= $Next ?>" 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">
<div class="table-responsive">
<table class="table table-bordered text-center" style="vertical-align: middle;">
<thead class="table-primary">
<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>
</tr>
</thead>
<t>
<?php
$count = 1;
$t_1 = 0;
$t_2 = 0;
foreach ($data as $key => $value) {
?>
<tr>
<td><?= $count ?></td>
<td><?= $data[$key]['tr_name'] ?></td>
<td><?= $data[$key]['number'] ?></td>
<td><?= $data[$key]['serv_name'] ?></td>
<td><?= $data[$key]['how_many'] ?></td>
<td><?= round($data[$key]['price'] * $data[$key]['how_many'], 2)?></td>
<td><?= $data[$key]['emp_name'] ?></td>
<td><?= $data[$key]['who_name'] ?></td>
<td><?= $data[$key]['reason'] ?></td>
<?php
$count++;
$t_1 += $data[$key]['how_many'];
$t_2 += round($data[$key]['price'] * $data[$key]['how_many'], 2);
}
?>
<tr>
<td colspan="4">المجاميع</td>
<td><?= $t_1 ?></td>
<td><?= $t_2 ?></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</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 = '<?= $page_name ?>d=' + SelectedDate
});
</script>
</body>
</html>