618 lines
26 KiB
PHP
Executable File
618 lines
26 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=32&";
|
|
$page_title = "نموذج تقرير فواتير المبيعات";
|
|
$today = date("Y-m-d");
|
|
if (!empty($_GET['d'])) {
|
|
$today = $_GET['d'];
|
|
if (DateTime::createFromFormat('Y-m-d', $today) == false) {
|
|
$today = date("Y-m-d");
|
|
}
|
|
}
|
|
|
|
|
|
$Next = date('Y-m-d', strtotime('+1 day', strtotime($today)));
|
|
$Previous = date('Y-m-d', strtotime('-1 day', strtotime($today)));
|
|
$Day = date('D', strtotime($today));
|
|
|
|
|
|
function Day_ar()
|
|
{
|
|
global $Day;
|
|
$find = array("Sat", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri");
|
|
$replace = array("السبت", "الأحد", "الإثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة");
|
|
$ar_day_format = $Day;
|
|
$Day_ar = str_replace($find, $replace, $ar_day_format);
|
|
|
|
return $Day_ar;
|
|
}
|
|
|
|
function Today_ar()
|
|
{
|
|
global $today;
|
|
$Today_ar = date('d-m-Y', strtotime($today));
|
|
return $Today_ar;
|
|
}
|
|
|
|
$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();
|
|
$inv_ids = "";
|
|
|
|
|
|
|
|
function __round($value)
|
|
{
|
|
return number_format((float) round($value, 3), 3, '.', '');
|
|
}
|
|
function __round_show($value)
|
|
{
|
|
return number_format((float) round($value, 2), 2, '.', '');
|
|
}
|
|
function __getLength($value)
|
|
{
|
|
return strlen($value);
|
|
}
|
|
function __toHex($value)
|
|
{
|
|
return pack("H*", sprintf("%02X", $value));
|
|
}
|
|
function __toString($__tag, $__value, $__length)
|
|
{
|
|
$value = (string) $__value;
|
|
return __toHex($__tag) . __toHex($__length) . $value;
|
|
}
|
|
function __getTLV($dataToEncode)
|
|
{
|
|
$__TLVS = '';
|
|
for ($i = 0; $i < count($dataToEncode); $i++) {
|
|
$__tag = $dataToEncode[$i][0];
|
|
$__value = $dataToEncode[$i][1];
|
|
$__length = __getLength($__value);
|
|
$__TLVS .= __toString($__tag, $__value, $__length);
|
|
}
|
|
|
|
return $__TLVS;
|
|
}
|
|
|
|
|
|
|
|
$get_invoices_sql = mysqli_query(
|
|
$db,
|
|
"SELECT
|
|
`invoices`.`id` AS `i_id`,
|
|
`invoices`.`date_time`,
|
|
`invoices`.`number_style`,
|
|
`invoices_details_has_how_pay`.`how_pay_id`,
|
|
|
|
`invoices_details`.`pay`,
|
|
|
|
`invoices_discount`.`discount`,
|
|
|
|
`book`.`id` AS `b_id`,
|
|
|
|
`invoices_details`.`id` AS `id_id`,
|
|
`services`.`id` AS `serv_id`,
|
|
`services`.`name`,
|
|
`services`.`price`
|
|
|
|
FROM `invoices_details_has_how_pay`
|
|
INNER JOIN `invoices_details` ON `invoices_details_has_how_pay`.`invoices_details_id` = `invoices_details`.`id`
|
|
INNER JOIN `invoices_discount` ON `invoices_discount`.`invoices_details_id` = `invoices_details`.`id`
|
|
INNER JOIN `invoices` ON `invoices_details`.`invoices_id` = `invoices`.`id`
|
|
INNER JOIN `invoices_has_book` ON `invoices_has_book`.`invoices_id` = `invoices`.`id`
|
|
INNER JOIN `book` ON `invoices_has_book`.`book_id` = `book`.`id`
|
|
INNER JOIN `book_details` AS `bd` ON `bd`.`book_id` = `book`.`id`
|
|
INNER JOIN `services` ON `bd`.`services_id` = `services`.`id`
|
|
JOIN (
|
|
SELECT `book_id`, MAX(`id`) AS `max_id`
|
|
FROM `book_details`
|
|
GROUP BY `book_id`
|
|
) `t1_max`
|
|
ON `bd`.`book_id` = `t1_max`.`book_id` AND `bd`.`id` = `t1_max`.`max_id`
|
|
|
|
WHERE ((`invoices_details_has_how_pay`.`date_time` LIKE '$today%' AND `invoices_details_has_how_pay`.`date_time` >= '$today 03:00:00') OR (`invoices_details_has_how_pay`.`date_time` LIKE '$Next%' AND `invoices_details_has_how_pay`.`date_time` < '$Next 03:00:00'))
|
|
AND `invoices_details`.`branch_id` $branch_sql
|
|
AND `invoices_details`.`invoices_status_id` = 1
|
|
AND `invoices_details_has_how_pay`.`how_pay_id` IN (1,2,6,7,8,9,10)
|
|
|
|
ORDER BY `invoices`.`number_style`
|
|
"
|
|
);
|
|
|
|
if (mysqli_num_rows($get_invoices_sql) > 0) {
|
|
while ($get_invoices = mysqli_fetch_assoc($get_invoices_sql)) {
|
|
|
|
$QR_dataToEncode = [
|
|
[1, $campany_info['company_name']],
|
|
[2, $campany_info['vat_number']],
|
|
[3, date("Y-m-d\TH:i:s", strtotime($get_invoices['date_time']))],
|
|
[4, round($get_invoices['pay'], 2)],
|
|
[5, round((($get_invoices['pay'] / 1.15) * $vat / 100), 2)]
|
|
];
|
|
$QR___TLV = __getTLV($QR_dataToEncode);
|
|
$QR___QR = base64_encode($QR___TLV);
|
|
$QR_data = $QR___QR;
|
|
$QR_options = new QROptions([
|
|
'version' => 8,
|
|
'outputType' => QRCode::OUTPUT_IMAGE_PNG,
|
|
'eccLevel' => QRCode::ECC_L,
|
|
'scale' => 3,
|
|
'imageBase64' => true,
|
|
]);
|
|
$QR_qrcode = new QRCode($QR_options);
|
|
$QR_qrCodeBase64 = $QR_qrcode->render($QR_data);
|
|
|
|
|
|
|
|
if (array_key_exists($get_invoices['i_id'], $data)) {
|
|
|
|
|
|
$data[$get_invoices['i_id']]['books'][$get_invoices['b_id']] = array(
|
|
's_name' => $get_invoices['name'],
|
|
's_count' => 1,
|
|
's_price' => __round($get_invoices['price']),
|
|
's_price_with_s_count' => __round($get_invoices['price']),
|
|
'total_with_des' => __round($get_invoices['price']) - __round($get_invoices['discount']),
|
|
'vat_rate' => 15,
|
|
'vat' => ((__round($get_invoices['price']) - __round($get_invoices['discount'])) * 0.15),
|
|
'total_with_vat' => ((__round($get_invoices['price']) - __round($get_invoices['discount'])) * 0.15) + (__round($get_invoices['price']) - __round($get_invoices['discount'])),
|
|
'des' => __round($get_invoices['discount']),
|
|
'tt_pay' => __round($get_invoices['pay']),
|
|
);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($get_invoices['serv_id'] == 0) {
|
|
$book_id_for_bundle = $get_invoices['b_id'];
|
|
$bundle_s = mysqli_query($db, "SELECT
|
|
`services`.`id`,
|
|
`services`.`name`,
|
|
`bundle_services_has_services`.`how_many`,
|
|
`services`.`price`
|
|
|
|
FROM `bundle_services_has_services`
|
|
INNER JOIN `services` ON `services`.`id` = `bundle_services_has_services`.`services_id`
|
|
WHERE `bundle_services_has_services`.`bundle_services_id` = (SELECT `bundle_services_id` FROM `book_details_has_bundle_services` WHERE `book_details_id` = (SELECT MIN(`id`) FROM `book_details` WHERE `book_id` = $book_id_for_bundle AND `status_id` = 4))
|
|
");
|
|
|
|
if (mysqli_num_rows($bundle_s) > 0) {
|
|
while ($bundle_s_row = mysqli_fetch_assoc($bundle_s)) {
|
|
|
|
if (!array_key_exists($get_invoices['i_id'], $data)) {
|
|
$data[$get_invoices['i_id']] = array(
|
|
'number_style' => $get_invoices['number_style'],
|
|
'date_time' => $get_invoices['date_time'],
|
|
|
|
'books' => array(),
|
|
'tr_vat_name' => '',
|
|
'tr_vat_number' => '',
|
|
'tr_vat_adress' => '',
|
|
'tr_card_id' => '',
|
|
|
|
'QR' => $QR_qrCodeBase64,
|
|
|
|
);
|
|
}
|
|
|
|
|
|
$data[$get_invoices['i_id']]['books'][$get_invoices['b_id'] . $bundle_s_row['id']] = array(
|
|
's_name' => $bundle_s_row['name'],
|
|
's_count' => $bundle_s_row['how_many'],
|
|
's_price' => __round($bundle_s_row['price']),
|
|
's_price_with_s_count' => __round($bundle_s_row['price'] * $bundle_s_row['how_many']),
|
|
'total_with_des' => __round($bundle_s_row['price'] * $bundle_s_row['how_many']) - __round($get_invoices['discount']),
|
|
'vat_rate' => 15,
|
|
'vat' => ((__round($bundle_s_row['price'] * $bundle_s_row['how_many']) - __round($get_invoices['discount'])) * 0.15),
|
|
'total_with_vat' => ((__round($bundle_s_row['price'] * $bundle_s_row['how_many']) - __round($get_invoices['discount'])) * 0.15) + (__round($bundle_s_row['price'] * $bundle_s_row['how_many']) - __round($get_invoices['discount'])),
|
|
'des' => __round($get_invoices['discount']),
|
|
'tt_pay' => __round($get_invoices['pay']),
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$data[$get_invoices['i_id']] = array(
|
|
'number_style' => $get_invoices['number_style'],
|
|
'date_time' => $get_invoices['date_time'],
|
|
|
|
'books' => array(
|
|
$get_invoices['b_id'] => array(
|
|
's_name' => $get_invoices['name'],
|
|
's_count' => 1,
|
|
's_price' => __round($get_invoices['price']),
|
|
's_price_with_s_count' => __round($get_invoices['price']),
|
|
'total_with_des' => __round($get_invoices['price']) - __round($get_invoices['discount']),
|
|
'vat_rate' => 15,
|
|
'vat' => ((__round($get_invoices['price']) - __round($get_invoices['discount'])) * 0.15),
|
|
'total_with_vat' => ((__round($get_invoices['price']) - __round($get_invoices['discount'])) * 0.15) + (__round($get_invoices['price']) - __round($get_invoices['discount'])),
|
|
'des' => __round($get_invoices['discount']),
|
|
'tt_pay' => __round($get_invoices['pay']),
|
|
)
|
|
),
|
|
'tr_vat_name' => '',
|
|
'tr_vat_number' => '',
|
|
'tr_vat_adress' => '',
|
|
'tr_card_id' => '',
|
|
|
|
'QR' => $QR_qrCodeBase64,
|
|
|
|
);
|
|
}
|
|
}
|
|
$inv_ids .= $get_invoices['i_id'] . ',';
|
|
}
|
|
$inv_ids = rtrim($inv_ids, ',');
|
|
}
|
|
$get_invoices_sql = mysqli_query(
|
|
$db,
|
|
"SELECT `invoices_details`.`invoices_id`, `invoices_details_has_how_pay`.`pay`
|
|
|
|
FROM `invoices_details_has_how_pay`
|
|
INNER JOIN `invoices_details` ON `invoices_details_has_how_pay`.`invoices_details_id` = `invoices_details`.`id`
|
|
|
|
WHERE ((`invoices_details_has_how_pay`.`date_time` LIKE '2024-05-26%' AND `invoices_details_has_how_pay`.`date_time` >= '2024-05-26 03:00:00') OR (`invoices_details_has_how_pay`.`date_time` LIKE '2024-05-27%' AND `invoices_details_has_how_pay`.`date_time` < '2024-05-27 03:00:00'))
|
|
AND `invoices_details_has_how_pay`.`how_pay_id` IN (3,4)
|
|
AND `invoices_details`.`branch_id` $branch_sql
|
|
AND `invoices_details`.`invoices_status_id` = 1
|
|
AND `invoices_details`.`invoices_id` IN ($inv_ids)
|
|
"
|
|
);
|
|
|
|
if (mysqli_num_rows($get_invoices_sql) > 0) {
|
|
while ($get_invoices = mysqli_fetch_assoc($get_invoices_sql)) {
|
|
$data[$get_invoices['invoices_id']]['from_stuck'] += $get_invoices['pay'] / 1.15;
|
|
$data[$get_invoices['invoices_id']]['from_stuck_vat'] += $get_invoices['pay'];
|
|
}
|
|
}
|
|
|
|
?>
|
|
<!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 ?>
|
|
<?= Day_ar() ?>
|
|
<br />
|
|
<?= Today_ar() ?>
|
|
</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>
|
|
<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>
|
|
<tbody>
|
|
<?php
|
|
$count = 1;
|
|
$t1 = 0;
|
|
$t2 = 0;
|
|
$t3 = 0;
|
|
$t4 = 0;
|
|
$t5 = 15;
|
|
$t6 = 0;
|
|
$t7 = 0;
|
|
foreach ($data as $key => $value) {
|
|
?>
|
|
|
|
<tr>
|
|
<td rowspan="<?= count($data[$key]['books']) ?>"><?= $count ?></td>
|
|
<td rowspan="<?= count($data[$key]['books']) ?>"><?= $data[$key]['number_style'] ?></td>
|
|
<td rowspan="<?= count($data[$key]['books']) ?>"><?= $data[$key]['date_time'] ?></td>
|
|
<?php
|
|
if (count($data[$key]['books']) > 1) {
|
|
$price_temp = 0;
|
|
foreach ($data[$key]['books'] as $key2 => $value2) {
|
|
$price_temp += __round($data[$key]['books'][$key2]['s_price']);
|
|
}
|
|
}
|
|
$cc = 0;
|
|
foreach ($data[$key]['books'] as $key2 => $value2) {
|
|
if (count($data[$key]['books']) > 1) {
|
|
$cc += 1;
|
|
$ber_temp = __round($data[$key]['books'][$key2]['s_price']) / __round($price_temp);
|
|
$total_des = ($data[$key]['books'][$key2]['des'] + $data[$key]['from_stuck']) * $ber_temp;
|
|
$tt_pay = $data[$key]['books'][$key2]['tt_pay'] - $data[$key]['from_stuck_vat'];
|
|
|
|
$data[$key]['books'][$key2]['des'] = __round($total_des);
|
|
$data[$key]['books'][$key2]['total_with_des'] = __round($data[$key]['books'][$key2]['s_price_with_s_count']) - __round($data[$key]['books'][$key2]['des']);
|
|
$data[$key]['books'][$key2]['vat'] = __round($data[$key]['books'][$key2]['total_with_des']) * 0.15;
|
|
$data[$key]['books'][$key2]['total_with_vat'] = __round($data[$key]['books'][$key2]['total_with_des']) + __round($data[$key]['books'][$key2]['vat']);
|
|
|
|
if(count($data[$key]['books']) == $cc) {
|
|
$tt = 0;
|
|
foreach ($data[$key]['books'] as $key3 => $value3) {
|
|
$tt += __round_show($data[$key]['books'][$key3]['total_with_vat']);
|
|
}
|
|
echo $data[$key]['number_style'];
|
|
echo ' // // // ';
|
|
echo __round_show($tt);
|
|
echo ' // // // ';
|
|
echo __round_show($tt_pay);
|
|
echo ' // // // ';
|
|
echo __round_show($data[$key]['books'][$key2]['total_with_vat']);
|
|
echo '<br/>';
|
|
if (__round_show($tt) != __round_show($tt_pay)){
|
|
if(__round_show($tt) < __round_show($tt_pay)) {
|
|
$data[$key]['books'][$key2]['total_with_vat'] += 0.01;
|
|
} else if (__round_show($tt) > __round_show($tt_pay)) {
|
|
$data[$key]['books'][$key2]['total_with_vat'] -= 0.01;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (count($data[$key]['books']) == 1 && $data[$key]['from_stuck'] > 0){
|
|
$total_des = ($data[$key]['books'][$key2]['des'] + $data[$key]['from_stuck']);
|
|
|
|
$data[$key]['books'][$key2]['des'] = __round($total_des);
|
|
$data[$key]['books'][$key2]['total_with_des'] = __round($data[$key]['books'][$key2]['s_price_with_s_count']) - __round($data[$key]['books'][$key2]['des']);
|
|
$data[$key]['books'][$key2]['vat'] = __round($data[$key]['books'][$key2]['total_with_des']) * 0.15;
|
|
$data[$key]['books'][$key2]['total_with_vat'] = __round($data[$key]['books'][$key2]['total_with_des']) + __round($data[$key]['books'][$key2]['vat']);
|
|
}
|
|
?>
|
|
<td><?= $data[$key]['books'][$key2]['s_name'] ?></td>
|
|
<td><?= $data[$key]['books'][$key2]['s_count'] ?></td>
|
|
<td><?= __round_show($data[$key]['books'][$key2]['s_price']) ?></td>
|
|
<td><?= __round_show($data[$key]['books'][$key2]['s_price_with_s_count']) ?></td>
|
|
|
|
<td><?= __round_show($data[$key]['books'][$key2]['des']) ?></td>
|
|
|
|
<td><?= __round_show($data[$key]['books'][$key2]['total_with_des']) ?></td>
|
|
<td><?= $data[$key]['books'][$key2]['vat_rate'] ?>%</td>
|
|
<td><?= __round_show($data[$key]['books'][$key2]['vat']) ?></td>
|
|
<td><?= __round_show($data[$key]['books'][$key2]['total_with_vat']) ?></td>
|
|
<td><?= $data[$key]['tr_vat_name'] ?></td>
|
|
<td><?= $data[$key]['tr_vat_number'] ?></td>
|
|
<td><?= $data[$key]['tr_vat_adress'] ?></td>
|
|
<td><?= $data[$key]['tr_card_id'] ?></td>
|
|
<td><img src="<?= $data[$key]['QR'] ?>" width="100" height="100"></td>
|
|
<td><a target="_blank" href="https://aqdamy.com.sa/cp/print?book_id=<?= $key2 ?>&p=1">طباعة
|
|
الفاتورة</a></td>
|
|
</tr>
|
|
|
|
<?php
|
|
$t1 += __round_show($data[$key]['books'][$key2]['s_price']);
|
|
$t2 += __round_show($data[$key]['books'][$key2]['s_price_with_s_count']);
|
|
$t3 += __round_show($data[$key]['books'][$key2]['des']);
|
|
$t4 += __round_show($data[$key]['books'][$key2]['total_with_des']);
|
|
$t6 += __round_show($data[$key]['books'][$key2]['vat']);
|
|
$t7 += __round_show($data[$key]['books'][$key2]['total_with_vat']);
|
|
}
|
|
?>
|
|
<?php
|
|
$count++;
|
|
}
|
|
?>
|
|
|
|
<tr>
|
|
<td colspan="5">المجموع</td>
|
|
<td><?= $t1 ?></td>
|
|
<td><?= $t2 ?></td>
|
|
<td><?= $t3 ?></td>
|
|
<td><?= $t4 ?></td>
|
|
<td><?= $t5 ?>%</td>
|
|
<td><?= $t6 ?></td>
|
|
<td><?= $t7 ?></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td></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>
|