booking/work/files/old/booking15092022.php
2025-03-24 19:02:58 +03:00

272 lines
10 KiB
PHP

<?php
require_once('fixed/config/go_con.php');
access(50);
// if come with number
$number = $_GET['number'];
// if come with number end
// if come with booking_id
$booking_id = $_GET['booking_id'];
if (empty($booking_id)) {
$booking_id = 0;
} else {
if (!is_numeric($booking_id)) {
$booking_id = 0;
}
}
// if come with booking_id
$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)) {
header('location:index.php');
}
$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'); ?>
<!-- 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="" 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-6 col-lg-6 col-xl-6">
<label for="" class="col-form-label text-right">الخدمة المطلوبة</label>
<select id="theService" style="font-family: system-ui;" class="form-control">
</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>
<!-- Container-fluid Ends-->
</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;
// get services
$(function() {
var empName = <?= json_encode($emp_id) ?>;
$.post("work/order/ajax/get_services_ajax.php", {
empName: empName
}, function(theService) {
$("#theService").html(theService);
})
});
// 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() {
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;
}
let theService = $("#theService").val();
if (theService == 0) {
swalfun('حدث خطأ', 'يرجى اختيار نوع الخدمة', 'error');
return false;
}
let booking_notes = $("[name='booking_notes']").val();
let booking_id = <?=json_encode($booking_id);?>;
let branch_id = <?=json_encode($booking_branch_id);?>;
let emp_id = $("#emp_name").val();
let booking_day_date = <?=json_encode($booking_day_date);?>;
let booking_day_time = <?=json_encode($booking_day_time);?>;
if (click == 0) {
click++;
$.post("work/order/ajax/add_booking_ajax.php", {
tretment_id,
booking_id,
theService,
booking_notes,
branch_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_services_ajax.php", {
empName,
}, function(theService) {
$("#theService").html(theService);
})
$.post("work/order/ajax/get_branch_ajax.php", {
empName,
}, function(data) {
$("#branch_vv").val(data['val']);
})
});
});
</script>
</body>
</html>