55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?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);
|
|
}
|
|
}
|
|
|
|
}
|
|
?>
|