129 lines
4.4 KiB
PHP
129 lines
4.4 KiB
PHP
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
/** Users_model januari 2015 */
|
|
|
|
class Users_model extends MY_Model{
|
|
|
|
|
|
protected $tablename = "tb_users";
|
|
public $gID;
|
|
|
|
function __construct(){
|
|
parent::__construct();
|
|
$models = array();
|
|
$this->load->model($models);
|
|
$this->userid = $this->session->userdata('userid');//gets userid from session
|
|
if($this->userid){
|
|
$this->get_fullname($this->userid);//set the full username if user is logged on
|
|
$this->gID = $this->userid;
|
|
}
|
|
}
|
|
function get_user_detail_by_id($userid){
|
|
$this->sql = "SELECT id, gnaam as user_name, concat_ws(' ' , voornaam, tussenvoegsel, achternaam) as fullname
|
|
FROM tb_users
|
|
WHERE id={$userid}";
|
|
return $this->get_query_row();
|
|
}
|
|
function get_fullname($userid){
|
|
$this->sql=" select concat_ws(' ', voornaam,tussenvoegsel,achternaam) as fullname
|
|
from tb_users
|
|
where id = {$userid}";
|
|
$rij = $this->get_query_row();
|
|
return $rij->fullname;
|
|
}
|
|
function getdetails ($userid){
|
|
$this->sql = "SELECT voornaam , tussenvoegsel, achternaam, email, zout
|
|
FROM tb_users
|
|
WHERE id = $userid";
|
|
return $this->get_query_row();
|
|
}
|
|
|
|
function getorggebruikers($orgid,$userid=false){
|
|
$this->sql = "SELECT U.id as userid, voornaam, tussenvoegsel, achternaam, email,gnaam, U.actief,
|
|
A.nivo_id, AN.naam as autorisatienaam, if (AN.nivo > 0, TRUE,FALSE) as OUactief
|
|
FROM tb_users U
|
|
JOIN tb_orgusers OU ON OU.user_id= U.id
|
|
JOIN tb_autorisaties A ON A.orguser_id = OU.id
|
|
JOIN tb_autorisatienivos AN ON AN.id = A.nivo_id
|
|
WHERE OU.organisatie_id = $orgid";
|
|
if ($userid) {
|
|
$this->sql .=" AND U.id = {$userid} ";
|
|
};
|
|
|
|
$this->sql .= " ORDER BY UPPER(U.achternaam)";
|
|
if ($userid) {return $this->get_query_row() ;}
|
|
else {return $this->get_query_result();}
|
|
}
|
|
function check_username($gnaam,$userid = false){
|
|
$this->sql="SELECT count(id) as aantal
|
|
FROM tb_users
|
|
WHERE gnaam = '{$gnaam}'";
|
|
if ($userid) {
|
|
$this->sql .= " AND id <> $userid ";
|
|
}
|
|
$gevonden= $this->get_query_row();
|
|
return $gevonden->aantal;
|
|
}
|
|
function getleerkracht($lkid){
|
|
$this->sql = "SELECT U.id, OU.organisatie_id, U.aanhef,
|
|
U.voornaam, U.tussenvoegsel, U.achternaam, U.email,
|
|
A.nivo_id
|
|
FROM tb_orgusers OU
|
|
JOIN tb_autorisaties A ON A.orguser_id = OU.id
|
|
JOIN tb_users U ON U.id = OU.user_id
|
|
WHERE U.actief = 1
|
|
AND U.id = {$lkid}";
|
|
return $this->get_query_row();
|
|
}
|
|
function getleerkrachten($orgid){
|
|
$this->sql = "SELECT U.id, U.id as userid, OU.organisatie_id, U.aanhef,
|
|
U.voornaam, U.tussenvoegsel, U.achternaam, U.email,
|
|
concat_ws(' ',U.voornaam, U.tussenvoegsel, U.achternaam) AS fullname,
|
|
A.nivo_id
|
|
FROM tb_orgusers OU
|
|
JOIN tb_autorisaties A ON A.orguser_id = OU.id
|
|
JOIN tb_users U ON U.id = OU.user_id
|
|
WHERE U.actief = 1
|
|
AND OU.organisatie_id = {$orgid}
|
|
AND A.nivo_id <> 100
|
|
ORDER BY U.achternaam";
|
|
return $this->get_query_result();
|
|
}
|
|
// function otherusers($orgid, $orgids){
|
|
// $this->sql="SELECT DISTINCT(U.id), concat_ws(' ',voornaam, tussenvoegsel, achternaam) AS fullname
|
|
// FROM tb_users U
|
|
// JOIN tb_orgusers OU ON OU.user_id= U.id
|
|
// WHERE (SELECT count(id) FROM tb_orgusers WHERE user_id = U.id AND organisatie_id = {$orgid})
|
|
// AND (OU.organisatie_id IN ({$orgids}) )
|
|
// ORDER BY achternaam";
|
|
// return $this->get_query_result();
|
|
// }
|
|
function otherusers($orgid, $orgids){
|
|
$this->sql="SELECT DISTINCT(U.id), concat_ws(' ',voornaam, tussenvoegsel, achternaam) AS fullname
|
|
FROM tb_users U
|
|
JOIN tb_orgusers OU ON OU.user_id= U.id
|
|
WHERE OU.organisatie_id IN ({$orgids})
|
|
AND U.actief = 1
|
|
AND U.voornaam <> ''
|
|
AND U.achternaam <> ''
|
|
AND OU.user_id NOT IN (
|
|
SELECT OU2.user_id
|
|
FROM tb_orgusers OU2
|
|
WHERE OU2.organisatie_id = {$orgid}
|
|
)
|
|
GROUP BY U.id
|
|
ORDER BY achternaam ";
|
|
return $this->get_query_result();
|
|
}
|
|
|
|
|
|
function get_users_by_organisatie($orgid){
|
|
// uit partituur users
|
|
$this->sql = "SELECT U.id, U.gnaam as user_name, concat_ws(' ', voornaam, tussenvoegsel, achternaam) as fullname
|
|
FROM tb_users U
|
|
JOIN tb_orgusers OU on OU.user_id = U.id
|
|
WHERE OU.organisatie_id= {$orgid}
|
|
ORDER BY U.achternaam";
|
|
return $this->get_query_result();
|
|
}
|
|
} |