Skip to content

Commit 8629b33

Browse files
authored
Merge pull request #199 from MultinetInteractive/master
2.0.19
2 parents 2ccb3de + 60b33c8 commit 8629b33

21 files changed

Lines changed: 592 additions & 461 deletions

class/class-eduadmin-bookinghandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ private function get_customer() {
614614
}
615615

616616
if ( ! empty( $_POST['invoiceReference'] ) ) { // Var input okay.
617-
$billing_info->SellerReference = sanitize_text_field( $_POST['invoiceReference'] ); // Var input okay.
617+
$billing_info->BuyerReference = sanitize_text_field( $_POST['invoiceReference'] ); // Var input okay.
618618
}
619619

620620
if ( ! empty( $customerInvoiceEmailAddress ) ) {

content/template/bookingTemplate/course-info.php

Lines changed: 9 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -9,52 +9,15 @@
99
$fetch_months = 6;
1010
}
1111

12-
$edo = get_transient( 'eduadmin-object_' . $course_id . '__' . EDU()->version );
13-
if ( ! $edo ) {
14-
$expands = array();
15-
16-
$expands['Subjects'] = '';
17-
$expands['Categories'] = '';
18-
$expands['PriceNames'] = '$filter=PublicPriceName;';
19-
$expands['Events'] =
20-
'$filter=' .
21-
'HasPublicPriceName' .
22-
' and StatusId eq 1' .
23-
' and CustomerId eq null' .
24-
' and CompanySpecific eq false' .
25-
' and LastApplicationDate ge ' . date( 'c' ) .
26-
' and StartDate le ' . date( 'c', strtotime( 'now 23:59:59 +' . $fetch_months . ' months' ) ) .
27-
' and EndDate ge ' . date( 'c', strtotime( 'now' ) ) .
28-
';' .
29-
'$expand=PriceNames($filter=PublicPriceName),EventDates,Sessions($expand=PriceNames($filter=PublicPriceName;);$filter=HasPublicPriceName;),PaymentMethods' .
30-
';' .
31-
'$orderby=' . ( $group_by_city ? 'City asc,' : '' ) . 'StartDate asc' .
32-
';';
33-
34-
$expands['CustomFields'] = '$filter=ShowOnWeb';
35-
36-
$expand_arr = array();
37-
foreach ( $expands as $key => $value ) {
38-
if ( empty( $value ) ) {
39-
$expand_arr[] = $key;
40-
} else {
41-
$expand_arr[] = $key . '(' . $value . ')';
42-
}
43-
}
44-
45-
$edo = EDUAPI()->OData->CourseTemplates->GetItem(
46-
$course_id,
47-
null,
48-
join( ',', $expand_arr )
49-
);
50-
set_transient( 'eduadmin-object_' . $course_id . '__' . EDU()->version, $edo, 10 );
51-
}
12+
$edo = EDUAPIHelper()->GetCourseDetailInfo( $course_id, $fetch_months, $group_by_city );
5213

5314
$selected_course = false;
5415
$name = '';
16+
5517
if ( $edo ) {
18+
$selected_course = json_decode( $edo, true );
19+
$edo = $selected_course;
5620
$name = ( ! empty( $edo['CourseName'] ) ? $edo['CourseName'] : $edo['InternalCourseName'] );
57-
$selected_course = $edo;
5821
}
5922

6023
if ( ! $selected_course || 0 === count( $selected_course['Events'] ) ) {
@@ -78,11 +41,11 @@
7841
}
7942
}
8043

81-
$questions = get_transient( 'eduadmin-event_questions_' . $event['EventId'] . '__' . EDU()->version );
82-
if ( ! $questions ) {
83-
$questions = EDUAPI()->REST->Event->BookingQuestions( $event['EventId'], true );
84-
set_transient( 'eduadmin-event_questions_' . $event['EventId'] . '__' . EDU()->version, $questions, DAY_IN_SECONDS );
85-
}
44+
$event_id = $event['EventId'];
45+
46+
$questions = EDU()->get_transient( 'eduadmin-event_questions', function() use ( $event_id ) {
47+
return EDUAPI()->REST->Event->BookingQuestions( $event_id, true );
48+
}, DAY_IN_SECONDS, $event_id );
8649

8750
$booking_questions = $questions['BookingQuestions'];
8851
$participant_questions = $questions['ParticipantQuestions'];

content/template/bookingTemplate/template_A.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,8 @@
3636
$participant_discount_percent = 0.0;
3737
$customer_invoice_email = '';
3838

