diff --git a/application/controllers/Uitslag.php b/application/controllers/Uitslag.php new file mode 100644 index 0000000..5208079 --- /dev/null +++ b/application/controllers/Uitslag.php @@ -0,0 +1,54 @@ +session->userdata('validated')){ + redirect(base_url('/login')); + } + if (! ($this->session->admin == '1' OR $this->session->superadmin == '1')) { + redirect(base_url('/dashboard')); + } + } + + public function index() + { + $data['page'] = 'uitslag'; + + // Get data + $this->load->model('Uitslag_model'); + $subgroepen = $this->Uitslag_model->get_subgroep_list(); + $spelgebieden = $this->Uitslag_model->get_spelgebieden_list(); + + foreach ($subgroepen as $subgroep) { + $data['uitslag'][$subgroep['id']]['total'] = 0; + $scores = $this->Uitslag_model->get_subgroep_punten($subgroep['id']); + + foreach ($scores as $score) { + $data['uitslag'][$subgroep['id']][$score['spelgebiedid']] = $score['score']; + $data['uitslag'][$subgroep['id']]['total'] = $data['uitslag'][$subgroep['id']]['total'] + $score['score']; + } + } + + // Prepare data + $data['subgroepen'] = $subgroepen; + $data['spelgebieden'] = $spelgebieden; + + // Header + $this->load->view('header', $data); + + // Ranking page + $this->load->view('uitslag_ranking', $data); + + // Footer + $this->load->view('footer'); + } + +} \ No newline at end of file diff --git a/application/models/Uitslag_model.php b/application/models/Uitslag_model.php new file mode 100644 index 0000000..9d66f05 --- /dev/null +++ b/application/models/Uitslag_model.php @@ -0,0 +1,71 @@ +db->select('subgroep.id AS id, + subgroep.naam AS naam, + subgroep.themanaam AS themanaam, + subgroep.nummer AS nummer, + groep.naam AS groepsnaam'); + $this->db->from('subgroep'); + $this->db->where('subgroep.regioid', $this->session->regio); + $this->db->where('subgroep.jaar', date('Y')); + $this->db->join('groep', 'subgroep.groepid=groep.id', 'left'); + $this->db->order_by('nummer', 'ASC'); + + $query = $this->db->get(); + + return $query->result_array(); + } + + public function get_spelgebieden_list() + { + $this->db->select('id, naam'); + $this->db->from('spelgebied'); + $this->db->where('regioid', $this->session->regio); + $this->db->where('jaar', date('Y')); + $this->db->order_by('naam', 'ASC'); + + $query = $this->db->get(); + + return $query->result_array(); + } + + public function get_subgroep_punten($subgroepid) + { + $this->db->select('SUM(resultaat.score/lijst.ronde) AS score, + spelgebied.id AS spelgebiedid, + '); + $this->db->from('resultaat'); + + $this->db->where('resultaat.regioid', $this->session->regio); + $this->db->where('vragen.jaar', date('Y')); + $this->db->where('resultaat.subgroepid', $subgroepid); + + $this->db->join('vragen', 'resultaat.vraagid=vragen.id', 'left'); + $this->db->join('onderdeel', 'vragen.onderdeelid=onderdeel.id', 'left'); + $this->db->join('spelgebied', 'onderdeel.spelgebiedid=spelgebied.id', 'left'); + $this->db->join('lijst', 'vragen.lijstid=lijst.id', 'left'); + + $this->db->group_by('spelgebied.naam'); + + $this->db->order_by('spelgebied.id', 'ASC'); + + $query = $this->db->get(); + + return $query->result_array(); + } + +} \ No newline at end of file diff --git a/application/views/header.php b/application/views/header.php index 9a86e1c..83f1da4 100644 --- a/application/views/header.php +++ b/application/views/header.php @@ -28,6 +28,7 @@
  • class="active" >Home
  • class="active" >Beoordelen
  • session->admin == '1' OR $this->session->superadmin == '1') { ?> +
  • class="active" >Uitslag
  • class="active" >Configuratie
  • class="active" >Informatie
  • diff --git a/application/views/uitslag_ranking.php b/application/views/uitslag_ranking.php new file mode 100644 index 0000000..b3c3452 --- /dev/null +++ b/application/views/uitslag_ranking.php @@ -0,0 +1,40 @@ +
    +
    +
    +
    + + + + + + + ".$spelgebied['naam'].""; + } ?> + + + + + + + + + + ".round($score, 2).""; + } + echo ""; + ?> + + + + +
    #SubgroepGroepTotaal
    ".round($uitslag[$subgroep['id']]['total'], 2)."
    +
    +
    \ No newline at end of file