From bce246e1a39ef4fc36f550981fcb40a8775eba0e Mon Sep 17 00:00:00 2001 From: Monique Date: Mon, 23 May 2022 13:02:26 +0200 Subject: [PATCH 1/2] ouders in monpas --- application/config/constants.php | 4 +- application/controllers/shared/Portal.php | 82 ++++++++++++++----- application/core/MY_Controller.php | 3 +- application/models/monpas/Menus_model.php | 1 - .../models/shared/Autorisatienivos_model.php | 12 +++ application/models/shared/Licenties_model.php | 13 ++- public/js/monpas/models/monitormodel.js | 5 +- public/js/monpas/models/portalmodel.js | 2 +- 8 files changed, 87 insertions(+), 35 deletions(-) diff --git a/application/config/constants.php b/application/config/constants.php index d450be3..66a8bdb 100644 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -86,6 +86,6 @@ defined( 'EXIT__AUTO_MAX' ) or define( 'EXIT__AUTO_MAX', 125 ); // highest autom define( 'SUPERUSER', 3 ); define( 'SYSTEM', 3 ); // system wordt gebruikt in de partituur -define( 'WRITER', 343 ); -define( 'READER', 1023 ); +define( 'WRITER', 1367 ); +define( 'READER', 1367 ); diff --git a/application/controllers/shared/Portal.php b/application/controllers/shared/Portal.php index b0606a3..b05b6d3 100644 --- a/application/controllers/shared/Portal.php +++ b/application/controllers/shared/Portal.php @@ -15,6 +15,7 @@ class Portal extends MY_Controller { "monpas/Home_model", "monpas/Orgversies_model", "monpas/Scores_model", + "monpas/Menus_model", "monpas/Labels_model", "monpas/Modules_model"); $this->load->model($models); @@ -34,33 +35,68 @@ class Portal extends MY_Controller { function getlicenties() { + $userniveau = $this->Autorisatienivos_model->checknivo($this->userid, $this->globorgid); $ongeclusterdId = 0; - $isCluster = 'F'; - $ongeclusterd = $this->Licenties_model->get_ongeclusterd($this->globorgid, $ongeclusterdId); - if ($ongeclusterd){ - foreach ($ongeclusterd as $bolletje) { - $bolletje->isCluster = $isCluster;//geen knop om het cluster te openen en te sluiten - } - } else { - $ongeclusterd = []; - }; + $isCluster = 'F'; + $ongeclusterd = []; + $results = $this->Licenties_model->get_ongeclusterd($this->globorgid, $ongeclusterdId);// bolletjes zonder cluster + if ($results) { + foreach ($results as $result) { + $pagniveau = $this->Menus_model->get_fieldvalue(['holdernaam'=>'home', 'module'=>$result->sysnr ], 'autorisatienivo');//nivo van de homepage van het instrument + if ($pagniveau > $userniveau) {// als de user het instrument niet mag gebruiken moet het bolletje ook niet getoond worden + $result->isCluster = $isCluster;//geen knop om het cluster te openen en te sluiten + $ongeclusterd [] = $result; + } + } + } $isCluster = 'T'; $clusters = $this->Licenties_model->get_clusters_org($this->globorgid); if($clusters) { $i = -1; foreach ($clusters as $cluster) { - $i ++; - if ($cluster->aantalmodules == 1) { - $cluster->isCluster = "F"; - $newitem = $this->Licenties_model->get_ongeclusterd($this->globorgid, $cluster->id); - $ongeclusterd = array_merge($ongeclusterd, $newitem); - unset($clusters[$i]); - } else { - $cluster->isCluster = $isCluster; //ivm knop om het cluster te openen en te sluiten - $cluster->sub = $this->Licenties_model->get_licentie_cluster($this->globorgid, $cluster->id);//instrumenten bij het cluster - $cluster->cluster_id = $cluster->id; //zodat cluster en instrument eenzelfde attribuut hebben - } - }; + $i++; + if ($cluster->aantalmodules > 1) {// bolletje met link want meer instrumenten bij bolletje + $instrumenten = $this->Licenties_model->get_licentie_cluster($this->globorgid, $cluster->id); + $array = []; + foreach ($instrumenten as $instrument) { + $pagniveau = $this->Menus_model->get_fieldvalue(['holdernaam' => 'home', 'module' => $instrument->sysnr], 'autorisatienivo'); + if ($pagniveau > $userniveau) { + $array[] = $instrument; + } + } + if (count($array) > 1) { + $cluster->isCluster = $isCluster; //ivm knop om het cluster te openen en te sluiten + $cluster->sub = $array;//instrumenten bij het cluster + $cluster->cluster_id = $cluster->id; //zodat cluster en instrument eenzelfde attribuut hebben + } else if (count($array) == 1) { //toegang tot maar 1 instrument dus geen menu + $cluster->isCluster = "F"; + $array[0]->kleur1 = $cluster->kleur1; + $array[0]->kleur2 = $cluster->kleur2; + + $ongeclusterd = array_merge($ongeclusterd, $array); + unset($clusters[$i]); + } + else{ + $cluster->isCluster = "F"; + unset($clusters[$i]); + } + } + else if ($cluster->aantalmodules == 1) { //1 instrument bij bolletje + $cluster->isCluster = "F"; + $newitem = $this->Licenties_model->get_ongeclusterd($this->globorgid, $cluster->id); + $pagniveau = $this->Menus_model->get_fieldvalue(['holdernaam' => 'home', 'module' =>$newitem[0]->sysnr], 'autorisatienivo'); + if ($pagniveau > $userniveau) { + $ongeclusterd = array_merge($ongeclusterd, $newitem); + } + unset($clusters[$i]); + } + + + else{// geen toegang tot instrumenten bij cluster + unset($clusters[$i]); + } + } + }; // if $clusters if (! $ongeclusterd){ @@ -70,7 +106,9 @@ class Portal extends MY_Controller { $clusters = []; }; - $licenties = array_merge($ongeclusterd, $clusters); + + $licenties = array_merge($clusters, $ongeclusterd); + usort($licenties, array($this, 'opAlfabet'));//bollen op alfbetische volgorde echo json_encode($licenties); diff --git a/application/core/MY_Controller.php b/application/core/MY_Controller.php index 89d8b20..1e23a39 100644 --- a/application/core/MY_Controller.php +++ b/application/core/MY_Controller.php @@ -70,7 +70,8 @@ class MY_Controller extends CI_Controller{ // public $version = '1.17.93';// stuur bijlage bij new wachtwoord // public $version = '1.17.95';// verbeteringen invullijst, fout omvang // public $version = '1.17.96';// nieuwe handleidingen - public $version = '1.17.97';// omvang geen grafiek bij 0 resultaten +// public $version = '1.17.97';// omvang geen grafiek bij 0 resultaten + public $version = '1.17.98';// instrumenten voor ouders diff --git a/application/models/monpas/Menus_model.php b/application/models/monpas/Menus_model.php index 5c67379..7951e5f 100644 --- a/application/models/monpas/Menus_model.php +++ b/application/models/monpas/Menus_model.php @@ -63,5 +63,4 @@ class Menus_model extends MY_Model{ ORDER BY volgorde" ; return $this->get_query_result(); } - } \ No newline at end of file diff --git a/application/models/shared/Autorisatienivos_model.php b/application/models/shared/Autorisatienivos_model.php index 26ebb5a..b5203cd 100644 --- a/application/models/shared/Autorisatienivos_model.php +++ b/application/models/shared/Autorisatienivos_model.php @@ -39,4 +39,16 @@ class Autorisatienivos_model extends MY_Model{ if ($result) {return $result->nivo;} else {return null ;}; } + + function checknivo($userid, $orgid){ + $this->sql=" SELECT nivo + FROM tb_autorisatienivos AN + JOIN tb_autorisaties A ON A.nivo_id = AN.id + JOIN tb_orgusers OU ON OU.id = A.orguser_id + WHERE OU.user_id = {$userid} + AND OU.organisatie_id = {$orgid} "; + return $this->get_query_row('nivo'); + } + + } \ No newline at end of file diff --git a/application/models/shared/Licenties_model.php b/application/models/shared/Licenties_model.php index a77f4b9..a84ad79 100644 --- a/application/models/shared/Licenties_model.php +++ b/application/models/shared/Licenties_model.php @@ -25,15 +25,15 @@ class Licenties_model extends MY_Model{ function get_ongeclusterd($orgid, $clusterId){ - $this->sql = "SELECT M.id, M.sysnr, M. cluster_id, M.naam,M.naamkort, + $this->sql = "SELECT DISTINCT(M.id), M.sysnr, M.cluster_id, M.naam,M.naamkort, IF (C.id, C.kleur1, '#ffffff') as kleur1, IF (C.id , C.kleur2, '#ebebeb' ) as kleur2 FROM tb_organisaties O JOIN tb_licenties L ON L.orgid = O.id JOIN tb_modules M on M.sysnr = L.modulenr - LEFT JOIN tb_cluster C ON C.id = M.cluster_id + LEFT JOIN tb_cluster C ON C.id = M.cluster_id WHERE O.id = {$orgid} - AND actief = 1 + AND O.actief = 1 AND M.cluster_id = {$clusterId} ORDER BY M.naam "; return $this->get_query_result(); @@ -43,7 +43,6 @@ class Licenties_model extends MY_Model{ $this->sql = "SELECT C.id, C.naam, count(M.id) as aantalmodules, C.kleur1, C.kleur2 FROM tb_organisaties O - JOIN tb_licenties L ON L.orgid = O.id JOIN tb_modules M on M.sysnr = L.modulenr JOIN tb_cluster C on C.id = M.cluster_id @@ -85,14 +84,14 @@ class Licenties_model extends MY_Model{ } function get_licentie_cluster($orgid, $clusterid){ - $this->sql = "SELECT M.id, M.cluster_id, M.naam, M.naamkort, M.sysnr - FROM tb_organisaties O + $this->sql = "SELECT DISTINCT(M.id), M.cluster_id, M.naam, M.naamkort, M.sysnr + FROM tb_organisaties O JOIN tb_licenties L ON L.orgid = O.id JOIN tb_modules M on M.sysnr = L.modulenr JOIN tb_cluster C on C.id = M.cluster_id WHERE O.id = {$orgid} AND C.id = {$clusterid} - AND actief = 1 "; + AND O.actief = 1 "; return $this->get_query_result(); } diff --git a/public/js/monpas/models/monitormodel.js b/public/js/monpas/models/monitormodel.js index cc3c24b..6372c50 100644 --- a/public/js/monpas/models/monitormodel.js +++ b/public/js/monpas/models/monitormodel.js @@ -187,7 +187,10 @@ $(function(){ // als de versie een schoolversie is, dan mag alleen het management invullen // maar ook het management mag niet invullen voorbij de invuldatum - if (self.editok() && self.selectedOrgversion().vorm==1) {self.editok(data.writer)} + if (self.editok() && self.selectedOrgversion().vorm==1) {self.editok(data.writer) + console.log(self.editok(), "edit ok"); + console.log(data.writer, "writer") + } },'json'); }, diff --git a/public/js/monpas/models/portalmodel.js b/public/js/monpas/models/portalmodel.js index a6dd35c..fe4eea9 100644 --- a/public/js/monpas/models/portalmodel.js +++ b/public/js/monpas/models/portalmodel.js @@ -130,11 +130,11 @@ $( function () { var self = ls.PortalModel; self.fToonPopup(); $.post( "index.php/shared/portal/getlicenties", function ( result ) { + console.log(result, "result") self.licenties.removeAll(); if ( result ) { $.each( result, function ( i, p ) { var clusterid = ''; - self.licenties.push( new fAddLicentie( p, clusterid ) ); } ); // each From cf8f7e855020cacfe658e738a8a31cb5d51d413a Mon Sep 17 00:00:00 2001 From: Monique Date: Mon, 23 May 2022 16:11:35 +0200 Subject: [PATCH 2/2] instrumenten ook voor leerlingen --- application/controllers/shared/Portal.php | 104 ++++++++++++++++------ application/core/MY_Controller.php | 3 +- application/views/monpas/pages/portal.php | 4 +- public/js/monpas/models/portalmodel.js | 1 - 4 files changed, 80 insertions(+), 32 deletions(-) diff --git a/application/controllers/shared/Portal.php b/application/controllers/shared/Portal.php index b05b6d3..ddc8c4b 100644 --- a/application/controllers/shared/Portal.php +++ b/application/controllers/shared/Portal.php @@ -205,26 +205,28 @@ class Portal extends MY_Controller { echo json_encode(array('scores' =>$scores)); } // getscores - - - - - function kiesCluster(){ $clusterId = $this->uri->segment(4); - - $ongeclusterdId = 0; + $userniveau = $this->Autorisatienivos_model->checknivo($this->userid, $this->globorgid); + $ongeclusterdId = 0; $isCluster = 'F'; $wasniveau2 = 'F'; //hingen voor de keuze niet aan cluster + $keuzesarray = []; + $clusterarray = []; + $ongeclusterd = []; - $ongeclusterd = $this->Licenties_model->get_ongeclusterd($this->globorgid, $ongeclusterdId); + $results = $this->Licenties_model->get_ongeclusterd($this->globorgid, $ongeclusterdId); //instrumenten die niet bij een cluster horen - if($ongeclusterd) { - foreach ($ongeclusterd as $bol) { - $bol->wasNiveau2 = $wasniveau2; - $bol->isCluster = $isCluster; - } - } + if($results) { + foreach ($results as $result) { + $pagniveau = $this->Menus_model->get_fieldvalue(['holdernaam' => 'home', 'module' => $result->sysnr], 'autorisatienivo');//nivo van de homepage van het instrument + if ($pagniveau > $userniveau) {// als de user het instrument niet mag gebruiken moet het bolletje ook niet getoond worden + $result->isCluster = $isCluster;//geen knop om het cluster te openen en te sluiten + $result->wasNiveau2 = $wasniveau2; + $ongeclusterd [] = $result; + } + } + } $isCluster = 'T'; $clusters = $this->Licenties_model->get_clusters_org($this->globorgid); if($clusters) { @@ -238,33 +240,79 @@ class Portal extends MY_Controller { $wasniveau2 = 'T'; $keuze = $this->Licenties_model->get_ongeclusterd($this->globorgid, $clusterId); //gekozen cluster van instrumenten if($keuze) { + foreach ($keuze as $keus) { - $keus->wasNiveau2 = $wasniveau2;// waren bollen onde cluster nu niveau hoger - $keus->isCluster = $isCluster; + $pagniveau = $this->Menus_model->get_fieldvalue(['holdernaam' => 'home', 'module' => $keus->sysnr], 'autorisatienivo'); + if ($pagniveau > $userniveau) { + $keus->wasNiveau2 = $wasniveau2;// waren bollen onde cluster nu niveau hoger + $keus->isCluster = $isCluster; + $keuzesarray[] = $keus; + } } }; if($clusters) { + $i =-1; foreach ($clusters as $cluster) { - $cluster->cluster_id = $cluster->id; - if ($cluster->cluster_id != $clusterId) { //voeg instrumenten toe aan niet-gekozen clusters - $cluster->sub = $this->Licenties_model->get_licentie_cluster($this->globorgid, $cluster->id); - } + $i++; + + $cluster->cluster_id = $cluster->id; + if ($cluster->cluster_id != $clusterId) { //voeg instrumenten toe aan niet-gekozen clusters + if ($cluster->aantalmodules > 1){ + $instrumenten = $this->Licenties_model->get_licentie_cluster($this->globorgid, $cluster->id); + if ($instrumenten) { + foreach ($instrumenten as $instrument) { + $pagniveau = $this->Menus_model->get_fieldvalue(['holdernaam' => 'home', 'module' => $instrument->sysnr], 'autorisatienivo'); + if ($pagniveau > $userniveau) { + $clusterarray[] = $instrument; + } + } + } + if (count($clusterarray) > 1) { + $cluster->isCluster = $isCluster; //ivm knop om het cluster te openen en te sluiten + $cluster->sub = $clusterarray;//instrumenten bij het cluster + $cluster->cluster_id = $cluster->id; //zodat cluster en instrument eenzelfde attribuut hebben + } else if (count($clusterarray) == 1) { //toegang tot maar 1 instrument dus geen menu + $cluster->isCluster = "F"; + $clusterarray[0]->kleur1 = $cluster->kleur1; + $clusterarray[0]->kleur2 = $cluster->kleur2; + + $ongeclusterd = array_merge($ongeclusterd, $clusterarray); + unset($clusters[$i]); + } + else{ + $cluster->isCluster = "F"; + unset($clusters[$i]); + } + } + else if ($cluster->aantalmodules == 1) { //1 instrument bij bolletje + $cluster->isCluster = "F"; + $newitem = $this->Licenties_model->get_ongeclusterd($this->globorgid, $cluster->id); + $pagniveau = $this->Menus_model->get_fieldvalue(['holdernaam' => 'home', 'module' =>$newitem[0]->sysnr], 'autorisatienivo'); + if ($pagniveau > $userniveau) { + $ongeclusterd = array_merge($ongeclusterd, $newitem); + } + unset($clusters[$i]); + } + + + else{// geen toegang tot instrumenten bij cluster + unset($clusters[$i]); + } + + + + } } }; - if(!$clusters){ - $clusters =[]; - }; - if(!$ongeclusterd){ - $ongeclusterd = []; - }; - $licenties = array_merge($ongeclusterd, $clusters); + + $licenties = array_merge( $ongeclusterd, $clusters); usort($licenties, array($this, 'opAlfabet')); usort($keuze, array($this, 'opAlfabet')); $clusternaam = $this->Licenties_model->get_clusterNaam($clusterId); - $geselecteerd = $this->arrayinArray($licenties, $keuze, $clusterId, $clusternaam); + $geselecteerd = $this->arrayinArray($licenties, $keuzesarray, $clusterId, $clusternaam); echo json_encode($geselecteerd); } diff --git a/application/core/MY_Controller.php b/application/core/MY_Controller.php index 1e23a39..56d1a9e 100644 --- a/application/core/MY_Controller.php +++ b/application/core/MY_Controller.php @@ -71,7 +71,8 @@ class MY_Controller extends CI_Controller{ // public $version = '1.17.95';// verbeteringen invullijst, fout omvang // public $version = '1.17.96';// nieuwe handleidingen // public $version = '1.17.97';// omvang geen grafiek bij 0 resultaten - public $version = '1.17.98';// instrumenten voor ouders +// public $version = '1.17.98';// instrumenten voor ouders + public $version = '1.17.99';// instrumenten ook voor leerlingen diff --git a/application/views/monpas/pages/portal.php b/application/views/monpas/pages/portal.php index b2aead9..8fbd26e 100644 --- a/application/views/monpas/pages/portal.php +++ b/application/views/monpas/pages/portal.php @@ -37,7 +37,7 @@
diff --git a/public/js/monpas/models/portalmodel.js b/public/js/monpas/models/portalmodel.js index fe4eea9..a71e69b 100644 --- a/public/js/monpas/models/portalmodel.js +++ b/public/js/monpas/models/portalmodel.js @@ -130,7 +130,6 @@ $( function () { var self = ls.PortalModel; self.fToonPopup(); $.post( "index.php/shared/portal/getlicenties", function ( result ) { - console.log(result, "result") self.licenties.removeAll(); if ( result ) { $.each( result, function ( i, p ) {