|
8 | 8 | $fetch_months = 6; |
9 | 9 | } |
10 | 10 |
|
11 | | -$filters = array(); |
12 | | -$expands = array(); |
13 | | -$sorting = array(); |
14 | | - |
15 | | -$expands['Subjects'] = ''; |
16 | | -$expands['Categories'] = ''; |
17 | | -$expands['PriceNames'] = ''; |
18 | | -$expands['Events'] = |
19 | | - '$filter=' . |
20 | | - 'HasPublicPriceName' . |
21 | | - ' and StatusId eq 1' . |
22 | | - ' and CustomerId eq null' . |
23 | | - ' and CompanySpecific eq false' . |
24 | | - ' and LastApplicationDate ge ' . date( 'c' ) . |
25 | | - ' and StartDate le ' . date( 'c', strtotime( 'now 23:59:59 +' . $fetch_months . ' months' ) ) . |
26 | | - ' and EndDate ge ' . date( 'c', strtotime( 'now' ) ) . |
27 | | - ';' . |
28 | | - '$expand=PriceNames' . |
29 | | - ';' . |
30 | | - '$orderby=StartDate asc' . |
31 | | - ';'; |
32 | | - |
33 | | -$expands['CustomFields'] = '$filter=ShowOnWeb'; |
34 | | - |
35 | | -$filters[] = 'ShowOnWeb'; |
36 | | - |
37 | 11 | $show_events_with_events_only = $attributes['onlyevents']; |
38 | 12 | $show_events_without_events_only = $attributes['onlyempty']; |
39 | 13 |
|
| 14 | +if ( ! empty( $_REQUEST['eduadmin-category'] ) ) { |
| 15 | + $category_id = intval( $_REQUEST['eduadmin-category'] ); |
| 16 | +} |
| 17 | + |
40 | 18 | if ( $category_id > 0 ) { |
41 | | - $filters[] = 'CategoryId eq ' . $category_id; |
42 | 19 | $attributes['category'] = $category_id; |
43 | 20 | } |
44 | 21 |
|
45 | | -if ( ! empty( $_REQUEST['eduadmin-category'] ) ) { |
46 | | - $filters[] = 'CategoryId eq ' . intval( sanitize_text_field( $_REQUEST['eduadmin-category'] ) ); |
47 | | - $attributes['category'] = intval( $_REQUEST['eduadmin-category'] ); |
48 | | -} |
| 22 | +$city = null; |
49 | 23 |
|
50 | 24 | if ( ! empty( $_REQUEST['eduadmin-city'] ) ) { |
51 | | - $filters[] = 'Events/any(e:e/LocationId eq ' . intval( $_REQUEST['eduadmin-city'] ) . ')'; |
52 | | - $attributes['city'] = intval( $_REQUEST['eduadmin-city'] ); |
| 25 | + $city = intval( $_REQUEST['eduadmin-city'] ); |
| 26 | + $attributes['city'] = $city; |
53 | 27 | } |
54 | 28 |
|
55 | | -if ( isset( $attributes['subject'] ) && ! empty( $attributes['subject'] ) ) { |
56 | | - $filters[] = 'Subjects/any(s:s/SubjectName eq \'' . sanitize_text_field( $attributes['subject'] ) . '\')'; |
57 | | -} |
| 29 | +$subject_id = null; |
58 | 30 |
|
59 | 31 | if ( ! empty( $_REQUEST['eduadmin-subject'] ) ) { |
60 | | - $filters[] = 'Subjects/any(s:s/SubjectId eq ' . intval( $_REQUEST['eduadmin-subject'] ) . ')'; |
61 | | - $attributes['subjectid'] = intval( $_REQUEST['eduadmin-subject'] ); |
| 32 | + $subject_id = intval( $_REQUEST['eduadmin-subject'] ); |
| 33 | + $attributes['subjectid'] = $subject_id; |
62 | 34 | } |
63 | 35 |
|
64 | | -if ( ! empty( $_REQUEST['eduadmin-level'] ) ) { |
65 | | - $filters[] = 'CourseLevelId eq ' . intval( sanitize_text_field( $_REQUEST['eduadmin-level'] ) ); |
66 | | -} |
67 | | - |
68 | | -$sort_order = get_option( 'eduadmin-listSortOrder', 'SortIndex' ); |
69 | | - |
70 | | -if ( null !== $custom_order_by ) { |
71 | | - $orderby = explode( ' ', $custom_order_by ); |
72 | | - $sortorder = explode( ' ', $custom_order_by_order ); |
73 | | - foreach ( $orderby as $od => $v ) { |
74 | | - if ( isset( $sortorder[ $od ] ) ) { |
75 | | - $or = $sortorder[ $od ]; |
76 | | - } else { |
77 | | - $or = 'asc'; |
78 | | - } |
| 36 | +$course_level = null; |
79 | 37 |
|
80 | | - if ( edu_validate_column( 'course', $v ) !== false ) { |
81 | | - $sorting[] = $v . ' ' . strtolower( $or ); |
82 | | - } |
83 | | - } |
84 | | -} |
85 | | -if ( edu_validate_column( 'course', $sort_order ) !== false ) { |
86 | | - $sorting[] = $sort_order . ' asc'; |
| 38 | +if ( ! empty( $_REQUEST['eduadmin-level'] ) ) { |
| 39 | + $course_level = intval( sanitize_text_field( $_REQUEST['eduadmin-level'] ) ); |
87 | 40 | } |
88 | 41 |
|
89 | | -$expand_arr = array(); |
90 | | -foreach ( $expands as $key => $value ) { |
91 | | - if ( empty( $value ) ) { |
92 | | - $expand_arr[] = $key; |
93 | | - } else { |
94 | | - $expand_arr[] = $key . '(' . $value . ')'; |
95 | | - } |
96 | | -} |
| 42 | +$edo = EDUAPIHelper()->GetCourseList( $attributes, $category_id, $city, $subject_id, $course_level, $custom_order_by, $custom_order_by_order ); |
97 | 43 |
|
98 | | -$edo = EDUAPI()->OData->CourseTemplates->Search( |
99 | | - null, |
100 | | - join( ' and ', $filters ), |
101 | | - join( ',', $expand_arr ), |
102 | | - join( ',', $sorting ) |
103 | | -); |
104 | 44 | $courses = $edo['value']; |
105 | 45 |
|
106 | 46 | if ( ! empty( $_REQUEST['searchCourses'] ) ) { |
|
156 | 96 | $show_next_event_date = get_option( 'eduadmin-showNextEventDate', false ); |
157 | 97 | $show_course_locations = get_option( 'eduadmin-showCourseLocations', false ); |
158 | 98 | $show_event_price = get_option( 'eduadmin-showEventPrice', false ); |
159 | | -$org = get_transient( 'eduadmin-organization' . '__' . EDU()->version ); |
160 | | -if ( ! $org ) { |
161 | | - $org = EDUAPI()->REST->Organisation->GetOrganisation(); |
162 | | - set_transient( 'eduadmin-organization' . '__' . EDU()->version, $org, DAY_IN_SECONDS ); |
163 | | -} |
| 99 | + |
| 100 | +$org = EDUAPIHelper()->GetOrganization(); |
| 101 | + |
164 | 102 | $inc_vat = $org['PriceIncVat']; |
165 | 103 |
|
166 | 104 | $show_course_days = get_option( 'eduadmin-showCourseDays', true ); |
|
0 commit comments