load->model($models); $this->load->library('monpas/kleurcodes'); $this->load->helper('string'); if (!$this->check_online_status()) { echo json_encode(array('offline' => TRUE)); die; };// if } function naarmodule() { if ($this->nologin) return; $module = $this->uri->segment(4); $this->Session_model->set_module($module); } function getlicenties() { $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 = '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 } }; }; // if $clusters if (! $ongeclusterd){ $ongeclusterd = []; }; if(!$clusters){ $clusters = []; }; $licenties = array_merge($ongeclusterd, $clusters); usort($licenties, array($this, 'opAlfabet'));//bollen op alfbetische volgorde echo json_encode($licenties); } /** * haalt individuele instrumenten op voor orgusers met een bij het instrument horende functie. * Voor export naar monPon */ function getBollenMonPon() { $portalorg = 5; $portaluser = 6; $orgid = $this->Organisaties_model->get_fieldvalue(array('portal_id'=>$portalorg),"id"); $userid = $this->Users_model->get_fieldvalue(array('portal_id'=>$portaluser),"id"); $functiebollen = []; $functiesuser = $this->Functies_model->getFunctiesOrguser($orgid, $userid); if (!$functiesuser) { return; } $bollen = $this->Modules_model->get_instrumenten_ind_org($orgid); if (!$bollen) { return; } foreach ($bollen as $bolletje) { $functiesmod = $this->Functies_model->getFunctiesBijModule($bolletje->moduleid); if ($functiesmod) { foreach ($functiesmod as $mfunctie) { foreach ($functiesuser as $userfunctie) { if ($mfunctie->functie_id == $userfunctie->functieid) { $bolletje->userid = $userfunctie->userid; $bolletje->fullname = $userfunctie->fullname; if (sizeof($functiebollen) < 1) { array_push($functiebollen, $bolletje); } else { foreach ($functiebollen as $fbol) { if ($fbol->moduleid != $bolletje->moduleid) { array_push($functiebollen, $bolletje); } } } } } $functiebollen = array_map("unserialize", array_unique(array_map("serialize", $functiebollen)));//verwijdert dubbele instrumenten } } } $bollendef = $this->getIngevuldeInstrumenten($userid, $orgid, $functiebollen); echo json_encode($bollendef); } function getAgendaMonPon(){ if (!$this->userid) die; $filledversionid = $this->uri->segment(4); $scores = null; $gewenst = null; // let op ja nee bezig wordt vertaald naar 10, 0 en 5 $scores = $this->Scores_model->calculateindividualMonPon($filledversionid); // haal ook nog de criteria van de organisatie op foreach($scores as $score){ $score->gem = 0; if ($score->num > 0){ $score->gem = round($score->somscore / $score->num,1); } $score->huidig= $this->kleurcodes->getnummer($score->gem); } ; // foreach scores // $gewenst=$this->Scores_model->getgewenst($orgid, $orgversieid); // if ($gewenst){ // $i =0; // foreach($scores as $score){ // $score->gewenstid= $gewenst[$i]->id; // $score->gewenst = $gewenst[$i]->wens; // $i = $i + 1; // }; //foreach // } echo json_encode(array('scores' =>$scores)); } // getscores function kiesCluster(){ $clusterId = $this->uri->segment(4); $ongeclusterdId = 0; $isCluster = 'F'; $wasniveau2 = 'F'; //hingen voor de keuze niet aan cluster $ongeclusterd = $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; } } $isCluster = 'T'; $clusters = $this->Licenties_model->get_clusters_org($this->globorgid); if($clusters) { foreach ($clusters as $cluster) { $cluster->wasNiveau2 = $wasniveau2; $cluster->isCluster = $isCluster; } }; $isCluster = 'F'; $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; } }; if($clusters) { 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); } } }; if(!$clusters){ $clusters =[]; }; if(!$ongeclusterd){ $ongeclusterd = []; }; $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); echo json_encode($geselecteerd); } function getmodule() { $module = $this->session->userdata['module']; $hometekst = $this->Home_model->get_fieldvalue(['modulenr' => $module], 'tekst'); echo json_encode(['module' => $module, 'hometekst' => $hometekst]); } private function arrayinArray($knipArray, $invoegArray, $var1, $var2) { $lengte = count($knipArray); $breekpunt = 0; $eindpunt = 0; for ($i = 0; $i < $lengte; $i++) { if ($knipArray[$i]->id == $var1 && $knipArray[$i]->naam == $var2) { $breekpunt = $i + 1; //array wordt geknipt na het cluster van de keuze $eindpunt = $lengte - $breekpunt - 1; } $licenties1 = array_slice($knipArray, 0, $breekpunt); $licenties2 = array_slice($knipArray, $breekpunt + 1, $eindpunt); $doelArray = array_merge($licenties1, $invoegArray, $licenties2); //array invoegen na breekpunt } return $doelArray; } private function opAlfabet($a, $b) { return strcmp($a->naam, $b->naam); } private function getIngevuldeInstrumenten($userid, $orgid, $bollen){ foreach ($bollen as $bolletje){ $versies = $this->Modules_model->get_instrumenten_ingevuld_ind($bolletje->moduleid, $userid, $orgid); if($versies){ $bolletje->ingevuld = 'T'; $bolletje->versies = $versies; $bolletje->label = $this->Labels_model->getLabel($bolletje->sysnr); } else{ $bolletje->ingevuld = 'F'; } } return $bollen; } }