2410 lines
77 KiB
PHP
2410 lines
77 KiB
PHP
<?php
|
|
class Setupmcucpone extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "Patient API";
|
|
}
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_onedev = $this->load->database("onedev", true);
|
|
}
|
|
|
|
// cpone
|
|
public function searchv0()
|
|
{
|
|
$prm = $this->sys_input;
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
// $search = $prm['search'];
|
|
// if (isset($prm['search'])) {
|
|
// $search = trim($prm["search"]);
|
|
// if ($search != "") {
|
|
// $search = '%' . $prm['search'] . '%';
|
|
// }else{
|
|
// $search = '%%';
|
|
// }
|
|
// }
|
|
|
|
$limit = '';
|
|
$filter_paket = $prm['searchPacket'];
|
|
if($all == 'N'){
|
|
$limit = ' LIMIT 10';
|
|
}
|
|
$number_limit = 10;
|
|
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
|
$sql_where = "
|
|
WHERE (
|
|
Mgm_McuNumber LIKE '%{$prm['search']}%'
|
|
OR CorporateName LIKE '%{$prm['search']}%'
|
|
OR Mgm_McuLabel LIKE '%{$prm['search']}%'
|
|
)";
|
|
|
|
$sql = "SELECT COUNT(*) AS total
|
|
FROM (
|
|
SELECT mgm.Mgm_McuID
|
|
FROM mgm_mcu mgm
|
|
LEFT JOIN corporate corp
|
|
ON mgm.Mgm_McuCorporateID = corp.CorporateID
|
|
AND corp.CorporateIsActive = 'Y'
|
|
AND mgm.Mgm_McuIsActive = 'Y'
|
|
JOIN t_priceheader price
|
|
ON mgm.Mgm_McuT_PriceHeaderID = price.T_PriceHeaderID
|
|
AND price.T_PriceHeaderIsActive = 'Y'
|
|
JOIN mgm_mcupacket packet
|
|
ON mgm.Mgm_McuID = packet.Mgm_McuPacketMgm_McuID
|
|
AND packet.Mgm_McuPacketIsActive = 'Y'
|
|
LEFT JOIN mgm_mcutemplate template
|
|
ON mgm.Mgm_McuID = template.Mgm_McuTemplateMgm_McuID
|
|
AND template.Mgm_McuTemplateIsActive = 'Y'
|
|
LEFT JOIN fisik_template_mapping fisik
|
|
ON template.Mgm_McuTemplateFisikTemplateMappingID = fisik.FisikTemplateMappingID
|
|
AND fisik.FisikTemplateMappingIsActive = 'Y'
|
|
$sql_where
|
|
GROUP BY mgm.Mgm_McuID
|
|
) subquery;";
|
|
|
|
$sql_param = array();
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
$tot_count = 0;
|
|
$tot_page = 0;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
$tot_page = ceil($tot_count/$number_limit);
|
|
} else {
|
|
$this->sys_error_db("mgmmcu count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
// sql data
|
|
$sql = "SELECT
|
|
-- mgm_mcu
|
|
IFNULL(mgm.Mgm_McuID, 0) AS Mgm_McuID,
|
|
IFNULL(mgm.Mgm_McuLabel, '') AS Mgm_McuLabel,
|
|
-- IFNULL(mgm.Mgm_McuFlagRelasiBayarSendiri, '') AS Mgm_McuFlagRelasiBayarSendiri,
|
|
-- IFNULL(mgm.Mgm_McuBisaTambahPemeriksaan, '') AS Mgm_McuBisaTambahPemeriksaan,
|
|
mgm.Mgm_McuFlagRelasiBayarSendiri,
|
|
mgm.Mgm_McuBisaTambahPemeriksaan,
|
|
IFNULL(mgm.Mgm_McuCorporateID, 0) AS Mgm_McuCorporateID,
|
|
IFNULL(mgm.Mgm_McuNumber, '') AS Mgm_McuNumber,
|
|
IFNULL(mgm.Mgm_McuNumberNational, '') AS Mgm_McuNumberNational,
|
|
IFNULL(mgm.Mgm_McuNote, '') AS Mgm_McuNote,
|
|
IFNULL(mgm.Mgm_McuStartDate, '0000-00-00') AS Mgm_McuStartDate,
|
|
IFNULL(mgm.Mgm_McuEndDate, '0000-00-00') AS Mgm_McuEndDate,
|
|
IFNULL(DATE_FORMAT(mgm.Mgm_McuStartDate, '%d-%m-%Y'), '00-00-0000') AS Mgm_McuStartDateTxt,
|
|
IFNULL(DATE_FORMAT(mgm.Mgm_McuEndDate, '%d-%m-%Y'), '00-00-0000') AS Mgm_McuEndDateTxt,
|
|
IFNULL(mgm.Mgm_McuIsActive, '') AS Mgm_McuIsActive,
|
|
IFNULL(mgm.Mgm_McuTotalParticipant, 0) AS Mgm_McuTotalParticipant,
|
|
IFNULL(mgm.Mgm_McuPicEmail, '') AS Mgm_McuPicEmail,
|
|
IFNULL(mgm.Mgm_McuPicPassword, '') AS Mgm_McuPicPassword,
|
|
IFNULL(mgm.Mgm_McuT_PriceHeaderID, 0) AS Mgm_McuT_PriceHeaderID,
|
|
-- corporate
|
|
IFNULL(corp.CorporateID, 0) AS CorporateID,
|
|
IFNULL(corp.CorporateCode, '') AS CorporateCode,
|
|
IFNULL(corp.CorporateName, '') AS CorporateName,
|
|
IFNULL(corp.CorporateAddress, '') AS CorporateAddress,
|
|
IFNULL(corp.CorporateAddressRegionalCd, '') AS CorporateAddressRegionalCd,
|
|
IFNULL(corp.CorporateAddressRT, '') AS CorporateAddressRT,
|
|
IFNULL(corp.CorporateAddressRW, '') AS CorporateAddressRW,
|
|
IFNULL(corp.CorporateAddressVillage, '') AS CorporateAddressVillage,
|
|
IFNULL(corp.CorporateAddressDistrict, '') AS CorporateAddressDistrict,
|
|
IFNULL(corp.CorporateAddressCity, '') AS CorporateAddressCity,
|
|
IFNULL(corp.CorporateAddressState, '') AS CorporateAddressState,
|
|
IFNULL(corp.CorporateAddressCountry, '') AS CorporateAddressCountry,
|
|
IFNULL(corp.CorporateEmail, '') AS CorporateEmail,
|
|
IFNULL(corp.CorporatePhone, '') AS CorporatePhone,
|
|
IFNULL(corp.CorporatePICName, '') AS CorporatePICName,
|
|
IFNULL(corp.CorporatePICEmail, '') AS CorporatePICEmail,
|
|
IFNULL(corp.CorporatePICPhone, '') AS CorporatePICPhone,
|
|
IFNULL(corp.CorporateFlagHolding, '') AS CorporateFlagHolding,
|
|
IFNULL(corp.CorporateHoldingCorporateID, 0) AS CorporateHoldingCorporateID,
|
|
IFNULL(corp.CorporateRelationCorporateID, 0) AS CorporateRelationCorporateID,
|
|
IFNULL(corp.CorporatePICBillName, '') AS CorporatePICBillName,
|
|
IFNULL(corp.CorporatePICBillEmail, '') AS CorporatePICBillEmail,
|
|
IFNULL(corp.CorporatePICBillPhone, '') AS CorporatePICBillPhone,
|
|
IFNULL(corp.CorporateDueDate, 0) AS CorporateDueDate,
|
|
IFNULL(corp.CorporateFlagJPA, '') AS CorporateFlagJPA,
|
|
IFNULL(corp.CorporateUsername, '') AS CorporateUsername,
|
|
IFNULL(corp.CorporatePassword, '') AS CorporatePassword,
|
|
IFNULL(corp.CorporateIsActive, '') AS CorporateIsActive,
|
|
-- t_priceheader
|
|
IFNULL(price.T_PriceHeaderID, 0) AS T_PriceHeaderID,
|
|
IFNULL(price.T_PriceHeaderName, '') AS T_PriceHeaderName,
|
|
IFNULL(price.T_PriceHeaderStartDate, '0000-00-00') AS T_PriceHeaderStartDate,
|
|
IFNULL(price.T_PriceHeaderEndDate, '0000-00-00') AS T_PriceHeaderEndDate,
|
|
IFNULL(price.T_PriceHeaderIsActive, '') AS T_PriceHeaderIsActive,
|
|
-- mgm_mcupacket
|
|
IFNULL(packet.Mgm_McuPacketID, 0) AS Mgm_McuPacketID,
|
|
IFNULL(packet.Mgm_McuPacketT_PacketID, 0) AS Mgm_McuPacketT_PacketID,
|
|
IFNULL(packet.Mgm_McuPacketIsActive, '') AS Mgm_McuPacketIsActive,
|
|
IFNULL(template.Mgm_McuTemplateID, 0) AS Mgm_McuTemplateID,
|
|
IFNULL(template.Mgm_McuTemplateFisikTemplateMappingID, 0) AS Mgm_McuTemplateFisikTemplateMappingID,
|
|
IFNULL(template.Mgm_McuTemplateIsActive, '') AS Mgm_McuTemplateIsActive,
|
|
-- fisik_template_mapping
|
|
IFNULL(fisik.FisikTemplateMappingID, 0) AS FisikTemplateMappingID,
|
|
IFNULL(fisik.FisikTemplateMappingName, '') AS FisikTemplateMappingName,
|
|
IFNULL(fisik.FisikTemplateMappingIsActive, '') AS FisikTemplateMappingIsActive,
|
|
IFNULL(fisik.FisikTemplateMappingCreated, '0000-00-00 00:00:00') AS FisikTemplateMappingCreated,
|
|
IFNULL(fisik.FisikTemplateMappingCreatedUserID, 0) AS FisikTemplateMappingCreatedUserID,
|
|
IFNULL(fisik.FisikTemplateMappingLastUpdated, '0000-00-00 00:00:00') AS FisikTemplateMappingLastUpdated,
|
|
IFNULL(fisik.FisikTemplateMappingLastUpdatedUserID, 0) AS FisikTemplateMappingLastUpdatedUserID,
|
|
IFNULL(fisik.FisikTemplateMappingDeleted, '0000-00-00 00:00:00') AS FisikTemplateMappingDeleted,
|
|
IFNULL(fisik.FisikTemplateMappingDeletedUserID, 0) AS FisikTemplateMappingDeletedUserID,
|
|
'' as packets
|
|
FROM mgm_mcu mgm
|
|
left join corporate corp
|
|
ON mgm.Mgm_McuCorporateID = corp.CorporateID
|
|
AND corp.CorporateIsActive = 'Y'
|
|
AND mgm.Mgm_McuIsActive = 'Y'
|
|
JOIN t_priceheader price
|
|
ON mgm.Mgm_McuT_PriceHeaderID = price.T_PriceHeaderID
|
|
AND price.T_PriceHeaderIsActive = 'Y'
|
|
JOIN mgm_mcupacket packet
|
|
ON mgm.Mgm_McuID = packet.Mgm_McuPacketMgm_McuID
|
|
AND packet.Mgm_McuPacketIsActive = 'Y'
|
|
LEFT JOIN mgm_mcutemplate template
|
|
ON mgm.Mgm_McuID = template.Mgm_McuTemplateMgm_McuID
|
|
AND template.Mgm_McuTemplateIsActive = 'Y'
|
|
LEFT JOIN fisik_template_mapping fisik
|
|
ON template.Mgm_McuTemplateFisikTemplateMappingID = fisik.FisikTemplateMappingID
|
|
AND fisik.FisikTemplateMappingIsActive = 'Y'
|
|
$sql_where
|
|
GROUP BY mgm.Mgm_McuID
|
|
ORDER BY mgm.Mgm_McuID DESC
|
|
limit $number_limit offset $number_offset
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
if ($query === false) {
|
|
// If query failed, log the error and exit
|
|
$this->sys_error_db("select mgmmcu data", $this->db_onedev);
|
|
exit;
|
|
}
|
|
$rows = $query->result_array();
|
|
|
|
if(count($rows) > 0) {
|
|
foreach($rows as $k => $v){
|
|
$rows[$k]['packets'] = array();
|
|
// query dapatkan paket
|
|
$sql_paket = "SELECT group_concat(Mgm_McuPacketT_PacketID) as Mgm_McuPacketT_PacketID
|
|
from mgm_mcupacket
|
|
WHERE Mgm_McuPacketMgm_McuID = {$v['Mgm_McuID']}
|
|
AND Mgm_McuPacketIsActive = 'Y'";
|
|
|
|
$query_paket = $this->db_onedev->query($sql_paket);
|
|
if (!$query_paket) {
|
|
// If query failed, log the error and exit
|
|
$this->sys_error_db("select mgmmcu data", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$row_paket = $query_paket->row_array();
|
|
|
|
$where_in_T_PacketID = "AND T_PacketID IN ({$row_paket['Mgm_McuPacketT_PacketID']})";
|
|
|
|
// $where_in_T_PacketID = "AND T_PacketID IN ('')";
|
|
// if($v['Mgm_McuPacketT_PacketID'] != ''){
|
|
// $xjoin_packets = explode(',',$v['Mgm_McuPacketT_PacketID']);
|
|
// //print_r($xjoin_packets);
|
|
// if($xjoin_packets){
|
|
// foreach($xjoin_packets as $kjt => $vjt){
|
|
// if($join_packet != '')
|
|
// $join_packet .= ",";
|
|
|
|
// $join_packet .= "'{$vjt}'";
|
|
|
|
// }
|
|
// }
|
|
|
|
// //echo $join_packet;
|
|
// $where_in_T_PacketID = "AND T_PacketID IN ({$join_packet})";
|
|
// }
|
|
|
|
$sql = "SELECT
|
|
T_PacketID as id,
|
|
T_PacketID,
|
|
T_PacketT_PriceHeaderID,
|
|
T_PacketSasCode,
|
|
T_PacketName,
|
|
T_PriceHeaderStartDate,
|
|
T_PriceHeaderEndDate,
|
|
T_PacketSasCode as code,
|
|
T_PacketName as name,
|
|
'Y' as T_PacketIsActive
|
|
from t_packet
|
|
join t_priceheader
|
|
ON T_PacketT_PriceHeaderID = T_PriceHeaderID
|
|
AND T_PacketIsActive = 'Y'
|
|
AND T_PriceHeaderIsActive = 'Y'
|
|
AND T_PacketT_PriceHeaderID = {$v['Mgm_McuT_PriceHeaderID']}
|
|
AND (
|
|
T_PacketSasCode LIKE '%$filter_paket%'
|
|
OR T_PacketName LIKE '%$filter_paket%'
|
|
)
|
|
$where_in_T_PacketID";
|
|
//echo $sql;
|
|
$qry_paket_data = $this->db_onedev->query($sql);
|
|
if(!$qry_paket_data){
|
|
$this->sys_error_db("select packet where in data", $this->db_onedev);
|
|
exit;
|
|
}
|
|
$datapaket = $qry_paket_data->result_array();
|
|
$dataNew = [];
|
|
|
|
if(count($datapaket) > 0){
|
|
foreach ($datapaket as $key => $vx) {
|
|
$dataNew[] = $vx;
|
|
}
|
|
}
|
|
|
|
// echo "datapaket\n";
|
|
// print_r($datapaket);
|
|
// echo "\ndataNew\n";
|
|
// print_r($dataNew);
|
|
|
|
$rows[$k]['packets'] = $dataNew;
|
|
// $rows[$k]['packets'] = $this->db_onedev->query($sql)->result_array();
|
|
}
|
|
}
|
|
|
|
$result = array(
|
|
"total" => $tot_page,
|
|
"records" => $rows,
|
|
"sql"=> $this->db_onedev->last_query()
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
public function searchv0x1()
|
|
{
|
|
$prm = $this->sys_input;
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
// $search = $prm['search'];
|
|
// if (isset($prm['search'])) {
|
|
// $search = trim($prm["search"]);
|
|
// if ($search != "") {
|
|
// $search = '%' . $prm['search'] . '%';
|
|
// }else{
|
|
// $search = '%%';
|
|
// }
|
|
// }
|
|
|
|
$limit = '';
|
|
$filter_paket = $prm['searchPacket'];
|
|
if($all == 'N'){
|
|
$limit = ' LIMIT 10';
|
|
}
|
|
$number_limit = 10;
|
|
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
|
$sql_where = "
|
|
WHERE (
|
|
Mgm_McuNumber LIKE '%{$prm['search']}%'
|
|
OR CorporateName LIKE '%{$prm['search']}%'
|
|
OR Mgm_McuLabel LIKE '%{$prm['search']}%'
|
|
)";
|
|
|
|
$sql = "SELECT count(*) as total
|
|
FROM mgm_mcu mgm
|
|
left join corporate corp
|
|
ON mgm.Mgm_McuCorporateID = corp.CorporateID
|
|
AND corp.CorporateIsActive = 'Y'
|
|
AND mgm.Mgm_McuIsActive = 'Y'
|
|
JOIN t_priceheader price
|
|
ON mgm.Mgm_McuT_PriceHeaderID = price.T_PriceHeaderID
|
|
AND price.T_PriceHeaderIsActive = 'Y'
|
|
JOIN mgm_mcupacket packet
|
|
ON mgm.Mgm_McuID = packet.Mgm_McuPacketMgm_McuID
|
|
AND packet.Mgm_McuPacketIsActive = 'Y'
|
|
LEFT JOIN mgm_mcutemplate template
|
|
ON mgm.Mgm_McuID = template.Mgm_McuTemplateMgm_McuID
|
|
AND template.Mgm_McuTemplateIsActive = 'Y'
|
|
LEFT JOIN fisik_template_mapping fisik
|
|
ON template.Mgm_McuTemplateFisikTemplateMappingID = fisik.FisikTemplateMappingID
|
|
AND fisik.FisikTemplateMappingIsActive = 'Y'
|
|
$sql_where
|
|
GROUP BY mgm.Mgm_McuID
|
|
";
|
|
|
|
$sql_param = array();
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
$tot_count = 0;
|
|
$tot_page = 0;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
$tot_page = ceil($tot_count/$number_limit);
|
|
} else {
|
|
$this->sys_error_db("mgmmcu count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
// sql data
|
|
$sql = "SELECT
|
|
-- mgm_mcu
|
|
IFNULL(mgm.Mgm_McuID, 0) AS Mgm_McuID,
|
|
IFNULL(mgm.Mgm_McuLabel, '') AS Mgm_McuLabel,
|
|
-- IFNULL(mgm.Mgm_McuFlagRelasiBayarSendiri, '') AS Mgm_McuFlagRelasiBayarSendiri,
|
|
-- IFNULL(mgm.Mgm_McuBisaTambahPemeriksaan, '') AS Mgm_McuBisaTambahPemeriksaan,
|
|
mgm.Mgm_McuFlagRelasiBayarSendiri,
|
|
mgm.Mgm_McuBisaTambahPemeriksaan,
|
|
IFNULL(mgm.Mgm_McuCorporateID, 0) AS Mgm_McuCorporateID,
|
|
IFNULL(mgm.Mgm_McuNumber, '') AS Mgm_McuNumber,
|
|
IFNULL(mgm.Mgm_McuNumberNational, '') AS Mgm_McuNumberNational,
|
|
IFNULL(mgm.Mgm_McuNote, '') AS Mgm_McuNote,
|
|
IFNULL(mgm.Mgm_McuStartDate, '0000-00-00') AS Mgm_McuStartDate,
|
|
IFNULL(mgm.Mgm_McuEndDate, '0000-00-00') AS Mgm_McuEndDate,
|
|
IFNULL(DATE_FORMAT(mgm.Mgm_McuStartDate, '%d-%m-%Y'), '00-00-0000') AS Mgm_McuStartDateTxt,
|
|
IFNULL(DATE_FORMAT(mgm.Mgm_McuEndDate, '%d-%m-%Y'), '00-00-0000') AS Mgm_McuEndDateTxt,
|
|
IFNULL(mgm.Mgm_McuIsActive, '') AS Mgm_McuIsActive,
|
|
IFNULL(mgm.Mgm_McuTotalParticipant, 0) AS Mgm_McuTotalParticipant,
|
|
IFNULL(mgm.Mgm_McuPicEmail, '') AS Mgm_McuPicEmail,
|
|
IFNULL(mgm.Mgm_McuPicPassword, '') AS Mgm_McuPicPassword,
|
|
IFNULL(mgm.Mgm_McuT_PriceHeaderID, 0) AS Mgm_McuT_PriceHeaderID,
|
|
-- corporate
|
|
IFNULL(corp.CorporateID, 0) AS CorporateID,
|
|
IFNULL(corp.CorporateCode, '') AS CorporateCode,
|
|
IFNULL(corp.CorporateName, '') AS CorporateName,
|
|
IFNULL(corp.CorporateAddress, '') AS CorporateAddress,
|
|
IFNULL(corp.CorporateAddressRegionalCd, '') AS CorporateAddressRegionalCd,
|
|
IFNULL(corp.CorporateAddressRT, '') AS CorporateAddressRT,
|
|
IFNULL(corp.CorporateAddressRW, '') AS CorporateAddressRW,
|
|
IFNULL(corp.CorporateAddressVillage, '') AS CorporateAddressVillage,
|
|
IFNULL(corp.CorporateAddressDistrict, '') AS CorporateAddressDistrict,
|
|
IFNULL(corp.CorporateAddressCity, '') AS CorporateAddressCity,
|
|
IFNULL(corp.CorporateAddressState, '') AS CorporateAddressState,
|
|
IFNULL(corp.CorporateAddressCountry, '') AS CorporateAddressCountry,
|
|
IFNULL(corp.CorporateEmail, '') AS CorporateEmail,
|
|
IFNULL(corp.CorporatePhone, '') AS CorporatePhone,
|
|
IFNULL(corp.CorporatePICName, '') AS CorporatePICName,
|
|
IFNULL(corp.CorporatePICEmail, '') AS CorporatePICEmail,
|
|
IFNULL(corp.CorporatePICPhone, '') AS CorporatePICPhone,
|
|
IFNULL(corp.CorporateFlagHolding, '') AS CorporateFlagHolding,
|
|
IFNULL(corp.CorporateHoldingCorporateID, 0) AS CorporateHoldingCorporateID,
|
|
IFNULL(corp.CorporateRelationCorporateID, 0) AS CorporateRelationCorporateID,
|
|
IFNULL(corp.CorporatePICBillName, '') AS CorporatePICBillName,
|
|
IFNULL(corp.CorporatePICBillEmail, '') AS CorporatePICBillEmail,
|
|
IFNULL(corp.CorporatePICBillPhone, '') AS CorporatePICBillPhone,
|
|
IFNULL(corp.CorporateDueDate, 0) AS CorporateDueDate,
|
|
IFNULL(corp.CorporateFlagJPA, '') AS CorporateFlagJPA,
|
|
IFNULL(corp.CorporateUsername, '') AS CorporateUsername,
|
|
IFNULL(corp.CorporatePassword, '') AS CorporatePassword,
|
|
IFNULL(corp.CorporateIsActive, '') AS CorporateIsActive,
|
|
-- t_priceheader
|
|
IFNULL(price.T_PriceHeaderID, 0) AS T_PriceHeaderID,
|
|
IFNULL(price.T_PriceHeaderName, '') AS T_PriceHeaderName,
|
|
IFNULL(price.T_PriceHeaderStartDate, '0000-00-00') AS T_PriceHeaderStartDate,
|
|
IFNULL(price.T_PriceHeaderEndDate, '0000-00-00') AS T_PriceHeaderEndDate,
|
|
IFNULL(price.T_PriceHeaderIsActive, '') AS T_PriceHeaderIsActive,
|
|
-- mgm_mcupacket
|
|
IFNULL(packet.Mgm_McuPacketID, 0) AS Mgm_McuPacketID,
|
|
IFNULL(packet.Mgm_McuPacketT_PacketID, 0) AS Mgm_McuPacketT_PacketID,
|
|
IFNULL(packet.Mgm_McuPacketIsActive, '') AS Mgm_McuPacketIsActive,
|
|
IFNULL(template.Mgm_McuTemplateID, 0) AS Mgm_McuTemplateID,
|
|
IFNULL(template.Mgm_McuTemplateFisikTemplateMappingID, 0) AS Mgm_McuTemplateFisikTemplateMappingID,
|
|
IFNULL(template.Mgm_McuTemplateIsActive, '') AS Mgm_McuTemplateIsActive,
|
|
-- fisik_template_mapping
|
|
IFNULL(fisik.FisikTemplateMappingID, 0) AS FisikTemplateMappingID,
|
|
IFNULL(fisik.FisikTemplateMappingName, '') AS FisikTemplateMappingName,
|
|
IFNULL(fisik.FisikTemplateMappingIsActive, '') AS FisikTemplateMappingIsActive,
|
|
IFNULL(fisik.FisikTemplateMappingCreated, '0000-00-00 00:00:00') AS FisikTemplateMappingCreated,
|
|
IFNULL(fisik.FisikTemplateMappingCreatedUserID, 0) AS FisikTemplateMappingCreatedUserID,
|
|
IFNULL(fisik.FisikTemplateMappingLastUpdated, '0000-00-00 00:00:00') AS FisikTemplateMappingLastUpdated,
|
|
IFNULL(fisik.FisikTemplateMappingLastUpdatedUserID, 0) AS FisikTemplateMappingLastUpdatedUserID,
|
|
IFNULL(fisik.FisikTemplateMappingDeleted, '0000-00-00 00:00:00') AS FisikTemplateMappingDeleted,
|
|
IFNULL(fisik.FisikTemplateMappingDeletedUserID, 0) AS FisikTemplateMappingDeletedUserID,
|
|
'' as packets
|
|
FROM mgm_mcu mgm
|
|
left join corporate corp
|
|
ON mgm.Mgm_McuCorporateID = corp.CorporateID
|
|
AND corp.CorporateIsActive = 'Y'
|
|
AND mgm.Mgm_McuIsActive = 'Y'
|
|
JOIN t_priceheader price
|
|
ON mgm.Mgm_McuT_PriceHeaderID = price.T_PriceHeaderID
|
|
AND price.T_PriceHeaderIsActive = 'Y'
|
|
JOIN mgm_mcupacket packet
|
|
ON mgm.Mgm_McuID = packet.Mgm_McuPacketMgm_McuID
|
|
AND packet.Mgm_McuPacketIsActive = 'Y'
|
|
LEFT JOIN mgm_mcutemplate template
|
|
ON mgm.Mgm_McuID = template.Mgm_McuTemplateMgm_McuID
|
|
AND template.Mgm_McuTemplateIsActive = 'Y'
|
|
LEFT JOIN fisik_template_mapping fisik
|
|
ON template.Mgm_McuTemplateFisikTemplateMappingID = fisik.FisikTemplateMappingID
|
|
AND fisik.FisikTemplateMappingIsActive = 'Y'
|
|
$sql_where
|
|
GROUP BY mgm.Mgm_McuID
|
|
ORDER BY mgm.Mgm_McuID DESC
|
|
limit $number_limit offset $number_offset
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
if ($query === false) {
|
|
// If query failed, log the error and exit
|
|
$this->sys_error_db("select mgmmcu data", $this->db_onedev);
|
|
exit;
|
|
}
|
|
$rows = $query->result_array();
|
|
|
|
if(count($rows) > 0) {
|
|
foreach($rows as $k => $v){
|
|
$rows[$k]['packets'] = array();
|
|
$where_in_T_PacketID = "AND T_PacketID IN ('')";
|
|
if($v['Mgm_McuPacketT_PacketID'] != ''){
|
|
$xjoin_packets = explode(',',$v['Mgm_McuPacketT_PacketID']);
|
|
//print_r($xjoin_packets);
|
|
if($xjoin_packets){
|
|
foreach($xjoin_packets as $kjt => $vjt){
|
|
if($join_packet != '')
|
|
$join_packet .= ",";
|
|
|
|
$join_packet .= "'{$vjt}'";
|
|
|
|
}
|
|
}
|
|
|
|
//echo $join_packet;
|
|
$where_in_T_PacketID = "AND T_PacketID IN ({$join_packet})";
|
|
}
|
|
|
|
$sql = "SELECT
|
|
T_PacketID as id,
|
|
T_PacketID,
|
|
T_PacketT_PriceHeaderID,
|
|
T_PacketSasCode,
|
|
T_PacketName,
|
|
T_PriceHeaderStartDate,
|
|
T_PriceHeaderEndDate,
|
|
T_PacketSasCode as code,
|
|
T_PacketName as name,
|
|
'Y' as T_PacketIsActive
|
|
from t_packet
|
|
join t_priceheader
|
|
ON T_PacketT_PriceHeaderID = T_PriceHeaderID
|
|
AND T_PacketIsActive = 'Y'
|
|
AND T_PriceHeaderIsActive = 'Y'
|
|
-- AND CURDATE() BETWEEN T_PriceHeaderStartDate AND T_PriceHeaderEndDate
|
|
AND T_PacketT_PriceHeaderID = {$v['Mgm_McuT_PriceHeaderID']}
|
|
AND (
|
|
T_PacketSasCode LIKE '%$filter_paket%'
|
|
OR T_PacketName LIKE '%$filter_paket%'
|
|
)
|
|
$where_in_T_PacketID";
|
|
//echo $sql;
|
|
$rows[$k]['packets'] = $this->db_onedev->query($sql)->result_array();
|
|
}
|
|
}
|
|
|
|
$result = array(
|
|
"total" => $tot_page,
|
|
"records" => $rows,
|
|
"sql"=> $this->db_onedev->last_query()
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
public function searchv0x()
|
|
{
|
|
$prm = $this->sys_input;
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
// $search = $prm['search'];
|
|
// if (isset($prm['search'])) {
|
|
// $search = trim($prm["search"]);
|
|
// if ($search != "") {
|
|
// $search = '%' . $prm['search'] . '%';
|
|
// }else{
|
|
// $search = '%%';
|
|
// }
|
|
// }
|
|
|
|
$limit = '';
|
|
if($all == 'N'){
|
|
$limit = ' LIMIT 10';
|
|
}
|
|
$number_limit = 10;
|
|
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
|
$sql_where = "
|
|
WHERE
|
|
Mgm_McuIsActive = 'Y'
|
|
AND (
|
|
Mgm_McuNumber LIKE '%{$prm['search']}%'
|
|
OR CorporateName LIKE '%{$prm['search']}%'
|
|
OR Mgm_McuLabel LIKE '%{$prm['search']}%'
|
|
)";
|
|
|
|
$sql = "SELECT count(*) as total
|
|
FROM mgm_mcu
|
|
JOIN corporate
|
|
ON Mgm_McuCorporateID = CorporateID
|
|
$sql_where
|
|
";
|
|
|
|
$sql_param = array();
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
$tot_count = 0;
|
|
$tot_page = 0;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
$tot_page = ceil($tot_count/$number_limit);
|
|
} else {
|
|
$this->sys_error_db("mgmmcu count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
// sql data
|
|
$sql = "SELECT
|
|
IFNULL(mgm.Mgm_McuID, 0) AS Mgm_McuID,
|
|
IFNULL(mgm.Mgm_McuLabel, '') AS Mgm_McuLabel,
|
|
IFNULL(mgm.Mgm_McuFlagRelasiBayarSendiri, '') AS Mgm_McuFlagRelasiBayarSendiri,
|
|
IFNULL(mgm.Mgm_McuBisaTambahPemeriksaan, '') AS Mgm_McuBisaTambahPemeriksaan,
|
|
IFNULL(mgm.Mgm_McuCorporateID, 0) AS Mgm_McuCorporateID,
|
|
IFNULL(mgm.Mgm_McuNumber, '') AS Mgm_McuNumber,
|
|
IFNULL(mgm.Mgm_McuNumberNational, '') AS Mgm_McuNumberNational,
|
|
IFNULL(mgm.Mgm_McuNote, '') AS Mgm_McuNote,
|
|
IFNULL(mgm.Mgm_McuStartDate, '0000-00-00') AS Mgm_McuStartDate,
|
|
IFNULL(mgm.Mgm_McuEndDate, '0000-00-00') AS Mgm_McuEndDate,
|
|
IFNULL(DATE_FORMAT(mgm.Mgm_McuStartDate, '%d-%m-%Y'), '00-00-0000') AS Mgm_McuStartDateTxt,
|
|
IFNULL(DATE_FORMAT(mgm.Mgm_McuEndDate, '%d-%m-%Y'), '00-00-0000') AS Mgm_McuEndDateTxt,
|
|
IFNULL(mgm.Mgm_McuIsActive, '') AS Mgm_McuIsActive,
|
|
IFNULL(mgm.Mgm_McuCreated, '0000-00-00 00:00:00') AS Mgm_McuCreated,
|
|
IFNULL(mgm.Mgm_McuCreatedUserID, 0) AS Mgm_McuCreatedUserID,
|
|
IFNULL(mgm.Mgm_McuLastUpdated, '0000-00-00 00:00:00') AS Mgm_McuLastUpdated,
|
|
IFNULL(mgm.Mgm_McuLastUpdatedUserID, 0) AS Mgm_McuLastUpdatedUserID,
|
|
IFNULL(mgm.Mgm_McuLastDeleted, '0000-00-00 00:00:00') AS Mgm_McuLastDeleted,
|
|
IFNULL(mgm.Mgm_McuLastDeletedUserID, 0) AS Mgm_McuLastDeletedUserID,
|
|
IFNULL(mgm.Mgm_McuTotalParticipant, 0) AS Mgm_McuTotalParticipant,
|
|
IFNULL(mgm.Mgm_McuPicEmail, '') AS Mgm_McuPicEmail,
|
|
IFNULL(mgm.Mgm_McuPicPassword, '') AS Mgm_McuPicPassword,
|
|
IFNULL(corp.CorporateID, 0) AS CorporateID,
|
|
IFNULL(corp.CorporateCode, '') AS CorporateCode,
|
|
IFNULL(corp.CorporateName, '') AS CorporateName,
|
|
IFNULL(corp.CorporateAddress, '') AS CorporateAddress,
|
|
IFNULL(corp.CorporateAddressRegionalCd, '') AS CorporateAddressRegionalCd,
|
|
IFNULL(corp.CorporateAddressRT, '') AS CorporateAddressRT,
|
|
IFNULL(corp.CorporateAddressRW, '') AS CorporateAddressRW,
|
|
IFNULL(corp.CorporateAddressVillage, '') AS CorporateAddressVillage,
|
|
IFNULL(corp.CorporateAddressDistrict, '') AS CorporateAddressDistrict,
|
|
IFNULL(corp.CorporateAddressCity, '') AS CorporateAddressCity,
|
|
IFNULL(corp.CorporateAddressState, '') AS CorporateAddressState,
|
|
IFNULL(corp.CorporateAddressCountry, '') AS CorporateAddressCountry,
|
|
IFNULL(corp.CorporateEmail, '') AS CorporateEmail,
|
|
IFNULL(corp.CorporatePhone, '') AS CorporatePhone,
|
|
IFNULL(corp.CorporatePICName, '') AS CorporatePICName,
|
|
IFNULL(corp.CorporatePICEmail, '') AS CorporatePICEmail,
|
|
IFNULL(corp.CorporatePICPhone, '') AS CorporatePICPhone,
|
|
IFNULL(corp.CorporateFlagHolding, '') AS CorporateFlagHolding,
|
|
IFNULL(corp.CorporateHoldingCorporateID, 0) AS CorporateHoldingCorporateID,
|
|
IFNULL(corp.CorporateRelationCorporateID, 0) AS CorporateRelationCorporateID,
|
|
IFNULL(corp.CorporatePICBillName, '') AS CorporatePICBillName,
|
|
IFNULL(corp.CorporatePICBillEmail, '') AS CorporatePICBillEmail,
|
|
IFNULL(corp.CorporatePICBillPhone, '') AS CorporatePICBillPhone,
|
|
IFNULL(corp.CorporateDueDate, 0) AS CorporateDueDate,
|
|
IFNULL(corp.CorporateFlagJPA, '') AS CorporateFlagJPA,
|
|
IFNULL(corp.CorporateUsername, '') AS CorporateUsername,
|
|
IFNULL(corp.CorporatePassword, '') AS CorporatePassword,
|
|
IFNULL(corp.CorporateCreated, '0000-00-00 00:00:00') AS CorporateCreated,
|
|
IFNULL(corp.CorporateCreatedUserID, 0) AS CorporateCreatedUserID,
|
|
IFNULL(corp.CorporateLastUpdated, '0000-00-00 00:00:00') AS CorporateLastUpdated,
|
|
IFNULL(corp.CorporateLastUpdatedUserID, 0) AS CorporateLastUpdatedUserID,
|
|
IFNULL(corp.CorporateDeleted, '0000-00-00 00:00:00') AS CorporateDeleted,
|
|
IFNULL(corp.CorporateDeletedUserID, 0) AS CorporateDeletedUserID,
|
|
IFNULL(corp.CorporateIsActive, '') AS CorporateIsActive
|
|
FROM
|
|
mgm_mcu mgm
|
|
JOIN
|
|
corporate corp
|
|
ON
|
|
mgm.Mgm_McuCorporateID = corp.CorporateID
|
|
$sql_where
|
|
ORDER BY mgm.Mgm_McuID DESC
|
|
limit $number_limit offset $number_offset
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
if ($query === false) {
|
|
// If query failed, log the error and exit
|
|
$this->sys_error_db("select mgmmcu data", $this->db_onedev);
|
|
exit;
|
|
}
|
|
$rows = $query->result_array();
|
|
|
|
$result = array(
|
|
"total" => $tot_page,
|
|
"records" => $rows,
|
|
"sql"=> $this->db_onedev->last_query()
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getTemplateFisikMapping()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$sql = "SELECT FisikTemplateMappingID,
|
|
FisikTemplateMappingName
|
|
FROM fisik_template_mapping
|
|
WHERE FisikTemplateMappingIsActive = 'Y'";
|
|
$qry = $this->db_onedev->query($sql);
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->sys_error_db("template fisik select error", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$result = array(
|
|
"records" => $rows,
|
|
"sql" => $this->db_onedev->last_query()
|
|
);
|
|
$this->sys_ok($result);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function searchcorporate(){
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM corporate
|
|
WHERE
|
|
CorporateName like ?
|
|
AND CorporateIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("corporate count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT CorporateID as id, CorporateName as name
|
|
FROM corporate
|
|
WHERE
|
|
CorporateName like ?
|
|
AND CorporateIsActive = 'Y'
|
|
ORDER BY CorporateName ASC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("corporate rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
function getPackets(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$search = $prm["searchPacket"];
|
|
|
|
$number_limit = 10;
|
|
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
|
|
|
$sql = "SELECT count(*) as total
|
|
FROM (
|
|
select
|
|
T_PacketID as id,
|
|
T_PacketID,
|
|
T_PacketT_PriceHeaderID,
|
|
T_PacketSasCode,
|
|
T_PacketName,
|
|
T_PriceHeaderStartDate,
|
|
T_PriceHeaderEndDate,
|
|
T_PacketSasCode as code,
|
|
T_PacketName as name,
|
|
'N' as T_PacketIsActive
|
|
from t_packet
|
|
join t_priceheader
|
|
ON T_PacketT_PriceHeaderID = T_PriceHeaderID
|
|
AND T_PacketIsActive = 'Y'
|
|
AND T_PriceHeaderIsActive = 'Y'
|
|
AND CURDATE() BETWEEN T_PriceHeaderStartDate AND T_PriceHeaderEndDate
|
|
AND (
|
|
T_PacketSasCode LIKE '%$search%'
|
|
OR T_PacketName LIKE '%$search%'
|
|
)
|
|
) x
|
|
";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
$tot_count = 0;
|
|
$tot_page = 0;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
$tot_page = ceil($tot_count/$number_limit);
|
|
} else {
|
|
$this->sys_error_db("m_doctor count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$query ="
|
|
SELECT
|
|
T_PacketID as id,
|
|
T_PacketID,
|
|
T_PacketT_PriceHeaderID,
|
|
T_PacketSasCode,
|
|
T_PacketName,
|
|
T_PriceHeaderStartDate,
|
|
T_PriceHeaderEndDate,
|
|
T_PacketSasCode as code,
|
|
T_PacketName as name,
|
|
'N' as T_PacketIsActive
|
|
from t_packet
|
|
join t_priceheader
|
|
ON T_PacketT_PriceHeaderID = T_PriceHeaderID
|
|
AND T_PacketIsActive = 'Y'
|
|
AND T_PriceHeaderIsActive = 'Y'
|
|
AND CURDATE() BETWEEN T_PriceHeaderStartDate AND T_PriceHeaderEndDate
|
|
AND (
|
|
T_PacketSasCode LIKE '%$search%'
|
|
OR T_PacketName LIKE '%$search%'
|
|
)
|
|
ORDER BY T_PacketSasCode ASC
|
|
limit $number_limit offset $number_offset
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query)->result_array();
|
|
// if($rows){
|
|
// foreach($rows as $kp => $vp){
|
|
// $rows[$kp]['nat_test'] = json_decode($vp['nat_test']);
|
|
// }
|
|
// }
|
|
|
|
$result = array(
|
|
"total" => $tot_page ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function savesetupv0(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$prm = $this->sys_input;
|
|
$priceheaderid = array();
|
|
// $Packetid = array();
|
|
if(count($prm['selected_packets']) > 0){
|
|
foreach($prm['selected_packets'] as $kp => $vp){
|
|
array_push($priceheaderid,$vp['T_PacketT_PriceHeaderID']);
|
|
// array_push($Packetid,$vp['T_PacketID']);
|
|
}
|
|
}
|
|
|
|
if(count($priceheaderid) > 0){
|
|
$Mgm_McuT_PriceHeaderID = join(',',$priceheaderid);
|
|
}
|
|
|
|
// if(count($Packetid) > 0){
|
|
// $Mgm_McuPacketT_PacketID = join(',',$Packetid);
|
|
// }
|
|
|
|
$Mgm_McuTemplateFisikTemplateMappingID = $prm['Mgm_McuTemplateFisikTemplateMappingID']['FisikTemplateMappingID'];
|
|
|
|
$password = $prm['Mgm_McuPicPassword'];
|
|
$Mgm_McuPicPassword = md5($this->one_salt . $password . $this->one_salt);
|
|
|
|
$Mgm_McuFlagRelasiBayarSendiri = "N";
|
|
$Mgm_McuBisaTambahPemeriksaan = "N";
|
|
|
|
if($prm['Mgm_McuBisaTambahPemeriksaan'] == true){
|
|
$Mgm_McuBisaTambahPemeriksaan = "Y";
|
|
}
|
|
|
|
if($prm['Mgm_McuFlagRelasiBayarSendiri'] == true){
|
|
$Mgm_McuFlagRelasiBayarSendiri = "Y";
|
|
}
|
|
|
|
$Mgm_McuCorporateID = $prm['Mgm_McuCorporateID']['id'];
|
|
$Mgm_McuNumber = "";
|
|
$Mgm_McuNumberNational = "";
|
|
$Mgm_McuNote = $prm['Mgm_McuNote'];
|
|
$Mgm_McuLabel = $prm['Mgm_McuLabel'];
|
|
$Mgm_McuStartDate = date('Y-m-d',strtotime($prm["Mgm_McuStartDate"]));
|
|
$Mgm_McuEndDate = date('Y-m-d',strtotime($prm["Mgm_McuEndDate"]));
|
|
$Mgm_McuPicEmail = $prm['Mgm_McuPicEmail'];
|
|
$Mgm_McuTotalParticipant = $prm['Mgm_McuTotalParticipant'];
|
|
|
|
if($prm["act"] == 'new'){
|
|
// get numbering
|
|
$sql_get_numbering = "SELECT fn_numbering_cpone('SM') as numberx";
|
|
$qry_get_numbering = $this->db_onedev->query($sql_get_numbering);
|
|
if(!$qry_get_numbering){
|
|
$this->db_onedev->trans_rollback();
|
|
$this->sys_error_db("mgm_mcu numbering cpone", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$data_numbering = $qry_get_numbering->result_array();
|
|
|
|
$Mgm_McuNumber = $data_numbering[0]['numberx'];
|
|
|
|
// insert mgm_mcu
|
|
$sql_mgmmcu ="INSERT INTO mgm_mcu (
|
|
Mgm_McuT_PriceHeaderID,
|
|
Mgm_McuLabel,
|
|
Mgm_McuFlagRelasiBayarSendiri,
|
|
Mgm_McuBisaTambahPemeriksaan,
|
|
Mgm_McuCorporateID,
|
|
Mgm_McuNumber,
|
|
Mgm_McuNumberNational,
|
|
Mgm_McuNote,
|
|
Mgm_McuStartDate,
|
|
Mgm_McuEndDate,
|
|
Mgm_McuPicEmail,
|
|
Mgm_McuPicPassword,
|
|
Mgm_McuIsActive,
|
|
Mgm_McuCreated,
|
|
Mgm_McuCreatedUserID,
|
|
Mgm_McuTotalParticipant
|
|
) VALUES (
|
|
'{$Mgm_McuT_PriceHeaderID}',
|
|
'{$Mgm_McuLabel}',
|
|
'{$Mgm_McuFlagRelasiBayarSendiri}',
|
|
'{$Mgm_McuBisaTambahPemeriksaan}',
|
|
{$Mgm_McuCorporateID},
|
|
'{$Mgm_McuNumber}',
|
|
'{$Mgm_McuNumberNational}',
|
|
'{$Mgm_McuNote}',
|
|
'{$Mgm_McuStartDate}',
|
|
'{$Mgm_McuEndDate}',
|
|
'{$Mgm_McuPicEmail}',
|
|
'{$Mgm_McuPicPassword}',
|
|
'Y',
|
|
NOW(),
|
|
{$userid},
|
|
{$Mgm_McuTotalParticipant}
|
|
)
|
|
";
|
|
|
|
$qry = $this->db_onedev->query($sql_mgmmcu);
|
|
if(!$qry){
|
|
$this->db_onedev->trans_rollback();
|
|
$this->sys_error_db("mgm_mcu insert", $this->db_onedev);
|
|
exit;
|
|
}
|
|
$last_id = $this->db_onedev->insert_id();
|
|
|
|
// insert mgm_mcupacket
|
|
if(count($prm['selected_packets']) > 0){
|
|
foreach($prm['selected_packets'] as $kp => $vp){
|
|
$Mgm_McuPacketT_PacketID = $vp['T_PacketID'];
|
|
$sql_mgm_mcupacket = "INSERT INTO mgm_mcupacket (
|
|
Mgm_McuPacketMgm_McuID,
|
|
Mgm_McuPacketT_PacketID,
|
|
Mgm_McuPacketIsActive,
|
|
Mgm_McuPacketCreated,
|
|
Mgm_McuPacketCreatedUserID
|
|
) VALUES (
|
|
$last_id,
|
|
'{$Mgm_McuPacketT_PacketID}',
|
|
'Y',
|
|
NOW(),
|
|
$userid
|
|
)";
|
|
|
|
$qry_mgm_mcupacket = $this->db_onedev->query($sql_mgm_mcupacket);
|
|
if(!$qry_mgm_mcupacket){
|
|
$this->db_onedev->trans_rollback();
|
|
$this->sys_error_db("mgm_mcupacket insert", $this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
}
|
|
|
|
// insert mgm_mcutemplate
|
|
$mgm_mcutemplate = "INSERT INTO mgm_mcutemplate (
|
|
Mgm_McuTemplateMgm_McuID,
|
|
Mgm_McuTemplateFisikTemplateMappingID,
|
|
Mgm_McuTemplateIsActive,
|
|
Mgm_McuTemplateCreated,
|
|
Mgm_McuTemplateCreatedUserID
|
|
) VALUES (
|
|
$last_id,
|
|
$Mgm_McuTemplateFisikTemplateMappingID,
|
|
'Y',
|
|
NOW(),
|
|
$userid
|
|
)";
|
|
|
|
$qry_mgm_mcutemplate = $this->db_onedev->query($mgm_mcutemplate);
|
|
if(!$qry_mgm_mcutemplate){
|
|
$this->db_onedev->trans_rollback();
|
|
$this->sys_error_db("mgm_mcutemplate insert", $this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
// kalau edit yg mgm_mcupacket di N kan sesuai
|
|
// Mgm_McuPacketMgm_McuID
|
|
// baru di insert yg baru
|
|
|
|
else
|
|
{
|
|
// var_dump($prm);
|
|
// check data password for update
|
|
$sql_check = "SELECT *
|
|
FROM mgm_mcu
|
|
WHERE Mgm_McuID = {$prm["xid"]}";
|
|
|
|
$qry_check = $this->db_onedev->query($sql_check);
|
|
if (!$qry_check) {
|
|
$this->db_onedev->trans_rollback();
|
|
$this->sys_error_db("mgm_mcu select check", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$rowx = $qry_check->row_array();
|
|
$passwordOld = $rowx['Mgm_McuPicPassword'];
|
|
|
|
if($passwordOld == $password){
|
|
$Mgm_McuPicPassword = $passwordOld;
|
|
}
|
|
|
|
// echo $passwordOld;
|
|
// echo "\n".$password;
|
|
// echo "\n".$Mgm_McuPicPassword;
|
|
// exit;
|
|
|
|
// update mgmmcu
|
|
$sql_mgmmcu = "UPDATE mgm_mcu
|
|
SET
|
|
Mgm_McuT_PriceHeaderID = '{$Mgm_McuT_PriceHeaderID}',
|
|
Mgm_McuLabel = '{$Mgm_McuLabel}',
|
|
Mgm_McuFlagRelasiBayarSendiri = '{$Mgm_McuFlagRelasiBayarSendiri}',
|
|
Mgm_McuBisaTambahPemeriksaan = '{$Mgm_McuBisaTambahPemeriksaan}',
|
|
Mgm_McuCorporateID = {$Mgm_McuCorporateID},
|
|
-- Mgm_McuNumber = '{$Mgm_McuNumber}',
|
|
-- Mgm_McuNumberNational = '{$Mgm_McuNumberNational}',
|
|
Mgm_McuNote = '{$Mgm_McuNote}',
|
|
Mgm_McuStartDate = '{$Mgm_McuStartDate}',
|
|
Mgm_McuEndDate = '{$Mgm_McuEndDate}',
|
|
Mgm_McuPicEmail = '{$Mgm_McuPicEmail}',
|
|
Mgm_McuPicPassword = '{$Mgm_McuPicPassword}',
|
|
Mgm_McuIsActive = 'Y',
|
|
Mgm_McuLastUpdated = NOW(),
|
|
Mgm_McuLastUpdatedUserID = {$userid},
|
|
Mgm_McuTotalParticipant = {$Mgm_McuTotalParticipant}
|
|
WHERE
|
|
Mgm_McuID = {$prm["xid"]}
|
|
";
|
|
|
|
$qry = $this->db_onedev->query($sql_mgmmcu);
|
|
if (!$qry) {
|
|
$this->db_onedev->trans_rollback();
|
|
$this->sys_error_db("mgm_mcu update", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$last_id = $prm["xid"];
|
|
|
|
// // update packets
|
|
// // update isActive N kan semua
|
|
$sqlUpdatePacket = "UPDATE mgm_mcupacket
|
|
SET
|
|
Mgm_McuPacketIsActive = 'N',
|
|
Mgm_McuPacketLastUpdated = NOW(),
|
|
Mgm_McuPacketLastUpdatedUserID = $userid
|
|
WHERE Mgm_McuPacketMgm_McuID = $last_id";
|
|
|
|
// echo $sqlUpdatePacket;
|
|
|
|
$qry_mgm_update_mcupacket = $this->db_onedev->query($sqlUpdatePacket);
|
|
if(!$qry_mgm_update_mcupacket){
|
|
$this->db_onedev->trans_rollback();
|
|
$this->sys_error_db("mgm_mcupacket update", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
if(count($prm['selected_packets']) > 0){
|
|
foreach($prm['selected_packets'] as $kp => $vp){
|
|
$Mgm_McuPacketT_PacketID = $vp['T_PacketID'];
|
|
$sql_mgm_mcupacket = "INSERT INTO mgm_mcupacket (
|
|
Mgm_McuPacketMgm_McuID,
|
|
Mgm_McuPacketT_PacketID,
|
|
Mgm_McuPacketIsActive,
|
|
Mgm_McuPacketCreated,
|
|
Mgm_McuPacketCreatedUserID
|
|
) VALUES (
|
|
$last_id,
|
|
'{$Mgm_McuPacketT_PacketID}',
|
|
'Y',
|
|
NOW(),
|
|
$userid
|
|
)";
|
|
|
|
$qry_mgm_mcupacket = $this->db_onedev->query($sql_mgm_mcupacket);
|
|
if(!$qry_mgm_mcupacket){
|
|
$this->db_onedev->trans_rollback();
|
|
$this->sys_error_db("mgm_mcupacket insert", $this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
}
|
|
|
|
// update mgm_mcutemplate
|
|
$mgm_mcutemplate = "UPDATE mgm_mcutemplate
|
|
SET
|
|
Mgm_McuTemplateFisikTemplateMappingID = $Mgm_McuTemplateFisikTemplateMappingID,
|
|
Mgm_McuTemplateLastUpdated = NOW(),
|
|
Mgm_McuTemplateLastUpdatedUserID = $userid
|
|
WHERE
|
|
Mgm_McuTemplateMgm_McuID = $last_id
|
|
AND Mgm_McuTemplateIsActive = 'Y'
|
|
";
|
|
|
|
$qry_mgm_mcutemplate = $this->db_onedev->query($mgm_mcutemplate);
|
|
if (!$qry_mgm_mcutemplate) {
|
|
$this->db_onedev->trans_rollback();
|
|
$this->sys_error_db("mgm_mcutemplate update", $this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
$sql = "SELECT Mgm_McuNumber as xnumber
|
|
FROM mgm_mcu
|
|
WHERE Mgm_McuID = {$last_id}";
|
|
|
|
//echo $sql;
|
|
$row = $this->db_onedev->query($sql)->row_array();
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => $row,
|
|
);
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function deletemcuv0(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$prm = $this->sys_input;
|
|
|
|
// mcu
|
|
$query_mgmmcu = $this->db_onedev->query("UPDATE mgm_mcu SET
|
|
Mgm_McuIsActive = 'N',
|
|
Mgm_McuLastDeletedUserID = {$userid},
|
|
Mgm_McuLastDeleted = NOW()
|
|
WHERE
|
|
Mgm_McuID = '{$prm['id']}'
|
|
");
|
|
|
|
if(!$query_mgmmcu){
|
|
$this->db_onedev->trans_rollback();
|
|
$this->sys_error_db("mgm_mcu delete cpone eror", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
// packet
|
|
$query_mgmmcu_packet = $this->db_onedev->query("UPDATE mgm_mcupacket SET
|
|
Mgm_McuPacketIsActive = 'N',
|
|
Mgm_McuPacketDeleted = NOW(),
|
|
Mgm_McuPacketDeletedUserID = {$userid}
|
|
WHERE
|
|
Mgm_McuPacketMgm_McuID = '{$prm['id']}'
|
|
");
|
|
|
|
if(!$query_mgmmcu_packet){
|
|
$this->db_onedev->trans_rollback();
|
|
$this->sys_error_db("mgm_mcu paket delete cpone eror", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
// template
|
|
$query_mgm_mcutemplate = $this->db_onedev->query("UPDATE
|
|
mgm_mcutemplate SET
|
|
Mgm_McuTemplateIsActive = 'N',
|
|
Mgm_McuTemplateDelete = NOW(),
|
|
Mgm_McuTemplateDeletedUserID = {$userid}
|
|
WHERE
|
|
Mgm_McuTemplateMgm_McuID = '{$prm['id']}'
|
|
");
|
|
|
|
if(!$query_mgm_mcutemplate){
|
|
$this->db_onedev->trans_rollback();
|
|
$this->sys_error_db("mgm_mcu templete delete cpone eror", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
// $rows = $this->db_onedev->query($query_mgmmcu);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getDetailPacketByID() {
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$prm = $this->sys_input;
|
|
|
|
$T_PacketID = $prm['T_PacketID'];
|
|
|
|
$sql = "SELECT
|
|
pd.T_PacketDetailID,
|
|
pd.T_PacketDetailT_PacketID,
|
|
pd.T_PacketDetailT_TestID,
|
|
pd.T_PacketDetailOriginalPrice,
|
|
pd.T_PacketDetailPrice,
|
|
pd.T_PacketDetailIsActive,
|
|
pd.T_PacketDetailCreated,
|
|
pd.T_PacketDetailLastUpdated,
|
|
pd.T_PacketDetailPriceAmount,
|
|
pd.T_PacketDetailPriceDisc,
|
|
pd.T_PacketDetailPriceDiscRp,
|
|
pd.T_PacketDetailPriceSubTotal,
|
|
t.T_TestID,
|
|
t.T_TestNat_GroupID,
|
|
t.T_TestNat_SubgroupID,
|
|
t.T_TestParentT_TestID,
|
|
t.T_TestCode,
|
|
t.T_TestSasCode,
|
|
t.T_TestName,
|
|
t.T_TestShortName,
|
|
t.T_TestShortNameBarcode,
|
|
t.T_TestWorklistName,
|
|
t.T_TestNat_TestID,
|
|
t.T_TestRequirement,
|
|
t.T_TestIsParent,
|
|
t.T_TestFontSize,
|
|
t.T_TestFontColor,
|
|
t.T_TestIsBold,
|
|
t.T_TestIsItalic,
|
|
t.T_TestT_SampleTypeID,
|
|
t.T_TestResultPosition,
|
|
t.T_TestNormalValue,
|
|
t.T_TestFlagGluc,
|
|
t.T_TestIsQuantitative,
|
|
t.T_TestIsPrintNota,
|
|
t.T_TestIsResult,
|
|
t.T_TestIsPrintResult,
|
|
t.T_TestIsPrice,
|
|
t.T_TestForceSell,
|
|
t.T_TestIsWorklist,
|
|
t.T_TestIsNonLab,
|
|
t.T_TestIsDeltaCheck,
|
|
t.T_TestIsTrendAnalysis,
|
|
t.T_TestLeftMargin,
|
|
t.T_TestCreated,
|
|
t.T_TestLastUpdated,
|
|
t.T_TestIsActive,
|
|
t.T_TestMaxDiscount,
|
|
t.T_TestFlagLow,
|
|
t.T_TestFlagHigh,
|
|
t.T_TestUserID,
|
|
t.T_TestFlagMCU,
|
|
t.T_TestNat_SubSubGroupID,
|
|
t.T_TestCreatedUserID,
|
|
t.T_TestLastUpdatedUserID,
|
|
t.T_TestDeleted,
|
|
t.T_TestDeletedUserID
|
|
FROM
|
|
t_packetdetail as pd
|
|
JOIN
|
|
t_test as t
|
|
ON
|
|
pd.T_PacketDetailT_TestID = t.T_TestID
|
|
AND t.T_TestIsActive = 'Y'
|
|
AND pd.T_PacketDetailIsActive = 'Y'
|
|
AND pd.T_PacketDetailT_PacketID = $T_PacketID";
|
|
|
|
$qry = $this->db_onedev->query($sql);
|
|
if(!$qry){
|
|
$this->sys_error_db("list packet", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$rows = $qry->result_array();
|
|
$result = array(
|
|
// "total" => $tot_page,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
// cpone
|
|
|
|
public function search()
|
|
{
|
|
$prm = $this->sys_input;
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$status = isset($prm["status"]["id"])?$prm["status"]["id"]:'N';
|
|
$company = isset($prm["company"])?intval($prm["company"]):0;
|
|
// echo $norm;
|
|
$filter_company = '';
|
|
if($company > 0){
|
|
$filter_company = " AND McuOfflinePrepareM_CompanyID = {$company}";
|
|
}
|
|
|
|
$sql_where = "WHERE McuOfflinePrepareIsActive = 'Y' AND McuOfflinePrepareIsDownloaded = '{$status}' $filter_company";
|
|
$sql_param = array();
|
|
|
|
$limit = '';
|
|
if($all == 'N'){
|
|
$limit = ' LIMIT 10';
|
|
}
|
|
$number_limit = 10;
|
|
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
|
$sql = " SELECT count(*) as total
|
|
FROM mcu_offline_prepare
|
|
JOIN m_company ON McuOfflinePrepareM_CompanyID = M_CompanyID
|
|
$sql_where
|
|
";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
//echo $this->db_onedev->last_query();
|
|
$tot_count = 0;
|
|
$tot_page = 0;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
$tot_page = ceil($tot_count/$number_limit);
|
|
} else {
|
|
$this->sys_error_db("m_patient count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = " SELECT mcu_offline_prepare.*, M_CompanyName,
|
|
DATE_FORMAT(McuOfflinePrepareStartDate, '%d.%m.%Y') as start_date,
|
|
DATE_FORMAT(McuOfflinePrepareEndDate, '%d.%m.%Y') as end_date,
|
|
McuOfflinePreparePromiseDate as promise_date,
|
|
McuOfflinePreparePromiseTime as promise_time,
|
|
McuOfflinePrepareDoctors as doctors,
|
|
McuOfflinePrepareMous as mous,
|
|
McuOfflinePrepareDeliveries as deliveries,
|
|
'' as allmous,
|
|
McuOfflinePrepareM_MouDefaultID as mou_default_id,
|
|
M_MouName as mou_default_name,
|
|
CONCAT('[ ',M_DoctorCode,' ] ',IFNULL(M_DoctorPrefix,''),'',IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as doctor_default_name,
|
|
McuOfflinePrepareM_DoctorDefaultID as doctor_default_id,
|
|
'' as default_mou,
|
|
'' as default_doctor,
|
|
'' as default_doctor_address,
|
|
M_DoctorAddressID as doctor_address_id,
|
|
M_DoctorAddressNote as doctor_address_label,
|
|
M_DoctorAddressDescription as doctor_address_description,
|
|
'' as doctor_address,
|
|
'' as packets,
|
|
'' as tests
|
|
FROM mcu_offline_prepare
|
|
JOIN m_company ON McuOfflinePrepareM_CompanyID = M_CompanyID
|
|
JOIN m_mou ON McuOfflinePrepareM_MouDefaultID = M_MouID
|
|
JOIN m_doctor ON McuOfflinePrepareM_DoctorDefaultID = M_DoctorID
|
|
JOIN m_doctoraddress ON McuOfflinePrepareM_DoctorAddressDefaultID = M_DoctorAddressID
|
|
$sql_where
|
|
ORDER BY McuOfflinePrepareCode ASC
|
|
limit $number_limit offset $number_offset
|
|
";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
$rows = $query->result_array();
|
|
if($rows){
|
|
foreach($rows as $k => $v){
|
|
$v['doctors'] = preg_replace("/\\n/", "___n___", $v['doctors']);
|
|
$rows[$k]['doctors'] = json_decode($v['doctors']);
|
|
//print_r($v['doctors']);
|
|
$v['mous'] = preg_replace("/\\n/", "___n___", $v['mous']);
|
|
$rows[$k]['mous'] = json_decode($v['mous']);
|
|
$v['deliveries'] = preg_replace("/\\n/", "___n___", $v['deliveries']);
|
|
$rows[$k]['deliveries'] = json_decode($v['deliveries']);
|
|
$rows[$k]['default_mou'] = array('id'=>$v['mou_default_id'],'name'=>$v['mou_default_name']);
|
|
$rows[$k]['packets'] = array();
|
|
$rows[$k]['tests'] = array();
|
|
|
|
|
|
$join_test = '';
|
|
$filter_paket = "AND T_PacketSasCode IN ('')";
|
|
$filter_test = "AND T_TestSasCode IN ('')";
|
|
if($v['McuOfflinePrepareTests'] != ''){
|
|
$xjoin_tests = explode(',',$v['McuOfflinePrepareTests']);
|
|
//print_r($xjoin_tests);
|
|
if($xjoin_tests){
|
|
foreach($xjoin_tests as $kjt => $vjt){
|
|
if($join_test != '')
|
|
$join_test .= ",";
|
|
|
|
$join_test .= "'{$vjt}'";
|
|
|
|
}
|
|
}
|
|
//echo $join_test;
|
|
$filter_paket = "AND T_PacketSasCode IN ({$join_test})";
|
|
$filter_test = "AND T_TestSasCode IN ({$join_test}) ";
|
|
}
|
|
|
|
|
|
$sql = "SELECT T_PacketID as id, T_PacketName as name, T_PacketSasCode as code, nat_test
|
|
FROM ss_price_mou
|
|
JOIN t_packet ON T_TestID = T_PacketID AND T_PacketIsActive = 'Y'
|
|
WHERE
|
|
Ss_PriceMouM_MouID = {$v['mou_default_id']} AND is_packet = 'Y' $filter_paket";
|
|
//echo $sql;
|
|
$rows[$k]['packets'] = $this->db_onedev->query($sql)->result_array();
|
|
if($rows[$k]['packets']){
|
|
foreach($rows[$k]['packets'] as $kp => $vp){
|
|
$rows[$k]['packets'][$kp]['nat_test'] = json_decode($vp['nat_test']);
|
|
}
|
|
}
|
|
|
|
$sql = "SELECT test.T_TestID as id, test.T_TestName as name, test.T_TestSasCode as code, nat_test
|
|
FROM ss_price_mou
|
|
JOIN t_test test ON test.T_TestID = ss_price_mou.T_TestID AND T_TestIsActive = 'Y'
|
|
WHERE
|
|
Ss_PriceMouM_MouID = {$v['mou_default_id']} AND is_packet = 'N' AND
|
|
T_PriceIsCito = 'N' $filter_test";
|
|
//echo $sql;
|
|
$rows[$k]['tests'] = $this->db_onedev->query($sql)->result_array();
|
|
if($rows[$k]['tests']){
|
|
foreach($rows[$k]['tests'] as $kp => $vp){
|
|
$rows[$k]['tests'][$kp]['nat_test'] = json_decode($vp['nat_test']);
|
|
}
|
|
}
|
|
|
|
$sql = "SELECT M_MouID as id, M_MouName as name
|
|
FROM m_mou
|
|
WHERE
|
|
M_MouM_CompanyID = {$v['McuOfflinePrepareM_CompanyID']} AND
|
|
( '{$v['McuOfflinePrepareStartDate']}' >= M_MouStartDate) AND
|
|
( '{$v['McuOfflinePrepareEndDate']}' <= M_MouEndDate ) AND
|
|
M_MouIsActive = 'Y' AND M_MouIsReleased = 'Y'";
|
|
//echo $sql;
|
|
$rows[$k]['allmous'] = $this->db_onedev->query($sql)->result_array();
|
|
$rows[$k]['default_doctor_address'] = array('id'=>$v['doctor_address_id'],'label'=>$v['doctor_address_label'],'description'=>$v['doctor_address_description']);
|
|
$sql = "SELECT M_DoctorAddressID as id, M_DoctorAddressNote as label, M_DoctorAddressDescription as description FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorID = {$v['doctor_default_id']} AND M_DoctorAddressIsActive = 'Y'";
|
|
//echo $sql;
|
|
$rows[$k]['doctor_address'] = $this->db_onedev->query($sql)->result_array();
|
|
$rows[$k]['default_doctor'] = array('id'=>$v['doctor_default_id'],'name'=>$v['doctor_default_name'],'xaddress'=>$rows[$k]['doctor_address']);
|
|
}
|
|
}
|
|
|
|
|
|
//$this->_add_address($rows);
|
|
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getdatapackets(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$search = $prm["search"];
|
|
|
|
$number_limit = 10;
|
|
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
|
|
|
$sql = "SELECT count(*) as total
|
|
FROM (
|
|
SELECT T_PacketID as id, T_PacketName as name, T_PacketSasCode as code
|
|
FROM ss_price_mou
|
|
JOIN t_packet ON T_TestID = T_PacketID AND T_PacketIsActive = 'Y'
|
|
WHERE
|
|
Ss_PriceMouM_MouID = {$prm['id']} AND is_packet = 'Y' AND
|
|
( T_TestName LIKE CONCAT('%','{$search}','%') )
|
|
) x
|
|
";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
$tot_count = 0;
|
|
$tot_page = 0;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
$tot_page = ceil($tot_count/$number_limit);
|
|
} else {
|
|
$this->sys_error_db("m_doctor count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$query ="
|
|
SELECT T_PacketID as id, T_PacketName as name, T_PacketSasCode as code, nat_test
|
|
FROM ss_price_mou
|
|
JOIN t_packet ON T_TestID = T_PacketID AND T_PacketIsActive = 'Y'
|
|
WHERE
|
|
Ss_PriceMouM_MouID = {$prm['id']} AND is_packet = 'Y' AND
|
|
( T_TestName LIKE CONCAT('%','{$search}','%') )
|
|
ORDER BY T_PacketSasCode ASC
|
|
limit $number_limit offset $number_offset
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query)->result_array();
|
|
if($rows){
|
|
foreach($rows as $kp => $vp){
|
|
$rows[$kp]['nat_test'] = json_decode($vp['nat_test']);
|
|
}
|
|
}
|
|
|
|
$result = array(
|
|
"total" => $tot_page ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getdatatests(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$search = $prm["search"];
|
|
$number_limit = 10;
|
|
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
|
|
|
$sql = "SELECT count(*) as total
|
|
FROM (
|
|
SELECT test.T_TestID as id, test.T_TestName as name, test.T_TestSasCode as code, nat_test
|
|
FROM ss_price_mou
|
|
JOIN t_test test ON test.T_TestID = ss_price_mou.T_TestID
|
|
WHERE
|
|
Ss_PriceMouM_MouID = {$prm['id']} AND
|
|
( ss_price_mou.T_TestName LIKE CONCAT('%','{$search}','%') ) AND
|
|
T_PriceIsCito = 'N'
|
|
GROUP BY Ss_PriceMouID
|
|
) x
|
|
";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
$tot_count = 0;
|
|
$tot_page = 0;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
$tot_page = ceil($tot_count/$number_limit);
|
|
} else {
|
|
$this->sys_error_db("m_doctor count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
$query ="
|
|
SELECT test.T_TestID as id, test.T_TestName as name, test.T_TestSasCode as code, nat_test
|
|
FROM ss_price_mou
|
|
JOIN t_test test ON test.T_TestID = ss_price_mou.T_TestID AND is_packet = 'N'
|
|
WHERE
|
|
Ss_PriceMouM_MouID = {$prm['id']} AND
|
|
( ss_price_mou.T_TestName LIKE CONCAT('%','{$search}','%') ) AND
|
|
T_PriceIsCito = 'N'
|
|
GROUP BY Ss_PriceMouID
|
|
ORDER BY T_TestSasCode ASC
|
|
limit $number_limit offset $number_offset
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query)->result_array();
|
|
if($rows){
|
|
foreach($rows as $kp => $vp){
|
|
$rows[$kp]['nat_test'] = json_decode($vp['nat_test']);
|
|
}
|
|
}
|
|
$result = array(
|
|
"total" => $tot_page ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getmou(){
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
//$prm['start_date'] = strtotime($prm['start_date']);
|
|
//$prm['end_date'] = strtotime($prm['end_date']);
|
|
$query =" SELECT M_MouID as id, M_MouName as name, M_MouNumber as code
|
|
FROM m_mou
|
|
WHERE
|
|
M_MouM_CompanyID = {$prm['id']} AND
|
|
M_MouIsActive = 'Y' AND
|
|
(
|
|
( '{$prm['start_date']}' BETWEEN M_MouStartDate AND M_MouEndDate ) AND
|
|
( '{$prm['end_date']}' BETWEEN M_MouStartDate AND M_MouEndDate )
|
|
) AND
|
|
M_MouIsReleased = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query)->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getdeliveries(){
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$id = $prm['id'];
|
|
//$prm['start_date'] = strtotime($prm['start_date']);
|
|
//$prm['end_date'] = strtotime($prm['end_date']);
|
|
$type = 'mou';
|
|
$sql = "SELECT * FROM m_mou WHERE M_MouID = {$id}";
|
|
$data_mou = $this->db_onedev->query($sql)->row_array();
|
|
$sql = " SELECT 0 as kelurahan,
|
|
0 as address_id,
|
|
M_DeliveryM_DeliveryTypeID as delivery_type,
|
|
M_DeliveryID as delivery_id,
|
|
M_DeliveryName as delivery_name,
|
|
'' as description,
|
|
'N' as chex,
|
|
'' as note,
|
|
'origin' as typeform,
|
|
'patient' as type,
|
|
M_DeliveryTypeCode as delivery_code
|
|
FROM m_delivery
|
|
JOIN m_deliverytype ON M_DeliveryTypeCode = 'PICKUP' AND M_DeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
|
WHERE
|
|
M_DeliverySource = 'patient' AND M_DeliveryIsActive = 'Y'
|
|
UNION
|
|
SELECT M_CompanyM_KelurahanID as kelurahan,
|
|
M_CompanyID as address_id,
|
|
M_DeliveryM_DeliveryTypeID as delivery_type,
|
|
M_DeliveryID as delivery_id,
|
|
M_DeliveryName as delivery_name,
|
|
CONCAT(M_CompanyAddress,' ',M_KelurahanName,', ',M_DistrictName,', ',M_CityName) as description,
|
|
'N' as chex,
|
|
'' as note,
|
|
'origin' as typeform,
|
|
'{$type}' as type,
|
|
M_DeliveryTypeCode as delivery_code
|
|
FROM m_company
|
|
JOIN m_delivery ON M_DeliverySource = 'COMPANY' AND M_DeliveryIsActive = 'Y'
|
|
JOIN m_deliverytype ON M_DeliveryTypeCode = 'ADDRESS' AND M_DeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
|
JOIN m_kelurahan ON M_CompanyM_KelurahanID = M_KelurahanID
|
|
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
|
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
|
WHERE
|
|
M_CompanyID = {$data_mou['M_MouM_CompanyID']}
|
|
UNION
|
|
SELECT 0 as kelurahan,
|
|
0 as address_id,
|
|
M_DeliveryM_DeliveryTypeID as delivery_type,
|
|
M_DeliveryID as delivery_id,
|
|
M_DeliveryName as delivery_name,
|
|
IFNULL(M_MouEmail,'Belum ada email agreement') as description,
|
|
IFNULL(M_MouEmailIsDefault,'N') as chex,
|
|
'' as note,
|
|
'origin' as typeform,
|
|
'{$type}' as type,
|
|
M_DeliveryTypeCode as delivery_code
|
|
FROM m_mou
|
|
JOIN m_delivery ON M_DeliverySource = 'mou' AND M_DeliveryIsActive = 'Y'
|
|
JOIN m_deliverytype ON M_DeliveryTypeCode = 'EMAIL' AND M_DeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
|
WHERE
|
|
M_MouID = {$id}";
|
|
//echo $sql;
|
|
$rows = $this->db_onedev->query($sql)->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getsexreg(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM m_title
|
|
WHERE
|
|
M_TitleIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['titles'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query =" SELECT *
|
|
FROM m_sex
|
|
WHERE
|
|
M_SexIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['sexes'] = $this->db_onedev->query($query)->result_array();
|
|
$query =" SELECT *
|
|
FROM m_religion
|
|
WHERE
|
|
M_ReligionIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['religions'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query =" SELECT *
|
|
FROM m_idtype
|
|
WHERE
|
|
M_IdTypeIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['kartuidentitass'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function searchcity(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM m_city
|
|
WHERE
|
|
M_CityName like ?
|
|
AND M_CityIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_city count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT *
|
|
FROM m_city
|
|
WHERE
|
|
M_CityName like ?
|
|
AND M_CityIsActive = 'Y'
|
|
ORDER BY M_CityName DESC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_city rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
function searchcompany(){
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM m_company
|
|
WHERE
|
|
M_CompanyName like ?
|
|
AND M_CompanyIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_company count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT M_CompanyID as id, M_CompanyName as name
|
|
FROM m_company
|
|
WHERE
|
|
M_CompanyName like ?
|
|
AND M_CompanyIsActive = 'Y'
|
|
ORDER BY M_CompanyName ASC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_company rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
|
|
function filtersearchcompany(){
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM m_company
|
|
WHERE
|
|
M_CompanyName like ?
|
|
AND M_CompanyIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_company count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT M_CompanyID as id, M_CompanyName as name
|
|
FROM m_company
|
|
WHERE
|
|
M_CompanyName like ?
|
|
AND M_CompanyIsActive = 'Y'
|
|
ORDER BY M_CompanyName ASC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
array_push($rows,array('id'=>0,'name'=>'Semua'));
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_company rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
|
|
function searchdoctor(){
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM m_doctor
|
|
WHERE
|
|
M_DoctorName like ?
|
|
AND M_DoctorIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_doctor count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT M_DoctorID as id, CONCAT('[ ',M_DoctorCode,' ] ',IFNULL(M_DoctorPrefix,''),'',IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as name, '' as xaddress
|
|
FROM m_doctor
|
|
WHERE
|
|
CONCAT('[ ',M_DoctorCode,' ] ',IFNULL(M_DoctorPrefix,''),'',IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) like '{$q['search']}'
|
|
AND M_DoctorIsActive = 'Y'
|
|
group by M_DoctorID
|
|
ORDER BY M_DoctorName ASC
|
|
LIMIT 20
|
|
";
|
|
// echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
foreach($rows as $k => $v){
|
|
$sql = "SELECT M_DoctorAddressID as id, M_DoctorAddressNote as label, M_DoctorAddressDescription as description FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorID = {$v['id']} AND M_DoctorAddressIsActive = 'Y'";
|
|
$rows[$k]['xaddress'] = $this->db_onedev->query($sql)->result();
|
|
}
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_doctor rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
function savesetup(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$prm = $this->sys_input;
|
|
$sdate = date('Y-m-d',strtotime($prm["startdate"]));
|
|
$edate = date('Y-m-d',strtotime($prm["enddate"]));
|
|
$promise_date = date('Y-m-d',strtotime($prm["promise_date"]));
|
|
$promise_time = date('H:i:s',strtotime($prm["promise_time"]));
|
|
$mous = json_encode($prm["mous"]);
|
|
$deliveries = json_encode($prm["deliveries"]);
|
|
$doctors = addslashes(str_replace('\n', '\\\n', json_encode($prm["doctors"])));
|
|
$packettests = array();
|
|
if(count($prm['selected_packets']) > 0){
|
|
foreach($prm['selected_packets'] as $kp => $vp){
|
|
array_push($packettests,$vp['code']);
|
|
}
|
|
}
|
|
if(count($prm['selected_tests']) > 0){
|
|
foreach($prm['selected_tests'] as $kt => $vt){
|
|
array_push($packettests,$vt['code']);
|
|
}
|
|
}
|
|
if(count($packettests) > 0){
|
|
$McuOfflinePrepareTests = join(',',$packettests);
|
|
}
|
|
if($prm["act"] == 'new'){
|
|
$query =" INSERT INTO mcu_offline_prepare(
|
|
McuOfflinePrepareStartDate,
|
|
McuOfflinePrepareEndDate,
|
|
McuOfflinePrepareM_CompanyID,
|
|
McuOfflinePrepareMous,
|
|
McuOfflinePrepareDoctors,
|
|
McuOfflinePrepareM_MouDefaultID,
|
|
McuOfflinePrepareM_DoctorDefaultID,
|
|
McuOfflinePrepareM_DoctorAddressDefaultID,
|
|
McuOfflinePreparePromiseDate,
|
|
McuOfflinePreparePromiseTime,
|
|
McuOfflinePrepareDeliveries,
|
|
McuOfflinePrepareTests,
|
|
McuOfflinePrepareUserID,
|
|
McuOfflinePrepareCreated
|
|
)
|
|
VALUES(
|
|
'{$sdate}',
|
|
'{$edate}',
|
|
{$prm["company"]["id"]},
|
|
'{$mous}',
|
|
'{$doctors}',
|
|
{$prm["default_mou"]["id"]},
|
|
{$prm["default_doctor"]["id"]},
|
|
{$prm["default_doctor_address"]["id"]},
|
|
'{$promise_date}',
|
|
'{$promise_time}',
|
|
'{$deliveries}',
|
|
'{$McuOfflinePrepareTests}',
|
|
{$userid},
|
|
NOW()
|
|
)
|
|
";
|
|
//echo $query;
|
|
$this->db_onedev->query($query);
|
|
$last_id = $this->db_onedev->insert_id();
|
|
|
|
}
|
|
else{
|
|
$query =" UPDATE mcu_offline_prepare SET
|
|
McuOfflinePrepareStartDate = '{$sdate}',
|
|
McuOfflinePrepareEndDate = '{$edate}',
|
|
McuOfflinePrepareM_CompanyID = {$prm["company"]["id"]},
|
|
McuOfflinePrepareMous = '{$mous}',
|
|
McuOfflinePrepareDeliveries = '{$deliveries}',
|
|
McuOfflinePrepareDoctors = '{$doctors}',
|
|
McuOfflinePreparePromiseDate = '{$promise_date}',
|
|
McuOfflinePreparePromiseTime = '{$promise_time}',
|
|
McuOfflinePrepareM_MouDefaultID = {$prm["default_mou"]["id"]},
|
|
McuOfflinePrepareM_DoctorDefaultID = {$prm["default_doctor"]["id"]},
|
|
McuOfflinePrepareM_DoctorAddressDefaultID = {$prm["default_doctor_address"]["id"]},
|
|
McuOfflinePrepareUserID = {$userid}
|
|
WHERE
|
|
McuOfflinePrepareID = {$prm["xid"]}
|
|
";
|
|
$this->db_onedev->query($query);
|
|
$last_id = $prm["xid"];
|
|
}
|
|
|
|
|
|
//echo $query;
|
|
$sql = "SELECT McuOfflinePrepareCode as xnumber FROM mcu_offline_prepare WHERE McuOfflinePrepareID = {$last_id}";
|
|
//echo $sql;
|
|
$row = $this->db_onedev->query($sql)->row_array();
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => $row,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
|
|
function getdistrict(){
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT *
|
|
FROM m_district
|
|
WHERE
|
|
M_DistrictIsActive = 'Y' AND M_DistrictM_CityID = ?
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getkelurahan(){
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT *
|
|
FROM m_kelurahan
|
|
WHERE
|
|
M_KelurahanIsActive = 'Y' AND M_KelurahanM_DistrictID = ?
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function save(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$prm = $this->sys_input;
|
|
$pdob = date('Y-m-d',strtotime($prm['M_PatientDOB']));
|
|
$query ="UPDATE m_patient SET
|
|
M_PatientM_TitleID = '{$prm['M_PatientM_TitleID']}',
|
|
M_PatientPrefix = '{$prm['M_PatientPrefix']}',
|
|
M_PatientName = '{$prm['M_PatientName']}',
|
|
M_PatientSuffix = '{$prm['M_PatientSuffix']}',
|
|
M_PatientDOB = '{$pdob}',
|
|
M_PatientM_SexID = '{$prm['M_PatientM_SexID']}',
|
|
M_PatientM_ReligionID = '{$prm['M_PatientM_ReligionID']}',
|
|
M_PatientEmail = '{$prm['M_PatientEmail']}',
|
|
M_PatientPOB = '{$prm['M_PatientPOB']}',
|
|
M_PatientHP = '{$prm['M_PatientHP']}',
|
|
M_PatientPhone = '{$prm['M_PatientPhone']}',
|
|
M_PatientM_IdTypeID = '{$prm['M_PatientM_IdTypeID']}',
|
|
M_PatientIDNumber = '{$prm['M_PatientIDNumber']}',
|
|
M_PatientNote = '{$prm['M_PatientNote']}',
|
|
M_PatientNIK = '{$prm['M_PatientNIK']}',
|
|
M_PatientJabatan = '{$prm['M_PatientJabatan']}',
|
|
M_PatientKedudukan = '{$prm['M_PatientKedudukan']}',
|
|
M_PatientPJ = '{$prm['M_PatientPJ']}',
|
|
M_PatientLocation = '{$prm['M_PatientLocation']}',
|
|
M_PatientJob = '{$prm['M_PatientJob']}'
|
|
WHERE
|
|
M_PatientID = '{$prm['M_PatientID']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$ptn = $prm;
|
|
$ptn["M_PatientDOB"] = $pdob;
|
|
$ptn = json_encode($ptn);
|
|
$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.EDIT', '{$ptn}', $userid)");
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function newpatient(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
$pdob = date('Y-m-d',strtotime($prm['M_PatientDOB']));
|
|
$query ="INSERT INTO m_patient (
|
|
M_PatientM_TitleID,
|
|
M_PatientPrefix,
|
|
M_PatientName,
|
|
M_PatientSuffix,
|
|
M_PatientDOB,
|
|
M_PatientM_SexID,
|
|
M_PatientM_ReligionID,
|
|
M_PatientEmail,
|
|
M_PatientPOB,
|
|
M_PatientHP,
|
|
M_PatientPhone,
|
|
M_PatientM_IdTypeID,
|
|
M_PatientIDNumber,
|
|
M_PatientNote,
|
|
M_PatientNIK,
|
|
M_PatientJabatan,
|
|
M_PatientKedudukan,
|
|
M_PatientPJ,
|
|
M_PatientLocation,
|
|
M_PatientJob,
|
|
M_PatientUserID
|
|
)
|
|
VALUES(
|
|
'{$prm['M_PatientM_TitleID']}',
|
|
'{$prm['M_PatientPrefix']}',
|
|
'{$prm['M_PatientName']}',
|
|
'{$prm['M_PatientSuffix']}',
|
|
'{$pdob}',
|
|
'{$prm['M_PatientM_SexID']}',
|
|
'{$prm['M_PatientM_ReligionID']}',
|
|
'{$prm['M_PatientEmail']}',
|
|
'{$prm['M_PatientPOB']}',
|
|
'{$prm['M_PatientHP']}',
|
|
'{$prm['M_PatientPhone']}',
|
|
'{$prm['M_PatientM_IdTypeID']}',
|
|
'{$prm['M_PatientIDNumber']}',
|
|
'{$prm['M_PatientNote']}',
|
|
'{$prm['M_PatientNIK']}',
|
|
'{$prm['M_PatientJabatan']}',
|
|
'{$prm['M_PatientKedudukan']}',
|
|
'{$prm['M_PatientPJ']}',
|
|
'{$prm['M_PatientLocation']}',
|
|
'{$prm['M_PatientJob']}',
|
|
$userid
|
|
)
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
$last_id = $this->db_onedev->insert_id();
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK'),
|
|
"id" => $last_id
|
|
);
|
|
$ptn = $prm;
|
|
$ptn["M_PatientID"] = $last_id;
|
|
$ptn["M_PatientDOB"] = $pdob;
|
|
$ptn = json_encode($ptn);
|
|
$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADD', '{$ptn}', $userid)");
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function deletepatient(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$prm = $this->sys_input;
|
|
$query ="UPDATE mcu_offline_prepare SET
|
|
McuOfflinePrepareIsActive = 'N'
|
|
WHERE
|
|
McuOfflinePrepareID = '{$prm['id']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getaddress(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT m_patientaddress.*,
|
|
M_KelurahanName,
|
|
M_DistrictID,
|
|
M_DistrictName,
|
|
M_CityID,
|
|
M_CityName,
|
|
'' as action
|
|
FROM m_patientaddress
|
|
JOIN m_kelurahan ON M_PatientAddressM_KelurahanID = M_KelurahanID
|
|
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
|
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
|
WHERE
|
|
M_PatientAddressIsActive = 'Y' AND M_PatientAddressM_PatientID = ?
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
|
if($rows){
|
|
foreach($rows as $k => $v){
|
|
$rows[$k]['action'] = '<v-icon color="error" @click="deleteAddress(props.item)">delete</v-icon>';
|
|
$rows[$k]['action'] .= '<v-icon color="primary" @click="deleteAddress(props.item)">edit</v-icon>';
|
|
|
|
}
|
|
}
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function savenewaddress(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$prm = $this->sys_input;
|
|
$count_addrs = $this->db_onedev->query("SELECT COUNT(*) as countx FROM m_patientaddress WHERE M_PatientAddressM_PatientID = '{$prm['M_PatientAddressM_PatientID']}' AND M_PatientAddressIsActive = 'Y'")->row()->countx;
|
|
|
|
//echo $this->db_onedev->last_query();
|
|
if($count_addrs == 0){
|
|
$prm['M_PatientAddressNote'] = 'Utama';
|
|
}
|
|
else{
|
|
$count_addrs_utama = $this->db_onedev->query("SELECT COUNT(*) as countx FROM m_patientaddress WHERE M_PatientAddressM_PatientID = '{$prm['M_PatientAddressM_PatientID']}' AND M_PatientAddressNote = 'Utama' AND M_PatientAddressIsActive = 'Y'")->row()->countx;
|
|
if($count_addrs_utama > 0 && strtolower($prm['M_PatientAddressNote']) == 'utama'){
|
|
$rx = date('YmdHis');
|
|
$prm['M_PatientAddressNote'] = 'Utama_'.$rx;
|
|
}
|
|
}
|
|
$query ="INSERT INTO m_patientaddress (
|
|
M_PatientAddressM_PatientID,
|
|
M_PatientAddressNote,
|
|
M_PatientAddressDescription,
|
|
M_PatientAddressM_KelurahanID,
|
|
M_PatientAddressCreated
|
|
)
|
|
VALUES(
|
|
'{$prm['M_PatientAddressM_PatientID']}',
|
|
'{$prm['M_PatientAddressNote']}',
|
|
'{$prm['M_PatientAddressDescription']}',
|
|
'{$prm['M_PatientAddressM_KelurahanID']}',
|
|
NOW()
|
|
)
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$ptn = $prm;
|
|
$ptn["M_UserID"] = $pdob;
|
|
$ptn = json_encode($ptn);
|
|
$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADDR_ADD', '{$ptn}', $userid)");
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function saveeditaddress(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$prm = $this->sys_input;
|
|
|
|
$query ="UPDATE m_patientaddress SET
|
|
M_PatientAddressM_PatientID = '{$prm['M_PatientAddressM_PatientID']}',
|
|
M_PatientAddressNote = '{$prm['M_PatientAddressNote']}',
|
|
M_PatientAddressDescription = '{$prm['M_PatientAddressDescription']}',
|
|
M_PatientAddressM_KelurahanID = '{$prm['M_PatientAddressM_KelurahanID']}'
|
|
WHERE
|
|
M_PatientAddressID = '{$prm['M_PatientAddressID']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$ptn = $prm;
|
|
$ptn["M_UserID"] = $pdob;
|
|
$ptn = json_encode($ptn);
|
|
$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADDR_EDIT', '{$ptn}', $userid)");
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function deleteaddress(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$prm = $this->sys_input;
|
|
|
|
$query ="UPDATE m_patientaddress SET
|
|
M_PatientAddressIsActive = 'N'
|
|
WHERE
|
|
M_PatientAddressID = '{$prm['M_PatientAddressID']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$ptn = $prm;
|
|
$ptn["M_UserID"] = $pdob;
|
|
$ptn = json_encode($ptn);
|
|
$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADDR_DELETE', '{$ptn}', $userid)");
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
|
|
}
|