You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.8 KiB

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