diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 1130749..f9eb141 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -211,13 +211,13 @@ $routes->group('certificates', function($routes) { // Untuk Index Tiap Menu $routes->get('maintenance', 'Certificates::maintenanceIndex'); // OK - // $routes->get('installation', 'Certificates::installationIndex'); // OK + $routes->get('installation', 'Certificates::installationIndex'); // OK // $routes->get('training', 'Certificates::trainingIndex'); // OK // $routes->get('calibration', 'Certificates::calibrateIndex'); // OK // Untuk Get API $routes->get('api/getindexmaintenance', 'Certificates::getDataIndexMaintenance'); // OK - // $routes->get('api/getindexinstallation', 'Certificates::getDataIndexInstallation'); // OK + $routes->get('api/getindexinstallation', 'Certificates::getDataIndexInstallation'); // OK // $routes->get('api/getindextraining', 'Certificates::getDataIndexTraining'); // OK // $routes->get('api/getindexcalibrate', 'Certificates::getDataIndexCalibrate'); diff --git a/app/Controllers/Activities.php b/app/Controllers/Activities.php index 8e4f977..7586f4c 100644 --- a/app/Controllers/Activities.php +++ b/app/Controllers/Activities.php @@ -1666,6 +1666,7 @@ class Activities extends Controller { return view('invtrans_index', $data); } + // Untuk CRUD Sertifikat Maintenance public function createCertificateMaintenance ($actid, $issuedDate, $userid_owner) { $db = \Config\Database::connect(); @@ -1789,4 +1790,6 @@ class Activities extends Controller { $certificateModel->where('actid', $actid)->delete(); } + + } \ No newline at end of file diff --git a/app/Controllers/Certificates.php b/app/Controllers/Certificates.php index 03abb9b..77ff1d0 100644 --- a/app/Controllers/Certificates.php +++ b/app/Controllers/Certificates.php @@ -15,62 +15,54 @@ class Certificates extends BaseController { protected array $data; - // Untuk Sertifikat Instalasi [1] + // Untuk Sertifikat Instalasi (BAI) [1] public function installationIndex() { // Index return view('certificate_installation_index'); } public function getDataIndexInstallation() { // Untuk API Get Data - // $actid = $this->request->getVar('actid'); Siapa Tahu Buat - - $certificates = [ - [ - 'certid' => 'f353ca91-4fc5-49f2-9b9e-304f83d11914', - 'certname' => 'Jokoh Calibration Certificate', - 'productname' => 'Jokoh', - 'productnumber' => 'SN-2024-001', - 'issuedate' => '2024-01-15', - 'expirydate' => '2025-01-15', - 'vendor' => 'Summit Calibration Lab', - 'isval' => null - ], - [ - 'certid' => 'f353ca91-4fc5-49f2-9b9e-304f83d11915', - 'certname' => 'Electrical Safety Test', - 'productname' => 'GE Healthcare VIVID', - 'productnumber' => 'GE-VIV-Q992', - 'issuedate' => '2024-06-12', - 'expirydate' => '2026-03-01', - 'vendor' => 'Pramita Medika Service', - 'isval' => '2026-03-01' - ], - [ - 'certid' => 'f353ca91-4fc5-49f2-9b9e-304f83d11915', - 'certname' => 'Electrical Safety Test', - 'productname' => 'GE Healthcare VIVID', - 'productnumber' => 'GE-VIV-Q992', - 'issuedate' => '2024-06-12', - 'expirydate' => '2026-10-01', - 'vendor' => 'Pramita Medika Service', - 'isval' => '2026-09-01' - ], - [ - 'certid' => 'f353ca91-4fc5-49f2-9b9e-304f83d11915', - 'certname' => 'Electrical Safety Test', - 'productname' => 'GE Healthcare VIVID', - 'productnumber' => 'GE-VIV-Q992', - 'issuedate' => '2024-06-12', - 'expirydate' => '2026-01-01', - 'vendor' => 'Pramita Medika Service', - 'isval' => '2026-09-01' - ], - ]; + $userPosId = session()->get('userposid'); + $userId = session()->get('userid'); - // If no actid, return all certificates - if (empty($certificates)) { - return $this->response->setJSON(null); + $certificateModel = new CertificateModel(); + + // 1. Mulai Query Builder + $builder = $certificateModel->select(' + certificates.cert_id, + certificates.cert_number, + certificates.cert_name, + certificates.cert_type, + certificates.actid, + certificates.issued_date, + certificates.expired_date, + certificates.status, + certificates.user_validation_at, + certificates.spv_validation_at, + certificates.manager_validation_at, + activities.subject as activity_subject, + CONCAT(users.firstname, " ", users.lastname) as fullname + ') + ->join('activities', 'activities.actid = certificates.actid', 'left') + ->join('users', 'users.userid = certificates.user_id', 'left') + ->where('certificates.cert_type', 'BAI'); + + // 2. Filter berdasarkan Role + if (in_array($userPosId, [1, 3, 5])) { // Manager & IT: Tidak perlu filter tambahan (lihat semua) + } else if ($userPosId == 2) { // SPV: Melihat data user yang "reportto"-nya adalah ID supervisor ini + $builder->where('users.reportto', $userId); + } else if ($userPosId == 4) { // TSOIVD: Hanya melihat data milik sendiri + $builder->where('certificates.user_id', $userId); + } else {// Role lain: Tidak diberi akses + return $this->response->setJSON([]); } - return $this->response->setJSON($certificates); + // 3. Eksekusi Query + $allData = $builder->findAll(); + + if (empty($allData)) { + return $this->response->setJSON([]); // Kembalikan array kosong agar frontend tidak error + } + + return $this->response->setJSON($allData); } public function createinstallationPreview($certid = null) { // Untuk Preview Sertifikat //Melakukan search data dari database @@ -126,7 +118,8 @@ class Certificates extends BaseController { CONCAT(users.firstname, " ", users.lastname) as fullname ') ->join('activities', 'activities.actid = certificates.actid', 'left') - ->join('users', 'users.userid = certificates.user_id', 'left'); + ->join('users', 'users.userid = certificates.user_id', 'left') + ->where('certificates.cert_type', 'MC');; // 2. Filter berdasarkan Role if (in_array($userPosId, [1, 3, 5])) { // Manager & IT: Tidak perlu filter tambahan (lihat semua) @@ -268,133 +261,133 @@ class Certificates extends BaseController { // Untuk Sertifikat Training [3] - public function trainingIndex() { - return view('certificate_training_index'); - } - public function getDataIndexTraining() { - // $actid = $this->request->getVar('actid'); + // public function trainingIndex() { + // return view('certificate_training_index'); + // } + // public function getDataIndexTraining() { + // // $actid = $this->request->getVar('actid'); - // Sample data - replace with actual database query - $certificates = [ - [ - 'certid' => 'f353ca91-4fc5-49f2-9b9e-304f83d11919', - 'certname' => 'Jokoh Calibration Certificate', - 'productname' => 'Jokoh', - 'productnumber' => 'SN-2024-001', - 'issuedate' => '2024-01-15', - 'expirydate' => '2025-01-15', - 'vendor' => 'Summit Calibration Lab', - 'isval' => null - ], - [ - 'certid' => 'f353ca91-4fc5-49f2-9b9e-304f83d11919', - 'certname' => 'Electrical Safety Test', - 'productname' => 'GE Healthcare VIVID', - 'productnumber' => 'GE-VIV-Q992', - 'issuedate' => '2024-06-12', - 'expirydate' => '2026-10-01', - 'vendor' => 'Pramita Medika Service', - 'isval' => '2026-03-01' - ] - ]; + // // Sample data - replace with actual database query + // $certificates = [ + // [ + // 'certid' => 'f353ca91-4fc5-49f2-9b9e-304f83d11919', + // 'certname' => 'Jokoh Calibration Certificate', + // 'productname' => 'Jokoh', + // 'productnumber' => 'SN-2024-001', + // 'issuedate' => '2024-01-15', + // 'expirydate' => '2025-01-15', + // 'vendor' => 'Summit Calibration Lab', + // 'isval' => null + // ], + // [ + // 'certid' => 'f353ca91-4fc5-49f2-9b9e-304f83d11919', + // 'certname' => 'Electrical Safety Test', + // 'productname' => 'GE Healthcare VIVID', + // 'productnumber' => 'GE-VIV-Q992', + // 'issuedate' => '2024-06-12', + // 'expirydate' => '2026-10-01', + // 'vendor' => 'Pramita Medika Service', + // 'isval' => '2026-03-01' + // ] + // ]; - // If no actid, return all certificates - if (empty($certificates)) { - return $this->response->setJSON(null); - } + // // If no actid, return all certificates + // if (empty($certificates)) { + // return $this->response->setJSON(null); + // } - return $this->response->setJSON($certificates); - } - public function createTrainingPreview($certid = null) { // Untuk Preview Sertifikat - //Melakukan search data dari database + // return $this->response->setJSON($certificates); + // } + // public function createTrainingPreview($certid = null) { // Untuk Preview Sertifikat + // //Melakukan search data dari database - if (!$certid) { - return $this->response->setStatusCode(400)->setJSON(['error' => 'Certificate ID is required']); - } + // if (!$certid) { + // return $this->response->setStatusCode(400)->setJSON(['error' => 'Certificate ID is required']); + // } - // Get certificate data Berdasarkan certid - $certificate = [ - 'certid' => 'f353ca91-4fc5-49f2-9b9e-304f83d11919', - 'certname' => 'Jokoh Calibration Certificate', - 'productname' => 'Jokoh', - 'productnumber' => 'SN-2024-001', - 'issuedate' => '2024-01-15', - 'expirydate' => '2025-01-15', - 'vendor' => 'Summit Calibration Lab', - 'isval' => null - ]; + // // Get certificate data Berdasarkan certid + // $certificate = [ + // 'certid' => 'f353ca91-4fc5-49f2-9b9e-304f83d11919', + // 'certname' => 'Jokoh Calibration Certificate', + // 'productname' => 'Jokoh', + // 'productnumber' => 'SN-2024-001', + // 'issuedate' => '2024-01-15', + // 'expirydate' => '2025-01-15', + // 'vendor' => 'Summit Calibration Lab', + // 'isval' => null + // ]; - if (empty($certificate)) { // JIka Tidak Ada - return $this->response->setStatusCode(404)->setJSON(['error' => 'Maintenance certificate not found']); - } + // if (empty($certificate)) { // JIka Tidak Ada + // return $this->response->setStatusCode(404)->setJSON(['error' => 'Maintenance certificate not found']); + // } - return $this->previewPdf($certificate, 'training'); // Preview PDF - } + // return $this->previewPdf($certificate, 'training'); // Preview PDF + // } // Untuk Sertifikat Calibrate [4] - public function calibrateIndex() { - return view('certificate_calibrate_index'); - } - public function getDataIndexCalibrate() { - // $actid = $this->request->getVar('actid'); + // public function calibrateIndex() { + // return view('certificate_calibrate_index'); + // } + // public function getDataIndexCalibrate() { + // // $actid = $this->request->getVar('actid'); - // Sample data - replace with actual database query - $certificates = [ - [ - 'certid' => 'f353ca91-4fc5-49f2-9b9e-304f83d11919', - 'certname' => 'Jokoh Calibration Certificate', - 'productname' => 'Jokoh', - 'productnumber' => 'SN-2024-001', - 'issuedate' => '2024-01-15', - 'expirydate' => '2025-01-15', - 'vendor' => 'Summit Calibration Lab', - 'isval' => null - ], - [ - 'certid' => 'f353ca91-4fc5-49f2-9b9e-304f83d11919', - 'certname' => 'Electrical Safety Test', - 'productname' => 'GE Healthcare VIVID', - 'productnumber' => 'GE-VIV-Q992', - 'issuedate' => '2024-06-12', - 'expirydate' => '2026-10-01', - 'vendor' => 'Pramita Medika Service', - 'isval' => '2026-03-01' - ] - ]; + // // Sample data - replace with actual database query + // $certificates = [ + // [ + // 'certid' => 'f353ca91-4fc5-49f2-9b9e-304f83d11919', + // 'certname' => 'Jokoh Calibration Certificate', + // 'productname' => 'Jokoh', + // 'productnumber' => 'SN-2024-001', + // 'issuedate' => '2024-01-15', + // 'expirydate' => '2025-01-15', + // 'vendor' => 'Summit Calibration Lab', + // 'isval' => null + // ], + // [ + // 'certid' => 'f353ca91-4fc5-49f2-9b9e-304f83d11919', + // 'certname' => 'Electrical Safety Test', + // 'productname' => 'GE Healthcare VIVID', + // 'productnumber' => 'GE-VIV-Q992', + // 'issuedate' => '2024-06-12', + // 'expirydate' => '2026-10-01', + // 'vendor' => 'Pramita Medika Service', + // 'isval' => '2026-03-01' + // ] + // ]; - // If no actid, return all certificates - if (empty($certificates)) { - return $this->response->setJSON(null); - } + // // If no actid, return all certificates + // if (empty($certificates)) { + // return $this->response->setJSON(null); + // } - return $this->response->setJSON($certificates); - } - public function createCalibratePreview($certid = null) { // Untuk Preview Sertifikat - //Melakukan search data dari database + // return $this->response->setJSON($certificates); + // } + // public function createCalibratePreview($certid = null) { // Untuk Preview Sertifikat + // //Melakukan search data dari database - if (!$certid) { - return $this->response->setStatusCode(400)->setJSON(['error' => 'Certificate ID is required']); - } + // if (!$certid) { + // return $this->response->setStatusCode(400)->setJSON(['error' => 'Certificate ID is required']); + // } - // Get certificate data Berdasarkan certid - $certificate = [ - 'certid' => 'f353ca91-4fc5-49f2-9b9e-304f83d11919', - 'certname' => 'Jokoh Calibration Certificate', - 'productname' => 'Jokoh', - 'productnumber' => 'SN-2024-001', - 'issuedate' => '2024-01-15', - 'expirydate' => '2025-01-15', - 'vendor' => 'Summit Calibration Lab', - 'isval' => null - ]; + // // Get certificate data Berdasarkan certid + // $certificate = [ + // 'certid' => 'f353ca91-4fc5-49f2-9b9e-304f83d11919', + // 'certname' => 'Jokoh Calibration Certificate', + // 'productname' => 'Jokoh', + // 'productnumber' => 'SN-2024-001', + // 'issuedate' => '2024-01-15', + // 'expirydate' => '2025-01-15', + // 'vendor' => 'Summit Calibration Lab', + // 'isval' => null + // ]; - if (empty($certificate)) { // JIka Tidak Ada - return $this->response->setStatusCode(404)->setJSON(['error' => 'Maintenance certificate not found']); - } + // if (empty($certificate)) { // JIka Tidak Ada + // return $this->response->setStatusCode(404)->setJSON(['error' => 'Maintenance certificate not found']); + // } - return $this->previewPdf($certificate, 'calibrate', 'tms24i'); // Preview PDF - } + // return $this->previewPdf($certificate, 'calibrate', 'tms24i'); // Preview PDF + // } // Helper Function Preview dan Validate diff --git a/app/Views/activities_editor.php b/app/Views/activities_editor.php index 2227a64..0bff096 100644 --- a/app/Views/activities_editor.php +++ b/app/Views/activities_editor.php @@ -223,7 +223,7 @@ if(isset($data)) { Calibration Certificate - + -->
@@ -232,7 +232,7 @@ if(isset($data)) { Installation Certificate
-
--> +
@@ -250,9 +250,9 @@ if(isset($data)) { Berita Acara Instalasi
-
+ --> -
+ -
- -
-
-
-
-
-
-
- - -
-
-
- -
-
- -
-
- -
-
- -
- - - - - - - - - - - - - - - - Expired'; - $statusClass = 'expired'; - } elseif($daysUntilExpiry <= 30) { - $statusBadge = 'Expiring Soon'; - $statusClass = 'expiring'; - } else { - $statusBadge = 'Active'; - $statusClass = 'active'; - } - } else { - $expirydate = '-'; - $statusBadge = 'N/A'; - $statusClass = ''; - } - - // Type badge - $typeBadge = ''; - switch(strtolower($type)) { - case 'calibration': - $typeBadge = 'Calibration'; - break; - case 'training': - $typeBadge = 'Training'; - break; - case 'maintenance': - $typeBadge = 'Maintenance'; - break; - default: - $typeBadge = '' . htmlspecialchars($type) . ''; - } - ?> - - - - - - - - - - - - - - - -
NoCertificate NameProduct/EquipmentTypeIssue DateExpiry DateStatusVendorAction
- -
- ID: -
- - -
SN: - -
-
- - -
-
-
-
-
-
-
- - - - - - - - - - - - - - - -endSection() ?> - -section('script') ?> - -endSection() ?> diff --git a/app/Views/certificate_installation_index.php b/app/Views/certificate_installation_index.php index 4a199a4..87da263 100644 --- a/app/Views/certificate_installation_index.php +++ b/app/Views/certificate_installation_index.php @@ -3,167 +3,162 @@ section('content') ?>
-
-
-
-

Certificates Installation Management

-
-
+
+
+
+

Certificates Installation Management

+
+
-
-
-
-
-
-
-
- - -
-
-
- -
-
- -
-
- -
-
+
+
+
+
+
+
+
+ + +
+
+
+ +
+
+ +
+
+ +
+
-
- - - - - - - + + + + +
Certificate NameProduct/EquipmentActivity ReportIssue DateExpiry DateStatusActionCertificateAct ReportIssue DateValidationAction
-
-
-
-
-
-
+
+
+
+
+
+
- endSection() ?> section('style') ?> - endSection() ?> section('script') ?> @@ -171,7 +166,7 @@ $(function () { let table = $('#certificatesTable').DataTable({ - order: [[5, 'asc']], + order: [[3, 'asc']], // Order by Validation Column pageLength: 25, dom: '<"row"<"col-md-6"l>>rtip', responsive: true, @@ -182,53 +177,43 @@ $(function () { .then(response => response.json()) .then(result => { callback({ - data: result.map(cert => { - let certid = cert.certid || ''; - let certname = cert.certname || '-'; - let productname = cert.productname || '-'; - let productnumber = cert.productnumber || ''; - let issuedateRaw = cert.issuedate || ''; - let expirydateRaw = cert.expirydate || ''; - let vendor = cert.vendor || '-'; - let isval = cert.isval || null; + data: result.map((cert, index) => { + + let certid = cert.cert_id || ''; + let certname = cert.cert_name || '-'; + let certnumber = cert.cert_number || ''; + let actid = cert.actid || ''; + let issuedateRaw = cert.issued_date || ''; + let status = cert.status; // Validation status + let fullname = cert.fullname; + let activity_subject = cert.activity_subject; let issuedate = '-'; - let expirydate = '-'; - let statusBadge = 'Need Validation'; + let validationBadge = ''; - if (isval != null) { - if (issuedateRaw && issuedateRaw !== '0000-00-00') { - issuedate = new Date(issuedateRaw).toLocaleDateString('en-US', { month: 'short', day: '2-digit', year: 'numeric' }); - } + if (issuedateRaw && issuedateRaw !== '0000-00-00') { + let date = new Date(issuedateRaw); + let day = String(date.getDate()).padStart(2, '0'); + let month = date.toLocaleString('en-US', { month: 'short' }); + let year = date.getFullYear(); + issuedate = `${day} ${month} ${year}`; + } - if (expirydateRaw && expirydateRaw !== '0000-00-00') { - expirydate = new Date(expirydateRaw).toLocaleDateString('en-US', { month: 'short', day: '2-digit', year: 'numeric' }); - let today = new Date(); - let expiryDate = new Date(expirydateRaw); - let days = Math.ceil((expiryDate - today) / (1000 * 60 * 60 * 24)); - - if (days < 0) { - statusBadge = 'Expired'; - } else if (days <= 30) { - statusBadge = 'Expiring Soon'; - } else { - statusBadge = 'Active'; - } - } else { - statusBadge = 'N/A'; - } + if (status == 'unvalidated') { + validationBadge = '
unvalidated
'; + } else { + validationBadge = '
validated
'; } return [ - `${certname}
ID: ${certid}`, - `${productname}${productnumber ? '
SN: ' + productnumber + '' : ''}`, - `Act ID - Nama AR - Nama User `, + `${certname}
Cert# : ${certnumber}`, + `#${actid} - ${activity_subject}  
Owner : ${fullname}
`, issuedate, - expirydate, - statusBadge, - isval == null - ? `
` - : `
` + validationBadge, + status == 'unvalidated' + ? `
` + : `
+
` ]; }) }); @@ -238,19 +223,26 @@ $(function () { callback({ data: [] }); }); }, - columnDefs: [{ - targets: 5, - render: function (data, type) { - if (type === 'sort') { - if (data.includes('Need Validation')) return 1; - if (data.includes('Expired')) return 2; - if (data.includes('Expiring Soon')) return 3; - if (data.includes('Active')) return 4; - return 5; + columnDefs: [ + { + // Kondisi untuk Kolom 3 (Validation) + targets: 3, + render: function (data, type) { + if (type === 'sort') { + let val = data.toLowerCase(); + if (val.includes('unvalidated')) return 1; + if (val.includes('validated')) return 2; + return 3; + } + return data; } - return data; + }, + { + // Kondisi untuk Kolom 4 (Action) + targets: [4], + orderable: false } - }] + ] }); $('#certificatesTable_filter').hide(); @@ -261,70 +253,107 @@ $(function () { }); // Type filter using DataTables column filter - $('#typeFilter').on('change', function () { + $('#productFilter').on('change', function () { let type = $(this).val(); - // Filter by type column (index 1 - Certificate Name contains type info) if (type === '') { - table.column(1).search('').draw(); + table.column(0).search('').draw(); } else { - // Capitalize first letter for search let typeText = type.charAt(0).toUpperCase() + type.slice(1); - table.column(1).search(typeText).draw(); + table.column(0).search(typeText).draw(); } }); - // Status filter - $('#statusFilter').on('change', function () { - let map = { - active: 'Active', - expired: 'Expired', - expiring: 'Expiring Soon', - isval: 'Need Validation' - }; - table.column(5).search(map[this.value] || '').draw(); + $('#validationFilter').on('change', function () { + let validation = $(this).val(); + if (validation === '') { + table.column(3).search('').draw(); + } else if (validation === 'unval') { + table.column(3).search('unv').draw(); + } else if (validation === 'valid') { + table.column(3).search('^validated$', true, false).draw(); + } }); // Reset window.resetFilters = function () { - $('#searchInput, #statusFilter').val(''); - table.search('').columns().search('').order([5,'asc']).draw(); + $('#searchInput, #productFilter, #validationFilter').val(''); + table.search('').columns().search('').draw(); }; // View PDF $(document).on('click', '.btn-view', function () { - let certid = $(this).data('certid'); - window.open('' + certid, '_blank'); + let certnumber = $(this).data('certnumber'); + window.open('' + certnumber, '_blank'); }); // Activity report $(document).on('click', '.activity-report-link', function () { - let certid = $(this).data('certid'); + let actid = $(this).data('actid'); window.open( - '' + certid, + '' + actid, '_blank', 'width=1200,height=800,scrollbars=yes,resizable=yes' ); }); // Open modal - $(document).on('click', '.btn-validate', function () { + $(document).on('click', '.btn-validate-modal', function () { let btn = $(this); + let certid = btn.data('certid'); - $('#modalCertId').text(btn.data('certid')); - $('#modalCertName').text(btn.data('certname')); - $('#modalProductName').text(btn.data('productname')); - $('#modalProductNumber').text(btn.data('productnumber')); - $('#modalIssueDate').text(btn.data('issuedate')); - $('#modalExpiryDate').text(btn.data('expirydate')); - $('#modalVendor').text(btn.data('vendor')); + // POST API call to fetch certificate data + $.post( + '', + { certid }, + function (data) { + $('#modalCertName').text(data.cert_name || '-'); + $('#modalCertNumber').text(data.cert_number || '-'); + $('#modalProductName').text(data.productname || '-'); + $('#modalProductNumber').text(data.productnumber || '-'); + $('#modalIssueDate').text(data.issued_date || '-'); + $('#modalSiteName').text(data.sitename || '-'); - $('#confirmValidateBtn').data('certid', btn.data('certid')); - $('#certificatePreview').attr( - 'src', - '' + btn.data('certid') - ); + // Cek status validasi + const isValid = data.status === 'validated'; + const theme = isValid ? 'success' : 'warning'; + const icon = isValid ? 'fa-regular fa-circle-check' : 'fa-solid fa-triangle-exclamation'; + const note = isValid + ? 'Sertifikat Sudah Divalidasi' + : 'Review data berikut dengan teliti, setelah divalidasi maka sertifikat akan dinyatakan Valid dan sah secara sistem.'; + + $('#modalHeader').removeClass('bg-warning bg-success').addClass(`bg-${theme} text-dark`); + $('#modalValidation').html( + ` + ${data.status || '-'} + ` + ); + + $('#modalInfo').html( + `
+ +
+ Validation Note:
+ ${note} +
+
` + ); + + $('#modalActivity').text(data.actid ? `#${data.actid} - ${data.subject || '-'}` : '-'); + $('#modalActivityLink').attr('data-actid', data.actid || ''); + $('#modalValOwner').html(data.user_validation_at ? `${data.username} - ${data.user_validation_at}` : '-'); + $('#modalValSpv').html(data.spv_validation_at ? `${data.spvname} - ${data.spv_validation_at}` : '-'); + $('#modalValManager').html(data.manager_validation_at ? `${data.managername} - ${data.manager_validation_at}` : '-'); + }, + 'json' + ).fail(function () { + console.error('Error fetching certificate data'); + }); + + // INI JANGAN DIUBAH + $('#confirmValidateBtn').data('certid', certid); + $('#certificatePreview').attr('src','' + certid); $('#validateModal').modal('show'); }); @@ -337,43 +366,23 @@ $(function () { if (!confirm('Are you sure?')) return; $.post( - '', + '', { certid, certificateType}, function (response) { if (response.success) { $('#validateModal').modal('hide'); alert(response.message); - - // Generate and save PDF after successful validation - $.post( - '', - { certid, certificateType }, - function (pdfResponse) { - if (pdfResponse.success) { - alert('PDF generated and saved successfully!'); - location.reload(); - } else { - alert('Validation successful but PDF generation failed: ' + (pdfResponse.message || 'Unknown error')); - location.reload(); - } - }, - 'json' - ).fail(function () { - alert('Validation successful but failed to generate PDF'); - location.reload(); - }); - + location.reload(); } else { alert(response.message || 'Validation failed'); } }, 'json' - ).fail(function () { - $('#validateModal').modal('hide'); - alert('Server error.'); + ).fail(function (xhr) { + console.log(xhr); + alert(xhr.responseText); }); - }); }); diff --git a/app/Views/certificates/certificate_maintenance_index.php b/app/Views/certificates/certificate_maintenance_index.php deleted file mode 100644 index 97de5c7..0000000 --- a/app/Views/certificates/certificate_maintenance_index.php +++ /dev/null @@ -1,545 +0,0 @@ -extend('layouts/main.php') ?> - -section('content') ?> - -
-
-
-
-

Certificates Maintenance Management

-
-
- -
-
- -
-
-
-
-
-
-
- - -
-
-
- -
-
- -
-
- -
-
- -
- - - - - - - - - - - - - - - - Expired'; - $statusClass = 'expired'; - } elseif($daysUntilExpiry <= 30) { - $statusBadge = 'Expiring Soon'; - $statusClass = 'expiring'; - } else { - $statusBadge = 'Active'; - $statusClass = 'active'; - } - } else { - $expirydate = '-'; - $statusBadge = 'N/A'; - $statusClass = ''; - } - - // Type badge - $typeBadge = ''; - switch(strtolower($type)) { - case 'calibration': - $typeBadge = 'Calibration'; - break; - case 'training': - $typeBadge = 'Training'; - break; - case 'maintenance': - $typeBadge = 'Maintenance'; - break; - default: - $typeBadge = '' . htmlspecialchars($type) . ''; - } - ?> - - - - - - - - - - - - - - - - - -
NoCertificate NameProduct/EquipmentTypeIssue DateExpiry DateStatusVendorAction
- -
- ID: -
- - -
SN: - -
-
- - - -
-
- -

No certificates found

- -
-
-
-
-
-
-
-
- - - - - - - - - - -endSection() ?> - -section('script') ?> - -endSection() ?> diff --git a/app/Views/layouts/_sidebar.php b/app/Views/layouts/_sidebar.php index 376aadf..3eb9f18 100644 --- a/app/Views/layouts/_sidebar.php +++ b/app/Views/layouts/_sidebar.php @@ -41,10 +41,10 @@