Advertisement
simbasounds

custom_functions

May 12th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.69 KB | None | 0 0
  1. <?php
  2. function event_espresso_my_events(){
  3.         global $espresso_premium; if ($espresso_premium != true) return;
  4.         global $wpdb, $org_options;
  5.         global $ticketing_installed;
  6.         $notifications['success'] = array();
  7.         $notifications['error']  = array();
  8.         require_once('user_vars.php');
  9.         if( ! is_user_logged_in() ){
  10.             if( $login_page != '' ) {
  11.                 echo '<p>'.sprintf(__('Please <a href="%s">log in</a> to view the events you are registered to attend.', 'event_espresso'), $login_page ).'</p>';
  12.                 return;
  13.             }else{
  14.                 echo '<p>'.__('You must be logged in to view this page.', 'event_espresso').'</p>';
  15.                 return;
  16.             }
  17.         }
  18.         ?>
  19.  
  20. <div id="configure_organization_form" class="wrap meta-box-sortables ui-sortable">
  21.     <div id="event_reg_theme" class="wrap">
  22.         <div id="icon-options-event" class="icon32"></div>
  23.         <h2><?php echo _e('My Events Management', 'event_espresso') ?></h2>
  24.         <div id="poststuff" class="metabox-holder">
  25.             <?php
  26.         if( filter_has_var( INPUT_POST, 'cancel_registration' ) && $_POST['cancel_registration'] == true ){
  27.             if( filter_has_var( INPUT_POST, 'checkbox' ) && is_array( $_POST['checkbox'] ) ){
  28.                                
  29.                 while(list($key,$value)=each($_POST['checkbox'])){
  30.                    
  31.                     //Update the attendee payment status to 'Cancelled'
  32.                     $upd_success = $wpdb->query(
  33.                         $wpdb->prepare(
  34.                             "UPDATE " . EVENTS_ATTENDEE_TABLE . " ea JOIN " . EVENTS_MEMBER_REL_TABLE . " emr ON (emr.attendee_id = ea.id)
  35.                                 SET ea.payment_status = 'Cancelled'
  36.                             WHERE emr.attendee_id = %d and emr.user_id = %d",
  37.                             $key,
  38.                             $userid
  39.                         )
  40.                     );
  41.                    
  42.                     if ( $upd_success === FALSE ) {
  43.                         $notifications['error'][] = __('An error occured. The registration was not cancelled.', 'event_espresso');
  44.                     }else{
  45.                         //If there are no errors, send a confirmation email
  46.                         do_action('action_hook_espresso_after_registration_cancellation', array('attendee_id'=>$key) );
  47.                     }
  48.                 }
  49.                
  50.                 $notifications['success'][] = __('You have cancelled your registration(s).', 'event_espresso');
  51.                
  52.             }
  53.            
  54.             // display success messages
  55.             if ( ! empty( $notifications['success'] )) {
  56.                 $success_msg = implode( $notifications['success'], '<br />' );
  57.             ?>
  58.             <div id="message" class="updated fade">
  59.                 <p> <strong><?php echo $success_msg; ?></strong> </p>
  60.             </div>
  61.             <?php
  62.              }
  63.             // display error messages
  64.             if ( ! empty( $notifications['error'] )) {
  65.                 $error_msg = implode( $notifications['error'], '<br />' );
  66.             ?>
  67.             <div id="message" class="error">
  68.                 <p> <strong><?php echo $error_msg; ?></strong> </p>
  69.             </div>
  70.             <?php }
  71.                 }
  72.             ?>
  73.             <form id="form1" name="form1" method="post" action="<?php echo $_SERVER["REQUEST_URI"]?>">
  74.                 <div style="clear:both; margin-bottom:30px;"></div>
  75.                 <table id="table" class="widefat my_events_table" width="100%">
  76.                     <thead>
  77.                         <tr>
  78.                             <th class="manage-column column-cb check-column" id="cb" scope="col" style="width:5%;"></th>
  79.                             <th class="manage-column column-title" id="name" scope="col" title="Click to Sort" style="width:10%;"><span>
  80.                                 <?php _e('Event Name','event_espresso'); ?>
  81.                                 </span><span class="sorting-indicator"></span></th>
  82.                             <th class="manage-column column-title" id="event" scope="col" title="Click to Sort" style="width: 10%;"> <span>
  83.                                 <?php _e('Type','event_espresso'); ?>
  84.                                 </span> <span class="sorting-indicator"></span> </th>
  85.                             <th class="manage-column column-author" id="start" scope="col" title="Click to Sort" style="width:10%;"><span>
  86.                                 <?php _e('Date','event_espresso'); ?>
  87.                                 </span><span class="sorting-indicator"></span></th>
  88.                             <th class="manage-column column-date" id="begins" scope="col" title="Click to Sort" style="width:5%;"><span>
  89.                                 <?php _e('Time','event_espresso'); ?>
  90.                                 </span><span class="sorting-indicator"></span></th>
  91.                             <th class="manage-column column-date" id="status" scope="col" title="Click to Sort" style="width:5%;"><span>
  92.                                 <?php _e('Status','event_espresso'); ?>
  93.                                 </span><span class="sorting-indicator"></span></th>
  94.                             <th class="manage-column column-date" id="attendees" scope="col" title="Click to Sort" style="width:5%;"><span>
  95.                                 <?php _e('Cost','event_espresso'); ?>
  96.                                 </span><span class="sorting-indicator"></span></th>
  97.                             <th class="manage-column column-date" id="invoice" scope="col" style="width:5%;"><?php _e('Invoice','event_espresso'); ?></th>
  98.                             <?php echo $ticketing_installed == true?'<th class="manage-column column-author" id="ticket" scope="col" style="width:10%;">'.__('Ticket','event_espresso').'</th>':''; ?> </tr>
  99.                     </thead>
  100.                     <tbody>
  101.                         <?php
  102.             $wpdb->get_results(
  103.                 $wpdb->prepare(
  104.                     "SELECT id FROM ". EVENTS_MEMBER_REL_TABLE . " WHERE user_id = '%d'",
  105.                     $current_user->ID
  106.                 )
  107.             );
  108.            
  109.             if ($wpdb->num_rows > 0) {
  110.                 $events = $wpdb->get_results(
  111.                     $wpdb->prepare(
  112.                         "SELECT e.id event_id, e.event_name, e.event_code, e.start_date, e.event_desc, e.display_desc, a.id attendee_id, a.event_time start_time, a.payment_status, a.payment_date, a.amount_pd, u.user_id user_id, a.registration_id, a.fname, a.lname, a.price_option, a.event_time
  113.                             FROM " . EVENTS_ATTENDEE_TABLE . " a
  114.                             JOIN " . EVENTS_MEMBER_REL_TABLE . " u ON u.attendee_id = a.id
  115.                             JOIN " . EVENTS_DETAIL_TABLE . " e ON e.id = u.event_id
  116.                         WHERE u.user_id = '%d' AND a.payment_status != 'Cancelled'",
  117.                         $current_user->ID
  118.                     )
  119.                 );
  120.                
  121.                 foreach ($events as $event){
  122.                         $event_id           = $event->event_id;
  123.                         $event_code         = $event->event_code;
  124.                         $attendee_id        = $event->attendee_id;
  125.                         $registration_id    = $event->registration_id;
  126.                         $lname              = $event->lname;
  127.                         $fname              = $event->fname;
  128.                         $event_name         = $event->event_name;
  129.                         $start_date         = $event->start_date;
  130.                         $start_time         = $event->start_time;
  131.                         $event_desc         = $event->event_desc;
  132.                         $display_desc       = $event->display_desc;
  133.                         $payment_status     = $event->payment_status;
  134.                         $amount_pd          = espresso_attendee_price(array('attendee_id'=>$attendee_id));
  135.                         $payment_date       = $event->payment_date;
  136.                         $ticket_type        = $event->price_option;
  137.                        
  138.                         if ($payment_status == ''){
  139.                             $payment_link = get_option('siteurl') . "/?page_id=" . $org_options['return_url'] . "&id=" . $attendee_id;
  140.                             $payment_status = '<a href="' . $payment_link . '">Pay Now</a>';
  141.                         }
  142.                        
  143.                         $event_url = home_url() . "/?page_id=" . $org_options['event_page_id']. "&regevent_action=register&event_id=". $event_id;
  144.                         $event_link = '<a class="row-title" href="' . $event_url . '">' . stripslashes_deep($event->event_name) . '</a>';
  145.                        
  146.                         //Build the payment link
  147.                         $payment_url = home_url() . "/?page_id=" . $org_options['return_url'] . "&amp;registration_id=" . $registration_id;
  148.                        
  149.                         //Deprecated ticketing system support
  150.                         //If the custom ticket is available, load the template file
  151.                         if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . "/ticketing/template.php")){
  152.                             if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . "/ticketing/functions.php")){
  153.                                 include_once(EVENT_ESPRESSO_UPLOAD_DIR . "/ticketing/functions.php");
  154.                                 $qr_code = espresso_qr_code(array('attendee_id' => $attendee_id,'event_name' => stripslashes_deep($event_name), 'attendee_first' => $fname, 'attendee_last'=> $lname, 'registration_id'=> $registration_id, 'event_code'=> $event_code, 'ticket_type'=>$ticket_type, 'event_time'=>$event_time, 'amount_pd'=>$amount_pd));
  155.                             }
  156.                                     //Build the ticket link
  157.                             $ticket_url = home_url() . "/?download_ticket=true&amp;id=" . $attendee_id . "&amp;registration_id=".$registration_id;
  158.                             $ticket_link = '<a href="' . $ticket_url . '">' . __('Download Ticket Now!') . '</a>';
  159.                         }
  160.                        
  161.                         //New ticketing system suport
  162.                         if (function_exists('espresso_ticket_launch')){
  163.                             $ticket_link = espresso_ticket_links($registration_id, $attendee_id);
  164.                         }
  165.    
  166.     ?>
  167.                         <tr>
  168.                             <td><input name="checkbox[<?php echo $attendee_id?>]" type="checkbox"  title="Cancel registration for <?php echo $event_name?>"></td>
  169.                             <td class="post-title page-title column-title"><strong><?php echo stripslashes_deep($event->event_name);?></strong></td>
  170.                             <td class="post-title page-title column-title"><?php echo $ticket_type ?></td>
  171.                             <td class="date column-date"><?php echo event_date_display($start_date)?></td>
  172.                             <td class="date column-date"><?php echo $start_time?></td>
  173.                             <td class="date column-date"><?php echo '<a target="_blank" href="' . $payment_url . '" title="'.__('View Your Payment Details').'">'; ?>
  174.                                 <?php event_espresso_paid_status_icon( $payment_status ) . '</a>'; ?></td>
  175.                             <td class="date column-date"><?php echo $org_options[ 'currency_symbol' ] ?><?php echo $amount_pd?></td>
  176.                             <td class="date column-date"><a href="<?php echo home_url();?>/?download_invoice=true&amp;admin=true&amp;registration_id=<?php echo $registration_id ?>" target="_blank"  title="<?php _e('Download Invoice', 'event_espresso'); ?>"><img src="<?php echo EVENT_ESPRESSO_PLUGINFULLURL ?>images/icons/page_white_acrobat.png" width="16" height="16" alt="<?php _e('Download Invoice', 'event_espresso'); ?>" /></a></td>
  177.                             <?php echo $ticketing_installed == true?'<td class="post-title page-title column-title">'.$ticket_link.'</td>':''; ?> </tr>
  178.                         <?php }
  179.             }
  180.             ?>
  181.                     </tbody>
  182.                 </table>
  183.                 <div class="bottom_settings" style="clear:both; margin-bottom:30px;">
  184.                     <input type="checkbox" name="sAll" onclick="selectAll(this)" />
  185.                     <strong>
  186.                     <?php _e('Check All','event_espresso'); ?>
  187.                     </strong>
  188.                     <input name="cancel_registration" type="submit" class="button-secondary" id="cancel_registration" value="<?php _e('Cancel Registration','event_espresso'); ?>" onclick="return confirmDelete();">
  189.                     <a style="margin-left:20px" class="button-primary"  onclick="window.location='<?php echo admin_url(); ?>profile.php#event_espresso_profile'">
  190.                     <?php _e('Your Profile','event_espresso'); ?>
  191.                     </a> </div>
  192.             </form>
  193.         </div>
  194.     </div>
  195. </div>
  196. <script>
  197.     jQuery(document).ready(function($) {                       
  198.            
  199.         /* show the table data */
  200.         var mytable = $('#table').dataTable( {
  201.                 "bStateSave": true,
  202.                 "sPaginationType": "full_numbers",
  203.    
  204.                 "oLanguage": {  "sSearch": "<strong><?php _e('Live Search Filter', 'event_espresso'); ?>:</strong>",
  205.                                 "sZeroRecords": "<?php _e('No Records Found!','event_espresso'); ?>" },
  206.                 "aoColumns": [
  207.                                 { "bSortable": false },
  208.                                  null,
  209.                                  null,
  210.                                  null,
  211.                                  null,
  212.                                  null,
  213.                                  null,
  214.                                  { "bSortable": false },
  215.                                 <?php echo $ticketing_installed == true?'{ "bSortable": false }':'';?>
  216.                             ]
  217.    
  218.         } );
  219.        
  220.     } );
  221.     </script>
  222. <?php
  223. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement