Update Validate Untuk Maintenance
This commit is contained in:
parent
80f7eb5142
commit
5a872b2fad
@ -213,15 +213,15 @@ $routes->group('certificates', function($routes) {
|
|||||||
$routes->get('/', 'Certificates::index');
|
$routes->get('/', 'Certificates::index');
|
||||||
|
|
||||||
// Untuk Index Tiap Menu
|
// Untuk Index Tiap Menu
|
||||||
|
$routes->get('maintenance', 'Certificates::maintenanceIndex');
|
||||||
$routes->get('training', 'Certificates::trainingIndex');
|
$routes->get('training', 'Certificates::trainingIndex');
|
||||||
$routes->get('calibration', 'Certificates::calibrateIndex');
|
$routes->get('calibration', 'Certificates::calibrateIndex');
|
||||||
$routes->get('maintenance', 'Certificates::maintenanceIndex');
|
|
||||||
|
|
||||||
$routes->get('api/getindexmaintenance', 'Certificates::getDataIndexMaintenance');
|
$routes->get('api/getindexmaintenance', 'Certificates::getDataIndexMaintenance');
|
||||||
$routes->get('api/getindextraining', 'Certificates::getDataIndexTraining');
|
$routes->get('api/getindextraining', 'Certificates::getDataIndexTraining');
|
||||||
|
|
||||||
|
|
||||||
$routes->post('validate', 'Certificates::validateCertificate');
|
$routes->post('api/validate', 'Certificates::validateCertificate');
|
||||||
|
|
||||||
|
|
||||||
// Untuk View Cerificate
|
// Untuk View Cerificate
|
||||||
|
|||||||
@ -267,15 +267,56 @@ class Certificates extends BaseController {
|
|||||||
|
|
||||||
public function validateCertificate() {
|
public function validateCertificate() {
|
||||||
$certid = $this->request->getPost('certid');
|
$certid = $this->request->getPost('certid');
|
||||||
$certificateType = $this->request->getPost('certificateType');
|
|
||||||
|
|
||||||
// if (!$certid) {
|
if (!$certid) {
|
||||||
|
return $this->response->setJSON([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Certificate ID is required'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->response->setJSON([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Certificate validated successfully'
|
||||||
|
// 'validationDate' => $validationDate
|
||||||
|
]);
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// $db = \Config\Database::connect();
|
||||||
|
// $builder = $db->table('certificates');
|
||||||
|
|
||||||
|
// $certificate = $builder->where('certid', $certid)->get()->getRowArray();
|
||||||
|
|
||||||
|
// if (!$certificate) {
|
||||||
|
// return $this->response->setJSON([
|
||||||
|
// 'success' => false,
|
||||||
|
// 'message' => 'Certificate not found'
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if ($certificate['isval'] !== null) {
|
||||||
|
// return $this->response->setJSON([
|
||||||
|
// 'success' => false,
|
||||||
|
// 'message' => 'Certificate has already been validated'
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $validationDate = date('Y-m-d');
|
||||||
|
// $builder->where('certid', $certid)->update(['isval' => $validationDate]);
|
||||||
|
|
||||||
|
// return $this->response->setJSON([
|
||||||
|
// 'success' => true,
|
||||||
|
// 'message' => 'Certificate validated successfully',
|
||||||
|
// 'validationDate' => $validationDate
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
// } catch (\Exception $e) {
|
||||||
|
// log_message('error', 'Certificate validation error: ' . $e->getMessage());
|
||||||
// return $this->response->setJSON([
|
// return $this->response->setJSON([
|
||||||
// 'success' => false,
|
// 'success' => false,
|
||||||
// 'message' => 'Certificate ID is required'
|
// 'message' => 'An error occurred during validation'
|
||||||
// ]);
|
// ]);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -316,8 +316,8 @@ $(function () {
|
|||||||
if (!confirm('Are you sure?')) return;
|
if (!confirm('Are you sure?')) return;
|
||||||
|
|
||||||
$.post(
|
$.post(
|
||||||
'<?= base_url('certificates/validate') ?>',
|
'<?= base_url('certificates/api/validate') ?>',
|
||||||
{ certid, certificateType},
|
{ certid },
|
||||||
function (response) {
|
function (response) {
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
|
|||||||
@ -215,9 +215,11 @@
|
|||||||
<li> <a class="has-arrow waves-effect waves-dark" href='javascript:void(0)' aria-expanded="false"> <i class="fa-solid fa-certificate"></i><span class='hide-menu'>Certificates</span> </a>
|
<li> <a class="has-arrow waves-effect waves-dark" href='javascript:void(0)' aria-expanded="false"> <i class="fa-solid fa-certificate"></i><span class='hide-menu'>Certificates</span> </a>
|
||||||
<ul aria-expanded="false" class="collapse">
|
<ul aria-expanded="false" class="collapse">
|
||||||
<!-- <li><a href="<?=base_url();?>certificates">All</a></li> -->
|
<!-- <li><a href="<?=base_url();?>certificates">All</a></li> -->
|
||||||
|
<li><a href="<?=base_url();?>certificates/maintenance">Maintenance</a></li>
|
||||||
|
<li><a href="<?=base_url();?>certificates/installation">Installation</a></li>
|
||||||
<li><a href="<?=base_url();?>certificates/training">Training</a></li>
|
<li><a href="<?=base_url();?>certificates/training">Training</a></li>
|
||||||
<li><a href="<?=base_url();?>certificates/calibration">Callibration</a></li>
|
<li><a href="<?=base_url();?>certificates/calibration">Callibration</a></li>
|
||||||
<li><a href="<?=base_url();?>certificates/maintenance">Maintenance</a></li>
|
<li><a href="<?=base_url();?>certificates/official-report">Official Report</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<!-- <li> <a class="waves-effect waves-dark" href='<?=base_url();?>certificates' aria-expanded="false"> <i class="fa-solid fa-certificate"></i><span class='hide-menu'>Certificate</span> </a> </li> -->
|
<!-- <li> <a class="waves-effect waves-dark" href='<?=base_url();?>certificates' aria-expanded="false"> <i class="fa-solid fa-certificate"></i><span class='hide-menu'>Certificate</span> </a> </li> -->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user