Advertisement
GILZID

Auth.php

Dec 14th, 2019
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.71 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') or exit('No direct script access allowed');
  3.  
  4. class Auth extends CI_Controller
  5. {
  6.     public function __construct()
  7.     {
  8.         parent::__construct();
  9.         $this->load->model('auth/auth_m', 'authm');
  10.     }
  11.  
  12.     public function registration_list()
  13.     {
  14.         $role_ids = $this->authm->get_list_role();
  15.  
  16.         $opt = array('' => 'Pilih Role');
  17.         foreach ($role_ids as $role_id) {
  18.             if($role_id == 1) {
  19.                 $role = "Administrator";
  20.             }
  21.             if($role_id == 2) {
  22.                 $role = "Member";
  23.             }
  24.             $opt[$role_id] = $role;
  25.         }
  26.  
  27.         $is_actives = $this->authm->get_list_active();
  28.  
  29.         $opt2 = array('' => 'Pilih Status');
  30.         foreach ($is_actives as $is_active) {
  31.             if($is_active == 0) {
  32.                 $status = "Aktif";
  33.             }
  34.             if($is_active == 1) {
  35.                 $status = "Tidak Aktif";
  36.             }
  37.             $opt2[$is_active] = $status;
  38.         }
  39.  
  40.         $data['form_role'] = form_dropdown('', $opt, '', 'class="form-control" id="role"');
  41.         $data['form_status'] = form_dropdown('', $opt2, '', 'class="form-control" id="status"');
  42.         $this->load->view('auth/registration_list', $data);
  43.     }
  44.  
  45.     public function ajax_list()
  46.     {
  47.         $list = $this->authm->get_datatables();
  48.         $data = array();
  49.         $no = $_POST['start'];
  50.         foreach ($list as $admin_panel) {
  51.             $no++;
  52.             $row = array();
  53.             $row[] = $no;
  54.             $row[] = $admin_panel->name;
  55.             $row[] = $admin_panel->username;
  56.             $row[] = $admin_panel->email;
  57.             $row[] = $admin_panel->role_id;
  58.             $row[] = $admin_panel->is_active;
  59.             $row[] = 'TES';
  60.  
  61.             $data[] = $row;
  62.         }
  63.  
  64.         $output = array(
  65.             "draw" => $_POST['draw'],
  66.             "recordsTotal" => $this->authm->count_all(),
  67.             "recordsFiltered" => $this->authm->count_filtered(),
  68.             "data" => $data,
  69.         );
  70.  
  71.         //Output To JSON Format
  72.         echo json_encode($output);
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement