634 lines
40 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
require_once('fixed/config/go_con.php');
$get_invoices_sql = mysqli_query(
$db,
"SELECT `r_month_user_invoices`.`filter`, `r_month_user_invoices`.`total`, `r_month_user_invoices`.`invoices_status_id`, `r_month_user_invoices`.`how_pay_id` FROM `r_month_user_invoices`
INNER JOIN `branch` ON `branch`.`id` = `r_month_user_invoices`.`branch_id`
WHERE `r_month_user_invoices`.`filter` > '2023-09-25'
AND `r_month_user_invoices`.`branch_id` = 12
AND `branch`.`commercial_register_id` = 3
"
);
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':
case '2':
switch ($get_invoices['how_pay_id']) {
case '1':
$data['inv'][$get_invoices['filter']]['cash'] += $get_invoices['total'];
break;
case '2':
$data['inv'][$get_invoices['filter']]['card'] += $get_invoices['total'];
break;
case '3':
case '4':
$data['inv'][$get_invoices['filter']]['stuck'] += $get_invoices['total'];
break;
case '6':
case '7':
case '8':
case '9':
case '10':
$data['inv'][$get_invoices['filter']]['trans'] += $get_invoices['total'];
break;
default:
$data['inv'][$get_invoices['filter']]['else'] += $get_invoices['total'];
$error++;
break;
}
break;
case '3':
switch ($get_invoices['how_pay_id']) {
case '1':
$data['back'][$get_invoices['filter']]['cash'] += $get_invoices['total'];
break;
case '2':
$data['back'][$get_invoices['filter']]['card'] += $get_invoices['total'];
break;
case '3':
case '4':
$data['back'][$get_invoices['filter']]['stuck'] += $get_invoices['total'];
break;
case '5':
$data['back'][$get_invoices['filter']]['trans'] += $get_invoices['total'];
break;
default:
$data['back'][$get_invoices['filter']]['else'] += $get_invoices['total'];
$error++;
break;
}
break;
default:
$error++;
break;
}
}
}
$get_invoices_sql = mysqli_query(
$db,
"SELECT `r_month_user_bonds`.`filter`, `r_month_user_bonds`.`total`, `r_month_user_bonds`.`bonds_status_id`, `r_month_user_bonds`.`how_pay_id` FROM `r_month_user_bonds`
INNER JOIN `branch` ON `branch`.`id` = `r_month_user_bonds`.`branch_id`
WHERE `r_month_user_bonds`.`filter` > '2023-09-25'
AND `r_month_user_bonds`.`branch_id` = 12
AND `branch`.`commercial_register_id` = 3
AND `branch`.`commercial_register_id` <> 5
"
);
if (mysqli_num_rows($get_invoices_sql) > 0) {
while ($get_invoices = mysqli_fetch_assoc($get_invoices_sql)) {
switch ($get_invoices['bonds_status_id']) {
case '1':
case '2':
switch ($get_invoices['how_pay_id']) {
case '1':
$data['bonds'][$get_invoices['filter']]['cash'] += $get_invoices['total'];
break;
case '2':
$data['bonds'][$get_invoices['filter']]['card'] += $get_invoices['total'];
break;
case '3':
case '4':
$data['bonds'][$get_invoices['filter']]['stuck'] += $get_invoices['total'];
break;
case '6':
case '7':
case '8':
case '9':
case '10':
$data['bonds'][$get_invoices['filter']]['trans'] += $get_invoices['total'];
break;
default:
$data['bonds'][$get_invoices['filter']]['else'] += $get_invoices['total'];
$error++;
break;
}
break;
case '3':
switch ($get_invoices['how_pay_id']) {
case '1':
$data['bond_back'][$get_invoices['filter']]['cash'] += $get_invoices['total'];
break;
case '2':
$data['bond_back'][$get_invoices['filter']]['card'] += $get_invoices['total'];
break;
case '3':
case '4':
$data['bond_back'][$get_invoices['filter']]['stuck'] += $get_invoices['total'];
break;
case '5':
$data['bond_back'][$get_invoices['filter']]['trans'] += $get_invoices['total'];
break;
default:
$data['bond_back'][$get_invoices['filter']]['else'] += $get_invoices['total'];
$error++;
break;
}
break;
default:
$error++;
break;
}
}
}
$get_bonds_details_has_services_sql = mysqli_query(
$db,
"SELECT DATE_FORMAT(`bonds_details_has_services`.`date_time`, '%Y-%m-%d') AS `date`, `services`.`price`, `services`.`name`,`services`.`id`, count(`services`.`id`) AS `count`, `bonds_details_has_services`.`bonds_details_id`
FROM `bonds_details_has_services`
INNER JOIN `bonds_details` ON `bonds_details_has_services`.`bonds_details_id` = `bonds_details`.`id`
INNER JOIN `services` ON `bonds_details_has_services`.`services_id` = `services`.`id`
WHERE `bonds_details_has_services`.`discount` = 50 AND `bonds_details_has_services`.`just_for_branch` = 12
GROUP BY DATE_FORMAT(`bonds_details_has_services`.`date_time`, '%Y-%m-%d'), `services_id`
ORDER BY `bonds_details_has_services`.`bonds_details_id` ASC
"
);
if (mysqli_num_rows($get_bonds_details_has_services_sql) > 0) {
while ($get_bonds_details_has_services = mysqli_fetch_assoc($get_bonds_details_has_services_sql)) {
$data['serv'][$get_bonds_details_has_services['date']]['serv'][$get_bonds_details_has_services['id']] = array(
'name' => $get_bonds_details_has_services['name'],
'count' => $get_bonds_details_has_services['count'],
'price' => round((round(($get_bonds_details_has_services['price']) + (($get_bonds_details_has_services['price'] * 15)/100),2) * $get_bonds_details_has_services['count']) / 2, 2)
);
}
}
?>
<!DOCTYPE html>
<html lang="en" dir="rtl">
<?php require_once('fixed/head/go.php'); ?>
<body class="rtl">
<style>
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'); ?>
<!-- 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">
<div class="container-fluid">
<div class="row">
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-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>
تقرير خصومات النسائي 50%
</h4>
</div>
<div class="col-12 col-sm-12 col-md-3 col-lg-4 col-xl-4">
</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"
style="vertical-align: middle;">
<thead class="table-primary" style="vertical-align: middle;">
<tr>
<th rowspan="2" scope="col" width='10%'>التاريخ</th>
<th rowspan="2" scope="col" width='10%'>البيان</th>
<th colspan="5" scope="col" width='10%'>المتحصلات اليومية
</th>
<th scope="col" colspan="3" width='70%'>الباقات ب خصم 50%</th>
</tr>
<tr>
<th scope="col" width='2%'>كاش</th>
<th scope="col" width='2%'>شبكة</th>
<th scope="col" width='2%'>تحويل</th>
<th scope="col" width='2%'>اخرى</th>
<th scope="col" width='2%'>إجمالي المتحصلات</th>
<th scope="col" width='20%'>السندات</th>
<th scope="col" width='30%'>خدمات خصم 50%</th>
<th scope="col" width='20%'>المبلغ المستفاد من ال50%</th>
</tr>
</thead>
<tbody>
<?php
$count = 1;
$t1_1 = 0;
$t1_2 = 0;
$t1_3 = 0;
$t1_4 = 0;
$t1_5 = 0;
$t2_1 = 0;
$t2_2 = 0;
$t2_3 = 0;
$t2_4 = 0;
$t2_5 = 0;
$t3_1 = 0;
$t3_2 = 0;
$t3_3 = 0;
$t3_4 = 0;
$t3_5 = 0;
$t4_1 = 0;
$t4_2 = 0;
$t4_3 = 0;
$t4_4 = 0;
$t4_5 = 0;
$t5_1 = 0;
$t5_2 = 0;
$t5_3 = 0;
$t5_4 = 0;
$t5_5 = 0;
$s1 = 0;
$s2 = 0;
$s3 = 0;
$s4 = 0;
$a1 = 0;
$a2 = 0;
$Zeroo = 0;
$frist_day = date('Y-m-d', strtotime('2023-09-26'));
$last_day = date('Y-m-d');
while ($frist_day <= $last_day) {
?>
<tr>
<?php
// every 4 is not add in total
$t1_1_temp = round($data['inv'][$frist_day]['cash'], 2);
$t1_2_temp = round($data['inv'][$frist_day]['card'], 2);
$t1_3_temp = round($data['inv'][$frist_day]['trans'], 2);
$t1_4_temp = round($data['inv'][$frist_day]['eles'], 2);
$t1_5_temp = $t1_1_temp + $t1_2_temp + $t1_3_temp;
$inv_stuck = round($data['inv'][$frist_day]['stuck'], 2);
//////////////////////////////////////////////////////////////////////
$t2_1_temp = round($data['back'][$frist_day]['cash'], 2);
$t2_2_temp = round($data['back'][$frist_day]['card'], 2);
$t2_3_temp = round($data['back'][$frist_day]['trans'], 2);
$t2_4_temp = round($data['back'][$frist_day]['eles'], 2);
// مرتجع لرصيد
$inv_back_stuck = round((($data['back'][$frist_day]['stuck'])), 2);
// التحويل لا يتم خصمة من المتحصلات
$t2_5_temp = $t2_1_temp + $t2_2_temp;
//////////////////////////////////////////////////////////////////////
$t3_1_temp = round($data['bonds'][$frist_day]['cash'], 2);
$t3_2_temp = round($data['bonds'][$frist_day]['card'], 2);
$t3_3_temp = round($data['bonds'][$frist_day]['trans'], 2);
$t3_4_temp = round($data['bonds'][$frist_day]['eles'], 2);
$t3_5_temp = $t3_1_temp + $t3_2_temp + $t3_3_temp;
$bonds_stuck = round($data['bonds'][$frist_day]['stuck'], 2);
//////////////////////////////////////////////////////////////////////
$t4_1_temp = round($data['bond_back'][$frist_day]['cash'], 2);
$t4_2_temp = round($data['bond_back'][$frist_day]['card'], 2);
$t4_3_temp = round($data['bond_back'][$frist_day]['trans'], 2);
$t4_4_temp = round($data['bond_back'][$frist_day]['eles'], 2);
// مرتجع لرصيد
$bonds_back_stuck = round($data['bond_back'][$frist_day]['stuck'], 2);
// التحويل لا يتم خصمة من المتحصلات
$t4_5_temp = $t4_1_temp + $t4_2_temp;
//////////////////////////////////////////////////////////////////////
$t5_1_temp = ($t1_1_temp - $t2_1_temp) + ($t3_1_temp - $t4_1_temp);
$t5_2_temp = ($t1_2_temp - $t2_2_temp) + ($t3_2_temp - $t4_2_temp);
$t5_3_temp = $t1_3_temp + $t3_3_temp;
$t5_4_temp = ($t1_4_temp - $t2_4_temp) + ($t3_4_temp - $t4_4_temp);
$t5_5_temp = $t5_1_temp + $t5_2_temp + $t5_3_temp;
//////////////////////////////////////////////////////////////////////
$s1_temp = $t1_5_temp;
$s2_temp = $inv_stuck;
$s3_temp = $t2_1_temp + $t2_2_temp + $t2_3_temp + $inv_back_stuck;
$s4_temp = ($s1_temp + $s2_temp) - $s3_temp;
$a1_temp = round($s4_temp - ($s4_temp / 1.15), 2);
$a2_temp = round($s4_temp / 1.15, 2);
?>
<td rowspan="5"><a
href="daily_user?date=<?= $frist_day ?>&b=<?= $branch_id ?>">
<?= $frist_day ?>
</a></td>
<td>فواتير</td>
<td>
<?= $t1_1_temp ?>
</td>
<td>
<?= $t1_2_temp ?>
</td>
<td>
<?= $t1_3_temp ?>
</td>
<td>
<?= $t1_4_temp ?>
</td>
<td>
<?= $t1_5_temp ?>
</td>
<td rowspan="5">
<?= $t3_5_temp ?>
</td>
<td rowspan="5">
<table class="table table-bordered text-center"
style="vertical-align: middle;">
<?php
$qweqwdfxs = 0;
if(is_array($data['serv'][$frist_day]) && count($data['serv'][$frist_day]) > 0) {
foreach ($data['serv'][$frist_day]['serv'] as $key => $value) {
?>
<thead class="table-primary"
style="vertical-align: middle;">
<tr>
<th scope="col"><?=$data['serv'][$frist_day]['serv'][$key]['name']?></th>
</tr>
</thead>
<tbody>
<tr>
<td><?=$data['serv'][$frist_day]['serv'][$key]['count']?></td>
</tr>
</tbody>
<?php
$qweqwdfxs += $data['serv'][$frist_day]['serv'][$key]['price'];
}
}
?>
</table>
</td>
<td rowspan="5">
<?=$qweqwdfxs?>
</td>
</tr>
<tr>
<td>إيرادات مرتجعة</td>
<td>
<?= $t2_1_temp ?>
</td>
<td>-
<?= $t2_2_temp ?>
</td>
<td>-
<?= $Zeroo ?>
</td>
<td>-
<?= $t2_4_temp ?>
</td>
<td>-
<?= $t2_5_temp ?>
</td>
</tr>
<tr>
<td>أرصدة دائنة للعملاء</td>
<td>
<?= $t3_1_temp ?>
</td>
<td>
<?= $t3_2_temp ?>
</td>
<td>
<?= $t3_3_temp ?>
</td>
<td>
<?= $t3_4_temp ?>
</td>
<td style="background:#e9f0ee;">
<?= $t3_5_temp ?>
</td>
</tr>
<tr>
<td>مرتجع أرصدة دائنة</td>
<td>-
<?= $t4_1_temp ?>
</td>
<td>-
<?= $t4_2_temp ?>
</td>
<td>-
<?= $Zeroo ?>
</td>
<td>-
<?= $t4_4_temp ?>
</td>
<td>-
<?= $t4_5_temp ?>
</td>
</tr>
<tr style="font-weight: bold;">
<td>مجموع</td>
<td>
<?= $t5_1_temp ?>
</td>
<td>
<?= $t5_2_temp ?>
</td>
<td>
<?= $t5_3_temp ?>
</td>
<td>
<?= $t5_4_temp ?>
</td>
<td>
<?= $t5_5_temp ?>
</td>
</tr>
<?php
$t1_1 += $t1_1_temp;
$t1_2 += $t1_2_temp;
$t1_3 += $t1_3_temp;
$t1_4 += $t1_4_temp;
$t1_5 += $t1_5_temp;
$t2_1 += $t2_1_temp;
$t2_2 += $t2_2_temp;
$t2_3 += $t2_3_temp;
$t2_4 += $t2_4_temp;
$t2_5 += $t2_5_temp;
$t3_1 += $t3_1_temp;
$t3_2 += $t3_2_temp;
$t3_3 += $t3_3_temp;
$t3_4 += $t3_4_temp;
$t3_5 += $t3_5_temp;
$t4_1 += $t4_1_temp;
$t4_2 += $t4_2_temp;
$t4_3 += $t4_3_temp;
$t4_4 += $t4_4_temp;
$t4_5 += $t4_5_temp;
$t5_1 += $t5_1_temp;
$t5_2 += $t5_2_temp;
$t5_3 += $t5_3_temp;
$t5_4 += $t5_4_temp;
$t5_5 += $t5_5_temp;
$s1 += $s1_temp;
$s2 += $s2_temp;
$s3 += $s3_temp;
$s4 += $s4_temp;
$a1 += $a1_temp;
$a2 += $a2_temp;
$count++;
$frist_day = date('Y-m-d', strtotime('+1 day', strtotime($frist_day)));
}
?>
<tr>
<td rowspan="6">المجموع الكلي</td>
</tr>
<tr>
<td>فواتير</td>
<td>
<?= $t1_1 ?>
</td>
<td>
<?= $t1_2 ?>
</td>
<td>
<?= $t1_3 ?>
</td>
<td>
<?= $t1_4 ?>
</td>
<td>
<?= $t1_5 ?>
</td>
<td rowspan="5">
<?= $s1 ?>
</td>
</tr>
<tr>
<td>إيرادات مرتجعة</td>
<td>-
<?= $t2_1 ?>
</td>
<td>-
<?= $t2_2 ?>
</td>
<td>-
<?= $Zeroo ?>
</td>
<td>-
<?= $t2_4 ?>
</td>
<td>-
<?= $t2_5 ?>
</td>
</tr>
<tr>
<td>أرصدة دائنة للعملاء</td>
<td>
<?= $t3_1 ?>
</td>
<td>
<?= $t3_2 ?>
</td>
<td>
<?= $t3_3 ?>
</td>
<td>
<?= $t3_4 ?>
</td>
<td>
<?= $t3_5 ?>
</td>
</tr>
<tr>
<td>مرتجع أرصدة دائنة</td>
<td>-
<?= $t4_1 ?>
</td>
<td>-
<?= $t4_2 ?>
</td>
<td>-
<?= $Zeroo ?>
</td>
<td>-
<?= $t4_4 ?>
</td>
<td>-
<?= $t4_5 ?>
</td>
</tr>
<tr>
<td>مجموع</td>
<td>
<?= $t5_1 ?>
</td>
<td>
<?= $t5_2 ?>
</td>
<td>
<?= $t5_3 ?>
</td>
<td>
<?= $t5_4 ?>
</td>
<td>
<?= $t5_5 ?>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php require_once('fixed/footer/go.php'); ?>
</div>
<div id="get_data"></div>
</div>
<?php require_once('fixed/js/go.php'); ?>
<script>
$("#Select-date").change(function () {
var SelectedDate = $(this).val();
window.location = 'month_user?branch=<?= $branch_id ?>&date=' + SelectedDate
});
</script>
</body>
</html>