Code Duplication    Length = 64-64 lines in 2 locations

caffeinated/admin/extend/events/Extend_Events_Admin_Page.core.php 1 location

@@ 1008-1071 (lines=64) @@
1005
1006
1007
1008
	public function get_default_tickets( $per_page = 10, $count = FALSE, $trashed = FALSE ) {
1009
1010
		$orderby= empty( $this->_req_data['orderby'] ) ? 'TKT_name' : $this->_req_data['orderby'];
1011
		$order = empty( $this->_req_data['order'] ) ? 'ASC' : $this->_req_data['order'];
1012
1013
		switch ( $orderby ) {
1014
			case 'TKT_name' :
1015
				$orderby = array( 'TKT_name' => $order );
1016
				break;
1017
1018
			case 'TKT_price' :
1019
				$orderby = array( 'TKT_price' => $order );
1020
				break;
1021
1022
			case 'TKT_uses' :
1023
				$orderby = array( 'TKT_uses' => $order );
1024
				break;
1025
1026
			case 'TKT_min' :
1027
				$orderby = array( 'TKT_min' => $order );
1028
				break;
1029
1030
			case 'TKT_max' :
1031
				$orderby = array( 'TKT_max' => $order );
1032
				break;
1033
1034
			case 'TKT_qty' :
1035
				$orderby = array( 'TKT_qty' => $order );
1036
				break;
1037
		}
1038
1039
		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
1040
		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page;
1041
1042
		$_where = array(
1043
			'TKT_is_default' => 1,
1044
			'TKT_deleted' => $trashed
1045
			);
1046
1047
		$offset = ($current_page-1)*$per_page;
1048
		$limit = array( $offset, $per_page );
1049
1050
		if ( isset( $this->_req_data['s'] ) ) {
1051
			$sstr = '%' . $this->_req_data['s'] . '%';
1052
			$_where['OR'] = array(
1053
				'TKT_name' => array('LIKE',$sstr ),
1054
				'TKT_description' => array('LIKE',$sstr )
1055
				);
1056
		}
1057
1058
		$query_params = array(
1059
			$_where,
1060
			'order_by'=>$orderby,
1061
			'limit'=>$limit,
1062
			'group_by'=>'TKT_ID'
1063
			);
1064
1065
		if($count){
1066
			return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where));
1067
		}else{
1068
			return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params);
1069
		}
1070
1071
	}
1072
1073
1074

caffeinated/admin/new/tickets/Tickets_Admin_Page.core.php 1 location

@@ 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