- system/ vervangen door CodeIgniter 3.4.5 (pocketarc/codeigniter, PHP 8.2-8.5 compatibel) - config.php, mimes.php, user_agents.php en error-views bijgewerkt naar 3.4.5 - composer.json: php-constraint "^7.4 || ^8.0" zodat composer install op 8.3 werkt - PHP 8-fatals opgelost: count()/array-functies op FALSE/null, rekenen met lege strings, delen door nul, property zetten op FALSE, curly-brace string offsets, ongedefinieerde constanten, foute curl_setopt in Phantom_model::create_img - dynamic properties gedeclareerd in libraries, optionele parameters voor verplichte opgelost - vergelijkingen waar '' == 0 in PHP 8 anders uitvalt gecast naar (int) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
287 lines
9.0 KiB
PHP
287 lines
9.0 KiB
PHP
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class Individuelescores
|
|
{
|
|
private $CI;
|
|
private $userid;
|
|
private $aantalY = 0;
|
|
private $scores;
|
|
private $score;
|
|
private $ambities;
|
|
private $kleuren;
|
|
private $aantaldisablenvt = 0;
|
|
private $aantalscores = 0;
|
|
private $ijkpuntenok = 0;
|
|
private $results;
|
|
private $gemiddelde;
|
|
private $resultaten;
|
|
private $adviezen;
|
|
private $somscore = 0;
|
|
private $welkelaagste;
|
|
private $welkehoogste;
|
|
private $laagstescore = 110;
|
|
private $hoogstescore = 0;
|
|
private $orgversieid;
|
|
private $orgid;
|
|
private $orguserid;
|
|
private $scoretype;
|
|
private $org;
|
|
private $orgnaam;
|
|
private $ijkpunten;
|
|
|
|
|
|
public function __construct( $orgversieid, $orguserid, $orgid, $scoretype)
|
|
{
|
|
$this->CI = & get_instance();
|
|
$this->orgversieid = $orgversieid;
|
|
$this->orgid = $orgid;
|
|
$this->orguserid = $orguserid;
|
|
$this->scoretype = $scoretype;
|
|
$this->handle();
|
|
}
|
|
|
|
public function getScores(){
|
|
return $this->scores;
|
|
}
|
|
|
|
public function getResults(){
|
|
return $this->results;
|
|
}
|
|
|
|
private function handle(){
|
|
$this->setUserid();
|
|
$this->setOrg();
|
|
$this->setIJkpunten();
|
|
$this->telIJkpunten();
|
|
$this->setScores();
|
|
$this->setAmbities();
|
|
$this->setKleuren();
|
|
$this->loopScores();
|
|
$this->setGemiddeldeScore();
|
|
$this->addGemiddeldeScore();
|
|
$this->setResults();
|
|
|
|
}
|
|
|
|
private function setUserid(){
|
|
$this->userid = $this->CI->Orgusers_model->get_fieldvalue(['id' =>$this->orguserid], 'user_id');
|
|
}
|
|
private function setOrg(){
|
|
$this->org = $this->CI->Organisaties_model->get_record_by_id($this->orgid);
|
|
$this->orgnaam = $this->org->brin? $this->org->brin . ' ' . $this->org->naamkort : $this->org->naamkort;
|
|
}
|
|
|
|
private function setIJkpunten(){
|
|
$this->ijkpunten = $this->CI->Ijkpunten_model->getijkpuntenMetIndicatoren($this->orgversieid);
|
|
}
|
|
|
|
private function telIJkpunten(){
|
|
if($this->ijkpunten){
|
|
foreach($this->ijkpunten as $ijkpunt){
|
|
if($ijkpunt->disabled == 'F'){
|
|
$this->aantalY++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private function setScores(){
|
|
if($this->scoretype ==4 )$this->scores = $this->CI->Scores_model->calculateindividualscorestype4($this->orgversieid, $this->orgid, $this->userid);
|
|
else $this->scores = $this->CI->Scores_model->calculateindividualscores($this->orgversieid, $this->orgid, $this->userid);
|
|
}
|
|
|
|
|
|
|
|
private function setAmbities(){
|
|
$ambitieorgs = '';
|
|
|
|
$ambitieorgs = $this->getAmbitieOrgs($this->orgid, $ambitieorgs);
|
|
$ambitieorgs = rtrim($ambitieorgs, ',');
|
|
|
|
$toporgsarray = explode(',', $ambitieorgs);
|
|
$toporgs = '';
|
|
$index = 0;
|
|
for($i = count($toporgsarray)-1; $i >= 0 ; $i--) {
|
|
if($index < 2) {
|
|
$toporgs .= $toporgsarray[$i] . ',';
|
|
$index++;
|
|
}
|
|
}
|
|
$toporgs = rtrim($toporgs, ',' );
|
|
|
|
$this->ambities = $this->CI->Ambities_model->mh_get_ambitie_orgversie($this->orgversieid, $ambitieorgs, $toporgs);
|
|
|
|
}
|
|
|
|
private function setKleuren(){
|
|
|
|
$this->kleuren = new stdClass();
|
|
$this->kleuren->grens1 = '60';
|
|
$this->kleuren->grens2 = '80';
|
|
$this->kleuren->grens3 = '90';
|
|
$this->kleuren->grens4 = '100';
|
|
if($this->scoretype ==7){
|
|
$this->kleuren->grens1 = '33';
|
|
$this->kleuren->grens2 = '66';
|
|
$this->kleuren->grens3 = '100';
|
|
}
|
|
$this->kleuren->kleur1 = '#e08885';
|
|
$this->kleuren->kleur2 = '#ffcc80';
|
|
$this->kleuren->kleur3 = '#9fdf9f';
|
|
$this->kleuren->kleur4 = '#99d6ff';
|
|
$this->kleuren->organisatie_id = '0';
|
|
|
|
}
|
|
|
|
|
|
private function loopScores(){
|
|
$this->aantaldisablenvt = 0;
|
|
if(! isset($this->scores) || $this->scores == false ) return;
|
|
foreach($this->scores as $this->score) {
|
|
$this->setNietVanToepassing();
|
|
$this->setGem();
|
|
$this->setSomscores();
|
|
$this->setScoreKleuren();
|
|
$this->telIJkpuntenok();
|
|
$this->setResultaten();
|
|
$this->setAdviezen();
|
|
}
|
|
}
|
|
|
|
private function setNietVanToepassing(){
|
|
if(! isset($this->scores) || $this->scores == false || $this->scoretype != 4 ) return;
|
|
if($this->score->disablenvt == 'T'){
|
|
$this->aantaldisablenvt++;
|
|
}
|
|
|
|
}
|
|
|
|
private function setGem(){
|
|
if(! isset($this->scores) || $this->scores == false ) return;
|
|
if($this->scoretype == 4) $this->score->gem = round($this->score->somscore);
|
|
else {
|
|
$this->score->gem = 0;
|
|
if (isset($this->score->somscore) && $this->score->num > 0) {
|
|
$this->score->gem = round($this->score->somscore / $this->score->num);
|
|
}
|
|
}
|
|
}
|
|
|
|
private function setSomscores()
|
|
{ if(! isset($this->scores) || $this->scores == false ) return;
|
|
if ($this->score->disabled == 'F' && $this->score->disablenvt == 'F') {
|
|
$this->somscore = $this->somscore + $this->score->gem;
|
|
$this->aantalscores++;
|
|
}
|
|
}
|
|
|
|
private function setScoreKleuren(){
|
|
if(! isset($this->scores) || $this->scores == false ) return;
|
|
$kleur = $this->CI->Scorekleuren_model->getGemiddeldeKleur($this->scoretype, $this->score->gem);
|
|
$kleur = $kleur->kleurcode;
|
|
if(!$kleur) $kleur = '#ffffff';
|
|
$this->score->kleur = $kleur;
|
|
|
|
}
|
|
|
|
private function telIJkpuntenok(){
|
|
if($this->ambities && $this->score->disabled == 'F' && $this->score->disablenvt == 'F') {
|
|
if ($this->score->gem >= $this->ambities->zprocent) {
|
|
$this->ijkpuntenok++;
|
|
}
|
|
}
|
|
}
|
|
private function setResultaten(){
|
|
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 setAdviezen(){
|
|
if(! isset($this->scores) || $this->scores == false ) return;
|
|
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;
|
|
}
|
|
$this->adviezen[] = ["nummer"=> $this->score->nummer, "omschrijving" =>$omschrijving];
|
|
}
|
|
}
|
|
private function setGemiddeldeScore(){
|
|
if(!$this->scores || $this->aantalscores == 0) return;
|
|
$this->gemiddelde = new stdClass();
|
|
$this->gemiddelde->gem = 0;
|
|
$deler = $this->aantalY - $this->aantaldisablenvt;
|
|
if($deler > 0) $this->gemiddelde->gem = round($this->somscore / $deler);
|
|
|
|
$this->gemiddelde->disabled = 'F';
|
|
$this->gemiddelde->disablenvt = 'F';
|
|
$this->gemiddelde->nummer = 'gem';
|
|
|
|
$kleur = $this->CI->Scorekleuren_model->getGemiddeldeKleur($this->scoretype, $this->gemiddelde->gem);
|
|
$kleur = $kleur->kleurcode;
|
|
if(!$kleur) $kleur = '#ffffff';
|
|
$this->gemiddelde->kleur = $kleur;
|
|
|
|
}
|
|
private function addGemiddeldeScore(){
|
|
if(!$this->scores || ! $this->gemiddelde) return;
|
|
array_push($this->scores, $this->gemiddelde);
|
|
}
|
|
|
|
private function setResults(){
|
|
if($this->scores) {
|
|
$this->resultaten = [
|
|
'totgem' => $this->gemiddelde->gem,
|
|
'ijkpuntenok' => $this->ijkpuntenok,
|
|
'welkehoogste' => $this->welkehoogste,
|
|
'hoogstescore' => round($this->hoogstescore, 1),
|
|
'welkelaagste' => $this->welkelaagste,
|
|
'laagstescore' => round($this->laagstescore, 1),
|
|
];
|
|
}
|
|
|
|
$this->results= [
|
|
'orgnaam' => $this->orgnaam,
|
|
'ijkpunten' => $this->ijkpunten,
|
|
'scores' => $this->scores ? $this->scores : false,
|
|
'ambities' => $this->ambities,
|
|
'kleuren' => $this->kleuren,
|
|
'resultaten' => $this->resultaten,
|
|
'adviezen' => $this->adviezen,
|
|
'aantalY' => $this->aantalY
|
|
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function getAmbitieOrgs($orgid, $ambitieorgs){
|
|
$ambitieorgs .= $orgid . ',';
|
|
$valtonder = $this->CI->Organisaties_model->get_fieldvalue(['id' => $orgid], 'valtonder_id');
|
|
if($valtonder != $orgid){
|
|
return $this->getAmbitieOrgs($valtonder, $ambitieorgs);
|
|
}
|
|
return $ambitieorgs;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} |