| @@ 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 | ||
| @@ 1250-1303 (lines=54) @@ | ||
| 1247 | * @throws InvalidDataTypeException |
|
| 1248 | * @throws InvalidInterfaceException |
|
| 1249 | */ |
|
| 1250 | public function get_default_tickets($per_page = 10, $count = false, $trashed = false) |
|
| 1251 | { |
|
| 1252 | $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby']; |
|
| 1253 | $order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order']; |
|
| 1254 | switch ($orderby) { |
|
| 1255 | case 'TKT_name': |
|
| 1256 | $orderby = array('TKT_name' => $order); |
|
| 1257 | break; |
|
| 1258 | case 'TKT_price': |
|
| 1259 | $orderby = array('TKT_price' => $order); |
|
| 1260 | break; |
|
| 1261 | case 'TKT_uses': |
|
| 1262 | $orderby = array('TKT_uses' => $order); |
|
| 1263 | break; |
|
| 1264 | case 'TKT_min': |
|
| 1265 | $orderby = array('TKT_min' => $order); |
|
| 1266 | break; |
|
| 1267 | case 'TKT_max': |
|
| 1268 | $orderby = array('TKT_max' => $order); |
|
| 1269 | break; |
|
| 1270 | case 'TKT_qty': |
|
| 1271 | $orderby = array('TKT_qty' => $order); |
|
| 1272 | break; |
|
| 1273 | } |
|
| 1274 | $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
| 1275 | ? $this->_req_data['paged'] |
|
| 1276 | : 1; |
|
| 1277 | $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
| 1278 | ? $this->_req_data['perpage'] |
|
| 1279 | : $per_page; |
|
| 1280 | $_where = array( |
|
| 1281 | 'TKT_is_default' => 1, |
|
| 1282 | 'TKT_deleted' => $trashed, |
|
| 1283 | ); |
|
| 1284 | $offset = ($current_page - 1) * $per_page; |
|
| 1285 | $limit = array($offset, $per_page); |
|
| 1286 | if (isset($this->_req_data['s'])) { |
|
| 1287 | $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 1288 | $_where['OR'] = array( |
|
| 1289 | 'TKT_name' => array('LIKE', $sstr), |
|
| 1290 | 'TKT_description' => array('LIKE', $sstr), |
|
| 1291 | ); |
|
| 1292 | } |
|
| 1293 | $query_params = array( |
|
| 1294 | $_where, |
|
| 1295 | 'order_by' => $orderby, |
|
| 1296 | 'limit' => $limit, |
|
| 1297 | 'group_by' => 'TKT_ID', |
|
| 1298 | ); |
|
| 1299 | if ($count) { |
|
| 1300 | return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where)); |
|
| 1301 | } |
|
| 1302 | return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params); |
|
| 1303 | } |
|
| 1304 | ||
| 1305 | ||
| 1306 | /** |
|