FHM29052601IBL - add GET /report/qr/{id} preview endpoint dari qr_printout

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
sas.fajri
2026-05-29 16:33:00 +07:00
parent a3f9e04787
commit cf8ef0e590
2 changed files with 20 additions and 0 deletions

View File

@@ -52,4 +52,5 @@ defined('BASEPATH') OR exit('No direct script access allowed');
$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['report/qr/(:num)'] = 'tools/merge_report/preview_qr/$1';
$route['report/(:num)'] = 'tools/merge_report/preview/$1';

View File

@@ -12,6 +12,25 @@ class Merge_report extends MY_Controller {
$this->preview($id);
}
public function preview_qr($id = null) {
if ($id === null || !is_numeric($id)) {
header('Content-Type: application/json');
echo json_encode(['status' => 'ERR', 'message' => 'T_ORDER_HEADER_ID_INVALID - ID tidak valid.']);
return;
}
$result = $this->ibl_merge_report_gateway->stream_from_qr_printout((int) $id);
if ($result['status'] !== 'OK') {
header('Content-Type: application/json');
echo json_encode(['status' => 'ERR', 'message' => $result['code'] . ' - ' . $result['message']]);
return;
}
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="' . $result['data']['payload']['name'] . '"');
echo $result['data']['body'];
}
public function preview($id = null) {
if ($id === null || !is_numeric($id)) {
header('Content-Type: application/json');