GRAYBYTE WORDPRESS FILE MANAGER8764

Server IP : 198.54.121.189 / Your IP : 216.73.216.112
System : Linux premium69.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /home/giriqfky/public_html/Barga/application/modules/categories/models/
Upload Files :
Current_dir [ Writeable ] Document_root [ Writeable ]

Command :


Current File : /home/giriqfky/public_html/Barga/application/modules/categories/models//Categories_model.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Categories_model extends CI_Model
{
	var $table_gen_categories = TABLE_GENERAL_CATEGORIES;
	var $table_modules = TABLE_MODULES;
	
	public function __construct()
    {
        parent::__construct();
    }
	
	public function categorySave($data_array, $id = 0)
	{
		if($id == 0) {
			$this->db->insert($this->table_gen_categories, $data_array);
			$last_id = $this->db->insert_id();
		} else {
			$this->db->where('general_category_id', $id);
			$this->db->update($this->table_gen_categories, $data_array);
			$last_id = $id;
		}
		return $last_id;
	}
	
	public function getCategoryList($params = array())
	{
        $this->db->select('*');
        $this->db->from($this->table_gen_categories);
       
		if(!empty($params['search']['module_id'])){
            $this->db->where('module_id',$params['search']['module_id']);
        }
		
		if(!empty($params['search']['general_category_id'])){
            $this->db->where('general_category_id',$params['search']['general_category_id']);
        }
		
		$this->db->where('general_category_id > ', 0); 
		$this->db->order_by('general_category_id','DESC');
		
        //set start and limit
        if(array_key_exists("start",$params) && array_key_exists("limit",$params)) {
            $this->db->limit($params['limit'],$params['start']);
        } elseif(!array_key_exists("start",$params) && array_key_exists("limit",$params)) {
            $this->db->limit($params['limit']);
        }
        return $this->db->get()->result();
    }
	
	public function getCategoryDataById($general_category_id)
	{
		$this->db->select('*');	
		$this->db->where('general_category_id', $general_category_id);
		$this->db->limit(1);
		return $this->db->get($this->table_gen_categories)->row();
	}
	
	public function getModulesById($parent_id)
	{
		$this->db->select('module_id,module_parent_id,module_code,module_name,');
		$this->db->where(array('module_parent_id' => $parent_id, 'is_visible' => 1));
		$this->db->where_not_in('module_id',array(1,6,11,28,30,32,19));
		$this->db->order_by('module_order', 'ASC');
		return $this->db->get($this->table_modules)->result();
	}
	
	public function getCategoryNameById($general_category_id)
	{
		$this->db->select('general_category_name');
		$this->db->where('general_category_id', $general_category_id);	
		$this->db->limit(1);
		$category_data = $this->db->get($this->table_gen_categories)->row();
		return $category_data->general_category_name;	
	}
	
	/*** Recursive Dropdown Start ***/
	public function getCategoryParentDropDown($selected_id, $self_id, $required, $field_name)
	{
		if(empty($selected_id)) $selected_id = array();	
		if($required == true) $required = '<span class="required">*</span>';
		$dropdown = "";
		$dropdown .= '<select name="'.$field_name.'" id="'.$field_name.'" class="form-control">';
		$dropdown .= '<option value="">All Categories</option>';
		if($selected_id == 0 && $selected_id !='') {
			$dropdown .= '<option value="0" selected="selected">Parent</option>';
		} else {
			$dropdown .= '<option value="0">Parent</option>';
		}
				
		$this->db->select('*');
		$this->db->where('is_visible', 1);
		$this->db->where('parent_id', 0);
		if($self_id != '') {
			$this->db->where('general_category_id !=', $self_id);
		}
		$this->db->order_by('general_category_name', 'ASC');
		$parent_data = $this->db->get($this->table_gen_categories)->result();
		foreach($parent_data as $key => $p_data){
			if($p_data->general_category_id == $selected_id) {
				$dropdown .= '<option value="'.$p_data->general_category_id.'" selected> &nbsp; &nbsp;'.$p_data->general_category_name.'</option>';
			} else {
				$dropdown .= '<option value="'.$p_data->general_category_id.'"> &nbsp; &nbsp;'.$p_data->general_category_name.'</option>';	
			}
			$category_parent_id = $p_data->general_category_id;
			$dropdown .= $this->categoryRecurssive($category_parent_id,$selected_id,$self_id);
		}
		
		$dropdown .= '</select>';
		return $dropdown;
	}
	
	public function categoryRecurssive($category_parent_id, $selected_id, $self_id)
	{
		if(empty($selected_id)) $selected_id = array();	
	   	$dropdown = "";
		$this->db->select('*');
		$this->db->where('is_visible', 1);
		$this->db->where('parent_id', $category_parent_id);
		if($self_id != '') {
			$this->db->where('general_category_id !=', $self_id);
		}
		$this->db->order_by('general_category_name', 'ASC');
		$child_data = $this->db->get($this->table_gen_categories)->result();
		
		foreach($child_data as $key => $c_data){
			$spaces = $this->categorySpacePrint($c_data->general_category_id);
			if($c_data->general_category_id == $selected_id) {
				$dropdown .= '<option value="'.$c_data->general_category_id.'" selected>'.$spaces.$c_data->general_category_name.'</option>';
			} else {
				$dropdown .= '<option value="'.$c_data->general_category_id.'">'.$spaces.$c_data->general_category_name.'</option>';	
			}
			$category_parent_id = $c_data->general_category_id;
			if($category_parent_id != ''){
				$dropdown .= $this->categoryRecurssive($category_parent_id,$selected_id,$self_id);
			}
		}
		
		return $dropdown;
	}
	
	public function categorySpacePrint($general_category_id)
	{
		$print_space = "";
		do {
			$this->db->select('*');
			$this->db->where('is_visible', 1);
			$this->db->where('general_category_id', $general_category_id);
			$this->db->limit(1);
			$d_data = $this->db->get($this->table_gen_categories)->row();
			if($d_data->parent_id != 0) {
				$print_space .="&nbsp; &nbsp; &nbsp; &nbsp; ";
				$general_category_id = $d_data->parent_id;
				$continue = 1;
			} else {
				$continue = 0;
			}
			
		} while($continue == 1);
		
		return $print_space;
	}
	/*** Recursive Dropdown End ***/
}

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
July 27 2024 00:19:25
giriqfky / giriqfky
0755
Categories_model.php
5.755 KB
July 27 2024 00:19:25
giriqfky / giriqfky
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF