309 lines
15 KiB
PHP
Executable File
309 lines
15 KiB
PHP
Executable File
<?php
|
|
require_once('fixed/config/go_con.php');
|
|
|
|
$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;
|
|
}
|
|
|
|
$frist_day = date('Y-m-d', strtotime($today));
|
|
$last_day = date("Y-m-t", strtotime($frist_day));
|
|
$last_day = date('Y-m-d', strtotime('+1 day', strtotime($last_day)));
|
|
|
|
$data = array();
|
|
|
|
$inv_sql = '';
|
|
$get_bonds_sql = mysqli_query($db,
|
|
"SELECT
|
|
`bonds`.`id` AS `inv_id`,
|
|
`bonds`.`number_style`,
|
|
`bonds_details`.`id`,
|
|
`bonds_details`.`bonds_status_id`,
|
|
DATE(`bonds_details`.`date_time`) AS `date`,
|
|
`bonds`.`date_time`,
|
|
`bonds_details_has_how_pay`.`date_time` AS `t_date_time`,
|
|
`bonds_details_has_how_pay`.`how_pay_id`,
|
|
`bonds_details_has_how_pay`.`pay`,
|
|
`tretment`.`name` AS `tr_name`,
|
|
`tretment`.`number` AS `tr_number`,
|
|
`user`.`name` AS `user_name`
|
|
|
|
FROM `bonds_details_has_how_pay`
|
|
INNER JOIN `bonds_details` ON `bonds_details_has_how_pay`.`bonds_details_id` = `bonds_details`.`id`
|
|
INNER JOIN `bonds` ON `bonds_details`.`bonds_id` = `bonds`.`id`
|
|
INNER JOIN `user` ON `bonds_details_has_how_pay`.`user_id` = `user`.`id`
|
|
INNER JOIN `branch` ON `bonds_details`.`branch_id` = `branch`.`id`
|
|
INNER JOIN `tretment` ON `bonds`.`tretment_id` = `tretment`.`id`
|
|
WHERE ((`bonds_details_has_how_pay`.`date_time` LIKE '$today%' AND `bonds_details_has_how_pay`.`date_time` >= '$frist_day 03:00:00') OR (`bonds_details_has_how_pay`.`date_time` LIKE '$last_day%' AND `bonds_details_has_how_pay`.`date_time` < '$last_day 03:00:00'))
|
|
AND `bonds_details`.`branch_id` $branch_sql
|
|
AND `bonds`.`bonds_type_type_id` = 2
|
|
AND `bonds_details`.`bonds_status_id` NOT IN (3)
|
|
ORDER BY `bonds_details_has_how_pay`.`date_time` ASC
|
|
");
|
|
|
|
$data['show']['inv'] = array();
|
|
if (mysqli_num_rows($get_bonds_sql) > 0) {
|
|
while ($get_bonds = mysqli_fetch_assoc($get_bonds_sql)) {
|
|
$inv_sql .= $get_bonds['inv_id'] . ', ';
|
|
if (!array_key_exists($get_bonds['id'],$data['show']['inv'])) {
|
|
$data['show']['inv'][$get_bonds['id']] = array();
|
|
}
|
|
switch ($get_bonds['bonds_status_id']) {
|
|
case '1': case '2':
|
|
switch ($get_bonds['how_pay_id']) {
|
|
case '1': case '2': case '3': case '4': case '6': case '7': case '8': case '9':
|
|
$data['show']['inv'][$get_bonds['id']]['payments'] += $get_bonds['pay'];
|
|
break;
|
|
default:
|
|
$error++;
|
|
break;
|
|
}
|
|
break;
|
|
case '3':
|
|
switch ($get_bonds['how_pay_id']) {
|
|
case '1': case '2': case '3': case '4': case '5':
|
|
$data['show']['inv'][$get_bonds['id']]['payments'] -= $get_bonds['pay'];
|
|
break;
|
|
default:
|
|
$error++;
|
|
break;
|
|
}
|
|
break;
|
|
default:
|
|
$error++;
|
|
break;
|
|
}
|
|
$data['show']['inv'][$get_bonds['id']]['number_style'] = $get_bonds['number_style'];
|
|
$data['show']['inv'][$get_bonds['id']]['date_time'] = $get_bonds['date_time'];
|
|
$data['show']['inv'][$get_bonds['id']]['t_date_time'] = $get_bonds['t_date_time'];
|
|
$data['show']['inv'][$get_bonds['id']]['inv_id'] = $get_bonds['inv_id'];
|
|
$data['show']['inv'][$get_bonds['id']]['tretment'] = '' . $get_bonds['tr_name'] . '<br/>' . $get_bonds['tr_number'];
|
|
$data['show']['inv'][$get_bonds['id']]['user_name'] = $get_bonds['user_name'];
|
|
}
|
|
}
|
|
|
|
|
|
?>
|
|
<!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'); ?>
|
|
<!-- 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">
|
|
<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='month_money?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="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="month_money?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="month_money?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="card-body new-user order-list">
|
|
<h6>تفاصيل التقرير</h6>
|
|
<ol>
|
|
<li>
|
|
التقرير يظهر حركات الاضافة التي حدثت في السندات الخاصة ب الباقات
|
|
</li>
|
|
<li>
|
|
يجب ان يكون عمود التطابق يساوي 0
|
|
<ol>
|
|
<li>اذا كان اقل ف يعني العميل دفع اقل من سعر الباقة</li>
|
|
<li>اذا كان اكثر ف يعني العميل دفع اكثر من سعر الباقة</li>
|
|
<li>وقد يكون العميل دفع نفس سعر الباقة ولكن الموظف اصدرها مع زيادتها او نقصانها</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
يجب ان يتطابق التقرير مع السندات بالشروط التالية
|
|
<ol>
|
|
<li>عدم حساب المرتجعات</li>
|
|
<li>دمج تقرير نوع رصيد الخدمات</li>
|
|
<li>دمج تقرير نوع رصيد الاموال</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
<b style="color:red">
|
|
تنبية :
|
|
</b>
|
|
عند وجود اي خطأ في (عدد الاخطاء) يرجى اشعار القسم التقني
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="card-body new-user order-list">
|
|
عدد الاخطاء
|
|
<?= $error ?>
|
|
<div class="table-responsive">
|
|
<table id="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
|
|
$count = 1;
|
|
foreach ($data['show']['inv'] as $key => $value) {
|
|
?>
|
|
<tr>
|
|
<td><?=$count?></td>
|
|
<td><?=$data['show']['inv'][$key]['number_style']?></td>
|
|
<td><?=$data['show']['inv'][$key]['date_time']?></td>
|
|
<td><?=$data['show']['inv'][$key]['t_date_time']?></td>
|
|
<td><?=$data['show']['inv'][$key]['payments']?></td>
|
|
<td><?=$data['show']['inv'][$key]['user_name']?></td>
|
|
<td><?=$data['show']['inv'][$key]['tretment']?></td>
|
|
</tr>
|
|
<?php
|
|
$count++;
|
|
}
|
|
?>
|
|
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<button type="button" id="export_button" class="btn btn-success btn-sm">ملف excel</button>
|
|
</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>
|
|
$("#Select-date").change(function() {
|
|
var SelectedDate = $(this).val();
|
|
window.location = 'month_money?b=<?= $branch_id ?>&date=' + SelectedDate
|
|
});
|
|
</script>
|
|
<script type="text/javascript" src="https://unpkg.com/xlsx@0.15.1/dist/xlsx.full.min.js"></script>
|
|
<script>
|
|
function padTo2Digits(num) {
|
|
return num.toString().padStart(2, '0');
|
|
}
|
|
|
|
function formatDate(date) {
|
|
return (
|
|
[
|
|
date.getFullYear(),
|
|
padTo2Digits(date.getMonth() + 1),
|
|
padTo2Digits(date.getDate()),
|
|
].join('') +
|
|
'' +
|
|
[
|
|
padTo2Digits(date.getHours()),
|
|
padTo2Digits(date.getMinutes()),
|
|
padTo2Digits(date.getSeconds()),
|
|
].join('')
|
|
);
|
|
}
|
|
|
|
function html_table_to_excel(type) {
|
|
var data = document.getElementById('data');
|
|
var file = XLSX.utils.table_to_book(data, { sheet: "sheet1" });
|
|
XLSX.write(file, { bookType: type, bookSST: true, type: 'base64' });
|
|
XLSX.writeFile(file, formatDate(new Date()) + 'month_money.' + type);
|
|
}
|
|
const export_button = document.getElementById('export_button');
|
|
export_button.addEventListener('click', () => {
|
|
html_table_to_excel('xlsx');
|
|
});
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|