303 lines
13 KiB
PHP
Executable File
303 lines
13 KiB
PHP
Executable File
<?php
|
|
require_once('fixed/config/go_con.php');
|
|
access(23);
|
|
|
|
$emp_id = $_GET['emp_id'];
|
|
$booking_day_date = $_GET['date'];
|
|
$booking_day_time = $_GET['time'];
|
|
$booking_branch_id = $_GET['branch'];
|
|
if (empty($booking_day_date) || empty($booking_day_time) || empty($booking_branch_id)) {
|
|
echo "
|
|
<script>
|
|
window.location.href = 'book_visits';
|
|
</script>
|
|
";
|
|
}
|
|
$branch_name =''; // for view branch name in box
|
|
mysqli_query($db,
|
|
"INSERT INTO `table`(`day_date`, `day_time`, `notes`, `branch_id`, `emplyee_id`, `status_id`, `date_time`, `user_id`, `activation_id`)
|
|
VALUES ('$booking_day_date', '$booking_day_time', '', '$booking_branch_id', '$emp_id', '3', '$date_time', '$admin_id', '2')"
|
|
);
|
|
|
|
$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");
|
|
?>
|
|
<!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>
|
|
<h6 class="mt-0 header-title">معلومات الحجز</h6>
|
|
<div class="form-group row">
|
|
<div class="col-12 col-sm-12 col-md-3 col-lg-3 col-xl-3">
|
|
<label for="" 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
|
|
while ($emplyee_row = mysqli_fetch_assoc($get_emplyee_sql)) {
|
|
?>
|
|
<option <?php if($emp_id == $emplyee_row['id']) {$branch_name = $emplyee_row['br_name']; echo 'selected';}?> value="<?= $emplyee_row['id'] ?>"><?= $emplyee_row['name'] ?></option>
|
|
<?php
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
<div class="col-12 col-sm-12 col-md-3 col-lg-3 col-xl-3">
|
|
<label for="" class="col-form-label text-right">الخدمة المطلوبة</label>
|
|
<select id="theService" style="font-family: system-ui;" class="form-control">
|
|
<option value="-1" data-cuPrice="0" data-price="0" selected>المرجو الاختيار</option>
|
|
<?php
|
|
$get_Service_sql = mysqli_query($db, "SELECT `id`, `name`, `price` FROM `services`
|
|
WHERE `type_of_services_id` = 14
|
|
AND `commercial_register_id` = 1
|
|
AND `activation_id` = 2
|
|
");
|
|
while($Service_row = mysqli_fetch_assoc($get_Service_sql)) {
|
|
?>
|
|
<option value="<?=$Service_row['id']?>" data-cuPrice="<?=round($Service_row['price'],2)?>" data-price="<?=round($Service_row['price'] + (($Service_row['price'])*$vat)/100,2)?>"><?=$Service_row['name']?> >>> السعر : <?=round($Service_row['price'] + (($Service_row['price'])*$vat)/100, 2) ?> </option>
|
|
<?php
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
<div class="col-12 col-sm-12 col-md-3 col-lg-3 col-xl-3">
|
|
<label for="driver" class="col-form-label text-right">السائق</label>
|
|
<select id="driver" style="font-family: system-ui;" class="form-control">
|
|
<option value="0" data-cuPrice="0" data-price="0" selected>المرجو الاختيار</option>
|
|
<?php
|
|
$get_Service_sql = mysqli_query($db, "SELECT `id`, `name` FROM `emplyee`
|
|
WHERE `occupation_id` = 7
|
|
AND `activation_id` = 2
|
|
");
|
|
while($Service_row = mysqli_fetch_assoc($get_Service_sql)) {
|
|
?>
|
|
<option value="<?=$Service_row['id']?>" ><?=$Service_row['name']?></option>
|
|
<?php
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
<div class="col-12 col-sm-12 col-md-3 col-lg-3 col-xl-3">
|
|
<label for="send_sms" class="col-form-label text-right">ارسال رسالة</label>
|
|
<select id="send_sms" style="font-family: system-ui;" class="form-control">
|
|
<option value="1">لا</option>
|
|
<option value="2" selected>نعم</option>
|
|
</select>
|
|
</div>
|
|
<div class="col-12 col-sm-12 col-md-6 col-lg-4 col-xl-4">
|
|
<label for="" class="col-form-label text-right">التاريخ</label>
|
|
<input class="form-control clickfun" type="text" value="<?=$booking_day_date?>" disabled>
|
|
</div>
|
|
<div class="col-12 col-sm-12 col-md-6 col-lg-4 col-xl-4">
|
|
<label for="" class="col-form-label text-right">الوقت</label>
|
|
<input class="form-control clickfun" type="text" value="<?=$booking_day_time?>" disabled>
|
|
</div>
|
|
<div class="col-12 col-sm-12 col-md-6 col-lg-4 col-xl-4">
|
|
<label for="" class="col-form-label text-right">الفرع</label>
|
|
<input id="branch_vv" class="form-control clickfun" type="text" value="<?=$branch_name?>" disabled>
|
|
</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 row="4" name="booking_notes" class="form-control" type="text"> </textarea>
|
|
</div>
|
|
</div>
|
|
<hr>
|
|
<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_booking">إضافة</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php require_once('fixed/footer/go.php'); ?>
|
|
</div>
|
|
</div>
|
|
<?php require_once('fixed/js/go.php'); ?>
|
|
<script>
|
|
// for limit clicks
|
|
searchClick = 0;
|
|
click = 0;
|
|
|
|
// if come with number
|
|
<?php
|
|
if (!empty($number)) {
|
|
?>
|
|
$("#number").val(<?=json_encode($number);?>);
|
|
search_tretment();
|
|
<?php
|
|
}
|
|
?>
|
|
|
|
// search for tretment
|
|
$(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
|
|
$(function() {
|
|
$("#add_booking").click(function() {
|
|
add_booking();
|
|
});
|
|
});
|
|
$('.clickfun2').keypress(function (e) {
|
|
var key = e.which;
|
|
if(key == 13) {
|
|
add_booking();
|
|
}
|
|
});
|
|
function add_booking() {
|
|
|
|
tretment_id = $("[name='tretment_id']").val();
|
|
if (tretment_id == undefined) {
|
|
swalfun('حدث خطأ', 'يرجى تحديد العميل', 'error');
|
|
return false;
|
|
}
|
|
var tretmentName = $("#tretmentName").html();
|
|
var tretmentNumber = $("#number").val();
|
|
if (tretmentNumber.length !== 9) {
|
|
swalfun('حدث خطأ', 'رقم الجوال يجب أن يتكون من 9 أرقام وبدون 0 في البداية', 'error');
|
|
return false;
|
|
}
|
|
emp = $("#emp_name").val();
|
|
if (emp == 0) {
|
|
swalfun('حدث خطأ', 'يرجى اختيار الفني ', 'error');
|
|
return false;
|
|
}
|
|
theService = $("#theService").val();
|
|
if (theService <= 0) {
|
|
swalfun('حدث خطأ', 'يرجى اختيار نوع الخدمة', 'error');
|
|
return false;
|
|
}
|
|
|
|
driver = $("#driver").val();
|
|
if (driver <= 0) {
|
|
swalfun('حدث خطأ', 'يرجى اختيار نوع الخدمة', 'error');
|
|
return false;
|
|
}
|
|
|
|
send_sms = $("#send_sms").val();
|
|
|
|
bundle_id = $("#bundle_name").val();
|
|
if (bundle_id == 0) {
|
|
swalfun('حدث خطأ', 'يرجى اختيار نوع الخدمات المجمعة', 'error');
|
|
return false;
|
|
}
|
|
|
|
booking_notes = $("[name='booking_notes']").val();
|
|
booking_id = <?=json_encode($booking_id);?>;
|
|
branch_id = <?=json_encode($booking_branch_id);?>;
|
|
emp_id = $("#emp_name").val();
|
|
emp_name = $("#emp_name").find(":selected").text();
|
|
booking_day_date = <?=json_encode($booking_day_date);?>;
|
|
booking_day_time = <?=json_encode($booking_day_time);?>;
|
|
if (click == 0) {
|
|
click++;
|
|
$.post("work/order/ajax/add_booking_visits_ajax.php", {
|
|
tretment_id,
|
|
emp_name,
|
|
tretmentNumber,
|
|
tretmentName,
|
|
booking_id,
|
|
theService,
|
|
driver,
|
|
send_sms,
|
|
booking_notes,
|
|
branch_id,
|
|
bundle_id,
|
|
emp_id,
|
|
booking_day_date,
|
|
booking_day_time,
|
|
}, 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_branch_ajax.php", {
|
|
empName,
|
|
}, function(data) {
|
|
$("#branch_vv").val(data['val']);
|
|
})
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|