%PDF-1.4
Directory : /var/www/vhosts/lautnusantara.com/httpdocs/mis/app/Models/ |
<?php namespace App\Models; use CodeIgniter\Model; class User_Model extends Model { public function get_users() { $builder = $this->db->table('ssn_users'); $builder->select('ssn_users.*,ssn_user_groups.name as name_group'); $builder->join('ssn_user_groups','ssn_users.usergroup_id=ssn_user_groups.id','left'); $builder->where('ssn_users.trash','0'); $builder->orderBy('first_name', 'ASC'); return $builder->get(); } public function get_detail_users($id) { $builder = $this->db->table('ssn_users'); $builder->select('*'); $builder->where('ssn_users.id',$id); $builder->where('ssn_users.trash','0'); return $builder->get(); } public function save_users($data) { $query = $this->db->table('ssn_users')->insert($data); return $query; } public function update_users($data,$id) { $query = $this->db->table('ssn_users')->update($data, array('id'=> $id)); return $query; } public function delete_users($data,$id) { $query = $this->db->table('ssn_users')->update($data, array('id'=> $id)); return $query; } public function get_user_menu_map($id) { $builder = $this->db->table('ssn_menu'); // ,ssn_user_groups.id as group_id $builder->select('ssn_user_menu_map.id,ssn_menu.title,ssn_menu.parent_id,ssn_menu.have_child ,ssn_menu.id as id_menu ,IF(ISNULL(ssn_user_menu_map.id),0,ssn_user_menu_map.active) AS active'); $builder->join('ssn_user_menu_map','ssn_user_menu_map.menu_id=ssn_menu.id and ssn_user_menu_map.user_id='.$id,'left'); // $builder->join('ssn_user_groups','ssn_user_menu_map.user_id=ssn_user_groups.id and ssn_user_menu_map.user_id='.$id,'left'); $builder->orderBy('ssn_menu.sortir', 'ASC'); $builder->where('ssn_menu.typemenu_id','2'); $builder->where('ssn_menu.active','1'); $builder->where('ssn_menu.trash','0'); return $builder->get(); } public function cek_user_menu_map($id,$menu_id) { $builder = $this->db->table('ssn_user_menu_map'); $builder->where('user_id',$id); $builder->where('menu_id',$menu_id); $builder->where('ubis_id','1'); return $builder->countAllResults(); } public function update_user_level($data,$id) { $query = $this->db->table('ssn_user_menu_map')->update($data, array('id'=> $id)); return $query; } public function delete_user_level($data,$id) { $query = $this->db->table('ssn_user_menu_map')->update($data, array('id'=> $id)); return $query; } public function save_user_menu_level($data) { $query = $this->db->table('ssn_user_menu_map')->insert($data); return $query; } } ?>