crm-summit/app/Controllers/Certificates.php
2026-02-19 08:53:25 +07:00

1156 lines
39 KiB
PHP

<?php
namespace App\Controllers;
use App\Controllers\BaseController;
use Dompdf\Dompdf;
use Dompdf\Options;
class Certificates extends BaseController {
protected array $data;
// public function index() {
// $certificates = [
// [
// 'certid' => 'CERT001',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-001',
// 'type' => 'calibration',
// 'issuedate' => '2024-01-15',
// 'expirydate' => '2025-01-15',
// 'vendor' => 'Summit Calibration Lab'
// ],
// [
// 'certid' => 'CERT002',
// 'certname' => 'CL900i Operator Training',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-002',
// 'type' => 'training',
// 'issuedate' => '2024-03-20',
// 'expirydate' => '2025-03-20',
// 'vendor' => 'Summit Training Center'
// ],
// [
// 'certid' => 'CERT003',
// 'certname' => 'CL900i Maintenance Record',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-003',
// 'type' => 'maintenance',
// 'issuedate' => '2024-06-10',
// 'expirydate' => '2024-12-10',
// 'vendor' => 'Summit Service Team'
// ]
// ];
// // Data dummy untuk products dropdown
// // $products = [
// // ['productid' => '1', 'productname' => 'CL900i', 'productnumber' => 'SN-2024-001'],
// // ['productid' => '2', 'productname' => 'CL900i', 'productnumber' => 'SN-2024-002'],
// // ['productid' => '3', 'productname' => 'CL900i', 'productnumber' => 'SN-2024-003']
// // ];
// $data = [
// 'certificates' => $certificates,
// // 'products' => $products
// ];
// return view('certificate_index', $data);
// }
// public function view($certid = null) {
// if (!$certid) {
// return $this->response->setStatusCode(400)->setJSON(['error' => 'Certificate ID is required']);
// }
// // Get certificate data from dummy data
// $certificates = [
// [
// 'certid' => 'CERT001',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-001',
// 'type' => 'calibration',
// 'issuedate' => '2024-01-15',
// 'expirydate' => '2025-01-15',
// 'vendor' => 'Summit Calibration Lab',
// 'description' => 'Annual calibration certificate for CL900i equipment. All parameters verified and within specifications.'
// ],
// [
// 'certid' => 'CERT002',
// 'certname' => 'CL900i Operator Training',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-002',
// 'type' => 'training',
// 'issuedate' => '2024-03-20',
// 'expirydate' => '2025-03-20',
// 'vendor' => 'Summit Training Center',
// 'description' => 'Operator training completion certificate. Covers basic operation and safety procedures.'
// ],
// [
// 'certid' => 'CERT003',
// 'certname' => 'CL900i Maintenance Record',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-003',
// 'type' => 'maintenance',
// 'issuedate' => '2024-06-10',
// 'expirydate' => '2024-12-10',
// 'vendor' => 'Summit Service Team',
// 'description' => 'Regular maintenance record for CL900i equipment. All components checked and serviced.'
// ],
// [
// 'certid' => 'CERT004',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-004',
// 'type' => 'calibration',
// 'issuedate' => '2023-11-01',
// 'expirydate' => '2024-11-01',
// 'vendor' => 'External Calibration Lab',
// 'description' => 'Annual calibration certificate for CL900i equipment. All parameters verified and within specifications.'
// ],
// [
// 'certid' => 'CERT005',
// 'certname' => 'CL900i Advanced Training',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-005',
// 'type' => 'training',
// 'issuedate' => '2024-05-15',
// 'expirydate' => '2025-05-15',
// 'vendor' => 'Summit Training Center',
// 'description' => 'Advanced training completion certificate. Covers advanced operation and troubleshooting procedures.'
// ],
// [
// 'certid' => 'CERT006',
// 'certname' => 'CL900i Annual Maintenance',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-006',
// 'type' => 'maintenance',
// 'issuedate' => '2024-01-01',
// 'expirydate' => '2025-01-01',
// 'vendor' => 'Summit Service Team',
// 'description' => 'Annual maintenance record for CL900i equipment. All components checked and serviced.'
// ],
// [
// 'certid' => 'CERT007',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-007',
// 'type' => 'calibration',
// 'issuedate' => '2024-02-28',
// 'expirydate' => '2025-02-28',
// 'vendor' => 'Summit Calibration Lab',
// 'description' => 'Annual calibration certificate for CL900i equipment. All parameters verified and within specifications.'
// ],
// [
// 'certid' => 'CERT008',
// 'certname' => 'CL900i Safety Training',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-008',
// 'type' => 'training',
// 'issuedate' => '2024-04-10',
// 'expirydate' => '2025-04-10',
// 'vendor' => 'External Safety Institute',
// 'description' => 'Safety training completion certificate. Covers safety procedures and emergency protocols.'
// ],
// [
// 'certid' => 'CERT009',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-009',
// 'type' => 'calibration',
// 'issuedate' => '2024-07-20',
// 'expirydate' => '2025-07-20',
// 'vendor' => 'Summit Calibration Lab',
// 'description' => 'Annual calibration certificate for CL900i equipment. All parameters verified and within specifications.'
// ],
// [
// 'certid' => 'CERT010',
// 'certname' => 'CL900i Technical Training',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-010',
// 'type' => 'training',
// 'issuedate' => '2024-08-05',
// 'expirydate' => '2025-08-05',
// 'vendor' => 'Summit Training Center',
// 'description' => 'Technical training completion certificate. Covers technical specifications and maintenance procedures.'
// ],
// [
// 'certid' => 'CERT011',
// 'certname' => 'CL900i Maintenance Record',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-011',
// 'type' => 'maintenance',
// 'issuedate' => '2024-09-15',
// 'expirydate' => '2025-03-15',
// 'vendor' => 'Summit Service Team',
// 'description' => 'Regular maintenance record for CL900i equipment. All components checked and serviced.'
// ],
// [
// 'certid' => 'CERT012',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-012',
// 'type' => 'calibration',
// 'issuedate' => '2024-10-01',
// 'expirydate' => '2025-10-01',
// 'vendor' => 'External Calibration Lab',
// 'description' => 'Annual calibration certificate for CL900i equipment. All parameters verified and within specifications.'
// ],
// [
// 'certid' => 'CERT013',
// 'certname' => 'CL900i Basic Training',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-013',
// 'type' => 'training',
// 'issuedate' => '2024-11-20',
// 'expirydate' => '2025-11-20',
// 'vendor' => 'Summit Training Center',
// 'description' => 'Basic training completion certificate. Covers basic operation procedures.'
// ],
// [
// 'certid' => 'CERT014',
// 'certname' => 'CL900i Maintenance Record',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-014',
// 'type' => 'maintenance',
// 'issuedate' => '2024-12-01',
// 'expirydate' => '2025-06-01',
// 'vendor' => 'Summit Service Team',
// 'description' => 'Regular maintenance record for CL900i equipment. All components checked and serviced.'
// ],
// [
// 'certid' => 'CERT015',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-015',
// 'type' => 'calibration',
// 'issuedate' => '2024-01-10',
// 'expirydate' => '2025-01-10',
// 'vendor' => 'Summit Calibration Lab',
// 'description' => 'Annual calibration certificate for CL900i equipment. All parameters verified and within specifications.'
// ],
// [
// 'certid' => 'CERT016',
// 'certname' => 'CL900i Operator Training',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-016',
// 'type' => 'training',
// 'issuedate' => '2024-02-15',
// 'expirydate' => '2025-02-15',
// 'vendor' => 'External Training Institute',
// 'description' => 'Operator training completion certificate. Covers basic operation and safety procedures.'
// ],
// [
// 'certid' => 'CERT017',
// 'certname' => 'CL900i Maintenance Record',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-017',
// 'type' => 'maintenance',
// 'issuedate' => '2024-03-25',
// 'expirydate' => '2024-09-25',
// 'vendor' => 'Summit Service Team',
// 'description' => 'Regular maintenance record for CL900i equipment. All components checked and serviced.'
// ],
// [
// 'certid' => 'CERT018',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-018',
// 'type' => 'calibration',
// 'issuedate' => '2024-04-30',
// 'expirydate' => '2025-04-30',
// 'vendor' => 'Summit Calibration Lab',
// 'description' => 'Annual calibration certificate for CL900i equipment. All parameters verified and within specifications.'
// ],
// [
// 'certid' => 'CERT019',
// 'certname' => 'CL900i Advanced Training',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-019',
// 'type' => 'training',
// 'issuedate' => '2024-05-20',
// 'expirydate' => '2025-05-20',
// 'vendor' => 'Summit Training Center',
// 'description' => 'Advanced training completion certificate. Covers advanced operation and troubleshooting procedures.'
// ],
// [
// 'certid' => 'CERT020',
// 'certname' => 'CL900i Maintenance Record',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-020',
// 'type' => 'maintenance',
// 'issuedate' => '2024-06-15',
// 'expirydate' => '2024-12-15',
// 'vendor' => 'External Service Provider',
// 'description' => 'Regular maintenance record for CL900i equipment. All components checked and serviced.'
// ],
// [
// 'certid' => 'CERT021',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-021',
// 'type' => 'calibration',
// 'issuedate' => '2024-07-10',
// 'expirydate' => '2025-07-10',
// 'vendor' => 'Summit Calibration Lab',
// 'description' => 'Annual calibration certificate for CL900i equipment. All parameters verified and within specifications.'
// ],
// [
// 'certid' => 'CERT022',
// 'certname' => 'CL900i Safety Training',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-022',
// 'type' => 'training',
// 'issuedate' => '2024-08-25',
// 'expirydate' => '2025-08-25',
// 'vendor' => 'External Safety Institute',
// 'description' => 'Safety training completion certificate. Covers safety procedures and emergency protocols.'
// ],
// [
// 'certid' => 'CERT023',
// 'certname' => 'CL900i Maintenance Record',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-023',
// 'type' => 'maintenance',
// 'issuedate' => '2024-09-05',
// 'expirydate' => '2025-03-05',
// 'vendor' => 'Summit Service Team',
// 'description' => 'Regular maintenance record for CL900i equipment. All components checked and serviced.'
// ],
// [
// 'certid' => 'CERT024',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-024',
// 'type' => 'calibration',
// 'issuedate' => '2024-10-15',
// 'expirydate' => '2025-10-15',
// 'vendor' => 'External Calibration Lab',
// 'description' => 'Annual calibration certificate for CL900i equipment. All parameters verified and within specifications.'
// ],
// [
// 'certid' => 'CERT025',
// 'certname' => 'CL900i Technical Training',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-025',
// 'type' => 'training',
// 'issuedate' => '2024-11-10',
// 'expirydate' => '2025-11-10',
// 'vendor' => 'Summit Training Center',
// 'description' => 'Technical training completion certificate. Covers technical specifications and maintenance procedures.'
// ],
// [
// 'certid' => 'CERT026',
// 'certname' => 'CL900i Maintenance Record',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-026',
// 'type' => 'maintenance',
// 'issuedate' => '2024-12-20',
// 'expirydate' => '2025-06-20',
// 'vendor' => 'Summit Service Team',
// 'description' => 'Regular maintenance record for CL900i equipment. All components checked and serviced.'
// ],
// [
// 'certid' => 'CERT027',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-027',
// 'type' => 'calibration',
// 'issuedate' => '2024-01-05',
// 'expirydate' => '2025-01-05',
// 'vendor' => 'Summit Calibration Lab',
// 'description' => 'Annual calibration certificate for CL900i equipment. All parameters verified and within specifications.'
// ],
// [
// 'certid' => 'CERT028',
// 'certname' => 'CL900i Operator Training',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-028',
// 'type' => 'training',
// 'issuedate' => '2024-02-20',
// 'expirydate' => '2025-02-20',
// 'vendor' => 'External Training Institute',
// 'description' => 'Operator training completion certificate. Covers basic operation and safety procedures.'
// ],
// [
// 'certid' => 'CERT029',
// 'certname' => 'CL900i Maintenance Record',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-029',
// 'type' => 'maintenance',
// 'issuedate' => '2024-03-10',
// 'expirydate' => '2024-09-10',
// 'vendor' => 'Summit Service Team',
// 'description' => 'Regular maintenance record for CL900i equipment. All components checked and serviced.'
// ],
// [
// 'certid' => 'CERT030',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-030',
// 'type' => 'calibration',
// 'issuedate' => '2024-04-25',
// 'expirydate' => '2025-04-25',
// 'vendor' => 'Summit Calibration Lab',
// 'description' => 'Annual calibration certificate for CL900i equipment. All parameters verified and within specifications.'
// ]
// ];
// $certificate = null;
// foreach ($certificates as $cert) {
// if ($cert['certid'] === $certid) {
// $certificate = $cert;
// break;
// }
// }
// if (!$certificate) {
// return $this->response->setStatusCode(404)->setJSON(['error' => 'Certificate not found']);
// }
// // Generate PDF based on type
// return $this->generatePDF($certificate, $certificate['type']);
// }
// public function get($certid = null) {
// $certificates = [
// [
// 'certid' => 'CERT001',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-001',
// 'type' => 'calibration',
// 'issuedate' => '2024-01-15',
// 'expirydate' => '2025-01-15',
// 'vendor' => 'Summit Calibration Lab',
// 'description' => 'Annual calibration certificate for CL900i equipment.'
// ],
// [
// 'certid' => 'CERT002',
// 'certname' => 'CL900i Operator Training',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-002',
// 'type' => 'training',
// 'issuedate' => '2024-03-20',
// 'expirydate' => '2025-03-20',
// 'vendor' => 'Summit Training Center',
// 'description' => 'Operator training completion certificate.'
// ],
// [
// 'certid' => 'CERT003',
// 'certname' => 'CL900i Maintenance Record',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-003',
// 'type' => 'maintenance',
// 'issuedate' => '2024-06-10',
// 'expirydate' => '2024-12-10',
// 'vendor' => 'Summit Service Team',
// 'description' => 'Regular maintenance record for CL900i equipment.'
// ],
// [
// 'certid' => 'CERT004',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-004',
// 'type' => 'calibration',
// 'issuedate' => '2023-11-01',
// 'expirydate' => '2024-11-01',
// 'vendor' => 'External Calibration Lab',
// 'description' => 'Annual calibration certificate for CL900i equipment.'
// ],
// [
// 'certid' => 'CERT005',
// 'certname' => 'CL900i Advanced Training',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-005',
// 'type' => 'training',
// 'issuedate' => '2024-05-15',
// 'expirydate' => '2025-05-15',
// 'vendor' => 'Summit Training Center',
// 'description' => 'Advanced training completion certificate.'
// ],
// [
// 'certid' => 'CERT006',
// 'certname' => 'CL900i Annual Maintenance',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-006',
// 'type' => 'maintenance',
// 'issuedate' => '2024-01-01',
// 'expirydate' => '2025-01-01',
// 'vendor' => 'Summit Service Team',
// 'description' => 'Annual maintenance record for CL900i equipment.'
// ],
// [
// 'certid' => 'CERT007',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-007',
// 'type' => 'calibration',
// 'issuedate' => '2024-02-28',
// 'expirydate' => '2025-02-28',
// 'vendor' => 'Summit Calibration Lab',
// 'description' => 'Annual calibration certificate for CL900i equipment.'
// ],
// [
// 'certid' => 'CERT008',
// 'certname' => 'CL900i Safety Training',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-008',
// 'type' => 'training',
// 'issuedate' => '2024-04-10',
// 'expirydate' => '2025-04-10',
// 'vendor' => 'External Safety Institute',
// 'description' => 'Safety training completion certificate.'
// ],
// [
// 'certid' => 'CERT009',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-009',
// 'type' => 'calibration',
// 'issuedate' => '2024-07-20',
// 'expirydate' => '2025-07-20',
// 'vendor' => 'Summit Calibration Lab',
// 'description' => 'Annual calibration certificate for CL900i equipment.'
// ],
// [
// 'certid' => 'CERT010',
// 'certname' => 'CL900i Technical Training',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-010',
// 'type' => 'training',
// 'issuedate' => '2024-08-05',
// 'expirydate' => '2025-08-05',
// 'vendor' => 'Summit Training Center',
// 'description' => 'Technical training completion certificate.'
// ],
// [
// 'certid' => 'CERT011',
// 'certname' => 'CL900i Maintenance Record',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-011',
// 'type' => 'maintenance',
// 'issuedate' => '2024-09-15',
// 'expirydate' => '2025-03-15',
// 'vendor' => 'Summit Service Team',
// 'description' => 'Regular maintenance record for CL900i equipment.'
// ],
// [
// 'certid' => 'CERT012',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-012',
// 'type' => 'calibration',
// 'issuedate' => '2024-10-01',
// 'expirydate' => '2025-10-01',
// 'vendor' => 'External Calibration Lab',
// 'description' => 'Annual calibration certificate for CL900i equipment.'
// ],
// [
// 'certid' => 'CERT013',
// 'certname' => 'CL900i Basic Training',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-013',
// 'type' => 'training',
// 'issuedate' => '2024-11-20',
// 'expirydate' => '2025-11-20',
// 'vendor' => 'Summit Training Center',
// 'description' => 'Basic training completion certificate.'
// ],
// [
// 'certid' => 'CERT014',
// 'certname' => 'CL900i Maintenance Record',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-014',
// 'type' => 'maintenance',
// 'issuedate' => '2024-12-01',
// 'expirydate' => '2025-06-01',
// 'vendor' => 'Summit Service Team',
// 'description' => 'Regular maintenance record for CL900i equipment.'
// ],
// [
// 'certid' => 'CERT015',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-015',
// 'type' => 'calibration',
// 'issuedate' => '2024-01-10',
// 'expirydate' => '2025-01-10',
// 'vendor' => 'Summit Calibration Lab',
// 'description' => 'Annual calibration certificate for CL900i equipment.'
// ],
// [
// 'certid' => 'CERT016',
// 'certname' => 'CL900i Operator Training',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-016',
// 'type' => 'training',
// 'issuedate' => '2024-02-15',
// 'expirydate' => '2025-02-15',
// 'vendor' => 'External Training Institute',
// 'description' => 'Operator training completion certificate.'
// ],
// [
// 'certid' => 'CERT017',
// 'certname' => 'CL900i Maintenance Record',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-017',
// 'type' => 'maintenance',
// 'issuedate' => '2024-03-25',
// 'expirydate' => '2024-09-25',
// 'vendor' => 'Summit Service Team',
// 'description' => 'Regular maintenance record for CL900i equipment.'
// ],
// [
// 'certid' => 'CERT018',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-018',
// 'type' => 'calibration',
// 'issuedate' => '2024-04-30',
// 'expirydate' => '2025-04-30',
// 'vendor' => 'Summit Calibration Lab',
// 'description' => 'Annual calibration certificate for CL900i equipment.'
// ],
// [
// 'certid' => 'CERT019',
// 'certname' => 'CL900i Advanced Training',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-019',
// 'type' => 'training',
// 'issuedate' => '2024-05-20',
// 'expirydate' => '2025-05-20',
// 'vendor' => 'Summit Training Center',
// 'description' => 'Advanced training completion certificate.'
// ],
// [
// 'certid' => 'CERT020',
// 'certname' => 'CL900i Maintenance Record',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-020',
// 'type' => 'maintenance',
// 'issuedate' => '2024-06-15',
// 'expirydate' => '2024-12-15',
// 'vendor' => 'External Service Provider',
// 'description' => 'Regular maintenance record for CL900i equipment.'
// ],
// [
// 'certid' => 'CERT021',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-021',
// 'type' => 'calibration',
// 'issuedate' => '2024-07-10',
// 'expirydate' => '2025-07-10',
// 'vendor' => 'Summit Calibration Lab',
// 'description' => 'Annual calibration certificate for CL900i equipment.'
// ],
// [
// 'certid' => 'CERT022',
// 'certname' => 'CL900i Safety Training',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-022',
// 'type' => 'training',
// 'issuedate' => '2024-08-25',
// 'expirydate' => '2025-08-25',
// 'vendor' => 'External Safety Institute',
// 'description' => 'Safety training completion certificate.'
// ],
// [
// 'certid' => 'CERT023',
// 'certname' => 'CL900i Maintenance Record',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-023',
// 'type' => 'maintenance',
// 'issuedate' => '2024-09-05',
// 'expirydate' => '2025-03-05',
// 'vendor' => 'Summit Service Team',
// 'description' => 'Regular maintenance record for CL900i equipment.'
// ],
// [
// 'certid' => 'CERT024',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-024',
// 'type' => 'calibration',
// 'issuedate' => '2024-10-15',
// 'expirydate' => '2025-10-15',
// 'vendor' => 'External Calibration Lab',
// 'description' => 'Annual calibration certificate for CL900i equipment.'
// ],
// [
// 'certid' => 'CERT025',
// 'certname' => 'CL900i Technical Training',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-025',
// 'type' => 'training',
// 'issuedate' => '2024-11-10',
// 'expirydate' => '2025-11-10',
// 'vendor' => 'Summit Training Center',
// 'description' => 'Technical training completion certificate.'
// ],
// [
// 'certid' => 'CERT026',
// 'certname' => 'CL900i Maintenance Record',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-026',
// 'type' => 'maintenance',
// 'issuedate' => '2024-12-20',
// 'expirydate' => '2025-06-20',
// 'vendor' => 'Summit Service Team',
// 'description' => 'Regular maintenance record for CL900i equipment.'
// ],
// [
// 'certid' => 'CERT027',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-027',
// 'type' => 'calibration',
// 'issuedate' => '2024-01-05',
// 'expirydate' => '2025-01-05',
// 'vendor' => 'Summit Calibration Lab',
// 'description' => 'Annual calibration certificate for CL900i equipment.'
// ],
// [
// 'certid' => 'CERT028',
// 'certname' => 'CL900i Operator Training',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-028',
// 'type' => 'training',
// 'issuedate' => '2024-02-20',
// 'expirydate' => '2025-02-20',
// 'vendor' => 'External Training Institute',
// 'description' => 'Operator training completion certificate.'
// ],
// [
// 'certid' => 'CERT029',
// 'certname' => 'CL900i Maintenance Record',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-029',
// 'type' => 'maintenance',
// 'issuedate' => '2024-03-10',
// 'expirydate' => '2024-09-10',
// 'vendor' => 'Summit Service Team',
// 'description' => 'Regular maintenance record for CL900i equipment.'
// ],
// [
// 'certid' => 'CERT030',
// 'certname' => 'CL900i Calibration Certificate',
// 'productname' => 'CL900i',
// 'productnumber' => 'SN-2024-030',
// 'type' => 'calibration',
// 'issuedate' => '2024-04-25',
// 'expirydate' => '2025-04-25',
// 'vendor' => 'Summit Calibration Lab',
// 'description' => 'Annual calibration certificate for CL900i equipment.'
// ]
// ];
// foreach ($certificates as $cert) {
// if ($cert['certid'] === $certid) {
// return $this->response->setJSON($cert);
// }
// }
// return $this->response->setStatusCode(404)->setJSON(['error' => 'Certificate not found']);
// }
// Untuk Tampilan List Sertifikat
public function trainingIndex() {
$certificates = [
[
'certid' => 'CERT002',
'certname' => 'Jokoh Calibration Certificate',
'productname' => 'Jokoh',
'productnumber' => 'SN-2024-001',
'issuedate' => '2024-01-15',
'expirydate' => '2025-01-15',
'vendor' => 'Summit Calibration Lab'
]
];
$data = ['certificates' => $certificates];
return view('certificate_training_index', $data);
}
public function calibrateIndex() {
$certificates = [
[
'certid' => 'CERT001',
'certname' => 'TMS50i Calibration Certificate',
'productname' => 'tms50i',
'productnumber' => 'SN-2024-001',
'type' => 'calibration',
'issuedate' => '2024-01-15',
'expirydate' => '2025-01-15',
'vendor' => 'Summit Calibration Lab',
'description' => 'Annual calibration certificate for TMS50i equipment.'
],
[
'certid' => 'CERT002',
'certname' => 'TMS24i Calibration Certificate',
'productname' => 'tms24i',
'productnumber' => 'SN-2024-002',
'type' => 'calibration',
'issuedate' => '2024-01-16',
'expirydate' => '2025-01-16',
'vendor' => 'Summit Calibration Lab',
'description' => 'Annual calibration certificate for tms24i equipment.'
],
[
'certid' => 'CERT003',
'certname' => 'tms30i Calibration Certificate',
'productname' => 'tms30i',
'productnumber' => 'SN-2024-003',
'type' => 'calibration',
'issuedate' => '2024-01-17',
'expirydate' => '2025-01-17',
'vendor' => 'Summit Calibration Lab',
'description' => 'Annual calibration certificate for tms30i equipment.'
],
[
'certid' => 'CERT004',
'certname' => 'BS430 Calibration Certificate',
'productname' => 'bs430',
'productnumber' => 'SN-2024-004',
'type' => 'calibration',
'issuedate' => '2024-01-18',
'expirydate' => '2025-01-18',
'vendor' => 'Summit Calibration Lab',
'description' => 'Annual calibration certificate for BS430 equipment.'
],
[
'certid' => 'CERT005',
'certname' => 'CL900i Calibration Certificate',
'productname' => 'cl900i',
'productnumber' => 'SN-2024-005',
'type' => 'calibration',
'issuedate' => '2024-01-19',
'expirydate' => '2025-01-19',
'vendor' => 'Summit Calibration Lab',
'description' => 'Annual calibration certificate for CL900i equipment.'
],
[
'certid' => 'CERT006',
'certname' => 'Jokoh Calibration Certificate',
'productname' => 'jokoh',
'productnumber' => 'SN-2024-006',
'type' => 'calibration',
'issuedate' => '2024-01-20',
'expirydate' => '2025-01-20',
'vendor' => 'Summit Calibration Lab',
'description' => 'Annual calibration certificate for Jokoh equipment.'
],
[
'certid' => 'CERT007',
'certname' => 'BC760R Calibration Certificate',
'productname' => 'bc760r',
'productnumber' => 'SN-2024-007',
'type' => 'calibration',
'issuedate' => '2024-01-21',
'expirydate' => '2025-01-21',
'vendor' => 'Summit Calibration Lab',
'description' => 'Annual calibration certificate for BC760R equipment.'
],
[
'certid' => 'CERT008',
'certname' => 'BC5140 Calibration Certificate',
'productname' => 'bc5140',
'productnumber' => 'SN-2024-008',
'type' => 'calibration',
'issuedate' => '2024-01-22',
'expirydate' => '2025-01-22',
'vendor' => 'Summit Calibration Lab',
'description' => 'Annual calibration certificate for BC5140 equipment.'
],
];
$data = ['certificates' => $certificates];
return view('certificate_calibration_index', $data);
}
public function maintenanceIndex() {
$certificates = [
[
'certid' => 'CERT001',
'certname' => 'Jokoh Calibration Certificate',
'productname' => 'Jokoh',
'productnumber' => 'SN-2024-001',
'issuedate' => '2024-01-15',
'expirydate' => '2025-01-15',
'vendor' => 'Summit Calibration Lab'
]
];
$data = ['certificates' => $certificates];
return view('certificate_maintenance_index', $data);
}
public function createTraining($certid = null) {
if (!$certid) {
return $this->response->setStatusCode(400)->setJSON(['error' => 'Certificate ID is required']);
}
// Get certificate data
$certificates = [
[
'certid' => 'CERT002',
'certname' => 'Jokoh Training Certificate',
'productname' => 'Jokoh',
'productnumber' => 'SN-2024-001',
'issuedate' => '2024-01-15',
'expirydate' => '2025-01-15',
'vendor' => 'Summit Calibration Lab'
]
];
$certificate = null;
foreach ($certificates as $cert) {
if ($cert['certid'] === $certid) {
$certificate = $cert;
break;
}
}
if (!$certificate) {
return $this->response->setStatusCode(404)->setJSON(['error' => 'Training certificate not found']);
}
// Generate PDF
return $this->generatePDF($certificate, 'training');
}
public function createCalibrate($certid = null, $productname = null) {
if (!$certid) {
return $this->response->setStatusCode(400)->setJSON(['error' => 'Certificate ID is required']);
}
// Get certificate data
$certificates = [
[
'certid' => 'CERT001',
'certname' => 'TMS50i Calibration Certificate',
'productname' => 'tms50i',
'productnumber' => 'SN-2024-001',
'type' => 'calibration',
'issuedate' => '2024-01-15',
'expirydate' => '2025-01-15',
'vendor' => 'Summit Calibration Lab',
'description' => 'Annual calibration certificate for TMS50i equipment.'
],
[
'certid' => 'CERT002',
'certname' => 'tms24i Calibration Certificate',
'productname' => 'tms24i',
'productnumber' => 'SN-2024-002',
'type' => 'calibration',
'issuedate' => '2024-01-16',
'expirydate' => '2025-01-16',
'vendor' => 'Summit Calibration Lab',
'description' => 'Annual calibration certificate for tms24i equipment.'
],
[
'certid' => 'CERT003',
'certname' => 'tms30i Calibration Certificate',
'productname' => 'tms30i',
'productnumber' => 'SN-2024-003',
'type' => 'calibration',
'issuedate' => '2024-01-17',
'expirydate' => '2025-01-17',
'vendor' => 'Summit Calibration Lab',
'description' => 'Annual calibration certificate for tms30i equipment.'
],
[
'certid' => 'CERT004',
'certname' => 'BS430 Calibration Certificate',
'productname' => 'bs430',
'productnumber' => 'SN-2024-004',
'type' => 'calibration',
'issuedate' => '2024-01-18',
'expirydate' => '2025-01-18',
'vendor' => 'Summit Calibration Lab',
'description' => 'Annual calibration certificate for BS430 equipment.'
],
[
'certid' => 'CERT005',
'certname' => 'CL900i Calibration Certificate',
'productname' => 'cl900i',
'productnumber' => 'SN-2024-005',
'type' => 'calibration',
'issuedate' => '2024-01-19',
'expirydate' => '2025-01-19',
'vendor' => 'Summit Calibration Lab',
'description' => 'Annual calibration certificate for CL900i equipment.'
],
[
'certid' => 'CERT006',
'certname' => 'Jokoh Calibration Certificate',
'productname' => 'jokoh',
'productnumber' => 'SN-2024-006',
'type' => 'calibration',
'issuedate' => '2024-01-20',
'expirydate' => '2025-01-20',
'vendor' => 'Summit Calibration Lab',
'description' => 'Annual calibration certificate for Jokoh equipment.'
],
[
'certid' => 'CERT007',
'certname' => 'BC760R Calibration Certificate',
'productname' => 'bc760r',
'productnumber' => 'SN-2024-007',
'type' => 'calibration',
'issuedate' => '2024-01-21',
'expirydate' => '2025-01-21',
'vendor' => 'Summit Calibration Lab',
'description' => 'Annual calibration certificate for BC760R equipment.'
],
[
'certid' => 'CERT008',
'certname' => 'BC5140 Calibration Certificate',
'productname' => 'bc5140',
'productnumber' => 'SN-2024-008',
'type' => 'calibration',
'issuedate' => '2024-01-22',
'expirydate' => '2025-01-22',
'vendor' => 'Summit Calibration Lab',
'description' => 'Annual calibration certificate for BC5140 equipment.'
],
];
$certificate = null;
foreach ($certificates as $cert) {
if ($cert['certid'] === $certid) {
$certificate = $cert;
break;
}
}
if (!$certificate) {
return $this->response->setStatusCode(404)->setJSON(['error' => 'Calibration certificate not found']);
}
// Generate PDF
return $this->generatePDF($certificate, 'calibration', $productname);
}
public function createMaintenance($certid = null) {
if (!$certid) {
return $this->response->setStatusCode(400)->setJSON(['error' => 'Certificate ID is required']);
}
// Get certificate data
$certificates = [
[
'certid' => 'CERT001',
'certname' => 'Jokoh Calibration Certificate',
'productname' => 'Jokoh',
'productnumber' => 'SN-2024-001',
'issuedate' => '2024-01-15',
'expirydate' => '2025-01-15',
'vendor' => 'Summit Calibration Lab'
]
];
$certificate = null;
foreach ($certificates as $cert) {
if ($cert['certid'] === $certid) {
$certificate = $cert;
break;
}
}
if (!$certificate) {
return $this->response->setStatusCode(404)->setJSON(['error' => 'Maintenance certificate not found']);
}
// dd($certificate);
// Generate PDF
return $this->generatePDF($certificate, 'maintenance');
}
// Digunakan Untuk Generate PDF Show
private function generatePDF($certificate, $type, $productType=null) {
// Generate PDF
$options = new Options();
$options->set('isRemoteEnabled', true);
$options->set('isHtml5ParserEnabled', true);
// $options->set('defaultFont', 'Playfair Display');
$dompdf = new Dompdf($options);
// Format dates
$issuedate = date('F d, Y', strtotime($certificate['issuedate']));
$expirydate = date('F d, Y', strtotime($certificate['expirydate']));
// Get status
$today = date('Y-m-d');
$expiryCheck = date('Y-m-d', strtotime($certificate['expirydate']));
$daysUntilExpiry = (strtotime($expiryCheck) - strtotime($today)) / (60 * 60 * 24);
if ($daysUntilExpiry < 0) {
$status = 'Expired';
$statusColor = '#dc3545';
} elseif ($daysUntilExpiry <= 30) {
$status = 'Expiring Soon';
$statusColor = '#ffc107';
} else {
$status = 'Active';
$statusColor = '#28a745';
}
// Select template and orientation based on type
$template = 'certificate_pdf';
$orientation = 'portrait';
switch($type) {
case 'training':
$template = 'certificates/certificate_training';
$orientation = 'landscape';
break;
case 'calibration':
if ($productType == 'tms50i') {
$template = 'certificates/callibrations_template/certificate_tms50i_calibration';
} else if ($productType == 'tms24i') {
$template = 'certificates/callibrations_template/certificate_tms24i_calibration';
} else if ($productType == 'tms30i') {
$template = 'certificates/callibrations_template/certificate_tms30i_calibration';
} else if ($productType == 'bs430') {
$template = 'certificates/callibrations_template/certificate_bs430_calibration';
} else if ($productType == 'cl900i') {
$template = 'certificates/callibrations_template/certificate_cl900i_calibration';
} else if ($productType == 'jokoh') {
$template = 'certificates/callibrations_template/certificate_jokoh_calibration';
} else if ($productType == 'bc760r') {
$template = 'certificates/callibrations_template/certificate_bc760r_calibration';
} else if ($productType == 'bc5140') {
$template = 'certificates/callibrations_template/certificate_bc5140_calibration';
} else {
return $this->response->setStatusCode(404)->setJSON(['error' => 'Not Found']);
}
$orientation = 'portrait';
break;
case 'maintenance':
$template = 'certificates/certificate_maintenance';
$orientation = 'landscape';
break;
}
$html = view($template, [
'certificate' => $certificate,
'issuedate' => $issuedate,
'expirydate' => $expirydate,
'status' => $status,
'statusColor' => $statusColor
]);
$dompdf->loadHtml($html);
// $dompdf->set_option('isRemoteEnabled', true);
$dompdf->setPaper('A4', $orientation);
$dompdf->render();
// Output PDF
$filename = 'Certificate_' . $certificate['certid'] . '.pdf';
$dompdf->stream($filename, ['Attachment' => false]);
}
}