Files
2026-04-27 10:31:17 +07:00

68 lines
1.9 KiB
PHP

<?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("clinicdev", true);
}
function save()
{
$prm = $this->sys_input;
$prm['header']['complaint'] = str_replace(PHP_EOL, '<br>', $prm['header']['complaint']);
$header_json = json_encode($prm['header']);
$payment_json = json_encode($prm['payment']);
$uid = $this->sys_user['M_UserID'];
$sql = "CALL sp_clinic_fo_save('{$prm['order_id']}', '{$header_json}', '{$payment_json}', '{$uid}');";
$query = $this->db_smartone->query($sql);
if ($query)
{
$rst = $query->row();
$rst->data = json_decode($rst->data);
// if ($rst->status == "OK")
// {
// // persiapkan curl
// $ch = curl_init();
// // set url
// curl_setopt($ch, CURLOPT_URL, "http://anggrek.aplikasi.web.id:9090/ticket/KLINIK");
// // return the transfer as a string
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// // $output contains the output string
// $output = json_decode(curl_exec($ch));
// // tutup curl
// curl_close($ch);
// // menampilkan hasil curl
// // echo $output;
// if ($output != null)
// if ($output->status == "OK")
// $rst->data->queue = $output->data[0]->number;
// }
echo json_encode($rst);
}
else
{
$this->sys_error_db("save order", $this->db_smartone);
exit;
}
}
}