39-
$org = get_transient( 'eduadmin-organization' . '__' . EDU()->version );
40-
if ( ! $org ) {
41-
$org = EDUAPI()->REST->Organisation->GetOrganisation();
42-
set_transient( 'eduadmin-organization' . '__' . EDU()->version, $org, DAY_IN_SECONDS );
43-
}
39+
$org = EDUAPIHelper()->GetOrganization();
40+
4441
$inc_vat = $org['PriceIncVat'];
4542

4643
if ( isset( EDU()->session['eduadmin-loginUser'] ) ) {

content/template/detailTemplate/course-info.php

Lines changed: 8 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -8,50 +8,13 @@
88
}
99
$group_by_city = get_option( 'eduadmin-groupEventsByCity', false );
1010
$group_by_city_class = '';
11-
$edo = get_transient( 'eduadmin-object_' . $course_id . '_json' . '__' . EDU()->version );
12-
$fetch_months = get_option( 'eduadmin-monthsToFetch', 6 );
11+
12+
$fetch_months = get_option( 'eduadmin-monthsToFetch', 6 );
1313
if ( ! is_numeric( $fetch_months ) ) {
1414
$fetch_months = 6;
1515
}
16-
if ( ! $edo ) {
17-
$expands = array();
18-
19-
$expands['Subjects'] = '';
20-
$expands['Categories'] = '';
21-
$expands['PriceNames'] = '$filter=PublicPriceName;';
22-
$expands['Events'] =
23-
'$filter=' .
24-
'HasPublicPriceName' .
25-
' and StatusId eq 1' .
26-
' and CustomerId eq null' .
27-
' and CompanySpecific eq false' .
28-
' and LastApplicationDate ge ' . date( 'c' ) .
29-
' and StartDate le ' . date( 'c', strtotime( 'now 23:59:59 +' . $fetch_months . ' months' ) ) .
30-
' and EndDate ge ' . date( 'c', strtotime( 'now' ) ) .
31-
';' .
32-
'$expand=PriceNames($filter=PublicPriceName),EventDates($orderby=StartDate)' .
33-
';' .
34-
'$orderby=StartDate asc' . ( $group_by_city ? ', City asc' : '' ) .
35-
';';
36-
37-
$expands['CustomFields'] = '$filter=ShowOnWeb';
38-
39-
$expand_arr = array();
40-
foreach ( $expands as $key => $value ) {
41-
if ( empty( $value ) ) {
42-
$expand_arr[] = $key;
43-
} else {
44-
$expand_arr[] = $key . '(' . $value . ')';
45-
}
46-
}
4716

48-
$edo = wp_json_encode( EDUAPI()->OData->CourseTemplates->GetItem(
49-
$course_id,
50-
null,
51-
join( ',', $expand_arr )
52-
) );
53-
set_transient( 'eduadmin-object_' . $course_id . '_json' . '__' . EDU()->version, $edo, 10 );
54-
}
17+
$edo = EDUAPIHelper()->GetCourseDetailInfo( $course_id, $fetch_months, $group_by_city );
5518

5619
$selected_course = false;
5720
$name = '';
@@ -72,10 +35,10 @@
7235

7336
$pricenames = array();
7437
foreach ( $selected_course['PriceNames'] as $pn ) {
75-
$pricenames[] = $pn['Price'];
38+
$pricenames[] = $pn;
7639
}
7740
foreach ( $event['PriceNames'] as $pn ) {
78-
$pricenames[] = $pn['Price'];
41+
$pricenames[] = $pn;
7942
}
8043

8144
$event = array_merge( $event['CourseTemplate'], $event );
@@ -87,18 +50,7 @@
8750
$events[] = $event;
8851
}
8952

90-
$tr = EDU()->start_timer( 'GetRegions' );
91-
$regions = get_transient( 'eduadmin-regions' . '__' . EDU()->version );
92-
if ( ! $regions ) {
93-
$regions = EDUAPI()->OData->Regions->Search(
94-
null,
95-
null,
96-
'Locations($filter=PublicLocation;$expand=LocationAddresses;)',
97-
'RegionName asc'
98-
);
99-
set_transient( 'eduadmin-regions' . '__' . EDU()->version, $regions, DAY_IN_SECONDS );
100-
}
101-
EDU()->stop_timer( $tr );
53+
$regions = EDUAPIHelper()->GetRegions();
10254

