192 lines
6.3 KiB
PHP
192 lines
6.3 KiB
PHP
<?php
|
|
class Updatenik extends MY_Controller
|
|
{
|
|
var $db_smartone;
|
|
public function index() {
|
|
echo "Update NIK";
|
|
}
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_smartone = $this->load->database("onedev", true);
|
|
}
|
|
|
|
// public function updatenik() {
|
|
// try {
|
|
// if (!$this->isLogin) {
|
|
// $this->sys_error("invalid token");
|
|
// exit;
|
|
// }
|
|
// $para = $this->sys_input;
|
|
// $nik = $para['nik'];
|
|
// $orderID = $para['orderID'];
|
|
|
|
// if (!$nik || !$orderID) {
|
|
// $this->sys_error("[Error] parameter tidak lengkap");
|
|
// exit;
|
|
// }
|
|
|
|
// $url = "https://mobile.pramita.co.id/one_api_coba/mobile/nikupdate/changenik";
|
|
// // $url = "https://devregonline.pramita.co.id/one_api/mobile/nikupdate/changenik";
|
|
// $ch = curl_init($url);
|
|
// $paylaod = json_encode(array(
|
|
// "nik" => $nik,
|
|
// "orderID" => $orderID
|
|
// ));
|
|
|
|
// curl_setopt($ch, CURLOPT_POSTFIELDS, $paylaod);
|
|
// curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
|
// curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
|
// 'Content-Type: application/json',
|
|
// 'Content-Length: ' . strlen($paylaod))
|
|
// );
|
|
|
|
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
// $result = curl_exec($ch);
|
|
// if (!$result) {
|
|
// $error = curl_error($ch);
|
|
// $this->sys_error("cURL Error: " . $error);
|
|
// curl_close($ch);
|
|
// exit;
|
|
// }
|
|
// curl_close($ch);
|
|
// $this->sys_ok($result);
|
|
|
|
// // $array_rst = $this->objToArray(json_decode($result));
|
|
// // if (!$array_rst) {
|
|
// // $this->sys_error("[Error] decode return");
|
|
// // exit;
|
|
// // }
|
|
// // $this->sys_ok($array_rst);
|
|
// } catch (Exception $exc) {
|
|
// $message = $exc->getMessage();
|
|
// $this->sys_error($message);
|
|
// }
|
|
// }
|
|
|
|
public function checkpatient() {
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("invalid token");
|
|
exit;
|
|
}
|
|
|
|
$para = $this->sys_input;
|
|
$dob = $para['dob'];
|
|
$nohp = $para['nohp'];
|
|
$nama = $para['nama'];
|
|
|
|
// $url = "https://mobile.pramita.co.id/one_api_coba/mobile/nikupdate/checkpatient";
|
|
$url = "http://devregonline.pramita.co.id/one_api_coba/mobile/nikupdate/checkpatient";
|
|
$payload = json_encode(array(
|
|
"dob" => $dob,
|
|
"nohp" => $nohp,
|
|
"nama" => $nama
|
|
));
|
|
|
|
$ch = curl_init($url);
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
|
'Content-Type: application/json',
|
|
'Content-Length: ' . strlen($payload)
|
|
));
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
$result = curl_exec($ch);
|
|
if (!$result) {
|
|
$error = curl_error($ch);
|
|
$this->sys_error("cURL Error: " . $error);
|
|
curl_close($ch);
|
|
exit;
|
|
}
|
|
curl_close($ch);
|
|
$array_rst = $this->objToArray(json_decode($result));
|
|
|
|
if ($array_rst['status'] != 'OK') {
|
|
$this->sys_error($array_rst['data']);
|
|
exit;
|
|
}
|
|
|
|
// if (empty($array_rst['data'])) {
|
|
// $this->sys_ok(0);
|
|
// exit;
|
|
// }
|
|
$this->sys_ok($array_rst['data']);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
public function updatenik() {
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("invalid token");
|
|
exit;
|
|
}
|
|
|
|
$para = $this->sys_input;
|
|
$pasnid = $para['patientID'];
|
|
$newnik = $para['newNIK'];
|
|
|
|
if (!$pasnid && !$newnik) {
|
|
$this->sys_error("[Error] empty parameter");
|
|
exit;
|
|
}
|
|
|
|
// $url = "https://mobile.pramita.co.id/one_api_coba/mobile/nikupdate/updatenik";
|
|
$url = "http://devregonline.pramita.co.id/one_api_coba/mobile/nikupdate/updatenik";
|
|
$payload = json_encode(array(
|
|
"patientID" => $pasnid,
|
|
"newNIK" => $newnik
|
|
));
|
|
|
|
$ch = curl_init($url);
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
|
'Content-Type: application/json',
|
|
'Content-Length: ' . strlen($payload)
|
|
));
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
$result = curl_exec($ch);
|
|
if (!$result) {
|
|
$error = curl_error($ch);
|
|
$this->sys_error("cURL Error: " . $error);
|
|
curl_close($ch);
|
|
exit;
|
|
}
|
|
curl_close($ch);
|
|
$array_rst = $this->objToArray(json_decode($result));
|
|
|
|
if ($array_rst['status'] != 'OK') {
|
|
$this->sys_error($array_rst['data']);
|
|
exit;
|
|
}
|
|
|
|
if (empty($array_rst['data'])) {
|
|
$this->sys_error("[Info] Patient not found");
|
|
exit;
|
|
}
|
|
$this->sys_ok($array_rst['data']);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
protected function objToArray($obj) {
|
|
if (!is_object($obj) && !is_array($obj)) {
|
|
return $obj;
|
|
}
|
|
|
|
foreach ($obj as $key => $value) {
|
|
$arr[$key] = $this->objToArray($value);
|
|
}
|
|
|
|
return $arr;
|
|
}
|
|
} |