60 lines
2.1 KiB
PHP
60 lines
2.1 KiB
PHP
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
/** Orgusers_model januari 2015 */
|
|
|
|
class Orgusers_model extends MY_Model{
|
|
|
|
|
|
protected $tablename = 'tb_orgusers';
|
|
|
|
function getuserrole($userid, $orgid){
|
|
$this->sql="SELECT AN.nivo
|
|
FROM tb_orgusers OU
|
|
JOIN tb_autorisaties A ON orguser_id = OU.id
|
|
JOIN tb_autorisatienivos AN ON AN.id = A.nivo_id
|
|
WHERE user_id={$userid}
|
|
AND organisatie_id = {$orgid}";
|
|
return $this->get_query_row();
|
|
}
|
|
|
|
function get_org_users($orgid, $level = FALSE){
|
|
$this->sql=" SELECT ou.id,
|
|
CONCAT_WS(' ', u.voornaam,u.tussenvoegsel,u.achternaam) as fullname
|
|
FROM tb_orgusers ou, tb_users u
|
|
WHERE ou.organisatie_id = {$orgid}
|
|
AND u.id = ou.user_id
|
|
AND u.actief = 1";
|
|
if ($level) {
|
|
$this->sql .= " AND u.gnaam IS NOT NULL ";
|
|
}
|
|
$this->sql .= " ORDER BY u.achternaam ";
|
|
return $this->get_query_result();
|
|
}
|
|
function get_user($userid, $orgid){
|
|
$this->sql=" SELECT ou.id,
|
|
CONCAT_WS(' ', u.voornaam,u.tussenvoegsel,u.achternaam) as fullname
|
|
FROM tb_orgusers ou
|
|
JOIN tb_users u ON u.id = ou.user_id
|
|
WHERE ou.organisatie_id = {$orgid}
|
|
AND ou.user_id = {$userid}";
|
|
return $this->get_query_result();
|
|
}
|
|
function get_org_user($userid){
|
|
$this->sql="SELECT ou.id,
|
|
CONCAT_WS(' ', u.voornaam,u.tussenvoegsel,u.achternaam) as fullname
|
|
FROM tb_orgusers ou, tb_users u
|
|
WHERE ou.id= {$userid}
|
|
AND u.id = ou.user_id";
|
|
return $this->get_query_row();
|
|
}
|
|
function gethighestautorisatie($userid){
|
|
$this->sql = "SELECT OU.id, OU.user_id,OU.organisatie_id ,AN.nivo
|
|
FROM tb_orgusers OU
|
|
JOIN tb_autorisaties A ON A.orguser_id = OU.id
|
|
JOIN tb_autorisatienivos AN ON AN.id = A.nivo_id
|
|
WHERE OU.user_id={$userid}
|
|
AND AN.nivo <>0
|
|
ORDER BY nivo";
|
|
return $this->get_query_row();
|
|
}
|
|
} |