144 lines
4.4 KiB
PHP
144 lines
4.4 KiB
PHP
<?php
|
|
class Uploadpaymentpoint extends MY_Controller
|
|
{
|
|
var $db;
|
|
var $load;
|
|
var $sspricemou;
|
|
var $hostname;
|
|
var $db_onedev;
|
|
|
|
public function index()
|
|
{
|
|
echo "CPONE MD PRICE API";
|
|
}
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_onedev = $this->load->database("onedev", true);
|
|
$this->hostname = 'bankpoint.jala.my.id';
|
|
// $this->load->library("SsPriceMou");
|
|
}
|
|
function reply($resp)
|
|
{
|
|
echo json_encode($resp);
|
|
}
|
|
|
|
function reply_gz($resp, $debug = "")
|
|
{
|
|
if ($debug != "") {
|
|
echo json_encode($resp);
|
|
} else {
|
|
echo gzcompress(json_encode($resp));
|
|
}
|
|
}
|
|
|
|
function get_param()
|
|
{
|
|
$body = file_get_contents("php://input");
|
|
return json_decode($body, true);
|
|
}
|
|
|
|
function get_param_z()
|
|
{
|
|
$body_z = file_get_contents("php://input");
|
|
$body = gzuncompress($body_z);
|
|
return json_decode($body, true);
|
|
}
|
|
public function post($url, $data)
|
|
{
|
|
$ch = curl_init($url);
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
|
"Content-Type: application/text",
|
|
"Content-Length: " . strlen($data),
|
|
]);
|
|
$result = curl_exec($ch);
|
|
if (curl_error($ch) != "") {
|
|
echo json_encode([
|
|
"status" => "ERR",
|
|
"message" => "Http Error : " . curl_error($ch),
|
|
]);
|
|
curl_close($ch);
|
|
exit();
|
|
}
|
|
curl_close($ch);
|
|
return $result;
|
|
}
|
|
public function list($date = "")
|
|
{
|
|
if ($date == "") {
|
|
$date = date("Y-m-d");
|
|
}
|
|
$sql = "select F_PaymentDetailID,
|
|
T_OrderHeaderID,
|
|
M_PatientIDNumber as NIK,
|
|
T_OrderHeaderM_PatientID,
|
|
T_OrderHeaderLabNumber as nolab,
|
|
F_PaymentDetailCreated as tgl,
|
|
M_BranchCode as brachcode,
|
|
M_BranchName as brachname,
|
|
F_PaymentDetailAmount as total_payment
|
|
FROM
|
|
f_paymentdetail
|
|
JOIN f_payment ON F_PaymentID = F_PaymentDetailF_PaymentID
|
|
JOIN t_orderheader ON T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
|
JOIN m_patient ON M_PatientID = T_OrderHeaderM_PatientID
|
|
JOIN m_branch ON M_BranchIsActive = 'Y' AND M_BranchIsDefault = 'Y'
|
|
WHERE F_PaymentDetailM_PaymentTypeID = '30'
|
|
AND F_PaymentDetailIsActive = 'Y'
|
|
AND date(F_PaymentDetailCreated) = ?
|
|
AND F_PaymentDetailAmount > 0";
|
|
|
|
$qry = $this->db_onedev->query($sql, array($date));
|
|
//echo $this->db_onedev->last_query();
|
|
if (!$qry) {
|
|
$rst["message"] = "Err select f_paymentdetail | " . $this->db_onedev->error()["message"] . "|"
|
|
. $this->db_onedev->last_query();
|
|
}
|
|
$rows = $qry->result_array();
|
|
if ($api == "Y") {
|
|
$this->sys_ok($rows);
|
|
# code...
|
|
}
|
|
return $rows;
|
|
}
|
|
function upload($date = "")
|
|
{
|
|
if ($date == "") {
|
|
$date = date("Y-m-d");
|
|
}
|
|
$url_nat = "http://" . $this->hostname . "/one-api/tools/member/downloadpaymentpoint/getpaymentpoint/";
|
|
$data = $this->list($date);
|
|
$prm = array(
|
|
"status" => 'OK',
|
|
"data" => $data,
|
|
);
|
|
$prm_json = gzcompress(json_encode($prm));
|
|
// echo "JSON PRM \n";
|
|
// print_r($prm_json);
|
|
// echo " \n";
|
|
// print_r($url_nat . "generate");
|
|
// echo " \n";
|
|
if (count($data) > 0) {
|
|
# code...
|
|
$resp = $this->post($url_nat . "generate", $prm_json);
|
|
// echo "JSON resp \n";
|
|
// print_r($resp);
|
|
$retVal = json_decode(gzuncompress($resp), true);
|
|
// print_r($retVal);
|
|
if ($retVal['status'] == 'OK') {
|
|
$this->sys_ok("Success");
|
|
} else {
|
|
$this->sys_error($retVal);
|
|
};
|
|
} else {
|
|
$this->sys_ok("Tidak ada data update");
|
|
}
|
|
}
|
|
}
|