Browse Source

New ranking page.

master
Rogier Neeleman 9 years ago
parent
commit
9f84c77e2d
  1. 54
      application/controllers/Uitslag.php
  2. 71
      application/models/Uitslag_model.php
  3. 1
      application/views/header.php
  4. 40
      application/views/uitslag_ranking.php

54
application/controllers/Uitslag.php

@ -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');
}
}

71
application/models/Uitslag_model.php

@ -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();
}
}

1
application/views/header.php

@ -28,6 +28,7 @@
<li role="presentation" <?php if ($page == 'home') {?> class="active" <?php } ?> ><a href="<?php echo base_url('/');?>">Home</a></li> <li role="presentation" <?php if ($page == 'home') {?> class="active" <?php } ?> ><a href="<?php echo base_url('/');?>">Home</a></li>
<li role="presentation" <?php if ($page == 'beoordelen') {?> class="active" <?php } ?> ><a href="<?php echo base_url('beoordelen/');?>">Beoordelen</a></li> <li role="presentation" <?php if ($page == 'beoordelen') {?> class="active" <?php } ?> ><a href="<?php echo base_url('beoordelen/');?>">Beoordelen</a></li>
<?php if ($this->session->admin == '1' OR $this->session->superadmin == '1') { ?> <?php if ($this->session->admin == '1' OR $this->session->superadmin == '1') { ?>
<li role="presentation" <?php if ($page == 'uitslag') {?> class="active" <?php } ?> ><a href="<?php echo base_url('uitslag/');?>">Uitslag</a></li>
<li role="presentation" <?php if ($page == 'config') {?> class="active" <?php } ?> ><a href="<?php echo base_url('config/');?>">Configuratie</a></li> <li role="presentation" <?php if ($page == 'config') {?> class="active" <?php } ?> ><a href="<?php echo base_url('config/');?>">Configuratie</a></li>
<?php }; ?> <?php }; ?>
<li role="presentation" <?php if ($page == 'info') {?> class="active" <?php } ?> ><a href="<?php echo base_url('info/');?>">Informatie</a></li> <li role="presentation" <?php if ($page == 'info') {?> class="active" <?php } ?> ><a href="<?php echo base_url('info/');?>">Informatie</a></li>

40
application/views/uitslag_ranking.php

@ -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…
Cancel
Save