'Enrollment open date (d-m-Y or d/m/Y)', '--close' => 'Enrollment close date (d-m-Y or d/m/Y)', ]; public function run(array $params) { helper('utility'); $openDate = CLI::getOption('open') ?? '01-07-2026'; $closeDate = CLI::getOption('close') ?? '31/07/2026'; $sample = ROOTPATH . 'public/sample_excel/enrollment.xlsx'; if (!is_file($sample)) { CLI::error('Sample file not found: ' . $sample); return; } require_once ROOTPATH . 'tests/_support/TestUploadedFile.php'; $db = Database::connect('default'); $row = $db->query( 'SELECT client_id, policy_id, client_branch_id, created_by FROM files WHERE client_id IS NOT NULL AND policy_id IS NOT NULL AND client_branch_id IS NOT NULL AND created_by IS NOT NULL ORDER BY id DESC LIMIT 1' )->getRowArray(); if (empty($row)) { CLI::error('No fixture row found in files table.'); return; } CLI::write('Input dates:', 'yellow'); CLI::write(" open : {$openDate}"); CLI::write(" close : {$closeDate}"); CLI::write('Converted:', 'yellow'); CLI::write(' open : ' . change_date_format($openDate, null, 'Y-m-d')); CLI::write(' close : ' . change_date_format($closeDate, null, 'Y-m-d')); $tmpPath = tempnam(sys_get_temp_dir(), 'enroll_manual_'); copy($sample, $tmpPath); $uploadedFile = new TestUploadedFile( $tmpPath, basename($sample), 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', filesize($tmpPath), UPLOAD_ERR_OK ); $postData = [ 'client_id' => (int) $row['client_id'], 'policy_id' => (int) $row['policy_id'], 'client_branch_id' => (int) $row['client_branch_id'], 'created_by' => (int) $row['created_by'], 'enrollment_open_date' => $openDate, 'enrollment_close_date' => $closeDate, 'emplist' => $uploadedFile, ]; $controller = new EmployeeController(); $result = $controller->employeesUplodWithEvents($postData); CLI::newLine(); CLI::write('Upload result:', 'green'); CLI::write(json_encode($result, JSON_PRETTY_PRINT)); if (empty($result['file_id'])) { return; } $file = $db->table('files')->where('id', $result['file_id'])->get()->getRowArray(); CLI::newLine(); CLI::write('DB record:', 'green'); CLI::write(json_encode([ 'id' => $file['id'] ?? null, 'file_name' => $file['file_name'] ?? null, 'action' => $file['action'] ?? null, 'status' => $file['status'] ?? null, 'enrollment_open_date' => $file['enrollment_open_date'] ?? null, 'enrollment_close_date' => $file['enrollment_close_date'] ?? null, ], JSON_PRETTY_PRINT)); } }