Files
BE_IBL/application/libraries/Reporturl.php
2026-04-15 15:16:12 +07:00

139 lines
16 KiB
PHP

<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Reporturl
{
function __construct(){
$CI = &get_instance();
$this->db = $CI->load->database("onedev", true);
}
function get_report_by_code($report_code, $params){
$sql = "SELECT *
FROM print_transaction
WHERE
Print_TransactionCode = ? ";
$qry = $this->db->query($sql, array(
$report_code
));
if (!$qry) {
return array(false, print_r($this->db->error(), true));
}
$rows_return = $qry->row_array();
return $rows_return;
}
function get_report_url_by_code($report_code, $params = array(), $show='N'){
$CI = &get_instance();
$this->db = $CI->load->database("onedev", true);
// Get report data by code
$report_data = $this->get_report_by_code($report_code, $params);
if (!$report_data || empty($report_data)) {
return array(false, "Report code not found: " . $report_code);
}
// Get URL template
$url_template = $report_data['Print_TransactionUrl'];
if (empty($url_template)) {
return array(false, "URL template is empty for report code: " . $report_code);
}
// Replace placeholders with actual parameter values
$final_url = $url_template;
foreach ($params as $param_key => $param_value) {
// Determine if value should be quoted (string) or not (numeric)
$replacement_value = is_numeric($param_value) ? $param_value : "'" . $param_value . "'";
// Replace placeholder in URL
$final_url = str_replace($param_key, $replacement_value, $final_url);
}
if($show == 'N'){
return array(true, $final_url);
}
else{
$final_url = 'http'.($_SERVER['HTTPS'] == 'on' ? 's' : '').'://'.$_SERVER['HTTP_HOST'].$final_url;
$response = file_get_contents($final_url);
header("Content-type: application/pdf");
header(
'Content-Disposition: inline; filename="' .
$output_file_name .
'"'
);
echo ($response);
}
}
/*
CREATE TABLE `print_transaction` (
`Print_TransactionID` int(11) NOT NULL AUTO_INCREMENT,
`Print_TransactionType` char(2) NOT NULL DEFAULT 'P' COMMENT 'P (paper), E (Email)',
`Print_TransactionCode` varchar(20) NOT NULL DEFAULT '',
`Print_TransactionName` varchar(150) NOT NULL DEFAULT '',
`Print_TransactionUrl` varchar(500) NOT NULL DEFAULT '',
`Print_TransactionParams` varchar(500) NOT NULL DEFAULT '',
`Print_TransactionCreated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`Print_TransactionCreatedUserID` int(11) NOT NULL DEFAULT 0,
`Print_TransactionLastUpdated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`Print_TransactionLastUpdatedUserID` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`Print_TransactionID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `print_transaction` (`Print_TransactionID`, `Print_TransactionType`, `Print_TransactionCode`, `Print_TransactionName`, `Print_TransactionUrl`, `Print_TransactionParams`, `Print_TransactionCreated`, `Print_TransactionCreatedUserID`, `Print_TransactionLastUpdated`, `Print_TransactionLastUpdatedUserID`) VALUES
(1, 'P', 'LAB-RESULT-P-01', 'Report hasil test lab untuk diprint', '/birt/frameset?__report=report/onelab/lab/rpt_test.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 09:26:48', 555, '0000-00-00 00:00:00', 0),
(2, 'P', 'LAB-RESULT-P-02', 'Report hasil test lab untuk diprint', '/birt/frameset?__report=report/onelab/lab/rpt_test_email.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '0000-00-00 00:00:00', 555, '0000-00-00 00:00:00', 0),
(3, 'P', 'LAB-RESULT-P-03', 'Report hasil test lab untuk diprint', '/birt/frameset?__report=report/onelab/lab/rpt_test_prev.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 10:32:54', 555, '0000-00-00 00:00:00', 0),
(4, 'P', 'LAB-RESULT-NP-01', 'Report hasil test lab tidak untuk diprint', '/birt/frameset?__report=report/onelab/lab/rpt_test_not_print.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 10:25:02', 555, '0000-00-00 00:00:00', 0),
(5, 'E', 'LAB-RESULT-NP-02', 'Report hasil test lab tidak untuk email', '/birt/frameset?__report=report/onelab/lab/rpt_test_email_not_print.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 10:25:51', 555, '0000-00-00 00:00:00', 0),
(6, 'P', 'LAB-RESULT-NP-03', 'Report hasil test lab tidak untuk diprint', '/birt/frameset?__report=report/onelab/lab/rpt_test_prev_not_print.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 10:25:51', 555, '0000-00-00 00:00:00', 0),
(7, 'P', 'LABEN-RESULT-P-01', 'Report hasil test lab untuk diprint versi inggris', '/birt/frameset?__report=report/onelab/lab/rpt_test_eng.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 10:32:09', 555, '0000-00-00 00:00:00', 0),
(8, 'E', 'LABEN-RESULT-P-02', 'Report hasil test lab untuk email versi inggris', '/birt/frameset?__report=report/onelab/lab/rpt_test_email_eng.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 10:34:57', 555, '0000-00-00 00:00:00', 0),
(9, 'P', 'LABEN-RESULT-P-03', 'Report hasil test lab untuk diprint versi inggris', '/birt/frameset?__report=report/onelab/lab/rpt_test_eng_prev.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 10:34:57', 555, '0000-00-00 00:00:00', 0),
(10, 'P', 'LABEN-RESULT-NP-01', 'Report hasil test lab tidak untuk diprint versi inggris', '/birt/frameset?__report=report/onelab/lab/rpt_test_not_print_eng.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 10:34:57', 555, '0000-00-00 00:00:00', 0),
(11, 'P', 'MIKROEN-RESULT-P-01', 'Report hasil test mikro untuk diprint versi inggris', '/birt/frameset?__report=report/onelab/lab/rpt_test_eng.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 10:34:57', 555, '0000-00-00 00:00:00', 0),
(12, 'E', 'MIKROEN-RESULT-P-02', 'Report hasil test mikro untuk email versi inggris', '/birt/frameset?__report=report/onelab/lab/rpt_test_email_eng.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 10:34:57', 555, '0000-00-00 00:00:00', 0),
(13, 'P', 'MIKROEN-RESULT-P-03', 'Report hasil test mikro untuk diprint versi inggris', '/birt/frameset?__report=report/onelab/lab/rpt_test_eng_prev.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 10:34:57', 555, '0000-00-00 00:00:00', 0),
(14, 'P', 'MIKROEN-RESULT-NP-01', 'Report hasil test mikro tidak untuk diprint versi inggris', '/birt/frameset?__report=report/onelab/lab/rpt_test_not_print_eng.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 10:34:57', 555, '0000-00-00 00:00:00', 0),
(45, 'P', 'PS-RESULT-P-01', 'Report hasil test preparasi sperma untuk diprint', '/birt/frameset?__report=report/onelab/lab/rpt_hasil_sperma.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(46, 'E', 'PS-RESULT-P-02', 'Report hasil test preparasi sperma untuk email', '/birt/frameset?__report=report/onelab/lab/rpt_hasil_sperma_email.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(47, 'P', 'PS-RESULT-NP-01', 'Report hasil test preparasi sperma tidak untuk diprint', '/birt/frameset?__report=report/onelab/lab/rpt_hasil_sperma_not_print.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(48, 'P', 'DFI-RESULT-P-01', 'Report hasil test dfi untuk diprint', '/birt/frameset?__report=report/onelab/lab/rpt_hasil_dfi.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(49, 'E', 'DFI-RESULT-P-02', 'Report hasil test dfi untuk email', '/birt/frameset?__report=report/onelab/lab/rpt_hasil_dfi_email.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(50, 'P', 'DFI-RESULT-NP-01', 'Report hasil test dfi tidak untuk diprint', '/birt/frameset?__report=report/onelab/lab/rpt_hasil_dfi_not_print.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(51, 'P', 'FNA-RESULT-P-01', 'Report hasil test fna untuk diprint', '/birt/frameset?__report=report/onelab/lab/rpt_hasil_fna.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(52, 'E', 'FNA-RESULT-P-02', 'Report hasil test fna untuk diprint', '/birt/frameset?__report=report/onelab/lab/rpt_hasil_fna_email.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(53, 'P', 'FNA-RESULT-NP-01', 'Report hasil test fna tidak untuk diprint', '/birt/frameset?__report=report/onelab/lab/rpt_hasil_fna_not_print.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(54, 'P', 'PA-RESULT-P-01', 'Report hasil test patologi anatomi untuk diprint', '/birt/frameset?__report=report/onelab/lab/rpt_patologi_anatomy.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(55, 'E', 'PA-RESULT-P-02', 'Report hasil test patologi anatomi untuk diprint', '/birt/frameset?__report=report/onelab/lab/rpt_patologi_anatomy_email.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(56, 'P', 'PA-RESULT-NP-01', 'Report hasil test patologi anatomi tidak untuk diprint', '/birt/frameset?__report=report/onelab/lab/rpt_patologi_anatomy_not_print.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(57, 'P', 'PAP-RESULT-P-01', 'Report hasil test pap smear untuk diprint', '/birt/frameset?__report=report/onelab/lab/rpt_hasil_papsmear.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(58, 'E', 'PAP-RESULT-P-02', 'Report hasil test pap smear untuk diprint', '/birt/frameset?__report=report/onelab/lab/rpt_hasil_papsmear_email.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(59, 'P', 'PAP-RESULT-NP-01', 'Report hasil test pap smear tidak untuk diprint', '/birt/frameset?__report=report/onelab/lab/rpt_hasil_papsmear_not_print.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(60, 'P', 'PAPLCP-RESULT-P-01', 'Report hasil test pap smear (liquid c prep) untuk diprint', '/birt/frameset?__report=report/onelab/lab/rpt_hasil_lcprep.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(61, 'E', 'PAPLCP-RESULT-P-02', 'Report hasil test pap smear (liquid c prep) untuk diprint', '/birt/frameset?__report=report/onelab/lab/rpt_hasil_lcprep_email.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(62, 'P', 'PAPLCP-RESULT-NP-01', 'Report hasil test pap smear (liquid c prep) tidak untuk diprint', '/birt/frameset?__report=report/onelab/lab/rpt_hasil_lcprep_not_print.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(63, 'P', 'PAPLEN-RESULT-P-01', 'Report hasil test pap smear (liquid c prep) untuk diprint versi inggris', '/birt/frameset?__report=report/onelab/lab/rpt_hasil_lcprep_eng.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(64, 'E', 'PAPLEN-RESULT-P-02', 'Report hasil test pap smear (liquid c prep) untuk diprint versi inggris', '/birt/frameset?__report=report/onelab/lab/rpt_hasil_lcprep_email_eng.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(65, 'P', 'PAPLEN-RESULT-NP-01', 'Report hasil test pap smear (liquid c prep) tidak untuk diprint versi inggris', '/birt/frameset?__report=report/onelab/lab/rpt_hasil_lcprep_not_print_eng.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(66, 'P', 'MIKRO-RESULT-P-01', 'Report hasil test mikro untuk diprint terlampir', '/birt/frameset?__report=report/onelab/lab/rpt_test_mikro.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(67, 'E', 'MIKRO-RESULT-P-02', 'Report hasil test mikro untuk email terlampir', '/birt/frameset?__report=report/onelab/lab/rpt_test_mikro_email.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(68, 'P', 'MIKRO-RESULT-NP-01', 'Report hasil test mikro tidak untuk diprint terlampir', '/birt/frameset?__report=report/onelab/lab/rpt_test_mikro_not_print.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(69, 'P', 'MIKROO-RESULT-P-01', 'Report hasil test mikro untuk diprint tidak terlampir', '/birt/frameset?__report=report/onelab/lab/rpt_test.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(70, 'E', 'MIKROO-RESULT-P-02', 'Report hasil test mikro untuk email tidak terlampir', '/birt/frameset?__report=report/onelab/lab/rpt_test_email.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(71, 'P', 'MIKROO-RESULT-NP-01', 'Report hasil test mikro untuk tidak diprint tidak terlampir', '/birt/frameset?__report=report/onelab/lab/rpt_test_not_print.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(72, 'P', 'CT-RESULT-P-01', 'Report hasil test citology untuk diprint', '/birt/frameset?__report=report/onelab/lab/rpt_hasil_cytologi.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(73, 'E', 'CT-RESULT-P-02', 'Report hasil test citology untuk email', '/birt/frameset?__report=report/onelab/lab/rpt_hasil_cytologi_email.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0),
(74, 'P', 'CT-RESULT-NP-01', 'Report hasil test citology untuk tidak diprint', '/birt/frameset?__report=report/onelab/lab/rpt_hasil_cytologi_not_print.rptdesign&__format=pdf&username=PUsername&PID=PT_OrderHeaderID&tm=TS', 'PUsername,PT_OrderHeaderID,TS', '2026-02-06 11:24:51', 555, '0000-00-00 00:00:00', 0);
-- 2026-02-06 06:35:26
*/
}