booking/work/order/ajax/procedures_book_ajax.php

183 lines
6.6 KiB
PHP
Executable File

<?php
require_once('../../../fixed/config/go_con.php');
access(78);
require_once('../../../fixed/functions/book_colors.php');
require_once('../../../fixed/functions/book_actions.php');
$number = mysqli_real_escape_string($db, $_POST['number']);
if (!empty($number)) {
$get_tretment_sql = mysqli_query($db, "SELECT
`tretment`.`name` AS `tr_name`,
`tretment`.`number` AS `tr_number`,
`book`.`id`,
`book_details`.`id` AS `bd_id`,
`book_details`.`day_date`,
`book_details`.`day_time`,
`book_details`.`notes` AS `note`,
`book_details`.`date_time` AS `date_time`,
`book`.`notes`,
`emplyee`.`id` AS `emp_id`,
`emplyee`.`his_img`,
`emplyee`.`name`AS `emp_name`,
`services`.`name`,
`branch`.`branch_name`,
`status`.`id` AS `state`,
`user`.`name` AS `username`,
`status`.`small_name` AS `state_string`
FROM `tretment`
LEFT JOIN `book` ON `book`.`tretment_id` = `tretment`.`id`
LEFT JOIN `book_details` ON `book`.`id` = `book_details`.`book_id`
LEFT JOIN `services` ON `book_details`.`services_id` = `services`.`id`
LEFT JOIN `emplyee` ON `book_details`.`emplyee_id` = `emplyee`.`id`
LEFT JOIN `status` ON `book_details`.`status_id` = `status`.`id`
LEFT JOIN `branch` ON `book_details`.`branch_id` = `branch`.`id`
LEFT JOIN `user` ON `book_details`.`user_id` = `user`.`id`
WHERE `book`.`id` = '$number'
ORDER BY `book_details`.`id` DESC");
$data = [];
if (mysqli_num_rows($get_tretment_sql) > 0) {
while ($booking_row = mysqli_fetch_assoc($get_tretment_sql)) {
$data['info']['t_name'] = $booking_row['tr_name'];
$data['info']['t_number'] = $booking_row['tr_number'];
$data['info']['book_id'] = $booking_row['id'];
$data['info']['notes'] = $booking_row['notes'];
$data['data'][$booking_row['bd_id']] = [
'date' => $booking_row['day_date'],
'time' => $booking_row['day_time'],
'note' => $booking_row['note'],
'emp_id' => $booking_row['emp_id'],
'his_img' => $booking_row['his_img'],
'emp_name' => $booking_row['emp_name'],
's_name' => $booking_row['name'],
'branch_name' => $booking_row['branch_name'],
'state' => $booking_row['state'],
'username' => $booking_row['username'],
'state_string' => $booking_row['state_string'],
'date_time' => $booking_row['date_time'],
];
}
?>
<table class="table table-bordered mb-0 table-centered text-center" style="vertical-align: middle;">
<thead>
<tr class="align-self-center">
<th colspan="3">اسم العميل</th>
<th colspan="3"><?=$data['info']['t_name']?></th>
<th colspan="3">رقم العميل</th>
<th colspan="2"><?=$data['info']['t_number']?></th>
</tr>
<tr class="align-self-center">
<th colspan="3">رقم الحجز</th>
<th colspan="3"><?=$data['info']['book_id']?></th>
<th colspan="3">الملاحظات</th>
<th colspan="2"><?=$data['info']['notes']?></th>
</tr>
</thead>
<thead>
<tr class="align-self-center">
<th>#</th>
<th>التاريخ</th>
<th>الوقت</th>
<th>الفني</th>
<th>الخدمة</th>
<th>ملاحظات</th>
<th>الحالة</th>
<th>الفرع</th>
<th>تاريخ و وقت العملية</th>
<th>الموظف</th>
<th>الاجراءات</th>
</tr>
</thead>
<tbody>
<?php
$count = 0;
$data_count = count($data['data']);
foreach ($data['data'] as $key => $value) {
?>
<tr>
<td><?=$key?></td>
<td><?=$data['data'][$key]['date']?></td>
<td><?=$data['data'][$key]['time']?></td>
<td><img src="uploads/emplyee/<?=$data['data'][$key]['emp_id']?>/face/<?=$data['data'][$key]['his_img']?>" alt="emp_img" class="thumb-sm rounded-circle mr-2"><bt /><?=$data['data'][$key]['emp_name']?></td>
<td><?=$data['data'][$key]['s_name']?></td>
<td><?=$data['data'][$key]['note']?></td>
<td style="<?=book_colors($data['data'][$key]['state'])?>"><?=$data['data'][$key]['state_string']?></td>
<td><?=$data['data'][$key]['branch_name']?></td>
<td>
<?=date('d-m-Y', strtotime($data['data'][$key]['date_time']))?>
<br/>
<?= date((date("H", strtotime($data['data'][$key]['date_time'])) > 11) ? 'h:i \م' : 'h:i \ص', strtotime($data['data'][$key]['date_time'])) ?>
</td>
<td><?=$data['data'][$key]['username']?></td>
<td>
<?php
if ($count == 0) {
book_actions($data['data'][$key]['state'], $data['info']['book_id'], 1);
}
?>
</td>
</tr><!--end tr-->
<?php
$count++;
}
?>
</tbody><!--end tbody-->
</table><!--end table-->
<script>
click = 0;
// for dropdown
$(document).ready(function() {
var tooltip_init = {
init: function() {
$("button").tooltip();
$("a").tooltip();
$("input").tooltip();
}
};
tooltip_init.init()
});
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl)
})
</script>
<?php
} else {
echo"
<script>
swalfun('تنبية','لا يوجد اي بيانات لهذا الرقم','info');
click = 0;
</script>
";
}
} else {
echo"
<script>
swalfun('حدث خطأ', 'رقم الجوال يجب أن يتكون من 9 أرقام وبدون 0 في البداية', 'error');
click = 0;
</script>
";
}
?>