step 1 : download one api pettycash
This commit is contained in:
55
pettycash/Usercompany.php
Normal file
55
pettycash/Usercompany.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
class Usercompany extends MY_Controller {
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "AUTH API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
function list_company(){
|
||||
try {
|
||||
//# cek token valid
|
||||
/* if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
*/
|
||||
$prm = $this->sys_input;
|
||||
$sql = "SELECT
|
||||
M_CompanyID as companyid,
|
||||
M_CompanyName as companyname,
|
||||
M_UserDefaultCompany
|
||||
FROM m_user
|
||||
join m_usercompany
|
||||
on M_UserCompanyM_UserID = M_UserID
|
||||
and M_UserCompanyIsActive = 'Y'
|
||||
join m_company
|
||||
on M_CompanyID = M_UserCompanyM_CompanyID
|
||||
and M_CompanyIsActive = 'Y'
|
||||
WHERE M_userID = ?
|
||||
and M_UserIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,array($prm['M_UserID']));
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("Company select");
|
||||
exit;
|
||||
}
|
||||
$this->sys_ok($rows);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user