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:
@@ -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';
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user