110 lines
3.7 KiB
PHP
110 lines
3.7 KiB
PHP
<?php
|
|
|
|
class Demolabku_kasir extends MY_Controller
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->debug = false;
|
|
$this->ONLINE_USER_ID = 1500;
|
|
$this->SENDER_DOCTOR_ID = 0;
|
|
$this->SENDER_ADDRESS_ID = 0;
|
|
$this->PJ_DOCTOR_ID = 0;
|
|
$this->KASIR_ONLINE_USER = 1500;
|
|
$this->url =
|
|
"https://sasmobile.aplikasi.web.id/one_api_coba/tools/regonline/r_download/";
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
echo "{$this->now()} Start Serahkan ke kasir\n";
|
|
$this->db->trans_begin();
|
|
$arr = [
|
|
"F_PaymentKasirNumber",
|
|
"F_PaymentKasirDate",
|
|
"F_PaymentKasirUserID",
|
|
];
|
|
$arrd = [
|
|
"F_PaymentKasirDetailF_PaymentID",
|
|
"F_PaymentKasirDetailF_PaymentKasirID",
|
|
];
|
|
$sql = "select F_PaymentID
|
|
from f_payment
|
|
join t_onlineorder
|
|
on F_PaymentT_OrderHeaderID = T_OnlineOrderT_OrderHeaderID
|
|
and T_OnlineOrderIsActive = 'Y'
|
|
and F_PaymentIsActive = 'Y'
|
|
and F_PaymentID not in (
|
|
select F_PaymentKasirDetailF_PaymentID
|
|
from f_payment_kasir_detail
|
|
where F_PaymentKasirDetailIsActive = 'Y'
|
|
)";
|
|
$qry = $this->db->query($sql);
|
|
if (!$qry) {
|
|
$this->db->trans_rollback();
|
|
echo "{$this->now()} ERR : {$this->db->error()["message"]}\n";
|
|
exit();
|
|
}
|
|
$payment_rows = $qry->result_array();
|
|
if (count($payment_rows) == 0) {
|
|
echo "{$this->now()} No Transaction\n";
|
|
exit();
|
|
}
|
|
//get serah no
|
|
$sql = "select fn_numbering('F2C') serah_no";
|
|
$qry = $this->db->query($sql);
|
|
if (!$qry) {
|
|
$this->db->trans_rollback();
|
|
echo "{$this->now()} ERR Get F2C Numbering : {$this->db->error()["message"]}\n";
|
|
exit();
|
|
}
|
|
$rows = $qry->result_array();
|
|
if (count($rows) == 0) {
|
|
echo "{$this->now()} No F2C Numbering \n";
|
|
exit();
|
|
}
|
|
$f2c_no = $rows[0]["serah_no"];
|
|
|
|
//create F_PaymentKasir
|
|
$arr_kasir = [
|
|
"F_PaymentKasirNumber" => $f2c_no,
|
|
"F_PaymentKasirDate" => date("Y-m-d H:i:s"),
|
|
"F_PaymentKasirCreated" => date("Y-m-d H:i:s"),
|
|
"F_PaymentKasirCreated" => date("Y-m-d H:i:s"),
|
|
"F_PaymentKasirUserID" => $this->KASIR_ONLINE_USER,
|
|
];
|
|
$qry = $this->db->insert("f_payment_kasir", $arr_kasir);
|
|
if (!$qry) {
|
|
$this->db->trans_rollback();
|
|
echo "{$this->now()} ERR Insert F Payment Kasir : {$this->db->error()["message"]}\n";
|
|
exit();
|
|
}
|
|
$fPaymentKasirID = $this->db->insert_id();
|
|
//create F_PaymentKasirDetail
|
|
foreach ($payment_rows as $p) {
|
|
$arrd = [
|
|
"F_PaymentKasirDetailF_PaymentID" => $p["F_PaymentID"],
|
|
"F_PaymentKasirDetailF_PaymentKasirID" => $fPaymentKasirID,
|
|
];
|
|
$qry = $this->db->insert("f_payment_kasir_detail", $arrd);
|
|
if (!$qry) {
|
|
$this->db->trans_rollback();
|
|
echo "{$this->now()} ERR Insert F Payment Kasir Detail : {$this->db->error()["message"]}\n";
|
|
exit();
|
|
}
|
|
}
|
|
|
|
if ($this->db->trans_status === false) {
|
|
$this->db->trans_rollback();
|
|
echo "{$this->now()} ERR : {$db_msg}\n";
|
|
} else {
|
|
$this->db->trans_commit();
|
|
echo "{$this->now()} Created Penyerahan Kasir $f2c_no\n";
|
|
}
|
|
}
|
|
public function now()
|
|
{
|
|
return Date("Y-m-d H:i:s");
|
|
}
|
|
}
|