Plugin Directory

Changeset 3182069


Ignore:
Timestamp:
11/05/2024 08:06:45 AM (14 months ago)
Author:
mnchga
Message:

Committing changes for 5.3.0

Location:
eduadmin-booking/trunk
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • eduadmin-booking/trunk/CHANGELOG.md

    r3181493 r3182069  
    22
    33All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
     4
     5## [5.3.0](https://github.com/MultinetInteractive/EduAdmin-WordPress/compare/v5.2.0...v5.3.0) (2024-11-05)
     6
     7
     8### Features
     9
     10* 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)
    411
    512## [5.2.0](https://github.com/MultinetInteractive/EduAdmin-WordPress/compare/v5.1.3...v5.2.0) (2024-11-04)
  • eduadmin-booking/trunk/PLUGIN-CHECKSUM

    r3181536 r3182069  
    1 c33fd5286522bad5382137445a5dd118
     15cd3f4c5d7825087108a651e5f73d89f
  • eduadmin-booking/trunk/content/template/bookingTemplate/template_A.php

    r2967419 r3182069  
    44global $wp_query;
    55$api_key = EDU()->get_option( 'eduadmin-api-key' );
    6 
    7 if ( ! $api_key || empty( $api_key ) ) {
    8     echo 'Please complete the configuration: <a href="' . esc_url( admin_url() . 'admin.php?page=eduadmin-settings' ) . '">EduAdmin - Api Authentication</a>';
     6if ( ! EDU()->api_connection ) {
     7    echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' );
    98} else {
    10     include_once 'course-info.php';
    11 
    12     if ( EDU()->is_checked( 'eduadmin-useBookingFormFromApi', false ) ) {
    13         if ( ! empty( $event['BookingFormUrl'] ) ) {
    14             ?>
    15             <iframe id="eduadmin-booking-frame" class="edu-bookingform-page-frame"
    16                     src="<?php echo esc_attr( $event['BookingFormUrl'] ); ?>"></iframe>
    17             <?php
    18             if ( ! key_exists( 'eduadmin-booking-form-javascript-set', $GLOBALS ) && ! empty( trim( EDU()->get_option( 'eduadmin-booking-form-javascript', '' ) ) ) ) {
     9    if ( ! $api_key || empty( $api_key ) ) {
     10        echo 'Please complete the configuration: <a href="' . esc_url( admin_url() . 'admin.php?page=eduadmin-settings' ) . '">EduAdmin - Api Authentication</a>';
     11    } else {
     12        include_once 'course-info.php';
     13
     14        if ( EDU()->is_checked( 'eduadmin-useBookingFormFromApi', false ) ) {
     15            if ( ! empty( $event['BookingFormUrl'] ) ) {
    1916                ?>
    20                 <script type="text/javascript">
    21                     <?php echo EDU()->get_option( 'eduadmin-booking-form-javascript', '' ); ?>
    22                 </script>
     17                <iframe id="eduadmin-booking-frame" class="edu-bookingform-page-frame"
     18                        src="<?php echo esc_attr( $event['BookingFormUrl'] ); ?>"></iframe>
    2319                <?php
    24                 $GLOBALS['eduadmin-booking-form-javascript-set'] = true;
    25             }
    26         } else {
    27             echo _x( 'The booking form needs configuration in EduAdmin before this works.', 'frontend', 'eduadmin-booking' );
     20                if ( ! key_exists( 'eduadmin-booking-form-javascript-set', $GLOBALS ) && ! empty( trim( EDU()->get_option( 'eduadmin-booking-form-javascript', '' ) ) ) ) {
     21                    ?>
     22                    <script type="text/javascript">
     23                        <?php echo EDU()->get_option( 'eduadmin-booking-form-javascript', '' ); ?>
     24                    </script>
     25                    <?php
     26                    $GLOBALS['eduadmin-booking-form-javascript-set'] = true;
     27                }
     28            } else {
     29                echo _x( 'The booking form needs configuration in EduAdmin before this works.', 'frontend', 'eduadmin-booking' );
     30            }
     31
     32            return;
    2833        }
    2934
    30         return;
    31     }
    32 
    33     $currency = EDU()->get_option( 'eduadmin-currency', 'SEK' );
    34 
    35     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'] ) ) {
    36         $error_list = apply_filters( 'edu-booking-error', array() );
    37         if ( ! empty( $error_list ) ) {
    38             echo '<div class="eduadmin">';
    39             foreach ( $error_list as $error ) {
    40                 ?>
    41                 <div class="edu-modal warning">
    42                     <?php echo esc_html( $error ); ?>
    43                 </div>
    44                 <?php
    45             }
    46             do_action( 'eduadmin-bookingerror', $error_list );
    47             echo '</div>';
    48         } else {
    49             if ( ! empty( $GLOBALS['edubookinginfo'] ) ) {
    50                 $ebi = $GLOBALS['edubookinginfo'];
     35        $currency = EDU()->get_option( 'eduadmin-currency', 'SEK' );
     36
     37        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'] ) ) {
     38            $error_list = apply_filters( 'edu-booking-error', array() );
     39            if ( ! empty( $error_list ) ) {
     40                echo '<div class="eduadmin">';
     41                foreach ( $error_list as $error ) {
     42                    ?>
     43                    <div class="edu-modal warning">
     44                        <?php echo esc_html( $error ); ?>
     45                    </div>
     46                    <?php
     47                }
     48                do_action( 'eduadmin-bookingerror', $error_list );
     49                echo '</div>';
    5150            } else {
    52                 $booking_id           = intval( $_GET['booking_id'] );
    53                 $programme_booking_id = intval( $_GET['programme_booking_id'] );
    54 
    55                 if ( $booking_id > 0 ) {
    56                     $event_booking = EDUAPI()->OData->Bookings->GetItem(
    57                         $booking_id,
     51                if ( ! empty( $GLOBALS['edubookinginfo'] ) ) {
     52                    $ebi = $GLOBALS['edubookinginfo'];
     53                } else {
     54                    $booking_id           = intval( $_GET['booking_id'] );
     55                    $programme_booking_id = intval( $_GET['programme_booking_id'] );
     56
     57                    if ( $booking_id > 0 ) {
     58                        $event_booking = EDUAPI()->OData->Bookings->GetItem(
     59                            $booking_id,
     60                            null,
     61                            'Customer($select=CustomerId;),ContactPerson($select=PersonId;),OrderRows',
     62                            false
     63                        );
     64                    } elseif ( $programme_booking_id > 0 ) {
     65                        $event_booking = EDUAPI()->OData->ProgrammeBookings->GetItem(
     66                            $programme_booking_id,
     67                            null,
     68                            'Customer($select=CustomerId;),ContactPerson($select=PersonId;),OrderRows',
     69                            false
     70                        );
     71                    }
     72
     73                    if ( $event_booking['@curl']['http_code'] === 404 ) {
     74                        // The booking does not exist any longer (probably removed)
     75                        include_once __DIR__ . '/views/booking-deleted.php';
     76
     77                        return;
     78                    }
     79
     80                    $_customer = EDUAPI()->OData->Customers->GetItem(
     81                        $event_booking['Customer']['CustomerId'],
    5882                        null,
    59                         'Customer($select=CustomerId;),ContactPerson($select=PersonId;),OrderRows',
     83                        "BillingInfo",
    6084                        false
    6185                    );
    62                 } elseif ( $programme_booking_id > 0 ) {
    63                     $event_booking = EDUAPI()->OData->ProgrammeBookings->GetItem(
    64                         $programme_booking_id,
     86
     87                    $_contact = EDUAPI()->OData->Persons->GetItem(
     88                        $event_booking['ContactPerson']['PersonId'],
    6589                        null,
    66                         'Customer($select=CustomerId;),ContactPerson($select=PersonId;),OrderRows',
     90                        null,
    6791                        false
    6892                    );
     93
     94                    $ebi                       = new EduAdmin_BookingInfo( $event_booking, $_customer, $_contact );
     95                    $GLOBALS['edubookinginfo'] = $ebi;
    6996                }
    70 
    71                 if ( $event_booking['@curl']['http_code'] === 404 ) {
    72                     // The booking does not exist any longer (probably removed)
    73                     include_once __DIR__ . '/views/booking-deleted.php';
    74 
    75                     return;
     97                do_action( 'eduadmin-processbooking', $ebi );
     98                do_action( 'eduadmin-bookingcompleted' );
     99            }
     100        } 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'] ) ) {
     101            do_action( 'eduadmin-bookingcompleted' );
     102        } else {
     103            $contact  = new EduAdmin_Data_ContactPerson();
     104            $customer = new EduAdmin_Data_Customer();
     105
     106            $discount_percent             = 0.0;
     107            $participant_discount_percent = 0.0;
     108            $customer_invoice_email       = '';
     109
     110            if ( isset( EDU()->session['eduadmin-loginUser'] ) ) {
     111                $user     = EDU()->session['eduadmin-loginUser'];
     112                $contact  = $user->Contact;
     113                $customer = $user->Customer;
     114            }
     115
     116            $unique_prices = array();
     117            if ( ! $GLOBALS['noAvailableDates'] ) {
     118                foreach ( $event['PriceNames'] as $price ) {
     119                    $unique_prices[ $price['PriceNameDescription'] ] = $price;
    76120                }
    77 
    78                 $_customer = EDUAPI()->OData->Customers->GetItem(
    79                     $event_booking['Customer']['CustomerId'],
    80                     null,
    81                     "BillingInfo",
    82                     false
    83                 );
    84 
    85                 $_contact = EDUAPI()->OData->Persons->GetItem(
    86                     $event_booking['ContactPerson']['PersonId'],
    87                     null,
    88                     null,
    89                     false
    90                 );
    91 
    92                 $ebi                       = new EduAdmin_BookingInfo( $event_booking, $_customer, $_contact );
    93                 $GLOBALS['edubookinginfo'] = $ebi;
    94             }
    95             do_action( 'eduadmin-processbooking', $ebi );
    96             do_action( 'eduadmin-bookingcompleted' );
    97         }
    98     } 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'] ) ) {
    99         do_action( 'eduadmin-bookingcompleted' );
    100     } else {
    101         $contact  = new EduAdmin_Data_ContactPerson();
    102         $customer = new EduAdmin_Data_Customer();
    103 
    104         $discount_percent             = 0.0;
    105         $participant_discount_percent = 0.0;
    106         $customer_invoice_email       = '';
    107 
    108         if ( isset( EDU()->session['eduadmin-loginUser'] ) ) {
    109             $user     = EDU()->session['eduadmin-loginUser'];
    110             $contact  = $user->Contact;
    111             $customer = $user->Customer;
    112         }
    113 
    114         $unique_prices = array();
    115         if ( ! $GLOBALS['noAvailableDates'] ) {
    116             foreach ( $event['PriceNames'] as $price ) {
    117                 $unique_prices[ $price['PriceNameDescription'] ] = $price;
    118             }
    119         }
    120 
    121         // PriceNameVat
    122         $first_price = current( $unique_prices );
    123 
    124         $hide_sub_event_date_info = EDU()->is_checked( 'eduadmin-hideSubEventDateTime', false );
    125         ?>
    126         <div class="eduadmin booking-page"
    127              data-courseid="<?php echo esc_attr( $selected_course['CourseTemplateId'] ); ?>"
    128              data-eventid="<?php echo( isset( $_REQUEST['eid'] ) ? esc_attr( sanitize_text_field( $_REQUEST['eid'] ) ) : '' ); ?>">
    129             <form action="" method="post" id="edu-booking-form">
    130                 <input type="hidden" name="act" value="bookCourse" />
    131                 <input type="hidden" name="edu-valid-form"
    132                        value="<?php echo esc_attr( wp_create_nonce( 'edu-booking-confirm' ) ); ?>" />
    133                 <div class="not-a-good-idea">
    134                     <input type="text" name="username" />
    135                     <input type="text" name="email" />
    136                 </div>
    137                 <a href="javascript://" onclick="eduGlobalMethods.GoBack('../', event);"
    138                    class="backLink"><?php echo esc_html_x( '« Go back', 'frontend', 'eduadmin-booking' ); ?></a>
    139 
    140                 <div class="title">
    141                     <?php if ( ! empty( $selected_course['ImageUrl'] ) ) : ?>
    142                         <img class="courseImage" src="<?php echo esc_url( $selected_course['ImageUrl'] ); ?>" />
    143                     <?php endif; ?>
    144                     <h1 class="courseTitle">
    145                         <?php echo esc_html( $name ); ?>
    146                     </h1>
    147                     <?php require_once 'event-selector.php'; ?>
    148                 </div>
    149                 <?php
    150                 if ( ! $GLOBALS['noAvailableDates'] )
    151                 {
    152                 if ( isset( EDU()->session['eduadmin-loginUser'] ) ) {
    153                     $user_val = '';
    154                     if ( isset( $contact->PersonId ) && $contact->PersonId > 0 ) {
    155                         $user_val = trim( $contact->FirstName . ' ' . $contact->LastName );
    156                     } else {
    157                         $selected_login_field = EDU()->get_option( 'eduadmin-loginField', 'Email' );
    158                         switch ( $selected_login_field ) {
    159                             case 'Email':
    160                                 $user_val = $contact->Email;
    161                                 break;
    162                             case 'CivicRegistrationNumber':
    163                                 $user_val = $contact->CivicRegistrationNumber;
    164                                 break;
    165                             default:
    166                                 $user_val = $contact->Email;
    167                                 break;
     121            }
     122
     123            // PriceNameVat
     124            $first_price = current( $unique_prices );
     125
     126            $hide_sub_event_date_info = EDU()->is_checked( 'eduadmin-hideSubEventDateTime', false );
     127            ?>
     128            <div class="eduadmin booking-page"
     129                 data-courseid="<?php echo esc_attr( $selected_course['CourseTemplateId'] ); ?>"
     130                 data-eventid="<?php echo( isset( $_REQUEST['eid'] ) ? esc_attr( sanitize_text_field( $_REQUEST['eid'] ) ) : '' ); ?>">
     131                <form action="" method="post" id="edu-booking-form">
     132                    <input type="hidden" name="act" value="bookCourse" />
     133                    <input type="hidden" name="edu-valid-form"
     134                           value="<?php echo esc_attr( wp_create_nonce( 'edu-booking-confirm' ) ); ?>" />
     135                    <div class="not-a-good-idea">
     136                        <input type="text" name="username" />
     137                        <input type="text" name="email" />
     138                    </div>
     139                    <a href="javascript://" onclick="eduGlobalMethods.GoBack('../', event);"
     140                       class="backLink"><?php echo esc_html_x( '« Go back', 'frontend', 'eduadmin-booking' ); ?></a>
     141
     142                    <div class="title">
     143                        <?php if ( ! empty( $selected_course['ImageUrl'] ) ) : ?>
     144                            <img class="courseImage" src="<?php echo esc_url( $selected_course['ImageUrl'] ); ?>" />
     145                        <?php endif; ?>
     146                        <h1 class="courseTitle">
     147                            <?php echo esc_html( $name ); ?>
     148                        </h1>
     149                        <?php require_once 'event-selector.php'; ?>
     150                    </div>
     151                    <?php
     152                    if ( ! $GLOBALS['noAvailableDates'] )
     153                    {
     154                    if ( isset( EDU()->session['eduadmin-loginUser'] ) ) {
     155                        $user_val = '';
     156                        if ( isset( $contact->PersonId ) && $contact->PersonId > 0 ) {
     157                            $user_val = trim( $contact->FirstName . ' ' . $contact->LastName );
     158                        } else {
     159                            $selected_login_field = EDU()->get_option( 'eduadmin-loginField', 'Email' );
     160                            switch ( $selected_login_field ) {
     161                                case 'Email':
     162                                    $user_val = $contact->Email;
     163                                    break;
     164                                case 'CivicRegistrationNumber':
     165                                    $user_val = $contact->CivicRegistrationNumber;
     166                                    break;
     167                                default:
     168                                    $user_val = $contact->Email;
     169                                    break;
     170                            }
    168171                        }
    169                     }
    170                     $surl     = get_home_url();
    171                     $cat      = EDU()->get_option( 'eduadmin-rewriteBaseUrl' );
    172                     $base_url = $surl . '/' . $cat;
    173                     ?>
    174                     <div class="notUserCheck">
    175                         <i>
    176                             <?php
    177                             /* translators: 1: User display name 2: Beginning of link 3: End of link */
    178                             echo wp_kses( sprintf( _x( 'Not <b>%1$s</b>? %2$sLog out%3$s', 'frontend', 'eduadmin-booking' ), esc_html( $user_val ), '<a href="' . esc_url( $base_url . '/profile/logout' ) . '">', '</a>' ), wp_kses_allowed_html( 'post' ) );
    179                             ?>
    180                         </i>
    181                     </div>
    182                     <?php
    183                 }
    184                 ?>
    185                 <?php
    186                 $no_invoice_free_events         = EDU()->is_checked( 'eduadmin-noInvoiceFreeEvents', false );
    187                 $single_person_booking          = EDU()->is_checked( 'eduadmin-singlePersonBooking', false );
    188                 $show_invoice_email             = isset( $attributes['hideinvoiceemailfield'] ) ? false == $attributes['hideinvoiceemailfield'] : ! EDU()->is_checked( 'eduadmin-hideInvoiceEmailField', false );
    189                 $force_show_invoice_information = isset( $attributes['showinvoiceinformation'] ) ? false == $attributes['showinvoiceinformation'] : EDU()->is_checked( 'eduadmin-showInvoiceInformation', false );
    190                 if ( $single_person_booking ) {
    191                     include_once 'single-person-booking.php';
    192                 } else {
    193                     $field_order = EDU()->get_option( 'eduadmin-fieldOrder', 'contact_customer' );
    194                     if ( 'contact_customer' === $field_order ) {
    195                         include_once 'contact-view.php';
    196                         include_once 'customer-view.php';
    197                     } elseif ( 'customer_contact' === $field_order ) {
    198                         include_once 'customer-view.php';
    199                         include_once 'contact-view.php';
    200                     }
    201                     include_once 'participant-view.php';
    202                 }
    203                 ?>
    204                 <?php if ( 'selectWholeEvent' === EDU()->get_option( 'eduadmin-selectPricename', 'firstPublic' ) ) : ?>
    205                     <div class="priceView">
    206                         <?php echo esc_html_x( 'Price name', 'frontend', 'eduadmin-booking' ); ?>
    207                         <select id="edu-pricename" name="edu-pricename" required class="edudropdown edu-pricename"
    208                                 onchange="eduBookingView.UpdatePrice();">
    209                             <option data-price="0"
    210                                     value=""><?php echo esc_html_x( 'Choose price', 'frontend', 'eduadmin-booking' ); ?></option>
    211                             <?php foreach ( $event['PriceNames'] as $price ) : ?>
    212                                 <option data-price="<?php echo esc_attr( $price['Price'] ); ?>"
    213                                         date-discountpercent="<?php echo esc_attr( $price['DiscountPercent'] ); ?>"
    214                                         data-pricelnkid="<?php echo esc_attr( $price['PriceNameId'] ); ?>"
    215                                         data-maxparticipants="<?php echo esc_attr( $price['MaxParticipantNumber'] ); ?>"
    216                                         data-currentparticipants="<?php echo esc_attr( $price['NumberOfParticipants'] ); ?>"
    217                                     <?php if ( ! empty( $price['MaxParticipantNumber'] ) && $price['NumberOfParticipants'] >= $price['MaxParticipantNumber'] ) { ?>
    218                                         disabled
    219                                     <?php } ?>
    220                                         value="<?php echo esc_attr( $price['PriceNameId'] ); ?>">
    221                                     <?php echo esc_html( $price['PriceNameDescription'] ); ?>
    222                                     (<?php echo esc_html( edu_get_price( $price['Price'], $selected_course['ParticipantVat'] ) ); ?>
    223                                     )
    224                                 </option>
    225                             <?php endforeach; ?>
    226                         </select>
    227                     </div>
    228                 <?php endif; ?>
    229                 <?php
    230                 include_once 'question-view.php';
    231                 include_once 'discount-code.php';
    232                 include_once 'limited-discount-view.php';
    233                 include_once __DIR__ . '/../payment-methods.php';
    234                 include_once __DIR__ . '/../recaptcha-form.php';
    235                 eduadmin_render_payment_methods( $event );
    236                 eduadmin_render_recaptcha_form();
    237                 ?>
    238                 <div class="submitView">
    239                     <?php if ( EDU()->is_checked( 'eduadmin-useBookingTermsCheckbox', false ) && $link = EDU()->get_option( 'eduadmin-bookingTermsLink', '' ) ): ?>
    240                         <div class="confirmTermsHolder">
    241                             <label>
    242                                 <input type="checkbox" id="confirmTerms" name="confirmTerms" value="agree" />
     172                        $surl     = get_home_url();
     173                        $cat      = EDU()->get_option( 'eduadmin-rewriteBaseUrl' );
     174                        $base_url = $surl . '/' . $cat;
     175                        ?>
     176                        <div class="notUserCheck">
     177                            <i>
    243178                                <?php
    244                                 /* translators: 1: Start of link 2: End of link */
    245                                 echo wp_kses( sprintf( _x( 'I agree to the %1$sTerms and Conditions%2$s', 'frontend', 'eduadmin-booking' ), '<a href="' . $link . '" target="_blank">', '</a>' ), wp_kses_allowed_html( 'post' ) );
     179                                /* translators: 1: User display name 2: Beginning of link 3: End of link */
     180                                echo wp_kses( sprintf( _x( 'Not <b>%1$s</b>? %2$sLog out%3$s', 'frontend', 'eduadmin-booking' ), esc_html( $user_val ), '<a href="' . esc_url( $base_url . '/profile/logout' ) . '">', '</a>' ), wp_kses_allowed_html( 'post' ) );
    246181                                ?>
    247                             </label>
    248                         </div>
    249                     <?php endif; ?>
    250                     <div class="sumTotal">
    251                         <?php echo esc_html_x( 'Total sum:', 'frontend', 'eduadmin-booking' ); ?>
    252                         <span id="sumValue" class="sumValue"></span>
    253                     </div>
    254                     <?php if ( 0 === intval( $event['MaxParticipantNumber'] ) || 0 !== $event['ParticipantNumberLeft'] ) : ?>
    255                         <input type="submit" class="bookButton cta-btn" id="edu-book-btn"
    256                                onclick="eduBookingView.UpdatePrice(); var validated = eduBookingView.CheckValidation(false, false); return validated;"
    257                                value="<?php echo esc_attr_x( 'Book now', 'frontend', 'eduadmin-booking' ); ?>" />
    258                     <?php else : ?>
    259                         <div class="bookButton neutral-btn cta-disabled">
    260                             <?php echo esc_html_x( 'No free spots left on this event', 'frontend', 'eduadmin-booking' ); ?>
    261                         </div>
    262                     <?php endif; ?>
    263                     <div class="edu-modal warning" id="edu-warning-pricecheck"></div>
    264                     <div class="edu-modal warning" id="edu-warning-recaptcha">
    265                         <?php echo esc_html_x( 'You must confirm that you are not a bot before continuing.', 'frontend', 'eduadmin-booking' ); ?>
    266                     </div>
    267                     <div class="edu-modal warning" id="edu-warning-terms">
    268                         <?php echo esc_html_x( 'You must accept Terms and Conditions to continue.', 'frontend', 'eduadmin-booking' ); ?>
    269                     </div>
    270                     <div class="edu-modal warning" id="edu-warning-no-participants">
    271                         <?php echo esc_html_x( 'You must add some participants.', 'frontend', 'eduadmin-booking' ); ?>
    272                     </div>
    273                     <div class="edu-modal warning" id="edu-warning-missing-participants">
    274                         <?php echo esc_html_x( 'One or more participants is missing a name.', 'frontend', 'eduadmin-booking' ); ?>
    275                     </div>
    276                     <div class="edu-modal warning" id="edu-warning-missing-civicregno">
    277                         <?php echo esc_html_x( 'One or more participants is missing their civic registration number.', 'frontend', 'eduadmin-booking' ); ?>
    278                     </div>
    279                     <?php
    280                     $error_list = apply_filters( 'edu-booking-error', array() );
    281                     foreach ( $error_list as $error ) {
    282                         ?>
    283                         <div class="edu-modal warning">
    284                             <?php esc_html( $error ); ?>
     182                            </i>
    285183                        </div>
    286184                        <?php
    287185                    }
    288186                    ?>
    289                 </div>
    290             </form>
    291         </div>
    292 
    293         <?php
    294         $original_title = get_the_title();
    295         $new_title      = $name . ' | ' . $original_title;
    296 
    297         $discount_value = 0.0;
    298         if ( 0 !== $participant_discount_percent ) {
    299             $discount_value = ( $participant_discount_percent / 100 ) * $first_price['Price'];
     187                    <?php
     188                    $no_invoice_free_events         = EDU()->is_checked( 'eduadmin-noInvoiceFreeEvents', false );
     189                    $single_person_booking          = EDU()->is_checked( 'eduadmin-singlePersonBooking', false );
     190                    $show_invoice_email             = isset( $attributes['hideinvoiceemailfield'] ) ? false == $attributes['hideinvoiceemailfield'] : ! EDU()->is_checked( 'eduadmin-hideInvoiceEmailField', false );
     191                    $force_show_invoice_information = isset( $attributes['showinvoiceinformation'] ) ? false == $attributes['showinvoiceinformation'] : EDU()->is_checked( 'eduadmin-showInvoiceInformation', false );
     192                    if ( $single_person_booking ) {
     193                        include_once 'single-person-booking.php';
     194                    } else {
     195                        $field_order = EDU()->get_option( 'eduadmin-fieldOrder', 'contact_customer' );
     196                        if ( 'contact_customer' === $field_order ) {
     197                            include_once 'contact-view.php';
     198                            include_once 'customer-view.php';
     199                        } elseif ( 'customer_contact' === $field_order ) {
     200                            include_once 'customer-view.php';
     201                            include_once 'contact-view.php';
     202                        }
     203                        include_once 'participant-view.php';
     204                    }
     205                    ?>
     206                    <?php if ( 'selectWholeEvent' === EDU()->get_option( 'eduadmin-selectPricename', 'firstPublic' ) ) : ?>
     207                        <div class="priceView">
     208                            <?php echo esc_html_x( 'Price name', 'frontend', 'eduadmin-booking' ); ?>
     209                            <select id="edu-pricename" name="edu-pricename" required class="edudropdown edu-pricename"
     210                                    onchange="eduBookingView.UpdatePrice();">
     211                                <option data-price="0"
     212                                        value=""><?php echo esc_html_x( 'Choose price', 'frontend', 'eduadmin-booking' ); ?></option>
     213                                <?php foreach ( $event['PriceNames'] as $price ) : ?>
     214                                    <option data-price="<?php echo esc_attr( $price['Price'] ); ?>"
     215                                            date-discountpercent="<?php echo esc_attr( $price['DiscountPercent'] ); ?>"
     216                                            data-pricelnkid="<?php echo esc_attr( $price['PriceNameId'] ); ?>"
     217                                            data-maxparticipants="<?php echo esc_attr( $price['MaxParticipantNumber'] ); ?>"
     218                                            data-currentparticipants="<?php echo esc_attr( $price['NumberOfParticipants'] ); ?>"
     219                                        <?php if ( ! empty( $price['MaxParticipantNumber'] ) && $price['NumberOfParticipants'] >= $price['MaxParticipantNumber'] ) { ?>
     220                                            disabled
     221                                        <?php } ?>
     222                                            value="<?php echo esc_attr( $price['PriceNameId'] ); ?>">
     223                                        <?php echo esc_html( $price['PriceNameDescription'] ); ?>
     224                                        (<?php echo esc_html( edu_get_price( $price['Price'], $selected_course['ParticipantVat'] ) ); ?>
     225                                        )
     226                                    </option>
     227                                <?php endforeach; ?>
     228                            </select>
     229                        </div>
     230                    <?php endif; ?>
     231                    <?php
     232                    include_once 'question-view.php';
     233                    include_once 'discount-code.php';
     234                    include_once 'limited-discount-view.php';
     235                    include_once __DIR__ . '/../payment-methods.php';
     236                    include_once __DIR__ . '/../recaptcha-form.php';
     237                    eduadmin_render_payment_methods( $event );
     238                    eduadmin_render_recaptcha_form();
     239                    ?>
     240                    <div class="submitView">
     241                        <?php if ( EDU()->is_checked( 'eduadmin-useBookingTermsCheckbox', false ) && $link = EDU()->get_option( 'eduadmin-bookingTermsLink', '' ) ): ?>
     242                            <div class="confirmTermsHolder">
     243                                <label>
     244                                    <input type="checkbox" id="confirmTerms" name="confirmTerms" value="agree" />
     245                                    <?php
     246                                    /* translators: 1: Start of link 2: End of link */
     247                                    echo wp_kses( sprintf( _x( 'I agree to the %1$sTerms and Conditions%2$s', 'frontend', 'eduadmin-booking' ), '<a href="' . $link . '" target="_blank">', '</a>' ), wp_kses_allowed_html( 'post' ) );
     248                                    ?>
     249                                </label>
     250                            </div>
     251                        <?php endif; ?>
     252                        <div class="sumTotal">
     253                            <?php echo esc_html_x( 'Total sum:', 'frontend', 'eduadmin-booking' ); ?>
     254                            <span id="sumValue" class="sumValue"></span>
     255                        </div>
     256                        <?php if ( 0 === intval( $event['MaxParticipantNumber'] ) || 0 !== $event['ParticipantNumberLeft'] ) : ?>
     257                            <input type="submit" class="bookButton cta-btn" id="edu-book-btn"
     258                                   onclick="eduBookingView.UpdatePrice(); var validated = eduBookingView.CheckValidation(false, false); return validated;"
     259                                   value="<?php echo esc_attr_x( 'Book now', 'frontend', 'eduadmin-booking' ); ?>" />
     260                        <?php else : ?>
     261                            <div class="bookButton neutral-btn cta-disabled">
     262                                <?php echo esc_html_x( 'No free spots left on this event', 'frontend', 'eduadmin-booking' ); ?>
     263                            </div>
     264                        <?php endif; ?>
     265                        <div class="edu-modal warning" id="edu-warning-pricecheck"></div>
     266                        <div class="edu-modal warning" id="edu-warning-recaptcha">
     267                            <?php echo esc_html_x( 'You must confirm that you are not a bot before continuing.', 'frontend', 'eduadmin-booking' ); ?>
     268                        </div>
     269                        <div class="edu-modal warning" id="edu-warning-terms">
     270                            <?php echo esc_html_x( 'You must accept Terms and Conditions to continue.', 'frontend', 'eduadmin-booking' ); ?>
     271                        </div>
     272                        <div class="edu-modal warning" id="edu-warning-no-participants">
     273                            <?php echo esc_html_x( 'You must add some participants.', 'frontend', 'eduadmin-booking' ); ?>
     274                        </div>
     275                        <div class="edu-modal warning" id="edu-warning-missing-participants">
     276                            <?php echo esc_html_x( 'One or more participants is missing a name.', 'frontend', 'eduadmin-booking' ); ?>
     277                        </div>
     278                        <div class="edu-modal warning" id="edu-warning-missing-civicregno">
     279                            <?php echo esc_html_x( 'One or more participants is missing their civic registration number.', 'frontend', 'eduadmin-booking' ); ?>
     280                        </div>
     281                        <?php
     282                        $error_list = apply_filters( 'edu-booking-error', array() );
     283                        foreach ( $error_list as $error ) {
     284                            ?>
     285                            <div class="edu-modal warning">
     286                                <?php esc_html( $error ); ?>
     287                            </div>
     288                            <?php
     289                        }
     290                        ?>
     291                    </div>
     292                </form>
     293            </div>
     294
     295            <?php
     296            $original_title = get_the_title();
     297            $new_title      = $name . ' | ' . $original_title;
     298
     299            $discount_value = 0.0;
     300            if ( 0 !== $participant_discount_percent ) {
     301                $discount_value = ( $participant_discount_percent / 100 ) * $first_price['Price'];
     302            }
     303
     304            ?>
     305            <script type="text/javascript">
     306                var pricePerParticipant = <?php echo esc_js( round( $first_price['Price'] - $discount_value, 2 ) ); ?>;
     307                var discountPerParticipant = <?php echo esc_js( round( $participant_discount_percent / 100, 2 ) ); ?>;
     308                var totalPriceDiscountPercent = <?php echo esc_js( $discount_percent ); ?>;
     309
     310                (function () {
     311                    var title = document.title;
     312                    title = title.replace('<?php echo esc_js( $original_title ); ?>', '<?php echo esc_js( $new_title ); ?>');
     313                    document.title = title;
     314                    eduBookingView.SingleParticipant = <?php echo esc_js( $single_person_booking ? "true" : "false" ); ?>;
     315                    eduBookingView.ProgrammeBooking = false;
     316                    eduBookingView.ForceContactCivicRegNo = <?php echo( $selected_course['RequireCivicRegistrationNumber'] ? 'true' : 'false' ); ?>;
     317                    eduBookingView.MaxParticipants = <?php echo esc_js( $event['ParticipantNumberLeft'] != null ? intval( $event['ParticipantNumberLeft'] ) : - 1 ); ?>;
     318                    eduBookingView.AddParticipant();
     319                    eduBookingView.CheckPrice(false);
     320                })();
     321            </script>
     322            <?php
     323            do_action( 'eduadmin-bookingform-view', $selected_course );
    300324        }
    301 
    302         ?>
    303         <script type="text/javascript">
    304             var pricePerParticipant = <?php echo esc_js( round( $first_price['Price'] - $discount_value, 2 ) ); ?>;
    305             var discountPerParticipant = <?php echo esc_js( round( $participant_discount_percent / 100, 2 ) ); ?>;
    306             var totalPriceDiscountPercent = <?php echo esc_js( $discount_percent ); ?>;
    307 
    308             (function () {
    309                 var title = document.title;
    310                 title = title.replace('<?php echo esc_js( $original_title ); ?>', '<?php echo esc_js( $new_title ); ?>');
    311                 document.title = title;
    312                 eduBookingView.SingleParticipant = <?php echo esc_js( $single_person_booking ? "true" : "false" ); ?>;
    313                 eduBookingView.ProgrammeBooking = false;
    314                 eduBookingView.ForceContactCivicRegNo = <?php echo( $selected_course['RequireCivicRegistrationNumber'] ? 'true' : 'false' ); ?>;
    315                 eduBookingView.MaxParticipants = <?php echo esc_js( $event['ParticipantNumberLeft'] != null ? intval( $event['ParticipantNumberLeft'] ) : - 1 ); ?>;
    316                 eduBookingView.AddParticipant();
    317                 eduBookingView.CheckPrice(false);
    318             })();
    319         </script>
    320         <?php
    321         do_action( 'eduadmin-bookingform-view', $selected_course );
     325        }
    322326    }
    323     }
     327    do_action( 'eduadmin-bookingform-loaded', EDU()->session['eduadmin-loginUser'] );
    324328}
    325 do_action( 'eduadmin-bookingform-loaded', EDU()->session['eduadmin-loginUser'] );
     329
    326330$out = ob_get_clean();
    327331
  • eduadmin-booking/trunk/content/template/data/ld-json.php

    r3181493 r3182069  
    11<?php
    22global $wp_query;
     3
     4if ( ! EDU()->api_connection ) {
     5    return;
     6}
    37
    48if ( ! empty( $wp_query->query_vars['courseId'] ) ) {
  • eduadmin-booking/trunk/content/template/data/ogp.php

    r3181493 r3182069  
    11<?php
    22global $wp_query;
     3
     4if ( ! EDU()->api_connection ) {
     5    return;
     6}
    37
    48if ( ! empty( $wp_query->query_vars['courseId'] ) ) {
  • eduadmin-booking/trunk/content/template/detailTemplate/template_A.php

    r2655123 r3182069  
    44$api_key = EDU()->get_option( 'eduadmin-api-key' );
    55
    6 if ( ! $api_key || empty( $api_key ) ) {
    7     echo 'Please complete the configuration: <a href="' . esc_url( admin_url() . 'admin.php?page=eduadmin-settings' ) . '">EduAdmin - Api Authentication</a>';
     6if ( ! EDU()->api_connection ) {
     7    echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' );
    88} else {
    9     include 'course-info.php';
    10     if ( ! $selected_course ) {
     9    if ( ! $api_key || empty( $api_key ) ) {
     10        echo 'Please complete the configuration: <a href="' . esc_url( admin_url() . 'admin.php?page=eduadmin-settings' ) . '">EduAdmin - Api Authentication</a>';
     11    } else {
     12        include 'course-info.php';
     13        if ( ! $selected_course ) {
     14            ?>
     15            <script type="text/javascript">location.href = '<?php echo esc_url( $base_url ); ?>';</script>
     16            <?php
     17            exit( 200 );
     18        }
    1119        ?>
    12         <script type="text/javascript">location.href = '<?php echo esc_url( $base_url ); ?>';</script>
    13         <?php
    14         exit( 200 );
    15     }
    16     ?>
    17     <div class="eduadmin detail-view" data-courseid="<?php echo esc_attr( $selected_course['CourseTemplateId'] ); ?>"
    18          data-eventid="<?php echo( isset( $_REQUEST['eid'] ) ? esc_attr( sanitize_text_field( $_REQUEST['eid'] ) ) : '' ); ?>">
    19         <a href="javascript://" onclick="eduGlobalMethods.GoBack('../', event);"
    20            class="backLink"><?php echo esc_html_x( '« Go back', 'frontend', 'eduadmin-booking' ); ?></a>
    21         <div class="title">
    22             <?php if ( ! empty( $selected_course['ImageUrl'] ) ) : ?>
    23                 <img src="<?php echo esc_url( $selected_course['ImageUrl'] ); ?>" class="courseImage" />
    24             <?php endif; ?>
    25             <h1 class="courseTitle"><?php echo esc_html( $name ); ?>
    26                 <small
    27                     class="courseLevel"><?php echo esc_html( false !== $course_level ? $course_level['Name'] : '' ); ?></small>
    28             </h1>
    29         </div>
    30         <hr />
    31         <div class="textblock">
    32             <?php
    33             if ( ! in_array( 'description', $hide_sections, true ) && ! empty( $selected_course['CourseDescription'] ) ) {
    34                 if ( $show_headers ) {
     20        <div class="eduadmin detail-view"
     21             data-courseid="<?php echo esc_attr( $selected_course['CourseTemplateId'] ); ?>"
     22             data-eventid="<?php echo( isset( $_REQUEST['eid'] ) ? esc_attr( sanitize_text_field( $_REQUEST['eid'] ) ) : '' ); ?>">
     23            <a href="javascript://" onclick="eduGlobalMethods.GoBack('../', event);"
     24               class="backLink"><?php echo esc_html_x( '« Go back', 'frontend', 'eduadmin-booking' ); ?></a>
     25            <div class="title">
     26                <?php if ( ! empty( $selected_course['ImageUrl'] ) ) : ?>
     27                    <img src="<?php echo esc_url( $selected_course['ImageUrl'] ); ?>" class="courseImage" />
     28                <?php endif; ?>
     29                <h1 class="courseTitle"><?php echo esc_html( $name ); ?>
     30                    <small
     31                        class="courseLevel"><?php echo esc_html( false !== $course_level ? $course_level['Name'] : '' ); ?></small>
     32                </h1>
     33            </div>
     34            <hr />
     35            <div class="textblock">
     36                <?php
     37                if ( ! in_array( 'description', $hide_sections, true ) && ! empty( $selected_course['CourseDescription'] ) ) {
     38                    if ( $show_headers ) {
     39                        ?>
     40                        <h3><?php echo esc_html_x( 'Course description', 'frontend', 'eduadmin-booking' ); ?></h3>
     41                    <?php } ?>
     42                    <div>
     43                        <?php
     44                        echo wp_kses_post( $selected_course['CourseDescription'] );
     45                        ?>
     46                    </div>
     47                <?php } ?>
     48                <?php
     49                if ( ! in_array( 'goal', $hide_sections, true ) && ! empty( $selected_course['CourseGoal'] ) ) {
     50                    if ( $show_headers ) {
     51                        ?>
     52                        <h3><?php echo esc_html_x( 'Course goal', 'frontend', 'eduadmin-booking' ); ?></h3>
     53                    <?php } ?>
     54                    <div>
     55                        <?php
     56                        echo wp_kses_post( $selected_course['CourseGoal'] );
     57                        ?>
     58                    </div>
     59                <?php } ?>
     60                <?php
     61                if ( ! in_array( 'target', $hide_sections, true ) && ! empty( $selected_course['TargetGroup'] ) ) {
     62                    if ( $show_headers ) {
     63                        ?>
     64                        <h3><?php echo esc_html_x( 'Target group', 'frontend', 'eduadmin-booking' ); ?></h3>
     65                    <?php } ?>
     66                    <div>
     67                        <?php
     68                        echo wp_kses_post( $selected_course['TargetGroup'] );
     69                        ?>
     70                    </div>
     71                <?php } ?>
     72                <?php
     73                if ( ! in_array( 'prerequisites', $hide_sections, true ) && ! empty( $selected_course['Prerequisites'] ) ) {
     74                    if ( $show_headers ) {
     75                        ?>
     76                        <h3><?php echo esc_html_x( 'Prerequisites', 'frontend', 'eduadmin-booking' ); ?></h3>
     77                    <?php } ?>
     78                    <div>
     79                        <?php
     80                        echo wp_kses_post( $selected_course['Prerequisites'] );
     81                        ?>
     82                    </div>
     83                <?php } ?>
     84                <?php
     85                if ( ! in_array( 'after', $hide_sections, true ) && ! empty( $selected_course['CourseAfter'] ) ) {
     86                    if ( $show_headers ) {
     87                        ?>
     88                        <h3><?php echo esc_html_x( 'After the course', 'frontend', 'eduadmin-booking' ); ?></h3>
     89                    <?php } ?>
     90                    <div>
     91                        <?php
     92                        echo wp_kses_post( $selected_course['CourseAfter'] );
     93                        ?>
     94                    </div>
     95                <?php } ?>
     96                <?php
     97                if ( ! in_array( 'quote', $hide_sections, true ) && ! empty( $selected_course['Quote'] ) ) {
     98                    if ( $show_headers ) {
     99                        ?>
     100                        <h3><?php echo esc_html_x( 'Quotes', 'frontend', 'eduadmin-booking' ); ?></h3>
     101                    <?php } ?>
     102                    <div>
     103                        <?php
     104                        echo wp_kses_post( $selected_course['Quote'] );
     105                        ?>
     106                    </div>
     107                <?php } ?>
     108            </div>
     109            <div class="eventInformation">
     110                <?php
     111                if ( ! in_array( 'time', $hide_sections, true ) && ! empty( $selected_course['StartTime'] ) && ! empty( $selected_course['EndTime'] ) ) {
    35112                    ?>
    36                     <h3><?php echo esc_html_x( 'Course description', 'frontend', 'eduadmin-booking' ); ?></h3>
    37                 <?php } ?>
    38                 <div>
     113                    <h3><?php echo esc_html_x( 'Time', 'frontend', 'eduadmin-booking' ); ?></h3>
    39114                    <?php
    40                     echo wp_kses_post( $selected_course['CourseDescription'] );
     115                    /* translators: 1: Number of days */
     116                    echo esc_html( ( $selected_course['Days'] > 0 ? sprintf( _n( '%1$d day', '%1$d days', $selected_course['Days'], 'eduadmin-booking' ), $selected_course['Days'] ) . ', ' : '' ) . $selected_course['StartTime'] . ' - ' . $selected_course['EndTime'] );
     117                }
     118
     119                if ( ! in_array( 'price', $hide_sections, true ) && ! empty( $prices ) ) {
    41120                    ?>
    42                 </div>
    43             <?php } ?>
    44             <?php
    45             if ( ! in_array( 'goal', $hide_sections, true ) && ! empty( $selected_course['CourseGoal'] ) ) {
    46                 if ( $show_headers ) {
    47                     ?>
    48                     <h3><?php echo esc_html_x( 'Course goal', 'frontend', 'eduadmin-booking' ); ?></h3>
    49                 <?php } ?>
    50                 <div>
     121                    <h3><?php echo esc_html_x( 'Price', 'frontend', 'eduadmin-booking' ); ?></h3>
    51122                    <?php
    52                     echo wp_kses_post( $selected_course['CourseGoal'] );
    53                     ?>
    54                 </div>
    55             <?php } ?>
    56             <?php
    57             if ( ! in_array( 'target', $hide_sections, true ) && ! empty( $selected_course['TargetGroup'] ) ) {
    58                 if ( $show_headers ) {
    59                     ?>
    60                     <h3><?php echo esc_html_x( 'Target group', 'frontend', 'eduadmin-booking' ); ?></h3>
    61                 <?php } ?>
    62                 <div>
    63                     <?php
    64                     echo wp_kses_post( $selected_course['TargetGroup'] );
    65                     ?>
    66                 </div>
    67             <?php } ?>
    68             <?php
    69             if ( ! in_array( 'prerequisites', $hide_sections, true ) && ! empty( $selected_course['Prerequisites'] ) ) {
    70                 if ( $show_headers ) {
    71                     ?>
    72                     <h3><?php echo esc_html_x( 'Prerequisites', 'frontend', 'eduadmin-booking' ); ?></h3>
    73                 <?php } ?>
    74                 <div>
    75                     <?php
    76                     echo wp_kses_post( $selected_course['Prerequisites'] );
    77                     ?>
    78                 </div>
    79             <?php } ?>
    80             <?php
    81             if ( ! in_array( 'after', $hide_sections, true ) && ! empty( $selected_course['CourseAfter'] ) ) {
    82                 if ( $show_headers ) {
    83                     ?>
    84                     <h3><?php echo esc_html_x( 'After the course', 'frontend', 'eduadmin-booking' ); ?></h3>
    85                 <?php } ?>
    86                 <div>
    87                     <?php
    88                     echo wp_kses_post( $selected_course['CourseAfter'] );
    89                     ?>
    90                 </div>
    91             <?php } ?>
    92             <?php
    93             if ( ! in_array( 'quote', $hide_sections, true ) && ! empty( $selected_course['Quote'] ) ) {
    94                 if ( $show_headers ) {
    95                     ?>
    96                     <h3><?php echo esc_html_x( 'Quotes', 'frontend', 'eduadmin-booking' ); ?></h3>
    97                 <?php } ?>
    98                 <div>
    99                     <?php
    100                     echo wp_kses_post( $selected_course['Quote'] );
    101                     ?>
    102                 </div>
    103             <?php } ?>
    104         </div>
    105         <div class="eventInformation">
    106             <?php
    107             if ( ! in_array( 'time', $hide_sections, true ) && ! empty( $selected_course['StartTime'] ) && ! empty( $selected_course['EndTime'] ) ) {
    108                 ?>
    109                 <h3><?php echo esc_html_x( 'Time', 'frontend', 'eduadmin-booking' ); ?></h3>
    110                 <?php
    111                 /* translators: 1: Number of days */
    112                 echo esc_html( ( $selected_course['Days'] > 0 ? sprintf( _n( '%1$d day', '%1$d days', $selected_course['Days'], 'eduadmin-booking' ), $selected_course['Days'] ) . ', ' : '' ) . $selected_course['StartTime'] . ' - ' . $selected_course['EndTime'] );
    113             }
     123                    $currency = EDU()->get_option( 'eduadmin-currency', 'SEK' );
    114124
    115             if ( ! in_array( 'price', $hide_sections, true ) && ! empty( $prices ) ) {
    116                 ?>
    117                 <h3><?php echo esc_html_x( 'Price', 'frontend', 'eduadmin-booking' ); ?></h3>
    118                 <?php
    119                 $currency = EDU()->get_option( 'eduadmin-currency', 'SEK' );
    120 
    121                 if ( 1 === count( $prices ) ) {
    122                     echo wp_kses_post( sprintf( '<div class="pricename"><span class="pricename-description">%1$s</span> <span class="pricename-price">%2$s</span></div>', current( $prices )['PriceNameDescription'], edu_get_price( current( $prices )['Price'], $selected_course['ParticipantVat'] ) ) );
    123                 } else {
    124                     foreach ( $prices as $up ) {
    125                         echo wp_kses_post( sprintf( '<div class="pricename"><span class="pricename-description">%1$s</span> <span class="pricename-price">%2$s</span></div>', $up['PriceNameDescription'], edu_get_price( $up['Price'], $selected_course['ParticipantVat'] ) ) );
     125                    if ( 1 === count( $prices ) ) {
     126                        echo wp_kses_post( sprintf( '<div class="pricename"><span class="pricename-description">%1$s</span> <span class="pricename-price">%2$s</span></div>', current( $prices )['PriceNameDescription'], edu_get_price( current( $prices )['Price'], $selected_course['ParticipantVat'] ) ) );
     127                    } else {
     128                        foreach ( $prices as $up ) {
     129                            echo wp_kses_post( sprintf( '<div class="pricename"><span class="pricename-description">%1$s</span> <span class="pricename-price">%2$s</span></div>', $up['PriceNameDescription'], edu_get_price( $up['Price'], $selected_course['ParticipantVat'] ) ) );
     130                        }
    126131                    }
    127132                }
     133                ?>
     134            </div>
     135
     136            <?php
     137            include 'blocks/event-list.php';
     138            if ( $allow_interest_reg_object && false !== $object_interest_page ) {
     139                ?>
     140                <br />
     141                <div class="inquiry">
     142                    <a class="inquiry-link"
     143                       href="<?php echo esc_url( $base_url . '/' . make_slugs( $name ) . '__' . $selected_course['CourseTemplateId'] . '/interest/' . edu_get_query_string( '?' ) . '&_=' . time() ); ?>"><?php echo esc_html_x( 'Send inquiry about this course', 'frontend', 'eduadmin-booking' ); ?></a>
     144                </div>
     145                <?php
    128146            }
    129147            ?>
    130148        </div>
    131 
    132149        <?php
    133         include 'blocks/event-list.php';
    134         if ( $allow_interest_reg_object && false !== $object_interest_page ) {
    135             ?>
    136             <br />
    137             <div class="inquiry">
    138                 <a class="inquiry-link"
    139                    href="<?php echo esc_url( $base_url . '/' . make_slugs( $name ) . '__' . $selected_course['CourseTemplateId'] . '/interest/' . edu_get_query_string( '?' ) . '&_=' . time() ); ?>"><?php echo esc_html_x( 'Send inquiry about this course', 'frontend', 'eduadmin-booking' ); ?></a>
    140             </div>
    141             <?php
    142         }
    143         ?>
    144     </div>
    145     <?php
     150    }
    146151}
    147 
    148152$out = ob_get_clean();
    149153
  • eduadmin-booking/trunk/content/template/detailTemplate/template_B.php

    r2655123 r3182069  
    44$api_key = EDU()->get_option( 'eduadmin-api-key' );
    55
    6 if ( ! $api_key || empty( $api_key ) ) {
    7     echo 'Please complete the configuration: <a href="' . esc_url( admin_url() . 'admin.php?page=eduadmin-settings' ) . '">EduAdmin - Api Authentication</a>';
     6if ( ! EDU()->api_connection ) {
     7    echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' );
    88} else {
    9     include_once 'course-info.php';
    10     if ( ! $selected_course ) {
     9    if ( ! $api_key || empty( $api_key ) ) {
     10        echo 'Please complete the configuration: <a href="' . esc_url( admin_url() . 'admin.php?page=eduadmin-settings' ) . '">EduAdmin - Api Authentication</a>';
     11    } else {
     12        include_once 'course-info.php';
     13        if ( ! $selected_course ) {
     14            ?>
     15            <script type="text/javascript">location.href = '<?php echo esc_url( $base_url ); ?>';</script>
     16            <?php
     17            die();
     18        }
     19
    1120        ?>
    12         <script type="text/javascript">location.href = '<?php echo esc_url( $base_url ); ?>';</script>
    13         <?php
    14         die();
    15     }
    16 
    17     ?>
    18     <div class="eduadmin detail-view" data-courseid="<?php echo esc_attr( $selected_course['CourseTemplateId'] ); ?>"
    19          data-eventid="<?php echo( isset( $_REQUEST['eid'] ) ? esc_attr( sanitize_text_field( $_REQUEST['eid'] ) ) : '' ); ?>">
    20         <a href="javascript://" onclick="eduGlobalMethods.GoBack('../', event);"
    21            class="backLink"><?php echo esc_html_x( '« Go back', 'frontend', 'eduadmin-booking' ); ?></a>
    22         <div class="title">
    23             <?php if ( ! empty( $selected_course['ImageUrl'] ) ) : ?>
    24                 <img src="<?php echo esc_url( $selected_course['ImageUrl'] ); ?>" class="courseImage" />
    25             <?php endif; ?>
    26             <h1 class="courseTitle"><?php echo esc_html( $name ); ?>
    27                 <small
    28                     class="courseLevel"><?php echo esc_html( false !== $course_level ? $course_level['Name'] : '' ); ?></small>
    29             </h1>
    30         </div>
    31         <hr />
    32         <div class="textblock leftBlock">
    33             <?php if ( ! in_array( 'description', $hide_sections, true ) && ! empty( $selected_course['CourseDescription'] ) ) { ?><?php if ( $show_headers ) { ?>
    34                 <h3><?php _ex( 'Course description', 'frontend', 'eduadmin-booking' ); ?></h3>
    35             <?php } ?>
     21        <div class="eduadmin detail-view"
     22             data-courseid="<?php echo esc_attr( $selected_course['CourseTemplateId'] ); ?>"
     23             data-eventid="<?php echo( isset( $_REQUEST['eid'] ) ? esc_attr( sanitize_text_field( $_REQUEST['eid'] ) ) : '' ); ?>">
     24            <a href="javascript://" onclick="eduGlobalMethods.GoBack('../', event);"
     25               class="backLink"><?php echo esc_html_x( '« Go back', 'frontend', 'eduadmin-booking' ); ?></a>
     26            <div class="title">
     27                <?php if ( ! empty( $selected_course['ImageUrl'] ) ) : ?>
     28                    <img src="<?php echo esc_url( $selected_course['ImageUrl'] ); ?>" class="courseImage" />
     29                <?php endif; ?>
     30                <h1 class="courseTitle"><?php echo esc_html( $name ); ?>
     31                    <small
     32                        class="courseLevel"><?php echo esc_html( false !== $course_level ? $course_level['Name'] : '' ); ?></small>
     33                </h1>
     34            </div>
     35            <hr />
     36            <div class="textblock leftBlock">
     37                <?php if ( ! in_array( 'description', $hide_sections, true ) && ! empty( $selected_course['CourseDescription'] ) ) { ?><?php if ( $show_headers ) { ?>
     38                    <h3><?php _ex( 'Course description', 'frontend', 'eduadmin-booking' ); ?></h3>
     39                <?php } ?>
     40                    <div>
     41                        <?php
     42                        echo $selected_course['CourseDescription'];
     43                        ?>
     44                    </div>
     45                <?php } ?>
     46                <?php if ( ! in_array( 'goal', $hide_sections, true ) && ! empty( $selected_course['CourseGoal'] ) ) { ?><?php if ( $show_headers ) { ?>
     47                    <h3><?php _ex( 'Course goal', 'frontend', 'eduadmin-booking' ); ?></h3>
     48                <?php } ?>
     49                    <div>
     50                        <?php
     51                        echo $selected_course['CourseGoal'];
     52                        ?>
     53                    </div>
     54                <?php } ?>
     55                <?php if ( ! in_array( 'target', $hide_sections, true ) && ! empty( $selected_course['TargetGroup'] ) ) { ?><?php if ( $show_headers ) { ?>
     56                    <h3><?php _ex( 'Target group', 'frontend', 'eduadmin-booking' ); ?></h3>
     57                <?php } ?>
     58                    <div>
     59                        <?php
     60                        echo $selected_course['TargetGroup'];
     61                        ?>
     62                    </div>
     63                <?php } ?>
     64                <?php if ( ! in_array( 'prerequisites', $hide_sections, true ) && ! empty( $selected_course['Prerequisites'] ) ) { ?>
     65                <?php if ( $show_headers ) { ?>
     66                    <h3><?php _ex( 'Prerequisites', 'frontend', 'eduadmin-booking' ); ?></h3>
     67                <?php } ?>
    3668                <div>
    3769                    <?php
    38                     echo $selected_course['CourseDescription'];
     70                    echo $selected_course['Prerequisites'];
    3971                    ?>
    4072                </div>
    41             <?php } ?>
    42             <?php if ( ! in_array( 'goal', $hide_sections, true ) && ! empty( $selected_course['CourseGoal'] ) ) { ?><?php if ( $show_headers ) { ?>
    43                 <h3><?php _ex( 'Course goal', 'frontend', 'eduadmin-booking' ); ?></h3>
    44             <?php } ?>
    45                 <div>
     73            </div>
     74            <div class="textblock rightBlock">
     75                <?php } ?>
     76                <?php if ( ! in_array( 'after', $hide_sections, true ) && ! empty( $selected_course['CourseAfter'] ) ) { ?><?php if ( $show_headers ) { ?>
     77                    <h3><?php _ex( 'After the course', 'frontend', 'eduadmin-booking' ); ?></h3>
     78                <?php } ?>
     79                    <div>
     80                        <?php
     81                        echo $selected_course['CourseAfter'];
     82                        ?>
     83                    </div>
     84                <?php } ?>
     85                <?php if ( ! in_array( 'quote', $hide_sections, true ) && ! empty( $selected_course['Quote'] ) ) { ?><?php if ( $show_headers ) { ?>
     86                    <h3><?php _ex( 'Quotes', 'frontend', 'eduadmin-booking' ); ?></h3>
     87                <?php } ?>
     88                    <div>
     89                        <?php
     90                        echo $selected_course['Quote'];
     91                        ?>
     92                    </div>
     93                <?php } ?>
     94            </div>
     95            <div class="eventInformation">
     96                <?php if ( ! in_array( 'time', $hide_sections, true ) && ! empty( $selected_course['StartTime'] ) && ! empty( $selected_course['EndTime'] ) ) { ?>
     97                    <h3><?php _ex( 'Time', 'frontend', 'eduadmin-booking' ); ?></h3>
    4698                    <?php
    47                     echo $selected_course['CourseGoal'];
     99                    echo ( $selected_course['Days'] > 0 ? sprintf( _n( '%1$d day', '%1$d days', $selected_course['Days'], 'eduadmin-booking' ), $selected_course['Days'] ) . ', ' : '' ) .
     100                         $selected_course['StartTime'] . ' - ' . $selected_course['EndTime'];
     101                }
     102
     103                if ( ! in_array( 'price', $hide_sections, true ) && ! empty( $prices ) ) {
    48104                    ?>
    49                 </div>
    50             <?php } ?>
    51             <?php if ( ! in_array( 'target', $hide_sections, true ) && ! empty( $selected_course['TargetGroup'] ) ) { ?><?php if ( $show_headers ) { ?>
    52                 <h3><?php _ex( 'Target group', 'frontend', 'eduadmin-booking' ); ?></h3>
    53             <?php } ?>
    54                 <div>
     105                    <h3><?php _ex( 'Price', 'frontend', 'eduadmin-booking' ); ?></h3>
    55106                    <?php
    56                     echo $selected_course['TargetGroup'];
    57                     ?>
    58                 </div>
    59             <?php } ?>
    60             <?php if ( ! in_array( 'prerequisites', $hide_sections, true ) && ! empty( $selected_course['Prerequisites'] ) ) { ?>
    61             <?php if ( $show_headers ) { ?>
    62                 <h3><?php _ex( 'Prerequisites', 'frontend', 'eduadmin-booking' ); ?></h3>
    63             <?php } ?>
    64             <div>
    65                 <?php
    66                 echo $selected_course['Prerequisites'];
     107                    $currency = EDU()->get_option( 'eduadmin-currency', 'SEK' );
     108                    if ( 1 === count( $prices ) ) {
     109                        echo wp_kses_post( sprintf( '<div class="pricename"><span class="pricename-description">%1$s</span> <span class="pricename-price">%2$s</span></div>', current( $prices )['PriceNameDescription'], edu_get_price( current( $prices )['Price'], $selected_course['ParticipantVat'] ) ) );
     110                    } else {
     111                        foreach ( $prices as $up ) {
     112                            echo wp_kses_post( sprintf( '<div class="pricename"><span class="pricename-description">%1$s</span> <span class="pricename-price">%2$s</span></div>', $up['PriceNameDescription'], edu_get_price( $up['Price'], $selected_course['ParticipantVat'] ) ) );
     113                        }
     114                    }
     115                }
    67116                ?>
    68117            </div>
    69         </div>
    70         <div class="textblock rightBlock">
    71             <?php } ?>
    72             <?php if ( ! in_array( 'after', $hide_sections, true ) && ! empty( $selected_course['CourseAfter'] ) ) { ?><?php if ( $show_headers ) { ?>
    73                 <h3><?php _ex( 'After the course', 'frontend', 'eduadmin-booking' ); ?></h3>
    74             <?php } ?>
    75                 <div>
    76                     <?php
    77                     echo $selected_course['CourseAfter'];
    78                     ?>
     118            <?php
     119            include( 'blocks/event-list.php' );
     120            if ( $allow_interest_reg_object && $object_interest_page != false ) {
     121                ?>
     122                <br />
     123                <div class="inquiry">
     124                    <a class="inquiry-link"
     125                       href="<?php echo $base_url; ?>/<?php echo make_slugs( $name ); ?>__<?php echo $selected_course['CourseTemplateId']; ?>/interest/<?php echo edu_get_query_string( '?' ) . '&_=' . time(); ?>"><?php _ex( 'Send inquiry about this course', 'frontend', 'eduadmin-booking' ); ?></a>
    79126                </div>
    80             <?php } ?>
    81             <?php if ( ! in_array( 'quote', $hide_sections, true ) && ! empty( $selected_course['Quote'] ) ) { ?><?php if ( $show_headers ) { ?>
    82                 <h3><?php _ex( 'Quotes', 'frontend', 'eduadmin-booking' ); ?></h3>
    83             <?php } ?>
    84                 <div>
    85                     <?php
    86                     echo $selected_course['Quote'];
    87                     ?>
    88                 </div>
    89             <?php } ?>
    90         </div>
    91         <div class="eventInformation">
    92             <?php if ( ! in_array( 'time', $hide_sections, true ) && ! empty( $selected_course['StartTime'] ) && ! empty( $selected_course['EndTime'] ) ) { ?>
    93                 <h3><?php _ex( 'Time', 'frontend', 'eduadmin-booking' ); ?></h3>
    94127                <?php
    95                 echo ( $selected_course['Days'] > 0 ? sprintf( _n( '%1$d day', '%1$d days', $selected_course['Days'], 'eduadmin-booking' ), $selected_course['Days'] ) . ', ' : '' ) .
    96                      $selected_course['StartTime'] . ' - ' . $selected_course['EndTime'];
    97             }
    98 
    99             if ( ! in_array( 'price', $hide_sections, true ) && ! empty( $prices ) ) {
    100                 ?>
    101                 <h3><?php _ex( 'Price', 'frontend', 'eduadmin-booking' ); ?></h3>
    102                 <?php
    103                 $currency = EDU()->get_option( 'eduadmin-currency', 'SEK' );
    104                 if ( 1 === count( $prices ) ) {
    105                     echo wp_kses_post( sprintf( '<div class="pricename"><span class="pricename-description">%1$s</span> <span class="pricename-price">%2$s</span></div>', current( $prices )['PriceNameDescription'], edu_get_price( current( $prices )['Price'], $selected_course['ParticipantVat'] ) ) );
    106                 } else {
    107                     foreach ( $prices as $up ) {
    108                         echo wp_kses_post( sprintf( '<div class="pricename"><span class="pricename-description">%1$s</span> <span class="pricename-price">%2$s</span></div>', $up['PriceNameDescription'], edu_get_price( $up['Price'], $selected_course['ParticipantVat'] ) ) );
    109                     }
    110                 }
    111128            }
    112129            ?>
    113130        </div>
    114131        <?php
    115         include( 'blocks/event-list.php' );
    116         if ( $allow_interest_reg_object && $object_interest_page != false ) {
    117             ?>
    118             <br />
    119             <div class="inquiry">
    120                 <a class="inquiry-link"
    121                    href="<?php echo $base_url; ?>/<?php echo make_slugs( $name ); ?>__<?php echo $selected_course['CourseTemplateId']; ?>/interest/<?php echo edu_get_query_string( '?' ) . '&_=' . time(); ?>"><?php _ex( 'Send inquiry about this course', 'frontend', 'eduadmin-booking' ); ?></a>
    122             </div>
    123             <?php
    124         }
    125         ?>
    126     </div>
    127     <?php
     132    }
    128133}
    129134$out = ob_get_clean();
  • eduadmin-booking/trunk/content/template/interestRegTemplate/interest-reg-event.php

    r2849684 r3182069  
    44$api_key = EDU()->get_option( 'eduadmin-api-key' );
    55
    6 if ( ! $api_key || empty( $api_key ) ) {
    7     echo 'Please complete the configuration: <a href="' . admin_url() . 'admin.php?page=eduadmin-settings">EduAdmin - Api Authentication</a>';
     6if ( ! EDU()->api_connection ) {
     7    echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' );
    88} else {
    9     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'] ) ) {
    10         include_once 'send-event-inquiry.php';
    11     }
     9    if ( ! $api_key || empty( $api_key ) ) {
     10        echo 'Please complete the configuration: <a href="' . admin_url() . 'admin.php?page=eduadmin-settings">EduAdmin - Api Authentication</a>';
     11    } else {
     12        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'] ) ) {
     13            include_once 'send-event-inquiry.php';
     14        }
    1215
    13     $course_id     = $wp_query->query_vars['courseId'];
    14     $group_by_city = EDU()->is_checked( 'eduadmin-groupEventsByCity', false );
    15     $fetch_months  = EDU()->get_option( 'eduadmin-monthsToFetch', 6 );
    16     if ( ! is_numeric( $fetch_months ) ) {
    17         $fetch_months = 6;
    18     }
    19     $edo = json_decode( EDUAPIHelper()->GetCourseDetailInfo( $course_id, $fetch_months, $group_by_city ), true );
     16        $course_id     = $wp_query->query_vars['courseId'];
     17        $group_by_city = EDU()->is_checked( 'eduadmin-groupEventsByCity', false );
     18        $fetch_months  = EDU()->get_option( 'eduadmin-monthsToFetch', 6 );
     19        if ( ! is_numeric( $fetch_months ) ) {
     20            $fetch_months = 6;
     21        }
     22        $edo = json_decode( EDUAPIHelper()->GetCourseDetailInfo( $course_id, $fetch_months, $group_by_city ), true );
    2023
    21     $selected_course = false;
    22     $name            = '';
    23     if ( $edo ) {
    24         $name            = ( ! empty( $edo['CourseName'] ) ? $edo['CourseName'] : $edo['InternalCourseName'] );
    25         $selected_course = $edo;
    26     }
     24        $selected_course = false;
     25        $name            = '';
     26        if ( $edo ) {
     27            $name            = ( ! empty( $edo['CourseName'] ) ? $edo['CourseName'] : $edo['InternalCourseName'] );
     28            $selected_course = $edo;
     29        }
    2730
    28     $is_ondemand = $selected_course['OnDemand'];
     31        $is_ondemand = $selected_course['OnDemand'];
    2932
    30     if ( $is_ondemand ) {
    31         $selected_course = json_decode( EDUAPIHelper()->GetOnDemandCourseDetailInfo( $course_id, $group_by_city ), true );
    32     }
     33        if ( $is_ondemand ) {
     34            $selected_course = json_decode( EDUAPIHelper()->GetOnDemandCourseDetailInfo( $course_id, $group_by_city ), true );
     35        }
    3336
    34     if ( ! $selected_course ) {
     37        if ( ! $selected_course ) {
     38            ?>
     39            <script>history.go(-1);</script>
     40            <?php
     41            die();
     42        }
     43
     44        $events = $selected_course['Events'];
     45
     46        if ( empty( $events ) ) {
     47            ?>
     48            <script>history.go(-1);</script>
     49            <?php
     50            die();
     51        }
     52
     53        if ( ! empty( $_REQUEST['eid'] ) && is_numeric( $_REQUEST['eid'] ) ) {
     54            foreach ( $events as $_event ) {
     55                if ( $_event['EventId'] === intval( $_REQUEST['eid'] ) ) {
     56                    $event = $_event;
     57                    break;
     58                }
     59            }
     60        } else {
     61            $event = $events[0];
     62        }
     63
    3564        ?>
    36         <script>history.go(-1);</script>
    37         <?php
    38         die();
    39     }
    40 
    41     $events = $selected_course['Events'];
    42 
    43     if ( empty( $events ) ) {
    44         ?>
    45         <script>history.go(-1);</script>
    46         <?php
    47         die();
    48     }
    49 
    50     if ( ! empty( $_REQUEST['eid'] ) && is_numeric( $_REQUEST['eid'] ) ) {
    51         foreach ( $events as $_event ) {
    52             if ( $_event['EventId'] === intval( $_REQUEST['eid'] ) ) {
    53                 $event = $_event;
    54                 break;
    55             }
    56         }
    57     } else {
    58         $event = $events[0];
    59     }
    60 
    61     ?>
    62     <div class="eduadmin">
    63         <a href="javascript://" onclick="eduGlobalMethods.GoBack('../../');"
    64            class="backLink"><?php echo esc_html_x( '« Go back', 'frontend', 'eduadmin-booking' ); ?></a>
    65         <div class="title">
    66             <?php if ( ! empty( $selected_course['ImageUrl'] ) ) : ?>
    67                 <img src="<?php echo esc_url( $selected_course['ImageUrl'] ); ?>" class="courseImage" />
    68             <?php endif; ?>
    69             <h1 class="courseTitle"><?php echo esc_html( $name ); ?> - <?php echo esc_html_x( 'Inquiry', 'frontend', 'eduadmin-booking' ); ?></h1>
    70         </div>
    71         <div class="dateInfo">
    72             <?php edu_event_item_date( $event, null );
    73             echo esc_html( edu_output_event_venue( array( $event['AddressName'], $event['City'] ), '&nbsp;' ) );
    74             ?>
    75         </div>
    76         <hr />
    77         <div class="textblock">
    78             <?php echo esc_html_x( 'Please fill out the form below to send a inquiry to us about this course.', 'frontend', 'eduadmin-booking' ); ?>
     65        <div class="eduadmin">
     66            <a href="javascript://" onclick="eduGlobalMethods.GoBack('../../');"
     67               class="backLink"><?php echo esc_html_x( '« Go back', 'frontend', 'eduadmin-booking' ); ?></a>
     68            <div class="title">
     69                <?php if ( ! empty( $selected_course['ImageUrl'] ) ) : ?>
     70                    <img src="<?php echo esc_url( $selected_course['ImageUrl'] ); ?>" class="courseImage" />
     71                <?php endif; ?>
     72                <h1 class="courseTitle"><?php echo esc_html( $name ); ?> - <?php echo esc_html_x( 'Inquiry', 'frontend', 'eduadmin-booking' ); ?></h1>
     73            </div>
     74            <div class="dateInfo">
     75                <?php edu_event_item_date( $event, null );
     76                echo esc_html( edu_output_event_venue( array( $event['AddressName'], $event['City'] ), '&nbsp;' ) );
     77                ?>
     78            </div>
    7979            <hr />
    80             <form action="" method="POST">
    81                 <input type="hidden" name="edu-interest-nonce"
    82                        value="<?php echo esc_attr( wp_create_nonce( 'edu-event-interest' ) ); ?>" />
    83                 <input type="hidden" name="objectid"
    84                        value="<?php echo esc_attr( $selected_course['CourseTemplateId'] ); ?>" />
    85                 <input type="hidden" name="eventid" value="<?php echo esc_attr( $event['EventId'] ); ?>" />
    86                 <input type="hidden" name="act" value="eventInquiry" />
    87                 <input type="hidden" name="email" />
    88                 <label class="edu-interest-company">
    89                     <div
    90                         class="inputLabel"><?php echo esc_html_x( 'Customer name', 'frontend', 'eduadmin-booking' ); ?> *
    91                     </div>
    92                     <div class="inputHolder">
    93                         <input type="text" autocomplete="off" required name="edu-companyName" maxlength="100"
    94                                placeholder="<?php echo esc_attr_x( 'Customer name', 'frontend', 'eduadmin-booking' ); ?>" />
    95                     </div>
    96                 </label>
    97                 <label class="edu-interest-contact">
    98                     <div
    99                         class="inputLabel"><?php echo esc_html_x( 'Contact name', 'frontend', 'eduadmin-booking' ); ?> *
    100                     </div>
    101                     <div class="inputHolder" style="display: flex;">
    102                         <input type="text" autocomplete="off" required name="edu-contactFirstName" class="first-name" maxlength="100"
    103                                placeholder="<?php echo esc_attr_x( 'Contact first name', 'frontend', 'eduadmin-booking' ); ?>" />
    104                         <input type="text" autocomplete="off" required name="edu-contactLastName" class="last-name" maxlength="100"
    105                                placeholder="<?php echo esc_attr_x( 'Contact surname', 'frontend', 'eduadmin-booking' ); ?>" />
    106                     </div>
    107                 </label>
    108                 <label class="edu-interest-email">
    109                     <div
    110                         class="inputLabel"><?php echo esc_html_x( 'E-mail address', 'frontend', 'eduadmin-booking' ); ?> *
    111                     </div>
    112                     <div class="inputHolder">
    113                         <input type="email" autocomplete="off" required name="edu-emailAddress" maxlength="200"
    114                                placeholder="<?php echo esc_attr_x( 'E-mail address', 'frontend', 'eduadmin-booking' ); ?>" />
    115                     </div>
    116                 </label>
    117                 <label class="edu-interest-phone">
    118                     <div
    119                         class="inputLabel"><?php echo esc_html_x( 'Phone number', 'frontend', 'eduadmin-booking' ); ?></div>
    120                     <div class="inputHolder">
    121                         <input type="tel" autocomplete="off" name="edu-phone" maxlength="50"
    122                                placeholder="<?php echo esc_attr_x( 'Phone number', 'frontend', 'eduadmin-booking' ); ?>" />
    123                     </div>
    124                 </label>
    125                 <label class="edu-interest-mobile">
    126                     <div
    127                         class="inputLabel"><?php echo esc_html_x( 'Mobile number', 'frontend', 'eduadmin-booking' ); ?></div>
    128                     <div class="inputHolder">
    129                         <input type="tel" autocomplete="off" name="edu-mobile" maxlength="50"
    130                                placeholder="<?php echo esc_attr_x( 'Mobile number', 'frontend', 'eduadmin-booking' ); ?>" />
    131                     </div>
    132                 </label>
    133                 <label class="edu-interest-notes">
    134                     <div class="inputLabel"><?php echo esc_html_x( 'Notes', 'frontend', 'eduadmin-booking' ); ?></div>
    135                     <div class="inputHolder">
     80            <div class="textblock">
     81                <?php echo esc_html_x( 'Please fill out the form below to send a inquiry to us about this course.', 'frontend', 'eduadmin-booking' ); ?>
     82                <hr />
     83                <form action="" method="POST">
     84                    <input type="hidden" name="edu-interest-nonce"
     85                           value="<?php echo esc_attr( wp_create_nonce( 'edu-event-interest' ) ); ?>" />
     86                    <input type="hidden" name="objectid"
     87                           value="<?php echo esc_attr( $selected_course['CourseTemplateId'] ); ?>" />
     88                    <input type="hidden" name="eventid" value="<?php echo esc_attr( $event['EventId'] ); ?>" />
     89                    <input type="hidden" name="act" value="eventInquiry" />
     90                    <input type="hidden" name="email" />
     91                    <label class="edu-interest-company">
     92                        <div
     93                            class="inputLabel"><?php echo esc_html_x( 'Customer name', 'frontend', 'eduadmin-booking' ); ?> *
     94                        </div>
     95                        <div class="inputHolder">
     96                            <input type="text" autocomplete="off" required name="edu-companyName" maxlength="100"
     97                                   placeholder="<?php echo esc_attr_x( 'Customer name', 'frontend', 'eduadmin-booking' ); ?>" />
     98                        </div>
     99                    </label>
     100                    <label class="edu-interest-contact">
     101                        <div
     102                            class="inputLabel"><?php echo esc_html_x( 'Contact name', 'frontend', 'eduadmin-booking' ); ?> *
     103                        </div>
     104                        <div class="inputHolder" style="display: flex;">
     105                            <input type="text" autocomplete="off" required name="edu-contactFirstName"
     106                                   class="first-name" maxlength="100"
     107                                   placeholder="<?php echo esc_attr_x( 'Contact first name', 'frontend', 'eduadmin-booking' ); ?>" />
     108                            <input type="text" autocomplete="off" required name="edu-contactLastName" class="last-name"
     109                                   maxlength="100"
     110                                   placeholder="<?php echo esc_attr_x( 'Contact surname', 'frontend', 'eduadmin-booking' ); ?>" />
     111                        </div>
     112                    </label>
     113                    <label class="edu-interest-email">
     114                        <div
     115                            class="inputLabel"><?php echo esc_html_x( 'E-mail address', 'frontend', 'eduadmin-booking' ); ?> *
     116                        </div>
     117                        <div class="inputHolder">
     118                            <input type="email" autocomplete="off" required name="edu-emailAddress" maxlength="200"
     119                                   placeholder="<?php echo esc_attr_x( 'E-mail address', 'frontend', 'eduadmin-booking' ); ?>" />
     120                        </div>
     121                    </label>
     122                    <label class="edu-interest-phone">
     123                        <div
     124                            class="inputLabel"><?php echo esc_html_x( 'Phone number', 'frontend', 'eduadmin-booking' ); ?></div>
     125                        <div class="inputHolder">
     126                            <input type="tel" autocomplete="off" name="edu-phone" maxlength="50"
     127                                   placeholder="<?php echo esc_attr_x( 'Phone number', 'frontend', 'eduadmin-booking' ); ?>" />
     128                        </div>
     129                    </label>
     130                    <label class="edu-interest-mobile">
     131                        <div
     132                            class="inputLabel"><?php echo esc_html_x( 'Mobile number', 'frontend', 'eduadmin-booking' ); ?></div>
     133                        <div class="inputHolder">
     134                            <input type="tel" autocomplete="off" name="edu-mobile" maxlength="50"
     135                                   placeholder="<?php echo esc_attr_x( 'Mobile number', 'frontend', 'eduadmin-booking' ); ?>" />
     136                        </div>
     137                    </label>
     138                    <label class="edu-interest-notes">
     139                        <div
     140                            class="inputLabel"><?php echo esc_html_x( 'Notes', 'frontend', 'eduadmin-booking' ); ?></div>
     141                        <div class="inputHolder">
    136142                        <textarea name="edu-notes" autocomplete="off" maxlength="1000"
    137143                                  placeholder="<?php echo esc_attr_x( 'Notes', 'frontend', 'eduadmin-booking' ); ?>"></textarea>
    138                     </div>
    139                 </label>
    140                 <?php if ( EDU()->is_checked( 'eduadmin-singlePersonBooking', false ) ) { ?>
    141                     <input type="hidden" name="edu-participants" value="1" />
    142                 <?php } else { ?>
    143                     <label class="edu-interest-participants">
    144                         <div
    145                             class="inputLabel"><?php echo esc_html_x( 'Number of participants', 'frontend', 'eduadmin-booking' ); ?> *
    146                         </div>
    147                         <div class="inputHolder">
    148                             <input type="number" autocomplete="off" name="edu-participants"
    149                                    placeholder="<?php echo esc_attr_x( 'Number of participants', 'frontend', 'eduadmin-booking' ); ?>" />
    150144                        </div>
    151145                    </label>
    152                 <?php } ?>
    153                 <input type="submit" class="bookButton cta-btn"
    154                        value="<?php echo esc_attr_x( 'Send inquiry', 'frontend', 'eduadmin-booking' ); ?>" />
    155             </form>
     146                    <?php if ( EDU()->is_checked( 'eduadmin-singlePersonBooking', false ) ) { ?>
     147                        <input type="hidden" name="edu-participants" value="1" />
     148                    <?php } else { ?>
     149                        <label class="edu-interest-participants">
     150                            <div
     151                                class="inputLabel"><?php echo esc_html_x( 'Number of participants', 'frontend', 'eduadmin-booking' ); ?> *
     152                            </div>
     153                            <div class="inputHolder">
     154                                <input type="number" autocomplete="off" name="edu-participants"
     155                                       placeholder="<?php echo esc_attr_x( 'Number of participants', 'frontend', 'eduadmin-booking' ); ?>" />
     156                            </div>
     157                        </label>
     158                    <?php } ?>
     159                    <input type="submit" class="bookButton cta-btn"
     160                           value="<?php echo esc_attr_x( 'Send inquiry', 'frontend', 'eduadmin-booking' ); ?>" />
     161                </form>
     162            </div>
    156163        </div>
    157     </div>
    158     <?php
    159     $original_title = get_the_title();
    160     $new_title      = $name . ' | ' . $original_title;
    161     ?>
    162     <script type="text/javascript">
    163         (function () {
    164             var title = document.title;
    165             title = title.replace('<?php echo esc_js( $original_title ); ?>', '<?php echo esc_js( $new_title ); ?>');
    166             document.title = title;
    167         })();
    168     </script>
    169     <?php
     164        <?php
     165        $original_title = get_the_title();
     166        $new_title      = $name . ' | ' . $original_title;
     167        ?>
     168        <script type="text/javascript">
     169            (function () {
     170                var title = document.title;
     171                title = title.replace('<?php echo esc_js( $original_title ); ?>', '<?php echo esc_js( $new_title ); ?>');
     172                document.title = title;
     173            })();
     174        </script>
     175        <?php
     176    }
    170177}
    171178
  • eduadmin-booking/trunk/content/template/interestRegTemplate/interest-reg-object.php

    r2962827 r3182069  
    33global $wp_query;
    44$api_key = EDU()->get_option( 'eduadmin-api-key' );
     5if ( ! EDU()->api_connection ) {
     6    echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' );
     7} else {
     8    if ( ! $api_key || empty( $api_key ) ) {
     9        echo 'Please complete the configuration: <a href="' . esc_url( admin_url() . 'admin.php?page=eduadmin-settings' ) . '">EduAdmin - Api Authentication</a>';
     10    } else {
     11        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'] ) ) {
     12            include_once 'send-object-inquiry.php';
     13        }
    514
    6 if ( ! $api_key || empty( $api_key ) ) {
    7     echo 'Please complete the configuration: <a href="' . esc_url( admin_url() . 'admin.php?page=eduadmin-settings' ) . '">EduAdmin - Api Authentication</a>';
    8 } else {
    9     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'] ) ) {
    10         include_once 'send-object-inquiry.php';
    11     }
     15        $course_id     = $wp_query->query_vars['courseId'];
     16        $group_by_city = EDU()->is_checked( 'eduadmin-groupEventsByCity', false );
     17        $fetch_months  = EDU()->get_option( 'eduadmin-monthsToFetch', 6 );
     18        if ( ! is_numeric( $fetch_months ) ) {
     19            $fetch_months = 6;
     20        }
    1221
    13     $course_id     = $wp_query->query_vars['courseId'];
    14     $group_by_city = EDU()->is_checked( 'eduadmin-groupEventsByCity', false );
    15     $fetch_months  = EDU()->get_option( 'eduadmin-monthsToFetch', 6 );
    16     if ( ! is_numeric( $fetch_months ) ) {
    17         $fetch_months = 6;
    18     }
     22        $edo = json_decode( EDUAPIHelper()->GetCourseDetailInfo( $course_id, $fetch_months, $group_by_city ), true );
    1923
    20     $edo = json_decode( EDUAPIHelper()->GetCourseDetailInfo( $course_id, $fetch_months, $group_by_city ), true );
     24        $selected_course = false;
     25        $name            = '';
     26        if ( $edo ) {
     27            $name            = ( ! empty( $edo['CourseName'] ) ? $edo['CourseName'] : $edo['InternalCourseName'] );
     28            $selected_course = $edo;
     29        }
    2130
    22     $selected_course = false;
    23     $name            = '';
    24     if ( $edo ) {
    25         $name            = ( ! empty( $edo['CourseName'] ) ? $edo['CourseName'] : $edo['InternalCourseName'] );
    26         $selected_course = $edo;
    27     }
     31        if ( ! $selected_course ) {
     32            ?>
     33            <script>history.go(-1);</script>
     34            <?php
     35            die();
     36        }
    2837
    29     if ( ! $selected_course ) {
    3038        ?>
    31         <script>history.go(-1);</script>
    32         <?php
    33         die();
    34     }
    35 
    36     ?>
    37     <div class="eduadmin">
    38         <a href="javascript://" onclick="eduGlobalMethods.GoBack('../', event);"
    39            class="backLink"><?php echo esc_html_x( '« Go back', 'frontend', 'eduadmin-booking' ); ?></a>
    40         <div class="title">
    41             <?php if ( ! empty( $selected_course['ImageUrl'] ) ) : ?>
    42                 <img src="<?php echo esc_url( $selected_course['ImageUrl'] ); ?>" class="courseImage" />
    43             <?php endif; ?>
    44             <h1 class="courseTitle"><?php echo esc_html( $name ); ?> - <?php echo esc_html_x( 'Inquiry', 'frontend', 'eduadmin-booking' ); ?></h1>
    45         </div>
    46         <hr />
    47         <div class="textblock">
    48             <?php echo esc_html_x( 'Please fill out the form below to send a inquiry to us about this course.', 'frontend', 'eduadmin-booking' ); ?>
     39        <div class="eduadmin">
     40            <a href="javascript://" onclick="eduGlobalMethods.GoBack('../', event);"
     41               class="backLink"><?php echo esc_html_x( '« Go back', 'frontend', 'eduadmin-booking' ); ?></a>
     42            <div class="title">
     43                <?php if ( ! empty( $selected_course['ImageUrl'] ) ) : ?>
     44                    <img src="<?php echo esc_url( $selected_course['ImageUrl'] ); ?>" class="courseImage" />
     45                <?php endif; ?>
     46                <h1 class="courseTitle"><?php echo esc_html( $name ); ?> - <?php echo esc_html_x( 'Inquiry', 'frontend', 'eduadmin-booking' ); ?></h1>
     47            </div>
    4948            <hr />
    50             <form action="" method="POST" autocomplete="off">
    51                 <input type="hidden" name="edu-interest-nonce"
    52                        value="<?php echo esc_attr( wp_create_nonce( 'edu-object-interest' ) ); ?>" />
    53                 <input type="hidden" name="objectid"
    54                        value="<?php echo esc_attr( $selected_course['CourseTemplateId'] ); ?>" />
    55                 <input type="hidden" name="act" value="objectInquiry" />
    56                 <input type="hidden" name="email" />
    57                 <label class="edu-interest-company">
    58                     <div
    59                         class="inputLabel"><?php echo esc_html_x( 'Customer name', 'frontend', 'eduadmin-booking' ); ?> *
    60                     </div>
    61                     <div class="inputHolder">
    62                         <input type="text" autocomplete="off" required name="edu-companyName" maxlength="100"
    63                                placeholder="<?php echo esc_attr_x( 'Customer name', 'frontend', 'eduadmin-booking' ); ?>" />
    64                     </div>
    65                 </label>
    66                 <label class="edu-interest-contact">
    67                     <div
    68                         class="inputLabel"><?php echo esc_html_x( 'Contact name', 'frontend', 'eduadmin-booking' ); ?> *
    69                     </div>
    70                     <div class="inputHolder" style="display: flex;">
    71                         <input type="text" autocomplete="off" required name="edu-contactFirstName" class="first-name"
    72                                maxlength="100"
    73                                placeholder="<?php echo esc_attr_x( 'Contact first name', 'frontend', 'eduadmin-booking' ); ?>" />
    74                         <input type="text" autocomplete="off" required name="edu-contactLastName" class="last-name"
    75                                maxlength="100"
    76                                placeholder="<?php echo esc_attr_x( 'Contact surname', 'frontend', 'eduadmin-booking' ); ?>" />
    77                     </div>
    78                 </label>
    79                 <label class="edu-interest-email">
    80                     <div
    81                         class="inputLabel"><?php echo esc_html_x( 'E-mail address', 'frontend', 'eduadmin-booking' ); ?> *
    82                     </div>
    83                     <div class="inputHolder">
    84                         <input type="email" autocomplete="off" required name="edu-emailAddress" maxlength="200"
    85                                placeholder="<?php echo esc_attr_x( 'E-mail address', 'frontend', 'eduadmin-booking' ); ?>" />
    86                     </div>
    87                 </label>
    88                 <label class="edu-interest-phone">
    89                     <div
    90                         class="inputLabel"><?php echo esc_html_x( 'Phone number', 'frontend', 'eduadmin-booking' ); ?></div>
    91                     <div class="inputHolder">
    92                         <input type="tel" autocomplete="off" name="edu-phone" maxlength="50"
    93                                placeholder="<?php echo esc_attr_x( 'Phone number', 'frontend', 'eduadmin-booking' ); ?>" />
    94                     </div>
    95                 </label>
    96                 <label class="edu-interest-mobile">
    97                     <div
    98                         class="inputLabel"><?php echo esc_html_x( 'Mobile number', 'frontend', 'eduadmin-booking' ); ?></div>
    99                     <div class="inputHolder">
    100                         <input type="tel" autocomplete="off" name="edu-mobile" maxlength="50"
    101                                placeholder="<?php echo esc_attr_x( 'Mobile number', 'frontend', 'eduadmin-booking' ); ?>" />
    102                     </div>
    103                 </label>
    104                 <label class="edu-interest-notes">
    105                     <div class="inputLabel"><?php echo esc_html_x( 'Notes', 'frontend', 'eduadmin-booking' ); ?></div>
    106                     <div class="inputHolder">
     49            <div class="textblock">
     50                <?php echo esc_html_x( 'Please fill out the form below to send a inquiry to us about this course.', 'frontend', 'eduadmin-booking' ); ?>
     51                <hr />
     52                <form action="" method="POST" autocomplete="off">
     53                    <input type="hidden" name="edu-interest-nonce"
     54                           value="<?php echo esc_attr( wp_create_nonce( 'edu-object-interest' ) ); ?>" />
     55                    <input type="hidden" name="objectid"
     56                           value="<?php echo esc_attr( $selected_course['CourseTemplateId'] ); ?>" />
     57                    <input type="hidden" name="act" value="objectInquiry" />
     58                    <input type="hidden" name="email" />
     59                    <label class="edu-interest-company">
     60                        <div
     61                            class="inputLabel"><?php echo esc_html_x( 'Customer name', 'frontend', 'eduadmin-booking' ); ?> *
     62                        </div>
     63                        <div class="inputHolder">
     64                            <input type="text" autocomplete="off" required name="edu-companyName" maxlength="100"
     65                                   placeholder="<?php echo esc_attr_x( 'Customer name', 'frontend', 'eduadmin-booking' ); ?>" />
     66                        </div>
     67                    </label>
     68                    <label class="edu-interest-contact">
     69                        <div
     70                            class="inputLabel"><?php echo esc_html_x( 'Contact name', 'frontend', 'eduadmin-booking' ); ?> *
     71                        </div>
     72                        <div class="inputHolder" style="display: flex;">
     73                            <input type="text" autocomplete="off" required name="edu-contactFirstName"
     74                                   class="first-name" maxlength="100"
     75                                   placeholder="<?php echo esc_attr_x( 'Contact first name', 'frontend', 'eduadmin-booking' ); ?>" />
     76                            <input type="text" autocomplete="off" required name="edu-contactLastName" class="last-name"
     77                                   maxlength="100"
     78                                   placeholder="<?php echo esc_attr_x( 'Contact surname', 'frontend', 'eduadmin-booking' ); ?>" />
     79                        </div>
     80                    </label>
     81                    <label class="edu-interest-email">
     82                        <div
     83                            class="inputLabel"><?php echo esc_html_x( 'E-mail address', 'frontend', 'eduadmin-booking' ); ?> *
     84                        </div>
     85                        <div class="inputHolder">
     86                            <input type="email" autocomplete="off" required name="edu-emailAddress" maxlength="200"
     87                                   placeholder="<?php echo esc_attr_x( 'E-mail address', 'frontend', 'eduadmin-booking' ); ?>" />
     88                        </div>
     89                    </label>
     90                    <label class="edu-interest-phone">
     91                        <div
     92                            class="inputLabel"><?php echo esc_html_x( 'Phone number', 'frontend', 'eduadmin-booking' ); ?></div>
     93                        <div class="inputHolder">
     94                            <input type="tel" autocomplete="off" name="edu-phone" maxlength="50"
     95                                   placeholder="<?php echo esc_attr_x( 'Phone number', 'frontend', 'eduadmin-booking' ); ?>" />
     96                        </div>
     97                    </label>
     98                    <label class="edu-interest-mobile">
     99                        <div
     100                            class="inputLabel"><?php echo esc_html_x( 'Mobile number', 'frontend', 'eduadmin-booking' ); ?></div>
     101                        <div class="inputHolder">
     102                            <input type="tel" autocomplete="off" name="edu-mobile" maxlength="50"
     103                                   placeholder="<?php echo esc_attr_x( 'Mobile number', 'frontend', 'eduadmin-booking' ); ?>" />
     104                        </div>
     105                    </label>
     106                    <label class="edu-interest-notes">
     107                        <div
     108                            class="inputLabel"><?php echo esc_html_x( 'Notes', 'frontend', 'eduadmin-booking' ); ?></div>
     109                        <div class="inputHolder">
    107110                        <textarea name="edu-notes" autocomplete="off" maxlength="1000"
    108111                                  placeholder="<?php echo esc_attr_x( 'Notes', 'frontend', 'eduadmin-booking' ); ?>"></textarea>
    109                     </div>
    110                 </label>
    111                 <?php if ( EDU()->is_checked( 'eduadmin-singlePersonBooking', false ) ) { ?>
    112                     <input type="hidden" name="edu-participants" value="1" />
    113                 <?php } else { ?>
    114                     <label class="edu-interest-participants">
    115                         <div
    116                             class="inputLabel"><?php echo esc_html_x( 'Number of participants', 'frontend', 'eduadmin-booking' ); ?> *
    117                         </div>
    118                         <div class="inputHolder">
    119                             <input type="number" autocomplete="off" name="edu-participants"
    120                                    placeholder="<?php echo esc_attr_x( 'Number of participants', 'frontend', 'eduadmin-booking' ); ?>" />
    121112                        </div>
    122113                    </label>
    123                 <?php } ?>
     114                    <?php if ( EDU()->is_checked( 'eduadmin-singlePersonBooking', false ) ) { ?>
     115                        <input type="hidden" name="edu-participants" value="1" />
     116                    <?php } else { ?>
     117                        <label class="edu-interest-participants">
     118                            <div
     119                                class="inputLabel"><?php echo esc_html_x( 'Number of participants', 'frontend', 'eduadmin-booking' ); ?> *
     120                            </div>
     121                            <div class="inputHolder">
     122                                <input type="number" autocomplete="off" name="edu-participants"
     123                                       placeholder="<?php echo esc_attr_x( 'Number of participants', 'frontend', 'eduadmin-booking' ); ?>" />
     124                            </div>
     125                        </label>
     126                    <?php } ?>
    124127
    125                 <input type="submit" class="bookButton cta-btn"
    126                        value="<?php echo esc_attr_x( 'Send inquiry', 'frontend', 'eduadmin-booking' ); ?>" />
    127             </form>
     128                    <input type="submit" class="bookButton cta-btn"
     129                           value="<?php echo esc_attr_x( 'Send inquiry', 'frontend', 'eduadmin-booking' ); ?>" />
     130                </form>
     131            </div>
    128132        </div>
    129     </div>
    130     <?php
    131     $original_title = get_the_title();
    132     $new_title      = $name . ' | ' . $original_title;
    133     ?>
    134     <script type="text/javascript">
    135         (function () {
    136             var title = document.title;
    137             title = title.replace('<?php echo esc_js( $original_title ); ?>', '<?php echo esc_js( $new_title ); ?>');
    138             document.title = title;
    139         })();
    140     </script>
    141     <?php
     133        <?php
     134        $original_title = get_the_title();
     135        $new_title      = $name . ' | ' . $original_title;
     136        ?>
     137        <script type="text/javascript">
     138            (function () {
     139                var title = document.title;
     140                title = title.replace('<?php echo esc_js( $original_title ); ?>', '<?php echo esc_js( $new_title ); ?>');
     141                document.title = title;
     142            })();
     143        </script>
     144        <?php
     145    }
    142146}
    143147
  • eduadmin-booking/trunk/content/template/listTemplate/list-events.php

    r2967419 r3182069  
    11<?php
     2
     3if ( ! EDU()->api_connection ) {
     4    echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' );
     5
     6    return;
     7}
     8
    29$surl     = get_home_url();
    310$cat      = EDU()->get_option( 'eduadmin-rewriteBaseUrl', '' );
  • eduadmin-booking/trunk/content/template/listTemplate/search-form.php

    r2417788 r3182069  
     1<?php
     2if ( ! EDU()->api_connection ) {
     3
     4    return;
     5}
     6?>
    17<?php if ( $search_visible ) { ?>
    28    <form method="POST" class="search-form">
  • eduadmin-booking/trunk/content/template/listTemplate/template-loader.php

    r2909523 r3182069  
    11<?php
     2
     3if ( ! EDU()->api_connection ) {
     4    echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' );
     5
     6    return;
     7}
     8
    29$eds = $subjects;
    310
     
    4653
    4754$all_courses = false;
    48 if(!empty($attributes['allcourses'])) {
     55if ( ! empty( $attributes['allcourses'] ) ) {
    4956    $all_courses = $attributes['allcourses'];
     57}
     58
     59switch ( $attributes['template'] ) {
     60    case "template_A":
     61    case "template_B":
     62    case "template_GF":
     63        break;
     64    default:
     65        $attributes['template'] = "template_A";
     66        break;
    5067}
    5168
  • eduadmin-booking/trunk/content/template/listTemplate/template_A.php

    r2435699 r3182069  
    55$api_key = EDU()->get_option( 'eduadmin-api-key' );
    66
    7 if ( ! $api_key || empty( $api_key ) ) {
    8     echo 'Please complete the configuration: <a href="' . esc_url( admin_url() . 'admin.php?page=eduadmin-settings' ) . '">EduAdmin - Api Authentication</a>';
     7if ( ! EDU()->api_connection ) {
     8    echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' );
    99} else {
    10     include 'list-options.php';
    11     ?>
    12     <div class="eduadmin">
     10    if ( empty( $api_key ) ) {
     11        echo 'Please complete the configuration: <a href="' . esc_url( admin_url() . 'admin.php?page=eduadmin-settings' ) . '">EduAdmin - Api Authentication</a>';
     12    } else {
     13        include 'list-options.php';
     14        ?>
     15        <div class="eduadmin">
     16            <?php
     17            include 'search-form.php';
     18            include 'template-loader.php';
     19            ?>
     20        </div>
    1321        <?php
    14         include 'search-form.php';
    15         include 'template-loader.php';
    16         ?>
    17     </div>
    18     <?php
     22    }
    1923}
    2024$out = ob_get_clean();
  • eduadmin-booking/trunk/content/template/listTemplate/template_B.php

    r2435699 r3182069  
    44$api_key = EDU()->get_option( 'eduadmin-api-key' );
    55
    6 if ( ! $api_key || empty( $api_key ) ) {
    7     echo 'Please complete the configuration: <a href="' . esc_url( admin_url() . 'admin.php?page=eduadmin-settings' ) . '">EduAdmin - Api Authentication</a>';
     6if ( ! EDU()->api_connection ) {
     7    echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' );
    88} else {
    9     include 'list-options.php';
    10     ?>
    11     <div class="eduadmin">
     9    if ( ! $api_key || empty( $api_key ) ) {
     10        echo 'Please complete the configuration: <a href="' . esc_url( admin_url() . 'admin.php?page=eduadmin-settings' ) . '">EduAdmin - Api Authentication</a>';
     11    } else {
     12        include 'list-options.php';
     13        ?>
     14        <div class="eduadmin">
     15            <?php
     16            include 'search-form.php';
     17            include 'template-loader.php';
     18            ?>
     19        </div>
    1220        <?php
    13         include 'search-form.php';
    14         include 'template-loader.php';
    15         ?>
    16     </div>
    17     <?php
     21    }
    1822}
    1923$out = ob_get_clean();
  • eduadmin-booking/trunk/content/template/listTemplate/template_GF.php

    r2435699 r3182069  
    44$api_key = EDU()->get_option( 'eduadmin-api-key' );
    55
    6 if ( ! $api_key || empty( $api_key ) ) {
    7     echo 'Please complete the configuration: <a href="' . esc_url( admin_url() . 'admin.php?page=eduadmin-settings' ) . '">EduAdmin - Api Authentication</a>';
     6if ( ! EDU()->api_connection ) {
     7    echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' );
    88} else {
    9     include 'list-options.php';
    10     ?>
    11     <div class="eduadmin">
    12         <div class="courseContainer">
    13             <?php include 'template-loader.php'; ?>
     9    if ( ! $api_key || empty( $api_key ) ) {
     10        echo 'Please complete the configuration: <a href="' . esc_url( admin_url() . 'admin.php?page=eduadmin-settings' ) . '">EduAdmin - Api Authentication</a>';
     11    } else {
     12        include 'list-options.php';
     13        ?>
     14        <div class="eduadmin">
     15            <div class="courseContainer">
     16                <?php include 'template-loader.php'; ?>
     17            </div>
    1418        </div>
    15     </div>
    16     <?php
     19        <?php
     20    }
    1721}
    1822$out = ob_get_clean();
  • eduadmin-booking/trunk/content/template/myPagesTemplate/login.php

    r2976204 r3182069  
    55$api_key = EDU()->get_option( 'eduadmin-api-key' );
    66
    7 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 ) {
    8     if ( isset( $q['edu-login'] ) || isset( $q['edu-profile'] ) ) {
    9         require_once 'profile.php';
    10     } elseif ( isset( $q['edu-bookings'] ) ) {
    11         require_once 'bookings.php';
    12     } elseif ( isset( $q['edu-limiteddiscount'] ) ) {
    13         require_once 'limited-discount.php';
    14     } elseif ( isset( $q['edu-certificates'] ) ) {
    15         require_once 'certificates.php';
    16     } elseif ( isset( $q['edu-password'] ) ) {
    17         require_once 'change-password.php';
     7if ( ! EDU()->api_connection ) {
     8    echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' );
     9} else {
     10    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 ) {
     11        if ( isset( $q['edu-login'] ) || isset( $q['edu-profile'] ) ) {
     12            require_once 'profile.php';
     13        } elseif ( isset( $q['edu-bookings'] ) ) {
     14            require_once 'bookings.php';
     15        } elseif ( isset( $q['edu-limiteddiscount'] ) ) {
     16            require_once 'limited-discount.php';
     17        } elseif ( isset( $q['edu-certificates'] ) ) {
     18            require_once 'certificates.php';
     19        } elseif ( isset( $q['edu-password'] ) ) {
     20            require_once 'change-password.php';
     21        } else {
     22            require_once 'profile.php';
     23        }
    1824    } else {
    19         require_once 'profile.php';
     25        require_once 'login-page.php';
    2026    }
    21 } else {
    22     require_once 'login-page.php';
    2327}
    2428
  • eduadmin-booking/trunk/content/template/programme/book.php

    r2976806 r3182069  
    22ob_start();
    33// phpcs:disable WordPress.NamingConventions,Squiz
    4 
    5 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'] ) ) {
    6     $error_list = apply_filters( 'edu-booking-error', array() );
    7     if ( ! empty( $error_list ) ) {
    8         echo '<div class="eduadmin">';
    9         foreach ( $error_list as $error ) {
    10             ?>
    11             <div class="edu-modal warning">
    12                 <?php echo esc_html( $error ); ?>
    13             </div>
    14             <?php
     4if ( ! EDU()->api_connection ) {
     5    echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' );
     6} else {
     7    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'] ) ) {
     8        $error_list = apply_filters( 'edu-booking-error', array() );
     9        if ( ! empty( $error_list ) ) {
     10            echo '<div class="eduadmin">';
     11            foreach ( $error_list as $error ) {
     12                ?>
     13                <div class="edu-modal warning">
     14                    <?php echo esc_html( $error ); ?>
     15                </div>
     16                <?php
     17            }
     18            do_action( 'eduadmin-bookingerror', $error_list );
     19            echo '</div>';
     20        } else {
     21            $ebi = $GLOBALS['edubookinginfo'];
     22            do_action( 'eduadmin-processbooking', $ebi );
     23            do_action( 'eduadmin-bookingcompleted' );
    1524        }
    16         do_action( 'eduadmin-bookingerror', $error_list );
    17         echo '</div>';
    1825    } else {
    19         $ebi = $GLOBALS['edubookinginfo'];
    20         do_action( 'eduadmin-processbooking', $ebi );
    21         do_action( 'eduadmin-bookingcompleted' );
    22     }
    23 } else {
    24     if ( EDU()->is_checked( 'eduadmin-useBookingFormFromApi', false ) ) {
    25         if ( ! empty( $programme['BookingFormUrl'] ) ) {
    26             ?>
    27             <iframe id="eduadmin-booking-frame" class="edu-bookingform-page-frame"
    28                     src="<?php echo esc_attr( $programme['BookingFormUrl'] ); ?>"></iframe>
    29             <?php
    30             if ( ! empty( trim( EDU()->get_option( 'eduadmin-booking-form-javascript', '' ) ) ) ) {
     26        if ( EDU()->is_checked( 'eduadmin-useBookingFormFromApi', false ) ) {
     27            if ( ! empty( $programme['BookingFormUrl'] ) ) {
     28                ?>
     29                <iframe id="eduadmin-booking-frame" class="edu-bookingform-page-frame"
     30                        src="<?php echo esc_attr( $programme['BookingFormUrl'] ); ?>"></iframe>
     31                <?php
     32                if ( ! empty( trim( EDU()->get_option( 'eduadmin-booking-form-javascript', '' ) ) ) ) {
     33                    ?>
     34                    <script type="text/javascript">
     35                        <?php echo EDU()->get_option( 'eduadmin-booking-form-javascript', '' ); ?>
     36                    </script>
     37                    <?php
     38                    $GLOBALS['eduadmin-booking-form-javascript-set'] = true;
     39                }
     40            } else {
     41                echo _x( 'The booking form needs configuration in EduAdmin before this works.', 'frontend', 'eduadmin-booking' );
     42            }
     43
     44            return;
     45        }
     46
     47        $contact  = new EduAdmin_Data_ContactPerson();
     48        $customer = new EduAdmin_Data_Customer();
     49
     50        $discount_percent             = 0.0;
     51        $participant_discount_percent = 0.0;
     52        $customer_invoice_email       = '';
     53
     54        if ( isset( EDU()->session['eduadmin-loginUser'] ) ) {
     55            $user     = EDU()->session['eduadmin-loginUser'];
     56            $contact  = $user->Contact;
     57            $customer = $user->Customer;
     58        }
     59
     60        $no_invoice_free_events = EDU()->is_checked( 'eduadmin-noInvoiceFreeEvents', false );
     61
     62        $first_price = current( $programme['PriceNames'] );
     63
     64        $show_invoice_email             = isset( $attributes['hideinvoiceemailfield'] ) ? false === $attributes['hideinvoiceemailfield'] : ! EDU()->is_checked( 'eduadmin-hideInvoiceEmailField', false );
     65        $force_show_invoice_information = isset( $attributes['showinvoiceinformation'] ) ? false === $attributes['showinvoiceinformation'] : EDU()->is_checked( 'eduadmin-showInvoiceInformation', false );
     66
     67        $block_edit_if_logged_in = EDU()->is_checked( 'eduadmin-blockEditIfLoggedIn', true );
     68        $__block                 = ( $block_edit_if_logged_in && isset( $contact->PersonId ) && 0 !== $contact->PersonId );
     69
     70        $questions = EDUAPI()->REST->ProgrammeStart->BookingQuestions( $programme['ProgrammeStartId'], true );
     71
     72        $booking_questions     = $questions['BookingQuestions'];
     73        $participant_questions = $questions['ParticipantQuestions'];
     74
     75        ?>
     76        <div class="eduadmin booking-page" data-courseid="<?php echo esc_attr( $programme['ProgrammeId'] ); ?>"
     77             data-eventid="<?php echo( isset( $_REQUEST['id'] ) ? esc_attr( sanitize_text_field( $_REQUEST['id'] ) ) : '' ); ?>">
     78            <form action="" method="post" id="edu-booking-form">
     79                <input type="hidden" name="act" value="bookProgramme" />
     80                <input type="hidden" name="edu-programme-start" value="<?php echo intval( $_REQUEST['id'] ); ?>" />
     81                <input type="hidden" name="edu-valid-form"
     82                       value="<?php echo esc_attr( wp_create_nonce( 'edu-booking-confirm' ) ); ?>" />
     83                <div class="not-a-good-idea">
     84                    <input type="text" name="username" />
     85                    <input type="text" name="email" />
     86                </div>
     87                <a href="javascript://" onclick="eduGlobalMethods.GoBack('../', event);"
     88                   class="backLink"><?php echo esc_html_x( '« Go back', 'frontend', 'eduadmin-booking' ); ?></a>
     89
     90                <div class="title">
     91                    <h1 class="courseTitle">
     92                        <?php echo esc_html( $programme['ProgrammeStartName'] ) . ' (' . wp_kses_post( get_display_date( $programme['StartDate'] ) ) . ' - ' . wp_kses_post( get_display_date( $programme['EndDate'] ) ) . ')'; ?>
     93                    </h1>
     94                </div>
     95                <?php
     96
     97                if ( ! empty( $customer->BillingInfo ) ) {
     98                    $billing_customer = $customer->BillingInfo;
     99                } else {
     100                    $billing_customer = new EduAdmin_Data_BillingInfo();
     101                }
     102                if ( isset( $contact->PersonId ) && 0 !== $contact->PersonId ) {
     103                    echo '<input type="hidden" name="edu-contactId" value="' . esc_attr( $contact->PersonId ) . '" />';
     104                }
     105                if ( isset( $customer->CustomerId ) && 0 !== $customer->CustomerId ) {
     106                    echo '<input type="hidden" name="edu-customerId" value="' . esc_attr( $customer->CustomerId ) . '" />';
     107                }
     108                ?>
     109                <br />
     110                <div class="contactView">
     111                    <h2><?php echo esc_html_x( 'Contact information', 'frontend', 'eduadmin-booking' ); ?></h2>
     112                    <label onclick="event.preventDefault()" class="edu-book-contact-contactName">
     113                        <div class="inputLabel">
     114                            <?php echo esc_html_x( 'Contact name', 'frontend', 'eduadmin-booking' ); ?>
     115                        </div>
     116                        <div class="inputHolder"><input type="text" autocomplete="off"
     117                                <?php echo( $__block ? ' readonly' : '' ); ?>
     118                                                        required onchange="eduBookingView.ContactAsParticipant();"
     119                                                        id="edu-contactFirstName" name="contactFirstName"
     120                                                        class="first-name" maxlength="100"
     121                                                        placeholder="<?php echo esc_attr_x( 'Contact first name', 'frontend', 'eduadmin-booking' ); ?>"
     122                                                        value="<?php echo esc_attr( $contact->FirstName ); ?>" /><input
     123                                type="text" <?php echo( $__block ? ' readonly' : '' ); ?>
     124                                required onchange="eduBookingView.ContactAsParticipant();" id="edu-contactLastName"
     125                                class="last-name" name="contactLastName" maxlength="100"
     126                                placeholder="<?php echo esc_attr_x( 'Contact surname', 'frontend', 'eduadmin-booking' ); ?>"
     127                                value="<?php echo esc_attr( $contact->LastName ); ?>" />
     128                        </div>
     129                    </label>
     130                    <label class="edu-book-contact-contactEmail">
     131                        <div class="inputLabel">
     132                            <?php echo esc_html_x( 'E-mail address', 'frontend', 'eduadmin-booking' ); ?>
     133                        </div>
     134                        <div class="inputHolder">
     135                            <input type="email" autocomplete="off" id="edu-contactEmail" required
     136                                   name="contactEmail"<?php echo( $__block ? ' readonly' : '' ); ?>
     137                                   onchange="eduBookingView.ContactAsParticipant();" maxlength="200"
     138                                   placeholder="<?php echo esc_attr_x( 'E-mail address', 'frontend', 'eduadmin-booking' ); ?>"
     139                                   value="<?php echo esc_attr( $contact->Email ); ?>" />
     140                        </div>
     141                    </label>
     142                    <label class="edu-book-contact-contactPhone">
     143                        <div class="inputLabel">
     144                            <?php echo esc_html_x( 'Phone number', 'frontend', 'eduadmin-booking' ); ?>
     145                        </div>
     146                        <div class="inputHolder">
     147                            <input type="tel" autocomplete="off" id="edu-contactPhone" name="contactPhone"
     148                                   onchange="eduBookingView.ContactAsParticipant();" maxlength="100"
     149                                   placeholder="<?php echo esc_attr_x( 'Phone number', 'frontend', 'eduadmin-booking' ); ?>"
     150                                   value="<?php echo esc_attr( $contact->Phone ); ?>" />
     151                        </div>
     152                    </label>
     153                    <label class="edu-book-contact-contactMobile">
     154                        <div class="inputLabel">
     155                            <?php echo esc_html_x( 'Mobile number', 'frontend', 'eduadmin-booking' ); ?>
     156                        </div>
     157                        <div class="inputHolder">
     158                            <input type="tel" autocomplete="off" id="edu-contactMobile" name="contactMobile"
     159                                   onchange="eduBookingView.ContactAsParticipant();" maxlength="100"
     160                                   placeholder="<?php echo esc_attr_x( 'Mobile number', 'frontend', 'eduadmin-booking' ); ?>"
     161                                   value="<?php echo esc_attr( $contact->Mobile ); ?>" />
     162                        </div>
     163                    </label>
     164                    <?php $selected_login_field = EDU()->get_option( 'eduadmin-loginField', 'Email' ); ?>
     165                    <?php if ( 'CivicRegistrationNumber' === $selected_login_field ) { ?>
     166                        <label class="edu-book-contact-contactCivicRegNo">
     167                            <div class="inputLabel">
     168                                <?php echo esc_html_x( 'Civic Registration Number', 'frontend', 'eduadmin-booking' ); ?>
     169                            </div>
     170                            <div class="inputHolder">
     171                                <input type="text" autocomplete="off" id="edu-contactCivReg" required
     172                                       name="contactCivReg" pattern="(\d{2,4})-?(\d{2,2})-?(\d{2,2})-?(\d{4,4})"
     173                                       class="eduadmin-civicRegNo" onchange="eduBookingView.ContactAsParticipant();"
     174                                       maxlength="50"
     175                                       placeholder="<?php echo esc_attr_x( 'Civic Registration Number', 'frontend', 'eduadmin-booking' ); ?>"
     176                                       value="<?php echo esc_attr( $contact->CivicRegistrationNumber ); ?>" />
     177                            </div>
     178                        </label>
     179                    <?php } ?>
     180                    <?php if ( EDU()->is_checked( 'eduadmin-useLogin', false ) && ! $contact->CanLogin ) { ?>
     181                        <label class="edu-book-contact-contactPassword">
     182                            <div class="inputLabel">
     183                                <?php echo esc_html_x( 'Please enter a password', 'frontend', 'eduadmin-booking' ); ?>
     184                            </div>
     185                            <div class="inputHolder">
     186                                <input type="password" autocomplete="off" required name="contactPass" maxlength="50"
     187                                       placeholder="<?php echo esc_attr_x( 'Please enter a password', 'frontend', 'eduadmin-booking' ); ?>" />
     188                            </div>
     189                        </label>
     190                    <?php } ?>
     191                    <div class="edu-modal warning" id="edu-warning-participants-contact">
     192                        <?php echo esc_html_x( 'You cannot add any more participants.', 'frontend', 'eduadmin-booking' ); ?>
     193                    </div>
     194                </div>
     195                <div class="attributeView">
     196                    <?php
     197                    $contact_custom_fields = EDUAPI()->OData->CustomFields->Search(
     198                        null,
     199                        'ShowOnWeb and CustomFieldOwner eq \'Person\'',
     200                        'CustomFieldAlternatives',
     201                        'SortIndex'
     202                    )['value'];
     203
     204                    foreach ( $contact_custom_fields as $custom_field ) {
     205                        $data = null;
     206                        if ( null !== $contact && null !== $contact->CustomFields ) {
     207                            foreach ( $contact->CustomFields as $cf ) {
     208                                if ( $cf->CustomFieldId === $custom_field['CustomFieldId'] ) {
     209                                    switch ( $cf->CustomFieldType ) {
     210                                        case 'Checkbox':
     211                                            $data = $cf->CustomFieldChecked;
     212                                            break;
     213                                        case 'Dropdown':
     214                                            $data = $cf->CustomFieldAlternativeId;
     215                                            break;
     216                                        default:
     217                                            $data = $cf->CustomFieldValue;
     218                                            break;
     219                                    }
     220                                    break;
     221                                }
     222                            }
     223                        }
     224                        render_attribute( $custom_field, false, 'contact', $data );
     225                    }
     226
     227                    ?>
     228                </div>
     229                <div class="customerView">
     230                    <h2><?php echo esc_html_x( 'Customer information', 'frontend', 'eduadmin-booking' ); ?></h2>
     231                    <label class="edu-book-customerName">
     232                        <div class="inputLabel">
     233                            <?php echo esc_html_x( 'Customer name', 'frontend', 'eduadmin-booking' ); ?>
     234                        </div>
     235                        <div class="inputHolder">
     236                            <input type="text" autocomplete="off" required name="customerName"
     237                                   autocomplete="organization" maxlength="200"
     238                                   placeholder="<?php echo esc_attr_x( 'Customer name', 'frontend', 'eduadmin-booking' ); ?>"
     239                                   value="<?php echo esc_attr( $customer->CustomerName ); ?>" />
     240                        </div>
     241                    </label>
     242                    <?php
     243                    if ( empty( $no_invoice_free_events ) || ( $no_invoice_free_events && $first_price['Price'] > 0 ) ) {
     244                        ?>
     245                        <label class="edu-book-customerVatNo">
     246                            <div class="inputLabel">
     247                                <?php echo esc_html_x( 'Org.No.', 'frontend', 'eduadmin-booking' ); ?>
     248                            </div>
     249                            <div class="inputHolder">
     250                                <input type="text" autocomplete="off" name="customerVatNo" maxlength="50"
     251                                       placeholder="<?php echo esc_attr_x( 'Org.No.', 'frontend', 'eduadmin-booking' ); ?>"
     252                                       value="<?php echo esc_attr( $customer->OrganisationNumber ); ?>" />
     253                            </div>
     254                        </label>
     255                        <label class="edu-book-customerAddress1">
     256                            <div class="inputLabel">
     257                                <?php echo esc_html_x( 'Address 1', 'frontend', 'eduadmin-booking' ); ?>
     258                            </div>
     259                            <div class="inputHolder">
     260                                <input type="text" autocomplete="off" name="customerAddress1" maxlength="200"
     261                                       placeholder="<?php echo esc_attr_x( 'Address 1', 'frontend', 'eduadmin-booking' ); ?>"
     262                                       value="<?php echo esc_attr( $customer->Address ); ?>" />
     263                            </div>
     264                        </label>
     265                        <label class="edu-book-customerAddress2">
     266                            <div class="inputLabel">
     267                                <?php echo esc_html_x( 'Address 2', 'frontend', 'eduadmin-booking' ); ?>
     268                            </div>
     269                            <div class="inputHolder">
     270                                <input type="text" autocomplete="off" name="customerAddress2" maxlength="200"
     271                                       placeholder="<?php echo esc_attr_x( 'Address 2', 'frontend', 'eduadmin-booking' ); ?>"
     272                                       value="<?php echo esc_attr( $customer->Address2 ); ?>" />
     273                            </div>
     274                        </label>
     275                        <label class="edu-book-customerPostalCode">
     276                            <div class="inputLabel">
     277                                <?php echo esc_html_x( 'Postal code', 'frontend', 'eduadmin-booking' ); ?>
     278                            </div>
     279                            <div class="inputHolder">
     280                                <input type="text" autocomplete="off" name="customerPostalCode" maxlength="50"
     281                                       placeholder="<?php echo esc_attr_x( 'Postal code', 'frontend', 'eduadmin-booking' ); ?>"
     282                                       value="<?php echo esc_attr( $customer->Zip ); ?>" />
     283                            </div>
     284                        </label>
     285                        <label class="edu-book-customerPostalCity">
     286                            <div class="inputLabel">
     287                                <?php echo esc_html_x( 'Postal city', 'frontend', 'eduadmin-booking' ); ?>
     288                            </div>
     289                            <div class="inputHolder">
     290                                <input type="text" autocomplete="off" name="customerPostalCity" maxlength="200"
     291                                       placeholder="<?php echo esc_attr_x( 'Postal city', 'frontend', 'eduadmin-booking' ); ?>"
     292                                       value="<?php echo esc_attr( $customer->City ); ?>" />
     293                            </div>
     294                        </label>
     295                        <label class="edu-book-customerCountry">
     296                            <div class="inputLabel">
     297                                <?php echo esc_html_x( 'Country', 'frontend', 'eduadmin-booking' ); ?>
     298                            </div>
     299                            <div class="inputHolder">
     300                                <?php edu_get_country_list( 'customerCountryCode', $customer->CountryCode ); ?>
     301                            </div>
     302                        </label>
     303                        <label class="edu-book-customerEmailAddress">
     304                            <div class="inputLabel">
     305                                <?php echo esc_html_x( 'E-mail address', 'frontend', 'eduadmin-booking' ); ?>
     306                            </div>
     307                            <div class="inputHolder">
     308                                <input type="text" autocomplete="off" name="customerEmail" maxlength="200"
     309                                       placeholder="<?php echo esc_attr_x( 'E-mail address', 'frontend', 'eduadmin-booking' ); ?>"
     310                                       value="<?php echo esc_attr( $customer->Email ); ?>" />
     311                            </div>
     312                        </label>
     313                        <div id="invoiceView" class="invoiceView"
     314                             style="<?php echo( $force_show_invoice_information ? 'display: block;' : 'display: none;' ); ?>">
     315                            <h2><?php echo esc_html_x( 'Invoice information', 'frontend', 'eduadmin-booking' ); ?></h2>
     316                            <label class="edu-book-invoice-customerName">
     317                                <div class="inputLabel">
     318                                    <?php echo esc_html_x( 'Customer name', 'frontend', 'eduadmin-booking' ); ?>
     319                                </div>
     320                                <div class="inputHolder">
     321                                    <input type="text" autocomplete="off" name="invoiceName" maxlength="200"
     322                                           placeholder="<?php echo esc_attr_x( 'Customer name', 'frontend', 'eduadmin-booking' ); ?>"
     323                                           value="<?php echo esc_attr( $billing_customer->CustomerName ); ?>" />
     324                                </div>
     325                            </label>
     326                            <label class="edu-book-invoice-customerAddress1">
     327                                <div class="inputLabel">
     328                                    <?php echo esc_html_x( 'Address 1', 'frontend', 'eduadmin-booking' ); ?>
     329                                </div>
     330                                <div class="inputHolder">
     331                                    <input type="text" autocomplete="off" name="invoiceAddress1" maxlength="200"
     332                                           placeholder="<?php echo esc_attr_x( 'Address 1', 'frontend', 'eduadmin-booking' ); ?>"
     333                                           value="<?php echo esc_attr( $billing_customer->Address ); ?>" />
     334                                </div>
     335                            </label>
     336                            <label class="edu-book-invoice-customerAddress2">
     337                                <div class="inputLabel">
     338                                    <?php echo esc_html_x( 'Address 2', 'frontend', 'eduadmin-booking' ); ?>
     339                                </div>
     340                                <div class="inputHolder">
     341                                    <input type="text" autocomplete="off" name="invoiceAddress2" maxlength="200"
     342                                           placeholder="<?php echo esc_attr_x( 'Address 2', 'frontend', 'eduadmin-booking' ); ?>"
     343                                           value="<?php echo esc_attr( $billing_customer->Address2 ); ?>" />
     344                                </div>
     345                            </label>
     346                            <label class="edu-book-invoice-customerPostalCode">
     347                                <div class="inputLabel">
     348                                    <?php echo esc_html_x( 'Postal code', 'frontend', 'eduadmin-booking' ); ?>
     349                                </div>
     350                                <div class="inputHolder">
     351                                    <input type="text" autocomplete="off" name="invoicePostalCode" maxlength="50"
     352                                           placeholder="<?php echo esc_attr_x( 'Postal code', 'frontend', 'eduadmin-booking' ); ?>"
     353                                           value="<?php echo esc_attr( $billing_customer->Zip ); ?>" />
     354                                </div>
     355                            </label>
     356                            <label class="edu-book-invoice-customerPostalCity">
     357                                <div class="inputLabel">
     358                                    <?php echo esc_html_x( 'Postal city', 'frontend', 'eduadmin-booking' ); ?>
     359                                </div>
     360                                <div class="inputHolder">
     361                                    <input type="text" autocomplete="off" name="invoicePostalCity" maxlength="200"
     362                                           placeholder="<?php echo esc_attr_x( 'Postal city', 'frontend', 'eduadmin-booking' ); ?>"
     363                                           value="<?php echo esc_attr( $billing_customer->City ); ?>" />
     364                                </div>
     365                            </label>
     366                            <label class="edu-book-invoice-customerCountry">
     367                                <div class="inputLabel">
     368                                    <?php echo esc_html_x( 'Country', 'frontend', 'eduadmin-booking' ); ?>
     369                                </div>
     370                                <div class="inputHolder">
     371                                    <?php edu_get_country_list( 'invoiceCountryCode', $billing_customer->CountryCode, false ); ?>
     372                                </div>
     373                            </label>
     374                        </div>
     375                        <?php if ( $show_invoice_email ) { ?>
     376                            <label class="edu-book-invoice-customerInvoiceEmail">
     377                                <div class="inputLabel">
     378                                    <?php echo esc_html_x( 'Invoice e-mail address', 'frontend', 'eduadmin-booking' ); ?>
     379                                </div>
     380                                <div class="inputHolder">
     381                                    <input type="text" autocomplete="off" name="invoiceEmail" maxlength="20"
     382                                           placeholder="<?php echo esc_attr_x( 'Invoice e-mail address', 'frontend', 'eduadmin-booking' ); ?>"
     383                                           value="<?php echo esc_attr( $billing_customer->Email ); ?>" />
     384                                </div>
     385                            </label>
     386                        <?php } ?>
     387                        <label class="edu-book-invoice-customerInvoiceReference">
     388                            <div class="inputLabel">
     389                                <?php echo esc_html_x( 'Invoice reference', 'frontend', 'eduadmin-booking' ); ?>
     390                            </div>
     391                            <div class="inputHolder">
     392                                <input type="text" autocomplete="off" name="invoiceReference" maxlength="100"
     393                                       placeholder="<?php echo esc_attr_x( 'Invoice reference', 'frontend', 'eduadmin-booking' ); ?>"
     394                                       value="<?php echo esc_attr( ! empty( $billing_customer->SellerReference ) ? $billing_customer->SellerReference : '' ); ?>" />
     395                            </div>
     396                        </label>
     397                        <label class="edu-book-invoice-customerPurchaseOrderNumber">
     398                            <div class="inputLabel">
     399                                <?php echo esc_html_x( 'Purchase order number', 'frontend', 'eduadmin-booking' ); ?>
     400                            </div>
     401                            <div class="inputHolder">
     402                                <input type="text" autocomplete="off" name="purchaseOrderNumber" maxlength="200"
     403                                       placeholder="<?php echo esc_attr_x( 'Purchase order number', 'frontend', 'eduadmin-booking' ); ?>"
     404                                       value="<?php echo esc_attr( ! empty( $_POST['purchaseOrderNumber'] ) ? $_POST['purchaseOrderNumber'] : '' ); ?>" />
     405                            </div>
     406                        </label>
     407                        <label class="edu-book-invoice-customerEdiReference">
     408                            <div class="inputLabel">
     409                                <?php echo esc_html_x( 'EDI Reference', 'frontend', 'eduadmin-booking' ); ?>
     410                            </div>
     411                            <div class="inputHolder">
     412                                <input type="text" autocomplete="off" name="ediReference" maxlength="100"
     413                                       placeholder="<?php echo esc_attr_x( 'EDI Reference', 'frontend', 'eduadmin-booking' ); ?>"
     414                                       value="<?php echo esc_attr( ! empty( $billing_customer->EdiReference ) ? $billing_customer->EdiReference : '' ); ?>" />
     415                            </div>
     416                        </label>
     417                        <?php
     418                    }
     419
     420                    $customer_custom_fields = EDUAPI()->OData->CustomFields->Search(
     421                        null,
     422                        'ShowOnWeb and CustomFieldOwner eq \'Customer\'',
     423                        'CustomFieldAlternatives',
     424                        'SortIndex'
     425                    )['value'];
     426
     427                    foreach ( $customer_custom_fields as $custom_field ) {
     428                        $data = null;
     429                        if ( ! empty( $customer->CustomFields ) ) {
     430                            foreach ( $customer->CustomFields as $cf ) {
     431                                if ( $cf->CustomFieldId === $custom_field['CustomFieldId'] ) {
     432                                    switch ( $cf->CustomFieldType ) {
     433                                        case 'Checkbox':
     434                                            $data = $cf->CustomFieldChecked;
     435                                            break;
     436                                        case 'Dropdown':
     437                                            $data = $cf->CustomFieldAlternativeId;
     438                                            break;
     439                                        default:
     440                                            $data = $cf->CustomFieldValue;
     441                                            break;
     442                                    }
     443                                    break;
     444                                }
     445                            }
     446                        }
     447                        render_attribute( $custom_field, false, 'customer', $data );
     448                    }
     449                    if ( ! $no_invoice_free_events || $first_price['Price'] > 0 ) {
     450                        ?>
     451                        <label<?php echo $force_show_invoice_information ? ' style="display: none;"' : ''; ?>>
     452                            <div class="inputHolder alsoInvoiceCustomer">
     453                                <label class="inline-checkbox" for="alsoInvoiceCustomer">
     454                                    <input type="checkbox" id="alsoInvoiceCustomer" name="alsoInvoiceCustomer"
     455                                           value="true" onchange="eduBookingView.UpdateInvoiceCustomer(this);"
     456                                        <?php echo $force_show_invoice_information ? 'checked' : ''; ?>/>
     457                                    <?php echo esc_html_x( 'Use other information for invoicing', 'frontend', 'eduadmin-booking' ); ?>
     458                                </label>
     459                            </div>
     460                        </label>
     461                    <?php } ?>
     462                    <?php if ( EDU()->is_checked( 'eduadmin-useLogin', false ) && EDU()->is_checked( 'eduadmin-allowCustomerUpdate', false ) && isset( $customer->CustomerId ) && 0 !== $customer->CustomerId ) { ?>
     463                        <label>
     464                            <div class="inputHolder">
     465                                <label class="inline-checkbox" for="overwriteCustomerData">
     466                                    <input type="checkbox" id="overwriteCustomerData" name="overwriteCustomerData"
     467                                           value="true" />
     468                                    <?php echo esc_html_x( 'Also update my customer information for future use', 'frontend', 'eduadmin-booking' ); ?>
     469                                </label>
     470                            </div>
     471                        </label>
     472                    <?php } ?>
     473                </div>
     474                <div class="questionPanel">
     475                    <?php
     476                    if ( ! empty( $_REQUEST['eid'] ) ) {
     477                        foreach ( $booking_questions as $question ) {
     478                            render_question( $question, false, 'booking' );
     479                        }
     480                    }
     481                    ?>
     482                </div>
     483                <div class="participantView">
     484                    <h2><?php echo esc_html_x( 'Participant information', 'frontend', 'eduadmin-booking' ); ?></h2>
     485                    <div class="participantHolder" id="edu-participantHolder">
     486                        <div class="participantItem template" style="display: none;">
     487                            <h3>
     488                                <?php echo esc_html_x( 'Participant', 'frontend', 'eduadmin-booking' ); ?>
     489                                <?php if ( ! EDU()->is_checked( 'eduadmin-singlePersonBooking', false ) ) { ?>
     490                                    <div class="removeParticipant"
     491                                         onclick="eduBookingView.RemoveParticipant(this);"><?php echo esc_html_x( 'Remove', 'frontend', 'eduadmin-booking' ); ?></div>
     492                                <?php } ?>
     493                            </h3>
     494                            <label onclick="event.preventDefault()">
     495                                <div class="inputLabel">
     496                                    <?php echo esc_html_x( 'Participant name', 'frontend', 'eduadmin-booking' ); ?>
     497                                </div>
     498                                <div class="inputHolder">
     499                                    <input type="text" autocomplete="off" class="participantFirstName first-name"
     500                                           onchange="eduBookingView.CheckPrice(false);" name="participantFirstName[]"
     501                                           maxlength="100"
     502                                           placeholder="<?php echo esc_attr_x( 'Participant first name', 'frontend', 'eduadmin-booking' ); ?>" /><input
     503                                        type="text" class="participantLastName last-name"
     504                                        onchange="eduBookingView.CheckPrice(false);" name="participantLastName[]"
     505                                        maxlength="100"
     506                                        placeholder="<?php echo esc_attr_x( 'Participant surname', 'frontend', 'eduadmin-booking' ); ?>" />
     507                                </div>
     508                            </label>
     509                            <label>
     510                                <div class="inputLabel">
     511                                    <?php echo esc_html_x( 'E-mail address', 'frontend', 'eduadmin-booking' ); ?>
     512                                </div>
     513                                <div class="inputHolder">
     514                                    <input type="email" autocomplete="off" name="participantEmail[]"
     515                                           onchange="eduBookingView.CheckPrice(false);" maxlength="200"
     516                                           placeholder="<?php echo esc_attr_x( 'E-mail address', 'frontend', 'eduadmin-booking' ); ?>" />
     517                                </div>
     518                            </label>
     519                            <label>
     520                                <div class="inputLabel">
     521                                    <?php echo esc_html_x( 'Phone number', 'frontend', 'eduadmin-booking' ); ?>
     522                                </div>
     523                                <div class="inputHolder">
     524                                    <input type="tel" autocomplete="off" name="participantPhone[]" maxlength="100"
     525                                           placeholder="<?php echo esc_attr_x( 'Phone number', 'frontend', 'eduadmin-booking' ); ?>" />
     526                                </div>
     527                            </label>
     528                            <label>
     529                                <div class="inputLabel">
     530                                    <?php echo esc_html_x( 'Mobile number', 'frontend', 'eduadmin-booking' ); ?>
     531                                </div>
     532                                <div class="inputHolder">
     533                                    <input type="tel" autocomplete="off" name="participantMobile[]" maxlength="100"
     534                                           placeholder="<?php echo esc_attr_x( 'Mobile number', 'frontend', 'eduadmin-booking' ); ?>" />
     535                                </div>
     536                            </label>
     537                            <?php
     538                            if ( ! empty( $contact_custom_fields ) ) {
     539                                foreach ( $contact_custom_fields as $attr ) {
     540                                    render_attribute( $attr, true, 'participant' );
     541                                }
     542                            }
     543
     544                            if ( ! empty( $participant_questions ) ) {
     545                                foreach ( $participant_questions as $question ) {
     546                                    render_question( $question, true, 'participant' );
     547                                }
     548                            }
     549                            ?>
     550                        </div>
     551                    </div>
     552                    <?php if ( ! EDU()->is_checked( 'eduadmin-singlePersonBooking', false ) ) { ?>
     553                        <div>
     554                            <a href="javascript://" class="addParticipantLink neutral-btn"
     555                               onclick="eduBookingView.AddParticipant(); return false;"><?php echo esc_html_x( '+ Add participant', 'frontend', 'eduadmin-booking' ); ?></a>
     556                        </div>
     557                    <?php } ?>
     558                    <div class="edu-modal warning" id="edu-warning-participants">
     559                        <?php echo esc_html_x( 'You cannot add any more participants.', 'frontend', 'eduadmin-booking' ); ?>
     560                    </div>
     561                </div>
     562                <?php
     563                include_once 'coupon-code.php';
     564                include_once __DIR__ . '/../payment-methods.php';
     565                include_once __DIR__ . '/../recaptcha-form.php';
     566                eduadmin_render_payment_methods( $programme );
     567                eduadmin_render_recaptcha_form();
     568                ?>
     569                <div class="submitView">
     570                    <?php if ( EDU()->is_checked( 'eduadmin-useBookingTermsCheckbox', false ) && $link = EDU()->get_option( 'eduadmin-bookingTermsLink', '' ) ): ?>
     571                        <div class="confirmTermsHolder">
     572                            <label>
     573                                <input type="checkbox" id="confirmTerms" name="confirmTerms" value="agree" />
     574                                <?php
     575                                /* translators: 1: Start of link 2: End of link */
     576                                echo wp_kses( sprintf( _x( 'I agree to the %1$sTerms and Conditions%2$s', 'frontend', 'eduadmin-booking' ), '<a href="' . $link . '" target="_blank">', '</a>' ), wp_kses_allowed_html( 'post' ) );
     577                                ?>
     578                            </label>
     579                        </div>
     580                    <?php endif; ?>
     581                    <div class="sumTotal">
     582                        <?php echo esc_html_x( 'Total sum:', 'frontend', 'eduadmin-booking' ); ?>
     583                        <span id="sumValue" class="sumValue"></span>
     584                    </div>
     585                    <?php if ( 0 !== $programme['ParticipantNumberLeft'] ) : ?>
     586                        <input type="submit" class="bookButton cta-btn" id="edu-book-btn"
     587                               onclick="eduBookingView.UpdatePrice(); var validated = eduBookingView.CheckValidation(false, false); return validated;"
     588                               value="<?php echo esc_attr_x( 'Book now', 'frontend', 'eduadmin-booking' ); ?>" />
     589                    <?php else : ?>
     590                        <div class="bookButton neutral-btn cta-disabled">
     591                            <?php echo esc_html_x( 'No free spots left on this event', 'frontend', 'eduadmin-booking' ); ?>
     592                        </div>
     593                    <?php endif; ?>
     594                    <div class="edu-modal warning" id="edu-warning-pricecheck"></div>
     595                    <div class="edu-modal warning" id="edu-warning-recaptcha">
     596                        <?php echo esc_html_x( 'You must confirm that you are not a bot before continuing.', 'frontend', 'eduadmin-booking' ); ?>
     597                    </div>
     598                    <div class="edu-modal warning" id="edu-warning-terms">
     599                        <?php echo esc_html_x( 'You must accept Terms and Conditions to continue.', 'frontend', 'eduadmin-booking' ); ?>
     600                    </div>
     601                    <div class="edu-modal warning" id="edu-warning-no-participants">
     602                        <?php echo esc_html_x( 'You must add some participants.', 'frontend', 'eduadmin-booking' ); ?>
     603                    </div>
     604                    <div class="edu-modal warning" id="edu-warning-missing-participants">
     605                        <?php echo esc_html_x( 'One or more participants is missing a name.', 'frontend', 'eduadmin-booking' ); ?>
     606                    </div>
     607                    <div class="edu-modal warning" id="edu-warning-missing-civicregno">
     608                        <?php echo esc_html_x( 'One or more participants is missing their civic registration number.', 'frontend', 'eduadmin-booking' ); ?>
     609                    </div>
     610                    <?php
     611                    $error_list = apply_filters( 'edu-booking-error', array() );
     612                    foreach ( $error_list as $error ) {
     613                        ?>
     614                        <div class="edu-modal warning">
     615                            <?php esc_html( $error ); ?>
     616                        </div>
     617                        <?php
     618                    }
     619                    ?>
     620                </div>
     621                <?php
     622                $original_title = get_the_title();
     623                $new_title      = $programme['ProgrammeStartName'] . ' | ' . $original_title;
     624
     625                $discount_value = 0.0;
     626                if ( 0 !== $participant_discount_percent ) {
     627                    $discount_value = ( $participant_discount_percent / 100 ) * $first_price['Price'];
     628                }
    31629                ?>
    32630                <script type="text/javascript">
    33                     <?php echo EDU()->get_option( 'eduadmin-booking-form-javascript', '' ); ?>
     631                    var pricePerParticipant = <?php echo esc_js( round( $first_price['Price'] - $discount_value, 2 ) ); ?>;
     632                    var discountPerParticipant = <?php echo esc_js( round( $participant_discount_percent / 100, 2 ) ); ?>;
     633                    var totalPriceDiscountPercent = <?php echo esc_js( $discount_percent ); ?>;
     634
     635                    (function () {
     636                        var title = document.title;
     637                        title = title.replace('<?php echo esc_js( $original_title ); ?>', '<?php echo esc_js( $new_title ); ?>');
     638                        document.title = title;
     639                        eduBookingView.ProgrammeBooking = true;
     640                        eduBookingView.MaxParticipants = <?php echo esc_js( intval( $programme['ParticipantNumberLeft'] ) ); ?>;
     641                        eduBookingView.AddParticipant();
     642                        eduBookingView.CheckPrice(false);
     643                    })();
    34644                </script>
    35                 <?php
    36                 $GLOBALS['eduadmin-booking-form-javascript-set'] = true;
    37             }
    38         } else {
    39             echo _x( 'The booking form needs configuration in EduAdmin before this works.', 'frontend', 'eduadmin-booking' );
    40         }
    41 
    42         return;
     645            </form>
     646        </div>
     647        <?php
     648        do_action( 'eduadmin-programme-bookingform-view', $programme );
    43649    }
    44 
    45     $contact  = new EduAdmin_Data_ContactPerson();
    46     $customer = new EduAdmin_Data_Customer();
    47 
    48     $discount_percent             = 0.0;
    49     $participant_discount_percent = 0.0;
    50     $customer_invoice_email       = '';
    51 
    52     if ( isset( EDU()->session['eduadmin-loginUser'] ) ) {
    53         $user     = EDU()->session['eduadmin-loginUser'];
    54         $contact  = $user->Contact;
    55         $customer = $user->Customer;
    56     }
    57 
    58     $no_invoice_free_events = EDU()->is_checked( 'eduadmin-noInvoiceFreeEvents', false );
    59 
    60     $first_price = current( $programme['PriceNames'] );
    61 
    62     $show_invoice_email             = isset( $attributes['hideinvoiceemailfield'] ) ? false === $attributes['hideinvoiceemailfield'] : ! EDU()->is_checked( 'eduadmin-hideInvoiceEmailField', false );
    63     $force_show_invoice_information = isset( $attributes['showinvoiceinformation'] ) ? false === $attributes['showinvoiceinformation'] : EDU()->is_checked( 'eduadmin-showInvoiceInformation', false );
    64 
    65     $block_edit_if_logged_in = EDU()->is_checked( 'eduadmin-blockEditIfLoggedIn', true );
    66     $__block                 = ( $block_edit_if_logged_in && isset( $contact->PersonId ) && 0 !== $contact->PersonId );
    67 
    68     $questions = EDUAPI()->REST->ProgrammeStart->BookingQuestions( $programme['ProgrammeStartId'], true );
    69 
    70     $booking_questions     = $questions['BookingQuestions'];
    71     $participant_questions = $questions['ParticipantQuestions'];
    72 
    73     ?>
    74     <div class="eduadmin booking-page" data-courseid="<?php echo esc_attr( $programme['ProgrammeId'] ); ?>"
    75          data-eventid="<?php echo( isset( $_REQUEST['id'] ) ? esc_attr( sanitize_text_field( $_REQUEST['id'] ) ) : '' ); ?>">
    76         <form action="" method="post" id="edu-booking-form">
    77             <input type="hidden" name="act" value="bookProgramme" />
    78             <input type="hidden" name="edu-programme-start" value="<?php echo intval( $_REQUEST['id'] ); ?>" />
    79             <input type="hidden" name="edu-valid-form"
    80                    value="<?php echo esc_attr( wp_create_nonce( 'edu-booking-confirm' ) ); ?>" />
    81             <div class="not-a-good-idea">
    82                 <input type="text" name="username" />
    83                 <input type="text" name="email" />
    84             </div>
    85             <a href="javascript://" onclick="eduGlobalMethods.GoBack('../', event);"
    86                class="backLink"><?php echo esc_html_x( '« Go back', 'frontend', 'eduadmin-booking' ); ?></a>
    87 
    88             <div class="title">
    89                 <h1 class="courseTitle">
    90                     <?php echo esc_html( $programme['ProgrammeStartName'] ) . ' (' . wp_kses_post( get_display_date( $programme['StartDate'] ) ) . ' - ' . wp_kses_post( get_display_date( $programme['EndDate'] ) ) . ')'; ?>
    91                 </h1>
    92             </div>
    93             <?php
    94 
    95             if ( ! empty( $customer->BillingInfo ) ) {
    96                 $billing_customer = $customer->BillingInfo;
    97             } else {
    98                 $billing_customer = new EduAdmin_Data_BillingInfo();
    99             }
    100             if ( isset( $contact->PersonId ) && 0 !== $contact->PersonId ) {
    101                 echo '<input type="hidden" name="edu-contactId" value="' . esc_attr( $contact->PersonId ) . '" />';
    102             }
    103             if ( isset( $customer->CustomerId ) && 0 !== $customer->CustomerId ) {
    104                 echo '<input type="hidden" name="edu-customerId" value="' . esc_attr( $customer->CustomerId ) . '" />';
    105             }
    106             ?>
    107             <br />
    108             <div class="contactView">
    109                 <h2><?php echo esc_html_x( 'Contact information', 'frontend', 'eduadmin-booking' ); ?></h2>
    110                 <label onclick="event.preventDefault()" class="edu-book-contact-contactName">
    111                     <div class="inputLabel">
    112                         <?php echo esc_html_x( 'Contact name', 'frontend', 'eduadmin-booking' ); ?>
    113                     </div>
    114                     <div class="inputHolder"><input type="text" autocomplete="off"
    115                             <?php echo( $__block ? ' readonly' : '' ); ?>
    116                                                     required onchange="eduBookingView.ContactAsParticipant();"
    117                                                     id="edu-contactFirstName" name="contactFirstName" class="first-name"
    118                                                     maxlength="100"
    119                                                     placeholder="<?php echo esc_attr_x( 'Contact first name', 'frontend', 'eduadmin-booking' ); ?>"
    120                                                     value="<?php echo esc_attr( $contact->FirstName ); ?>" /><input
    121                             type="text" <?php echo( $__block ? ' readonly' : '' ); ?>
    122                             required onchange="eduBookingView.ContactAsParticipant();" id="edu-contactLastName"
    123                             class="last-name" name="contactLastName" maxlength="100"
    124                             placeholder="<?php echo esc_attr_x( 'Contact surname', 'frontend', 'eduadmin-booking' ); ?>"
    125                             value="<?php echo esc_attr( $contact->LastName ); ?>" />
    126                     </div>
    127                 </label>
    128                 <label class="edu-book-contact-contactEmail">
    129                     <div class="inputLabel">
    130                         <?php echo esc_html_x( 'E-mail address', 'frontend', 'eduadmin-booking' ); ?>
    131                     </div>
    132                     <div class="inputHolder">
    133                         <input type="email" autocomplete="off" id="edu-contactEmail" required
    134                                name="contactEmail"<?php echo( $__block ? ' readonly' : '' ); ?>
    135                                onchange="eduBookingView.ContactAsParticipant();" maxlength="200"
    136                                placeholder="<?php echo esc_attr_x( 'E-mail address', 'frontend', 'eduadmin-booking' ); ?>"
    137                                value="<?php echo esc_attr( $contact->Email ); ?>" />
    138                     </div>
    139                 </label>
    140                 <label class="edu-book-contact-contactPhone">
    141                     <div class="inputLabel">
    142                         <?php echo esc_html_x( 'Phone number', 'frontend', 'eduadmin-booking' ); ?>
    143                     </div>
    144                     <div class="inputHolder">
    145                         <input type="tel" autocomplete="off" id="edu-contactPhone" name="contactPhone"
    146                                onchange="eduBookingView.ContactAsParticipant();" maxlength="100"
    147                                placeholder="<?php echo esc_attr_x( 'Phone number', 'frontend', 'eduadmin-booking' ); ?>"
    148                                value="<?php echo esc_attr( $contact->Phone ); ?>" />
    149                     </div>
    150                 </label>
    151                 <label class="edu-book-contact-contactMobile">
    152                     <div class="inputLabel">
    153                         <?php echo esc_html_x( 'Mobile number', 'frontend', 'eduadmin-booking' ); ?>
    154                     </div>
    155                     <div class="inputHolder">
    156                         <input type="tel" autocomplete="off" id="edu-contactMobile" name="contactMobile"
    157                                onchange="eduBookingView.ContactAsParticipant();" maxlength="100"
    158                                placeholder="<?php echo esc_attr_x( 'Mobile number', 'frontend', 'eduadmin-booking' ); ?>"
    159                                value="<?php echo esc_attr( $contact->Mobile ); ?>" />
    160                     </div>
    161                 </label>
    162                 <?php $selected_login_field = EDU()->get_option( 'eduadmin-loginField', 'Email' ); ?>
    163                 <?php if ( 'CivicRegistrationNumber' === $selected_login_field ) { ?>
    164                     <label class="edu-book-contact-contactCivicRegNo">
    165                         <div class="inputLabel">
    166                             <?php echo esc_html_x( 'Civic Registration Number', 'frontend', 'eduadmin-booking' ); ?>
    167                         </div>
    168                         <div class="inputHolder">
    169                             <input type="text" autocomplete="off" id="edu-contactCivReg" required name="contactCivReg"
    170                                    pattern="(\d{2,4})-?(\d{2,2})-?(\d{2,2})-?(\d{4,4})" class="eduadmin-civicRegNo"
    171                                    onchange="eduBookingView.ContactAsParticipant();" maxlength="50"
    172                                    placeholder="<?php echo esc_attr_x( 'Civic Registration Number', 'frontend', 'eduadmin-booking' ); ?>"
    173                                    value="<?php echo esc_attr( $contact->CivicRegistrationNumber ); ?>" />
    174                         </div>
    175                     </label>
    176                 <?php } ?>
    177                 <?php if ( EDU()->is_checked( 'eduadmin-useLogin', false ) && ! $contact->CanLogin ) { ?>
    178                     <label class="edu-book-contact-contactPassword">
    179                         <div class="inputLabel">
    180                             <?php echo esc_html_x( 'Please enter a password', 'frontend', 'eduadmin-booking' ); ?>
    181                         </div>
    182                         <div class="inputHolder">
    183                             <input type="password" autocomplete="off" required name="contactPass" maxlength="50"
    184                                    placeholder="<?php echo esc_attr_x( 'Please enter a password', 'frontend', 'eduadmin-booking' ); ?>" />
    185                         </div>
    186                     </label>
    187                 <?php } ?>
    188                 <div class="edu-modal warning" id="edu-warning-participants-contact">
    189                     <?php echo esc_html_x( 'You cannot add any more participants.', 'frontend', 'eduadmin-booking' ); ?>
    190                 </div>
    191             </div>
    192             <div class="attributeView">
    193                 <?php
    194                 $contact_custom_fields = EDUAPI()->OData->CustomFields->Search(
    195                     null,
    196                     'ShowOnWeb and CustomFieldOwner eq \'Person\'',
    197                     'CustomFieldAlternatives',
    198                     'SortIndex'
    199                 )['value'];
    200 
    201                 foreach ( $contact_custom_fields as $custom_field ) {
    202                     $data = null;
    203                     if ( null !== $contact && null !== $contact->CustomFields ) {
    204                         foreach ( $contact->CustomFields as $cf ) {
    205                             if ( $cf->CustomFieldId === $custom_field['CustomFieldId'] ) {
    206                                 switch ( $cf->CustomFieldType ) {
    207                                     case 'Checkbox':
    208                                         $data = $cf->CustomFieldChecked;
    209                                         break;
    210                                     case 'Dropdown':
    211                                         $data = $cf->CustomFieldAlternativeId;
    212                                         break;
    213                                     default:
    214                                         $data = $cf->CustomFieldValue;
    215                                         break;
    216                                 }
    217                                 break;
    218                             }
    219                         }
    220                     }
    221                     render_attribute( $custom_field, false, 'contact', $data );
    222                 }
    223 
    224                 ?>
    225             </div>
    226             <div class="customerView">
    227                 <h2><?php echo esc_html_x( 'Customer information', 'frontend', 'eduadmin-booking' ); ?></h2>
    228                 <label class="edu-book-customerName">
    229                     <div class="inputLabel">
    230                         <?php echo esc_html_x( 'Customer name', 'frontend', 'eduadmin-booking' ); ?>
    231                     </div>
    232                     <div class="inputHolder">
    233                         <input type="text" autocomplete="off" required name="customerName" autocomplete="organization"
    234                                maxlength="200"
    235                                placeholder="<?php echo esc_attr_x( 'Customer name', 'frontend', 'eduadmin-booking' ); ?>"
    236                                value="<?php echo esc_attr( $customer->CustomerName ); ?>" />
    237                     </div>
    238                 </label>
    239                 <?php
    240                 if ( empty( $no_invoice_free_events ) || ( $no_invoice_free_events && $first_price['Price'] > 0 ) ) {
    241                     ?>
    242                     <label class="edu-book-customerVatNo">
    243                         <div class="inputLabel">
    244                             <?php echo esc_html_x( 'Org.No.', 'frontend', 'eduadmin-booking' ); ?>
    245                         </div>
    246                         <div class="inputHolder">
    247                             <input type="text" autocomplete="off" name="customerVatNo" maxlength="50"
    248                                    placeholder="<?php echo esc_attr_x( 'Org.No.', 'frontend', 'eduadmin-booking' ); ?>"
    249                                    value="<?php echo esc_attr( $customer->OrganisationNumber ); ?>" />
    250                         </div>
    251                     </label>
    252                     <label class="edu-book-customerAddress1">
    253                         <div class="inputLabel">
    254                             <?php echo esc_html_x( 'Address 1', 'frontend', 'eduadmin-booking' ); ?>
    255                         </div>
    256                         <div class="inputHolder">
    257                             <input type="text" autocomplete="off" name="customerAddress1" maxlength="200"
    258                                    placeholder="<?php echo esc_attr_x( 'Address 1', 'frontend', 'eduadmin-booking' ); ?>"
    259                                    value="<?php echo esc_attr( $customer->Address ); ?>" />
    260                         </div>
    261                     </label>
    262                     <label class="edu-book-customerAddress2">
    263                         <div class="inputLabel">
    264                             <?php echo esc_html_x( 'Address 2', 'frontend', 'eduadmin-booking' ); ?>
    265                         </div>
    266                         <div class="inputHolder">
    267                             <input type="text" autocomplete="off" name="customerAddress2" maxlength="200"
    268                                    placeholder="<?php echo esc_attr_x( 'Address 2', 'frontend', 'eduadmin-booking' ); ?>"
    269                                    value="<?php echo esc_attr( $customer->Address2 ); ?>" />
    270                         </div>
    271                     </label>
    272                     <label class="edu-book-customerPostalCode">
    273                         <div class="inputLabel">
    274                             <?php echo esc_html_x( 'Postal code', 'frontend', 'eduadmin-booking' ); ?>
    275                         </div>
    276                         <div class="inputHolder">
    277                             <input type="text" autocomplete="off" name="customerPostalCode" maxlength="50"
    278                                    placeholder="<?php echo esc_attr_x( 'Postal code', 'frontend', 'eduadmin-booking' ); ?>"
    279                                    value="<?php echo esc_attr( $customer->Zip ); ?>" />
    280                         </div>
    281                     </label>
    282                     <label class="edu-book-customerPostalCity">
    283                         <div class="inputLabel">
    284                             <?php echo esc_html_x( 'Postal city', 'frontend', 'eduadmin-booking' ); ?>
    285                         </div>
    286                         <div class="inputHolder">
    287                             <input type="text" autocomplete="off" name="customerPostalCity" maxlength="200"
    288                                    placeholder="<?php echo esc_attr_x( 'Postal city', 'frontend', 'eduadmin-booking' ); ?>"
    289                                    value="<?php echo esc_attr( $customer->City ); ?>" />
    290                         </div>
    291                     </label>
    292                     <label class="edu-book-customerCountry">
    293                         <div class="inputLabel">
    294                             <?php echo esc_html_x( 'Country', 'frontend', 'eduadmin-booking' ); ?>
    295                         </div>
    296                         <div class="inputHolder">
    297                             <?php edu_get_country_list( 'customerCountryCode', $customer->CountryCode ); ?>
    298                         </div>
    299                     </label>
    300                     <label class="edu-book-customerEmailAddress">
    301                         <div class="inputLabel">
    302                             <?php echo esc_html_x( 'E-mail address', 'frontend', 'eduadmin-booking' ); ?>
    303                         </div>
    304                         <div class="inputHolder">
    305                             <input type="text" autocomplete="off" name="customerEmail" maxlength="200"
    306                                    placeholder="<?php echo esc_attr_x( 'E-mail address', 'frontend', 'eduadmin-booking' ); ?>"
    307                                    value="<?php echo esc_attr( $customer->Email ); ?>" />
    308                         </div>
    309                     </label>
    310                     <div id="invoiceView" class="invoiceView"
    311                          style="<?php echo( $force_show_invoice_information ? 'display: block;' : 'display: none;' ); ?>">
    312                         <h2><?php echo esc_html_x( 'Invoice information', 'frontend', 'eduadmin-booking' ); ?></h2>
    313                         <label class="edu-book-invoice-customerName">
    314                             <div class="inputLabel">
    315                                 <?php echo esc_html_x( 'Customer name', 'frontend', 'eduadmin-booking' ); ?>
    316                             </div>
    317                             <div class="inputHolder">
    318                                 <input type="text" autocomplete="off" name="invoiceName" maxlength="200"
    319                                        placeholder="<?php echo esc_attr_x( 'Customer name', 'frontend', 'eduadmin-booking' ); ?>"
    320                                        value="<?php echo esc_attr( $billing_customer->CustomerName ); ?>" />
    321                             </div>
    322                         </label>
    323                         <label class="edu-book-invoice-customerAddress1">
    324                             <div class="inputLabel">
    325                                 <?php echo esc_html_x( 'Address 1', 'frontend', 'eduadmin-booking' ); ?>
    326                             </div>
    327                             <div class="inputHolder">
    328                                 <input type="text" autocomplete="off" name="invoiceAddress1" maxlength="200"
    329                                        placeholder="<?php echo esc_attr_x( 'Address 1', 'frontend', 'eduadmin-booking' ); ?>"
    330                                        value="<?php echo esc_attr( $billing_customer->Address ); ?>" />
    331                             </div>
    332                         </label>
    333                         <label class="edu-book-invoice-customerAddress2">
    334                             <div class="inputLabel">
    335                                 <?php echo esc_html_x( 'Address 2', 'frontend', 'eduadmin-booking' ); ?>
    336                             </div>
    337                             <div class="inputHolder">
    338                                 <input type="text" autocomplete="off" name="invoiceAddress2" maxlength="200"
    339                                        placeholder="<?php echo esc_attr_x( 'Address 2', 'frontend', 'eduadmin-booking' ); ?>"
    340                                        value="<?php echo esc_attr( $billing_customer->Address2 ); ?>" />
    341                             </div>
    342                         </label>
    343                         <label class="edu-book-invoice-customerPostalCode">
    344                             <div class="inputLabel">
    345                                 <?php echo esc_html_x( 'Postal code', 'frontend', 'eduadmin-booking' ); ?>
    346                             </div>
    347                             <div class="inputHolder">
    348                                 <input type="text" autocomplete="off" name="invoicePostalCode" maxlength="50"
    349                                        placeholder="<?php echo esc_attr_x( 'Postal code', 'frontend', 'eduadmin-booking' ); ?>"
    350                                        value="<?php echo esc_attr( $billing_customer->Zip ); ?>" />
    351                             </div>
    352                         </label>
    353                         <label class="edu-book-invoice-customerPostalCity">
    354                             <div class="inputLabel">
    355                                 <?php echo esc_html_x( 'Postal city', 'frontend', 'eduadmin-booking' ); ?>
    356                             </div>
    357                             <div class="inputHolder">
    358                                 <input type="text" autocomplete="off" name="invoicePostalCity" maxlength="200"
    359                                        placeholder="<?php echo esc_attr_x( 'Postal city', 'frontend', 'eduadmin-booking' ); ?>"
    360                                        value="<?php echo esc_attr( $billing_customer->City ); ?>" />
    361                             </div>
    362                         </label>
    363                         <label class="edu-book-invoice-customerCountry">
    364                             <div class="inputLabel">
    365                                 <?php echo esc_html_x( 'Country', 'frontend', 'eduadmin-booking' ); ?>
    366                             </div>
    367                             <div class="inputHolder">
    368                                 <?php edu_get_country_list( 'invoiceCountryCode', $billing_customer->CountryCode, false ); ?>
    369                             </div>
    370                         </label>
    371                     </div>
    372                     <?php if ( $show_invoice_email ) { ?>
    373                         <label class="edu-book-invoice-customerInvoiceEmail">
    374                             <div class="inputLabel">
    375                                 <?php echo esc_html_x( 'Invoice e-mail address', 'frontend', 'eduadmin-booking' ); ?>
    376                             </div>
    377                             <div class="inputHolder">
    378                                 <input type="text" autocomplete="off" name="invoiceEmail" maxlength="20"
    379                                        placeholder="<?php echo esc_attr_x( 'Invoice e-mail address', 'frontend', 'eduadmin-booking' ); ?>"
    380                                        value="<?php echo esc_attr( $billing_customer->Email ); ?>" />
    381                             </div>
    382                         </label>
    383                     <?php } ?>
    384                     <label class="edu-book-invoice-customerInvoiceReference">
    385                         <div class="inputLabel">
    386                             <?php echo esc_html_x( 'Invoice reference', 'frontend', 'eduadmin-booking' ); ?>
    387                         </div>
    388                         <div class="inputHolder">
    389                             <input type="text" autocomplete="off" name="invoiceReference" maxlength="100"
    390                                    placeholder="<?php echo esc_attr_x( 'Invoice reference', 'frontend', 'eduadmin-booking' ); ?>"
    391                                    value="<?php echo esc_attr( ! empty( $billing_customer->SellerReference ) ? $billing_customer->SellerReference : '' ); ?>" />
    392                         </div>
    393                     </label>
    394                     <label class="edu-book-invoice-customerPurchaseOrderNumber">
    395                         <div class="inputLabel">
    396                             <?php echo esc_html_x( 'Purchase order number', 'frontend', 'eduadmin-booking' ); ?>
    397                         </div>
    398                         <div class="inputHolder">
    399                             <input type="text" autocomplete="off" name="purchaseOrderNumber" maxlength="200"
    400                                    placeholder="<?php echo esc_attr_x( 'Purchase order number', 'frontend', 'eduadmin-booking' ); ?>"
    401                                    value="<?php echo esc_attr( ! empty( $_POST['purchaseOrderNumber'] ) ? $_POST['purchaseOrderNumber'] : '' ); ?>" />
    402                         </div>
    403                     </label>
    404                     <label class="edu-book-invoice-customerEdiReference">
    405                         <div class="inputLabel">
    406                             <?php echo esc_html_x( 'EDI Reference', 'frontend', 'eduadmin-booking' ); ?>
    407                         </div>
    408                         <div class="inputHolder">
    409                             <input type="text" autocomplete="off" name="ediReference" maxlength="100"
    410                                    placeholder="<?php echo esc_attr_x( 'EDI Reference', 'frontend', 'eduadmin-booking' ); ?>"
    411                                    value="<?php echo esc_attr( ! empty( $billing_customer->EdiReference ) ? $billing_customer->EdiReference : '' ); ?>" />
    412                         </div>
    413                     </label>
    414                     <?php
    415                 }
    416 
    417                 $customer_custom_fields = EDUAPI()->OData->CustomFields->Search(
    418                     null,
    419                     'ShowOnWeb and CustomFieldOwner eq \'Customer\'',
    420                     'CustomFieldAlternatives',
    421                     'SortIndex'
    422                 )['value'];
    423 
    424                 foreach ( $customer_custom_fields as $custom_field ) {
    425                     $data = null;
    426                     if ( ! empty( $customer->CustomFields ) ) {
    427                         foreach ( $customer->CustomFields as $cf ) {
    428                             if ( $cf->CustomFieldId === $custom_field['CustomFieldId'] ) {
    429                                 switch ( $cf->CustomFieldType ) {
    430                                     case 'Checkbox':
    431                                         $data = $cf->CustomFieldChecked;
    432                                         break;
    433                                     case 'Dropdown':
    434                                         $data = $cf->CustomFieldAlternativeId;
    435                                         break;
    436                                     default:
    437                                         $data = $cf->CustomFieldValue;
    438                                         break;
    439                                 }
    440                                 break;
    441                             }
    442                         }
    443                     }
    444                     render_attribute( $custom_field, false, 'customer', $data );
    445                 }
    446                 if ( ! $no_invoice_free_events || $first_price['Price'] > 0 ) {
    447                     ?>
    448                     <label<?php echo $force_show_invoice_information ? ' style="display: none;"' : ''; ?>>
    449                         <div class="inputHolder alsoInvoiceCustomer">
    450                             <label class="inline-checkbox" for="alsoInvoiceCustomer">
    451                                 <input type="checkbox" id="alsoInvoiceCustomer" name="alsoInvoiceCustomer" value="true"
    452                                        onchange="eduBookingView.UpdateInvoiceCustomer(this);"
    453                                     <?php echo $force_show_invoice_information ? 'checked' : ''; ?>/>
    454                                 <?php echo esc_html_x( 'Use other information for invoicing', 'frontend', 'eduadmin-booking' ); ?>
    455                             </label>
    456                         </div>
    457                     </label>
    458                 <?php } ?>
    459                 <?php if ( EDU()->is_checked( 'eduadmin-useLogin', false ) && EDU()->is_checked( 'eduadmin-allowCustomerUpdate', false ) && isset( $customer->CustomerId ) && 0 !== $customer->CustomerId ) { ?>
    460                     <label>
    461                         <div class="inputHolder">
    462                             <label class="inline-checkbox" for="overwriteCustomerData">
    463                                 <input type="checkbox" id="overwriteCustomerData" name="overwriteCustomerData"
    464                                        value="true" />
    465                                 <?php echo esc_html_x( 'Also update my customer information for future use', 'frontend', 'eduadmin-booking' ); ?>
    466                             </label>
    467                         </div>
    468                     </label>
    469                 <?php } ?>
    470             </div>
    471             <div class="questionPanel">
    472                 <?php
    473                 if ( ! empty( $_REQUEST['eid'] ) ) {
    474                     foreach ( $booking_questions as $question ) {
    475                         render_question( $question, false, 'booking' );
    476                     }
    477                 }
    478                 ?>
    479             </div>
    480             <div class="participantView">
    481                 <h2><?php echo esc_html_x( 'Participant information', 'frontend', 'eduadmin-booking' ); ?></h2>
    482                 <div class="participantHolder" id="edu-participantHolder">
    483                     <div class="participantItem template" style="display: none;">
    484                         <h3>
    485                             <?php echo esc_html_x( 'Participant', 'frontend', 'eduadmin-booking' ); ?>
    486                             <?php if ( ! EDU()->is_checked( 'eduadmin-singlePersonBooking', false ) ) { ?>
    487                                 <div class="removeParticipant"
    488                                      onclick="eduBookingView.RemoveParticipant(this);"><?php echo esc_html_x( 'Remove', 'frontend', 'eduadmin-booking' ); ?></div>
    489                             <?php } ?>
    490                         </h3>
    491                         <label onclick="event.preventDefault()">
    492                             <div class="inputLabel">
    493                                 <?php echo esc_html_x( 'Participant name', 'frontend', 'eduadmin-booking' ); ?>
    494                             </div>
    495                             <div class="inputHolder">
    496                                 <input type="text" autocomplete="off" class="participantFirstName first-name"
    497                                        onchange="eduBookingView.CheckPrice(false);" name="participantFirstName[]"
    498                                        maxlength="100"
    499                                        placeholder="<?php echo esc_attr_x( 'Participant first name', 'frontend', 'eduadmin-booking' ); ?>" /><input
    500                                     type="text" class="participantLastName last-name"
    501                                     onchange="eduBookingView.CheckPrice(false);" name="participantLastName[]"
    502                                     maxlength="100"
    503                                     placeholder="<?php echo esc_attr_x( 'Participant surname', 'frontend', 'eduadmin-booking' ); ?>" />
    504                             </div>
    505                         </label>
    506                         <label>
    507                             <div class="inputLabel">
    508                                 <?php echo esc_html_x( 'E-mail address', 'frontend', 'eduadmin-booking' ); ?>
    509                             </div>
    510                             <div class="inputHolder">
    511                                 <input type="email" autocomplete="off" name="participantEmail[]"
    512                                        onchange="eduBookingView.CheckPrice(false);" maxlength="200"
    513                                        placeholder="<?php echo esc_attr_x( 'E-mail address', 'frontend', 'eduadmin-booking' ); ?>" />
    514                             </div>
    515                         </label>
    516                         <label>
    517                             <div class="inputLabel">
    518                                 <?php echo esc_html_x( 'Phone number', 'frontend', 'eduadmin-booking' ); ?>
    519                             </div>
    520                             <div class="inputHolder">
    521                                 <input type="tel" autocomplete="off" name="participantPhone[]" maxlength="100"
    522                                        placeholder="<?php echo esc_attr_x( 'Phone number', 'frontend', 'eduadmin-booking' ); ?>" />
    523                             </div>
    524                         </label>
    525                         <label>
    526                             <div class="inputLabel">
    527                                 <?php echo esc_html_x( 'Mobile number', 'frontend', 'eduadmin-booking' ); ?>
    528                             </div>
    529                             <div class="inputHolder">
    530                                 <input type="tel" autocomplete="off" name="participantMobile[]" maxlength="100"
    531                                        placeholder="<?php echo esc_attr_x( 'Mobile number', 'frontend', 'eduadmin-booking' ); ?>" />
    532                             </div>
    533                         </label>
    534                         <?php
    535                         if ( ! empty( $contact_custom_fields ) ) {
    536                             foreach ( $contact_custom_fields as $attr ) {
    537                                 render_attribute( $attr, true, 'participant' );
    538                             }
    539                         }
    540 
    541                         if ( ! empty( $participant_questions ) ) {
    542                             foreach ( $participant_questions as $question ) {
    543                                 render_question( $question, true, 'participant' );
    544                             }
    545                         }
    546                         ?>
    547                     </div>
    548                 </div>
    549                 <?php if ( ! EDU()->is_checked( 'eduadmin-singlePersonBooking', false ) ) { ?>
    550                     <div>
    551                         <a href="javascript://" class="addParticipantLink neutral-btn"
    552                            onclick="eduBookingView.AddParticipant(); return false;"><?php echo esc_html_x( '+ Add participant', 'frontend', 'eduadmin-booking' ); ?></a>
    553                     </div>
    554                 <?php } ?>
    555                 <div class="edu-modal warning" id="edu-warning-participants">
    556                     <?php echo esc_html_x( 'You cannot add any more participants.', 'frontend', 'eduadmin-booking' ); ?>
    557                 </div>
    558             </div>
    559             <?php
    560             include_once 'coupon-code.php';
    561             include_once __DIR__ . '/../payment-methods.php';
    562             include_once __DIR__ . '/../recaptcha-form.php';
    563             eduadmin_render_payment_methods( $programme );
    564             eduadmin_render_recaptcha_form();
    565             ?>
    566             <div class="submitView">
    567                 <?php if ( EDU()->is_checked( 'eduadmin-useBookingTermsCheckbox', false ) && $link = EDU()->get_option( 'eduadmin-bookingTermsLink', '' ) ): ?>
    568                     <div class="confirmTermsHolder">
    569                         <label>
    570                             <input type="checkbox" id="confirmTerms" name="confirmTerms" value="agree" />
    571                             <?php
    572                             /* translators: 1: Start of link 2: End of link */
    573                             echo wp_kses( sprintf( _x( 'I agree to the %1$sTerms and Conditions%2$s', 'frontend', 'eduadmin-booking' ), '<a href="' . $link . '" target="_blank">', '</a>' ), wp_kses_allowed_html( 'post' ) );
    574                             ?>
    575                         </label>
    576                     </div>
    577                 <?php endif; ?>
    578                 <div class="sumTotal">
    579                     <?php echo esc_html_x( 'Total sum:', 'frontend', 'eduadmin-booking' ); ?>
    580                     <span id="sumValue" class="sumValue"></span>
    581                 </div>
    582                 <?php if ( 0 !== $programme['ParticipantNumberLeft'] ) : ?>
    583                     <input type="submit" class="bookButton cta-btn" id="edu-book-btn"
    584                            onclick="eduBookingView.UpdatePrice(); var validated = eduBookingView.CheckValidation(false, false); return validated;"
    585                            value="<?php echo esc_attr_x( 'Book now', 'frontend', 'eduadmin-booking' ); ?>" />
    586                 <?php else : ?>
    587                     <div class="bookButton neutral-btn cta-disabled">
    588                         <?php echo esc_html_x( 'No free spots left on this event', 'frontend', 'eduadmin-booking' ); ?>
    589                     </div>
    590                 <?php endif; ?>
    591                 <div class="edu-modal warning" id="edu-warning-pricecheck"></div>
    592                 <div class="edu-modal warning" id="edu-warning-recaptcha">
    593                     <?php echo esc_html_x( 'You must confirm that you are not a bot before continuing.', 'frontend', 'eduadmin-booking' ); ?>
    594                 </div>
    595                 <div class="edu-modal warning" id="edu-warning-terms">
    596                     <?php echo esc_html_x( 'You must accept Terms and Conditions to continue.', 'frontend', 'eduadmin-booking' ); ?>
    597                 </div>
    598                 <div class="edu-modal warning" id="edu-warning-no-participants">
    599                     <?php echo esc_html_x( 'You must add some participants.', 'frontend', 'eduadmin-booking' ); ?>
    600                 </div>
    601                 <div class="edu-modal warning" id="edu-warning-missing-participants">
    602                     <?php echo esc_html_x( 'One or more participants is missing a name.', 'frontend', 'eduadmin-booking' ); ?>
    603                 </div>
    604                 <div class="edu-modal warning" id="edu-warning-missing-civicregno">
    605                     <?php echo esc_html_x( 'One or more participants is missing their civic registration number.', 'frontend', 'eduadmin-booking' ); ?>
    606                 </div>
    607                 <?php
    608                 $error_list = apply_filters( 'edu-booking-error', array() );
    609                 foreach ( $error_list as $error ) {
    610                     ?>
    611                     <div class="edu-modal warning">
    612                         <?php esc_html( $error ); ?>
    613                     </div>
    614                     <?php
    615                 }
    616                 ?>
    617             </div>
    618             <?php
    619             $original_title = get_the_title();
    620             $new_title      = $programme['ProgrammeStartName'] . ' | ' . $original_title;
    621 
    622             $discount_value = 0.0;
    623             if ( 0 !== $participant_discount_percent ) {
    624                 $discount_value = ( $participant_discount_percent / 100 ) * $first_price['Price'];
    625             }
    626             ?>
    627             <script type="text/javascript">
    628                 var pricePerParticipant = <?php echo esc_js( round( $first_price['Price'] - $discount_value, 2 ) ); ?>;
    629                 var discountPerParticipant = <?php echo esc_js( round( $participant_discount_percent / 100, 2 ) ); ?>;
    630                 var totalPriceDiscountPercent = <?php echo esc_js( $discount_percent ); ?>;
    631 
    632                 (function () {
    633                     var title = document.title;
    634                     title = title.replace('<?php echo esc_js( $original_title ); ?>', '<?php echo esc_js( $new_title ); ?>');
    635                     document.title = title;
    636                     eduBookingView.ProgrammeBooking = true;
    637                     eduBookingView.MaxParticipants = <?php echo esc_js( intval( $programme['ParticipantNumberLeft'] ) ); ?>;
    638                     eduBookingView.AddParticipant();
    639                     eduBookingView.CheckPrice(false);
    640                 })();
    641             </script>
    642         </form>
    643     </div>
    644     <?php
    645     do_action( 'eduadmin-programme-bookingform-view', $programme );
    646650}
     651
    647652$out = ob_get_clean();
    648653
  • eduadmin-booking/trunk/content/template/programme/detail.php

    r2976806 r3182069  
    22ob_start();
    33$show_headers = EDU()->is_checked( 'eduadmin-showDetailHeaders', true );
    4 ?>
     4if ( ! EDU()->api_connection ) {
     5    echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' );
     6} else {
     7    ?>
    58    <div class="eduadmin" data-courseid="<?php echo esc_attr( $programme['ProgrammeId'] ); ?>"
    69         data-eventid="<?php echo( isset( $_REQUEST['id'] ) ? esc_attr( sanitize_text_field( $_REQUEST['id'] ) ) : '' ); ?>">
     
    4346        ?>
    4447    </div>
    45 <?php
     48    <?php
     49}
     50
    4651$out = ob_get_clean();
    4752
  • eduadmin-booking/trunk/content/template/programme/list.php

    r2976806 r3182069  
    55$spot_settings    = EDU()->get_option( 'eduadmin-spotsSettings', "1-5\n5-10\n10+" );
    66
    7 if ( empty( $programmes['Errors'] ) ) {
     7if ( ! EDU()->api_connection ) {
     8    ?>
     9    <div class="eduadmin programme-list">
     10        <div class="programme-header">
     11            <div><b><?php echo esc_html_x( 'Programme', 'frontend', 'eduadmin-booking' ); ?></b></div>
     12            <div><b><?php echo esc_html_x( 'Length', 'frontend', 'eduadmin-booking' ); ?></b></div>
     13            <div></div>
     14            <div></div>
     15        </div>
     16        <div class="eduadmin-error">
     17            <?php echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' ); ?>
     18        </div>
     19    </div>
     20    <?php
     21} elseif ( empty( $programmes['Errors'] ) ) {
    822    ?>
    923    <div class="eduadmin programme-list">
  • eduadmin-booking/trunk/eduadmin.php

    r3181532 r3182069  
    1010 * Description: EduAdmin plugin to allow visitors to book courses at your website
    1111 * Tags:    booking, participants, courses, events, eduadmin
    12  * Version: 5.2.0
     12 * Version: 5.3.0
    1313 * GitHub Plugin URI: multinetinteractive/eduadmin-wordpress
    1414 * GitHub Plugin URI: https://github.com/multinetinteractive/eduadmin-wordpress
     
    9494        /** @var string */
    9595        private $currentIntegrityHash;
     96        /** @var boolean */
     97        public $api_connection;
    9698
    9799        /**
     
    271273
    272274        public function get_news() {
     275            if ( ! EDU()->api_connection ) {
     276                return null;
     277            }
     278
    273279            return $this->get_transient( 'eduadmin-wp-news', function() {
    274280                $user_locale = get_user_locale();
     
    355361        private function includes() {
    356362            $t = $this->start_timer( __METHOD__ );
     363
    357364            include_once 'libraries/plugin-checksum.php';
    358365            include_once 'libraries/EDURequestCache.php';
     
    384391            include_once 'includes/plugin/class-edu-integrationloader.php'; // Integration loader
    385392
    386             if ( is_wp_error( $this->get_new_api_token() ) ) {
    387                 add_action( 'admin_notices', array( $this, 'setup_warning' ) );
    388             }
    389 
    390393            include_once 'includes/edu-options.php';
    391394            include_once 'includes/edu-ajax-functions.php';
     
    404407            $this->booking_handler = new EduAdmin_BookingHandler();
    405408            $this->login_handler   = new EduAdmin_LoginHandler();
     409
    406410            $this->stop_timer( $t );
    407411        }
    408412
    409413        public function call_home() {
     414            if ( ! EDU()->api_connection ) {
     415                return;
     416            }
     417
    410418            global $wp_version;
    411419            $integrity             = EduAdminPluginIntegrityChecker::check_plugin_integrity();
     
    441449        private function init_hooks() {
    442450            $t = $this->start_timer( __METHOD__ );
     451
    443452            register_activation_hook( __FILE__, array( $this, 'activate' ) );
    444453
     
    608617            );
    609618
     619            if ( ! $this->check_api_connection() ) {
     620                add_action( 'admin_notices', array( $this, 'api_connection_warning' ) );
     621                $this->stop_timer( $t );
     622
     623                return;
     624            }
     625
     626            if ( is_wp_error( $this->get_new_api_token() ) ) {
     627                add_action( 'admin_notices', array( $this, 'setup_warning' ) );
     628            }
     629
    610630            $this->stop_timer( $t );
    611631        }
     
    624644        }
    625645
     646        public static function api_connection_warning() {
     647            ?>
     648            <div class="notice notice-error">
     649                <p>
     650                    <?php
     651                    /* translators: 1: start of link 2: end of link */
     652                    echo wp_kses_post( sprintf( _x( 'Could not connect to the EduAdmin API, contact the %1$sEduAdmin Support%2$s if the issue persists.', 'backend', 'eduadmin-booking' ), '<a href="https://support.eduadmin.se/en/support/tickets/new" target="_blank">', '</a>' ) );
     653                    ?>
     654                </p>
     655            </div>
     656            <?php
     657        }
     658
    626659        /**
    627660         * @return string Returns the users IP adress
     
    733766
    734767        private function get_new_api_token() {
     768            if ( $this->api_connection === false ) {
     769                return new WP_Error( 'broke', _x( 'Could not connect to the EduAdmin API, please contact MultiNet support.', 'backend', 'eduadmin-booking' ) );
     770            }
     771
    735772            $new_key = $this->get_option( 'eduadmin-newapi-key', null );
    736773
     
    765802
    766803            return null;
     804        }
     805
     806        public function check_api_connection() {
     807            $api_check = wp_remote_head( "https://api.eduadmin.se/healthchecks", [
     808                'timeout'  => 0.25,
     809                'blocking' => false,
     810            ] );
     811
     812            $this->api_connection = ! is_wp_error( $api_check ) && 200 === wp_remote_retrieve_response_code( $api_check );
     813
     814            return $this->api_connection;
    767815        }
    768816    }
  • eduadmin-booking/trunk/includes/booking-settings.php

    r2967419 r3182069  
    66    <div class="eduadmin wrap">
    77        <h2><?php echo esc_html( sprintf( _x( 'EduAdmin settings - %s', 'backend', 'eduadmin-booking' ), _x( 'Booking settings', 'backend', 'eduadmin-booking' ) ) ); ?></h2>
    8         <form method="post" action="options.php">
    9             <?php settings_fields( 'eduadmin-booking' ); ?>
    10             <?php do_settings_sections( 'eduadmin-booking' ); ?>
    11             <div class="block">
    12                 <?php
    13                 if ( empty( EDUAPI()->api_token ) ) {
    14                     add_action( 'admin_notices', array( 'EduAdmin', 'SetupWarning' ) );
    15                 } else {
    16                     echo '<h3>' . esc_html_x( 'Use booking form from EduAdmin', 'backend', 'eduadmin-booking' ) . '</h3>';
    17                     ?>
    18                     <label>
    19                         <input type="checkbox" name="eduadmin-useBookingFormFromApi" value="true"
    20                             <?php echo( EDU()->get_option( 'eduadmin-useBookingFormFromApi', false ) ? ' checked="checked"' : '' ); ?>
    21                                onchange="EduAdmin.ToggleVisibility(!this.checked, '.non-eduform-options');" />
    22                         <?php echo esc_html_x( 'Use booking form from EduAdmin (will turn off all settings below)', 'backend', 'eduadmin-booking' ); ?>
    23                     </label>
    24                     <br />
    25                     <em><?php echo esc_html_x( 'By enabling this option, all options below will be ineffective, as we use an external booking form from EduAdmin instead.', 'backend', 'eduadmin-booking' ); ?></em>
    26                     <br />
    27                     <h3><?php echo esc_html_x( 'Javascript to run the booking form is used', 'backend', 'eduadmin-booking' ); ?></h3>
    28                     <em><?php echo esc_html_x( 'Do not include &lt;script&gt; here, it is handled automatically.', 'backend', 'eduadmin-booking' ); ?></em>
    29                     <table>
    30                         <tr>
    31                             <td style="vertical-align: top;">
     8        <?php
     9        if ( ! EDU()->api_connection ) {
     10            echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'backend', 'eduadmin-booking' );
     11        } else {
     12            ?>
     13            <form method="post" action="options.php">
     14                <?php settings_fields( 'eduadmin-booking' ); ?>
     15                <?php do_settings_sections( 'eduadmin-booking' ); ?>
     16                <div class="block">
     17                    <?php
     18                    if ( empty( EDUAPI()->api_token ) ) {
     19                        add_action( 'admin_notices', array( 'EduAdmin', 'SetupWarning' ) );
     20                    } else {
     21                        echo '<h3>' . esc_html_x( 'Use booking form from EduAdmin', 'backend', 'eduadmin-booking' ) . '</h3>';
     22                        ?>
     23                        <label>
     24                            <input type="checkbox" name="eduadmin-useBookingFormFromApi" value="true"
     25                                <?php echo( EDU()->get_option( 'eduadmin-useBookingFormFromApi', false ) ? ' checked="checked"' : '' ); ?>
     26                                   onchange="EduAdmin.ToggleVisibility(!this.checked, '.non-eduform-options');" />
     27                            <?php echo esc_html_x( 'Use booking form from EduAdmin (will turn off all settings below)', 'backend', 'eduadmin-booking' ); ?>
     28                        </label>
     29                        <br />
     30                        <em><?php echo esc_html_x( 'By enabling this option, all options below will be ineffective, as we use an external booking form from EduAdmin instead.', 'backend', 'eduadmin-booking' ); ?></em>
     31                        <br />
     32                        <h3><?php echo esc_html_x( 'Javascript to run the booking form is used', 'backend', 'eduadmin-booking' ); ?></h3>
     33                        <em><?php echo esc_html_x( 'Do not include &lt;script&gt; here, it is handled automatically.', 'backend', 'eduadmin-booking' ); ?></em>
     34                        <table>
     35                            <tr>
     36                                <td style="vertical-align: top;">
    3237                                <textarea class="form-control" rows="12" cols="60"
    3338                                          name="eduadmin-booking-form-javascript"><?php echo EDU()->get_option( 'eduadmin-booking-form-javascript' ); ?></textarea>
    34                             </td>
    35                             <td style="vertical-align: top;">
    36                                 The booking form will use
    37                                 <code>window.parent.postMessage</code> to post data from the form.
    38                                 <br />
    39                                 The event you want to keep track of it <code>eduadmin-order</code>.
    40                                 <br />
    41                                 <br />
    42                                 Example code to listen to the <code>eduadmin-order</code> "event":
    43                                 <br />
     39                                </td>
     40                                <td style="vertical-align: top;">
     41                                    The booking form will use
     42                                    <code>window.parent.postMessage</code> to post data from the form.
     43                                    <br />
     44                                    The event you want to keep track of it <code>eduadmin-order</code>.
     45                                    <br />
     46                                    <br />
     47                                    Example code to listen to the <code>eduadmin-order</code> "event":
     48                                    <br />
    4449
    45                                 <pre>
     50                                    <pre>
    4651window.addEventListener('message', function (event) {
    4752  if (event.data.type == "eduadmin-order") {
     
    5358}, false);</pre>
    5459
    55                             </td>
    56                         </tr>
    57                     </table>
    58                     <div
    59                         class="non-eduform-options"<?php echo( ! EDU()->is_checked( 'eduadmin-useBookingFormFromApi', false ) ? ' style="display: block;"' : ' style="display: none;"' ); ?>>
    60                         <?php
    61 
    62                         echo '<h3>' . esc_html_x( 'Default customer group', 'backend', 'eduadmin-booking' ) . '</h3>';
    63                         $cg = EDUAPI()->OData->CustomerGroups->Search(
    64                             'CustomerGroupId,ParentCustomerGroupId,CustomerGroupName',
    65                             'PublicGroup',
    66                             null,
    67                             'ParentCustomerGroupId'
    68                         );
    69 
    70                         $parent = array();
    71                         foreach ( $cg['value'] as $i => $v ) {
    72                             $parent[ $i ] = $v['ParentCustomerGroupId'];
    73                         }
    74 
    75                         array_multisort( $parent, SORT_ASC, $cg['value'] );
    76 
    77                         $level_stack = array();
    78                         foreach ( $cg['value'] as $g ) {
    79                             $level_stack[ (string) $g['ParentCustomerGroupId'] ][] = $g;
    80                         }
    81 
    82                         $depth = 0;
    83 
    84                         function edu_write_options( $g, $array, $depth, $selected_option ) {
    85                             echo '<option value="' . esc_attr( $g['CustomerGroupId'] ) . '"' . ( $selected_option === (string) $g['CustomerGroupId'] ? ' selected="selected"' : '' ) . '>' .
    86                                  str_repeat( '&nbsp;', $depth * 4 ) .
    87                                  esc_html( wp_strip_all_tags( $g['CustomerGroupName'] ) ) .
    88                                  "</option>\n";
    89                             if ( array_key_exists( (string) $g['CustomerGroupId'], $array ) ) {
    90                                 $depth ++;
    91                                 foreach ( $array[ (string) $g['CustomerGroupId'] ] as $ng ) {
    92                                     edu_write_options( $ng, $array, $depth, $selected_option );
    93                                 }
    94                                 $depth --;
    95                             }
    96                         }
    97 
    98                         ?>
    99                         <select required name="eduadmin-customerGroupId"
    100                                 title="<?php echo esc_attr_x( 'Select customer group', 'backend', 'eduadmin-booking' ); ?>">
    101                             <option
    102                                 value=""><?php echo esc_html_x( 'Select customer group', 'backend', 'eduadmin-booking' ); ?></option>
    103                             <?php
    104                             $root            = $level_stack['0'];
    105                             $selected_option = EDU()->get_option( 'eduadmin-customerGroupId', null );
    106                             foreach ( $root as $g ) {
    107                                 edu_write_options( $g, $level_stack, $depth, $selected_option );
    108                             }
    109                             ?>
    110                         </select>
    111                         <br />
    112                         <br />
    113                         <label>
    114                             <input type="checkbox" name="eduadmin-useLogin" value="true"
    115                                 <?php echo( EDU()->get_option( 'eduadmin-useLogin', false ) ? ' checked="checked"' : '' ); ?>
    116                                    onchange="EduAdmin.ToggleVisibility(this.checked, '.eduadmin-forceLogin');" />
    117                             <?php echo esc_html_x( 'Use login', 'backend', 'eduadmin-booking' ); ?>
    118                         </label>
    119                         <br />
    120                         <div
    121                             class="eduadmin-forceLogin"<?php echo( EDU()->is_checked( 'eduadmin-useLogin', false ) ? ' style="display: block;"' : ' style="display: none;"' ); ?>>
    122                             <label>
    123                                 <input type="checkbox" name="eduadmin-allowCustomerRegistration" value="true"
    124                                     <?php echo EDU()->get_option( 'eduadmin-allowCustomerRegistration', true ) ? ' checked="checked"' : ''; ?>
    125                                 />
    126                                 <?php echo esc_html_x( 'Allow customer registration', 'backend', 'eduadmin-booking' ); ?>
    127                             </label>
    128                         </div>
    129                         <br />
    130                         <label>
    131                             <?php echo esc_html_x( 'Login field', 'backend', 'eduadmin-booking' ); ?>
    132                             <?php $selected_login_field = EDU()->get_option( 'eduadmin-loginField', 'Email' ); ?>
    133                             <select name="eduadmin-loginField">
    134                                 <option<?php echo( 'Email' === $selected_login_field ? ' selected="selected"' : '' ); ?>
    135                                     value="Email"><?php echo esc_html_x( 'E-mail address', 'backend', 'eduadmin-booking' ); ?></option>
    136                                 <option<?php echo( 'CivicRegistrationNumber' === $selected_login_field ? ' selected="selected"' : '' ); ?>
    137                                     value="CivicRegistrationNumber"><?php echo esc_html_x( 'Civic Registration Number', 'backend', 'eduadmin-booking' ); ?></option>
    138                                 <!--<option value="CustomerNumber"><?php echo esc_html_x( 'Customer number', 'backend', 'eduadmin-booking' ); ?></option>-->
    139                                 <!-- To be enabled when it works in the API -->
    140                             </select>
    141                         </label>
    142                         <h3><?php echo esc_html_x( 'Booking form settings', 'backend', 'eduadmin-booking' ); ?></h3> <?php
    143                         $singlePersonBooking = EDU()->get_option( 'eduadmin-singlePersonBooking', false );
    144                         ?>
    145                         <label>
    146                             <input type="checkbox"
    147                                    name="eduadmin-singlePersonBooking"<?php echo( 'true' === $singlePersonBooking ? " checked=\"checked\"" : "" ); ?>
    148                                    value="true" />
    149                             <?php echo esc_html_x( 'Participant is also customer and contact (Only allow a single participant)', 'backend', 'eduadmin-booking' ); ?>
    150                         </label>
    151                         <br /> <?php
    152                         $blockEditIfLoggedIn = EDU()->get_option( 'eduadmin-blockEditIfLoggedIn', true );
    153                         ?>
    154                         <label>
    155                             <input type="checkbox"
    156                                    name="eduadmin-blockEditIfLoggedIn"<?php echo( $blockEditIfLoggedIn ? " checked=\"checked\"" : "" ); ?>
    157                                    value="true" />
    158                             <?php echo esc_html_x( 'Block ability to edit login information if logged in', 'backend', 'eduadmin-booking' ); ?>
    159                         </label>
    160                         <br /> <?php
    161                         $allowCustomerToUpdate = EDU()->get_option( 'eduadmin-allowCustomerUpdate', false );
    162                         ?>
    163                         <label>
    164                             <input type="checkbox"
    165                                    name="eduadmin-allowCustomerUpdate"<?php echo( $allowCustomerToUpdate ? " checked=\"checked\"" : "" ); ?>
    166                                    value="true" />
    167                             <?php echo esc_html_x( 'Allow end customer to overwrite customer info (requires logged in users)', 'backend', 'eduadmin-booking' ); ?>
    168                         </label>
    169                         <br /><?php
    170                         $alwaysAllowChangeEvent = EDU()->get_option( 'eduadmin-alwaysAllowChangeEvent', false );
    171                         ?>
    172                         <label>
    173                             <input type="checkbox"
    174                                    name="eduadmin-alwaysAllowChangeEvent"<?php checked( $alwaysAllowChangeEvent, "true" ); ?>
    175                                    value="true" />
    176                             <?php echo esc_html_x( 'Allow end customers to always switch between available events', 'backend', 'eduadmin-booking' ); ?>
    177                         </label>
    178                         <br /> <?php
    179                         $allowDiscountCode = EDU()->get_option( 'eduadmin-allowDiscountCode', false );
    180                         ?>
    181                         <label>
    182                             <input type="checkbox"
    183                                    name="eduadmin-allowDiscountCode"<?php checked( $allowDiscountCode, "true" ); ?>
    184                                    value="true" />
    185                             <?php echo esc_html_x( 'Allow end customers to use discount codes', 'backend', 'eduadmin-booking' ); ?>
    186                         </label>
    187                         <br /> <?php
    188                         $useLimitedDiscount = EDU()->get_option( 'eduadmin-useLimitedDiscount', false );
    189                         ?>
    190                         <label>
    191                             <input type="checkbox"
    192                                    name="eduadmin-useLimitedDiscount"<?php checked( $useLimitedDiscount, "true" ); ?>
    193                                    value="true" />
    194                             <?php echo esc_html_x( 'Allow end customers to use discount cards', 'backend', 'eduadmin-booking' ); ?>
    195                         </label>
    196                         <br /> <?php
    197                         $validateCivicRegNo = EDU()->get_option( 'eduadmin-validateCivicRegNo', false );
    198                         ?>
    199                         <label>
    200                             <input type="checkbox"
    201                                    name="eduadmin-validateCivicRegNo"<?php checked( $validateCivicRegNo, "true" ); ?>
    202                                    value="true" />
    203                             <?php echo esc_html_x( 'Validate civic registration numbers (Swedish)', 'backend', 'eduadmin-booking' ); ?>
    204                         </label>
    205                         <br /><?php
    206                         $alwaysUsePaymentPlugin = EDU()->get_option( 'eduadmin-alwaysUsePaymentPlugin', false );
    207                         ?>
    208                         <label>
    209                             <input type="checkbox"
    210                                    name="eduadmin-alwaysUsePaymentPlugin"<?php checked( $alwaysUsePaymentPlugin, "true" ); ?>
    211                                    value="true" />
    212                             <?php echo esc_html_x( 'Always use payment plugin (if applicable) for bookings', 'backend', 'eduadmin-booking' ); ?>
    213                         </label>
    214                         <br /><?php
    215                         $dontSendConfirmation = EDU()->get_option( 'eduadmin-dontSendConfirmation', false );
    216                         ?>
    217                         <label>
    218                             <input type="checkbox"
    219                                    name="eduadmin-dontSendConfirmation"<?php checked( $dontSendConfirmation, "true" ); ?>
    220                                    value="true" />
    221                             <?php echo esc_html_x( 'Do not send confirmation emails (if you use automatic emails in EduAdmin)', 'backend', 'eduadmin-booking' ); ?>
    222                         </label>
    223                         <br />
    224 
    225                         <h4><?php echo esc_html_x( 'Confirmation settings', 'backend', 'eduadmin-booking' ); ?></h4>
    226                         <?php
    227                         $confirmationSettingsParticipants    = EDU()->get_option( 'eduadmin-confirmationSettings-participants', "true" );
    228                         $confirmationSettingsCustomer        = EDU()->get_option( 'eduadmin-confirmationSettings-customer', "true" );
    229                         $confirmationSettingsCustomerContact = EDU()->get_option( 'eduadmin-confirmationSettings-customercontact', "true" );
    230                         ?>
    231                         <p><?php echo esc_html_x( 'Decide who gets the confirmation after a booking is completed.', 'backend', 'eduadmin-booking' ); ?></p>
    232                         <label>
    233                             <input type="checkbox"
    234                                    name="eduadmin-confirmationSettings-participants"<?php checked( $confirmationSettingsParticipants, 'true' ); ?>
    235                                    value="true" />
    236                             <?php echo esc_html_x( 'Send confirmation to all participants', 'backend', 'eduadmin-booking' ); ?>
    237                         </label>
    238                         <br />
    239                         <label>
    240                             <input type="checkbox"
    241                                    name="eduadmin-confirmationSettings-customer"<?php checked( $confirmationSettingsCustomer, 'true' ); ?>
    242                                    value="true" />
    243                             <?php echo esc_html_x( 'Send confirmation to the customer email', 'backend', 'eduadmin-booking' ); ?>
    244                         </label>
    245                         <br />
    246                         <label>
    247                             <input type="checkbox"
    248                                    name="eduadmin-confirmationSettings-customercontact"<?php checked( $confirmationSettingsCustomerContact, 'true' ); ?>
    249                                    value="true" />
    250                             <?php echo esc_html_x( 'Send confirmation to the customer contact', 'backend', 'eduadmin-booking' ); ?>
    251                         </label>
    252                         <br />
    253 
    254                         <h4><?php echo esc_html_x( 'Field order', 'backend', 'eduadmin-booking' ); ?></h4> <?php
    255                         $fieldOrder = EDU()->get_option( 'eduadmin-fieldOrder', 'contact_customer' );
    256                         ?>
    257                         <label>
    258                             <input type="radio"
    259                                    name="eduadmin-fieldOrder"<?php checked( $fieldOrder, "contact_customer" ); ?>
    260                                    value="contact_customer" />
    261                             <?php echo esc_html_x( 'Contact, customer', 'backend', 'eduadmin-booking' ); ?>
    262                         </label>
    263                         <br />
    264                         <label>
    265                             <input type="radio"
    266                                    name="eduadmin-fieldOrder"<?php checked( $fieldOrder, "customer_contact" ); ?>
    267                                    value="customer_contact" />
    268                             <?php echo esc_html_x( 'Customer, contact', 'backend', 'eduadmin-booking' ); ?>
    269                         </label>
    270                         <br />
    271                         <h4><?php echo esc_html_x( 'Sub Events', 'backend', 'eduadmin-booking' ); ?></h4> <?php
    272                         $hideSubEventDateTime = EDU()->get_option( 'eduadmin-hideSubEventDateTime', false );
    273                         ?>
    274                         <label>
    275                             <input type="checkbox"
    276                                    name="eduadmin-hideSubEventDateTime"<?php checked( $hideSubEventDateTime, "true" ); ?>
    277                                    value="true" />
    278                             <?php echo esc_html_x( 'Hide date and time information from sub events', 'backend', 'eduadmin-booking' ); ?>
    279                         </label>
    280                         <br />
    281                         <h4><?php echo esc_html_x( 'Interest registration', 'backend', 'eduadmin-booking' ); ?></h4> <?php
    282                         $allowInterestRegObject = EDU()->get_option( 'eduadmin-allowInterestRegObject', false );
    283                         $allowInterestRegEvent  = EDU()->get_option( 'eduadmin-allowInterestRegEvent', false );
    284                         ?>
    285                         <label>
    286                             <input type="checkbox"
    287                                    name="eduadmin-allowInterestRegObject"<?php checked( $allowInterestRegObject, "true" ); ?>
    288                                    value="true" />
    289                             <?php echo esc_html_x( 'Allow interest registration for course', 'backend', 'eduadmin-booking' ); ?>
    290                         </label>
    291                         <br />
    292                         <label>
    293                             <input type="checkbox"
    294                                    name="eduadmin-allowInterestRegEvent"<?php checked( $allowInterestRegEvent, "true" ); ?>
    295                                    value="true" />
    296                             <?php echo esc_html_x( 'Allow interest registration for event', 'backend', 'eduadmin-booking' ); ?>
    297                         </label>
    298                         <br />
    299                         <h4><?php echo esc_html_x( 'Form settings', 'backend', 'eduadmin-booking' ); ?></h4>
    300                         <button class="button" disabled
    301                                 onclick="showFormWindow(); return false;"><?php _ex( 'Show settings', 'backend', 'eduadmin-booking' ); ?></button>
    302                         <br />
    303                         <br /> <?php $noInvoiceFreeEvents = EDU()->get_option( 'eduadmin-noInvoiceFreeEvents', false ); ?>
    304                         <label>
    305                             <input type="checkbox"
    306                                    name="eduadmin-noInvoiceFreeEvents"<?php checked( $noInvoiceFreeEvents, "true" ); ?>
    307                                    value="true" />
    308                             <?php echo esc_html_x( 'Hide invoice information if the event is free', 'backend', 'eduadmin-booking' ); ?>
    309                         </label>
    310                         <br /> <?php $hideInvoiceEmailField = EDU()->get_option( 'eduadmin-hideInvoiceEmailField', false ); ?>
    311                         <label>
    312                             <input type="checkbox"
    313                                    name="eduadmin-hideInvoiceEmailField"<?php checked( $hideInvoiceEmailField, "true" ); ?>
    314                                    value="true" />
    315                             <?php echo esc_html_x( 'Hide the invoice e-mail field', 'backend', 'eduadmin-booking' ); ?>
    316                         </label>
    317                         <br /> <?php $forceShowInvoiceInformation = EDU()->get_option( 'eduadmin-showInvoiceInformation', false ); ?>
    318                         <label>
    319                             <input type="checkbox"
    320                                    name="eduadmin-showInvoiceInformation"<?php checked( $forceShowInvoiceInformation, "true" ); ?>
    321                                    value="true" />
    322                             <?php echo esc_html_x( 'Force show invoice information fields', 'backend', 'eduadmin-booking' ); ?>
    323                         </label>
    324                         <h3><?php echo esc_html_x( 'Price name settings', 'backend', 'eduadmin-booking' ); ?></h3> <?php
    325                         $priceNameSetting = EDU()->get_option( 'eduadmin-selectPricename', 'firstPublic' );
    326                         ?>
    327                         <label>
    328                             <input type="radio"
    329                                    name="eduadmin-selectPricename"<?php checked( $priceNameSetting, "firstPublic" ); ?>
    330                                    value="firstPublic" />
    331                             <?php echo esc_html_x( 'EduAdmin chooses the appropriate price name for the event and participants', 'backend', 'eduadmin-booking' ); ?>
    332                         </label>
    333                         <br />
    334                         <label>
    335                             <input type="radio"
    336                                    name="eduadmin-selectPricename"<?php checked( $priceNameSetting, "selectWholeEvent" ); ?>
    337                                    value="selectWholeEvent" />
    338                             <?php echo esc_html_x( 'Can choose between public price names', 'backend', 'eduadmin-booking' ); ?>
    339                         </label>
    340                         <br />
    341                         <label>
    342                             <input type="radio"
    343                                    name="eduadmin-selectPricename"<?php checked( $priceNameSetting, "selectParticipant" ); ?>
    344                                    value="selectParticipant" />
    345                             <?php echo esc_html_x( 'Can choose per participant', 'backend', 'eduadmin-booking' ); ?>
    346                         </label> <?php
    347                         $selected_match = EDU()->get_option( 'eduadmin-customerMatching', 'use-match' );
    348                         ?>
    349                         <h3><?php echo esc_html_x( 'Customer matching', 'backend', 'eduadmin-booking' ); ?></h3>
    350                         <select name="eduadmin-customerMatching">
    351                             <option<?php selected( $selected_match, 'use-match' ); ?> value="use-match">
    352                                 <?php echo esc_html_x( 'Let EduAdmin match customers (Creates new if no match is found)', 'backend', 'eduadmin-booking' ); ?>
    353                             </option>
    354                             <option<?php selected( $selected_match, 'no-match' ); ?> value="no-match">
    355                                 <?php echo esc_html_x( 'No matching (Creates new customers every time)', 'backend', 'eduadmin-booking' ); ?>
    356                             </option>
    357                         </select>
    358                         <br />
    359                         <br /> <?php
    360                         $selectedCurrency = EDU()->get_option( 'eduadmin-currency', 'SEK' );
    361                         ?> <h3><?php echo esc_html_x( 'Currency', 'backend', 'eduadmin-booking' ); ?></h3>
    362                         <select name="eduadmin-currency">
    363                             <option value="AED"<?php selected( $selectedCurrency, "AED" ); ?>>
    364                                 AED
    365                                 - United Arab Emirates, Dirhams
    366                             </option>
    367                             <option value="AFN"<?php selected( $selectedCurrency, "AFN" ); ?>>
    368                                 AFN
    369                                 - Afghanistan, Afghanis
    370                             </option>
    371                             <option value="ALL"<?php selected( $selectedCurrency, "ALL" ); ?>>
    372                                 ALL
    373                                 - Albania, Leke
    374                             </option>
    375                             <option value="AMD"<?php selected( $selectedCurrency, "AMD" ); ?>>
    376                                 AMD
    377                                 - Armenia, Drams
    378                             </option>
    379                             <option value="ANG"<?php selected( $selectedCurrency, "ANG" ); ?>>
    380                                 ANG
    381                                 - Netherlands Antilles, Guilders (also called Florins)
    382                             </option>
    383                             <option value="AOA"<?php selected( $selectedCurrency, "AOA" ); ?>>
    384                                 AOA
    385                                 - Angola, Kwanza
    386                             </option>
    387                             <option value="ARS"<?php selected( $selectedCurrency, "ARS" ); ?>>
    388                                 ARS
    389                                 - Argentina, Pesos
    390                             </option>
    391                             <option value="AUD"<?php selected( $selectedCurrency, "AUD" ); ?>>
    392                                 AUD
    393                                 - Australia, Dollars
    394                             </option>
    395                             <option value="AWG"<?php selected( $selectedCurrency, "AWG" ); ?>>
    396                                 AWG
    397                                 - Aruba, Guilders (also called Florins)
    398                             </option>
    399                             <option value="AZN"<?php selected( $selectedCurrency, "AZN" ); ?>>
    400                                 AZN
    401                                 - Azerbaijan, New Manats
    402                             </option>
    403                             <option value="BAM"<?php selected( $selectedCurrency, "BAM" ); ?>>
    404                                 BAM
    405                                 - Bosnia and Herzegovina, Convertible Marka
    406                             </option>
    407                             <option value="BBD"<?php selected( $selectedCurrency, "BBD" ); ?>>
    408                                 BBD
    409                                 - Barbados, Dollars
    410                             </option>
    411                             <option value="BDT"<?php selected( $selectedCurrency, "BDT" ); ?>>
    412                                 BDT
    413                                 - Bangladesh, Taka
    414                             </option>
    415                             <option value="BGN"<?php selected( $selectedCurrency, "BGN" ); ?>>
    416                                 BGN
    417                                 - Bulgaria, Leva
    418                             </option>
    419                             <option value="BHD"<?php selected( $selectedCurrency, "BHD" ); ?>>
    420                                 BHD
    421                                 - Bahrain, Dinars
    422                             </option>
    423                             <option value="BIF"<?php selected( $selectedCurrency, "BIF" ); ?>>
    424                                 BIF
    425                                 - Burundi, Francs
    426                             </option>
    427                             <option value="BMD"<?php selected( $selectedCurrency, "BMD" ); ?>>
    428                                 BMD
    429                                 - Bermuda, Dollars
    430                             </option>
    431                             <option value="BND"<?php selected( $selectedCurrency, "BND" ); ?>>
    432                                 BND
    433                                 - Brunei Darussalam, Dollars
    434                             </option>
    435                             <option value="BOB"<?php selected( $selectedCurrency, "BOB" ); ?>>
    436                                 BOB
    437                                 - Bolivia, Bolivianos
    438                             </option>
    439                             <option value="BRL"<?php selected( $selectedCurrency, "BRL" ); ?>>
    440                                 BRL
    441                                 - Brazil, Brazil Real
    442                             </option>
    443                             <option value="BSD"<?php selected( $selectedCurrency, "BSD" ); ?>>
    444                                 BSD
    445                                 - Bahamas, Dollars
    446                             </option>
    447                             <option value="BTN"<?php selected( $selectedCurrency, "BTN" ); ?>>
    448                                 BTN
    449                                 - Bhutan, Ngultrum
    450                             </option>
    451                             <option value="BWP"<?php selected( $selectedCurrency, "BWP" ); ?>>
    452                                 BWP
    453                                 - Botswana, Pulas
    454                             </option>
    455                             <option value="BYR"<?php selected( $selectedCurrency, "BYR" ); ?>>
    456                                 BYR
    457                                 - Belarus, Rubles
    458                             </option>
    459                             <option value="BZD"<?php selected( $selectedCurrency, "BZD" ); ?>>
    460                                 BZD
    461                                 - Belize, Dollars
    462                             </option>
    463                             <option value="CAD"<?php selected( $selectedCurrency, "CAD" ); ?>>
    464                                 CAD
    465                                 - Canada, Dollars
    466                             </option>
    467                             <option value="CDF"<?php selected( $selectedCurrency, "CDF" ); ?>>
    468                                 CDF
    469                                 - Congo/Kinshasa, Congolese Francs
    470                             </option>
    471                             <option value="CHF"<?php selected( $selectedCurrency, "CHF" ); ?>>
    472                                 CHF
    473                                 - Switzerland, Francs
    474                             </option>
    475                             <option value="CLP"<?php selected( $selectedCurrency, "CLP" ); ?>>
    476                                 CLP
    477                                 - Chile, Pesos
    478                             </option>
    479                             <option value="CNY"<?php selected( $selectedCurrency, "CNY" ); ?>>
    480                                 CNY
    481                                 - China, Yuan Renminbi
    482                             </option>
    483                             <option value="COP"<?php selected( $selectedCurrency, "COP" ); ?>>
    484                                 COP
    485                                 - Colombia, Pesos
    486                             </option>
    487                             <option value="CRC"<?php selected( $selectedCurrency, "CRC" ); ?>>
    488                                 CRC
    489                                 - Costa Rica, Colones
    490                             </option>
    491                             <option value="CUP"<?php selected( $selectedCurrency, "CUP" ); ?>>
    492                                 CUP
    493                                 - Cuba, Pesos
    494                             </option>
    495                             <option value="CVE"<?php selected( $selectedCurrency, "CVE" ); ?>>
    496                                 CVE
    497                                 - Cape Verde, Escudos
    498                             </option>
    499                             <option value="CZK"<?php selected( $selectedCurrency, "CZK" ); ?>>
    500                                 CZK
    501                                 - Czech Republic, Koruny
    502                             </option>
    503                             <option value="DJF"<?php selected( $selectedCurrency, "DJF" ); ?>>
    504                                 DJF
    505                                 - Djibouti, Francs
    506                             </option>
    507                             <option value="DKK"<?php selected( $selectedCurrency, "DKK" ); ?>>
    508                                 DKK
    509                                 - Denmark, Kroner
    510                             </option>
    511                             <option value="DOP"<?php selected( $selectedCurrency, "DOP" ); ?>>
    512                                 DOP
    513                                 - Dominican Republic, Pesos
    514                             </option>
    515                             <option value="DZD"<?php selected( $selectedCurrency, "DZD" ); ?>>
    516                                 DZD
    517                                 - Algeria, Algeria Dinars
    518                             </option>
    519                             <option value="EGP"<?php selected( $selectedCurrency, "EGP" ); ?>>
    520                                 EGP
    521                                 - Egypt, Pounds
    522                             </option>
    523                             <option value="ERN"<?php selected( $selectedCurrency, "ERN" ); ?>>
    524                                 ERN
    525                                 - Eritrea, Nakfa
    526                             </option>
    527                             <option value="ETB"<?php selected( $selectedCurrency, "ETB" ); ?>>
    528                                 ETB
    529                                 - Ethiopia, Birr
    530                             </option>
    531                             <option value="EUR"<?php selected( $selectedCurrency, "EUR" ); ?>>
    532                                 EUR
    533                                 - Euro Member Countries, Euro
    534                             </option>
    535                             <option value="FJD"<?php selected( $selectedCurrency, "FJD" ); ?>>
    536                                 FJD
    537                                 - Fiji, Dollars
    538                             </option>
    539                             <option value="FKP"<?php selected( $selectedCurrency, "FKP" ); ?>>
    540                                 FKP
    541                                 - Falkland Islands (Malvinas), Pounds
    542                             </option>
    543                             <option value="GBP"<?php selected( $selectedCurrency, "GBP" ); ?>>
    544                                 GBP
    545                                 - United Kingdom, Pounds
    546                             </option>
    547                             <option value="GEL"<?php selected( $selectedCurrency, "GEL" ); ?>>
    548                                 GEL
    549                                 - Georgia, Lari
    550                             </option>
    551                             <option value="GHS"<?php selected( $selectedCurrency, "GHS" ); ?>>
    552                                 GHS
    553                                 - Ghana, Cedis
    554                             </option>
    555                             <option value="GIP"<?php selected( $selectedCurrency, "GIP" ); ?>>
    556                                 GIP
    557                                 - Gibraltar, Pounds
    558                             </option>
    559                             <option value="GMD"<?php selected( $selectedCurrency, "GMD" ); ?>>
    560                                 GMD
    561                                 - Gambia, Dalasi
    562                             </option>
    563                             <option value="GNF"<?php selected( $selectedCurrency, "GNF" ); ?>>
    564                                 GNF
    565                                 - Guinea, Francs
    566                             </option>
    567                             <option value="GTQ"<?php selected( $selectedCurrency, "GTQ" ); ?>>
    568                                 GTQ
    569                                 - Guatemala, Quetzales
    570                             </option>
    571                             <option value="GYD"<?php selected( $selectedCurrency, "GYD" ); ?>>
    572                                 GYD
    573                                 - Guyana, Dollars
    574                             </option>
    575                             <option value="HKD"<?php selected( $selectedCurrency, "HKD" ); ?>>
    576                                 HKD
    577                                 - Hong Kong, Dollars
    578                             </option>
    579                             <option value="HNL"<?php selected( $selectedCurrency, "HNL" ); ?>>
    580                                 HNL
    581                                 - Honduras, Lempiras
    582                             </option>
    583                             <option value="HRK"<?php selected( $selectedCurrency, "HRK" ); ?>>
    584                                 HRK
    585                                 - Croatia, Kuna
    586                             </option>
    587                             <option value="HTG"<?php selected( $selectedCurrency, "HTG" ); ?>>
    588                                 HTG
    589                                 - Haiti, Gourdes
    590                             </option>
    591                             <option value="HUF"<?php selected( $selectedCurrency, "HUF" ); ?>>
    592                                 HUF
    593                                 - Hungary, Forint
    594                             </option>
    595                             <option value="IDR"<?php selected( $selectedCurrency, "IDR" ); ?>>
    596                                 IDR
    597                                 - Indonesia, Rupiahs
    598                             </option>
    599                             <option value="ILS"<?php selected( $selectedCurrency, "ILS" ); ?>>
    600                                 ILS
    601                                 - Israel, New Shekels
    602                             </option>
    603                             <option value="INR"<?php selected( $selectedCurrency, "INR" ); ?>>
    604                                 INR
    605                                 - India, Rupees
    606                             </option>
    607                             <option value="IQD"<?php selected( $selectedCurrency, "IQD" ); ?>>
    608                                 IQD
    609                                 - Iraq, Dinars
    610                             </option>
    611                             <option value="IRR"<?php selected( $selectedCurrency, "IRR" ); ?>>
    612                                 IRR
    613                                 - Iran, Rials
    614                             </option>
    615                             <option value="ISK"<?php selected( $selectedCurrency, "ISK" ); ?>>
    616                                 ISK
    617                                 - Iceland, Kronur
    618                             </option>
    619                             <option value="JMD"<?php selected( $selectedCurrency, "JMD" ); ?>>
    620                                 JMD
    621                                 - Jamaica, Dollars
    622                             </option>
    623                             <option value="JOD"<?php selected( $selectedCurrency, "JOD" ); ?>>
    624                                 JOD
    625                                 - Jordan, Dinars
    626                             </option>
    627                             <option value="JPY"<?php selected( $selectedCurrency, "JPY" ); ?>>
    628                                 JPY
    629                                 - Japan, Yen
    630                             </option>
    631                             <option value="KES"<?php selected( $selectedCurrency, "KES" ); ?>>
    632                                 KES
    633                                 - Kenya, Shillings
    634                             </option>
    635                             <option value="KGS"<?php selected( $selectedCurrency, "KGS" ); ?>>
    636                                 KGS
    637                                 - Kyrgyzstan, Soms
    638                             </option>
    639                             <option value="KHR"<?php selected( $selectedCurrency, "KHR" ); ?>>
    640                                 KHR
    641                                 - Cambodia, Riels
    642                             </option>
    643                             <option value="KMF"<?php selected( $selectedCurrency, "KMF" ); ?>>
    644                                 KMF
    645                                 - Comoros, Francs
    646                             </option>
    647                             <option value="KPW"<?php selected( $selectedCurrency, "KPW" ); ?>>
    648                                 KPW
    649                                 - Korea (North), Won
    650                             </option>
    651                             <option value="KRW"<?php selected( $selectedCurrency, "KRW" ); ?>>
    652                                 KRW
    653                                 - Korea (South), Won
    654                             </option>
    655                             <option value="KWD"<?php selected( $selectedCurrency, "KWD" ); ?>>
    656                                 KWD
    657                                 - Kuwait, Dinars
    658                             </option>
    659                             <option value="KYD"<?php selected( $selectedCurrency, "KYD" ); ?>>
    660                                 KYD
    661                                 - Cayman Islands, Dollars
    662                             </option>
    663                             <option value="KZT"<?php selected( $selectedCurrency, "KZT" ); ?>>
    664                                 KZT
    665                                 - Kazakhstan, Tenge
    666                             </option>
    667                             <option value="LAK"<?php selected( $selectedCurrency, "LAK" ); ?>>
    668                                 LAK
    669                                 - Laos, Kips
    670                             </option>
    671                             <option value="LBP"<?php selected( $selectedCurrency, "LBP" ); ?>>
    672                                 LBP
    673                                 - Lebanon, Pounds
    674                             </option>
    675                             <option value="LKR"<?php selected( $selectedCurrency, "LKR" ); ?>>
    676                                 LKR
    677                                 - Sri Lanka, Rupees
    678                             </option>
    679                             <option value="LRD"<?php selected( $selectedCurrency, "LRD" ); ?>>
    680                                 LRD
    681                                 - Liberia, Dollars
    682                             </option>
    683                             <option value="LSL"<?php selected( $selectedCurrency, "LSL" ); ?>>
    684                                 LSL
    685                                 - Lesotho, Maloti
    686                             </option>
    687                             <option value="LYD"<?php selected( $selectedCurrency, "LYD" ); ?>>
    688                                 LYD
    689                                 - Libya, Dinars
    690                             </option>
    691                             <option value="MAD"<?php selected( $selectedCurrency, "MAD" ); ?>>
    692                                 MAD
    693                                 - Morocco, Dirhams
    694                             </option>
    695                             <option value="MDL"<?php selected( $selectedCurrency, "MDL" ); ?>>
    696                                 MDL
    697                                 - Moldova, Lei
    698                             </option>
    699                             <option value="MGA"<?php selected( $selectedCurrency, "MGA" ); ?>>
    700                                 MGA
    701                                 - Madagascar, Ariary
    702                             </option>
    703                             <option value="MKD"<?php selected( $selectedCurrency, "MKD" ); ?>>
    704                                 MKD
    705                                 - Macedonia, Denars
    706                             </option>
    707                             <option value="MMK"<?php selected( $selectedCurrency, "MMK" ); ?>>
    708                                 MMK
    709                                 - Myanmar (Burma), Kyats
    710                             </option>
    711                             <option value="MNT"<?php selected( $selectedCurrency, "MNT" ); ?>>
    712                                 MNT
    713                                 - Mongolia, Tugriks
    714                             </option>
    715                             <option value="MOP"<?php selected( $selectedCurrency, "MOP" ); ?>>
    716                                 MOP
    717                                 - Macau, Patacas
    718                             </option>
    719                             <option value="MRO"<?php selected( $selectedCurrency, "MRO" ); ?>>
    720                                 MRO
    721                                 - Mauritania, Ouguiyas
    722                             </option>
    723                             <option value="MUR"<?php selected( $selectedCurrency, "MUR" ); ?>>
    724                                 MUR
    725                                 - Mauritius, Rupees
    726                             </option>
    727                             <option value="MWK"<?php selected( $selectedCurrency, "MWK" ); ?>>
    728                                 MWK
    729                                 - Malawi, Kwachas
    730                             </option>
    731                             <option value="MVR"<?php selected( $selectedCurrency, "MVR" ); ?>>
    732                                 MVR
    733                                 - Maldives (Maldive Islands), Rufiyaa
    734                             </option>
    735                             <option value="MXN"<?php selected( $selectedCurrency, "MXN" ); ?>>
    736                                 MXN
    737                                 - Mexico, Pesos
    738                             </option>
    739                             <option value="MYR"<?php selected( $selectedCurrency, "MYR" ); ?>>
    740                                 MYR
    741                                 - Malaysia, Ringgits
    742                             </option>
    743                             <option value="MZN"<?php selected( $selectedCurrency, "MZN" ); ?>>
    744                                 MZN
    745                                 - Mozambique, Meticais
    746                             </option>
    747                             <option value="NAD"<?php selected( $selectedCurrency, "NAD" ); ?>>
    748                                 NAD
    749                                 - Namibia, Dollars
    750                             </option>
    751                             <option value="NGN"<?php selected( $selectedCurrency, "NGN" ); ?>>
    752                                 NGN
    753                                 - Nigeria, Nairas
    754                             </option>
    755                             <option value="NIO"<?php selected( $selectedCurrency, "NIO" ); ?>>
    756                                 NIO
    757                                 - Nicaragua, Cordobas
    758                             </option>
    759                             <option value="NOK"<?php selected( $selectedCurrency, "NOK" ); ?>>
    760                                 NOK
    761                                 - Norway, Krone
    762                             </option>
    763                             <option value="NPR"<?php selected( $selectedCurrency, "NPR" ); ?>>
    764                                 NPR
    765                                 - Nepal, Nepal Rupees
    766                             </option>
    767                             <option value="NZD"<?php selected( $selectedCurrency, "NZD" ); ?>>
    768                                 NZD
    769                                 - New Zealand, Dollars
    770                             </option>
    771                             <option value="OMR"<?php selected( $selectedCurrency, "OMR" ); ?>>
    772                                 OMR
    773                                 - Oman, Rials
    774                             </option>
    775                             <option value="PAB"<?php selected( $selectedCurrency, "PAB" ); ?>>
    776                                 PAB
    777                                 - Panama, Balboa
    778                             </option>
    779                             <option value="PEN"<?php selected( $selectedCurrency, "PEN" ); ?>>
    780                                 PEN
    781                                 - Peru, Nuevos Soles
    782                             </option>
    783                             <option value="PGK"<?php selected( $selectedCurrency, "PGK" ); ?>>
    784                                 PGK
    785                                 - Papua New Guinea, Kina
    786                             </option>
    787                             <option value="PHP"<?php selected( $selectedCurrency, "PHP" ); ?>>
    788                                 PHP
    789                                 - Philippines, Pesos
    790                             </option>
    791                             <option value="PKR"<?php selected( $selectedCurrency, "PKR" ); ?>>
    792                                 PKR
    793                                 - Pakistan, Rupees
    794                             </option>
    795                             <option value="PLN"<?php selected( $selectedCurrency, "PLN" ); ?>>
    796                                 PLN
    797                                 - Poland, Zlotych
    798                             </option>
    799                             <option value="PYG"<?php selected( $selectedCurrency, "PYG" ); ?>>
    800                                 PYG
    801                                 - Paraguay, Guarani
    802                             </option>
    803                             <option value="QAR"<?php selected( $selectedCurrency, "QAR" ); ?>>
    804                                 QAR
    805                                 - Qatar, Rials
    806                             </option>
    807                             <option value="RON"<?php selected( $selectedCurrency, "RON" ); ?>>
    808                                 RON
    809                                 - Romania, New Lei
    810                             </option>
    811                             <option value="RSD"<?php selected( $selectedCurrency, "RSD" ); ?>>
    812                                 RSD
    813                                 - Serbia, Dinars
    814                             </option>
    815                             <option value="RUB"<?php selected( $selectedCurrency, "RUB" ); ?>>
    816                                 RUB
    817                                 - Russia, Rubles
    818                             </option>
    819                             <option value="RWF"<?php selected( $selectedCurrency, "RWF" ); ?>>
    820                                 RWF
    821                                 - Rwanda, Rwanda Francs
    822                             </option>
    823                             <option value="SAR"<?php selected( $selectedCurrency, "SAR" ); ?>>
    824                                 SAR
    825                                 - Saudi Arabia, Riyals
    826                             </option>
    827                             <option value="SBD"<?php selected( $selectedCurrency, "SBD" ); ?>>
    828                                 SBD
    829                                 - Solomon Islands, Dollars
    830                             </option>
    831                             <option value="SCR"<?php selected( $selectedCurrency, "SCR" ); ?>>
    832                                 SCR
    833                                 - Seychelles, Rupees
    834                             </option>
    835                             <option value="SDG"<?php selected( $selectedCurrency, "SDG" ); ?>>
    836                                 SDG
    837                                 - Sudan, Pounds
    838                             </option>
    839                             <option value="SEK"<?php selected( $selectedCurrency, "SEK" ); ?>>
    840                                 SEK
    841                                 - Sweden, Kronor
    842                             </option>
    843                             <option value="SGD"<?php selected( $selectedCurrency, "SGD" ); ?>>
    844                                 SGD
    845                                 - Singapore, Dollars
    846                             </option>
    847                             <option value="SHP"<?php selected( $selectedCurrency, "SHP" ); ?>>
    848                                 SHP
    849                                 - Saint Helena, Pounds
    850                             </option>
    851                             <option value="SLL"<?php selected( $selectedCurrency, "SLL" ); ?>>
    852                                 SLL
    853                                 - Sierra Leone, Leones
    854                             </option>
    855                             <option value="SOS"<?php selected( $selectedCurrency, "SOS" ); ?>>
    856                                 SOS
    857                                 - Somalia, Shillings
    858                             </option>
    859                             <option value="SRD"<?php selected( $selectedCurrency, "SRD" ); ?>>
    860                                 SRD
    861                                 - Suriname, Dollars
    862                             </option>
    863                             <option value="STD"<?php selected( $selectedCurrency, "STD" ); ?>>
    864                                 STD
    865                                 - São Tome and Principe, Dobras
    866                             </option>
    867                             <option value="SYP"<?php selected( $selectedCurrency, "SYP" ); ?>>
    868                                 SYP
    869                                 - Syria, Pounds
    870                             </option>
    871                             <option value="SZL"<?php selected( $selectedCurrency, "SZL" ); ?>>
    872                                 SZL
    873                                 - Swaziland, Emalangeni
    874                             </option>
    875                             <option value="THB"<?php selected( $selectedCurrency, "THB" ); ?>>
    876                                 THB
    877                                 - Thailand, Baht
    878                             </option>
    879                             <option value="TJS"<?php selected( $selectedCurrency, "TJS" ); ?>>
    880                                 TJS
    881                                 - Tajikistan, Somoni
    882                             </option>
    883                             <option value="TMT"<?php selected( $selectedCurrency, "TMT" ); ?>>
    884                                 TMT
    885                                 - Turkmenistan, New Manats
    886                             </option>
    887                             <option value="TND"<?php selected( $selectedCurrency, "TND" ); ?>>
    888                                 TND
    889                                 - Tunisia, Dinars
    890                             </option>
    891                             <option value="TOP"<?php selected( $selectedCurrency, "TOP" ); ?>>
    892                                 TOP
    893                                 - Tonga, Pa'anga
    894                             </option>
    895                             <option value="TRY"<?php selected( $selectedCurrency, "TRY" ); ?>>
    896                                 TRY
    897                                 - Turkey, New Lira
    898                             </option>
    899                             <option value="TTD"<?php selected( $selectedCurrency, "TTD" ); ?>>
    900                                 TTD
    901                                 - Trinidad and Tobago, Dollars
    902                             </option>
    903                             <option value="TWD"<?php selected( $selectedCurrency, "TWD" ); ?>>
    904                                 TWD
    905                                 - Taiwan, New Dollars
    906                             </option>
    907                             <option value="TZS"<?php selected( $selectedCurrency, "TZS" ); ?>>
    908                                 TZS
    909                                 - Tanzania, Shillings
    910                             </option>
    911                             <option value="UAH"<?php selected( $selectedCurrency, "UAH" ); ?>>
    912                                 UAH
    913                                 - Ukraine, Hryvnia
    914                             </option>
    915                             <option value="UGX"<?php selected( $selectedCurrency, "UGX" ); ?>>
    916                                 UGX
    917                                 - Uganda, Shillings
    918                             </option>
    919                             <option value="USD"<?php selected( $selectedCurrency, "USD" ); ?>>
    920                                 USD
    921                                 - United States of America, Dollars
    922                             </option>
    923                             <option value="UYU"<?php selected( $selectedCurrency, "UYU" ); ?>>
    924                                 UYU
    925                                 - Uruguay, Pesos
    926                             </option>
    927                             <option value="UZS"<?php selected( $selectedCurrency, "UZS" ); ?>>
    928                                 UZS
    929                                 - Uzbekistan, Sums
    930                             </option>
    931                             <option value="VEF"<?php selected( $selectedCurrency, "VEF" ); ?>>
    932                                 VEF
    933                                 - Venezuela, Bolivares Fuertes
    934                             </option>
    935                             <option value="VND"<?php selected( $selectedCurrency, "VND" ); ?>>
    936                                 VND
    937                                 - Viet Nam, Dong
    938                             </option>
    939                             <option value="WST"<?php selected( $selectedCurrency, "WST" ); ?>>
    940                                 WST
    941                                 - Samoa, Tala
    942                             </option>
    943                             <option value="VUV"<?php selected( $selectedCurrency, "VUV" ); ?>>
    944                                 VUV
    945                                 - Vanuatu, Vatu
    946                             </option>
    947                             <option value="XAF"<?php selected( $selectedCurrency, "XAF" ); ?>>
    948                                 XAF
    949                                 - Communauté Financière Africaine BEAC, Francs
    950                             </option>
    951                             <option value="XAG"<?php selected( $selectedCurrency, "XAG" ); ?>>
    952                                 XAG
    953                                 - Silver, Ounces
    954                             </option>
    955                             <option value="XAU"<?php selected( $selectedCurrency, "XAU" ); ?>>
    956                                 XAU
    957                                 - Gold, Ounces
    958                             </option>
    959                             <option value="XCD"<?php selected( $selectedCurrency, "XCD" ); ?>>
    960                                 XCD
    961                                 - East Caribbean Dollars
    962                             </option>
    963                             <option value="XDR"<?php selected( $selectedCurrency, "XDR" ); ?>>
    964                                 XDR
    965                                 - International Monetary Fund (IMF) Special Drawing Rights
    966                             </option>
    967                             <option value="XOF"<?php selected( $selectedCurrency, "XOF" ); ?>>
    968                                 XOF
    969                                 - Communauté Financière Africaine BCEAO, Francs
    970                             </option>
    971                             <option value="XPD"<?php selected( $selectedCurrency, "XPD" ); ?>>
    972                                 XPD
    973                                 - Palladium Ounces
    974                             </option>
    975                             <option value="XPF"<?php selected( $selectedCurrency, "XPF" ); ?>>
    976                                 XPF
    977                                 - Comptoirs Français du Pacifique Francs
    978                             </option>
    979                             <option value="XPT"<?php selected( $selectedCurrency, "XPT" ); ?>>
    980                                 XPT
    981                                 - Platinum, Ounces
    982                             </option>
    983                             <option value="YER"<?php selected( $selectedCurrency, "YER" ); ?>>
    984                                 YER
    985                                 - Yemen, Rials
    986                             </option>
    987                             <option value="ZAR"<?php selected( $selectedCurrency, "ZAR" ); ?>>
    988                                 ZAR
    989                                 - South Africa, Rand
    990                             </option>
    991                             <option value="ZMW"<?php selected( $selectedCurrency, "ZMW" ); ?>>
    992                                 ZMW
    993                                 - Zambia, Kwacha
    994                             </option>
    995                         </select>
    996                         <h3><?php echo esc_html_x( 'Booking terms', 'backend', 'eduadmin-booking' ); ?></h3>
    997                         <h4><?php echo esc_html_x( 'Booking terms link', 'backend', 'eduadmin-booking' ); ?></h4>
    998                         <input type="url" class="form-control" style="width: 100%;" name="eduadmin-bookingTermsLink"
    999                                placeholder="<?php _ex( 'Booking terms link', 'backend', 'eduadmin-booking' ); ?>"
    1000                                value="<?php echo EDU()->get_option( 'eduadmin-bookingTermsLink' ); ?>" />
    1001                         <br />
    1002                         <label>
    1003                             <input type="checkbox" name="eduadmin-useBookingTermsCheckbox"
    1004                                    value="true"<?php checked( EDU()->get_option( 'eduadmin-useBookingTermsCheckbox', false ), "true" ); ?> />
    1005                             <?php echo esc_html_x( 'Use booking terms', 'backend', 'eduadmin-booking' ); ?>
    1006                         </label>
    1007                         <h3><?php echo esc_html_x( 'Javascript to run when a booking is completed', 'backend', 'eduadmin-booking' ); ?></h3>
    1008                         <i><?php echo esc_html_x( 'You do not need to include &lt;script&gt;-tags', 'backend', 'eduadmin-booking' ); ?></i>
    1009                         <br />
    1010                         <table>
    1011                             <tr>
    1012                                 <td style="vertical-align: top;">
    1013                                 <textarea class="form-control" rows="10" cols="60"
    1014                                           name="eduadmin-javascript"><?php echo EDU()->get_option( 'eduadmin-javascript' ); ?></textarea>
    1015                                 </td>
    1016                                 <td style="vertical-align: top;">
    1017                                     <b><?php echo esc_html_x( 'Keywords for JavaScript', 'backend', 'eduadmin-booking' ); ?></b>
    1018                                     <br />
    1019                                     <hr noshade="noshade" />
    1020                                     <table>
    1021                                         <tr>
    1022                                             <td><b>$bookingno$</b></td>
    1023                                             <td><?php echo esc_html_x( 'The booking number', 'backend', 'eduadmin-booking' ); ?></td>
    1024                                         </tr>
    1025                                         <tr>
    1026                                             <td><b>$productname$</b></td>
    1027                                             <td><?php echo esc_html_x( 'Inserts the product name', 'backend', 'eduadmin-booking' ); ?></td>
    1028                                         </tr>
    1029                                         <tr>
    1030                                             <td><b>$totalsum$</b></td>
    1031                                             <td><?php echo esc_html_x( 'Inserts the total sum', 'backend', 'eduadmin-booking' ); ?></td>
    1032                                         </tr>
    1033                                         <tr>
    1034                                             <td><b>$participants$</b></td>
    1035                                             <td><?php echo esc_html_x( 'Inserts the number participants', 'backend', 'eduadmin-booking' ); ?></td>
    1036                                         </tr>
    1037                                         <tr>
    1038                                             <td><b>$startdate$</b></td>
    1039                                             <td><?php echo esc_html_x( 'Inserts the start date of the event', 'backend', 'eduadmin-booking' ); ?></td>
    1040                                         </tr>
    1041                                         <tr>
    1042                                             <td><b>$enddate$</b></td>
    1043                                             <td><?php echo esc_html_x( 'Inserts the end date of the event', 'backend', 'eduadmin-booking' ); ?></td>
    1044                                         </tr>
    1045                                         <tr>
    1046                                             <td><b>$eventid$</b></td>
    1047                                             <td><?php echo esc_html_x( 'Inserts the event unique identifier', 'backend', 'eduadmin-booking' ); ?></td>
    1048                                         </tr>
    1049                                         <tr>
    1050                                             <td><b>$eventdescription$</b></td>
    1051                                             <td><?php echo esc_html_x( 'Inserts the event description', 'backend', 'eduadmin-booking' ); ?></td>
    1052                                         </tr>
    1053                                         <tr>
    1054                                             <td><b>$customerid$</b></td>
    1055                                             <td><?php echo esc_html_x( 'Inserts the generated customer id', 'backend', 'eduadmin-booking' ); ?></td>
    1056                                         </tr>
    1057                                         <tr>
    1058                                             <td><b>$customercontactid$</b></td>
    1059                                             <td><?php echo esc_html_x( 'Inserts the generated contact id', 'backend', 'eduadmin-booking' ); ?></td>
    1060                                         </tr>
    1061                                         <tr>
    1062                                             <td><b>$created$</b></td>
    1063                                             <td><?php echo esc_html_x( 'Inserts the date the booking was created', 'backend', 'eduadmin-booking' ); ?></td>
    1064                                         </tr>
    1065                                         <tr>
    1066                                             <td><b>$paid$</b></td>
    1067                                             <td><?php echo esc_html_x( 'Inserts the payment status', 'backend', 'eduadmin-booking' ); ?></td>
    1068                                         </tr>
    1069                                         <tr>
    1070                                             <td><b>$objectid$</b></td>
    1071                                             <td><?php echo esc_html_x( 'Inserts the unique identifier for the course', 'backend', 'eduadmin-booking' ); ?></td>
    1072                                         </tr>
    1073                                         <tr>
    1074                                             <td><b>$notes$</b></td>
    1075                                             <td><?php echo esc_html_x( 'Inserts the booking notes', 'backend', 'eduadmin-booking' ); ?></td>
    1076                                         </tr>
    1077                                         <tr>
    1078                                             <td><b>$orderrows$</b></td>
    1079                                             <td><?php echo esc_html_x( 'Inserts the order rows, formatted as JSON (can be used for special handling)', 'backend', 'eduadmin-booking' ); ?></td>
    1080                                         </tr>
    1081                                     </table>
    108260                                </td>
    108361                            </tr>
    108462                        </table>
    1085                     </div>
    1086                     <br /><p class="submit">
    1087                         <input type="submit" name="submit" id="submit" class="button button-primary"
    1088                                value="<?php echo _x( 'Save settings', 'backend', 'eduadmin-booking' ); ?>" />
    1089                     </p>
    1090                 <?php } ?>
    1091             </div>
    1092         </form>
     63                        <div
     64                            class="non-eduform-options"<?php echo( ! EDU()->is_checked( 'eduadmin-useBookingFormFromApi', false ) ? ' style="display: block;"' : ' style="display: none;"' ); ?>>
     65                            <?php
     66
     67                            echo '<h3>' . esc_html_x( 'Default customer group', 'backend', 'eduadmin-booking' ) . '</h3>';
     68                            $cg = EDUAPI()->OData->CustomerGroups->Search(
     69                                'CustomerGroupId,ParentCustomerGroupId,CustomerGroupName',
     70                                'PublicGroup',
     71                                null,
     72                                'ParentCustomerGroupId'
     73                            );
     74
     75                            $parent = array();
     76                            foreach ( $cg['value'] as $i => $v ) {
     77                                $parent[ $i ] = $v['ParentCustomerGroupId'];
     78                            }
     79
     80                            array_multisort( $parent, SORT_ASC, $cg['value'] );
     81
     82                            $level_stack = array();
     83                            foreach ( $cg['value'] as $g ) {
     84                                $level_stack[ (string) $g['ParentCustomerGroupId'] ][] = $g;
     85                            }
     86
     87                            $depth = 0;
     88
     89                            function edu_write_options( $g, $array, $depth, $selected_option ) {
     90                                echo '<option value="' . esc_attr( $g['CustomerGroupId'] ) . '"' . ( $selected_option === (string) $g['CustomerGroupId'] ? ' selected="selected"' : '' ) . '>' .
     91                                     str_repeat( '&nbsp;', $depth * 4 ) .
     92                                     esc_html( wp_strip_all_tags( $g['CustomerGroupName'] ) ) .
     93                                     "</option>\n";
     94                                if ( array_key_exists( (string) $g['CustomerGroupId'], $array ) ) {
     95                                    $depth ++;
     96                                    foreach ( $array[ (string) $g['CustomerGroupId'] ] as $ng ) {
     97                                        edu_write_options( $ng, $array, $depth, $selected_option );
     98                                    }
     99                                    $depth --;
     100                                }
     101                            }
     102
     103                            ?>
     104                            <select required name="eduadmin-customerGroupId"
     105                                    title="<?php echo esc_attr_x( 'Select customer group', 'backend', 'eduadmin-booking' ); ?>">
     106                                <option
     107                                    value=""><?php echo esc_html_x( 'Select customer group', 'backend', 'eduadmin-booking' ); ?></option>
     108                                <?php
     109                                $root            = $level_stack['0'];
     110                                $selected_option = EDU()->get_option( 'eduadmin-customerGroupId', null );
     111                                foreach ( $root as $g ) {
     112                                    edu_write_options( $g, $level_stack, $depth, $selected_option );
     113                                }
     114                                ?>
     115                            </select>
     116                            <br />
     117                            <br />
     118                            <label>
     119                                <input type="checkbox" name="eduadmin-useLogin" value="true"
     120                                    <?php echo( EDU()->get_option( 'eduadmin-useLogin', false ) ? ' checked="checked"' : '' ); ?>
     121                                       onchange="EduAdmin.ToggleVisibility(this.checked, '.eduadmin-forceLogin');" />
     122                                <?php echo esc_html_x( 'Use login', 'backend', 'eduadmin-booking' ); ?>
     123                            </label>
     124                            <br />
     125                            <div
     126                                class="eduadmin-forceLogin"<?php echo( EDU()->is_checked( 'eduadmin-useLogin', false ) ? ' style="display: block;"' : ' style="display: none;"' ); ?>>
     127                                <label>
     128                                    <input type="checkbox" name="eduadmin-allowCustomerRegistration" value="true"
     129                                        <?php echo EDU()->get_option( 'eduadmin-allowCustomerRegistration', true ) ? ' checked="checked"' : ''; ?>
     130                                    />
     131                                    <?php echo esc_html_x( 'Allow customer registration', 'backend', 'eduadmin-booking' ); ?>
     132                                </label>
     133                            </div>
     134                            <br />
     135                            <label>
     136                                <?php echo esc_html_x( 'Login field', 'backend', 'eduadmin-booking' ); ?>
     137                                <?php $selected_login_field = EDU()->get_option( 'eduadmin-loginField', 'Email' ); ?>
     138                                <select name="eduadmin-loginField">
     139                                    <option<?php echo( 'Email' === $selected_login_field ? ' selected="selected"' : '' ); ?>
     140                                        value="Email"><?php echo esc_html_x( 'E-mail address', 'backend', 'eduadmin-booking' ); ?></option>
     141                                    <option<?php echo( 'CivicRegistrationNumber' === $selected_login_field ? ' selected="selected"' : '' ); ?>
     142                                        value="CivicRegistrationNumber"><?php echo esc_html_x( 'Civic Registration Number', 'backend', 'eduadmin-booking' ); ?></option>
     143                                    <!--<option value="CustomerNumber"><?php echo esc_html_x( 'Customer number', 'backend', 'eduadmin-booking' ); ?></option>-->
     144                                    <!-- To be enabled when it works in the API -->
     145                                </select>
     146                            </label>
     147                            <h3><?php echo esc_html_x( 'Booking form settings', 'backend', 'eduadmin-booking' ); ?></h3> <?php
     148                            $singlePersonBooking = EDU()->get_option( 'eduadmin-singlePersonBooking', false );
     149                            ?>
     150                            <label>
     151                                <input type="checkbox"
     152                                       name="eduadmin-singlePersonBooking"<?php echo( 'true' === $singlePersonBooking ? " checked=\"checked\"" : "" ); ?>
     153                                       value="true" />
     154                                <?php echo esc_html_x( 'Participant is also customer and contact (Only allow a single participant)', 'backend', 'eduadmin-booking' ); ?>
     155                            </label>
     156                            <br /> <?php
     157                            $blockEditIfLoggedIn = EDU()->get_option( 'eduadmin-blockEditIfLoggedIn', true );
     158                            ?>
     159                            <label>
     160                                <input type="checkbox"
     161                                       name="eduadmin-blockEditIfLoggedIn"<?php echo( $blockEditIfLoggedIn ? " checked=\"checked\"" : "" ); ?>
     162                                       value="true" />
     163                                <?php echo esc_html_x( 'Block ability to edit login information if logged in', 'backend', 'eduadmin-booking' ); ?>
     164                            </label>
     165                            <br /> <?php
     166                            $allowCustomerToUpdate = EDU()->get_option( 'eduadmin-allowCustomerUpdate', false );
     167                            ?>
     168                            <label>
     169                                <input type="checkbox"
     170                                       name="eduadmin-allowCustomerUpdate"<?php echo( $allowCustomerToUpdate ? " checked=\"checked\"" : "" ); ?>
     171                                       value="true" />
     172                                <?php echo esc_html_x( 'Allow end customer to overwrite customer info (requires logged in users)', 'backend', 'eduadmin-booking' ); ?>
     173                            </label>
     174                            <br /><?php
     175                            $alwaysAllowChangeEvent = EDU()->get_option( 'eduadmin-alwaysAllowChangeEvent', false );
     176                            ?>
     177                            <label>
     178                                <input type="checkbox"
     179                                       name="eduadmin-alwaysAllowChangeEvent"<?php checked( $alwaysAllowChangeEvent, "true" ); ?>
     180                                       value="true" />
     181                                <?php echo esc_html_x( 'Allow end customers to always switch between available events', 'backend', 'eduadmin-booking' ); ?>
     182                            </label>
     183                            <br /> <?php
     184                            $allowDiscountCode = EDU()->get_option( 'eduadmin-allowDiscountCode', false );
     185                            ?>
     186                            <label>
     187                                <input type="checkbox"
     188                                       name="eduadmin-allowDiscountCode"<?php checked( $allowDiscountCode, "true" ); ?>
     189                                       value="true" />
     190                                <?php echo esc_html_x( 'Allow end customers to use discount codes', 'backend', 'eduadmin-booking' ); ?>
     191                            </label>
     192                            <br /> <?php
     193                            $useLimitedDiscount = EDU()->get_option( 'eduadmin-useLimitedDiscount', false );
     194                            ?>
     195                            <label>
     196                                <input type="checkbox"
     197                                       name="eduadmin-useLimitedDiscount"<?php checked( $useLimitedDiscount, "true" ); ?>
     198                                       value="true" />
     199                                <?php echo esc_html_x( 'Allow end customers to use discount cards', 'backend', 'eduadmin-booking' ); ?>
     200                            </label>
     201                            <br /> <?php
     202                            $validateCivicRegNo = EDU()->get_option( 'eduadmin-validateCivicRegNo', false );
     203                            ?>
     204                            <label>
     205                                <input type="checkbox"
     206                                       name="eduadmin-validateCivicRegNo"<?php checked( $validateCivicRegNo, "true" ); ?>
     207                                       value="true" />
     208                                <?php echo esc_html_x( 'Validate civic registration numbers (Swedish)', 'backend', 'eduadmin-booking' ); ?>
     209                            </label>
     210                            <br /><?php
     211                            $alwaysUsePaymentPlugin = EDU()->get_option( 'eduadmin-alwaysUsePaymentPlugin', false );
     212                            ?>
     213                            <label>
     214                                <input type="checkbox"
     215                                       name="eduadmin-alwaysUsePaymentPlugin"<?php checked( $alwaysUsePaymentPlugin, "true" ); ?>
     216                                       value="true" />
     217                                <?php echo esc_html_x( 'Always use payment plugin (if applicable) for bookings', 'backend', 'eduadmin-booking' ); ?>
     218                            </label>
     219                            <br /><?php
     220                            $dontSendConfirmation = EDU()->get_option( 'eduadmin-dontSendConfirmation', false );
     221                            ?>
     222                            <label>
     223                                <input type="checkbox"
     224                                       name="eduadmin-dontSendConfirmation"<?php checked( $dontSendConfirmation, "true" ); ?>
     225                                       value="true" />
     226                                <?php echo esc_html_x( 'Do not send confirmation emails (if you use automatic emails in EduAdmin)', 'backend', 'eduadmin-booking' ); ?>
     227                            </label>
     228                            <br />
     229
     230                            <h4><?php echo esc_html_x( 'Confirmation settings', 'backend', 'eduadmin-booking' ); ?></h4>
     231                            <?php
     232                            $confirmationSettingsParticipants    = EDU()->get_option( 'eduadmin-confirmationSettings-participants', "true" );
     233                            $confirmationSettingsCustomer        = EDU()->get_option( 'eduadmin-confirmationSettings-customer', "true" );
     234                            $confirmationSettingsCustomerContact = EDU()->get_option( 'eduadmin-confirmationSettings-customercontact', "true" );
     235                            ?>
     236                            <p><?php echo esc_html_x( 'Decide who gets the confirmation after a booking is completed.', 'backend', 'eduadmin-booking' ); ?></p>
     237                            <label>
     238                                <input type="checkbox"
     239                                       name="eduadmin-confirmationSettings-participants"<?php checked( $confirmationSettingsParticipants, 'true' ); ?>
     240                                       value="true" />
     241                                <?php echo esc_html_x( 'Send confirmation to all participants', 'backend', 'eduadmin-booking' ); ?>
     242                            </label>
     243                            <br />
     244                            <label>
     245                                <input type="checkbox"
     246                                       name="eduadmin-confirmationSettings-customer"<?php checked( $confirmationSettingsCustomer, 'true' ); ?>
     247                                       value="true" />
     248                                <?php echo esc_html_x( 'Send confirmation to the customer email', 'backend', 'eduadmin-booking' ); ?>
     249                            </label>
     250                            <br />
     251                            <label>
     252                                <input type="checkbox"
     253                                       name="eduadmin-confirmationSettings-customercontact"<?php checked( $confirmationSettingsCustomerContact, 'true' ); ?>
     254                                       value="true" />
     255                                <?php echo esc_html_x( 'Send confirmation to the customer contact', 'backend', 'eduadmin-booking' ); ?>
     256                            </label>
     257                            <br />
     258
     259                            <h4><?php echo esc_html_x( 'Field order', 'backend', 'eduadmin-booking' ); ?></h4> <?php
     260                            $fieldOrder = EDU()->get_option( 'eduadmin-fieldOrder', 'contact_customer' );
     261                            ?>
     262                            <label>
     263                                <input type="radio"
     264                                       name="eduadmin-fieldOrder"<?php checked( $fieldOrder, "contact_customer" ); ?>
     265                                       value="contact_customer" />
     266                                <?php echo esc_html_x( 'Contact, customer', 'backend', 'eduadmin-booking' ); ?>
     267                            </label>
     268                            <br />
     269                            <label>
     270                                <input type="radio"
     271                                       name="eduadmin-fieldOrder"<?php checked( $fieldOrder, "customer_contact" ); ?>
     272                                       value="customer_contact" />
     273                                <?php echo esc_html_x( 'Customer, contact', 'backend', 'eduadmin-booking' ); ?>
     274                            </label>
     275                            <br />
     276                            <h4><?php echo esc_html_x( 'Sub Events', 'backend', 'eduadmin-booking' ); ?></h4> <?php
     277                            $hideSubEventDateTime = EDU()->get_option( 'eduadmin-hideSubEventDateTime', false );
     278                            ?>
     279                            <label>
     280                                <input type="checkbox"
     281                                       name="eduadmin-hideSubEventDateTime"<?php checked( $hideSubEventDateTime, "true" ); ?>
     282                                       value="true" />
     283                                <?php echo esc_html_x( 'Hide date and time information from sub events', 'backend', 'eduadmin-booking' ); ?>
     284                            </label>
     285                            <br />
     286                            <h4><?php echo esc_html_x( 'Interest registration', 'backend', 'eduadmin-booking' ); ?></h4> <?php
     287                            $allowInterestRegObject = EDU()->get_option( 'eduadmin-allowInterestRegObject', false );
     288                            $allowInterestRegEvent  = EDU()->get_option( 'eduadmin-allowInterestRegEvent', false );
     289                            ?>
     290                            <label>
     291                                <input type="checkbox"
     292                                       name="eduadmin-allowInterestRegObject"<?php checked( $allowInterestRegObject, "true" ); ?>
     293                                       value="true" />
     294                                <?php echo esc_html_x( 'Allow interest registration for course', 'backend', 'eduadmin-booking' ); ?>
     295                            </label>
     296                            <br />
     297                            <label>
     298                                <input type="checkbox"
     299                                       name="eduadmin-allowInterestRegEvent"<?php checked( $allowInterestRegEvent, "true" ); ?>
     300                                       value="true" />
     301                                <?php echo esc_html_x( 'Allow interest registration for event', 'backend', 'eduadmin-booking' ); ?>
     302                            </label>
     303                            <br />
     304                            <h4><?php echo esc_html_x( 'Form settings', 'backend', 'eduadmin-booking' ); ?></h4>
     305                            <button class="button" disabled
     306                                    onclick="showFormWindow(); return false;"><?php _ex( 'Show settings', 'backend', 'eduadmin-booking' ); ?></button>
     307                            <br />
     308                            <br /> <?php $noInvoiceFreeEvents = EDU()->get_option( 'eduadmin-noInvoiceFreeEvents', false ); ?>
     309                            <label>
     310                                <input type="checkbox"
     311                                       name="eduadmin-noInvoiceFreeEvents"<?php checked( $noInvoiceFreeEvents, "true" ); ?>
     312                                       value="true" />
     313                                <?php echo esc_html_x( 'Hide invoice information if the event is free', 'backend', 'eduadmin-booking' ); ?>
     314                            </label>
     315                            <br /> <?php $hideInvoiceEmailField = EDU()->get_option( 'eduadmin-hideInvoiceEmailField', false ); ?>
     316                            <label>
     317                                <input type="checkbox"
     318                                       name="eduadmin-hideInvoiceEmailField"<?php checked( $hideInvoiceEmailField, "true" ); ?>
     319                                       value="true" />
     320                                <?php echo esc_html_x( 'Hide the invoice e-mail field', 'backend', 'eduadmin-booking' ); ?>
     321                            </label>
     322                            <br /> <?php $forceShowInvoiceInformation = EDU()->get_option( 'eduadmin-showInvoiceInformation', false ); ?>
     323                            <label>
     324                                <input type="checkbox"
     325                                       name="eduadmin-showInvoiceInformation"<?php checked( $forceShowInvoiceInformation, "true" ); ?>
     326                                       value="true" />
     327                                <?php echo esc_html_x( 'Force show invoice information fields', 'backend', 'eduadmin-booking' ); ?>
     328                            </label>
     329                            <h3><?php echo esc_html_x( 'Price name settings', 'backend', 'eduadmin-booking' ); ?></h3> <?php
     330                            $priceNameSetting = EDU()->get_option( 'eduadmin-selectPricename', 'firstPublic' );
     331                            ?>
     332                            <label>
     333                                <input type="radio"
     334                                       name="eduadmin-selectPricename"<?php checked( $priceNameSetting, "firstPublic" ); ?>
     335                                       value="firstPublic" />
     336                                <?php echo esc_html_x( 'EduAdmin chooses the appropriate price name for the event and participants', 'backend', 'eduadmin-booking' ); ?>
     337                            </label>
     338                            <br />
     339                            <label>
     340                                <input type="radio"
     341                                       name="eduadmin-selectPricename"<?php checked( $priceNameSetting, "selectWholeEvent" ); ?>
     342                                       value="selectWholeEvent" />
     343                                <?php echo esc_html_x( 'Can choose between public price names', 'backend', 'eduadmin-booking' ); ?>
     344                            </label>
     345                            <br />
     346                            <label>
     347                                <input type="radio"
     348                                       name="eduadmin-selectPricename"<?php checked( $priceNameSetting, "selectParticipant" ); ?>
     349                                       value="selectParticipant" />
     350                                <?php echo esc_html_x( 'Can choose per participant', 'backend', 'eduadmin-booking' ); ?>
     351                            </label> <?php
     352                            $selected_match = EDU()->get_option( 'eduadmin-customerMatching', 'use-match' );
     353                            ?>
     354                            <h3><?php echo esc_html_x( 'Customer matching', 'backend', 'eduadmin-booking' ); ?></h3>
     355                            <select name="eduadmin-customerMatching">
     356                                <option<?php selected( $selected_match, 'use-match' ); ?> value="use-match">
     357                                    <?php echo esc_html_x( 'Let EduAdmin match customers (Creates new if no match is found)', 'backend', 'eduadmin-booking' ); ?>
     358                                </option>
     359                                <option<?php selected( $selected_match, 'no-match' ); ?> value="no-match">
     360                                    <?php echo esc_html_x( 'No matching (Creates new customers every time)', 'backend', 'eduadmin-booking' ); ?>
     361                                </option>
     362                            </select>
     363                            <br />
     364                            <br /> <?php
     365                            $selectedCurrency = EDU()->get_option( 'eduadmin-currency', 'SEK' );
     366                            ?> <h3><?php echo esc_html_x( 'Currency', 'backend', 'eduadmin-booking' ); ?></h3>
     367                            <select name="eduadmin-currency">
     368                                <option value="AED"<?php selected( $selectedCurrency, "AED" ); ?>>
     369                                    AED
     370                                    - United Arab Emirates, Dirhams
     371                                </option>
     372                                <option value="AFN"<?php selected( $selectedCurrency, "AFN" ); ?>>
     373                                    AFN
     374                                    - Afghanistan, Afghanis
     375                                </option>
     376                                <option value="ALL"<?php selected( $selectedCurrency, "ALL" ); ?>>
     377                                    ALL
     378                                    - Albania, Leke
     379                                </option>
     380                                <option value="AMD"<?php selected( $selectedCurrency, "AMD" ); ?>>
     381                                    AMD
     382                                    - Armenia, Drams
     383                                </option>
     384                                <option value="ANG"<?php selected( $selectedCurrency, "ANG" ); ?>>
     385                                    ANG
     386                                    - Netherlands Antilles, Guilders (also called Florins)
     387                                </option>
     388                                <option value="AOA"<?php selected( $selectedCurrency, "AOA" ); ?>>
     389                                    AOA
     390                                    - Angola, Kwanza
     391                                </option>
     392                                <option value="ARS"<?php selected( $selectedCurrency, "ARS" ); ?>>
     393                                    ARS
     394                                    - Argentina, Pesos
     395                                </option>
     396                                <option value="AUD"<?php selected( $selectedCurrency, "AUD" ); ?>>
     397                                    AUD
     398                                    - Australia, Dollars
     399                                </option>
     400                                <option value="AWG"<?php selected( $selectedCurrency, "AWG" ); ?>>
     401                                    AWG
     402                                    - Aruba, Guilders (also called Florins)
     403                                </option>
     404                                <option value="AZN"<?php selected( $selectedCurrency, "AZN" ); ?>>
     405                                    AZN
     406                                    - Azerbaijan, New Manats
     407                                </option>
     408                                <option value="BAM"<?php selected( $selectedCurrency, "BAM" ); ?>>
     409                                    BAM
     410                                    - Bosnia and Herzegovina, Convertible Marka
     411                                </option>
     412                                <option value="BBD"<?php selected( $selectedCurrency, "BBD" ); ?>>
     413                                    BBD
     414                                    - Barbados, Dollars
     415                                </option>
     416                                <option value="BDT"<?php selected( $selectedCurrency, "BDT" ); ?>>
     417                                    BDT
     418                                    - Bangladesh, Taka
     419                                </option>
     420                                <option value="BGN"<?php selected( $selectedCurrency, "BGN" ); ?>>
     421                                    BGN
     422                                    - Bulgaria, Leva
     423                                </option>
     424                                <option value="BHD"<?php selected( $selectedCurrency, "BHD" ); ?>>
     425                                    BHD
     426                                    - Bahrain, Dinars
     427                                </option>
     428                                <option value="BIF"<?php selected( $selectedCurrency, "BIF" ); ?>>
     429                                    BIF
     430                                    - Burundi, Francs
     431                                </option>
     432                                <option value="BMD"<?php selected( $selectedCurrency, "BMD" ); ?>>
     433                                    BMD
     434                                    - Bermuda, Dollars
     435                                </option>
     436                                <option value="BND"<?php selected( $selectedCurrency, "BND" ); ?>>
     437                                    BND
     438                                    - Brunei Darussalam, Dollars
     439                                </option>
     440                                <option value="BOB"<?php selected( $selectedCurrency, "BOB" ); ?>>
     441                                    BOB
     442                                    - Bolivia, Bolivianos
     443                                </option>
     444                                <option value="BRL"<?php selected( $selectedCurrency, "BRL" ); ?>>
     445                                    BRL
     446                                    - Brazil, Brazil Real
     447                                </option>
     448                                <option value="BSD"<?php selected( $selectedCurrency, "BSD" ); ?>>
     449                                    BSD
     450                                    - Bahamas, Dollars
     451                                </option>
     452                                <option value="BTN"<?php selected( $selectedCurrency, "BTN" ); ?>>
     453                                    BTN
     454                                    - Bhutan, Ngultrum
     455                                </option>
     456                                <option value="BWP"<?php selected( $selectedCurrency, "BWP" ); ?>>
     457                                    BWP
     458                                    - Botswana, Pulas
     459                                </option>
     460                                <option value="BYR"<?php selected( $selectedCurrency, "BYR" ); ?>>
     461                                    BYR
     462                                    - Belarus, Rubles
     463                                </option>
     464                                <option value="BZD"<?php selected( $selectedCurrency, "BZD" ); ?>>
     465                                    BZD
     466                                    - Belize, Dollars
     467                                </option>
     468                                <option value="CAD"<?php selected( $selectedCurrency, "CAD" ); ?>>
     469                                    CAD
     470                                    - Canada, Dollars
     471                                </option>
     472                                <option value="CDF"<?php selected( $selectedCurrency, "CDF" ); ?>>
     473                                    CDF
     474                                    - Congo/Kinshasa, Congolese Francs
     475                                </option>
     476                                <option value="CHF"<?php selected( $selectedCurrency, "CHF" ); ?>>
     477                                    CHF
     478                                    - Switzerland, Francs
     479                                </option>
     480                                <option value="CLP"<?php selected( $selectedCurrency, "CLP" ); ?>>
     481                                    CLP
     482                                    - Chile, Pesos
     483                                </option>
     484                                <option value="CNY"<?php selected( $selectedCurrency, "CNY" ); ?>>
     485                                    CNY
     486                                    - China, Yuan Renminbi
     487                                </option>
     488                                <option value="COP"<?php selected( $selectedCurrency, "COP" ); ?>>
     489                                    COP
     490                                    - Colombia, Pesos
     491                                </option>
     492                                <option value="CRC"<?php selected( $selectedCurrency, "CRC" ); ?>>
     493                                    CRC
     494                                    - Costa Rica, Colones
     495                                </option>
     496                                <option value="CUP"<?php selected( $selectedCurrency, "CUP" ); ?>>
     497                                    CUP
     498                                    - Cuba, Pesos
     499                                </option>
     500                                <option value="CVE"<?php selected( $selectedCurrency, "CVE" ); ?>>
     501                                    CVE
     502                                    - Cape Verde, Escudos
     503                                </option>
     504                                <option value="CZK"<?php selected( $selectedCurrency, "CZK" ); ?>>
     505                                    CZK
     506                                    - Czech Republic, Koruny
     507                                </option>
     508                                <option value="DJF"<?php selected( $selectedCurrency, "DJF" ); ?>>
     509                                    DJF
     510                                    - Djibouti, Francs
     511                                </option>
     512                                <option value="DKK"<?php selected( $selectedCurrency, "DKK" ); ?>>
     513                                    DKK
     514                                    - Denmark, Kroner
     515                                </option>
     516                                <option value="DOP"<?php selected( $selectedCurrency, "DOP" ); ?>>
     517                                    DOP
     518                                    - Dominican Republic, Pesos
     519                                </option>
     520                                <option value="DZD"<?php selected( $selectedCurrency, "DZD" ); ?>>
     521                                    DZD
     522                                    - Algeria, Algeria Dinars
     523                                </option>
     524                                <option value="EGP"<?php selected( $selectedCurrency, "EGP" ); ?>>
     525                                    EGP
     526                                    - Egypt, Pounds
     527                                </option>
     528                                <option value="ERN"<?php selected( $selectedCurrency, "ERN" ); ?>>
     529                                    ERN
     530                                    - Eritrea, Nakfa
     531                                </option>
     532                                <option value="ETB"<?php selected( $selectedCurrency, "ETB" ); ?>>
     533                                    ETB
     534                                    - Ethiopia, Birr
     535                                </option>
     536                                <option value="EUR"<?php selected( $selectedCurrency, "EUR" ); ?>>
     537                                    EUR
     538                                    - Euro Member Countries, Euro
     539                                </option>
     540                                <option value="FJD"<?php selected( $selectedCurrency, "FJD" ); ?>>
     541                                    FJD
     542                                    - Fiji, Dollars
     543                                </option>
     544                                <option value="FKP"<?php selected( $selectedCurrency, "FKP" ); ?>>
     545                                    FKP
     546                                    - Falkland Islands (Malvinas), Pounds
     547                                </option>
     548                                <option value="GBP"<?php selected( $selectedCurrency, "GBP" ); ?>>
     549                                    GBP
     550                                    - United Kingdom, Pounds
     551                                </option>
     552                                <option value="GEL"<?php selected( $selectedCurrency, "GEL" ); ?>>
     553                                    GEL
     554                                    - Georgia, Lari
     555                                </option>
     556                                <option value="GHS"<?php selected( $selectedCurrency, "GHS" ); ?>>
     557                                    GHS
     558                                    - Ghana, Cedis
     559                                </option>
     560                                <option value="GIP"<?php selected( $selectedCurrency, "GIP" ); ?>>
     561                                    GIP
     562                                    - Gibraltar, Pounds
     563                                </option>
     564                                <option value="GMD"<?php selected( $selectedCurrency, "GMD" ); ?>>
     565                                    GMD
     566                                    - Gambia, Dalasi
     567                                </option>
     568                                <option value="GNF"<?php selected( $selectedCurrency, "GNF" ); ?>>
     569                                    GNF
     570                                    - Guinea, Francs
     571                                </option>
     572                                <option value="GTQ"<?php selected( $selectedCurrency, "GTQ" ); ?>>
     573                                    GTQ
     574                                    - Guatemala, Quetzales
     575                                </option>
     576                                <option value="GYD"<?php selected( $selectedCurrency, "GYD" ); ?>>
     577                                    GYD
     578                                    - Guyana, Dollars
     579                                </option>
     580                                <option value="HKD"<?php selected( $selectedCurrency, "HKD" ); ?>>
     581                                    HKD
     582                                    - Hong Kong, Dollars
     583                                </option>
     584                                <option value="HNL"<?php selected( $selectedCurrency, "HNL" ); ?>>
     585                                    HNL
     586                                    - Honduras, Lempiras
     587                                </option>
     588                                <option value="HRK"<?php selected( $selectedCurrency, "HRK" ); ?>>
     589                                    HRK
     590                                    - Croatia, Kuna
     591                                </option>
     592                                <option value="HTG"<?php selected( $selectedCurrency, "HTG" ); ?>>
     593                                    HTG
     594                                    - Haiti, Gourdes
     595                                </option>
     596                                <option value="HUF"<?php selected( $selectedCurrency, "HUF" ); ?>>
     597                                    HUF
     598                                    - Hungary, Forint
     599                                </option>
     600                                <option value="IDR"<?php selected( $selectedCurrency, "IDR" ); ?>>
     601                                    IDR
     602                                    - Indonesia, Rupiahs
     603                                </option>
     604                                <option value="ILS"<?php selected( $selectedCurrency, "ILS" ); ?>>
     605                                    ILS
     606                                    - Israel, New Shekels
     607                                </option>
     608                                <option value="INR"<?php selected( $selectedCurrency, "INR" ); ?>>
     609                                    INR
     610                                    - India, Rupees
     611                                </option>
     612                                <option value="IQD"<?php selected( $selectedCurrency, "IQD" ); ?>>
     613                                    IQD
     614                                    - Iraq, Dinars
     615                                </option>
     616                                <option value="IRR"<?php selected( $selectedCurrency, "IRR" ); ?>>
     617                                    IRR
     618                                    - Iran, Rials
     619                                </option>
     620                                <option value="ISK"<?php selected( $selectedCurrency, "ISK" ); ?>>
     621                                    ISK
     622                                    - Iceland, Kronur
     623                                </option>
     624                                <option value="JMD"<?php selected( $selectedCurrency, "JMD" ); ?>>
     625                                    JMD
     626                                    - Jamaica, Dollars
     627                                </option>
     628                                <option value="JOD"<?php selected( $selectedCurrency, "JOD" ); ?>>
     629                                    JOD
     630                                    - Jordan, Dinars
     631                                </option>
     632                                <option value="JPY"<?php selected( $selectedCurrency, "JPY" ); ?>>
     633                                    JPY
     634                                    - Japan, Yen
     635                                </option>
     636                                <option value="KES"<?php selected( $selectedCurrency, "KES" ); ?>>
     637                                    KES
     638                                    - Kenya, Shillings
     639                                </option>
     640                                <option value="KGS"<?php selected( $selectedCurrency, "KGS" ); ?>>
     641                                    KGS
     642                                    - Kyrgyzstan, Soms
     643                                </option>
     644                                <option value="KHR"<?php selected( $selectedCurrency, "KHR" ); ?>>
     645                                    KHR
     646                                    - Cambodia, Riels
     647                                </option>
     648                                <option value="KMF"<?php selected( $selectedCurrency, "KMF" ); ?>>
     649                                    KMF
     650                                    - Comoros, Francs
     651                                </option>
     652                                <option value="KPW"<?php selected( $selectedCurrency, "KPW" ); ?>>
     653                                    KPW
     654                                    - Korea (North), Won
     655                                </option>
     656                                <option value="KRW"<?php selected( $selectedCurrency, "KRW" ); ?>>
     657                                    KRW
     658                                    - Korea (South), Won
     659                                </option>
     660                                <option value="KWD"<?php selected( $selectedCurrency, "KWD" ); ?>>
     661                                    KWD
     662                                    - Kuwait, Dinars
     663                                </option>
     664                                <option value="KYD"<?php selected( $selectedCurrency, "KYD" ); ?>>
     665                                    KYD
     666                                    - Cayman Islands, Dollars
     667                                </option>
     668                                <option value="KZT"<?php selected( $selectedCurrency, "KZT" ); ?>>
     669                                    KZT
     670                                    - Kazakhstan, Tenge
     671                                </option>
     672                                <option value="LAK"<?php selected( $selectedCurrency, "LAK" ); ?>>
     673                                    LAK
     674                                    - Laos, Kips
     675                                </option>
     676                                <option value="LBP"<?php selected( $selectedCurrency, "LBP" ); ?>>
     677                                    LBP
     678                                    - Lebanon, Pounds
     679                                </option>
     680                                <option value="LKR"<?php selected( $selectedCurrency, "LKR" ); ?>>
     681                                    LKR
     682                                    - Sri Lanka, Rupees
     683                                </option>
     684                                <option value="LRD"<?php selected( $selectedCurrency, "LRD" ); ?>>
     685                                    LRD
     686                                    - Liberia, Dollars
     687                                </option>
     688                                <option value="LSL"<?php selected( $selectedCurrency, "LSL" ); ?>>
     689                                    LSL
     690                                    - Lesotho, Maloti
     691                                </option>
     692                                <option value="LYD"<?php selected( $selectedCurrency, "LYD" ); ?>>
     693                                    LYD
     694                                    - Libya, Dinars
     695                                </option>
     696                                <option value="MAD"<?php selected( $selectedCurrency, "MAD" ); ?>>
     697                                    MAD
     698                                    - Morocco, Dirhams
     699                                </option>
     700                                <option value="MDL"<?php selected( $selectedCurrency, "MDL" ); ?>>
     701                                    MDL
     702                                    - Moldova, Lei
     703                                </option>
     704                                <option value="MGA"<?php selected( $selectedCurrency, "MGA" ); ?>>
     705                                    MGA
     706                                    - Madagascar, Ariary
     707                                </option>
     708                                <option value="MKD"<?php selected( $selectedCurrency, "MKD" ); ?>>
     709                                    MKD
     710                                    - Macedonia, Denars
     711                                </option>
     712                                <option value="MMK"<?php selected( $selectedCurrency, "MMK" ); ?>>
     713                                    MMK
     714                                    - Myanmar (Burma), Kyats
     715                                </option>
     716                                <option value="MNT"<?php selected( $selectedCurrency, "MNT" ); ?>>
     717                                    MNT
     718                                    - Mongolia, Tugriks
     719                                </option>
     720                                <option value="MOP"<?php selected( $selectedCurrency, "MOP" ); ?>>
     721                                    MOP
     722                                    - Macau, Patacas
     723                                </option>
     724                                <option value="MRO"<?php selected( $selectedCurrency, "MRO" ); ?>>
     725                                    MRO
     726                                    - Mauritania, Ouguiyas
     727                                </option>
     728                                <option value="MUR"<?php selected( $selectedCurrency, "MUR" ); ?>>
     729                                    MUR
     730                                    - Mauritius, Rupees
     731                                </option>
     732                                <option value="MWK"<?php selected( $selectedCurrency, "MWK" ); ?>>
     733                                    MWK
     734                                    - Malawi, Kwachas
     735                                </option>
     736                                <option value="MVR"<?php selected( $selectedCurrency, "MVR" ); ?>>
     737                                    MVR
     738                                    - Maldives (Maldive Islands), Rufiyaa
     739                                </option>
     740                                <option value="MXN"<?php selected( $selectedCurrency, "MXN" ); ?>>
     741                                    MXN
     742                                    - Mexico, Pesos
     743                                </option>
     744                                <option value="MYR"<?php selected( $selectedCurrency, "MYR" ); ?>>
     745                                    MYR
     746                                    - Malaysia, Ringgits
     747                                </option>
     748                                <option value="MZN"<?php selected( $selectedCurrency, "MZN" ); ?>>
     749                                    MZN
     750                                    - Mozambique, Meticais
     751                                </option>
     752                                <option value="NAD"<?php selected( $selectedCurrency, "NAD" ); ?>>
     753                                    NAD
     754                                    - Namibia, Dollars
     755                                </option>
     756                                <option value="NGN"<?php selected( $selectedCurrency, "NGN" ); ?>>
     757                                    NGN
     758                                    - Nigeria, Nairas
     759                                </option>
     760                                <option value="NIO"<?php selected( $selectedCurrency, "NIO" ); ?>>
     761                                    NIO
     762                                    - Nicaragua, Cordobas
     763                                </option>
     764                                <option value="NOK"<?php selected( $selectedCurrency, "NOK" ); ?>>
     765                                    NOK
     766                                    - Norway, Krone
     767                                </option>
     768                                <option value="NPR"<?php selected( $selectedCurrency, "NPR" ); ?>>
     769                                    NPR
     770                                    - Nepal, Nepal Rupees
     771                                </option>
     772                                <option value="NZD"<?php selected( $selectedCurrency, "NZD" ); ?>>
     773                                    NZD
     774                                    - New Zealand, Dollars
     775                                </option>
     776                                <option value="OMR"<?php selected( $selectedCurrency, "OMR" ); ?>>
     777                                    OMR
     778                                    - Oman, Rials
     779                                </option>
     780                                <option value="PAB"<?php selected( $selectedCurrency, "PAB" ); ?>>
     781                                    PAB
     782                                    - Panama, Balboa
     783                                </option>
     784                                <option value="PEN"<?php selected( $selectedCurrency, "PEN" ); ?>>
     785                                    PEN
     786                                    - Peru, Nuevos Soles
     787                                </option>
     788                                <option value="PGK"<?php selected( $selectedCurrency, "PGK" ); ?>>
     789                                    PGK
     790                                    - Papua New Guinea, Kina
     791                                </option>
     792                                <option value="PHP"<?php selected( $selectedCurrency, "PHP" ); ?>>
     793                                    PHP
     794                                    - Philippines, Pesos
     795                                </option>
     796                                <option value="PKR"<?php selected( $selectedCurrency, "PKR" ); ?>>
     797                                    PKR
     798                                    - Pakistan, Rupees
     799                                </option>
     800                                <option value="PLN"<?php selected( $selectedCurrency, "PLN" ); ?>>
     801                                    PLN
     802                                    - Poland, Zlotych
     803                                </option>
     804                                <option value="PYG"<?php selected( $selectedCurrency, "PYG" ); ?>>
     805                                    PYG
     806                                    - Paraguay, Guarani
     807                                </option>
     808                                <option value="QAR"<?php selected( $selectedCurrency, "QAR" ); ?>>
     809                                    QAR
     810                                    - Qatar, Rials
     811                                </option>
     812                                <option value="RON"<?php selected( $selectedCurrency, "RON" ); ?>>
     813                                    RON
     814                                    - Romania, New Lei
     815                                </option>
     816                                <option value="RSD"<?php selected( $selectedCurrency, "RSD" ); ?>>
     817                                    RSD
     818                                    - Serbia, Dinars
     819                                </option>
     820                                <option value="RUB"<?php selected( $selectedCurrency, "RUB" ); ?>>
     821                                    RUB
     822                                    - Russia, Rubles
     823                                </option>
     824                                <option value="RWF"<?php selected( $selectedCurrency, "RWF" ); ?>>
     825                                    RWF
     826                                    - Rwanda, Rwanda Francs
     827                                </option>
     828                                <option value="SAR"<?php selected( $selectedCurrency, "SAR" ); ?>>
     829                                    SAR
     830                                    - Saudi Arabia, Riyals
     831                                </option>
     832                                <option value="SBD"<?php selected( $selectedCurrency, "SBD" ); ?>>
     833                                    SBD
     834                                    - Solomon Islands, Dollars
     835                                </option>
     836                                <option value="SCR"<?php selected( $selectedCurrency, "SCR" ); ?>>
     837                                    SCR
     838                                    - Seychelles, Rupees
     839                                </option>
     840                                <option value="SDG"<?php selected( $selectedCurrency, "SDG" ); ?>>
     841                                    SDG
     842                                    - Sudan, Pounds
     843                                </option>
     844                                <option value="SEK"<?php selected( $selectedCurrency, "SEK" ); ?>>
     845                                    SEK
     846                                    - Sweden, Kronor
     847                                </option>
     848                                <option value="SGD"<?php selected( $selectedCurrency, "SGD" ); ?>>
     849                                    SGD
     850                                    - Singapore, Dollars
     851                                </option>
     852                                <option value="SHP"<?php selected( $selectedCurrency, "SHP" ); ?>>
     853                                    SHP
     854                                    - Saint Helena, Pounds
     855                                </option>
     856                                <option value="SLL"<?php selected( $selectedCurrency, "SLL" ); ?>>
     857                                    SLL
     858                                    - Sierra Leone, Leones
     859                                </option>
     860                                <option value="SOS"<?php selected( $selectedCurrency, "SOS" ); ?>>
     861                                    SOS
     862                                    - Somalia, Shillings
     863                                </option>
     864                                <option value="SRD"<?php selected( $selectedCurrency, "SRD" ); ?>>
     865                                    SRD
     866                                    - Suriname, Dollars
     867                                </option>
     868                                <option value="STD"<?php selected( $selectedCurrency, "STD" ); ?>>
     869                                    STD
     870                                    - São Tome and Principe, Dobras
     871                                </option>
     872                                <option value="SYP"<?php selected( $selectedCurrency, "SYP" ); ?>>
     873                                    SYP
     874                                    - Syria, Pounds
     875                                </option>
     876                                <option value="SZL"<?php selected( $selectedCurrency, "SZL" ); ?>>
     877                                    SZL
     878                                    - Swaziland, Emalangeni
     879                                </option>
     880                                <option value="THB"<?php selected( $selectedCurrency, "THB" ); ?>>
     881                                    THB
     882                                    - Thailand, Baht
     883                                </option>
     884                                <option value="TJS"<?php selected( $selectedCurrency, "TJS" ); ?>>
     885                                    TJS
     886                                    - Tajikistan, Somoni
     887                                </option>
     888                                <option value="TMT"<?php selected( $selectedCurrency, "TMT" ); ?>>
     889                                    TMT
     890                                    - Turkmenistan, New Manats
     891                                </option>
     892                                <option value="TND"<?php selected( $selectedCurrency, "TND" ); ?>>
     893                                    TND
     894                                    - Tunisia, Dinars
     895                                </option>
     896                                <option value="TOP"<?php selected( $selectedCurrency, "TOP" ); ?>>
     897                                    TOP
     898                                    - Tonga, Pa'anga
     899                                </option>
     900                                <option value="TRY"<?php selected( $selectedCurrency, "TRY" ); ?>>
     901                                    TRY
     902                                    - Turkey, New Lira
     903                                </option>
     904                                <option value="TTD"<?php selected( $selectedCurrency, "TTD" ); ?>>
     905                                    TTD
     906                                    - Trinidad and Tobago, Dollars
     907                                </option>
     908                                <option value="TWD"<?php selected( $selectedCurrency, "TWD" ); ?>>
     909                                    TWD
     910                                    - Taiwan, New Dollars
     911                                </option>
     912                                <option value="TZS"<?php selected( $selectedCurrency, "TZS" ); ?>>
     913                                    TZS
     914                                    - Tanzania, Shillings
     915                                </option>
     916                                <option value="UAH"<?php selected( $selectedCurrency, "UAH" ); ?>>
     917                                    UAH
     918                                    - Ukraine, Hryvnia
     919                                </option>
     920                                <option value="UGX"<?php selected( $selectedCurrency, "UGX" ); ?>>
     921                                    UGX
     922                                    - Uganda, Shillings
     923                                </option>
     924                                <option value="USD"<?php selected( $selectedCurrency, "USD" ); ?>>
     925                                    USD
     926                                    - United States of America, Dollars
     927                                </option>
     928                                <option value="UYU"<?php selected( $selectedCurrency, "UYU" ); ?>>
     929                                    UYU
     930                                    - Uruguay, Pesos
     931                                </option>
     932                                <option value="UZS"<?php selected( $selectedCurrency, "UZS" ); ?>>
     933                                    UZS
     934                                    - Uzbekistan, Sums
     935                                </option>
     936                                <option value="VEF"<?php selected( $selectedCurrency, "VEF" ); ?>>
     937                                    VEF
     938                                    - Venezuela, Bolivares Fuertes
     939                                </option>
     940                                <option value="VND"<?php selected( $selectedCurrency, "VND" ); ?>>
     941                                    VND
     942                                    - Viet Nam, Dong
     943                                </option>
     944                                <option value="WST"<?php selected( $selectedCurrency, "WST" ); ?>>
     945                                    WST
     946                                    - Samoa, Tala
     947                                </option>
     948                                <option value="VUV"<?php selected( $selectedCurrency, "VUV" ); ?>>
     949                                    VUV
     950                                    - Vanuatu, Vatu
     951                                </option>
     952                                <option value="XAF"<?php selected( $selectedCurrency, "XAF" ); ?>>
     953                                    XAF
     954                                    - Communauté Financière Africaine BEAC, Francs
     955                                </option>
     956                                <option value="XAG"<?php selected( $selectedCurrency, "XAG" ); ?>>
     957                                    XAG
     958                                    - Silver, Ounces
     959                                </option>
     960                                <option value="XAU"<?php selected( $selectedCurrency, "XAU" ); ?>>
     961                                    XAU
     962                                    - Gold, Ounces
     963                                </option>
     964                                <option value="XCD"<?php selected( $selectedCurrency, "XCD" ); ?>>
     965                                    XCD
     966                                    - East Caribbean Dollars
     967                                </option>
     968                                <option value="XDR"<?php selected( $selectedCurrency, "XDR" ); ?>>
     969                                    XDR
     970                                    - International Monetary Fund (IMF) Special Drawing Rights
     971                                </option>
     972                                <option value="XOF"<?php selected( $selectedCurrency, "XOF" ); ?>>
     973                                    XOF
     974                                    - Communauté Financière Africaine BCEAO, Francs
     975                                </option>
     976                                <option value="XPD"<?php selected( $selectedCurrency, "XPD" ); ?>>
     977                                    XPD
     978                                    - Palladium Ounces
     979                                </option>
     980                                <option value="XPF"<?php selected( $selectedCurrency, "XPF" ); ?>>
     981                                    XPF
     982                                    - Comptoirs Français du Pacifique Francs
     983                                </option>
     984                                <option value="XPT"<?php selected( $selectedCurrency, "XPT" ); ?>>
     985                                    XPT
     986                                    - Platinum, Ounces
     987                                </option>
     988                                <option value="YER"<?php selected( $selectedCurrency, "YER" ); ?>>
     989                                    YER
     990                                    - Yemen, Rials
     991                                </option>
     992                                <option value="ZAR"<?php selected( $selectedCurrency, "ZAR" ); ?>>
     993                                    ZAR
     994                                    - South Africa, Rand
     995                                </option>
     996                                <option value="ZMW"<?php selected( $selectedCurrency, "ZMW" ); ?>>
     997                                    ZMW
     998                                    - Zambia, Kwacha
     999                                </option>
     1000                            </select>
     1001                            <h3><?php echo esc_html_x( 'Booking terms', 'backend', 'eduadmin-booking' ); ?></h3>
     1002                            <h4><?php echo esc_html_x( 'Booking terms link', 'backend', 'eduadmin-booking' ); ?></h4>
     1003                            <input type="url" class="form-control" style="width: 100%;" name="eduadmin-bookingTermsLink"
     1004                                   placeholder="<?php _ex( 'Booking terms link', 'backend', 'eduadmin-booking' ); ?>"
     1005                                   value="<?php echo EDU()->get_option( 'eduadmin-bookingTermsLink' ); ?>" />
     1006                            <br />
     1007                            <label>
     1008                                <input type="checkbox" name="eduadmin-useBookingTermsCheckbox"
     1009                                       value="true"<?php checked( EDU()->get_option( 'eduadmin-useBookingTermsCheckbox', false ), "true" ); ?> />
     1010                                <?php echo esc_html_x( 'Use booking terms', 'backend', 'eduadmin-booking' ); ?>
     1011                            </label>
     1012                            <h3><?php echo esc_html_x( 'Javascript to run when a booking is completed', 'backend', 'eduadmin-booking' ); ?></h3>
     1013                            <i><?php echo esc_html_x( 'You do not need to include &lt;script&gt;-tags', 'backend', 'eduadmin-booking' ); ?></i>
     1014                            <br />
     1015                            <table>
     1016                                <tr>
     1017                                    <td style="vertical-align: top;">
     1018                                <textarea class="form-control" rows="10" cols="60"
     1019                                          name="eduadmin-javascript"><?php echo EDU()->get_option( 'eduadmin-javascript' ); ?></textarea>
     1020                                    </td>
     1021                                    <td style="vertical-align: top;">
     1022                                        <b><?php echo esc_html_x( 'Keywords for JavaScript', 'backend', 'eduadmin-booking' ); ?></b>
     1023                                        <br />
     1024                                        <hr noshade="noshade" />
     1025                                        <table>
     1026                                            <tr>
     1027                                                <td><b>$bookingno$</b></td>
     1028                                                <td><?php echo esc_html_x( 'The booking number', 'backend', 'eduadmin-booking' ); ?></td>
     1029                                            </tr>
     1030                                            <tr>
     1031                                                <td><b>$productname$</b></td>
     1032                                                <td><?php echo esc_html_x( 'Inserts the product name', 'backend', 'eduadmin-booking' ); ?></td>
     1033                                            </tr>
     1034                                            <tr>
     1035                                                <td><b>$totalsum$</b></td>
     1036                                                <td><?php echo esc_html_x( 'Inserts the total sum', 'backend', 'eduadmin-booking' ); ?></td>
     1037                                            </tr>
     1038                                            <tr>
     1039                                                <td><b>$participants$</b></td>
     1040                                                <td><?php echo esc_html_x( 'Inserts the number participants', 'backend', 'eduadmin-booking' ); ?></td>
     1041                                            </tr>
     1042                                            <tr>
     1043                                                <td><b>$startdate$</b></td>
     1044                                                <td><?php echo esc_html_x( 'Inserts the start date of the event', 'backend', 'eduadmin-booking' ); ?></td>
     1045                                            </tr>
     1046                                            <tr>
     1047                                                <td><b>$enddate$</b></td>
     1048                                                <td><?php echo esc_html_x( 'Inserts the end date of the event', 'backend', 'eduadmin-booking' ); ?></td>
     1049                                            </tr>
     1050                                            <tr>
     1051                                                <td><b>$eventid$</b></td>
     1052                                                <td><?php echo esc_html_x( 'Inserts the event unique identifier', 'backend', 'eduadmin-booking' ); ?></td>
     1053                                            </tr>
     1054                                            <tr>
     1055                                                <td><b>$eventdescription$</b></td>
     1056                                                <td><?php echo esc_html_x( 'Inserts the event description', 'backend', 'eduadmin-booking' ); ?></td>
     1057                                            </tr>
     1058                                            <tr>
     1059                                                <td><b>$customerid$</b></td>
     1060                                                <td><?php echo esc_html_x( 'Inserts the generated customer id', 'backend', 'eduadmin-booking' ); ?></td>
     1061                                            </tr>
     1062                                            <tr>
     1063                                                <td><b>$customercontactid$</b></td>
     1064                                                <td><?php echo esc_html_x( 'Inserts the generated contact id', 'backend', 'eduadmin-booking' ); ?></td>
     1065                                            </tr>
     1066                                            <tr>
     1067                                                <td><b>$created$</b></td>
     1068                                                <td><?php echo esc_html_x( 'Inserts the date the booking was created', 'backend', 'eduadmin-booking' ); ?></td>
     1069                                            </tr>
     1070                                            <tr>
     1071                                                <td><b>$paid$</b></td>
     1072                                                <td><?php echo esc_html_x( 'Inserts the payment status', 'backend', 'eduadmin-booking' ); ?></td>
     1073                                            </tr>
     1074                                            <tr>
     1075                                                <td><b>$objectid$</b></td>
     1076                                                <td><?php echo esc_html_x( 'Inserts the unique identifier for the course', 'backend', 'eduadmin-booking' ); ?></td>
     1077                                            </tr>
     1078                                            <tr>
     1079                                                <td><b>$notes$</b></td>
     1080                                                <td><?php echo esc_html_x( 'Inserts the booking notes', 'backend', 'eduadmin-booking' ); ?></td>
     1081                                            </tr>
     1082                                            <tr>
     1083                                                <td><b>$orderrows$</b></td>
     1084                                                <td><?php echo esc_html_x( 'Inserts the order rows, formatted as JSON (can be used for special handling)', 'backend', 'eduadmin-booking' ); ?></td>
     1085                                            </tr>
     1086                                        </table>
     1087                                    </td>
     1088                                </tr>
     1089                            </table>
     1090                        </div>
     1091                        <br /><p class="submit">
     1092                            <input type="submit" name="submit" id="submit" class="button button-primary"
     1093                                   value="<?php echo _x( 'Save settings', 'backend', 'eduadmin-booking' ); ?>" />
     1094                        </p>
     1095                    <?php } ?>
     1096                </div>
     1097            </form>
     1098        <?php } ?>
    10931099    </div>
    10941100    <?php
  • eduadmin-booking/trunk/includes/edu-options.php

    r3181493 r3182069  
    121121function eduadmin_page_title( $title, $sep = '|' ) {
    122122    global $wp;
     123
     124    if ( ! EDU()->api_connection ) {
     125        return $title;
     126    }
    123127
    124128    if ( empty( $sep ) ) {
  • eduadmin-booking/trunk/includes/edu-shortcodes.php

    r3166316 r3182069  
    6161        'eduadmin-listview'
    6262    );
    63     $str        = include EDUADMIN_PLUGIN_PATH . '/content/template/listTemplate/' . $attributes['template'] . '.php';
     63
     64    switch ( $attributes['template'] ) {
     65        case "template_A":
     66        case "template_B":
     67        case "template_GF":
     68            break;
     69        default:
     70            $attributes['template'] = "template_A";
     71            break;
     72    }
     73
     74    $str = include EDUADMIN_PLUGIN_PATH . '/content/template/listTemplate/' . $attributes['template'] . '.php';
    6475    EDU()->stop_timer( $t );
    6576
     
    314325            '),PriceNames'
    315326        );
     327
     328        if ( ! EDU()->api_connection ) {
     329            EDU()->stop_timer( $t );
     330
     331            return esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' );
     332        }
    316333
    317334        if ( isset( $programme["@error"] ) ) {
     
    465482            return 'Course with ID ' . $course_id . ' could not be found.';
    466483        } else {
     484            if ( ! EDU()->api_connection ) {
     485                EDU()->stop_timer( $t );
     486
     487                return esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' );
     488            }
     489
    467490            if ( isset( $selected_course["@error"] ) ) {
    468491                EDU()->stop_timer( $t );
  • eduadmin-booking/trunk/includes/eduadmin-api-phpclient/rest-client.php

    r2239891 r3182069  
    1313     * @var string API Password
    1414     */
    15     static $api_pass = null;
    16     static $root_url = 'https://api.eduadmin.se';
    17     protected $api_url = '';
    18 
    19     /**
    20      * @param resource $curl
     15    static    $api_pass = null;
     16    static    $root_url = 'https://api.eduadmin.se';
     17    protected $api_url  = '';
     18    /**
     19     * @var float Timeout for connecting to the API
     20     */
     21    static $connect_timeout_seconds = 0.5;
     22    /**
     23     * @var float Timeout for receiving the results from the API
     24     */
     25    static    $response_timeout_seconds = 5.0;
     26    protected $curl_version             = null;
     27    protected $php_version              = PHP_VERSION;
     28
     29    /**
     30     * @param \CurlHandle $curl
    2131     *
    2232     * @return mixed
     
    2535        $headers = array();
    2636
    27         curl_setopt( $curl, CURLOPT_HEADERFUNCTION, function ( $curl, $header ) use ( &$headers ) {
     37        if ( function_exists( 'add_action' ) && isset( $GLOBALS['eduadmin'] ) && ! $GLOBALS['eduadmin']->api_connection ) {
     38            // Something is wrong with the API connection, so we will not try to execute any commands
     39            curl_close( $curl );
     40
     41            return [ '@error' => 'EduAdmin Api connection not established' ];
     42        }
     43
     44        curl_setopt( $curl, CURLOPT_HEADERFUNCTION, function( $curl, $header ) use ( &$headers ) {
    2845            $len    = strlen( $header );
    2946            $header = explode( ':', $header, 2 );
     
    4865                $obj['data'] = $r;
    4966            }
    50             $obj['@curl']  = $i;
     67            $obj['@curl']    = $i;
    5168            $obj['@headers'] = $headers;
    52             $obj['@error'] = $r;
     69            $obj['@error']   = $r;
    5370
    5471            return $obj;
     
    6582            }
    6683        }
    67         $obj['@curl'] = $i;
     84        $obj['@curl']    = $i;
    6885        $obj['@headers'] = $headers;
    6986
     
    7289
    7390    /**
    74      * @param      $endpoint   string Where are we going with this request?
    75      * @param      $params     string|object|array Contains all parameters that we want to pass to the API
    76      * @param      $method_name string Which method called us?
    77      * @param bool $is_json Decides if this is a post with JSON
     91     * @param      $endpoint    string Where are we going with this request?
     92     * @param      $params      string|object|array Contains all parameters that we want to pass to the API
     93     * @param      $method_name string Which method called us?
     94     * @param bool $is_json     Decides if this is a post with JSON
    7895     *
    7996     * @return mixed
     
    84101
    85102    /**
    86      * @param      $endpoint   string Where are we going with this request?
    87      * @param      $params     string|object|array Contains all parameters that we want to pass to the API
    88      * @param      $method_name string Which method called us?
    89      * @param bool $is_json Decides if this is a post with JSON
     103     * @param      $endpoint    string Where are we going with this request?
     104     * @param      $params      string|object|array Contains all parameters that we want to pass to the API
     105     * @param      $method_name string Which method called us?
     106     * @param bool $is_json     Decides if this is a post with JSON
    90107     *
    91108     * @return mixed
     
    96113
    97114    /**
    98      * @param      $endpoint   string Where are we going with this request?
    99      * @param      $params     string|object|array Contains all parameters that we want to pass to the API
    100      * @param      $method_name string Which method called us?
    101      * @param bool $is_json Decides if this is a post with JSON
     115     * @param      $endpoint    string Where are we going with this request?
     116     * @param      $params      string|object|array Contains all parameters that we want to pass to the API
     117     * @param      $method_name string Which method called us?
     118     * @param bool $is_json     Decides if this is a post with JSON
    102119     *
    103120     * @return mixed
     
    108125
    109126    /**
    110      * @param      $endpoint   string Where are we going with this request?
    111      * @param      $params     string|object|array Contains all parameters that we want to pass to the API
    112      * @param      $method_name string Which method called us?
    113      * @param bool $is_json Decides if this is a post with JSON
     127     * @param      $endpoint    string Where are we going with this request?
     128     * @param      $params      string|object|array Contains all parameters that we want to pass to the API
     129     * @param      $method_name string Which method called us?
     130     * @param bool $is_json     Decides if this is a post with JSON
    114131     *
    115132     * @return mixed
     
    120137
    121138    /**
    122      * @param string $type
    123      * @param string $endpoint
     139     * @param string              $type
     140     * @param string              $endpoint
    124141     * @param string|array|object $params
    125      * @param string $method_name
    126      * @param bool $is_json
     142     * @param string              $method_name
     143     * @param bool                $is_json
    127144     *
    128145     * @return mixed
     
    154171
    155172    /**
    156      * @param string $endpoint
     173     * @param string       $endpoint
    157174     * @param object|array $params
    158      * @param string $method_name
     175     * @param string       $method_name
    159176     *
    160177     * @return mixed
     
    173190     * @param string $endpoint
    174191     *
    175      * @return resource
     192     * @return \CurlHandle|false
    176193     */
    177194    private function get_curl_object( $endpoint ) {
    178         if ( ! strpos( $endpoint, '/' ) === 0 ) {
     195        if ( ! strpos( $endpoint, '/' ) == 0 ) {
    179196            $endpoint = '/' . $endpoint;
    180197        }
     198
     199        if ( $this->curl_version == null ) {
     200            $this->curl_version = curl_version();
     201        }
     202
    181203        $c = curl_init( self::$root_url . $this->api_url . $endpoint );
    182204        curl_setopt( $c, CURLOPT_RETURNTRANSFER, true );
    183205
     206        switch ( true ) {
     207            case version_compare( $this->curl_version['version'], '7.16.2' ) >= 0:
     208                curl_setopt( $c, CURLOPT_TIMEOUT_MS, self::$response_timeout_seconds * 1000 );
     209                curl_setopt( $c, CURLOPT_CONNECTTIMEOUT_MS, self::$connect_timeout_seconds * 1000 );
     210                break;
     211            case version_compare( $this->curl_version['version'], '7.16.2' ) < 0:
     212                curl_setopt( $c, CURLOPT_TIMEOUT, (int) self::$response_timeout_seconds );
     213                curl_setopt( $c, CURLOPT_CONNECTTIMEOUT, (int) self::$connect_timeout_seconds );
     214                break;
     215        }
     216
    184217        return $c;
    185218    }
     
    187220    /**
    188221     * @param resource $curl_object
    189      * @param array $array
     222     * @param array    $array
    190223     */
    191224    private function set_headers( $curl_object, array $array = array() ) {
  • eduadmin-booking/trunk/includes/news-page.php

    r2340225 r3182069  
    1010            <?php
    1111            $news = EDU()->get_news();
    12             foreach ( $news as $item ) {
    13                 edu_render_news_item( $item );
     12            if ( $news == null ) {
     13                echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'backend', 'eduadmin-booking' );
     14            } else {
     15                foreach ( $news as $item ) {
     16                    edu_render_news_item( $item );
     17                }
    1418            }
    1519            ?>
  • eduadmin-booking/trunk/readme.txt

    r3181536 r3182069  
    44Requires at least: 6.0
    55Tested up to: 6.6
    6 Stable tag: 5.2.0
     6Stable tag: 5.3.0
    77Requires PHP: 8.1
    88License: GPL3
     
    5050The full changelog available on [GitHub](https://github.com/MultinetInteractive/EduAdmin-WordPress/blob/production/CHANGELOG.md)
    5151
     52### [5.3.0](https://github.com/MultinetInteractive/EduAdmin-WordPress/compare/v5.2.0...v5.3.0) (2024-11-05)
     53
     54
     55#### Features
     56
     57* 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)
     58
    5259### [5.2.0](https://github.com/MultinetInteractive/EduAdmin-WordPress/compare/v5.1.3...v5.2.0) (2024-11-04)
    5360
     
    7178* Fix potential LFI vulnerability ([89a8479](https://github.com/MultinetInteractive/EduAdmin-WordPress/commit/89a84796caaf40187c0272850632da92ee01477f))
    7279
    73 ### [5.1.1](https://github.com/MultinetInteractive/EduAdmin-WordPress/compare/v5.1.0...v5.1.1) (2024-09-18)
    7480
    7581
    76 #### Bug Fixes
    77 
    78 * Fetch AnswerId for checkbox questions the correct way ([d123497](https://github.com/MultinetInteractive/EduAdmin-WordPress/commit/d123497be9795741796aad8f13469623bc072701))
    79 
    80 
    81 
Note: See TracChangeset for help on using the changeset viewer.