Files
monpas/application/libraries/monpas/Versions.php
T
2021-09-27 10:24:08 +02:00

215 lines
6.3 KiB
PHP

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Versions
{
private $CI;
private $chapterid;
private $profielid;
private $clusterid;
private $profiel;
private $orgversieid;
private $oordelen;
private $standaarden = 'NVT';
private $filledversies =[];
private $gevuldeversies;
private $heeftijkpunten;
private $sopversies;
private $versie;
private $vormtekst;
private $geopendeversies = [];
private $sopaanwezig = 'F';
private $versies;
public function __construct($chapterid, $profielid, $modulenr)
{
$this->CI =& get_instance();
$this->chapterid = $chapterid;
$this->profielid = $profielid;
$this->modulenr = $modulenr;
$this->handle();
}
public function getorgversieid(){
return $this->orgversieid;
}
public function getFilledversies(){
return $this->filledversies;
}
public function getModuleNummer(){
return $this->modulenr;
}
public function getSopAanwezig(){
return $this->sopaanwezig;
}
public function getStandaarden(){
return $this->standaarden;
}
public function getVersies(){
return $this->versies;
}
public function getMetIjkpunten(){
return $this->heeftijkpunten;
}
private function handle()
{
$this->setProfiel();
$this->setClusterid();
$this->setLijstVersies();
$this->loopGeopendeVersies();
$this->setMetIJkpunten();
$this->setSopVersies();
$this->setOrgversieid();
$this->setVersies();
}
private function setProfiel(){
$this->profiel = $this->CI->Sop_model->getnieuwsop($this->profielid);
}
private function setClusterid(){
if(!$this->modulenr) return;
$this->clusterid = $this->CI->Modules_model->get_fieldvalue([ "sysnr"=> $this->modulenr], "cluster_id");
}
private function setLijstVersies(){
if(!$this->modulenr) return;
$this->geopendeversies = $this->CI->Filledversions_model->getfilledversionsperorg(
$this->CI->globorgid, $this->modulenr); //id = orgversieid
}
private function loopGeopendeVersies(){
if(!$this->modulenr) return;
if(!$this->geopendeversies) return;
foreach($this->geopendeversies as $index =>$this->versie){
$this->checkStandaarden();
$this->setGevuldeVersies();
}
}
private function checkStandaarden(){
if(!$this->clusterid || $this->clusterid != 4) return;
$this->versie->standaarden = 'F';
$this->standaarden = 'F';
$this->oordelen = $this->CI->Scores_model->telOordelen($this->CI->globorgid, $this->versie->id);
if ($this->oordelen >= 2) {
$this->versie->standaarden = 'T';
$this->standaarden = 'T';
}
}
private function setGevuldeVersies(){
if(!$this->modulenr) return;
if(!$this->geopendeversies) return;
$this->gevuldeversies = $this->CI->Scores_model->fGetGevuldeVersies(
$this->versie->id, $this->CI->globorgid);
if($this->gevuldeversies) {
if ($this->standaarden == 'NVT' || $this->versie->standaarden == 'T') {
if($this->versie->vorm == 1){
$this->vormtekst = 'schoolversie';
}
if($this->versie->vorm == 2){
$this->vormtekst = 'individuele versie';
}
$this->versie->naam = $this->versie->naam . ', periode: ' . $this->versie->periodenummer . ':
' . $this->versie->geldigvanaf . ' - ' . $this->versie->geldigtm .', '.
$this->vormtekst;
$this->versie->naamkort = 'Periode: ' . $this->versie->periodenummer . ':
' . $this->versie->geldigvanaf . ' - ' . $this->versie->geldigtm;
$this->filledversies [] = $this->versie;
}
}
}
private function setMetIJkpunten(){
switch ($this->clusterid){
case 0: $this->heeftijkpunten = 'T';
break;
case 1: $this->heeftijkpunten = 'F';
break;
case 2:
case 3:
case 4:
case 5: $this->heeftijkpunten = 'T';
break;
case 6:
case 7: $this->heeftijkpunten = 'F';
break;
case 8: $this->heeftijkpunten = 'T';
break;
case 10: $this->heeftijkpunten = 'T';
break;
default: $this->heeftijkpunten = 'F';
break;
}
}
private function setSopVersies(){
if(!$this->modulenr) return;
if($this->standaarden == 'F') return;
if(!$this->filledversies) return;
// $this->sopversies = $this->CI->Filledversions_model->getversiesperorgperperiode(
// $this->CI->globorgid, $this->modulenr,$this->profiel->van, $this->profiel->tm);
foreach($this->filledversies as $index => $this->versie){
$this->versie->insop = 'F';
$valterin = $this->CI->Filledversions_model->checkperiode($this->versie->id, date2mysql($this->profiel->van),
date2mysql($this->profiel->tm) );
if($valterin){
$this->versie->insop = 'T';
$this->sopaanwezig = "T";
}
}
}
private function setOrgversieid(){
if (!$this->filledversies) return;
if($this->sopaanwezig === 'F'){
$this->orgversieid = $this->filledversies[0]->id;
}
if($this->sopaanwezig === 'T'){
foreach($this->filledversies as $index =>$this->versie){
if($this->versie->insop == 'T'){
$this->orgversieid = $this->versie->id;
return;
}
}
}
}
private function setVersies(){
if(!$this->modulenr) $this->versies = [];
$this->versies =[
"orgversieid" => $this->orgversieid,
"filledversies" => $this->filledversies,
"aanwezig" => $this->sopaanwezig,
"standaarden" => $this->standaarden,
];
}
}