277 lines
12 KiB
PHP
277 lines
12 KiB
PHP
<?php
|
|
require_once('fixed/config/go_con.php');
|
|
access(70);
|
|
|
|
$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['ba'];
|
|
if (!empty($_GET['ba'])) {
|
|
$branch_id = $_GET['ba'];
|
|
if (!is_numeric($branch_id)) {
|
|
$branch_id = 1;
|
|
}
|
|
} else {
|
|
$branch_id = 1;
|
|
}
|
|
$branch_sql = '='.$branch_id;
|
|
if ($branch_id == 1) {
|
|
$branch_sql = '<>'.$branch_id;
|
|
}
|
|
|
|
$data = array();
|
|
|
|
$get_invoices_sql = mysqli_query($db,
|
|
"SELECT
|
|
COUNT(`invoices`.`id`) AS `count`,
|
|
SUM(`invoices`.`price`) AS `total`,
|
|
SUM(`invoices`.`price_cut`) AS `total_cut`,
|
|
DATE(`invoices`.`date_time`) AS `date`
|
|
|
|
|
|
FROM `invoices`
|
|
LEFT JOIN `invoices_details` AS `dd` ON `dd`.`invoices_id` = `invoices`.`id`
|
|
LEFT JOIN `branch` ON `dd`.`branch_id` = `branch`.`id`
|
|
|
|
WHERE `branch`.`id` $branch_sql
|
|
AND `invoices`.`date_time` LIKE '$today%'
|
|
AND `dd`.`id` IN (SELECT MIN(`id`) FROM `invoices_details` WHERE `invoices_id` = `dd`.`invoices_id`)
|
|
|
|
GROUP BY `date`
|
|
ORDER BY `date` ASC
|
|
");
|
|
|
|
$toooot6 = 0;
|
|
while ($get_invoices = mysqli_fetch_assoc($get_invoices_sql)) {
|
|
$toooot6 += round($get_invoices['total'],2);
|
|
}
|
|
$data['total'] = $toooot6;
|
|
|
|
$get_invoices_sql = mysqli_query($db,
|
|
"SELECT
|
|
`services`.`id`,
|
|
`services`.`name`,
|
|
COUNT(`services`.`id`) AS `count`,
|
|
`services`.`price`
|
|
|
|
FROM `services`
|
|
INNER JOIN `book_details` AS `bb` ON `bb`.`services_id` = `services`.`id`
|
|
INNER JOIN `book` ON `bb`.`book_id` = `book`.`id`
|
|
|
|
WHERE `bb`.`id` IN (SELECT MAX(`id`) FROM `book_details` WHERE `book_id` = `bb`.`book_id`)
|
|
AND `bb`.`status_id` IN (6,8,14,15,16)
|
|
AND `bb`.`branch_id` $branch_sql
|
|
AND `bb`.`day_date` LIKE '$today%'
|
|
GROUP BY `services`.`id`
|
|
");
|
|
|
|
$toooot1 = 0;
|
|
$total_price_deq = 0;
|
|
$total_count_deq = 0;
|
|
while ($get_invoices = mysqli_fetch_assoc($get_invoices_sql)) {
|
|
if ($get_invoices['id'] != 0) {
|
|
$data['serv'][$get_invoices['id']] = array(
|
|
'name' => $get_invoices['name'],
|
|
'count' => $get_invoices['count'],
|
|
'price' => $get_invoices['price'],
|
|
'Max_price' => round($get_invoices['price']+ (($get_invoices['price']*$vat)/100),2) * $get_invoices['count'],
|
|
);
|
|
$total_price_deq += $get_invoices['price'];
|
|
$total_count_deq += $get_invoices['count'];
|
|
}
|
|
}
|
|
|
|
$html = '';
|
|
$serv = $data['serv'];
|
|
$count = 1;
|
|
$total_show_non_vat = 0;
|
|
$total_show_vat = 0;
|
|
$return_values = array();
|
|
foreach ($serv as $key => $value) {
|
|
$data['serv'][$key]['price_deq'] = $serv[$key]['price'] / $total_price_deq;
|
|
$data['serv'][$key]['count_deq'] = $serv[$key]['count'] / $total_count_deq;
|
|
$data['serv'][$key]['total_deq'] = ($data['serv'][$key]['price_deq'] + $data['serv'][$key]['count_deq']) / 2;
|
|
$data['serv'][$key]['deq'] = $data['serv'][$key]['total_deq'] * $data['total'];
|
|
|
|
//if ($data['serv'][$key]['Max_price'] < $data['serv'][$key]['deq']) {
|
|
// $temp1 = $data['serv'][$key]['Max_price'] / $data['total'];
|
|
// $temp2 = $data['serv'][$key]['total_deq'];
|
|
// $return_values['total'] += $temp2 - $temp1;
|
|
// $return_values[$key] = $temp2 - $temp1;
|
|
// $data['serv'][$key]['deq'] = $data['serv'][$key]['Max_price'];
|
|
//}
|
|
|
|
$html .= '
|
|
<tr>
|
|
<th scope="row">'.$count.'</th>
|
|
<td>'.$data['serv'][$key]['name'].'</td>
|
|
|
|
<td>'.round($data['serv'][$key]['deq']/1.15,2).'</td>
|
|
<td>'.round($data['serv'][$key]['deq'],2).'</td>
|
|
</tr>
|
|
';
|
|
//<td>'.$data['serv'][$key]['count'].'</td>
|
|
//<td>'.$data['serv'][$key]['Max_price'].'</td>
|
|
|
|
$total_show_non_vat += round($data['serv'][$key]['deq']/1.15,2);
|
|
$total_show_vat += $data['serv'][$key]['deq'];
|
|
$count++;
|
|
}
|
|
print_r($return_values);
|
|
?>
|
|
|
|
<!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='serv_come_inv?date=<?= $today ?>&ba=<?=$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="serv_come_inv?date=<?= $Previous ?>&ba=<?= $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="serv_come_inv?date=<?= $Next ?>&ba=<?= $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 rowspan="2" scope="col">#</th>
|
|
<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>
|
|
<?=$html?>
|
|
</tbody>
|
|
<tr>
|
|
<td colspan="2">المجموع</td>
|
|
<!--<td><?=$total_count_deq?></td>-->
|
|
<td><?=$total_show_non_vat?></td>
|
|
<td><?=$total_show_vat?></td>
|
|
</tr>
|
|
</table>
|
|
<button type="button" id="export_button" class="btn btn-success btn-sm">ملف excel</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- Container-fluid Ends-->
|
|
</div>
|
|
<?php require_once('fixed/footer/go.php'); ?>
|
|
</div>
|
|
</div>
|
|
<div id="get_data"></div>
|
|
<?php require_once('fixed/js/go.php'); ?>
|
|
<script type="text/javascript" src="https://unpkg.com/xlsx@0.15.1/dist/xlsx.full.min.js"></script>
|
|
<script>
|
|
$("#Select-date").change(function() {
|
|
var SelectedDate = $(this).val();
|
|
window.location = 'serv_come_inv?ba=<?= $branch_id ?>&date=' + SelectedDate
|
|
});
|
|
function html_table_to_excel(type)
|
|
{
|
|
var data = document.getElementById('employee_data');
|
|
var file = XLSX.utils.table_to_book(data, {sheet: "sheet1"});
|
|
XLSX.write(file, { bookType: type, bookSST: true, type: 'base64' });
|
|
XLSX.writeFile(file, 'الايراد للخدمة لكل شهر.' + type);
|
|
}
|
|
const export_button = document.getElementById('export_button');
|
|
export_button.addEventListener('click', () => {
|
|
html_table_to_excel('xlsx');
|
|
});
|
|
</script>
|
|
|
|
<?php require_once('fixed/waiting_ajax/go.php'); ?>
|
|
</body>
|
|
</html>
|