133 lines
4.4 KiB
PHP
Executable File
133 lines
4.4 KiB
PHP
Executable File
<?php
|
|
|
|
if (!defined('BASEPATH'))
|
|
exit('No direct script access allowed');
|
|
|
|
class Permission_model extends CI_model {
|
|
|
|
function __construct() {
|
|
parent::__construct();
|
|
$this->load->database();
|
|
}
|
|
|
|
function insertPermission($data) {
|
|
$this->db->insert('permissions', $data);
|
|
}
|
|
|
|
function getPermission() {
|
|
$query = $this->db->get('permissions');
|
|
return $query->result();
|
|
}
|
|
|
|
|
|
function getPermissionBySearch($search) {
|
|
$this->db->order_by('id', 'desc');
|
|
$this->db->like('id', $search);
|
|
$this->db->or_like('name', $search);
|
|
$this->db->or_like('url', $search);
|
|
$query = $this->db->get('permissions');
|
|
return $query->result();
|
|
}
|
|
|
|
function getPermissionByLimit($limit, $start) {
|
|
$this->db->order_by('id', 'desc');
|
|
$this->db->limit($limit, $start);
|
|
$query = $this->db->get('permissions');
|
|
return $query->result();
|
|
}
|
|
|
|
function getPermissionByLimitBySearch($limit, $start, $search) {
|
|
|
|
$this->db->like('id', $search);
|
|
|
|
$this->db->order_by('id', 'desc');
|
|
|
|
$this->db->or_like('name', $search);
|
|
$this->db->or_like('url', $search);
|
|
|
|
$this->db->limit($limit, $start);
|
|
$query = $this->db->get('permissions');
|
|
return $query->result();
|
|
}
|
|
|
|
function getPermissionById($id) {
|
|
$this->db->where('id', $id);
|
|
$query = $this->db->get('permissions');
|
|
return $query->row();
|
|
}
|
|
|
|
// function getMenuByIonUserId($id) {
|
|
// $this->db->where('ion_user_id', $id);
|
|
// $query = $this->db->get('doctor');
|
|
// return $query->row();
|
|
// }
|
|
|
|
function updatePermission($id, $data) {
|
|
$this->db->where('id', $id);
|
|
$this->db->update('permissions', $data);
|
|
}
|
|
|
|
function delete($id) {
|
|
$this->db->where('id', $id);
|
|
$this->db->delete('permissions');
|
|
}
|
|
|
|
// function updateIonUser($username, $email, $password, $ion_user_id) {
|
|
// $uptade_ion_user = array(
|
|
// 'username' => $username,
|
|
// 'email' => $email,
|
|
// 'password' => $password
|
|
// );
|
|
// $this->db->where('id', $ion_user_id);
|
|
// $this->db->update('users', $uptade_ion_user);
|
|
// }
|
|
|
|
// function getDoctorInfo($searchTerm) {
|
|
// if (!empty($searchTerm)) {
|
|
// $this->db->select('*');
|
|
// $this->db->where("name like '%" . $searchTerm . "%' ");
|
|
// $this->db->or_where("id like '%" . $searchTerm . "%' ");
|
|
// $fetched_records = $this->db->get('doctor');
|
|
// $users = $fetched_records->result_array();
|
|
// } else {
|
|
// $this->db->select('*');
|
|
// // $this->db->where("name like '%".$searchTerm."%' ");
|
|
// // $this->db->or_where("id like '%".$searchTerm."%' ");
|
|
// $this->db->limit(10);
|
|
// $fetched_records = $this->db->get('doctor');
|
|
// $users = $fetched_records->result_array();
|
|
// }
|
|
// // Initialize Array with fetched data
|
|
// $data = array();
|
|
// foreach ($users as $user) {
|
|
// $data[] = array("id" => $user['id'], "text" => $user['name'] . ' ('.lang('id').': ' . $user['id'].')');
|
|
// }
|
|
// return $data;
|
|
// }
|
|
|
|
// function getDoctorWithAddNewOption($searchTerm) {
|
|
// if (!empty($searchTerm)) {
|
|
// $this->db->select('*');
|
|
// $this->db->where("name like '%" . $searchTerm . "%' ");
|
|
// $this->db->or_where("id like '%" . $searchTerm . "%' ");
|
|
// $fetched_records = $this->db->get('doctor');
|
|
// $users = $fetched_records->result_array();
|
|
// } else {
|
|
// $this->db->select('*');
|
|
// // $this->db->where("name like '%".$searchTerm."%' ");
|
|
// // $this->db->or_where("id like '%".$searchTerm."%' ");
|
|
// $this->db->limit(10);
|
|
// $fetched_records = $this->db->get('doctor');
|
|
// $users = $fetched_records->result_array();
|
|
// }
|
|
// // Initialize Array with fetched data
|
|
// $data = array();
|
|
// $data[] = array("id" => 'add_new', "text" => lang('add_new'));
|
|
// foreach ($users as $user) {
|
|
// $data[] = array("id" => $user['id'], "text" => $user['name'] . ' ('.lang('id').': ' . $user['id'].')');
|
|
// }
|
|
// return $data;
|
|
// }
|
|
|
|
}
|