db->query("select database() as current_db")->result(); echo "API local order online dan offline"; // print_r($cek); } function get_order() { try { if (!$this->isLogin) { $this->sys_error("Invalid Token"); exit; } $prm = $this->sys_input; $date = ""; if (isset($prm["date"])) { $date = trim($prm["date"]); } $sql = "SELECT M_BranchID, M_BranchCode, M_BranchName FROM one_hs.m_branch WHERE M_BranchIsActive = 'Y' AND M_BranchIsDefault = 'Y'"; $qry = $this->db->query($sql); $last_query = $this->db->last_query(); if (!$qry) { $this->db->trans_rollback(); $error = array( "message" => $this->db->error()["message"], "qry" => $last_query ); $this->sys_error_db($error); exit; } $rows = $qry->result_array(); if (count($rows) == 0) { $error = array( "message" => "no default branch" ); $this->sys_error_db($error); exit; } $branchid = $rows[0]["M_BranchID"]; $branchcode = $rows[0]["M_BranchCode"]; $sql_online = "SELECT ? as M_BranchID, ? as M_BranchCode, T_OrderID, T_OrderOldID, T_OrderT_TransactionOldID, T_OrderT_TransactionID, T_OrderNumber, T_OrderQrCode, T_OrderM_BranchID, T_OrderM_PatientID, T_OrderM_PatientOldID, T_OrderTest_PurposeID, T_OrderEHAC, T_OrderIsKlinisi, T_OrderDate FROM one_hs.t_order WHERE T_OrderIsActive = 'N' AND T_OrderDate >= ? AND T_OrderT_TransactionOldID IS NOT NULL"; $qry_online = $this->db->query($sql_online, array($branchid, $branchcode, $date)); if ($qry_online) { $rows_online = $qry_online->result_array(); } else { $this->sys_error_db("local online error", $this->db); exit; } $sql_offline = "SELECT ? as M_BranchID, ? as M_BranchCode, T_OrderID, T_OrderOldID, T_OrderT_TransactionOldID, T_OrderT_TransactionID, T_OrderNumber, T_OrderQrCode, T_OrderM_BranchID, T_OrderM_PatientID, T_OrderM_PatientOldID, T_OrderTest_PurposeID, T_OrderEHAC, T_OrderIsKlinisi, T_OrderDate FROM one_hs.t_order WHERE T_OrderDate >= ? AND T_OrderT_TransactionOldID IS NULL"; $qry_offline = $this->db->query($sql_offline, array($branchid, $branchcode, $date)); if ($qry_offline) { $rows_offline = $qry_offline->result_array(); } else { $this->sys_error_db("local offline error", $this->db); exit; } $result = array( "online" => $rows_online, "offline" => $rows_offline ); $this->sys_ok($result); exit; } catch (Exception $exc) { $message = $exc->getMessage(); $this->sys_error($message); } } } ?>