2114 lines
156 KiB
PHP
Executable File

<?php
require_once('fixed/config/go_con.php');
access(7); // 7
$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'];
// if ($br_id == 5) {
// access(50);
// }
$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`,
`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`.`day_date` = '$day_date'
AND `dd`.`status_id` IN (4)
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 = '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)) {
$price_temp_a = $row_an_employee_offer_has_services['price'];
$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('2023-12-31 23:59:59') ) {
if ($serv_id_temp == 1 || $serv_id_temp == 2) {
$temp_des = $price_temp_a - 100;
$discount_p = $temp_des;
$discount_style = $temp_des . 'ريال';
$stop_date_time_reg_tretment_offer = false;
} elseif ($serv_id_temp == 3) {
$temp_des = $price_temp_a - 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']
)
);
}
}
}
$he_is_3_serv = false;
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,8,14,15)
");
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) {
$he_is_3_serv = true;
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']
)
);
}
}
}
}
// from to offers
$do_not_enter = false;
$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
");
$do_not_enter_with_this_ids = array(12,13,14);
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];
$skip_frist = 0;
for ($from; $from <= $to; $from++) {
$push_time_work = $from . ":00:00";
if ($skip_frist != 0) {
if ($from < 10) {
$push_time_work = "0" . $from . ":00:00";
}
}
array_push($time_work, $push_time_work);
$skip_frist++;
}
$offer_id = $row_from_to_offers['offer_id'];
if (in_array($offer_id, $do_not_enter_with_this_ids)) {
$do_not_enter = true;
}
$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'];
if (($he_is_old && $row_from_to_offers['services_id'] == 3)|| $he_is_3_serv) {
$discount_p = ($row_from_to_offers['discount']/100) * ($row_from_to_offers['price']-50);
}
$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 || $he_is_3_serv) && $row_special_offer['services_id'] == 3) {
$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']
)
);
}
}
}
}
// custom discount
$has_custom_discount = 0;
$get_an_employee_offer_has_services_sql = mysqli_query($db, "SELECT
`tretment_has_custom_discount`.`services_id`,
`services`.`name` AS `serv_name`,
`services`.`price`,
`tretment_has_custom_discount`.`id` AS `offer_id`,
`custom_discount`.`reason` AS `name`,
`tretment_has_custom_discount`.`discount`,
`tretment_has_custom_discount`.`type_discount_id`
FROM `tretment_has_custom_discount`
LEFT JOIN `custom_discount` ON `custom_discount`.`id` = `tretment_has_custom_discount`.`inv_table_id`
LEFT JOIN `services` ON `services`.`id` = `tretment_has_custom_discount`.`services_id`
WHERE `tretment_has_custom_discount`.`tretment_id` = $tretment_id
AND `tretment_has_custom_discount`.`done_id` = 1
AND `tretment_has_custom_discount`.`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;
}
$has_custom_discount++;
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' => 18,
'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' => 1
)
);
}
}
// coupon
$has_coupon = 0;
$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` = 21 AND `isdtdshsdbts`.`db_tables_id_to_id` IN (2,3,4,5)
AND bk.tretment_id = $tretment_id
");
if (mysqli_num_rows($get_does_he_use_it_sql) == 0 && $serv_id_temp == 1) {
$get_an_employee_offer_has_services_sql = mysqli_query($db, "SELECT
`tretment_has_coupons`.`coupons_id` AS `offer_id`,
`tretment_has_coupons`.`code` AS `name`,
`coupons`.`discount`,
`coupons`.`type_discount_id`
FROM `tretment_has_coupons`
INNER JOIN `coupons` ON `coupons`.`id` = `tretment_has_coupons`.`coupons_id`
WHERE `tretment_has_coupons`.`tretment_id` = $tretment_id
");
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) * 200;
$discount_style = $row_an_employee_offer_has_services['discount'] . '%';
break;
}
$has_custom_discount++;
array_push($offers['s_1_'.$serv_count[$serv_id_temp]],
array(
'offer_id' => $row_an_employee_offer_has_services['offer_id'],
'serv_name' => 'تدليك الاقدام',
'db_id' => 21,
'discount_name' => $row_an_employee_offer_has_services['name'],
'discount' => $discount_p,
'discount_style' => $discount_style,
'services_id' => 1,
'does_discount_enters_id' => 1,
)
);
}
}
}
// custom offer
if(!$do_not_enter){
if ($has_custom_discount == 0 || $has_coupon == 0) {
$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']
)
);
}
}
}
}
}
}
// $sort_by_price = array();
// foreach ($offers as $key => $row)
// {
// $sort_by_price[$key] = $row['discount'];
// }
// array_multisort($sort_by_price, SORT_DESC, $offers);
$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" 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>
<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">
<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">
<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_free_service_sql = mysqli_query($db,
"SELECT `services`.`id` AS `serv_id`, `services`.`name`, `tretment_has_free_service`.`id`, `services`.`price`
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
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_free_service_sql) > 0) {
while ($row_tretment_has_free_service = mysqli_fetch_assoc($get_tretment_has_free_service_sql)) {
$price_temp = $row_tretment_has_free_service['price'];
if (!empty($vat)) {
$price_temp = $price_temp + ($price_temp*$vat)/100;
}
if (array_key_exists($row_tretment_has_free_service['serv_id'], $serv_count)) {
if ($serv_count[$row_tretment_has_free_service['serv_id']] > 0) {
array_push($can,
array(
'id' => $row_tretment_has_free_service['serv_id'],
'name' => $row_tretment_has_free_service['name'],
'price' => round($price_temp,2)
)
);
$serv_count[$row_tretment_has_free_service['serv_id']]--;
} else {
array_push($cant,
array(
'id' => $row_tretment_has_free_service['serv_id'],
'name' => $row_tretment_has_free_service['name'],
'price' => round($price_temp,2)
)
);
}
} else {
array_push($cant,
array(
'id' => $row_tretment_has_free_service['serv_id'],
'name' => $row_tretment_has_free_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="f_s_<?=$can[$i]['id']?>_<?=$i+1?>" value="<?=$can[$i]['id']?>" data-price="<?=$can[$i]['price']?>" name="f_serv_c" type="checkbox">
<label for="f_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>
</div>
<div class="card-body new-user order-list">
<div id="pay" class="form-group row">
<hr>
<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="" 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); 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="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 class="form-check form-check-inline">
<div class="radio radio-primary">
<input type="radio" id="card_type_TRANS" name="card_type" data-parsley-multiple="groups" data-parsley-mincheck="2" value="4">
<label class="mb-0" for="card_type_TRANS">تحويل</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" <?php if($br_id != 5){echo "disabled";} ?>>
</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" <?php if($br_id != 5){echo "disabled";} ?>>
<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;" <?php if($br_id != 5){echo "disabled";} ?>>
</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" <?php if($br_id != 5){echo "disabled";} ?>></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);?>;
var inputTypes = [];
var inputTypes_checked = [];
$("[name='cash_pay']").keypress(function (e) {
var key = e.which;
if(key == 13) {
$('.get-data-radio input[type=radio]').each(function(){
inputTypes.push($(this).attr('type'));
});
$('.get-data-radio input[type=radio]:checked').each(function(){
inputTypes_checked.push($(this).attr('type'));
});
//code();
if (inputTypes.length > 0) {
if (inputTypes_checked.length > 0) {
pay();
} else {
pay1();
}
} else {
pay();
}
}
});
$("[name='card_pay']").keypress(function (e) {
var key = e.which;
if(key == 13) {
$('.get-data-radio input[type=radio]').each(function(){
inputTypes.push($(this).attr('type'));
});
$('.get-data-radio input[type=radio]:checked').each(function(){
inputTypes_checked.push($(this).attr('type'));
});
//code();
if (inputTypes.length > 0) {
if (inputTypes_checked.length > 0) {
pay();
} else {
pay1();
}
} else {
pay();
}
}
});
$(function() {
$("#pay-action").click(function() {
$('.get-data-radio input[type=radio]').each(function(){
inputTypes.push($(this).attr('type'));
});
$('.get-data-radio input[type=radio]:checked').each(function(){
inputTypes_checked.push($(this).attr('type'));
});
//code();
if (inputTypes.length > 0) {
if (inputTypes_checked.length > 0) {
pay();
} else {
pay1();
}
} else {
pay();
}
});
});
let click = 0;
let curr_price = parseFloat($('#current_price').html());
let serv_desc = 0
let free_stack_descu = 0
let stack_descu = 0
let have_descount = 0;
let money_stuck = 0;
let static_money_stuck = parseFloat(<?=json_encode($static_money_stuck)?>);
$('.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 free_serv_checkboxs = $('input[name="f_serv_c"]');
for (let o = 0; o < free_serv_checkboxs.length; o++) {
if (free_serv_checkboxs[o].getAttribute("id") == ('f_'+value)) {
free_serv_checkboxs[o].disabled = true;
break;
}
}
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');
}
let free_serv_checkboxs = $('input[name="f_serv_c"]');
for (let o = 0; o < free_serv_checkboxs.length; o++) {
if (free_serv_checkboxs[o].getAttribute("id") == ('f_'+value)) {
free_serv_checkboxs[o].disabled = false;
break;
}
}
}
}
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;
});
$("[name='f_serv_c']").change(function() {
let radios = $('input[name="f_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").slice(2);
// for radios
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")
}
// for radios
// for checkbox serv_c
let serv_checkboxs = $('input[name="serv_c"]');
for (let o = 0; o < serv_checkboxs.length; o++) {
if (serv_checkboxs[o].getAttribute("id") == (value)) {
serv_checkboxs[o].disabled = true;
break;
}
}
// for checkbox serv_c
let price = oneRadio.getAttribute("data-price");
descu += parseFloat(price)
} else {
let oneRadio = radios[i];
let value = oneRadio.getAttribute("id").slice(2);
// for radios
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');
}
// for radios
// for checkbox serv_c
let serv_checkboxs = $('input[name="serv_c"]');
for (let o = 0; o < serv_checkboxs.length; o++) {
if (serv_checkboxs[o].getAttribute("id") == (value)) {
serv_checkboxs[o].disabled = false;
break;
}
}
// for checkbox serv_c
}
}
total = Math.round((parseFloat(descu)) * 100) / 100;
free_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(Math.round((curr_price - serv_desc - stack_descu - free_stack_descu - money_stuck) * 100) / 100)
})
$('input[type=checkbox]').change(function() {
$('#current_price').html(Math.round((curr_price - serv_desc - stack_descu - free_stack_descu - money_stuck) * 100) / 100)
})
$("[name='cash_pay']").change(function() {
let cash_pay = $("[name='cash_pay']").val();
// $("[name='card_pay']").val(Math.round((curr_price - serv_desc - stack_descu - free_stack_descu - cash_pay) * 100) / 100)
})
$("[name='card_pay']").change(function() {
let card_pay = $("[name='card_pay']").val();
// $("[name='cash_pay']").val(Math.round((curr_price - serv_desc - stack_descu - free_stack_descu - card_pay) * 100) / 100)
})
function money_stuck_value() {
money_stuck = $("#money_stuck").val();
if(money_stuck > static_money_stuck) {
swalfun("يرجى التحقق", "لا يمكن ان يكون المبلغ المدخل اكبر من رصيد العميل", "warning");
return;
}
$('#current_price').html(Math.round((curr_price - serv_desc - stack_descu - free_stack_descu - money_stuck) * 100) / 100)
}
$('#money_stuck').change(function() {
money_stuck_value()
})
//function code() {
// swal.fire({
// title: 'كود التفعيل',
// text: '',
// type: 'warning',
// showCancelButton: true,
// confirmButtonColor: '#3085d6',
// cancelButtonColor: '#d33',
// confirmButtonText: 'تحقق',
// cancelButtonText: 'الغاء'
// }).then((result) => {
// if (result.value <= 9999 && result.lengh == 4) {
// pay1()
// } else {
// swalfun('يرجى التحقق','ادخل رمز مكون من 4 ارقام','info');
// }
// })
//}
function pay1() {
swal.fire({
title: 'يوجد خصم للعميل',
text: '',
type: 'error',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'تجاهل',
cancelButtonText: 'الغاء'
}).then((result) => {
if (result.value) {
pay();
}
})
}
function pay() {
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;
}
let cash_pay = parseFloat($("[name='cash_pay']").val());
let card_pay = parseFloat($("[name='card_pay']").val());
let card_approval_number = $("[name='card_approval_number']").val();
let card_type = $('input[name="card_type"]:checked').val();
if (card_pay > 0) {
if (card_type != 4) {
if (card_approval_number.length != 6) {
swalfun("يرجى التحقق", "رقم التفويض", "warning");
return;
}
}
}
let total_temp = Math.round((curr_price - serv_desc - stack_descu - free_stack_descu) * 100) / 100;
if (cash_pay < 0 || card_pay < 0) {
swalfun("يرجى التحقق", "لا يمكن ان يكون المبلغ المدخل بالسالب", "warning");
return;
}
if (total_temp != (cash_pay + card_pay + money_stuck)) {
swalfun('يرجى التحقق','مدخلات الدفع غير مطابقه المبلغ المستحق','info');
return;
}
data = {
'serv':<?=json_encode($services_ids)?>,
'total': total_temp,
'money_stuck': money_stuck,
'total_discount':serv_desc + stack_descu + free_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['from_stuck_free'] == undefined || e['from_stuck_free'] == false) && (e['offers'] == undefined || e['offers'] == false));
if (y !== -1) {
data_serv[y]['from_stuck'] = true;
}
}
let f_serv_c = $('input[name="f_serv_c"]:checked');
for (let i = 0; i < f_serv_c.length; i++) {
let value = f_serv_c[i].value;
let y = data_serv.findIndex(e => e['id'] == value && (e['from_stuck_free'] == undefined || e['from_stuck_free'] == false) && (e['from_stuck'] == undefined || e['from_stuck'] == false) && (e['offers'] == undefined || e['offers'] == false));
if (y !== -1) {
data_serv[y]['from_stuck_free'] = 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) && (e['from_stuck_free'] == undefined || e['from_stuck_free'] == 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 br_id = <?=json_encode($br_id);?>;
let cash_note = $("[name='cash_note']").val();
let card_note = $("[name='card_note']").val();
//for more action
let day_date = <?=json_encode($day_date);?>;
click = 0
console.log(data)
if (click == 0) {
click++;
$.post("work/order/ajax/active_ajax_4.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>