1486 lines
109 KiB
PHP
1486 lines
109 KiB
PHP
<?php
|
|
require_once('fixed/config/go_con.php');
|
|
access(50);
|
|
|
|
$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 = 'index.php';
|
|
</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'];
|
|
$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'] == 6) {
|
|
?>
|
|
<script type='text/javascript'>
|
|
window.location.href = 'index.php';
|
|
</script>
|
|
<?php
|
|
}
|
|
if ($row_services['activation_id'] == 1) {
|
|
?>
|
|
<script type='text/javascript'>
|
|
window.location.href = 'index.php';
|
|
</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`,
|
|
`book_details`.`day_time`,
|
|
`book_details`.`day_date`,
|
|
`branch`.`branch_name`,
|
|
`services`.`id`,
|
|
`services`.`name`,
|
|
`services`.`price`
|
|
|
|
FROM `book_details`
|
|
LEFT JOIN `book` ON `book_details`.`book_id` = `book`.`id`
|
|
LEFT JOIN `tretment` ON `book`.`tretment_id` = `tretment`.`id`
|
|
LEFT JOIN `services` ON `book_details`.`services_id` = `services`.`id`
|
|
LEFT JOIN `branch` ON `book_details`.`branch_id` = `branch`.`id`
|
|
WHERE `tretment`.`id` = $tretment_id
|
|
AND `services`.`activation_id` = 2
|
|
AND `book_details`.`day_date` = '$day_date'
|
|
AND `book_details`.`status_id` = '4'
|
|
AND `book_details`.`id` IN (
|
|
SELECT MAX(`book_details`.`id`)
|
|
FROM `book_details`
|
|
WHERE `book_details`.`day_date` = '$day_date'
|
|
GROUP BY `book_details`.`book_id`)
|
|
ORDER BY `book_details`.`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)) {
|
|
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)
|
|
)
|
|
);
|
|
if (!empty($vat)) {
|
|
$price_temp = round($row_book_details['price'] + ($row_book_details['price']*$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.php?booking_id=<?=$row_book_details['book_id']?>&loc=1">الغاء</a></td>
|
|
</tr>
|
|
<?php
|
|
$count++;
|
|
$total += $row_book_details['price'];
|
|
$total_w_vat += $price_temp;
|
|
}
|
|
} else {
|
|
?>
|
|
<script type='text/javascript'>
|
|
window.location.href = 'index.php'
|
|
</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-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 colspan="6" scope="col">الخصومات</th>
|
|
</tr>
|
|
</thead>
|
|
<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>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$offers = array();
|
|
$array_count_values = array();
|
|
|
|
for ($z=0; $z < count($services_ids); $z++) {
|
|
$serv_id_temp = $services_ids[$z]['id'];
|
|
$book_time = $services_ids[$z]['book_time'];
|
|
$book_day = $services_ids[$z]['book_day'];
|
|
$book_price = $services_ids[$z]['price'];
|
|
$book_day_time = $services_ids[$z]['book_day'] . ' ' . $services_ids[$z]['book_time'];
|
|
|
|
array_push($array_count_values,$serv_id_temp);
|
|
$serv_count = array_count_values($array_count_values);
|
|
|
|
$offers['s_'.$serv_id_temp.'_'.$serv_count[$serv_id_temp]] = array();
|
|
|
|
|
|
$stop_date_time_reg_tretment_offer = true;
|
|
// an employee offers
|
|
$get_an_employee_offer_has_services_sql = mysqli_query($db, "SELECT
|
|
(SELECT `id` FROM `db_tables` WHERE `name` = 'an_employee_offer') AS `db_id`,
|
|
`an_employee_offer_has_services`.`services_id`,
|
|
`services`.`name` AS `serv_name`,
|
|
`services`.`price`,
|
|
`an_employee_offer`.`id` AS `offer_id`,
|
|
`an_employee_offer`.`name`,
|
|
`an_employee_offer`.`discount`,
|
|
`an_employee_offer`.`type_discount_id`,
|
|
`an_employee_offer`.`does_discount_enters_id`
|
|
FROM `an_employee_offer_has_services`
|
|
LEFT JOIN `an_employee_offer` ON `an_employee_offer`.`id` = `an_employee_offer_has_services`.`an_employee_offer_id`
|
|
LEFT JOIN `services` ON `services`.`id` = `an_employee_offer_has_services`.`services_id`
|
|
WHERE `an_employee_offer_has_services`.`an_employee_offer_id` = $emp_id
|
|
AND `an_employee_offer_has_services`.`services_id` = $serv_id_temp
|
|
");
|
|
if (mysqli_num_rows($get_an_employee_offer_has_services_sql) > 0) {
|
|
while ($row_an_employee_offer_has_services = mysqli_fetch_assoc($get_an_employee_offer_has_services_sql)) {
|
|
$discount_p = '';
|
|
$discount_style = '';
|
|
switch ($row_an_employee_offer_has_services['type_discount_id']) {
|
|
case 2:
|
|
$discount_p = $row_an_employee_offer_has_services['discount'];
|
|
$discount_style = $row_an_employee_offer_has_services['discount'] . 'ريال';
|
|
break;
|
|
case 3:
|
|
$discount_p = ($row_an_employee_offer_has_services['discount']/100) * $row_an_employee_offer_has_services['price'];
|
|
$discount_style = $row_an_employee_offer_has_services['discount'] . '%';
|
|
break;
|
|
}
|
|
|
|
if ($an_employee_offer_id == 45) {
|
|
if (strtotime($book_day_time) >= strtotime('2022-01-01 00:00:00') && strtotime($book_day_time) < strtotime('2022-12-31 23:59:59') ) {
|
|
if ($serv_id_temp == 1 || $serv_id_temp == 2) {
|
|
$temp_des = $price - 100;
|
|
$discount_p = $temp_des;
|
|
$discount_style = $temp_des . 'ريال';
|
|
$stop_date_time_reg_tretment_offer = false;
|
|
} elseif ($serv_id_temp == 3) {
|
|
$temp_des = $price - 180;
|
|
$discount_p = $temp_des;
|
|
$discount_style = $temp_des . 'ريال';
|
|
$stop_date_time_reg_tretment_offer = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
array_push($offers['s_'.$row_an_employee_offer_has_services['services_id'].'_'.$serv_count[$serv_id_temp]],
|
|
array(
|
|
'offer_id' => $row_an_employee_offer_has_services['offer_id'],
|
|
'serv_name' => $row_an_employee_offer_has_services['serv_name'],
|
|
'db_id' => $row_an_employee_offer_has_services['db_id'],
|
|
'discount_name' => $row_an_employee_offer_has_services['name'],
|
|
'discount' => $discount_p,
|
|
'discount_style' => $discount_style,
|
|
'services_id' => $row_an_employee_offer_has_services['services_id'],
|
|
'does_discount_enters_id' => $row_an_employee_offer_has_services['does_discount_enters_id']
|
|
)
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// ranks offer
|
|
$get_ranks_offer_has_services_sql = mysqli_query($db, "SELECT
|
|
(SELECT `id` FROM `db_tables` WHERE `name` = 'ranks_offer') AS `db_id`,
|
|
`ranks_offer_has_services`.`services_id`,
|
|
`services`.`name` AS `serv_name`,
|
|
`services`.`price`,
|
|
`ranks_offer`.`id` AS `offer_id`,
|
|
`ranks_offer`.`name`,
|
|
`ranks_offer`.`discount`,
|
|
`ranks_offer`.`type_discount_id`,
|
|
`ranks_offer`.`does_discount_enters_id`
|
|
FROM `ranks_offer_has_services`
|
|
LEFT JOIN `ranks_offer` ON `ranks_offer`.`id` = `ranks_offer_has_services`.`ranks_offer_id`
|
|
LEFT JOIN `ranks` ON `ranks`.`id` = `ranks_offer`.`ranks_id`
|
|
LEFT JOIN `services` ON `services`.`id` = `ranks_offer_has_services`.`services_id`
|
|
WHERE '$tretment_points' BETWEEN `ranks`.`start` AND `ranks`.`end`
|
|
AND `ranks_offer_has_services`.`services_id` = $serv_id_temp
|
|
");
|
|
|
|
if (mysqli_num_rows($get_ranks_offer_has_services_sql) > 0) {
|
|
while ($row_ranks_offer_has_services = mysqli_fetch_assoc($get_ranks_offer_has_services_sql)) {
|
|
$discount_p = '';
|
|
$discount_style = '';
|
|
switch ($row_ranks_offer_has_services['type_discount_id']) {
|
|
case 2:
|
|
$discount_p = $row_ranks_offer_has_services['discount'];
|
|
$discount_style = $row_ranks_offer_has_services['discount'] . 'ريال';
|
|
break;
|
|
case 3:
|
|
$discount_p = ($row_ranks_offer_has_services['discount']/100) * $row_ranks_offer_has_services['price'];
|
|
$discount_style = $row_ranks_offer_has_services['discount'] . '%';
|
|
break;
|
|
}
|
|
|
|
array_push($offers['s_'.$row_ranks_offer_has_services['services_id'].'_'.$serv_count[$serv_id_temp]],
|
|
array(
|
|
'offer_id' => $row_ranks_offer_has_services['offer_id'],
|
|
'serv_name' => $row_ranks_offer_has_services['serv_name'],
|
|
'db_id' => $row_ranks_offer_has_services['db_id'],
|
|
'discount_name' => $row_ranks_offer_has_services['name'],
|
|
'discount' => $discount_p,
|
|
'discount_style' => $discount_style,
|
|
'services_id' => $row_ranks_offer_has_services['services_id'],
|
|
'does_discount_enters_id' => $row_ranks_offer_has_services['does_discount_enters_id']
|
|
)
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// date time reg tretment_offer
|
|
$he_is_old = false;
|
|
if ($stop_date_time_reg_tretment_offer) {
|
|
$get_date_time_reg_tretment_offer_sql = mysqli_query($db, "SELECT
|
|
(SELECT `id` FROM `db_tables` WHERE `name` = 'date_time_reg_tretment_offer') AS `db_id`,
|
|
`date_time_reg_tretment_offer_has_services`.`services_id`,
|
|
`services`.`name` AS `serv_name`,
|
|
`services`.`price`,
|
|
`date_time_reg_tretment_offer`.`id` AS `offer_id`,
|
|
`date_time_reg_tretment_offer`.`name`,
|
|
`date_time_reg_tretment_offer`.`discount`,
|
|
`date_time_reg_tretment_offer`.`type_discount_id`,
|
|
`date_time_reg_tretment_offer`.`does_discount_enters_id`,
|
|
TIME(`date_time_reg_tretment_offer`.`from_date_time`) AS `fromTime`,
|
|
TIME(`date_time_reg_tretment_offer`.`to_date_time`) AS `toTime`
|
|
|
|
FROM `date_time_reg_tretment_offer_has_services`
|
|
LEFT JOIN `date_time_reg_tretment_offer` ON `date_time_reg_tretment_offer`.`id` = `date_time_reg_tretment_offer_has_services`.`date_time_reg_tretment_offer_id`
|
|
LEFT JOIN `services` ON `services`.`id` = `date_time_reg_tretment_offer_has_services`.`services_id`
|
|
|
|
WHERE `branch_id` = $br_id
|
|
AND '$tretment_date_time' BETWEEN `from_date_time` AND `to_date_time`
|
|
AND `date_time_reg_tretment_offer_has_services`.`services_id` = $serv_id_temp
|
|
AND `date_time_reg_tretment_offer`.`activation_id` = 2
|
|
");
|
|
|
|
if (mysqli_num_rows($get_date_time_reg_tretment_offer_sql) > 0) {
|
|
$he_is_old = true;
|
|
while ($row_date_time_reg_tretment_offer = mysqli_fetch_assoc($get_date_time_reg_tretment_offer_sql)) {
|
|
|
|
$offer_id = $row_date_time_reg_tretment_offer['offer_id'];
|
|
|
|
$discount_p = '';
|
|
$discount_style = '';
|
|
|
|
switch ($row_date_time_reg_tretment_offer['type_discount_id']) {
|
|
case 2:
|
|
$discount_p = $row_date_time_reg_tretment_offer['discount'];
|
|
$discount_style = $row_date_time_reg_tretment_offer['discount'] . ' ريال ';
|
|
break;
|
|
case 3:
|
|
$discount_p = ($row_date_time_reg_tretment_offer['discount']/100) * $row_date_time_reg_tretment_offer['price'];
|
|
$discount_style = $row_date_time_reg_tretment_offer['discount'] . '%';
|
|
break;
|
|
}
|
|
array_push($offers['s_'.$row_date_time_reg_tretment_offer['services_id'].'_'.$serv_count[$serv_id_temp]],
|
|
array(
|
|
'offer_id' => $row_date_time_reg_tretment_offer['offer_id'],
|
|
'serv_name' => $row_date_time_reg_tretment_offer['serv_name'],
|
|
'db_id' => $row_date_time_reg_tretment_offer['db_id'],
|
|
'discount_name' => $row_date_time_reg_tretment_offer['name'],
|
|
'discount' => $discount_p,
|
|
'discount_style' => $discount_style,
|
|
'services_id' => $row_date_time_reg_tretment_offer['services_id'],
|
|
'does_discount_enters_id' => $row_date_time_reg_tretment_offer['does_discount_enters_id']
|
|
)
|
|
);
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// from to offers
|
|
$get_from_to_offers_sql = mysqli_query($db, "SELECT
|
|
(SELECT `id` FROM `db_tables` WHERE `name` = 'from_to_offers') AS `db_id`,
|
|
`from_to_offers_has_services`.`services_id`,
|
|
`services`.`name` AS `serv_name`,
|
|
`services`.`price`,
|
|
`from_to_offers`.`id` AS `offer_id`,
|
|
`from_to_offers`.`name`,
|
|
`from_to_offers`.`discount`,
|
|
`from_to_offers`.`type_discount_id`,
|
|
`from_to_offers`.`does_discount_enters_id`,
|
|
`from_to_offers`.`offer_does_have_dayoff_id`,
|
|
TIME(`from_to_offers`.`from_date_time`) AS `fromTime`,
|
|
TIME(`from_to_offers`.`to_date_time`) AS `toTime`
|
|
|
|
FROM `from_to_offers_has_services`
|
|
LEFT JOIN `from_to_offers` ON `from_to_offers`.`id` = `from_to_offers_has_services`.`from_to_offers_id`
|
|
LEFT JOIN `services` ON `services`.`id` = `from_to_offers_has_services`.`services_id`
|
|
|
|
WHERE `branch_id` = $br_id
|
|
AND `to_date_time` >= '$book_day_time'
|
|
AND `from_to_offers_has_services`.`services_id` = $serv_id_temp
|
|
AND `from_to_offers`.`activation_id` = 2
|
|
");
|
|
|
|
if (mysqli_num_rows($get_from_to_offers_sql) > 0) {
|
|
while ($row_from_to_offers = mysqli_fetch_assoc($get_from_to_offers_sql)) {
|
|
|
|
$time_work = array();
|
|
$from = $row_from_to_offers['fromTime'][0] . $row_from_to_offers['fromTime'][1];
|
|
$to = $row_from_to_offers['toTime'][0] . $row_from_to_offers['toTime'][1];
|
|
for ($from; $from <= $to; $from++) {
|
|
$push_time_work = $from . ":00:00";
|
|
array_push($time_work, $push_time_work);
|
|
}
|
|
|
|
$offer_id = $row_from_to_offers['offer_id'];
|
|
$go_flowerd_in_des = true;
|
|
|
|
if ($row_from_to_offers['offer_does_have_dayoff_id'] == 2) {
|
|
$get_from_to_offers_has_days_sql = mysqli_query($db, "SELECT
|
|
`days`.`day`
|
|
|
|
FROM `from_to_offers_has_days`
|
|
LEFT JOIN `days` ON `days`.`id` = `from_to_offers_has_days`.`days_id`
|
|
|
|
WHERE `from_to_offers_has_days`.`activation_id` = 2
|
|
AND `from_to_offers_has_days`.`from_to_offers_id` = $offer_id
|
|
");
|
|
$Days = array();
|
|
if (mysqli_num_rows($get_from_to_offers_has_days_sql) > 0) {
|
|
while ($row_from_to_offers_has_days = mysqli_fetch_assoc($get_from_to_offers_has_days_sql)) {
|
|
array_push($Days, $row_from_to_offers_has_days['day']);
|
|
}
|
|
|
|
$Day = date('D', strtotime($book_day));
|
|
if (!in_array($Day, $Days)) {
|
|
$go_flowerd_in_des = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
if (in_array($book_time, $time_work) && $go_flowerd_in_des) {
|
|
$discount_p = '';
|
|
$discount_style = '';
|
|
|
|
switch ($row_from_to_offers['type_discount_id']) {
|
|
case 2:
|
|
$discount_p = $row_from_to_offers['discount'];
|
|
$discount_style = $row_from_to_offers['discount'] . ' ريال ';
|
|
break;
|
|
case 3:
|
|
$discount_p = ($row_from_to_offers['discount']/100) * $row_from_to_offers['price'];
|
|
$discount_style = $row_from_to_offers['discount'] . '%';
|
|
break;
|
|
}
|
|
array_push($offers['s_'.$row_from_to_offers['services_id'].'_'.$serv_count[$serv_id_temp]],
|
|
array(
|
|
'offer_id' => $row_from_to_offers['offer_id'],
|
|
'serv_name' => $row_from_to_offers['serv_name'],
|
|
'db_id' => $row_from_to_offers['db_id'],
|
|
'discount_name' => $row_from_to_offers['name'],
|
|
'discount' => $discount_p,
|
|
'discount_style' => $discount_style,
|
|
'services_id' => $row_from_to_offers['services_id'],
|
|
'does_discount_enters_id' => $row_from_to_offers['does_discount_enters_id']
|
|
)
|
|
);
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// special offer
|
|
$get_an_employee_offer_sql = mysqli_query($db, "SELECT
|
|
`special_offer_id`
|
|
FROM `tretment_has_special_offer`
|
|
WHERE `tretment_has_special_offer`.`tretment_id` = $tretment_id
|
|
");
|
|
|
|
if (mysqli_num_rows($get_an_employee_offer_sql) > 0) {
|
|
while ($get_special_offer = mysqli_fetch_assoc($get_an_employee_offer_sql)) {
|
|
$special_offer_id = $get_special_offer['special_offer_id'];
|
|
|
|
$get_special_offer_sql = mysqli_query($db, "SELECT
|
|
(SELECT `id` FROM `db_tables` WHERE `name` = 'special_offer') AS `db_id`,
|
|
`special_offer_has_services`.`services_id`,
|
|
`services`.`name` AS `serv_name`,
|
|
`services`.`price`,
|
|
`special_offer`.`id` AS `offer_id`,
|
|
`special_offer`.`name`,
|
|
`special_offer`.`discount`,
|
|
`special_offer`.`type_discount_id`,
|
|
`special_offer`.`does_discount_enters_id`
|
|
FROM `special_offer_has_services`
|
|
LEFT JOIN `special_offer` ON `special_offer`.`id` = `special_offer_has_services`.`special_offer_id`
|
|
LEFT JOIN `services` ON `services`.`id` = `special_offer_has_services`.`services_id`
|
|
WHERE `special_offer_has_services`.`special_offer_id` = $special_offer_id
|
|
AND `special_offer_has_services`.`services_id` = $serv_id_temp
|
|
");
|
|
|
|
|
|
|
|
if (mysqli_num_rows($get_special_offer_sql) > 0) {
|
|
while ($row_special_offer = mysqli_fetch_assoc($get_special_offer_sql)) {
|
|
$discount_p = '';
|
|
$discount_style = '';
|
|
switch ($row_special_offer['type_discount_id']) {
|
|
case 2:
|
|
$discount_p = $row_special_offer['discount'];
|
|
$discount_style = $row_special_offer['discount'] . 'ريال';
|
|
break;
|
|
case 3:
|
|
$discount_p = ($row_special_offer['discount']/100) * $row_special_offer['price'];
|
|
if ($he_is_old) {
|
|
$discount_p = ($row_special_offer['discount']/100) * ($row_special_offer['price']-50);
|
|
}
|
|
$discount_style = $row_special_offer['discount'] . '%';
|
|
break;
|
|
}
|
|
|
|
array_push($offers['s_'.$row_special_offer['services_id'].'_'.$serv_count[$serv_id_temp]],
|
|
array(
|
|
'offer_id' => $row_special_offer['offer_id'],
|
|
'serv_name' => $row_special_offer['serv_name'],
|
|
'db_id' => $row_special_offer['db_id'],
|
|
'discount_name' => $row_special_offer['name'],
|
|
'discount' => $discount_p,
|
|
'discount_style' => $discount_style,
|
|
'services_id' => $row_special_offer['services_id'],
|
|
'does_discount_enters_id' => $row_special_offer['does_discount_enters_id']
|
|
)
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (!$he_is_old) {
|
|
// after how many serv offer // not auto
|
|
$get_after_how_many_serv_offer_sql = mysqli_query($db, "SELECT `book`.`id`
|
|
FROM `tretment`
|
|
LEFT JOIN `book` ON `book`.`tretment_id` = `tretment`.`id`
|
|
LEFT JOIN `book_details` AS `dd` ON `book`.`id` = `dd`.`book_id`
|
|
WHERE `tretment`.`id` = $tretment_id
|
|
AND `dd`.`id` IN (SELECT MAX(`id`) FROM `book_details` WHERE `book_id` = `dd`.`book_id`)
|
|
AND `dd`.`services_id` IN (1,3,93,95)
|
|
AND `dd`.`status_id` IN (6)
|
|
");
|
|
|
|
if (mysqli_num_rows($get_after_how_many_serv_offer_sql) >= 3) {
|
|
|
|
$get_after_how_many_serv_offer_has_services_sql = mysqli_query($db, "SELECT
|
|
(SELECT `id` FROM `db_tables` WHERE `name` = 'after_how_many_serv_offer') AS `db_id`,
|
|
`after_how_many_serv_offer_has_services`.`services_id`,
|
|
`services`.`name` AS `serv_name`,
|
|
`services`.`price`,
|
|
`after_how_many_serv_offer`.`id` AS `offer_id`,
|
|
`after_how_many_serv_offer`.`name`,
|
|
`after_how_many_serv_offer`.`discount`,
|
|
`after_how_many_serv_offer`.`type_discount_id`,
|
|
`after_how_many_serv_offer`.`does_discount_enters_id`
|
|
FROM `after_how_many_serv_offer_has_services`
|
|
LEFT JOIN `after_how_many_serv_offer` ON `after_how_many_serv_offer`.`id` = `after_how_many_serv_offer_has_services`.`after_how_many_serv_offer_id`
|
|
LEFT JOIN `services` ON `services`.`id` = `after_how_many_serv_offer_has_services`.`services_id`
|
|
WHERE `after_how_many_serv_offer_has_services`.`after_how_many_serv_offer_id` = 1
|
|
AND `after_how_many_serv_offer_has_services`.`services_id` = $serv_id_temp
|
|
");
|
|
|
|
if (mysqli_num_rows($get_after_how_many_serv_offer_has_services_sql) > 0) {
|
|
while ($row_after_how_many_serv_offer_has_services = mysqli_fetch_assoc($get_after_how_many_serv_offer_has_services_sql)) {
|
|
$discount_p = '';
|
|
$discount_style = '';
|
|
switch ($row_after_how_many_serv_offer_has_services['type_discount_id']) {
|
|
case 2:
|
|
$discount_p = $row_after_how_many_serv_offer_has_services['discount'];
|
|
$discount_style = $row_after_how_many_serv_offer_has_services['discount'] . 'ريال';
|
|
break;
|
|
case 3:
|
|
$discount_p = ($row_after_how_many_serv_offer_has_services['discount']/100) * $row_after_how_many_serv_offer_has_services['price'];
|
|
if ($he_is_old) {
|
|
$discount_p = ($row_after_how_many_serv_offer_has_services['discount']/100) * ($row_after_how_many_serv_offer_has_services['price']-50);
|
|
}
|
|
$discount_style = $row_after_how_many_serv_offer_has_services['discount'] . '%';
|
|
break;
|
|
}
|
|
array_push($offers['s_'.$row_after_how_many_serv_offer_has_services['services_id'].'_'.$serv_count[$serv_id_temp]],
|
|
array(
|
|
'offer_id' => $row_after_how_many_serv_offer_has_services['offer_id'],
|
|
'serv_name' => $row_after_how_many_serv_offer_has_services['serv_name'],
|
|
'db_id' => $row_after_how_many_serv_offer_has_services['db_id'],
|
|
'discount_name' => $row_after_how_many_serv_offer_has_services['name'],
|
|
'discount' => $discount_p,
|
|
'discount_style' => $discount_style,
|
|
'services_id' => $row_after_how_many_serv_offer_has_services['services_id'],
|
|
'does_discount_enters_id' => $row_after_how_many_serv_offer_has_services['does_discount_enters_id']
|
|
)
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// custom offer
|
|
$get_invoices_has_book_sql = mysqli_query($db, "SELECT
|
|
`invoices_id` FROM `invoices_has_book` WHERE `book_id` IN (
|
|
SELECT `id` FROM `book` WHERE `tretment_id` = $tretment_id
|
|
)
|
|
LIMIT 1
|
|
");
|
|
|
|
$get_does_he_use_it_sql = mysqli_query($db, "SELECT `isdtdshsdbts`.`invoices_discount_details_id`
|
|
FROM `invoices_discount_details_has_db_tables` AS `isdtdshsdbts`
|
|
LEFT JOIN `invoices_discount_details` AS `isdtds` ON `isdtds`.`id` = `isdtdshsdbts`.`invoices_discount_details_id`
|
|
LEFT JOIN `invoices_discount` AS `isdt` ON `isdtds`.`invoices_discount_id` = `isdt`.`id`
|
|
LEFT JOIN `invoices_details` AS `isds` ON `isdt`.`invoices_details_id` = `isds`.`id`
|
|
LEFT JOIN `invoices_has_book` AS `ishsbk` ON `isds`.`invoices_id` = `ishsbk`.`invoices_id`
|
|
LEFT JOIN `book` AS `bk` ON `bk`.`id` = `ishsbk`.`book_id`
|
|
|
|
WHERE `isdtdshsdbts`.`db_tables_id` = 7 AND `isdtdshsdbts`.`db_tables_id_to_id` = 1
|
|
AND bk.tretment_id = $tretment_id
|
|
");
|
|
|
|
if (mysqli_num_rows($get_invoices_has_book_sql) > 0 && mysqli_num_rows($get_does_he_use_it_sql) == 0) {
|
|
$get_custom_offer_sql = mysqli_query($db, "SELECT
|
|
(SELECT `id` FROM `db_tables` WHERE `name` = 'custom_offer') AS `db_id`,
|
|
`custom_offer_has_services`.`services_id`,
|
|
`services`.`name` AS `serv_name`,
|
|
`services`.`price`,
|
|
`custom_offer`.`id` AS `offer_id`,
|
|
`custom_offer`.`name`,
|
|
`custom_offer`.`discount`,
|
|
`custom_offer`.`type_discount_id`,
|
|
`custom_offer`.`does_discount_enters_id`
|
|
FROM `custom_offer_has_services`
|
|
LEFT JOIN `custom_offer` ON `custom_offer`.`id` = `custom_offer_has_services`.`custom_offer_id`
|
|
LEFT JOIN `services` ON `services`.`id` = `custom_offer_has_services`.`services_id`
|
|
WHERE `custom_offer_has_services`.`services_id` = $serv_id_temp
|
|
");
|
|
|
|
if (mysqli_num_rows($get_custom_offer_sql) > 0) {
|
|
while ($row_custom_offer = mysqli_fetch_assoc($get_custom_offer_sql)) {
|
|
$discount_p = '';
|
|
$discount_style = '';
|
|
switch ($row_custom_offer['type_discount_id']) {
|
|
case 2:
|
|
$discount_p = $row_custom_offer['discount'];
|
|
$discount_style = $row_custom_offer['discount'] . 'ريال';
|
|
break;
|
|
case 3:
|
|
$discount_p = ($row_custom_offer['discount']/100) * $row_custom_offer['price'];
|
|
$discount_style = $row_custom_offer['discount'] . '%';
|
|
break;
|
|
}
|
|
|
|
array_push($offers['s_'.$row_custom_offer['services_id'].'_'.$serv_count[$serv_id_temp]],
|
|
array(
|
|
'offer_id' => $row_custom_offer['offer_id'],
|
|
'serv_name' => $row_custom_offer['serv_name'],
|
|
'db_id' => $row_custom_offer['db_id'],
|
|
'discount_name' => $row_custom_offer['name'],
|
|
'discount' => $discount_p,
|
|
'discount_style' => $discount_style,
|
|
'services_id' => $row_custom_offer['services_id'],
|
|
'does_discount_enters_id' => $row_custom_offer['does_discount_enters_id']
|
|
)
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
$count_temp_2 = 1;
|
|
$move_flowerd = array_keys($offers);
|
|
$filter_offers = array_filter($offers);
|
|
|
|
if (count($filter_offers) == 0) {
|
|
?>
|
|
<tr>
|
|
<td colspan="6" scope="row">لا يتوفر اي خصم للعميل</td>
|
|
</tr>
|
|
</tbody>
|
|
<?php
|
|
} else {
|
|
for ($i=0; $i < count($offers); $i++) {
|
|
if (count($offers[$move_flowerd[$i]]) == 0) {
|
|
continue;
|
|
}
|
|
?>
|
|
<td rowspan="<?=count($offers[$move_flowerd[$i]])+1?>" scope="row"><?=$count_temp_2?></td>
|
|
<td rowspan="<?=count($offers[$move_flowerd[$i]])+1?>" scope="row"><?=$offers[$move_flowerd[$i]][0]['serv_name']?></td>
|
|
<?php
|
|
for ($z=0; $z < count($offers[$move_flowerd[$i]]); $z++) {
|
|
$one_singil_offer = $offers[$move_flowerd[$i]][$z];
|
|
if (!empty($vat)) {
|
|
$discount_temp = round($one_singil_offer['discount'] + ($one_singil_offer['discount']*$vat)/100, 2);
|
|
}
|
|
|
|
?>
|
|
<tr>
|
|
<td scope="row"><?=$one_singil_offer['discount_style']?></td>
|
|
<td scope="row"><?=$one_singil_offer['discount_name']?></td>
|
|
<td scope="row"><?=$discount_temp?></td>
|
|
<td scope="row">
|
|
<div class="form-check form-check-inline">
|
|
<div class="radio radio-primary get-data-radio">
|
|
<input type="radio" id="<?=$move_flowerd[$i].$z?>" name="<?php if ($one_singil_offer['does_discount_enters_id'] == 1){echo $move_flowerd[$i];}elseif($one_singil_offer['does_discount_enters_id'] == 2){echo $move_flowerd[$i].$z;}?>" data-when-call-all='<?=$move_flowerd[$i]?>' data-parsley-multiple="groups" data-parsley-mincheck="2"
|
|
data-offer-id='<?=$one_singil_offer["offer_id"]?>'
|
|
data-db-id='<?=$one_singil_offer["db_id"]?>'
|
|
data-discount='<?=$discount_temp?>'
|
|
data-why-discount='<?=$one_singil_offer['discount_name']?>'
|
|
data-discount-style='<?=$one_singil_offer["discount_style"]?>'
|
|
data-services-id='<?=$one_singil_offer["services_id"]?>'
|
|
data-does-discount-enters-id='<?=$one_singil_offer["does_discount_enters_id"]?>'>
|
|
<label class="mb-0" for="<?=$move_flowerd[$i].$z?>">تفعيل</label>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
$count_temp_2++;
|
|
}
|
|
?>
|
|
|
|
</tbody>
|
|
<thead class="table-primary">
|
|
<tr>
|
|
<th colspan="4" scope="col">المجموع</th>
|
|
<th style ="background-color: #fff;" scope="col" id='total_desc'><?=$total_discount_w_vat?></th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<?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-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">رصيد اموال</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<?php
|
|
$get_v_tretment_money_sql = mysqli_query($db,
|
|
"SELECT `money` FROM `tretment_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"><?=$row_v_tretment_money['money']?> ريال</th>
|
|
<?php
|
|
} else {
|
|
?>
|
|
<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
|
|
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>
|
|
</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">
|
|
<div class="form-group row">
|
|
<div class="col-12 col-sm-12 col-md-6 col-lg-6 col-xl-6">
|
|
<div class="table-responsive">
|
|
<table class="table table-bordered text-center">
|
|
<thead class="table-primary">
|
|
<tr>
|
|
<th scope="col">يمكن الاستفادة</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$get_tretment_has_service_sql = mysqli_query($db,
|
|
"SELECT `services`.`id` AS `serv_id`, `services`.`name`, `tretment_has_service`.`id`, `services`.`price`
|
|
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
|
|
ORDER BY `services`.`id` ASC"
|
|
);
|
|
$can = array();
|
|
$cant = array();
|
|
$serv_count = array_count_values($array_count_values);
|
|
ksort($serv_count);
|
|
|
|
if (mysqli_num_rows($get_tretment_has_service_sql) > 0) {
|
|
while ($row_tretment_has_service = mysqli_fetch_assoc($get_tretment_has_service_sql)) {
|
|
$price_temp = $row_tretment_has_service['price'];
|
|
if (!empty($vat)) {
|
|
$price_temp = $price_temp + ($price_temp*$vat)/100;
|
|
}
|
|
if (array_key_exists($row_tretment_has_service['serv_id'], $serv_count)) {
|
|
|
|
if ($serv_count[$row_tretment_has_service['serv_id']] > 0) {
|
|
array_push($can,
|
|
array(
|
|
'id' => $row_tretment_has_service['serv_id'],
|
|
'name' => $row_tretment_has_service['name'],
|
|
'price' => round($price_temp,2)
|
|
)
|
|
);
|
|
|
|
$serv_count[$row_tretment_has_service['serv_id']]--;
|
|
} else {
|
|
array_push($cant,
|
|
array(
|
|
'id' => $row_tretment_has_service['serv_id'],
|
|
'name' => $row_tretment_has_service['name'],
|
|
'price' => round($price_temp,2)
|
|
)
|
|
);
|
|
}
|
|
|
|
} else {
|
|
array_push($cant,
|
|
array(
|
|
'id' => $row_tretment_has_service['serv_id'],
|
|
'name' => $row_tretment_has_service['name'],
|
|
'price' => round($price_temp,2)
|
|
)
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (count($can)) {
|
|
for ($i=0; $i < count($can); $i++) {
|
|
?>
|
|
<tr>
|
|
<th scope="col">
|
|
<div class="checkbox">
|
|
<input id="s_<?=$can[$i]['id']?>_<?=$i+1?>" value="<?=$can[$i]['id']?>" data-price="<?=$can[$i]['price']?>" name="serv_c" type="checkbox">
|
|
<label for="s_<?=$can[$i]['id']?>_<?=$i+1?>"><?=$can[$i]['name']?></label>
|
|
</div>
|
|
</th>
|
|
</tr>
|
|
<?php
|
|
}
|
|
} else {
|
|
?>
|
|
<tr>
|
|
<th scope="col">لا يوجد</th>
|
|
</tr>
|
|
<?php
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="col-12 col-sm-12 col-md-6 col-lg-6 col-xl-6">
|
|
<div class="table-responsive">
|
|
<table class="table table-bordered text-center">
|
|
<thead class="table-danger">
|
|
<tr>
|
|
<th scope="col">لا يمكن الاستفادة</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
if (count($cant)) {
|
|
for ($i=0; $i < count($cant); $i++) {
|
|
?>
|
|
<tr>
|
|
<th scope="col"><?=$cant[$i]['name']?></th>
|
|
</tr>
|
|
<?php
|
|
}
|
|
} else {
|
|
?>
|
|
<tr>
|
|
<th scope="col">لا يوجد</th>
|
|
</tr>
|
|
<?php
|
|
}
|
|
?>
|
|
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="tab-pane fade" id="w-money" role="tabpanel" aria-labelledby="w-money-tab">
|
|
<p class="mb-0 m-t-30">
|
|
2
|
|
</p>
|
|
</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="after_stock" class="form-group row" style="display:none">
|
|
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
|
|
<h2 class="text-center" style="background: chartreuse;">
|
|
المبلغ المستحق بعد الاستفاده من احد الارصدة
|
|
<br />
|
|
<span id="price_after_stock" style="color:red">0</span>
|
|
ريال
|
|
</h2>
|
|
</div>
|
|
</div>
|
|
|
|
<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());
|
|
let serv_desc = 0
|
|
let stack_descu = 0
|
|
|
|
$('.get-data-radio input[type=radio]').change(function() {
|
|
let radios = $('.get-data-radio input[type=radio]:checked');
|
|
let total = 0;
|
|
for (let i = 0; i < radios.length; i++) {
|
|
let oneRadio = radios[i];
|
|
let value = oneRadio.getAttribute("data-discount");
|
|
|
|
total += parseFloat(value);
|
|
}
|
|
$('#total_desc').html(total);
|
|
total = Math.round((total) * 100) / 100
|
|
serv_desc = total;
|
|
|
|
$("[name='cash_pay']").val(0)
|
|
$("[name='card_pay']").val(0)
|
|
})
|
|
|
|
$("[name='serv_c']").change(function() {
|
|
let radios = $('input[name="serv_c"]');
|
|
let descu = 0;
|
|
for (let i = 0; i < radios.length; i++) {
|
|
if (radios[i].checked == true) {
|
|
let oneRadio = radios[i];
|
|
let value = oneRadio.getAttribute("id");
|
|
|
|
let radios_temp_all = $('.get-data-radio input[data-when-call-all="'+value+'"]');
|
|
for (let o = 0; o < radios_temp_all.length; o++) {
|
|
radios_temp_all[o].checked = false
|
|
radios_temp_all[o].disabled = true
|
|
radios_temp_all[o].parentElement.setAttribute("class", radios_temp_all[o].parentElement.getAttribute("class") + " radio-primary-custom")
|
|
}
|
|
|
|
let price = oneRadio.getAttribute("data-price");
|
|
descu += parseFloat(price)
|
|
|
|
} else {
|
|
let oneRadio = radios[i];
|
|
let value = oneRadio.getAttribute("id");
|
|
|
|
let radios_temp_all = $('.get-data-radio input[data-when-call-all="'+value+'"]');
|
|
for (let o = 0; o < radios_temp_all.length; o++) {
|
|
radios_temp_all[o].disabled = false
|
|
radios_temp_all[o].parentElement.classList.remove('radio-primary-custom');
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
total = Math.round((parseFloat(descu)) * 100) / 100;
|
|
stack_descu = total;
|
|
|
|
$("[name='cash_pay']").val(0)
|
|
$("[name='card_pay']").val(0)
|
|
|
|
total = 0;
|
|
radios = $('.get-data-radio input[type=radio]:checked');
|
|
for (let i = 0; i < radios.length; i++) {
|
|
let oneRadio = radios[i];
|
|
let value = oneRadio.getAttribute("data-discount");
|
|
|
|
total += parseFloat(value);
|
|
}
|
|
$('#total_desc').html(total);
|
|
total = Math.round((total) * 100) / 100
|
|
serv_desc = total;
|
|
});
|
|
|
|
$('input[type=radio]').change(function() {
|
|
$('#current_price').html(curr_price - serv_desc - stack_descu)
|
|
})
|
|
$('input[type=checkbox]').change(function() {
|
|
$('#current_price').html(curr_price - serv_desc - stack_descu)
|
|
})
|
|
|
|
$("[name='cash_pay']").change(function() {
|
|
let cash_pay = $("[name='cash_pay']").val();
|
|
$("[name='card_pay']").val(curr_price - serv_desc - stack_descu - cash_pay)
|
|
})
|
|
|
|
$("[name='card_pay']").change(function() {
|
|
let card_pay = $("[name='card_pay']").val();
|
|
$("[name='cash_pay']").val(curr_price - serv_desc - stack_descu - card_pay)
|
|
})
|
|
|
|
function pay1() {
|
|
let cash_pay = parseFloat($("[name='cash_pay']").val());
|
|
let card_pay = parseFloat($("[name='card_pay']").val());
|
|
let total_temp = curr_price - serv_desc - stack_descu;
|
|
|
|
if (cash_pay < 0 || card_pay < 0) {
|
|
swalfun("يرجى التحقق", "لا يمكن ان يكون المبلغ المدخل بالسالب", "warning");
|
|
return;
|
|
}
|
|
|
|
if (total_temp != (cash_pay + card_pay)) {
|
|
swalfun('يرجى التحقق','مدخلات الدفع غير مطابقه المبلغ المستحق','info');
|
|
return;
|
|
}
|
|
|
|
data = {
|
|
'serv':<?=json_encode($services_ids)?>,
|
|
'total': total_temp,
|
|
'total_discount':serv_desc + stack_descu,
|
|
}
|
|
|
|
let data_serv = data['serv'];
|
|
|
|
let serv_c = $('input[name="serv_c"]:checked');
|
|
for (let i = 0; i < serv_c.length; i++) {
|
|
let value = serv_c[i].value;
|
|
|
|
let y = data_serv.findIndex(e => e['id'] == value && (e['from_stuck'] == undefined || e['from_stuck'] == false) && (e['offers'] == undefined || e['offers'] == false));
|
|
if (y !== -1) {
|
|
data_serv[y]['from_stuck'] = true;
|
|
}
|
|
}
|
|
|
|
let serv_d = $('.get-data-radio input[type=radio]:checked');
|
|
let serv_d_temp = {};
|
|
for (let i = 0; i < serv_d.length; i++) {
|
|
let call_all = serv_d[i].getAttribute("data-when-call-all");
|
|
if (!serv_d_temp.hasOwnProperty(call_all)) {
|
|
serv_d_temp[call_all] = true
|
|
}
|
|
}
|
|
|
|
let serv_d_temp_keys = Object.keys(serv_d_temp);
|
|
for (let m = 0; m < serv_d_temp_keys.length; m++) {
|
|
|
|
let serv_dd = $('.get-data-radio input[data-when-call-all="'+serv_d_temp_keys[m]+'"]:checked');
|
|
let value_temp = serv_dd[0].getAttribute("data-services-id");
|
|
let y = data_serv.findIndex(e => e['id'] == value_temp && (e['from_stuck'] == undefined || e['from_stuck'] == false) && (e['offers'] == undefined || e['offers'] == false));
|
|
for (let a = 0; a < serv_dd.length; a++) {
|
|
let value = serv_dd[a].getAttribute("data-services-id");
|
|
|
|
if (y !== -1) {
|
|
data_serv[y]['offers'] = true;
|
|
if (!data_serv[y].hasOwnProperty("offers_d")) {
|
|
data_serv[y]['offers_d'] = [];
|
|
}
|
|
data_serv[y]['offers_d'].push({
|
|
'db_id': serv_dd[a].getAttribute("data-db-id"),
|
|
'offer_id': serv_dd[a].getAttribute("data-offer-id"),
|
|
'discount': serv_dd[a].getAttribute("data-discount"),
|
|
'why_discount': serv_dd[a].getAttribute("data-why-discount")
|
|
})
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
let tretment_id = <?=json_encode($tretment_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_ajax_2.php", {
|
|
data,
|
|
tretment_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>
|