Initial import
This commit is contained in:
226
one-api/application/controllers/v1/master/Bank.php
Normal file
226
one-api/application/controllers/v1/master/Bank.php
Normal file
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
/*
|
||||
### Bank API
|
||||
- Functions
|
||||
- search
|
||||
- add
|
||||
- edit
|
||||
- delete
|
||||
|
||||
template function {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class Bank extends MY_Controller {
|
||||
function index() {
|
||||
echo "Bank Api";
|
||||
}
|
||||
function search() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
|
||||
//2A. jumlah baris per page default 25 jika tidak di set
|
||||
$row_per_page = 10;
|
||||
if (isset($prm["row_per_page"])) $row_per_page = $prm["row_per_page"];
|
||||
$page = 1;
|
||||
if (isset($prm["page"])) $page = $prm["page"];
|
||||
$tot_count = 0;
|
||||
$sql_param = array($s_query);
|
||||
|
||||
//3. hitung total rows
|
||||
$sql = "select count(*) as tot
|
||||
from m_bank
|
||||
where M_BankName like ? and M_BankIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("m_bank count");
|
||||
exit;
|
||||
}
|
||||
|
||||
//4. cari records jika total count > 0
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
//4A. start_limit set ke 0 jika negative atau > total count
|
||||
$start_limit = ($page - 1) * $row_per_page;
|
||||
if ($start_limit > $tot_count) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
if ($start_limit < 0) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
$sql = "select *
|
||||
from m_bank
|
||||
where M_BankName like ? and M_BankIsActive='Y'
|
||||
limit $start_limit,$row_per_page";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_bank rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function add() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//3. validasi input jika di perlukan, contoh di sini cek M_BankCode harus belum ada
|
||||
$sql = "select count(*) tot
|
||||
from m_bank
|
||||
where M_BankIsActive='Y' and M_BankCode=?";
|
||||
$query = $this->db->query($sql,array($prm["M_BankCode"]));
|
||||
//cek jika query error kirim pesan agar tidak crash
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
if ($tot_count > 0) {
|
||||
$message = "BankCode : " . $prm["M_BankCode"] . " already exists.";
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_bank bankCode validation");
|
||||
exit;
|
||||
}
|
||||
//4. insert statement menggunakan explicit field name di sebutkan
|
||||
// untuk menghindari kesalahan karena penambahan field baru
|
||||
$sql = "insert into m_bank(M_BankCode, M_BankName, M_BankAddress, M_BankBranch, M_BankHISDefault,
|
||||
M_BankUserID, M_BankLastUpdate) values( ?, ?, ?, ?, ?, ?, now())";
|
||||
//4a. Create statment
|
||||
$query = $this->db->query($sql,
|
||||
array($prm["M_BankCode"], $prm["M_BankName"], $prm["M_BankAddress"], $prm["M_BankBranch"], $prm["M_BankHisIsDefault"],
|
||||
$tokenM_UserID)
|
||||
);
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"inserted_id" => $this->db->insert_id(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_bank insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function edit() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_bank
|
||||
set M_BankCode = ? , M_BankName = ?, M_BankAddress = ? , M_BankBranch = ?, M_BankHISDefault = ?,
|
||||
M_BankLastUpdate = now() , M_BankUserID = ?
|
||||
where M_BankID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$prm["M_BankCode"], $prm["M_BankName"], $prm["M_BankAddress"], $prm["M_BankBranch"], $prm["M_BankHISDefault"],
|
||||
$tokenM_UserID, $prm["M_BankID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_bank update");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function delete() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_bank
|
||||
set M_BankIsActive = 'N', M_BankLastUpdate = now(),
|
||||
M_BankUserID = ?
|
||||
where M_BankID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$tokenM_UserID, $prm["M_BankID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_bank delete");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
209
one-api/application/controllers/v1/master/Pamorfology.php
Normal file
209
one-api/application/controllers/v1/master/Pamorfology.php
Normal file
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
/*
|
||||
### Sex API
|
||||
- Functions
|
||||
- search
|
||||
- add
|
||||
- edit
|
||||
- delete
|
||||
|
||||
template function {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class Pamorfology extends MY_Controller {
|
||||
function index() {
|
||||
echo "Pamorfology Api";
|
||||
}
|
||||
function search() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
|
||||
//2A. jumlah baris per page default 25 jika tidak di set
|
||||
$row_per_page = 25;
|
||||
if (isset($prm["row_per_page"])) $row_per_page = $prm["row_per_page"];
|
||||
$page = 1;
|
||||
if (isset($prm["page"])) $page = $prm["page"];
|
||||
$tot_count = 0;
|
||||
$sql_param = array($s_query);
|
||||
|
||||
//3. hitung total rows
|
||||
$sql = "select count(*) as tot
|
||||
from pa_morfology
|
||||
where Pa_MorfologyName like ? and Pa_MorfologyIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("pa_morfology count");
|
||||
exit;
|
||||
}
|
||||
|
||||
//4. cari records jika total count > 0
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
//4A. start_limit set ke 0 jika negative atau > total count
|
||||
$start_limit = ($page - 1) * $row_per_page;
|
||||
if ($start_limit > $tot_count) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
if ($start_limit < 0) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
$sql = "select *
|
||||
from pa_morfology
|
||||
where Pa_MorfologyName like ? and Pa_MorfologyIsActive='Y'
|
||||
limit $start_limit,$row_per_page";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("pa_morfology rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function add() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["Pa_MorfologyUserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
|
||||
//4. insert statement menggunakan explicit field name di sebutkan
|
||||
// untuk menghindari kesalahan karena penambahan field baru
|
||||
$sql = "insert into pa_morfology(Pa_MorfologyName, Pa_MorfologyUserID, Pa_MorfologyLastUpdate) values( ?,?, now())";
|
||||
//4a. Create statment
|
||||
$query = $this->db->query($sql,
|
||||
array($prm["Pa_MorfologyName"],$tokenM_UserID)
|
||||
);
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"inserted_id" => $this->db->insert_id(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("pa_morfology insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function edit() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["Pa_MorfologyUserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update pa_morfology
|
||||
set Pa_MorfologyName = ?,
|
||||
Pa_MorfologyLastUpdate = now() , Pa_MorfologyUserID = ?
|
||||
where Pa_MorfologyID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$prm["Pa_MorfologyName"],
|
||||
$tokenM_UserID, $prm["Pa_MorfologyID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("pa_morfology update");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function delete() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["Pa_MorfologyUserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update pa_morfology
|
||||
set Pa_MorfologyIsActive = 'N', Pa_MorfologyLastUpdate = now(),
|
||||
Pa_MorfologyUserID = ?
|
||||
where Pa_MorfologyID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$tokenM_UserID, $prm["Pa_MorfologyID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("pa_morfology delete");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
95
one-api/application/controllers/v1/master/Province.php
Normal file
95
one-api/application/controllers/v1/master/Province.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Province extends MY_Controller
|
||||
{
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
|
||||
// $this->sys_debug();
|
||||
try
|
||||
{
|
||||
// Token validation
|
||||
if (! $this->isLogin)
|
||||
{
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Getting inputs
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
|
||||
// Predefined values
|
||||
$row_per_page = 25;
|
||||
$page = 1;
|
||||
$tot_count = 0;
|
||||
|
||||
$sqlc = "SELECT COUNT(*) as n
|
||||
FROM m_province
|
||||
WHERE M_ProvinceName LIKE ? AND M_ProvinceIsActive='Y'";
|
||||
|
||||
if (isset($prm["row_per_page"])) $row_per_page = $prm["row_per_page"];
|
||||
if (isset($prm["page"])) $page = $prm["page"];
|
||||
|
||||
$sql_param = array($s_query);
|
||||
|
||||
// Getting total rows
|
||||
$sql = $sqlc;
|
||||
$query = $this->db->query($sql, $sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->row()->n;
|
||||
} else {
|
||||
$this->sys_error_db("m_sex count");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Getting records if count > 0
|
||||
$rows = array();
|
||||
if ($tot_count > 0)
|
||||
{
|
||||
// Start_limit < 0 ? > total_count ?
|
||||
$start_limit = ($page - 1) * $row_per_page;
|
||||
if ($start_limit > $tot_count)
|
||||
$start_limit = 0;
|
||||
|
||||
if ($start_limit < 0)
|
||||
$start_limit = 0;
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM m_province
|
||||
WHERE M_ProvinceName like ? and M_ProvinceIsActive='Y'
|
||||
LIMIT $start_limit, $row_per_page";
|
||||
$query = $this->db->query($sql, $sql_param);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_sex rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
}
|
||||
|
||||
catch(Exception $exc)
|
||||
{
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
229
one-api/application/controllers/v1/master/Religion.php
Normal file
229
one-api/application/controllers/v1/master/Religion.php
Normal file
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
/*
|
||||
### Religion API
|
||||
- Functions
|
||||
- search
|
||||
- add
|
||||
- edit
|
||||
- delete
|
||||
|
||||
template function {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class Religion extends MY_Controller {
|
||||
function index() {
|
||||
echo "Religion Api";
|
||||
}
|
||||
function search() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
|
||||
//2A. jumlah baris per page default 25 jika tidak di set
|
||||
$row_per_page = 10;
|
||||
if (isset($prm["row_per_page"])) $row_per_page = $prm["row_per_page"];
|
||||
$page = 1;
|
||||
if (isset($prm["page"])) $page = $prm["page"];
|
||||
$tot_count = 0;
|
||||
$sql_param = array($s_query);
|
||||
|
||||
//3. hitung total rows
|
||||
$sql = "select count(*) as tot
|
||||
from m_religion
|
||||
where M_ReligionName like ? and M_ReligionIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("m_religion count");
|
||||
exit;
|
||||
}
|
||||
|
||||
//4. cari records jika total count > 0
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
//4A. start_limit set ke 0 jika negative atau > total count
|
||||
$start_limit = ($page - 1) * $row_per_page;
|
||||
if ($start_limit > $tot_count) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
if ($start_limit < 0) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
$sql = "select *
|
||||
from m_religion
|
||||
where M_ReligionName like ? and M_ReligionIsActive='Y'
|
||||
limit $start_limit,$row_per_page";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_religion rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function add() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//3. validasi input jika di perlukan, contoh di sini cek M_ReligionCode harus belum ada
|
||||
/*
|
||||
$sql = "select count(*) tot
|
||||
from m_religion
|
||||
where M_ReligionIsActive='Y' and M_ReligionCode=?";
|
||||
$query = $this->db->query($sql,array($prm["M_ReligionCode"]));
|
||||
//cek jika query error kirim pesan agar tidak crash
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
if ($tot_count > 0) {
|
||||
$message = "ReligionCode : " . $prm["M_ReligionCode"] . " already exists.";
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_religion religionCode validation");
|
||||
exit;
|
||||
}
|
||||
|
||||
*/
|
||||
//4. insert statement menggunakan explicit field name di sebutkan
|
||||
// untuk menghindari kesalahan karena penambahan field baru
|
||||
$sql = "insert into m_religion(M_ReligionName, M_ReligionHISDefault,
|
||||
M_ReligionUserID, M_ReligionLastUpdate) values(?, ?, ?, now())";
|
||||
//4a. Create statment
|
||||
$query = $this->db->query($sql,
|
||||
array($prm["M_ReligionName"], $prm["M_ReligionHISDefault"],
|
||||
$tokenM_UserID)
|
||||
);
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"inserted_id" => $this->db->insert_id(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_religion insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function edit() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_religion
|
||||
set M_ReligionName = ?, M_ReligionHISDefault = ?,
|
||||
M_ReligionLastUpdate = now() , M_ReligionUserID = ?
|
||||
where M_ReligionID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$prm["M_ReligionName"], $prm["M_ReligionHISDefault"],
|
||||
$tokenM_UserID, $prm["M_ReligionID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_religion update");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function delete() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_religion
|
||||
set M_ReligionIsActive = 'N', M_ReligionLastUpdate = now(),
|
||||
M_ReligionUserID = ?
|
||||
where M_ReligionID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$tokenM_UserID, $prm["M_ReligionID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_religion delete");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
226
one-api/application/controllers/v1/master/Sex.php
Normal file
226
one-api/application/controllers/v1/master/Sex.php
Normal file
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
/*
|
||||
### Sex API
|
||||
- Functions
|
||||
- search
|
||||
- add
|
||||
- edit
|
||||
- delete
|
||||
|
||||
template function {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class Sex extends MY_Controller {
|
||||
function index() {
|
||||
echo "Sex Api";
|
||||
}
|
||||
function search() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
|
||||
//2A. jumlah baris per page default 25 jika tidak di set
|
||||
$row_per_page = 25;
|
||||
if (isset($prm["row_per_page"])) $row_per_page = $prm["row_per_page"];
|
||||
$page = 1;
|
||||
if (isset($prm["page"])) $page = $prm["page"];
|
||||
$tot_count = 0;
|
||||
$sql_param = array($s_query);
|
||||
|
||||
//3. hitung total rows
|
||||
$sql = "select count(*) as tot
|
||||
from m_sex
|
||||
where M_SexName like ? and M_SexIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("m_sex count");
|
||||
exit;
|
||||
}
|
||||
|
||||
//4. cari records jika total count > 0
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
//4A. start_limit set ke 0 jika negative atau > total count
|
||||
$start_limit = ($page - 1) * $row_per_page;
|
||||
if ($start_limit > $tot_count) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
if ($start_limit < 0) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
$sql = "select *
|
||||
from m_sex
|
||||
where M_SexName like ? and M_SexIsActive='Y'
|
||||
limit $start_limit,$row_per_page";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_sex rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function add() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//3. validasi input jika di perlukan, contoh di sini cek M_SexCode harus belum ada
|
||||
$sql = "select count(*) tot
|
||||
from m_sex
|
||||
where M_SexIsActive='Y' and M_SexCode=?";
|
||||
$query = $this->db->query($sql,array($prm["M_SexCode"]));
|
||||
//cek jika query error kirim pesan agar tidak crash
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
if ($tot_count > 0) {
|
||||
$message = "SexCode : " . $prm["M_SexCode"] . " already exists.";
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_sex sexCode validation");
|
||||
exit;
|
||||
}
|
||||
//4. insert statement menggunakan explicit field name di sebutkan
|
||||
// untuk menghindari kesalahan karena penambahan field baru
|
||||
$sql = "insert into m_sex(M_SexCode, M_SexName, M_SexHISDefault,
|
||||
M_SexUserID, M_SexLastUpdate) values( ?, ?, ?, ?, now())";
|
||||
//4a. Create statment
|
||||
$query = $this->db->query($sql,
|
||||
array($prm["M_SexCode"], $prm["M_SexName"], $prm["M_SexHisIsDefault"],
|
||||
$tokenM_UserID)
|
||||
);
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"inserted_id" => $this->db->insert_id(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_sex insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function edit() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_sex
|
||||
set M_SexCode = ? , M_SexName = ?, M_SexHISDefault = ?,
|
||||
M_SexLastUpdate = now() , M_SexUserID = ?
|
||||
where M_SexID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$prm["M_SexCode"], $prm["M_SexName"], $prm["M_SexHISDefault"],
|
||||
$tokenM_UserID, $prm["M_SexID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_sex update");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function delete() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_sex
|
||||
set M_SexIsActive = 'N', M_SexLastUpdate = now(),
|
||||
M_SexUserID = ?
|
||||
where M_SexID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$tokenM_UserID, $prm["M_SexID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_sex delete");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
231
one-api/application/controllers/v1/master/Title.php
Normal file
231
one-api/application/controllers/v1/master/Title.php
Normal file
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
/*
|
||||
### Title API
|
||||
- Functions
|
||||
- search
|
||||
- add
|
||||
- edit
|
||||
- delete
|
||||
|
||||
template function {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class Title extends MY_Controller {
|
||||
function index() {
|
||||
echo "Title Api";
|
||||
}
|
||||
function search() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
$s_query2 = "%" . $prm["query2"] . "%";
|
||||
|
||||
//2A. jumlah baris per page default 25 jika tidak di set
|
||||
$row_per_page = 25;
|
||||
if (isset($prm["row_per_page"])) $row_per_page = $prm["row_per_page"];
|
||||
$page = 1;
|
||||
if (isset($prm["page"])) $page = $prm["page"];
|
||||
$tot_count = 0;
|
||||
$sql_param = array($s_query,$s_query2);
|
||||
|
||||
//3. hitung total rows
|
||||
$sql = "select count(*) as tot
|
||||
from m_title
|
||||
left join m_sex on M_TitleM_SexID = M_SexID
|
||||
where M_TitleName like ? and M_SexName like ? and M_TitleIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("m_title count");
|
||||
exit;
|
||||
}
|
||||
|
||||
//4. cari records jika total count > 0
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
//4A. start_limit set ke 0 jika negative atau > total count
|
||||
$start_limit = ($page - 1) * $row_per_page;
|
||||
if ($start_limit > $tot_count) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
if ($start_limit < 0) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
$sql = "select *, M_SexName
|
||||
from m_title
|
||||
left join m_sex on M_TitleM_SexID = M_SexID
|
||||
where M_TitleName like ? and M_SexName like ? and M_TitleIsActive='Y'
|
||||
limit $start_limit,$row_per_page";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_title rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function add() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//3. validasi input jika di perlukan, contoh di sini cek M_TitleCode harus belum ada
|
||||
/*
|
||||
$sql = "select count(*) tot
|
||||
from m_title
|
||||
where M_TitleIsActive='Y' and M_TitleCode=?";
|
||||
$query = $this->db->query($sql,array($prm["M_TitleCode"]));
|
||||
//cek jika query error kirim pesan agar tidak crash
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
if ($tot_count > 0) {
|
||||
$message = "TitleCode : " . $prm["M_TitleCode"] . " already exists.";
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_title titleCode validation");
|
||||
exit;
|
||||
}
|
||||
*/
|
||||
//4. insert statement menggunakan explicit field name di sebutkan
|
||||
// untuk menghindari kesalahan karena penambahan field baru
|
||||
$sql = "insert into m_title(M_TitleM_SexID, M_TitleName, M_TitleHISDefault,
|
||||
M_TitleUserID, M_TitleLastUpdate) values( ?, ?, ?, ?, now())";
|
||||
//4a. Create statment
|
||||
$query = $this->db->query($sql,
|
||||
array($prm["M_TitleM_SexID"], $prm["M_TitleName"], $prm["M_TitleHISDefault"],
|
||||
$tokenM_UserID)
|
||||
);
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"inserted_id" => $this->db->insert_id(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_title insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function edit() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_title
|
||||
set M_TitleM_SexID = ? , M_TitleName = ?, M_TitleHISDefault = ?,
|
||||
M_TitleLastUpdate = now() , M_TitleUserID = ?
|
||||
where M_TitleID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$prm["M_TitleM_SexID"], $prm["M_TitleName"], $prm["M_TitleHISDefault"],
|
||||
$tokenM_UserID, $prm["M_TitleID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_title update");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function delete() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_title
|
||||
set M_TitleIsActive = 'N', M_TitleLastUpdate = now(),
|
||||
M_TitleUserID = ?
|
||||
where M_TitleID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$tokenM_UserID, $prm["M_TitleID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_title delete");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user