85 lines
1.9 KiB
PHP
85 lines
1.9 KiB
PHP
<?php
|
|
class Jpaleft extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "Samplingverify API";
|
|
}
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_onedev = $this->load->database("onedev", 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_onedev->query($sql);
|
|
$rows = $query->result_array();
|
|
|
|
$result = array("total" => count($rows), "records" => $rows, "sql"=> $this->db_onedev->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_onedev->query($query);
|
|
|
|
if($action){
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array(),
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
else{
|
|
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} |