booking/bundle_services.php

204 lines
7.6 KiB
PHP
Executable File

<?php
require_once('fixed/config/go_con.php');
access(27);
?>
<!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'); ?>
<!-- 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">
<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>
<h6 class="mt-0 header-title">معلومات الحجز</h6>
<div class="form-group row">
<div class="col-12 col-sm-12 col-md-6 col-lg-6 col-xl-6">
<label for="bundle_name" class="col-form-label text-right">اسم المجموعة</label>
<input id="bundle_name" class="form-control" type="text">
</div>
<div class="col-12 col-sm-12 col-md-6 col-lg-6 col-xl-6">
<label for="emp_name" class="col-form-label text-right">اسم الفني</label>
<select id="emp_name" style="font-family: system-ui;" class="form-control" name="booking_car_type">
<option value="0" selected>المرجو الاختيار</option>
<?php
$get_emplyee_sql = mysqli_query($db, "SELECT `branch`.`branch_name` AS `br_name`, `emplyee`.`id`,`emplyee`.`name` FROM `occupation`
LEFT JOIN `emplyee` ON `emplyee`.`occupation_id` = `occupation`.`id`
LEFT JOIN `branch` ON `emplyee`.`branch_id` = `branch`.`id`
WHERE `occupation`.`show_in_table_id` = 2");
while ($emplyee_row = mysqli_fetch_assoc($get_emplyee_sql)) {
?>
<option value="<?= $emplyee_row['id'] ?>"><?= $emplyee_row['name'] ?></option>
<?php
}
?>
</select>
</div>
</div>
<hr>
<div id="theService" class="form-group row">
</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_bundle">إضافة</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Container-fluid Ends-->
</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);
})
} else {
swalfun("يرجى الانتظار","", "warning");
}
}
// add booking
click = 0;
$(function() {
$("#add_bundle").click(function() {
add_bundle();
});
});
$('.clickfun').keypress(function (e) {
var key = e.which;
if(key == 13) {
add_bundle();
}
});
function add_bundle() {
let data = {};
$("input[name='how_many']").each(function(){
if (parseInt($(this).val()) > 0) {
data[$(this)[0].getAttribute("data-id")] = parseInt($(this).val());
}
});
if (Object.keys(data).length == 0) {
swalfun('حدث خطأ', 'لا يوجد اي خدمة مجمعة مضافة', 'error');
return false;
}
let bundle_name = $("#bundle_name").val();
if (bundle_name == '') {
swalfun('حدث خطأ', 'يرجى كتابة اسم للمجموعة', 'error');
return false;
}
let tretment_id = $("[name='tretment_id']").val();
if (tretment_id == undefined) {
swalfun('حدث خطأ', 'يرجى تحديد العميل', 'error');
return false;
}
let emp = $("#emp_name").val();
if (emp == 0) {
swalfun('حدث خطأ', 'يرجى اختيار الفني ', 'error');
return false;
}
if (click == 0) {
click++;
$.post("work/order/ajax/add_bundle_services_ajax.php", {
data,
bundle_name,
tretment_id,
emp,
}, function(get_tretment) {
$("#get_tretment").html(get_tretment);
})
} else {
swalfun("يرجى الانتظار", "", "warning");
}
}
// get branch when change emplyee
$(function() {
$("#emp_name").change(function() {
var empName = $(this).val();
$.post("work/order/ajax/get_bundle_services_ajax.php", {
empName,
}, function(theService) {
$("#theService").html(theService);
})
});
});
</script>
</body>
</html>