Esempio n. 1
0
 function ajax()
 {
     if (!$this->input->is_ajax_request()) {
         exit('No direct script access allowed');
     } else {
         $table = '' . DBPREFIX . 'user';
         $primaryKey = 'id_user';
         $columns = array(array('db' => 'id_user', 'dt' => 'id_user'), array('db' => 'username', 'dt' => 'username'), array('db' => 'role_name', 'dt' => 'role_name'), array('db' => 'nama', 'dt' => 'nama'), array('db' => 'email', 'dt' => 'email'), array('db' => 'id_user', 'dt' => 'action', 'formatter' => function ($id) {
             return '<a href="' . base_url('' . $this->uri->segment(1) . '/' . $this->uri->segment(2) . '/view/' . $id) . '" target="_blank" class="btn btn-info btn-xs">View</a> <a href="' . base_url('' . $this->uri->segment(1) . '/' . $this->uri->segment(2) . '/update/' . $id) . '" class="btn btn-primary btn-xs">Update</a> <a href="' . base_url('' . $this->uri->segment(1) . '/' . $this->uri->segment(2) . '/delete/' . $id) . '" class="btn btn-danger btn-xs">Delete</a>';
         }));
         $joinQuery = "FROM `" . DBPREFIX . "user` JOIN `" . DBPREFIX . "role` ON `" . DBPREFIX . "user`.`role_id`=`" . DBPREFIX . "role`.`id_role`";
         $sql_details = array('user' => $this->db->username, 'pass' => $this->db->password, 'db' => $this->db->database, 'host' => $this->db->hostname);
         $this->output->set_content_type('application/json')->set_output(json_encode(Datatables_join::simple($_GET, $sql_details, $table, $primaryKey, $columns, $joinQuery), JSON_PRETTY_PRINT));
     }
 }
Esempio n. 2
0
 function ajax()
 {
     if (!$this->input->is_ajax_request()) {
         exit('No direct script access allowed');
     } else {
         $table = '' . DBPREFIX . 'vote';
         $primaryKey = 'id_vote';
         $columns = array(array('db' => 'id_vote', 'dt' => 'id_vote'), array('db' => 'username', 'dt' => 'username'), array('db' => 'vote_in', 'dt' => 'vote_in'), array('db' => 'vote_for', 'dt' => 'vote_for', 'formatter' => function ($vote) {
             if ($vote === 'Up') {
                 return '<i class="fa fa-thumbs-o-up"></i>';
             } else {
                 return '<i class="fa fa-thumbs-o-down"></i>';
             }
         }), array('db' => 'id_vote', 'dt' => 'action', 'formatter' => function ($id) {
             return '<a href="' . base_url('' . $this->uri->segment(1) . '/' . $this->uri->segment(2) . '/delete/' . $id) . '" class="btn btn-danger btn-xs">Delete</a>';
         }));
         $joinQuery = "FROM `" . DBPREFIX . "vote` JOIN `" . DBPREFIX . "user` ON `" . DBPREFIX . "vote`.`user_id`=`" . DBPREFIX . "user`.`id_user`";
         $sql_details = array('user' => $this->db->username, 'pass' => $this->db->password, 'db' => $this->db->database, 'host' => $this->db->hostname);
         $this->output->set_content_type('application/json')->set_output(json_encode(Datatables_join::simple($_GET, $sql_details, $table, $primaryKey, $columns, $joinQuery), JSON_PRETTY_PRINT));
     }
 }