@@ 1139-1202 (lines=64) @@ | ||
1136 | * @param bool $trashed |
|
1137 | * @return \EE_Soft_Delete_Base_Class[]|int |
|
1138 | */ |
|
1139 | public function get_default_tickets($per_page = 10, $count = false, $trashed = false) |
|
1140 | { |
|
1141 | $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby']; |
|
1142 | $order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order']; |
|
1143 | switch ($orderby) { |
|
1144 | case 'TKT_name': |
|
1145 | $orderby = array('TKT_name' => $order); |
|
1146 | break; |
|
1147 | case 'TKT_price': |
|
1148 | $orderby = array('TKT_price' => $order); |
|
1149 | break; |
|
1150 | case 'TKT_uses': |
|
1151 | $orderby = array('TKT_uses' => $order); |
|
1152 | break; |
|
1153 | case 'TKT_min': |
|
1154 | $orderby = array('TKT_min' => $order); |
|
1155 | break; |
|
1156 | case 'TKT_max': |
|
1157 | $orderby = array('TKT_max' => $order); |
|
1158 | break; |
|
1159 | case 'TKT_qty': |
|
1160 | $orderby = array('TKT_qty' => $order); |
|
1161 | break; |
|
1162 | } |
|
1163 | $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
1164 | ? $this->_req_data['paged'] |
|
1165 | : 1; |
|
1166 | $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
1167 | ? $this->_req_data['perpage'] |
|
1168 | : $per_page; |
|
1169 | $_where = array( |
|
1170 | 'TKT_is_default' => 1, |
|
1171 | 'TKT_deleted' => $trashed, |
|
1172 | ); |
|
1173 | $offset = ($current_page - 1) * $per_page; |
|
1174 | $limit = array($offset, $per_page); |
|
1175 | if (isset($this->_req_data['s'])) { |
|
1176 | $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1177 | $_where['OR'] = array( |
|
1178 | 'TKT_name' => array('LIKE', $sstr), |
|
1179 | 'TKT_description' => array('LIKE', $sstr), |
|
1180 | ); |
|
1181 | } |
|
1182 | $query_params = array( |
|
1183 | $_where, |
|
1184 | 'order_by' => $orderby, |
|
1185 | 'limit' => $limit, |
|
1186 | 'group_by' => 'TKT_ID', |
|
1187 | ); |
|
1188 | if ($count) { |
|
1189 | return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where)); |
|
1190 | } else { |
|
1191 | return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params); |
|
1192 | } |
|
1193 | } |
|
1194 | ||
1195 | ||
1196 | /** |
|
1197 | * @param bool $trash |
|
1198 | * @throws EE_Error |
|
1199 | */ |
|
1200 | protected function _trash_or_restore_ticket($trash = false) |
|
1201 | { |
|
1202 | $success = 1; |
|
1203 | $TKT = EEM_Ticket::instance(); |
|
1204 | // checkboxes? |
|
1205 | if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
@@ 173-236 (lines=64) @@ | ||
170 | } |
|
171 | ||
172 | ||
173 | public function get_default_tickets($per_page = 10, $count = false, $trashed = false) |
|
174 | { |
|
175 | ||
176 | $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby']; |
|
177 | $order = empty($this->_req_data['order']) ? 'ASC' : $order; |
|
178 | ||
179 | switch ($orderby) { |
|
180 | case 'TKT_name': |
|
181 | $orderby = array('TKT_name' => $order); |
|
182 | break; |
|
183 | ||
184 | case 'TKT_price': |
|
185 | $orderby = array('TKT_price' => $order); |
|
186 | break; |
|
187 | ||
188 | case 'TKT_uses': |
|
189 | $orderby = array('TKT_uses' => $order); |
|
190 | break; |
|
191 | ||
192 | case 'TKT_min': |
|
193 | $orderby = array('TKT_min' => $order); |
|
194 | break; |
|
195 | ||
196 | case 'TKT_max': |
|
197 | $orderby = array('TKT_max' => $order); |
|
198 | break; |
|
199 | ||
200 | case 'TKT_qty': |
|
201 | $orderby = array('TKT_qty' => $order); |
|
202 | break; |
|
203 | } |
|
204 | ||
205 | $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
206 | ? $this->_req_data['paged'] : 1; |
|
207 | $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
208 | ? $this->_req_data['perpage'] : $per_page; |
|
209 | ||
210 | $_where = array( |
|
211 | 'TKT_is_default' => 1, |
|
212 | 'TKT_deleted' => $trashed, |
|
213 | ); |
|
214 | ||
215 | $offset = ($current_page - 1) * $per_page; |
|
216 | $limit = array($offset, $per_page); |
|
217 | ||
218 | if (isset($this->_req_data['s'])) { |
|
219 | $sstr = '%' . $this->_req_data['s'] . '%'; |
|
220 | $_where['OR'] = array( |
|
221 | 'TKT_name' => array('LIKE', $sstr), |
|
222 | 'TKT_description' => array('LIKE', $sstr), |
|
223 | ); |
|
224 | } |
|
225 | ||
226 | $query_params = array( |
|
227 | $_where, |
|
228 | 'order_by' => $orderby, |
|
229 | 'limit' => $limit, |
|
230 | 'group_by' => 'TKT_ID', |
|
231 | ); |
|
232 | ||
233 | if ($count) { |
|
234 | return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where)); |
|
235 | } else { |
|
236 | return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params); |
|
237 | } |
|
238 | } |
|
239 |