booking/tretment_serv_details.php

229 lines
9.8 KiB
PHP
Executable File

<?php
require_once('fixed/config/go_con.php');
access(5);
?>
<!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;
}
</style>
<?php require_once('fixed/loader/go.php'); ?>
<div class="page-wrapper" id="pageWrapper">
<?php require_once('fixed/header/go.php'); ?>
<div class="page-body-wrapper">
<?php require_once('fixed/sidebar/go.php'); ?>
<div class="page-body">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body new-user order-list">
<h6 class="mt-0 header-title">البحث</h6>
<div class="form-group row">
<div class="col-8 col-sm-6 col-lg-3 p-r-0">
<label for="" class="col-form-label text-right">رقم الجوال</label>
<input id="number" class="form-control clickfun1" type="number" value="" required>
</div>
<div class="col-4 col-sm-6 col-lg-1 p-l-0">
<label style="visibility: hidden;" for="" class="col-form-label text-right">..</label>
<div class="form-control" style="background-color: #086367; color:white; text-align:center; cursor: pointer;" id="search_tretment">بحث</div>
</div>
</div>
<div id="get_tretment">
</div>
<hr>
<?php
$type_of_services_sql = mysqli_query($db, "SELECT `type_of_services`.`id`, `type_of_services`.`name`
FROM `services`
INNER JOIN `type_of_services` ON `type_of_services`.`id` = `services`.`type_of_services_id`
WHERE `services`.`commercial_register_id` = $commercial_register_id AND `services`.`activation_id` = 2
GROUP BY `type_of_services`.`id`
");
if (mysqli_num_rows($type_of_services_sql) > 0) {
?>
<div class="card-body">
<ul class="nav nav-pills nav-justified" role="tablist">
<?php
if (mysqli_num_rows($type_of_services_sql) > 1) {
?>
<?php
while ($type_of_services = mysqli_fetch_assoc($type_of_services_sql)) {
?>
<li class="nav-item waves-effect waves-light">
<a class="nav-link" id="tap_id<?=$type_of_services['id']?>-tab" data-bs-toggle="pill" href="#tap_id<?=$type_of_services['id']?>" role="tab" aria-controls="tap_id<?=$type_of_services['id']?>" aria-selected="false"><?=$type_of_services['name']?></a>
</li>
<?php
}
}
?>
</ul>
</div>
<?php
}
?>
<div id="theService" class="form-group row">
<div class="tab-content" id="pills-tabContent">
<?php
$type_of_services_sql = mysqli_query($db, "SELECT `type_of_services`.`id`, `type_of_services`.`name`
FROM `services`
INNER JOIN `type_of_services` ON `type_of_services`.`id` = `services`.`type_of_services_id`
WHERE `services`.`commercial_register_id` = $commercial_register_id AND `services`.`activation_id` = 2
GROUP BY `type_of_services`.`id`
");
if (mysqli_num_rows($type_of_services_sql) > 0) {
while ($type_of_services = mysqli_fetch_assoc($type_of_services_sql)) {
?>
<div class="tab-pane fade" id="tap_id<?=$type_of_services['id']?>" role="tabpanel" aria-labelledby="tap_id<?=$type_of_services['id']?>-tab">
<div class="form-group row">
<?php
$temp_id = $type_of_services['id'];
$get_services_sql = mysqli_query($db, "SELECT
`services`.`id`,
`services`.`price`,
`services`.`name`
FROM `services`
WHERE `services`.`type_of_services_id` = $temp_id AND `services`.`commercial_register_id` = $commercial_register_id AND `services`.`activation_id` = 2
");
if (mysqli_num_rows($get_services_sql) > 0) {
while ($services_row = mysqli_fetch_assoc($get_services_sql)) {
?>
<div class="col-12 col-sm-12 col-md-6 col-lg-6 col-xl-6">
<label for="serv_<?=$services_row['id']?>" class="col-form-label text-right">اسم الخدمة</label>
<input id="serv_<?=$services_row['id']?>" class="form-control" type="text" value="<?=$services_row['name']?>" disabled>
</div>
<div class="col-12 col-sm-12 col-md-6 col-lg-6 col-xl-6">
<label for="many_<?=$services_row['id']?>" class="col-form-label text-right">العدد</label>
<input id="many_<?=$services_row['id']?>" name="how_many" data-price="<?=round(($services_row['price']) + (($services_row['price'] * 15)/100),2)?>" data-id="<?=$services_row['id']?>" class="form-control clickfun1" type="number" value="0">
</div>
<?php
}
}
?>
</div>
</div>
<?php
}
}
?>
</div>
</div>
<div class="form-group row">
<div class="col-lg-12">
<div class="form-control" style="background-color: #086367; color:white; text-align:center; cursor: pointer;" id="add_services">حساب المبلغ</div>
</div>
</div>
</div>
</div>
<div id="get_data"></div>
</div>
</div>
</div>
</div>
<?php require_once('fixed/footer/go.php'); ?>
</div>
</div>
<?php require_once('fixed/js/go.php'); ?>
<script>
// search for tretment
searchClick = 0;
$(function() {
$("#search_tretment").click(function() {
search_tretment();
});
});
$('.clickfun1').keypress(function (e) {
var key = e.which;
if(key == 13) {
search_tretment();
}
});
function search_tretment() {
if ($("#number").val().length !== 9) {
swalfun('حدث خطأ', 'رقم الجوال يجب أن يتكون من 9 أرقام وبدون 0 في البداية', 'error');
return false;
}
var tretmentNumber = $("#number").val();
let branch_id = <?=json_encode($booking_branch_id);?>;
var emp_id = <?=json_encode($emp_id);?>;
var booking_day_date = <?=json_encode($booking_day_date);?>;
var booking_day_time = <?=json_encode($booking_day_time);?>;
if (searchClick == 0) {
searchClick++;
$.post("work/order/ajax/get_tretment_ajax.php", {
tretmentNumber,
branch_id,
emp_id,
booking_day_date,
booking_day_time,
}, function(get_tretment) {
$("#get_tretment").html(get_tretment);
$("#get_data").html('<hr/>');
})
} else {
swalfun("يرجى الانتظار","", "warning");
}
}
// add booking
click = 0;
$(function() {
$("#add_services").click(function() {
add_services();
});
});
$('.clickfun1').keypress(function (e) {
var key = e.which;
if(key == 13) {
add_services();
}
});
let total = 0;
function add_services() {
let data = {};
total = 0;
$("input[name='how_many']").each(function(){
if (parseInt($(this).val()) > 0) {
data[$(this)[0].getAttribute("data-id")] = parseInt($(this).val());
total += parseFloat($(this).attr('data-price')) * parseInt($(this).val());
}
});
if (Object.keys(data).length == 0) {
swalfun('حدث خطأ', 'لا يوجد اي خدمة مضافة', 'error');
return false;
}
let tretment_id = $("[name='tretment_id']").val();
if (tretment_id == undefined) {
swalfun('حدث خطأ', 'يرجى تحديد العميل', 'error');
return false;
}
total = total;
console.log(data);
// if (click == 0) {
click++;
$.post("work/order/ajax/tretment_serv_details_ajax.php", {
data,
tretment_id,
}, function(get_tretment) {
$("#get_data").html(get_tretment);
})
// } else {
// swalfun("يرجى الانتظار", "", "warning");
// }
}
</script>
</body>
</html>