Initial import
This commit is contained in:
703
one-api/application/controllers/mockup/mcu/Mcu_agreement.php
Normal file
703
one-api/application/controllers/mockup/mcu/Mcu_agreement.php
Normal file
@@ -0,0 +1,703 @@
|
||||
<?php
|
||||
class Mcu_agreement extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Samplingcall API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function searchcompany(){
|
||||
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_city 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 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_company rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getsampletypes(){
|
||||
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$orderid = $prm['orderid'];
|
||||
$stationid = $prm['stationid'];
|
||||
$statusid = $prm['statusid'];
|
||||
|
||||
$sql = "SELECT T_OrderDetailID,
|
||||
T_OrderDetailT_TestCode,
|
||||
T_OrderDetailT_TestName,
|
||||
T_SampleTypeID,
|
||||
T_SampleTypeName,
|
||||
T_BahanName,
|
||||
IF(ISNULL(T_SamplingSoID),'N',T_SamplingSoFlag) as status,
|
||||
IF(ISNULL(T_SamplingSoID),DATE_FORMAT(CURDATE(),'%d-%m-%Y'),DATE_FORMAT(T_SamplingSoProcessDate,'%d-%m-%Y')) as process_date,
|
||||
IF(ISNULL(T_SamplingSoID),DATE_FORMAT(CURTIME(),'%H:%i'),DATE_FORMAT(T_SamplingSoProcessTime,'%H:%i')) as process_time,
|
||||
IF(ISNULL(T_SamplingSoID) OR T_SamplingSoFlag = 'P',DATE_FORMAT(CURDATE(),'%d-%m-%Y'),DATE_FORMAT(T_SamplingSoDoneDate,'%d-%m-%Y')) as done_date,
|
||||
IF(ISNULL(T_SamplingSoID) OR T_SamplingSoFlag = 'P',DATE_FORMAT(CURTIME(),'%H:%i'),DATE_FORMAT(T_SamplingSoDoneTime,'%H:%i')) as done_time
|
||||
FROM t_orderheader
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
||||
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = {$stationid}
|
||||
LEFT JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND T_SamplingSoT_SampleTypeID = T_SampleTypeID AND T_SamplingSoIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderHeaderID = {$orderid} AND T_OrderHeaderIsActive = 'Y'
|
||||
GROUP BY T_SampleTypeID";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
$result = array("total" => count($rows), "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$filter_company_id = $prm["filter_company"]["id"];
|
||||
|
||||
|
||||
// echo $norm;
|
||||
$sql_where = "";
|
||||
if($filter_company_id != 0 || $filter_company_id != '0')
|
||||
$sql_where = " AND Mcu_AgreementCustomerM_CompanyID = {$filter_company_id}";
|
||||
|
||||
//$sql_param = array();
|
||||
|
||||
|
||||
$sql = " SELECT COUNT(*) as total
|
||||
FROM mcu_agreement
|
||||
LEFT JOIN mcu_agreement_customer ON Mcu_AgreementCustomerMcu_AgreementID = Mcu_AgreementID
|
||||
LEFT JOIN mcu_agreement_facility ON Mcu_AgreementFacilityMcu_AgreementID = Mcu_AgreementID
|
||||
LEFT JOIN mcu_agreement_implementation ON Mcu_AgreementImplementationMcu_AgreementID = Mcu_AgreementID
|
||||
LEFT JOIN mcu_agreement_marketing ON Mcu_AgreementMarketingMcu_AgreementID = Mcu_AgreementID
|
||||
LEFT JOIN mcu_agreement_notes ON Mcu_AgreementNotesMcu_AgreementID = Mcu_AgreementID
|
||||
LEFT JOIN mcu_agreement_price ON Mcu_AgreementPriceMcu_AgreementID = Mcu_AgreementID
|
||||
LEFT JOIN mcu_agreement_scopework ON Mcu_AgreementScopeWorkMcu_AgreementID = Mcu_AgreementID
|
||||
LEFT JOIN mcu_agreement_send_result ON Mcu_AgreementSendResultMcu_AgreementID = Mcu_AgreementID
|
||||
LEFT JOIN m_company ON Mcu_AgreementCustomerM_CompanyID = M_CompanyID
|
||||
LEFT JOIN m_mou ON Mcu_AgreementCustomerM_MouID = M_MouID
|
||||
WHERE
|
||||
Mcu_AgreementIsActive = 'Y' $sql_where
|
||||
";
|
||||
//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;
|
||||
}
|
||||
|
||||
$sql = "SELECT Mcu_AgreementID as trx_id,
|
||||
DATE_FORMAT(Mcu_AgreementDate,'%d-%m-%Y') as trx_date,
|
||||
Mcu_AgreementNumbering as trx_numbering,
|
||||
mcu_agreement.*,
|
||||
mcu_agreement_customer.*,
|
||||
mcu_agreement_facility.*,
|
||||
mcu_agreement_implementation.*,
|
||||
mcu_agreement_marketing.*,
|
||||
mcu_agreement_notes.*,
|
||||
mcu_agreement_price.*,
|
||||
mcu_agreement_scopework.*,
|
||||
mcu_agreement_send_result.*,
|
||||
mcu_agreement_promise.*,
|
||||
M_CompanyName, M_MouName, Mcu_AgreementTypeName,
|
||||
'' as mou,
|
||||
time_format(Mcu_AgreementPromiseAtTime,'%H:%i') as promise_time
|
||||
FROM mcu_agreement
|
||||
LEFT JOIN mcu_agreement_customer ON Mcu_AgreementCustomerMcu_AgreementID = Mcu_AgreementID
|
||||
LEFT JOIN mcu_agreement_facility ON Mcu_AgreementFacilityMcu_AgreementID = Mcu_AgreementID
|
||||
LEFT JOIN mcu_agreement_implementation ON Mcu_AgreementImplementationMcu_AgreementID = Mcu_AgreementID
|
||||
LEFT JOIN mcu_agreement_marketing ON Mcu_AgreementMarketingMcu_AgreementID = Mcu_AgreementID
|
||||
LEFT JOIN mcu_agreement_notes ON Mcu_AgreementNotesMcu_AgreementID = Mcu_AgreementID
|
||||
LEFT JOIN mcu_agreement_price ON Mcu_AgreementPriceMcu_AgreementID = Mcu_AgreementID
|
||||
LEFT JOIN mcu_agreement_scopework ON Mcu_AgreementScopeWorkMcu_AgreementID = Mcu_AgreementID
|
||||
LEFT JOIN mcu_agreement_send_result ON Mcu_AgreementSendResultMcu_AgreementID = Mcu_AgreementID
|
||||
LEFT JOIN m_company ON Mcu_AgreementCustomerM_CompanyID = M_CompanyID
|
||||
LEFT JOIN m_mou ON Mcu_AgreementCustomerM_MouID = M_MouID
|
||||
LEFT JOIN mcu_agreementtype ON Mcu_AgreementScopeWorkMcu_AgreementTypeID = Mcu_AgreementTypeID
|
||||
LEFT JOIN mcu_agreement_promise ON Mcu_AgreementPromiseMcu_AgreementID = Mcu_AgreementID
|
||||
WHERE
|
||||
Mcu_AgreementIsActive = 'Y' $sql_where
|
||||
limit 0,20";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$companyid = $v['Mcu_AgreementCustomerM_CompanyID'];
|
||||
$query =" SELECT M_MouID as id, M_MouName as name
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouM_CompanyID = $companyid AND M_MouIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows[$k]['mou'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
}
|
||||
}
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getstationstatus(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT T_SampleStationID as id, T_SampleStationName as name
|
||||
FROM t_samplestation
|
||||
WHERE
|
||||
T_SampleStationIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['stations'] = $this->db_onedev->query($query)->result_array();
|
||||
$rows['statuses'] = array(array('id'=>0,'name'=>'New'));
|
||||
$query =" SELECT T_SamplingQueueStatusID as id, T_SamplingQueueStatusName as name
|
||||
FROM t_sampling_queue_status
|
||||
WHERE
|
||||
T_SamplingCallStatusIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$statuses = $this->db_onedev->query($query)->result_array();
|
||||
//print_r($statuses);
|
||||
foreach($statuses as $k=>$v){
|
||||
array_push($rows['statuses'],$v);
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getagreementtype(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT Mcu_AgreementTypeID as id, Mcu_AgreementTypeName as name
|
||||
FROM mcu_agreementtype
|
||||
WHERE
|
||||
Mcu_AgreementTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getmou(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$companyid = $prm['company']['id'];
|
||||
$query =" SELECT M_MouID as id, M_MouName as name
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouM_CompanyID = $companyid AND M_MouIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows),
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveagreement(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$header_id = $prm['trx_id'];
|
||||
$numbering = '';
|
||||
|
||||
if($header_id == '0' || $header_id == 0){
|
||||
$numbering = $this->db_onedev->query("SELECT fn_numbering('AG') as numbering")->row()->numbering;
|
||||
$query = "INSERT INTO mcu_agreement(
|
||||
Mcu_AgreementNumbering,
|
||||
Mcu_AgreementDate,
|
||||
Mcu_AgreementCreatedBy,
|
||||
Mcu_AgreementUserID,
|
||||
Mcu_AgreementCreated
|
||||
) VALUES(
|
||||
'{$numbering}',
|
||||
CURDATE(),
|
||||
'{$userid}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)";
|
||||
|
||||
$r = $this->db_onedev->query($query);
|
||||
$header_id = $this->db_onedev->insert_id();
|
||||
}
|
||||
else{
|
||||
$numbering = $this->db_onedev->query("SELECT Mcu_AgreementNumbering as numbering FROM mcu_agreement WHERE Mcu_AgreementID = '{$header_id}'")->row()->numbering;
|
||||
}
|
||||
|
||||
|
||||
$query = "INSERT INTO mcu_agreement_customer(
|
||||
Mcu_AgreementCustomerMcu_AgreementID,
|
||||
Mcu_AgreementCustomerM_CompanyID,
|
||||
Mcu_AgreementCustomerM_MouID,
|
||||
Mcu_AgreementCustomerCpName,
|
||||
Mcu_AgreementCustomerCpHp,
|
||||
Mcu_AgreementCustomerCreated,
|
||||
Mcu_AgreementCustomerUserID
|
||||
) VALUES(
|
||||
'{$header_id}',
|
||||
'{$prm['company']['id']}',
|
||||
'{$prm['mou']['id']}',
|
||||
'{$prm['company_cpname']}',
|
||||
'{$prm['company_cphp']}',
|
||||
CURDATE(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Mcu_AgreementCustomerM_CompanyID = '{$prm['company']['id']}',
|
||||
Mcu_AgreementCustomerM_MouID = '{$prm['mou']['id']}',
|
||||
Mcu_AgreementCustomerCpName = '{$prm['company_cpname']}',
|
||||
Mcu_AgreementCustomerCpHp = '{$prm['company_cphp']}',
|
||||
Mcu_AgreementCustomerUserID = {$userid},
|
||||
Mcu_AgreementCustomerIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$xr = $this->db_onedev->query($query);
|
||||
//echo $this->db_onedev->last_query();
|
||||
|
||||
$query = "INSERT INTO mcu_agreement_scopework(
|
||||
Mcu_AgreementScopeWorkMcu_AgreementID,
|
||||
Mcu_AgreementScopeWorkMcu_AgreementTypeID,
|
||||
Mcu_AgreementScopeWorkParticipants,
|
||||
Mcu_AgreementScopeWorkResultTypeReport,
|
||||
Mcu_AgreementScopeWorkSpecialRequirements,
|
||||
Mcu_AgreementScopeWorkUserID,
|
||||
Mcu_AgreementScopeWorkCreated
|
||||
) VALUES(
|
||||
'{$header_id}',
|
||||
'{$prm['agreement_type']['id']}',
|
||||
'{$prm['participants']}',
|
||||
'{$prm['resulttype_report']}',
|
||||
'{$prm['special_requirement']}',
|
||||
{$userid},
|
||||
CURDATE()
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
Mcu_AgreementScopeWorkMcu_AgreementTypeID = '{$prm['agreement_type']['id']}',
|
||||
Mcu_AgreementScopeWorkParticipants = '{$prm['participants']}',
|
||||
Mcu_AgreementScopeWorkResultTypeReport = '{$prm['company_cpname']}',
|
||||
Mcu_AgreementScopeWorkSpecialRequirements = '{$prm['resulttype_report']}',
|
||||
Mcu_AgreementScopeWorkUserID = {$userid},
|
||||
Mcu_AgreementScopeWorkIsActive = 'Y'
|
||||
";
|
||||
|
||||
$xs = $this->db_onedev->query($query);
|
||||
|
||||
$query = "INSERT INTO mcu_agreement_implementation(
|
||||
Mcu_AgreementImplementationMcu_AgreementID,
|
||||
Mcu_AgreementImplementationDate,
|
||||
Mcu_AgreementImplementationTime,
|
||||
Mcu_AgreementImplementationPlace,
|
||||
Mcu_AgreementImplementationSetupInstumentTime,
|
||||
Mcu_AgreementImplementationUserID,
|
||||
Mcu_AgreementImplementationCreated
|
||||
) VALUES(
|
||||
'{$header_id}',
|
||||
'{$prm['implementation_date']}',
|
||||
'{$prm['implementation_time']}',
|
||||
'{$prm['implementation_place']}',
|
||||
'{$prm['setupinstrument_time']}',
|
||||
{$userid},
|
||||
CURDATE()
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
Mcu_AgreementImplementationDate = '{$prm['implementation_date']}',
|
||||
Mcu_AgreementImplementationTime = '{$prm['implementation_time']}',
|
||||
Mcu_AgreementImplementationPlace = '{$prm['implementation_place']}',
|
||||
Mcu_AgreementImplementationSetupInstumentTime = '{$prm['setupinstrument_time']}',
|
||||
Mcu_AgreementImplementationUserID = {$userid},
|
||||
Mcu_AgreementImplementationIsActive = 'Y'
|
||||
";
|
||||
|
||||
$xt = $this->db_onedev->query($query);
|
||||
|
||||
$query = "INSERT INTO mcu_agreement_price(
|
||||
Mcu_AgreementPriceMcu_AgreementID,
|
||||
Mcu_AgreementPriceNormalPrice,
|
||||
Mcu_AgreementPriceAgreementPrice,
|
||||
Mcu_AgreementPriceDiscount,
|
||||
Mcu_AgreementPriceBillingSystem,
|
||||
Mcu_AgreementPriceDueDate,
|
||||
Mcu_AgreementPriceUserID,
|
||||
Mcu_AgreementPriceCreated
|
||||
) VALUES(
|
||||
'{$header_id}',
|
||||
'{$prm['normal_price']}',
|
||||
'{$prm['agreement_price']}',
|
||||
'{$prm['discount_price']}',
|
||||
'{$prm['billing_system']}',
|
||||
'{$prm['duedate']}',
|
||||
{$userid},
|
||||
CURDATE()
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
Mcu_AgreementPriceNormalPrice = '{$prm['normal_price']}',
|
||||
Mcu_AgreementPriceAgreementPrice = '{$prm['agreement_price']}',
|
||||
Mcu_AgreementPriceDiscount = '{$prm['discount_price']}',
|
||||
Mcu_AgreementPriceBillingSystem = '{$prm['billing_system']}',
|
||||
Mcu_AgreementPriceDueDate = '{$prm['duedate']}',
|
||||
Mcu_AgreementPriceUserID = {$userid},
|
||||
Mcu_AgreementPriceIsActive = 'Y'
|
||||
";
|
||||
|
||||
$xu = $this->db_onedev->query($query);
|
||||
|
||||
$query = "INSERT INTO mcu_agreement_facility(
|
||||
Mcu_AgreementFacilityMcu_AgreementID,
|
||||
Mcu_AgreementFacilityFood,
|
||||
Mcu_AgreementFacilityUserID,
|
||||
Mcu_AgreementFacilityCreated
|
||||
) VALUES(
|
||||
'{$header_id}',
|
||||
'{$prm['foods']}',
|
||||
{$userid},
|
||||
CURDATE()
|
||||
)ON DUPLICATE KEY UPDATE
|
||||
Mcu_AgreementFacilityFood = '{$prm['foods']}',
|
||||
Mcu_AgreementFacilityUserID = {$userid},
|
||||
Mcu_AgreementFacilityIsActive = 'Y'
|
||||
";
|
||||
|
||||
$xv = $this->db_onedev->query($query);
|
||||
|
||||
|
||||
$query = "INSERT INTO mcu_agreement_send_result(
|
||||
Mcu_AgreementSendResultMcu_AgreementID,
|
||||
Mcu_AgreementSendResultDate,
|
||||
Mcu_AgreementSendResultPlace,
|
||||
Mcu_AgreementSendResultCPName,
|
||||
Mcu_AgreementSendResultCPHP,
|
||||
Mcu_AgreementSendResultUserID,
|
||||
Mcu_AgreementSendResultCreated
|
||||
) VALUES(
|
||||
'{$header_id}',
|
||||
'{$prm['sendresult_date']}',
|
||||
'{$prm['sendresult_place']}',
|
||||
'{$prm['sendresult_cpname']}',
|
||||
'{$prm['sendresult_cphp']}',
|
||||
{$userid},
|
||||
CURDATE()
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
Mcu_AgreementSendResultDate = '{$prm['sendresult_date']}',
|
||||
Mcu_AgreementSendResultPlace = '{$prm['sendresult_place']}',
|
||||
Mcu_AgreementSendResultCPName = '{$prm['sendresult_cpname']}',
|
||||
Mcu_AgreementSendResultCPHP = '{$prm['sendresult_cphp']}',
|
||||
Mcu_AgreementSendResultUserID = {$userid},
|
||||
Mcu_AgreementSendResultIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$xw = $this->db_onedev->query($query);
|
||||
|
||||
$query = "INSERT INTO mcu_agreement_marketing(
|
||||
Mcu_AgreementMarketingMcu_AgreementID,
|
||||
Mcu_AgreementMarketingName,
|
||||
Mcu_AgreementMarketingUserID,
|
||||
Mcu_AgreementMarketingCreated
|
||||
) VALUES(
|
||||
'{$header_id}',
|
||||
'{$prm['marketing_staff']}',
|
||||
{$userid},
|
||||
CURDATE()
|
||||
)ON DUPLICATE KEY UPDATE
|
||||
Mcu_AgreementMarketingName = '{$prm['marketing_staff']}',
|
||||
Mcu_AgreementMarketingUserID = {$userid},
|
||||
Mcu_AgreementMarketingIsActive = 'Y'
|
||||
";
|
||||
|
||||
$xx = $this->db_onedev->query($query);
|
||||
|
||||
$query = "INSERT INTO mcu_agreement_notes(
|
||||
Mcu_AgreementNotesMcu_AgreementID,
|
||||
Mcu_AgrrementNotesValue,
|
||||
Mcu_AgrrementNotesUserID,
|
||||
Mcu_AgrrementNotesCreated
|
||||
) VALUES(
|
||||
'{$header_id}',
|
||||
'{$prm['notes']}',
|
||||
{$userid},
|
||||
CURDATE()
|
||||
)ON DUPLICATE KEY UPDATE
|
||||
Mcu_AgrrementNotesValue = '{$prm['notes']}',
|
||||
Mcu_AgrrementNotesUserID = {$userid},
|
||||
Mcu_AgrrementNotesIsActive = 'Y'
|
||||
";
|
||||
|
||||
$xz = $this->db_onedev->query($query);
|
||||
|
||||
$query = "INSERT INTO mcu_agreement_promise(
|
||||
Mcu_AgreementPromiseMcu_AgreementID,
|
||||
Mcu_AgreementPromiseStartDate,
|
||||
Mcu_AgreementPromiseEndDate,
|
||||
Mcu_AgreementPromiseMonth,
|
||||
Mcu_AgreementPromiseWeek,
|
||||
Mcu_AgreementPromiseDay,
|
||||
Mcu_AgreementPromiseFlagAtTime,
|
||||
Mcu_AgreementPromiseAtTime,
|
||||
Mcu_AgreementPromiseUserID,
|
||||
Mcu_AgreementPromiseCreated
|
||||
) VALUES(
|
||||
'{$header_id}',
|
||||
'{$prm['startdate']}',
|
||||
'{$prm['enddate']}',
|
||||
'{$prm['xmonth']}',
|
||||
'{$prm['xweek']}',
|
||||
'{$prm['xday']}',
|
||||
'{$prm['flagattime']}',
|
||||
'{$prm['attime']}',
|
||||
{$userid},
|
||||
CURDATE()
|
||||
)ON DUPLICATE KEY UPDATE
|
||||
Mcu_AgreementPromiseStartDate = '{$prm['startdate']}',
|
||||
Mcu_AgreementPromiseEndDate = '{$prm['enddate']}',
|
||||
Mcu_AgreementPromiseMonth = '{$prm['xmonth']}',
|
||||
Mcu_AgreementPromiseWeek = '{$prm['xweek']}',
|
||||
Mcu_AgreementPromiseDay = '{$prm['xday']}',
|
||||
Mcu_AgreementPromiseFlagAtTime = '{$prm['flagattime']}',
|
||||
Mcu_AgreementPromiseAtTime = '{$prm['attime']}',
|
||||
Mcu_AgreementPromiseUserID = {$userid},
|
||||
Mcu_AgreementPromiseIsActive = 'Y'
|
||||
";
|
||||
|
||||
$xz = $this->db_onedev->query($query);
|
||||
|
||||
|
||||
|
||||
$rows['numbering'] = $numbering;
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
function doaction(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$next_status = $prm['statusnextid'];
|
||||
if($prm['act'] == 'samplingprocess'){
|
||||
|
||||
$sql = "INSERT INTO t_samplingso (
|
||||
T_SamplingSoT_OrderHeaderID,
|
||||
T_SamplingSoT_SampleTypeID,
|
||||
T_SamplingSoProcessDate,
|
||||
T_SamplingSoProcessTime,
|
||||
T_SamplingSoProcessUserID,
|
||||
T_SamplingSoCreated,
|
||||
T_SamplingSoUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['id']},
|
||||
{$prm['sample']['T_SampleTypeID']},
|
||||
CURDATE(),
|
||||
CURTIME(),
|
||||
{$userid},
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
T_SamplingSoProcessDate = CURDATE(),
|
||||
T_SamplingSoProcessTime = CURTIME(),
|
||||
T_SamplingSoFlag = 'P',
|
||||
T_SamplingSoIsActive = 'Y',
|
||||
T_SamplingSoProcessUserID = {$userid},
|
||||
T_SamplingSoUserID = {$userid}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
if($prm['act'] == 'samplingdone'){
|
||||
$sql = "INSERT INTO t_samplingso (
|
||||
T_SamplingSoT_OrderHeaderID,
|
||||
T_SamplingSoT_SampleTypeID,
|
||||
T_SamplingSoDoneDate,
|
||||
T_SamplingSoDoneTime,
|
||||
T_SamplingSoDoneUserID,
|
||||
T_SamplingSoCreated,
|
||||
T_SamplingSoUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['id']},
|
||||
{$prm['sample']['T_SampleTypeID']},
|
||||
CURDATE(),
|
||||
CURTIME(),
|
||||
{$userid},
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
T_SamplingSoDoneDate = CURDATE(),
|
||||
T_SamplingSoDoneTime = CURTIME(),
|
||||
T_SamplingSoFlag = 'D',
|
||||
T_SamplingSoIsActive = 'Y',
|
||||
T_SamplingSoDoneUserID = {$userid},
|
||||
T_SamplingSoUserID = {$userid}";
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$sql = "SELECT count(*) as xcount
|
||||
FROM (SELECT *
|
||||
FROM t_orderheader
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
||||
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID
|
||||
LEFT JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_SamplingSoT_SampleTypeID = T_SampleTypeID AND
|
||||
T_SamplingSoIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderHeaderID = {$prm['id']} AND T_SamplingSoT_SampleTypeID <> {$prm['sample']['T_SampleTypeID']} AND
|
||||
(ISNULL(T_SamplingSoID) OR T_SamplingSoFlag = 'P') AND T_OrderHeaderIsActive = 'Y'
|
||||
GROUP BY T_SampleTypeID ) xx";
|
||||
//echo $sql;
|
||||
$xcount = $this->db_onedev->query($sql)->row()->xcount;
|
||||
if($xcount == 0){
|
||||
$next_status = 5;
|
||||
}
|
||||
}
|
||||
|
||||
if($prm['act'] !== 'samplingprocess'){
|
||||
$dt_json = json_encode(array('T_SampleStationID'=>$prm['stationid'],'T_OrderHeaderID'=>$prm['id'],'T_SamplingQueueStatusID'=>$next_status));
|
||||
$query = "INSERT INTO one_log.log_sampling_queue (Log_SamplingQueueDate,Log_SamplingQueueJSON,Log_SamplingQueueUserID)
|
||||
VALUES(NOW(),'{$dt_json}',{$userid})";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$sql = "SELECT *
|
||||
FROM t_sampling_queue_last_status
|
||||
WHERE
|
||||
T_SamplingQueueLastStatusT_SampleStationID = {$prm['stationid']} AND
|
||||
T_SamplingQueueLastStatusT_OrderHeaderID = {$prm['id']} AND
|
||||
T_SamplingQueueLastStatusIsActive = 'Y'";
|
||||
$data_last = $this->db_onedev->query($sql)->row();
|
||||
|
||||
$query = "INSERT INTO t_sampling_queue_last_status (
|
||||
T_SamplingQueueLastStatusT_SampleStationID,
|
||||
T_SamplingQueueLastStatusT_OrderHeaderID,
|
||||
T_SamplingQueueLastStatusT_SamplingQueueStatusID,
|
||||
T_SamplingQueueLastStatusUserID)
|
||||
VALUES(
|
||||
{$prm['stationid']},
|
||||
{$prm['id']},
|
||||
{$next_status},
|
||||
{$userid}) ON DUPLICATE KEY UPDATE T_SamplingQueueLastStatusT_SamplingQueueStatusID = {$next_status}";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
241
one-api/application/controllers/mockup/mcu/Mcu_download.php
Normal file
241
one-api/application/controllers/mockup/mcu/Mcu_download.php
Normal file
@@ -0,0 +1,241 @@
|
||||
<?php
|
||||
class Mcu_download extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Samplingcall API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
$this->load->library('zip');
|
||||
}
|
||||
|
||||
function runningtodo(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
if(isset($prm['agreement']) && isset($prm['suffix'])){
|
||||
$delete_x = "UPDATE mcu_download SET Mcu_DownloadIsActive = 'N' WHERE Mcu_DownloadMcu_AgreementID = {$prm['agreement']['id']} AND Mcu_DownloadIsActive = 'Y'";
|
||||
$this->db_onedev->query($delete_x);
|
||||
$insert_x = "INSERT INTO mcu_download (
|
||||
Mcu_DownloadDate,
|
||||
Mcu_DownloadMcu_AgreementID,
|
||||
Mcu_DownloadSuffix ,
|
||||
Mcu_DownloadCreated
|
||||
)
|
||||
vALUES(
|
||||
now(),
|
||||
{$prm['agreement']['id']},
|
||||
'{$prm['suffix']}',
|
||||
NOW()
|
||||
)";
|
||||
$this->db_onedev->query($insert_x);
|
||||
}
|
||||
|
||||
$zipname = '';
|
||||
|
||||
$todos = $prm['todos'];
|
||||
$table_name = '';
|
||||
$restToDo = 0;
|
||||
$ag_number = '';
|
||||
|
||||
foreach ($todos as $k => $v){
|
||||
$ag_number = $v['agreement']['name'];
|
||||
if($v['process'] == 'Y'){
|
||||
if($v['section'] == 'data_patient'){
|
||||
$table_name = 'm_patient';
|
||||
$query = "SELECT * FROM {$table_name}";
|
||||
}
|
||||
if($v['section'] == 'data_test' && ($v['rest'] == 2 || $v['rest'] == '2')){
|
||||
$table_name = 't_sampletype';
|
||||
$query = "SELECT * FROM {$table_name}";
|
||||
}
|
||||
if($v['section'] == 'data_test' && ($v['rest'] == 1 || $v['rest'] == '1')){
|
||||
$table_name = 't_test';
|
||||
$query = "SELECT * FROM {$table_name}";
|
||||
//echo $query;
|
||||
}
|
||||
if($v['section'] == 'data_price' && ($v['rest'] == 3 || $v['rest'] == '3')){
|
||||
$table_name = 'm_company';
|
||||
$query = "SELECT *
|
||||
FROM {$table_name}
|
||||
JOIN mcu_agreement_customer ON Mcu_AgreementCustomerM_CompanyID = M_CompanyID AND
|
||||
Mcu_AgreementCustomerMcu_AgreementID = {$v['agreement']['id']}
|
||||
WHERE
|
||||
M_CompanyIsActive = 'Y'
|
||||
";
|
||||
}
|
||||
|
||||
if($v['section'] == 'data_price' && ($v['rest'] == 2 || $v['rest'] == '2')){
|
||||
$table_name = 'm_mou';
|
||||
$query = "SELECT *
|
||||
FROM {$table_name}
|
||||
JOIN mcu_agreement_customer ON Mcu_AgreementCustomerM_MouID = M_MouID AND
|
||||
Mcu_AgreementCustomerMcu_AgreementID = {$v['agreement']['id']}
|
||||
WHERE
|
||||
M_MouIsActive = 'Y'
|
||||
";
|
||||
}
|
||||
|
||||
if($v['section'] == 'data_price' && ($v['rest'] == 1 || $v['rest'] == '1')){
|
||||
$table_name = 't_price';
|
||||
$get_mou_def = $this->db_onedev->query("SELECT * FROM m_mou WHERE M_MouIsDefault = 'Y' AND M_MouIsActive = 'Y'")->row();
|
||||
$q_moudef = "";
|
||||
if($get_mou_def){
|
||||
$mou_def = $get_mou_def->M_MouID;
|
||||
$q_moudef = "SELECT {$table_name}.*
|
||||
FROM {$table_name}
|
||||
WHERE
|
||||
T_PriceM_MouID = {$mou_def} AND T_PriceIsActive = 'Y'
|
||||
UNION
|
||||
";
|
||||
|
||||
}
|
||||
|
||||
$query = " {$q_moudef}
|
||||
SELECT {$table_name}.*
|
||||
FROM {$table_name}
|
||||
JOIN mcu_agreement_customer ON Mcu_AgreementCustomerM_MouID = T_PriceM_MouID AND
|
||||
Mcu_AgreementCustomerM_CompanyID = T_PriceM_CompanyID AND
|
||||
Mcu_AgreementCustomerMcu_AgreementID = {$v['agreement']['id']}
|
||||
WHERE
|
||||
T_PriceIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
}
|
||||
|
||||
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
$data = json_encode($rows,JSON_PRETTY_PRINT);
|
||||
|
||||
$todos[$k]['progressvalue'] = ceil(intval($v['progressvalue']) + (100/intval($v['actions'])));
|
||||
$rest = intval($v['rest']) - 1;
|
||||
$todos[$k]['rest'] = $rest;
|
||||
|
||||
if($rest == 0){
|
||||
$todos[$k]['process'] = 'N';
|
||||
if($k != count($todos) -1 ){
|
||||
$todos[$k+1]['process'] = 'Y';
|
||||
}
|
||||
|
||||
$todos[$k]['complete'] = 'Y';
|
||||
}
|
||||
|
||||
$restToDo = $restToDo + $rest;
|
||||
|
||||
$filename = $table_name.'.json';
|
||||
if (file_exists("/home/one/Web/one-media/one-mcu-download/".$filename)) {
|
||||
unlink("/home/one/Web/one-media/one-mcu-download/".$filename);
|
||||
}
|
||||
if(file_put_contents("/home/one/Web/one-media/one-mcu-download/".$filename, $data,FILE_APPEND )){
|
||||
|
||||
$xfilename = $filename;
|
||||
if($todos[$k]['filename'] != ''){
|
||||
$xfilename = ' , '.$filename;
|
||||
}
|
||||
$todos[$k]['filename'] = $xfilename;
|
||||
|
||||
$this->zip->read_file("/home/one/Web/one-media/one-mcu-download/".$table_name.".json");
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
$restToDo = $restToDo + intval($v['rest']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($restToDo == 0){
|
||||
if (file_exists("/home/one/Web/one-media/mcudownload_".$ag_number.".zip")) {
|
||||
unlink("/home/one/Web/one-media/mcudownload_".$ag_number.".zip");
|
||||
}
|
||||
$this->zip->archive("/home/one/Web/one-media/mcudownload_".$ag_number.".zip");
|
||||
$zipname = 'https://'.$_SERVER['SERVER_NAME']."/one-media/mcudownload_".$ag_number.".zip";
|
||||
}
|
||||
|
||||
$prm['count'] = intval($prm['count']) - 1;
|
||||
$result = array(
|
||||
"total" => $prm['count'],
|
||||
"records" => $todos,
|
||||
"zipname" => $zipname
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
function search_agreement(){
|
||||
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 mcu_agreement
|
||||
JOIN mcu_agreement_customer ON Mcu_AgreementCustomerMcu_AgreementID = Mcu_AgreementID
|
||||
JOIN m_company ON Mcu_AgreementCustomerM_CompanyID = M_CompanyID
|
||||
WHERE
|
||||
( M_CompanyName like '{$q['search']}' OR Mcu_AgreementNumbering like '{$q['search']}' )
|
||||
AND Mcu_AgreementIsActive = 'Y'
|
||||
ORDER BY Mcu_AgreementID DESC";
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $sql;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_city count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Mcu_AgreementID as id, Mcu_AgreementNumbering as name
|
||||
FROM mcu_agreement
|
||||
JOIN mcu_agreement_customer ON Mcu_AgreementCustomerMcu_AgreementID = Mcu_AgreementID
|
||||
JOIN m_company ON Mcu_AgreementCustomerM_CompanyID = M_CompanyID
|
||||
WHERE
|
||||
( M_CompanyName like '{$q['search']}' OR Mcu_AgreementNumbering like '{$q['search']}' )
|
||||
AND Mcu_AgreementIsActive = 'Y'
|
||||
ORDER BY Mcu_AgreementID DESC
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
1045
one-api/application/controllers/mockup/mcu/Mcu_preregister.php
Normal file
1045
one-api/application/controllers/mockup/mcu/Mcu_preregister.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,189 @@
|
||||
<?php
|
||||
|
||||
class Mcu_reporttemplate extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "MCU Report Template API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 12;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(Mcu_ReportTemplateID) total
|
||||
from mcu_reporttemplate
|
||||
where Mcu_ReportTemplateName like ?
|
||||
and Mcu_ReportTemplateIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, array($search));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("mcu report template count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql = "select Mcu_ReportTemplateID, Mcu_ReportTemplateName
|
||||
from mcu_reporttemplate
|
||||
where Mcu_ReportTemplateName like ?
|
||||
and Mcu_ReportTemplateIsActive = 'Y'
|
||||
order by Mcu_ReportTemplateName
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, array($search));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("mcu report template rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_detail()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 12;
|
||||
|
||||
$t_id = $prm["template_id"];
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(Mcu_ReportTemplateDetailID) total
|
||||
from mcu_reporttemplatedetail
|
||||
where Mcu_ReportTemplateDetailMcu_ReportTemplateID like ?
|
||||
and Mcu_ReportTemplateDetailIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, array($t_id));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("mcu report template detail count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql = "select Mcu_ReportTemplateDetailID, Mcu_ReportTemplateDetailIsTest,
|
||||
Mcu_ReportTemplateDetailT_TestID, Mcu_ReportTemplateDetailT_TestCode,
|
||||
Mcu_ReportTemplateDetailDesc, Mcu_ReportTemplateDetailLeftMargin
|
||||
from mcu_reporttemplatedetail
|
||||
where Mcu_ReportTemplateDetailMcu_ReportTemplateID like ?
|
||||
and Mcu_ReportTemplateDetailIsActive = 'Y'
|
||||
order by Mcu_ReportTemplateDetailLeft";
|
||||
$query = $this->db_smartone->query($sql, array($t_id));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("mcu report template detail rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$r = $this->db_smartone->set('Mcu_ReportTemplateName', $prm['template_name'])
|
||||
->insert('mcu_reporttemplate');
|
||||
|
||||
if ($r)
|
||||
{
|
||||
$id = $this->db_smartone->insert_id();
|
||||
$this->sys_ok($id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("mcu report template insert", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function save_detail()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$r = $this->db_smartone->query("CALL sp_mcu_report_template_detail_new('{$prm['template_id']}', '{$prm['desc']}', '{$prm['is_test']}', '{$prm['test_id']}', '{$prm['pos']}', '{$prm['from_id']}')")
|
||||
->row();
|
||||
|
||||
if ($r->status == "OK")
|
||||
{
|
||||
$this->sys_ok($r->data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("mcu report template insert", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_px()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
t_test
|
||||
where T_TestIsActive = 'Y'
|
||||
and (T_TestName like ? OR T_TestCode LIKE ?)";
|
||||
$query = $this->db_smartone->query($sql, array($q['search'], $q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_TestID, T_TestName, T_TestCode
|
||||
from t_test
|
||||
where T_TestIsActive = 'Y'
|
||||
and (T_TestName like ? OR T_TestCode LIKE ?)";
|
||||
$query = $this->db_smartone->query($sql, array($q['search'], $q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
1594
one-api/application/controllers/mockup/mcu/Mcu_resume.php
Normal file
1594
one-api/application/controllers/mockup/mcu/Mcu_resume.php
Normal file
File diff suppressed because it is too large
Load Diff
323
one-api/application/controllers/mockup/mcu/Screening.php
Normal file
323
one-api/application/controllers/mockup/mcu/Screening.php
Normal file
@@ -0,0 +1,323 @@
|
||||
<?php
|
||||
class Screening extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Screening API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$sql_where = "";
|
||||
if($prm['search'] != '')
|
||||
$sql_where .= " AND ( M_PatientName LIKE CONCAT('%','{$prm['search']}','%') OR T_OrderHeaderLabNumber LIKE CONCAT('%','{$prm['search']}','%') )";
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT
|
||||
T_OrderHeaderID as orderid,
|
||||
T_OrderHeaderLabNumber as labnumber,
|
||||
CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patient_fullname,
|
||||
DATE_FORMAT(T_OrderHeaderDate,'%d-%m-%Y') as date_order,
|
||||
'' as tests,
|
||||
'' as sampletypes
|
||||
FROM t_orderheader
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
WHERE
|
||||
T_OrderHeaderIsActive = 'Y' AND T_OrderHeaderM_MouID = '{$prm['mouid']}'
|
||||
$sql_where
|
||||
) xs
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db->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("t_samplestorageout count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
T_OrderHeaderID as orderid,
|
||||
T_OrderHeaderM_MouID as mouid,
|
||||
T_OrderHeaderLabNumber as labnumber,
|
||||
CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patient_fullname,
|
||||
DATE_FORMAT(T_OrderHeaderDate,'%d-%m-%Y') as date_order,
|
||||
'' as tests,
|
||||
'' as sampletypes,
|
||||
0 as xtotal,
|
||||
0 as xrest
|
||||
FROM t_orderheader
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
WHERE
|
||||
T_OrderHeaderIsActive = 'Y' AND T_OrderHeaderM_MouID = '{$prm['mouid']}'
|
||||
$sql_where
|
||||
ORDER BY T_OrderHeaderLabNumber ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$sql = "SELECT
|
||||
T_OrderDetailT_TestName as name
|
||||
FROM t_orderdetail
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$v['orderid']} AND
|
||||
T_OrderDetailIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows[$k]['tests'] = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$sql = "SELECT {$v['orderid']} as orderid,
|
||||
Mcu_AgreementCustomerMcu_AgreementID as agreement_id,
|
||||
Mcu_AgreementCustomerM_CompanyID as company_id,
|
||||
Mcu_AgreementCustomerM_MouID as mouid,
|
||||
T_TestT_SampleTypeID as sampletype_id,
|
||||
T_SampleTypeName as name,
|
||||
T_BarcodeLabBarcode as barcode,
|
||||
T_OrderDetailID as orderdetailid,
|
||||
IFNULL(Mcu_ScreeningID,0) as trx_id,
|
||||
IF(ISNULL(Mcu_ScreeningID), 'N', 'Y') as status,
|
||||
IF(ISNULL(Mcu_ScreeningID), 'N', Mcu_ScreeningIsExport) as flag_ex
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_barcodelab ON T_BarcodeLabT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_BarcodeLabT_SampleTypeID = T_TestT_SampleTypeID AND T_BarcodeLabIsActive = 'Y'
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
JOIN mcu_agreement_customer ON Mcu_AgreementCustomerM_MouID = {$v['mouid']} AND
|
||||
Mcu_AgreementCustomerIsActive = 'Y'
|
||||
LEFT JOIN mcu_screening ON Mcu_ScreeningT_SampleTypeID = T_SampleTypeID AND Mcu_ScreeningIsActive = 'Y' AND
|
||||
T_OrderDetailT_OrderHeaderID = Mcu_ScreeningT_OrderHeaderID AND Mcu_ScreeningBarcode = T_BarcodeLabBarcode
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$v['orderid']} AND
|
||||
T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY T_BarcodeLabID
|
||||
ORDER BY T_SampleTypeName ASC";
|
||||
//echo $sql;
|
||||
$rows[$k]['sampletypes'] = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$sql = "SELECT count( distinct T_BarcodeLabID) as total
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_barcodelab ON T_BarcodeLabT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_BarcodeLabT_SampleTypeID = T_TestT_SampleTypeID AND T_BarcodeLabIsActive = 'Y'
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
JOIN mcu_agreement_customer ON Mcu_AgreementCustomerM_MouID = {$v['mouid']} AND
|
||||
Mcu_AgreementCustomerIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
|
||||
$rows[$k]['xtotal'] = $this->db_onedev->query($sql)->row()->total;
|
||||
|
||||
|
||||
$sql = "SELECT count( distinct T_BarcodeLabID) as total
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_barcodelab ON T_BarcodeLabT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_BarcodeLabT_SampleTypeID = T_TestT_SampleTypeID AND T_BarcodeLabIsActive = 'Y'
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
JOIN mcu_agreement_customer ON Mcu_AgreementCustomerM_MouID = {$v['mouid']} AND
|
||||
Mcu_AgreementCustomerIsActive = 'Y'
|
||||
JOIN mcu_screening ON Mcu_ScreeningT_SampleTypeID = T_SampleTypeID AND Mcu_ScreeningIsActive = 'Y' AND
|
||||
T_OrderDetailT_OrderHeaderID = Mcu_ScreeningT_OrderHeaderID AND Mcu_ScreeningBarcode = T_BarcodeLabBarcode
|
||||
WHERE
|
||||
T_OrderDetailIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows[$k]['xrest'] = $rows[$k]['xtotal'] - $this->db_onedev->query($sql)->row()->total ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//$tot_count = 25;
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getinitialdatas(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT M_MouID as id,
|
||||
Mcu_AgreementID,
|
||||
Mcu_AgreementNumbering,
|
||||
M_CompanyName,
|
||||
M_MouID,
|
||||
M_MouName,
|
||||
M_MouStartDate,
|
||||
M_MouEndDate,
|
||||
CONCAT(M_CompanyName,' ( ',DATE_FORMAT(M_MouStartDate,'%d-%m-%Y'),' s.d. ',DATE_FORMAT(M_MouEndDate,'%d-%m-%Y'),' ) ') as name
|
||||
FROM mcu_agreement
|
||||
JOIN mcu_agreement_customer ON Mcu_AgreementCustomerMcu_AgreementID = Mcu_AgreementID
|
||||
JOIN m_company ON Mcu_AgreementCustomerM_CompanyID = M_CompanyID
|
||||
JOIN m_mou ON Mcu_AgreementCustomerM_MouID = M_MouID
|
||||
WHERE
|
||||
( DATE(NOW()) BETWEEN CONCAT(M_MouStartDate,' 00:00:00') AND CONCAT(M_MouEndDate,' 23:59:59') ) AND
|
||||
Mcu_AgreementFlagAgree = 'Y' AND Mcu_AgreementIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['mous'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function dosampled(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
if($prm['trx_id'] == '0' || $prm['trx_id'] == 0){
|
||||
$sql = "INSERT INTO mcu_screening (
|
||||
Mcu_ScreeningMcu_AgreementID,
|
||||
Mcu_ScreeningT_OrderHeaderID,
|
||||
Mcu_ScreeningT_SampleTypeID,
|
||||
Mcu_ScreeningBarcode,
|
||||
Mcu_ScreeningUserID,
|
||||
Mcu_ScreeningCreated
|
||||
)
|
||||
VALUES(
|
||||
{$prm['agreement_id']},
|
||||
{$prm['orderid']},
|
||||
{$prm['sampletype_id']},
|
||||
'{$prm['barcode']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
$msg = "Spesimen ".$prm['name']." [".$prm['barcode']."] berhasil masuk screening";
|
||||
}
|
||||
else{
|
||||
$sql =" UPDATE mcu_screening SET Mcu_ScreeningIsActive = 'N' , Mcu_ScreeningUserID = {$userid}
|
||||
WHERE
|
||||
Mcu_ScreeningID = {$prm['trx_id']}";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
$msg = "Spesimen ".$prm['name']." [".$prm['barcode']."] berhasil dibatalkan";
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $msg
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function scanbarcode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "SELECT T_OrderDetailT_OrderHeaderID as orderid,
|
||||
Mcu_AgreementCustomerMcu_AgreementID as agreement_id,
|
||||
Mcu_AgreementCustomerM_CompanyID as company_id,
|
||||
Mcu_AgreementCustomerM_MouID as mouid,
|
||||
T_TestT_SampleTypeID as sampletype_id,
|
||||
T_SampleTypeName as name,
|
||||
T_BarcodeLabBarcode as barcode,
|
||||
T_OrderDetailID as orderdetailid,
|
||||
IFNULL(Mcu_ScreeningID,0) as trx_id,
|
||||
IF(ISNULL(Mcu_ScreeningID), 'N', 'Y') as status
|
||||
FROM t_orderdetail
|
||||
JOIN t_orderheader ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_barcodelab ON T_BarcodeLabT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_BarcodeLabT_SampleTypeID = T_TestT_SampleTypeID AND T_BarcodeLabIsActive = 'Y'
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
JOIN mcu_agreement_customer ON Mcu_AgreementCustomerM_MouID = T_OrderHeaderM_MouID AND Mcu_AgreementCustomerIsActive = 'Y'
|
||||
LEFT JOIN mcu_screening ON Mcu_ScreeningT_SampleTypeID = T_SampleTypeID AND Mcu_ScreeningIsActive = 'Y'
|
||||
WHERE
|
||||
T_BarcodeLabBarcode = '{$prm['barcode']}' AND
|
||||
T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY T_BarcodeLabID
|
||||
LIMIT 1";
|
||||
//echo $sql;
|
||||
$row = $this->db_onedev->query($sql)->row_array();
|
||||
|
||||
$msg = "";
|
||||
if($row){
|
||||
if($row['trx_id'] == '0' || $row['trx_id'] == 0){
|
||||
$sql = "INSERT INTO mcu_screening (
|
||||
Mcu_ScreeningMcu_AgreementID,
|
||||
Mcu_ScreeningT_OrderHeaderID,
|
||||
Mcu_ScreeningT_SampleTypeID,
|
||||
Mcu_ScreeningBarcode,
|
||||
Mcu_ScreeningUserID,
|
||||
Mcu_ScreeningCreated
|
||||
)
|
||||
VALUES(
|
||||
{$row['agreement_id']},
|
||||
{$row['orderid']},
|
||||
{$row['sampletype_id']},
|
||||
'{$row['barcode']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
$msg = "Spesimen ".$row['name']." [".$row['barcode']."] berhasil masuk screening";
|
||||
}
|
||||
else{
|
||||
$msg = "Spesimen ".$row['name']." [".$row['barcode']."] sudah di screening";
|
||||
}
|
||||
}else{
|
||||
$msg = "Spesimen dengan barcode ".$prm['name']." [".$prm['barcode']."] tidak ditemukan";
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $msg
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user