@@ 164-227 (lines=64) @@ | ||
161 | ||
162 | ||
163 | ||
164 | public function get_default_tickets( $per_page = 10, $count = FALSE, $trashed = FALSE ) { |
|
165 | ||
166 | $orderby= empty( $this->_req_data['orderby'] ) ? 'TKT_name' : $this->_req_data['orderby']; |
|
167 | $order = empty( $this->_req_data['order'] ) ? 'ASC' : $order; |
|
168 | ||
169 | switch ( $orderby ) { |
|
170 | case 'TKT_name' : |
|
171 | $orderby = array( 'TKT_name' => $order ); |
|
172 | break; |
|
173 | ||
174 | case 'TKT_price' : |
|
175 | $orderby = array( 'TKT_price' => $order ); |
|
176 | break; |
|
177 | ||
178 | case 'TKT_uses' : |
|
179 | $orderby = array( 'TKT_uses' => $order ); |
|
180 | break; |
|
181 | ||
182 | case 'TKT_min' : |
|
183 | $orderby = array( 'TKT_min' => $order ); |
|
184 | break; |
|
185 | ||
186 | case 'TKT_max' : |
|
187 | $orderby = array( 'TKT_max' => $order ); |
|
188 | break; |
|
189 | ||
190 | case 'TKT_qty' : |
|
191 | $orderby = array( 'TKT_qty' => $order ); |
|
192 | break; |
|
193 | } |
|
194 | ||
195 | $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
196 | $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
197 | ||
198 | $_where = array( |
|
199 | 'TKT_is_default' => 1, |
|
200 | 'TKT_deleted' => $trashed |
|
201 | ); |
|
202 | ||
203 | $offset = ($current_page-1)*$per_page; |
|
204 | $limit = array( $offset, $per_page ); |
|
205 | ||
206 | if ( isset( $this->_req_data['s'] ) ) { |
|
207 | $sstr = '%' . $this->_req_data['s'] . '%'; |
|
208 | $_where['OR'] = array( |
|
209 | 'TKT_name' => array('LIKE',$sstr ), |
|
210 | 'TKT_description' => array('LIKE',$sstr ) |
|
211 | ); |
|
212 | } |
|
213 | ||
214 | $query_params = array( |
|
215 | $_where, |
|
216 | 'order_by'=>$orderby, |
|
217 | 'limit'=>$limit, |
|
218 | 'group_by'=>'TKT_ID' |
|
219 | ); |
|
220 | ||
221 | if($count){ |
|
222 | return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where)); |
|
223 | }else{ |
|
224 | return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params); |
|
225 | } |
|
226 | ||
227 | } |
|
228 | ||
229 | ||
230 |
@@ 1024-1087 (lines=64) @@ | ||
1021 | ||
1022 | ||
1023 | ||
1024 | public function get_default_tickets( $per_page = 10, $count = FALSE, $trashed = FALSE ) { |
|
1025 | ||
1026 | $orderby= empty( $this->_req_data['orderby'] ) ? 'TKT_name' : $this->_req_data['orderby']; |
|
1027 | $order = empty( $this->_req_data['order'] ) ? 'ASC' : $this->_req_data['order']; |
|
1028 | ||
1029 | switch ( $orderby ) { |
|
1030 | case 'TKT_name' : |
|
1031 | $orderby = array( 'TKT_name' => $order ); |
|
1032 | break; |
|
1033 | ||
1034 | case 'TKT_price' : |
|
1035 | $orderby = array( 'TKT_price' => $order ); |
|
1036 | break; |
|
1037 | ||
1038 | case 'TKT_uses' : |
|
1039 | $orderby = array( 'TKT_uses' => $order ); |
|
1040 | break; |
|
1041 | ||
1042 | case 'TKT_min' : |
|
1043 | $orderby = array( 'TKT_min' => $order ); |
|
1044 | break; |
|
1045 | ||
1046 | case 'TKT_max' : |
|
1047 | $orderby = array( 'TKT_max' => $order ); |
|
1048 | break; |
|
1049 | ||
1050 | case 'TKT_qty' : |
|
1051 | $orderby = array( 'TKT_qty' => $order ); |
|
1052 | break; |
|
1053 | } |
|
1054 | ||
1055 | $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
1056 | $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
1057 | ||
1058 | $_where = array( |
|
1059 | 'TKT_is_default' => 1, |
|
1060 | 'TKT_deleted' => $trashed |
|
1061 | ); |
|
1062 | ||
1063 | $offset = ($current_page-1)*$per_page; |
|
1064 | $limit = array( $offset, $per_page ); |
|
1065 | ||
1066 | if ( isset( $this->_req_data['s'] ) ) { |
|
1067 | $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1068 | $_where['OR'] = array( |
|
1069 | 'TKT_name' => array('LIKE',$sstr ), |
|
1070 | 'TKT_description' => array('LIKE',$sstr ) |
|
1071 | ); |
|
1072 | } |
|
1073 | ||
1074 | $query_params = array( |
|
1075 | $_where, |
|
1076 | 'order_by'=>$orderby, |
|
1077 | 'limit'=>$limit, |
|
1078 | 'group_by'=>'TKT_ID' |
|
1079 | ); |
|
1080 | ||
1081 | if($count){ |
|
1082 | return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where)); |
|
1083 | }else{ |
|
1084 | return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params); |
|
1085 | } |
|
1086 | ||
1087 | } |
|
1088 | ||
1089 | ||
1090 |