@@ -48,8 +48,7 @@ function edu_listview_courselist() {
4848 }
4949
5050 if ( ! empty ( $ _POST ['city ' ] ) && is_numeric ( $ _POST ['city ' ] ) ) {
51- $ filters [] = 'Events/any(e:e/LocationId eq ' . intval ( $ _POST ['city ' ] ) . ') ' ;
52- $ event_filters [] = 'LocationId eq ' . intval ( $ _POST ['city ' ] );
51+ $ filters [] = 'Events/any(e:e/LocationId eq ' . intval ( $ _POST ['city ' ] ) . ') ' ;
5352 }
5453
5554 if ( ! empty ( $ _POST ['subject ' ] ) ) {
@@ -109,111 +108,33 @@ function edu_api_listview_eventlist() {
109108 $ fetch_months = 6 ;
110109 }
111110
112- $ ondemand = $ _POST ['ondemand ' ];
113-
114- $ filters = array ();
115- $ selects = array ();
116- $ event_filters = array ();
117- $ expands = array ();
118-
119- $ selects [] = 'CourseTemplateId ' ;
120- $ selects [] = 'CourseName ' ;
121- $ selects [] = 'InternalCourseName ' ;
122- $ selects [] = 'ImageUrl ' ;
123- $ selects [] = 'CourseDescription ' ;
124- $ selects [] = 'CourseDescriptionShort ' ;
125- $ selects [] = 'CourseGoal ' ;
126- $ selects [] = 'TargetGroup ' ;
127- $ selects [] = 'Prerequisites ' ;
128- $ selects [] = 'CourseAfter ' ;
129- $ selects [] = 'Quote ' ;
130- $ selects [] = 'Days ' ;
131- $ selects [] = 'StartTime ' ;
132- $ selects [] = 'EndTime ' ;
133- $ selects [] = 'RequireCivicRegistrationNumber ' ;
134- $ selects [] = 'ParticipantVat ' ;
135- $ selects [] = 'OnDemand ' ;
136- $ selects [] = 'OnDemandAccessDays ' ;
137-
138- $ event_filters [] = 'HasPublicPriceName ' ;
139- $ event_filters [] = 'StatusId eq 1 ' ;
140- $ event_filters [] = 'CustomerId eq null ' ;
141- $ event_filters [] = 'CompanySpecific eq false ' ;
142-
143- if ( ! $ ondemand ) {
144- $ event_filters [] = 'LastApplicationDate ge ' . date_i18n ( 'c ' );
145- $ event_filters [] = 'StartDate le ' . edu_get_timezoned_date ( 'c ' , 'now 23:59:59 + ' . $ fetch_months . ' months ' );
146- $ event_filters [] = 'EndDate ge ' . edu_get_timezoned_date ( 'c ' , 'now ' );
147- } else {
148- $ event_filters [] = 'OnDemand ' ;
149- $ event_filters [] = 'OnDemandPublished ' ;
111+ $ city = null ;
112+ $ subject_id = null ;
113+ $ course_level = null ;
150114
151- $ filters [] = 'OnDemand ' ;
152- }
153-
154- $ filters [] = 'ShowOnWeb ' ;
115+ $ ondemand = $ _POST ['ondemand ' ];
116+ $ all_courses = $ _POST ['allcourses ' ];
155117
156118 $ category_id = wp_unslash ( sanitize_text_field ( $ _POST ['category ' ] ) );
157119
158120 if ( ! empty ( $ _POST ['categorydeep ' ] ) ) {
159121 $ category_id = 'deep- ' . sanitize_text_field ( $ _POST ['categorydeep ' ] );
160122 }
161123
162- if ( ! empty ( $ category_id ) && ! edu_starts_with ( $ category_id , 'deep- ' ) ) {
163- $ filters [] = 'CategoryId eq ' . $ category_id ;
164- } elseif ( ! empty ( $ category_id ) && edu_starts_with ( $ category_id , 'deep- ' ) ) {
165- $ filters [] = 'Categories/any(c:c/CategoryId eq ' . str_replace ( 'deep- ' , '' , $ category_id ) . ') ' ;
166- }
167-
168124 if ( ! empty ( $ _POST ['city ' ] ) && is_numeric ( $ _POST ['city ' ] ) ) {
169- $ filters [] = 'Events/any(e:e/LocationId eq ' . intval ( $ _POST ['city ' ] ) . ') ' ;
170- $ event_filters [] = 'LocationId eq ' . intval ( $ _POST ['city ' ] );
125+ $ city = intval ( $ _POST ['city ' ] );
171126 }
172127
173128 if ( ! empty ( $ _POST ['subject ' ] ) ) {
174- $ filters [] = ' Subjects/any(s:s/SubjectName eq \'' . sanitize_text_field ( $ _POST ['subject ' ] ) . '\' ) ' ;
129+ $ subject_id = intval ( $ _POST ['subject ' ] );
175130 }
176131
177132 if ( ! empty ( $ _POST ['subjectid ' ] ) ) {
178- $ filters [] = ' Subjects/any(s:s/SubjectId eq ' . intval ( $ _POST ['subjectid ' ] ) . ' ) ' ;
133+ $ subject_id = intval ( $ _POST ['subjectid ' ] );
179134 }
180135
181136 if ( ! empty ( $ _POST ['courselevel ' ] ) ) {
182- $ filters [] = 'CourseLevelId eq ' . intval ( sanitize_text_field ( $ _POST ['courselevel ' ] ) );
183- }
184-
185- $ expands ['Subjects ' ] = '$select=SubjectName; ' ;
186- $ expands ['Categories ' ] = '$select=CategoryName; ' ;
187- $ expands ['PriceNames ' ] = '$filter=PublicPriceName ' ;
188- $ expands ['Events ' ] =
189- '$filter= ' .
190- join ( ' and ' , $ event_filters ) .
191- '; ' .
192- '$expand=PriceNames($filter=PublicPriceName;$select=PriceNameId,PriceNameDescription,Price,MaxParticipantNumber,NumberOfParticipants,DiscountPercent;),EventDates($orderby=StartDate;$select=StartDate,EndDate;) ' .
193- '; ' .
194- '$orderby=StartDate asc ' .
195- '; ' .
196- '$select=EventId,City,ParticipantNumberLeft,MaxParticipantNumber,StartDate,EndDate,AddressName,EventName,ParticipantVat,BookingFormUrl,OnDemand,OnDemandPublished,OnDemandAccessDays,ApplicationOpenDate ' ;
197-
198- $ expands ['CustomFields ' ] = '$filter=ShowOnWeb;$select=CustomFieldId,CustomFieldName,CustomFieldType,CustomFieldValue,CustomFieldChecked,CustomFieldDate,CustomFieldAlternativeId,CustomFieldAlternativeValue; ' ;
199-
200- if ( ! $ ondemand ) {
201- $ filters [] = 'Events/any(b:b/HasPublicPriceName ' .
202- ' and b/StatusId eq 1 ' .
203- ' and b/CustomerId eq null ' .
204- ' and b/CompanySpecific eq false ' .
205- ' and b/LastApplicationDate ge ' . date_i18n ( 'c ' ) .
206- ' and b/StartDate le ' . edu_get_timezoned_date ( 'c ' , 'now 23:59:59 + ' . $ fetch_months . ' months ' ) .
207- ' and b/EndDate ge ' . edu_get_timezoned_date ( 'c ' , 'now ' ) .
208- ') ' ;
209- } else {
210- $ filters [] = 'Events/any(b:b/HasPublicPriceName ' .
211- ' and b/StatusId eq 1 ' .
212- ' and b/CustomerId eq null ' .
213- ' and b/CompanySpecific eq false ' .
214- ' and b/OnDemand ' .
215- ' and b/OnDemandPublished ' .
216- ') ' ;
137+ $ course_level = intval ( sanitize_text_field ( $ _POST ['courselevel ' ] ) );
217138 }
218139
219140 $ order_by = array ();
@@ -247,20 +168,23 @@ function edu_api_listview_eventlist() {
247168 array_push ( $ order , 1 );
248169 }
249170
250- $ expand_arr = array ();
251- foreach ( $ expands as $ key => $ value ) {
252- if ( empty ( $ value ) ) {
253- $ expand_arr [] = $ key ;
171+ $ attributes = $ _POST ;
172+
173+ if ( $ all_courses ) {
174+ $ _courses = EDUAPIHelper ()->GetEventList ( $ attributes , $ category_id , $ city , $ subject_id , $ course_level , $ custom_order_by , $ custom_order_by_order );
175+ $ _ondemandcourses = EDUAPIHelper ()->GetOnDemandEventList ( $ attributes , $ category_id , $ city , $ subject_id , $ course_level , $ custom_order_by , $ custom_order_by_order );
176+
177+ $ edo = [
178+ 'value ' => array_merge ( $ _ondemandcourses ['value ' ], $ _courses ['value ' ] ),
179+ ];
180+ } else {
181+ if ( ! $ ondemand ) {
182+ $ edo = EDUAPIHelper ()->GetEventList ( $ attributes , $ category_id , $ city , $ subject_id , $ course_level , $ custom_order_by , $ custom_order_by_order );
254183 } else {
255- $ expand_arr [] = $ key . ' ( ' . $ value . ' ) ' ;
184+ $ edo = EDUAPIHelper ()-> GetOnDemandEventList ( $ attributes , $ category_id , $ city , $ subject_id , $ course_level , $ custom_order_by , $ custom_order_by_order ) ;
256185 }
257186 }
258187
259- $ edo = EDUAPI ()->OData ->CourseTemplates ->Search (
260- join ( ', ' , $ selects ),
261- join ( ' and ' , $ filters ),
262- join ( ', ' , $ expand_arr )
263- );
264188 $ courses = $ edo ['value ' ];
265189
266190 if ( ! empty ( $ _POST ['search ' ] ) ) {
@@ -405,6 +329,8 @@ function edu_api_listview_eventlist_template_A( $data, $request ) {
405329 'showvenue ' ,
406330 'order ' ,
407331 'orderby ' ,
332+ 'ondemand ' ,
333+ 'allcourses ' ,
408334 );
409335
410336 $ current_events = 0 ;
@@ -481,6 +407,8 @@ function edu_api_listview_eventlist_template_B( $data, $request ) {
481407 'showvenue ' ,
482408 'order ' ,
483409 'orderby ' ,
410+ 'ondemand ' ,
411+ 'allcourses ' ,
484412 );
485413
486414 $ current_events = 0 ;
0 commit comments