bbone/application/modules/Business/models/Business_model.php

103 lines
3.1 KiB
PHP

<?php
class Business_model extends MY_Model {
public function get_business_details()
{
$this->db->select('B.* , state.name as state_name ');
$this->db->from('business B');
$this->db->join('state', 'state.id = B.state', 'left');
$this->db->order_by('B.id','ASC');
// $this->db->where('B.is_active', 1);
$query = $this->db->get();
$query = $query->result();
return $query;
}
public function get_business_by_md5_id($id)
{
$this->db->select('B.* , state.name as state_name ');
$this->db->from('business B');
$this->db->join('state', 'state.id = B.state', 'left');
$this->db->where('B.is_active', 1);
$this->db->where('md5(B.uid)', $id);
$query = $this->db->get();
$query = $query->row();
return $query;
}
public function delete_by_md5_id($id,$data)
{
$this->db->where('id', $id);
$this->db->update('business', $data);
}
public function get_business_modules($business_id)
{
$this->db->select('permit_modules.*,modules.modules');
$this->db->from('permit_modules');
$this->db->join('modules', 'permit_modules.module_id = modules.id and modules.is_active = 1', 'left');
$this->db->where('md5(uid)', $business_id);
$this->db->where('permit_modules.is_active', 1);
$query = $this->db->get();
return $query->result();
}
public function get_business_module_is_active($business_id)
{
$this->db->select('module_id');
$this->db->from('permit_modules');
$this->db->where('uid', $business_id);
$this->db->where('is_active', 1);
$query = $this->db->get();
return $query->result();
}
public function get_group_module_data_by_id($id , $module_id = null)
{
$this->db->select('module_id');
$this->db->from('permit_modules');
$this->db->where('uid', $id);
if($module_id != null){ $this->db->where('module_id', $module_id); }
$this->db->where('is_active', 1);
$query = $this->db->get();
return $query->result();
}
public function delete_group_module_data_by_id($id , $module_id )
{
$this->db->where('uid', $id);
$this->db->where('module_id', $module_id);
$this->db->delete('permit_modules');
return;
}
public function diable_module_in_group_permisssion($module_id, $data)
{
$this->db->where('module_id', $module_id);
$this->db->update('group_permisssion', $data);
return;
}
public function Enable_module_in_group_permisssion($module_id, $mdata)
{
$this->db->where('module_id', $module_id);
$this->db->update('group_permisssion', $mdata);
return;
}
public function get_group_id_by_module_id($module_id)
{
$this->db->select('group_membership.group_id');
$this->db->from('group_membership');
$this->db->join('group_permisssion', 'group_permisssion.group_id = group_membership.group_id');
$this->db->where('module_id', $module_id);
$query = $this->db->get();
return $query->result();
}
}