Rogier Neeleman
9 years ago
4 changed files with 166 additions and 0 deletions
@ -0,0 +1,54 @@ |
|||||||
|
<?php |
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed'); |
||||||
|
|
||||||
|
/** |
||||||
|
* Info Class |
||||||
|
*/ |
||||||
|
class Uitslag extends CI_Controller |
||||||
|
{ |
||||||
|
|
||||||
|
public function __construct() |
||||||
|
{ |
||||||
|
parent::__construct(); |
||||||
|
if(! $this->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'); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,71 @@ |
|||||||
|
<?php |
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed'); |
||||||
|
|
||||||
|
/** |
||||||
|
* Regio model |
||||||
|
*/ |
||||||
|
class Uitslag_model extends CI_Model |
||||||
|
{ |
||||||
|
|
||||||
|
public function __construct() |
||||||
|
{ |
||||||
|
parent::__construct(); |
||||||
|
} |
||||||
|
|
||||||
|
public function get_subgroep_list() |
||||||
|
{ |
||||||
|
$this->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(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,40 @@ |
|||||||
|
<div class="container"> |
||||||
|
<hr> |
||||||
|
<div class="row"> |
||||||
|
<div class="col-md-12"> |
||||||
|
<table class="table table-hover"> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th>#</th> |
||||||
|
<th>Subgroep</th> |
||||||
|
<th>Groep</th> |
||||||
|
<?php foreach ($spelgebieden as $spelgebied) {
|
||||||
|
echo "<th>".$spelgebied['naam']."</th>"; |
||||||
|
} ?> |
||||||
|
<th>Totaal</th> |
||||||
|
</thead> |
||||||
|
|
||||||
|
<tbody> |
||||||
|
<?php foreach ($subgroepen as $subgroep) { ?> |
||||||
|
<tr> |
||||||
|
<td><?php echo $subgroep['nummer']?></td>
|
||||||
|
<td><?php echo $subgroep['naam']?></td>
|
||||||
|
<td><?php echo $subgroep['groepsnaam']?></td>
|
||||||
|
<?php foreach ($spelgebieden as $spelgebied) { |
||||||
|
if (isset($uitslag[$subgroep['id']][$spelgebied['id']])) { |
||||||
|
$score = $uitslag[$subgroep['id']][$spelgebied['id']]; |
||||||
|
} else { |
||||||
|
$score = 0; |
||||||
|
} |
||||||
|
echo "<th>".round($score, 2)."</th>"; |
||||||
|
} |
||||||
|
echo "<th>".round($uitslag[$subgroep['id']]['total'], 2)."</th>"; |
||||||
|
?> |
||||||
|
</tr> |
||||||
|
<?php } ?> |
||||||
|
</tbody> |
||||||
|
|
||||||
|
</table> |
||||||
|
</div> |
||||||
|
</div |
||||||
|
</div> |
Loading…
Reference in new issue