4 changed files with 128 additions and 0 deletions
			
			
		| @ -0,0 +1,58 @@@@ -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/')); | ||||
| 	} | ||||
| 	 | ||||
| } | ||||
| @ -0,0 +1,39 @@@@ -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); | ||||
| 	} | ||||
| 	 | ||||
| } | ||||
| @ -0,0 +1,30 @@@@ -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> | ||||
					Loading…
					
					
				
		Reference in new issue