booking/active_visits.php

875 lines
56 KiB
PHP
Executable File

<?php
require_once('fixed/config/go_con.php');
access(64); //
$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_visits';
</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`.`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_rank = $row_services['rank'];
if ($row_services['status_id'] == 12) {
?>
<script type='text/javascript'>
window.location.href = 'book_visits';
</script>
<?php
}
if ($row_services['activation_id'] == 1) {
?>
<script type='text/javascript'>
window.location.href = 'book_visits';
</script>
<?php
}
$price = $row_services['price'];
$price_vat = 0;
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 (10)
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 (!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_visits'
</script>
<?php
}
//collect data
$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-3 col-lg-3 col-xl-3">
<div class="table-responsive">
<table class="table table-bordered text-center">
<thead class="table-primary">
<tr>
<th colspan="2" scope="col">رصيد الخدمات</th>
</tr>
</thead>
<?php
$get_tretment_has_service_sql = mysqli_query($db,
"SELECT `services`.`id`, `services`.`name`, COUNT(`tretment_has_service`.`id`) AS `how_many`
FROM `tretment_has_service`
LEFT JOIN `services` ON `tretment_has_service`.`services_id` = `services`.`id`
WHERE `tretment_has_service`.`tretment_id` = $tretment_id
AND `tretment_has_service`.`done_id` = 1
AND `tretment_has_service`.`activation_id` = 2
GROUP BY `services`.`id`"
);
if (mysqli_num_rows($get_tretment_has_service_sql) > 0) {
?>
<thead class="table-primary">
<tr>
<th scope="col">الخدمة</th>
<th scope="col">العدد</th>
</tr>
</thead>
<tbody>
<?php
while ($row_tretment_has_service = mysqli_fetch_assoc($get_tretment_has_service_sql)) {
?>
<tr>
<th scope="row"><?=$row_tretment_has_service['name']?></th>
<th scope="row"><?=$row_tretment_has_service['how_many']?></th>
</tr>
<?php
}
?>
</tbody>
<?php
} else {
?>
<tbody>
<tr>
<th colspan="2" scope="row">غير متوفر</th>
</tr>
</tbody>
<?php
}
?>
</table>
</div>
</div>
<div class="col-12 col-sm-12 col-md-2 col-lg-2 col-xl-2">
<div class="table-responsive">
<table class="table table-bordered text-center">
<thead class="table-primary">
<tr>
<th scope="col" colspan="2">رصيد اموال</th>
</tr>
</thead>
<tbody>
<tr>
<?php
$get_v_tretment_money_sql = mysqli_query($db,
"SELECT `money` FROM `tretment_money` WHERE `tretment_id` = $tretment_id"
);
$static_money_stuck = 0;
if (mysqli_num_rows($get_v_tretment_money_sql) > 0) {
$row_v_tretment_money = mysqli_fetch_assoc($get_v_tretment_money_sql);
$static_money_stuck = $row_v_tretment_money['money'];
?>
<th scope="col">مدفوع</th>
<th scope="col"><?=$row_v_tretment_money['money']?> ريال</th>
<?php
} else {
?>
<th scope="col">مدفوع</th>
<th scope="col">0 ريال</th>
<?php
}
?>
</tr>
<tr>
<?php
$get_v_tretment_money_sql = mysqli_query($db,
"SELECT `money` FROM `tretment_free_money` WHERE `tretment_id` = $tretment_id"
);
if (mysqli_num_rows($get_v_tretment_money_sql) > 0) {
$row_v_tretment_money = mysqli_fetch_assoc($get_v_tretment_money_sql)
?>
<th scope="col">مجاني</th>
<th scope="col"><?=$row_v_tretment_money['money']?> ريال</th>
<?php
} else {
?>
<th scope="col">مجاني</th>
<th scope="col">0 ريال</th>
<?php
}
?>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col-12 col-sm-12 col-md-2 col-lg-2 col-xl-2">
<div class="table-responsive">
<table class="table table-bordered text-center">
<thead class="table-primary">
<tr>
<th scope="col">رصيد نقاط</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="col">0 نقطة</th>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col-12 col-sm-12 col-md-2 col-lg-2 col-xl-2">
<div class="table-responsive">
<table class="table table-bordered text-center">
<thead class="table-primary">
<tr>
<th colspan="2" scope="col">عرض مره وحدة</th>
</tr>
</thead>
<?php
if (false) {
?>
<thead class="table-primary">
<tr>
<th scope="col">الخدمة</th>
<th scope="col">العدد</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">#</th>
<th scope="row">#</th>
</tr>
</tbody>
<?php
} else {
?>
<tbody>
<tr>
<th colspan="2" scope="row">غير متوفر</th>
</tr>
</tbody>
<?php
}
?>
</table>
</div>
</div>
<div class="col-12 col-sm-12 col-md-3 col-lg-3 col-xl-3">
<div class="table-responsive">
<table class="table table-bordered text-center">
<thead class="table-primary">
<tr>
<th colspan="2" scope="col">خدمات مجانية</th>
</tr>
</thead>
<?php
$get_tretment_has_free_service_sql = mysqli_query($db,
"SELECT `services`.`id`, `services`.`name`, COUNT(`tretment_has_free_service`.`id`) AS `how_many`
FROM `tretment_has_free_service`
LEFT JOIN `services` ON `tretment_has_free_service`.`services_id` = `services`.`id`
WHERE `tretment_has_free_service`.`tretment_id` = $tretment_id
AND `tretment_has_free_service`.`done_id` = 1
AND `tretment_has_free_service`.`activation_id` = 2
GROUP BY `services`.`id`"
);
if (mysqli_num_rows($get_tretment_has_free_service_sql) > 0) {
?>
<thead class="table-primary">
<tr>
<th scope="col">الخدمة</th>
<th scope="col">العدد</th>
</tr>
</thead>
<tbody>
<?php
while ($row_tretment_has_free_service = mysqli_fetch_assoc($get_tretment_has_free_service_sql)) {
?>
<tr>
<th scope="row"><?=$row_tretment_has_free_service['name']?></th>
<th scope="row"><?=$row_tretment_has_free_service['how_many']?></th>
</tr>
<?php
}
?>
</tbody>
<?php
} else {
?>
<tbody>
<tr>
<th colspan="2" scope="row">غير متوفر</th>
</tr>
</tbody>
<?php
}
?>
</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">
<ul class="nav nav-pills nav-justified" id="pills-tab" role="tablist">
<li class="nav-item waves-effect waves-light">
<a class="nav-link" id="w-serv-tab" data-bs-toggle="pill" href="#w-serv" role="tab" aria-controls="w-serv" aria-selected="true">
رصيد الخدمات
</a>
</li>
<li class="nav-item waves-effect waves-light">
<a class="nav-link" id="w-money-tab" data-bs-toggle="pill" href="#w-money" role="tab" aria-controls="w-money" aria-selected="false">
رصيد اموال
</a>
</li>
<li class="nav-item waves-effect waves-light">
<a class="nav-link" id="w-points-tab" data-bs-toggle="pill" href="#w-points" role="tab" aria-controls="w-points" aria-selected="false">
رصيد نقاط
</a>
</li>
<li class="nav-item waves-effect waves-light">
<a class="nav-link" id="w-free-tab" data-bs-toggle="pill" href="#w-free" role="tab" aria-controls="w-free" aria-selected="false">
خدمات مجانية
</a>
</li>
</ul>
<div class="tab-content" id="pills-tabContent">
<div class="tab-pane fade" id="w-serv" role="tabpanel" aria-labelledby="w-serv-tab">
<p class="mb-0 m-t-30">
1
</p>
</div>
<div class="tab-pane fade" id="w-money" role="tabpanel" aria-labelledby="w-money-tab">
<div class="row theme-form mt-3">
<div class="col-xxl-6 mb-3 d-flex">
<label class="col-form-label pe-2" for="money_stuck" style="white-space: nowrap;">المبلغ المدفوع</label>
<input class="form-control" id="money_stuck" type="number" name="money_stuck" placeholder="المبلغ" step="any" value="0">
</div>
<div class="col-xxl-4 mb-3 d-flex">
<button class="btn btn-primary">احسب</button>
</div>
</div>
<div class="row theme-form mt-3">
<div class="col-xxl-6 mb-3 d-flex">
<label class="col-form-label pe-2" for="free_money_stuck" style="white-space: nowrap;">المبلغ المجاني</label>
<input class="form-control" id="free_money_stuck" type="number" name="free_money_stuck" placeholder="المبلغ" step="any" value="0">
</div>
<div class="col-xxl-4 mb-3 d-flex">
<button class="btn btn-primary">احسب</button>
</div>
</div>
</div>
<div class="tab-pane fade" id="w-points" role="tabpanel" aria-labelledby="w-points-tab">
<p class="mb-0 m-t-30">
3
</p>
</div>
<div class="tab-pane fade" id="w-free" role="tabpanel" aria-labelledby="w-free-tab">
<p class="mb-0 m-t-30">
4
</p>
</div>
</div>
</div>
<div class="card-body new-user order-list">
<div id="pay" class="form-group row">
<hr>
<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 style="border-right: 1px solid rgba(0,0,0); 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="trans_pay" class="col-form-label text-right">المبلغ المدفوع</label>
<input id="trans_pay" name="trans_pay" class="form-control" type="number" step="any" value="0">
</div>
<div class="row">
<div class="col-6 col-sm-6 col-md-6 col-lg-6 col-xl-6">
<label for="trans_type" class="col-form-label text-right">الى حساب</label>
<select id="trans_type" style="font-family: system-ui;" class="form-control">
<option value="0">المرجو الاختيار</option>
<?php
$trans_to_sql = mysqli_query($db, "SELECT `id`, `name` FROM `how_pay` WHERE `id` IN (6,7,8,9)
");
if (mysqli_num_rows($trans_to_sql) > 0) {
while ($trans_to = mysqli_fetch_assoc($trans_to_sql)) {
?>
<option value="<?=$trans_to['id']?>"><?=$trans_to['name']?></option>
<?php
}
}
?>
</select>
</div>
<div class="col-6 col-sm-6 col-md-6 col-lg-6 col-xl-6">
<label for="trans_date" class="col-form-label text-right">تاريخ التحويل</label>
<input id="trans_date" name="trans_date" class="form-control" type="date" style="text-align: center;">
</div>
</div>
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
<label for="trans_note" class="col-form-label text-right">ملاحظات</label>
<textarea id="trans_note" rows="6" name="trans_note" class="form-control" type="text"></textarea>
</div>
</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);?>;
let money_stuck = 0;
let static_money_stuck = parseFloat(<?=json_encode($static_money_stuck)?>);
$("[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 money_stuck_value() {
money_stuck = $("#money_stuck").val();
if(money_stuck > static_money_stuck) {
swalfun("يرجى التحقق", "لا يمكن ان يكون المبلغ المدخل اكبر من رصيد العميل", "warning");
return;
}
curr_price = (Math.round((curr_price - money_stuck) * 100) / 100);
if(curr_price < 0){
swalfun("يرجى التحقق", "لا يمكن ان يكون المبلغ المستحق اقل من 0", "warning");
curr_price = parseFloat($('#current_price').html());
}
$('#current_price').html(curr_price)
}
$('#money_stuck').change(function() {
money_stuck_value()
})
function pay1() {
let cash_pay = parseFloat($("[name='cash_pay']").val());
let card_pay = parseFloat($("[name='card_pay']").val());
let trans_pay = parseFloat($("[name='trans_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()
let money_stuck = parseFloat($("#money_stuck").val());
if(money_stuck > static_money_stuck) {
swalfun("يرجى التحقق", "لا يمكن ان يكون المبلغ المدخل اكبر من رصيد العميل", "warning");
return;
}
if(money_stuck <= 0 || money_stuck == undefined) {
money_stuck = 0;
}
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 || trans_pay < 0) {
swalfun("يرجى التحقق", "لا يمكن ان يكون المبلغ المدخل بالسالب", "warning");
return;
}
if (show_price_change != (cash_pay + card_pay + trans_pay + money_stuck)) {
swalfun('يرجى التحقق','مدخلات الدفع غير مطابقه المبلغ المستحق','info');
return;
}
data = {
'serv':<?=json_encode($services_ids)?>,
'total': total_temp,
'total_discount': total_discount,
'total_add': total_add,
'reason': reason_for_change,
'money_stuck': money_stuck,
}
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();
let trans_type = $('#trans_type').find(":selected").val();
let trans_date = $("[name='trans_date']").val();
let trans_note = $("[name='trans_note']").val();
if(trans_pay > 0) {
if(trans_type == 0) {
swalfun('حدث خطأ', 'يرجى تحديد الحساب المحول له', 'error');
return false;
}
if (trans_date == '' || trans_date == undefined) {
swalfun('حدث خطأ', 'يرجى اختيار تاريخ التحويل', 'error');
return false;
}
trans_note += ' تاريخ التحويل ' + trans_date
}
//for more action
let day_date = <?=json_encode($day_date);?>;
click = 0
if (click == 0) {
click++;
$.post("work/order/ajax/active_visits_ajax.php", {
data,
tretment_id,
br_id,
cash_pay,
cash_note,
card_pay,
card_type,
card_approval_number,
card_note,
money_stuck,
trans_pay,
trans_type,
trans_date,
trans_note,
// for more actions
day_date
}, function(get_data) {
$("#get_data").html(get_data);
})
} else {
swalfun("يرجى الانتظار", "", "warning");
}
}
</script>
</body>
</html>