Add MCU report template mapping flow

This commit is contained in:
sas.fajri
2026-04-29 15:38:26 +07:00
parent 6ae695d053
commit 37dea1f398
4 changed files with 177 additions and 11 deletions

View File

@@ -1,7 +1,44 @@
<?php
class Setupmcucponev7 extends MY_Controller
{
var $db_onedev;
class Setupmcucponev7 extends MY_Controller
{
var $db_onedev;
private function resolve_report_template_id($prm)
{
if (isset($prm['Mcu_ReportUrlTemplateID'])) {
if (is_array($prm['Mcu_ReportUrlTemplateID']) && isset($prm['Mcu_ReportUrlTemplateID']['id'])) {
return intval($prm['Mcu_ReportUrlTemplateID']['id']);
}
return intval($prm['Mcu_ReportUrlTemplateID']);
}
return 0;
}
private function upsert_mgm_mcureport($mgmMcuID, $templateID, $userID)
{
$mgmMcuID = intval($mgmMcuID);
$templateID = intval($templateID);
$userID = intval($userID);
if ($mgmMcuID <= 0 || $templateID <= 0) {
return;
}
$sql = "INSERT INTO mgm_mcureport (
Mgm_McuReportMgm_McuID,
Mgm_McuReportMcu_ReportUrlTemplateID,
Mgm_McuReportIsActive,
Mgm_McuReportCreated,
Mgm_McuReportCreatedUserID,
Mgm_McuReportLastUpdated,
Mgm_McuReportLastUpdatedUserID
) VALUES (?, ?, 'Y', NOW(), ?, NOW(), ?)
ON DUPLICATE KEY UPDATE
Mgm_McuReportMcu_ReportUrlTemplateID = VALUES(Mgm_McuReportMcu_ReportUrlTemplateID),
Mgm_McuReportIsActive = 'Y',
Mgm_McuReportLastUpdated = NOW(),
Mgm_McuReportLastUpdatedUserID = VALUES(Mgm_McuReportLastUpdatedUserID)";
$this->db_onedev->query($sql, array($mgmMcuID, $templateID, $userID, $userID));
}
public function index()
{
echo "Patient API";
@@ -861,9 +898,10 @@ class Setupmcucponev7 extends MY_Controller
// $Mgm_McuTotalParticipant = $prm['Mgm_McuTotalParticipant'];
$Mgm_McuTotalParticipant = 0;
$Mgm_McuT_PriceHeaderID = $prm['Mgm_McuT_PriceHeaderID'];
$Mgm_McuM_BranchID = $prm['Mgm_McuM_BranchID'];
$Mgm_McuReportHasil = $prm['Mgm_McuReportHasil'];
$Mgm_McuGeneratePasswordBY = $prm['Mgm_McuGeneratePasswordBY'];
$Mgm_McuM_BranchID = $prm['Mgm_McuM_BranchID'];
$Mgm_McuReportHasil = $prm['Mgm_McuReportHasil'];
$Mcu_ReportUrlTemplateID = $this->resolve_report_template_id($prm);
$Mgm_McuGeneratePasswordBY = $prm['Mgm_McuGeneratePasswordBY'];
$cover = isset($prm['cover']) ? $prm['cover'] : ['code' => 'DFLT', 'name' => 'Cover Default'];
$background = isset($prm['background']) ? $prm['background'] : ['code' => 'DFLT', 'name' => 'Background Default', 'image' => 'one-ui/BackgroundWesterindo.png'];
@@ -958,7 +996,8 @@ class Setupmcucponev7 extends MY_Controller
$this->sys_error_db("mgm_mcu insert", $this->db_onedev);
exit;
}
$last_id = $this->db_onedev->insert_id();
$last_id = $this->db_onedev->insert_id();
$this->upsert_mgm_mcureport($last_id, $Mcu_ReportUrlTemplateID, $userid);
@@ -1090,7 +1129,8 @@ class Setupmcucponev7 extends MY_Controller
// check data password for update
// check paket exists or not
$last_id = $prm["xid"];
$last_id = $prm["xid"];
$this->upsert_mgm_mcureport($last_id, $Mcu_ReportUrlTemplateID, $userid);
$sql = "SELECT *
FROM mgm_mcu

View File

@@ -54,7 +54,7 @@ class Resumeindividucponev7 extends MY_Controller
Published_McuDasboardLastUpdatedUserID = VALUES(Published_McuDasboardLastUpdatedUserID)";
$this->db_onedev->query($sql, array($orderID, $userID, $userID));
}
public function getsetup()
public function getsetup()
{
try {
// if (!$this->isLogin) {
@@ -78,8 +78,68 @@ class Resumeindividucponev7 extends MY_Controller
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
}
}
function get_report_mcu()
{
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$mgmMcuID = 0;
if (isset($prm['Mgm_McuID'])) {
$mgmMcuID = intval($prm['Mgm_McuID']);
} else if (isset($prm['setupID'])) {
$mgmMcuID = intval($prm['setupID']);
}
if ($mgmMcuID <= 0) {
$this->sys_error("Mgm_McuID is required");
exit;
}
$sql = "SELECT
t.Mcu_ReportUrlTemplateID AS id,
t.Mcu_ReportUrlTemplateName AS reportName,
t.Mcu_ReportUrlTemplateType AS reportType,
t.Mcu_ReportUrlTemplateUrl AS reportUrl,
t.Mcu_ReportUrlTemplateParams AS reportParams,
IF(mr.Mgm_McuReportMcu_ReportUrlTemplateID = t.Mcu_ReportUrlTemplateID, 'Y', 'N') AS selected
FROM mcu_report_url_template t
LEFT JOIN mgm_mcureport mr
ON mr.Mgm_McuReportMcu_ReportUrlTemplateID = t.Mcu_ReportUrlTemplateID
AND mr.Mgm_McuReportMgm_McuID = ?
AND mr.Mgm_McuReportIsActive = 'Y'
WHERE t.Mcu_ReportUrlTemplateIsActive = 'Y'
ORDER BY t.Mcu_ReportUrlTemplateName ASC";
$query = $this->db_onedev->query($sql, array($mgmMcuID));
if (!$query) {
$message = $this->db_onedev->error();
$message['qry'] = $this->db_onedev->last_query();
$this->sys_error($message);
exit;
}
$rows = $query->result_array();
$selected = null;
foreach ($rows as $row) {
if ($row['selected'] === 'Y') {
$selected = $row;
break;
}
}
$result = array(
"total" => count($rows),
"records" => $rows,
"selected" => $selected
);
$this->sys_ok($result);
exit;
}
function search()
{
if (!$this->isLogin) {