From ecf0e94eab9d947c7e52804469d44a9aea3790f2 Mon Sep 17 00:00:00 2001 From: Rogier Neeleman Date: Thu, 7 Apr 2016 11:49:39 +0200 Subject: [PATCH] Afronding komt nu uit de database config --- application/controllers/Uitslag.php | 8 ++++++-- application/models/Uitslag_model.php | 13 +++++++++++++ application/views/uitslag_groep.php | 18 +++++++++--------- application/views/uitslag_ranking.php | 4 ++-- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/application/controllers/Uitslag.php b/application/controllers/Uitslag.php index bb31939..31338f1 100644 --- a/application/controllers/Uitslag.php +++ b/application/controllers/Uitslag.php @@ -27,6 +27,8 @@ class Uitslag extends CI_Controller $subgroepen = $this->Uitslag_model->get_subgroep_list(); $spelgebieden = $this->Uitslag_model->get_spelgebieden_list(); $maxpuntenraw = $this->Uitslag_model->get_max_punten(); + $maxtotaalpunten = $this->Uitslag_model->get_config('maxpunten'); + $data['round'] = $this->Uitslag_model->get_config('round'); // Totaal bepalen $totaal = 0; @@ -35,7 +37,7 @@ class Uitslag extends CI_Controller $scoremax = $this->Uitslag_model->get_max_punten_detail($spelgebied['id']); $totaalgewicht = $totaalgewicht + $scoremax['gewicht']; } - $totaalpsg = 1000/$totaalgewicht; + $totaalpsg = $maxtotaalpunten/$totaalgewicht; foreach ($maxpuntenraw as $max) { $maxpunten[$max['spelgebiedid']]['maxscore'] = $max['maxscore']; @@ -78,6 +80,8 @@ class Uitslag extends CI_Controller $onderdelen = $this->Uitslag_model->get_lijst_detail(); $spelgebieden = $this->Uitslag_model->get_spelgebieden_list(); $data['subgroepinfo'] = $this->Uitslag_model->get_subgroep($subgroepid); + $maxtotaalpunten = $this->Uitslag_model->get_config('maxpunten'); + $data['round'] = $this->Uitslag_model->get_config('round'); // Data order $totaal = 0; @@ -86,7 +90,7 @@ class Uitslag extends CI_Controller $scoremax = $this->Uitslag_model->get_max_punten_detail($spelgebied['id']); $totaalgewicht = $totaalgewicht + $scoremax['gewicht']; } - $totaalpsg = 1000/$totaalgewicht; + $totaalpsg = $maxtotaalpunten/$totaalgewicht; foreach ($onderdelen as $onderdeel) { $scoremax = $this->Uitslag_model->get_max_punten_detail($onderdeel['spelgebiedid'], $onderdeel['onderdeelid']); diff --git a/application/models/Uitslag_model.php b/application/models/Uitslag_model.php index f5a4df2..dc30244 100644 --- a/application/models/Uitslag_model.php +++ b/application/models/Uitslag_model.php @@ -61,6 +61,19 @@ class Uitslag_model extends CI_Model return $query->result_array(); } + public function get_config($configname) + { + $this->db->select('value'); + $this->db->from('config'); + $this->db->where('regioid', $this->session->regio); + $this->db->where('jaar', date('Y')); + $this->db->where('name', $configname); + + $query = $this->db->get(); + + return $query->row()->value; + } + public function get_subgroep_punten($subgroepid) { $this->db->select('SUM('.$this->db->dbprefix('resultaat').'.score/'.$this->db->dbprefix('lijst').'.ronde) AS score, diff --git a/application/views/uitslag_groep.php b/application/views/uitslag_groep.php index fb03a70..92b8217 100644 --- a/application/views/uitslag_groep.php +++ b/application/views/uitslag_groep.php @@ -25,9 +25,9 @@ $scoremaxtot=0; foreach ($spelgebied['onderdeel'] as $onderdeel) { ?> - - - + + + @@ -36,9 +36,9 @@ $totalmax=$totalmax+$onderdeel['scoremax']; } ?> Subtotaal: - - - % + + + % @@ -46,9 +46,9 @@ Totaal: - - - % + + + % diff --git a/application/views/uitslag_ranking.php b/application/views/uitslag_ranking.php index 3e9ec75..51156c0 100644 --- a/application/views/uitslag_ranking.php +++ b/application/views/uitslag_ranking.php @@ -26,9 +26,9 @@ } else { $score = 0; } - echo "".round($score, 0).""; + echo "".number_format(round($score, $round), $round, ',', '').""; } - echo "".round($uitslag[$subgroep['id']]['total'], 0).""; + echo "".number_format(round($uitslag[$subgroep['id']]['total'], $round), $round, ',', '').""; ?>