initial commit
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/** Berichten_model december 2017 */
|
||||
|
||||
class Berichten_model extends MY_Model{
|
||||
|
||||
protected $tablename = 'tb_berichten';
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$models = array('');
|
||||
$this->load->model($models);
|
||||
}
|
||||
function getberichten($userid, $frontpage=FALSE){
|
||||
|
||||
$this->sql =" SELECT B.id, B.samenvatting, B.inhoud, B.startdatum
|
||||
FROM tb_berichten B
|
||||
JOIN tb_modulebericht MB ON B.id = MB.bericht_id
|
||||
JOIN tb_licenties L ON MB.modulenr = L.modulenr
|
||||
JOIN tb_organisaties O ON L.orgid = O.id
|
||||
JOIN tb_orgusers OU ON O.id = OU.organisatie_id
|
||||
WHERE OU.user_id = {$userid}
|
||||
AND samenvatting IS NOT NULL
|
||||
AND inhoud IS NOT NULL ";
|
||||
if($frontpage){
|
||||
$this->sql.="AND B.id NOT IN(SELECT bericht_id
|
||||
FROM tb_getoondeberichten
|
||||
WHERE user_id = {$userid}) ";
|
||||
}
|
||||
$this->sql.="GROUP BY B.id
|
||||
ORDER BY B.startdatum DESC ";
|
||||
|
||||
|
||||
return $this->get_query_result();
|
||||
}
|
||||
|
||||
function getalleberichten(){
|
||||
$this->sql ="SELECT id, samenvatting, inhoud, startdatum
|
||||
FROM tb_berichten
|
||||
ORDER BY if( samenvatting IS NULL, 0,1 ),
|
||||
if( inhoud IS NULL, 0, 1 ),
|
||||
startdatum DESC";
|
||||
return $this->get_query_result();
|
||||
}
|
||||
|
||||
function getberichtmodules($clusterid, $berichtid){
|
||||
$this->sql=" SELECT M.sysnr as modulenr, M.naam, M.cluster_id AS clusterid
|
||||
FROM tb_modules M
|
||||
JOIN tb_modulebericht MB ON (M.sysnr = MB.modulenr)
|
||||
WHERE MB.bericht_id = {$berichtid}
|
||||
AND M.cluster_id = {$clusterid}
|
||||
ORDER BY M.id ";
|
||||
return $this->get_query_result();
|
||||
}
|
||||
|
||||
function getberichtenbijmodule($berichtid, $modulenr){
|
||||
$this->sql=" SELECT id
|
||||
FROM tb_modulebericht
|
||||
WHERE bericht_id = {$berichtid}
|
||||
AND modulenr = {$modulenr} ";
|
||||
return $this->get_query_result();
|
||||
}
|
||||
|
||||
function getberichtclusters($berichtid){
|
||||
$this->sql = " SELECT C.id as clusterid, C.naam as clusternaam
|
||||
FROM tb_modules M
|
||||
JOIN tb_cluster C ON C.id = M.cluster_id
|
||||
JOIN tb_modulebericht MB ON (M.sysnr = MB.modulenr)
|
||||
WHERE MB.bericht_id = {$berichtid}
|
||||
GROUP BY C.id ";
|
||||
return $this->get_query_result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user