| @@ -81,8 +81,34 @@ | ||
| 81 | 81 | |
| 82 | 82 | return array(); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | + public function get_pagination_simple($limit, $offset, $where = array(), $order_by = NULL) | |
| 86 | + { | |
| 87 | + $this->load->model('listing_m'); | |
| 88 | + | |
| 89 | + $this->db->from($this->_table_name); | |
| 90 | + | |
| 91 | + $this->db->where($where); | |
| 92 | + $this->db->limit($limit); | |
| 93 | + $this->db->offset($offset); | |
| 94 | + | |
| 95 | + $this->db->group_by('idcategory'); | |
| 96 | + | |
| 97 | + if(!empty($order_by)){ | |
| 98 | + $this->db->order_by($order_by); | |
| 99 | + } else { | |
| 100 | + $this->db->order_by($this->_order_by); | |
| 101 | + } | |
| 102 | + | |
| 103 | + $query = $this->db->get(); | |
| 104 | + | |
| 105 | + if ($this->db->num_rows() > 0) | |
| 106 | + return $this->db->results(); | |
| 107 | + | |
| 108 | + return array(); | |
| 109 | + } | |
| 110 | + | |
| 85 | 111 | public function check_deletable($id) |
| 86 | 112 | { |
| 87 | 113 | return true; |
| 88 | 114 | } |
| @@ -100,8 +126,9 @@ | ||
| 100 | 126 | |
| 101 | 127 | if($this->_timestamps === TRUE && !isset($data['date'])) |
| 102 | 128 | $data['date'] = current_time( 'mysql' ); |
| 103 | 129 | |
| 130 | + $data['level_0_id'] = 0; | |
| 104 | 131 | $data['level'] = 0; |
| 105 | 132 | $data['parent_path'] = ''; |
| 106 | 133 | |
| 107 | 134 | if(!empty($data['parent_id'])) |
| @@ -111,8 +138,14 @@ | ||
| 111 | 138 | if(isset($parent[0])) |
| 112 | 139 | { |
| 113 | 140 | $data['level'] = $parent[0]->level + 1; |
| 114 | 141 | $data['parent_path'] = $parent[0]->parent_path.(!empty($parent[0]->parent_path)?',':'').$parent[0]->idcategory; |
| 142 | + | |
| 143 | + if(strpos($data['parent_path'], ',') !== FALSE) { | |
| 144 | + $data['level_0_id'] = substr($data['parent_path'],0,strpos($data['parent_path'], ',')); | |
| 145 | + } else { | |
| 146 | + $data['level_0_id'] = $data['parent_path']; | |
| 147 | + } | |
| 115 | 148 | } |
| 116 | 149 | } |
| 117 | 150 | |
| 118 | 151 | if(empty($data['order_index'])) |