10355
if ( ! empty( $_REQUEST['edu-region'] ) ) {
10456
$matching_regions = array_filter( $regions['value'], function( $region ) {
@@ -153,11 +105,8 @@
153105
set_transient( 'eduadmin-courseLevel-' . $selected_course['CourseTemplateId'] . '__' . EDU()->version, $course_level, HOUR_IN_SECONDS );
154106
}
155107

156-
$org = get_transient( 'eduadmin-organization' . '__' . EDU()->version );
157-
if ( ! $org ) {
158-
$org = EDUAPI()->REST->Organisation->GetOrganisation();
159-
set_transient( 'eduadmin-organization' . '__' . EDU()->version, $org, DAY_IN_SECONDS );
160-
}
108+
$org = EDUAPIHelper()->GetOrganization();
109+
161110
$inc_vat = $org['PriceIncVat'];
162111
$show_headers = get_option( 'eduadmin-showDetailHeaders', true );
163112

content/template/interestRegTemplate/interest-reg-event.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@
1111
}
1212

1313
$course_id = $wp_query->query_vars['courseId'];
14-
$edo = get_transient( 'eduadmin-object_' . $course_id. '__' . EDU()->version );
15-
if ( ! $edo ) {
16-
$edo = EDUAPI()->OData->CourseTemplates->GetItem(
17-
$course_id,
18-
null,
19-
'Subjects,Events($filter=EventId eq ' . intval( $_REQUEST['eid'] ) . ';),CustomFields'
20-
);
21-
set_transient( 'eduadmin-object_' . $course_id. '__' . EDU()->version, $edo, 10 );
14+
$group_by_city = get_option( 'eduadmin-groupEventsByCity', false );
15+
$fetch_months = get_option( 'eduadmin-monthsToFetch', 6 );
16+
if ( ! is_numeric( $fetch_months ) ) {
17+
$fetch_months = 6;
2218
}
19+
$edo = json_decode( EDUAPIHelper()->GetCourseDetailInfo( $course_id, $fetch_months, $group_by_city ), true );
2320

2421
$selected_course = false;
2522
$name = '';

content/template/interestRegTemplate/interest-reg-object.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,15 @@
1010
include_once 'send-object-inquiry.php';
1111
}
1212

13-
$course_id = $wp_query->query_vars['courseId'];
14-
$edo = get_transient( 'eduadmin-object_' . $course_id. '__' . EDU()->version );
15-
if ( ! $edo ) {
16-
$edo = EDUAPI()->OData->CourseTemplates->GetItem(
17-
$course_id,
18-
null,
19-
'Subjects,Events,CustomFields'
20-
);
21-
set_transient( 'eduadmin-object_' . $course_id. '__' . EDU()->version, $edo, 10 );
13+
$course_id = $wp_query->query_vars['courseId'];
14+
$group_by_city = get_option( 'eduadmin-groupEventsByCity', false );
15+
$fetch_months = get_option( 'eduadmin-monthsToFetch', 6 );
16+
if ( ! is_numeric( $fetch_months ) ) {
17+
$fetch_months = 6;
2218
}
2319

20+
$edo = json_decode( EDUAPIHelper()->GetCourseDetailInfo( $course_id, $fetch_months, $group_by_city ), true );
21+
2422
$selected_course = false;
2523
$name = '';
2624
if ( $edo ) {

content/template/listTemplate/list-courses.php

Lines changed: 17 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -8,99 +8,39 @@
88
$fetch_months = 6;
99
}
1010

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-
3711
$show_events_with_events_only = $attributes['onlyevents'];
3812
$show_events_without_events_only = $attributes['onlyempty'];
3913

14+
if ( ! empty( $_REQUEST['eduadmin-category'] ) ) {
15+
$category_id = intval( $_REQUEST['eduadmin-category'] );
16+
}
17+
4018
if ( $category_id > 0 ) {
41-
$filters[] = 'CategoryId eq ' . $category_id;
4219
$attributes['category'] = $category_id;
4320
}
4421

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;
4923

5024
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;
5327
}
5428

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;
5830

5931
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;
6234
}
6335

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;
7937

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'] ) );
8740
}
8841

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 );
9743

98-
$edo = EDUAPI()->OData->CourseTemplates->Search(
99-
null,
100-
join( ' and ', $filters ),
101-
join( ',', $expand_arr ),
102-
join( ',', $sorting )
103-
);
10444
$courses = $edo['value'];
10545

10646
if ( ! empty( $_REQUEST['searchCourses'] ) ) {
@@ -156,11 +96,9 @@
15696
$show_next_event_date = get_option( 'eduadmin-showNextEventDate', false );
15797
$show_course_locations = get_option( 'eduadmin-showCourseLocations', false );
15898
$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+
164102
$inc_vat = $org['PriceIncVat'];
165103

166104
$show_course_days = get_option( 'eduadmin-showCourseDays', true );

0 commit comments

Comments
 (0)