diff --git a/application/controllers/mockup/fo/ibl_registration/Order.php b/application/controllers/mockup/fo/ibl_registration/Order.php index 54e2061e..b8c4e573 100644 --- a/application/controllers/mockup/fo/ibl_registration/Order.php +++ b/application/controllers/mockup/fo/ibl_registration/Order.php @@ -1066,20 +1066,16 @@ class Order extends MY_Controller function get_inform_consent_by_order($order_id) { - $fallback = [ - 'type' => 'umum', - 'title' => '', - 'content' => '', - 'company_type_group_name' => '', - 'company_type_group_id' => 0 - ]; + $fallback = $this->get_inform_consent_template('umum'); + $fallback['company_type_group_name'] = ''; + $fallback['company_type_group_id'] = 0; $sql_group = "SELECT - IFNULL(g.M_CompanyTypeGroupID, 0) as company_type_group_id, + IFNULL(c.M_CompanyM_CompanyGroupTypeID, 0) as company_type_group_id, IFNULL(g.M_CompanyTypeGroupName, '') as company_type_group_name FROM t_orderheader h JOIN m_company c ON h.T_OrderHeaderM_CompanyID = c.M_CompanyID - LEFT JOIN m_companytypegroup g ON c.M_CompanyM_CompanyTypeGroupID = g.M_CompanyTypeGroupID + LEFT JOIN m_companytypegroup g ON c.M_CompanyM_CompanyGroupTypeID = g.M_CompanyTypeGroupID WHERE h.T_OrderHeaderID = ? LIMIT 1"; $query_group = $this->db_smartone->query($sql_group, [$order_id]); @@ -1092,8 +1088,8 @@ class Order extends MY_Controller return $fallback; } - $group_name = strtoupper(trim($dt_group['company_type_group_name'])); - $template_type = ($group_name === 'CPMI') ? 'cpmi' : 'umum'; + $group_type_id = intval($dt_group['company_type_group_id']); + $template_type = ($group_type_id === 8) ? 'cpmi' : 'umum'; $sql_template = "SELECT M_InformConsentType as type, @@ -1105,7 +1101,7 @@ class Order extends MY_Controller LIMIT 1"; $query_template = $this->db_smartone->query($sql_template, [$template_type]); if (!$query_template) { - $fallback['type'] = $template_type; + $fallback = $this->get_inform_consent_template($template_type); $fallback['company_type_group_name'] = $dt_group['company_type_group_name']; $fallback['company_type_group_id'] = intval($dt_group['company_type_group_id']); return $fallback; @@ -1113,7 +1109,7 @@ class Order extends MY_Controller $dt_template = $query_template->row_array(); if (!$dt_template) { - $fallback['type'] = $template_type; + $fallback = $this->get_inform_consent_template($template_type); $fallback['company_type_group_name'] = $dt_group['company_type_group_name']; $fallback['company_type_group_id'] = intval($dt_group['company_type_group_id']); return $fallback; @@ -1123,6 +1119,34 @@ class Order extends MY_Controller $dt_template['company_type_group_id'] = intval($dt_group['company_type_group_id']); return $dt_template; } + + function get_inform_consent_template($template_type) + { + $fallback = [ + 'type' => $template_type, + 'title' => '', + 'content' => '' + ]; + + $sql_template = "SELECT + M_InformConsentType as type, + M_InformConsentTitle as title, + M_InformConsentContent as content + FROM m_informconsent + WHERE M_InformConsentType = ? + AND M_InformConsentIsActive = 'Y' + LIMIT 1"; + $query_template = $this->db_smartone->query($sql_template, [$template_type]); + if (!$query_template) { + return $fallback; + } + + $dt_template = $query_template->row_array(); + if (!$dt_template) { + return $fallback; + } + return $dt_template; + }