[ Mini Kiebo ]
Server: Windows NT AKFAR_SERVER 10.0 build 26200 (Windows 10) AMD64
Path:
D:
/
xampp
/
htdocs
/
smk
/
application
/
controllers
/
hotspot
/
[
Home
]
File: Daftaruser.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Daftaruser extends Member_Controller { private $kode_menu = 'hotspot-daftaruser'; private $url = 'hotspot/daftaruser'; function __construct(){ parent:: __construct(); $this->load->model('hotspot/user_model'); $this->load->model('akademik/kelas_model'); } public function index($page=null, $id=null){ $data['kode_menu'] = $this->kode_menu; $data['nama'] = $this->access->get_nama(); parent::cek_akses($data['kode_menu']); $this->template->display_admin($this->url.'/list_view', 'Daftar User Hotspot', $data); } function edit(){ $this->load->library('form_validation'); $this->form_validation->set_rules('id', 'ID User','required|strip_tags'); $this->form_validation->set_rules('aksi', 'Aksi','required|strip_tags'); $this->form_validation->set_rules('username', 'Username','required|strip_tags'); $this->form_validation->set_rules('nama', 'Nama','required|strip_tags'); $this->form_validation->set_rules('password', 'Password','required|strip_tags'); if($this->form_validation->run() == TRUE){ $aksi = $this->input->post('aksi', TRUE); $id = $this->input->post('id', TRUE); if($aksi==0){//hapus $this->user_model->delete($id); $status['status'] = 1; $status['pesan'] = 'User Hotspot berhasil dihapus'; }else if($aksi==1){//simpan $data['password'] = $this->input->post('password', true); $data['status'] = $this->input->post('status', true); $this->user_model->update($data, $id); $status['status'] = 1; $status['pesan'] = 'Data User Hotspot berhasil di Simpan'; } }else{ $status['status'] = 0; $status['pesan'] = validation_errors(); } echo json_encode($status); } function hapussemua(){ $this->load->library('form_validation'); $this->form_validation->set_rules('iduser', 'User','required'); if($this->form_validation->run() == TRUE){ $user = $this->input->post('iduser', true); foreach( $user as $kunci => $isi ) { $this->user_model->delete($kunci); } $status['status'] = 1; $status['pesan'] = 'User Hotspot yang terpilih berhasil dihapus'; }else{ $status['status'] = 0; $status['pesan'] = validation_errors(); } echo json_encode($status); } function get_user_by_id($id=null){ $data['data'] = 0; if(!empty($id)){ $query = $this->user_model->get_user_by_id($id); if($query->num_rows()>0){ $query = $query->row(); $data['data'] = 1; $data['id'] = $query->id; $data['username'] = $query->username; $data['nama'] = $query->nama; $data['password'] = $query->password; $data['status'] = $query->status; } } echo json_encode($data); } function get_all_user(){ $is_edit = $this->access->cek_akses_crud($this->kode_menu, 1); // variable initialization $search = ""; $start = 0; $rows = 10; // get search value (if any) if (isset($_GET['sSearch']) && $_GET['sSearch'] != "" ) { $search = $_GET['sSearch']; } // limit $start = $this->get_start(); $rows = $this->get_rows(); // run query to get user listing $query = $this->user_model->get_all_user($start, $rows, $search); $iFilteredTotal = $query->num_rows(); $iTotal=$this->user_model->get_all_user_count($search)->row()->hasil; $output = array( "sEcho" => intval($_GET['sEcho']), "iTotalRecords" => $iTotal, "iTotalDisplayRecords" => $iTotal, "aaData" => array() ); // get result after running query and put it in array $i=$start; $user = $query->result(); foreach ($user as $temp) { $record = array(); $record[] = '<input type="checkbox" name="iduser['.$temp->id.']" >'; $record[] = $temp->nis; $record[] = $temp->nama; $record[] = $this->kelas_model->get_kelas_by_id($temp->id_kelas)->row()->kelas; if($temp->status==1){ $record[] = "AKTIF"; }else{ $record[] = "NON AKTIF"; } if($is_edit){ $record[] = '<a onclick="edit(\''.$temp->id.'\')" class="btn btn-default btn-xs">Edit</a>'; }else{ $record[] = ''; } $output['aaData'][] = $record; } // format it to JSON, this output will be displayed in datatable echo json_encode($output); } /** * funsi tambahan * * */ function get_start() { $start = 0; if (isset($_GET['iDisplayStart'])) { $start = intval($_GET['iDisplayStart']); if ($start < 0) $start = 0; } return $start; } function get_rows() { $rows = 10; if (isset($_GET['iDisplayLength'])) { $rows = intval($_GET['iDisplayLength']); if ($rows < 5 || $rows > 500) { $rows = 10; } } return $rows; } function get_sort_dir() { $sort_dir = "ASC"; $sdir = strip_tags($_GET['sSortDir_0']); if (isset($sdir)) { if ($sdir != "asc" ) { $sort_dir = "DESC"; } } return $sort_dir; } }