tussenopslag
This commit is contained in:
@@ -4,16 +4,23 @@ 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;
|
||||
|
||||
public function __construct( $orgversieid, $orguserid, $orgid)
|
||||
public function __construct( $orgversieid, $orguserid, $orgid, $scoretype)
|
||||
{
|
||||
$this->CI = & get_instance();
|
||||
$this->orgversieid = $orgversieid;
|
||||
$this->orgid = $orgid;
|
||||
$this->orguserid = $orguserid;
|
||||
$this->teller = 0;
|
||||
$this->scoretype = $scoretype;
|
||||
$this->handle();
|
||||
}
|
||||
|
||||
@@ -21,26 +28,103 @@ class Individuelescores
|
||||
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(){
|
||||
$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(){
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +132,7 @@ class Individuelescores
|
||||
$this->score->disablenvt = 'F';
|
||||
if($this->score->aantalvier> 0 && $this->score->aantalvier == $this->score->aantalnvt)
|
||||
$this->score->disablenvt = 'T';
|
||||
$this->aantaldisablenvt++;
|
||||
|
||||
}
|
||||
|
||||
@@ -58,5 +143,119 @@ class Individuelescores
|
||||
}
|
||||
}
|
||||
|
||||
private function setSomscores()
|
||||
{
|
||||
if ($this->score->disabled == 'F' && $this->score->disablenvt == 'F') {
|
||||
$this->somscore = $this->somscore + $this->score->gem;
|
||||
$this->aantalscores++;
|
||||
}
|
||||
}
|
||||
|
||||
private function setScoreKleuren(){
|
||||
$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->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->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(){
|
||||
|
||||
$this->resultaten = [
|
||||
'totgem' => $this->score->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,
|
||||
'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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user