203 lines
6.2 KiB
PHP
203 lines
6.2 KiB
PHP
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class Vergelijkbareversies
|
|
{
|
|
private $CI;
|
|
private $soort;
|
|
private $orgids;
|
|
private $versies;
|
|
private $versie;
|
|
private $versieid;
|
|
private $vergelijkbaar = false;
|
|
private $versiesarray = [];
|
|
private $checkarray = [];
|
|
private $versieinfo;
|
|
private $series = [];
|
|
private $aantal;
|
|
private $teller = 0;
|
|
private $orgversieid;
|
|
private $periode;
|
|
private $specificaties = [];
|
|
private $filledids;
|
|
|
|
|
|
public function getSeries(){
|
|
return $this->series;
|
|
}
|
|
|
|
public function __construct($orgid, $modulenr){
|
|
$this->CI =& get_instance();
|
|
$this->orgid = $orgid;
|
|
$this->modulenr = $modulenr;
|
|
$this->handle();
|
|
}
|
|
|
|
private function handle(){
|
|
$this->setOrgSoort();
|
|
$this->setScholenString();
|
|
$this->setSchoolVersies();
|
|
$this->loopVersies();
|
|
$this->setAantal();
|
|
$this->loopVersiesarray();
|
|
$this->LoopSeries();
|
|
}
|
|
|
|
private function setOrgSoort(){
|
|
$this->soort = $this->CI->Organisaties_model->get_fieldvalue(['id'=>$this->orgid], 'soort');
|
|
}
|
|
|
|
private function setScholenString(){
|
|
$this->orgids = implode(',', $this->CI->Organisaties_model->getscholenondertarget($this->orgid));
|
|
}
|
|
|
|
|
|
private function setSchoolVersies(){
|
|
if($this->soort == 4){
|
|
$this->versies = $this->CI->Filledversions_model->gettevergelijkenschoolversies1school(
|
|
$this->orgid, $this->modulenr);
|
|
}
|
|
else {
|
|
$this->versies = $this->CI->Filledversions_model->gettevergelijkenschoolversies(
|
|
$this->orgids, $this->modulenr);
|
|
}
|
|
}
|
|
|
|
private function loopVersies(){
|
|
if(!$this->versies) return;
|
|
foreach($this->versies as $index => $this->versie){
|
|
$this->setGevuldeVersiesArray();
|
|
}
|
|
}
|
|
|
|
private function setGevuldeVersiesArray(){
|
|
if($this->soort ==4){
|
|
$this->filledids = $this->CI->Scores_model->fGetGevuldeVersies($this->versie->orgversieid, $this->orgid);
|
|
}
|
|
else {
|
|
if($this->orgids){
|
|
$this->filledids = $this->CI->Scores_model->fGetGevuldeSWVVersies($this->versie->orgversieid, $this->orgids);
|
|
}
|
|
}
|
|
|
|
if($this->filledids){
|
|
$this->versiesarray [] = $this->versie;
|
|
}
|
|
}
|
|
|
|
private function setAantal(){
|
|
if(!$this->versiesarray) return;
|
|
$this->aantal = count($this->versiesarray);
|
|
}
|
|
|
|
private function loopVersiesarray(){
|
|
if(!$this->versiesarray) return;
|
|
for($i = 0; $i < $this->aantal; $i++) {
|
|
$this->setEersteWaardeVerzamelarray($i);
|
|
$this->setCheckarray($i);
|
|
$this->setTeller();
|
|
$this->innerLoopVersiesArray($i);
|
|
$this->setSeries();
|
|
}
|
|
}
|
|
|
|
private function setEersteWaardeVerzamelarray($i){
|
|
$this->versieinfo = new stdClass();
|
|
$this->versieinfo->status = 'F';
|
|
if($this->vergelijkbaar == true) return;
|
|
if(in_array($this->versiesarray[$i]->orgversieid, $this->checkarray)) return;
|
|
$this->versieinfo->status = 'T';
|
|
$this->versieinfo->versieid = $this->versiesarray[$i]->versieid;
|
|
$this->versieinfo->naam = $this->versiesarray[$i]->naam;
|
|
$this->versieinfo->scoretype = $this->versiesarray[$i]->scoretype;
|
|
$this->versieinfo->omschrijving = $this->versiesarray[$i]->omschrijving;
|
|
$this->versieinfo->orgversieids = [];
|
|
$this->versieinfo->orgversieids [] = $this->versiesarray[$i]->orgversieid;
|
|
$this->versieinfo->specificaties = [];
|
|
}
|
|
|
|
private function setTeller(){
|
|
if($this->teller === false) return;
|
|
if($this->teller < $this->aantal) {
|
|
$this->teller ++;
|
|
}
|
|
else{
|
|
$this->teller = false;
|
|
}
|
|
}
|
|
|
|
private function innerLoopVersiesArray($i){
|
|
if($this->teller === false) return;
|
|
if($this->aantal <= 1) return;
|
|
for($x = $this->teller; $x < $this->aantal; $x++) {
|
|
$this->checkVergelijkbaar($i, $x);
|
|
$this->setOrgversieid($x);
|
|
|
|
}
|
|
}
|
|
|
|
private function checkVergelijkbaar($i, $x){
|
|
if($this->aantal <= 1) return;
|
|
if($this->versiesarray[$i]->orgversieid == $this->versiesarray[$x]->orgversieid) return;
|
|
if($this->versiesarray[$i]->versieid == $this->versiesarray[$x]->versieid &&
|
|
// $this->versiesarray[$i]->vorm == $this->versiesarray[$x]->vorm &&
|
|
$this->versiesarray[$i]->scoretype == $this->versiesarray[$x]->scoretype){
|
|
|
|
|
|
$this->checkarray [] = $this->versiesarray[$x]->orgversieid;
|
|
$this->vergelijkbaar = true;
|
|
}
|
|
else{
|
|
$this->vergelijkbaar = false;
|
|
}
|
|
}
|
|
|
|
private function setOrgversieid($x){
|
|
if ($this->vergelijkbaar == false) return;
|
|
$this->versieinfo->orgversieids [] = $this->versiesarray[$x]->orgversieid;
|
|
}
|
|
|
|
private function setCheckarray($x){
|
|
$this->checkarray [] = $this->versiesarray[$x]->orgversieid;
|
|
|
|
}
|
|
|
|
private function setSeries(){
|
|
if($this->teller === false) return;
|
|
if($this->versieinfo->status == 'F') return;
|
|
$this->series [] = $this->versieinfo;
|
|
|
|
|
|
}
|
|
|
|
private function LoopSeries(){
|
|
if (!$this->series) return;
|
|
|
|
foreach($this->series as $index => $this->versieinfo) {
|
|
$this->loopOrgversieIDs();
|
|
}
|
|
}
|
|
|
|
private function loopOrgversieIDs(){
|
|
$this->specificaties = [];
|
|
if(!isset($this->versieinfo->orgversieids)) return;
|
|
foreach($this->versieinfo->orgversieids as $key => $this->orgversieid){
|
|
$this->setPeriode();
|
|
$this->vulSpecificaties();
|
|
$this->setSpecificaties();
|
|
}
|
|
}
|
|
|
|
private function setPeriode(){
|
|
$this->periode = $this->CI->Orgversies_model->getVersieInfo($this->orgversieid);
|
|
}
|
|
private function vulSpecificaties(){
|
|
$this->specificaties[]=$this->periode;
|
|
|
|
}
|
|
|
|
private function setSpecificaties(){
|
|
$this->versieinfo->specificaties = $this->specificaties;
|
|
}
|
|
|
|
|
|
} |