Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- do_action('em_template_my_bookings_header');
- global $wpdb, $current_user, $EM_Notices, $EM_Person;
- if ( is_user_logged_in() ) :
- $EM_Person = new EM_Person( get_current_user_id() );
- $EM_Bookings = $EM_Person->get_bookings();
- $bookings_count = count($EM_Bookings->bookings);
- if ($bookings_count > 0) {
- // Get events here in one query to speed things up
- $event_ids = array();
- foreach($EM_Bookings as $EM_Booking) {
- $event_ids[] = $EM_Booking->event_id;
- }
- }
- $limit = ( !empty($_GET['limit']) ) ? $_GET['limit'] : 20; // Default limit
- $page = ( !empty($_GET['pno']) ) ? $_GET['pno']:1;
- $offset = ( $page > 1 ) ? ($page-1) * $limit : 0;
- echo $EM_Notices;
- ?>
- <div class='em-my-bookings'>
- <?php if ( $bookings_count >= $limit ) : ?>
- <div class='tablenav'>
- <?php
- if ( $bookings_count >= $limit ) {
- $link = em_add_get_params($_SERVER['REQUEST_URI'], array('pno'=>'%PAGE%'), false); // don't html encode, so em_paginate does its thing
- $bookings_nav = em_paginate( $link, $bookings_count, $limit, $page);
- echo $bookings_nav;
- }
- ?>
- <div class="clear"></div>
- </div>
- <?php endif; ?>
- <div class="clear"></div>
- <?php if ( $bookings_count > 0 ) : ?>
- <div class='table-wrap'>
- <table id='dbem-bookings-table' class='widefat post fixed'>
- <?php // set table columns ?>
- <thead>
- <tr>
- <th class='manage-column' scope='col'><?php _e('Event', 'dbem'); ?></th>
- <th class='manage-column' scope='col'><?php _e('Date', 'dbem'); ?></th>
- <th class='manage-column' scope='col'><?php _e('Status', 'dbem'); ?></th>
- <th class='manage-column' scope='col'> </th>
- </tr>
- </thead>
- <tbody>
- <?php
- $rowno = 0;
- $event_count = 0;
- foreach ($EM_Bookings as $EM_Booking) {
- // start of an event
- $EM_Event = $EM_Booking->get_event();
- if( ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0) ) {
- $rowno++;
- $bookingid = $EM_Booking->output("#_BOOKINGID");
- $eventid = $EM_Event->output("#_EVENTID");
- $event_post_id = $EM_Event->output("#_EVENTPOSTID");
- $siteurl = home_url();
- $stripzerodprice = str_replace("000","0",$EM_Booking->booking_price);
- ?>
- <tr class="bookingstartrow">
- <td class="eventlink"><?php echo $EM_Event->output("#_EVENTLINK"); ?></td>
- <td><?php echo date_i18n( get_option('dbem_date_format'), $EM_Event->start ); ?></td>
- <td>
- <?php
- echo $EM_Booking->get_status(); // echo payment status
- if ( in_array($EM_Booking->booking_status, array(0,5)) ) { // if status = pending/awaiting payment
- // event specific paypal values
- $paypalaccount = get_post_meta($event_post_id, 'Paypal', true);
- $paypalmerchant = get_post_meta($event_post_id, 'Merchant ID', true);
- $paypalcurrency = get_post_meta($event_post_id, 'Paypal currency', true);
- if ( empty($paypalcurrency) ) { $paypalcurrency = 'EUR'; } // if no Paypal currency set, use EUR
- if ( !empty($paypalaccount) ) { // paypal payments standard
- ?>
- <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
- <input type="hidden" name="amount" value="<?php echo $stripzerodprice; ?>">
- <input type="hidden" name="business" value="<?php echo $paypalaccount; ?>">
- <input type="hidden" name="cancel_return" value="<?php echo $siteurl; ?>/events/cancelled/">
- <input type="hidden" name="cmd" value="_xclick">
- <input type="hidden" name="currency_code" value="<?php echo $paypalcurrency; ?>">
- <input type="hidden" name="custom" value="<?php echo $bookingid; ?>">
- <input type="hidden" name="item_name" value="<?php echo $EM_Event->output("#_EVENTNAME"); ?>">
- <input type="hidden" name="notify_url" value="<?php echo $siteurl; ?>/wp-admin/admin-ajax.php?action=em_payment&em_payment_gateway=paypal">
- <input type="hidden" name="no_note" value="0">
- <input type="hidden" name="quantity" value="1">
- <input type="hidden" name="return" value="<?php echo $siteurl; ?>/events/registration-completed/">
- <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/x-click-but6.gif" border="0" name="submit" alt="Pay now with Paypal">
- </form>
- <?
- } // end if paypal payments standard
- if ( !empty($paypalmerchant) ) { // if organizer has business account/merchant id
- echo '<p><script
- async="async"
- src="http://www.domein.com/wp-content/themes/theme-name/js/paypal-button.min.js?merchant='.$paypalmerchant.'"
- custom="'.$bookingid.'"
- data-button="paynow"
- data-name="'.$EM_Event->event_name.'"
- data-quantity="1"
- data-amount="'.$stripzerodprice.'"
- data-currency="'.$paypalcurrency.'"
- data-shipping="0"
- data-tax="0"
- data-cancel-return="'.$siteurl.'/events/cancelled/"
- data-return="'.$siteurl.'/events/registration-completed/"
- data-callback="'.$siteurl.'/wp-admin/admin-ajax.php?action=em_payment&em_payment_gateway=paypal"
- txn_id="'.$bookingid.'"
- ></script></p>';
- echo '<p></p>';
- }
- }
- ?>
- </td>
- <td>
- <?php
- if ( !in_array($EM_Booking->booking_status, array(1)) ) { // if status = pending/awaiting payment
- // option to resend last email
- echo '<form action="" method="post" class="em-booking-single-status-info">';
- echo '<input type="submit" class="em-booking-resend-email" id="em-booking-resend-email" value="Resend Mail" />';
- echo '<input type="hidden" name="action" value="booking_resend_email"/>';
- echo '<input type="hidden" name="booking_id" value="'.$bookingid.'"/>';
- echo '<input type="hidden" name="event_id" value="'.$EM_Event->output("#_EVENTID").'"/>';
- echo '<input type="hidden" name="_wpnonce" value="'.wp_create_nonce('booking_resend_email_'.$bookingid).'"/>';
- echo '</form>';
- }
- ?>
- </td>
- </tr>
- <tr class="">
- <td colspan="5">
- <?php
- if ( in_array($EM_Booking->booking_status, array(0,5)) ) { // if status = pending/awaiting payment
- // bank info
- $ibaninfo = get_post_meta($event_post_id, 'Bank IBAN', true);
- $bicinfo = get_post_meta($event_post_id, 'Bank BIC', true);
- $accountholder = get_post_meta($event_post_id, 'Account holder', true);
- if ( $ibaninfo && $bicinfo && $accountholder ) {
- echo '<div class="toon fjalla">Pay now by bank (click to for more info)</div>';
- echo '<div class="verberg">';
- echo '<p><span class="fjalla">BANK INFO</span><br />IBAN: '.$ibaninfo.'<br />BIC/Swift: '.$bicinfo.'<br />';
- echo 'Account holder: '.$accountholder.'<br />';
- echo '</p>';
- echo '<p class="paymentinfo">Use this payment description: '.$EM_Booking->booking_id.' - '.$EM_Booking->person->display_name.' - '.$EM_Event->output("#_EVENTNAME").'</p>';
- echo '</div>';
- }
- if ( !$ibaninfo && !$paypalaccount && !$paypalmerchant ) {
- $cashevents = array('4521');
- if (in_array($event_post_id, $cashevents)) {
- echo "<p><span class='fjalla'>PAYMENT INFO</span><br />This organizer has on-site cash payment only.</p>";
- } else {
- echo "<p>The organizer hasn't entered his payment details yet (his fault, sorry), so we can't provide them right now. Once he enters them, we will send you the email.</p>";
- }
- }
- } // end if status = pending/awaiting payment
- echo '<div class="toon fjalla">Bookings info (click to for more info)</div>';
- echo '<div class="verberg">';
- if ( !in_array($EM_Booking->booking_status, array(2,3)) ) { // if is not cancelled/rejected
- echo '<p>Your booking ID = '.$bookingid.'</p>';
- echo '<p>The total price of your booking is '.$EM_Booking->get_price(true).'.</p>';
- echo '<p>You have registered the following people/info:</p>';
- echo $EM_Booking->output("#_BOOKINGATTENDEES");
- }
- echo '</div>';
- ?>
- </td>
- </tr>
- <?php
- } // end foreach/event
- do_action('em_my_bookings_booking_loop',$EM_Booking);
- $event_count++;
- }
- ?>
- </tbody>
- </table>
- </div>
- <?php else: ?>
- <?php _e('You haven\'t registered for any events (yet).', 'dbem'); ?>
- <?php endif; ?>
- <?php if( !empty($bookings_nav) && $bookings_count >= $limit ) : ?>
- <div class='tablenav'>
- <?php echo $bookings_nav; ?>
- <div class="clear"></div>
- </div>
- <?php endif; ?>
- </div>
- <?php do_action('em_template_my_bookings_footer', $EM_Bookings); ?>
- <?php else : ?>
- <p><?php echo sprintf(__('Please <a href="%s">Log In</a> to view your bookings.','dbem'),site_url('wp-login.php?redirect_to=' . urlencode(get_permalink()), 'login')); ?></p>
- <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement