394 lines
12 KiB
PHP
394 lines
12 KiB
PHP
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class Schoolafbeeldingen {
|
|
|
|
private $CI;
|
|
|
|
private $scores;
|
|
private $score;
|
|
private $somscore;
|
|
private $ambities;
|
|
private $wensen;
|
|
private $ijkpunten;
|
|
private $aantalY = 0;
|
|
private $labels;
|
|
private $kleuren;
|
|
private $orgversie;
|
|
private $vantm;
|
|
private $gemiddelde;
|
|
private $adviezen= [];
|
|
private $rij = 708;
|
|
private $standaardorg = 250;
|
|
private $aantal = 15;
|
|
private $kolombreedte = 0;
|
|
private $kolomInt = 0;
|
|
private $orgbreedte = 0;
|
|
private $aantalscores = 0;
|
|
private $ijkpuntenok = 0;
|
|
private $welkehoogste = 0;
|
|
private $hoogstescore = -1;
|
|
private $welkelaagste = 0;
|
|
private $laagstescore = 101;
|
|
private $schoolafbeeldingen;
|
|
private $resultaten;
|
|
private $disablenvt;
|
|
|
|
public function __construct(Schoolscores $schoolscores, $modulenr, $orgversieid, $clusterid, $orgid){
|
|
$this->CI = & get_instance();
|
|
$this->schoolscores = $schoolscores;
|
|
$this->modulenr = $modulenr;
|
|
$this->orgversieid = $orgversieid;
|
|
$this->orgid = $orgid;
|
|
$this->clusterid = $clusterid;
|
|
$this->setScores();
|
|
$this->setAmbities();
|
|
$this->setWensen();
|
|
$this->setIJkpunten();
|
|
$this->handle();
|
|
}
|
|
|
|
public function getSchoolAfbeeldingen(){
|
|
return $this->schoolafbeeldingen;
|
|
}
|
|
|
|
public function getIJkpunten(){
|
|
return $this->ijkpunten;
|
|
}
|
|
|
|
public function getLabels(){
|
|
return $this->labels;
|
|
}
|
|
|
|
public function getScores(){
|
|
return $this->scores;
|
|
}
|
|
|
|
public function getAmbities(){
|
|
return $this->ambities;
|
|
}
|
|
|
|
public function getOrgVersie(){
|
|
return $this->orgversie;
|
|
}
|
|
|
|
public function getResultaten(){
|
|
$gem = "";
|
|
if($this->gemiddelde){
|
|
$gem = $this->gemiddelde->gem;
|
|
}
|
|
$this->resultaten = [
|
|
'totgem' => $gem,
|
|
'ijkpuntenok' => $this->ijkpuntenok,
|
|
'welkehoogste' => $this->welkehoogste,
|
|
'hoogstescore' => round($this->hoogstescore, 1),
|
|
'welkelaagste' => $this->welkelaagste,
|
|
'laagstescore' => round($this->laagstescore, 1),
|
|
];
|
|
|
|
return $this->resultaten;
|
|
}
|
|
|
|
public function getVantm(){
|
|
return $this->vantm;
|
|
}
|
|
|
|
public function getAdviezen(){
|
|
return $this->adviezen;
|
|
}
|
|
|
|
private function setScores(){
|
|
$this->scores = $this->schoolscores->getScores();
|
|
}
|
|
|
|
private function setAmbities(){
|
|
$this->ambities = $this->schoolscores->getAmbities();
|
|
}
|
|
|
|
private function setWensen(){
|
|
$this->wensen = $this->schoolscores->getWensen();
|
|
}
|
|
|
|
private function setIJkpunten(){
|
|
$this->ijkpunten = $this->schoolscores->getIJKpunten();
|
|
|
|
}
|
|
|
|
private function handle(){
|
|
$this->setSwvid();
|
|
$this->setLabels();
|
|
$this->telIJkpunten();
|
|
$this->setPeriode();
|
|
$this->setKleuren();
|
|
$this->loopScores1();
|
|
$this->setGemiddeldeScore();
|
|
$this->addGemiddeldeScore();
|
|
$this->loopScores2();
|
|
$this->setKolombreedte();
|
|
$this->setOrgbreedte();
|
|
$this->setSchoolAfbeeldingen();
|
|
|
|
}
|
|
private function setSwvid(){
|
|
$this->swvid = $this->CI->Organisaties_model->get_swvid($this->orgid);
|
|
}
|
|
|
|
private function setLabels(){
|
|
$this->labels = $this->CI->Labels_model->getalllabels($this->modulenr);
|
|
if(! $this->labels){
|
|
$this->labels = $this->CI->Labels_model->getalllabels(1);
|
|
}
|
|
}
|
|
|
|
private function telIJkpunten(){
|
|
if($this->ijkpunten){
|
|
foreach($this->ijkpunten as $ijkpunt){
|
|
if($ijkpunt->disabled == 'F'){
|
|
$this->aantalY++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private function setPeriode(){
|
|
$this->orgversie = $this->CI->Orgversies_model->get_record_by_id($this->orgversieid);
|
|
$this->vantm = "Gegevens uit periode ".$this->orgversie->periodenummer." van ".mysql2date($this->orgversie->geldigvanaf)." t/m ".mysql2date($this->orgversie->geldigtm);
|
|
}
|
|
|
|
|
|
|
|
private function setKleuren(){
|
|
|
|
// $this->kleuren = $this->kleurcodes->getKleurcodesOrg($this->clusterid, $this->swvid);
|
|
// if(!$this->kleuren || $this->kleuren == " ") {
|
|
$this->kleuren = new stdClass();
|
|
$this->kleuren->cluster_id = $this->clusterid;
|
|
$this->kleuren->grens1 = '60';
|
|
$this->kleuren->grens2 = '80';
|
|
$this->kleuren->grens3 = '90';
|
|
$this->kleuren->grens4 = '100';
|
|
if($this->orgversie->scoretype== 7){
|
|
$this->kleuren->grens1 = '33';
|
|
$this->kleuren->grens2 = '66';
|
|
$this->kleuren->grens3 = '100';
|
|
}
|
|
// $this->kleuren->kleur1 = '#fe2219';
|
|
// $this->kleuren->kleur2 = '#fea719';
|
|
// $this->kleuren->kleur3 = '#15d029';
|
|
// $this->kleuren->kleur4 = '#1558d0';
|
|
$this->kleuren->kleur1 = '#e08885';
|
|
$this->kleuren->kleur2 = '#ffcc80';
|
|
$this->kleuren->kleur3 = '#9fdf9f';
|
|
$this->kleuren->kleur4 = '#99d6ff';
|
|
$this->kleuren->organisatie_id = '0';
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function loopScores1(){
|
|
if(!$this->scores) return;
|
|
foreach ($this->scores as $index => $this->score) {
|
|
if($this->score->disabled == 'F' && $this->score->disablenvt == 'F') {
|
|
|
|
$this->somscore = $this->somscore + $this->score->gem;
|
|
|
|
$this->aantalscores++;
|
|
}
|
|
if($this->score->disabled == 'F' && $this->score->disablenvt == 'T'){
|
|
$this->disablenvt++;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
private function setGemiddeldeScore(){
|
|
if(!$this->scores || $this->aantalscores == 0) return;
|
|
$this->gemiddelde = new stdClass();
|
|
$this->gemiddelde->gem = 0;
|
|
$deler = $this->aantalY - $this->disablenvt;
|
|
if($deler > 0) $this->gemiddelde->gem = round($this->somscore / $deler);
|
|
|
|
$this->gemiddelde->disabled = 'F';
|
|
$this->gemiddelde->disablenvt = 'F';
|
|
$this->gemiddelde->nummer = 'gem';
|
|
$this->score = $this->gemiddelde;
|
|
}
|
|
|
|
private function addGemiddeldeScore(){
|
|
if(!$this->scores || ! $this->gemiddelde) return;
|
|
array_push($this->scores, $this->score);
|
|
}
|
|
|
|
private function loopScores2()
|
|
{
|
|
if (!$this->scores) return;
|
|
foreach ($this->scores as $index => $this->score) {
|
|
$this->setScoreNummer();
|
|
$this->rondScoresAf();
|
|
$this->setScoreKleuren();
|
|
$this->addGewensteScores($index);
|
|
$this->setWensKleuren();
|
|
$this->setAdvies();
|
|
$this->setResultatenOverzicht();
|
|
$this->telIJKpuntenok();
|
|
}
|
|
}
|
|
|
|
private function setScoreNummer(){
|
|
$this->score->huidig = 1;
|
|
if ($this->score->gem >= $this->kleuren->grens1) $this->score->huidig =2;
|
|
if ($this->score->gem >= $this->kleuren->grens2) $this->score->huidig =3;
|
|
if ($this->score->gem >= $this->kleuren->grens3) $this->score->huidig =4;
|
|
|
|
if($this->orgversie->scoretype == 7){
|
|
if ($this->score->gem == $this->kleuren->grens3) $this->score->huidig = 4;
|
|
if ($this->score->gem < $this->kleuren->grens3) $this->score->huidig = 3;
|
|
if ($this->score->gem <= $this->kleuren->grens2) $this->score->huidig = 2;
|
|
if ($this->score->gem <= $this->kleuren->grens1) $this->score->huidig = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private function rondScoresAf(){
|
|
$this->score->gem = round($this->score->gem);
|
|
}
|
|
|
|
|
|
private function setScoreKleuren(){
|
|
switch ($this->score->huidig) {
|
|
case 1:
|
|
$this->score->kleur = $this->kleuren->kleur1;
|
|
break;
|
|
case 2:
|
|
$this->score->kleur = $this->kleuren->kleur2;
|
|
break;
|
|
case 3:
|
|
$this->score->kleur = $this->kleuren->kleur3;
|
|
break;
|
|
case 4:
|
|
$this->score->kleur = $this->kleuren->kleur4;
|
|
break;
|
|
default:
|
|
$this->score->kleur = '#ffffff';
|
|
}
|
|
|
|
}
|
|
|
|
private function addGewensteScores($index){
|
|
$this->score->wens = 3;
|
|
if ($this->wensen && $index < $this->aantalscores) {
|
|
$this->score->wens = $this->wensen[$index]->wens;
|
|
}
|
|
}
|
|
|
|
private function setWensKleuren(){
|
|
if(! isset($this->wensen)) return;
|
|
if(!isset($this->score->wens)) return;
|
|
if($this->score->disabled == 'T')
|
|
{$this->score->wenskleur = '#ffffff';
|
|
return;}
|
|
switch ($this->score->wens) {
|
|
case 1:
|
|
$this->score->wenskleur = $this->kleuren->kleur1;
|
|
break;
|
|
case 2:
|
|
$this->score->wenskleur = $this->kleuren->kleur2;
|
|
break;
|
|
case 3:
|
|
$this->score->wenskleur = $this->kleuren->kleur3;
|
|
break;
|
|
case 4:
|
|
$this->score->wenskleur = $this->kleuren->kleur4;
|
|
break;
|
|
default:
|
|
$this->score->wenskleur = '#ffffff';
|
|
}
|
|
}
|
|
|
|
private function setAdvies(){
|
|
|
|
if(isset($this->score->wens) &&
|
|
$this->score->huidig < $this->score->wens &&
|
|
$this->score->wens!= 0 &&
|
|
$this->score->disabled == 'F' &&
|
|
$this->score->disablenvt == 'F'){
|
|
$omschrijving = "";
|
|
if(isset($this->score->omschrijving)){
|
|
$omschrijving = $this->score->omschrijving;
|
|
}
|
|
array_push($this->adviezen, ["nummer"=> $this->score->nummer, "omschrijving" =>$omschrijving]);
|
|
}
|
|
}
|
|
|
|
private function setResultatenOverzicht()
|
|
{
|
|
if($this->score->disabled == 'F' && $this->score->disablenvt == 'F') {
|
|
if ($this->score->gem > $this->hoogstescore) {
|
|
$this->hoogstescore = $this->score->gem;
|
|
$this->welkehoogste = $this->score->nummer;
|
|
}
|
|
if ($this->score->gem <= $this->laagstescore) {
|
|
$this->laagstescore = $this->score->gem;
|
|
$this->welkelaagste = $this->score->nummer;
|
|
}
|
|
}
|
|
}
|
|
|
|
private function telIJkpuntenok()
|
|
{
|
|
if($this->score->disabled == 'F' && $this->score->disablenvt == 'F') {
|
|
if ($this->ambities && $this->score->gem >= $this->ambities->zprocent && $this->score->disabled == 'F') {
|
|
$this->ijkpuntenok++;
|
|
}
|
|
}
|
|
}
|
|
|
|
private function setKolombreedte(){
|
|
if($this->aantalY > 1) $this->aantal = $this->aantalY;
|
|
$kolombreedte = floor(($this->rij - $this->standaardorg)/$this->aantal);
|
|
$this->kolomInt = $kolombreedte;
|
|
$this->kolombreedte = $kolombreedte . 'px';
|
|
}
|
|
private function setOrgbreedte(){
|
|
if($this->aantalY > 1){
|
|
$this->aantal = $this->aantalY;}
|
|
$orgbreedte = floor($this->rij - ($this->aantal * $this->kolomInt));
|
|
$this->orgbreedte = $orgbreedte . 'px';
|
|
}
|
|
|
|
private function setSchoolAfbeeldingen()
|
|
{
|
|
//nagaan of het tabelid altijd klopt
|
|
if (!$this->scores) {
|
|
$this->schoolafbeeldingen = false;
|
|
|
|
}
|
|
|
|
if ($this->scores) {
|
|
$this->schoolafbeeldingen = [
|
|
"module" => $this->modulenr,
|
|
"scores" => $this->scores,
|
|
"labels" => $this->labels,
|
|
|
|
"kleuren" => $this->kleuren,
|
|
"vantm" => $this->vantm,
|
|
"ambitie" => $this->ambities,
|
|
"adviezen" => $this->adviezen,
|
|
"ijkpunten" => $this->ijkpunten,
|
|
'ijkpuntenok' => $this->ijkpuntenok,
|
|
'welkehoogste' => $this->welkehoogste,
|
|
'hoogstescore' => round($this->hoogstescore, 1),
|
|
'welkelaagste' => $this->welkelaagste,
|
|
'laagstescore' => round($this->laagstescore, 1),
|
|
"aantalY" => $this->aantalY,
|
|
"totgem" => $this->gemiddelde->gem,
|
|
"orgbreedte" => $this->orgbreedte,
|
|
"kolombreedte" => $this->kolombreedte,
|
|
];
|
|
}
|
|
}
|
|
|
|
} |