function eme_printable_booking_report($event_id) { global $eme_timezone; $event = eme_get_event($event_id); $current_userid=get_current_user_id(); if (!(current_user_can( get_option('eme_cap_edit_events')) || current_user_can( get_option('eme_cap_list_events')) || (current_user_can( get_option('eme_cap_author_event')) && ($event['event_author']==$current_userid || $event['event_contactperson_id']==$current_userid)))) { echo "No access"; die; } $is_multiprice = eme_is_multi($event['price']); $is_multiseat = eme_is_multi($event['event_seats']); $bookings = eme_get_bookings_for($event_id); $answer_columns = eme_get_answercolumns(eme_get_bookingids_for($event_id)); $available_seats = eme_get_available_seats($event_id); $booked_seats = eme_get_booked_seats($event_id); $pending_seats = eme_get_pending_seats($event_id); if ($is_multiseat) { $available_seats_ms=eme_convert_array2multi(eme_get_available_multiseats($event_id)); $booked_seats_ms=eme_convert_array2multi(eme_get_booked_multiseats($event_id)); $pending_seats_ms=eme_convert_array2multi(eme_get_pending_multiseats($event_id)); } $stylesheet = EME_PLUGIN_URL."events_manager.css"; foreach($answer_columns as $col) { $formfield[$col["field_name"]]=eme_get_formfield_id_byname($col["field_name"]); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <title>Bookings for <?php echo eme_trans_sanitize_html($event['event_name']);?></title> <link rel="stylesheet" href="<?php echo $stylesheet; ?>" type="text/css" media="screen" /> <?php $file_name= get_stylesheet_directory()."/eme.css"; if (file_exists($file_name)) echo "<link rel='stylesheet' href='".get_stylesheet_directory_uri()."/eme.css' type='text/css' media='screen' />\n"; $file_name= get_stylesheet_directory()."/eme_print.css"; if (file_exists($file_name)) echo "<link rel='stylesheet' href='".get_stylesheet_directory_uri()."/eme_print.css' type='text/css' media='print' />\n"; ?> </head> <body id="eme_printable_body"> <div id="eme_printable_container"> <h1>Bookings for <?php echo eme_trans_sanitize_html($event['event_name']);?></h1> <p><?php echo eme_localised_date($event['event_start_date']." ".$event['event_start_time']." ".$eme_timezone); ?></p> <p><?php if ($event['location_id']) echo eme_replace_placeholders("#_LOCATIONNAME, #_ADDRESS, #_TOWN", $event); ?></p> <?php if ($event['price']) ?> <p><?php _e ( 'Price: ','eme' ); echo eme_replace_placeholders("#_CURRENCY #_PRICE", $event)?></p> <h1><?php _e('Bookings data', 'eme');?></h1> <table id="eme_printable_table"> <tr> <th scope='col' class='eme_print_id'><?php _e('ID', 'eme')?></th> <th scope='col' class='eme_print_name'><?php _e('Last Name', 'eme')?></th> <th scope='col' class='eme_print_name'><?php _e('First Name', 'eme')?></th> <th scope='col' class='eme_print_email'><?php _e('E-mail', 'eme')?></th> <th scope='col' class='eme_print_phone'><?php _e('Phone number', 'eme')?></th> <th scope='col' class='eme_print_seats'><?php if ($is_multiprice) _e('Seats (Multiprice)', 'eme'); else _e('Seats', 'eme'); ?></th> <th scope='col' class='eme_print_paid'><?php _e('Paid', 'eme')?></th> <th scope='col' class='eme_print_booking_date'><?php _e('Booking date', 'eme')?></th> <th scope='col' class='eme_print_total_price'><?php _e('Total price', 'eme')?></th> <th scope='col' class='eme_print_unique_nbr'><?php _e('Unique nbr', 'eme')?></th> <th scope='col' class='eme_print_comment'><?php _e('Comment', 'eme')?></th> <?php $nbr_columns=11; foreach($answer_columns as $col) { $class="eme_print_formfield".$formfield[$col['field_name']]; print "<th scope='col' class='$class'>".$col['field_name']."</th>"; $nbr_columns++; } ?> </tr> <?php foreach($bookings as $booking) { $localised_booking_date = eme_localised_date($booking['creation_date']." ".$eme_timezone); $localised_booking_time = eme_localised_time($booking['creation_date']." ".$eme_timezone); $person = eme_get_person ($booking['person_id']); $pending_string=""; if (eme_event_needs_approval($event_id) && !$booking['booking_approved']) { $pending_string=__('(pending)','eme'); } ?> <tr> <td class='eme_print_id'><?php echo $booking['booking_id']?></td> <td class='eme_print_name'><?php echo $person['lastname']?></td> <td class='eme_print_name'><?php echo $person['firstname']?></td> <td class='eme_print_email'><?php echo $person['email']?></td> <td class='eme_print_phone'><?php echo $person['phone']?></td> <td class='eme_print_seats' class='seats-number'><?php if ($is_multiprice) { // in cases where the event switched to multiprice, but somebody already registered while it was still single price: booking_seats_mp is then empty if ($booking['booking_seats_mp'] == "") $booking['booking_seats_mp']=$booking['booking_seats']; echo $booking['booking_seats']." (".$booking['booking_seats_mp'].") ".$pending_string; } else { echo $booking['booking_seats']." ".$pending_string; } ?> </td> <td class='eme_print_paid'><?php if ($booking['booking_payed']) _e('Yes'); else _e('No'); ?></td> <td class='eme_print_booking_date'><?php echo $localised_booking_date." ".$localised_booking_time; ?></td> <td class='eme_print_total_price'><?php echo eme_get_total_booking_price($event,$booking); ?></td> <td class='eme_print_unique_nbr'><?php echo $booking['transfer_nbr_be97']; ?></td> <td class='eme_print_comment'><?=$booking['booking_comment'] ?></td> <?php $answers = eme_get_answers($booking['booking_id']); foreach($answer_columns as $col) { $found=0; foreach ($answers as $answer) { $class="eme_print_formfield".$formfield[$col['field_name']]; if ($answer['field_name'] == $col['field_name']) { print "<td class='$class'>".eme_sanitize_html(eme_convert_answer2tag($answer))."</td>"; $found=1; break; } } # to make sure the number of columns are correct, we add an empty answer if none was found if (!$found) print "<td class='$class'> </td>"; } ?> </tr> <?php } ?> <tr id='eme_printable_booked-seats'> <td colspan='<?php echo $nbr_columns-4;?>'> </td> <td class='total-label'><?php _e('Booked', 'eme')?>:</td> <td colspan='3' class='seats-number'><?php print $booked_seats; if ($is_multiseat) print " ($booked_seats_ms)"; if ($pending_seats>0) { if ($is_multiseat) print " ".sprintf( __('(%s pending)','eme'), $pending_seats . " ($pending_seats_ms)"); else print " ".sprintf( __('(%s pending)','eme'), $pending_seats); } ?> </td> </tr> <tr id='eme_printable_available-seats'> <td colspan='<?php echo $nbr_columns-4;?>'> </td> <td class='total-label'><?php _e('Available', 'eme')?>:</td> <td colspan='3' class='seats-number'><?php print $available_seats; if ($is_multiseat) print " ($available_seats_ms)"; ?></td> </tr> </table> </div> </body> </html> <?php die(); }
function eme_send_mails_page() { global $wpdb; $event_id = isset($_POST['event_id']) ? intval($_POST['event_id']) : 0; $action = isset($_POST['eme_admin_action']) ? $_POST['eme_admin_action'] : ''; $onchange = isset($_POST['onchange']) ? intval($_POST['onchange']) : 0; if (isset($_POST['mail_subject']) && !empty($_POST['mail_subject'])) { $mail_subject = stripslashes_deep($_POST['mail_subject']); } elseif (isset($_POST['subject_template']) && intval($_POST['subject_template']) > 0) { $mail_subject = eme_get_template_format(intval($_POST['subject_template'])); } else { $mail_subject = ""; } if (isset($_POST['mail_message']) && !empty($_POST['mail_message'])) { $mail_message = stripslashes_deep($_POST['mail_message']); } elseif (isset($_POST['message_template']) && intval($_POST['message_template']) > 0) { $mail_message = eme_get_template_format(intval($_POST['message_template'])); } else { $mail_message = ""; } if (!$onchange && $event_id > 0 && $action == 'send_mail') { $pending_approved = isset($_POST['pending_approved']) ? $_POST['pending_approved'] : 0; $only_unpayed = isset($_POST['only_unpayed']) ? $_POST['only_unpayed'] : 0; $eme_mail_type = isset($_POST['eme_mail_type']) ? $_POST['eme_mail_type'] : 'attendees'; if (empty($mail_subject) || empty($mail_message)) { print "<div id='message' class='error'><p>" . __('Please enter both subject and message for the mail to be sent.', 'eme') . "</p></div>"; } else { $event = eme_get_event($event_id); $current_userid = get_current_user_id(); if (current_user_can(get_option('eme_cap_send_other_mails')) || current_user_can(get_option('eme_cap_send_mails')) && ($event['event_author'] == $current_userid || $event['event_contactperson_id'] == $current_userid)) { $event_name = $event['event_name']; $contact = eme_get_contact($event); $contact_email = $contact->user_email; $contact_name = $contact->display_name; $mail_text_html = get_option('eme_rsvp_send_html') ? "html" : "text"; if ($eme_mail_type == 'attendees') { $attendees = eme_get_attendees_for($event_id, $pending_approved, $only_unpayed); foreach ($attendees as $attendee) { $tmp_subject = eme_replace_placeholders($mail_subject, $event, "text", 0, $attendee['lang']); $tmp_message = eme_replace_placeholders($mail_message, $event, $mail_text_html, 0, $attendee['lang']); $tmp_subject = eme_replace_attendees_placeholders($tmp_subject, $event, $attendee, "text", 0, $attendee['lang']); $tmp_message = eme_replace_attendees_placeholders($tmp_message, $event, $attendee, $mail_text_html, 0, $attendee['lang']); $tmp_subject = eme_translate($tmp_subject, $attendee['lang']); $tmp_message = eme_translate($tmp_message, $attendee['lang']); $person_name = $attendee['lastname'] . ' ' . $attendee['firstname']; eme_send_mail($tmp_subject, $tmp_message, $attendee['email'], $person_name, $contact_email, $contact_name); } } elseif ($eme_mail_type == 'bookings') { $bookings = eme_get_bookings_for($event_id, $pending_approved, $only_unpayed); foreach ($bookings as $booking) { // we use the language done in the booking for the mails, not the attendee lang in this case $attendee = eme_get_person($booking['person_id']); if ($attendee && is_array($attendee)) { $tmp_subject = eme_replace_placeholders($mail_subject, $event, "text", 0, $booking['lang']); $tmp_message = eme_replace_placeholders($mail_message, $event, $mail_text_html, 0, $booking['lang']); $tmp_subject = eme_replace_booking_placeholders($tmp_subject, $event, $booking, "text", 0, $booking['lang']); $tmp_message = eme_replace_booking_placeholders($tmp_message, $event, $booking, $mail_text_html, 0, $booking['lang']); $tmp_subject = eme_translate($tmp_subject, $booking['lang']); $tmp_message = eme_translate($tmp_message, $booking['lang']); $person_name = $attendee['lastname'] . ' ' . $attendee['firstname']; eme_send_mail($tmp_subject, $tmp_message, $attendee['email'], $person_name, $contact_email, $contact_name); } } } elseif ($eme_mail_type == 'all_wp') { $wp_users = get_users(); $tmp_subject = eme_replace_placeholders($mail_subject, $event, "text"); $tmp_message = eme_replace_placeholders($mail_message, $event, $mail_text_html); foreach ($wp_users as $wp_user) { eme_send_mail($tmp_subject, $tmp_message, $wp_user->user_email, $wp_user->display_name, $contact_email, $contact_name); } } elseif ($eme_mail_type == 'all_wp_not_registered') { $wp_users = get_users(); $attendee_wp_ids = eme_get_wp_ids_for($event_id); $tmp_subject = eme_replace_placeholders($mail_subject, $event, "text"); $tmp_message = eme_replace_placeholders($mail_message, $event, $mail_text_html); foreach ($wp_users as $wp_user) { if (!in_array($wp_user->ID, $attendee_wp_ids)) { eme_send_mail($tmp_subject, $tmp_message, $wp_user->user_email, $wp_user->display_name, $contact_email, $contact_name); } } } print "<div id='message' class='updated'><p>" . __('The mail has been sent.', 'eme') . "</p></div>"; } else { print "<div id='message' class='error'><p>" . __('You do not have the permission to send mails for this event.', 'eme') . "</p></div>"; } } } // now show the form eme_send_mail_form($event_id); }