booking/daily_branchs_report.php

586 lines
25 KiB
PHP
Executable File

<?php
require_once('fixed/config/go_con.php');
access(42);
$MIX = true;
$today = date("Y-m-d");
$prev = 7;
$Day = date('D', strtotime($today));
$get_old_new = 0;
switch ($Day) {
case 'Sat':
$prev += 1;
$get_old_new = 0;
break;
case 'Sun':
$prev += 2;
$get_old_new = 1;
break;
case 'Mon':
$prev += 3;
$get_old_new = 2;
break;
case 'Tue':
$prev += 4;
$get_old_new = 3;
break;
case 'Wed':
$prev += 5;
$get_old_new = 4;
break;
case 'Thu':
$prev += 6;
$get_old_new = 5;
break;
case 'Fri':
$prev += 7;
$get_old_new = 6;
break;
};
$today = date('Y-m-d', strtotime('+1 day', strtotime($today)));
$Previous = date('Y-m-d', strtotime('-'.$prev.' day', strtotime($today)));
$data = array();
$get_report_for_invoice_daily_sql = mysqli_query($db, "SELECT `date`, `id`, `total` FROM `report_for_invoice_daily` WHERE `id` <> 0 AND (`date` BETWEEN '$Previous' AND '$today') ORDER BY `date`, `report_for_invoice_daily`.`id` ASC");
if (mysqli_num_rows($get_report_for_invoice_daily_sql) > 0) {
while ($row_report_for_invoice_daily = mysqli_fetch_assoc($get_report_for_invoice_daily_sql)) {
if(!array_key_exists($row_report_for_invoice_daily['date'], $data)){
$data[$row_report_for_invoice_daily['date']] = array();
}
$data[$row_report_for_invoice_daily['date']][$row_report_for_invoice_daily['id']] = $row_report_for_invoice_daily['total'];
}
}
$all = array(
'last' => array(),
'now' => array()
);
$exit_15 = array(
'last' => array(),
'now' => array()
);
$exit_7 = array(
'last' => array(),
'now' => array()
);
$exit_29 = array(
'last' => array(),
'now' => array()
);
$exit_6 = array(
'last' => array(),
'now' => array()
);
$count = 1;
foreach ($data as $key => $value) {
if($count <= 7) {
array_push($all['last'], round($data[$key]['2']+$data[$key]['3']+$data[$key]['4']+$data[$key]['5'],2));
array_push($exit_15['last'], round($data[$key]['2'],2));
array_push($exit_7['last'], round($data[$key]['3'],2));
array_push($exit_29['last'], round($data[$key]['4'],2));
array_push($exit_6['last'], round($data[$key]['5'],2));
} else {
array_push($all['now'], round($data[$key]['2']+$data[$key]['3']+$data[$key]['4']+$data[$key]['5'],2));
array_push($exit_15['now'], round($data[$key]['2'],2));
array_push($exit_7['now'], round($data[$key]['3'],2));
array_push($exit_29['now'], round($data[$key]['4'],2));
array_push($exit_6['now'], round($data[$key]['5'],2));
}
$count++;
}
function get_deg(int $old, int $new)
{
global $get_old_new;
if ($old > $new) {
return round((($old - $new)/$old)*100,2);
} elseif ($old < $new) {
return round((($new - $old)/$old)*100,2);
} else {
return 0;
}
}
function get_deg_arrow(int $old, int $new)
{
global $get_old_new;
if ($old > $new) {
return 'down';
} elseif ($old < $new) {
return 'up';
} else {
return '';
}
}
?>
<!DOCTYPE html>
<html lang="en" dir="rtl">
<?php require_once('fixed/head/go.php'); ?>
<body class="rtl">
<style>
.apexcharts-tooltip-series-group {
direction: rtl !important;
}
.apexcharts-tooltip-marker {
margin-right: auto;
margin-left: 10px;
}
</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">
<!-- Container-fluid starts-->
<div class="container-fluid chart-widget">
<div class="row">
<div class="col-xl-12">
<div class="card o-hidden">
<div class="chart-widget-top">
<div class="row card-body">
<div class="col-5">
<h6 class="f-w-600 font-primary">المبيعات جميع الفروع</h6><span class="num"><span><?php if(empty($all['now'][$get_old_new])) {echo get_deg($all['last'][$get_old_new - 1], $all['now'][$get_old_new - 1]);} else {echo get_deg($all['last'][$get_old_new], $all['now'][$get_old_new]);}?></span>%<i class="icon-angle-<?php if(empty($all['now'][$get_old_new])) {echo get_deg_arrow($all['last'][$get_old_new - 1], $all['now'][$get_old_new - 1]);} else {echo get_deg_arrow($all['last'][$get_old_new], $all['now'][$get_old_new]);}?> f-12"></i></span>
</div>
<div class="col-7 text-end">
<h4 class="num total-value"><span><?=$all['now'][count($all['now'])-1]?></span> ريال</h4>
</div>
</div>
<div>
<div id="chart-widget1"></div>
</div>
</div>
</div>
</div>
<div class="col-xl-3">
<div class="card o-hidden">
<div class="chart-widget-top">
<div class="row card-body">
<div class="col-5">
<h6 class="f-w-600 font-primary">المبيعات فرع 15</h6><span class="num"><span><?php if(empty($exit_15['now'][$get_old_new])) {echo get_deg($exit_15['last'][$get_old_new - 1], $exit_15['now'][$get_old_new - 1]);} else {echo get_deg($exit_15['last'][$get_old_new], $exit_15['now'][$get_old_new]);}?></span>%<i class="icon-angle-<?php if(empty($exit_15['now'][$get_old_new])) {echo get_deg_arrow($exit_15['last'][$get_old_new - 1], $exit_15['now'][$get_old_new - 1]);} else {echo get_deg_arrow($exit_15['last'][$get_old_new], $exit_15['now'][$get_old_new]);}?> f-12"></i></span>
</div>
<div class="col-7 text-end">
<h4 class="num total-value"><span><?=$exit_15['now'][count($exit_15['now'])-1]?></span> ريال</h4>
</div>
</div>
<div>
<div id="chart-widget2"></div>
</div>
</div>
</div>
</div>
<div class="col-xl-3">
<div class="card o-hidden">
<div class="chart-widget-top">
<div class="row card-body">
<div class="col-5">
<h6 class="f-w-600 font-primary">المبيعات فرع 7</h6><span class="num"><span><?php if(empty($exit_7['now'][$get_old_new])) {echo get_deg($exit_7['last'][$get_old_new - 1], $exit_7['now'][$get_old_new - 1]);} else {echo get_deg($exit_7['last'][$get_old_new], $exit_7['now'][$get_old_new]);}?></span>%<i class="icon-angle-<?php if(empty($exit_7['now'][$get_old_new])) {echo get_deg_arrow($exit_7['last'][$get_old_new - 1], $exit_7['now'][$get_old_new - 1]);} else {echo get_deg_arrow($exit_7['last'][$get_old_new], $exit_7['now'][$get_old_new]);}?> f-12"></i></span>
</div>
<div class="col-7 text-end">
<h4 class="num total-value"><span><?=$exit_7['now'][count($exit_7['now'])-1]?></span> ريال</h4>
</div>
</div>
<div>
<div id="chart-widget3"></div>
</div>
</div>
</div>
</div>
<div class="col-xl-3">
<div class="card o-hidden">
<div class="chart-widget-top">
<div class="row card-body">
<div class="col-5">
<h6 class="f-w-600 font-primary">المبيعات فرع 29</h6><span class="num"><span><?php if(empty($exit_29['now'][$get_old_new])) {echo get_deg($exit_29['last'][$get_old_new - 1], $exit_29['now'][$get_old_new - 1]);} else {echo get_deg($exit_29['last'][$get_old_new], $exit_29['now'][$get_old_new]);}?></span>%<i class="icon-angle-<?php if(empty($exit_29['now'][$get_old_new])) {echo get_deg_arrow($exit_29['last'][$get_old_new - 1], $exit_29['now'][$get_old_new - 1]);} else {echo get_deg_arrow($exit_29['last'][$get_old_new], $exit_29['now'][$get_old_new]);}?> f-12"></i></span>
</div>
<div class="col-7 text-end">
<h4 class="num total-value"><span><?=$exit_29['now'][count($exit_29['now'])-1]?></span> ريال</h4>
</div>
</div>
<div>
<div id="chart-widget4"></div>
</div>
</div>
</div>
</div>
<div class="col-xl-3">
<div class="card o-hidden">
<div class="chart-widget-top">
<div class="row card-body">
<div class="col-5">
<h6 class="f-w-600 font-primary">المبيعات فرع 6</h6><span class="num"><span><?php if(empty($exit_6['now'][$get_old_new])) {echo get_deg($exit_6['last'][$get_old_new - 1], $exit_6['now'][$get_old_new - 1]);} else {echo get_deg($exit_6['last'][$get_old_new], $exit_6['now'][$get_old_new]);}?></span>%<i class="icon-angle-<?php if(empty($exit_6['now'][$get_old_new])) {echo get_deg_arrow($exit_6['last'][$get_old_new - 1], $exit_6['now'][$get_old_new - 1]);} else {echo get_deg_arrow($exit_6['last'][$get_old_new], $exit_6['now'][$get_old_new]);}?> f-12"></i></span>
</div>
<div class="col-7 text-end">
<h4 class="num total-value"><span><?=$exit_6['now'][count($exit_6['now'])-1]?></span> ريال</h4>
</div>
</div>
<div>
<div id="chart-widget5"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Container-fluid Ends-->
</div>
<?php require_once('fixed/footer/go.php'); ?>
</div>
</div>
<?php require_once('fixed/js/go.php'); ?>
<script>
var optionslinechart = {
chart: {
toolbar: {
show: false
},
height: 320,
type: 'area'
},
dataLabels: {
enabled: false
},
stroke: {
curve: 'smooth'
},
series: [{
name: 'الاسبوع الحالي',
data: <?=json_encode($all['now'])?>,
}, {
name: 'الاسبوع الماضي',
data: <?=json_encode($all['last'])?>
}],
fill: {
colors: [vihoAdminConfig.primary, vihoAdminConfig.secondary],
type: 'gradient',
gradient: {
shade: 'light',
type: 'vertical',
shadeIntensity: 0.4,
inverseColors: false,
opacityFrom: 0.9,
opacityTo: 0.5,
stops: [0, 100]
}
},
colors: [vihoAdminConfig.primary, vihoAdminConfig.secondary],
labels: ['السبت', 'الأحد', 'الإثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة'],
markers: {
size: 0
},
yaxis: [{
axisBorder: {
show: false,
},
}],
legend: {
horizontalAlign: 'right'
},
tooltip: {
shared: true,
intersect: false,
y: {
formatter: function(y) {
if (typeof y !== "undefined") {
return (Math.round(y*100)/100) + " ريال ";
}
return y;
}
}
}
};
var chartlinechart = new ApexCharts(document.querySelector("#chart-widget1"), optionslinechart);
chartlinechart.render();
var optionslinechart = {
chart: {
toolbar: {
show: false
},
height: 170,
type: 'area'
},
dataLabels: {
enabled: false
},
stroke: {
curve: 'smooth'
},
xaxis: {
show: false,
type: 'text',
categories: ['الأحد', 'الإثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
labels: {
show: false,
},
axisBorder: {
show: false,
},
},
grid: {
show: false,
padding: {
left: 0,
right: 0,
bottom: -40
}
},
fill: {
type: 'gradient',
gradient: {
shade: 'light',
type: 'vertical',
shadeIntensity: 0.4,
inverseColors: false,
opacityFrom: 0.8,
opacityTo: 0.2,
stops: [0, 100]
},
},
colors: [vihoAdminConfig.primary, vihoAdminConfig.secondary],
series: [{
name: 'الاسبوع الحالي',
data: <?=json_encode($exit_15['now'])?>,
}, {
name: 'الاسبوع الماضي',
data: <?=json_encode($exit_15['last'])?>
}],
tooltip: {
x: {
format: 'dd/MM/yy'
},
y: {
formatter: function(y) {
if (typeof y !== "undefined") {
return (Math.round(y*100)/100) + " ريال ";
}
return y;
}
}
}
};
var chartlinechart = new ApexCharts(document.querySelector("#chart-widget2"), optionslinechart);
chartlinechart.render();
var optionslinechart = {
chart: {
toolbar: {
show: false
},
height: 170,
type: 'area'
},
dataLabels: {
enabled: false
},
stroke: {
curve: 'smooth'
},
xaxis: {
show: false,
type: 'text',
categories: ['الأحد', 'الإثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
labels: {
show: false,
},
axisBorder: {
show: false,
},
},
grid: {
show: false,
padding: {
left: 0,
right: 0,
bottom: -40
}
},
fill: {
type: 'gradient',
gradient: {
shade: 'light',
type: 'vertical',
shadeIntensity: 0.4,
inverseColors: false,
opacityFrom: 0.8,
opacityTo: 0.2,
stops: [0, 100]
},
},
colors: [vihoAdminConfig.primary, vihoAdminConfig.secondary],
series: [{
name: 'الاسبوع الحالي',
data: <?=json_encode($exit_7['now'])?>,
}, {
name: 'الاسبوع الماضي',
data: <?=json_encode($exit_7['last'])?>
}],
tooltip: {
x: {
format: 'dd/MM/yy'
},
y: {
formatter: function(y) {
if (typeof y !== "undefined") {
return (Math.round(y*100)/100) + " ريال ";
}
return y;
}
}
}
};
var chartlinechart = new ApexCharts(document.querySelector("#chart-widget3"), optionslinechart);
chartlinechart.render();
var optionslinechart = {
chart: {
toolbar: {
show: false
},
height: 170,
type: 'area'
},
dataLabels: {
enabled: false
},
stroke: {
curve: 'smooth'
},
xaxis: {
show: false,
type: 'text',
categories: ['الأحد', 'الإثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
labels: {
show: false,
},
axisBorder: {
show: false,
},
},
grid: {
show: false,
padding: {
left: 0,
right: 0,
bottom: -40
}
},
fill: {
type: 'gradient',
gradient: {
shade: 'light',
type: 'vertical',
shadeIntensity: 0.4,
inverseColors: false,
opacityFrom: 0.8,
opacityTo: 0.2,
stops: [0, 100]
},
},
colors: [vihoAdminConfig.primary, vihoAdminConfig.secondary],
series: [{
name: 'الاسبوع الحالي',
data: <?=json_encode($exit_29['now'])?>,
}, {
name: 'الاسبوع الماضي',
data: <?=json_encode($exit_29['last'])?>
}],
tooltip: {
x: {
format: 'dd/MM/yy'
},
y: {
formatter: function(y) {
if (typeof y !== "undefined") {
return (Math.round(y*100)/100) + " ريال ";
}
return y;
}
}
}
};
var chartlinechart = new ApexCharts(document.querySelector("#chart-widget4"), optionslinechart);
chartlinechart.render();
var optionslinechart = {
chart: {
toolbar: {
show: false
},
height: 170,
type: 'area'
},
dataLabels: {
enabled: false
},
stroke: {
curve: 'smooth'
},
xaxis: {
show: false,
type: 'text',
categories: ['الأحد', 'الإثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
labels: {
show: false,
},
axisBorder: {
show: false,
},
},
grid: {
show: false,
padding: {
left: 0,
right: 0,
bottom: -40
}
},
fill: {
type: 'gradient',
gradient: {
shade: 'light',
type: 'vertical',
shadeIntensity: 0.4,
inverseColors: false,
opacityFrom: 0.8,
opacityTo: 0.2,
stops: [0, 100]
},
},
colors: [vihoAdminConfig.primary, vihoAdminConfig.secondary],
series: [{
name: 'الاسبوع الحالي',
data: <?=json_encode($exit_6['now'])?>,
}, {
name: 'الاسبوع الماضي',
data: <?=json_encode($exit_6['last'])?>
}],
tooltip: {
x: {
format: 'dd/MM/yy'
},
y: {
formatter: function(y) {
if (typeof y !== "undefined") {
return (Math.round(y*100)/100) + " ريال ";
}
return y;
}
}
}
};
var chartlinechart = new ApexCharts(document.querySelector("#chart-widget5"), optionslinechart);
chartlinechart.render();
</script>
</body>
</html>