100 lines
3.4 KiB
PHP
Executable File
100 lines
3.4 KiB
PHP
Executable File
<?php
|
|
require_once('../../../fixed/config/go_con.php');
|
|
|
|
$emp_id = mysqli_real_escape_string($db, $_POST['emp_id']);
|
|
$holiday = mysqli_real_escape_string($db, $_POST['holiday']);
|
|
$branch_id = mysqli_real_escape_string($db, $_POST['branch_id']);
|
|
$activation = mysqli_real_escape_string($db, $_POST['activation']);
|
|
$occupation_id = mysqli_real_escape_string($db, $_POST['occupation_id']);
|
|
$emp_card = mysqli_real_escape_string($db, $_POST['emp_card']);
|
|
$rolls_group = mysqli_real_escape_string($db, $_POST['rolls_group']);
|
|
$services = $_POST['services'];
|
|
if(empty($services)) {
|
|
$services = array();
|
|
}
|
|
|
|
|
|
if (!empty($emp_id)) {
|
|
if (count($services)) {
|
|
mysqli_query($db,"DELETE FROM `emplyee_has_services` WHERE `emplyee_id` = $emp_id");
|
|
$services_sql = '';
|
|
for ($i=0; $i < count($services); $i++) {
|
|
$services_val = $services[$i];
|
|
$services_sql .= "(
|
|
'$emp_id',
|
|
'$services_val',
|
|
'$date_time',
|
|
'$admin_id',
|
|
'2'
|
|
)";
|
|
if($i != (count($services)-1)){$services_sql .= ",";}
|
|
}
|
|
|
|
if (!mysqli_query(
|
|
$db,
|
|
"INSERT INTO `emplyee_has_services`(
|
|
`emplyee_id`,
|
|
`services_id`,
|
|
`date_time`,
|
|
`user_id`,
|
|
`activation_id`
|
|
)
|
|
VALUES $services_sql"
|
|
)) {
|
|
echo"
|
|
<script>
|
|
swalfun('LC525-5','','error');
|
|
</script>
|
|
";
|
|
} else {
|
|
if (!mysqli_query(
|
|
$db,
|
|
"UPDATE `emplyee` SET `emp_id`='$emp_card', `branch_id`='$branch_id',`holi_days_id`='$holiday', `occupation_id`='$occupation_id', `rolls_group_id`='$rolls_group', `activation_id`='$activation' WHERE `id`=$emp_id"
|
|
)) {
|
|
echo"
|
|
<script>
|
|
swalfun('LC571-5','','error');
|
|
</script>
|
|
";
|
|
} else {
|
|
echo "
|
|
<script>
|
|
swalfun('تمت العملية بنجاح', '', 'success');
|
|
</script>
|
|
";
|
|
}
|
|
}
|
|
} else {
|
|
mysqli_query($db,"DELETE FROM `emplyee_has_services` WHERE `emplyee_id` = $emp_id");
|
|
|
|
if (!mysqli_query(
|
|
$db,
|
|
"UPDATE `emplyee` SET `emp_id`='$emp_card', `branch_id`='$branch_id',`holi_days_id`='$holiday', `occupation_id`='$occupation_id', `rolls_group_id`='$rolls_group', `activation_id`='$activation' WHERE `id`=$emp_id"
|
|
)) {
|
|
echo"
|
|
<script>
|
|
swalfun('LC621-5','','error');
|
|
</script>
|
|
";
|
|
} else {
|
|
echo "
|
|
<script>
|
|
swalfun('تمت العملية بنجاح', '', 'success');
|
|
</script>
|
|
";
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
echo "
|
|
<script>
|
|
swalfun('حدث خطأ', '', 'error');
|
|
</script>
|
|
";
|
|
}
|
|
|
|
|