db->select(); $this->db->from('asset'); $this->db->where('business_id', $business_id); $this->db->where('is_active', 1); $query = $this->db->get(); $query = $query->num_rows(); return $query; } public function get_users_count($business_id) { $this->db->select(); $this->db->from('users'); $this->db->where('business_id', $business_id); $this->db->where('role !=', 'admin'); $this->db->where('is_active', 1); $query = $this->db->get(); $query = $query->num_rows(); return $query; } public function get_amc_count($business_id) { $this->db->select(); $this->db->from('amc'); $this->db->where('business_id', $business_id); $this->db->where('is_active', 1); $this->db->where('type', 3); $this->db->where('valid_to >', date("Y-m-d")); $this->db->where('valid_to <=', date('Y-m-d', strtotime('+30 day', strtotime(date("Y-m-d"))))); $this->db->group_by('asset_id'); $this->db->order_by('id','DESC'); //$this->db->limit(1); $query = $this->db->get(); $query = $query->num_rows(); return $query; } public function get_expired_amc_count($business_id) { $this->db->select(); $this->db->from('amc'); $this->db->where('business_id', $business_id); $this->db->where('is_active', 1); $this->db->where('type', 3); $this->db->where('valid_to <', date("Y-m-d")); $this->db->group_by('asset_id'); $this->db->order_by('id','DESC'); //$this->db->limit(1); $query = $this->db->get(); $query = $query->num_rows(); return $query; } public function get_insurance_count($business_id) { $this->db->select(); $this->db->from('amc'); $this->db->where('business_id', $business_id); $this->db->where('is_active', 1); $this->db->where('type', 4); $this->db->where('valid_to >', date("Y-m-d")); $this->db->where('valid_to <=', date('Y-m-d', strtotime('+30 day', strtotime(date("Y-m-d"))))); $this->db->group_by('asset_id'); $this->db->order_by('id','DESC'); //$this->db->limit(1); $query = $this->db->get(); $query = $query->num_rows(); return $query; } public function get_expired_insurance_count($business_id) { $this->db->select(); $this->db->from('amc'); $this->db->where('business_id', $business_id); $this->db->where('is_active', 1); $this->db->where('type', 4); $this->db->where('valid_to <', date("Y-m-d")); $this->db->group_by('asset_id'); $this->db->order_by('id','DESC'); //$this->db->limit(1); $query = $this->db->get(); $query = $query->num_rows(); return $query; } public function get_amc($business_id) { $this->db->select('a.* , asset.name as asset_name' ); $this->db->from('amc a'); $this->db->join('asset', 'asset.id=a.asset_id', 'left'); $this->db->where('a.business_id', $business_id); $this->db->where('a.is_active', 1); $this->db->where('a.type', 3); $this->db->group_by('asset_id'); $this->db->order_by('id','DESC'); $query = $this->db->get(); $query = $query->result(); return $query; } public function get_insurence($business_id) { $this->db->select('a.* , asset.name as asset_name' ); $this->db->from('amc a'); $this->db->join('asset', 'asset.id=a.asset_id', 'left'); $this->db->where('a.business_id', $business_id); $this->db->where('a.is_active', 1); $this->db->where('a.type', 4); $this->db->group_by('asset_id'); $this->db->order_by('id','DESC'); $query = $this->db->get(); $query = $query->result(); return $query; } public function get_business_count() { $this->db->select(); $this->db->from('business'); $this->db->where('is_active', 1); $query = $this->db->get(); $query = $query->num_rows(); return $query; } public function get_user_count_for_sadmin() { $this->db->select(); $this->db->from('users'); $this->db->where('is_active', 1); $this->db->where('role !=', 'sadmin'); $query = $this->db->get(); $query = $query->num_rows(); return $query; } }