Browse Source

Overzichtspagina voor aanpassen van lijsten.

master
Rogier Neeleman 9 years ago
parent
commit
32189c1004
  1. 58
      application/controllers/Edit.php
  2. 39
      application/models/Edit_model.php
  3. 30
      application/views/edit_lijst.php
  4. 1
      application/views/header.php

58
application/controllers/Edit.php

@ -0,0 +1,58 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Info Class
*/
class Edit 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'] = 'edit';
// Get data
$this->load->model('Edit_model');
$lijsten = $this->Edit_model->get_lijst();
// Prepare data
$data['lijsten'] = $lijsten;
// Header
$this->load->view('header', $data);
// lijst list page
$this->load->view('edit_lijst', $data);
// Footer
$this->load->view('footer');
}
public function enable($lijstid)
{
$this->load->model('Edit_model');
$this->Edit_model->change_lijst($lijstid, '1');
redirect(base_url('edit/'));
}
public function disable($lijstid)
{
$this->load->model('Edit_model');
$this->Edit_model->change_lijst($lijstid, '0');
redirect(base_url('edit/'));
}
}

39
application/models/Edit_model.php

@ -0,0 +1,39 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Regio model
*/
class Edit_model extends CI_Model
{
public function __construct()
{
parent::__construct();
}
public function get_lijst()
{
$this->db->select('id, naam, actief');
$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 change_lijst($id, $val)
{
$data = array(
'actief' => $val
);
$this->db->where('id', $id);
$this->db->where('regioid', $this->session->regio);
$this->db->where('jaar', date('Y'));
$this->db->update('lijst', $data);
}
}

30
application/views/edit_lijst.php

@ -0,0 +1,30 @@
<div class="container">
<hr>
<div class="row">
<div class="col-md-4 col-md-offset-4">
<table class="table table-hover" id="maintable">
<thead>
<tr>
<th>Naam</th>
<th>Aanpassen</th>
<th>Actief</th>
</thead>
<tbody>
<?php foreach ($lijsten as $lijst) {?>
<tr>
<td><?php echo $lijst['naam']; ?></td>
<td class="text-center"><a href="<?php echo base_url('edit/lijst/'.$lijst['id'])?>"><span class="glyphicon glyphicon-pencil"></span></a></td>
<?php if ($lijst['actief'] == 1) { ?>
<td class="text-center"><a href="<?php echo base_url('edit/disable/'.$lijst['id'])?>"><span class="glyphicon glyphicon-ok text-success"></span></a></td>
<?php } else { ?>
<td class="text-center"><a href="<?php echo base_url('edit/enable/'.$lijst['id'])?>"><span class="glyphicon glyphicon-remove text-danger"></span></a></td>
<?php } ?>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div
</div>

1
application/views/header.php

@ -29,6 +29,7 @@
<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 == 'uitslag') {?> class="active" <?php } ?> ><a href="<?php echo base_url('uitslag/');?>">Uitslag</a></li>
<li role="presentation" <?php if ($page == 'edit') {?> class="active" <?php } ?> ><a href="<?php echo base_url('edit/');?>">Aanpassen</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>
<?php if ($this->session->admin == '1' OR $this->session->superadmin == '1') { ?> <?php if ($this->session->admin == '1' OR $this->session->superadmin == '1') { ?>

Loading…
Cancel
Save