diff --git a/application/config/routes.php b/application/config/routes.php index 02fa61cc..ef6357f6 100755 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -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'; diff --git a/application/controllers/tools/Merge_report.php b/application/controllers/tools/Merge_report.php index 754ebbaa..0dad91a7 100644 --- a/application/controllers/tools/Merge_report.php +++ b/application/controllers/tools/Merge_report.php @@ -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');