diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e9f654f..87e45895 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [5.3.0](https://github.com/MultinetInteractive/EduAdmin-WordPress/compare/v5.2.0...v5.3.0) (2024-11-05) + + +### Features + +* Handle API being down/blocked, instead of making the site hang until the configured timeout happens. ([a1a5104](https://github.com/MultinetInteractive/EduAdmin-WordPress/commit/a1a51042d4b7687830de5eaa9127ae2959a3f577)), closes [#153](https://github.com/MultinetInteractive/EduAdmin-WordPress/issues/153) + ## [5.2.0](https://github.com/MultinetInteractive/EduAdmin-WordPress/compare/v5.1.3...v5.2.0) (2024-11-04) diff --git a/PLUGIN-CHECKSUM b/PLUGIN-CHECKSUM index 7f3e9d02..ce753253 100644 --- a/PLUGIN-CHECKSUM +++ b/PLUGIN-CHECKSUM @@ -1 +1 @@ -f43f26b58da1439fef621c2813477a7d +5cd3f4c5d7825087108a651e5f73d89f diff --git a/content/template/bookingTemplate/template_A.php b/content/template/bookingTemplate/template_A.php index 5890b7ce..c5712873 100644 --- a/content/template/bookingTemplate/template_A.php +++ b/content/template/bookingTemplate/template_A.php @@ -3,326 +3,330 @@ ob_start(); global $wp_query; $api_key = EDU()->get_option( 'eduadmin-api-key' ); - -if ( ! $api_key || empty( $api_key ) ) { - echo 'Please complete the configuration: EduAdmin - Api Authentication'; +if ( ! EDU()->api_connection ) { + echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' ); } else { - include_once 'course-info.php'; + if ( ! $api_key || empty( $api_key ) ) { + echo 'Please complete the configuration: EduAdmin - Api Authentication'; + } else { + include_once 'course-info.php'; - if ( EDU()->is_checked( 'eduadmin-useBookingFormFromApi', false ) ) { - if ( ! empty( $event['BookingFormUrl'] ) ) { - ?> - - get_option( 'eduadmin-booking-form-javascript', '' ) ) ) ) { + if ( EDU()->is_checked( 'eduadmin-useBookingFormFromApi', false ) ) { + if ( ! empty( $event['BookingFormUrl'] ) ) { ?> - + get_option( 'eduadmin-booking-form-javascript', '' ) ) ) ) { + ?> + + get_option( 'eduadmin-currency', 'SEK' ); + $currency = EDU()->get_option( 'eduadmin-currency', 'SEK' ); - if ( ! empty( $_REQUEST['edu-valid-form'] ) && wp_verify_nonce( $_REQUEST['edu-valid-form'], 'edu-booking-confirm' ) && isset( $_REQUEST['act'] ) && 'bookCourse' === sanitize_text_field( $_REQUEST['act'] ) ) { - $error_list = apply_filters( 'edu-booking-error', array() ); - if ( ! empty( $error_list ) ) { - echo '
'; - foreach ( $error_list as $error ) { - ?> -
- -
- '; - } else { - if ( ! empty( $GLOBALS['edubookinginfo'] ) ) { - $ebi = $GLOBALS['edubookinginfo']; + if ( ! empty( $_REQUEST['edu-valid-form'] ) && wp_verify_nonce( $_REQUEST['edu-valid-form'], 'edu-booking-confirm' ) && isset( $_REQUEST['act'] ) && 'bookCourse' === sanitize_text_field( $_REQUEST['act'] ) ) { + $error_list = apply_filters( 'edu-booking-error', array() ); + if ( ! empty( $error_list ) ) { + echo '
'; + foreach ( $error_list as $error ) { + ?> +
+ +
+ '; } else { - $booking_id = intval( $_GET['booking_id'] ); - $programme_booking_id = intval( $_GET['programme_booking_id'] ); + if ( ! empty( $GLOBALS['edubookinginfo'] ) ) { + $ebi = $GLOBALS['edubookinginfo']; + } else { + $booking_id = intval( $_GET['booking_id'] ); + $programme_booking_id = intval( $_GET['programme_booking_id'] ); + + if ( $booking_id > 0 ) { + $event_booking = EDUAPI()->OData->Bookings->GetItem( + $booking_id, + null, + 'Customer($select=CustomerId;),ContactPerson($select=PersonId;),OrderRows', + false + ); + } elseif ( $programme_booking_id > 0 ) { + $event_booking = EDUAPI()->OData->ProgrammeBookings->GetItem( + $programme_booking_id, + null, + 'Customer($select=CustomerId;),ContactPerson($select=PersonId;),OrderRows', + false + ); + } + + if ( $event_booking['@curl']['http_code'] === 404 ) { + // The booking does not exist any longer (probably removed) + include_once __DIR__ . '/views/booking-deleted.php'; + + return; + } - if ( $booking_id > 0 ) { - $event_booking = EDUAPI()->OData->Bookings->GetItem( - $booking_id, + $_customer = EDUAPI()->OData->Customers->GetItem( + $event_booking['Customer']['CustomerId'], null, - 'Customer($select=CustomerId;),ContactPerson($select=PersonId;),OrderRows', + "BillingInfo", false ); - } elseif ( $programme_booking_id > 0 ) { - $event_booking = EDUAPI()->OData->ProgrammeBookings->GetItem( - $programme_booking_id, + + $_contact = EDUAPI()->OData->Persons->GetItem( + $event_booking['ContactPerson']['PersonId'], + null, null, - 'Customer($select=CustomerId;),ContactPerson($select=PersonId;),OrderRows', false ); - } - if ( $event_booking['@curl']['http_code'] === 404 ) { - // The booking does not exist any longer (probably removed) - include_once __DIR__ . '/views/booking-deleted.php'; - - return; + $ebi = new EduAdmin_BookingInfo( $event_booking, $_customer, $_contact ); + $GLOBALS['edubookinginfo'] = $ebi; } - - $_customer = EDUAPI()->OData->Customers->GetItem( - $event_booking['Customer']['CustomerId'], - null, - "BillingInfo", - false - ); - - $_contact = EDUAPI()->OData->Persons->GetItem( - $event_booking['ContactPerson']['PersonId'], - null, - null, - false - ); - - $ebi = new EduAdmin_BookingInfo( $event_booking, $_customer, $_contact ); - $GLOBALS['edubookinginfo'] = $ebi; + do_action( 'eduadmin-processbooking', $ebi ); + do_action( 'eduadmin-bookingcompleted' ); } - do_action( 'eduadmin-processbooking', $ebi ); + } elseif ( ! empty( $_REQUEST['edu-valid-form'] ) && wp_verify_nonce( $_REQUEST['edu-valid-form'], 'edu-booking-confirm' ) && isset( $_REQUEST['act'] ) && 'paymentCompleted' === sanitize_text_field( $_REQUEST['act'] ) ) { do_action( 'eduadmin-bookingcompleted' ); - } - } elseif ( ! empty( $_REQUEST['edu-valid-form'] ) && wp_verify_nonce( $_REQUEST['edu-valid-form'], 'edu-booking-confirm' ) && isset( $_REQUEST['act'] ) && 'paymentCompleted' === sanitize_text_field( $_REQUEST['act'] ) ) { - do_action( 'eduadmin-bookingcompleted' ); - } else { - $contact = new EduAdmin_Data_ContactPerson(); - $customer = new EduAdmin_Data_Customer(); + } else { + $contact = new EduAdmin_Data_ContactPerson(); + $customer = new EduAdmin_Data_Customer(); - $discount_percent = 0.0; - $participant_discount_percent = 0.0; - $customer_invoice_email = ''; + $discount_percent = 0.0; + $participant_discount_percent = 0.0; + $customer_invoice_email = ''; - if ( isset( EDU()->session['eduadmin-loginUser'] ) ) { - $user = EDU()->session['eduadmin-loginUser']; - $contact = $user->Contact; - $customer = $user->Customer; - } + if ( isset( EDU()->session['eduadmin-loginUser'] ) ) { + $user = EDU()->session['eduadmin-loginUser']; + $contact = $user->Contact; + $customer = $user->Customer; + } - $unique_prices = array(); - if ( ! $GLOBALS['noAvailableDates'] ) { - foreach ( $event['PriceNames'] as $price ) { - $unique_prices[ $price['PriceNameDescription'] ] = $price; + $unique_prices = array(); + if ( ! $GLOBALS['noAvailableDates'] ) { + foreach ( $event['PriceNames'] as $price ) { + $unique_prices[ $price['PriceNameDescription'] ] = $price; + } } - } - // PriceNameVat - $first_price = current( $unique_prices ); + // PriceNameVat + $first_price = current( $unique_prices ); - $hide_sub_event_date_info = EDU()->is_checked( 'eduadmin-hideSubEventDateTime', false ); - ?> -
-
- - -
- - -
- + $hide_sub_event_date_info = EDU()->is_checked( 'eduadmin-hideSubEventDateTime', false ); + ?> +
+ + + +
+ + +
+ -
- - - -

- -

- -
- session['eduadmin-loginUser'] ) ) { - $user_val = ''; - if ( isset( $contact->PersonId ) && $contact->PersonId > 0 ) { - $user_val = trim( $contact->FirstName . ' ' . $contact->LastName ); - } else { - $selected_login_field = EDU()->get_option( 'eduadmin-loginField', 'Email' ); - switch ( $selected_login_field ) { - case 'Email': - $user_val = $contact->Email; - break; - case 'CivicRegistrationNumber': - $user_val = $contact->CivicRegistrationNumber; - break; - default: - $user_val = $contact->Email; - break; - } - } - $surl = get_home_url(); - $cat = EDU()->get_option( 'eduadmin-rewriteBaseUrl' ); - $base_url = $surl . '/' . $cat; - ?> -
- - %1$s? %2$sLog out%3$s', 'frontend', 'eduadmin-booking' ), esc_html( $user_val ), '', '' ), wp_kses_allowed_html( 'post' ) ); - ?> - +
+ + + +

+ +

+
- is_checked( 'eduadmin-noInvoiceFreeEvents', false ); - $single_person_booking = EDU()->is_checked( 'eduadmin-singlePersonBooking', false ); - $show_invoice_email = isset( $attributes['hideinvoiceemailfield'] ) ? false == $attributes['hideinvoiceemailfield'] : ! EDU()->is_checked( 'eduadmin-hideInvoiceEmailField', false ); - $force_show_invoice_information = isset( $attributes['showinvoiceinformation'] ) ? false == $attributes['showinvoiceinformation'] : EDU()->is_checked( 'eduadmin-showInvoiceInformation', false ); - if ( $single_person_booking ) { - include_once 'single-person-booking.php'; - } else { - $field_order = EDU()->get_option( 'eduadmin-fieldOrder', 'contact_customer' ); - if ( 'contact_customer' === $field_order ) { - include_once 'contact-view.php'; - include_once 'customer-view.php'; - } elseif ( 'customer_contact' === $field_order ) { - include_once 'customer-view.php'; - include_once 'contact-view.php'; - } - include_once 'participant-view.php'; - } - ?> - get_option( 'eduadmin-selectPricename', 'firstPublic' ) ) : ?> -
- - -
- - -
- is_checked( 'eduadmin-useBookingTermsCheckbox', false ) && $link = EDU()->get_option( 'eduadmin-bookingTermsLink', '' ) ): ?> -
-
- - - ', ''); + document.title = title; + eduBookingView.SingleParticipant = ; + eduBookingView.ProgrammeBooking = false; + eduBookingView.ForceContactCivicRegNo = ; + eduBookingView.MaxParticipants = ; + eduBookingView.AddParticipant(); + eduBookingView.CheckPrice(false); + })(); + + session['eduadmin-loginUser'] ); } -do_action( 'eduadmin-bookingform-loaded', EDU()->session['eduadmin-loginUser'] ); + $out = ob_get_clean(); return $out; diff --git a/content/template/data/ld-json.php b/content/template/data/ld-json.php index 0c452738..c7ebe9d7 100644 --- a/content/template/data/ld-json.php +++ b/content/template/data/ld-json.php @@ -1,6 +1,10 @@ api_connection ) { + return; +} + if ( ! empty( $wp_query->query_vars['courseId'] ) ) { $course_id = $wp_query->query_vars['courseId']; } elseif ( ! empty( $attributes['courseid'] ) ) { diff --git a/content/template/data/ogp.php b/content/template/data/ogp.php index c6872a20..e001c355 100644 --- a/content/template/data/ogp.php +++ b/content/template/data/ogp.php @@ -1,6 +1,10 @@ api_connection ) { + return; +} + if ( ! empty( $wp_query->query_vars['courseId'] ) ) { $course_id = $wp_query->query_vars['courseId']; } elseif ( ! empty( $attributes['courseid'] ) ) { diff --git a/content/template/detailTemplate/template_A.php b/content/template/detailTemplate/template_A.php index b820b65a..a4b4be8d 100644 --- a/content/template/detailTemplate/template_A.php +++ b/content/template/detailTemplate/template_A.php @@ -3,148 +3,152 @@ global $wp_query; $api_key = EDU()->get_option( 'eduadmin-api-key' ); -if ( ! $api_key || empty( $api_key ) ) { - echo 'Please complete the configuration: EduAdmin - Api Authentication'; +if ( ! EDU()->api_connection ) { + echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' ); } else { - include 'course-info.php'; - if ( ! $selected_course ) { - ?> - - -
- -
- - - -

- -

-
-
-
+ if ( ! $api_key || empty( $api_key ) ) { + echo 'Please complete the configuration: EduAdmin - Api Authentication'; + } else { + include 'course-info.php'; + if ( ! $selected_course ) { + ?> + -

+ exit( 200 ); + } + ?> +
+ +
+ + + +

+ +

+
+
+
+ +

+ +
+ +
-
- -
- - -

+ +

+ +
+ +
-
- -
- - -

+ +

+ +
+ +
-
- -
- - -

+ +

+ +
+ +
-
- -
- - -

+ +

+ +
+ +
-
- -
- - -

+ +

+ +
+ +
-
+
+
+ +

0 ? sprintf( _n( '%1$d day', '%1$d days', $selected_course['Days'], 'eduadmin-booking' ), $selected_course['Days'] ) . ', ' : '' ) . $selected_course['StartTime'] . ' - ' . $selected_course['EndTime'] ); + } + + if ( ! in_array( 'price', $hide_sections, true ) && ! empty( $prices ) ) { ?> -
- -
-
- + get_option( 'eduadmin-currency', 'SEK' ); + + if ( 1 === count( $prices ) ) { + echo wp_kses_post( sprintf( '
%1$s %2$s
', current( $prices )['PriceNameDescription'], edu_get_price( current( $prices )['Price'], $selected_course['ParticipantVat'] ) ) ); + } else { + foreach ( $prices as $up ) { + echo wp_kses_post( sprintf( '
%1$s %2$s
', $up['PriceNameDescription'], edu_get_price( $up['Price'], $selected_course['ParticipantVat'] ) ) ); + } + } + } ?> -

- 0 ? sprintf( _n( '%1$d day', '%1$d days', $selected_course['Days'], 'eduadmin-booking' ), $selected_course['Days'] ) . ', ' : '' ) . $selected_course['StartTime'] . ' - ' . $selected_course['EndTime'] ); - } +
- if ( ! in_array( 'price', $hide_sections, true ) && ! empty( $prices ) ) { + -

+
+
+ +
get_option( 'eduadmin-currency', 'SEK' ); - - if ( 1 === count( $prices ) ) { - echo wp_kses_post( sprintf( '
%1$s %2$s
', current( $prices )['PriceNameDescription'], edu_get_price( current( $prices )['Price'], $selected_course['ParticipantVat'] ) ) ); - } else { - foreach ( $prices as $up ) { - echo wp_kses_post( sprintf( '
%1$s %2$s
', $up['PriceNameDescription'], edu_get_price( $up['Price'], $selected_course['ParticipantVat'] ) ) ); - } - } } ?>
- -
-
- -
- -
- get_option( 'eduadmin-api-key' ); -if ( ! $api_key || empty( $api_key ) ) { - echo 'Please complete the configuration: EduAdmin - Api Authentication'; +if ( ! EDU()->api_connection ) { + echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' ); } else { - include_once 'course-info.php'; - if ( ! $selected_course ) { - ?> - - EduAdmin - Api Authentication'; + } else { + include_once 'course-info.php'; + if ( ! $selected_course ) { + ?> + + -
- -
- - - -

- -

-
-
-
- -

- + ?> +
+ +
+ + + +

+ +

+
+
+
+ +

+ +
+ +
+ + +

+ +
+ +
+ + +

+ +
+ +
+ + + +

+
- - -

- -
+
+
+ + +

+ +
+ +
+ + +

+ +
+ +
+ +
+
+ +

0 ? sprintf( _n( '%1$d day', '%1$d days', $selected_course['Days'], 'eduadmin-booking' ), $selected_course['Days'] ) . ', ' : '' ) . + $selected_course['StartTime'] . ' - ' . $selected_course['EndTime']; + } + + if ( ! in_array( 'price', $hide_sections, true ) && ! empty( $prices ) ) { ?> -
- - -

- -
+

-
- - - -

- -
- get_option( 'eduadmin-currency', 'SEK' ); + if ( 1 === count( $prices ) ) { + echo wp_kses_post( sprintf( '
%1$s %2$s
', current( $prices )['PriceNameDescription'], edu_get_price( current( $prices )['Price'], $selected_course['ParticipantVat'] ) ) ); + } else { + foreach ( $prices as $up ) { + echo wp_kses_post( sprintf( '
%1$s %2$s
', $up['PriceNameDescription'], edu_get_price( $up['Price'], $selected_course['ParticipantVat'] ) ) ); + } + } + } ?>
-
-
- - -

- -
- -
- - -

- -
- -
- -
-
- -

- 0 ? sprintf( _n( '%1$d day', '%1$d days', $selected_course['Days'], 'eduadmin-booking' ), $selected_course['Days'] ) . ', ' : '' ) . - $selected_course['StartTime'] . ' - ' . $selected_course['EndTime']; - } - - if ( ! in_array( 'price', $hide_sections, true ) && ! empty( $prices ) ) { + -

+
+
+ +
get_option( 'eduadmin-currency', 'SEK' ); - if ( 1 === count( $prices ) ) { - echo wp_kses_post( sprintf( '
%1$s %2$s
', current( $prices )['PriceNameDescription'], edu_get_price( current( $prices )['Price'], $selected_course['ParticipantVat'] ) ) ); - } else { - foreach ( $prices as $up ) { - echo wp_kses_post( sprintf( '
%1$s %2$s
', $up['PriceNameDescription'], edu_get_price( $up['Price'], $selected_course['ParticipantVat'] ) ) ); - } - } } ?>
-
-
- -
- -
- get_option( 'eduadmin-api-key' ); -if ( ! $api_key || empty( $api_key ) ) { - echo 'Please complete the configuration: EduAdmin - Api Authentication'; +if ( ! EDU()->api_connection ) { + echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' ); } else { - if ( ! empty( $_POST['edu-interest-nonce'] ) && wp_verify_nonce( $_POST['edu-interest-nonce'], 'edu-event-interest' ) && isset( $_POST['act'] ) && 'eventInquiry' === sanitize_text_field( $_POST['act'] ) ) { - include_once 'send-event-inquiry.php'; - } + if ( ! $api_key || empty( $api_key ) ) { + echo 'Please complete the configuration: EduAdmin - Api Authentication'; + } else { + if ( ! empty( $_POST['edu-interest-nonce'] ) && wp_verify_nonce( $_POST['edu-interest-nonce'], 'edu-event-interest' ) && isset( $_POST['act'] ) && 'eventInquiry' === sanitize_text_field( $_POST['act'] ) ) { + include_once 'send-event-inquiry.php'; + } - $course_id = $wp_query->query_vars['courseId']; - $group_by_city = EDU()->is_checked( 'eduadmin-groupEventsByCity', false ); - $fetch_months = EDU()->get_option( 'eduadmin-monthsToFetch', 6 ); - if ( ! is_numeric( $fetch_months ) ) { - $fetch_months = 6; - } - $edo = json_decode( EDUAPIHelper()->GetCourseDetailInfo( $course_id, $fetch_months, $group_by_city ), true ); + $course_id = $wp_query->query_vars['courseId']; + $group_by_city = EDU()->is_checked( 'eduadmin-groupEventsByCity', false ); + $fetch_months = EDU()->get_option( 'eduadmin-monthsToFetch', 6 ); + if ( ! is_numeric( $fetch_months ) ) { + $fetch_months = 6; + } + $edo = json_decode( EDUAPIHelper()->GetCourseDetailInfo( $course_id, $fetch_months, $group_by_city ), true ); - $selected_course = false; - $name = ''; - if ( $edo ) { - $name = ( ! empty( $edo['CourseName'] ) ? $edo['CourseName'] : $edo['InternalCourseName'] ); - $selected_course = $edo; - } + $selected_course = false; + $name = ''; + if ( $edo ) { + $name = ( ! empty( $edo['CourseName'] ) ? $edo['CourseName'] : $edo['InternalCourseName'] ); + $selected_course = $edo; + } - $is_ondemand = $selected_course['OnDemand']; + $is_ondemand = $selected_course['OnDemand']; - if ( $is_ondemand ) { - $selected_course = json_decode( EDUAPIHelper()->GetOnDemandCourseDetailInfo( $course_id, $group_by_city ), true ); - } + if ( $is_ondemand ) { + $selected_course = json_decode( EDUAPIHelper()->GetOnDemandCourseDetailInfo( $course_id, $group_by_city ), true ); + } - if ( ! $selected_course ) { - ?> - - + + - - + + -
- -
- - - -

-

-
-
- -
-
-
- + ?> +
+ +
+ + + +

-

+
+
+ +

-
- - - - - - - - - - - - is_checked( 'eduadmin-singlePersonBooking', false ) ) { ?> - - -
-
- - - + + get_option( 'eduadmin-api-key' ); - -if ( ! $api_key || empty( $api_key ) ) { - echo 'Please complete the configuration: EduAdmin - Api Authentication'; +if ( ! EDU()->api_connection ) { + echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' ); } else { - if ( ! empty( $_POST['edu-interest-nonce'] ) && wp_verify_nonce( $_POST['edu-interest-nonce'], 'edu-object-interest' ) && isset( $_POST['act'] ) && 'objectInquiry' === sanitize_text_field( $_POST['act'] ) ) { - include_once 'send-object-inquiry.php'; - } + if ( ! $api_key || empty( $api_key ) ) { + echo 'Please complete the configuration: EduAdmin - Api Authentication'; + } else { + if ( ! empty( $_POST['edu-interest-nonce'] ) && wp_verify_nonce( $_POST['edu-interest-nonce'], 'edu-object-interest' ) && isset( $_POST['act'] ) && 'objectInquiry' === sanitize_text_field( $_POST['act'] ) ) { + include_once 'send-object-inquiry.php'; + } - $course_id = $wp_query->query_vars['courseId']; - $group_by_city = EDU()->is_checked( 'eduadmin-groupEventsByCity', false ); - $fetch_months = EDU()->get_option( 'eduadmin-monthsToFetch', 6 ); - if ( ! is_numeric( $fetch_months ) ) { - $fetch_months = 6; - } + $course_id = $wp_query->query_vars['courseId']; + $group_by_city = EDU()->is_checked( 'eduadmin-groupEventsByCity', false ); + $fetch_months = EDU()->get_option( 'eduadmin-monthsToFetch', 6 ); + if ( ! is_numeric( $fetch_months ) ) { + $fetch_months = 6; + } - $edo = json_decode( EDUAPIHelper()->GetCourseDetailInfo( $course_id, $fetch_months, $group_by_city ), true ); + $edo = json_decode( EDUAPIHelper()->GetCourseDetailInfo( $course_id, $fetch_months, $group_by_city ), true ); - $selected_course = false; - $name = ''; - if ( $edo ) { - $name = ( ! empty( $edo['CourseName'] ) ? $edo['CourseName'] : $edo['InternalCourseName'] ); - $selected_course = $edo; - } + $selected_course = false; + $name = ''; + if ( $edo ) { + $name = ( ! empty( $edo['CourseName'] ) ? $edo['CourseName'] : $edo['InternalCourseName'] ); + $selected_course = $edo; + } - if ( ! $selected_course ) { - ?> - - + + -
- -
- - - -

-

-
-
-
- + ?> +
+ +
+ + + +

-

+

-
- - - - - - - - - - - is_checked( 'eduadmin-singlePersonBooking', false ) ) { ?> - - -
-
- - - + + api_connection ) { + echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' ); + + return; +} + $surl = get_home_url(); $cat = EDU()->get_option( 'eduadmin-rewriteBaseUrl', '' ); $base_url = $surl . '/' . $cat; diff --git a/content/template/listTemplate/search-form.php b/content/template/listTemplate/search-form.php index fc570f93..9eddb3ac 100644 --- a/content/template/listTemplate/search-form.php +++ b/content/template/listTemplate/search-form.php @@ -1,3 +1,9 @@ +api_connection ) { + + return; +} +?>
diff --git a/content/template/listTemplate/template-loader.php b/content/template/listTemplate/template-loader.php index d40f9656..21bf3ff8 100644 --- a/content/template/listTemplate/template-loader.php +++ b/content/template/listTemplate/template-loader.php @@ -1,4 +1,11 @@ api_connection ) { + echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' ); + + return; +} + $eds = $subjects; $edl = $levels; @@ -45,10 +52,20 @@ } $all_courses = false; -if(!empty($attributes['allcourses'])) { +if ( ! empty( $attributes['allcourses'] ) ) { $all_courses = $attributes['allcourses']; } +switch ( $attributes['template'] ) { + case "template_A": + case "template_B": + case "template_GF": + break; + default: + $attributes['template'] = "template_A"; + break; +} + if ( null !== $custom_mode ) { if ( 'event' === $custom_mode ) { $str = include $attributes['template'] . '_listEvents.php'; diff --git a/content/template/listTemplate/template_A.php b/content/template/listTemplate/template_A.php index 3b62fd09..f16e1c62 100644 --- a/content/template/listTemplate/template_A.php +++ b/content/template/listTemplate/template_A.php @@ -4,18 +4,22 @@ global $wp_query; $api_key = EDU()->get_option( 'eduadmin-api-key' ); -if ( ! $api_key || empty( $api_key ) ) { - echo 'Please complete the configuration: EduAdmin - Api Authentication'; +if ( ! EDU()->api_connection ) { + echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' ); } else { - include 'list-options.php'; - ?> -
- EduAdmin - Api Authentication'; + } else { + include 'list-options.php'; ?> -
- + +
+ get_option( 'eduadmin-api-key' ); -if ( ! $api_key || empty( $api_key ) ) { - echo 'Please complete the configuration: EduAdmin - Api Authentication'; +if ( ! EDU()->api_connection ) { + echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' ); } else { - include 'list-options.php'; - ?> -
- EduAdmin - Api Authentication'; + } else { + include 'list-options.php'; ?> -
- + +
+ get_option( 'eduadmin-api-key' ); -if ( ! $api_key || empty( $api_key ) ) { - echo 'Please complete the configuration: EduAdmin - Api Authentication'; +if ( ! EDU()->api_connection ) { + echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' ); } else { - include 'list-options.php'; - ?> -
-
- + if ( ! $api_key || empty( $api_key ) ) { + echo 'Please complete the configuration: EduAdmin - Api Authentication'; + } else { + include 'list-options.php'; + ?> +
+
+ +
-
- query; $api_key = EDU()->get_option( 'eduadmin-api-key' ); -if ( ! empty( EDU()->session['eduadmin-loginUser'] ) && ! empty( EDU()->session['eduadmin-loginUser']->Contact ) && ! empty( EDU()->session['eduadmin-loginUser']->Contact->PersonId ) && 0 !== EDU()->session['eduadmin-loginUser']->Contact->PersonId ) { - if ( isset( $q['edu-login'] ) || isset( $q['edu-profile'] ) ) { - require_once 'profile.php'; - } elseif ( isset( $q['edu-bookings'] ) ) { - require_once 'bookings.php'; - } elseif ( isset( $q['edu-limiteddiscount'] ) ) { - require_once 'limited-discount.php'; - } elseif ( isset( $q['edu-certificates'] ) ) { - require_once 'certificates.php'; - } elseif ( isset( $q['edu-password'] ) ) { - require_once 'change-password.php'; +if ( ! EDU()->api_connection ) { + echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' ); +} else { + if ( ! empty( EDU()->session['eduadmin-loginUser'] ) && ! empty( EDU()->session['eduadmin-loginUser']->Contact ) && ! empty( EDU()->session['eduadmin-loginUser']->Contact->PersonId ) && 0 !== EDU()->session['eduadmin-loginUser']->Contact->PersonId ) { + if ( isset( $q['edu-login'] ) || isset( $q['edu-profile'] ) ) { + require_once 'profile.php'; + } elseif ( isset( $q['edu-bookings'] ) ) { + require_once 'bookings.php'; + } elseif ( isset( $q['edu-limiteddiscount'] ) ) { + require_once 'limited-discount.php'; + } elseif ( isset( $q['edu-certificates'] ) ) { + require_once 'certificates.php'; + } elseif ( isset( $q['edu-password'] ) ) { + require_once 'change-password.php'; + } else { + require_once 'profile.php'; + } } else { - require_once 'profile.php'; + require_once 'login-page.php'; } -} else { - require_once 'login-page.php'; } $out = ob_get_clean(); diff --git a/content/template/programme/book.php b/content/template/programme/book.php index 997b06a4..e9a21702 100644 --- a/content/template/programme/book.php +++ b/content/template/programme/book.php @@ -1,649 +1,654 @@ '; - foreach ( $error_list as $error ) { - ?> -
- -
- '; - } else { - $ebi = $GLOBALS['edubookinginfo']; - do_action( 'eduadmin-processbooking', $ebi ); - do_action( 'eduadmin-bookingcompleted' ); - } +if ( ! EDU()->api_connection ) { + echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' ); } else { - if ( EDU()->is_checked( 'eduadmin-useBookingFormFromApi', false ) ) { - if ( ! empty( $programme['BookingFormUrl'] ) ) { - ?> - - get_option( 'eduadmin-booking-form-javascript', '' ) ) ) ) { + if ( ! empty( $_POST['edu-valid-form'] ) && wp_verify_nonce( $_POST['edu-valid-form'], 'edu-booking-confirm' ) && isset( $_POST['act'] ) && 'bookProgramme' === sanitize_text_field( $_POST['act'] ) ) { + $error_list = apply_filters( 'edu-booking-error', array() ); + if ( ! empty( $error_list ) ) { + echo '
'; + foreach ( $error_list as $error ) { ?> - +
+ +
'; } else { - echo _x( 'The booking form needs configuration in EduAdmin before this works.', 'frontend', 'eduadmin-booking' ); + $ebi = $GLOBALS['edubookinginfo']; + do_action( 'eduadmin-processbooking', $ebi ); + do_action( 'eduadmin-bookingcompleted' ); } + } else { + if ( EDU()->is_checked( 'eduadmin-useBookingFormFromApi', false ) ) { + if ( ! empty( $programme['BookingFormUrl'] ) ) { + ?> + + get_option( 'eduadmin-booking-form-javascript', '' ) ) ) ) { + ?> + + session['eduadmin-loginUser'] ) ) { - $user = EDU()->session['eduadmin-loginUser']; - $contact = $user->Contact; - $customer = $user->Customer; - } + $discount_percent = 0.0; + $participant_discount_percent = 0.0; + $customer_invoice_email = ''; - $no_invoice_free_events = EDU()->is_checked( 'eduadmin-noInvoiceFreeEvents', false ); + if ( isset( EDU()->session['eduadmin-loginUser'] ) ) { + $user = EDU()->session['eduadmin-loginUser']; + $contact = $user->Contact; + $customer = $user->Customer; + } - $first_price = current( $programme['PriceNames'] ); + $no_invoice_free_events = EDU()->is_checked( 'eduadmin-noInvoiceFreeEvents', false ); - $show_invoice_email = isset( $attributes['hideinvoiceemailfield'] ) ? false === $attributes['hideinvoiceemailfield'] : ! EDU()->is_checked( 'eduadmin-hideInvoiceEmailField', false ); - $force_show_invoice_information = isset( $attributes['showinvoiceinformation'] ) ? false === $attributes['showinvoiceinformation'] : EDU()->is_checked( 'eduadmin-showInvoiceInformation', false ); + $first_price = current( $programme['PriceNames'] ); - $block_edit_if_logged_in = EDU()->is_checked( 'eduadmin-blockEditIfLoggedIn', true ); - $__block = ( $block_edit_if_logged_in && isset( $contact->PersonId ) && 0 !== $contact->PersonId ); + $show_invoice_email = isset( $attributes['hideinvoiceemailfield'] ) ? false === $attributes['hideinvoiceemailfield'] : ! EDU()->is_checked( 'eduadmin-hideInvoiceEmailField', false ); + $force_show_invoice_information = isset( $attributes['showinvoiceinformation'] ) ? false === $attributes['showinvoiceinformation'] : EDU()->is_checked( 'eduadmin-showInvoiceInformation', false ); - $questions = EDUAPI()->REST->ProgrammeStart->BookingQuestions( $programme['ProgrammeStartId'], true ); + $block_edit_if_logged_in = EDU()->is_checked( 'eduadmin-blockEditIfLoggedIn', true ); + $__block = ( $block_edit_if_logged_in && isset( $contact->PersonId ) && 0 !== $contact->PersonId ); - $booking_questions = $questions['BookingQuestions']; - $participant_questions = $questions['ParticipantQuestions']; + $questions = EDUAPI()->REST->ProgrammeStart->BookingQuestions( $programme['ProgrammeStartId'], true ); - ?> -
- - - - -
- - -
- + $booking_questions = $questions['BookingQuestions']; + $participant_questions = $questions['ParticipantQuestions']; -
-

- -

-
- +
+ + + + +
+ + +
+ - if ( ! empty( $customer->BillingInfo ) ) { - $billing_customer = $customer->BillingInfo; - } else { - $billing_customer = new EduAdmin_Data_BillingInfo(); - } - if ( isset( $contact->PersonId ) && 0 !== $contact->PersonId ) { - echo ''; - } - if ( isset( $customer->CustomerId ) && 0 !== $customer->CustomerId ) { - echo ''; - } - ?> -
-
-

- - - - - get_option( 'eduadmin-loginField', 'Email' ); ?> - - - - is_checked( 'eduadmin-useLogin', false ) && ! $contact->CanLogin ) { ?> - - -
- +
+

+ +

-
-
OData->CustomFields->Search( - null, - 'ShowOnWeb and CustomFieldOwner eq \'Person\'', - 'CustomFieldAlternatives', - 'SortIndex' - )['value']; - foreach ( $contact_custom_fields as $custom_field ) { - $data = null; - if ( null !== $contact && null !== $contact->CustomFields ) { - foreach ( $contact->CustomFields as $cf ) { - if ( $cf->CustomFieldId === $custom_field['CustomFieldId'] ) { - switch ( $cf->CustomFieldType ) { - case 'Checkbox': - $data = $cf->CustomFieldChecked; - break; - case 'Dropdown': - $data = $cf->CustomFieldAlternativeId; - break; - default: - $data = $cf->CustomFieldValue; - break; - } - break; - } - } - } - render_attribute( $custom_field, false, 'contact', $data ); + if ( ! empty( $customer->BillingInfo ) ) { + $billing_customer = $customer->BillingInfo; + } else { + $billing_customer = new EduAdmin_Data_BillingInfo(); + } + if ( isset( $contact->PersonId ) && 0 !== $contact->PersonId ) { + echo ''; + } + if ( isset( $customer->CustomerId ) && 0 !== $customer->CustomerId ) { + echo ''; } - ?> -
-
-

- - 0 ) ) { - ?> - -