583 lines
35 KiB
PHP
Executable File
583 lines
35 KiB
PHP
Executable File
<?php
|
|
require_once('fixed/config/go_con.php');
|
|
access(77);
|
|
|
|
function check($id_number)
|
|
{
|
|
$id = trim($id_number);
|
|
if (!is_numeric($id))
|
|
return -1;
|
|
if (strlen($id) !== 10)
|
|
return -1;
|
|
$type = substr($id, 0, 1);
|
|
if ($type != 2 && $type != 1)
|
|
return -1;
|
|
$sum = 0;
|
|
for ($i = 0; $i < 10; $i++) {
|
|
if ($i % 2 == 0) {
|
|
$ZFOdd = str_pad((substr($id, $i, 1) * 2), 2, "0", STR_PAD_LEFT);
|
|
$sum += substr($ZFOdd, 0, 1) + substr($ZFOdd, 1, 1);
|
|
} else {
|
|
$sum += substr($id, $i, 1);
|
|
}
|
|
}
|
|
return $sum % 10 ? -1 : $type;
|
|
}
|
|
|
|
$booking_id = mysqli_real_escape_string($db, $_GET['booking_id']);
|
|
|
|
$get_invoices_sql = mysqli_query($db, "SELECT * FROM `invoices_has_book` WHERE `book_id`='$booking_id'");
|
|
if (mysqli_num_rows($get_invoices_sql) > 0) {
|
|
?>
|
|
<script type='text/javascript'>
|
|
window.location.href = 'book_physical_therapy';
|
|
</script>
|
|
<?php
|
|
}
|
|
|
|
$data = array();
|
|
$get_services_sql = mysqli_query($db, "SELECT
|
|
`services`.`activation_id`,
|
|
`services`.`price`,
|
|
`book_details`.`status_id`,
|
|
`book_details`.`day_date`,
|
|
`book`.`id` AS `book_id`,
|
|
`tretment`.`an_employee_offer_id`,
|
|
`tretment`.`name`,
|
|
`branch`.`id` AS `br_id`,
|
|
`an_employee_offer`.`id` AS `emp_id`,
|
|
`an_employee_offer`.`name` AS `emp_name`,
|
|
`book`.`tretment_id`,
|
|
`total_points`.`point`,
|
|
`tretment`.`id_number`,
|
|
`tretment`.`date_time`,
|
|
(SELECT `name` FROM `ranks` WHERE `total_points`.`point` BETWEEN `start` AND `end`) AS `rank`
|
|
|
|
FROM `book_details`
|
|
LEFT JOIN `services` ON `book_details`.`services_id` = `services`.`id`
|
|
LEFT JOIN `book` ON `book_details`.`book_id` = `book`.`id`
|
|
LEFT JOIN `tretment` ON `book`.`tretment_id` = `tretment`.`id`
|
|
LEFT JOIN `an_employee_offer` ON `tretment`.`an_employee_offer_id` = `an_employee_offer`.`id`
|
|
LEFT JOIN `commercial_register` ON `tretment`.`commercial_register_id` = `commercial_register`.`id`
|
|
LEFT JOIN `emplyee` ON `book_details`.`emplyee_id` = `emplyee`.`id`
|
|
LEFT JOIN `branch` ON `emplyee`.`branch_id` = `branch`.`id`
|
|
LEFT JOIN `total_points` ON `total_points`.`tretment_id` = `tretment`.`id`
|
|
|
|
WHERE `book_details`.`book_id` = $booking_id
|
|
AND `branch`.`commercial_register_id` = `tretment`.`commercial_register_id`
|
|
ORDER BY `book_details`.`id` DESC LIMIT 1"
|
|
);
|
|
$row_services = mysqli_fetch_assoc($get_services_sql);
|
|
|
|
$day_date = $row_services['day_date'];
|
|
$Next_day = date('Y-m-d', strtotime('+1 day', strtotime($day_date)));
|
|
$br_id = $row_services['br_id'];
|
|
$name = $row_services['name'];
|
|
$emp_id = $row_services['emp_id'];
|
|
$emp_name = $row_services['emp_name'];
|
|
$tretment_id = $row_services['tretment_id'];
|
|
$an_employee_offer_id = $row_services['an_employee_offer_id'];
|
|
$booking_id = $row_services['book_id'];
|
|
$tretment_date_time = $row_services['date_time'];
|
|
$tretment_points = $row_services['point'];
|
|
$tretment_id_number = $row_services['id_number'];
|
|
$tretment_rank = $row_services['rank'];
|
|
|
|
if ($row_services['status_id'] == 6 || $row_services['status_id'] == 8) {
|
|
?>
|
|
<script type='text/javascript'>
|
|
window.location.href = 'book_physical_therapy';
|
|
</script>
|
|
<?php
|
|
}
|
|
if ($row_services['activation_id'] == 1) {
|
|
?>
|
|
<script type='text/javascript'>
|
|
window.location.href = 'book_physical_therapy';
|
|
</script>
|
|
<?php
|
|
}
|
|
|
|
$price = $row_services['price'];
|
|
$price_vat = 0;
|
|
$has_vat = true;
|
|
|
|
if(check($tretment_id_number) == 1) {
|
|
$price_vat = 0;
|
|
$has_vat = false;
|
|
} else {
|
|
if (!empty($vat)) {
|
|
$price_vat = ($price * $vat) / 100;
|
|
}
|
|
}
|
|
|
|
|
|
$show_price = $price + $price_vat;
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en" dir="rtl">
|
|
<?php require_once('fixed/head/go.php'); ?>
|
|
|
|
<body class="rtl">
|
|
<style>
|
|
.header-title {
|
|
color: #086367 !important;
|
|
font-weight: bold !important;
|
|
}
|
|
|
|
.form-check,
|
|
.custom-control {
|
|
padding-right: 0px !important;
|
|
}
|
|
|
|
hr {
|
|
border-top: 1px solid rgb(0 0 0 / 40%) !important;
|
|
padding: 0 !important;
|
|
margin: 1rem auto;
|
|
}
|
|
|
|
.radio-primary-custom input[type="radio"]+label::before {
|
|
border-color: #ff0000 !important;
|
|
}
|
|
</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">
|
|
<div class="card">
|
|
<div class="card-body new-user order-list">
|
|
<div class="form-group row">
|
|
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
|
|
<div class="table-responsive">
|
|
<table class="table table-bordered text-center"
|
|
style="vertical-align: middle;">
|
|
<thead class="table-primary">
|
|
<tr>
|
|
<th scope="col">العميل</th>
|
|
<td style="background-color: #fff;" scope="col">
|
|
<?= $name ?>
|
|
</td>
|
|
<th scope="col">جهه العمل</th>
|
|
<td style="background-color: #fff;" scope="col">
|
|
<?= $emp_name ?>
|
|
</td>
|
|
<th scope="col">العضوية</th>
|
|
<td style="background-color: #fff;" scope="col">
|
|
<?= $tretment_rank ?>
|
|
</td>
|
|
</tr>
|
|
</thead>
|
|
<thead class="table-primary">
|
|
<tr>
|
|
<th scope="col">#</th>
|
|
<th colspan="2" scope="col">الخدمات</th>
|
|
<th scope="col">الفرع</th>
|
|
<th scope="col">السعر</th>
|
|
<th scope="col">اجراءات</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$get_book_details_sql = mysqli_query($db, "SELECT
|
|
`book`.`id` AS `book_id`,
|
|
`dd`.`id` AS `bd_id`,
|
|
`dd`.`day_time`,
|
|
`dd`.`day_date`,
|
|
`branch`.`branch_name`,
|
|
`services`.`id`,
|
|
`services`.`name`,
|
|
`services`.`price`
|
|
|
|
FROM `book_details` AS `dd`
|
|
LEFT JOIN `book` ON `dd`.`book_id` = `book`.`id`
|
|
LEFT JOIN `tretment` ON `book`.`tretment_id` = `tretment`.`id`
|
|
LEFT JOIN `services` ON `dd`.`services_id` = `services`.`id`
|
|
LEFT JOIN `branch` ON `dd`.`branch_id` = `branch`.`id`
|
|
WHERE `tretment`.`id` = $tretment_id
|
|
AND `services`.`activation_id` = 2
|
|
AND `dd`.`status_id` IN (4)
|
|
AND ((`dd`.`day_date` = '$day_date') OR (`dd`.`day_date` = '$Next_day' AND `dd`.`day_time` = '00:00:00'))
|
|
AND `dd`.`id` IN (
|
|
SELECT MAX(`book_details`.`id`)
|
|
FROM `book_details`
|
|
WHERE `book_details`.`book_id` = `dd`.`book_id`)
|
|
ORDER BY `dd`.`day_time`"
|
|
);
|
|
|
|
$count = 1;
|
|
$total = 0;
|
|
$total_w_vat = 0;
|
|
$services_ids = array();
|
|
if (mysqli_num_rows($get_book_details_sql) > 0) {
|
|
while ($row_book_details = mysqli_fetch_assoc($get_book_details_sql)) {
|
|
$price_temp = 0;
|
|
if ($row_book_details['id'] == 0) {
|
|
$bd_id = $row_book_details['book_id'];
|
|
$get_bundle_services_sql = mysqli_query($db, "SELECT `bundle_services_id` FROM `book_details_has_bundle_services` WHERE `book_details_id` IN (SELECT
|
|
MIN(`dd`.`id`)
|
|
FROM `book_details` AS `dd`
|
|
WHERE `dd`.`book_id` = $bd_id AND `dd`.`status_id` = 4) LIMIT 1");
|
|
if (mysqli_num_rows($get_bundle_services_sql) > 0) {
|
|
$row_bundle_services = mysqli_fetch_assoc($get_bundle_services_sql);
|
|
$bundle_services_id = $row_bundle_services['bundle_services_id'];
|
|
$get_bundle_services_has_services_sql = mysqli_query($db, "SELECT
|
|
`bundle_services_has_services`.`how_many`,
|
|
`services`.`id`,
|
|
`services`.`name`,
|
|
`services`.`price`
|
|
|
|
FROM `bundle_services_has_services`
|
|
LEFT JOIN `services` ON `services`.`id` = `bundle_services_has_services`.`services_id`
|
|
|
|
WHERE `bundle_services_has_services`.`bundle_services_id` = $bundle_services_id
|
|
");
|
|
if (mysqli_num_rows($get_bundle_services_has_services_sql) > 0) {
|
|
while ($row_bundle_services_has_services = mysqli_fetch_assoc($get_bundle_services_has_services_sql)) {
|
|
for ($i = 0; $i < $row_bundle_services_has_services['how_many']; $i++) {
|
|
array_push($services_ids,
|
|
array(
|
|
'book_id' => $row_book_details['book_id'],
|
|
'book_time' => $row_book_details['day_time'],
|
|
'book_day' => $row_book_details['day_date'],
|
|
'id' => $row_bundle_services_has_services['id'],
|
|
'name' => $row_bundle_services_has_services['name'],
|
|
'price' => $row_bundle_services_has_services['price'],
|
|
'price_v' => round($row_bundle_services_has_services['price'] + ($row_bundle_services_has_services['price'] * $vat) / 100, 2)
|
|
)
|
|
);
|
|
$price_temp += $row_bundle_services_has_services['price'];
|
|
}
|
|
}
|
|
} else {
|
|
echo "
|
|
<script>
|
|
swalfun('LT115-7','','error');
|
|
click = 0;
|
|
</script>
|
|
";
|
|
exit;
|
|
}
|
|
} else {
|
|
echo "
|
|
<script>
|
|
swalfun('LT245-7','','error');
|
|
click = 0;
|
|
</script>
|
|
";
|
|
exit;
|
|
}
|
|
} else {
|
|
array_push($services_ids,
|
|
array(
|
|
'book_id' => $row_book_details['book_id'],
|
|
'book_time' => $row_book_details['day_time'],
|
|
'book_day' => $row_book_details['day_date'],
|
|
'id' => $row_book_details['id'],
|
|
'name' => $row_book_details['name'],
|
|
'price' => $row_book_details['price'],
|
|
'price_v' => round($row_book_details['price'] + ($row_book_details['price'] * $vat) / 100, 2)
|
|
)
|
|
);
|
|
$price_temp += $row_book_details['price'];
|
|
}
|
|
if(check($tretment_id_number) == 1) {
|
|
$price_temp = $price_temp;
|
|
} else {
|
|
if (!empty($vat)) {
|
|
$price_temp = round($price_temp + ($price_temp * $vat) / 100, 2);
|
|
}
|
|
}
|
|
?>
|
|
<tr>
|
|
<td scope="row">
|
|
<?= $count ?>
|
|
</td>
|
|
<td colspan="2">
|
|
<?= $row_book_details['name'] ?>
|
|
</td>
|
|
<td>
|
|
<?= $row_book_details['branch_name'] ?>
|
|
</td>
|
|
<td>
|
|
<?= $price_temp ?>
|
|
</td>
|
|
<td><a class="btn btn-square btn-danger"
|
|
href="work/order/php/cancel?booking_id=<?= $row_book_details['book_id'] ?>&loc=1&lo=book">الغاء</a>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
$count++;
|
|
$total += $row_book_details['price'];
|
|
$total_w_vat += $price_temp;
|
|
}
|
|
} else {
|
|
?>
|
|
<script type='text/javascript'>
|
|
window.location.href = 'book_physical_therapy'
|
|
</script>
|
|
<?php
|
|
}
|
|
|
|
//collect data
|
|
$data['has_vat'] = $has_vat;
|
|
$data['serv'] = $services_ids;
|
|
$data['total'] = $total;
|
|
//collect data end
|
|
|
|
$show_price = $total_w_vat;
|
|
?>
|
|
</tbody>
|
|
<thead class="table-primary">
|
|
<tr>
|
|
<th colspan="4" scope="col">المجموع</th>
|
|
<th style="background-color: #fff;" scope="col">
|
|
<?= $total_w_vat ?>
|
|
</th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="form-group row">
|
|
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
|
|
<h2 class="text-center">
|
|
المبلغ المستحق
|
|
<span id='current_price' style="color:red">
|
|
<?= round($show_price, 2) ?>
|
|
</span>
|
|
ريال
|
|
</h2>
|
|
</div>
|
|
</div>
|
|
<div class="form-group row">
|
|
<div class="col-12 col-sm-12 col-md-6 col-lg-6 col-xl-6">
|
|
<label for="show_price_change" class="col-form-label text-right">المبلغ
|
|
المستحق</label>
|
|
<input id="show_price_change" class="form-control clickfun" type="number"
|
|
step="any" value="<?= round($show_price, 2) ?>">
|
|
</div>
|
|
|
|
<div class="col-12 col-sm-12 col-md-6 col-lg-6 col-xl-6">
|
|
<label for="resone_change" class="col-form-label text-right">ملاحظات</label>
|
|
<input id="resone_change" class="form-control clickfun" type="text"
|
|
value="">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card-body new-user order-list">
|
|
<div id="pay" class="form-group row">
|
|
<hr>
|
|
<div class="col-2"></div>
|
|
<div style="border-left: 1px solid rgba(0,0,0);"
|
|
class="form-group col-12 col-sm-6 col-md-4 col-lg-4 col-xl-4">
|
|
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
|
|
<h4 class="text-center">
|
|
كاش
|
|
</h4>
|
|
</div>
|
|
<hr>
|
|
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
|
|
<label for="" class="col-form-label text-right">المبلغ المدفوع</label>
|
|
<input name="cash_pay" class="form-control" type="number" step="any"
|
|
value="0">
|
|
</div>
|
|
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
|
|
<label for="" class="col-form-label text-right">ملاحظات</label>
|
|
<textarea rows="9" name="cash_note" class="form-control"
|
|
type="text"></textarea>
|
|
</div>
|
|
</div>
|
|
<div style="border-right: 1px solid rgba(0,0,0);"
|
|
class="form-group col-12 col-sm-6 col-md-4 col-lg-4 col-xl-4">
|
|
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
|
|
<h4 class="text-center">
|
|
شبكة
|
|
</h4>
|
|
</div>
|
|
<hr>
|
|
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
|
|
<label for="" class="col-form-label text-right">المبلغ المدفوع</label>
|
|
<input name="card_pay" class="form-control" type="number" step="any"
|
|
value="0">
|
|
</div>
|
|
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
|
|
<label for="" class="col-form-label text-right">نوع الكرت</label>
|
|
<div style="transform: translateY(-6px);">
|
|
<div class="form-check form-check-inline">
|
|
<div class="radio radio-primary">
|
|
<input type="radio" id="card_type_mada" name="card_type"
|
|
data-parsley-multiple="groups" data-parsley-mincheck="2"
|
|
value="1">
|
|
<label class="mb-0" for="card_type_mada">مدى</label>
|
|
</div>
|
|
</div>
|
|
<div class="form-check form-check-inline">
|
|
<div class="radio radio-primary">
|
|
<input type="radio" id="card_type_visa" name="card_type"
|
|
data-parsley-multiple="groups" data-parsley-mincheck="2"
|
|
value="2">
|
|
<label class="mb-0" for="card_type_visa">فيزا</label>
|
|
</div>
|
|
</div>
|
|
<div class="form-check form-check-inline">
|
|
<div class="radio radio-primary">
|
|
<input type="radio" id="card_type_master" name="card_type"
|
|
data-parsley-multiple="groups" data-parsley-mincheck="2"
|
|
value="3">
|
|
<label class="mb-0" for="card_type_master">ماستر
|
|
كارد</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div style="transform: translateY(-3px);"
|
|
class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
|
|
<label for="" class="col-form-label text-right">رقم التفويض</label>
|
|
<input name="card_approval_number" class="form-control" type="number"
|
|
value="">
|
|
</div>
|
|
<div style="transform: translateY(-3px);"
|
|
class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
|
|
<label for="" class="col-form-label text-right">ملاحظات</label>
|
|
<textarea rows="3" name="card_note" class="form-control"
|
|
type="text"></textarea>
|
|
</div>
|
|
</div>
|
|
<div class="col-2"></div>
|
|
<hr>
|
|
</div>
|
|
<div class="col-lg-12">
|
|
<div id="pay-action" class="form-control"
|
|
style="background-color: #086367; color:white; text-align:center; cursor: pointer;">
|
|
سداد</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php require_once('fixed/footer/go.php'); ?>
|
|
</div>
|
|
</div>
|
|
<div id='get_data'></div>
|
|
<?php require_once('fixed/js/go.php'); ?>
|
|
<script>
|
|
let data = <?= json_encode($data); ?>;
|
|
|
|
$("[name='cash_pay']").keypress(function (e) {
|
|
var key = e.which;
|
|
if (key == 13) {
|
|
pay1()
|
|
}
|
|
});
|
|
$("[name='card_pay']").keypress(function (e) {
|
|
var key = e.which;
|
|
if (key == 13) {
|
|
pay1()
|
|
}
|
|
});
|
|
$(function () {
|
|
$("#pay-action").click(function () {
|
|
pay1();
|
|
});
|
|
});
|
|
let click = 0;
|
|
|
|
let curr_price = parseFloat($('#current_price').html());
|
|
|
|
function pay1() {
|
|
let cash_pay = parseFloat($("[name='cash_pay']").val());
|
|
let card_pay = parseFloat($("[name='card_pay']").val());
|
|
let show_price_change = parseFloat($("#show_price_change").val());
|
|
let total_temp = curr_price;
|
|
let total_discount = 0;
|
|
let total_add = 0;
|
|
let reason_for_change = $("#resone_change").val()
|
|
|
|
if (show_price_change != total_temp) {
|
|
if (show_price_change > total_temp) {
|
|
total_add = show_price_change - total_temp;
|
|
} else {
|
|
total_discount = total_temp - show_price_change;
|
|
}
|
|
|
|
if (reason_for_change == "") {
|
|
swalfun('يرجى التحقق', 'سبب التعديل فارغ', 'info');
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (cash_pay < 0 || card_pay < 0) {
|
|
swalfun("يرجى التحقق", "لا يمكن ان يكون المبلغ المدخل بالسالب", "warning");
|
|
return;
|
|
}
|
|
|
|
if (show_price_change != (cash_pay + card_pay)) {
|
|
swalfun('يرجى التحقق', 'مدخلات الدفع غير مطابقه المبلغ المستحق', 'info');
|
|
return;
|
|
}
|
|
|
|
data = {
|
|
'has_vat': data['has_vat'],
|
|
'serv': <?= json_encode($services_ids) ?>,
|
|
'total': total_temp,
|
|
'total_discount': total_discount,
|
|
'total_add': total_add,
|
|
'reason': reason_for_change,
|
|
}
|
|
|
|
let data_serv = data['serv'];
|
|
|
|
let tretment_id = <?= json_encode($tretment_id); ?>;
|
|
let br_id = <?= json_encode($br_id); ?>;
|
|
|
|
let cash_note = $("[name='cash_note']").val();
|
|
|
|
let card_type = $("[name='card_type']").val();
|
|
let card_approval_number = $("[name='card_approval_number']").val();
|
|
let card_note = $("[name='card_note']").val();
|
|
|
|
//for more action
|
|
let day_date = <?= json_encode($day_date); ?>;
|
|
click = 0
|
|
if (click == 0) {
|
|
click++;
|
|
$.post("work/order/ajax/active_physical_therapy_ajax.php", {
|
|
data,
|
|
tretment_id,
|
|
br_id,
|
|
cash_pay,
|
|
cash_note,
|
|
card_pay,
|
|
card_type,
|
|
card_approval_number,
|
|
card_note,
|
|
|
|
// for more actions
|
|
day_date
|
|
}, function (get_data) {
|
|
$("#get_data").html(get_data);
|
|
})
|
|
} else {
|
|
swalfun("يرجى الانتظار", "", "warning");
|
|
}
|
|
}
|
|
|
|
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|