Initial import
This commit is contained in:
85
one-api/application/controllers/v1/masterdata/Jpaleft.php
Normal file
85
one-api/application/controllers/v1/masterdata/Jpaleft.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
class Jpaleft extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "Samplingverify API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT nat_jpa.*,'N' as open_edit
|
||||
FROM nat_jpa
|
||||
WHERE
|
||||
Nat_JpaIsActive = 'Y'
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_regional->query($sql);
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => count($rows), "records" => $rows, "sql"=> $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if(intval($prm['id']) != 0){
|
||||
if($prm['status'] == 'N')
|
||||
$query =" UPDATE nat_jpa SET Nat_JpaIsActive = 'N', Nat_JpaUserID = {$userid} WHERE Nat_JpaID = {$prm['id']}";
|
||||
else
|
||||
$query =" UPDATE nat_jpa SET Nat_JpaName = '{$prm['Nat_JpaName']}', Nat_JpaUserID = {$userid} WHERE Nat_JpaID = {$prm['id']}";
|
||||
}
|
||||
else{
|
||||
$query = "insert into nat_jpa(
|
||||
Nat_JpaName,
|
||||
Nat_JpaUserID,
|
||||
Nat_JpaCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['value']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
)";
|
||||
}
|
||||
//echo $query;
|
||||
$action = $this->db_regional->query($query);
|
||||
|
||||
if($action){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db($this->db_regional->last_query(), $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user