120 lines
3.7 KiB
PHP
120 lines
3.7 KiB
PHP
<?php
|
|
class Stephen extends MY_Controller{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
// https://devone.aplikasi.web.id/one-api/training/stephen
|
|
function index()
|
|
{
|
|
echo json_encode(["status" => "OK", "message" => ""]);
|
|
}
|
|
|
|
// https://devone.aplikasi.web.id/one-api/training/stephen/upload_request/100
|
|
function upload_request($mouID)
|
|
{
|
|
echo json_encode(["status" => "OK", "message" => "mcuID : $mouID"]);
|
|
}
|
|
function check_agreement($mouID)
|
|
{
|
|
echo json_encode(["status" => "OK", "message" => "mcuID : $mouID"]);
|
|
}
|
|
|
|
// https://devone.aplikasi.web.id/one-api/training/stephen/get_data_sex
|
|
function get_data_sex()
|
|
{
|
|
$user = $this->sys_user;
|
|
echo($user["M_UserID"]);
|
|
echo(" asduashd ");
|
|
$sql = "select * from m_sex where M_SexIsActive ='Y'";
|
|
//1. bikin query
|
|
$qry = $this->db->query($sql);
|
|
if (!$qry) {
|
|
echo json_encode(
|
|
[
|
|
"status" => "ERR",
|
|
"message" => $this->db->error(),
|
|
"sql" => $this->db->last_query()
|
|
]
|
|
);
|
|
exit;
|
|
}
|
|
$rows = $qry->result_array();
|
|
echo json_encode(["status" => "OK", "data" => $rows]);
|
|
}
|
|
|
|
function insert_data_sex()
|
|
{
|
|
// ambil user dari token
|
|
$user = $this->sys_user;
|
|
$userID = $user["M_UserID"];
|
|
$param = $this->sys_input;
|
|
|
|
// start transaction
|
|
$this->db->trans_start();
|
|
|
|
$sql = "insert into m_sex(M_SexCode,m_sexname,M_SexNameLang)
|
|
values (?,?,?)";
|
|
$qry = $this->db->query($sql, [$param["code"], $param["name"], $param["name_lang"]]);
|
|
if (!$qry) {
|
|
echo json_encode(
|
|
[
|
|
"status" => "ERR",
|
|
"message" => $this->db->error(),
|
|
"sql" => $this->db->last_query()
|
|
]
|
|
);
|
|
// rollback jika ada error
|
|
$this->db->trans_rollback();
|
|
exit;
|
|
}
|
|
// insert tbl c
|
|
// commit
|
|
$last_query = $this->db->last_query();
|
|
$xid = $this->db->insert_id();
|
|
$this->db->trans_commit();
|
|
echo json_encode([
|
|
"status" => "OK", "message" => "Last ID : $xid ",
|
|
"sql" => $last_query
|
|
]);
|
|
}
|
|
|
|
function update_data_sex()
|
|
{
|
|
// ambil user dari token
|
|
$user = $this->sys_user;
|
|
$userID = $user["M_UserID"];
|
|
$param = $this->sys_input;
|
|
// start transaction
|
|
$this->db->trans_start();
|
|
|
|
|
|
$sql = "update m_sex set M_SexIsActive = 'N'
|
|
where M_SexID = ?";
|
|
|
|
$qry = $this->db->query($sql, [$param["id"]]);
|
|
if (!$qry) {
|
|
echo json_encode(
|
|
[
|
|
"status" => "ERR",
|
|
"message" => $this->db->error(),
|
|
"sql" => $this->db->last_query()
|
|
]
|
|
);
|
|
// rollback jika ada error
|
|
$this->db->trans_rollback();
|
|
exit;
|
|
}
|
|
// insert tbl c
|
|
// commit
|
|
$last_query = $this->db->last_query();
|
|
$this->db->trans_commit();
|
|
echo json_encode([
|
|
"status" => "OK", "message" => "Last ID : {$param["id"]} ",
|
|
"sql" => $last_query
|
|
]);
|
|
}
|
|
}
|
|
|
|
?>
|