Browse Source

Dashboard view with progress

master 0.0.2
Rogier Neeleman 9 years ago
parent
commit
760f718f6a
  1. 58
      application/controllers/Dashboard.php
  2. 100
      application/models/Dashboard_model.php
  3. 45
      application/views/dashboard_user.php

58
application/controllers/Dashboard.php

@ -20,7 +20,8 @@ class Dashboard extends CI_Controller @@ -20,7 +20,8 @@ class Dashboard extends CI_Controller
if ($this->session->admin == '1' OR $this->session->superadmin == '1') {
redirect(base_url('/dashboard/admin'));
} else {
redirect(base_url('/dashboard/user'));
redirect(base_url('/dashboard/admin'));
// redirect(base_url('/dashboard/user'));
}
}
@ -28,11 +29,57 @@ class Dashboard extends CI_Controller @@ -28,11 +29,57 @@ class Dashboard extends CI_Controller
{
$data['page'] = 'home';
// Load model
// Totaal bar
$this->load->model('Dashboard_model');
$vragen = $this->Dashboard_model->get_total_vragen();
$antwoorden = $this->Dashboard_model->get_total_gedaan();
$data['gedaan'] = round(($antwoorden/$vragen)*100);
// Per lijst
$subgroepen = $this->Dashboard_model->get_subgroepen();
$lijsten = $this->Dashboard_model->get_lijsten();
foreach ($lijsten as $lijst)
{
$beantwoord = 0;
$bardata[$lijst['id']]['naam'] = $lijst['naam'];
$vragen = $this->Dashboard_model->get_vragen($lijst['id']);
foreach ($vragen as $vraag)
{
$aantal = $this->Dashboard_model->get_antwoorden($vraag['id']);
$beantwoord = $beantwoord + $aantal;
}
$bardata[$lijst['id']]['percentage'] = (($beantwoord)/($subgroepen*count($vragen)))*100;
}
$data['bardata'] = $bardata;
$barok = 0;
$barnok = 0;
$barbezig = 0;
foreach ($bardata as $bar)
{
if ($bar['percentage'] == 100) {
$barok = $barok + 1;
} elseif ($bar['percentage'] == 0) {
$barnok = $barnok + 1;
} else {
$barbezig = $barbezig + 1;
}
}
$data['bar']['gedaan'] = round(($barok/($barok + $barnok + $barbezig))*100);
$data['bar']['bezig'] = round(($barbezig/($barok + $barnok + $barbezig))*100);
$data['bar']['doen'] = 100-$data['bar']['gedaan']-$data['bar']['bezig'];
// Header
$this->load->view('header', $data);
// login page
//$this->load->view('dashboard_user', $data);
$this->load->view('dashboard_user', $data);
// Footer
$this->load->view('footer');
@ -42,6 +89,13 @@ class Dashboard extends CI_Controller @@ -42,6 +89,13 @@ class Dashboard extends CI_Controller
{
$data['page'] = 'home';
// Load model
$this->load->model('Dashboard_model');
$vragen = $this->Dashboard_model->get_total_vragen();
$antwoorden = $this->Dashboard_model->get_total_gedaan();
$data['gedaan'] = round(($antwoorden/$vragen)*100);
// Header
$this->load->view('header', $data);

100
application/models/Dashboard_model.php

@ -0,0 +1,100 @@ @@ -0,0 +1,100 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Regio model
*/
class Dashboard_model extends CI_Model
{
public function __construct()
{
parent::__construct();
}
public function get_total_vragen()
{
$this->db->select('COUNT(*) as antwoord');
$this->db->from('vragen');
$this->db->where('regioid', $this->session->regio);
$this->db->where('jaar', date('Y'));
$query = $this->db->get();
$vragen = $query->row()->antwoord;
$this->db->select('COUNT(*) as antwoord');
$this->db->from('subgroep');
$this->db->where('regioid', $this->session->regio);
$this->db->where('jaar', date('Y'));
$query = $this->db->get();
$subgroepen = $query->row()->antwoord;
return $vragen*$subgroepen;
}
public function get_total_gedaan()
{
$this->db->select('COUNT(*) as antwoord');
$this->db->from('resultaat');
$this->db->where('regioid', $this->session->regio);
//$this->db->where('jaar', date('Y'));
$query = $this->db->get();
return $query->row()->antwoord;
}
public function get_subgroepen()
{
$this->db->select('COUNT(*) as antwoord');
$this->db->from('subgroep');
$this->db->where('regioid', $this->session->regio);
$this->db->where('jaar', date('Y'));
$query = $this->db->get();
return $query->row()->antwoord;
}
public function get_lijsten()
{
$this->db->select('id, naam');
$this->db->from('lijst');
$this->db->where('jaar', date('Y'));
$this->db->where('regioid', $this->session->regio);
$this->db->order_by('naam', 'ASC');
$query = $this->db->get();
return $query->result_array();
}
public function get_vragen($lijstid)
{
$this->db->select('id');
$this->db->from('vragen');
$this->db->where('regioid', $this->session->regio);
$this->db->where('jaar', date('Y'));
$this->db->where('lijstid', $lijstid);
$query = $this->db->get();
return $query->result_array();
}
public function get_antwoorden($vraagid)
{
$this->db->select('COUNT(*) as antwoord');
$this->db->from('resultaat');
$this->db->where('regioid', $this->session->regio);
//$this->db->where('jaar', date('Y'));
$this->db->where('vraagid', $vraagid);
$query = $this->db->get();
return $query->row()->antwoord;
}
}

45
application/views/dashboard_user.php

@ -1,5 +1,48 @@ @@ -1,5 +1,48 @@
<div class="container">
<hr>
Welkom bij het score systeem. Maak een keuze.
<p><b>Totalen</b><br>
Er is op dit moment <?php echo $gedaan; ?>% van de beoordelingen beantwoord.</p>
<div class="progress">
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="<?php echo $gedaan; ?>" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo $gedaan; ?>%">
<span class="sr-only"><?php echo $gedaan; ?>% Gedaan</span>
</div>
</div>
Er is op dit moment van de lijsten <?php echo $bar['gedaan']; ?>% helemaal gedaan,
<?php echo $bar['bezig']; ?>% is gedeeltelijk gedaan en
<?php echo $bar['doen']; ?>% moet nog gedaan worden.</p>
<div class="progress">
<div class="progress-bar progress-bar-success" style="width: <?php echo $bar['gedaan']; ?>%">
<span class="sr-only"><?php echo $bar['gedaan']; ?>% Gedaan</span>
</div>
<div class="progress-bar progress-bar-warning" style="width: <?php echo $bar['bezig']; ?>%">
<span class="sr-only"><?php echo $bar['bezig']; ?>% Nog bezig</span>
</div>
<div class="progress-bar progress-bar-danger" style="width: <?php echo $bar['doen']; ?>%">
<span class="sr-only"><?php echo $bar['doen']; ?>% Te doen</span>
</div>
</div>
<p><b>Per onderdeel</b>
<?php foreach ($bardata as $bar) { ?>
<p><?php echo $bar['naam']; ?>
<?php if ($bar['percentage'] == 100) {?>
<div class="progress">
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="<?php echo $bar['percentage']; ?>" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo $bar['percentage']; ?>%">
<span class="sr-only"><?php echo $bar['percentage']; ?>% Complete</span>
</div>
</div>
<?php } else { ?>
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="<?php echo $bar['percentage']; ?>" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo $bar['percentage']; ?>%">
<span class="sr-only"><?php echo $bar['percentage']; ?>% Complete</span>
</div>
</div>
<?php } ?>
</p>
<?php } ?>
</p>
</div>
Loading…
Cancel
Save