112 lines
2.9 KiB
PHP
Executable File
112 lines
2.9 KiB
PHP
Executable File
<?php
|
|
|
|
class Order extends MY_Controller
|
|
{
|
|
var $db_smartone;
|
|
public function index()
|
|
{
|
|
echo "ORDER API";
|
|
}
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_smartone = $this->load->database("onedev", true);
|
|
}
|
|
|
|
function save()
|
|
{
|
|
$prm = $this->sys_input;
|
|
$hdr = $prm['header'];
|
|
$header_json = json_encode($hdr);
|
|
$detail_json = json_encode($prm['detail']);
|
|
$delivery_json = json_encode($prm['delivery']);
|
|
$req_json = json_encode($prm['req']);
|
|
|
|
$sql = "CALL sp_fo_register_save('{$prm['order_id']}', '{$header_json}', '{$delivery_json}', '{$detail_json}', '{$req_json}', '{$this->sys_user['M_UserID']}');";
|
|
$query = $this->db_smartone->query($sql);
|
|
|
|
if ($query)
|
|
{
|
|
$rst = $query->row();
|
|
$rst->data = json_decode($rst->data);
|
|
echo json_encode($rst);
|
|
}
|
|
else
|
|
{
|
|
$this->sys_error_db("save order", $this->db_smartone);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
function load_from_clinic()
|
|
{
|
|
$prm = $this->sys_input;
|
|
|
|
$sql = "CALL sp_fo_clinic_load('{$prm['queue']}');";
|
|
$query = $this->db_smartone->query($sql);
|
|
|
|
if ($query)
|
|
{
|
|
$rst = $query->row();
|
|
if ($rst->status == "OK")
|
|
{
|
|
$rst->data = json_decode($rst->data);
|
|
|
|
$rst->data->doctor->address = $rst->data->doctor_address;
|
|
unset($rst->data->doctor_address);
|
|
|
|
$rst->data->company->mou = [$rst->data->mou];
|
|
unset($rst->data->mou);
|
|
}
|
|
else
|
|
{
|
|
$this->sys_error("Tidak ada order");
|
|
exit;
|
|
}
|
|
|
|
echo json_encode($rst);
|
|
}
|
|
else
|
|
{
|
|
$this->sys_error_db("save order", $this->db_smartone);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
function load()
|
|
{
|
|
$prm = $this->sys_input;
|
|
|
|
$sql = "CALL sp_fo_register_load('{$prm['id']}');";
|
|
$query = $this->db_smartone->query($sql);
|
|
|
|
if ($query)
|
|
{
|
|
$rst = $query->row();
|
|
if ($rst->status == "OK")
|
|
{
|
|
$rst->data = json_decode($rst->data);
|
|
|
|
$rst->data->doctor->address = $rst->data->doctor_address;
|
|
unset($rst->data->doctor_address);
|
|
|
|
$rst->data->company->mou = [$rst->data->mou];
|
|
unset($rst->data->mou);
|
|
}
|
|
else
|
|
{
|
|
$this->sys_error("Tidak ada order");
|
|
exit;
|
|
}
|
|
|
|
echo json_encode($rst);
|
|
}
|
|
else
|
|
{
|
|
$this->sys_error_db("save order", $this->db_smartone);
|
|
exit;
|
|
}
|
|
}
|
|
}
|