Cod
Cod
<?php
require '../config/config.php';
require CL_SESSION_PATH;
require CONNECT_PATH;
require DOMAIN_PATH . '/call_func/islogin.php';
require DOMAIN_PATH . '/call_func/global_func.php';
include DOMAIN_PATH . "/include/admin_link.php";
if (USER_ROLE != "admin") {
// header("Location: ".BASE_URL."admin_login/login.php");
include ERROR_401;
exit();
}
?>
<style>
.dropify-wrapper .dropify-message p {
margin: 5px 0 0 0;
font-size: 15px;
}
</style>
<div class="content-page">
<div class="content">
<!-- Topbar Start -->
<?php
include DOMAIN_PATH . "/include/admin_top.php";
?>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<!-- Transac Process Steps -->
<ul class="nav nav-pills bg-nav-pills nav-
justified mb-3">
<li class="nav-item">
<a href="#processing-information" data-
bs-toggle="tab" aria-expanded="false" class="nav-link rounded-0 active">
<i class="mdi mdi-account-circle
font-18"></i>
<span class="d-none d-lg-
block">Pending Certificate</span>
</a>
</li>
<li class="nav-item">
<a href="#print-information" data-bs-
toggle="tab" aria-expanded="false" class="nav-link rounded-0">
<i class="mdi mdi-cash-multiple
font-18"></i>
<span class="d-none d-lg-
block">Print Certificate</span>
</a>
</li>
<li class="nav-item">
<a href="#health-certificate-record-
information" data-bs-toggle="tab" aria-expanded="false" class="nav-link rounded-0">
<i class="mdi mdi-cash-multiple
font-18"></i>
<span class="d-none d-lg-
block">Health Certificate Record</span>
</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane show active"
id="processing-information">
<div class="table-responsive">
<table class="table table-centered
w-100 dt-responsive nowrap" id="customer_order_table">
<thead class="table-light">
<tr>
<th>Action</th>
<th>Status</th>
<th>Name</th>
<th>Age</th>
<th>Sex</th>
<th>Nationality</th>
<th>Work Type</th>
<th>Appointment</th>
<th style="width:
125px;">Remark</th>
</tr>
</thead>
<tbody>
<?php
date_default_timezone_set('Asia/Manila');
$created_date = date("F d,
Y");
$current_time = date("h:i:s
A");
$sel_health_cert_pending =
"SELECT * FROM health_request WHERE status = 'pending'";
$health_cert_pending_query
= mysqli_query($db_connect, $sel_health_cert_pending);
$type_work_array = array();
// Array to store type_work entries
if
($health_cert_pending_query) {
if
(mysqli_num_rows($health_cert_pending_query) > 0) {
while ($row_record
= mysqli_fetch_array($health_cert_pending_query)) {
$id = !
empty($row_record['id']) ? trim($row_record['id']) : '';
$no_id = !
empty($row_record['no_id']) ? trim($row_record['no_id']) : 'Awaiting Transaction';
$transaction_number = !empty($row_record['transaction_number']) ?
trim($row_record['transaction_number']) : 'Awaiting Transaction';
$reference_number = !empty($row_record['reference_number']) ?
trim($row_record['reference_number']) : 'Awaiting Transaction';
$name = !
empty($row_record['name']) ? trim($row_record['name']) : '';
$age = !
empty($row_record['age']) ? trim($row_record['age']) : '';
$sex = !
empty($row_record['sex']) ? trim($row_record['sex']) : '';
$date_expired =
!empty($row_record['date_expired']) ? trim($row_record['date_expired']) : '';
$nationality
= !empty($row_record['nationality']) ? trim($row_record['nationality']) : '';
$type_work = !
empty($row_record['type_work']) ? trim($row_record['type_work']) : '';
$start_time = !
empty($row_record['start_time']) ? trim($row_record['start_time']) : '';
$payment = !
empty($row_record['payment']) ? trim($row_record['payment']) : '';
$end_time = !
empty($row_record['end_time']) ? trim($row_record['end_time']) : '';
$time_end =
date("h:i:s A", strtotime($end_time));
$time_start =
date("h:i:s A", strtotime($start_time));
if
($created_date == date("F d, Y", strtotime($end_time)) and $created_date !=
$date_expired) {
if
((strtotime($current_time) >= strtotime($time_start) && strtotime($current_time) <=
strtotime($time_end))) {
$skipRow = false;
$close_start = !empty($row_close['close_start']) ?
trim($row_close['close_start']) : '';
$skipRow = true;
}
}
}
if (!
$skipRow) {
?>
<tr>
<td>
</span>
</td>
</tr>
<?
php }
} else {
if
($isAppointmentActive) {
$skipRow = false;
if
(mysqli_num_rows($close_date_query) > 0) {
$skipRow = true;
}
}
if
(!$skipRow) {
?>
<tr>
<td>
</button>
</td>
<td>
</span>
</td>
</tr>
<?php
}
}
}
} else if
(date("F d, Y", strtotime($end_time)) >= $created_date) {
$skipRow =
false;
$close_start = !empty($row_close['close_start']) ?
trim($row_close['close_start']) : '';
$skipRow = true;
?>
<tr>
<td>
</span>
</td>
?>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col-sm-12 text-end mb-
2">
<button type="button"
class="btn btn-success" data-bs-toggle="modal" data-bs-target="#payment-stub-
modal"> <i class="mdi mdi-cash-multiple "></i><span class="mx-1">PAYMENT
STUB</span></button>
</div>
</div>
<div class="table-responsive">
<table class="table table-centered
w-100 dt-responsive nowrap" id="issue_cert_table">
<thead class="table-light">
<tr>
<th>Action</th>
<th>Status</th>
<th>Name</th>
<th>Age</th>
<th>Sex</th>
<th>Nationality</th>
<th>Work Type</th>
<th>Appointment</th>
<th style="width:
125px;">Remark</th>
</tr>
</thead>
<tbody>
<?php
date_default_timezone_set('Asia/Manila');
$created_date = date("F d,
Y");
$current_time = date("h:i:s
A");
$sel_health_cert_pending =
"SELECT * FROM health_request WHERE status = 'Payment Pending'";
$health_cert_pending_query
= mysqli_query($db_connect, $sel_health_cert_pending);
$type_work_array = array();
// Array to store type_work entries
if
($health_cert_pending_query) {
if
(mysqli_num_rows($health_cert_pending_query) > 0) {
while ($row_record
= mysqli_fetch_array($health_cert_pending_query)) {
$id = !
empty($row_record['id']) ? trim($row_record['id']) : '';
$no_id = !
empty($row_record['no_id']) ? trim($row_record['no_id']) : 'Awaiting Transaction';
$transaction_number = !empty($row_record['transaction_number']) ?
trim($row_record['transaction_number']) : 'Awaiting Transaction';
$reference_number = !empty($row_record['reference_number']) ?
trim($row_record['reference_number']) : 'Awaiting Transaction';
$name = !
empty($row_record['name']) ? trim($row_record['name']) : '';
$age = !
empty($row_record['age']) ? trim($row_record['age']) : '';
$sex = !
empty($row_record['sex']) ? trim($row_record['sex']) : '';
$date_expired =
!empty($row_record['date_expired']) ? trim($row_record['date_expired']) : '';
$nationality
= !empty($row_record['nationality']) ? trim($row_record['nationality']) : '';
$type_work = !
empty($row_record['type_work']) ? trim($row_record['type_work']) : '';
$start_time = !
empty($row_record['start_time']) ? trim($row_record['start_time']) : '';
$payment = !
empty($row_record['payment']) ? trim($row_record['payment']) : '';
$end_time = !
empty($row_record['end_time']) ? trim($row_record['end_time']) : '';
$time_end =
date("h:i:s A", strtotime($end_time));
$time_start =
date("h:i:s A", strtotime($start_time));
$skipRow = false;
$close_start = !empty($row_close['close_start']) ?
trim($row_close['close_start']) : '';
$skipRow = true;
}
}
}
if (!
$skipRow) {
?>
<tr>
<td>
</span>
</td>
</tr>
<?
php }
} else {
$skipRow = false;
$close_start = !empty($row_close['close_start']) ?
trim($row_close['close_start']) : '';
$skipRow = true;
}
}
if
(!$skipRow) {
?>
<tr>
<td>
</td>
</tr>
<?php }
}
}
} else if
(date("F d, Y", strtotime($end_time)) >= $created_date) {
$skipRow =
false;
$close_start = !empty($row_close['close_start']) ?
trim($row_close['close_start']) : '';
$skipRow = true;
?>
<tr>
</span>
</td>
?>
</tbody>
</table>
</div>
</div>
<div class="tab-pane " id="health-
certificate-record-information">
<div class="row">
<div class="col-12 m-2 text-end pe-
4">
<!-- <button class="btn btn-
info fw-bold" data-bs-toggle="modal" data-bs-target="#old_health_cert_modal">OLD
Health Certificate ID</button> -->
<!--<a href="<?= BASE_URL ?
>admin-page/old_health_certificate_report.php" class="btn btn-info fw-bold">Print
Old Health Certificate ID</a>-->
</div>
</div>
<div class="table-responsive">
<table class="table table-centered
w-100 dt-responsive nowrap" id="health_cert_record_table">
<thead class="table-light">
<tr>
<th>Action</th>
<th>Status</th>
<th>Prepared By</th>
<th>No. ID</th>
<th>Reference No.</th>
<th>Transaction
No.</th>
<th>Name</th>
<th>Age</th>
<th>Sex</th>
<th>Nationality</th>
<th>Work Type</th>
<th>Remark</th>
</tr>
</thead>
<tbody>
<?php
$sel_health_cert_pending =
"SELECT * FROM health_request WHERE status = 'completed'";
$health_cert_pending_query
= mysqli_query($db_connect, $sel_health_cert_pending);
if
($health_cert_pending_query) {
if
(mysqli_num_rows($health_cert_pending_query) > 0) {
while ($row_pending
= mysqli_fetch_array($health_cert_pending_query)) {
$id = !
empty($row_pending['id']) ? trim($row_pending['id']) : '';
$creator_by = !
empty($row_pending['creator']) ? trim($row_pending['creator']) : '';
$no_id = !
empty($row_pending['no_id']) ? trim($row_pending['no_id']) : '';
$transaction_number = !empty($row_pending['transaction_number']) ?
trim($row_pending['transaction_number']) : '';
$reference_number = !empty($row_pending['reference_number']) ?
trim($row_pending['reference_number']) : '';
$name = !
empty($row_pending['name']) ? trim($row_pending['name']) : '';
$age = !
empty($row_pending['age']) ? trim($row_pending['age']) : '';
$sex = !
empty($row_pending['sex']) ? trim($row_pending['sex']) : '';
$nationality
= !empty($row_pending['nationality']) ? trim($row_pending['nationality']) : '';
$type_work = !
empty($row_pending['type_work']) ? trim($row_pending['type_work']) : '';
$start_time = !
empty($row_pending['start_time']) ? trim($row_pending['start_time']) : '';
$end_time = !
empty($row_pending['end_time']) ? trim($row_pending['end_time']) : '';
$status = !
empty($row_pending['status']) ? trim($row_pending['status']) : '';
$remarks = !
empty($row_pending['remarks']) ? trim($row_pending['remarks']) : '';
$date_issued
= !empty($row_pending['date_issued']) ? trim($row_pending['date_issued']) : '';
$date_expired =
!empty($row_pending['date_expired']) ? trim($row_pending['date_expired']) : '';
$created_date =
date("F d, Y");
?>
<tr>
<?php
if
(strtotime($created_date) < strtotime($date_expired)) {
?>
<td>
</span>
</td>
<?php }
if
(strtotime($created_date) >= strtotime($date_expired)) {
?>
<td></td>
<td>
</span>
</td>
<?php } ?>
<td class="
fw-bold"><?= mb_strtoupper($creator_by) ?></td>
<td
class="text-danger fw-bold"><?= $no_id ?></td>
<td
class="text-danger fw-bold"><?= $reference_number ?></td>
<td
class="text-danger fw-bold"><?= $transaction_number ?></td>
<td><?=
ucfirst($name) ?></td>
<td><?=
$age ?></td>
<td><?=
$sex ?></td>
<td><?=
$nationality ?></td>
<td><?=
$type_work ?></td>
<?php
if
($created_date < $date_expired) {
?>
<td>
The
Health Certificate ID will remain valid until <?= $date_expired ?>.
</td>
<?php }
if
($created_date >= $date_expired) {
?>
<td>
</tr>
<?php }
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</form>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
$no_id = !
empty($row_pending['no_id']) ? trim($row_pending['no_id']) : 'Awaiting
Transaction';
$transaction_number = !
empty($row_pending['transaction_number']) ?
trim($row_pending['transaction_number']) : 'Awaiting Transaction';
$reference_number = !
empty($row_pending['reference_number']) ? trim($row_pending['reference_number']) :
'Awaiting Transaction';
$name = !
empty($row_pending['name']) ? trim($row_pending['name']) : '';
$age = !
empty($row_pending['age']) ? trim($row_pending['age']) : '';
$sex = !
empty($row_pending['sex']) ? trim($row_pending['sex']) : '';
$nationality = !
empty($row_pending['nationality']) ? trim($row_pending['nationality']) : '';
$type_work = !
empty($row_pending['type_work']) ? trim($row_pending['type_work']) : '';
$start_time = !
empty($row_pending['start_time']) ? trim($row_pending['start_time']) : '';
$end_time = !
empty($row_pending['end_time']) ? trim($row_pending['end_time']) : '';
$status = !
empty($row_pending['status']) ? trim($row_pending['status']) : '';
$remarks = !
empty($row_pending['remarks']) ? trim($row_pending['remarks']) : '';
$date_issued = !
empty($row_pending['date_issued']) ? trim($row_pending['date_issued']) : '';
$created_date = date("F
d, Y");
if ($created_date <=
date("F d, Y", strtotime($end_time))) {
$created_time =
date("h:i:s A");
if ($created_date
>= date("h:i:s A", strtotime($end_time))) {
?>
<tr>
<td><a
type="button" class="btn btn-info" href="<?= BASE_URL
?>admin-page/health_certificate_transaction_payment.php?id=<?= base64_encode($id) ?
>"><i class="mdi mdi-eye me-1"></i> <span>PRINT</span> </a></td>
<td>
<span
class="badge badge-warning-lighten" style="font-size: 15px;"> <?= $status ?>
</span>
</td>
<td><?=
ucfirst($name) ?></td>
<td><?=
$age ?></td>
<td><?=
$sex ?></td>
<td><?=
$nationality ?></td>
<td><?=
$type_work ?></td>
<td><?=
$remarks ?></td>
</tr>
<?php }
}
}
}
}
?>
</tbody>
</table>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light"
data-bs-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- or -->
<div id="or-stub-modal" class="modal fade"
tabindex="-1" role="dialog" data-bs-backdrop="static" aria-labelledby="payment-
stub-modalLabel" aria-hidden="true">
<div class="modal-dialog modal-l">
<div class="modal-content">
<div class="modal-header modal-colored-header bg-
success">
<h4 class="modal-title" id="or-stub-
modalLabel">Official Reciept Number | Payment Stub</h4>
<button type="button" class="btn-close" data-
bs-dismiss="modal" aria-hidden="true"></button>
</div>
<div class="modal-body">
<div class="col-lg-9 mb-9">
<label>Insert Official Reciept Number<b
class="text-danger">*</b></label>
<input type="number" name="orn" id="orn"
class="form-control" placeholder="Input Official Reciept Number">
<div class="text-danger"
id="orn_error"></div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light"
data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-info
print_old" id="<?= $id ?>" data-bs-toggle="modal" data-bs-target="#or-stub-
modal"><i class="mdi mdi-eye me-1"></i> <span>PRINT</span> </button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div class="m-2">
<div class="table-responsive">
<table class="table table-centered w-
100 dt-responsive nowrap" id="old_health_table">
<thead class="table-light">
<tr>
<th>No. ID</th>
<th>Reference No.</th>
<th>Transaction No.</th>
<th>Work Type</th>
<th>Amount Paid</th>
<th>Payment Date</th>
<th>Appointment Date</th>
<th>Remark</th>
<th>Date Issued</th>
<th>Date Expired</th>
</tr>
</thead>
<tbody>
<?php
date_default_timezone_set('Asia/Manila');
$created_date = date("F d, Y");
$current_time = date("h:i:s
A");
$sel_health_cert_pending =
"SELECT * FROM health_request_expired WHERE user_id = '" .
string_escape($user_id) . "'";
$health_cert_pending_query =
mysqli_query($db_connect, $sel_health_cert_pending);
$type_work_array = array(); //
Array to store type_work entries
if ($health_cert_pending_query)
{
if
(mysqli_num_rows($health_cert_pending_query) > 0) {
while ($row_record =
mysqli_fetch_array($health_cert_pending_query)) {
$id = !
empty($row_record['id']) ? trim($row_record['id']) : '';
$no_id = !
empty($row_record['no_id']) ? trim($row_record['no_id']) : 'Awaiting Transaction';
$transaction_number
= !empty($row_record['transaction_number']) ?
trim($row_record['transaction_number']) : 'Awaiting Transaction';
$reference_number =
!empty($row_record['reference_number']) ? trim($row_record['reference_number']) :
'Awaiting Transaction';
$age = !
empty($row_record['age']) ? trim($row_record['age']) : '';
$sex = !
empty($row_record['sex']) ? trim($row_record['sex']) : '';
$date_expired = !
empty($row_record['date_expired']) ? trim($row_record['date_expired']) : '';
$nationality = !
empty($row_record['nationality']) ? trim($row_record['nationality']) : '';
$type_work = !
empty($row_record['type_work']) ? trim($row_record['type_work']) : '';
$start_time = !
empty($row_record['start_time']) ? trim($row_record['start_time']) : '';
$payment = !
empty($row_record['payment']) ? trim($row_record['payment']) : '';
$end_time = !
empty($row_record['end_time']) ? trim($row_record['end_time']) : '';
$time_end =
date("h:i:s A", strtotime($end_time));
$time_start =
date("h:i:s A", strtotime($start_time));
$appointment_format
= date("F d, Y", strtotime($start_time)) . " / " . $time_start . " to " .
$time_end;
$status = !
empty($row_record['status']) ? trim($row_record['status']) : '';
$remarks = !
empty($row_record['remarks']) ? trim($row_record['remarks']) : '';
$date_issued = !
empty($row_record['date_issued']) ? trim($row_record['date_issued']) : 'Awaiting
Transaction';
$exp_id = !
empty($row_record['exp_id']) ? trim($row_record['exp_id']) : 'Awaiting
Transaction';
?>
<tr>
<td
class="text-danger fw-bold"><?= $no_id ?></td>
<td
class="text-danger fw-bold"><?= $reference_number ?></td>
<td
class="text-danger fw-bold"><?= $transaction_number ?></td>
<td><?=
$type_work ?></td>
<td>₱<?=
number_format((float)($payment), 2, '.', ',') ?></td>
<td><?= !
empty(date("F d, Y | h:i:s A", strtotime($date_issued))) ? trim($date_issued) :
'' ?></td>
<td><?=
$appointment_format ?></td>
<td>This date
was closed.</td>
<td><?=
$date_issued ?></td>
<td><?=
$date_expired ?></td>
</tr>
<?php }
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger"
data-bs-dismiss="modal">Close</button>
<!-- <button type="button" class="btn btn-
success">Save changes</button> -->
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</div>
</div>
<!-- END wrapper -->
<!-- script and the end body and html tag start-->
<?php
include DOMAIN_PATH . "/include/admin_script.php";
include DOMAIN_PATH . "/global/admin_notification.php";
// include DOMAIN_PATH . "/global/admin_notification.php";
?>
<!-- script and the end body and html tag end-->
<script>
// Delete
$(document).ready(function() {
$(document).on('click', '.decline_health', function() {
var decline_id = $(this).attr('id');
Swal.fire({
title: 'Are you Sure You want to decline this Health
Certificate?',
// text: "You won't be able to recover this Banner
Announcement!",
// showDenyButton: true,
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#bb2d3b',
confirmButtonText: 'Yes',
cancelButtonText: 'No',
}).then((result) => {
/* Read more about isConfirmed, isDenied below */
if (result.isConfirmed) {
$.ajax({
type: 'POST',
url: 'health_decline_process.php',
data: {
decline_id: decline_id
},
success: function(response) {
var res = jQuery.parseJSON(response);
if (res.status == 400) {
Swal.fire({
icon: 'warning',
title: 'Something Went Wrong.',
text: res.msg,
timer: 3000
})
} else if (res.status == 200) {
Swal.fire({
icon: 'success',
title: 'SUCCESS',
text: res.msg,
timer: 2000
}).then(function() {
location.reload();
});
}
}
})
} else if (result.isDenied) {
Swal.fire('Changes are not saved', '',
'info').then(function() {
location.reload();
});
}
})
});
});
$(document).ready(function() {
$('#old_health_table').DataTable({
"paging": true, // Enable pagination
"lengthChange": true, // Enable the "Show [X] entries" dropdown
"searching": true, // Enable the search bar
// Additional DataTables options can be configured here
aLengthMenu: [
[10, 25, 50, 100, -1],
[10, 25, 50, 100, "All"]
],
iDisplayLength: 10
});
$('#customer_order_table').DataTable({
"paging": true, // Enable pagination
"lengthChange": true, // Enable the "Show [X] entries" dropdown
"searching": true, // Enable the search bar
// Additional DataTables options can be configured here
aLengthMenu: [
[10, 25, 50, 100, -1],
[10, 25, 50, 100, "All"]
],
iDisplayLength: 10
});
$('#payment_pending_exist_table').DataTable({
"paging": true, // Enable pagination
"lengthChange": true, // Enable the "Show [X] entries" dropdown
"searching": true, // Enable the search bar
// Additional DataTables options can be configured here
aLengthMenu: [
[10, 25, 50, 100, -1],
[10, 25, 50, 100, "All"]
],
iDisplayLength: 10
});
$('#issue_cert_table').DataTable({
"paging": true, // Enable pagination
"lengthChange": true, // Enable the "Show [X] entries" dropdown
"searching": true, // Enable the search bar
// Additional DataTables options can be configured here
aLengthMenu: [
[10, 25, 50, 100, -1],
[10, 25, 50, 100, "All"]
],
iDisplayLength: 10
});
$('#health_cert_record_table').DataTable({
"paging": true, // Enable pagination
"lengthChange": true, // Enable the "Show [X] entries" dropdown
"searching": true, // Enable the search bar
// Additional DataTables options can be configured here
aLengthMenu: [
[10, 25, 50, 100, -1],
[10, 25, 50, 100, "All"]
],
iDisplayLength: 10
});
});
</script>
<script>
//get data to Update
$(document).ready(function() {
// Initialize Select2 outside the click event handler
// checkbox
// var result_xray = $('#result_xray').prop('checked');
// var result_urine = $('#result_urine').prop('checked');
// var result_stool = $('#result_stool').prop('checked');
// var result_hepa = $('#result_hepa').prop('checked');
// var result_drugtest = $('#result_drugtest').prop('checked');
// var result_cbc = $('#result_cbc').prop('checked');
// date
var date_xray = $('#date_xray').val();
var date_urine = $('#date_urine').val();
var date_stool = $('#date_stool').val();
var date_hepa = $('#date_hepa').val();
var date_drugtest = $('#date_drugtest').val();
var date_cbc = $('#date_cbc').val();
if (name === '') {
$('#name_error').text('Full Name is empty. Please enter a value.');
formHasErrors = true;
} else if (!letterPattern.test(name)) {
$('#name_error').text('Full Name should only contain letters.');
formHasErrors = true;
} else if (name.length < 5) {
$('#name_error').text('Full Name should only not less than 2
characters');
formHasErrors = true;
} else if (name.length > 50) {
$('#name_error').text('Full Name should only not greater than 15
characters');
formHasErrors = true;
} else {
$('#name_error').text(''); // Clear the error message
}
// if (!result_xray) {
// $('#result_xray_error').text('Chest X-ray is unchecked. Kindly
check this checkbox.');
// formHasErrors = true;
// } else {
// $('#result_xray_error').text(''); // Clear the error message
// }
// if (!result_urine) {
// $('#result_urine_error').text('Urine is unchecked. Kindly check
this checkbox.');
// formHasErrors = true;
// } else {
// $('#result_urine_error').text(''); // Clear the error message
// }
// if (!result_stool) {
// $('#result_stool_error').text('Stool is unchecked. Kindly check
this checkbox.');
// formHasErrors = true;
// } else {
// $('#result_stool_error').text(''); // Clear the error message
// }
// if (!result_hepa) {
// $('#result_hepa_error').text('Hepa A/B is unchecked. Kindly
check this checkbox.');
// formHasErrors = true;
// } else {
// $('#result_hepa_error').text(''); // Clear the error message
// }
// if (!result_drugtest) {
// $('#result_drugtest_error').text('Drug Test is unchecked. Kindly
check this checkbox.');
// formHasErrors = true;
// } else {
// $('#result_drugtest_error').text(''); // Clear the error message
// }
// if (!result_cbc) {
// $('#result_cbc_error').text('CBC is unchecked. Kindly check this
checkbox.');
// formHasErrors = true;
// } else {
// $('#result_cbc_error').text(''); // Clear the error message
// }
if (date_xray == '') {
$('#date_xray_error').text('Chest X-ray date unselected. Kindly
Select medical Date.');
formHasErrors = true;
} else {
$('#date_xray_error').text(''); // Clear the error message
}
if (date_urine === '') {
$('#date_urine_error').text('Urine date unselected. Kindly Select
medical Date.');
formHasErrors = true;
} else {
$('#date_urine_error').text(''); // Clear the error message
}
if (date_stool === '') {
$('#date_stool_error').text('Stool date unselected. Kindly Select
medical Date.');
formHasErrors = true;
} else {
$('#date_stool_error').text(''); // Clear the error message
}
if (date_hepa === '') {
$('#date_hepa_error').text('Hepa A/B date unselected. Kindly Select
medical Date.');
formHasErrors = true;
} else {
$('#date_hepa_error').text(''); // Clear the error message
}
if (date_drugtest === '') {
$('#date_drugtest_error').text('Drug Test date unselected. Kindly
Select medical Date.');
formHasErrors = true;
} else {
$('#date_drugtest_error').text(''); // Clear the error message
}
if (date_cbc === '') {
$('#date_cbc_error').text('CBC date unselected. Kindly Select
medical Date.');
formHasErrors = true;
} else {
$('#date_cbc_error').text(''); // Clear the error message
}
if (formHasErrors) {
// Display a general error message if there are any form errors
document.getElementById('form_error_message').innerHTML = `
<div class="bg-danger text-white fw-bold text-center p-1"
style="font-size:20px;">
Please fix the errors found in the provided form.
</div>
`;
return;
}
{
Swal.fire({
title: 'Please review carefully before submitting the Health
Certificate. Are you sure you want to submit this Health Certificate?',
showDenyButton: false,
showCancelButton: true,
confirmButtonText: 'ACCEPT',
}).then((result) => {
/* Read more about isConfirmed, isDenied below */
if (result.isConfirmed) {
$.ajax({
type: "POST",
url: "health_certificate_transaction_process.php",
//action
data: formData,
processData: false,
contentType: false,
success: function(response) {
var res = jQuery.parseJSON(response);
if (res.status == 400) {
Swal.fire({
icon: 'warning',
title: 'Something Went Wrong.',
text: res.msg,
timer: 3000
})
} else if (res.status == 500) {
Swal.fire({
icon: 'warning',
title: 'Something Went Wrong.',
text: res.msg,
timer: 3000
})
} else if (res.status == 200) {
Swal.fire({
icon: 'success',
title: 'SUCCESS',
text: res.msg,
timer: 2000
}).then(function() {
});
}
}
})
} else if (result.isDenied) {
Swal.fire('Changes are not saved', '',
'info').then(function() {
location.reload();
});
}
})
}
});
$(document).ready(function() {
$(document).on('click', '.certificate_print', function() {
var cert_id = $(this).attr('id');
Swal.fire({
title: 'Are you Sure You want to Print this Health
Certificate?',
// showDenyButton: true,
icon: 'warning',
showCancelButton: true,
confirmButtonColor: 'rgb(26 138 14)',
confirmButtonText: 'PRINT',
}).then((result) => {
/* Read more about isConfirmed, isDenied below */
if (result.isConfirmed) {
$.ajax({
type: 'POST',
url: 'health_certificate_transaction_process.php',
data: {
cert_id: cert_id
},
success: function(response) {
var res = jQuery.parseJSON(response);
if (res.status == 400) {
Swal.fire({
icon: 'warning',
title: 'Something Went Wrong.',
text: res.msg,
timer: 3000
})
} else if (res.status == 200) {
Swal.fire({
icon: 'success',
title: 'SUCCESS',
text: res.msg,
timer: 2000
}).then(function() {
if (res.type_work == "Food Worker") {
window.location.href = '<?= BASE_URL ?
>admin-page/health_certificate_transaction_food_worker_print.php?id=' + res.id +
'';
} else if (res.type_work == "Non-Food
Worker") {
window.location.href = '<?= BASE_URL ?
>admin-page/health_certificate_transaction_non_food_worker_print.php?id=' + res.id
+ '';
}
});
}
}
})
} else if (result.isDenied) {
Swal.fire('Changes are not saved', '',
'info').then(function() {
location.reload();
});
}
})
});
});
$(document).ready(function() {
$(document).on('click', '.print_old', function() {
var cert_id = $(this).attr('id');
Swal.fire({
title: 'Are you Sure You want to Print this Old Health
Certificate?',
// showDenyButton: true,
icon: 'warning',
showCancelButton: true,
confirmButtonColor: 'rgb(26 138 14)',
confirmButtonText: 'PRINT',
}).then((result) => {
/* Read more about isConfirmed, isDenied below */
if (result.isConfirmed) {
$.ajax({
type: 'POST',
url: 'health_certificate_transaction_process.php',
data: {
cert_id: cert_id
},
success: function(response) {
var res = jQuery.parseJSON(response);
if (res.status == 400) {
Swal.fire({
icon: 'warning',
title: 'Something Went Wrong.',
text: res.msg,
timer: 3000
})
} else if (res.status == 200) {
Swal.fire({
icon: 'success',
title: 'SUCCESS',
text: res.msg,
timer: 2000
}).then(function() {
if (res.type_work == "Food Worker") {
window.location.href = '<?= BASE_URL ?
>admin-page/health_certificate_transaction_food_worker_print_old.php?id=' + res.id
+ '';
} else if (res.type_work == "Non-Food
Worker") {
window.location.href = '<?= BASE_URL ?
>admin-page/health_certificate_transaction_non_food_worker_print_old.php?id=' +
res.id + '';
}
});
}
}
})
} else if (result.isDenied) {
Swal.fire('Changes are not saved', '',
'info').then(function() {
location.reload();
});
}
})
});
});
</script>