booking/add_emp_offer.php

335 lines
16 KiB
PHP
Executable File

<?php
require_once('fixed/config/go_con.php');
access(29);
$Select2 = true;
?>
<!DOCTYPE html>
<html lang="en" dir="rtl">
<?php require_once('fixed/head/go.php'); ?>
<body class="rtl">
<?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">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body new-user order-list">
<form action="" method="post" enctype="multipart/form-data">
<h4 class="mt-0 header-title">معلومات العرض</h4>
<div class="form-group row">
<div class="col-lg-4 col-sm-6">
<label for="an_emp_name" class="col-form-label text-right">اسم جهه العمل</label>
<input id="an_emp_name" class="form-control clickfun" type="text" required>
</div>
<div class="col-lg-4 col-sm-6">
<label for="an_emp_type" class="col-form-label text-right">نوع الخصم</label>
<select id="an_emp_type" class="form-control">
<?php
$get_an_employee_offer_sql = mysqli_query($db, "SELECT `id`, `name` FROM `type_discount` WHERE `activation_id` = 2");
while ($get_an_employee_offer = mysqli_fetch_assoc($get_an_employee_offer_sql)) {
?>
<option value="<?=$get_an_employee_offer['id']?>" data-upload="<?=$get_an_employee_offer['upload_image_id']?>" ><?=$get_an_employee_offer['name']?></option>
<?php
}
?>
</select>
</div>
<div class="col-lg-4 col-sm-6">
<label for="an_emp_number" class="col-form-label text-right">مبلغ الخصم / نسبة الخصم</label>
<input id="an_emp_number" class="form-control clickfun" type="number" required>
</div>
<div class="col-lg-6 col-sm-6">
<label for="an_emp_upload" class="col-form-label text-right">هل يجب رفع صوره ؟</label>
<select id="an_emp_upload" class="form-control">
<?php
$get_an_employee_offer_sql = mysqli_query($db, "SELECT `id`, `name` FROM `upload_image` WHERE `activation_id` = 2");
while ($get_an_employee_offer = mysqli_fetch_assoc($get_an_employee_offer_sql)) {
?>
<option value="<?=$get_an_employee_offer['id']?>" data-upload="<?=$get_an_employee_offer['upload_image_id']?>" ><?=$get_an_employee_offer['name']?></option>
<?php
}
?>
</select>
</div>
<div class="col-lg-6 col-sm-6">
<label for="an_emp_enters" class="col-form-label text-right">هل يدخل الخصم مع خصوم اخرى ؟</label>
<select id="an_emp_enters" class="form-control">
<?php
$get_how_to_hear_sql = mysqli_query($db, "SELECT `id`,`name`FROM `does_discount_enters` WHERE `activation_id` = 2");
while ($get_how_to_hear = mysqli_fetch_assoc($get_how_to_hear_sql)) {
?>
<option value="<?=$get_how_to_hear['id']?>"><?=$get_how_to_hear['name']?></option>
<?php
}
?>
</select>
</div>
<div class="col-lg-6 col-sm-6">
<label for="offer_does_have_dayoff" class="col-form-label text-right">هل يوجد له ايام محددة ؟</label>
<select id="offer_does_have_dayoff" class="form-control">
<?php
$get_how_to_hear_sql = mysqli_query($db, "SELECT `id`,`name`FROM `offer_does_have_dayoff` WHERE `activation_id` = 2");
while ($get_how_to_hear = mysqli_fetch_assoc($get_how_to_hear_sql)) {
?>
<option value="<?=$get_how_to_hear['id']?>"><?=$get_how_to_hear['name']?></option>
<?php
}
?>
</select>
</div>
<div class="col-lg-6 col-sm-6">
<label for="offer_does_have_spical_time" class="col-form-label text-right">هل يوجد له وقت محدد ؟</label>
<select id="offer_does_have_spical_time" class="form-control">
<?php
$get_how_to_hear_sql = mysqli_query($db, "SELECT `id`,`name`FROM `offer_does_have_spical_time` WHERE `activation_id` = 2");
while ($get_how_to_hear = mysqli_fetch_assoc($get_how_to_hear_sql)) {
?>
<option value="<?=$get_how_to_hear['id']?>"><?=$get_how_to_hear['name']?></option>
<?php
}
?>
</select>
</div>
<div class="col-lg-6 col-sm-6" style="display:none; visibility: hidden;">
<label for="days" class="col-form-label text-right">يرجى تحديد الايام</label>
<select id="days" class="select2 mb-3 select2-multiple" style="width: 100%;" multiple="multiple" data-placeholder="اضافة الايام">
<?php
$get_days_sql = mysqli_query($db, "SELECT `id`, `name` FROM `days` WHERE `activation_id` = 2 AND `id` > 1"
);
?>
<optgroup label="ايام لااسبوع">
<?php
while ($days_row = mysqli_fetch_assoc($get_days_sql)) {
?>
<option value="<?=$days_row['id']?>"><?=$days_row['name']?></option>
<?php
}
?>
</optgroup>
</select>
</div>
<div class="col-lg-6 col-sm-6" style="display:none; visibility: hidden;">
<label for="days" class="col-form-label text-right">يرجى تحديد الاوقات</label>
<select id="days" class="select2 mb-3 select2-multiple" style="width: 100%;" multiple="multiple" data-placeholder="اضافة الاوقات">
<?php
$get_days_sql = mysqli_query($db, "SELECT `id`, `time` FROM `times` WHERE `activation_id` = 2"
);
?>
<optgroup label="اوقات اليوم">
<?php
while ($days_row = mysqli_fetch_assoc($get_days_sql)) {
?>
<option value="<?=$days_row['id']?>"><?=$days_row['time']?></option>
<?php
}
?>
</optgroup>
</select>
</div>
</div>
<hr>
<div class="form-group row">
<div class="col-lg-12">
<div id="emp_offer" style="background-color: #086367; color:white; text-align:center; cursor: pointer;" class="form-control">إضافة</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body new-user order-list">
<div class="col-lg-12">
<div class="table-responsive">
<table class="table table-bordered text-center">
<thead class="table-primary">
<tr>
<th scope="col">#</th>
<th scope="col">اسم الجهه</th>
<th scope="col">نوع الخصم</th>
<th scope="col">مبلغ / نسبة الخصم</th>
</tr>
</thead>
<tbody>
<?php
$count = 1;
$get_an_employee_offer_sql = mysqli_query($db, "SELECT
`an_employee_offer`.`name`, `an_employee_offer`.`discount`,`type_discount`.`name` AS `t_name`
FROM `an_employee_offer`
LEFT JOIN `type_discount` ON `an_employee_offer`.`type_discount_id` = `type_discount`.`id`
WHERE `an_employee_offer`.`activation_id` = 2 AND `an_employee_offer`.`id` > 1");
while ($get_an_employee_offer = mysqli_fetch_assoc($get_an_employee_offer_sql)) {
?>
<tr>
<th scope="row"><?=$count?></th>
<td><?=$get_an_employee_offer['name']?></td>
<td><?=$get_an_employee_offer['t_name']?></td>
<td><?=$get_an_employee_offer['discount']?></td>
</tr>
<?php
$count++;
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body new-user order-list">
<form action="" method="post" enctype="multipart/form-data">
<h4 class="mt-0 header-title">اضافة خدمات خاصه للعرض</h4>
<div class="form-group row">
<div class="col-lg-6 col-sm-6">
<label for="tretment_offer_serv" class="col-form-label text-right">العروض</label>
<select id="tretment_offer_serv" class="form-control">
<?php
$get_an_employee_offer_sql = mysqli_query($db, "SELECT `id`,`name`,`upload_image_id` FROM `an_employee_offer` WHERE `activation_id` = 2");
while ($get_an_employee_offer = mysqli_fetch_assoc($get_an_employee_offer_sql)) {
?>
<option value="<?=$get_an_employee_offer['id']?>" data-upload="<?=$get_an_employee_offer['upload_image_id']?>" ><?=$get_an_employee_offer['name']?></option>
<?php
}
?>
</select>
</div>
<div id="an_employee_offer_has_services" class="col-lg-6 col-sm-6">
</div>
</div>
<hr>
<div class="form-group row">
<div class="col-lg-12">
<div id="add_serv_to_offer" style="background-color: #086367; color:white; text-align:center; cursor: pointer;" class="form-control">إضافة</div>
</div>
</div>
</form>
</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>
click = 0;
$(function() {
$("#emp_offer").click(function() {
add_emp_offer();
});
});
$('.clickfun').keypress(function (e) {
var key = e.which;
if(key == 13) {
add_emp_offer();
}
});
function add_emp_offer() {
let an_emp_name = $("#an_emp_name").val();
let an_emp_type = $("#an_emp_type").val();
let an_emp_number = $("#an_emp_number").val();
let an_emp_upload = $("#an_emp_upload").val();
let an_emp_enters = $("#an_emp_enters").val();
if (an_emp_type == 1 && an_emp_number > 0) {
swalfun("لا يوجد خصم", "يجب ان يكون مبلغ الخصم يساوي 0", "warning");
return;
} else
if (an_emp_name == '' && an_emp_type != 1) {
swalfun("يرجى ادخال اسم جهه العمل", "", "warning");
return;
} else
if (an_emp_number == '') {
swalfun("يرجى ادخال مبلغ / نسبة الخصم", "", "warning");
return;
} else
if (an_emp_type == 3 && an_emp_number > 100 ) {
swalfun("نسبة الخصم اكبر من 100%", "", "warning");
return;
}
if (click == 0) {
click++
$.post("work/order/ajax/add_emp_offer_ajax.php", {
an_emp_name,
an_emp_type,
an_emp_number,
an_emp_upload,
an_emp_enters
}, function(get_data) {
$("#get_data").html(get_data);
})
} else {
swalfun("يرجى الانتظار", "", "warning");
}
};
$(function() {
$("#tretment_offer_serv").change(function() {
var empName = $(this).val();
$.post("work/order/ajax/get_services_from_an_emplyee_ajax.php", {
empName,
}, function(theService) {
$("#an_employee_offer_has_services").html(theService);
})
});
});
$(".select2").select2({
width: '100%'
});
$(function() {
$("#add_serv_to_offer").click(function() {
add_serv_to_offer();
});
});
function add_serv_to_offer() {
let services = $("#services").val();
let tretment_offer_serv = $("#tretment_offer_serv").val();
$.post("work/order/ajax/add_serv_to_offer_ajax.php", {
services,
tretment_offer_serv
}, function(get_data) {
$("#get_data").html(get_data);
})
}
</script>
</body>
</html>