231 lines
4.9 KiB
PHP
231 lines
4.9 KiB
PHP
<?php
|
|
class Jpatestright 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_JPAGroupID,
|
|
Nat_JPAGroupName
|
|
FROM nat_jpagroup
|
|
WHERE
|
|
Nat_JPAGroupIsActive = 'Y'
|
|
GROUP BY Nat_JPAGroupID
|
|
";
|
|
//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;
|
|
}
|
|
|
|
public function search_listing()
|
|
{
|
|
$prm = $this->sys_input;
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT Nat_JPAGroupID,
|
|
Nat_JPAGroupName
|
|
FROM nat_jpagroup
|
|
WHERE
|
|
Nat_JPAGroupIsActive = '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"];
|
|
$query = "insert into nat_jpadetail(
|
|
Nat_JPADetailNat_JPAID,
|
|
Nat_JPADetailNat_JPAGroupID,
|
|
Nat_JPADetailDiscount,
|
|
Nat_JPADetailUserID,
|
|
Nat_JPADetailCreated
|
|
)
|
|
VALUES(
|
|
'{$prm['Nat_JpaID']}',
|
|
'{$prm['Nat_JPAGroupID']}',
|
|
'{$prm['Nat_JPADetailDiscount']}',
|
|
{$userid},
|
|
NOW()
|
|
) ON DUPLICATE KEY UPDATE
|
|
Nat_JPADetailDiscount = {$prm['Nat_JPADetailDiscount']},
|
|
Nat_JPADetailUserID = {$userid}";
|
|
|
|
//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;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
function savejpagroup(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query = "insert into nat_jpagroup(
|
|
Nat_JPAGroupName,
|
|
Nat_JPAGroupUserID,
|
|
Nat_JPAGroupCreated
|
|
)
|
|
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;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
function savelistingjpagroup(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query = " UPDATE nat_jpagroup SET
|
|
Nat_JPAGroupName = '{$prm['name']}',
|
|
Nat_JPAGroupIsActive = '{$prm['status']}',
|
|
Nat_JPAGroupUserID = {$userid}
|
|
WHERE
|
|
Nat_JPAGroupID = {$prm['id']}
|
|
";
|
|
|
|
//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;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
function savealljpadetail(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$details = $prm['details'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
foreach($details as $k => $v){
|
|
$query = "insert into nat_jpadetail(
|
|
Nat_JPADetailNat_JPAID,
|
|
Nat_JPADetailNat_JPAGroupID,
|
|
Nat_JPADetailDiscount,
|
|
Nat_JPADetailUserID,
|
|
Nat_JPADetailCreated
|
|
)
|
|
VALUES(
|
|
'{$v['Nat_JpaID']}',
|
|
'{$v['Nat_JPAGroupID']}',
|
|
'{$v['Nat_JPADetailDiscount']}',
|
|
{$userid},
|
|
NOW()
|
|
) ON DUPLICATE KEY UPDATE
|
|
Nat_JPADetailDiscount = {$v['Nat_JPADetailDiscount']},
|
|
Nat_JPADetailUserID = {$userid}";
|
|
|
|
//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;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |