@@ -1,4 +1,4 @@ |
||
| 1 | 1 | <p><strong><?php esc_html_e('Message Templates', 'event_espresso'); ?></strong></p> |
| 2 | -<p><?php printf( esc_html__('Message Templates are the %1$sformat%2$s of the messages going out. Think of them as a “form letter”. Templates tell the Messages system how to style your messages and the content (information) they will have when they are delivered.', 'event_espresso'), '<em>', '</em>'); ?></p> |
|
| 2 | +<p><?php printf(esc_html__('Message Templates are the %1$sformat%2$s of the messages going out. Think of them as a “form letter”. Templates tell the Messages system how to style your messages and the content (information) they will have when they are delivered.', 'event_espresso'), '<em>', '</em>'); ?></p> |
|
| 3 | 3 | <p><?php esc_html_e('There is a template created for each Messenger / Message Type and context combination. For example, messages that are sent for Payment Confirmation have a template for Event Administrator and a different one for Primary Registrant. Whereas, messages that are sent for the Registration confirmation have 3 templates: one for Event Administrator, one for the Primary Registrant, and another for each additional Registrant(s).', 'event_espresso'); ?></p> |
| 4 | -<p><?php esc_html_e('With the Event Espresso Messages system, every Messenger, Message Type, and context will have a global template created with some default content on creation. You have the ability to edit the global template that will be used for all events you create. Additionally, you have the ability to create custom templates for each event on the edit event page for the event (in a metabox labelled "Notifications").', 'event_espresso' ); ?></p> |
|
| 5 | 4 | \ No newline at end of file |
| 5 | +<p><?php esc_html_e('With the Event Espresso Messages system, every Messenger, Message Type, and context will have a global template created with some default content on creation. You have the ability to edit the global template that will be used for all events you create. Additionally, you have the ability to create custom templates for each event on the edit event page for the event (in a metabox labelled "Notifications").', 'event_espresso'); ?></p> |
|
| 6 | 6 | \ No newline at end of file |
@@ -1,4 +1,4 @@ |
||
| 1 | 1 | <h2><?php esc_html_e('What are Message Templates', 'event_espresso'); ?></h2> |
| 2 | -<p><?php printf( esc_html__('Message Templates are the %1$sformat%2$s of the messages going out. Think of them like a “Form letter”. Templates are used to tell the system what you want your messages to look like and the content they will have when they are delivered.', 'event_espresso'), '<em>', '</em>' ); ?></p> |
|
| 2 | +<p><?php printf(esc_html__('Message Templates are the %1$sformat%2$s of the messages going out. Think of them like a “Form letter”. Templates are used to tell the system what you want your messages to look like and the content they will have when they are delivered.', 'event_espresso'), '<em>', '</em>'); ?></p> |
|
| 3 | 3 | <p><?php esc_html_e('There is a template created for each messenger/message type AND context combination. So example, Emails that are sent for the Payment confirmation have a template for Event Administrator and a different one for Primary Registrant. Whereas, emails that are sent for the Registration confirmation have 3 templates, one for Event Administrator, Primary Registrant, and Registrant.', 'event_espresso'); ?></p> |
| 4 | -<p><?php esc_html_e('With the Event Espresso Messages system, every Messenger, Message Type and Context will have a global template created with some default content on creation. You have the ability to edit this global template that will be used for all events you create. However, you also have the ability to create custom templates for each event on the edit event page for the event (in a metabox labelled "Notifications").', 'event_espresso' ); ?></p> |
|
| 5 | 4 | \ No newline at end of file |
| 5 | +<p><?php esc_html_e('With the Event Espresso Messages system, every Messenger, Message Type and Context will have a global template created with some default content on creation. You have the ability to edit this global template that will be used for all events you create. However, you also have the ability to create custom templates for each event on the edit event page for the event (in a metabox labelled "Notifications").', 'event_espresso'); ?></p> |
|
| 6 | 6 | \ No newline at end of file |
@@ -2,29 +2,29 @@ |
||
| 2 | 2 | <p><?php _e('Here are a few things that you should know about the Message Template Editor:', 'event_espresso'); ?></p> |
| 3 | 3 | <p><strong><?php esc_html_e('1. The Event Editor Title', 'event_espresso'); ?></strong></p> |
| 4 | 4 | <p><?php echo $img1; ?></p> |
| 5 | -<p><?php printf( esc_html__( 'The Event Editor title is very helpful in indicating which template you are currently editing. In the example above, we can see that we are editing the template that for the %1$sEmail%2$s messenger, the %1$sPayment%2$s message type, and the %1$sEvent Admin%2$s context (which for this message type means "recipient").', 'event_espresso'), '<strong>','</strong>' ); ?></p> |
|
| 5 | +<p><?php printf(esc_html__('The Event Editor title is very helpful in indicating which template you are currently editing. In the example above, we can see that we are editing the template that for the %1$sEmail%2$s messenger, the %1$sPayment%2$s message type, and the %1$sEvent Admin%2$s context (which for this message type means "recipient").', 'event_espresso'), '<strong>', '</strong>'); ?></p> |
|
| 6 | 6 | <p><strong><?php esc_html_e('2. "Context Switcher" and Preview Button', 'event_espresso'); ?></strong></p> |
| 7 | 7 | <p><?php echo $img2; ?></p> |
| 8 | 8 | <p><?php esc_html_e('The context switcher allows you to quickly switch between templates. The current context you are working on is displayed in the dropdown. You can switch to any other template for contexts available to the messenger and message type template group you are working on.', 'event_espresso'); ?></p> |
| 9 | 9 | <p><?php esc_html_e('Remember that contexts can represent different things. In this example they represent "recipients" and so they are labelled as such. In this example (for email payment confirmations), you may want Event Administrators to receive different information than Primary Registrants (the other context available to edit).', 'event_espresso'); ?></p> |
| 10 | -<p><?php printf( esc_html__('The %sPreview%s button is simply a link to a special view of the current template displayed to give you an idea of how the actual message will look when delivered. More information on what the preview displays is available in the content of the help tab on the preview page.', 'event_espresso'), '<strong>', '</strong>' ); ?> |
|
| 10 | +<p><?php printf(esc_html__('The %sPreview%s button is simply a link to a special view of the current template displayed to give you an idea of how the actual message will look when delivered. More information on what the preview displays is available in the content of the help tab on the preview page.', 'event_espresso'), '<strong>', '</strong>'); ?> |
|
| 11 | 11 | </p> |
| 12 | 12 | <p><strong><?php esc_html_e('3. Template Form Fields', 'event_espresso'); ?></strong></p> |
| 13 | 13 | <p><?php echo $img3; ?><?php esc_html_e('The middle area of the page is dedicated to all the fields related to the message template. These fields are dynamic in the sense that different messengers may require different fields (and sometimes different message types will add or subtract fields as well.', 'event_espresso'); ?></p> |
| 14 | -<p><?php printf( esc_html__('When editing a "Email Payment Template", you will notice that there is a field labelled "Event List" along with "Main Content". The Event List field is a special field that holds the template for whenever the %1$s[EVENT_LIST]%2$s shortcode is used in the "Main Content" field. This is so you can more finely control how each "event" in the event list displays when shown in the Main content. The "Email Registration Template", has an additional field called "Registration List". It functions much the same except that the contents of the "Registration List" field are used to indicate how each registrant is listed in the Main Content when the %1$s[ATTENDEE_LIST]%2$s shortcode is parsed.', 'event_espresso'), '<strong>', '</strong>' ); ?></p> |
|
| 14 | +<p><?php printf(esc_html__('When editing a "Email Payment Template", you will notice that there is a field labelled "Event List" along with "Main Content". The Event List field is a special field that holds the template for whenever the %1$s[EVENT_LIST]%2$s shortcode is used in the "Main Content" field. This is so you can more finely control how each "event" in the event list displays when shown in the Main content. The "Email Registration Template", has an additional field called "Registration List". It functions much the same except that the contents of the "Registration List" field are used to indicate how each registrant is listed in the Main Content when the %1$s[ATTENDEE_LIST]%2$s shortcode is parsed.', 'event_espresso'), '<strong>', '</strong>'); ?></p> |
|
| 15 | 15 | <div style="clear:both"></div> |
| 16 | 16 | <p><strong><?php esc_html_e('4. Valid Shortcodes Metabox', 'event_espresso'); ?></strong></p> |
| 17 | 17 | <p> |
| 18 | 18 | <?php echo $img4; ?><?php esc_html_e('The "Valid Shortcodes" metabox contains a list of all the shortcodes that can be used for the displayed template. This list is dynamic and will vary between templates.', 'event_espresso'); ?> |
| 19 | 19 | </p> |
| 20 | 20 | <p><?php _e('This box is at a fixed height, but contents are scrollable. You can click the question mark to find out what the given shortcode will parse to when used in your template.', 'event_espresso'); ?></p> |
| 21 | -<p><?php printf( esc_html__('%sAn important note:%s The system has been designed so that when you save the template, checks will be performed on each field to make sure that only valid shortcodes (or values) are used within them. You will get a warning box with clear instructions if you\'ve tried to use a particular shortcode in a field that does not support it. Also, you\'ll want to try the Preview button if you\'ve made any changes to the template to see if the changes are as you expected!', 'event_espresso'), '<strong>', '</strong>' ); ?> |
|
| 21 | +<p><?php printf(esc_html__('%sAn important note:%s The system has been designed so that when you save the template, checks will be performed on each field to make sure that only valid shortcodes (or values) are used within them. You will get a warning box with clear instructions if you\'ve tried to use a particular shortcode in a field that does not support it. Also, you\'ll want to try the Preview button if you\'ve made any changes to the template to see if the changes are as you expected!', 'event_espresso'), '<strong>', '</strong>'); ?> |
|
| 22 | 22 | </p> |
| 23 | 23 | <div style="clear:both"></div> |
| 24 | 24 | <p><strong><?php esc_html_e('5. Override All Custom', 'event_espresso'); ?></strong></p> |
| 25 | 25 | <p> |
| 26 | 26 | <?php echo $img5; ?> |
| 27 | - <?php printf( esc_html__( 'When you are editing a template that is a global template (not a custom event template), you\'ll see an option in the Publish metabox in the right column labelled "Override all custom". When this option is selected, custom event templates for that %1$smessenger%2$s, %1$smessage type%2$s, and %1$scontext%2$s will be ignored and the global template will be used. Why would you want to do this? For this given example, you may want to be able to allow custom event templates to be able to modify the looks and content of what goes out to Primary Registrant but to never affect what the Event Administrator receives (as set by the global template).', 'event_espresso'), '<em>', '</em>' ); ?> |
|
| 27 | + <?php printf(esc_html__('When you are editing a template that is a global template (not a custom event template), you\'ll see an option in the Publish metabox in the right column labelled "Override all custom". When this option is selected, custom event templates for that %1$smessenger%2$s, %1$smessage type%2$s, and %1$scontext%2$s will be ignored and the global template will be used. Why would you want to do this? For this given example, you may want to be able to allow custom event templates to be able to modify the looks and content of what goes out to Primary Registrant but to never affect what the Event Administrator receives (as set by the global template).', 'event_espresso'), '<em>', '</em>'); ?> |
|
| 28 | 28 | </p> |
| 29 | 29 | <p> |
| 30 | 30 | <strong><?php esc_html_e('Recommendations', 'event_espresso'); ?></strong><br /> |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | </li> |
| 42 | 42 | <li> |
| 43 | 43 | <?php esc_html_e('Messenger', 'event_espresso'); ?><br /> |
| 44 | - <?php printf( esc_html__('This column displays a number of different elements for the listed template. First is the messenger that this template is delivered by. The messenger title is linked to the editor for the first %1$scontext%2$s listed (context is labelled "recipients" for payment message types)', 'event_espresso'), '<em>', '</em>'); ?><br /> |
|
| 44 | + <?php printf(esc_html__('This column displays a number of different elements for the listed template. First is the messenger that this template is delivered by. The messenger title is linked to the editor for the first %1$scontext%2$s listed (context is labelled "recipients" for payment message types)', 'event_espresso'), '<em>', '</em>'); ?><br /> |
|
| 45 | 45 | <?php esc_html_e('Below the Messenger title, is a list of different contexts. The context label varies for each message type but it is usually labelled "Recipients". You can click on each context title to go to the specific template for that context and edit it as desired.', 'event_espresso'); ?> |
| 46 | 46 | </li> |
| 47 | 47 | </ul> |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <h2><?php esc_html_e('What are Message Types?', 'event_espresso'); ?></h2> |
| 2 | -<p><?php printf( esc_html__('Message Types are the %1$skinds%2$s of messages that get delivered. Think of them as the "type" of package that is being delivered by the messenger. For example, Event Espresso comes with two Message Types attached to the Email messenger: Registration Confirmation (which is triggered by frontend event registrations), and Payment Confirmation (which is triggered by frontend payments).', 'event_espresso'), '<em>', '</em>'); ?></p> |
|
| 2 | +<p><?php printf(esc_html__('Message Types are the %1$skinds%2$s of messages that get delivered. Think of them as the "type" of package that is being delivered by the messenger. For example, Event Espresso comes with two Message Types attached to the Email messenger: Registration Confirmation (which is triggered by frontend event registrations), and Payment Confirmation (which is triggered by frontend payments).', 'event_espresso'), '<em>', '</em>'); ?></p> |
|
| 3 | 3 | <p><?php esc_html_e('Future iterations of Event Espresso 4.0 (premium versions), will include more and more different message types that can be attached to the various messengers that are available', 'event_espresso'); ?></p> |
| 4 | 4 | |
| 5 | 5 | <h3><?php esc_html_e('Contexts', 'event_espresso'); ?></h3> |
| 6 | -<p><?php printf( esc_html__('Each message type (or %1$skind%1$s of message remember!) has different contexts for messages created for that message type. Contexts are dynamic but generally speaking they tend to represent recipients. So for example, Registration Confirmation message type has three types of recipients for every time a registration confirmation is triggered: Event Administrator, Primary Registrant, and Registrant (which may be multiple messages if there are more than one attendee per event). Whereas the Payment Message Type only has two recipients (Event Administrator, Primary Registrant [the one making the payment]).', 'event_espresso' ), '<em>', '</em>'); ?></p> |
|
| 6 | +<p><?php printf(esc_html__('Each message type (or %1$skind%1$s of message remember!) has different contexts for messages created for that message type. Contexts are dynamic but generally speaking they tend to represent recipients. So for example, Registration Confirmation message type has three types of recipients for every time a registration confirmation is triggered: Event Administrator, Primary Registrant, and Registrant (which may be multiple messages if there are more than one attendee per event). Whereas the Payment Message Type only has two recipients (Event Administrator, Primary Registrant [the one making the payment]).', 'event_espresso'), '<em>', '</em>'); ?></p> |
|
| 7 | 7 | <p><?php esc_html_e('You will most likely never see the word "context" in any of the Messages system labelling because they are dynamic per message type. Usually, contexts will be labelled "Recipients" but there may be cases down the road where a message type might use contexts to represent something totally different', 'event_espresso'); ?></p> |
| 8 | 8 | \ No newline at end of file |
@@ -1,15 +1,15 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | //echo '<br/><h6 style="color:#2EA2CC;">'. __FILE__ . ' <span style="font-weight:normal;color:#E76700"> Line #: ' . __LINE__ . '</span></h6>'; |
| 3 | 3 | |
| 4 | -if ( is_single() || ( is_archive() && espresso_display_datetimes_in_event_list() ) ) : |
|
| 4 | +if (is_single() || (is_archive() && espresso_display_datetimes_in_event_list())) : |
|
| 5 | 5 | global $post; |
| 6 | -do_action( 'AHEE_event_details_before_event_date', $post ); |
|
| 6 | +do_action('AHEE_event_details_before_event_date', $post); |
|
| 7 | 7 | ?> |
| 8 | 8 | <div class="event-datetimes"> |
| 9 | - <?php espresso_list_of_event_dates( $post->ID );?> |
|
| 9 | + <?php espresso_list_of_event_dates($post->ID); ?> |
|
| 10 | 10 | </div> |
| 11 | 11 | <!-- .event-datetimes --> |
| 12 | 12 | <?php |
| 13 | -do_action( 'AHEE_event_details_after_event_date', $post ); |
|
| 13 | +do_action('AHEE_event_details_after_event_date', $post); |
|
| 14 | 14 | endif; |
| 15 | 15 | ?> |
| 16 | 16 | \ No newline at end of file |
@@ -1247,7 +1247,7 @@ |
||
| 1247 | 1247 | /** |
| 1248 | 1248 | * Sets up the limit for the registrations query. |
| 1249 | 1249 | * |
| 1250 | - * @param $per_page |
|
| 1250 | + * @param integer $per_page |
|
| 1251 | 1251 | * @return array |
| 1252 | 1252 | */ |
| 1253 | 1253 | protected function _get_limit($per_page) |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | |
@@ -23,1831 +23,1831 @@ discard block |
||
| 23 | 23 | class Registrations_Admin_Page extends EE_Admin_Page_CPT |
| 24 | 24 | { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var EE_Registration |
|
| 28 | - */ |
|
| 29 | - private $_registration; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @var EE_Event |
|
| 33 | - */ |
|
| 34 | - private $_reg_event; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @var EE_Session |
|
| 38 | - */ |
|
| 39 | - private $_session; |
|
| 40 | - |
|
| 41 | - private static $_reg_status; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Form for displaying the custom questions for this registration. |
|
| 45 | - * This gets used a few times throughout the request so its best to cache it |
|
| 46 | - * |
|
| 47 | - * @var EE_Registration_Custom_Questions_Form |
|
| 48 | - */ |
|
| 49 | - protected $_reg_custom_questions_form = null; |
|
| 50 | - |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * constructor |
|
| 54 | - * |
|
| 55 | - * @Constructor |
|
| 56 | - * @access public |
|
| 57 | - * @param bool $routing |
|
| 58 | - * @return Registrations_Admin_Page |
|
| 59 | - */ |
|
| 60 | - public function __construct($routing = true) |
|
| 61 | - { |
|
| 62 | - parent::__construct($routing); |
|
| 63 | - add_action('wp_loaded', array($this, 'wp_loaded')); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - public function wp_loaded() |
|
| 68 | - { |
|
| 69 | - // when adding a new registration... |
|
| 70 | - if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') { |
|
| 71 | - EE_System::do_not_cache(); |
|
| 72 | - if ( ! isset($this->_req_data['processing_registration']) |
|
| 73 | - || absint($this->_req_data['processing_registration']) !== 1 |
|
| 74 | - ) { |
|
| 75 | - // and it's NOT the attendee information reg step |
|
| 76 | - // force cookie expiration by setting time to last week |
|
| 77 | - setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/'); |
|
| 78 | - // and update the global |
|
| 79 | - $_COOKIE['ee_registration_added'] = 0; |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - protected function _init_page_props() |
|
| 86 | - { |
|
| 87 | - $this->page_slug = REG_PG_SLUG; |
|
| 88 | - $this->_admin_base_url = REG_ADMIN_URL; |
|
| 89 | - $this->_admin_base_path = REG_ADMIN; |
|
| 90 | - $this->page_label = __('Registrations', 'event_espresso'); |
|
| 91 | - $this->_cpt_routes = array( |
|
| 92 | - 'add_new_attendee' => 'espresso_attendees', |
|
| 93 | - 'edit_attendee' => 'espresso_attendees', |
|
| 94 | - 'insert_attendee' => 'espresso_attendees', |
|
| 95 | - 'update_attendee' => 'espresso_attendees', |
|
| 96 | - ); |
|
| 97 | - $this->_cpt_model_names = array( |
|
| 98 | - 'add_new_attendee' => 'EEM_Attendee', |
|
| 99 | - 'edit_attendee' => 'EEM_Attendee', |
|
| 100 | - ); |
|
| 101 | - $this->_cpt_edit_routes = array( |
|
| 102 | - 'espresso_attendees' => 'edit_attendee', |
|
| 103 | - ); |
|
| 104 | - $this->_pagenow_map = array( |
|
| 105 | - 'add_new_attendee' => 'post-new.php', |
|
| 106 | - 'edit_attendee' => 'post.php', |
|
| 107 | - 'trash' => 'post.php', |
|
| 108 | - ); |
|
| 109 | - add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10); |
|
| 110 | - //add filters so that the comment urls don't take users to a confusing 404 page |
|
| 111 | - add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - |
|
| 115 | - public function clear_comment_link($link, $comment, $args) |
|
| 116 | - { |
|
| 117 | - //gotta make sure this only happens on this route |
|
| 118 | - $post_type = get_post_type($comment->comment_post_ID); |
|
| 119 | - if ($post_type === 'espresso_attendees') { |
|
| 120 | - return '#commentsdiv'; |
|
| 121 | - } |
|
| 122 | - return $link; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - |
|
| 126 | - protected function _ajax_hooks() |
|
| 127 | - { |
|
| 128 | - //todo: all hooks for registrations ajax goes in here |
|
| 129 | - add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status')); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - |
|
| 133 | - protected function _define_page_props() |
|
| 134 | - { |
|
| 135 | - $this->_admin_page_title = $this->page_label; |
|
| 136 | - $this->_labels = array( |
|
| 137 | - 'buttons' => array( |
|
| 138 | - 'add-registrant' => __('Add New Registration', 'event_espresso'), |
|
| 139 | - 'add-attendee' => __('Add Contact', 'event_espresso'), |
|
| 140 | - 'edit' => __('Edit Contact', 'event_espresso'), |
|
| 141 | - 'report' => __("Event Registrations CSV Report", "event_espresso"), |
|
| 142 | - 'report_all' => __('All Registrations CSV Report', 'event_espresso'), |
|
| 143 | - 'report_filtered' => __('Filtered CSV Report', 'event_espresso'), |
|
| 144 | - 'contact_list_report' => __('Contact List Report', 'event_espresso'), |
|
| 145 | - 'contact_list_export' => __("Export Data", "event_espresso"), |
|
| 146 | - ), |
|
| 147 | - 'publishbox' => array( |
|
| 148 | - 'add_new_attendee' => __("Add Contact Record", 'event_espresso'), |
|
| 149 | - 'edit_attendee' => __("Update Contact Record", 'event_espresso'), |
|
| 150 | - ), |
|
| 151 | - 'hide_add_button_on_cpt_route' => array( |
|
| 152 | - 'edit_attendee' => true, |
|
| 153 | - ), |
|
| 154 | - ); |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * grab url requests and route them |
|
| 160 | - * |
|
| 161 | - * @access private |
|
| 162 | - * @return void |
|
| 163 | - */ |
|
| 164 | - public function _set_page_routes() |
|
| 165 | - { |
|
| 166 | - $this->_get_registration_status_array(); |
|
| 167 | - $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
| 168 | - ? $this->_req_data['_REG_ID'] : 0; |
|
| 169 | - $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID']) |
|
| 170 | - ? $this->_req_data['ATT_ID'] : 0; |
|
| 171 | - $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) ? $this->_req_data['post'] |
|
| 172 | - : $att_id; |
|
| 173 | - $this->_page_routes = array( |
|
| 174 | - 'default' => array( |
|
| 175 | - 'func' => '_registrations_overview_list_table', |
|
| 176 | - 'capability' => 'ee_read_registrations', |
|
| 177 | - ), |
|
| 178 | - 'view_registration' => array( |
|
| 179 | - 'func' => '_registration_details', |
|
| 180 | - 'capability' => 'ee_read_registration', |
|
| 181 | - 'obj_id' => $reg_id, |
|
| 182 | - ), |
|
| 183 | - 'edit_registration' => array( |
|
| 184 | - 'func' => '_update_attendee_registration_form', |
|
| 185 | - 'noheader' => true, |
|
| 186 | - 'headers_sent_route' => 'view_registration', |
|
| 187 | - 'capability' => 'ee_edit_registration', |
|
| 188 | - 'obj_id' => $reg_id, |
|
| 189 | - '_REG_ID' => $reg_id, |
|
| 190 | - ), |
|
| 191 | - 'trash_registrations' => array( |
|
| 192 | - 'func' => '_trash_or_restore_registrations', |
|
| 193 | - 'args' => array('trash' => true), |
|
| 194 | - 'noheader' => true, |
|
| 195 | - 'capability' => 'ee_delete_registrations', |
|
| 196 | - ), |
|
| 197 | - 'restore_registrations' => array( |
|
| 198 | - 'func' => '_trash_or_restore_registrations', |
|
| 199 | - 'args' => array('trash' => false), |
|
| 200 | - 'noheader' => true, |
|
| 201 | - 'capability' => 'ee_delete_registrations', |
|
| 202 | - ), |
|
| 203 | - 'delete_registrations' => array( |
|
| 204 | - 'func' => '_delete_registrations', |
|
| 205 | - 'noheader' => true, |
|
| 206 | - 'capability' => 'ee_delete_registrations', |
|
| 207 | - ), |
|
| 208 | - 'new_registration' => array( |
|
| 209 | - 'func' => 'new_registration', |
|
| 210 | - 'capability' => 'ee_edit_registrations', |
|
| 211 | - ), |
|
| 212 | - 'process_reg_step' => array( |
|
| 213 | - 'func' => 'process_reg_step', |
|
| 214 | - 'noheader' => true, |
|
| 215 | - 'capability' => 'ee_edit_registrations', |
|
| 216 | - ), |
|
| 217 | - 'redirect_to_txn' => array( |
|
| 218 | - 'func' => 'redirect_to_txn', |
|
| 219 | - 'noheader' => true, |
|
| 220 | - 'capability' => 'ee_edit_registrations', |
|
| 221 | - ), |
|
| 222 | - 'change_reg_status' => array( |
|
| 223 | - 'func' => '_change_reg_status', |
|
| 224 | - 'noheader' => true, |
|
| 225 | - 'capability' => 'ee_edit_registration', |
|
| 226 | - 'obj_id' => $reg_id, |
|
| 227 | - ), |
|
| 228 | - 'approve_registration' => array( |
|
| 229 | - 'func' => 'approve_registration', |
|
| 230 | - 'noheader' => true, |
|
| 231 | - 'capability' => 'ee_edit_registration', |
|
| 232 | - 'obj_id' => $reg_id, |
|
| 233 | - ), |
|
| 234 | - 'approve_and_notify_registration' => array( |
|
| 235 | - 'func' => 'approve_registration', |
|
| 236 | - 'noheader' => true, |
|
| 237 | - 'args' => array(true), |
|
| 238 | - 'capability' => 'ee_edit_registration', |
|
| 239 | - 'obj_id' => $reg_id, |
|
| 240 | - ), |
|
| 241 | - 'decline_registration' => array( |
|
| 242 | - 'func' => 'decline_registration', |
|
| 243 | - 'noheader' => true, |
|
| 244 | - 'capability' => 'ee_edit_registration', |
|
| 245 | - 'obj_id' => $reg_id, |
|
| 246 | - ), |
|
| 247 | - 'decline_and_notify_registration' => array( |
|
| 248 | - 'func' => 'decline_registration', |
|
| 249 | - 'noheader' => true, |
|
| 250 | - 'args' => array(true), |
|
| 251 | - 'capability' => 'ee_edit_registration', |
|
| 252 | - 'obj_id' => $reg_id, |
|
| 253 | - ), |
|
| 254 | - 'pending_registration' => array( |
|
| 255 | - 'func' => 'pending_registration', |
|
| 256 | - 'noheader' => true, |
|
| 257 | - 'capability' => 'ee_edit_registration', |
|
| 258 | - 'obj_id' => $reg_id, |
|
| 259 | - ), |
|
| 260 | - 'pending_and_notify_registration' => array( |
|
| 261 | - 'func' => 'pending_registration', |
|
| 262 | - 'noheader' => true, |
|
| 263 | - 'args' => array(true), |
|
| 264 | - 'capability' => 'ee_edit_registration', |
|
| 265 | - 'obj_id' => $reg_id, |
|
| 266 | - ), |
|
| 267 | - 'no_approve_registration' => array( |
|
| 268 | - 'func' => 'not_approve_registration', |
|
| 269 | - 'noheader' => true, |
|
| 270 | - 'capability' => 'ee_edit_registration', |
|
| 271 | - 'obj_id' => $reg_id, |
|
| 272 | - ), |
|
| 273 | - 'no_approve_and_notify_registration' => array( |
|
| 274 | - 'func' => 'not_approve_registration', |
|
| 275 | - 'noheader' => true, |
|
| 276 | - 'args' => array(true), |
|
| 277 | - 'capability' => 'ee_edit_registration', |
|
| 278 | - 'obj_id' => $reg_id, |
|
| 279 | - ), |
|
| 280 | - 'cancel_registration' => array( |
|
| 281 | - 'func' => 'cancel_registration', |
|
| 282 | - 'noheader' => true, |
|
| 283 | - 'capability' => 'ee_edit_registration', |
|
| 284 | - 'obj_id' => $reg_id, |
|
| 285 | - ), |
|
| 286 | - 'cancel_and_notify_registration' => array( |
|
| 287 | - 'func' => 'cancel_registration', |
|
| 288 | - 'noheader' => true, |
|
| 289 | - 'args' => array(true), |
|
| 290 | - 'capability' => 'ee_edit_registration', |
|
| 291 | - 'obj_id' => $reg_id, |
|
| 292 | - ), |
|
| 293 | - 'contact_list' => array( |
|
| 294 | - 'func' => '_attendee_contact_list_table', |
|
| 295 | - 'capability' => 'ee_read_contacts', |
|
| 296 | - ), |
|
| 297 | - 'add_new_attendee' => array( |
|
| 298 | - 'func' => '_create_new_cpt_item', |
|
| 299 | - 'args' => array( |
|
| 300 | - 'new_attendee' => true, |
|
| 301 | - 'capability' => 'ee_edit_contacts', |
|
| 302 | - ), |
|
| 303 | - ), |
|
| 304 | - 'edit_attendee' => array( |
|
| 305 | - 'func' => '_edit_cpt_item', |
|
| 306 | - 'capability' => 'ee_edit_contacts', |
|
| 307 | - 'obj_id' => $att_id, |
|
| 308 | - ), |
|
| 309 | - 'duplicate_attendee' => array( |
|
| 310 | - 'func' => '_duplicate_attendee', |
|
| 311 | - 'noheader' => true, |
|
| 312 | - 'capability' => 'ee_edit_contacts', |
|
| 313 | - 'obj_id' => $att_id, |
|
| 314 | - ), |
|
| 315 | - 'insert_attendee' => array( |
|
| 316 | - 'func' => '_insert_or_update_attendee', |
|
| 317 | - 'args' => array( |
|
| 318 | - 'new_attendee' => true, |
|
| 319 | - ), |
|
| 320 | - 'noheader' => true, |
|
| 321 | - 'capability' => 'ee_edit_contacts', |
|
| 322 | - ), |
|
| 323 | - 'update_attendee' => array( |
|
| 324 | - 'func' => '_insert_or_update_attendee', |
|
| 325 | - 'args' => array( |
|
| 326 | - 'new_attendee' => false, |
|
| 327 | - ), |
|
| 328 | - 'noheader' => true, |
|
| 329 | - 'capability' => 'ee_edit_contacts', |
|
| 330 | - 'obj_id' => $att_id, |
|
| 331 | - ), |
|
| 332 | - 'trash_attendees' => array( |
|
| 333 | - 'func' => '_trash_or_restore_attendees', |
|
| 334 | - 'args' => array( |
|
| 335 | - 'trash' => true, |
|
| 336 | - ), |
|
| 337 | - 'noheader' => true, |
|
| 338 | - 'capability' => 'ee_delete_contacts', |
|
| 339 | - 'obj_id' => $att_id, |
|
| 340 | - ), |
|
| 341 | - 'restore_attendees' => array( |
|
| 342 | - 'func' => '_trash_or_restore_attendees', |
|
| 343 | - 'args' => array( |
|
| 344 | - 'trash' => false, |
|
| 345 | - ), |
|
| 346 | - 'noheader' => true, |
|
| 347 | - 'capability' => 'ee_delete_contacts', |
|
| 348 | - 'obj_id' => $att_id, |
|
| 349 | - ), |
|
| 350 | - 'resend_registration' => array( |
|
| 351 | - 'func' => '_resend_registration', |
|
| 352 | - 'noheader' => true, |
|
| 353 | - 'capability' => 'ee_send_message', |
|
| 354 | - ), |
|
| 355 | - 'registrations_report' => array( |
|
| 356 | - 'func' => '_registrations_report', |
|
| 357 | - 'noheader' => true, |
|
| 358 | - 'capability' => 'ee_read_registrations', |
|
| 359 | - ), |
|
| 360 | - 'contact_list_export' => array( |
|
| 361 | - 'func' => '_contact_list_export', |
|
| 362 | - 'noheader' => true, |
|
| 363 | - 'capability' => 'export', |
|
| 364 | - ), |
|
| 365 | - 'contact_list_report' => array( |
|
| 366 | - 'func' => '_contact_list_report', |
|
| 367 | - 'noheader' => true, |
|
| 368 | - 'capability' => 'ee_read_contacts', |
|
| 369 | - ), |
|
| 370 | - ); |
|
| 371 | - } |
|
| 372 | - |
|
| 373 | - |
|
| 374 | - protected function _set_page_config() |
|
| 375 | - { |
|
| 376 | - $this->_page_config = array( |
|
| 377 | - 'default' => array( |
|
| 378 | - 'nav' => array( |
|
| 379 | - 'label' => __('Overview', 'event_espresso'), |
|
| 380 | - 'order' => 5, |
|
| 381 | - ), |
|
| 382 | - 'help_tabs' => array( |
|
| 383 | - 'registrations_overview_help_tab' => array( |
|
| 384 | - 'title' => __('Registrations Overview', 'event_espresso'), |
|
| 385 | - 'filename' => 'registrations_overview', |
|
| 386 | - ), |
|
| 387 | - 'registrations_overview_table_column_headings_help_tab' => array( |
|
| 388 | - 'title' => __('Registrations Table Column Headings', 'event_espresso'), |
|
| 389 | - 'filename' => 'registrations_overview_table_column_headings', |
|
| 390 | - ), |
|
| 391 | - 'registrations_overview_filters_help_tab' => array( |
|
| 392 | - 'title' => __('Registration Filters', 'event_espresso'), |
|
| 393 | - 'filename' => 'registrations_overview_filters', |
|
| 394 | - ), |
|
| 395 | - 'registrations_overview_views_help_tab' => array( |
|
| 396 | - 'title' => __('Registration Views', 'event_espresso'), |
|
| 397 | - 'filename' => 'registrations_overview_views', |
|
| 398 | - ), |
|
| 399 | - 'registrations_regoverview_other_help_tab' => array( |
|
| 400 | - 'title' => __('Registrations Other', 'event_espresso'), |
|
| 401 | - 'filename' => 'registrations_overview_other', |
|
| 402 | - ), |
|
| 403 | - ), |
|
| 404 | - 'help_tour' => array('Registration_Overview_Help_Tour'), |
|
| 405 | - 'qtips' => array('Registration_List_Table_Tips'), |
|
| 406 | - 'list_table' => 'EE_Registrations_List_Table', |
|
| 407 | - 'require_nonce' => false, |
|
| 408 | - ), |
|
| 409 | - 'view_registration' => array( |
|
| 410 | - 'nav' => array( |
|
| 411 | - 'label' => __('REG Details', 'event_espresso'), |
|
| 412 | - 'order' => 15, |
|
| 413 | - 'url' => isset($this->_req_data['_REG_ID']) |
|
| 414 | - ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url) |
|
| 415 | - : $this->_admin_base_url, |
|
| 416 | - 'persistent' => false, |
|
| 417 | - ), |
|
| 418 | - 'help_tabs' => array( |
|
| 419 | - 'registrations_details_help_tab' => array( |
|
| 420 | - 'title' => __('Registration Details', 'event_espresso'), |
|
| 421 | - 'filename' => 'registrations_details', |
|
| 422 | - ), |
|
| 423 | - 'registrations_details_table_help_tab' => array( |
|
| 424 | - 'title' => __('Registration Details Table', 'event_espresso'), |
|
| 425 | - 'filename' => 'registrations_details_table', |
|
| 426 | - ), |
|
| 427 | - 'registrations_details_form_answers_help_tab' => array( |
|
| 428 | - 'title' => __('Registration Form Answers', 'event_espresso'), |
|
| 429 | - 'filename' => 'registrations_details_form_answers', |
|
| 430 | - ), |
|
| 431 | - 'registrations_details_registrant_details_help_tab' => array( |
|
| 432 | - 'title' => __('Contact Details', 'event_espresso'), |
|
| 433 | - 'filename' => 'registrations_details_registrant_details', |
|
| 434 | - ), |
|
| 435 | - ), |
|
| 436 | - 'help_tour' => array('Registration_Details_Help_Tour'), |
|
| 437 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, |
|
| 438 | - array('_registration_details_metaboxes')), |
|
| 439 | - 'require_nonce' => false, |
|
| 440 | - ), |
|
| 441 | - 'new_registration' => array( |
|
| 442 | - 'nav' => array( |
|
| 443 | - 'label' => __('Add New Registration', 'event_espresso'), |
|
| 444 | - 'url' => '#', |
|
| 445 | - 'order' => 15, |
|
| 446 | - 'persistent' => false, |
|
| 447 | - ), |
|
| 448 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 449 | - 'labels' => array( |
|
| 450 | - 'publishbox' => __('Save Registration', 'event_espresso'), |
|
| 451 | - ), |
|
| 452 | - 'require_nonce' => false, |
|
| 453 | - ), |
|
| 454 | - 'add_new_attendee' => array( |
|
| 455 | - 'nav' => array( |
|
| 456 | - 'label' => __('Add Contact', 'event_espresso'), |
|
| 457 | - 'order' => 15, |
|
| 458 | - 'persistent' => false, |
|
| 459 | - ), |
|
| 460 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, |
|
| 461 | - array('_publish_post_box', 'attendee_editor_metaboxes')), |
|
| 462 | - 'require_nonce' => false, |
|
| 463 | - ), |
|
| 464 | - 'edit_attendee' => array( |
|
| 465 | - 'nav' => array( |
|
| 466 | - 'label' => __('Edit Contact', 'event_espresso'), |
|
| 467 | - 'order' => 15, |
|
| 468 | - 'persistent' => false, |
|
| 469 | - 'url' => isset($this->_req_data['ATT_ID']) |
|
| 470 | - ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url) |
|
| 471 | - : $this->_admin_base_url, |
|
| 472 | - ), |
|
| 473 | - 'metaboxes' => array('attendee_editor_metaboxes'), |
|
| 474 | - 'require_nonce' => false, |
|
| 475 | - ), |
|
| 476 | - 'contact_list' => array( |
|
| 477 | - 'nav' => array( |
|
| 478 | - 'label' => __('Contact List', 'event_espresso'), |
|
| 479 | - 'order' => 20, |
|
| 480 | - ), |
|
| 481 | - 'list_table' => 'EE_Attendee_Contact_List_Table', |
|
| 482 | - 'help_tabs' => array( |
|
| 483 | - 'registrations_contact_list_help_tab' => array( |
|
| 484 | - 'title' => __('Registrations Contact List', 'event_espresso'), |
|
| 485 | - 'filename' => 'registrations_contact_list', |
|
| 486 | - ), |
|
| 487 | - 'registrations_contact-list_table_column_headings_help_tab' => array( |
|
| 488 | - 'title' => __('Contact List Table Column Headings', 'event_espresso'), |
|
| 489 | - 'filename' => 'registrations_contact_list_table_column_headings', |
|
| 490 | - ), |
|
| 491 | - 'registrations_contact_list_views_help_tab' => array( |
|
| 492 | - 'title' => __('Contact List Views', 'event_espresso'), |
|
| 493 | - 'filename' => 'registrations_contact_list_views', |
|
| 494 | - ), |
|
| 495 | - 'registrations_contact_list_other_help_tab' => array( |
|
| 496 | - 'title' => __('Contact List Other', 'event_espresso'), |
|
| 497 | - 'filename' => 'registrations_contact_list_other', |
|
| 498 | - ), |
|
| 499 | - ), |
|
| 500 | - 'help_tour' => array('Contact_List_Help_Tour'), |
|
| 501 | - 'metaboxes' => array(), |
|
| 502 | - 'require_nonce' => false, |
|
| 503 | - ), |
|
| 504 | - //override default cpt routes |
|
| 505 | - 'create_new' => '', |
|
| 506 | - 'edit' => '', |
|
| 507 | - ); |
|
| 508 | - } |
|
| 509 | - |
|
| 510 | - |
|
| 511 | - /** |
|
| 512 | - * The below methods aren't used by this class currently |
|
| 513 | - */ |
|
| 514 | - protected function _add_screen_options() |
|
| 515 | - { |
|
| 516 | - } |
|
| 517 | - |
|
| 518 | - |
|
| 519 | - protected function _add_feature_pointers() |
|
| 520 | - { |
|
| 521 | - } |
|
| 522 | - |
|
| 523 | - |
|
| 524 | - public function admin_init() |
|
| 525 | - { |
|
| 526 | - EE_Registry::$i18n_js_strings['update_att_qstns'] = __('click "Update Registration Questions" to save your changes', |
|
| 527 | - 'event_espresso'); |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - |
|
| 531 | - public function admin_notices() |
|
| 532 | - { |
|
| 533 | - } |
|
| 534 | - |
|
| 535 | - |
|
| 536 | - public function admin_footer_scripts() |
|
| 537 | - { |
|
| 538 | - } |
|
| 539 | - |
|
| 540 | - |
|
| 541 | - /** |
|
| 542 | - * get list of registration statuses |
|
| 543 | - * |
|
| 544 | - * @access private |
|
| 545 | - * @return void |
|
| 546 | - */ |
|
| 547 | - private function _get_registration_status_array() |
|
| 548 | - { |
|
| 549 | - self::$_reg_status = EEM_Registration::reg_status_array(array(), true); |
|
| 550 | - } |
|
| 551 | - |
|
| 552 | - |
|
| 553 | - protected function _add_screen_options_default() |
|
| 554 | - { |
|
| 555 | - $this->_per_page_screen_option(); |
|
| 556 | - } |
|
| 557 | - |
|
| 558 | - |
|
| 559 | - protected function _add_screen_options_contact_list() |
|
| 560 | - { |
|
| 561 | - $page_title = $this->_admin_page_title; |
|
| 562 | - $this->_admin_page_title = __("Contacts", 'event_espresso'); |
|
| 563 | - $this->_per_page_screen_option(); |
|
| 564 | - $this->_admin_page_title = $page_title; |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - |
|
| 568 | - public function load_scripts_styles() |
|
| 569 | - { |
|
| 570 | - //style |
|
| 571 | - //wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
| 572 | - wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'), |
|
| 573 | - EVENT_ESPRESSO_VERSION); |
|
| 574 | - wp_enqueue_style('espresso_reg'); |
|
| 575 | - //script |
|
| 576 | - wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js', |
|
| 577 | - array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, true); |
|
| 578 | - wp_enqueue_script('espresso_reg'); |
|
| 579 | - } |
|
| 580 | - |
|
| 581 | - |
|
| 582 | - public function load_scripts_styles_edit_attendee() |
|
| 583 | - { |
|
| 584 | - //stuff to only show up on our attendee edit details page. |
|
| 585 | - $attendee_details_translations = array( |
|
| 586 | - 'att_publish_text' => sprintf(__('Created on: <b>%1$s</b>', 'event_espresso'), |
|
| 587 | - $this->_cpt_model_obj->get_datetime('ATT_created')), |
|
| 588 | - ); |
|
| 589 | - wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations); |
|
| 590 | - wp_enqueue_script('jquery-validate'); |
|
| 591 | - } |
|
| 592 | - |
|
| 593 | - |
|
| 594 | - public function load_scripts_styles_view_registration() |
|
| 595 | - { |
|
| 596 | - //styles |
|
| 597 | - wp_enqueue_style('espresso-ui-theme'); |
|
| 598 | - //scripts |
|
| 599 | - $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
| 600 | - $this->_reg_custom_questions_form->wp_enqueue_scripts(true); |
|
| 601 | - } |
|
| 602 | - |
|
| 603 | - |
|
| 604 | - public function load_scripts_styles_contact_list() |
|
| 605 | - { |
|
| 606 | - wp_deregister_style('espresso_reg'); |
|
| 607 | - wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'), |
|
| 608 | - EVENT_ESPRESSO_VERSION); |
|
| 609 | - wp_enqueue_style('espresso_att'); |
|
| 610 | - } |
|
| 611 | - |
|
| 612 | - |
|
| 613 | - public function load_scripts_styles_new_registration() |
|
| 614 | - { |
|
| 615 | - wp_register_script('ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'), |
|
| 616 | - EVENT_ESPRESSO_VERSION, true); |
|
| 617 | - wp_enqueue_script('ee-spco-for-admin'); |
|
| 618 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 619 | - EE_Form_Section_Proper::wp_enqueue_scripts(); |
|
| 620 | - EED_Ticket_Selector::load_tckt_slctr_assets(); |
|
| 621 | - EE_Datepicker_Input::enqueue_styles_and_scripts(); |
|
| 622 | - } |
|
| 623 | - |
|
| 624 | - |
|
| 625 | - public function AHEE__EE_Admin_Page__route_admin_request_resend_registration() |
|
| 626 | - { |
|
| 627 | - add_filter('FHEE_load_EE_messages', '__return_true'); |
|
| 628 | - } |
|
| 629 | - |
|
| 630 | - |
|
| 631 | - public function AHEE__EE_Admin_Page__route_admin_request_approve_registration() |
|
| 632 | - { |
|
| 633 | - add_filter('FHEE_load_EE_messages', '__return_true'); |
|
| 634 | - } |
|
| 635 | - |
|
| 636 | - |
|
| 637 | - protected function _set_list_table_views_default() |
|
| 638 | - { |
|
| 639 | - //for notification related bulk actions we need to make sure only active messengers have an option. |
|
| 640 | - EED_Messages::set_autoloaders(); |
|
| 641 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
| 642 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 643 | - $active_mts = $message_resource_manager->list_of_active_message_types(); |
|
| 644 | - //key= bulk_action_slug, value= message type. |
|
| 645 | - $match_array = array( |
|
| 646 | - 'approve_registration' => 'registration', |
|
| 647 | - 'decline_registration' => 'declined_registration', |
|
| 648 | - 'pending_registration' => 'pending_approval', |
|
| 649 | - 'no_approve_registration' => 'not_approved_registration', |
|
| 650 | - 'cancel_registration' => 'cancelled_registration', |
|
| 651 | - ); |
|
| 652 | - /** setup reg status bulk actions **/ |
|
| 653 | - $def_reg_status_actions['approve_registration'] = __('Approve Registrations', 'event_espresso'); |
|
| 654 | - if (in_array($match_array['approve_registration'], $active_mts) |
|
| 655 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 656 | - ) { |
|
| 657 | - $def_reg_status_actions['approve_and_notify_registration'] = __('Approve and Notify Registrations', |
|
| 658 | - 'event_espresso'); |
|
| 659 | - } |
|
| 660 | - $def_reg_status_actions['decline_registration'] = __('Decline Registrations', 'event_espresso'); |
|
| 661 | - if (in_array($match_array['decline_registration'], $active_mts) |
|
| 662 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 663 | - ) { |
|
| 664 | - $def_reg_status_actions['decline_and_notify_registration'] = __('Decline and Notify Registrations', |
|
| 665 | - 'event_espresso'); |
|
| 666 | - } |
|
| 667 | - $def_reg_status_actions['pending_registration'] = __('Set Registrations to Pending Payment', 'event_espresso'); |
|
| 668 | - if (in_array($match_array['pending_registration'], $active_mts) |
|
| 669 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 670 | - ) { |
|
| 671 | - $def_reg_status_actions['pending_and_notify_registration'] = __('Set Registrations to Pending Payment and Notify', |
|
| 672 | - 'event_espresso'); |
|
| 673 | - } |
|
| 674 | - $def_reg_status_actions['no_approve_registration'] = __('Set Registrations to Not Approved', 'event_espresso'); |
|
| 675 | - if (in_array($match_array['no_approve_registration'], $active_mts) |
|
| 676 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 677 | - ) { |
|
| 678 | - $def_reg_status_actions['no_approve_and_notify_registration'] = __('Set Registrations to Not Approved and Notify', |
|
| 679 | - 'event_espresso'); |
|
| 680 | - } |
|
| 681 | - $def_reg_status_actions['cancel_registration'] = __('Cancel Registrations', 'event_espresso'); |
|
| 682 | - if (in_array($match_array['cancel_registration'], $active_mts) |
|
| 683 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 684 | - ) { |
|
| 685 | - $def_reg_status_actions['cancel_and_notify_registration'] = __('Cancel Registrations and Notify', |
|
| 686 | - 'event_espresso'); |
|
| 687 | - } |
|
| 688 | - $this->_views = array( |
|
| 689 | - 'all' => array( |
|
| 690 | - 'slug' => 'all', |
|
| 691 | - 'label' => __('View All Registrations', 'event_espresso'), |
|
| 692 | - 'count' => 0, |
|
| 693 | - 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 694 | - 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
| 695 | - )), |
|
| 696 | - ), |
|
| 697 | - 'month' => array( |
|
| 698 | - 'slug' => 'month', |
|
| 699 | - 'label' => __('This Month', 'event_espresso'), |
|
| 700 | - 'count' => 0, |
|
| 701 | - 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 702 | - 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
| 703 | - )), |
|
| 704 | - ), |
|
| 705 | - 'today' => array( |
|
| 706 | - 'slug' => 'today', |
|
| 707 | - 'label' => sprintf(__('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp'))), |
|
| 708 | - 'count' => 0, |
|
| 709 | - 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 710 | - 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
| 711 | - )), |
|
| 712 | - ), |
|
| 713 | - ); |
|
| 714 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', |
|
| 715 | - 'espresso_registrations_delete_registration') |
|
| 716 | - ) { |
|
| 717 | - $this->_views['incomplete'] = array( |
|
| 718 | - 'slug' => 'incomplete', |
|
| 719 | - 'label' => __('Incomplete', 'event_espresso'), |
|
| 720 | - 'count' => 0, |
|
| 721 | - 'bulk_action' => array( |
|
| 722 | - 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
| 723 | - ), |
|
| 724 | - ); |
|
| 725 | - $this->_views['trash'] = array( |
|
| 726 | - 'slug' => 'trash', |
|
| 727 | - 'label' => __('Trash', 'event_espresso'), |
|
| 728 | - 'count' => 0, |
|
| 729 | - 'bulk_action' => array( |
|
| 730 | - 'restore_registrations' => __('Restore Registrations', 'event_espresso'), |
|
| 731 | - 'delete_registrations' => __('Delete Registrations Permanently', 'event_espresso'), |
|
| 732 | - ), |
|
| 733 | - ); |
|
| 734 | - } |
|
| 735 | - } |
|
| 736 | - |
|
| 737 | - |
|
| 738 | - protected function _set_list_table_views_contact_list() |
|
| 739 | - { |
|
| 740 | - $this->_views = array( |
|
| 741 | - 'in_use' => array( |
|
| 742 | - 'slug' => 'in_use', |
|
| 743 | - 'label' => __('In Use', 'event_espresso'), |
|
| 744 | - 'count' => 0, |
|
| 745 | - 'bulk_action' => array( |
|
| 746 | - 'trash_attendees' => __('Move to Trash', 'event_espresso'), |
|
| 747 | - ), |
|
| 748 | - ), |
|
| 749 | - ); |
|
| 750 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', |
|
| 751 | - 'espresso_registrations_trash_attendees') |
|
| 752 | - ) { |
|
| 753 | - $this->_views['trash'] = array( |
|
| 754 | - 'slug' => 'trash', |
|
| 755 | - 'label' => __('Trash', 'event_espresso'), |
|
| 756 | - 'count' => 0, |
|
| 757 | - 'bulk_action' => array( |
|
| 758 | - 'restore_attendees' => __('Restore from Trash', 'event_espresso'), |
|
| 759 | - ), |
|
| 760 | - ); |
|
| 761 | - } |
|
| 762 | - } |
|
| 763 | - |
|
| 764 | - |
|
| 765 | - protected function _registration_legend_items() |
|
| 766 | - { |
|
| 767 | - $fc_items = array( |
|
| 768 | - 'star-icon' => array( |
|
| 769 | - 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
| 770 | - 'desc' => __('This is the Primary Registrant', 'event_espresso'), |
|
| 771 | - ), |
|
| 772 | - 'view_details' => array( |
|
| 773 | - 'class' => 'dashicons dashicons-clipboard', |
|
| 774 | - 'desc' => __('View Registration Details', 'event_espresso'), |
|
| 775 | - ), |
|
| 776 | - 'edit_attendee' => array( |
|
| 777 | - 'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16', |
|
| 778 | - 'desc' => __('Edit Contact Details', 'event_espresso'), |
|
| 779 | - ), |
|
| 780 | - 'view_transaction' => array( |
|
| 781 | - 'class' => 'dashicons dashicons-cart', |
|
| 782 | - 'desc' => __('View Transaction Details', 'event_espresso'), |
|
| 783 | - ), |
|
| 784 | - 'view_invoice' => array( |
|
| 785 | - 'class' => 'dashicons dashicons-media-spreadsheet', |
|
| 786 | - 'desc' => __('View Transaction Invoice', 'event_espresso'), |
|
| 787 | - ), |
|
| 788 | - ); |
|
| 789 | - if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
| 790 | - 'espresso_registrations_resend_registration') |
|
| 791 | - ) { |
|
| 792 | - $fc_items['resend_registration'] = array( |
|
| 793 | - 'class' => 'dashicons dashicons-email-alt', |
|
| 794 | - 'desc' => __('Resend Registration Details', 'event_espresso'), |
|
| 795 | - ); |
|
| 796 | - } else { |
|
| 797 | - $fc_items['blank'] = array('class' => 'blank', 'desc' => ''); |
|
| 798 | - } |
|
| 799 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
| 800 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
| 801 | - if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
| 802 | - $fc_items['view_related_messages'] = array( |
|
| 803 | - 'class' => $related_for_icon['css_class'], |
|
| 804 | - 'desc' => $related_for_icon['label'], |
|
| 805 | - ); |
|
| 806 | - } |
|
| 807 | - } |
|
| 808 | - $sc_items = array( |
|
| 809 | - 'approved_status' => array( |
|
| 810 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 811 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
| 812 | - ), |
|
| 813 | - 'pending_status' => array( |
|
| 814 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 815 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
| 816 | - ), |
|
| 817 | - 'wait_list' => array( |
|
| 818 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 819 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
| 820 | - ), |
|
| 821 | - 'incomplete_status' => array( |
|
| 822 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete, |
|
| 823 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_incomplete, false, 'sentence'), |
|
| 824 | - ), |
|
| 825 | - 'not_approved' => array( |
|
| 826 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 827 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
| 828 | - ), |
|
| 829 | - 'declined_status' => array( |
|
| 830 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 831 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
| 832 | - ), |
|
| 833 | - 'cancelled_status' => array( |
|
| 834 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 835 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
| 836 | - ), |
|
| 837 | - ); |
|
| 838 | - return array_merge($fc_items, $sc_items); |
|
| 839 | - } |
|
| 840 | - |
|
| 841 | - |
|
| 842 | - |
|
| 843 | - /*************************************** REGISTRATION OVERVIEW **************************************/ |
|
| 844 | - /** |
|
| 845 | - * @throws \EE_Error |
|
| 846 | - */ |
|
| 847 | - protected function _registrations_overview_list_table() |
|
| 848 | - { |
|
| 849 | - $this->_template_args['admin_page_header'] = ''; |
|
| 850 | - $EVT_ID = ! empty($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0; |
|
| 851 | - if ($EVT_ID) { |
|
| 852 | - if (EE_Registry::instance()->CAP->current_user_can('ee_edit_registrations', |
|
| 853 | - 'espresso_registrations_new_registration', $EVT_ID) |
|
| 854 | - ) { |
|
| 855 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button('new_registration', 'add-registrant', |
|
| 856 | - array('event_id' => $EVT_ID), 'add-new-h2'); |
|
| 857 | - } |
|
| 858 | - $event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 859 | - if ($event instanceof EE_Event) { |
|
| 860 | - $this->_template_args['admin_page_header'] = sprintf(__('%s Viewing registrations for the event: %s%s', |
|
| 861 | - 'event_espresso'), '<h3 style="line-height:1.5em;">', |
|
| 862 | - '<br /><a href="' . EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 863 | - 'action' => 'edit', |
|
| 864 | - 'post' => $event->ID(), |
|
| 865 | - ), EVENTS_ADMIN_URL) . '"> ' . $event->get('EVT_name') . ' </a> ', '</h3>'); |
|
| 866 | - } |
|
| 867 | - $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0; |
|
| 868 | - $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 869 | - if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') { |
|
| 870 | - $this->_template_args['admin_page_header'] = substr($this->_template_args['admin_page_header'], 0, -5); |
|
| 871 | - $this->_template_args['admin_page_header'] .= ' <span class="drk-grey-text">'; |
|
| 872 | - $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
| 873 | - $this->_template_args['admin_page_header'] .= $datetime->name(); |
|
| 874 | - $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )'; |
|
| 875 | - $this->_template_args['admin_page_header'] .= '</span></h3>'; |
|
| 876 | - } |
|
| 877 | - } |
|
| 878 | - $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items()); |
|
| 879 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 880 | - } |
|
| 881 | - |
|
| 882 | - |
|
| 883 | - /** |
|
| 884 | - * This sets the _registration property for the registration details screen |
|
| 885 | - * |
|
| 886 | - * @access private |
|
| 887 | - * @return bool |
|
| 888 | - */ |
|
| 889 | - private function _set_registration_object() |
|
| 890 | - { |
|
| 891 | - //get out if we've already set the object |
|
| 892 | - if (is_object($this->_registration)) { |
|
| 893 | - return true; |
|
| 894 | - } |
|
| 895 | - $REG = EEM_Registration::instance(); |
|
| 896 | - $REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false; |
|
| 897 | - if ($this->_registration = $REG->get_one_by_ID($REG_ID)) { |
|
| 898 | - return true; |
|
| 899 | - } else { |
|
| 900 | - $error_msg = sprintf(__('An error occurred and the details for Registration ID #%s could not be retrieved.', |
|
| 901 | - 'event_espresso'), $REG_ID); |
|
| 902 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 903 | - $this->_registration = null; |
|
| 904 | - return false; |
|
| 905 | - } |
|
| 906 | - } |
|
| 907 | - |
|
| 908 | - |
|
| 909 | - /** |
|
| 910 | - * Used to retrieve registrations for the list table. |
|
| 911 | - * |
|
| 912 | - * @param int $per_page |
|
| 913 | - * @param bool $count |
|
| 914 | - * @param bool $this_month |
|
| 915 | - * @param bool $today |
|
| 916 | - * @return \EE_Registration[]|int |
|
| 917 | - */ |
|
| 918 | - public function get_registrations( |
|
| 919 | - $per_page = 10, |
|
| 920 | - $count = false, |
|
| 921 | - $this_month = false, |
|
| 922 | - $today = false |
|
| 923 | - ) { |
|
| 924 | - if( $this_month ) { |
|
| 925 | - $this->_req_data['status'] = 'month'; |
|
| 926 | - } |
|
| 927 | - if( $today ) { |
|
| 928 | - $this->_req_data['status'] = 'today'; |
|
| 929 | - } |
|
| 930 | - $query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count); |
|
| 931 | - return $count |
|
| 932 | - ? EEM_Registration::instance()->count($query_params) |
|
| 933 | - /** @type EE_Registration[] */ |
|
| 934 | - : EEM_Registration::instance()->get_all($query_params); |
|
| 935 | - } |
|
| 936 | - |
|
| 937 | - |
|
| 938 | - |
|
| 939 | - /** |
|
| 940 | - * Retrieves the query parameters to be used by the Registration model for getting registrations. |
|
| 941 | - * Note: this listens to values on the request for some of the query parameters. |
|
| 942 | - * |
|
| 943 | - * @param array $request |
|
| 944 | - * @param int $per_page |
|
| 945 | - * @param bool $count |
|
| 946 | - * @return array |
|
| 947 | - */ |
|
| 948 | - protected function _get_registration_query_parameters( |
|
| 949 | - $request = array(), |
|
| 950 | - $per_page = 10, |
|
| 951 | - $count = false |
|
| 952 | - ) { |
|
| 953 | - |
|
| 954 | - $query_params = array( |
|
| 955 | - 0 => $this->_get_where_conditions_for_registrations_query( |
|
| 956 | - $request |
|
| 957 | - ), |
|
| 958 | - 'caps' => EEM_Registration::caps_read_admin, |
|
| 959 | - 'default_where_conditions' => 'this_model_only', |
|
| 960 | - ); |
|
| 961 | - if ( ! $count) { |
|
| 962 | - $query_params = array_merge( |
|
| 963 | - $query_params, |
|
| 964 | - $this->_get_orderby_for_registrations_query(), |
|
| 965 | - $this->_get_limit($per_page) |
|
| 966 | - ); |
|
| 967 | - } |
|
| 968 | - |
|
| 969 | - return $query_params; |
|
| 970 | - } |
|
| 971 | - |
|
| 972 | - |
|
| 973 | - /** |
|
| 974 | - * This will add EVT_ID to the provided $where array for EE model query parameters. |
|
| 975 | - * |
|
| 976 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 977 | - * @return array |
|
| 978 | - */ |
|
| 979 | - protected function _add_event_id_to_where_conditions(array $request) |
|
| 980 | - { |
|
| 981 | - $where = array(); |
|
| 982 | - if ( ! empty($request['event_id'])) { |
|
| 983 | - $where['EVT_ID'] = absint($request['event_id']); |
|
| 984 | - } |
|
| 985 | - return $where; |
|
| 986 | - } |
|
| 987 | - |
|
| 988 | - |
|
| 989 | - /** |
|
| 990 | - * Adds category ID if it exists in the request to the where conditions for the registrations query. |
|
| 991 | - * |
|
| 992 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 993 | - * @return array |
|
| 994 | - */ |
|
| 995 | - protected function _add_category_id_to_where_conditions(array $request) |
|
| 996 | - { |
|
| 997 | - $where = array(); |
|
| 998 | - if ( ! empty($request['EVT_CAT']) && (int)$request['EVT_CAT'] !== -1) { |
|
| 999 | - $where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']); |
|
| 1000 | - } |
|
| 1001 | - return $where; |
|
| 1002 | - } |
|
| 1003 | - |
|
| 1004 | - |
|
| 1005 | - /** |
|
| 1006 | - * Adds the datetime ID if it exists in the request to the where conditions for the registrations query. |
|
| 1007 | - * |
|
| 1008 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1009 | - * @return array |
|
| 1010 | - */ |
|
| 1011 | - protected function _add_datetime_id_to_where_conditions(array $request) |
|
| 1012 | - { |
|
| 1013 | - $where = array(); |
|
| 1014 | - if ( ! empty($request['datetime_id'])) { |
|
| 1015 | - $where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']); |
|
| 1016 | - } |
|
| 1017 | - if( ! empty($request['DTT_ID'])){ |
|
| 1018 | - $where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']); |
|
| 1019 | - } |
|
| 1020 | - return $where; |
|
| 1021 | - } |
|
| 1022 | - |
|
| 1023 | - |
|
| 1024 | - /** |
|
| 1025 | - * Adds the correct registration status to the where conditions for the registrations query. |
|
| 1026 | - * |
|
| 1027 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1028 | - * @return array |
|
| 1029 | - */ |
|
| 1030 | - protected function _add_registration_status_to_where_conditions(array $request) |
|
| 1031 | - { |
|
| 1032 | - $where = array(); |
|
| 1033 | - $view = EEH_Array::is_set( $request, 'status', '' ); |
|
| 1034 | - $registration_status = ! empty($request['_reg_status']) |
|
| 1035 | - ? sanitize_text_field($request['_reg_status']) |
|
| 1036 | - : ''; |
|
| 1037 | - |
|
| 1038 | - /* |
|
| 26 | + /** |
|
| 27 | + * @var EE_Registration |
|
| 28 | + */ |
|
| 29 | + private $_registration; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @var EE_Event |
|
| 33 | + */ |
|
| 34 | + private $_reg_event; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @var EE_Session |
|
| 38 | + */ |
|
| 39 | + private $_session; |
|
| 40 | + |
|
| 41 | + private static $_reg_status; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Form for displaying the custom questions for this registration. |
|
| 45 | + * This gets used a few times throughout the request so its best to cache it |
|
| 46 | + * |
|
| 47 | + * @var EE_Registration_Custom_Questions_Form |
|
| 48 | + */ |
|
| 49 | + protected $_reg_custom_questions_form = null; |
|
| 50 | + |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * constructor |
|
| 54 | + * |
|
| 55 | + * @Constructor |
|
| 56 | + * @access public |
|
| 57 | + * @param bool $routing |
|
| 58 | + * @return Registrations_Admin_Page |
|
| 59 | + */ |
|
| 60 | + public function __construct($routing = true) |
|
| 61 | + { |
|
| 62 | + parent::__construct($routing); |
|
| 63 | + add_action('wp_loaded', array($this, 'wp_loaded')); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + public function wp_loaded() |
|
| 68 | + { |
|
| 69 | + // when adding a new registration... |
|
| 70 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') { |
|
| 71 | + EE_System::do_not_cache(); |
|
| 72 | + if ( ! isset($this->_req_data['processing_registration']) |
|
| 73 | + || absint($this->_req_data['processing_registration']) !== 1 |
|
| 74 | + ) { |
|
| 75 | + // and it's NOT the attendee information reg step |
|
| 76 | + // force cookie expiration by setting time to last week |
|
| 77 | + setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/'); |
|
| 78 | + // and update the global |
|
| 79 | + $_COOKIE['ee_registration_added'] = 0; |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + protected function _init_page_props() |
|
| 86 | + { |
|
| 87 | + $this->page_slug = REG_PG_SLUG; |
|
| 88 | + $this->_admin_base_url = REG_ADMIN_URL; |
|
| 89 | + $this->_admin_base_path = REG_ADMIN; |
|
| 90 | + $this->page_label = __('Registrations', 'event_espresso'); |
|
| 91 | + $this->_cpt_routes = array( |
|
| 92 | + 'add_new_attendee' => 'espresso_attendees', |
|
| 93 | + 'edit_attendee' => 'espresso_attendees', |
|
| 94 | + 'insert_attendee' => 'espresso_attendees', |
|
| 95 | + 'update_attendee' => 'espresso_attendees', |
|
| 96 | + ); |
|
| 97 | + $this->_cpt_model_names = array( |
|
| 98 | + 'add_new_attendee' => 'EEM_Attendee', |
|
| 99 | + 'edit_attendee' => 'EEM_Attendee', |
|
| 100 | + ); |
|
| 101 | + $this->_cpt_edit_routes = array( |
|
| 102 | + 'espresso_attendees' => 'edit_attendee', |
|
| 103 | + ); |
|
| 104 | + $this->_pagenow_map = array( |
|
| 105 | + 'add_new_attendee' => 'post-new.php', |
|
| 106 | + 'edit_attendee' => 'post.php', |
|
| 107 | + 'trash' => 'post.php', |
|
| 108 | + ); |
|
| 109 | + add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10); |
|
| 110 | + //add filters so that the comment urls don't take users to a confusing 404 page |
|
| 111 | + add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + |
|
| 115 | + public function clear_comment_link($link, $comment, $args) |
|
| 116 | + { |
|
| 117 | + //gotta make sure this only happens on this route |
|
| 118 | + $post_type = get_post_type($comment->comment_post_ID); |
|
| 119 | + if ($post_type === 'espresso_attendees') { |
|
| 120 | + return '#commentsdiv'; |
|
| 121 | + } |
|
| 122 | + return $link; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + |
|
| 126 | + protected function _ajax_hooks() |
|
| 127 | + { |
|
| 128 | + //todo: all hooks for registrations ajax goes in here |
|
| 129 | + add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status')); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + |
|
| 133 | + protected function _define_page_props() |
|
| 134 | + { |
|
| 135 | + $this->_admin_page_title = $this->page_label; |
|
| 136 | + $this->_labels = array( |
|
| 137 | + 'buttons' => array( |
|
| 138 | + 'add-registrant' => __('Add New Registration', 'event_espresso'), |
|
| 139 | + 'add-attendee' => __('Add Contact', 'event_espresso'), |
|
| 140 | + 'edit' => __('Edit Contact', 'event_espresso'), |
|
| 141 | + 'report' => __("Event Registrations CSV Report", "event_espresso"), |
|
| 142 | + 'report_all' => __('All Registrations CSV Report', 'event_espresso'), |
|
| 143 | + 'report_filtered' => __('Filtered CSV Report', 'event_espresso'), |
|
| 144 | + 'contact_list_report' => __('Contact List Report', 'event_espresso'), |
|
| 145 | + 'contact_list_export' => __("Export Data", "event_espresso"), |
|
| 146 | + ), |
|
| 147 | + 'publishbox' => array( |
|
| 148 | + 'add_new_attendee' => __("Add Contact Record", 'event_espresso'), |
|
| 149 | + 'edit_attendee' => __("Update Contact Record", 'event_espresso'), |
|
| 150 | + ), |
|
| 151 | + 'hide_add_button_on_cpt_route' => array( |
|
| 152 | + 'edit_attendee' => true, |
|
| 153 | + ), |
|
| 154 | + ); |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * grab url requests and route them |
|
| 160 | + * |
|
| 161 | + * @access private |
|
| 162 | + * @return void |
|
| 163 | + */ |
|
| 164 | + public function _set_page_routes() |
|
| 165 | + { |
|
| 166 | + $this->_get_registration_status_array(); |
|
| 167 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
| 168 | + ? $this->_req_data['_REG_ID'] : 0; |
|
| 169 | + $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID']) |
|
| 170 | + ? $this->_req_data['ATT_ID'] : 0; |
|
| 171 | + $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) ? $this->_req_data['post'] |
|
| 172 | + : $att_id; |
|
| 173 | + $this->_page_routes = array( |
|
| 174 | + 'default' => array( |
|
| 175 | + 'func' => '_registrations_overview_list_table', |
|
| 176 | + 'capability' => 'ee_read_registrations', |
|
| 177 | + ), |
|
| 178 | + 'view_registration' => array( |
|
| 179 | + 'func' => '_registration_details', |
|
| 180 | + 'capability' => 'ee_read_registration', |
|
| 181 | + 'obj_id' => $reg_id, |
|
| 182 | + ), |
|
| 183 | + 'edit_registration' => array( |
|
| 184 | + 'func' => '_update_attendee_registration_form', |
|
| 185 | + 'noheader' => true, |
|
| 186 | + 'headers_sent_route' => 'view_registration', |
|
| 187 | + 'capability' => 'ee_edit_registration', |
|
| 188 | + 'obj_id' => $reg_id, |
|
| 189 | + '_REG_ID' => $reg_id, |
|
| 190 | + ), |
|
| 191 | + 'trash_registrations' => array( |
|
| 192 | + 'func' => '_trash_or_restore_registrations', |
|
| 193 | + 'args' => array('trash' => true), |
|
| 194 | + 'noheader' => true, |
|
| 195 | + 'capability' => 'ee_delete_registrations', |
|
| 196 | + ), |
|
| 197 | + 'restore_registrations' => array( |
|
| 198 | + 'func' => '_trash_or_restore_registrations', |
|
| 199 | + 'args' => array('trash' => false), |
|
| 200 | + 'noheader' => true, |
|
| 201 | + 'capability' => 'ee_delete_registrations', |
|
| 202 | + ), |
|
| 203 | + 'delete_registrations' => array( |
|
| 204 | + 'func' => '_delete_registrations', |
|
| 205 | + 'noheader' => true, |
|
| 206 | + 'capability' => 'ee_delete_registrations', |
|
| 207 | + ), |
|
| 208 | + 'new_registration' => array( |
|
| 209 | + 'func' => 'new_registration', |
|
| 210 | + 'capability' => 'ee_edit_registrations', |
|
| 211 | + ), |
|
| 212 | + 'process_reg_step' => array( |
|
| 213 | + 'func' => 'process_reg_step', |
|
| 214 | + 'noheader' => true, |
|
| 215 | + 'capability' => 'ee_edit_registrations', |
|
| 216 | + ), |
|
| 217 | + 'redirect_to_txn' => array( |
|
| 218 | + 'func' => 'redirect_to_txn', |
|
| 219 | + 'noheader' => true, |
|
| 220 | + 'capability' => 'ee_edit_registrations', |
|
| 221 | + ), |
|
| 222 | + 'change_reg_status' => array( |
|
| 223 | + 'func' => '_change_reg_status', |
|
| 224 | + 'noheader' => true, |
|
| 225 | + 'capability' => 'ee_edit_registration', |
|
| 226 | + 'obj_id' => $reg_id, |
|
| 227 | + ), |
|
| 228 | + 'approve_registration' => array( |
|
| 229 | + 'func' => 'approve_registration', |
|
| 230 | + 'noheader' => true, |
|
| 231 | + 'capability' => 'ee_edit_registration', |
|
| 232 | + 'obj_id' => $reg_id, |
|
| 233 | + ), |
|
| 234 | + 'approve_and_notify_registration' => array( |
|
| 235 | + 'func' => 'approve_registration', |
|
| 236 | + 'noheader' => true, |
|
| 237 | + 'args' => array(true), |
|
| 238 | + 'capability' => 'ee_edit_registration', |
|
| 239 | + 'obj_id' => $reg_id, |
|
| 240 | + ), |
|
| 241 | + 'decline_registration' => array( |
|
| 242 | + 'func' => 'decline_registration', |
|
| 243 | + 'noheader' => true, |
|
| 244 | + 'capability' => 'ee_edit_registration', |
|
| 245 | + 'obj_id' => $reg_id, |
|
| 246 | + ), |
|
| 247 | + 'decline_and_notify_registration' => array( |
|
| 248 | + 'func' => 'decline_registration', |
|
| 249 | + 'noheader' => true, |
|
| 250 | + 'args' => array(true), |
|
| 251 | + 'capability' => 'ee_edit_registration', |
|
| 252 | + 'obj_id' => $reg_id, |
|
| 253 | + ), |
|
| 254 | + 'pending_registration' => array( |
|
| 255 | + 'func' => 'pending_registration', |
|
| 256 | + 'noheader' => true, |
|
| 257 | + 'capability' => 'ee_edit_registration', |
|
| 258 | + 'obj_id' => $reg_id, |
|
| 259 | + ), |
|
| 260 | + 'pending_and_notify_registration' => array( |
|
| 261 | + 'func' => 'pending_registration', |
|
| 262 | + 'noheader' => true, |
|
| 263 | + 'args' => array(true), |
|
| 264 | + 'capability' => 'ee_edit_registration', |
|
| 265 | + 'obj_id' => $reg_id, |
|
| 266 | + ), |
|
| 267 | + 'no_approve_registration' => array( |
|
| 268 | + 'func' => 'not_approve_registration', |
|
| 269 | + 'noheader' => true, |
|
| 270 | + 'capability' => 'ee_edit_registration', |
|
| 271 | + 'obj_id' => $reg_id, |
|
| 272 | + ), |
|
| 273 | + 'no_approve_and_notify_registration' => array( |
|
| 274 | + 'func' => 'not_approve_registration', |
|
| 275 | + 'noheader' => true, |
|
| 276 | + 'args' => array(true), |
|
| 277 | + 'capability' => 'ee_edit_registration', |
|
| 278 | + 'obj_id' => $reg_id, |
|
| 279 | + ), |
|
| 280 | + 'cancel_registration' => array( |
|
| 281 | + 'func' => 'cancel_registration', |
|
| 282 | + 'noheader' => true, |
|
| 283 | + 'capability' => 'ee_edit_registration', |
|
| 284 | + 'obj_id' => $reg_id, |
|
| 285 | + ), |
|
| 286 | + 'cancel_and_notify_registration' => array( |
|
| 287 | + 'func' => 'cancel_registration', |
|
| 288 | + 'noheader' => true, |
|
| 289 | + 'args' => array(true), |
|
| 290 | + 'capability' => 'ee_edit_registration', |
|
| 291 | + 'obj_id' => $reg_id, |
|
| 292 | + ), |
|
| 293 | + 'contact_list' => array( |
|
| 294 | + 'func' => '_attendee_contact_list_table', |
|
| 295 | + 'capability' => 'ee_read_contacts', |
|
| 296 | + ), |
|
| 297 | + 'add_new_attendee' => array( |
|
| 298 | + 'func' => '_create_new_cpt_item', |
|
| 299 | + 'args' => array( |
|
| 300 | + 'new_attendee' => true, |
|
| 301 | + 'capability' => 'ee_edit_contacts', |
|
| 302 | + ), |
|
| 303 | + ), |
|
| 304 | + 'edit_attendee' => array( |
|
| 305 | + 'func' => '_edit_cpt_item', |
|
| 306 | + 'capability' => 'ee_edit_contacts', |
|
| 307 | + 'obj_id' => $att_id, |
|
| 308 | + ), |
|
| 309 | + 'duplicate_attendee' => array( |
|
| 310 | + 'func' => '_duplicate_attendee', |
|
| 311 | + 'noheader' => true, |
|
| 312 | + 'capability' => 'ee_edit_contacts', |
|
| 313 | + 'obj_id' => $att_id, |
|
| 314 | + ), |
|
| 315 | + 'insert_attendee' => array( |
|
| 316 | + 'func' => '_insert_or_update_attendee', |
|
| 317 | + 'args' => array( |
|
| 318 | + 'new_attendee' => true, |
|
| 319 | + ), |
|
| 320 | + 'noheader' => true, |
|
| 321 | + 'capability' => 'ee_edit_contacts', |
|
| 322 | + ), |
|
| 323 | + 'update_attendee' => array( |
|
| 324 | + 'func' => '_insert_or_update_attendee', |
|
| 325 | + 'args' => array( |
|
| 326 | + 'new_attendee' => false, |
|
| 327 | + ), |
|
| 328 | + 'noheader' => true, |
|
| 329 | + 'capability' => 'ee_edit_contacts', |
|
| 330 | + 'obj_id' => $att_id, |
|
| 331 | + ), |
|
| 332 | + 'trash_attendees' => array( |
|
| 333 | + 'func' => '_trash_or_restore_attendees', |
|
| 334 | + 'args' => array( |
|
| 335 | + 'trash' => true, |
|
| 336 | + ), |
|
| 337 | + 'noheader' => true, |
|
| 338 | + 'capability' => 'ee_delete_contacts', |
|
| 339 | + 'obj_id' => $att_id, |
|
| 340 | + ), |
|
| 341 | + 'restore_attendees' => array( |
|
| 342 | + 'func' => '_trash_or_restore_attendees', |
|
| 343 | + 'args' => array( |
|
| 344 | + 'trash' => false, |
|
| 345 | + ), |
|
| 346 | + 'noheader' => true, |
|
| 347 | + 'capability' => 'ee_delete_contacts', |
|
| 348 | + 'obj_id' => $att_id, |
|
| 349 | + ), |
|
| 350 | + 'resend_registration' => array( |
|
| 351 | + 'func' => '_resend_registration', |
|
| 352 | + 'noheader' => true, |
|
| 353 | + 'capability' => 'ee_send_message', |
|
| 354 | + ), |
|
| 355 | + 'registrations_report' => array( |
|
| 356 | + 'func' => '_registrations_report', |
|
| 357 | + 'noheader' => true, |
|
| 358 | + 'capability' => 'ee_read_registrations', |
|
| 359 | + ), |
|
| 360 | + 'contact_list_export' => array( |
|
| 361 | + 'func' => '_contact_list_export', |
|
| 362 | + 'noheader' => true, |
|
| 363 | + 'capability' => 'export', |
|
| 364 | + ), |
|
| 365 | + 'contact_list_report' => array( |
|
| 366 | + 'func' => '_contact_list_report', |
|
| 367 | + 'noheader' => true, |
|
| 368 | + 'capability' => 'ee_read_contacts', |
|
| 369 | + ), |
|
| 370 | + ); |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + |
|
| 374 | + protected function _set_page_config() |
|
| 375 | + { |
|
| 376 | + $this->_page_config = array( |
|
| 377 | + 'default' => array( |
|
| 378 | + 'nav' => array( |
|
| 379 | + 'label' => __('Overview', 'event_espresso'), |
|
| 380 | + 'order' => 5, |
|
| 381 | + ), |
|
| 382 | + 'help_tabs' => array( |
|
| 383 | + 'registrations_overview_help_tab' => array( |
|
| 384 | + 'title' => __('Registrations Overview', 'event_espresso'), |
|
| 385 | + 'filename' => 'registrations_overview', |
|
| 386 | + ), |
|
| 387 | + 'registrations_overview_table_column_headings_help_tab' => array( |
|
| 388 | + 'title' => __('Registrations Table Column Headings', 'event_espresso'), |
|
| 389 | + 'filename' => 'registrations_overview_table_column_headings', |
|
| 390 | + ), |
|
| 391 | + 'registrations_overview_filters_help_tab' => array( |
|
| 392 | + 'title' => __('Registration Filters', 'event_espresso'), |
|
| 393 | + 'filename' => 'registrations_overview_filters', |
|
| 394 | + ), |
|
| 395 | + 'registrations_overview_views_help_tab' => array( |
|
| 396 | + 'title' => __('Registration Views', 'event_espresso'), |
|
| 397 | + 'filename' => 'registrations_overview_views', |
|
| 398 | + ), |
|
| 399 | + 'registrations_regoverview_other_help_tab' => array( |
|
| 400 | + 'title' => __('Registrations Other', 'event_espresso'), |
|
| 401 | + 'filename' => 'registrations_overview_other', |
|
| 402 | + ), |
|
| 403 | + ), |
|
| 404 | + 'help_tour' => array('Registration_Overview_Help_Tour'), |
|
| 405 | + 'qtips' => array('Registration_List_Table_Tips'), |
|
| 406 | + 'list_table' => 'EE_Registrations_List_Table', |
|
| 407 | + 'require_nonce' => false, |
|
| 408 | + ), |
|
| 409 | + 'view_registration' => array( |
|
| 410 | + 'nav' => array( |
|
| 411 | + 'label' => __('REG Details', 'event_espresso'), |
|
| 412 | + 'order' => 15, |
|
| 413 | + 'url' => isset($this->_req_data['_REG_ID']) |
|
| 414 | + ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url) |
|
| 415 | + : $this->_admin_base_url, |
|
| 416 | + 'persistent' => false, |
|
| 417 | + ), |
|
| 418 | + 'help_tabs' => array( |
|
| 419 | + 'registrations_details_help_tab' => array( |
|
| 420 | + 'title' => __('Registration Details', 'event_espresso'), |
|
| 421 | + 'filename' => 'registrations_details', |
|
| 422 | + ), |
|
| 423 | + 'registrations_details_table_help_tab' => array( |
|
| 424 | + 'title' => __('Registration Details Table', 'event_espresso'), |
|
| 425 | + 'filename' => 'registrations_details_table', |
|
| 426 | + ), |
|
| 427 | + 'registrations_details_form_answers_help_tab' => array( |
|
| 428 | + 'title' => __('Registration Form Answers', 'event_espresso'), |
|
| 429 | + 'filename' => 'registrations_details_form_answers', |
|
| 430 | + ), |
|
| 431 | + 'registrations_details_registrant_details_help_tab' => array( |
|
| 432 | + 'title' => __('Contact Details', 'event_espresso'), |
|
| 433 | + 'filename' => 'registrations_details_registrant_details', |
|
| 434 | + ), |
|
| 435 | + ), |
|
| 436 | + 'help_tour' => array('Registration_Details_Help_Tour'), |
|
| 437 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, |
|
| 438 | + array('_registration_details_metaboxes')), |
|
| 439 | + 'require_nonce' => false, |
|
| 440 | + ), |
|
| 441 | + 'new_registration' => array( |
|
| 442 | + 'nav' => array( |
|
| 443 | + 'label' => __('Add New Registration', 'event_espresso'), |
|
| 444 | + 'url' => '#', |
|
| 445 | + 'order' => 15, |
|
| 446 | + 'persistent' => false, |
|
| 447 | + ), |
|
| 448 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 449 | + 'labels' => array( |
|
| 450 | + 'publishbox' => __('Save Registration', 'event_espresso'), |
|
| 451 | + ), |
|
| 452 | + 'require_nonce' => false, |
|
| 453 | + ), |
|
| 454 | + 'add_new_attendee' => array( |
|
| 455 | + 'nav' => array( |
|
| 456 | + 'label' => __('Add Contact', 'event_espresso'), |
|
| 457 | + 'order' => 15, |
|
| 458 | + 'persistent' => false, |
|
| 459 | + ), |
|
| 460 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, |
|
| 461 | + array('_publish_post_box', 'attendee_editor_metaboxes')), |
|
| 462 | + 'require_nonce' => false, |
|
| 463 | + ), |
|
| 464 | + 'edit_attendee' => array( |
|
| 465 | + 'nav' => array( |
|
| 466 | + 'label' => __('Edit Contact', 'event_espresso'), |
|
| 467 | + 'order' => 15, |
|
| 468 | + 'persistent' => false, |
|
| 469 | + 'url' => isset($this->_req_data['ATT_ID']) |
|
| 470 | + ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url) |
|
| 471 | + : $this->_admin_base_url, |
|
| 472 | + ), |
|
| 473 | + 'metaboxes' => array('attendee_editor_metaboxes'), |
|
| 474 | + 'require_nonce' => false, |
|
| 475 | + ), |
|
| 476 | + 'contact_list' => array( |
|
| 477 | + 'nav' => array( |
|
| 478 | + 'label' => __('Contact List', 'event_espresso'), |
|
| 479 | + 'order' => 20, |
|
| 480 | + ), |
|
| 481 | + 'list_table' => 'EE_Attendee_Contact_List_Table', |
|
| 482 | + 'help_tabs' => array( |
|
| 483 | + 'registrations_contact_list_help_tab' => array( |
|
| 484 | + 'title' => __('Registrations Contact List', 'event_espresso'), |
|
| 485 | + 'filename' => 'registrations_contact_list', |
|
| 486 | + ), |
|
| 487 | + 'registrations_contact-list_table_column_headings_help_tab' => array( |
|
| 488 | + 'title' => __('Contact List Table Column Headings', 'event_espresso'), |
|
| 489 | + 'filename' => 'registrations_contact_list_table_column_headings', |
|
| 490 | + ), |
|
| 491 | + 'registrations_contact_list_views_help_tab' => array( |
|
| 492 | + 'title' => __('Contact List Views', 'event_espresso'), |
|
| 493 | + 'filename' => 'registrations_contact_list_views', |
|
| 494 | + ), |
|
| 495 | + 'registrations_contact_list_other_help_tab' => array( |
|
| 496 | + 'title' => __('Contact List Other', 'event_espresso'), |
|
| 497 | + 'filename' => 'registrations_contact_list_other', |
|
| 498 | + ), |
|
| 499 | + ), |
|
| 500 | + 'help_tour' => array('Contact_List_Help_Tour'), |
|
| 501 | + 'metaboxes' => array(), |
|
| 502 | + 'require_nonce' => false, |
|
| 503 | + ), |
|
| 504 | + //override default cpt routes |
|
| 505 | + 'create_new' => '', |
|
| 506 | + 'edit' => '', |
|
| 507 | + ); |
|
| 508 | + } |
|
| 509 | + |
|
| 510 | + |
|
| 511 | + /** |
|
| 512 | + * The below methods aren't used by this class currently |
|
| 513 | + */ |
|
| 514 | + protected function _add_screen_options() |
|
| 515 | + { |
|
| 516 | + } |
|
| 517 | + |
|
| 518 | + |
|
| 519 | + protected function _add_feature_pointers() |
|
| 520 | + { |
|
| 521 | + } |
|
| 522 | + |
|
| 523 | + |
|
| 524 | + public function admin_init() |
|
| 525 | + { |
|
| 526 | + EE_Registry::$i18n_js_strings['update_att_qstns'] = __('click "Update Registration Questions" to save your changes', |
|
| 527 | + 'event_espresso'); |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + |
|
| 531 | + public function admin_notices() |
|
| 532 | + { |
|
| 533 | + } |
|
| 534 | + |
|
| 535 | + |
|
| 536 | + public function admin_footer_scripts() |
|
| 537 | + { |
|
| 538 | + } |
|
| 539 | + |
|
| 540 | + |
|
| 541 | + /** |
|
| 542 | + * get list of registration statuses |
|
| 543 | + * |
|
| 544 | + * @access private |
|
| 545 | + * @return void |
|
| 546 | + */ |
|
| 547 | + private function _get_registration_status_array() |
|
| 548 | + { |
|
| 549 | + self::$_reg_status = EEM_Registration::reg_status_array(array(), true); |
|
| 550 | + } |
|
| 551 | + |
|
| 552 | + |
|
| 553 | + protected function _add_screen_options_default() |
|
| 554 | + { |
|
| 555 | + $this->_per_page_screen_option(); |
|
| 556 | + } |
|
| 557 | + |
|
| 558 | + |
|
| 559 | + protected function _add_screen_options_contact_list() |
|
| 560 | + { |
|
| 561 | + $page_title = $this->_admin_page_title; |
|
| 562 | + $this->_admin_page_title = __("Contacts", 'event_espresso'); |
|
| 563 | + $this->_per_page_screen_option(); |
|
| 564 | + $this->_admin_page_title = $page_title; |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + |
|
| 568 | + public function load_scripts_styles() |
|
| 569 | + { |
|
| 570 | + //style |
|
| 571 | + //wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
| 572 | + wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'), |
|
| 573 | + EVENT_ESPRESSO_VERSION); |
|
| 574 | + wp_enqueue_style('espresso_reg'); |
|
| 575 | + //script |
|
| 576 | + wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js', |
|
| 577 | + array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, true); |
|
| 578 | + wp_enqueue_script('espresso_reg'); |
|
| 579 | + } |
|
| 580 | + |
|
| 581 | + |
|
| 582 | + public function load_scripts_styles_edit_attendee() |
|
| 583 | + { |
|
| 584 | + //stuff to only show up on our attendee edit details page. |
|
| 585 | + $attendee_details_translations = array( |
|
| 586 | + 'att_publish_text' => sprintf(__('Created on: <b>%1$s</b>', 'event_espresso'), |
|
| 587 | + $this->_cpt_model_obj->get_datetime('ATT_created')), |
|
| 588 | + ); |
|
| 589 | + wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations); |
|
| 590 | + wp_enqueue_script('jquery-validate'); |
|
| 591 | + } |
|
| 592 | + |
|
| 593 | + |
|
| 594 | + public function load_scripts_styles_view_registration() |
|
| 595 | + { |
|
| 596 | + //styles |
|
| 597 | + wp_enqueue_style('espresso-ui-theme'); |
|
| 598 | + //scripts |
|
| 599 | + $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
| 600 | + $this->_reg_custom_questions_form->wp_enqueue_scripts(true); |
|
| 601 | + } |
|
| 602 | + |
|
| 603 | + |
|
| 604 | + public function load_scripts_styles_contact_list() |
|
| 605 | + { |
|
| 606 | + wp_deregister_style('espresso_reg'); |
|
| 607 | + wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'), |
|
| 608 | + EVENT_ESPRESSO_VERSION); |
|
| 609 | + wp_enqueue_style('espresso_att'); |
|
| 610 | + } |
|
| 611 | + |
|
| 612 | + |
|
| 613 | + public function load_scripts_styles_new_registration() |
|
| 614 | + { |
|
| 615 | + wp_register_script('ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'), |
|
| 616 | + EVENT_ESPRESSO_VERSION, true); |
|
| 617 | + wp_enqueue_script('ee-spco-for-admin'); |
|
| 618 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 619 | + EE_Form_Section_Proper::wp_enqueue_scripts(); |
|
| 620 | + EED_Ticket_Selector::load_tckt_slctr_assets(); |
|
| 621 | + EE_Datepicker_Input::enqueue_styles_and_scripts(); |
|
| 622 | + } |
|
| 623 | + |
|
| 624 | + |
|
| 625 | + public function AHEE__EE_Admin_Page__route_admin_request_resend_registration() |
|
| 626 | + { |
|
| 627 | + add_filter('FHEE_load_EE_messages', '__return_true'); |
|
| 628 | + } |
|
| 629 | + |
|
| 630 | + |
|
| 631 | + public function AHEE__EE_Admin_Page__route_admin_request_approve_registration() |
|
| 632 | + { |
|
| 633 | + add_filter('FHEE_load_EE_messages', '__return_true'); |
|
| 634 | + } |
|
| 635 | + |
|
| 636 | + |
|
| 637 | + protected function _set_list_table_views_default() |
|
| 638 | + { |
|
| 639 | + //for notification related bulk actions we need to make sure only active messengers have an option. |
|
| 640 | + EED_Messages::set_autoloaders(); |
|
| 641 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
| 642 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 643 | + $active_mts = $message_resource_manager->list_of_active_message_types(); |
|
| 644 | + //key= bulk_action_slug, value= message type. |
|
| 645 | + $match_array = array( |
|
| 646 | + 'approve_registration' => 'registration', |
|
| 647 | + 'decline_registration' => 'declined_registration', |
|
| 648 | + 'pending_registration' => 'pending_approval', |
|
| 649 | + 'no_approve_registration' => 'not_approved_registration', |
|
| 650 | + 'cancel_registration' => 'cancelled_registration', |
|
| 651 | + ); |
|
| 652 | + /** setup reg status bulk actions **/ |
|
| 653 | + $def_reg_status_actions['approve_registration'] = __('Approve Registrations', 'event_espresso'); |
|
| 654 | + if (in_array($match_array['approve_registration'], $active_mts) |
|
| 655 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 656 | + ) { |
|
| 657 | + $def_reg_status_actions['approve_and_notify_registration'] = __('Approve and Notify Registrations', |
|
| 658 | + 'event_espresso'); |
|
| 659 | + } |
|
| 660 | + $def_reg_status_actions['decline_registration'] = __('Decline Registrations', 'event_espresso'); |
|
| 661 | + if (in_array($match_array['decline_registration'], $active_mts) |
|
| 662 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 663 | + ) { |
|
| 664 | + $def_reg_status_actions['decline_and_notify_registration'] = __('Decline and Notify Registrations', |
|
| 665 | + 'event_espresso'); |
|
| 666 | + } |
|
| 667 | + $def_reg_status_actions['pending_registration'] = __('Set Registrations to Pending Payment', 'event_espresso'); |
|
| 668 | + if (in_array($match_array['pending_registration'], $active_mts) |
|
| 669 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 670 | + ) { |
|
| 671 | + $def_reg_status_actions['pending_and_notify_registration'] = __('Set Registrations to Pending Payment and Notify', |
|
| 672 | + 'event_espresso'); |
|
| 673 | + } |
|
| 674 | + $def_reg_status_actions['no_approve_registration'] = __('Set Registrations to Not Approved', 'event_espresso'); |
|
| 675 | + if (in_array($match_array['no_approve_registration'], $active_mts) |
|
| 676 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 677 | + ) { |
|
| 678 | + $def_reg_status_actions['no_approve_and_notify_registration'] = __('Set Registrations to Not Approved and Notify', |
|
| 679 | + 'event_espresso'); |
|
| 680 | + } |
|
| 681 | + $def_reg_status_actions['cancel_registration'] = __('Cancel Registrations', 'event_espresso'); |
|
| 682 | + if (in_array($match_array['cancel_registration'], $active_mts) |
|
| 683 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
| 684 | + ) { |
|
| 685 | + $def_reg_status_actions['cancel_and_notify_registration'] = __('Cancel Registrations and Notify', |
|
| 686 | + 'event_espresso'); |
|
| 687 | + } |
|
| 688 | + $this->_views = array( |
|
| 689 | + 'all' => array( |
|
| 690 | + 'slug' => 'all', |
|
| 691 | + 'label' => __('View All Registrations', 'event_espresso'), |
|
| 692 | + 'count' => 0, |
|
| 693 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 694 | + 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
| 695 | + )), |
|
| 696 | + ), |
|
| 697 | + 'month' => array( |
|
| 698 | + 'slug' => 'month', |
|
| 699 | + 'label' => __('This Month', 'event_espresso'), |
|
| 700 | + 'count' => 0, |
|
| 701 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 702 | + 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
| 703 | + )), |
|
| 704 | + ), |
|
| 705 | + 'today' => array( |
|
| 706 | + 'slug' => 'today', |
|
| 707 | + 'label' => sprintf(__('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp'))), |
|
| 708 | + 'count' => 0, |
|
| 709 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
| 710 | + 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
| 711 | + )), |
|
| 712 | + ), |
|
| 713 | + ); |
|
| 714 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', |
|
| 715 | + 'espresso_registrations_delete_registration') |
|
| 716 | + ) { |
|
| 717 | + $this->_views['incomplete'] = array( |
|
| 718 | + 'slug' => 'incomplete', |
|
| 719 | + 'label' => __('Incomplete', 'event_espresso'), |
|
| 720 | + 'count' => 0, |
|
| 721 | + 'bulk_action' => array( |
|
| 722 | + 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
| 723 | + ), |
|
| 724 | + ); |
|
| 725 | + $this->_views['trash'] = array( |
|
| 726 | + 'slug' => 'trash', |
|
| 727 | + 'label' => __('Trash', 'event_espresso'), |
|
| 728 | + 'count' => 0, |
|
| 729 | + 'bulk_action' => array( |
|
| 730 | + 'restore_registrations' => __('Restore Registrations', 'event_espresso'), |
|
| 731 | + 'delete_registrations' => __('Delete Registrations Permanently', 'event_espresso'), |
|
| 732 | + ), |
|
| 733 | + ); |
|
| 734 | + } |
|
| 735 | + } |
|
| 736 | + |
|
| 737 | + |
|
| 738 | + protected function _set_list_table_views_contact_list() |
|
| 739 | + { |
|
| 740 | + $this->_views = array( |
|
| 741 | + 'in_use' => array( |
|
| 742 | + 'slug' => 'in_use', |
|
| 743 | + 'label' => __('In Use', 'event_espresso'), |
|
| 744 | + 'count' => 0, |
|
| 745 | + 'bulk_action' => array( |
|
| 746 | + 'trash_attendees' => __('Move to Trash', 'event_espresso'), |
|
| 747 | + ), |
|
| 748 | + ), |
|
| 749 | + ); |
|
| 750 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', |
|
| 751 | + 'espresso_registrations_trash_attendees') |
|
| 752 | + ) { |
|
| 753 | + $this->_views['trash'] = array( |
|
| 754 | + 'slug' => 'trash', |
|
| 755 | + 'label' => __('Trash', 'event_espresso'), |
|
| 756 | + 'count' => 0, |
|
| 757 | + 'bulk_action' => array( |
|
| 758 | + 'restore_attendees' => __('Restore from Trash', 'event_espresso'), |
|
| 759 | + ), |
|
| 760 | + ); |
|
| 761 | + } |
|
| 762 | + } |
|
| 763 | + |
|
| 764 | + |
|
| 765 | + protected function _registration_legend_items() |
|
| 766 | + { |
|
| 767 | + $fc_items = array( |
|
| 768 | + 'star-icon' => array( |
|
| 769 | + 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
| 770 | + 'desc' => __('This is the Primary Registrant', 'event_espresso'), |
|
| 771 | + ), |
|
| 772 | + 'view_details' => array( |
|
| 773 | + 'class' => 'dashicons dashicons-clipboard', |
|
| 774 | + 'desc' => __('View Registration Details', 'event_espresso'), |
|
| 775 | + ), |
|
| 776 | + 'edit_attendee' => array( |
|
| 777 | + 'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16', |
|
| 778 | + 'desc' => __('Edit Contact Details', 'event_espresso'), |
|
| 779 | + ), |
|
| 780 | + 'view_transaction' => array( |
|
| 781 | + 'class' => 'dashicons dashicons-cart', |
|
| 782 | + 'desc' => __('View Transaction Details', 'event_espresso'), |
|
| 783 | + ), |
|
| 784 | + 'view_invoice' => array( |
|
| 785 | + 'class' => 'dashicons dashicons-media-spreadsheet', |
|
| 786 | + 'desc' => __('View Transaction Invoice', 'event_espresso'), |
|
| 787 | + ), |
|
| 788 | + ); |
|
| 789 | + if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
| 790 | + 'espresso_registrations_resend_registration') |
|
| 791 | + ) { |
|
| 792 | + $fc_items['resend_registration'] = array( |
|
| 793 | + 'class' => 'dashicons dashicons-email-alt', |
|
| 794 | + 'desc' => __('Resend Registration Details', 'event_espresso'), |
|
| 795 | + ); |
|
| 796 | + } else { |
|
| 797 | + $fc_items['blank'] = array('class' => 'blank', 'desc' => ''); |
|
| 798 | + } |
|
| 799 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
| 800 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
| 801 | + if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
| 802 | + $fc_items['view_related_messages'] = array( |
|
| 803 | + 'class' => $related_for_icon['css_class'], |
|
| 804 | + 'desc' => $related_for_icon['label'], |
|
| 805 | + ); |
|
| 806 | + } |
|
| 807 | + } |
|
| 808 | + $sc_items = array( |
|
| 809 | + 'approved_status' => array( |
|
| 810 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 811 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
| 812 | + ), |
|
| 813 | + 'pending_status' => array( |
|
| 814 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 815 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
| 816 | + ), |
|
| 817 | + 'wait_list' => array( |
|
| 818 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 819 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
| 820 | + ), |
|
| 821 | + 'incomplete_status' => array( |
|
| 822 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete, |
|
| 823 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_incomplete, false, 'sentence'), |
|
| 824 | + ), |
|
| 825 | + 'not_approved' => array( |
|
| 826 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 827 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
| 828 | + ), |
|
| 829 | + 'declined_status' => array( |
|
| 830 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 831 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
| 832 | + ), |
|
| 833 | + 'cancelled_status' => array( |
|
| 834 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 835 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
| 836 | + ), |
|
| 837 | + ); |
|
| 838 | + return array_merge($fc_items, $sc_items); |
|
| 839 | + } |
|
| 840 | + |
|
| 841 | + |
|
| 842 | + |
|
| 843 | + /*************************************** REGISTRATION OVERVIEW **************************************/ |
|
| 844 | + /** |
|
| 845 | + * @throws \EE_Error |
|
| 846 | + */ |
|
| 847 | + protected function _registrations_overview_list_table() |
|
| 848 | + { |
|
| 849 | + $this->_template_args['admin_page_header'] = ''; |
|
| 850 | + $EVT_ID = ! empty($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0; |
|
| 851 | + if ($EVT_ID) { |
|
| 852 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_registrations', |
|
| 853 | + 'espresso_registrations_new_registration', $EVT_ID) |
|
| 854 | + ) { |
|
| 855 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button('new_registration', 'add-registrant', |
|
| 856 | + array('event_id' => $EVT_ID), 'add-new-h2'); |
|
| 857 | + } |
|
| 858 | + $event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 859 | + if ($event instanceof EE_Event) { |
|
| 860 | + $this->_template_args['admin_page_header'] = sprintf(__('%s Viewing registrations for the event: %s%s', |
|
| 861 | + 'event_espresso'), '<h3 style="line-height:1.5em;">', |
|
| 862 | + '<br /><a href="' . EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 863 | + 'action' => 'edit', |
|
| 864 | + 'post' => $event->ID(), |
|
| 865 | + ), EVENTS_ADMIN_URL) . '"> ' . $event->get('EVT_name') . ' </a> ', '</h3>'); |
|
| 866 | + } |
|
| 867 | + $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0; |
|
| 868 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 869 | + if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') { |
|
| 870 | + $this->_template_args['admin_page_header'] = substr($this->_template_args['admin_page_header'], 0, -5); |
|
| 871 | + $this->_template_args['admin_page_header'] .= ' <span class="drk-grey-text">'; |
|
| 872 | + $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
| 873 | + $this->_template_args['admin_page_header'] .= $datetime->name(); |
|
| 874 | + $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )'; |
|
| 875 | + $this->_template_args['admin_page_header'] .= '</span></h3>'; |
|
| 876 | + } |
|
| 877 | + } |
|
| 878 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items()); |
|
| 879 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 880 | + } |
|
| 881 | + |
|
| 882 | + |
|
| 883 | + /** |
|
| 884 | + * This sets the _registration property for the registration details screen |
|
| 885 | + * |
|
| 886 | + * @access private |
|
| 887 | + * @return bool |
|
| 888 | + */ |
|
| 889 | + private function _set_registration_object() |
|
| 890 | + { |
|
| 891 | + //get out if we've already set the object |
|
| 892 | + if (is_object($this->_registration)) { |
|
| 893 | + return true; |
|
| 894 | + } |
|
| 895 | + $REG = EEM_Registration::instance(); |
|
| 896 | + $REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false; |
|
| 897 | + if ($this->_registration = $REG->get_one_by_ID($REG_ID)) { |
|
| 898 | + return true; |
|
| 899 | + } else { |
|
| 900 | + $error_msg = sprintf(__('An error occurred and the details for Registration ID #%s could not be retrieved.', |
|
| 901 | + 'event_espresso'), $REG_ID); |
|
| 902 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 903 | + $this->_registration = null; |
|
| 904 | + return false; |
|
| 905 | + } |
|
| 906 | + } |
|
| 907 | + |
|
| 908 | + |
|
| 909 | + /** |
|
| 910 | + * Used to retrieve registrations for the list table. |
|
| 911 | + * |
|
| 912 | + * @param int $per_page |
|
| 913 | + * @param bool $count |
|
| 914 | + * @param bool $this_month |
|
| 915 | + * @param bool $today |
|
| 916 | + * @return \EE_Registration[]|int |
|
| 917 | + */ |
|
| 918 | + public function get_registrations( |
|
| 919 | + $per_page = 10, |
|
| 920 | + $count = false, |
|
| 921 | + $this_month = false, |
|
| 922 | + $today = false |
|
| 923 | + ) { |
|
| 924 | + if( $this_month ) { |
|
| 925 | + $this->_req_data['status'] = 'month'; |
|
| 926 | + } |
|
| 927 | + if( $today ) { |
|
| 928 | + $this->_req_data['status'] = 'today'; |
|
| 929 | + } |
|
| 930 | + $query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count); |
|
| 931 | + return $count |
|
| 932 | + ? EEM_Registration::instance()->count($query_params) |
|
| 933 | + /** @type EE_Registration[] */ |
|
| 934 | + : EEM_Registration::instance()->get_all($query_params); |
|
| 935 | + } |
|
| 936 | + |
|
| 937 | + |
|
| 938 | + |
|
| 939 | + /** |
|
| 940 | + * Retrieves the query parameters to be used by the Registration model for getting registrations. |
|
| 941 | + * Note: this listens to values on the request for some of the query parameters. |
|
| 942 | + * |
|
| 943 | + * @param array $request |
|
| 944 | + * @param int $per_page |
|
| 945 | + * @param bool $count |
|
| 946 | + * @return array |
|
| 947 | + */ |
|
| 948 | + protected function _get_registration_query_parameters( |
|
| 949 | + $request = array(), |
|
| 950 | + $per_page = 10, |
|
| 951 | + $count = false |
|
| 952 | + ) { |
|
| 953 | + |
|
| 954 | + $query_params = array( |
|
| 955 | + 0 => $this->_get_where_conditions_for_registrations_query( |
|
| 956 | + $request |
|
| 957 | + ), |
|
| 958 | + 'caps' => EEM_Registration::caps_read_admin, |
|
| 959 | + 'default_where_conditions' => 'this_model_only', |
|
| 960 | + ); |
|
| 961 | + if ( ! $count) { |
|
| 962 | + $query_params = array_merge( |
|
| 963 | + $query_params, |
|
| 964 | + $this->_get_orderby_for_registrations_query(), |
|
| 965 | + $this->_get_limit($per_page) |
|
| 966 | + ); |
|
| 967 | + } |
|
| 968 | + |
|
| 969 | + return $query_params; |
|
| 970 | + } |
|
| 971 | + |
|
| 972 | + |
|
| 973 | + /** |
|
| 974 | + * This will add EVT_ID to the provided $where array for EE model query parameters. |
|
| 975 | + * |
|
| 976 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 977 | + * @return array |
|
| 978 | + */ |
|
| 979 | + protected function _add_event_id_to_where_conditions(array $request) |
|
| 980 | + { |
|
| 981 | + $where = array(); |
|
| 982 | + if ( ! empty($request['event_id'])) { |
|
| 983 | + $where['EVT_ID'] = absint($request['event_id']); |
|
| 984 | + } |
|
| 985 | + return $where; |
|
| 986 | + } |
|
| 987 | + |
|
| 988 | + |
|
| 989 | + /** |
|
| 990 | + * Adds category ID if it exists in the request to the where conditions for the registrations query. |
|
| 991 | + * |
|
| 992 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 993 | + * @return array |
|
| 994 | + */ |
|
| 995 | + protected function _add_category_id_to_where_conditions(array $request) |
|
| 996 | + { |
|
| 997 | + $where = array(); |
|
| 998 | + if ( ! empty($request['EVT_CAT']) && (int)$request['EVT_CAT'] !== -1) { |
|
| 999 | + $where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']); |
|
| 1000 | + } |
|
| 1001 | + return $where; |
|
| 1002 | + } |
|
| 1003 | + |
|
| 1004 | + |
|
| 1005 | + /** |
|
| 1006 | + * Adds the datetime ID if it exists in the request to the where conditions for the registrations query. |
|
| 1007 | + * |
|
| 1008 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1009 | + * @return array |
|
| 1010 | + */ |
|
| 1011 | + protected function _add_datetime_id_to_where_conditions(array $request) |
|
| 1012 | + { |
|
| 1013 | + $where = array(); |
|
| 1014 | + if ( ! empty($request['datetime_id'])) { |
|
| 1015 | + $where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']); |
|
| 1016 | + } |
|
| 1017 | + if( ! empty($request['DTT_ID'])){ |
|
| 1018 | + $where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']); |
|
| 1019 | + } |
|
| 1020 | + return $where; |
|
| 1021 | + } |
|
| 1022 | + |
|
| 1023 | + |
|
| 1024 | + /** |
|
| 1025 | + * Adds the correct registration status to the where conditions for the registrations query. |
|
| 1026 | + * |
|
| 1027 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1028 | + * @return array |
|
| 1029 | + */ |
|
| 1030 | + protected function _add_registration_status_to_where_conditions(array $request) |
|
| 1031 | + { |
|
| 1032 | + $where = array(); |
|
| 1033 | + $view = EEH_Array::is_set( $request, 'status', '' ); |
|
| 1034 | + $registration_status = ! empty($request['_reg_status']) |
|
| 1035 | + ? sanitize_text_field($request['_reg_status']) |
|
| 1036 | + : ''; |
|
| 1037 | + |
|
| 1038 | + /* |
|
| 1039 | 1039 | * If filtering by registration status, then we show registrations matching that status. |
| 1040 | 1040 | * If not filtering by specified status, then we show all registrations excluding incomplete registrations UNLESS |
| 1041 | 1041 | * viewing trashed registrations. |
| 1042 | 1042 | */ |
| 1043 | - if ( ! empty($registration_status)) { |
|
| 1044 | - $where['STS_ID'] = $registration_status; |
|
| 1045 | - } else { |
|
| 1046 | - //make sure we exclude incomplete registrations, but only if not trashed. |
|
| 1047 | - if ($view === 'trash') { |
|
| 1048 | - $where['REG_deleted'] = true; |
|
| 1049 | - } else if ($view === 'incomplete') { |
|
| 1050 | - $where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
| 1051 | - } else { |
|
| 1052 | - $where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 1053 | - } |
|
| 1054 | - } |
|
| 1055 | - return $where; |
|
| 1056 | - } |
|
| 1057 | - |
|
| 1058 | - |
|
| 1059 | - /** |
|
| 1060 | - * Adds any provided date restraints to the where conditions for the registrations query. |
|
| 1061 | - * |
|
| 1062 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1063 | - * @return array |
|
| 1064 | - */ |
|
| 1065 | - protected function _add_date_to_where_conditions(array $request) |
|
| 1066 | - { |
|
| 1067 | - $where = array(); |
|
| 1068 | - $view = EEH_Array::is_set( $request, 'status', '' ); |
|
| 1069 | - $month_range = ! empty($request['month_range']) |
|
| 1070 | - ? sanitize_text_field($request['month_range']) |
|
| 1071 | - : ''; |
|
| 1072 | - $retrieve_for_today = $view === 'today'; |
|
| 1073 | - $retrieve_for_this_month = $view === 'month'; |
|
| 1074 | - |
|
| 1075 | - if ($retrieve_for_today) { |
|
| 1076 | - $now = date('Y-m-d', current_time('timestamp')); |
|
| 1077 | - $where['REG_date'] = array( |
|
| 1078 | - 'BETWEEN', |
|
| 1079 | - array( |
|
| 1080 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1081 | - 'REG_date', |
|
| 1082 | - $now . ' 00:00:00', |
|
| 1083 | - 'Y-m-d H:i:s' |
|
| 1084 | - ), |
|
| 1085 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1086 | - 'REG_date', |
|
| 1087 | - $now . ' 23:59:59', |
|
| 1088 | - 'Y-m-d H:i:s' |
|
| 1089 | - ), |
|
| 1090 | - ), |
|
| 1091 | - ); |
|
| 1092 | - } elseif ($retrieve_for_this_month) { |
|
| 1093 | - $current_year_and_month = date('Y-m', current_time('timestamp')); |
|
| 1094 | - $days_this_month = date('t', current_time('timestamp')); |
|
| 1095 | - $where['REG_date'] = array( |
|
| 1096 | - 'BETWEEN', |
|
| 1097 | - array( |
|
| 1098 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1099 | - 'REG_date', |
|
| 1100 | - $current_year_and_month . '-01 00:00:00', |
|
| 1101 | - 'Y-m-d H:i:s' |
|
| 1102 | - ), |
|
| 1103 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1104 | - 'REG_date', |
|
| 1105 | - $current_year_and_month . '-' . $days_this_month . ' 23:59:59', |
|
| 1106 | - 'Y-m-d H:i:s' |
|
| 1107 | - ), |
|
| 1108 | - ), |
|
| 1109 | - ); |
|
| 1110 | - } elseif ($month_range) { |
|
| 1111 | - $pieces = explode(' ', $month_range, 3); |
|
| 1112 | - $month_requested = ! empty($pieces[0]) |
|
| 1113 | - ? date('m', strtotime($month_range)) |
|
| 1114 | - : ''; |
|
| 1115 | - $year_requested = ! empty($pieces[1]) |
|
| 1116 | - ? $pieces[1] |
|
| 1117 | - : ''; |
|
| 1118 | - //if there is not a month or year then we can't go further |
|
| 1119 | - if ($month_requested && $year_requested) { |
|
| 1120 | - $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01')); |
|
| 1121 | - $where['REG_date'] = array( |
|
| 1122 | - 'BETWEEN', |
|
| 1123 | - array( |
|
| 1124 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1125 | - 'REG_date', |
|
| 1126 | - $year_requested . '-' . $month_requested . '-01 00:00:00', |
|
| 1127 | - 'Y-m-d H:i:s' |
|
| 1128 | - ), |
|
| 1129 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1130 | - 'REG_date', |
|
| 1131 | - $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59', |
|
| 1132 | - 'Y-m-d H:i:s' |
|
| 1133 | - ), |
|
| 1134 | - ), |
|
| 1135 | - ); |
|
| 1136 | - } |
|
| 1137 | - } |
|
| 1138 | - return $where; |
|
| 1139 | - } |
|
| 1140 | - |
|
| 1141 | - |
|
| 1142 | - /** |
|
| 1143 | - * Adds any provided search restraints to the where conditions for the registrations query |
|
| 1144 | - * |
|
| 1145 | - * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1146 | - * @return array |
|
| 1147 | - */ |
|
| 1148 | - protected function _add_search_to_where_conditions(array $request) |
|
| 1149 | - { |
|
| 1150 | - $where = array(); |
|
| 1151 | - if ( ! empty($request['s'])) { |
|
| 1152 | - $search_string = '%' . sanitize_text_field($request['s']) . '%'; |
|
| 1153 | - $where['OR'] = array( |
|
| 1154 | - 'Event.EVT_name' => array('LIKE', $search_string), |
|
| 1155 | - 'Event.EVT_desc' => array('LIKE', $search_string), |
|
| 1156 | - 'Event.EVT_short_desc' => array('LIKE', $search_string), |
|
| 1157 | - 'Attendee.ATT_full_name' => array('LIKE', $search_string), |
|
| 1158 | - 'Attendee.ATT_fname' => array('LIKE', $search_string), |
|
| 1159 | - 'Attendee.ATT_lname' => array('LIKE', $search_string), |
|
| 1160 | - 'Attendee.ATT_short_bio' => array('LIKE', $search_string), |
|
| 1161 | - 'Attendee.ATT_email' => array('LIKE', $search_string), |
|
| 1162 | - 'Attendee.ATT_address' => array('LIKE', $search_string), |
|
| 1163 | - 'Attendee.ATT_address2' => array('LIKE', $search_string), |
|
| 1164 | - 'Attendee.ATT_city' => array('LIKE', $search_string), |
|
| 1165 | - 'REG_final_price' => array('LIKE', $search_string), |
|
| 1166 | - 'REG_code' => array('LIKE', $search_string), |
|
| 1167 | - 'REG_count' => array('LIKE', $search_string), |
|
| 1168 | - 'REG_group_size' => array('LIKE', $search_string), |
|
| 1169 | - 'Ticket.TKT_name' => array('LIKE', $search_string), |
|
| 1170 | - 'Ticket.TKT_description' => array('LIKE', $search_string), |
|
| 1171 | - 'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string), |
|
| 1172 | - ); |
|
| 1173 | - } |
|
| 1174 | - return $where; |
|
| 1175 | - } |
|
| 1176 | - |
|
| 1177 | - |
|
| 1178 | - /** |
|
| 1179 | - * Sets up the where conditions for the registrations query. |
|
| 1180 | - * |
|
| 1181 | - * @param array $request |
|
| 1182 | - * @return array |
|
| 1183 | - */ |
|
| 1184 | - protected function _get_where_conditions_for_registrations_query($request) |
|
| 1185 | - { |
|
| 1186 | - return array_merge( |
|
| 1187 | - $this->_add_event_id_to_where_conditions($request), |
|
| 1188 | - $this->_add_category_id_to_where_conditions($request), |
|
| 1189 | - $this->_add_datetime_id_to_where_conditions($request), |
|
| 1190 | - $this->_add_registration_status_to_where_conditions($request), |
|
| 1191 | - $this->_add_date_to_where_conditions($request), |
|
| 1192 | - $this->_add_search_to_where_conditions($request) |
|
| 1193 | - ); |
|
| 1194 | - } |
|
| 1195 | - |
|
| 1196 | - |
|
| 1197 | - /** |
|
| 1198 | - * Sets up the orderby for the registrations query. |
|
| 1199 | - * |
|
| 1200 | - * @return array |
|
| 1201 | - */ |
|
| 1202 | - protected function _get_orderby_for_registrations_query() |
|
| 1203 | - { |
|
| 1204 | - $orderby_field = ! empty($this->_req_data['orderby']) |
|
| 1205 | - ? sanitize_text_field($this->_req_data['orderby']) |
|
| 1206 | - : ''; |
|
| 1207 | - switch ($orderby_field) { |
|
| 1208 | - case '_REG_ID': |
|
| 1209 | - $orderby_field = 'REG_ID'; |
|
| 1210 | - break; |
|
| 1211 | - case '_Reg_status': |
|
| 1212 | - $orderby_field = 'STS_ID'; |
|
| 1213 | - break; |
|
| 1214 | - case 'ATT_fname': |
|
| 1215 | - //just for spite, we're going to order it by their LAST name, NOT their first name. Now who's the boss? |
|
| 1216 | - //jk, we don't want to break existing links, and customers preferred ordering by last name |
|
| 1217 | - //besides, from the UI, its ambiguous as to whether we will order by first or last name |
|
| 1218 | - $orderby_field = 'Attendee.ATT_lname'; |
|
| 1219 | - break; |
|
| 1220 | - case 'event_name': |
|
| 1221 | - $orderby_field = 'Event.EVT_name'; |
|
| 1222 | - break; |
|
| 1223 | - case 'DTT_EVT_start': |
|
| 1224 | - $orderby_field = 'Event.Datetime.DTT_EVT_start'; |
|
| 1225 | - break; |
|
| 1226 | - default: //'REG_date' |
|
| 1227 | - $orderby_field = 'REG_date'; |
|
| 1228 | - } |
|
| 1229 | - |
|
| 1230 | - //order |
|
| 1231 | - $order = ! empty($this->_req_data['order']) |
|
| 1232 | - ? sanitize_text_field($this->_req_data['order']) |
|
| 1233 | - : 'DESC'; |
|
| 1234 | - return array('order_by' => array($orderby_field => $order)); |
|
| 1235 | - } |
|
| 1236 | - |
|
| 1237 | - |
|
| 1238 | - /** |
|
| 1239 | - * Sets up the limit for the registrations query. |
|
| 1240 | - * |
|
| 1241 | - * @param $per_page |
|
| 1242 | - * @return array |
|
| 1243 | - */ |
|
| 1244 | - protected function _get_limit($per_page) |
|
| 1245 | - { |
|
| 1246 | - $current_page = ! empty($this->_req_data['paged']) |
|
| 1247 | - ? absint($this->_req_data['paged']) |
|
| 1248 | - : 1; |
|
| 1249 | - $per_page = ! empty($this->_req_data['perpage']) |
|
| 1250 | - ? $this->_req_data['perpage'] |
|
| 1251 | - : $per_page; |
|
| 1252 | - |
|
| 1253 | - //-1 means return all results so get out if that's set. |
|
| 1254 | - if ((int)$per_page === -1) { |
|
| 1255 | - return array(); |
|
| 1256 | - } |
|
| 1257 | - $per_page = absint($per_page); |
|
| 1258 | - $offset = ($current_page - 1) * $per_page; |
|
| 1259 | - return array('limit' => array($offset, $per_page)); |
|
| 1260 | - } |
|
| 1261 | - |
|
| 1262 | - |
|
| 1263 | - public function get_registration_status_array() |
|
| 1264 | - { |
|
| 1265 | - return self::$_reg_status; |
|
| 1266 | - } |
|
| 1267 | - |
|
| 1268 | - |
|
| 1269 | - |
|
| 1270 | - |
|
| 1271 | - /*************************************** REGISTRATION DETAILS ***************************************/ |
|
| 1272 | - /** |
|
| 1273 | - * generates HTML for the View Registration Details Admin page |
|
| 1274 | - * |
|
| 1275 | - * @access protected |
|
| 1276 | - * @return void |
|
| 1277 | - */ |
|
| 1278 | - protected function _registration_details() |
|
| 1279 | - { |
|
| 1280 | - $this->_template_args = array(); |
|
| 1281 | - $this->_set_registration_object(); |
|
| 1282 | - if (is_object($this->_registration)) { |
|
| 1283 | - $transaction = $this->_registration->transaction() ? $this->_registration->transaction() |
|
| 1284 | - : EE_Transaction::new_instance(); |
|
| 1285 | - $this->_session = $transaction->session_data(); |
|
| 1286 | - $event_id = $this->_registration->event_ID(); |
|
| 1287 | - $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID(); |
|
| 1288 | - $this->_template_args['reg_nmbr']['label'] = __('Registration Number', 'event_espresso'); |
|
| 1289 | - $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date'); |
|
| 1290 | - $this->_template_args['reg_datetime']['label'] = __('Date', 'event_espresso'); |
|
| 1291 | - $this->_template_args['grand_total'] = $transaction->total(); |
|
| 1292 | - $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 1293 | - // link back to overview |
|
| 1294 | - $this->_template_args['reg_overview_url'] = REG_ADMIN_URL; |
|
| 1295 | - $this->_template_args['registration'] = $this->_registration; |
|
| 1296 | - $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1297 | - 'action' => 'default', |
|
| 1298 | - 'event_id' => $event_id, |
|
| 1299 | - ), REG_ADMIN_URL); |
|
| 1300 | - $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1301 | - 'action' => 'default', |
|
| 1302 | - 'EVT_ID' => $event_id, |
|
| 1303 | - 'page' => 'espresso_transactions', |
|
| 1304 | - ), admin_url('admin.php')); |
|
| 1305 | - $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1306 | - 'page' => 'espresso_events', |
|
| 1307 | - 'action' => 'edit', |
|
| 1308 | - 'post' => $event_id, |
|
| 1309 | - ), admin_url('admin.php')); |
|
| 1310 | - //next and previous links |
|
| 1311 | - $next_reg = $this->_registration->next(null, array(), 'REG_ID'); |
|
| 1312 | - $this->_template_args['next_registration'] = $next_reg |
|
| 1313 | - ? $this->_next_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1314 | - 'action' => 'view_registration', |
|
| 1315 | - '_REG_ID' => $next_reg['REG_ID'], |
|
| 1316 | - ), REG_ADMIN_URL), 'dashicons dashicons-arrow-right ee-icon-size-22') : ''; |
|
| 1317 | - $previous_reg = $this->_registration->previous(null, array(), 'REG_ID'); |
|
| 1318 | - $this->_template_args['previous_registration'] = $previous_reg |
|
| 1319 | - ? $this->_previous_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1320 | - 'action' => 'view_registration', |
|
| 1321 | - '_REG_ID' => $previous_reg['REG_ID'], |
|
| 1322 | - ), REG_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : ''; |
|
| 1323 | - // grab header |
|
| 1324 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php'; |
|
| 1325 | - $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 1326 | - $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, |
|
| 1327 | - $this->_template_args, true); |
|
| 1328 | - } else { |
|
| 1329 | - $this->_template_args['admin_page_header'] = $this->display_espresso_notices(); |
|
| 1330 | - } |
|
| 1331 | - // the details template wrapper |
|
| 1332 | - $this->display_admin_page_with_sidebar(); |
|
| 1333 | - } |
|
| 1334 | - |
|
| 1335 | - |
|
| 1336 | - protected function _registration_details_metaboxes() |
|
| 1337 | - { |
|
| 1338 | - do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this); |
|
| 1339 | - $this->_set_registration_object(); |
|
| 1340 | - $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null; |
|
| 1341 | - add_meta_box('edit-reg-status-mbox', __('Registration Status', 'event_espresso'), |
|
| 1342 | - array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1343 | - add_meta_box('edit-reg-details-mbox', __('Registration Details', 'event_espresso'), |
|
| 1344 | - array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1345 | - if ($attendee instanceof EE_Attendee |
|
| 1346 | - && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox') |
|
| 1347 | - ) { |
|
| 1348 | - add_meta_box('edit-reg-questions-mbox', __('Registration Form Answers', 'event_espresso'), |
|
| 1349 | - array($this, '_reg_questions_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1350 | - } |
|
| 1351 | - add_meta_box('edit-reg-registrant-mbox', __('Contact Details', 'event_espresso'), |
|
| 1352 | - array($this, '_reg_registrant_side_meta_box'), $this->wp_page_slug, 'side', 'high'); |
|
| 1353 | - if ($this->_registration->group_size() > 1) { |
|
| 1354 | - add_meta_box('edit-reg-attendees-mbox', __('Other Registrations in this Transaction', 'event_espresso'), |
|
| 1355 | - array($this, '_reg_attendees_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1356 | - } |
|
| 1357 | - } |
|
| 1358 | - |
|
| 1359 | - |
|
| 1360 | - /** |
|
| 1361 | - * set_reg_status_buttons_metabox |
|
| 1362 | - * |
|
| 1363 | - * @access protected |
|
| 1364 | - * @return string |
|
| 1365 | - * @throws \EE_Error |
|
| 1366 | - */ |
|
| 1367 | - public function set_reg_status_buttons_metabox() |
|
| 1368 | - { |
|
| 1369 | - $this->_set_registration_object(); |
|
| 1370 | - $change_reg_status_form = $this->_generate_reg_status_change_form(); |
|
| 1371 | - echo $change_reg_status_form->form_open(self::add_query_args_and_nonce(array( |
|
| 1372 | - 'action' => 'change_reg_status', |
|
| 1373 | - ), REG_ADMIN_URL)); |
|
| 1374 | - echo $change_reg_status_form->get_html(); |
|
| 1375 | - echo $change_reg_status_form->form_close(); |
|
| 1376 | - } |
|
| 1377 | - |
|
| 1378 | - |
|
| 1379 | - /** |
|
| 1380 | - * @return EE_Form_Section_Proper |
|
| 1381 | - */ |
|
| 1382 | - protected function _generate_reg_status_change_form() |
|
| 1383 | - { |
|
| 1384 | - return new EE_Form_Section_Proper(array( |
|
| 1385 | - 'name' => 'reg_status_change_form', |
|
| 1386 | - 'html_id' => 'reg-status-change-form', |
|
| 1387 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
| 1388 | - 'subsections' => array( |
|
| 1389 | - 'return' => new EE_Hidden_Input(array( |
|
| 1390 | - 'name' => 'return', |
|
| 1391 | - 'default' => 'view_registration', |
|
| 1392 | - )), |
|
| 1393 | - 'REG_ID' => new EE_Hidden_Input(array( |
|
| 1394 | - 'name' => 'REG_ID', |
|
| 1395 | - 'default' => $this->_registration->ID(), |
|
| 1396 | - )), |
|
| 1397 | - 'current_status' => new EE_Form_Section_HTML(EEH_HTML::tr(EEH_HTML::th(EEH_HTML::label(EEH_HTML::strong(__('Current Registration Status', |
|
| 1398 | - 'event_espresso')))) . EEH_HTML::td(EEH_HTML::strong($this->_registration->pretty_status(), |
|
| 1399 | - '', 'status-' . $this->_registration->status_ID(), |
|
| 1400 | - 'line-height: 1em; font-size: 1.5em; font-weight: bold;')))), |
|
| 1401 | - 'reg_status' => new EE_Select_Input($this->_get_reg_statuses(), array( |
|
| 1402 | - 'html_label_text' => __('Change Registration Status to', 'event_espresso'), |
|
| 1403 | - 'default' => $this->_registration->status_ID(), |
|
| 1404 | - )), |
|
| 1405 | - 'send_notifications' => new EE_Yes_No_Input(array( |
|
| 1406 | - 'html_label_text' => __('Send Related Messages', 'event_espresso'), |
|
| 1407 | - 'default' => false, |
|
| 1408 | - 'html_help_text' => __('If set to "Yes", then the related messages will be sent to the registrant.', |
|
| 1409 | - 'event_espresso'), |
|
| 1410 | - )), |
|
| 1411 | - 'submit' => new EE_Submit_Input(array( |
|
| 1412 | - 'html_class' => 'button-primary', |
|
| 1413 | - 'html_label_text' => ' ', |
|
| 1414 | - 'default' => __('Update Registration Status', 'event_espresso'), |
|
| 1415 | - )), |
|
| 1416 | - ), |
|
| 1417 | - )); |
|
| 1418 | - } |
|
| 1419 | - |
|
| 1420 | - |
|
| 1421 | - |
|
| 1422 | - /** |
|
| 1423 | - * Returns an array of all the buttons for the various statuses and switch status actions |
|
| 1424 | - * |
|
| 1425 | - * @return array |
|
| 1426 | - */ |
|
| 1427 | - protected function _get_reg_statuses() |
|
| 1428 | - { |
|
| 1429 | - $reg_status_array = EEM_Registration::instance()->reg_status_array(); |
|
| 1430 | - unset ($reg_status_array[EEM_Registration::status_id_incomplete]); |
|
| 1431 | - // get current reg status |
|
| 1432 | - $current_status = $this->_registration->status_ID(); |
|
| 1433 | - // is registration for free event? This will determine whether to display the pending payment option |
|
| 1434 | - if ($current_status != EEM_Registration::status_id_pending_payment |
|
| 1435 | - && $this->_registration->transaction() |
|
| 1436 | - ->is_free() |
|
| 1437 | - ) { |
|
| 1438 | - unset($reg_status_array[EEM_Registration::status_id_pending_payment]); |
|
| 1439 | - } |
|
| 1440 | - return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence'); |
|
| 1441 | - } |
|
| 1442 | - |
|
| 1443 | - |
|
| 1444 | - /** |
|
| 1445 | - * This method is used when using _REG_ID from request which may or may not be an array of reg_ids. |
|
| 1446 | - * |
|
| 1447 | - * @param bool $status REG status given for changing registrations to. |
|
| 1448 | - * @param bool $notify Whether to send messages notifications or not. |
|
| 1449 | - * @return array (array with reg_id(s) updated and whether update was successful. |
|
| 1450 | - */ |
|
| 1451 | - protected function _set_registration_status_from_request($status = false, $notify = false) |
|
| 1452 | - { |
|
| 1453 | - if (isset($this->_req_data['reg_status_change_form'])) { |
|
| 1454 | - $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID']) |
|
| 1455 | - ? (array)$this->_req_data['reg_status_change_form']['REG_ID'] : array(); |
|
| 1456 | - } else { |
|
| 1457 | - $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array)$this->_req_data['_REG_ID'] : array(); |
|
| 1458 | - } |
|
| 1459 | - $success = $this->_set_registration_status($REG_IDs, $status); |
|
| 1460 | - //notify? |
|
| 1461 | - if ($success |
|
| 1462 | - && $notify |
|
| 1463 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
| 1464 | - 'espresso_registrations_resend_registration') |
|
| 1465 | - ) { |
|
| 1466 | - $this->_process_resend_registration(); |
|
| 1467 | - } |
|
| 1468 | - return $success; |
|
| 1469 | - } |
|
| 1470 | - |
|
| 1471 | - |
|
| 1472 | - /** |
|
| 1473 | - * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an |
|
| 1474 | - * array). Note, this method does NOT take care of possible notifications. That is required by calling code. |
|
| 1475 | - * |
|
| 1476 | - * @param array $REG_IDs |
|
| 1477 | - * @param bool $status |
|
| 1478 | - * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as |
|
| 1479 | - * the array of updated registrations). |
|
| 1480 | - */ |
|
| 1481 | - protected function _set_registration_status($REG_IDs = array(), $status = false) |
|
| 1482 | - { |
|
| 1483 | - $success = false; |
|
| 1484 | - // typecast $REG_IDs |
|
| 1485 | - $REG_IDs = (array)$REG_IDs; |
|
| 1486 | - if ( ! empty($REG_IDs)) { |
|
| 1487 | - $success = true; |
|
| 1488 | - // set default status if none is passed |
|
| 1489 | - $status = $status ? $status : EEM_Registration::status_id_pending_payment; |
|
| 1490 | - // sanitize $REG_IDs |
|
| 1491 | - $REG_IDs = array_filter($REG_IDs, 'absint'); |
|
| 1492 | - //loop through REG_ID's and change status |
|
| 1493 | - foreach ($REG_IDs as $REG_ID) { |
|
| 1494 | - $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 1495 | - if ($registration instanceof EE_Registration) { |
|
| 1496 | - $registration->set_status($status); |
|
| 1497 | - $result = $registration->save(); |
|
| 1498 | - // verifying explicit fails because update *may* just return 0 for 0 rows affected |
|
| 1499 | - $success = $result !== false ? $success : false; |
|
| 1500 | - } |
|
| 1501 | - } |
|
| 1502 | - } |
|
| 1503 | - //reset _req_data['_REG_ID'] for any potential future messages notifications |
|
| 1504 | - $this->_req_data['_REG_ID'] = $REG_IDs; |
|
| 1505 | - //return $success and processed registrations |
|
| 1506 | - return array('REG_ID' => $REG_IDs, 'success' => $success); |
|
| 1507 | - } |
|
| 1508 | - |
|
| 1509 | - |
|
| 1510 | - /** |
|
| 1511 | - * Common logic for setting up success message and redirecting to appropriate route |
|
| 1512 | - * |
|
| 1513 | - * @param string $STS_ID status id for the registration changed to |
|
| 1514 | - * @param bool $notify indicates whether the _set_registration_status_from_request does notifications or not. |
|
| 1515 | - * @return void |
|
| 1516 | - */ |
|
| 1517 | - protected function _reg_status_change_return($STS_ID, $notify = false) |
|
| 1518 | - { |
|
| 1519 | - $result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify) |
|
| 1520 | - : array('success' => false); |
|
| 1521 | - $success = isset($result['success']) && $result['success']; |
|
| 1522 | - //setup success message |
|
| 1523 | - if ($success) { |
|
| 1524 | - if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) { |
|
| 1525 | - $msg = sprintf(__('Registration status has been set to %s', 'event_espresso'), |
|
| 1526 | - EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
| 1527 | - } else { |
|
| 1528 | - $msg = sprintf(__('Registrations have been set to %s.', 'event_espresso'), |
|
| 1529 | - EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
| 1530 | - } |
|
| 1531 | - EE_Error::add_success($msg); |
|
| 1532 | - } else { |
|
| 1533 | - EE_Error::add_error(__('Something went wrong, and the status was not changed', 'event_espresso'), __FILE__, |
|
| 1534 | - __LINE__, __FUNCTION__); |
|
| 1535 | - } |
|
| 1536 | - if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') { |
|
| 1537 | - $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])); |
|
| 1538 | - } else { |
|
| 1539 | - $route = array('action' => 'default'); |
|
| 1540 | - } |
|
| 1541 | - //unset nonces |
|
| 1542 | - foreach ($this->_req_data as $ref => $value) { |
|
| 1543 | - if (strpos($ref, 'nonce') !== false) { |
|
| 1544 | - unset($this->_req_data[$ref]); |
|
| 1545 | - continue; |
|
| 1546 | - } |
|
| 1547 | - $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value); |
|
| 1548 | - $this->_req_data[$ref] = $value; |
|
| 1549 | - } |
|
| 1550 | - //merge request vars so that the reloaded list table contains any existing filter query params |
|
| 1551 | - $route = array_merge($this->_req_data, $route); |
|
| 1552 | - $this->_redirect_after_action($success, '', '', $route, true); |
|
| 1553 | - } |
|
| 1554 | - |
|
| 1555 | - |
|
| 1556 | - /** |
|
| 1557 | - * incoming reg status change from reg details page. |
|
| 1558 | - * |
|
| 1559 | - * @return void |
|
| 1560 | - */ |
|
| 1561 | - protected function _change_reg_status() |
|
| 1562 | - { |
|
| 1563 | - $this->_req_data['return'] = 'view_registration'; |
|
| 1564 | - //set notify based on whether the send notifications toggle is set or not |
|
| 1565 | - $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']); |
|
| 1566 | - //$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] ); |
|
| 1567 | - $this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status']) |
|
| 1568 | - ? $this->_req_data['reg_status_change_form']['reg_status'] : ''; |
|
| 1569 | - switch ($this->_req_data['reg_status_change_form']['reg_status']) { |
|
| 1570 | - case EEM_Registration::status_id_approved : |
|
| 1571 | - case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') : |
|
| 1572 | - $this->approve_registration($notify); |
|
| 1573 | - break; |
|
| 1574 | - case EEM_Registration::status_id_pending_payment : |
|
| 1575 | - case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') : |
|
| 1576 | - $this->pending_registration($notify); |
|
| 1577 | - break; |
|
| 1578 | - case EEM_Registration::status_id_not_approved : |
|
| 1579 | - case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') : |
|
| 1580 | - $this->not_approve_registration($notify); |
|
| 1581 | - break; |
|
| 1582 | - case EEM_Registration::status_id_declined : |
|
| 1583 | - case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') : |
|
| 1584 | - $this->decline_registration($notify); |
|
| 1585 | - break; |
|
| 1586 | - case EEM_Registration::status_id_cancelled : |
|
| 1587 | - case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') : |
|
| 1588 | - $this->cancel_registration($notify); |
|
| 1589 | - break; |
|
| 1590 | - case EEM_Registration::status_id_wait_list : |
|
| 1591 | - case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') : |
|
| 1592 | - $this->waitlist_registration($notify); |
|
| 1593 | - break; |
|
| 1594 | - case EEM_Registration::status_id_incomplete : |
|
| 1595 | - default : |
|
| 1596 | - $result['success'] = false; |
|
| 1597 | - unset($this->_req_data['return']); |
|
| 1598 | - $this->_reg_status_change_return('', false); |
|
| 1599 | - break; |
|
| 1600 | - } |
|
| 1601 | - } |
|
| 1602 | - |
|
| 1603 | - |
|
| 1604 | - /** |
|
| 1605 | - * approve_registration |
|
| 1606 | - * |
|
| 1607 | - * @access protected |
|
| 1608 | - * @param bool $notify whether or not to notify the registrant about their approval. |
|
| 1609 | - * @return void |
|
| 1610 | - */ |
|
| 1611 | - protected function approve_registration($notify = false) |
|
| 1612 | - { |
|
| 1613 | - $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify); |
|
| 1614 | - } |
|
| 1615 | - |
|
| 1616 | - |
|
| 1617 | - /** |
|
| 1618 | - * decline_registration |
|
| 1619 | - * |
|
| 1620 | - * @access protected |
|
| 1621 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1622 | - * @return void |
|
| 1623 | - */ |
|
| 1624 | - protected function decline_registration($notify = false) |
|
| 1625 | - { |
|
| 1626 | - $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify); |
|
| 1627 | - } |
|
| 1628 | - |
|
| 1629 | - |
|
| 1630 | - /** |
|
| 1631 | - * cancel_registration |
|
| 1632 | - * |
|
| 1633 | - * @access protected |
|
| 1634 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1635 | - * @return void |
|
| 1636 | - */ |
|
| 1637 | - protected function cancel_registration($notify = false) |
|
| 1638 | - { |
|
| 1639 | - $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify); |
|
| 1640 | - } |
|
| 1641 | - |
|
| 1642 | - |
|
| 1643 | - /** |
|
| 1644 | - * not_approve_registration |
|
| 1645 | - * |
|
| 1646 | - * @access protected |
|
| 1647 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1648 | - * @return void |
|
| 1649 | - */ |
|
| 1650 | - protected function not_approve_registration($notify = false) |
|
| 1651 | - { |
|
| 1652 | - $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify); |
|
| 1653 | - } |
|
| 1654 | - |
|
| 1655 | - |
|
| 1656 | - /** |
|
| 1657 | - * decline_registration |
|
| 1658 | - * |
|
| 1659 | - * @access protected |
|
| 1660 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1661 | - * @return void |
|
| 1662 | - */ |
|
| 1663 | - protected function pending_registration($notify = false) |
|
| 1664 | - { |
|
| 1665 | - $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify); |
|
| 1666 | - } |
|
| 1667 | - |
|
| 1668 | - |
|
| 1669 | - /** |
|
| 1670 | - * waitlist_registration |
|
| 1671 | - * |
|
| 1672 | - * @access protected |
|
| 1673 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1674 | - * @return void |
|
| 1675 | - */ |
|
| 1676 | - protected function waitlist_registration($notify = false) |
|
| 1677 | - { |
|
| 1678 | - $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify); |
|
| 1679 | - } |
|
| 1680 | - |
|
| 1681 | - |
|
| 1682 | - /** |
|
| 1683 | - * generates HTML for the Registration main meta box |
|
| 1684 | - * |
|
| 1685 | - * @access public |
|
| 1686 | - * @return void |
|
| 1687 | - */ |
|
| 1688 | - public function _reg_details_meta_box() |
|
| 1689 | - { |
|
| 1690 | - EEH_Autoloader::register_line_item_display_autoloaders(); |
|
| 1691 | - EEH_Autoloader::register_line_item_filter_autoloaders(); |
|
| 1692 | - EE_Registry::instance()->load_helper('Line_Item'); |
|
| 1693 | - $transaction = $this->_registration->transaction() ? $this->_registration->transaction() |
|
| 1694 | - : EE_Transaction::new_instance(); |
|
| 1695 | - $this->_session = $transaction->session_data(); |
|
| 1696 | - $filters = new EE_Line_Item_Filter_Collection(); |
|
| 1697 | - //$filters->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
| 1698 | - $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration)); |
|
| 1699 | - $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, |
|
| 1700 | - $transaction->total_line_item()); |
|
| 1701 | - $filtered_line_item_tree = $line_item_filter_processor->process(); |
|
| 1702 | - $line_item_display = new EE_Line_Item_Display('reg_admin_table', |
|
| 1703 | - 'EE_Admin_Table_Registration_Line_Item_Display_Strategy'); |
|
| 1704 | - $this->_template_args['line_item_table'] = $line_item_display->display_line_item($filtered_line_item_tree, |
|
| 1705 | - array('EE_Registration' => $this->_registration)); |
|
| 1706 | - $attendee = $this->_registration->attendee(); |
|
| 1707 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
| 1708 | - 'espresso_transactions_view_transaction') |
|
| 1709 | - ) { |
|
| 1710 | - $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1711 | - 'action' => 'view_transaction', |
|
| 1712 | - 'TXN_ID' => $transaction->ID(), |
|
| 1713 | - ), TXN_ADMIN_URL), esc_html__(' View Transaction'), 'button secondary-button right', |
|
| 1714 | - 'dashicons dashicons-cart'); |
|
| 1715 | - } else { |
|
| 1716 | - $this->_template_args['view_transaction_button'] = ''; |
|
| 1717 | - } |
|
| 1718 | - if ($attendee instanceof EE_Attendee |
|
| 1719 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
| 1720 | - 'espresso_registrations_resend_registration') |
|
| 1721 | - ) { |
|
| 1722 | - $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1723 | - 'action' => 'resend_registration', |
|
| 1724 | - '_REG_ID' => $this->_registration->ID(), |
|
| 1725 | - 'redirect_to' => 'view_registration', |
|
| 1726 | - ), REG_ADMIN_URL), esc_html__(' Resend Registration'), 'button secondary-button right', |
|
| 1727 | - 'dashicons dashicons-email-alt'); |
|
| 1728 | - } else { |
|
| 1729 | - $this->_template_args['resend_registration_button'] = ''; |
|
| 1730 | - } |
|
| 1731 | - $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 1732 | - $payment = $transaction->get_first_related('Payment'); |
|
| 1733 | - $payment = ! $payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment; |
|
| 1734 | - $payment_method = $payment->get_first_related('Payment_Method'); |
|
| 1735 | - $payment_method = ! $payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance() |
|
| 1736 | - : $payment_method; |
|
| 1737 | - $reg_details = array( |
|
| 1738 | - 'payment_method' => $payment_method->name(), |
|
| 1739 | - 'response_msg' => $payment->gateway_response(), |
|
| 1740 | - 'registration_id' => $this->_registration->get('REG_code'), |
|
| 1741 | - 'registration_session' => $this->_registration->session_ID(), |
|
| 1742 | - 'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '', |
|
| 1743 | - 'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '', |
|
| 1744 | - ); |
|
| 1745 | - if (isset($reg_details['registration_id'])) { |
|
| 1746 | - $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id']; |
|
| 1747 | - $this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso'); |
|
| 1748 | - $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text'; |
|
| 1749 | - } |
|
| 1750 | - if (isset($reg_details['payment_method'])) { |
|
| 1751 | - $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method']; |
|
| 1752 | - $this->_template_args['reg_details']['payment_method']['label'] = __('Most Recent Payment Method', |
|
| 1753 | - 'event_espresso'); |
|
| 1754 | - $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text'; |
|
| 1755 | - $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg']; |
|
| 1756 | - $this->_template_args['reg_details']['response_msg']['label'] = __('Payment method response', |
|
| 1757 | - 'event_espresso'); |
|
| 1758 | - $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text'; |
|
| 1759 | - } |
|
| 1760 | - $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session']; |
|
| 1761 | - $this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session', |
|
| 1762 | - 'event_espresso'); |
|
| 1763 | - $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text'; |
|
| 1764 | - $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address']; |
|
| 1765 | - $this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP', |
|
| 1766 | - 'event_espresso'); |
|
| 1767 | - $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text'; |
|
| 1768 | - $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent']; |
|
| 1769 | - $this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', |
|
| 1770 | - 'event_espresso'); |
|
| 1771 | - $this->_template_args['reg_details']['user_agent']['class'] = 'large-text'; |
|
| 1772 | - $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1773 | - 'action' => 'default', |
|
| 1774 | - 'event_id' => $this->_registration->event_ID(), |
|
| 1775 | - ), REG_ADMIN_URL); |
|
| 1776 | - $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 1777 | - $this->_template_args['event_id'] = $this->_registration->event_ID(); |
|
| 1778 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
| 1779 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 1780 | - } |
|
| 1781 | - |
|
| 1782 | - |
|
| 1783 | - /** |
|
| 1784 | - * generates HTML for the Registration Questions meta box. |
|
| 1785 | - * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters), |
|
| 1786 | - * otherwise uses new forms system |
|
| 1787 | - * |
|
| 1788 | - * @access public |
|
| 1789 | - * @return void |
|
| 1790 | - */ |
|
| 1791 | - public function _reg_questions_meta_box() |
|
| 1792 | - { |
|
| 1793 | - //allow someone to override this method entirely |
|
| 1794 | - if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, |
|
| 1795 | - $this->_registration)) { |
|
| 1796 | - $form = $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
| 1797 | - $this->_template_args['att_questions'] = count($form->subforms()) > 0 ? $form->get_html_and_js() : ''; |
|
| 1798 | - $this->_template_args['reg_questions_form_action'] = 'edit_registration'; |
|
| 1799 | - $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 1800 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 1801 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 1802 | - } |
|
| 1803 | - } |
|
| 1804 | - |
|
| 1805 | - |
|
| 1806 | - /** |
|
| 1807 | - * form_before_question_group |
|
| 1808 | - * |
|
| 1809 | - * @deprecated as of 4.8.32.rc.000 |
|
| 1810 | - * @access public |
|
| 1811 | - * @param string $output |
|
| 1812 | - * @return string |
|
| 1813 | - */ |
|
| 1814 | - public function form_before_question_group($output) |
|
| 1815 | - { |
|
| 1816 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1817 | - __('This method would have been protected but was used on a filter callback' |
|
| 1818 | - . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
| 1819 | - '4.8.32.rc.000'); |
|
| 1820 | - return ' |
|
| 1043 | + if ( ! empty($registration_status)) { |
|
| 1044 | + $where['STS_ID'] = $registration_status; |
|
| 1045 | + } else { |
|
| 1046 | + //make sure we exclude incomplete registrations, but only if not trashed. |
|
| 1047 | + if ($view === 'trash') { |
|
| 1048 | + $where['REG_deleted'] = true; |
|
| 1049 | + } else if ($view === 'incomplete') { |
|
| 1050 | + $where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
| 1051 | + } else { |
|
| 1052 | + $where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 1053 | + } |
|
| 1054 | + } |
|
| 1055 | + return $where; |
|
| 1056 | + } |
|
| 1057 | + |
|
| 1058 | + |
|
| 1059 | + /** |
|
| 1060 | + * Adds any provided date restraints to the where conditions for the registrations query. |
|
| 1061 | + * |
|
| 1062 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1063 | + * @return array |
|
| 1064 | + */ |
|
| 1065 | + protected function _add_date_to_where_conditions(array $request) |
|
| 1066 | + { |
|
| 1067 | + $where = array(); |
|
| 1068 | + $view = EEH_Array::is_set( $request, 'status', '' ); |
|
| 1069 | + $month_range = ! empty($request['month_range']) |
|
| 1070 | + ? sanitize_text_field($request['month_range']) |
|
| 1071 | + : ''; |
|
| 1072 | + $retrieve_for_today = $view === 'today'; |
|
| 1073 | + $retrieve_for_this_month = $view === 'month'; |
|
| 1074 | + |
|
| 1075 | + if ($retrieve_for_today) { |
|
| 1076 | + $now = date('Y-m-d', current_time('timestamp')); |
|
| 1077 | + $where['REG_date'] = array( |
|
| 1078 | + 'BETWEEN', |
|
| 1079 | + array( |
|
| 1080 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1081 | + 'REG_date', |
|
| 1082 | + $now . ' 00:00:00', |
|
| 1083 | + 'Y-m-d H:i:s' |
|
| 1084 | + ), |
|
| 1085 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1086 | + 'REG_date', |
|
| 1087 | + $now . ' 23:59:59', |
|
| 1088 | + 'Y-m-d H:i:s' |
|
| 1089 | + ), |
|
| 1090 | + ), |
|
| 1091 | + ); |
|
| 1092 | + } elseif ($retrieve_for_this_month) { |
|
| 1093 | + $current_year_and_month = date('Y-m', current_time('timestamp')); |
|
| 1094 | + $days_this_month = date('t', current_time('timestamp')); |
|
| 1095 | + $where['REG_date'] = array( |
|
| 1096 | + 'BETWEEN', |
|
| 1097 | + array( |
|
| 1098 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1099 | + 'REG_date', |
|
| 1100 | + $current_year_and_month . '-01 00:00:00', |
|
| 1101 | + 'Y-m-d H:i:s' |
|
| 1102 | + ), |
|
| 1103 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1104 | + 'REG_date', |
|
| 1105 | + $current_year_and_month . '-' . $days_this_month . ' 23:59:59', |
|
| 1106 | + 'Y-m-d H:i:s' |
|
| 1107 | + ), |
|
| 1108 | + ), |
|
| 1109 | + ); |
|
| 1110 | + } elseif ($month_range) { |
|
| 1111 | + $pieces = explode(' ', $month_range, 3); |
|
| 1112 | + $month_requested = ! empty($pieces[0]) |
|
| 1113 | + ? date('m', strtotime($month_range)) |
|
| 1114 | + : ''; |
|
| 1115 | + $year_requested = ! empty($pieces[1]) |
|
| 1116 | + ? $pieces[1] |
|
| 1117 | + : ''; |
|
| 1118 | + //if there is not a month or year then we can't go further |
|
| 1119 | + if ($month_requested && $year_requested) { |
|
| 1120 | + $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01')); |
|
| 1121 | + $where['REG_date'] = array( |
|
| 1122 | + 'BETWEEN', |
|
| 1123 | + array( |
|
| 1124 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1125 | + 'REG_date', |
|
| 1126 | + $year_requested . '-' . $month_requested . '-01 00:00:00', |
|
| 1127 | + 'Y-m-d H:i:s' |
|
| 1128 | + ), |
|
| 1129 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 1130 | + 'REG_date', |
|
| 1131 | + $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59', |
|
| 1132 | + 'Y-m-d H:i:s' |
|
| 1133 | + ), |
|
| 1134 | + ), |
|
| 1135 | + ); |
|
| 1136 | + } |
|
| 1137 | + } |
|
| 1138 | + return $where; |
|
| 1139 | + } |
|
| 1140 | + |
|
| 1141 | + |
|
| 1142 | + /** |
|
| 1143 | + * Adds any provided search restraints to the where conditions for the registrations query |
|
| 1144 | + * |
|
| 1145 | + * @param array $request usually the same as $this->_req_data but not necessarily |
|
| 1146 | + * @return array |
|
| 1147 | + */ |
|
| 1148 | + protected function _add_search_to_where_conditions(array $request) |
|
| 1149 | + { |
|
| 1150 | + $where = array(); |
|
| 1151 | + if ( ! empty($request['s'])) { |
|
| 1152 | + $search_string = '%' . sanitize_text_field($request['s']) . '%'; |
|
| 1153 | + $where['OR'] = array( |
|
| 1154 | + 'Event.EVT_name' => array('LIKE', $search_string), |
|
| 1155 | + 'Event.EVT_desc' => array('LIKE', $search_string), |
|
| 1156 | + 'Event.EVT_short_desc' => array('LIKE', $search_string), |
|
| 1157 | + 'Attendee.ATT_full_name' => array('LIKE', $search_string), |
|
| 1158 | + 'Attendee.ATT_fname' => array('LIKE', $search_string), |
|
| 1159 | + 'Attendee.ATT_lname' => array('LIKE', $search_string), |
|
| 1160 | + 'Attendee.ATT_short_bio' => array('LIKE', $search_string), |
|
| 1161 | + 'Attendee.ATT_email' => array('LIKE', $search_string), |
|
| 1162 | + 'Attendee.ATT_address' => array('LIKE', $search_string), |
|
| 1163 | + 'Attendee.ATT_address2' => array('LIKE', $search_string), |
|
| 1164 | + 'Attendee.ATT_city' => array('LIKE', $search_string), |
|
| 1165 | + 'REG_final_price' => array('LIKE', $search_string), |
|
| 1166 | + 'REG_code' => array('LIKE', $search_string), |
|
| 1167 | + 'REG_count' => array('LIKE', $search_string), |
|
| 1168 | + 'REG_group_size' => array('LIKE', $search_string), |
|
| 1169 | + 'Ticket.TKT_name' => array('LIKE', $search_string), |
|
| 1170 | + 'Ticket.TKT_description' => array('LIKE', $search_string), |
|
| 1171 | + 'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string), |
|
| 1172 | + ); |
|
| 1173 | + } |
|
| 1174 | + return $where; |
|
| 1175 | + } |
|
| 1176 | + |
|
| 1177 | + |
|
| 1178 | + /** |
|
| 1179 | + * Sets up the where conditions for the registrations query. |
|
| 1180 | + * |
|
| 1181 | + * @param array $request |
|
| 1182 | + * @return array |
|
| 1183 | + */ |
|
| 1184 | + protected function _get_where_conditions_for_registrations_query($request) |
|
| 1185 | + { |
|
| 1186 | + return array_merge( |
|
| 1187 | + $this->_add_event_id_to_where_conditions($request), |
|
| 1188 | + $this->_add_category_id_to_where_conditions($request), |
|
| 1189 | + $this->_add_datetime_id_to_where_conditions($request), |
|
| 1190 | + $this->_add_registration_status_to_where_conditions($request), |
|
| 1191 | + $this->_add_date_to_where_conditions($request), |
|
| 1192 | + $this->_add_search_to_where_conditions($request) |
|
| 1193 | + ); |
|
| 1194 | + } |
|
| 1195 | + |
|
| 1196 | + |
|
| 1197 | + /** |
|
| 1198 | + * Sets up the orderby for the registrations query. |
|
| 1199 | + * |
|
| 1200 | + * @return array |
|
| 1201 | + */ |
|
| 1202 | + protected function _get_orderby_for_registrations_query() |
|
| 1203 | + { |
|
| 1204 | + $orderby_field = ! empty($this->_req_data['orderby']) |
|
| 1205 | + ? sanitize_text_field($this->_req_data['orderby']) |
|
| 1206 | + : ''; |
|
| 1207 | + switch ($orderby_field) { |
|
| 1208 | + case '_REG_ID': |
|
| 1209 | + $orderby_field = 'REG_ID'; |
|
| 1210 | + break; |
|
| 1211 | + case '_Reg_status': |
|
| 1212 | + $orderby_field = 'STS_ID'; |
|
| 1213 | + break; |
|
| 1214 | + case 'ATT_fname': |
|
| 1215 | + //just for spite, we're going to order it by their LAST name, NOT their first name. Now who's the boss? |
|
| 1216 | + //jk, we don't want to break existing links, and customers preferred ordering by last name |
|
| 1217 | + //besides, from the UI, its ambiguous as to whether we will order by first or last name |
|
| 1218 | + $orderby_field = 'Attendee.ATT_lname'; |
|
| 1219 | + break; |
|
| 1220 | + case 'event_name': |
|
| 1221 | + $orderby_field = 'Event.EVT_name'; |
|
| 1222 | + break; |
|
| 1223 | + case 'DTT_EVT_start': |
|
| 1224 | + $orderby_field = 'Event.Datetime.DTT_EVT_start'; |
|
| 1225 | + break; |
|
| 1226 | + default: //'REG_date' |
|
| 1227 | + $orderby_field = 'REG_date'; |
|
| 1228 | + } |
|
| 1229 | + |
|
| 1230 | + //order |
|
| 1231 | + $order = ! empty($this->_req_data['order']) |
|
| 1232 | + ? sanitize_text_field($this->_req_data['order']) |
|
| 1233 | + : 'DESC'; |
|
| 1234 | + return array('order_by' => array($orderby_field => $order)); |
|
| 1235 | + } |
|
| 1236 | + |
|
| 1237 | + |
|
| 1238 | + /** |
|
| 1239 | + * Sets up the limit for the registrations query. |
|
| 1240 | + * |
|
| 1241 | + * @param $per_page |
|
| 1242 | + * @return array |
|
| 1243 | + */ |
|
| 1244 | + protected function _get_limit($per_page) |
|
| 1245 | + { |
|
| 1246 | + $current_page = ! empty($this->_req_data['paged']) |
|
| 1247 | + ? absint($this->_req_data['paged']) |
|
| 1248 | + : 1; |
|
| 1249 | + $per_page = ! empty($this->_req_data['perpage']) |
|
| 1250 | + ? $this->_req_data['perpage'] |
|
| 1251 | + : $per_page; |
|
| 1252 | + |
|
| 1253 | + //-1 means return all results so get out if that's set. |
|
| 1254 | + if ((int)$per_page === -1) { |
|
| 1255 | + return array(); |
|
| 1256 | + } |
|
| 1257 | + $per_page = absint($per_page); |
|
| 1258 | + $offset = ($current_page - 1) * $per_page; |
|
| 1259 | + return array('limit' => array($offset, $per_page)); |
|
| 1260 | + } |
|
| 1261 | + |
|
| 1262 | + |
|
| 1263 | + public function get_registration_status_array() |
|
| 1264 | + { |
|
| 1265 | + return self::$_reg_status; |
|
| 1266 | + } |
|
| 1267 | + |
|
| 1268 | + |
|
| 1269 | + |
|
| 1270 | + |
|
| 1271 | + /*************************************** REGISTRATION DETAILS ***************************************/ |
|
| 1272 | + /** |
|
| 1273 | + * generates HTML for the View Registration Details Admin page |
|
| 1274 | + * |
|
| 1275 | + * @access protected |
|
| 1276 | + * @return void |
|
| 1277 | + */ |
|
| 1278 | + protected function _registration_details() |
|
| 1279 | + { |
|
| 1280 | + $this->_template_args = array(); |
|
| 1281 | + $this->_set_registration_object(); |
|
| 1282 | + if (is_object($this->_registration)) { |
|
| 1283 | + $transaction = $this->_registration->transaction() ? $this->_registration->transaction() |
|
| 1284 | + : EE_Transaction::new_instance(); |
|
| 1285 | + $this->_session = $transaction->session_data(); |
|
| 1286 | + $event_id = $this->_registration->event_ID(); |
|
| 1287 | + $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID(); |
|
| 1288 | + $this->_template_args['reg_nmbr']['label'] = __('Registration Number', 'event_espresso'); |
|
| 1289 | + $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date'); |
|
| 1290 | + $this->_template_args['reg_datetime']['label'] = __('Date', 'event_espresso'); |
|
| 1291 | + $this->_template_args['grand_total'] = $transaction->total(); |
|
| 1292 | + $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 1293 | + // link back to overview |
|
| 1294 | + $this->_template_args['reg_overview_url'] = REG_ADMIN_URL; |
|
| 1295 | + $this->_template_args['registration'] = $this->_registration; |
|
| 1296 | + $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1297 | + 'action' => 'default', |
|
| 1298 | + 'event_id' => $event_id, |
|
| 1299 | + ), REG_ADMIN_URL); |
|
| 1300 | + $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1301 | + 'action' => 'default', |
|
| 1302 | + 'EVT_ID' => $event_id, |
|
| 1303 | + 'page' => 'espresso_transactions', |
|
| 1304 | + ), admin_url('admin.php')); |
|
| 1305 | + $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1306 | + 'page' => 'espresso_events', |
|
| 1307 | + 'action' => 'edit', |
|
| 1308 | + 'post' => $event_id, |
|
| 1309 | + ), admin_url('admin.php')); |
|
| 1310 | + //next and previous links |
|
| 1311 | + $next_reg = $this->_registration->next(null, array(), 'REG_ID'); |
|
| 1312 | + $this->_template_args['next_registration'] = $next_reg |
|
| 1313 | + ? $this->_next_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1314 | + 'action' => 'view_registration', |
|
| 1315 | + '_REG_ID' => $next_reg['REG_ID'], |
|
| 1316 | + ), REG_ADMIN_URL), 'dashicons dashicons-arrow-right ee-icon-size-22') : ''; |
|
| 1317 | + $previous_reg = $this->_registration->previous(null, array(), 'REG_ID'); |
|
| 1318 | + $this->_template_args['previous_registration'] = $previous_reg |
|
| 1319 | + ? $this->_previous_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1320 | + 'action' => 'view_registration', |
|
| 1321 | + '_REG_ID' => $previous_reg['REG_ID'], |
|
| 1322 | + ), REG_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : ''; |
|
| 1323 | + // grab header |
|
| 1324 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php'; |
|
| 1325 | + $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 1326 | + $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, |
|
| 1327 | + $this->_template_args, true); |
|
| 1328 | + } else { |
|
| 1329 | + $this->_template_args['admin_page_header'] = $this->display_espresso_notices(); |
|
| 1330 | + } |
|
| 1331 | + // the details template wrapper |
|
| 1332 | + $this->display_admin_page_with_sidebar(); |
|
| 1333 | + } |
|
| 1334 | + |
|
| 1335 | + |
|
| 1336 | + protected function _registration_details_metaboxes() |
|
| 1337 | + { |
|
| 1338 | + do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this); |
|
| 1339 | + $this->_set_registration_object(); |
|
| 1340 | + $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null; |
|
| 1341 | + add_meta_box('edit-reg-status-mbox', __('Registration Status', 'event_espresso'), |
|
| 1342 | + array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1343 | + add_meta_box('edit-reg-details-mbox', __('Registration Details', 'event_espresso'), |
|
| 1344 | + array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1345 | + if ($attendee instanceof EE_Attendee |
|
| 1346 | + && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox') |
|
| 1347 | + ) { |
|
| 1348 | + add_meta_box('edit-reg-questions-mbox', __('Registration Form Answers', 'event_espresso'), |
|
| 1349 | + array($this, '_reg_questions_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1350 | + } |
|
| 1351 | + add_meta_box('edit-reg-registrant-mbox', __('Contact Details', 'event_espresso'), |
|
| 1352 | + array($this, '_reg_registrant_side_meta_box'), $this->wp_page_slug, 'side', 'high'); |
|
| 1353 | + if ($this->_registration->group_size() > 1) { |
|
| 1354 | + add_meta_box('edit-reg-attendees-mbox', __('Other Registrations in this Transaction', 'event_espresso'), |
|
| 1355 | + array($this, '_reg_attendees_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1356 | + } |
|
| 1357 | + } |
|
| 1358 | + |
|
| 1359 | + |
|
| 1360 | + /** |
|
| 1361 | + * set_reg_status_buttons_metabox |
|
| 1362 | + * |
|
| 1363 | + * @access protected |
|
| 1364 | + * @return string |
|
| 1365 | + * @throws \EE_Error |
|
| 1366 | + */ |
|
| 1367 | + public function set_reg_status_buttons_metabox() |
|
| 1368 | + { |
|
| 1369 | + $this->_set_registration_object(); |
|
| 1370 | + $change_reg_status_form = $this->_generate_reg_status_change_form(); |
|
| 1371 | + echo $change_reg_status_form->form_open(self::add_query_args_and_nonce(array( |
|
| 1372 | + 'action' => 'change_reg_status', |
|
| 1373 | + ), REG_ADMIN_URL)); |
|
| 1374 | + echo $change_reg_status_form->get_html(); |
|
| 1375 | + echo $change_reg_status_form->form_close(); |
|
| 1376 | + } |
|
| 1377 | + |
|
| 1378 | + |
|
| 1379 | + /** |
|
| 1380 | + * @return EE_Form_Section_Proper |
|
| 1381 | + */ |
|
| 1382 | + protected function _generate_reg_status_change_form() |
|
| 1383 | + { |
|
| 1384 | + return new EE_Form_Section_Proper(array( |
|
| 1385 | + 'name' => 'reg_status_change_form', |
|
| 1386 | + 'html_id' => 'reg-status-change-form', |
|
| 1387 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
| 1388 | + 'subsections' => array( |
|
| 1389 | + 'return' => new EE_Hidden_Input(array( |
|
| 1390 | + 'name' => 'return', |
|
| 1391 | + 'default' => 'view_registration', |
|
| 1392 | + )), |
|
| 1393 | + 'REG_ID' => new EE_Hidden_Input(array( |
|
| 1394 | + 'name' => 'REG_ID', |
|
| 1395 | + 'default' => $this->_registration->ID(), |
|
| 1396 | + )), |
|
| 1397 | + 'current_status' => new EE_Form_Section_HTML(EEH_HTML::tr(EEH_HTML::th(EEH_HTML::label(EEH_HTML::strong(__('Current Registration Status', |
|
| 1398 | + 'event_espresso')))) . EEH_HTML::td(EEH_HTML::strong($this->_registration->pretty_status(), |
|
| 1399 | + '', 'status-' . $this->_registration->status_ID(), |
|
| 1400 | + 'line-height: 1em; font-size: 1.5em; font-weight: bold;')))), |
|
| 1401 | + 'reg_status' => new EE_Select_Input($this->_get_reg_statuses(), array( |
|
| 1402 | + 'html_label_text' => __('Change Registration Status to', 'event_espresso'), |
|
| 1403 | + 'default' => $this->_registration->status_ID(), |
|
| 1404 | + )), |
|
| 1405 | + 'send_notifications' => new EE_Yes_No_Input(array( |
|
| 1406 | + 'html_label_text' => __('Send Related Messages', 'event_espresso'), |
|
| 1407 | + 'default' => false, |
|
| 1408 | + 'html_help_text' => __('If set to "Yes", then the related messages will be sent to the registrant.', |
|
| 1409 | + 'event_espresso'), |
|
| 1410 | + )), |
|
| 1411 | + 'submit' => new EE_Submit_Input(array( |
|
| 1412 | + 'html_class' => 'button-primary', |
|
| 1413 | + 'html_label_text' => ' ', |
|
| 1414 | + 'default' => __('Update Registration Status', 'event_espresso'), |
|
| 1415 | + )), |
|
| 1416 | + ), |
|
| 1417 | + )); |
|
| 1418 | + } |
|
| 1419 | + |
|
| 1420 | + |
|
| 1421 | + |
|
| 1422 | + /** |
|
| 1423 | + * Returns an array of all the buttons for the various statuses and switch status actions |
|
| 1424 | + * |
|
| 1425 | + * @return array |
|
| 1426 | + */ |
|
| 1427 | + protected function _get_reg_statuses() |
|
| 1428 | + { |
|
| 1429 | + $reg_status_array = EEM_Registration::instance()->reg_status_array(); |
|
| 1430 | + unset ($reg_status_array[EEM_Registration::status_id_incomplete]); |
|
| 1431 | + // get current reg status |
|
| 1432 | + $current_status = $this->_registration->status_ID(); |
|
| 1433 | + // is registration for free event? This will determine whether to display the pending payment option |
|
| 1434 | + if ($current_status != EEM_Registration::status_id_pending_payment |
|
| 1435 | + && $this->_registration->transaction() |
|
| 1436 | + ->is_free() |
|
| 1437 | + ) { |
|
| 1438 | + unset($reg_status_array[EEM_Registration::status_id_pending_payment]); |
|
| 1439 | + } |
|
| 1440 | + return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence'); |
|
| 1441 | + } |
|
| 1442 | + |
|
| 1443 | + |
|
| 1444 | + /** |
|
| 1445 | + * This method is used when using _REG_ID from request which may or may not be an array of reg_ids. |
|
| 1446 | + * |
|
| 1447 | + * @param bool $status REG status given for changing registrations to. |
|
| 1448 | + * @param bool $notify Whether to send messages notifications or not. |
|
| 1449 | + * @return array (array with reg_id(s) updated and whether update was successful. |
|
| 1450 | + */ |
|
| 1451 | + protected function _set_registration_status_from_request($status = false, $notify = false) |
|
| 1452 | + { |
|
| 1453 | + if (isset($this->_req_data['reg_status_change_form'])) { |
|
| 1454 | + $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID']) |
|
| 1455 | + ? (array)$this->_req_data['reg_status_change_form']['REG_ID'] : array(); |
|
| 1456 | + } else { |
|
| 1457 | + $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array)$this->_req_data['_REG_ID'] : array(); |
|
| 1458 | + } |
|
| 1459 | + $success = $this->_set_registration_status($REG_IDs, $status); |
|
| 1460 | + //notify? |
|
| 1461 | + if ($success |
|
| 1462 | + && $notify |
|
| 1463 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
| 1464 | + 'espresso_registrations_resend_registration') |
|
| 1465 | + ) { |
|
| 1466 | + $this->_process_resend_registration(); |
|
| 1467 | + } |
|
| 1468 | + return $success; |
|
| 1469 | + } |
|
| 1470 | + |
|
| 1471 | + |
|
| 1472 | + /** |
|
| 1473 | + * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an |
|
| 1474 | + * array). Note, this method does NOT take care of possible notifications. That is required by calling code. |
|
| 1475 | + * |
|
| 1476 | + * @param array $REG_IDs |
|
| 1477 | + * @param bool $status |
|
| 1478 | + * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as |
|
| 1479 | + * the array of updated registrations). |
|
| 1480 | + */ |
|
| 1481 | + protected function _set_registration_status($REG_IDs = array(), $status = false) |
|
| 1482 | + { |
|
| 1483 | + $success = false; |
|
| 1484 | + // typecast $REG_IDs |
|
| 1485 | + $REG_IDs = (array)$REG_IDs; |
|
| 1486 | + if ( ! empty($REG_IDs)) { |
|
| 1487 | + $success = true; |
|
| 1488 | + // set default status if none is passed |
|
| 1489 | + $status = $status ? $status : EEM_Registration::status_id_pending_payment; |
|
| 1490 | + // sanitize $REG_IDs |
|
| 1491 | + $REG_IDs = array_filter($REG_IDs, 'absint'); |
|
| 1492 | + //loop through REG_ID's and change status |
|
| 1493 | + foreach ($REG_IDs as $REG_ID) { |
|
| 1494 | + $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 1495 | + if ($registration instanceof EE_Registration) { |
|
| 1496 | + $registration->set_status($status); |
|
| 1497 | + $result = $registration->save(); |
|
| 1498 | + // verifying explicit fails because update *may* just return 0 for 0 rows affected |
|
| 1499 | + $success = $result !== false ? $success : false; |
|
| 1500 | + } |
|
| 1501 | + } |
|
| 1502 | + } |
|
| 1503 | + //reset _req_data['_REG_ID'] for any potential future messages notifications |
|
| 1504 | + $this->_req_data['_REG_ID'] = $REG_IDs; |
|
| 1505 | + //return $success and processed registrations |
|
| 1506 | + return array('REG_ID' => $REG_IDs, 'success' => $success); |
|
| 1507 | + } |
|
| 1508 | + |
|
| 1509 | + |
|
| 1510 | + /** |
|
| 1511 | + * Common logic for setting up success message and redirecting to appropriate route |
|
| 1512 | + * |
|
| 1513 | + * @param string $STS_ID status id for the registration changed to |
|
| 1514 | + * @param bool $notify indicates whether the _set_registration_status_from_request does notifications or not. |
|
| 1515 | + * @return void |
|
| 1516 | + */ |
|
| 1517 | + protected function _reg_status_change_return($STS_ID, $notify = false) |
|
| 1518 | + { |
|
| 1519 | + $result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify) |
|
| 1520 | + : array('success' => false); |
|
| 1521 | + $success = isset($result['success']) && $result['success']; |
|
| 1522 | + //setup success message |
|
| 1523 | + if ($success) { |
|
| 1524 | + if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) { |
|
| 1525 | + $msg = sprintf(__('Registration status has been set to %s', 'event_espresso'), |
|
| 1526 | + EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
| 1527 | + } else { |
|
| 1528 | + $msg = sprintf(__('Registrations have been set to %s.', 'event_espresso'), |
|
| 1529 | + EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
| 1530 | + } |
|
| 1531 | + EE_Error::add_success($msg); |
|
| 1532 | + } else { |
|
| 1533 | + EE_Error::add_error(__('Something went wrong, and the status was not changed', 'event_espresso'), __FILE__, |
|
| 1534 | + __LINE__, __FUNCTION__); |
|
| 1535 | + } |
|
| 1536 | + if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') { |
|
| 1537 | + $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])); |
|
| 1538 | + } else { |
|
| 1539 | + $route = array('action' => 'default'); |
|
| 1540 | + } |
|
| 1541 | + //unset nonces |
|
| 1542 | + foreach ($this->_req_data as $ref => $value) { |
|
| 1543 | + if (strpos($ref, 'nonce') !== false) { |
|
| 1544 | + unset($this->_req_data[$ref]); |
|
| 1545 | + continue; |
|
| 1546 | + } |
|
| 1547 | + $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value); |
|
| 1548 | + $this->_req_data[$ref] = $value; |
|
| 1549 | + } |
|
| 1550 | + //merge request vars so that the reloaded list table contains any existing filter query params |
|
| 1551 | + $route = array_merge($this->_req_data, $route); |
|
| 1552 | + $this->_redirect_after_action($success, '', '', $route, true); |
|
| 1553 | + } |
|
| 1554 | + |
|
| 1555 | + |
|
| 1556 | + /** |
|
| 1557 | + * incoming reg status change from reg details page. |
|
| 1558 | + * |
|
| 1559 | + * @return void |
|
| 1560 | + */ |
|
| 1561 | + protected function _change_reg_status() |
|
| 1562 | + { |
|
| 1563 | + $this->_req_data['return'] = 'view_registration'; |
|
| 1564 | + //set notify based on whether the send notifications toggle is set or not |
|
| 1565 | + $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']); |
|
| 1566 | + //$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] ); |
|
| 1567 | + $this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status']) |
|
| 1568 | + ? $this->_req_data['reg_status_change_form']['reg_status'] : ''; |
|
| 1569 | + switch ($this->_req_data['reg_status_change_form']['reg_status']) { |
|
| 1570 | + case EEM_Registration::status_id_approved : |
|
| 1571 | + case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') : |
|
| 1572 | + $this->approve_registration($notify); |
|
| 1573 | + break; |
|
| 1574 | + case EEM_Registration::status_id_pending_payment : |
|
| 1575 | + case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') : |
|
| 1576 | + $this->pending_registration($notify); |
|
| 1577 | + break; |
|
| 1578 | + case EEM_Registration::status_id_not_approved : |
|
| 1579 | + case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') : |
|
| 1580 | + $this->not_approve_registration($notify); |
|
| 1581 | + break; |
|
| 1582 | + case EEM_Registration::status_id_declined : |
|
| 1583 | + case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') : |
|
| 1584 | + $this->decline_registration($notify); |
|
| 1585 | + break; |
|
| 1586 | + case EEM_Registration::status_id_cancelled : |
|
| 1587 | + case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') : |
|
| 1588 | + $this->cancel_registration($notify); |
|
| 1589 | + break; |
|
| 1590 | + case EEM_Registration::status_id_wait_list : |
|
| 1591 | + case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') : |
|
| 1592 | + $this->waitlist_registration($notify); |
|
| 1593 | + break; |
|
| 1594 | + case EEM_Registration::status_id_incomplete : |
|
| 1595 | + default : |
|
| 1596 | + $result['success'] = false; |
|
| 1597 | + unset($this->_req_data['return']); |
|
| 1598 | + $this->_reg_status_change_return('', false); |
|
| 1599 | + break; |
|
| 1600 | + } |
|
| 1601 | + } |
|
| 1602 | + |
|
| 1603 | + |
|
| 1604 | + /** |
|
| 1605 | + * approve_registration |
|
| 1606 | + * |
|
| 1607 | + * @access protected |
|
| 1608 | + * @param bool $notify whether or not to notify the registrant about their approval. |
|
| 1609 | + * @return void |
|
| 1610 | + */ |
|
| 1611 | + protected function approve_registration($notify = false) |
|
| 1612 | + { |
|
| 1613 | + $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify); |
|
| 1614 | + } |
|
| 1615 | + |
|
| 1616 | + |
|
| 1617 | + /** |
|
| 1618 | + * decline_registration |
|
| 1619 | + * |
|
| 1620 | + * @access protected |
|
| 1621 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1622 | + * @return void |
|
| 1623 | + */ |
|
| 1624 | + protected function decline_registration($notify = false) |
|
| 1625 | + { |
|
| 1626 | + $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify); |
|
| 1627 | + } |
|
| 1628 | + |
|
| 1629 | + |
|
| 1630 | + /** |
|
| 1631 | + * cancel_registration |
|
| 1632 | + * |
|
| 1633 | + * @access protected |
|
| 1634 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1635 | + * @return void |
|
| 1636 | + */ |
|
| 1637 | + protected function cancel_registration($notify = false) |
|
| 1638 | + { |
|
| 1639 | + $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify); |
|
| 1640 | + } |
|
| 1641 | + |
|
| 1642 | + |
|
| 1643 | + /** |
|
| 1644 | + * not_approve_registration |
|
| 1645 | + * |
|
| 1646 | + * @access protected |
|
| 1647 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1648 | + * @return void |
|
| 1649 | + */ |
|
| 1650 | + protected function not_approve_registration($notify = false) |
|
| 1651 | + { |
|
| 1652 | + $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify); |
|
| 1653 | + } |
|
| 1654 | + |
|
| 1655 | + |
|
| 1656 | + /** |
|
| 1657 | + * decline_registration |
|
| 1658 | + * |
|
| 1659 | + * @access protected |
|
| 1660 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1661 | + * @return void |
|
| 1662 | + */ |
|
| 1663 | + protected function pending_registration($notify = false) |
|
| 1664 | + { |
|
| 1665 | + $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify); |
|
| 1666 | + } |
|
| 1667 | + |
|
| 1668 | + |
|
| 1669 | + /** |
|
| 1670 | + * waitlist_registration |
|
| 1671 | + * |
|
| 1672 | + * @access protected |
|
| 1673 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
| 1674 | + * @return void |
|
| 1675 | + */ |
|
| 1676 | + protected function waitlist_registration($notify = false) |
|
| 1677 | + { |
|
| 1678 | + $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify); |
|
| 1679 | + } |
|
| 1680 | + |
|
| 1681 | + |
|
| 1682 | + /** |
|
| 1683 | + * generates HTML for the Registration main meta box |
|
| 1684 | + * |
|
| 1685 | + * @access public |
|
| 1686 | + * @return void |
|
| 1687 | + */ |
|
| 1688 | + public function _reg_details_meta_box() |
|
| 1689 | + { |
|
| 1690 | + EEH_Autoloader::register_line_item_display_autoloaders(); |
|
| 1691 | + EEH_Autoloader::register_line_item_filter_autoloaders(); |
|
| 1692 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
| 1693 | + $transaction = $this->_registration->transaction() ? $this->_registration->transaction() |
|
| 1694 | + : EE_Transaction::new_instance(); |
|
| 1695 | + $this->_session = $transaction->session_data(); |
|
| 1696 | + $filters = new EE_Line_Item_Filter_Collection(); |
|
| 1697 | + //$filters->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
| 1698 | + $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration)); |
|
| 1699 | + $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, |
|
| 1700 | + $transaction->total_line_item()); |
|
| 1701 | + $filtered_line_item_tree = $line_item_filter_processor->process(); |
|
| 1702 | + $line_item_display = new EE_Line_Item_Display('reg_admin_table', |
|
| 1703 | + 'EE_Admin_Table_Registration_Line_Item_Display_Strategy'); |
|
| 1704 | + $this->_template_args['line_item_table'] = $line_item_display->display_line_item($filtered_line_item_tree, |
|
| 1705 | + array('EE_Registration' => $this->_registration)); |
|
| 1706 | + $attendee = $this->_registration->attendee(); |
|
| 1707 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
| 1708 | + 'espresso_transactions_view_transaction') |
|
| 1709 | + ) { |
|
| 1710 | + $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1711 | + 'action' => 'view_transaction', |
|
| 1712 | + 'TXN_ID' => $transaction->ID(), |
|
| 1713 | + ), TXN_ADMIN_URL), esc_html__(' View Transaction'), 'button secondary-button right', |
|
| 1714 | + 'dashicons dashicons-cart'); |
|
| 1715 | + } else { |
|
| 1716 | + $this->_template_args['view_transaction_button'] = ''; |
|
| 1717 | + } |
|
| 1718 | + if ($attendee instanceof EE_Attendee |
|
| 1719 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
| 1720 | + 'espresso_registrations_resend_registration') |
|
| 1721 | + ) { |
|
| 1722 | + $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1723 | + 'action' => 'resend_registration', |
|
| 1724 | + '_REG_ID' => $this->_registration->ID(), |
|
| 1725 | + 'redirect_to' => 'view_registration', |
|
| 1726 | + ), REG_ADMIN_URL), esc_html__(' Resend Registration'), 'button secondary-button right', |
|
| 1727 | + 'dashicons dashicons-email-alt'); |
|
| 1728 | + } else { |
|
| 1729 | + $this->_template_args['resend_registration_button'] = ''; |
|
| 1730 | + } |
|
| 1731 | + $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 1732 | + $payment = $transaction->get_first_related('Payment'); |
|
| 1733 | + $payment = ! $payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment; |
|
| 1734 | + $payment_method = $payment->get_first_related('Payment_Method'); |
|
| 1735 | + $payment_method = ! $payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance() |
|
| 1736 | + : $payment_method; |
|
| 1737 | + $reg_details = array( |
|
| 1738 | + 'payment_method' => $payment_method->name(), |
|
| 1739 | + 'response_msg' => $payment->gateway_response(), |
|
| 1740 | + 'registration_id' => $this->_registration->get('REG_code'), |
|
| 1741 | + 'registration_session' => $this->_registration->session_ID(), |
|
| 1742 | + 'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '', |
|
| 1743 | + 'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '', |
|
| 1744 | + ); |
|
| 1745 | + if (isset($reg_details['registration_id'])) { |
|
| 1746 | + $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id']; |
|
| 1747 | + $this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso'); |
|
| 1748 | + $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text'; |
|
| 1749 | + } |
|
| 1750 | + if (isset($reg_details['payment_method'])) { |
|
| 1751 | + $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method']; |
|
| 1752 | + $this->_template_args['reg_details']['payment_method']['label'] = __('Most Recent Payment Method', |
|
| 1753 | + 'event_espresso'); |
|
| 1754 | + $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text'; |
|
| 1755 | + $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg']; |
|
| 1756 | + $this->_template_args['reg_details']['response_msg']['label'] = __('Payment method response', |
|
| 1757 | + 'event_espresso'); |
|
| 1758 | + $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text'; |
|
| 1759 | + } |
|
| 1760 | + $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session']; |
|
| 1761 | + $this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session', |
|
| 1762 | + 'event_espresso'); |
|
| 1763 | + $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text'; |
|
| 1764 | + $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address']; |
|
| 1765 | + $this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP', |
|
| 1766 | + 'event_espresso'); |
|
| 1767 | + $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text'; |
|
| 1768 | + $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent']; |
|
| 1769 | + $this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', |
|
| 1770 | + 'event_espresso'); |
|
| 1771 | + $this->_template_args['reg_details']['user_agent']['class'] = 'large-text'; |
|
| 1772 | + $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1773 | + 'action' => 'default', |
|
| 1774 | + 'event_id' => $this->_registration->event_ID(), |
|
| 1775 | + ), REG_ADMIN_URL); |
|
| 1776 | + $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 1777 | + $this->_template_args['event_id'] = $this->_registration->event_ID(); |
|
| 1778 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
| 1779 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 1780 | + } |
|
| 1781 | + |
|
| 1782 | + |
|
| 1783 | + /** |
|
| 1784 | + * generates HTML for the Registration Questions meta box. |
|
| 1785 | + * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters), |
|
| 1786 | + * otherwise uses new forms system |
|
| 1787 | + * |
|
| 1788 | + * @access public |
|
| 1789 | + * @return void |
|
| 1790 | + */ |
|
| 1791 | + public function _reg_questions_meta_box() |
|
| 1792 | + { |
|
| 1793 | + //allow someone to override this method entirely |
|
| 1794 | + if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, |
|
| 1795 | + $this->_registration)) { |
|
| 1796 | + $form = $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
| 1797 | + $this->_template_args['att_questions'] = count($form->subforms()) > 0 ? $form->get_html_and_js() : ''; |
|
| 1798 | + $this->_template_args['reg_questions_form_action'] = 'edit_registration'; |
|
| 1799 | + $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
| 1800 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 1801 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 1802 | + } |
|
| 1803 | + } |
|
| 1804 | + |
|
| 1805 | + |
|
| 1806 | + /** |
|
| 1807 | + * form_before_question_group |
|
| 1808 | + * |
|
| 1809 | + * @deprecated as of 4.8.32.rc.000 |
|
| 1810 | + * @access public |
|
| 1811 | + * @param string $output |
|
| 1812 | + * @return string |
|
| 1813 | + */ |
|
| 1814 | + public function form_before_question_group($output) |
|
| 1815 | + { |
|
| 1816 | + EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1817 | + __('This method would have been protected but was used on a filter callback' |
|
| 1818 | + . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
| 1819 | + '4.8.32.rc.000'); |
|
| 1820 | + return ' |
|
| 1821 | 1821 | <table class="form-table ee-width-100"> |
| 1822 | 1822 | <tbody> |
| 1823 | 1823 | '; |
| 1824 | - } |
|
| 1825 | - |
|
| 1826 | - |
|
| 1827 | - /** |
|
| 1828 | - * form_after_question_group |
|
| 1829 | - * |
|
| 1830 | - * @deprecated as of 4.8.32.rc.000 |
|
| 1831 | - * @access public |
|
| 1832 | - * @param string $output |
|
| 1833 | - * @return string |
|
| 1834 | - */ |
|
| 1835 | - public function form_after_question_group($output) |
|
| 1836 | - { |
|
| 1837 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1838 | - __('This method would have been protected but was used on a filter callback' |
|
| 1839 | - . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
| 1840 | - '4.8.32.rc.000'); |
|
| 1841 | - return ' |
|
| 1824 | + } |
|
| 1825 | + |
|
| 1826 | + |
|
| 1827 | + /** |
|
| 1828 | + * form_after_question_group |
|
| 1829 | + * |
|
| 1830 | + * @deprecated as of 4.8.32.rc.000 |
|
| 1831 | + * @access public |
|
| 1832 | + * @param string $output |
|
| 1833 | + * @return string |
|
| 1834 | + */ |
|
| 1835 | + public function form_after_question_group($output) |
|
| 1836 | + { |
|
| 1837 | + EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1838 | + __('This method would have been protected but was used on a filter callback' |
|
| 1839 | + . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
| 1840 | + '4.8.32.rc.000'); |
|
| 1841 | + return ' |
|
| 1842 | 1842 | <tr class="hide-if-no-js"> |
| 1843 | 1843 | <th> </th> |
| 1844 | 1844 | <td class="reg-admin-edit-attendee-question-td"> |
| 1845 | 1845 | <a class="reg-admin-edit-attendee-question-lnk" href="#" title="' |
| 1846 | - . esc_attr__('click to edit question', 'event_espresso') |
|
| 1847 | - . '"> |
|
| 1846 | + . esc_attr__('click to edit question', 'event_espresso') |
|
| 1847 | + . '"> |
|
| 1848 | 1848 | <span class="reg-admin-edit-question-group-spn lt-grey-txt">' |
| 1849 | - . __('edit the above question group', 'event_espresso') |
|
| 1850 | - . '</span> |
|
| 1849 | + . __('edit the above question group', 'event_espresso') |
|
| 1850 | + . '</span> |
|
| 1851 | 1851 | <div class="dashicons dashicons-edit"></div> |
| 1852 | 1852 | </a> |
| 1853 | 1853 | </td> |
@@ -1855,494 +1855,494 @@ discard block |
||
| 1855 | 1855 | </tbody> |
| 1856 | 1856 | </table> |
| 1857 | 1857 | '; |
| 1858 | - } |
|
| 1859 | - |
|
| 1860 | - |
|
| 1861 | - /** |
|
| 1862 | - * form_form_field_label_wrap |
|
| 1863 | - * |
|
| 1864 | - * @deprecated as of 4.8.32.rc.000 |
|
| 1865 | - * @access public |
|
| 1866 | - * @param string $label |
|
| 1867 | - * @return string |
|
| 1868 | - */ |
|
| 1869 | - public function form_form_field_label_wrap($label) |
|
| 1870 | - { |
|
| 1871 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1872 | - __('This method would have been protected but was used on a filter callback' |
|
| 1873 | - . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
| 1874 | - '4.8.32.rc.000'); |
|
| 1875 | - return ' |
|
| 1858 | + } |
|
| 1859 | + |
|
| 1860 | + |
|
| 1861 | + /** |
|
| 1862 | + * form_form_field_label_wrap |
|
| 1863 | + * |
|
| 1864 | + * @deprecated as of 4.8.32.rc.000 |
|
| 1865 | + * @access public |
|
| 1866 | + * @param string $label |
|
| 1867 | + * @return string |
|
| 1868 | + */ |
|
| 1869 | + public function form_form_field_label_wrap($label) |
|
| 1870 | + { |
|
| 1871 | + EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1872 | + __('This method would have been protected but was used on a filter callback' |
|
| 1873 | + . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
| 1874 | + '4.8.32.rc.000'); |
|
| 1875 | + return ' |
|
| 1876 | 1876 | <tr> |
| 1877 | 1877 | <th> |
| 1878 | 1878 | ' . $label . ' |
| 1879 | 1879 | </th>'; |
| 1880 | - } |
|
| 1881 | - |
|
| 1882 | - |
|
| 1883 | - /** |
|
| 1884 | - * form_form_field_input__wrap |
|
| 1885 | - * |
|
| 1886 | - * @deprecated as of 4.8.32.rc.000 |
|
| 1887 | - * @access public |
|
| 1888 | - * @param string $input |
|
| 1889 | - * @return string |
|
| 1890 | - */ |
|
| 1891 | - public function form_form_field_input__wrap($input) |
|
| 1892 | - { |
|
| 1893 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1894 | - __('This method would have been protected but was used on a filter callback' |
|
| 1895 | - . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
| 1896 | - '4.8.32.rc.000'); |
|
| 1897 | - return ' |
|
| 1880 | + } |
|
| 1881 | + |
|
| 1882 | + |
|
| 1883 | + /** |
|
| 1884 | + * form_form_field_input__wrap |
|
| 1885 | + * |
|
| 1886 | + * @deprecated as of 4.8.32.rc.000 |
|
| 1887 | + * @access public |
|
| 1888 | + * @param string $input |
|
| 1889 | + * @return string |
|
| 1890 | + */ |
|
| 1891 | + public function form_form_field_input__wrap($input) |
|
| 1892 | + { |
|
| 1893 | + EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1894 | + __('This method would have been protected but was used on a filter callback' |
|
| 1895 | + . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
| 1896 | + '4.8.32.rc.000'); |
|
| 1897 | + return ' |
|
| 1898 | 1898 | <td class="reg-admin-attendee-questions-input-td disabled-input"> |
| 1899 | 1899 | ' . $input . ' |
| 1900 | 1900 | </td> |
| 1901 | 1901 | </tr>'; |
| 1902 | - } |
|
| 1903 | - |
|
| 1904 | - |
|
| 1905 | - /** |
|
| 1906 | - * Updates the registration's custom questions according to the form info, if the form is submitted. |
|
| 1907 | - * If it's not a post, the "view_registrations" route will be called next on the SAME request |
|
| 1908 | - * to display the page |
|
| 1909 | - * |
|
| 1910 | - * @access protected |
|
| 1911 | - * @return void |
|
| 1912 | - */ |
|
| 1913 | - protected function _update_attendee_registration_form() |
|
| 1914 | - { |
|
| 1915 | - do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this); |
|
| 1916 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 1917 | - $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false; |
|
| 1918 | - $success = $this->_save_reg_custom_questions_form($REG_ID); |
|
| 1919 | - if ($success) { |
|
| 1920 | - $what = __('Registration Form', 'event_espresso'); |
|
| 1921 | - $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) |
|
| 1922 | - : array('action' => 'default'); |
|
| 1923 | - $this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
| 1924 | - } |
|
| 1925 | - } |
|
| 1926 | - } |
|
| 1927 | - |
|
| 1928 | - |
|
| 1929 | - /** |
|
| 1930 | - * Gets the form for saving registrations custom questions (if done |
|
| 1931 | - * previously retrieves the cached form object, which may have validation errors in it) |
|
| 1932 | - * |
|
| 1933 | - * @param int $REG_ID |
|
| 1934 | - * @return EE_Registration_Custom_Questions_Form |
|
| 1935 | - */ |
|
| 1936 | - protected function _get_reg_custom_questions_form($REG_ID) |
|
| 1937 | - { |
|
| 1938 | - if ( ! $this->_reg_custom_questions_form) { |
|
| 1939 | - require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php'); |
|
| 1940 | - $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(EEM_Registration::instance() |
|
| 1941 | - ->get_one_by_ID($REG_ID)); |
|
| 1942 | - $this->_reg_custom_questions_form->_construct_finalize(null, null); |
|
| 1943 | - } |
|
| 1944 | - return $this->_reg_custom_questions_form; |
|
| 1945 | - } |
|
| 1946 | - |
|
| 1947 | - |
|
| 1948 | - /** |
|
| 1949 | - * Saves |
|
| 1950 | - * |
|
| 1951 | - * @access private |
|
| 1952 | - * @param bool $REG_ID |
|
| 1953 | - * @return bool |
|
| 1954 | - */ |
|
| 1955 | - private function _save_reg_custom_questions_form($REG_ID = false) |
|
| 1956 | - { |
|
| 1957 | - if ( ! $REG_ID) { |
|
| 1958 | - EE_Error::add_error(__('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__, |
|
| 1959 | - __FUNCTION__, __LINE__); |
|
| 1960 | - } |
|
| 1961 | - $form = $this->_get_reg_custom_questions_form($REG_ID); |
|
| 1962 | - $form->receive_form_submission($this->_req_data); |
|
| 1963 | - $success = false; |
|
| 1964 | - if ($form->is_valid()) { |
|
| 1965 | - foreach ($form->subforms() as $question_group_id => $question_group_form) { |
|
| 1966 | - foreach ($question_group_form->inputs() as $question_id => $input) { |
|
| 1967 | - $where_conditions = array( |
|
| 1968 | - 'QST_ID' => $question_id, |
|
| 1969 | - 'REG_ID' => $REG_ID, |
|
| 1970 | - ); |
|
| 1971 | - $possibly_new_values = array( |
|
| 1972 | - 'ANS_value' => $input->normalized_value(), |
|
| 1973 | - ); |
|
| 1974 | - $answer = EEM_Answer::instance()->get_one(array($where_conditions)); |
|
| 1975 | - if ($answer instanceof EE_Answer) { |
|
| 1976 | - $success = $answer->save($possibly_new_values); |
|
| 1977 | - } else { |
|
| 1978 | - //insert it then |
|
| 1979 | - $cols_n_vals = array_merge($where_conditions, $possibly_new_values); |
|
| 1980 | - $answer = EE_Answer::new_instance($cols_n_vals); |
|
| 1981 | - $success = $answer->save(); |
|
| 1982 | - } |
|
| 1983 | - } |
|
| 1984 | - } |
|
| 1985 | - } else { |
|
| 1986 | - EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__); |
|
| 1987 | - } |
|
| 1988 | - return $success; |
|
| 1989 | - } |
|
| 1990 | - |
|
| 1991 | - |
|
| 1992 | - /** |
|
| 1993 | - * generates HTML for the Registration main meta box |
|
| 1994 | - * |
|
| 1995 | - * @access public |
|
| 1996 | - * @return void |
|
| 1997 | - */ |
|
| 1998 | - public function _reg_attendees_meta_box() |
|
| 1999 | - { |
|
| 2000 | - $REG = EEM_Registration::instance(); |
|
| 2001 | - //get all other registrations on this transaction, and cache |
|
| 2002 | - //the attendees for them so we don't have to run another query using force_join |
|
| 2003 | - $registrations = $REG->get_all(array( |
|
| 2004 | - array( |
|
| 2005 | - 'TXN_ID' => $this->_registration->transaction_ID(), |
|
| 2006 | - 'REG_ID' => array('!=', $this->_registration->ID()), |
|
| 2007 | - ), |
|
| 2008 | - 'force_join' => array('Attendee'), |
|
| 2009 | - )); |
|
| 2010 | - $this->_template_args['attendees'] = array(); |
|
| 2011 | - $this->_template_args['attendee_notice'] = ''; |
|
| 2012 | - if (empty($registrations) |
|
| 2013 | - || (is_array($registrations) |
|
| 2014 | - && ! EEH_Array::get_one_item_from_array($registrations)) |
|
| 2015 | - ) { |
|
| 2016 | - EE_Error::add_error(__('There are no records attached to this registration. Something may have gone wrong with the registration', |
|
| 2017 | - 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 2018 | - $this->_template_args['attendee_notice'] = EE_Error::get_notices(); |
|
| 2019 | - } else { |
|
| 2020 | - $att_nmbr = 1; |
|
| 2021 | - foreach ($registrations as $registration) { |
|
| 2022 | - /* @var $registration EE_Registration */ |
|
| 2023 | - $attendee = $registration->attendee() |
|
| 2024 | - ? $registration->attendee() |
|
| 2025 | - : EEM_Attendee::instance() |
|
| 2026 | - ->create_default_object(); |
|
| 2027 | - $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID(); |
|
| 2028 | - $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : ''; |
|
| 2029 | - $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : ''; |
|
| 2030 | - $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : ''; |
|
| 2031 | - $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : ''; |
|
| 2032 | - $this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ', |
|
| 2033 | - $attendee->full_address_as_array()); |
|
| 2034 | - $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array( |
|
| 2035 | - 'action' => 'edit_attendee', |
|
| 2036 | - 'post' => $attendee->ID(), |
|
| 2037 | - ), REG_ADMIN_URL); |
|
| 2038 | - $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
| 2039 | - $att_nmbr++; |
|
| 2040 | - } |
|
| 2041 | - //EEH_Debug_Tools::printr( $attendees, '$attendees <br /><span style="font-size:10px;font-weight:normal;">( file: '. __FILE__ . ' - line no: ' . __LINE__ . ' )</span>', 'auto' ); |
|
| 2042 | - $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 2043 | - // $this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees' ), REG_ADMIN_URL ); |
|
| 2044 | - } |
|
| 2045 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
|
| 2046 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2047 | - } |
|
| 2048 | - |
|
| 2049 | - |
|
| 2050 | - /** |
|
| 2051 | - * generates HTML for the Edit Registration side meta box |
|
| 2052 | - * |
|
| 2053 | - * @access public |
|
| 2054 | - * @return void |
|
| 2055 | - */ |
|
| 2056 | - public function _reg_registrant_side_meta_box() |
|
| 2057 | - { |
|
| 2058 | - /*@var $attendee EE_Attendee */ |
|
| 2059 | - $att_check = $this->_registration->attendee(); |
|
| 2060 | - $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object(); |
|
| 2061 | - //now let's determine if this is not the primary registration. If it isn't then we set the primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the primary registration object (that way we know if we need to show create button or not) |
|
| 2062 | - if ( ! $this->_registration->is_primary_registrant()) { |
|
| 2063 | - $primary_registration = $this->_registration->get_primary_registration(); |
|
| 2064 | - $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() |
|
| 2065 | - : null; |
|
| 2066 | - if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) { |
|
| 2067 | - //in here? This means the displayed registration is not the primary registrant but ALREADY HAS its own custom attendee object so let's not worry about the primary reg. |
|
| 2068 | - $primary_registration = null; |
|
| 2069 | - } |
|
| 2070 | - } else { |
|
| 2071 | - $primary_registration = null; |
|
| 2072 | - } |
|
| 2073 | - $this->_template_args['ATT_ID'] = $attendee->ID(); |
|
| 2074 | - $this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname; |
|
| 2075 | - $this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname; |
|
| 2076 | - $this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email; |
|
| 2077 | - $this->_template_args['phone'] = $attendee->phone(); |
|
| 2078 | - $this->_template_args['formatted_address'] = EEH_Address::format($attendee); |
|
| 2079 | - //edit link |
|
| 2080 | - $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2081 | - 'action' => 'edit_attendee', |
|
| 2082 | - 'post' => $attendee->ID(), |
|
| 2083 | - ), REG_ADMIN_URL); |
|
| 2084 | - $this->_template_args['att_edit_label'] = __('View/Edit Contact', 'event_espresso'); |
|
| 2085 | - //create link |
|
| 2086 | - $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration |
|
| 2087 | - ? EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2088 | - 'action' => 'duplicate_attendee', |
|
| 2089 | - '_REG_ID' => $this->_registration->ID(), |
|
| 2090 | - ), REG_ADMIN_URL) : ''; |
|
| 2091 | - $this->_template_args['create_label'] = __('Create Contact', 'event_espresso'); |
|
| 2092 | - $this->_template_args['att_check'] = $att_check; |
|
| 2093 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
|
| 2094 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2095 | - } |
|
| 2096 | - |
|
| 2097 | - |
|
| 2098 | - /** |
|
| 2099 | - * trash or restore registrations |
|
| 2100 | - * |
|
| 2101 | - * @param boolean $trash whether to archive or restore |
|
| 2102 | - * @access protected |
|
| 2103 | - * @return void |
|
| 2104 | - */ |
|
| 2105 | - protected function _trash_or_restore_registrations($trash = true) |
|
| 2106 | - { |
|
| 2107 | - $REGM = EEM_Registration::instance(); |
|
| 2108 | - $success = 1; |
|
| 2109 | - $error = 0; |
|
| 2110 | - $tickets = array(); |
|
| 2111 | - $dtts = array(); |
|
| 2112 | - //if empty _REG_ID then get out because there's nothing to do |
|
| 2113 | - if (empty($this->_req_data['_REG_ID'])) { |
|
| 2114 | - $msg = $trash |
|
| 2115 | - ? __('In order to trash registrations you must select which ones you wish to trash by clicking the checkboxes.', |
|
| 2116 | - 'event_espresso') |
|
| 2117 | - : __('In order to restore registrations you must select which ones you wish to restore by clicking the checkboxes.', |
|
| 2118 | - 'event_espresso'); |
|
| 2119 | - EE_Error::add_error($msg, __FILE__, __LINE__, __FUNCTION__); |
|
| 2120 | - $this->_redirect_after_action(false, '', '', array(), true); |
|
| 2121 | - } |
|
| 2122 | - //Checkboxes |
|
| 2123 | - if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
| 2124 | - // if array has more than one element than success message should be plural |
|
| 2125 | - $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
| 2126 | - // cycle thru checkboxes |
|
| 2127 | - while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
| 2128 | - /** @var EE_Registration $REG */ |
|
| 2129 | - $REG = $REGM->get_one_by_ID($REG_ID); |
|
| 2130 | - $payment_count = $REG->get_first_related('Transaction')->count_related('Payment'); |
|
| 2131 | - if ($payment_count > 0) { |
|
| 2132 | - $name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name() |
|
| 2133 | - : __('Unknown Attendee', 'event_espresso'); |
|
| 2134 | - $error = 1; |
|
| 2135 | - $success = 0; |
|
| 2136 | - EE_Error::add_error(sprintf(__('The registration for %s could not be trashed because it has payments attached to the related transaction. If you wish to trash this registration you must first delete the payments on the related transaction.', |
|
| 2137 | - 'event_espresso'), $name), __FILE__, __FUNCTION__, __LINE__); |
|
| 2138 | - continue; //can't trash this registration because it has payments. |
|
| 2139 | - } |
|
| 2140 | - $ticket = $REG->get_first_related('Ticket'); |
|
| 2141 | - $tickets[$ticket->ID()] = $ticket; |
|
| 2142 | - $dtt = $ticket->get_many_related('Datetime'); |
|
| 2143 | - $dtts = array_merge($dtts, $dtt); |
|
| 2144 | - $updated = $trash ? $REG->delete() : $REG->restore(); |
|
| 2145 | - if ( ! $updated) { |
|
| 2146 | - $success = 0; |
|
| 2147 | - } else { |
|
| 2148 | - $success = 2; |
|
| 2149 | - }/**/ |
|
| 2150 | - } |
|
| 2151 | - } else { |
|
| 2152 | - // grab single id and delete |
|
| 2153 | - $REG_ID = absint($this->_req_data['_REG_ID']); |
|
| 2154 | - $REG = $REGM->get_one_by_ID($REG_ID); |
|
| 2155 | - $ticket = $REG->get_first_related('Ticket'); |
|
| 2156 | - $tickets[$ticket->ID()] = $ticket; |
|
| 2157 | - $dtts = $ticket->get_many_related('Datetime'); |
|
| 2158 | - $updated = $trash ? $REG->delete() : $REG->restore(); |
|
| 2159 | - if ( ! $updated) { |
|
| 2160 | - $success = 0; |
|
| 2161 | - } |
|
| 2162 | - } |
|
| 2163 | - //now let's update counts |
|
| 2164 | - EEM_Ticket::instance()->update_tickets_sold($tickets); |
|
| 2165 | - EEM_Datetime::instance()->update_sold($dtts); |
|
| 2166 | - $what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso'); |
|
| 2167 | - $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
|
| 2168 | - $overwrite_msgs = $error ? true : false; |
|
| 2169 | - $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), $overwrite_msgs); |
|
| 2170 | - } |
|
| 2171 | - |
|
| 2172 | - |
|
| 2173 | - /** |
|
| 2174 | - * This is used to permanently delete registrations. Note, this will handle not only deleting permanently the |
|
| 2175 | - * registration but also. |
|
| 2176 | - * 1. Removing relations to EE_Attendee |
|
| 2177 | - * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are |
|
| 2178 | - * ALSO trashed. |
|
| 2179 | - * 3. Deleting permanently any related Line items but only if the above conditions are met. |
|
| 2180 | - * 4. Removing relationships between all tickets and the related registrations |
|
| 2181 | - * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.) |
|
| 2182 | - * 6. Deleting permanently any related Checkins. |
|
| 2183 | - * |
|
| 2184 | - * @return void |
|
| 2185 | - */ |
|
| 2186 | - protected function _delete_registrations() |
|
| 2187 | - { |
|
| 2188 | - $REG_MDL = EEM_Registration::instance(); |
|
| 2189 | - $success = 1; |
|
| 2190 | - //Checkboxes |
|
| 2191 | - if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
| 2192 | - // if array has more than one element than success message should be plural |
|
| 2193 | - $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
| 2194 | - // cycle thru checkboxes |
|
| 2195 | - while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
| 2196 | - $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
| 2197 | - if ( ! $REG instanceof EE_Registration) { |
|
| 2198 | - continue; |
|
| 2199 | - } |
|
| 2200 | - $deleted = $this->_delete_registration($REG); |
|
| 2201 | - if ( ! $deleted) { |
|
| 2202 | - $success = 0; |
|
| 2203 | - } |
|
| 2204 | - } |
|
| 2205 | - } else { |
|
| 2206 | - // grab single id and delete |
|
| 2207 | - $REG_ID = $this->_req_data['_REG_ID']; |
|
| 2208 | - $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
| 2209 | - $deleted = $this->_delete_registration($REG); |
|
| 2210 | - if ( ! $deleted) { |
|
| 2211 | - $success = 0; |
|
| 2212 | - } |
|
| 2213 | - } |
|
| 2214 | - $what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso'); |
|
| 2215 | - $action_desc = __('permanently deleted.', 'event_espresso'); |
|
| 2216 | - $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), true); |
|
| 2217 | - } |
|
| 2218 | - |
|
| 2219 | - |
|
| 2220 | - /** |
|
| 2221 | - * handles the permanent deletion of a registration. See comments with _delete_registrations() for details on what |
|
| 2222 | - * models get affected. |
|
| 2223 | - * |
|
| 2224 | - * @param EE_Registration $REG registration to be deleted permenantly |
|
| 2225 | - * @return boolean true = successful deletion, false = fail. |
|
| 2226 | - */ |
|
| 2227 | - protected function _delete_registration(EE_Registration $REG) |
|
| 2228 | - { |
|
| 2229 | - //first we start with the transaction... ultimately, we WILL not delete permanently if there are any related registrations on the transaction that are NOT trashed. |
|
| 2230 | - $TXN = $REG->get_first_related('Transaction'); |
|
| 2231 | - $REGS = $TXN->get_many_related('Registration'); |
|
| 2232 | - $all_trashed = true; |
|
| 2233 | - foreach ($REGS as $registration) { |
|
| 2234 | - if ( ! $registration->get('REG_deleted')) { |
|
| 2235 | - $all_trashed = false; |
|
| 2236 | - } |
|
| 2237 | - } |
|
| 2238 | - if ( ! $all_trashed) { |
|
| 2239 | - EE_Error::add_error(__('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well. These registrations will be permanently deleted in the same action.', |
|
| 2240 | - 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 2241 | - return false; |
|
| 2242 | - } |
|
| 2243 | - //k made it here so that means we can delete all the related transactions and their answers (but let's do them separately from THIS one). |
|
| 2244 | - foreach ($REGS as $registration) { |
|
| 2245 | - //delete related answers |
|
| 2246 | - $registration->delete_related_permanently('Answer'); |
|
| 2247 | - //remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact) |
|
| 2248 | - $attendee = $registration->get_first_related('Attendee'); |
|
| 2249 | - if ($attendee instanceof EE_Attendee) { |
|
| 2250 | - $registration->_remove_relation_to($attendee, 'Attendee'); |
|
| 2251 | - } |
|
| 2252 | - //now remove relationships to tickets on this registration. |
|
| 2253 | - $registration->_remove_relations('Ticket'); |
|
| 2254 | - //now delete permanently the checkins related to this registration. |
|
| 2255 | - $registration->delete_related_permanently('Checkin'); |
|
| 2256 | - if ($registration->ID() === $REG->ID()) { |
|
| 2257 | - continue; |
|
| 2258 | - } //we don't want to delete permanently the existing registration just yet. |
|
| 2259 | - //remove relation to transaction for these registrations if NOT the existing registrations |
|
| 2260 | - $registration->_remove_relations('Transaction'); |
|
| 2261 | - //delete permanently any related messages. |
|
| 2262 | - $registration->delete_related_permanently('Message'); |
|
| 2263 | - //now delete this registration permanently |
|
| 2264 | - $registration->delete_permanently(); |
|
| 2265 | - } |
|
| 2266 | - //now all related registrations on the transaction are handled. So let's just handle this registration itself (the transaction and line items should be all that's left). |
|
| 2267 | - //delete the line items related to the transaction for this registration. |
|
| 2268 | - $TXN->delete_related_permanently('Line_Item'); |
|
| 2269 | - //we need to remove all the relationships on the transaction |
|
| 2270 | - $TXN->delete_related_permanently('Payment'); |
|
| 2271 | - $TXN->delete_related_permanently('Extra_Meta'); |
|
| 2272 | - $TXN->delete_related_permanently('Message'); |
|
| 2273 | - //now we can delete this REG permanently (and the transaction of course) |
|
| 2274 | - $REG->delete_related_permanently('Transaction'); |
|
| 2275 | - return $REG->delete_permanently(); |
|
| 2276 | - } |
|
| 2277 | - |
|
| 2278 | - |
|
| 2279 | - /** |
|
| 2280 | - * generates HTML for the Register New Attendee Admin page |
|
| 2281 | - * |
|
| 2282 | - * @access private |
|
| 2283 | - * @throws \EE_Error |
|
| 2284 | - * @return void |
|
| 2285 | - */ |
|
| 2286 | - public function new_registration() |
|
| 2287 | - { |
|
| 2288 | - if ( ! $this->_set_reg_event()) { |
|
| 2289 | - throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', |
|
| 2290 | - 'event_espresso')); |
|
| 2291 | - } |
|
| 2292 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 2293 | - // gotta start with a clean slate if we're not coming here via ajax |
|
| 2294 | - if ( ! defined('DOING_AJAX') |
|
| 2295 | - && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error'])) |
|
| 2296 | - ) { |
|
| 2297 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2298 | - } |
|
| 2299 | - $this->_template_args['event_name'] = ''; |
|
| 2300 | - // event name |
|
| 2301 | - if ($this->_reg_event) { |
|
| 2302 | - $this->_template_args['event_name'] = $this->_reg_event->name(); |
|
| 2303 | - $edit_event_url = self::add_query_args_and_nonce(array( |
|
| 2304 | - 'action' => 'edit', |
|
| 2305 | - 'post' => $this->_reg_event->ID(), |
|
| 2306 | - ), EVENTS_ADMIN_URL); |
|
| 2307 | - $edit_event_lnk = '<a href="' |
|
| 2308 | - . $edit_event_url |
|
| 2309 | - . '" title="' |
|
| 2310 | - . esc_attr__('Edit ', 'event_espresso') |
|
| 2311 | - . $this->_reg_event->name() |
|
| 2312 | - . '">' |
|
| 2313 | - . __('Edit Event', 'event_espresso') |
|
| 2314 | - . '</a>'; |
|
| 2315 | - $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">' |
|
| 2316 | - . $edit_event_lnk |
|
| 2317 | - . '</span>'; |
|
| 2318 | - } |
|
| 2319 | - $this->_template_args['step_content'] = $this->_get_registration_step_content(); |
|
| 2320 | - if (defined('DOING_AJAX')) { |
|
| 2321 | - $this->_return_json(); |
|
| 2322 | - } |
|
| 2323 | - // grab header |
|
| 2324 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php'; |
|
| 2325 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
|
| 2326 | - $this->_template_args, true); |
|
| 2327 | - //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
| 2328 | - // the details template wrapper |
|
| 2329 | - $this->display_admin_page_with_sidebar(); |
|
| 2330 | - } |
|
| 2331 | - |
|
| 2332 | - |
|
| 2333 | - /** |
|
| 2334 | - * This returns the content for a registration step |
|
| 2335 | - * |
|
| 2336 | - * @access protected |
|
| 2337 | - * @return string html |
|
| 2338 | - */ |
|
| 2339 | - protected function _get_registration_step_content() |
|
| 2340 | - { |
|
| 2341 | - if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) { |
|
| 2342 | - $warning_msg = sprintf(__('%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s', |
|
| 2343 | - 'event_espresso'), '<br />', '<h3 class="important-notice">', '</h3>', '<div class="float-right">', |
|
| 2344 | - '<span id="redirect_timer" class="important-notice">30</span>', '</div>', '<b>', '</b>'); |
|
| 2345 | - return ' |
|
| 1902 | + } |
|
| 1903 | + |
|
| 1904 | + |
|
| 1905 | + /** |
|
| 1906 | + * Updates the registration's custom questions according to the form info, if the form is submitted. |
|
| 1907 | + * If it's not a post, the "view_registrations" route will be called next on the SAME request |
|
| 1908 | + * to display the page |
|
| 1909 | + * |
|
| 1910 | + * @access protected |
|
| 1911 | + * @return void |
|
| 1912 | + */ |
|
| 1913 | + protected function _update_attendee_registration_form() |
|
| 1914 | + { |
|
| 1915 | + do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this); |
|
| 1916 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 1917 | + $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false; |
|
| 1918 | + $success = $this->_save_reg_custom_questions_form($REG_ID); |
|
| 1919 | + if ($success) { |
|
| 1920 | + $what = __('Registration Form', 'event_espresso'); |
|
| 1921 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) |
|
| 1922 | + : array('action' => 'default'); |
|
| 1923 | + $this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
| 1924 | + } |
|
| 1925 | + } |
|
| 1926 | + } |
|
| 1927 | + |
|
| 1928 | + |
|
| 1929 | + /** |
|
| 1930 | + * Gets the form for saving registrations custom questions (if done |
|
| 1931 | + * previously retrieves the cached form object, which may have validation errors in it) |
|
| 1932 | + * |
|
| 1933 | + * @param int $REG_ID |
|
| 1934 | + * @return EE_Registration_Custom_Questions_Form |
|
| 1935 | + */ |
|
| 1936 | + protected function _get_reg_custom_questions_form($REG_ID) |
|
| 1937 | + { |
|
| 1938 | + if ( ! $this->_reg_custom_questions_form) { |
|
| 1939 | + require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php'); |
|
| 1940 | + $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(EEM_Registration::instance() |
|
| 1941 | + ->get_one_by_ID($REG_ID)); |
|
| 1942 | + $this->_reg_custom_questions_form->_construct_finalize(null, null); |
|
| 1943 | + } |
|
| 1944 | + return $this->_reg_custom_questions_form; |
|
| 1945 | + } |
|
| 1946 | + |
|
| 1947 | + |
|
| 1948 | + /** |
|
| 1949 | + * Saves |
|
| 1950 | + * |
|
| 1951 | + * @access private |
|
| 1952 | + * @param bool $REG_ID |
|
| 1953 | + * @return bool |
|
| 1954 | + */ |
|
| 1955 | + private function _save_reg_custom_questions_form($REG_ID = false) |
|
| 1956 | + { |
|
| 1957 | + if ( ! $REG_ID) { |
|
| 1958 | + EE_Error::add_error(__('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__, |
|
| 1959 | + __FUNCTION__, __LINE__); |
|
| 1960 | + } |
|
| 1961 | + $form = $this->_get_reg_custom_questions_form($REG_ID); |
|
| 1962 | + $form->receive_form_submission($this->_req_data); |
|
| 1963 | + $success = false; |
|
| 1964 | + if ($form->is_valid()) { |
|
| 1965 | + foreach ($form->subforms() as $question_group_id => $question_group_form) { |
|
| 1966 | + foreach ($question_group_form->inputs() as $question_id => $input) { |
|
| 1967 | + $where_conditions = array( |
|
| 1968 | + 'QST_ID' => $question_id, |
|
| 1969 | + 'REG_ID' => $REG_ID, |
|
| 1970 | + ); |
|
| 1971 | + $possibly_new_values = array( |
|
| 1972 | + 'ANS_value' => $input->normalized_value(), |
|
| 1973 | + ); |
|
| 1974 | + $answer = EEM_Answer::instance()->get_one(array($where_conditions)); |
|
| 1975 | + if ($answer instanceof EE_Answer) { |
|
| 1976 | + $success = $answer->save($possibly_new_values); |
|
| 1977 | + } else { |
|
| 1978 | + //insert it then |
|
| 1979 | + $cols_n_vals = array_merge($where_conditions, $possibly_new_values); |
|
| 1980 | + $answer = EE_Answer::new_instance($cols_n_vals); |
|
| 1981 | + $success = $answer->save(); |
|
| 1982 | + } |
|
| 1983 | + } |
|
| 1984 | + } |
|
| 1985 | + } else { |
|
| 1986 | + EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__); |
|
| 1987 | + } |
|
| 1988 | + return $success; |
|
| 1989 | + } |
|
| 1990 | + |
|
| 1991 | + |
|
| 1992 | + /** |
|
| 1993 | + * generates HTML for the Registration main meta box |
|
| 1994 | + * |
|
| 1995 | + * @access public |
|
| 1996 | + * @return void |
|
| 1997 | + */ |
|
| 1998 | + public function _reg_attendees_meta_box() |
|
| 1999 | + { |
|
| 2000 | + $REG = EEM_Registration::instance(); |
|
| 2001 | + //get all other registrations on this transaction, and cache |
|
| 2002 | + //the attendees for them so we don't have to run another query using force_join |
|
| 2003 | + $registrations = $REG->get_all(array( |
|
| 2004 | + array( |
|
| 2005 | + 'TXN_ID' => $this->_registration->transaction_ID(), |
|
| 2006 | + 'REG_ID' => array('!=', $this->_registration->ID()), |
|
| 2007 | + ), |
|
| 2008 | + 'force_join' => array('Attendee'), |
|
| 2009 | + )); |
|
| 2010 | + $this->_template_args['attendees'] = array(); |
|
| 2011 | + $this->_template_args['attendee_notice'] = ''; |
|
| 2012 | + if (empty($registrations) |
|
| 2013 | + || (is_array($registrations) |
|
| 2014 | + && ! EEH_Array::get_one_item_from_array($registrations)) |
|
| 2015 | + ) { |
|
| 2016 | + EE_Error::add_error(__('There are no records attached to this registration. Something may have gone wrong with the registration', |
|
| 2017 | + 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 2018 | + $this->_template_args['attendee_notice'] = EE_Error::get_notices(); |
|
| 2019 | + } else { |
|
| 2020 | + $att_nmbr = 1; |
|
| 2021 | + foreach ($registrations as $registration) { |
|
| 2022 | + /* @var $registration EE_Registration */ |
|
| 2023 | + $attendee = $registration->attendee() |
|
| 2024 | + ? $registration->attendee() |
|
| 2025 | + : EEM_Attendee::instance() |
|
| 2026 | + ->create_default_object(); |
|
| 2027 | + $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID(); |
|
| 2028 | + $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : ''; |
|
| 2029 | + $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : ''; |
|
| 2030 | + $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : ''; |
|
| 2031 | + $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : ''; |
|
| 2032 | + $this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ', |
|
| 2033 | + $attendee->full_address_as_array()); |
|
| 2034 | + $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array( |
|
| 2035 | + 'action' => 'edit_attendee', |
|
| 2036 | + 'post' => $attendee->ID(), |
|
| 2037 | + ), REG_ADMIN_URL); |
|
| 2038 | + $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
| 2039 | + $att_nmbr++; |
|
| 2040 | + } |
|
| 2041 | + //EEH_Debug_Tools::printr( $attendees, '$attendees <br /><span style="font-size:10px;font-weight:normal;">( file: '. __FILE__ . ' - line no: ' . __LINE__ . ' )</span>', 'auto' ); |
|
| 2042 | + $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 2043 | + // $this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees' ), REG_ADMIN_URL ); |
|
| 2044 | + } |
|
| 2045 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
|
| 2046 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2047 | + } |
|
| 2048 | + |
|
| 2049 | + |
|
| 2050 | + /** |
|
| 2051 | + * generates HTML for the Edit Registration side meta box |
|
| 2052 | + * |
|
| 2053 | + * @access public |
|
| 2054 | + * @return void |
|
| 2055 | + */ |
|
| 2056 | + public function _reg_registrant_side_meta_box() |
|
| 2057 | + { |
|
| 2058 | + /*@var $attendee EE_Attendee */ |
|
| 2059 | + $att_check = $this->_registration->attendee(); |
|
| 2060 | + $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object(); |
|
| 2061 | + //now let's determine if this is not the primary registration. If it isn't then we set the primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the primary registration object (that way we know if we need to show create button or not) |
|
| 2062 | + if ( ! $this->_registration->is_primary_registrant()) { |
|
| 2063 | + $primary_registration = $this->_registration->get_primary_registration(); |
|
| 2064 | + $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() |
|
| 2065 | + : null; |
|
| 2066 | + if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) { |
|
| 2067 | + //in here? This means the displayed registration is not the primary registrant but ALREADY HAS its own custom attendee object so let's not worry about the primary reg. |
|
| 2068 | + $primary_registration = null; |
|
| 2069 | + } |
|
| 2070 | + } else { |
|
| 2071 | + $primary_registration = null; |
|
| 2072 | + } |
|
| 2073 | + $this->_template_args['ATT_ID'] = $attendee->ID(); |
|
| 2074 | + $this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname; |
|
| 2075 | + $this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname; |
|
| 2076 | + $this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email; |
|
| 2077 | + $this->_template_args['phone'] = $attendee->phone(); |
|
| 2078 | + $this->_template_args['formatted_address'] = EEH_Address::format($attendee); |
|
| 2079 | + //edit link |
|
| 2080 | + $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2081 | + 'action' => 'edit_attendee', |
|
| 2082 | + 'post' => $attendee->ID(), |
|
| 2083 | + ), REG_ADMIN_URL); |
|
| 2084 | + $this->_template_args['att_edit_label'] = __('View/Edit Contact', 'event_espresso'); |
|
| 2085 | + //create link |
|
| 2086 | + $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration |
|
| 2087 | + ? EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2088 | + 'action' => 'duplicate_attendee', |
|
| 2089 | + '_REG_ID' => $this->_registration->ID(), |
|
| 2090 | + ), REG_ADMIN_URL) : ''; |
|
| 2091 | + $this->_template_args['create_label'] = __('Create Contact', 'event_espresso'); |
|
| 2092 | + $this->_template_args['att_check'] = $att_check; |
|
| 2093 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
|
| 2094 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2095 | + } |
|
| 2096 | + |
|
| 2097 | + |
|
| 2098 | + /** |
|
| 2099 | + * trash or restore registrations |
|
| 2100 | + * |
|
| 2101 | + * @param boolean $trash whether to archive or restore |
|
| 2102 | + * @access protected |
|
| 2103 | + * @return void |
|
| 2104 | + */ |
|
| 2105 | + protected function _trash_or_restore_registrations($trash = true) |
|
| 2106 | + { |
|
| 2107 | + $REGM = EEM_Registration::instance(); |
|
| 2108 | + $success = 1; |
|
| 2109 | + $error = 0; |
|
| 2110 | + $tickets = array(); |
|
| 2111 | + $dtts = array(); |
|
| 2112 | + //if empty _REG_ID then get out because there's nothing to do |
|
| 2113 | + if (empty($this->_req_data['_REG_ID'])) { |
|
| 2114 | + $msg = $trash |
|
| 2115 | + ? __('In order to trash registrations you must select which ones you wish to trash by clicking the checkboxes.', |
|
| 2116 | + 'event_espresso') |
|
| 2117 | + : __('In order to restore registrations you must select which ones you wish to restore by clicking the checkboxes.', |
|
| 2118 | + 'event_espresso'); |
|
| 2119 | + EE_Error::add_error($msg, __FILE__, __LINE__, __FUNCTION__); |
|
| 2120 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
| 2121 | + } |
|
| 2122 | + //Checkboxes |
|
| 2123 | + if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
| 2124 | + // if array has more than one element than success message should be plural |
|
| 2125 | + $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
| 2126 | + // cycle thru checkboxes |
|
| 2127 | + while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
| 2128 | + /** @var EE_Registration $REG */ |
|
| 2129 | + $REG = $REGM->get_one_by_ID($REG_ID); |
|
| 2130 | + $payment_count = $REG->get_first_related('Transaction')->count_related('Payment'); |
|
| 2131 | + if ($payment_count > 0) { |
|
| 2132 | + $name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name() |
|
| 2133 | + : __('Unknown Attendee', 'event_espresso'); |
|
| 2134 | + $error = 1; |
|
| 2135 | + $success = 0; |
|
| 2136 | + EE_Error::add_error(sprintf(__('The registration for %s could not be trashed because it has payments attached to the related transaction. If you wish to trash this registration you must first delete the payments on the related transaction.', |
|
| 2137 | + 'event_espresso'), $name), __FILE__, __FUNCTION__, __LINE__); |
|
| 2138 | + continue; //can't trash this registration because it has payments. |
|
| 2139 | + } |
|
| 2140 | + $ticket = $REG->get_first_related('Ticket'); |
|
| 2141 | + $tickets[$ticket->ID()] = $ticket; |
|
| 2142 | + $dtt = $ticket->get_many_related('Datetime'); |
|
| 2143 | + $dtts = array_merge($dtts, $dtt); |
|
| 2144 | + $updated = $trash ? $REG->delete() : $REG->restore(); |
|
| 2145 | + if ( ! $updated) { |
|
| 2146 | + $success = 0; |
|
| 2147 | + } else { |
|
| 2148 | + $success = 2; |
|
| 2149 | + }/**/ |
|
| 2150 | + } |
|
| 2151 | + } else { |
|
| 2152 | + // grab single id and delete |
|
| 2153 | + $REG_ID = absint($this->_req_data['_REG_ID']); |
|
| 2154 | + $REG = $REGM->get_one_by_ID($REG_ID); |
|
| 2155 | + $ticket = $REG->get_first_related('Ticket'); |
|
| 2156 | + $tickets[$ticket->ID()] = $ticket; |
|
| 2157 | + $dtts = $ticket->get_many_related('Datetime'); |
|
| 2158 | + $updated = $trash ? $REG->delete() : $REG->restore(); |
|
| 2159 | + if ( ! $updated) { |
|
| 2160 | + $success = 0; |
|
| 2161 | + } |
|
| 2162 | + } |
|
| 2163 | + //now let's update counts |
|
| 2164 | + EEM_Ticket::instance()->update_tickets_sold($tickets); |
|
| 2165 | + EEM_Datetime::instance()->update_sold($dtts); |
|
| 2166 | + $what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso'); |
|
| 2167 | + $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
|
| 2168 | + $overwrite_msgs = $error ? true : false; |
|
| 2169 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), $overwrite_msgs); |
|
| 2170 | + } |
|
| 2171 | + |
|
| 2172 | + |
|
| 2173 | + /** |
|
| 2174 | + * This is used to permanently delete registrations. Note, this will handle not only deleting permanently the |
|
| 2175 | + * registration but also. |
|
| 2176 | + * 1. Removing relations to EE_Attendee |
|
| 2177 | + * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are |
|
| 2178 | + * ALSO trashed. |
|
| 2179 | + * 3. Deleting permanently any related Line items but only if the above conditions are met. |
|
| 2180 | + * 4. Removing relationships between all tickets and the related registrations |
|
| 2181 | + * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.) |
|
| 2182 | + * 6. Deleting permanently any related Checkins. |
|
| 2183 | + * |
|
| 2184 | + * @return void |
|
| 2185 | + */ |
|
| 2186 | + protected function _delete_registrations() |
|
| 2187 | + { |
|
| 2188 | + $REG_MDL = EEM_Registration::instance(); |
|
| 2189 | + $success = 1; |
|
| 2190 | + //Checkboxes |
|
| 2191 | + if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
| 2192 | + // if array has more than one element than success message should be plural |
|
| 2193 | + $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
| 2194 | + // cycle thru checkboxes |
|
| 2195 | + while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
| 2196 | + $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
| 2197 | + if ( ! $REG instanceof EE_Registration) { |
|
| 2198 | + continue; |
|
| 2199 | + } |
|
| 2200 | + $deleted = $this->_delete_registration($REG); |
|
| 2201 | + if ( ! $deleted) { |
|
| 2202 | + $success = 0; |
|
| 2203 | + } |
|
| 2204 | + } |
|
| 2205 | + } else { |
|
| 2206 | + // grab single id and delete |
|
| 2207 | + $REG_ID = $this->_req_data['_REG_ID']; |
|
| 2208 | + $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
| 2209 | + $deleted = $this->_delete_registration($REG); |
|
| 2210 | + if ( ! $deleted) { |
|
| 2211 | + $success = 0; |
|
| 2212 | + } |
|
| 2213 | + } |
|
| 2214 | + $what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso'); |
|
| 2215 | + $action_desc = __('permanently deleted.', 'event_espresso'); |
|
| 2216 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), true); |
|
| 2217 | + } |
|
| 2218 | + |
|
| 2219 | + |
|
| 2220 | + /** |
|
| 2221 | + * handles the permanent deletion of a registration. See comments with _delete_registrations() for details on what |
|
| 2222 | + * models get affected. |
|
| 2223 | + * |
|
| 2224 | + * @param EE_Registration $REG registration to be deleted permenantly |
|
| 2225 | + * @return boolean true = successful deletion, false = fail. |
|
| 2226 | + */ |
|
| 2227 | + protected function _delete_registration(EE_Registration $REG) |
|
| 2228 | + { |
|
| 2229 | + //first we start with the transaction... ultimately, we WILL not delete permanently if there are any related registrations on the transaction that are NOT trashed. |
|
| 2230 | + $TXN = $REG->get_first_related('Transaction'); |
|
| 2231 | + $REGS = $TXN->get_many_related('Registration'); |
|
| 2232 | + $all_trashed = true; |
|
| 2233 | + foreach ($REGS as $registration) { |
|
| 2234 | + if ( ! $registration->get('REG_deleted')) { |
|
| 2235 | + $all_trashed = false; |
|
| 2236 | + } |
|
| 2237 | + } |
|
| 2238 | + if ( ! $all_trashed) { |
|
| 2239 | + EE_Error::add_error(__('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well. These registrations will be permanently deleted in the same action.', |
|
| 2240 | + 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 2241 | + return false; |
|
| 2242 | + } |
|
| 2243 | + //k made it here so that means we can delete all the related transactions and their answers (but let's do them separately from THIS one). |
|
| 2244 | + foreach ($REGS as $registration) { |
|
| 2245 | + //delete related answers |
|
| 2246 | + $registration->delete_related_permanently('Answer'); |
|
| 2247 | + //remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact) |
|
| 2248 | + $attendee = $registration->get_first_related('Attendee'); |
|
| 2249 | + if ($attendee instanceof EE_Attendee) { |
|
| 2250 | + $registration->_remove_relation_to($attendee, 'Attendee'); |
|
| 2251 | + } |
|
| 2252 | + //now remove relationships to tickets on this registration. |
|
| 2253 | + $registration->_remove_relations('Ticket'); |
|
| 2254 | + //now delete permanently the checkins related to this registration. |
|
| 2255 | + $registration->delete_related_permanently('Checkin'); |
|
| 2256 | + if ($registration->ID() === $REG->ID()) { |
|
| 2257 | + continue; |
|
| 2258 | + } //we don't want to delete permanently the existing registration just yet. |
|
| 2259 | + //remove relation to transaction for these registrations if NOT the existing registrations |
|
| 2260 | + $registration->_remove_relations('Transaction'); |
|
| 2261 | + //delete permanently any related messages. |
|
| 2262 | + $registration->delete_related_permanently('Message'); |
|
| 2263 | + //now delete this registration permanently |
|
| 2264 | + $registration->delete_permanently(); |
|
| 2265 | + } |
|
| 2266 | + //now all related registrations on the transaction are handled. So let's just handle this registration itself (the transaction and line items should be all that's left). |
|
| 2267 | + //delete the line items related to the transaction for this registration. |
|
| 2268 | + $TXN->delete_related_permanently('Line_Item'); |
|
| 2269 | + //we need to remove all the relationships on the transaction |
|
| 2270 | + $TXN->delete_related_permanently('Payment'); |
|
| 2271 | + $TXN->delete_related_permanently('Extra_Meta'); |
|
| 2272 | + $TXN->delete_related_permanently('Message'); |
|
| 2273 | + //now we can delete this REG permanently (and the transaction of course) |
|
| 2274 | + $REG->delete_related_permanently('Transaction'); |
|
| 2275 | + return $REG->delete_permanently(); |
|
| 2276 | + } |
|
| 2277 | + |
|
| 2278 | + |
|
| 2279 | + /** |
|
| 2280 | + * generates HTML for the Register New Attendee Admin page |
|
| 2281 | + * |
|
| 2282 | + * @access private |
|
| 2283 | + * @throws \EE_Error |
|
| 2284 | + * @return void |
|
| 2285 | + */ |
|
| 2286 | + public function new_registration() |
|
| 2287 | + { |
|
| 2288 | + if ( ! $this->_set_reg_event()) { |
|
| 2289 | + throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', |
|
| 2290 | + 'event_espresso')); |
|
| 2291 | + } |
|
| 2292 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 2293 | + // gotta start with a clean slate if we're not coming here via ajax |
|
| 2294 | + if ( ! defined('DOING_AJAX') |
|
| 2295 | + && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error'])) |
|
| 2296 | + ) { |
|
| 2297 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2298 | + } |
|
| 2299 | + $this->_template_args['event_name'] = ''; |
|
| 2300 | + // event name |
|
| 2301 | + if ($this->_reg_event) { |
|
| 2302 | + $this->_template_args['event_name'] = $this->_reg_event->name(); |
|
| 2303 | + $edit_event_url = self::add_query_args_and_nonce(array( |
|
| 2304 | + 'action' => 'edit', |
|
| 2305 | + 'post' => $this->_reg_event->ID(), |
|
| 2306 | + ), EVENTS_ADMIN_URL); |
|
| 2307 | + $edit_event_lnk = '<a href="' |
|
| 2308 | + . $edit_event_url |
|
| 2309 | + . '" title="' |
|
| 2310 | + . esc_attr__('Edit ', 'event_espresso') |
|
| 2311 | + . $this->_reg_event->name() |
|
| 2312 | + . '">' |
|
| 2313 | + . __('Edit Event', 'event_espresso') |
|
| 2314 | + . '</a>'; |
|
| 2315 | + $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">' |
|
| 2316 | + . $edit_event_lnk |
|
| 2317 | + . '</span>'; |
|
| 2318 | + } |
|
| 2319 | + $this->_template_args['step_content'] = $this->_get_registration_step_content(); |
|
| 2320 | + if (defined('DOING_AJAX')) { |
|
| 2321 | + $this->_return_json(); |
|
| 2322 | + } |
|
| 2323 | + // grab header |
|
| 2324 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php'; |
|
| 2325 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
|
| 2326 | + $this->_template_args, true); |
|
| 2327 | + //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
| 2328 | + // the details template wrapper |
|
| 2329 | + $this->display_admin_page_with_sidebar(); |
|
| 2330 | + } |
|
| 2331 | + |
|
| 2332 | + |
|
| 2333 | + /** |
|
| 2334 | + * This returns the content for a registration step |
|
| 2335 | + * |
|
| 2336 | + * @access protected |
|
| 2337 | + * @return string html |
|
| 2338 | + */ |
|
| 2339 | + protected function _get_registration_step_content() |
|
| 2340 | + { |
|
| 2341 | + if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) { |
|
| 2342 | + $warning_msg = sprintf(__('%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s', |
|
| 2343 | + 'event_espresso'), '<br />', '<h3 class="important-notice">', '</h3>', '<div class="float-right">', |
|
| 2344 | + '<span id="redirect_timer" class="important-notice">30</span>', '</div>', '<b>', '</b>'); |
|
| 2345 | + return ' |
|
| 2346 | 2346 | <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div> |
| 2347 | 2347 | <script > |
| 2348 | 2348 | // WHOAH !!! it appears that someone is using the back button from the Transaction admin page |
@@ -2355,658 +2355,658 @@ discard block |
||
| 2355 | 2355 | } |
| 2356 | 2356 | }, 800 ); |
| 2357 | 2357 | </script >'; |
| 2358 | - } |
|
| 2359 | - $template_args = array( |
|
| 2360 | - 'title' => '', |
|
| 2361 | - 'content' => '', |
|
| 2362 | - 'step_button_text' => '', |
|
| 2363 | - 'show_notification_toggle' => false, |
|
| 2364 | - ); |
|
| 2365 | - //to indicate we're processing a new registration |
|
| 2366 | - $hidden_fields = array( |
|
| 2367 | - 'processing_registration' => array( |
|
| 2368 | - 'type' => 'hidden', |
|
| 2369 | - 'value' => 0, |
|
| 2370 | - ), |
|
| 2371 | - 'event_id' => array( |
|
| 2372 | - 'type' => 'hidden', |
|
| 2373 | - 'value' => $this->_reg_event->ID(), |
|
| 2374 | - ), |
|
| 2375 | - ); |
|
| 2376 | - //if the cart is empty then we know we're at step one so we'll display ticket selector |
|
| 2377 | - $cart = EE_Registry::instance()->SSN->cart(); |
|
| 2378 | - $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
| 2379 | - switch ($step) { |
|
| 2380 | - case 'ticket' : |
|
| 2381 | - $hidden_fields['processing_registration']['value'] = 1; |
|
| 2382 | - $template_args['title'] = __('Step One: Select the Ticket for this registration', |
|
| 2383 | - 'event_espresso'); |
|
| 2384 | - $template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event); |
|
| 2385 | - $template_args['step_button_text'] = __('Add Tickets and Continue to Registrant Details', |
|
| 2386 | - 'event_espresso'); |
|
| 2387 | - $template_args['show_notification_toggle'] = false; |
|
| 2388 | - break; |
|
| 2389 | - case 'questions' : |
|
| 2390 | - $hidden_fields['processing_registration']['value'] = 2; |
|
| 2391 | - $template_args['title'] = __('Step Two: Add Registrant Details for this Registration', |
|
| 2392 | - 'event_espresso'); |
|
| 2393 | - //in theory we should be able to run EED_SPCO at this point because the cart should have been setup properly by the first process_reg_step run. |
|
| 2394 | - $template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin(); |
|
| 2395 | - $template_args['step_button_text'] = __('Save Registration and Continue to Details', |
|
| 2396 | - 'event_espresso'); |
|
| 2397 | - $template_args['show_notification_toggle'] = true; |
|
| 2398 | - break; |
|
| 2399 | - } |
|
| 2400 | - $this->_set_add_edit_form_tags('process_reg_step', |
|
| 2401 | - $hidden_fields); //we come back to the process_registration_step route. |
|
| 2402 | - return EEH_Template::display_template(REG_TEMPLATE_PATH |
|
| 2403 | - . 'reg_admin_register_new_attendee_step_content.template.php', |
|
| 2404 | - $template_args, true); |
|
| 2405 | - } |
|
| 2406 | - |
|
| 2407 | - |
|
| 2408 | - /** |
|
| 2409 | - * set_reg_event |
|
| 2410 | - * |
|
| 2411 | - * @access private |
|
| 2412 | - * @return boolean |
|
| 2413 | - */ |
|
| 2414 | - private function _set_reg_event() |
|
| 2415 | - { |
|
| 2416 | - if (is_object($this->_reg_event)) { |
|
| 2417 | - return true; |
|
| 2418 | - } |
|
| 2419 | - $EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false; |
|
| 2420 | - if ( ! $EVT_ID) { |
|
| 2421 | - return false; |
|
| 2422 | - } |
|
| 2423 | - $this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 2424 | - return true; |
|
| 2425 | - } |
|
| 2426 | - |
|
| 2427 | - |
|
| 2428 | - /** |
|
| 2429 | - * process_reg_step |
|
| 2430 | - * |
|
| 2431 | - * @access public |
|
| 2432 | - * @return string |
|
| 2433 | - * @throws \RuntimeException |
|
| 2434 | - * @throws \EE_Error |
|
| 2435 | - */ |
|
| 2436 | - public function process_reg_step() |
|
| 2437 | - { |
|
| 2438 | - EE_System::do_not_cache(); |
|
| 2439 | - $this->_set_reg_event(); |
|
| 2440 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 2441 | - EE_Registry::instance()->REQ->set('uts', time()); |
|
| 2442 | - //what step are we on? |
|
| 2443 | - $cart = EE_Registry::instance()->SSN->cart(); |
|
| 2444 | - $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
| 2445 | - //if doing ajax then we need to verify the nonce |
|
| 2446 | - if (defined('DOING_AJAX')) { |
|
| 2447 | - $nonce = isset($this->_req_data[$this->_req_nonce]) |
|
| 2448 | - ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : ''; |
|
| 2449 | - $this->_verify_nonce($nonce, $this->_req_nonce); |
|
| 2450 | - } |
|
| 2451 | - switch ($step) { |
|
| 2452 | - case 'ticket' : |
|
| 2453 | - //process ticket selection |
|
| 2454 | - $success = EED_Ticket_Selector::instance()->process_ticket_selections(); |
|
| 2455 | - if ($success) { |
|
| 2456 | - EE_Error::add_success(esc_html__('Tickets Selected. Now complete the registration.', |
|
| 2457 | - 'event_espresso')); |
|
| 2458 | - } else { |
|
| 2459 | - $query_args['step_error'] = $this->_req_data['step_error'] = true; |
|
| 2460 | - } |
|
| 2461 | - if (defined('DOING_AJAX')) { |
|
| 2462 | - $this->new_registration(); //display next step |
|
| 2463 | - } else { |
|
| 2464 | - $query_args = array( |
|
| 2465 | - 'action' => 'new_registration', |
|
| 2466 | - 'processing_registration' => 1, |
|
| 2467 | - 'event_id' => $this->_reg_event->ID(), |
|
| 2468 | - 'uts' => time(), |
|
| 2469 | - ); |
|
| 2470 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2471 | - } |
|
| 2472 | - break; |
|
| 2473 | - case 'questions' : |
|
| 2474 | - if ( ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['send_notifications'])) { |
|
| 2475 | - add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15); |
|
| 2476 | - } |
|
| 2477 | - //process registration |
|
| 2478 | - $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin(); |
|
| 2479 | - if ($cart instanceof EE_Cart) { |
|
| 2480 | - $grand_total = $cart->get_cart_grand_total(); |
|
| 2481 | - if ($grand_total instanceof EE_Line_Item) { |
|
| 2482 | - $grand_total->save_this_and_descendants_to_txn(); |
|
| 2483 | - } |
|
| 2484 | - } |
|
| 2485 | - if ( ! $transaction instanceof EE_Transaction) { |
|
| 2486 | - $query_args = array( |
|
| 2487 | - 'action' => 'new_registration', |
|
| 2488 | - 'processing_registration' => 2, |
|
| 2489 | - 'event_id' => $this->_reg_event->ID(), |
|
| 2490 | - 'uts' => time(), |
|
| 2491 | - ); |
|
| 2492 | - if (defined('DOING_AJAX')) { |
|
| 2493 | - //display registration form again because there are errors (maybe validation?) |
|
| 2494 | - $this->new_registration(); |
|
| 2495 | - return; |
|
| 2496 | - } else { |
|
| 2497 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2498 | - return; |
|
| 2499 | - } |
|
| 2500 | - } |
|
| 2501 | - // maybe update status, and make sure to save transaction if not done already |
|
| 2502 | - if ( ! $transaction->update_status_based_on_total_paid()) { |
|
| 2503 | - $transaction->save(); |
|
| 2504 | - } |
|
| 2505 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2506 | - $this->_req_data = array(); |
|
| 2507 | - $query_args = array( |
|
| 2508 | - 'action' => 'redirect_to_txn', |
|
| 2509 | - 'TXN_ID' => $transaction->ID(), |
|
| 2510 | - 'EVT_ID' => $this->_reg_event->ID(), |
|
| 2511 | - 'event_name' => urlencode($this->_reg_event->name()), |
|
| 2512 | - 'redirect_from' => 'new_registration', |
|
| 2513 | - ); |
|
| 2514 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2515 | - break; |
|
| 2516 | - } |
|
| 2517 | - //what are you looking here for? Should be nothing to do at this point. |
|
| 2518 | - } |
|
| 2519 | - |
|
| 2520 | - |
|
| 2521 | - /** |
|
| 2522 | - * redirect_to_txn |
|
| 2523 | - * |
|
| 2524 | - * @access public |
|
| 2525 | - * @return void |
|
| 2526 | - */ |
|
| 2527 | - public function redirect_to_txn() |
|
| 2528 | - { |
|
| 2529 | - EE_System::do_not_cache(); |
|
| 2530 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2531 | - $query_args = array( |
|
| 2532 | - 'action' => 'view_transaction', |
|
| 2533 | - 'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0, |
|
| 2534 | - 'page' => 'espresso_transactions', |
|
| 2535 | - ); |
|
| 2536 | - if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) { |
|
| 2537 | - $query_args['EVT_ID'] = $this->_req_data['EVT_ID']; |
|
| 2538 | - $query_args['event_name'] = urlencode($this->_req_data['event_name']); |
|
| 2539 | - $query_args['redirect_from'] = $this->_req_data['redirect_from']; |
|
| 2540 | - } |
|
| 2541 | - EE_Error::add_success(__('Registration Created. Please review the transaction and add any payments as necessary', |
|
| 2542 | - 'event_espresso')); |
|
| 2543 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2544 | - } |
|
| 2545 | - |
|
| 2546 | - |
|
| 2547 | - /** |
|
| 2548 | - * generates HTML for the Attendee Contact List |
|
| 2549 | - * |
|
| 2550 | - * @access protected |
|
| 2551 | - * @return void |
|
| 2552 | - */ |
|
| 2553 | - protected function _attendee_contact_list_table() |
|
| 2554 | - { |
|
| 2555 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2556 | - $this->_search_btn_label = __('Contacts', 'event_espresso'); |
|
| 2557 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 2558 | - } |
|
| 2559 | - |
|
| 2560 | - |
|
| 2561 | - /** |
|
| 2562 | - * get_attendees |
|
| 2563 | - * |
|
| 2564 | - * @param bool $count whether to return count or data. |
|
| 2565 | - * @access public |
|
| 2566 | - * @return array |
|
| 2567 | - */ |
|
| 2568 | - public function get_attendees($per_page, $count = false, $trash = false) |
|
| 2569 | - { |
|
| 2570 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2571 | - require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php'); |
|
| 2572 | - $ATT_MDL = EEM_Attendee::instance(); |
|
| 2573 | - $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
|
| 2574 | - switch ($this->_req_data['orderby']) { |
|
| 2575 | - case 'ATT_ID': |
|
| 2576 | - $orderby = 'ATT_ID'; |
|
| 2577 | - break; |
|
| 2578 | - case 'ATT_fname': |
|
| 2579 | - $orderby = 'ATT_fname'; |
|
| 2580 | - break; |
|
| 2581 | - case 'ATT_email': |
|
| 2582 | - $orderby = 'ATT_email'; |
|
| 2583 | - break; |
|
| 2584 | - case 'ATT_city': |
|
| 2585 | - $orderby = 'ATT_city'; |
|
| 2586 | - break; |
|
| 2587 | - case 'STA_ID': |
|
| 2588 | - $orderby = 'STA_ID'; |
|
| 2589 | - break; |
|
| 2590 | - case 'CNT_ID': |
|
| 2591 | - $orderby = 'CNT_ID'; |
|
| 2592 | - break; |
|
| 2593 | - default: |
|
| 2594 | - $orderby = 'ATT_lname'; |
|
| 2595 | - } |
|
| 2596 | - $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] |
|
| 2597 | - : 'ASC'; |
|
| 2598 | - $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
| 2599 | - ? $this->_req_data['paged'] : 1; |
|
| 2600 | - $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10; |
|
| 2601 | - $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
| 2602 | - ? $this->_req_data['perpage'] : $per_page; |
|
| 2603 | - $_where = array(); |
|
| 2604 | - if ( ! empty($this->_req_data['s'])) { |
|
| 2605 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 2606 | - $_where['OR'] = array( |
|
| 2607 | - 'Registration.Event.EVT_name' => array('LIKE', $sstr), |
|
| 2608 | - 'Registration.Event.EVT_desc' => array('LIKE', $sstr), |
|
| 2609 | - 'Registration.Event.EVT_short_desc' => array('LIKE', $sstr), |
|
| 2610 | - 'ATT_fname' => array('LIKE', $sstr), |
|
| 2611 | - 'ATT_lname' => array('LIKE', $sstr), |
|
| 2612 | - 'ATT_short_bio' => array('LIKE', $sstr), |
|
| 2613 | - 'ATT_email' => array('LIKE', $sstr), |
|
| 2614 | - 'ATT_address' => array('LIKE', $sstr), |
|
| 2615 | - 'ATT_address2' => array('LIKE', $sstr), |
|
| 2616 | - 'ATT_city' => array('LIKE', $sstr), |
|
| 2617 | - 'Country.CNT_name' => array('LIKE', $sstr), |
|
| 2618 | - 'State.STA_name' => array('LIKE', $sstr), |
|
| 2619 | - 'ATT_phone' => array('LIKE', $sstr), |
|
| 2620 | - 'Registration.REG_final_price' => array('LIKE', $sstr), |
|
| 2621 | - 'Registration.REG_code' => array('LIKE', $sstr), |
|
| 2622 | - 'Registration.REG_count' => array('LIKE', $sstr), |
|
| 2623 | - 'Registration.REG_group_size' => array('LIKE', $sstr), |
|
| 2624 | - ); |
|
| 2625 | - } |
|
| 2626 | - $offset = ($current_page - 1) * $per_page; |
|
| 2627 | - $limit = $count ? null : array($offset, $per_page); |
|
| 2628 | - if ($trash) { |
|
| 2629 | - $_where['status'] = array('!=', 'publish'); |
|
| 2630 | - $all_attendees = $count |
|
| 2631 | - ? $ATT_MDL->count(array( |
|
| 2632 | - $_where, |
|
| 2633 | - 'order_by' => array($orderby => $sort), |
|
| 2634 | - 'limit' => $limit, |
|
| 2635 | - ), 'ATT_ID', true) |
|
| 2636 | - : $ATT_MDL->get_all(array( |
|
| 2637 | - $_where, |
|
| 2638 | - 'order_by' => array($orderby => $sort), |
|
| 2639 | - 'limit' => $limit, |
|
| 2640 | - )); |
|
| 2641 | - } else { |
|
| 2642 | - $_where['status'] = array('IN', array('publish')); |
|
| 2643 | - $all_attendees = $count |
|
| 2644 | - ? $ATT_MDL->count(array( |
|
| 2645 | - $_where, |
|
| 2646 | - 'order_by' => array($orderby => $sort), |
|
| 2647 | - 'limit' => $limit, |
|
| 2648 | - ), 'ATT_ID', true) |
|
| 2649 | - : $ATT_MDL->get_all(array( |
|
| 2650 | - $_where, |
|
| 2651 | - 'order_by' => array($orderby => $sort), |
|
| 2652 | - 'limit' => $limit, |
|
| 2653 | - )); |
|
| 2654 | - } |
|
| 2655 | - return $all_attendees; |
|
| 2656 | - } |
|
| 2657 | - |
|
| 2658 | - |
|
| 2659 | - /** |
|
| 2660 | - * This is just taking care of resending the registration confirmation |
|
| 2661 | - * |
|
| 2662 | - * @access protected |
|
| 2663 | - * @return void |
|
| 2664 | - */ |
|
| 2665 | - protected function _resend_registration() |
|
| 2666 | - { |
|
| 2667 | - $this->_process_resend_registration(); |
|
| 2668 | - $query_args = isset($this->_req_data['redirect_to']) |
|
| 2669 | - ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID']) |
|
| 2670 | - : array( |
|
| 2671 | - 'action' => 'default', |
|
| 2672 | - ); |
|
| 2673 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2674 | - } |
|
| 2675 | - |
|
| 2676 | - /** |
|
| 2677 | - * Creates a registration report, but accepts the name of a method to use for preparing the query parameters |
|
| 2678 | - * to use when selecting registrations |
|
| 2679 | - * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing |
|
| 2680 | - * the query parameters from the request |
|
| 2681 | - * @return void ends the request with a redirect or download |
|
| 2682 | - */ |
|
| 2683 | - public function _registrations_report_base( $method_name_for_getting_query_params ) |
|
| 2684 | - { |
|
| 2685 | - if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 2686 | - wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2687 | - 'page' => 'espresso_batch', |
|
| 2688 | - 'batch' => 'file', |
|
| 2689 | - 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
| 2690 | - 'filters' => urlencode( |
|
| 2691 | - serialize( |
|
| 2692 | - call_user_func( |
|
| 2693 | - array( $this, $method_name_for_getting_query_params ), |
|
| 2694 | - EEH_Array::is_set( |
|
| 2695 | - $this->_req_data, |
|
| 2696 | - 'filters', |
|
| 2697 | - array() |
|
| 2698 | - ) |
|
| 2699 | - ) |
|
| 2700 | - ) |
|
| 2701 | - ), |
|
| 2702 | - 'use_filters' => EEH_Array::is_set($this->_req_data, 'use_filters', false), |
|
| 2703 | - 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'), |
|
| 2704 | - 'return_url' => urlencode($this->_req_data['return_url']), |
|
| 2705 | - ))); |
|
| 2706 | - } else { |
|
| 2707 | - $new_request_args = array( |
|
| 2708 | - 'export' => 'report', |
|
| 2709 | - 'action' => 'registrations_report_for_event', |
|
| 2710 | - 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
| 2711 | - ); |
|
| 2712 | - $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
| 2713 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 2714 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 2715 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
| 2716 | - $EE_Export->export(); |
|
| 2717 | - } |
|
| 2718 | - } |
|
| 2719 | - } |
|
| 2720 | - |
|
| 2721 | - |
|
| 2722 | - |
|
| 2723 | - /** |
|
| 2724 | - * Creates a registration report using only query parameters in the request |
|
| 2725 | - * @return void |
|
| 2726 | - */ |
|
| 2727 | - public function _registrations_report() |
|
| 2728 | - { |
|
| 2729 | - $this->_registrations_report_base( '_get_registration_query_parameters' ); |
|
| 2730 | - } |
|
| 2731 | - |
|
| 2732 | - |
|
| 2733 | - public function _contact_list_export() |
|
| 2734 | - { |
|
| 2735 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 2736 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 2737 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
| 2738 | - $EE_Export->export_attendees(); |
|
| 2739 | - } |
|
| 2740 | - } |
|
| 2741 | - |
|
| 2742 | - |
|
| 2743 | - public function _contact_list_report() |
|
| 2744 | - { |
|
| 2745 | - if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 2746 | - wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2747 | - 'page' => 'espresso_batch', |
|
| 2748 | - 'batch' => 'file', |
|
| 2749 | - 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'), |
|
| 2750 | - 'return_url' => urlencode($this->_req_data['return_url']), |
|
| 2751 | - ))); |
|
| 2752 | - } else { |
|
| 2753 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 2754 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 2755 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
| 2756 | - $EE_Export->report_attendees(); |
|
| 2757 | - } |
|
| 2758 | - } |
|
| 2759 | - } |
|
| 2760 | - |
|
| 2761 | - |
|
| 2762 | - |
|
| 2763 | - |
|
| 2764 | - |
|
| 2765 | - /*************************************** ATTENDEE DETAILS ***************************************/ |
|
| 2766 | - /** |
|
| 2767 | - * This duplicates the attendee object for the given incoming registration id and attendee_id. |
|
| 2768 | - * |
|
| 2769 | - * @return void |
|
| 2770 | - */ |
|
| 2771 | - protected function _duplicate_attendee() |
|
| 2772 | - { |
|
| 2773 | - $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default'; |
|
| 2774 | - //verify we have necessary info |
|
| 2775 | - if (empty($this->_req_data['_REG_ID'])) { |
|
| 2776 | - EE_Error::add_error(__('Unable to create the contact for the registration because the required parameters are not present (_REG_ID )', |
|
| 2777 | - 'event_espresso'), __FILE__, __LINE__, __FUNCTION__); |
|
| 2778 | - $query_args = array('action' => $action); |
|
| 2779 | - $this->_redirect_after_action('', '', '', $query_args, true); |
|
| 2780 | - } |
|
| 2781 | - //okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration. |
|
| 2782 | - $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']); |
|
| 2783 | - $attendee = $registration->attendee(); |
|
| 2784 | - //remove relation of existing attendee on registration |
|
| 2785 | - $registration->_remove_relation_to($attendee, 'Attendee'); |
|
| 2786 | - //new attendee |
|
| 2787 | - $new_attendee = clone $attendee; |
|
| 2788 | - $new_attendee->set('ATT_ID', 0); |
|
| 2789 | - $new_attendee->save(); |
|
| 2790 | - //add new attendee to reg |
|
| 2791 | - $registration->_add_relation_to($new_attendee, 'Attendee'); |
|
| 2792 | - EE_Error::add_success(__('New Contact record created. Now make any edits you wish to make for this contact.', |
|
| 2793 | - 'event_espresso')); |
|
| 2794 | - //redirect to edit page for attendee |
|
| 2795 | - $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee'); |
|
| 2796 | - $this->_redirect_after_action('', '', '', $query_args, true); |
|
| 2797 | - } |
|
| 2798 | - |
|
| 2799 | - |
|
| 2800 | - //related to cpt routes |
|
| 2801 | - protected function _insert_update_cpt_item($post_id, $post) |
|
| 2802 | - { |
|
| 2803 | - $success = true; |
|
| 2804 | - $attendee = EEM_Attendee::instance()->get_one_by_ID($post_id); |
|
| 2805 | - //for attendee updates |
|
| 2806 | - if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) { |
|
| 2807 | - //note we should only be UPDATING attendees at this point. |
|
| 2808 | - $updated_fields = array( |
|
| 2809 | - 'ATT_fname' => $this->_req_data['ATT_fname'], |
|
| 2810 | - 'ATT_lname' => $this->_req_data['ATT_lname'], |
|
| 2811 | - 'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], |
|
| 2812 | - 'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', |
|
| 2813 | - 'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', |
|
| 2814 | - 'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '', |
|
| 2815 | - 'STA_ID' => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '', |
|
| 2816 | - 'CNT_ISO' => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '', |
|
| 2817 | - 'ATT_zip' => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '', |
|
| 2818 | - 'ATT_email' => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '', |
|
| 2819 | - 'ATT_phone' => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : '', |
|
| 2820 | - ); |
|
| 2821 | - foreach ($updated_fields as $field => $value) { |
|
| 2822 | - $attendee->set($field, $value); |
|
| 2823 | - } |
|
| 2824 | - $success = $attendee->save(); |
|
| 2825 | - $attendee_update_callbacks = apply_filters('FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', |
|
| 2826 | - array()); |
|
| 2827 | - foreach ($attendee_update_callbacks as $a_callback) { |
|
| 2828 | - if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) { |
|
| 2829 | - throw new EE_Error(sprintf(__('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback. Please check the spelling.', |
|
| 2830 | - 'event_espresso'), $a_callback)); |
|
| 2831 | - } |
|
| 2832 | - } |
|
| 2833 | - } |
|
| 2834 | - if ($success === false) { |
|
| 2835 | - EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', |
|
| 2836 | - 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 2837 | - } |
|
| 2838 | - } |
|
| 2839 | - |
|
| 2840 | - |
|
| 2841 | - public function trash_cpt_item($post_id) |
|
| 2842 | - { |
|
| 2843 | - } |
|
| 2844 | - |
|
| 2845 | - |
|
| 2846 | - public function delete_cpt_item($post_id) |
|
| 2847 | - { |
|
| 2848 | - } |
|
| 2849 | - |
|
| 2850 | - |
|
| 2851 | - public function restore_cpt_item($post_id) |
|
| 2852 | - { |
|
| 2853 | - } |
|
| 2854 | - |
|
| 2855 | - |
|
| 2856 | - protected function _restore_cpt_item($post_id, $revision_id) |
|
| 2857 | - { |
|
| 2858 | - } |
|
| 2859 | - |
|
| 2860 | - |
|
| 2861 | - public function attendee_editor_metaboxes() |
|
| 2862 | - { |
|
| 2863 | - $this->verify_cpt_object(); |
|
| 2864 | - remove_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], |
|
| 2865 | - 'normal', 'core'); |
|
| 2866 | - remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
| 2867 | - if (post_type_supports('espresso_attendees', 'excerpt')) { |
|
| 2868 | - add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', |
|
| 2869 | - $this->_cpt_routes[$this->_req_action], 'normal'); |
|
| 2870 | - } |
|
| 2871 | - if (post_type_supports('espresso_attendees', 'comments')) { |
|
| 2872 | - add_meta_box('commentsdiv', __('Notes on the Contact', 'event_espresso'), 'post_comment_meta_box', |
|
| 2873 | - $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
| 2874 | - } |
|
| 2875 | - add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), |
|
| 2876 | - array($this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core'); |
|
| 2877 | - add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), |
|
| 2878 | - array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
| 2879 | - add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), |
|
| 2880 | - array($this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high'); |
|
| 2881 | - } |
|
| 2882 | - |
|
| 2883 | - |
|
| 2884 | - /** |
|
| 2885 | - * Metabox for attendee contact info |
|
| 2886 | - * |
|
| 2887 | - * @param WP_Post $post wp post object |
|
| 2888 | - * @return string attendee contact info ( and form ) |
|
| 2889 | - */ |
|
| 2890 | - public function attendee_contact_info($post) |
|
| 2891 | - { |
|
| 2892 | - //get attendee object ( should already have it ) |
|
| 2893 | - $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 2894 | - $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php'; |
|
| 2895 | - EEH_Template::display_template($template, $this->_template_args); |
|
| 2896 | - } |
|
| 2897 | - |
|
| 2898 | - |
|
| 2899 | - /** |
|
| 2900 | - * Metabox for attendee details |
|
| 2901 | - * |
|
| 2902 | - * @param WP_Post $post wp post object |
|
| 2903 | - * @return string attendee address details (and form) |
|
| 2904 | - */ |
|
| 2905 | - public function attendee_address_details($post) |
|
| 2906 | - { |
|
| 2907 | - //get attendee object (should already have it) |
|
| 2908 | - $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 2909 | - $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array( |
|
| 2910 | - 'QST_ID' => 0, |
|
| 2911 | - 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
| 2912 | - 'QST_system' => 'admin-state', |
|
| 2913 | - )), EE_Answer::new_instance(array( |
|
| 2914 | - 'ANS_ID' => 0, |
|
| 2915 | - 'ANS_value' => $this->_cpt_model_obj->state_ID(), |
|
| 2916 | - )), array( |
|
| 2917 | - 'input_id' => 'STA_ID', |
|
| 2918 | - 'input_name' => 'STA_ID', |
|
| 2919 | - 'input_prefix' => '', |
|
| 2920 | - 'append_qstn_id' => false, |
|
| 2921 | - ))); |
|
| 2922 | - $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array( |
|
| 2923 | - 'QST_ID' => 0, |
|
| 2924 | - 'QST_display_text' => __('Country', 'event_espresso'), |
|
| 2925 | - 'QST_system' => 'admin-country', |
|
| 2926 | - )), EE_Answer::new_instance(array( |
|
| 2927 | - 'ANS_ID' => 0, |
|
| 2928 | - 'ANS_value' => $this->_cpt_model_obj->country_ID(), |
|
| 2929 | - )), array( |
|
| 2930 | - 'input_id' => 'CNT_ISO', |
|
| 2931 | - 'input_name' => 'CNT_ISO', |
|
| 2932 | - 'input_prefix' => '', |
|
| 2933 | - 'append_qstn_id' => false, |
|
| 2934 | - ))); |
|
| 2935 | - $template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php'; |
|
| 2936 | - EEH_Template::display_template($template, $this->_template_args); |
|
| 2937 | - } |
|
| 2938 | - |
|
| 2939 | - |
|
| 2940 | - /** |
|
| 2941 | - * _attendee_details |
|
| 2942 | - * |
|
| 2943 | - * @access protected |
|
| 2944 | - * @return void |
|
| 2945 | - */ |
|
| 2946 | - public function attendee_registrations_meta_box($post) |
|
| 2947 | - { |
|
| 2948 | - $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 2949 | - $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration'); |
|
| 2950 | - $template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php'; |
|
| 2951 | - EEH_Template::display_template($template, $this->_template_args); |
|
| 2952 | - } |
|
| 2953 | - |
|
| 2954 | - |
|
| 2955 | - /** |
|
| 2956 | - * add in the form fields for the attendee edit |
|
| 2957 | - * |
|
| 2958 | - * @param WP_Post $post wp post object |
|
| 2959 | - * @return string html for new form. |
|
| 2960 | - */ |
|
| 2961 | - public function after_title_form_fields($post) |
|
| 2962 | - { |
|
| 2963 | - if ($post->post_type == 'espresso_attendees') { |
|
| 2964 | - $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php'; |
|
| 2965 | - $template_args['attendee'] = $this->_cpt_model_obj; |
|
| 2966 | - EEH_Template::display_template($template, $template_args); |
|
| 2967 | - } |
|
| 2968 | - } |
|
| 2969 | - |
|
| 2970 | - |
|
| 2971 | - /** |
|
| 2972 | - * _trash_or_restore_attendee |
|
| 2973 | - * |
|
| 2974 | - * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
| 2975 | - * @access protected |
|
| 2976 | - * @return void |
|
| 2977 | - */ |
|
| 2978 | - protected function _trash_or_restore_attendees($trash = true) |
|
| 2979 | - { |
|
| 2980 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2981 | - $ATT_MDL = EEM_Attendee::instance(); |
|
| 2982 | - $success = 1; |
|
| 2983 | - //Checkboxes |
|
| 2984 | - if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 2985 | - // if array has more than one element than success message should be plural |
|
| 2986 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
| 2987 | - // cycle thru checkboxes |
|
| 2988 | - while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 2989 | - $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID) |
|
| 2990 | - : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID); |
|
| 2991 | - if ( ! $updated) { |
|
| 2992 | - $success = 0; |
|
| 2993 | - } |
|
| 2994 | - } |
|
| 2995 | - } else { |
|
| 2996 | - // grab single id and delete |
|
| 2997 | - $ATT_ID = absint($this->_req_data['ATT_ID']); |
|
| 2998 | - //get attendee |
|
| 2999 | - $att = $ATT_MDL->get_one_by_ID($ATT_ID); |
|
| 3000 | - $updated = $trash ? $att->set_status('trash') : $att->set_status('publish'); |
|
| 3001 | - $updated = $att->save(); |
|
| 3002 | - if ( ! $updated) { |
|
| 3003 | - $success = 0; |
|
| 3004 | - } |
|
| 3005 | - } |
|
| 3006 | - $what = $success > 1 ? __('Contacts', 'event_espresso') : __('Contact', 'event_espresso'); |
|
| 3007 | - $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
|
| 3008 | - $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list')); |
|
| 3009 | - } |
|
| 2358 | + } |
|
| 2359 | + $template_args = array( |
|
| 2360 | + 'title' => '', |
|
| 2361 | + 'content' => '', |
|
| 2362 | + 'step_button_text' => '', |
|
| 2363 | + 'show_notification_toggle' => false, |
|
| 2364 | + ); |
|
| 2365 | + //to indicate we're processing a new registration |
|
| 2366 | + $hidden_fields = array( |
|
| 2367 | + 'processing_registration' => array( |
|
| 2368 | + 'type' => 'hidden', |
|
| 2369 | + 'value' => 0, |
|
| 2370 | + ), |
|
| 2371 | + 'event_id' => array( |
|
| 2372 | + 'type' => 'hidden', |
|
| 2373 | + 'value' => $this->_reg_event->ID(), |
|
| 2374 | + ), |
|
| 2375 | + ); |
|
| 2376 | + //if the cart is empty then we know we're at step one so we'll display ticket selector |
|
| 2377 | + $cart = EE_Registry::instance()->SSN->cart(); |
|
| 2378 | + $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
| 2379 | + switch ($step) { |
|
| 2380 | + case 'ticket' : |
|
| 2381 | + $hidden_fields['processing_registration']['value'] = 1; |
|
| 2382 | + $template_args['title'] = __('Step One: Select the Ticket for this registration', |
|
| 2383 | + 'event_espresso'); |
|
| 2384 | + $template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event); |
|
| 2385 | + $template_args['step_button_text'] = __('Add Tickets and Continue to Registrant Details', |
|
| 2386 | + 'event_espresso'); |
|
| 2387 | + $template_args['show_notification_toggle'] = false; |
|
| 2388 | + break; |
|
| 2389 | + case 'questions' : |
|
| 2390 | + $hidden_fields['processing_registration']['value'] = 2; |
|
| 2391 | + $template_args['title'] = __('Step Two: Add Registrant Details for this Registration', |
|
| 2392 | + 'event_espresso'); |
|
| 2393 | + //in theory we should be able to run EED_SPCO at this point because the cart should have been setup properly by the first process_reg_step run. |
|
| 2394 | + $template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin(); |
|
| 2395 | + $template_args['step_button_text'] = __('Save Registration and Continue to Details', |
|
| 2396 | + 'event_espresso'); |
|
| 2397 | + $template_args['show_notification_toggle'] = true; |
|
| 2398 | + break; |
|
| 2399 | + } |
|
| 2400 | + $this->_set_add_edit_form_tags('process_reg_step', |
|
| 2401 | + $hidden_fields); //we come back to the process_registration_step route. |
|
| 2402 | + return EEH_Template::display_template(REG_TEMPLATE_PATH |
|
| 2403 | + . 'reg_admin_register_new_attendee_step_content.template.php', |
|
| 2404 | + $template_args, true); |
|
| 2405 | + } |
|
| 2406 | + |
|
| 2407 | + |
|
| 2408 | + /** |
|
| 2409 | + * set_reg_event |
|
| 2410 | + * |
|
| 2411 | + * @access private |
|
| 2412 | + * @return boolean |
|
| 2413 | + */ |
|
| 2414 | + private function _set_reg_event() |
|
| 2415 | + { |
|
| 2416 | + if (is_object($this->_reg_event)) { |
|
| 2417 | + return true; |
|
| 2418 | + } |
|
| 2419 | + $EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false; |
|
| 2420 | + if ( ! $EVT_ID) { |
|
| 2421 | + return false; |
|
| 2422 | + } |
|
| 2423 | + $this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 2424 | + return true; |
|
| 2425 | + } |
|
| 2426 | + |
|
| 2427 | + |
|
| 2428 | + /** |
|
| 2429 | + * process_reg_step |
|
| 2430 | + * |
|
| 2431 | + * @access public |
|
| 2432 | + * @return string |
|
| 2433 | + * @throws \RuntimeException |
|
| 2434 | + * @throws \EE_Error |
|
| 2435 | + */ |
|
| 2436 | + public function process_reg_step() |
|
| 2437 | + { |
|
| 2438 | + EE_System::do_not_cache(); |
|
| 2439 | + $this->_set_reg_event(); |
|
| 2440 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 2441 | + EE_Registry::instance()->REQ->set('uts', time()); |
|
| 2442 | + //what step are we on? |
|
| 2443 | + $cart = EE_Registry::instance()->SSN->cart(); |
|
| 2444 | + $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
| 2445 | + //if doing ajax then we need to verify the nonce |
|
| 2446 | + if (defined('DOING_AJAX')) { |
|
| 2447 | + $nonce = isset($this->_req_data[$this->_req_nonce]) |
|
| 2448 | + ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : ''; |
|
| 2449 | + $this->_verify_nonce($nonce, $this->_req_nonce); |
|
| 2450 | + } |
|
| 2451 | + switch ($step) { |
|
| 2452 | + case 'ticket' : |
|
| 2453 | + //process ticket selection |
|
| 2454 | + $success = EED_Ticket_Selector::instance()->process_ticket_selections(); |
|
| 2455 | + if ($success) { |
|
| 2456 | + EE_Error::add_success(esc_html__('Tickets Selected. Now complete the registration.', |
|
| 2457 | + 'event_espresso')); |
|
| 2458 | + } else { |
|
| 2459 | + $query_args['step_error'] = $this->_req_data['step_error'] = true; |
|
| 2460 | + } |
|
| 2461 | + if (defined('DOING_AJAX')) { |
|
| 2462 | + $this->new_registration(); //display next step |
|
| 2463 | + } else { |
|
| 2464 | + $query_args = array( |
|
| 2465 | + 'action' => 'new_registration', |
|
| 2466 | + 'processing_registration' => 1, |
|
| 2467 | + 'event_id' => $this->_reg_event->ID(), |
|
| 2468 | + 'uts' => time(), |
|
| 2469 | + ); |
|
| 2470 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2471 | + } |
|
| 2472 | + break; |
|
| 2473 | + case 'questions' : |
|
| 2474 | + if ( ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['send_notifications'])) { |
|
| 2475 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15); |
|
| 2476 | + } |
|
| 2477 | + //process registration |
|
| 2478 | + $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin(); |
|
| 2479 | + if ($cart instanceof EE_Cart) { |
|
| 2480 | + $grand_total = $cart->get_cart_grand_total(); |
|
| 2481 | + if ($grand_total instanceof EE_Line_Item) { |
|
| 2482 | + $grand_total->save_this_and_descendants_to_txn(); |
|
| 2483 | + } |
|
| 2484 | + } |
|
| 2485 | + if ( ! $transaction instanceof EE_Transaction) { |
|
| 2486 | + $query_args = array( |
|
| 2487 | + 'action' => 'new_registration', |
|
| 2488 | + 'processing_registration' => 2, |
|
| 2489 | + 'event_id' => $this->_reg_event->ID(), |
|
| 2490 | + 'uts' => time(), |
|
| 2491 | + ); |
|
| 2492 | + if (defined('DOING_AJAX')) { |
|
| 2493 | + //display registration form again because there are errors (maybe validation?) |
|
| 2494 | + $this->new_registration(); |
|
| 2495 | + return; |
|
| 2496 | + } else { |
|
| 2497 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2498 | + return; |
|
| 2499 | + } |
|
| 2500 | + } |
|
| 2501 | + // maybe update status, and make sure to save transaction if not done already |
|
| 2502 | + if ( ! $transaction->update_status_based_on_total_paid()) { |
|
| 2503 | + $transaction->save(); |
|
| 2504 | + } |
|
| 2505 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2506 | + $this->_req_data = array(); |
|
| 2507 | + $query_args = array( |
|
| 2508 | + 'action' => 'redirect_to_txn', |
|
| 2509 | + 'TXN_ID' => $transaction->ID(), |
|
| 2510 | + 'EVT_ID' => $this->_reg_event->ID(), |
|
| 2511 | + 'event_name' => urlencode($this->_reg_event->name()), |
|
| 2512 | + 'redirect_from' => 'new_registration', |
|
| 2513 | + ); |
|
| 2514 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2515 | + break; |
|
| 2516 | + } |
|
| 2517 | + //what are you looking here for? Should be nothing to do at this point. |
|
| 2518 | + } |
|
| 2519 | + |
|
| 2520 | + |
|
| 2521 | + /** |
|
| 2522 | + * redirect_to_txn |
|
| 2523 | + * |
|
| 2524 | + * @access public |
|
| 2525 | + * @return void |
|
| 2526 | + */ |
|
| 2527 | + public function redirect_to_txn() |
|
| 2528 | + { |
|
| 2529 | + EE_System::do_not_cache(); |
|
| 2530 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 2531 | + $query_args = array( |
|
| 2532 | + 'action' => 'view_transaction', |
|
| 2533 | + 'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0, |
|
| 2534 | + 'page' => 'espresso_transactions', |
|
| 2535 | + ); |
|
| 2536 | + if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) { |
|
| 2537 | + $query_args['EVT_ID'] = $this->_req_data['EVT_ID']; |
|
| 2538 | + $query_args['event_name'] = urlencode($this->_req_data['event_name']); |
|
| 2539 | + $query_args['redirect_from'] = $this->_req_data['redirect_from']; |
|
| 2540 | + } |
|
| 2541 | + EE_Error::add_success(__('Registration Created. Please review the transaction and add any payments as necessary', |
|
| 2542 | + 'event_espresso')); |
|
| 2543 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2544 | + } |
|
| 2545 | + |
|
| 2546 | + |
|
| 2547 | + /** |
|
| 2548 | + * generates HTML for the Attendee Contact List |
|
| 2549 | + * |
|
| 2550 | + * @access protected |
|
| 2551 | + * @return void |
|
| 2552 | + */ |
|
| 2553 | + protected function _attendee_contact_list_table() |
|
| 2554 | + { |
|
| 2555 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2556 | + $this->_search_btn_label = __('Contacts', 'event_espresso'); |
|
| 2557 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 2558 | + } |
|
| 2559 | + |
|
| 2560 | + |
|
| 2561 | + /** |
|
| 2562 | + * get_attendees |
|
| 2563 | + * |
|
| 2564 | + * @param bool $count whether to return count or data. |
|
| 2565 | + * @access public |
|
| 2566 | + * @return array |
|
| 2567 | + */ |
|
| 2568 | + public function get_attendees($per_page, $count = false, $trash = false) |
|
| 2569 | + { |
|
| 2570 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2571 | + require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php'); |
|
| 2572 | + $ATT_MDL = EEM_Attendee::instance(); |
|
| 2573 | + $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
|
| 2574 | + switch ($this->_req_data['orderby']) { |
|
| 2575 | + case 'ATT_ID': |
|
| 2576 | + $orderby = 'ATT_ID'; |
|
| 2577 | + break; |
|
| 2578 | + case 'ATT_fname': |
|
| 2579 | + $orderby = 'ATT_fname'; |
|
| 2580 | + break; |
|
| 2581 | + case 'ATT_email': |
|
| 2582 | + $orderby = 'ATT_email'; |
|
| 2583 | + break; |
|
| 2584 | + case 'ATT_city': |
|
| 2585 | + $orderby = 'ATT_city'; |
|
| 2586 | + break; |
|
| 2587 | + case 'STA_ID': |
|
| 2588 | + $orderby = 'STA_ID'; |
|
| 2589 | + break; |
|
| 2590 | + case 'CNT_ID': |
|
| 2591 | + $orderby = 'CNT_ID'; |
|
| 2592 | + break; |
|
| 2593 | + default: |
|
| 2594 | + $orderby = 'ATT_lname'; |
|
| 2595 | + } |
|
| 2596 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] |
|
| 2597 | + : 'ASC'; |
|
| 2598 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
| 2599 | + ? $this->_req_data['paged'] : 1; |
|
| 2600 | + $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10; |
|
| 2601 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
| 2602 | + ? $this->_req_data['perpage'] : $per_page; |
|
| 2603 | + $_where = array(); |
|
| 2604 | + if ( ! empty($this->_req_data['s'])) { |
|
| 2605 | + $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 2606 | + $_where['OR'] = array( |
|
| 2607 | + 'Registration.Event.EVT_name' => array('LIKE', $sstr), |
|
| 2608 | + 'Registration.Event.EVT_desc' => array('LIKE', $sstr), |
|
| 2609 | + 'Registration.Event.EVT_short_desc' => array('LIKE', $sstr), |
|
| 2610 | + 'ATT_fname' => array('LIKE', $sstr), |
|
| 2611 | + 'ATT_lname' => array('LIKE', $sstr), |
|
| 2612 | + 'ATT_short_bio' => array('LIKE', $sstr), |
|
| 2613 | + 'ATT_email' => array('LIKE', $sstr), |
|
| 2614 | + 'ATT_address' => array('LIKE', $sstr), |
|
| 2615 | + 'ATT_address2' => array('LIKE', $sstr), |
|
| 2616 | + 'ATT_city' => array('LIKE', $sstr), |
|
| 2617 | + 'Country.CNT_name' => array('LIKE', $sstr), |
|
| 2618 | + 'State.STA_name' => array('LIKE', $sstr), |
|
| 2619 | + 'ATT_phone' => array('LIKE', $sstr), |
|
| 2620 | + 'Registration.REG_final_price' => array('LIKE', $sstr), |
|
| 2621 | + 'Registration.REG_code' => array('LIKE', $sstr), |
|
| 2622 | + 'Registration.REG_count' => array('LIKE', $sstr), |
|
| 2623 | + 'Registration.REG_group_size' => array('LIKE', $sstr), |
|
| 2624 | + ); |
|
| 2625 | + } |
|
| 2626 | + $offset = ($current_page - 1) * $per_page; |
|
| 2627 | + $limit = $count ? null : array($offset, $per_page); |
|
| 2628 | + if ($trash) { |
|
| 2629 | + $_where['status'] = array('!=', 'publish'); |
|
| 2630 | + $all_attendees = $count |
|
| 2631 | + ? $ATT_MDL->count(array( |
|
| 2632 | + $_where, |
|
| 2633 | + 'order_by' => array($orderby => $sort), |
|
| 2634 | + 'limit' => $limit, |
|
| 2635 | + ), 'ATT_ID', true) |
|
| 2636 | + : $ATT_MDL->get_all(array( |
|
| 2637 | + $_where, |
|
| 2638 | + 'order_by' => array($orderby => $sort), |
|
| 2639 | + 'limit' => $limit, |
|
| 2640 | + )); |
|
| 2641 | + } else { |
|
| 2642 | + $_where['status'] = array('IN', array('publish')); |
|
| 2643 | + $all_attendees = $count |
|
| 2644 | + ? $ATT_MDL->count(array( |
|
| 2645 | + $_where, |
|
| 2646 | + 'order_by' => array($orderby => $sort), |
|
| 2647 | + 'limit' => $limit, |
|
| 2648 | + ), 'ATT_ID', true) |
|
| 2649 | + : $ATT_MDL->get_all(array( |
|
| 2650 | + $_where, |
|
| 2651 | + 'order_by' => array($orderby => $sort), |
|
| 2652 | + 'limit' => $limit, |
|
| 2653 | + )); |
|
| 2654 | + } |
|
| 2655 | + return $all_attendees; |
|
| 2656 | + } |
|
| 2657 | + |
|
| 2658 | + |
|
| 2659 | + /** |
|
| 2660 | + * This is just taking care of resending the registration confirmation |
|
| 2661 | + * |
|
| 2662 | + * @access protected |
|
| 2663 | + * @return void |
|
| 2664 | + */ |
|
| 2665 | + protected function _resend_registration() |
|
| 2666 | + { |
|
| 2667 | + $this->_process_resend_registration(); |
|
| 2668 | + $query_args = isset($this->_req_data['redirect_to']) |
|
| 2669 | + ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID']) |
|
| 2670 | + : array( |
|
| 2671 | + 'action' => 'default', |
|
| 2672 | + ); |
|
| 2673 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 2674 | + } |
|
| 2675 | + |
|
| 2676 | + /** |
|
| 2677 | + * Creates a registration report, but accepts the name of a method to use for preparing the query parameters |
|
| 2678 | + * to use when selecting registrations |
|
| 2679 | + * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing |
|
| 2680 | + * the query parameters from the request |
|
| 2681 | + * @return void ends the request with a redirect or download |
|
| 2682 | + */ |
|
| 2683 | + public function _registrations_report_base( $method_name_for_getting_query_params ) |
|
| 2684 | + { |
|
| 2685 | + if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 2686 | + wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2687 | + 'page' => 'espresso_batch', |
|
| 2688 | + 'batch' => 'file', |
|
| 2689 | + 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
| 2690 | + 'filters' => urlencode( |
|
| 2691 | + serialize( |
|
| 2692 | + call_user_func( |
|
| 2693 | + array( $this, $method_name_for_getting_query_params ), |
|
| 2694 | + EEH_Array::is_set( |
|
| 2695 | + $this->_req_data, |
|
| 2696 | + 'filters', |
|
| 2697 | + array() |
|
| 2698 | + ) |
|
| 2699 | + ) |
|
| 2700 | + ) |
|
| 2701 | + ), |
|
| 2702 | + 'use_filters' => EEH_Array::is_set($this->_req_data, 'use_filters', false), |
|
| 2703 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'), |
|
| 2704 | + 'return_url' => urlencode($this->_req_data['return_url']), |
|
| 2705 | + ))); |
|
| 2706 | + } else { |
|
| 2707 | + $new_request_args = array( |
|
| 2708 | + 'export' => 'report', |
|
| 2709 | + 'action' => 'registrations_report_for_event', |
|
| 2710 | + 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
| 2711 | + ); |
|
| 2712 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
| 2713 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 2714 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 2715 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
| 2716 | + $EE_Export->export(); |
|
| 2717 | + } |
|
| 2718 | + } |
|
| 2719 | + } |
|
| 2720 | + |
|
| 2721 | + |
|
| 2722 | + |
|
| 2723 | + /** |
|
| 2724 | + * Creates a registration report using only query parameters in the request |
|
| 2725 | + * @return void |
|
| 2726 | + */ |
|
| 2727 | + public function _registrations_report() |
|
| 2728 | + { |
|
| 2729 | + $this->_registrations_report_base( '_get_registration_query_parameters' ); |
|
| 2730 | + } |
|
| 2731 | + |
|
| 2732 | + |
|
| 2733 | + public function _contact_list_export() |
|
| 2734 | + { |
|
| 2735 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 2736 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 2737 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
| 2738 | + $EE_Export->export_attendees(); |
|
| 2739 | + } |
|
| 2740 | + } |
|
| 2741 | + |
|
| 2742 | + |
|
| 2743 | + public function _contact_list_report() |
|
| 2744 | + { |
|
| 2745 | + if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
| 2746 | + wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2747 | + 'page' => 'espresso_batch', |
|
| 2748 | + 'batch' => 'file', |
|
| 2749 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'), |
|
| 2750 | + 'return_url' => urlencode($this->_req_data['return_url']), |
|
| 2751 | + ))); |
|
| 2752 | + } else { |
|
| 2753 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 2754 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 2755 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
| 2756 | + $EE_Export->report_attendees(); |
|
| 2757 | + } |
|
| 2758 | + } |
|
| 2759 | + } |
|
| 2760 | + |
|
| 2761 | + |
|
| 2762 | + |
|
| 2763 | + |
|
| 2764 | + |
|
| 2765 | + /*************************************** ATTENDEE DETAILS ***************************************/ |
|
| 2766 | + /** |
|
| 2767 | + * This duplicates the attendee object for the given incoming registration id and attendee_id. |
|
| 2768 | + * |
|
| 2769 | + * @return void |
|
| 2770 | + */ |
|
| 2771 | + protected function _duplicate_attendee() |
|
| 2772 | + { |
|
| 2773 | + $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default'; |
|
| 2774 | + //verify we have necessary info |
|
| 2775 | + if (empty($this->_req_data['_REG_ID'])) { |
|
| 2776 | + EE_Error::add_error(__('Unable to create the contact for the registration because the required parameters are not present (_REG_ID )', |
|
| 2777 | + 'event_espresso'), __FILE__, __LINE__, __FUNCTION__); |
|
| 2778 | + $query_args = array('action' => $action); |
|
| 2779 | + $this->_redirect_after_action('', '', '', $query_args, true); |
|
| 2780 | + } |
|
| 2781 | + //okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration. |
|
| 2782 | + $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']); |
|
| 2783 | + $attendee = $registration->attendee(); |
|
| 2784 | + //remove relation of existing attendee on registration |
|
| 2785 | + $registration->_remove_relation_to($attendee, 'Attendee'); |
|
| 2786 | + //new attendee |
|
| 2787 | + $new_attendee = clone $attendee; |
|
| 2788 | + $new_attendee->set('ATT_ID', 0); |
|
| 2789 | + $new_attendee->save(); |
|
| 2790 | + //add new attendee to reg |
|
| 2791 | + $registration->_add_relation_to($new_attendee, 'Attendee'); |
|
| 2792 | + EE_Error::add_success(__('New Contact record created. Now make any edits you wish to make for this contact.', |
|
| 2793 | + 'event_espresso')); |
|
| 2794 | + //redirect to edit page for attendee |
|
| 2795 | + $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee'); |
|
| 2796 | + $this->_redirect_after_action('', '', '', $query_args, true); |
|
| 2797 | + } |
|
| 2798 | + |
|
| 2799 | + |
|
| 2800 | + //related to cpt routes |
|
| 2801 | + protected function _insert_update_cpt_item($post_id, $post) |
|
| 2802 | + { |
|
| 2803 | + $success = true; |
|
| 2804 | + $attendee = EEM_Attendee::instance()->get_one_by_ID($post_id); |
|
| 2805 | + //for attendee updates |
|
| 2806 | + if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) { |
|
| 2807 | + //note we should only be UPDATING attendees at this point. |
|
| 2808 | + $updated_fields = array( |
|
| 2809 | + 'ATT_fname' => $this->_req_data['ATT_fname'], |
|
| 2810 | + 'ATT_lname' => $this->_req_data['ATT_lname'], |
|
| 2811 | + 'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], |
|
| 2812 | + 'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', |
|
| 2813 | + 'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', |
|
| 2814 | + 'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '', |
|
| 2815 | + 'STA_ID' => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '', |
|
| 2816 | + 'CNT_ISO' => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '', |
|
| 2817 | + 'ATT_zip' => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '', |
|
| 2818 | + 'ATT_email' => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '', |
|
| 2819 | + 'ATT_phone' => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : '', |
|
| 2820 | + ); |
|
| 2821 | + foreach ($updated_fields as $field => $value) { |
|
| 2822 | + $attendee->set($field, $value); |
|
| 2823 | + } |
|
| 2824 | + $success = $attendee->save(); |
|
| 2825 | + $attendee_update_callbacks = apply_filters('FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', |
|
| 2826 | + array()); |
|
| 2827 | + foreach ($attendee_update_callbacks as $a_callback) { |
|
| 2828 | + if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) { |
|
| 2829 | + throw new EE_Error(sprintf(__('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback. Please check the spelling.', |
|
| 2830 | + 'event_espresso'), $a_callback)); |
|
| 2831 | + } |
|
| 2832 | + } |
|
| 2833 | + } |
|
| 2834 | + if ($success === false) { |
|
| 2835 | + EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', |
|
| 2836 | + 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 2837 | + } |
|
| 2838 | + } |
|
| 2839 | + |
|
| 2840 | + |
|
| 2841 | + public function trash_cpt_item($post_id) |
|
| 2842 | + { |
|
| 2843 | + } |
|
| 2844 | + |
|
| 2845 | + |
|
| 2846 | + public function delete_cpt_item($post_id) |
|
| 2847 | + { |
|
| 2848 | + } |
|
| 2849 | + |
|
| 2850 | + |
|
| 2851 | + public function restore_cpt_item($post_id) |
|
| 2852 | + { |
|
| 2853 | + } |
|
| 2854 | + |
|
| 2855 | + |
|
| 2856 | + protected function _restore_cpt_item($post_id, $revision_id) |
|
| 2857 | + { |
|
| 2858 | + } |
|
| 2859 | + |
|
| 2860 | + |
|
| 2861 | + public function attendee_editor_metaboxes() |
|
| 2862 | + { |
|
| 2863 | + $this->verify_cpt_object(); |
|
| 2864 | + remove_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], |
|
| 2865 | + 'normal', 'core'); |
|
| 2866 | + remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
| 2867 | + if (post_type_supports('espresso_attendees', 'excerpt')) { |
|
| 2868 | + add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', |
|
| 2869 | + $this->_cpt_routes[$this->_req_action], 'normal'); |
|
| 2870 | + } |
|
| 2871 | + if (post_type_supports('espresso_attendees', 'comments')) { |
|
| 2872 | + add_meta_box('commentsdiv', __('Notes on the Contact', 'event_espresso'), 'post_comment_meta_box', |
|
| 2873 | + $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
| 2874 | + } |
|
| 2875 | + add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), |
|
| 2876 | + array($this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core'); |
|
| 2877 | + add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), |
|
| 2878 | + array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
| 2879 | + add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), |
|
| 2880 | + array($this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high'); |
|
| 2881 | + } |
|
| 2882 | + |
|
| 2883 | + |
|
| 2884 | + /** |
|
| 2885 | + * Metabox for attendee contact info |
|
| 2886 | + * |
|
| 2887 | + * @param WP_Post $post wp post object |
|
| 2888 | + * @return string attendee contact info ( and form ) |
|
| 2889 | + */ |
|
| 2890 | + public function attendee_contact_info($post) |
|
| 2891 | + { |
|
| 2892 | + //get attendee object ( should already have it ) |
|
| 2893 | + $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 2894 | + $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php'; |
|
| 2895 | + EEH_Template::display_template($template, $this->_template_args); |
|
| 2896 | + } |
|
| 2897 | + |
|
| 2898 | + |
|
| 2899 | + /** |
|
| 2900 | + * Metabox for attendee details |
|
| 2901 | + * |
|
| 2902 | + * @param WP_Post $post wp post object |
|
| 2903 | + * @return string attendee address details (and form) |
|
| 2904 | + */ |
|
| 2905 | + public function attendee_address_details($post) |
|
| 2906 | + { |
|
| 2907 | + //get attendee object (should already have it) |
|
| 2908 | + $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 2909 | + $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array( |
|
| 2910 | + 'QST_ID' => 0, |
|
| 2911 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
| 2912 | + 'QST_system' => 'admin-state', |
|
| 2913 | + )), EE_Answer::new_instance(array( |
|
| 2914 | + 'ANS_ID' => 0, |
|
| 2915 | + 'ANS_value' => $this->_cpt_model_obj->state_ID(), |
|
| 2916 | + )), array( |
|
| 2917 | + 'input_id' => 'STA_ID', |
|
| 2918 | + 'input_name' => 'STA_ID', |
|
| 2919 | + 'input_prefix' => '', |
|
| 2920 | + 'append_qstn_id' => false, |
|
| 2921 | + ))); |
|
| 2922 | + $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array( |
|
| 2923 | + 'QST_ID' => 0, |
|
| 2924 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
| 2925 | + 'QST_system' => 'admin-country', |
|
| 2926 | + )), EE_Answer::new_instance(array( |
|
| 2927 | + 'ANS_ID' => 0, |
|
| 2928 | + 'ANS_value' => $this->_cpt_model_obj->country_ID(), |
|
| 2929 | + )), array( |
|
| 2930 | + 'input_id' => 'CNT_ISO', |
|
| 2931 | + 'input_name' => 'CNT_ISO', |
|
| 2932 | + 'input_prefix' => '', |
|
| 2933 | + 'append_qstn_id' => false, |
|
| 2934 | + ))); |
|
| 2935 | + $template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php'; |
|
| 2936 | + EEH_Template::display_template($template, $this->_template_args); |
|
| 2937 | + } |
|
| 2938 | + |
|
| 2939 | + |
|
| 2940 | + /** |
|
| 2941 | + * _attendee_details |
|
| 2942 | + * |
|
| 2943 | + * @access protected |
|
| 2944 | + * @return void |
|
| 2945 | + */ |
|
| 2946 | + public function attendee_registrations_meta_box($post) |
|
| 2947 | + { |
|
| 2948 | + $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
| 2949 | + $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration'); |
|
| 2950 | + $template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php'; |
|
| 2951 | + EEH_Template::display_template($template, $this->_template_args); |
|
| 2952 | + } |
|
| 2953 | + |
|
| 2954 | + |
|
| 2955 | + /** |
|
| 2956 | + * add in the form fields for the attendee edit |
|
| 2957 | + * |
|
| 2958 | + * @param WP_Post $post wp post object |
|
| 2959 | + * @return string html for new form. |
|
| 2960 | + */ |
|
| 2961 | + public function after_title_form_fields($post) |
|
| 2962 | + { |
|
| 2963 | + if ($post->post_type == 'espresso_attendees') { |
|
| 2964 | + $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php'; |
|
| 2965 | + $template_args['attendee'] = $this->_cpt_model_obj; |
|
| 2966 | + EEH_Template::display_template($template, $template_args); |
|
| 2967 | + } |
|
| 2968 | + } |
|
| 2969 | + |
|
| 2970 | + |
|
| 2971 | + /** |
|
| 2972 | + * _trash_or_restore_attendee |
|
| 2973 | + * |
|
| 2974 | + * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
| 2975 | + * @access protected |
|
| 2976 | + * @return void |
|
| 2977 | + */ |
|
| 2978 | + protected function _trash_or_restore_attendees($trash = true) |
|
| 2979 | + { |
|
| 2980 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2981 | + $ATT_MDL = EEM_Attendee::instance(); |
|
| 2982 | + $success = 1; |
|
| 2983 | + //Checkboxes |
|
| 2984 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 2985 | + // if array has more than one element than success message should be plural |
|
| 2986 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
| 2987 | + // cycle thru checkboxes |
|
| 2988 | + while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 2989 | + $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID) |
|
| 2990 | + : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID); |
|
| 2991 | + if ( ! $updated) { |
|
| 2992 | + $success = 0; |
|
| 2993 | + } |
|
| 2994 | + } |
|
| 2995 | + } else { |
|
| 2996 | + // grab single id and delete |
|
| 2997 | + $ATT_ID = absint($this->_req_data['ATT_ID']); |
|
| 2998 | + //get attendee |
|
| 2999 | + $att = $ATT_MDL->get_one_by_ID($ATT_ID); |
|
| 3000 | + $updated = $trash ? $att->set_status('trash') : $att->set_status('publish'); |
|
| 3001 | + $updated = $att->save(); |
|
| 3002 | + if ( ! $updated) { |
|
| 3003 | + $success = 0; |
|
| 3004 | + } |
|
| 3005 | + } |
|
| 3006 | + $what = $success > 1 ? __('Contacts', 'event_espresso') : __('Contact', 'event_espresso'); |
|
| 3007 | + $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
|
| 3008 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list')); |
|
| 3009 | + } |
|
| 3010 | 3010 | |
| 3011 | 3011 | } |
| 3012 | 3012 | |
@@ -569,11 +569,11 @@ discard block |
||
| 569 | 569 | { |
| 570 | 570 | //style |
| 571 | 571 | //wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
| 572 | - wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'), |
|
| 572 | + wp_register_style('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.css', array('ee-admin-css'), |
|
| 573 | 573 | EVENT_ESPRESSO_VERSION); |
| 574 | 574 | wp_enqueue_style('espresso_reg'); |
| 575 | 575 | //script |
| 576 | - wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js', |
|
| 576 | + wp_register_script('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.js', |
|
| 577 | 577 | array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, true); |
| 578 | 578 | wp_enqueue_script('espresso_reg'); |
| 579 | 579 | } |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | public function load_scripts_styles_contact_list() |
| 605 | 605 | { |
| 606 | 606 | wp_deregister_style('espresso_reg'); |
| 607 | - wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'), |
|
| 607 | + wp_register_style('espresso_att', REG_ASSETS_URL.'espresso_attendees_admin.css', array('ee-admin-css'), |
|
| 608 | 608 | EVENT_ESPRESSO_VERSION); |
| 609 | 609 | wp_enqueue_style('espresso_att'); |
| 610 | 610 | } |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | |
| 613 | 613 | public function load_scripts_styles_new_registration() |
| 614 | 614 | { |
| 615 | - wp_register_script('ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'), |
|
| 615 | + wp_register_script('ee-spco-for-admin', REG_ASSETS_URL.'spco_for_admin.js', array('underscore', 'jquery'), |
|
| 616 | 616 | EVENT_ESPRESSO_VERSION, true); |
| 617 | 617 | wp_enqueue_script('ee-spco-for-admin'); |
| 618 | 618 | add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
@@ -722,7 +722,7 @@ discard block |
||
| 722 | 722 | 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
| 723 | 723 | ), |
| 724 | 724 | ); |
| 725 | - $this->_views['trash'] = array( |
|
| 725 | + $this->_views['trash'] = array( |
|
| 726 | 726 | 'slug' => 'trash', |
| 727 | 727 | 'label' => __('Trash', 'event_espresso'), |
| 728 | 728 | 'count' => 0, |
@@ -807,31 +807,31 @@ discard block |
||
| 807 | 807 | } |
| 808 | 808 | $sc_items = array( |
| 809 | 809 | 'approved_status' => array( |
| 810 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 810 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved, |
|
| 811 | 811 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
| 812 | 812 | ), |
| 813 | 813 | 'pending_status' => array( |
| 814 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 814 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment, |
|
| 815 | 815 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
| 816 | 816 | ), |
| 817 | 817 | 'wait_list' => array( |
| 818 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 818 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list, |
|
| 819 | 819 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
| 820 | 820 | ), |
| 821 | 821 | 'incomplete_status' => array( |
| 822 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete, |
|
| 822 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete, |
|
| 823 | 823 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_incomplete, false, 'sentence'), |
| 824 | 824 | ), |
| 825 | 825 | 'not_approved' => array( |
| 826 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 826 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved, |
|
| 827 | 827 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
| 828 | 828 | ), |
| 829 | 829 | 'declined_status' => array( |
| 830 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 830 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined, |
|
| 831 | 831 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
| 832 | 832 | ), |
| 833 | 833 | 'cancelled_status' => array( |
| 834 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 834 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled, |
|
| 835 | 835 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
| 836 | 836 | ), |
| 837 | 837 | ); |
@@ -852,17 +852,17 @@ discard block |
||
| 852 | 852 | if (EE_Registry::instance()->CAP->current_user_can('ee_edit_registrations', |
| 853 | 853 | 'espresso_registrations_new_registration', $EVT_ID) |
| 854 | 854 | ) { |
| 855 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button('new_registration', 'add-registrant', |
|
| 855 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button('new_registration', 'add-registrant', |
|
| 856 | 856 | array('event_id' => $EVT_ID), 'add-new-h2'); |
| 857 | 857 | } |
| 858 | 858 | $event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
| 859 | 859 | if ($event instanceof EE_Event) { |
| 860 | 860 | $this->_template_args['admin_page_header'] = sprintf(__('%s Viewing registrations for the event: %s%s', |
| 861 | 861 | 'event_espresso'), '<h3 style="line-height:1.5em;">', |
| 862 | - '<br /><a href="' . EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 862 | + '<br /><a href="'.EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 863 | 863 | 'action' => 'edit', |
| 864 | 864 | 'post' => $event->ID(), |
| 865 | - ), EVENTS_ADMIN_URL) . '"> ' . $event->get('EVT_name') . ' </a> ', '</h3>'); |
|
| 865 | + ), EVENTS_ADMIN_URL).'"> '.$event->get('EVT_name').' </a> ', '</h3>'); |
|
| 866 | 866 | } |
| 867 | 867 | $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0; |
| 868 | 868 | $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
@@ -871,7 +871,7 @@ discard block |
||
| 871 | 871 | $this->_template_args['admin_page_header'] .= ' <span class="drk-grey-text">'; |
| 872 | 872 | $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>'; |
| 873 | 873 | $this->_template_args['admin_page_header'] .= $datetime->name(); |
| 874 | - $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )'; |
|
| 874 | + $this->_template_args['admin_page_header'] .= ' ( '.$datetime->start_date().' )'; |
|
| 875 | 875 | $this->_template_args['admin_page_header'] .= '</span></h3>'; |
| 876 | 876 | } |
| 877 | 877 | } |
@@ -921,10 +921,10 @@ discard block |
||
| 921 | 921 | $this_month = false, |
| 922 | 922 | $today = false |
| 923 | 923 | ) { |
| 924 | - if( $this_month ) { |
|
| 924 | + if ($this_month) { |
|
| 925 | 925 | $this->_req_data['status'] = 'month'; |
| 926 | 926 | } |
| 927 | - if( $today ) { |
|
| 927 | + if ($today) { |
|
| 928 | 928 | $this->_req_data['status'] = 'today'; |
| 929 | 929 | } |
| 930 | 930 | $query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count); |
@@ -995,7 +995,7 @@ discard block |
||
| 995 | 995 | protected function _add_category_id_to_where_conditions(array $request) |
| 996 | 996 | { |
| 997 | 997 | $where = array(); |
| 998 | - if ( ! empty($request['EVT_CAT']) && (int)$request['EVT_CAT'] !== -1) { |
|
| 998 | + if ( ! empty($request['EVT_CAT']) && (int) $request['EVT_CAT'] !== -1) { |
|
| 999 | 999 | $where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']); |
| 1000 | 1000 | } |
| 1001 | 1001 | return $where; |
@@ -1014,7 +1014,7 @@ discard block |
||
| 1014 | 1014 | if ( ! empty($request['datetime_id'])) { |
| 1015 | 1015 | $where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']); |
| 1016 | 1016 | } |
| 1017 | - if( ! empty($request['DTT_ID'])){ |
|
| 1017 | + if ( ! empty($request['DTT_ID'])) { |
|
| 1018 | 1018 | $where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']); |
| 1019 | 1019 | } |
| 1020 | 1020 | return $where; |
@@ -1030,7 +1030,7 @@ discard block |
||
| 1030 | 1030 | protected function _add_registration_status_to_where_conditions(array $request) |
| 1031 | 1031 | { |
| 1032 | 1032 | $where = array(); |
| 1033 | - $view = EEH_Array::is_set( $request, 'status', '' ); |
|
| 1033 | + $view = EEH_Array::is_set($request, 'status', ''); |
|
| 1034 | 1034 | $registration_status = ! empty($request['_reg_status']) |
| 1035 | 1035 | ? sanitize_text_field($request['_reg_status']) |
| 1036 | 1036 | : ''; |
@@ -1065,7 +1065,7 @@ discard block |
||
| 1065 | 1065 | protected function _add_date_to_where_conditions(array $request) |
| 1066 | 1066 | { |
| 1067 | 1067 | $where = array(); |
| 1068 | - $view = EEH_Array::is_set( $request, 'status', '' ); |
|
| 1068 | + $view = EEH_Array::is_set($request, 'status', ''); |
|
| 1069 | 1069 | $month_range = ! empty($request['month_range']) |
| 1070 | 1070 | ? sanitize_text_field($request['month_range']) |
| 1071 | 1071 | : ''; |
@@ -1079,12 +1079,12 @@ discard block |
||
| 1079 | 1079 | array( |
| 1080 | 1080 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1081 | 1081 | 'REG_date', |
| 1082 | - $now . ' 00:00:00', |
|
| 1082 | + $now.' 00:00:00', |
|
| 1083 | 1083 | 'Y-m-d H:i:s' |
| 1084 | 1084 | ), |
| 1085 | 1085 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1086 | 1086 | 'REG_date', |
| 1087 | - $now . ' 23:59:59', |
|
| 1087 | + $now.' 23:59:59', |
|
| 1088 | 1088 | 'Y-m-d H:i:s' |
| 1089 | 1089 | ), |
| 1090 | 1090 | ), |
@@ -1097,12 +1097,12 @@ discard block |
||
| 1097 | 1097 | array( |
| 1098 | 1098 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1099 | 1099 | 'REG_date', |
| 1100 | - $current_year_and_month . '-01 00:00:00', |
|
| 1100 | + $current_year_and_month.'-01 00:00:00', |
|
| 1101 | 1101 | 'Y-m-d H:i:s' |
| 1102 | 1102 | ), |
| 1103 | 1103 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1104 | 1104 | 'REG_date', |
| 1105 | - $current_year_and_month . '-' . $days_this_month . ' 23:59:59', |
|
| 1105 | + $current_year_and_month.'-'.$days_this_month.' 23:59:59', |
|
| 1106 | 1106 | 'Y-m-d H:i:s' |
| 1107 | 1107 | ), |
| 1108 | 1108 | ), |
@@ -1117,18 +1117,18 @@ discard block |
||
| 1117 | 1117 | : ''; |
| 1118 | 1118 | //if there is not a month or year then we can't go further |
| 1119 | 1119 | if ($month_requested && $year_requested) { |
| 1120 | - $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01')); |
|
| 1120 | + $days_in_month = date('t', strtotime($year_requested.'-'.$month_requested.'-'.'01')); |
|
| 1121 | 1121 | $where['REG_date'] = array( |
| 1122 | 1122 | 'BETWEEN', |
| 1123 | 1123 | array( |
| 1124 | 1124 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1125 | 1125 | 'REG_date', |
| 1126 | - $year_requested . '-' . $month_requested . '-01 00:00:00', |
|
| 1126 | + $year_requested.'-'.$month_requested.'-01 00:00:00', |
|
| 1127 | 1127 | 'Y-m-d H:i:s' |
| 1128 | 1128 | ), |
| 1129 | 1129 | EEM_Registration::instance()->convert_datetime_for_query( |
| 1130 | 1130 | 'REG_date', |
| 1131 | - $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59', |
|
| 1131 | + $year_requested.'-'.$month_requested.'-'.$days_in_month.' 23:59:59', |
|
| 1132 | 1132 | 'Y-m-d H:i:s' |
| 1133 | 1133 | ), |
| 1134 | 1134 | ), |
@@ -1149,7 +1149,7 @@ discard block |
||
| 1149 | 1149 | { |
| 1150 | 1150 | $where = array(); |
| 1151 | 1151 | if ( ! empty($request['s'])) { |
| 1152 | - $search_string = '%' . sanitize_text_field($request['s']) . '%'; |
|
| 1152 | + $search_string = '%'.sanitize_text_field($request['s']).'%'; |
|
| 1153 | 1153 | $where['OR'] = array( |
| 1154 | 1154 | 'Event.EVT_name' => array('LIKE', $search_string), |
| 1155 | 1155 | 'Event.EVT_desc' => array('LIKE', $search_string), |
@@ -1251,7 +1251,7 @@ discard block |
||
| 1251 | 1251 | : $per_page; |
| 1252 | 1252 | |
| 1253 | 1253 | //-1 means return all results so get out if that's set. |
| 1254 | - if ((int)$per_page === -1) { |
|
| 1254 | + if ((int) $per_page === -1) { |
|
| 1255 | 1255 | return array(); |
| 1256 | 1256 | } |
| 1257 | 1257 | $per_page = absint($per_page); |
@@ -1297,12 +1297,12 @@ discard block |
||
| 1297 | 1297 | 'action' => 'default', |
| 1298 | 1298 | 'event_id' => $event_id, |
| 1299 | 1299 | ), REG_ADMIN_URL); |
| 1300 | - $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1300 | + $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1301 | 1301 | 'action' => 'default', |
| 1302 | 1302 | 'EVT_ID' => $event_id, |
| 1303 | 1303 | 'page' => 'espresso_transactions', |
| 1304 | 1304 | ), admin_url('admin.php')); |
| 1305 | - $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1305 | + $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1306 | 1306 | 'page' => 'espresso_events', |
| 1307 | 1307 | 'action' => 'edit', |
| 1308 | 1308 | 'post' => $event_id, |
@@ -1321,7 +1321,7 @@ discard block |
||
| 1321 | 1321 | '_REG_ID' => $previous_reg['REG_ID'], |
| 1322 | 1322 | ), REG_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : ''; |
| 1323 | 1323 | // grab header |
| 1324 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php'; |
|
| 1324 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php'; |
|
| 1325 | 1325 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
| 1326 | 1326 | $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, |
| 1327 | 1327 | $this->_template_args, true); |
@@ -1395,8 +1395,8 @@ discard block |
||
| 1395 | 1395 | 'default' => $this->_registration->ID(), |
| 1396 | 1396 | )), |
| 1397 | 1397 | 'current_status' => new EE_Form_Section_HTML(EEH_HTML::tr(EEH_HTML::th(EEH_HTML::label(EEH_HTML::strong(__('Current Registration Status', |
| 1398 | - 'event_espresso')))) . EEH_HTML::td(EEH_HTML::strong($this->_registration->pretty_status(), |
|
| 1399 | - '', 'status-' . $this->_registration->status_ID(), |
|
| 1398 | + 'event_espresso')))).EEH_HTML::td(EEH_HTML::strong($this->_registration->pretty_status(), |
|
| 1399 | + '', 'status-'.$this->_registration->status_ID(), |
|
| 1400 | 1400 | 'line-height: 1em; font-size: 1.5em; font-weight: bold;')))), |
| 1401 | 1401 | 'reg_status' => new EE_Select_Input($this->_get_reg_statuses(), array( |
| 1402 | 1402 | 'html_label_text' => __('Change Registration Status to', 'event_espresso'), |
@@ -1452,9 +1452,9 @@ discard block |
||
| 1452 | 1452 | { |
| 1453 | 1453 | if (isset($this->_req_data['reg_status_change_form'])) { |
| 1454 | 1454 | $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID']) |
| 1455 | - ? (array)$this->_req_data['reg_status_change_form']['REG_ID'] : array(); |
|
| 1455 | + ? (array) $this->_req_data['reg_status_change_form']['REG_ID'] : array(); |
|
| 1456 | 1456 | } else { |
| 1457 | - $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array)$this->_req_data['_REG_ID'] : array(); |
|
| 1457 | + $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array) $this->_req_data['_REG_ID'] : array(); |
|
| 1458 | 1458 | } |
| 1459 | 1459 | $success = $this->_set_registration_status($REG_IDs, $status); |
| 1460 | 1460 | //notify? |
@@ -1482,7 +1482,7 @@ discard block |
||
| 1482 | 1482 | { |
| 1483 | 1483 | $success = false; |
| 1484 | 1484 | // typecast $REG_IDs |
| 1485 | - $REG_IDs = (array)$REG_IDs; |
|
| 1485 | + $REG_IDs = (array) $REG_IDs; |
|
| 1486 | 1486 | if ( ! empty($REG_IDs)) { |
| 1487 | 1487 | $success = true; |
| 1488 | 1488 | // set default status if none is passed |
@@ -1775,7 +1775,7 @@ discard block |
||
| 1775 | 1775 | ), REG_ADMIN_URL); |
| 1776 | 1776 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
| 1777 | 1777 | $this->_template_args['event_id'] = $this->_registration->event_ID(); |
| 1778 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
| 1778 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
| 1779 | 1779 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
| 1780 | 1780 | } |
| 1781 | 1781 | |
@@ -1797,7 +1797,7 @@ discard block |
||
| 1797 | 1797 | $this->_template_args['att_questions'] = count($form->subforms()) > 0 ? $form->get_html_and_js() : ''; |
| 1798 | 1798 | $this->_template_args['reg_questions_form_action'] = 'edit_registration'; |
| 1799 | 1799 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
| 1800 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 1800 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 1801 | 1801 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
| 1802 | 1802 | } |
| 1803 | 1803 | } |
@@ -1813,7 +1813,7 @@ discard block |
||
| 1813 | 1813 | */ |
| 1814 | 1814 | public function form_before_question_group($output) |
| 1815 | 1815 | { |
| 1816 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1816 | + EE_Error::doing_it_wrong(__CLASS__.'::'.__FUNCTION__, |
|
| 1817 | 1817 | __('This method would have been protected but was used on a filter callback' |
| 1818 | 1818 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
| 1819 | 1819 | '4.8.32.rc.000'); |
@@ -1834,7 +1834,7 @@ discard block |
||
| 1834 | 1834 | */ |
| 1835 | 1835 | public function form_after_question_group($output) |
| 1836 | 1836 | { |
| 1837 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1837 | + EE_Error::doing_it_wrong(__CLASS__.'::'.__FUNCTION__, |
|
| 1838 | 1838 | __('This method would have been protected but was used on a filter callback' |
| 1839 | 1839 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
| 1840 | 1840 | '4.8.32.rc.000'); |
@@ -1868,14 +1868,14 @@ discard block |
||
| 1868 | 1868 | */ |
| 1869 | 1869 | public function form_form_field_label_wrap($label) |
| 1870 | 1870 | { |
| 1871 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1871 | + EE_Error::doing_it_wrong(__CLASS__.'::'.__FUNCTION__, |
|
| 1872 | 1872 | __('This method would have been protected but was used on a filter callback' |
| 1873 | 1873 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
| 1874 | 1874 | '4.8.32.rc.000'); |
| 1875 | 1875 | return ' |
| 1876 | 1876 | <tr> |
| 1877 | 1877 | <th> |
| 1878 | - ' . $label . ' |
|
| 1878 | + ' . $label.' |
|
| 1879 | 1879 | </th>'; |
| 1880 | 1880 | } |
| 1881 | 1881 | |
@@ -1890,13 +1890,13 @@ discard block |
||
| 1890 | 1890 | */ |
| 1891 | 1891 | public function form_form_field_input__wrap($input) |
| 1892 | 1892 | { |
| 1893 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
| 1893 | + EE_Error::doing_it_wrong(__CLASS__.'::'.__FUNCTION__, |
|
| 1894 | 1894 | __('This method would have been protected but was used on a filter callback' |
| 1895 | 1895 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
| 1896 | 1896 | '4.8.32.rc.000'); |
| 1897 | 1897 | return ' |
| 1898 | 1898 | <td class="reg-admin-attendee-questions-input-td disabled-input"> |
| 1899 | - ' . $input . ' |
|
| 1899 | + ' . $input.' |
|
| 1900 | 1900 | </td> |
| 1901 | 1901 | </tr>'; |
| 1902 | 1902 | } |
@@ -1936,7 +1936,7 @@ discard block |
||
| 1936 | 1936 | protected function _get_reg_custom_questions_form($REG_ID) |
| 1937 | 1937 | { |
| 1938 | 1938 | if ( ! $this->_reg_custom_questions_form) { |
| 1939 | - require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php'); |
|
| 1939 | + require_once(REG_ADMIN.'form_sections'.DS.'EE_Registration_Custom_Questions_Form.form.php'); |
|
| 1940 | 1940 | $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(EEM_Registration::instance() |
| 1941 | 1941 | ->get_one_by_ID($REG_ID)); |
| 1942 | 1942 | $this->_reg_custom_questions_form->_construct_finalize(null, null); |
@@ -1964,7 +1964,7 @@ discard block |
||
| 1964 | 1964 | if ($form->is_valid()) { |
| 1965 | 1965 | foreach ($form->subforms() as $question_group_id => $question_group_form) { |
| 1966 | 1966 | foreach ($question_group_form->inputs() as $question_id => $input) { |
| 1967 | - $where_conditions = array( |
|
| 1967 | + $where_conditions = array( |
|
| 1968 | 1968 | 'QST_ID' => $question_id, |
| 1969 | 1969 | 'REG_ID' => $REG_ID, |
| 1970 | 1970 | ); |
@@ -2000,7 +2000,7 @@ discard block |
||
| 2000 | 2000 | $REG = EEM_Registration::instance(); |
| 2001 | 2001 | //get all other registrations on this transaction, and cache |
| 2002 | 2002 | //the attendees for them so we don't have to run another query using force_join |
| 2003 | - $registrations = $REG->get_all(array( |
|
| 2003 | + $registrations = $REG->get_all(array( |
|
| 2004 | 2004 | array( |
| 2005 | 2005 | 'TXN_ID' => $this->_registration->transaction_ID(), |
| 2006 | 2006 | 'REG_ID' => array('!=', $this->_registration->ID()), |
@@ -2020,29 +2020,29 @@ discard block |
||
| 2020 | 2020 | $att_nmbr = 1; |
| 2021 | 2021 | foreach ($registrations as $registration) { |
| 2022 | 2022 | /* @var $registration EE_Registration */ |
| 2023 | - $attendee = $registration->attendee() |
|
| 2023 | + $attendee = $registration->attendee() |
|
| 2024 | 2024 | ? $registration->attendee() |
| 2025 | 2025 | : EEM_Attendee::instance() |
| 2026 | 2026 | ->create_default_object(); |
| 2027 | 2027 | $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID(); |
| 2028 | - $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : ''; |
|
| 2029 | - $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : ''; |
|
| 2030 | - $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : ''; |
|
| 2031 | - $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : ''; |
|
| 2028 | + $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname(); //( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : ''; |
|
| 2029 | + $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname(); //( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : ''; |
|
| 2030 | + $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email(); //( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : ''; |
|
| 2031 | + $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price(); //( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : ''; |
|
| 2032 | 2032 | $this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ', |
| 2033 | 2033 | $attendee->full_address_as_array()); |
| 2034 | 2034 | $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array( |
| 2035 | 2035 | 'action' => 'edit_attendee', |
| 2036 | 2036 | 'post' => $attendee->ID(), |
| 2037 | 2037 | ), REG_ADMIN_URL); |
| 2038 | - $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
| 2038 | + $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
| 2039 | 2039 | $att_nmbr++; |
| 2040 | 2040 | } |
| 2041 | 2041 | //EEH_Debug_Tools::printr( $attendees, '$attendees <br /><span style="font-size:10px;font-weight:normal;">( file: '. __FILE__ . ' - line no: ' . __LINE__ . ' )</span>', 'auto' ); |
| 2042 | 2042 | $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
| 2043 | 2043 | // $this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees' ), REG_ADMIN_URL ); |
| 2044 | 2044 | } |
| 2045 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
|
| 2045 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php'; |
|
| 2046 | 2046 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
| 2047 | 2047 | } |
| 2048 | 2048 | |
@@ -2071,26 +2071,26 @@ discard block |
||
| 2071 | 2071 | $primary_registration = null; |
| 2072 | 2072 | } |
| 2073 | 2073 | $this->_template_args['ATT_ID'] = $attendee->ID(); |
| 2074 | - $this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname; |
|
| 2075 | - $this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname; |
|
| 2076 | - $this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email; |
|
| 2074 | + $this->_template_args['fname'] = $attendee->fname(); //$this->_registration->ATT_fname; |
|
| 2075 | + $this->_template_args['lname'] = $attendee->lname(); //$this->_registration->ATT_lname; |
|
| 2076 | + $this->_template_args['email'] = $attendee->email(); //$this->_registration->ATT_email; |
|
| 2077 | 2077 | $this->_template_args['phone'] = $attendee->phone(); |
| 2078 | 2078 | $this->_template_args['formatted_address'] = EEH_Address::format($attendee); |
| 2079 | 2079 | //edit link |
| 2080 | - $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2080 | + $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 2081 | 2081 | 'action' => 'edit_attendee', |
| 2082 | 2082 | 'post' => $attendee->ID(), |
| 2083 | 2083 | ), REG_ADMIN_URL); |
| 2084 | 2084 | $this->_template_args['att_edit_label'] = __('View/Edit Contact', 'event_espresso'); |
| 2085 | 2085 | //create link |
| 2086 | - $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration |
|
| 2086 | + $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration |
|
| 2087 | 2087 | ? EE_Admin_Page::add_query_args_and_nonce(array( |
| 2088 | 2088 | 'action' => 'duplicate_attendee', |
| 2089 | 2089 | '_REG_ID' => $this->_registration->ID(), |
| 2090 | 2090 | ), REG_ADMIN_URL) : ''; |
| 2091 | 2091 | $this->_template_args['create_label'] = __('Create Contact', 'event_espresso'); |
| 2092 | 2092 | $this->_template_args['att_check'] = $att_check; |
| 2093 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
|
| 2093 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php'; |
|
| 2094 | 2094 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
| 2095 | 2095 | } |
| 2096 | 2096 | |
@@ -2304,7 +2304,7 @@ discard block |
||
| 2304 | 2304 | 'action' => 'edit', |
| 2305 | 2305 | 'post' => $this->_reg_event->ID(), |
| 2306 | 2306 | ), EVENTS_ADMIN_URL); |
| 2307 | - $edit_event_lnk = '<a href="' |
|
| 2307 | + $edit_event_lnk = '<a href="' |
|
| 2308 | 2308 | . $edit_event_url |
| 2309 | 2309 | . '" title="' |
| 2310 | 2310 | . esc_attr__('Edit ', 'event_espresso') |
@@ -2321,7 +2321,7 @@ discard block |
||
| 2321 | 2321 | $this->_return_json(); |
| 2322 | 2322 | } |
| 2323 | 2323 | // grab header |
| 2324 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php'; |
|
| 2324 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php'; |
|
| 2325 | 2325 | $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
| 2326 | 2326 | $this->_template_args, true); |
| 2327 | 2327 | //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
@@ -2343,7 +2343,7 @@ discard block |
||
| 2343 | 2343 | 'event_espresso'), '<br />', '<h3 class="important-notice">', '</h3>', '<div class="float-right">', |
| 2344 | 2344 | '<span id="redirect_timer" class="important-notice">30</span>', '</div>', '<b>', '</b>'); |
| 2345 | 2345 | return ' |
| 2346 | - <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div> |
|
| 2346 | + <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg.'</p></div> |
|
| 2347 | 2347 | <script > |
| 2348 | 2348 | // WHOAH !!! it appears that someone is using the back button from the Transaction admin page |
| 2349 | 2349 | // after just adding a new registration... we gotta try to put a stop to that !!! |
@@ -2568,7 +2568,7 @@ discard block |
||
| 2568 | 2568 | public function get_attendees($per_page, $count = false, $trash = false) |
| 2569 | 2569 | { |
| 2570 | 2570 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
| 2571 | - require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php'); |
|
| 2571 | + require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php'); |
|
| 2572 | 2572 | $ATT_MDL = EEM_Attendee::instance(); |
| 2573 | 2573 | $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
| 2574 | 2574 | switch ($this->_req_data['orderby']) { |
@@ -2602,7 +2602,7 @@ discard block |
||
| 2602 | 2602 | ? $this->_req_data['perpage'] : $per_page; |
| 2603 | 2603 | $_where = array(); |
| 2604 | 2604 | if ( ! empty($this->_req_data['s'])) { |
| 2605 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 2605 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
| 2606 | 2606 | $_where['OR'] = array( |
| 2607 | 2607 | 'Registration.Event.EVT_name' => array('LIKE', $sstr), |
| 2608 | 2608 | 'Registration.Event.EVT_desc' => array('LIKE', $sstr), |
@@ -2680,7 +2680,7 @@ discard block |
||
| 2680 | 2680 | * the query parameters from the request |
| 2681 | 2681 | * @return void ends the request with a redirect or download |
| 2682 | 2682 | */ |
| 2683 | - public function _registrations_report_base( $method_name_for_getting_query_params ) |
|
| 2683 | + public function _registrations_report_base($method_name_for_getting_query_params) |
|
| 2684 | 2684 | { |
| 2685 | 2685 | if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
| 2686 | 2686 | wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array( |
@@ -2690,7 +2690,7 @@ discard block |
||
| 2690 | 2690 | 'filters' => urlencode( |
| 2691 | 2691 | serialize( |
| 2692 | 2692 | call_user_func( |
| 2693 | - array( $this, $method_name_for_getting_query_params ), |
|
| 2693 | + array($this, $method_name_for_getting_query_params), |
|
| 2694 | 2694 | EEH_Array::is_set( |
| 2695 | 2695 | $this->_req_data, |
| 2696 | 2696 | 'filters', |
@@ -2710,8 +2710,8 @@ discard block |
||
| 2710 | 2710 | 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
| 2711 | 2711 | ); |
| 2712 | 2712 | $this->_req_data = array_merge($this->_req_data, $new_request_args); |
| 2713 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 2714 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 2713 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
| 2714 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
| 2715 | 2715 | $EE_Export = EE_Export::instance($this->_req_data); |
| 2716 | 2716 | $EE_Export->export(); |
| 2717 | 2717 | } |
@@ -2726,14 +2726,14 @@ discard block |
||
| 2726 | 2726 | */ |
| 2727 | 2727 | public function _registrations_report() |
| 2728 | 2728 | { |
| 2729 | - $this->_registrations_report_base( '_get_registration_query_parameters' ); |
|
| 2729 | + $this->_registrations_report_base('_get_registration_query_parameters'); |
|
| 2730 | 2730 | } |
| 2731 | 2731 | |
| 2732 | 2732 | |
| 2733 | 2733 | public function _contact_list_export() |
| 2734 | 2734 | { |
| 2735 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 2736 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 2735 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
| 2736 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
| 2737 | 2737 | $EE_Export = EE_Export::instance($this->_req_data); |
| 2738 | 2738 | $EE_Export->export_attendees(); |
| 2739 | 2739 | } |
@@ -2750,8 +2750,8 @@ discard block |
||
| 2750 | 2750 | 'return_url' => urlencode($this->_req_data['return_url']), |
| 2751 | 2751 | ))); |
| 2752 | 2752 | } else { |
| 2753 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 2754 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 2753 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
| 2754 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
| 2755 | 2755 | $EE_Export = EE_Export::instance($this->_req_data); |
| 2756 | 2756 | $EE_Export->report_attendees(); |
| 2757 | 2757 | } |
@@ -2808,7 +2808,7 @@ discard block |
||
| 2808 | 2808 | $updated_fields = array( |
| 2809 | 2809 | 'ATT_fname' => $this->_req_data['ATT_fname'], |
| 2810 | 2810 | 'ATT_lname' => $this->_req_data['ATT_lname'], |
| 2811 | - 'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], |
|
| 2811 | + 'ATT_full_name' => $this->_req_data['ATT_fname'].' '.$this->_req_data['ATT_lname'], |
|
| 2812 | 2812 | 'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', |
| 2813 | 2813 | 'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', |
| 2814 | 2814 | 'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '', |
@@ -2891,7 +2891,7 @@ discard block |
||
| 2891 | 2891 | { |
| 2892 | 2892 | //get attendee object ( should already have it ) |
| 2893 | 2893 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
| 2894 | - $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php'; |
|
| 2894 | + $template = REG_TEMPLATE_PATH.'attendee_contact_info_metabox_content.template.php'; |
|
| 2895 | 2895 | EEH_Template::display_template($template, $this->_template_args); |
| 2896 | 2896 | } |
| 2897 | 2897 | |
@@ -2932,7 +2932,7 @@ discard block |
||
| 2932 | 2932 | 'input_prefix' => '', |
| 2933 | 2933 | 'append_qstn_id' => false, |
| 2934 | 2934 | ))); |
| 2935 | - $template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php'; |
|
| 2935 | + $template = REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php'; |
|
| 2936 | 2936 | EEH_Template::display_template($template, $this->_template_args); |
| 2937 | 2937 | } |
| 2938 | 2938 | |
@@ -2947,7 +2947,7 @@ discard block |
||
| 2947 | 2947 | { |
| 2948 | 2948 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
| 2949 | 2949 | $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration'); |
| 2950 | - $template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php'; |
|
| 2950 | + $template = REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php'; |
|
| 2951 | 2951 | EEH_Template::display_template($template, $this->_template_args); |
| 2952 | 2952 | } |
| 2953 | 2953 | |
@@ -2961,7 +2961,7 @@ discard block |
||
| 2961 | 2961 | public function after_title_form_fields($post) |
| 2962 | 2962 | { |
| 2963 | 2963 | if ($post->post_type == 'espresso_attendees') { |
| 2964 | - $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php'; |
|
| 2964 | + $template = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php'; |
|
| 2965 | 2965 | $template_args['attendee'] = $this->_cpt_model_obj; |
| 2966 | 2966 | EEH_Template::display_template($template, $template_args); |
| 2967 | 2967 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | |
@@ -14,1368 +14,1368 @@ discard block |
||
| 14 | 14 | class EE_Event extends EE_CPT_Base implements EEI_Line_Item_Object, EEI_Admin_Links, EEI_Has_Icon, EEI_Event |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * cached value for the the logical active status for the event |
|
| 19 | - * |
|
| 20 | - * @see get_active_status() |
|
| 21 | - * @var string |
|
| 22 | - */ |
|
| 23 | - protected $_active_status = ''; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * This is just used for caching the Primary Datetime for the Event on initial retrieval |
|
| 27 | - * |
|
| 28 | - * @var EE_Datetime |
|
| 29 | - */ |
|
| 30 | - protected $_Primary_Datetime; |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @param array $props_n_values incoming values |
|
| 36 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 37 | - * used.) |
|
| 38 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 39 | - * date_format and the second value is the time format |
|
| 40 | - * @return EE_Event |
|
| 41 | - */ |
|
| 42 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
| 43 | - { |
|
| 44 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 45 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * @param array $props_n_values incoming values from the database |
|
| 52 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 53 | - * the website will be used. |
|
| 54 | - * @return EE_Event |
|
| 55 | - */ |
|
| 56 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 57 | - { |
|
| 58 | - return new self($props_n_values, true, $timezone); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Overrides parent set() method so that all calls to set( 'status', $status ) can be routed to internal methods |
|
| 65 | - * |
|
| 66 | - * @param string $field_name |
|
| 67 | - * @param mixed $field_value |
|
| 68 | - * @param bool $use_default |
|
| 69 | - */ |
|
| 70 | - public function set($field_name, $field_value, $use_default = false) |
|
| 71 | - { |
|
| 72 | - switch ($field_name) { |
|
| 73 | - case 'status' : |
|
| 74 | - $this->set_status($field_value, $use_default); |
|
| 75 | - break; |
|
| 76 | - default : |
|
| 77 | - parent::set($field_name, $field_value, $use_default); |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * set_status |
|
| 85 | - * Checks if event status is being changed to SOLD OUT |
|
| 86 | - * and updates event meta data with previous event status |
|
| 87 | - * so that we can revert things if/when the event is no longer sold out |
|
| 88 | - * |
|
| 89 | - * @access public |
|
| 90 | - * @param string $new_status |
|
| 91 | - * @param bool $use_default |
|
| 92 | - * @return bool|void |
|
| 93 | - * @throws \EE_Error |
|
| 94 | - */ |
|
| 95 | - public function set_status($new_status = null, $use_default = false) |
|
| 96 | - { |
|
| 97 | - // get current Event status |
|
| 98 | - $old_status = $this->status(); |
|
| 99 | - // if status has changed |
|
| 100 | - if ($old_status != $new_status) { |
|
| 101 | - // TO sold_out |
|
| 102 | - if ($new_status == EEM_Event::sold_out) { |
|
| 103 | - // save the previous event status so that we can revert if the event is no longer sold out |
|
| 104 | - $this->add_post_meta('_previous_event_status', $old_status); |
|
| 105 | - do_action('AHEE__EE_Event__set_status__to_sold_out', $this, $old_status, $new_status); |
|
| 106 | - // OR FROM sold_out |
|
| 107 | - } else if ($old_status == EEM_Event::sold_out) { |
|
| 108 | - $this->delete_post_meta('_previous_event_status'); |
|
| 109 | - do_action('AHEE__EE_Event__set_status__from_sold_out', $this, $old_status, $new_status); |
|
| 110 | - } |
|
| 111 | - // update status |
|
| 112 | - parent::set('status', $new_status, $use_default); |
|
| 113 | - do_action('AHEE__EE_Event__set_status__after_update', $this); |
|
| 114 | - return true; |
|
| 115 | - } else { |
|
| 116 | - // even though the old value matches the new value, it's still good to |
|
| 117 | - // allow the parent set method to have a say |
|
| 118 | - parent::set('status', $new_status, $use_default); |
|
| 119 | - return true; |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * Gets all the datetimes for this event |
|
| 127 | - * |
|
| 128 | - * @param array $query_params like EEM_Base::get_all |
|
| 129 | - * @return EE_Datetime[] |
|
| 130 | - */ |
|
| 131 | - public function datetimes($query_params = array()) |
|
| 132 | - { |
|
| 133 | - return $this->get_many_related('Datetime', $query_params); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * Gets all the datetimes for this event, ordered by DTT_EVT_start in ascending order |
|
| 140 | - * |
|
| 141 | - * @return EE_Datetime[] |
|
| 142 | - */ |
|
| 143 | - public function datetimes_in_chronological_order() |
|
| 144 | - { |
|
| 145 | - return $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC'))); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * Gets all the datetimes for this event, ordered by the DTT_order on the datetime. |
|
| 152 | - * @darren, we should probably UNSET timezone on the EEM_Datetime model |
|
| 153 | - * after running our query, so that this timezone isn't set for EVERY query |
|
| 154 | - * on EEM_Datetime for the rest of the request, no? |
|
| 155 | - * |
|
| 156 | - * @param boolean $show_expired whether or not to include expired events |
|
| 157 | - * @param boolean $show_deleted whether or not to include deleted events |
|
| 158 | - * @param null $limit |
|
| 159 | - * @return \EE_Datetime[] |
|
| 160 | - * @throws \EE_Error |
|
| 161 | - */ |
|
| 162 | - public function datetimes_ordered($show_expired = true, $show_deleted = false, $limit = null) |
|
| 163 | - { |
|
| 164 | - return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_event_ordered_by_DTT_order( |
|
| 165 | - $this->ID(), |
|
| 166 | - $show_expired, |
|
| 167 | - $show_deleted, |
|
| 168 | - $limit |
|
| 169 | - ); |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * Returns one related datetime. Mostly only used by some legacy code. |
|
| 176 | - * |
|
| 177 | - * @return EE_Datetime |
|
| 178 | - */ |
|
| 179 | - public function first_datetime() |
|
| 180 | - { |
|
| 181 | - return $this->get_first_related('Datetime'); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * Returns the 'primary' datetime for the event |
|
| 188 | - * |
|
| 189 | - * @param bool $try_to_exclude_expired |
|
| 190 | - * @param bool $try_to_exclude_deleted |
|
| 191 | - * @return EE_Datetime |
|
| 192 | - */ |
|
| 193 | - public function primary_datetime($try_to_exclude_expired = true, $try_to_exclude_deleted = true) |
|
| 194 | - { |
|
| 195 | - if ( ! empty ($this->_Primary_Datetime)) { |
|
| 196 | - return $this->_Primary_Datetime; |
|
| 197 | - } |
|
| 198 | - $this->_Primary_Datetime = EEM_Datetime::instance($this->_timezone) |
|
| 199 | - ->get_primary_datetime_for_event($this->ID(), $try_to_exclude_expired, |
|
| 200 | - $try_to_exclude_deleted); |
|
| 201 | - return $this->_Primary_Datetime; |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * Gets all the tickets available for purchase of this event |
|
| 208 | - * |
|
| 209 | - * @param array $query_params like EEM_Base::get_all |
|
| 210 | - * @return EE_Ticket[] |
|
| 211 | - */ |
|
| 212 | - public function tickets($query_params = array()) |
|
| 213 | - { |
|
| 214 | - //first get all datetimes |
|
| 215 | - $datetimes = $this->datetimes_ordered(); |
|
| 216 | - if ( ! $datetimes) { |
|
| 217 | - return array(); |
|
| 218 | - } |
|
| 219 | - $datetime_ids = array(); |
|
| 220 | - foreach ($datetimes as $datetime) { |
|
| 221 | - $datetime_ids[] = $datetime->ID(); |
|
| 222 | - } |
|
| 223 | - $where_params = array('Datetime.DTT_ID' => array('IN', $datetime_ids)); |
|
| 224 | - //if incoming $query_params has where conditions let's merge but not override existing. |
|
| 225 | - if (is_array($query_params) && isset($query_params[0])) { |
|
| 226 | - $where_params = array_merge($query_params[0], $where_params); |
|
| 227 | - unset($query_params[0]); |
|
| 228 | - } |
|
| 229 | - //now add $where_params to $query_params |
|
| 230 | - $query_params[0] = $where_params; |
|
| 231 | - return EEM_Ticket::instance()->get_all($query_params); |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - |
|
| 235 | - |
|
| 236 | - /** |
|
| 237 | - * @return bool |
|
| 238 | - */ |
|
| 239 | - public function additional_limit() |
|
| 240 | - { |
|
| 241 | - return $this->get('EVT_additional_limit'); |
|
| 242 | - } |
|
| 243 | - |
|
| 244 | - |
|
| 245 | - |
|
| 246 | - /** |
|
| 247 | - * @return bool |
|
| 248 | - */ |
|
| 249 | - public function allow_overflow() |
|
| 250 | - { |
|
| 251 | - return $this->get('EVT_allow_overflow'); |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - |
|
| 255 | - |
|
| 256 | - /** |
|
| 257 | - * @return bool |
|
| 258 | - */ |
|
| 259 | - public function created() |
|
| 260 | - { |
|
| 261 | - return $this->get('EVT_created'); |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * @return bool |
|
| 268 | - */ |
|
| 269 | - public function description() |
|
| 270 | - { |
|
| 271 | - return $this->get('EVT_desc'); |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - |
|
| 275 | - |
|
| 276 | - /** |
|
| 277 | - * Runs do_shortcode and wpautop on the description |
|
| 278 | - * |
|
| 279 | - * @return string of html |
|
| 280 | - */ |
|
| 281 | - public function description_filtered() |
|
| 282 | - { |
|
| 283 | - return $this->get_pretty('EVT_desc'); |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - |
|
| 287 | - |
|
| 288 | - /** |
|
| 289 | - * @return bool |
|
| 290 | - */ |
|
| 291 | - public function display_description() |
|
| 292 | - { |
|
| 293 | - return $this->get('EVT_display_desc'); |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - |
|
| 297 | - |
|
| 298 | - /** |
|
| 299 | - * @return bool |
|
| 300 | - */ |
|
| 301 | - public function display_ticket_selector() |
|
| 302 | - { |
|
| 303 | - return (bool)$this->get('EVT_display_ticket_selector'); |
|
| 304 | - } |
|
| 305 | - |
|
| 17 | + /** |
|
| 18 | + * cached value for the the logical active status for the event |
|
| 19 | + * |
|
| 20 | + * @see get_active_status() |
|
| 21 | + * @var string |
|
| 22 | + */ |
|
| 23 | + protected $_active_status = ''; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * This is just used for caching the Primary Datetime for the Event on initial retrieval |
|
| 27 | + * |
|
| 28 | + * @var EE_Datetime |
|
| 29 | + */ |
|
| 30 | + protected $_Primary_Datetime; |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @param array $props_n_values incoming values |
|
| 36 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 37 | + * used.) |
|
| 38 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 39 | + * date_format and the second value is the time format |
|
| 40 | + * @return EE_Event |
|
| 41 | + */ |
|
| 42 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
| 43 | + { |
|
| 44 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 45 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * @param array $props_n_values incoming values from the database |
|
| 52 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 53 | + * the website will be used. |
|
| 54 | + * @return EE_Event |
|
| 55 | + */ |
|
| 56 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 57 | + { |
|
| 58 | + return new self($props_n_values, true, $timezone); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Overrides parent set() method so that all calls to set( 'status', $status ) can be routed to internal methods |
|
| 65 | + * |
|
| 66 | + * @param string $field_name |
|
| 67 | + * @param mixed $field_value |
|
| 68 | + * @param bool $use_default |
|
| 69 | + */ |
|
| 70 | + public function set($field_name, $field_value, $use_default = false) |
|
| 71 | + { |
|
| 72 | + switch ($field_name) { |
|
| 73 | + case 'status' : |
|
| 74 | + $this->set_status($field_value, $use_default); |
|
| 75 | + break; |
|
| 76 | + default : |
|
| 77 | + parent::set($field_name, $field_value, $use_default); |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * set_status |
|
| 85 | + * Checks if event status is being changed to SOLD OUT |
|
| 86 | + * and updates event meta data with previous event status |
|
| 87 | + * so that we can revert things if/when the event is no longer sold out |
|
| 88 | + * |
|
| 89 | + * @access public |
|
| 90 | + * @param string $new_status |
|
| 91 | + * @param bool $use_default |
|
| 92 | + * @return bool|void |
|
| 93 | + * @throws \EE_Error |
|
| 94 | + */ |
|
| 95 | + public function set_status($new_status = null, $use_default = false) |
|
| 96 | + { |
|
| 97 | + // get current Event status |
|
| 98 | + $old_status = $this->status(); |
|
| 99 | + // if status has changed |
|
| 100 | + if ($old_status != $new_status) { |
|
| 101 | + // TO sold_out |
|
| 102 | + if ($new_status == EEM_Event::sold_out) { |
|
| 103 | + // save the previous event status so that we can revert if the event is no longer sold out |
|
| 104 | + $this->add_post_meta('_previous_event_status', $old_status); |
|
| 105 | + do_action('AHEE__EE_Event__set_status__to_sold_out', $this, $old_status, $new_status); |
|
| 106 | + // OR FROM sold_out |
|
| 107 | + } else if ($old_status == EEM_Event::sold_out) { |
|
| 108 | + $this->delete_post_meta('_previous_event_status'); |
|
| 109 | + do_action('AHEE__EE_Event__set_status__from_sold_out', $this, $old_status, $new_status); |
|
| 110 | + } |
|
| 111 | + // update status |
|
| 112 | + parent::set('status', $new_status, $use_default); |
|
| 113 | + do_action('AHEE__EE_Event__set_status__after_update', $this); |
|
| 114 | + return true; |
|
| 115 | + } else { |
|
| 116 | + // even though the old value matches the new value, it's still good to |
|
| 117 | + // allow the parent set method to have a say |
|
| 118 | + parent::set('status', $new_status, $use_default); |
|
| 119 | + return true; |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * Gets all the datetimes for this event |
|
| 127 | + * |
|
| 128 | + * @param array $query_params like EEM_Base::get_all |
|
| 129 | + * @return EE_Datetime[] |
|
| 130 | + */ |
|
| 131 | + public function datetimes($query_params = array()) |
|
| 132 | + { |
|
| 133 | + return $this->get_many_related('Datetime', $query_params); |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * Gets all the datetimes for this event, ordered by DTT_EVT_start in ascending order |
|
| 140 | + * |
|
| 141 | + * @return EE_Datetime[] |
|
| 142 | + */ |
|
| 143 | + public function datetimes_in_chronological_order() |
|
| 144 | + { |
|
| 145 | + return $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC'))); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * Gets all the datetimes for this event, ordered by the DTT_order on the datetime. |
|
| 152 | + * @darren, we should probably UNSET timezone on the EEM_Datetime model |
|
| 153 | + * after running our query, so that this timezone isn't set for EVERY query |
|
| 154 | + * on EEM_Datetime for the rest of the request, no? |
|
| 155 | + * |
|
| 156 | + * @param boolean $show_expired whether or not to include expired events |
|
| 157 | + * @param boolean $show_deleted whether or not to include deleted events |
|
| 158 | + * @param null $limit |
|
| 159 | + * @return \EE_Datetime[] |
|
| 160 | + * @throws \EE_Error |
|
| 161 | + */ |
|
| 162 | + public function datetimes_ordered($show_expired = true, $show_deleted = false, $limit = null) |
|
| 163 | + { |
|
| 164 | + return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_event_ordered_by_DTT_order( |
|
| 165 | + $this->ID(), |
|
| 166 | + $show_expired, |
|
| 167 | + $show_deleted, |
|
| 168 | + $limit |
|
| 169 | + ); |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * Returns one related datetime. Mostly only used by some legacy code. |
|
| 176 | + * |
|
| 177 | + * @return EE_Datetime |
|
| 178 | + */ |
|
| 179 | + public function first_datetime() |
|
| 180 | + { |
|
| 181 | + return $this->get_first_related('Datetime'); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * Returns the 'primary' datetime for the event |
|
| 188 | + * |
|
| 189 | + * @param bool $try_to_exclude_expired |
|
| 190 | + * @param bool $try_to_exclude_deleted |
|
| 191 | + * @return EE_Datetime |
|
| 192 | + */ |
|
| 193 | + public function primary_datetime($try_to_exclude_expired = true, $try_to_exclude_deleted = true) |
|
| 194 | + { |
|
| 195 | + if ( ! empty ($this->_Primary_Datetime)) { |
|
| 196 | + return $this->_Primary_Datetime; |
|
| 197 | + } |
|
| 198 | + $this->_Primary_Datetime = EEM_Datetime::instance($this->_timezone) |
|
| 199 | + ->get_primary_datetime_for_event($this->ID(), $try_to_exclude_expired, |
|
| 200 | + $try_to_exclude_deleted); |
|
| 201 | + return $this->_Primary_Datetime; |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * Gets all the tickets available for purchase of this event |
|
| 208 | + * |
|
| 209 | + * @param array $query_params like EEM_Base::get_all |
|
| 210 | + * @return EE_Ticket[] |
|
| 211 | + */ |
|
| 212 | + public function tickets($query_params = array()) |
|
| 213 | + { |
|
| 214 | + //first get all datetimes |
|
| 215 | + $datetimes = $this->datetimes_ordered(); |
|
| 216 | + if ( ! $datetimes) { |
|
| 217 | + return array(); |
|
| 218 | + } |
|
| 219 | + $datetime_ids = array(); |
|
| 220 | + foreach ($datetimes as $datetime) { |
|
| 221 | + $datetime_ids[] = $datetime->ID(); |
|
| 222 | + } |
|
| 223 | + $where_params = array('Datetime.DTT_ID' => array('IN', $datetime_ids)); |
|
| 224 | + //if incoming $query_params has where conditions let's merge but not override existing. |
|
| 225 | + if (is_array($query_params) && isset($query_params[0])) { |
|
| 226 | + $where_params = array_merge($query_params[0], $where_params); |
|
| 227 | + unset($query_params[0]); |
|
| 228 | + } |
|
| 229 | + //now add $where_params to $query_params |
|
| 230 | + $query_params[0] = $where_params; |
|
| 231 | + return EEM_Ticket::instance()->get_all($query_params); |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + |
|
| 235 | + |
|
| 236 | + /** |
|
| 237 | + * @return bool |
|
| 238 | + */ |
|
| 239 | + public function additional_limit() |
|
| 240 | + { |
|
| 241 | + return $this->get('EVT_additional_limit'); |
|
| 242 | + } |
|
| 243 | + |
|
| 244 | + |
|
| 245 | + |
|
| 246 | + /** |
|
| 247 | + * @return bool |
|
| 248 | + */ |
|
| 249 | + public function allow_overflow() |
|
| 250 | + { |
|
| 251 | + return $this->get('EVT_allow_overflow'); |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + |
|
| 255 | + |
|
| 256 | + /** |
|
| 257 | + * @return bool |
|
| 258 | + */ |
|
| 259 | + public function created() |
|
| 260 | + { |
|
| 261 | + return $this->get('EVT_created'); |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + |
|
| 265 | + |
|
| 266 | + /** |
|
| 267 | + * @return bool |
|
| 268 | + */ |
|
| 269 | + public function description() |
|
| 270 | + { |
|
| 271 | + return $this->get('EVT_desc'); |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + |
|
| 275 | + |
|
| 276 | + /** |
|
| 277 | + * Runs do_shortcode and wpautop on the description |
|
| 278 | + * |
|
| 279 | + * @return string of html |
|
| 280 | + */ |
|
| 281 | + public function description_filtered() |
|
| 282 | + { |
|
| 283 | + return $this->get_pretty('EVT_desc'); |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + |
|
| 287 | + |
|
| 288 | + /** |
|
| 289 | + * @return bool |
|
| 290 | + */ |
|
| 291 | + public function display_description() |
|
| 292 | + { |
|
| 293 | + return $this->get('EVT_display_desc'); |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + |
|
| 297 | + |
|
| 298 | + /** |
|
| 299 | + * @return bool |
|
| 300 | + */ |
|
| 301 | + public function display_ticket_selector() |
|
| 302 | + { |
|
| 303 | + return (bool)$this->get('EVT_display_ticket_selector'); |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | 306 | |
| 307 | 307 | |
| 308 | - /** |
|
| 309 | - * @return bool |
|
| 310 | - */ |
|
| 311 | - public function external_url() |
|
| 312 | - { |
|
| 313 | - return $this->get('EVT_external_URL'); |
|
| 314 | - } |
|
| 308 | + /** |
|
| 309 | + * @return bool |
|
| 310 | + */ |
|
| 311 | + public function external_url() |
|
| 312 | + { |
|
| 313 | + return $this->get('EVT_external_URL'); |
|
| 314 | + } |
|
| 315 | 315 | |
| 316 | 316 | |
| 317 | 317 | |
| 318 | - /** |
|
| 319 | - * @return bool |
|
| 320 | - */ |
|
| 321 | - public function member_only() |
|
| 322 | - { |
|
| 323 | - return $this->get('EVT_member_only'); |
|
| 324 | - } |
|
| 318 | + /** |
|
| 319 | + * @return bool |
|
| 320 | + */ |
|
| 321 | + public function member_only() |
|
| 322 | + { |
|
| 323 | + return $this->get('EVT_member_only'); |
|
| 324 | + } |
|
| 325 | 325 | |
| 326 | 326 | |
| 327 | 327 | |
| 328 | - /** |
|
| 329 | - * @return bool |
|
| 330 | - */ |
|
| 331 | - public function phone() |
|
| 332 | - { |
|
| 333 | - return $this->get('EVT_phone'); |
|
| 334 | - } |
|
| 328 | + /** |
|
| 329 | + * @return bool |
|
| 330 | + */ |
|
| 331 | + public function phone() |
|
| 332 | + { |
|
| 333 | + return $this->get('EVT_phone'); |
|
| 334 | + } |
|
| 335 | 335 | |
| 336 | 336 | |
| 337 | 337 | |
| 338 | - /** |
|
| 339 | - * @return bool |
|
| 340 | - */ |
|
| 341 | - public function modified() |
|
| 342 | - { |
|
| 343 | - return $this->get('EVT_modified'); |
|
| 344 | - } |
|
| 338 | + /** |
|
| 339 | + * @return bool |
|
| 340 | + */ |
|
| 341 | + public function modified() |
|
| 342 | + { |
|
| 343 | + return $this->get('EVT_modified'); |
|
| 344 | + } |
|
| 345 | 345 | |
| 346 | 346 | |
| 347 | 347 | |
| 348 | - /** |
|
| 349 | - * @return bool |
|
| 350 | - */ |
|
| 351 | - public function name() |
|
| 352 | - { |
|
| 353 | - return $this->get('EVT_name'); |
|
| 354 | - } |
|
| 348 | + /** |
|
| 349 | + * @return bool |
|
| 350 | + */ |
|
| 351 | + public function name() |
|
| 352 | + { |
|
| 353 | + return $this->get('EVT_name'); |
|
| 354 | + } |
|
| 355 | 355 | |
| 356 | 356 | |
| 357 | 357 | |
| 358 | - /** |
|
| 359 | - * @return bool |
|
| 360 | - */ |
|
| 361 | - public function order() |
|
| 362 | - { |
|
| 363 | - return $this->get('EVT_order'); |
|
| 364 | - } |
|
| 358 | + /** |
|
| 359 | + * @return bool |
|
| 360 | + */ |
|
| 361 | + public function order() |
|
| 362 | + { |
|
| 363 | + return $this->get('EVT_order'); |
|
| 364 | + } |
|
| 365 | 365 | |
| 366 | 366 | |
| 367 | 367 | |
| 368 | - /** |
|
| 369 | - * @return bool|string |
|
| 370 | - */ |
|
| 371 | - public function default_registration_status() |
|
| 372 | - { |
|
| 373 | - $event_default_registration_status = $this->get('EVT_default_registration_status'); |
|
| 374 | - return ! empty($event_default_registration_status) ? $event_default_registration_status |
|
| 375 | - : EE_Registry::instance()->CFG->registration->default_STS_ID; |
|
| 376 | - } |
|
| 368 | + /** |
|
| 369 | + * @return bool|string |
|
| 370 | + */ |
|
| 371 | + public function default_registration_status() |
|
| 372 | + { |
|
| 373 | + $event_default_registration_status = $this->get('EVT_default_registration_status'); |
|
| 374 | + return ! empty($event_default_registration_status) ? $event_default_registration_status |
|
| 375 | + : EE_Registry::instance()->CFG->registration->default_STS_ID; |
|
| 376 | + } |
|
| 377 | 377 | |
| 378 | 378 | |
| 379 | 379 | |
| 380 | - /** |
|
| 381 | - * @param int $num_words |
|
| 382 | - * @param null $more |
|
| 383 | - * @param bool $not_full_desc |
|
| 384 | - * @return bool|string |
|
| 385 | - */ |
|
| 386 | - public function short_description($num_words = 55, $more = null, $not_full_desc = false) |
|
| 387 | - { |
|
| 388 | - $short_desc = $this->get('EVT_short_desc'); |
|
| 389 | - if ( ! empty($short_desc) || $not_full_desc) { |
|
| 390 | - return $short_desc; |
|
| 391 | - } else { |
|
| 392 | - $full_desc = $this->get('EVT_desc'); |
|
| 393 | - return wp_trim_words($full_desc, $num_words, $more); |
|
| 394 | - } |
|
| 395 | - } |
|
| 380 | + /** |
|
| 381 | + * @param int $num_words |
|
| 382 | + * @param null $more |
|
| 383 | + * @param bool $not_full_desc |
|
| 384 | + * @return bool|string |
|
| 385 | + */ |
|
| 386 | + public function short_description($num_words = 55, $more = null, $not_full_desc = false) |
|
| 387 | + { |
|
| 388 | + $short_desc = $this->get('EVT_short_desc'); |
|
| 389 | + if ( ! empty($short_desc) || $not_full_desc) { |
|
| 390 | + return $short_desc; |
|
| 391 | + } else { |
|
| 392 | + $full_desc = $this->get('EVT_desc'); |
|
| 393 | + return wp_trim_words($full_desc, $num_words, $more); |
|
| 394 | + } |
|
| 395 | + } |
|
| 396 | 396 | |
| 397 | 397 | |
| 398 | 398 | |
| 399 | - /** |
|
| 400 | - * @return bool |
|
| 401 | - */ |
|
| 402 | - public function slug() |
|
| 403 | - { |
|
| 404 | - return $this->get('EVT_slug'); |
|
| 405 | - } |
|
| 399 | + /** |
|
| 400 | + * @return bool |
|
| 401 | + */ |
|
| 402 | + public function slug() |
|
| 403 | + { |
|
| 404 | + return $this->get('EVT_slug'); |
|
| 405 | + } |
|
| 406 | 406 | |
| 407 | 407 | |
| 408 | 408 | |
| 409 | - /** |
|
| 410 | - * @return bool |
|
| 411 | - */ |
|
| 412 | - public function timezone_string() |
|
| 413 | - { |
|
| 414 | - return $this->get('EVT_timezone_string'); |
|
| 415 | - } |
|
| 409 | + /** |
|
| 410 | + * @return bool |
|
| 411 | + */ |
|
| 412 | + public function timezone_string() |
|
| 413 | + { |
|
| 414 | + return $this->get('EVT_timezone_string'); |
|
| 415 | + } |
|
| 416 | 416 | |
| 417 | 417 | |
| 418 | 418 | |
| 419 | - /** |
|
| 420 | - * @return bool |
|
| 421 | - */ |
|
| 422 | - public function visible_on() |
|
| 423 | - { |
|
| 424 | - return $this->get('EVT_visible_on'); |
|
| 425 | - } |
|
| 419 | + /** |
|
| 420 | + * @return bool |
|
| 421 | + */ |
|
| 422 | + public function visible_on() |
|
| 423 | + { |
|
| 424 | + return $this->get('EVT_visible_on'); |
|
| 425 | + } |
|
| 426 | 426 | |
| 427 | 427 | |
| 428 | 428 | |
| 429 | - /** |
|
| 430 | - * @return int |
|
| 431 | - */ |
|
| 432 | - public function wp_user() |
|
| 433 | - { |
|
| 434 | - return $this->get('EVT_wp_user'); |
|
| 435 | - } |
|
| 429 | + /** |
|
| 430 | + * @return int |
|
| 431 | + */ |
|
| 432 | + public function wp_user() |
|
| 433 | + { |
|
| 434 | + return $this->get('EVT_wp_user'); |
|
| 435 | + } |
|
| 436 | 436 | |
| 437 | 437 | |
| 438 | 438 | |
| 439 | - /** |
|
| 440 | - * @return bool |
|
| 441 | - */ |
|
| 442 | - public function donations() |
|
| 443 | - { |
|
| 444 | - return $this->get('EVT_donations'); |
|
| 445 | - } |
|
| 439 | + /** |
|
| 440 | + * @return bool |
|
| 441 | + */ |
|
| 442 | + public function donations() |
|
| 443 | + { |
|
| 444 | + return $this->get('EVT_donations'); |
|
| 445 | + } |
|
| 446 | 446 | |
| 447 | 447 | |
| 448 | 448 | |
| 449 | - /** |
|
| 450 | - * @param $limit |
|
| 451 | - */ |
|
| 452 | - public function set_additional_limit($limit) |
|
| 453 | - { |
|
| 454 | - $this->set('EVT_additional_limit', $limit); |
|
| 455 | - } |
|
| 449 | + /** |
|
| 450 | + * @param $limit |
|
| 451 | + */ |
|
| 452 | + public function set_additional_limit($limit) |
|
| 453 | + { |
|
| 454 | + $this->set('EVT_additional_limit', $limit); |
|
| 455 | + } |
|
| 456 | 456 | |
| 457 | 457 | |
| 458 | 458 | |
| 459 | - /** |
|
| 460 | - * @param $created |
|
| 461 | - */ |
|
| 462 | - public function set_created($created) |
|
| 463 | - { |
|
| 464 | - $this->set('EVT_created', $created); |
|
| 465 | - } |
|
| 459 | + /** |
|
| 460 | + * @param $created |
|
| 461 | + */ |
|
| 462 | + public function set_created($created) |
|
| 463 | + { |
|
| 464 | + $this->set('EVT_created', $created); |
|
| 465 | + } |
|
| 466 | 466 | |
| 467 | 467 | |
| 468 | 468 | |
| 469 | - /** |
|
| 470 | - * @param $desc |
|
| 471 | - */ |
|
| 472 | - public function set_description($desc) |
|
| 473 | - { |
|
| 474 | - $this->set('EVT_desc', $desc); |
|
| 475 | - } |
|
| 469 | + /** |
|
| 470 | + * @param $desc |
|
| 471 | + */ |
|
| 472 | + public function set_description($desc) |
|
| 473 | + { |
|
| 474 | + $this->set('EVT_desc', $desc); |
|
| 475 | + } |
|
| 476 | 476 | |
| 477 | 477 | |
| 478 | 478 | |
| 479 | - /** |
|
| 480 | - * @param $display_desc |
|
| 481 | - */ |
|
| 482 | - public function set_display_description($display_desc) |
|
| 483 | - { |
|
| 484 | - $this->set('EVT_display_desc', $display_desc); |
|
| 485 | - } |
|
| 479 | + /** |
|
| 480 | + * @param $display_desc |
|
| 481 | + */ |
|
| 482 | + public function set_display_description($display_desc) |
|
| 483 | + { |
|
| 484 | + $this->set('EVT_display_desc', $display_desc); |
|
| 485 | + } |
|
| 486 | 486 | |
| 487 | 487 | |
| 488 | 488 | |
| 489 | - /** |
|
| 490 | - * @param $display_ticket_selector |
|
| 491 | - */ |
|
| 492 | - public function set_display_ticket_selector($display_ticket_selector) |
|
| 493 | - { |
|
| 494 | - $this->set('EVT_display_ticket_selector', $display_ticket_selector); |
|
| 495 | - } |
|
| 489 | + /** |
|
| 490 | + * @param $display_ticket_selector |
|
| 491 | + */ |
|
| 492 | + public function set_display_ticket_selector($display_ticket_selector) |
|
| 493 | + { |
|
| 494 | + $this->set('EVT_display_ticket_selector', $display_ticket_selector); |
|
| 495 | + } |
|
| 496 | 496 | |
| 497 | 497 | |
| 498 | 498 | |
| 499 | - /** |
|
| 500 | - * @param $external_url |
|
| 501 | - */ |
|
| 502 | - public function set_external_url($external_url) |
|
| 503 | - { |
|
| 504 | - $this->set('EVT_external_URL', $external_url); |
|
| 505 | - } |
|
| 499 | + /** |
|
| 500 | + * @param $external_url |
|
| 501 | + */ |
|
| 502 | + public function set_external_url($external_url) |
|
| 503 | + { |
|
| 504 | + $this->set('EVT_external_URL', $external_url); |
|
| 505 | + } |
|
| 506 | 506 | |
| 507 | 507 | |
| 508 | 508 | |
| 509 | - /** |
|
| 510 | - * @param $member_only |
|
| 511 | - */ |
|
| 512 | - public function set_member_only($member_only) |
|
| 513 | - { |
|
| 514 | - $this->set('EVT_member_only', $member_only); |
|
| 515 | - } |
|
| 509 | + /** |
|
| 510 | + * @param $member_only |
|
| 511 | + */ |
|
| 512 | + public function set_member_only($member_only) |
|
| 513 | + { |
|
| 514 | + $this->set('EVT_member_only', $member_only); |
|
| 515 | + } |
|
| 516 | 516 | |
| 517 | 517 | |
| 518 | 518 | |
| 519 | - /** |
|
| 520 | - * @param $event_phone |
|
| 521 | - */ |
|
| 522 | - public function set_event_phone($event_phone) |
|
| 523 | - { |
|
| 524 | - $this->set('EVT_phone', $event_phone); |
|
| 525 | - } |
|
| 519 | + /** |
|
| 520 | + * @param $event_phone |
|
| 521 | + */ |
|
| 522 | + public function set_event_phone($event_phone) |
|
| 523 | + { |
|
| 524 | + $this->set('EVT_phone', $event_phone); |
|
| 525 | + } |
|
| 526 | 526 | |
| 527 | 527 | |
| 528 | 528 | |
| 529 | - /** |
|
| 530 | - * @param $modified |
|
| 531 | - */ |
|
| 532 | - public function set_modified($modified) |
|
| 533 | - { |
|
| 534 | - $this->set('EVT_modified', $modified); |
|
| 535 | - } |
|
| 529 | + /** |
|
| 530 | + * @param $modified |
|
| 531 | + */ |
|
| 532 | + public function set_modified($modified) |
|
| 533 | + { |
|
| 534 | + $this->set('EVT_modified', $modified); |
|
| 535 | + } |
|
| 536 | 536 | |
| 537 | 537 | |
| 538 | 538 | |
| 539 | - /** |
|
| 540 | - * @param $name |
|
| 541 | - */ |
|
| 542 | - public function set_name($name) |
|
| 543 | - { |
|
| 544 | - $this->set('EVT_name', $name); |
|
| 545 | - } |
|
| 539 | + /** |
|
| 540 | + * @param $name |
|
| 541 | + */ |
|
| 542 | + public function set_name($name) |
|
| 543 | + { |
|
| 544 | + $this->set('EVT_name', $name); |
|
| 545 | + } |
|
| 546 | 546 | |
| 547 | 547 | |
| 548 | 548 | |
| 549 | - /** |
|
| 550 | - * @param $order |
|
| 551 | - */ |
|
| 552 | - public function set_order($order) |
|
| 553 | - { |
|
| 554 | - $this->set('EVT_order', $order); |
|
| 555 | - } |
|
| 549 | + /** |
|
| 550 | + * @param $order |
|
| 551 | + */ |
|
| 552 | + public function set_order($order) |
|
| 553 | + { |
|
| 554 | + $this->set('EVT_order', $order); |
|
| 555 | + } |
|
| 556 | 556 | |
| 557 | 557 | |
| 558 | 558 | |
| 559 | - /** |
|
| 560 | - * @param $short_desc |
|
| 561 | - */ |
|
| 562 | - public function set_short_description($short_desc) |
|
| 563 | - { |
|
| 564 | - $this->set('EVT_short_desc', $short_desc); |
|
| 565 | - } |
|
| 559 | + /** |
|
| 560 | + * @param $short_desc |
|
| 561 | + */ |
|
| 562 | + public function set_short_description($short_desc) |
|
| 563 | + { |
|
| 564 | + $this->set('EVT_short_desc', $short_desc); |
|
| 565 | + } |
|
| 566 | 566 | |
| 567 | 567 | |
| 568 | 568 | |
| 569 | - /** |
|
| 570 | - * @param $slug |
|
| 571 | - */ |
|
| 572 | - public function set_slug($slug) |
|
| 573 | - { |
|
| 574 | - $this->set('EVT_slug', $slug); |
|
| 575 | - } |
|
| 569 | + /** |
|
| 570 | + * @param $slug |
|
| 571 | + */ |
|
| 572 | + public function set_slug($slug) |
|
| 573 | + { |
|
| 574 | + $this->set('EVT_slug', $slug); |
|
| 575 | + } |
|
| 576 | 576 | |
| 577 | 577 | |
| 578 | 578 | |
| 579 | - /** |
|
| 580 | - * @param $timezone_string |
|
| 581 | - */ |
|
| 582 | - public function set_timezone_string($timezone_string) |
|
| 583 | - { |
|
| 584 | - $this->set('EVT_timezone_string', $timezone_string); |
|
| 585 | - } |
|
| 579 | + /** |
|
| 580 | + * @param $timezone_string |
|
| 581 | + */ |
|
| 582 | + public function set_timezone_string($timezone_string) |
|
| 583 | + { |
|
| 584 | + $this->set('EVT_timezone_string', $timezone_string); |
|
| 585 | + } |
|
| 586 | 586 | |
| 587 | 587 | |
| 588 | 588 | |
| 589 | - /** |
|
| 590 | - * @param $visible_on |
|
| 591 | - */ |
|
| 592 | - public function set_visible_on($visible_on) |
|
| 593 | - { |
|
| 594 | - $this->set('EVT_visible_on', $visible_on); |
|
| 595 | - } |
|
| 589 | + /** |
|
| 590 | + * @param $visible_on |
|
| 591 | + */ |
|
| 592 | + public function set_visible_on($visible_on) |
|
| 593 | + { |
|
| 594 | + $this->set('EVT_visible_on', $visible_on); |
|
| 595 | + } |
|
| 596 | 596 | |
| 597 | 597 | |
| 598 | 598 | |
| 599 | - /** |
|
| 600 | - * @param $wp_user |
|
| 601 | - */ |
|
| 602 | - public function set_wp_user($wp_user) |
|
| 603 | - { |
|
| 604 | - $this->set('EVT_wp_user', $wp_user); |
|
| 605 | - } |
|
| 599 | + /** |
|
| 600 | + * @param $wp_user |
|
| 601 | + */ |
|
| 602 | + public function set_wp_user($wp_user) |
|
| 603 | + { |
|
| 604 | + $this->set('EVT_wp_user', $wp_user); |
|
| 605 | + } |
|
| 606 | 606 | |
| 607 | 607 | |
| 608 | - |
|
| 609 | - /** |
|
| 610 | - * @param $default_registration_status |
|
| 611 | - */ |
|
| 612 | - public function set_default_registration_status($default_registration_status) |
|
| 613 | - { |
|
| 614 | - $this->set('EVT_default_registration_status', $default_registration_status); |
|
| 615 | - } |
|
| 616 | - |
|
| 617 | - |
|
| 618 | - |
|
| 619 | - /** |
|
| 620 | - * @param $donations |
|
| 621 | - */ |
|
| 622 | - public function set_donations($donations) |
|
| 623 | - { |
|
| 624 | - $this->set('EVT_donations', $donations); |
|
| 625 | - } |
|
| 626 | - |
|
| 627 | - |
|
| 628 | - |
|
| 629 | - /** |
|
| 630 | - * Adds a venue to this event |
|
| 631 | - * |
|
| 632 | - * @param EE_Venue /int $venue_id_or_obj |
|
| 633 | - * @return EE_Venue |
|
| 634 | - */ |
|
| 635 | - public function add_venue($venue_id_or_obj) |
|
| 636 | - { |
|
| 637 | - return $this->_add_relation_to($venue_id_or_obj, 'Venue'); |
|
| 638 | - } |
|
| 639 | - |
|
| 640 | - |
|
| 641 | - |
|
| 642 | - /** |
|
| 643 | - * Removes a venue from the event |
|
| 644 | - * |
|
| 645 | - * @param EE_Venue /int $venue_id_or_obj |
|
| 646 | - * @return EE_Venue |
|
| 647 | - */ |
|
| 648 | - public function remove_venue($venue_id_or_obj) |
|
| 649 | - { |
|
| 650 | - return $this->_remove_relation_to($venue_id_or_obj, 'Venue'); |
|
| 651 | - } |
|
| 652 | - |
|
| 653 | - |
|
| 654 | - |
|
| 655 | - /** |
|
| 656 | - * Gets all the venues related ot the event. May provide additional $query_params if desired |
|
| 657 | - * |
|
| 658 | - * @param array $query_params like EEM_Base::get_all's $query_params |
|
| 659 | - * @return EE_Venue[] |
|
| 660 | - */ |
|
| 661 | - public function venues($query_params = array()) |
|
| 662 | - { |
|
| 663 | - return $this->get_many_related('Venue', $query_params); |
|
| 664 | - } |
|
| 665 | - |
|
| 666 | - |
|
| 667 | - |
|
| 668 | - /** |
|
| 669 | - * check if event id is present and if event is published |
|
| 670 | - * |
|
| 671 | - * @access public |
|
| 672 | - * @return boolean true yes, false no |
|
| 673 | - */ |
|
| 674 | - private function _has_ID_and_is_published() |
|
| 675 | - { |
|
| 676 | - // first check if event id is present and not NULL, then check if this event is published (or any of the equivalent "published" statuses) |
|
| 677 | - return ($this->ID() && $this->ID() !== null |
|
| 678 | - && ($this->status() == 'publish' |
|
| 679 | - || $this->status() |
|
| 680 | - == EEM_Event::sold_out |
|
| 681 | - || $this->status() == EEM_Event::postponed |
|
| 682 | - || $this->status() == EEM_Event::cancelled)) ? true : false; |
|
| 683 | - } |
|
| 684 | - |
|
| 685 | - |
|
| 686 | - |
|
| 687 | - /** |
|
| 688 | - * This simply compares the internal dates with NOW and determines if the event is upcoming or not. |
|
| 689 | - * |
|
| 690 | - * @access public |
|
| 691 | - * @return boolean true yes, false no |
|
| 692 | - */ |
|
| 693 | - public function is_upcoming() |
|
| 694 | - { |
|
| 695 | - // check if event id is present and if this event is published |
|
| 696 | - if ($this->is_inactive()) { |
|
| 697 | - return false; |
|
| 698 | - } |
|
| 699 | - // set initial value |
|
| 700 | - $upcoming = false; |
|
| 701 | - //next let's get all datetimes and loop through them |
|
| 702 | - $datetimes = $this->datetimes_in_chronological_order(); |
|
| 703 | - foreach ($datetimes as $datetime) { |
|
| 704 | - if ($datetime instanceof EE_Datetime) { |
|
| 705 | - //if this dtt is expired then we continue cause one of the other datetimes might be upcoming. |
|
| 706 | - if ($datetime->is_expired()) { |
|
| 707 | - continue; |
|
| 708 | - } |
|
| 709 | - //if this dtt is active then we return false. |
|
| 710 | - if ($datetime->is_active()) { |
|
| 711 | - return false; |
|
| 712 | - } |
|
| 713 | - //otherwise let's check upcoming status |
|
| 714 | - $upcoming = $datetime->is_upcoming(); |
|
| 715 | - } |
|
| 716 | - } |
|
| 717 | - return $upcoming; |
|
| 718 | - } |
|
| 719 | - |
|
| 720 | - |
|
| 721 | - |
|
| 722 | - /** |
|
| 723 | - * @return bool |
|
| 724 | - */ |
|
| 725 | - public function is_active() |
|
| 726 | - { |
|
| 727 | - // check if event id is present and if this event is published |
|
| 728 | - if ($this->is_inactive()) { |
|
| 729 | - return false; |
|
| 730 | - } |
|
| 731 | - // set initial value |
|
| 732 | - $active = false; |
|
| 733 | - //next let's get all datetimes and loop through them |
|
| 734 | - $datetimes = $this->datetimes_in_chronological_order(); |
|
| 735 | - foreach ($datetimes as $datetime) { |
|
| 736 | - if ($datetime instanceof EE_Datetime) { |
|
| 737 | - //if this dtt is expired then we continue cause one of the other datetimes might be active. |
|
| 738 | - if ($datetime->is_expired()) { |
|
| 739 | - continue; |
|
| 740 | - } |
|
| 741 | - //if this dtt is upcoming then we return false. |
|
| 742 | - if ($datetime->is_upcoming()) { |
|
| 743 | - return false; |
|
| 744 | - } |
|
| 745 | - //otherwise let's check active status |
|
| 746 | - $active = $datetime->is_active(); |
|
| 747 | - } |
|
| 748 | - } |
|
| 749 | - return $active; |
|
| 750 | - } |
|
| 751 | - |
|
| 752 | - |
|
| 753 | - |
|
| 754 | - /** |
|
| 755 | - * @return bool |
|
| 756 | - */ |
|
| 757 | - public function is_expired() |
|
| 758 | - { |
|
| 759 | - // check if event id is present and if this event is published |
|
| 760 | - if ($this->is_inactive()) { |
|
| 761 | - return false; |
|
| 762 | - } |
|
| 763 | - // set initial value |
|
| 764 | - $expired = false; |
|
| 765 | - //first let's get all datetimes and loop through them |
|
| 766 | - $datetimes = $this->datetimes_in_chronological_order(); |
|
| 767 | - foreach ($datetimes as $datetime) { |
|
| 768 | - if ($datetime instanceof EE_Datetime) { |
|
| 769 | - //if this dtt is upcoming or active then we return false. |
|
| 770 | - if ($datetime->is_upcoming() || $datetime->is_active()) { |
|
| 771 | - return false; |
|
| 772 | - } |
|
| 773 | - //otherwise let's check active status |
|
| 774 | - $expired = $datetime->is_expired(); |
|
| 775 | - } |
|
| 776 | - } |
|
| 777 | - return $expired; |
|
| 778 | - } |
|
| 779 | - |
|
| 780 | - |
|
| 781 | - |
|
| 782 | - /** |
|
| 783 | - * @return bool |
|
| 784 | - */ |
|
| 785 | - public function is_inactive() |
|
| 786 | - { |
|
| 787 | - // check if event id is present and if this event is published |
|
| 788 | - if ($this->_has_ID_and_is_published()) { |
|
| 789 | - return false; |
|
| 790 | - } |
|
| 791 | - return true; |
|
| 792 | - } |
|
| 793 | - |
|
| 794 | - |
|
| 795 | - |
|
| 796 | - /** |
|
| 797 | - * perform_sold_out_status_check |
|
| 798 | - * checks all of this events's datetime reg_limit - sold values to determine if ANY datetimes have spaces |
|
| 799 | - * available... if NOT, then the event status will get toggled to 'sold_out' |
|
| 800 | - * |
|
| 801 | - * @access public |
|
| 802 | - * @return bool return the ACTUAL sold out state. |
|
| 803 | - */ |
|
| 804 | - public function perform_sold_out_status_check() |
|
| 805 | - { |
|
| 806 | - // get all unexpired untrashed tickets |
|
| 807 | - $tickets = $this->tickets(array( |
|
| 808 | - array( |
|
| 809 | - 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
|
| 810 | - 'TKT_deleted' => false, |
|
| 811 | - ), |
|
| 812 | - )); |
|
| 813 | - // if all the tickets are just expired, then don't update the event status to sold out |
|
| 814 | - if (empty($tickets)) { |
|
| 815 | - return true; |
|
| 816 | - } |
|
| 817 | - // set initial value |
|
| 818 | - $spaces_remaining = 0; |
|
| 819 | - foreach ($tickets as $ticket) { |
|
| 820 | - if ($ticket instanceof EE_Ticket) { |
|
| 821 | - $spaces_remaining += $ticket->qty('saleable'); |
|
| 822 | - } |
|
| 823 | - } |
|
| 824 | - if ($spaces_remaining === 0) { |
|
| 825 | - $this->set_status(EEM_Event::sold_out); |
|
| 826 | - if ( ! is_admin() || (is_admin() && defined('DOING_AJAX'))) { |
|
| 827 | - $this->save(); |
|
| 828 | - } |
|
| 829 | - $sold_out = true; |
|
| 830 | - } else { |
|
| 831 | - $sold_out = false; |
|
| 832 | - // was event previously marked as sold out ? |
|
| 833 | - if ($this->status() == EEM_Event::sold_out) { |
|
| 834 | - // revert status to previous value, if it was set |
|
| 835 | - $previous_event_status = $this->get_post_meta('_previous_event_status', true); |
|
| 836 | - if ($previous_event_status) { |
|
| 837 | - $this->set_status($previous_event_status); |
|
| 838 | - } |
|
| 839 | - } |
|
| 840 | - } |
|
| 841 | - //note: I considered changing the EEM_Event status away from sold_out if this status check reveals that it's no longer sold out (yet the status is still set as sold out) but the problem is... what do we change the status BACK to? We can't always assume that the previous event status was 'published' because this status check is always done in the admin and its entirely possible the event admin manually changes to sold_out status from some other status. We also don't want a draft event to become a "publish event" because the sold out check reveals its NOT sold out. |
|
| 842 | - // So I'll forgo the automatic switch away from sold out status for now and instead just return the $sold out status... so this check can be used to validate the TRUE sold out status regardless of what the Event status is set to. |
|
| 843 | - return $sold_out; |
|
| 844 | - } |
|
| 845 | - |
|
| 846 | - |
|
| 847 | - |
|
| 848 | - /** |
|
| 849 | - * This returns the total remaining spaces for sale on this event. |
|
| 850 | - * ############################ |
|
| 851 | - * VERY IMPORTANT FOR DEVELOPERS: |
|
| 852 | - * While included here, this method is still being tested internally, so its signature and behaviour COULD change. |
|
| 853 | - * While this comment block is in place, usage is at your own risk and know that it may change in future builds. |
|
| 854 | - * ############################ |
|
| 855 | - * |
|
| 856 | - * @uses EE_Event::total_available_spaces() |
|
| 857 | - * @return float|int (EE_INF is returned as float) |
|
| 858 | - */ |
|
| 859 | - public function spaces_remaining_for_sale() |
|
| 860 | - { |
|
| 861 | - //first get total available spaces including consideration for tickets that have already sold. |
|
| 862 | - $spaces_available = $this->total_available_spaces(true); |
|
| 863 | - //if total available = 0, then exit right away because that means everything is expired. |
|
| 864 | - if ($spaces_available === 0) { |
|
| 865 | - return 0; |
|
| 866 | - } |
|
| 867 | - //subtract total approved registrations from spaces available to get how many are remaining. |
|
| 868 | - $spots_taken = EEM_Registration::instance()->count(array( |
|
| 869 | - array( |
|
| 870 | - 'EVT_ID' => $this->ID(), |
|
| 871 | - 'STS_ID' => EEM_Registration::status_id_approved, |
|
| 872 | - ), |
|
| 873 | - ), 'REG_ID', true); |
|
| 874 | - $spaces_remaining = $spaces_available - $spots_taken; |
|
| 875 | - return $spaces_remaining > 0 ? $spaces_remaining : 0; |
|
| 876 | - } |
|
| 877 | - |
|
| 878 | - |
|
| 879 | - |
|
| 880 | - /** |
|
| 881 | - * This returns the total spaces available for an event while considering all the qtys on the tickets and the reg |
|
| 882 | - * limits on the datetimes attached to this event. |
|
| 883 | - * ############################ |
|
| 884 | - * VERY IMPORTANT FOR DEVELOPERS: |
|
| 885 | - * While included here, this method is still being tested internally, so its signature and behaviour COULD change. |
|
| 886 | - * While this comment block is in place, usage is at your own risk and know that it may change in future builds. |
|
| 887 | - * ############################ |
|
| 888 | - * Note: by "spaces available" we are not returning how many spaces remain. That is a calculation involving using |
|
| 889 | - * the value from this method and subtracting the approved registrations for the event. |
|
| 890 | - * |
|
| 891 | - * @param bool $current_total_available Whether to consider any tickets that have already sold in our |
|
| 892 | - * calculation. If this is false, then we return the most tickets that |
|
| 893 | - * could ever be sold for this event with the datetime and tickets |
|
| 894 | - * setup on the event under optimal selling conditions. Otherwise we |
|
| 895 | - * return a live calculation of spaces available based on tickets |
|
| 896 | - * sold. Depending on setup and stage of sales, this may appear to |
|
| 897 | - * equal remaining tickets. However, the more tickets are sold out, |
|
| 898 | - * the more accurate the "live" total is. |
|
| 899 | - * @return int|float (Note: if EE_INF is returned its considered a float by PHP) |
|
| 900 | - */ |
|
| 901 | - public function total_available_spaces($current_total_available = false) |
|
| 902 | - { |
|
| 903 | - $spaces_available = 0; |
|
| 904 | - //first get all tickets on the event and include expired tickets |
|
| 905 | - $tickets = $this->tickets(array('default_where_conditions' => 'none')); |
|
| 906 | - $ticket_sums = array(); |
|
| 907 | - $datetime_limits = array(); |
|
| 908 | - //loop through tickets and normalize them |
|
| 909 | - foreach ($tickets as $ticket) { |
|
| 910 | - $datetimes = $ticket->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC'))); |
|
| 911 | - if (empty($datetimes)) { |
|
| 912 | - continue; |
|
| 913 | - } |
|
| 914 | - //first datetime should be the lowest datetime |
|
| 915 | - $least_datetime = reset($datetimes); |
|
| 916 | - //lets reset the ticket quantity to be the lower of either the lowest datetime reg limit or the ticket quantity |
|
| 917 | - //IF datetimes sold (and we're not doing current live total available, then use spaces remaining for datetime, not reg_limit. |
|
| 918 | - if ($current_total_available) { |
|
| 919 | - if ($ticket->is_remaining()) { |
|
| 920 | - $remaining = $ticket->remaining(); |
|
| 921 | - } else { |
|
| 922 | - $spaces_available += $ticket->sold(); |
|
| 923 | - //and we don't cache this ticket to our list because its sold out. |
|
| 924 | - continue; |
|
| 925 | - } |
|
| 926 | - } else { |
|
| 927 | - $remaining = min($ticket->qty(), $least_datetime->reg_limit()); |
|
| 928 | - } |
|
| 929 | - //if $ticket_limit == infinity then let's drop out right away and just return that because any infinity amount trumps all other "available" amounts. |
|
| 930 | - if ($remaining === EE_INF) { |
|
| 931 | - return EE_INF; |
|
| 932 | - } |
|
| 933 | - //multiply normalized $tkt quantity by the number of datetimes on the ticket as the "sum" |
|
| 934 | - //also include the sum of all the datetime reg limits on the ticket for breaking ties. |
|
| 935 | - $ticket_sums[$ticket->ID()]['sum'] = $remaining * count($datetimes); |
|
| 936 | - $ticket_sums[$ticket->ID()]['datetime_sums'] = 0; |
|
| 937 | - foreach ($datetimes as $datetime) { |
|
| 938 | - if ($datetime->reg_limit() === EE_INF) { |
|
| 939 | - $ticket_sums[$ticket->ID()]['datetime_sums'] = EE_INF; |
|
| 940 | - } else { |
|
| 941 | - $ticket_sums[$ticket->ID()]['datetime_sums'] += $current_total_available |
|
| 942 | - ? $datetime->spaces_remaining() : $datetime->reg_limit(); |
|
| 943 | - } |
|
| 944 | - $datetime_limits[$datetime->ID()] = $current_total_available ? $datetime->spaces_remaining() |
|
| 945 | - : $datetime->reg_limit(); |
|
| 946 | - } |
|
| 947 | - $ticket_sums[$ticket->ID()]['ticket'] = $ticket; |
|
| 948 | - } |
|
| 949 | - //The order is sorted by lowest available first (which is calculated for each ticket by multiplying the normalized |
|
| 950 | - //ticket quantity by the number of datetimes on the ticket). For tie-breakers, then the next sort is based on the |
|
| 951 | - //ticket with the greatest sum of all remaining datetime->spaces_remaining() ( or $datetime->reg_limit() if not |
|
| 952 | - //$current_total_available ) for the datetimes on the ticket. |
|
| 953 | - usort($ticket_sums, function ($a, $b) { |
|
| 954 | - if ($a['sum'] == $b['sum']) { |
|
| 955 | - if ($a['datetime_sums'] == $b['datetime_sums']) { |
|
| 956 | - return 0; |
|
| 957 | - } |
|
| 958 | - return $a['datetime_sums'] < $b['datetime_sums'] ? 1 : -1; |
|
| 959 | - } |
|
| 960 | - return ($a['sum'] < $b['sum']) ? -1 : 1; |
|
| 961 | - }); |
|
| 962 | - //now let's loop through the sorted tickets and simulate sellouts |
|
| 963 | - foreach ($ticket_sums as $ticket_info) { |
|
| 964 | - if ($ticket_info['ticket'] instanceof EE_Ticket) { |
|
| 965 | - $datetimes = $ticket_info['ticket']->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC'))); |
|
| 966 | - //need to sort these $datetimes by remaining (only if $current_total_available) |
|
| 967 | - //setup datetimes for simulation |
|
| 968 | - $ticket_datetimes_remaining = array(); |
|
| 969 | - foreach ($datetimes as $datetime) { |
|
| 970 | - $ticket_datetimes_remaining[$datetime->ID()]['rem'] = $datetime_limits[$datetime->ID()]; |
|
| 971 | - $ticket_datetimes_remaining[$datetime->ID()]['datetime'] = $datetime; |
|
| 972 | - } |
|
| 973 | - usort($ticket_datetimes_remaining, function ($a, $b) { |
|
| 974 | - if ($a['rem'] == $b['rem']) { |
|
| 975 | - return 0; |
|
| 976 | - } |
|
| 977 | - return ($a['rem'] < $b['rem']) ? -1 : 1; |
|
| 978 | - }); |
|
| 979 | - //get the remaining on the first datetime (which should be the one with the least remaining) and that is |
|
| 980 | - //what we add to the spaces_available running total. Then we need to decrease the remaining on our datetime tracker. |
|
| 981 | - $lowest_datetime = reset($ticket_datetimes_remaining); |
|
| 982 | - //need to get the lower of; what the remaining is on the lowest datetime, and the remaining on the ticket. |
|
| 983 | - // If this ends up being 0 (because of previous tickets in our simulation selling out), then it has already |
|
| 984 | - // been tracked on $spaces available and this ticket is now sold out for the simulation, so we can continue |
|
| 985 | - // to the next ticket. |
|
| 986 | - if ($current_total_available) { |
|
| 987 | - $remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->remaining()); |
|
| 988 | - } else { |
|
| 989 | - $remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->qty()); |
|
| 990 | - } |
|
| 991 | - //if $remaining is infinite that means that all datetimes on this ticket are infinite but we've made it here because all |
|
| 992 | - //tickets have a quantity. So we don't have to track datetimes, we can just use ticket quantities for total |
|
| 993 | - //available. |
|
| 994 | - if ($remaining === EE_INF) { |
|
| 995 | - $spaces_available += $ticket_info['ticket']->qty(); |
|
| 996 | - continue; |
|
| 997 | - } |
|
| 998 | - //if ticket has sold amounts then we also need to add that (but only if doing live counts) |
|
| 999 | - if ($current_total_available) { |
|
| 1000 | - $spaces_available += $ticket_info['ticket']->sold(); |
|
| 1001 | - } |
|
| 1002 | - if ($remaining <= 0) { |
|
| 1003 | - continue; |
|
| 1004 | - } else { |
|
| 1005 | - $spaces_available += $remaining; |
|
| 1006 | - } |
|
| 1007 | - //loop through the datetimes and sell them out! |
|
| 1008 | - foreach ($ticket_datetimes_remaining as $datetime_info) { |
|
| 1009 | - if ($datetime_info['datetime'] instanceof EE_Datetime) { |
|
| 1010 | - $datetime_limits[$datetime_info['datetime']->ID()] += -$remaining; |
|
| 1011 | - } |
|
| 1012 | - } |
|
| 1013 | - } |
|
| 1014 | - } |
|
| 1015 | - return $spaces_available; |
|
| 1016 | - } |
|
| 1017 | - |
|
| 1018 | - |
|
| 1019 | - |
|
| 1020 | - /** |
|
| 1021 | - * Checks if the event is set to sold out |
|
| 1022 | - * |
|
| 1023 | - * @param bool $actual whether or not to perform calculations to not only figure the actual status but also to |
|
| 1024 | - * flip the status if necessary to sold out If false, we just check the existing status of the |
|
| 1025 | - * event |
|
| 1026 | - * @return boolean |
|
| 1027 | - */ |
|
| 1028 | - public function is_sold_out($actual = false) |
|
| 1029 | - { |
|
| 1030 | - if ( ! $actual) { |
|
| 1031 | - return $this->status() == EEM_Event::sold_out; |
|
| 1032 | - } else { |
|
| 1033 | - return $this->perform_sold_out_status_check(); |
|
| 1034 | - } |
|
| 1035 | - } |
|
| 1036 | - |
|
| 1037 | - |
|
| 1038 | - |
|
| 1039 | - /** |
|
| 1040 | - * Checks if the event is marked as postponed |
|
| 1041 | - * |
|
| 1042 | - * @return boolean |
|
| 1043 | - */ |
|
| 1044 | - public function is_postponed() |
|
| 1045 | - { |
|
| 1046 | - return $this->status() == EEM_Event::postponed; |
|
| 1047 | - } |
|
| 1048 | - |
|
| 1049 | - |
|
| 1050 | - |
|
| 1051 | - /** |
|
| 1052 | - * Checks if the event is marked as cancelled |
|
| 1053 | - * |
|
| 1054 | - * @return boolean |
|
| 1055 | - */ |
|
| 1056 | - public function is_cancelled() |
|
| 1057 | - { |
|
| 1058 | - return $this->status() == EEM_Event::cancelled; |
|
| 1059 | - } |
|
| 1060 | - |
|
| 1061 | - |
|
| 1062 | - |
|
| 1063 | - /** |
|
| 1064 | - * Get the logical active status in a hierarchical order for all the datetimes. Note |
|
| 1065 | - * Basically, we order the datetimes by EVT_start_date. Then first test on whether the event is published. If its |
|
| 1066 | - * NOT published then we test for whether its expired or not. IF it IS published then we test first on whether an |
|
| 1067 | - * event has any active dates. If no active dates then we check for any upcoming dates. If no upcoming dates then |
|
| 1068 | - * the event is considered expired. |
|
| 1069 | - * NOTE: this method does NOT calculate whether the datetimes are sold out when event is published. Sold Out is a |
|
| 1070 | - * status set on the EVENT when it is not published and thus is done |
|
| 1071 | - * |
|
| 1072 | - * @param bool $reset |
|
| 1073 | - * @return bool | string - based on EE_Datetime active constants or FALSE if error. |
|
| 1074 | - */ |
|
| 1075 | - public function get_active_status($reset = false) |
|
| 1076 | - { |
|
| 1077 | - // if the active status has already been set, then just use that value (unless we are resetting it) |
|
| 1078 | - if ( ! empty($this->_active_status) && ! $reset) { |
|
| 1079 | - return $this->_active_status; |
|
| 1080 | - } |
|
| 1081 | - //first check if event id is present on this object |
|
| 1082 | - if ( ! $this->ID()) { |
|
| 1083 | - return false; |
|
| 1084 | - } |
|
| 1085 | - $where_params_for_event = array(array('EVT_ID' => $this->ID())); |
|
| 1086 | - //if event is published: |
|
| 1087 | - if ($this->status() === 'publish') { |
|
| 1088 | - //active? |
|
| 1089 | - if (EEM_Datetime::instance()->get_datetime_count_for_status(EE_Datetime::active, $where_params_for_event) |
|
| 1090 | - > 0 |
|
| 1091 | - ) { |
|
| 1092 | - $this->_active_status = EE_Datetime::active; |
|
| 1093 | - } else { |
|
| 1094 | - //upcoming? |
|
| 1095 | - if (EEM_Datetime::instance() |
|
| 1096 | - ->get_datetime_count_for_status(EE_Datetime::upcoming, $where_params_for_event) > 0 |
|
| 1097 | - ) { |
|
| 1098 | - $this->_active_status = EE_Datetime::upcoming; |
|
| 1099 | - } else { |
|
| 1100 | - //expired? |
|
| 1101 | - if (EEM_Datetime::instance() |
|
| 1102 | - ->get_datetime_count_for_status(EE_Datetime::expired, $where_params_for_event) > 0 |
|
| 1103 | - ) { |
|
| 1104 | - $this->_active_status = EE_Datetime::expired; |
|
| 1105 | - } else { |
|
| 1106 | - //it would be odd if things make it this far because it basically means there are no datetime's |
|
| 1107 | - //attached to the event. So in this case it will just be considered inactive. |
|
| 1108 | - $this->_active_status = EE_Datetime::inactive; |
|
| 1109 | - } |
|
| 1110 | - } |
|
| 1111 | - } |
|
| 1112 | - } else { |
|
| 1113 | - //the event is not published, so let's just set it's active status according to its' post status |
|
| 1114 | - switch ($this->status()) { |
|
| 1115 | - case EEM_Event::sold_out : |
|
| 1116 | - $this->_active_status = EE_Datetime::sold_out; |
|
| 1117 | - break; |
|
| 1118 | - case EEM_Event::cancelled : |
|
| 1119 | - $this->_active_status = EE_Datetime::cancelled; |
|
| 1120 | - break; |
|
| 1121 | - case EEM_Event::postponed : |
|
| 1122 | - $this->_active_status = EE_Datetime::postponed; |
|
| 1123 | - break; |
|
| 1124 | - default : |
|
| 1125 | - $this->_active_status = EE_Datetime::inactive; |
|
| 1126 | - } |
|
| 1127 | - } |
|
| 1128 | - return $this->_active_status; |
|
| 1129 | - } |
|
| 1130 | - |
|
| 1131 | - |
|
| 1132 | - |
|
| 1133 | - /** |
|
| 1134 | - * pretty_active_status |
|
| 1135 | - * |
|
| 1136 | - * @access public |
|
| 1137 | - * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE) |
|
| 1138 | - * @return mixed void|string |
|
| 1139 | - */ |
|
| 1140 | - public function pretty_active_status($echo = true) |
|
| 1141 | - { |
|
| 1142 | - $active_status = $this->get_active_status(); |
|
| 1143 | - $status = '<span class="ee-status event-active-status-' |
|
| 1144 | - . $active_status |
|
| 1145 | - . '">' |
|
| 1146 | - . EEH_Template::pretty_status($active_status, false, 'sentence') |
|
| 1147 | - . '</span>'; |
|
| 1148 | - if ($echo) { |
|
| 1149 | - echo $status; |
|
| 1150 | - return ''; |
|
| 1151 | - } |
|
| 1152 | - return $status; |
|
| 1153 | - } |
|
| 1154 | - |
|
| 1155 | - |
|
| 1156 | - |
|
| 1157 | - /** |
|
| 1158 | - * @return bool|int |
|
| 1159 | - */ |
|
| 1160 | - public function get_number_of_tickets_sold() |
|
| 1161 | - { |
|
| 1162 | - $tkt_sold = 0; |
|
| 1163 | - if ( ! $this->ID()) { |
|
| 1164 | - return 0; |
|
| 1165 | - } |
|
| 1166 | - $datetimes = $this->datetimes(); |
|
| 1167 | - foreach ($datetimes as $datetime) { |
|
| 1168 | - if ($datetime instanceof EE_Datetime) { |
|
| 1169 | - $tkt_sold += $datetime->sold(); |
|
| 1170 | - } |
|
| 1171 | - } |
|
| 1172 | - return $tkt_sold; |
|
| 1173 | - } |
|
| 1174 | - |
|
| 1175 | - |
|
| 1176 | - |
|
| 1177 | - /** |
|
| 1178 | - * This just returns a count of all the registrations for this event |
|
| 1179 | - * |
|
| 1180 | - * @access public |
|
| 1181 | - * @return int |
|
| 1182 | - */ |
|
| 1183 | - public function get_count_of_all_registrations() |
|
| 1184 | - { |
|
| 1185 | - return EEM_Event::instance()->count_related($this, 'Registration'); |
|
| 1186 | - } |
|
| 1187 | - |
|
| 1188 | - |
|
| 1189 | - |
|
| 1190 | - /** |
|
| 1191 | - * This returns the ticket with the earliest start time that is available for this event (across all datetimes |
|
| 1192 | - * attached to the event) |
|
| 1193 | - * |
|
| 1194 | - * @return EE_Ticket |
|
| 1195 | - */ |
|
| 1196 | - public function get_ticket_with_earliest_start_time() |
|
| 1197 | - { |
|
| 1198 | - $where['Datetime.EVT_ID'] = $this->ID(); |
|
| 1199 | - $query_params = array($where, 'order_by' => array('TKT_start_date' => 'ASC')); |
|
| 1200 | - return EE_Registry::instance()->load_model('Ticket')->get_one($query_params); |
|
| 1201 | - } |
|
| 1202 | - |
|
| 1203 | - |
|
| 1204 | - |
|
| 1205 | - /** |
|
| 1206 | - * This returns the ticket with the latest end time that is available for this event (across all datetimes attached |
|
| 1207 | - * to the event) |
|
| 1208 | - * |
|
| 1209 | - * @return EE_Ticket |
|
| 1210 | - */ |
|
| 1211 | - public function get_ticket_with_latest_end_time() |
|
| 1212 | - { |
|
| 1213 | - $where['Datetime.EVT_ID'] = $this->ID(); |
|
| 1214 | - $query_params = array($where, 'order_by' => array('TKT_end_date' => 'DESC')); |
|
| 1215 | - return EE_Registry::instance()->load_model('Ticket')->get_one($query_params); |
|
| 1216 | - } |
|
| 1217 | - |
|
| 1218 | - |
|
| 1219 | - |
|
| 1220 | - /** |
|
| 1221 | - * This returns whether there are any tickets on sale for this event. |
|
| 1222 | - * |
|
| 1223 | - * @return bool true = YES tickets on sale. |
|
| 1224 | - */ |
|
| 1225 | - public function tickets_on_sale() |
|
| 1226 | - { |
|
| 1227 | - $earliest_ticket = $this->get_ticket_with_earliest_start_time(); |
|
| 1228 | - $latest_ticket = $this->get_ticket_with_latest_end_time(); |
|
| 1229 | - if ( ! $latest_ticket instanceof EE_Ticket && ! $earliest_ticket instanceof EE_Ticket) { |
|
| 1230 | - return false; |
|
| 1231 | - } |
|
| 1232 | - //check on sale for these two tickets. |
|
| 1233 | - if ($latest_ticket->is_on_sale() || $earliest_ticket->is_on_sale()) { |
|
| 1234 | - return true; |
|
| 1235 | - } |
|
| 1236 | - return false; |
|
| 1237 | - } |
|
| 1238 | - |
|
| 1239 | - |
|
| 1240 | - |
|
| 1241 | - /** |
|
| 1242 | - * Gets the URL for viewing this event on the front-end. Overrides parent |
|
| 1243 | - * to check for an external URL first |
|
| 1244 | - * |
|
| 1245 | - * @return string |
|
| 1246 | - */ |
|
| 1247 | - public function get_permalink() |
|
| 1248 | - { |
|
| 1249 | - if ($this->external_url()) { |
|
| 1250 | - return $this->external_url(); |
|
| 1251 | - } else { |
|
| 1252 | - return parent::get_permalink(); |
|
| 1253 | - } |
|
| 1254 | - } |
|
| 1255 | - |
|
| 1256 | - |
|
| 1257 | - |
|
| 1258 | - /** |
|
| 1259 | - * Gets the first term for 'espresso_event_categories' we can find |
|
| 1260 | - * |
|
| 1261 | - * @param array $query_params like EEM_Base::get_all |
|
| 1262 | - * @return EE_Term |
|
| 1263 | - */ |
|
| 1264 | - public function first_event_category($query_params = array()) |
|
| 1265 | - { |
|
| 1266 | - $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
| 1267 | - $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID(); |
|
| 1268 | - return EEM_Term::instance()->get_one($query_params); |
|
| 1269 | - } |
|
| 1270 | - |
|
| 1271 | - |
|
| 1272 | - |
|
| 1273 | - /** |
|
| 1274 | - * Gets all terms for 'espresso_event_categories' we can find |
|
| 1275 | - * |
|
| 1276 | - * @param array $query_params |
|
| 1277 | - * @return EE_Term[] |
|
| 1278 | - */ |
|
| 1279 | - public function get_all_event_categories($query_params = array()) |
|
| 1280 | - { |
|
| 1281 | - $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
| 1282 | - $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID(); |
|
| 1283 | - return EEM_Term::instance()->get_all($query_params); |
|
| 1284 | - } |
|
| 1285 | - |
|
| 1286 | - |
|
| 1287 | - |
|
| 1288 | - /** |
|
| 1289 | - * Gets all the question groups, ordering them by QSG_order ascending |
|
| 1290 | - * |
|
| 1291 | - * @param array $query_params @see EEM_Base::get_all |
|
| 1292 | - * @return EE_Question_Group[] |
|
| 1293 | - */ |
|
| 1294 | - public function question_groups($query_params = array()) |
|
| 1295 | - { |
|
| 1296 | - $query_params = ! empty($query_params) ? $query_params : array('order_by' => array('QSG_order' => 'ASC')); |
|
| 1297 | - return $this->get_many_related('Question_Group', $query_params); |
|
| 1298 | - } |
|
| 1299 | - |
|
| 1300 | - |
|
| 1301 | - |
|
| 1302 | - /** |
|
| 1303 | - * Implementation for EEI_Has_Icon interface method. |
|
| 1304 | - * |
|
| 1305 | - * @see EEI_Visual_Representation for comments |
|
| 1306 | - * @return string |
|
| 1307 | - */ |
|
| 1308 | - public function get_icon() |
|
| 1309 | - { |
|
| 1310 | - return '<span class="dashicons dashicons-flag"></span>'; |
|
| 1311 | - } |
|
| 1312 | - |
|
| 1313 | - |
|
| 1314 | - |
|
| 1315 | - /** |
|
| 1316 | - * Implementation for EEI_Admin_Links interface method. |
|
| 1317 | - * |
|
| 1318 | - * @see EEI_Admin_Links for comments |
|
| 1319 | - * @return string |
|
| 1320 | - */ |
|
| 1321 | - public function get_admin_details_link() |
|
| 1322 | - { |
|
| 1323 | - return $this->get_admin_edit_link(); |
|
| 1324 | - } |
|
| 1325 | - |
|
| 1326 | - |
|
| 1327 | - |
|
| 1328 | - /** |
|
| 1329 | - * Implementation for EEI_Admin_Links interface method. |
|
| 1330 | - * |
|
| 1331 | - * @see EEI_Admin_Links for comments |
|
| 1332 | - * @return string |
|
| 1333 | - */ |
|
| 1334 | - public function get_admin_edit_link() |
|
| 1335 | - { |
|
| 1336 | - return EEH_URL::add_query_args_and_nonce(array( |
|
| 1337 | - 'page' => 'espresso_events', |
|
| 1338 | - 'action' => 'edit', |
|
| 1339 | - 'post' => $this->ID(), |
|
| 1340 | - ), |
|
| 1341 | - admin_url('admin.php') |
|
| 1342 | - ); |
|
| 1343 | - } |
|
| 1344 | - |
|
| 1345 | - |
|
| 1346 | - |
|
| 1347 | - /** |
|
| 1348 | - * Implementation for EEI_Admin_Links interface method. |
|
| 1349 | - * |
|
| 1350 | - * @see EEI_Admin_Links for comments |
|
| 1351 | - * @return string |
|
| 1352 | - */ |
|
| 1353 | - public function get_admin_settings_link() |
|
| 1354 | - { |
|
| 1355 | - return EEH_URL::add_query_args_and_nonce(array( |
|
| 1356 | - 'page' => 'espresso_events', |
|
| 1357 | - 'action' => 'default_event_settings', |
|
| 1358 | - ), |
|
| 1359 | - admin_url('admin.php') |
|
| 1360 | - ); |
|
| 1361 | - } |
|
| 1362 | - |
|
| 1363 | - |
|
| 1364 | - |
|
| 1365 | - /** |
|
| 1366 | - * Implementation for EEI_Admin_Links interface method. |
|
| 1367 | - * |
|
| 1368 | - * @see EEI_Admin_Links for comments |
|
| 1369 | - * @return string |
|
| 1370 | - */ |
|
| 1371 | - public function get_admin_overview_link() |
|
| 1372 | - { |
|
| 1373 | - return EEH_URL::add_query_args_and_nonce(array( |
|
| 1374 | - 'page' => 'espresso_events', |
|
| 1375 | - 'action' => 'default' |
|
| 1376 | - ), |
|
| 1377 | - admin_url('admin.php') |
|
| 1378 | - ); |
|
| 1379 | - } |
|
| 608 | + |
|
| 609 | + /** |
|
| 610 | + * @param $default_registration_status |
|
| 611 | + */ |
|
| 612 | + public function set_default_registration_status($default_registration_status) |
|
| 613 | + { |
|
| 614 | + $this->set('EVT_default_registration_status', $default_registration_status); |
|
| 615 | + } |
|
| 616 | + |
|
| 617 | + |
|
| 618 | + |
|
| 619 | + /** |
|
| 620 | + * @param $donations |
|
| 621 | + */ |
|
| 622 | + public function set_donations($donations) |
|
| 623 | + { |
|
| 624 | + $this->set('EVT_donations', $donations); |
|
| 625 | + } |
|
| 626 | + |
|
| 627 | + |
|
| 628 | + |
|
| 629 | + /** |
|
| 630 | + * Adds a venue to this event |
|
| 631 | + * |
|
| 632 | + * @param EE_Venue /int $venue_id_or_obj |
|
| 633 | + * @return EE_Venue |
|
| 634 | + */ |
|
| 635 | + public function add_venue($venue_id_or_obj) |
|
| 636 | + { |
|
| 637 | + return $this->_add_relation_to($venue_id_or_obj, 'Venue'); |
|
| 638 | + } |
|
| 639 | + |
|
| 640 | + |
|
| 641 | + |
|
| 642 | + /** |
|
| 643 | + * Removes a venue from the event |
|
| 644 | + * |
|
| 645 | + * @param EE_Venue /int $venue_id_or_obj |
|
| 646 | + * @return EE_Venue |
|
| 647 | + */ |
|
| 648 | + public function remove_venue($venue_id_or_obj) |
|
| 649 | + { |
|
| 650 | + return $this->_remove_relation_to($venue_id_or_obj, 'Venue'); |
|
| 651 | + } |
|
| 652 | + |
|
| 653 | + |
|
| 654 | + |
|
| 655 | + /** |
|
| 656 | + * Gets all the venues related ot the event. May provide additional $query_params if desired |
|
| 657 | + * |
|
| 658 | + * @param array $query_params like EEM_Base::get_all's $query_params |
|
| 659 | + * @return EE_Venue[] |
|
| 660 | + */ |
|
| 661 | + public function venues($query_params = array()) |
|
| 662 | + { |
|
| 663 | + return $this->get_many_related('Venue', $query_params); |
|
| 664 | + } |
|
| 665 | + |
|
| 666 | + |
|
| 667 | + |
|
| 668 | + /** |
|
| 669 | + * check if event id is present and if event is published |
|
| 670 | + * |
|
| 671 | + * @access public |
|
| 672 | + * @return boolean true yes, false no |
|
| 673 | + */ |
|
| 674 | + private function _has_ID_and_is_published() |
|
| 675 | + { |
|
| 676 | + // first check if event id is present and not NULL, then check if this event is published (or any of the equivalent "published" statuses) |
|
| 677 | + return ($this->ID() && $this->ID() !== null |
|
| 678 | + && ($this->status() == 'publish' |
|
| 679 | + || $this->status() |
|
| 680 | + == EEM_Event::sold_out |
|
| 681 | + || $this->status() == EEM_Event::postponed |
|
| 682 | + || $this->status() == EEM_Event::cancelled)) ? true : false; |
|
| 683 | + } |
|
| 684 | + |
|
| 685 | + |
|
| 686 | + |
|
| 687 | + /** |
|
| 688 | + * This simply compares the internal dates with NOW and determines if the event is upcoming or not. |
|
| 689 | + * |
|
| 690 | + * @access public |
|
| 691 | + * @return boolean true yes, false no |
|
| 692 | + */ |
|
| 693 | + public function is_upcoming() |
|
| 694 | + { |
|
| 695 | + // check if event id is present and if this event is published |
|
| 696 | + if ($this->is_inactive()) { |
|
| 697 | + return false; |
|
| 698 | + } |
|
| 699 | + // set initial value |
|
| 700 | + $upcoming = false; |
|
| 701 | + //next let's get all datetimes and loop through them |
|
| 702 | + $datetimes = $this->datetimes_in_chronological_order(); |
|
| 703 | + foreach ($datetimes as $datetime) { |
|
| 704 | + if ($datetime instanceof EE_Datetime) { |
|
| 705 | + //if this dtt is expired then we continue cause one of the other datetimes might be upcoming. |
|
| 706 | + if ($datetime->is_expired()) { |
|
| 707 | + continue; |
|
| 708 | + } |
|
| 709 | + //if this dtt is active then we return false. |
|
| 710 | + if ($datetime->is_active()) { |
|
| 711 | + return false; |
|
| 712 | + } |
|
| 713 | + //otherwise let's check upcoming status |
|
| 714 | + $upcoming = $datetime->is_upcoming(); |
|
| 715 | + } |
|
| 716 | + } |
|
| 717 | + return $upcoming; |
|
| 718 | + } |
|
| 719 | + |
|
| 720 | + |
|
| 721 | + |
|
| 722 | + /** |
|
| 723 | + * @return bool |
|
| 724 | + */ |
|
| 725 | + public function is_active() |
|
| 726 | + { |
|
| 727 | + // check if event id is present and if this event is published |
|
| 728 | + if ($this->is_inactive()) { |
|
| 729 | + return false; |
|
| 730 | + } |
|
| 731 | + // set initial value |
|
| 732 | + $active = false; |
|
| 733 | + //next let's get all datetimes and loop through them |
|
| 734 | + $datetimes = $this->datetimes_in_chronological_order(); |
|
| 735 | + foreach ($datetimes as $datetime) { |
|
| 736 | + if ($datetime instanceof EE_Datetime) { |
|
| 737 | + //if this dtt is expired then we continue cause one of the other datetimes might be active. |
|
| 738 | + if ($datetime->is_expired()) { |
|
| 739 | + continue; |
|
| 740 | + } |
|
| 741 | + //if this dtt is upcoming then we return false. |
|
| 742 | + if ($datetime->is_upcoming()) { |
|
| 743 | + return false; |
|
| 744 | + } |
|
| 745 | + //otherwise let's check active status |
|
| 746 | + $active = $datetime->is_active(); |
|
| 747 | + } |
|
| 748 | + } |
|
| 749 | + return $active; |
|
| 750 | + } |
|
| 751 | + |
|
| 752 | + |
|
| 753 | + |
|
| 754 | + /** |
|
| 755 | + * @return bool |
|
| 756 | + */ |
|
| 757 | + public function is_expired() |
|
| 758 | + { |
|
| 759 | + // check if event id is present and if this event is published |
|
| 760 | + if ($this->is_inactive()) { |
|
| 761 | + return false; |
|
| 762 | + } |
|
| 763 | + // set initial value |
|
| 764 | + $expired = false; |
|
| 765 | + //first let's get all datetimes and loop through them |
|
| 766 | + $datetimes = $this->datetimes_in_chronological_order(); |
|
| 767 | + foreach ($datetimes as $datetime) { |
|
| 768 | + if ($datetime instanceof EE_Datetime) { |
|
| 769 | + //if this dtt is upcoming or active then we return false. |
|
| 770 | + if ($datetime->is_upcoming() || $datetime->is_active()) { |
|
| 771 | + return false; |
|
| 772 | + } |
|
| 773 | + //otherwise let's check active status |
|
| 774 | + $expired = $datetime->is_expired(); |
|
| 775 | + } |
|
| 776 | + } |
|
| 777 | + return $expired; |
|
| 778 | + } |
|
| 779 | + |
|
| 780 | + |
|
| 781 | + |
|
| 782 | + /** |
|
| 783 | + * @return bool |
|
| 784 | + */ |
|
| 785 | + public function is_inactive() |
|
| 786 | + { |
|
| 787 | + // check if event id is present and if this event is published |
|
| 788 | + if ($this->_has_ID_and_is_published()) { |
|
| 789 | + return false; |
|
| 790 | + } |
|
| 791 | + return true; |
|
| 792 | + } |
|
| 793 | + |
|
| 794 | + |
|
| 795 | + |
|
| 796 | + /** |
|
| 797 | + * perform_sold_out_status_check |
|
| 798 | + * checks all of this events's datetime reg_limit - sold values to determine if ANY datetimes have spaces |
|
| 799 | + * available... if NOT, then the event status will get toggled to 'sold_out' |
|
| 800 | + * |
|
| 801 | + * @access public |
|
| 802 | + * @return bool return the ACTUAL sold out state. |
|
| 803 | + */ |
|
| 804 | + public function perform_sold_out_status_check() |
|
| 805 | + { |
|
| 806 | + // get all unexpired untrashed tickets |
|
| 807 | + $tickets = $this->tickets(array( |
|
| 808 | + array( |
|
| 809 | + 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
|
| 810 | + 'TKT_deleted' => false, |
|
| 811 | + ), |
|
| 812 | + )); |
|
| 813 | + // if all the tickets are just expired, then don't update the event status to sold out |
|
| 814 | + if (empty($tickets)) { |
|
| 815 | + return true; |
|
| 816 | + } |
|
| 817 | + // set initial value |
|
| 818 | + $spaces_remaining = 0; |
|
| 819 | + foreach ($tickets as $ticket) { |
|
| 820 | + if ($ticket instanceof EE_Ticket) { |
|
| 821 | + $spaces_remaining += $ticket->qty('saleable'); |
|
| 822 | + } |
|
| 823 | + } |
|
| 824 | + if ($spaces_remaining === 0) { |
|
| 825 | + $this->set_status(EEM_Event::sold_out); |
|
| 826 | + if ( ! is_admin() || (is_admin() && defined('DOING_AJAX'))) { |
|
| 827 | + $this->save(); |
|
| 828 | + } |
|
| 829 | + $sold_out = true; |
|
| 830 | + } else { |
|
| 831 | + $sold_out = false; |
|
| 832 | + // was event previously marked as sold out ? |
|
| 833 | + if ($this->status() == EEM_Event::sold_out) { |
|
| 834 | + // revert status to previous value, if it was set |
|
| 835 | + $previous_event_status = $this->get_post_meta('_previous_event_status', true); |
|
| 836 | + if ($previous_event_status) { |
|
| 837 | + $this->set_status($previous_event_status); |
|
| 838 | + } |
|
| 839 | + } |
|
| 840 | + } |
|
| 841 | + //note: I considered changing the EEM_Event status away from sold_out if this status check reveals that it's no longer sold out (yet the status is still set as sold out) but the problem is... what do we change the status BACK to? We can't always assume that the previous event status was 'published' because this status check is always done in the admin and its entirely possible the event admin manually changes to sold_out status from some other status. We also don't want a draft event to become a "publish event" because the sold out check reveals its NOT sold out. |
|
| 842 | + // So I'll forgo the automatic switch away from sold out status for now and instead just return the $sold out status... so this check can be used to validate the TRUE sold out status regardless of what the Event status is set to. |
|
| 843 | + return $sold_out; |
|
| 844 | + } |
|
| 845 | + |
|
| 846 | + |
|
| 847 | + |
|
| 848 | + /** |
|
| 849 | + * This returns the total remaining spaces for sale on this event. |
|
| 850 | + * ############################ |
|
| 851 | + * VERY IMPORTANT FOR DEVELOPERS: |
|
| 852 | + * While included here, this method is still being tested internally, so its signature and behaviour COULD change. |
|
| 853 | + * While this comment block is in place, usage is at your own risk and know that it may change in future builds. |
|
| 854 | + * ############################ |
|
| 855 | + * |
|
| 856 | + * @uses EE_Event::total_available_spaces() |
|
| 857 | + * @return float|int (EE_INF is returned as float) |
|
| 858 | + */ |
|
| 859 | + public function spaces_remaining_for_sale() |
|
| 860 | + { |
|
| 861 | + //first get total available spaces including consideration for tickets that have already sold. |
|
| 862 | + $spaces_available = $this->total_available_spaces(true); |
|
| 863 | + //if total available = 0, then exit right away because that means everything is expired. |
|
| 864 | + if ($spaces_available === 0) { |
|
| 865 | + return 0; |
|
| 866 | + } |
|
| 867 | + //subtract total approved registrations from spaces available to get how many are remaining. |
|
| 868 | + $spots_taken = EEM_Registration::instance()->count(array( |
|
| 869 | + array( |
|
| 870 | + 'EVT_ID' => $this->ID(), |
|
| 871 | + 'STS_ID' => EEM_Registration::status_id_approved, |
|
| 872 | + ), |
|
| 873 | + ), 'REG_ID', true); |
|
| 874 | + $spaces_remaining = $spaces_available - $spots_taken; |
|
| 875 | + return $spaces_remaining > 0 ? $spaces_remaining : 0; |
|
| 876 | + } |
|
| 877 | + |
|
| 878 | + |
|
| 879 | + |
|
| 880 | + /** |
|
| 881 | + * This returns the total spaces available for an event while considering all the qtys on the tickets and the reg |
|
| 882 | + * limits on the datetimes attached to this event. |
|
| 883 | + * ############################ |
|
| 884 | + * VERY IMPORTANT FOR DEVELOPERS: |
|
| 885 | + * While included here, this method is still being tested internally, so its signature and behaviour COULD change. |
|
| 886 | + * While this comment block is in place, usage is at your own risk and know that it may change in future builds. |
|
| 887 | + * ############################ |
|
| 888 | + * Note: by "spaces available" we are not returning how many spaces remain. That is a calculation involving using |
|
| 889 | + * the value from this method and subtracting the approved registrations for the event. |
|
| 890 | + * |
|
| 891 | + * @param bool $current_total_available Whether to consider any tickets that have already sold in our |
|
| 892 | + * calculation. If this is false, then we return the most tickets that |
|
| 893 | + * could ever be sold for this event with the datetime and tickets |
|
| 894 | + * setup on the event under optimal selling conditions. Otherwise we |
|
| 895 | + * return a live calculation of spaces available based on tickets |
|
| 896 | + * sold. Depending on setup and stage of sales, this may appear to |
|
| 897 | + * equal remaining tickets. However, the more tickets are sold out, |
|
| 898 | + * the more accurate the "live" total is. |
|
| 899 | + * @return int|float (Note: if EE_INF is returned its considered a float by PHP) |
|
| 900 | + */ |
|
| 901 | + public function total_available_spaces($current_total_available = false) |
|
| 902 | + { |
|
| 903 | + $spaces_available = 0; |
|
| 904 | + //first get all tickets on the event and include expired tickets |
|
| 905 | + $tickets = $this->tickets(array('default_where_conditions' => 'none')); |
|
| 906 | + $ticket_sums = array(); |
|
| 907 | + $datetime_limits = array(); |
|
| 908 | + //loop through tickets and normalize them |
|
| 909 | + foreach ($tickets as $ticket) { |
|
| 910 | + $datetimes = $ticket->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC'))); |
|
| 911 | + if (empty($datetimes)) { |
|
| 912 | + continue; |
|
| 913 | + } |
|
| 914 | + //first datetime should be the lowest datetime |
|
| 915 | + $least_datetime = reset($datetimes); |
|
| 916 | + //lets reset the ticket quantity to be the lower of either the lowest datetime reg limit or the ticket quantity |
|
| 917 | + //IF datetimes sold (and we're not doing current live total available, then use spaces remaining for datetime, not reg_limit. |
|
| 918 | + if ($current_total_available) { |
|
| 919 | + if ($ticket->is_remaining()) { |
|
| 920 | + $remaining = $ticket->remaining(); |
|
| 921 | + } else { |
|
| 922 | + $spaces_available += $ticket->sold(); |
|
| 923 | + //and we don't cache this ticket to our list because its sold out. |
|
| 924 | + continue; |
|
| 925 | + } |
|
| 926 | + } else { |
|
| 927 | + $remaining = min($ticket->qty(), $least_datetime->reg_limit()); |
|
| 928 | + } |
|
| 929 | + //if $ticket_limit == infinity then let's drop out right away and just return that because any infinity amount trumps all other "available" amounts. |
|
| 930 | + if ($remaining === EE_INF) { |
|
| 931 | + return EE_INF; |
|
| 932 | + } |
|
| 933 | + //multiply normalized $tkt quantity by the number of datetimes on the ticket as the "sum" |
|
| 934 | + //also include the sum of all the datetime reg limits on the ticket for breaking ties. |
|
| 935 | + $ticket_sums[$ticket->ID()]['sum'] = $remaining * count($datetimes); |
|
| 936 | + $ticket_sums[$ticket->ID()]['datetime_sums'] = 0; |
|
| 937 | + foreach ($datetimes as $datetime) { |
|
| 938 | + if ($datetime->reg_limit() === EE_INF) { |
|
| 939 | + $ticket_sums[$ticket->ID()]['datetime_sums'] = EE_INF; |
|
| 940 | + } else { |
|
| 941 | + $ticket_sums[$ticket->ID()]['datetime_sums'] += $current_total_available |
|
| 942 | + ? $datetime->spaces_remaining() : $datetime->reg_limit(); |
|
| 943 | + } |
|
| 944 | + $datetime_limits[$datetime->ID()] = $current_total_available ? $datetime->spaces_remaining() |
|
| 945 | + : $datetime->reg_limit(); |
|
| 946 | + } |
|
| 947 | + $ticket_sums[$ticket->ID()]['ticket'] = $ticket; |
|
| 948 | + } |
|
| 949 | + //The order is sorted by lowest available first (which is calculated for each ticket by multiplying the normalized |
|
| 950 | + //ticket quantity by the number of datetimes on the ticket). For tie-breakers, then the next sort is based on the |
|
| 951 | + //ticket with the greatest sum of all remaining datetime->spaces_remaining() ( or $datetime->reg_limit() if not |
|
| 952 | + //$current_total_available ) for the datetimes on the ticket. |
|
| 953 | + usort($ticket_sums, function ($a, $b) { |
|
| 954 | + if ($a['sum'] == $b['sum']) { |
|
| 955 | + if ($a['datetime_sums'] == $b['datetime_sums']) { |
|
| 956 | + return 0; |
|
| 957 | + } |
|
| 958 | + return $a['datetime_sums'] < $b['datetime_sums'] ? 1 : -1; |
|
| 959 | + } |
|
| 960 | + return ($a['sum'] < $b['sum']) ? -1 : 1; |
|
| 961 | + }); |
|
| 962 | + //now let's loop through the sorted tickets and simulate sellouts |
|
| 963 | + foreach ($ticket_sums as $ticket_info) { |
|
| 964 | + if ($ticket_info['ticket'] instanceof EE_Ticket) { |
|
| 965 | + $datetimes = $ticket_info['ticket']->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC'))); |
|
| 966 | + //need to sort these $datetimes by remaining (only if $current_total_available) |
|
| 967 | + //setup datetimes for simulation |
|
| 968 | + $ticket_datetimes_remaining = array(); |
|
| 969 | + foreach ($datetimes as $datetime) { |
|
| 970 | + $ticket_datetimes_remaining[$datetime->ID()]['rem'] = $datetime_limits[$datetime->ID()]; |
|
| 971 | + $ticket_datetimes_remaining[$datetime->ID()]['datetime'] = $datetime; |
|
| 972 | + } |
|
| 973 | + usort($ticket_datetimes_remaining, function ($a, $b) { |
|
| 974 | + if ($a['rem'] == $b['rem']) { |
|
| 975 | + return 0; |
|
| 976 | + } |
|
| 977 | + return ($a['rem'] < $b['rem']) ? -1 : 1; |
|
| 978 | + }); |
|
| 979 | + //get the remaining on the first datetime (which should be the one with the least remaining) and that is |
|
| 980 | + //what we add to the spaces_available running total. Then we need to decrease the remaining on our datetime tracker. |
|
| 981 | + $lowest_datetime = reset($ticket_datetimes_remaining); |
|
| 982 | + //need to get the lower of; what the remaining is on the lowest datetime, and the remaining on the ticket. |
|
| 983 | + // If this ends up being 0 (because of previous tickets in our simulation selling out), then it has already |
|
| 984 | + // been tracked on $spaces available and this ticket is now sold out for the simulation, so we can continue |
|
| 985 | + // to the next ticket. |
|
| 986 | + if ($current_total_available) { |
|
| 987 | + $remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->remaining()); |
|
| 988 | + } else { |
|
| 989 | + $remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->qty()); |
|
| 990 | + } |
|
| 991 | + //if $remaining is infinite that means that all datetimes on this ticket are infinite but we've made it here because all |
|
| 992 | + //tickets have a quantity. So we don't have to track datetimes, we can just use ticket quantities for total |
|
| 993 | + //available. |
|
| 994 | + if ($remaining === EE_INF) { |
|
| 995 | + $spaces_available += $ticket_info['ticket']->qty(); |
|
| 996 | + continue; |
|
| 997 | + } |
|
| 998 | + //if ticket has sold amounts then we also need to add that (but only if doing live counts) |
|
| 999 | + if ($current_total_available) { |
|
| 1000 | + $spaces_available += $ticket_info['ticket']->sold(); |
|
| 1001 | + } |
|
| 1002 | + if ($remaining <= 0) { |
|
| 1003 | + continue; |
|
| 1004 | + } else { |
|
| 1005 | + $spaces_available += $remaining; |
|
| 1006 | + } |
|
| 1007 | + //loop through the datetimes and sell them out! |
|
| 1008 | + foreach ($ticket_datetimes_remaining as $datetime_info) { |
|
| 1009 | + if ($datetime_info['datetime'] instanceof EE_Datetime) { |
|
| 1010 | + $datetime_limits[$datetime_info['datetime']->ID()] += -$remaining; |
|
| 1011 | + } |
|
| 1012 | + } |
|
| 1013 | + } |
|
| 1014 | + } |
|
| 1015 | + return $spaces_available; |
|
| 1016 | + } |
|
| 1017 | + |
|
| 1018 | + |
|
| 1019 | + |
|
| 1020 | + /** |
|
| 1021 | + * Checks if the event is set to sold out |
|
| 1022 | + * |
|
| 1023 | + * @param bool $actual whether or not to perform calculations to not only figure the actual status but also to |
|
| 1024 | + * flip the status if necessary to sold out If false, we just check the existing status of the |
|
| 1025 | + * event |
|
| 1026 | + * @return boolean |
|
| 1027 | + */ |
|
| 1028 | + public function is_sold_out($actual = false) |
|
| 1029 | + { |
|
| 1030 | + if ( ! $actual) { |
|
| 1031 | + return $this->status() == EEM_Event::sold_out; |
|
| 1032 | + } else { |
|
| 1033 | + return $this->perform_sold_out_status_check(); |
|
| 1034 | + } |
|
| 1035 | + } |
|
| 1036 | + |
|
| 1037 | + |
|
| 1038 | + |
|
| 1039 | + /** |
|
| 1040 | + * Checks if the event is marked as postponed |
|
| 1041 | + * |
|
| 1042 | + * @return boolean |
|
| 1043 | + */ |
|
| 1044 | + public function is_postponed() |
|
| 1045 | + { |
|
| 1046 | + return $this->status() == EEM_Event::postponed; |
|
| 1047 | + } |
|
| 1048 | + |
|
| 1049 | + |
|
| 1050 | + |
|
| 1051 | + /** |
|
| 1052 | + * Checks if the event is marked as cancelled |
|
| 1053 | + * |
|
| 1054 | + * @return boolean |
|
| 1055 | + */ |
|
| 1056 | + public function is_cancelled() |
|
| 1057 | + { |
|
| 1058 | + return $this->status() == EEM_Event::cancelled; |
|
| 1059 | + } |
|
| 1060 | + |
|
| 1061 | + |
|
| 1062 | + |
|
| 1063 | + /** |
|
| 1064 | + * Get the logical active status in a hierarchical order for all the datetimes. Note |
|
| 1065 | + * Basically, we order the datetimes by EVT_start_date. Then first test on whether the event is published. If its |
|
| 1066 | + * NOT published then we test for whether its expired or not. IF it IS published then we test first on whether an |
|
| 1067 | + * event has any active dates. If no active dates then we check for any upcoming dates. If no upcoming dates then |
|
| 1068 | + * the event is considered expired. |
|
| 1069 | + * NOTE: this method does NOT calculate whether the datetimes are sold out when event is published. Sold Out is a |
|
| 1070 | + * status set on the EVENT when it is not published and thus is done |
|
| 1071 | + * |
|
| 1072 | + * @param bool $reset |
|
| 1073 | + * @return bool | string - based on EE_Datetime active constants or FALSE if error. |
|
| 1074 | + */ |
|
| 1075 | + public function get_active_status($reset = false) |
|
| 1076 | + { |
|
| 1077 | + // if the active status has already been set, then just use that value (unless we are resetting it) |
|
| 1078 | + if ( ! empty($this->_active_status) && ! $reset) { |
|
| 1079 | + return $this->_active_status; |
|
| 1080 | + } |
|
| 1081 | + //first check if event id is present on this object |
|
| 1082 | + if ( ! $this->ID()) { |
|
| 1083 | + return false; |
|
| 1084 | + } |
|
| 1085 | + $where_params_for_event = array(array('EVT_ID' => $this->ID())); |
|
| 1086 | + //if event is published: |
|
| 1087 | + if ($this->status() === 'publish') { |
|
| 1088 | + //active? |
|
| 1089 | + if (EEM_Datetime::instance()->get_datetime_count_for_status(EE_Datetime::active, $where_params_for_event) |
|
| 1090 | + > 0 |
|
| 1091 | + ) { |
|
| 1092 | + $this->_active_status = EE_Datetime::active; |
|
| 1093 | + } else { |
|
| 1094 | + //upcoming? |
|
| 1095 | + if (EEM_Datetime::instance() |
|
| 1096 | + ->get_datetime_count_for_status(EE_Datetime::upcoming, $where_params_for_event) > 0 |
|
| 1097 | + ) { |
|
| 1098 | + $this->_active_status = EE_Datetime::upcoming; |
|
| 1099 | + } else { |
|
| 1100 | + //expired? |
|
| 1101 | + if (EEM_Datetime::instance() |
|
| 1102 | + ->get_datetime_count_for_status(EE_Datetime::expired, $where_params_for_event) > 0 |
|
| 1103 | + ) { |
|
| 1104 | + $this->_active_status = EE_Datetime::expired; |
|
| 1105 | + } else { |
|
| 1106 | + //it would be odd if things make it this far because it basically means there are no datetime's |
|
| 1107 | + //attached to the event. So in this case it will just be considered inactive. |
|
| 1108 | + $this->_active_status = EE_Datetime::inactive; |
|
| 1109 | + } |
|
| 1110 | + } |
|
| 1111 | + } |
|
| 1112 | + } else { |
|
| 1113 | + //the event is not published, so let's just set it's active status according to its' post status |
|
| 1114 | + switch ($this->status()) { |
|
| 1115 | + case EEM_Event::sold_out : |
|
| 1116 | + $this->_active_status = EE_Datetime::sold_out; |
|
| 1117 | + break; |
|
| 1118 | + case EEM_Event::cancelled : |
|
| 1119 | + $this->_active_status = EE_Datetime::cancelled; |
|
| 1120 | + break; |
|
| 1121 | + case EEM_Event::postponed : |
|
| 1122 | + $this->_active_status = EE_Datetime::postponed; |
|
| 1123 | + break; |
|
| 1124 | + default : |
|
| 1125 | + $this->_active_status = EE_Datetime::inactive; |
|
| 1126 | + } |
|
| 1127 | + } |
|
| 1128 | + return $this->_active_status; |
|
| 1129 | + } |
|
| 1130 | + |
|
| 1131 | + |
|
| 1132 | + |
|
| 1133 | + /** |
|
| 1134 | + * pretty_active_status |
|
| 1135 | + * |
|
| 1136 | + * @access public |
|
| 1137 | + * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE) |
|
| 1138 | + * @return mixed void|string |
|
| 1139 | + */ |
|
| 1140 | + public function pretty_active_status($echo = true) |
|
| 1141 | + { |
|
| 1142 | + $active_status = $this->get_active_status(); |
|
| 1143 | + $status = '<span class="ee-status event-active-status-' |
|
| 1144 | + . $active_status |
|
| 1145 | + . '">' |
|
| 1146 | + . EEH_Template::pretty_status($active_status, false, 'sentence') |
|
| 1147 | + . '</span>'; |
|
| 1148 | + if ($echo) { |
|
| 1149 | + echo $status; |
|
| 1150 | + return ''; |
|
| 1151 | + } |
|
| 1152 | + return $status; |
|
| 1153 | + } |
|
| 1154 | + |
|
| 1155 | + |
|
| 1156 | + |
|
| 1157 | + /** |
|
| 1158 | + * @return bool|int |
|
| 1159 | + */ |
|
| 1160 | + public function get_number_of_tickets_sold() |
|
| 1161 | + { |
|
| 1162 | + $tkt_sold = 0; |
|
| 1163 | + if ( ! $this->ID()) { |
|
| 1164 | + return 0; |
|
| 1165 | + } |
|
| 1166 | + $datetimes = $this->datetimes(); |
|
| 1167 | + foreach ($datetimes as $datetime) { |
|
| 1168 | + if ($datetime instanceof EE_Datetime) { |
|
| 1169 | + $tkt_sold += $datetime->sold(); |
|
| 1170 | + } |
|
| 1171 | + } |
|
| 1172 | + return $tkt_sold; |
|
| 1173 | + } |
|
| 1174 | + |
|
| 1175 | + |
|
| 1176 | + |
|
| 1177 | + /** |
|
| 1178 | + * This just returns a count of all the registrations for this event |
|
| 1179 | + * |
|
| 1180 | + * @access public |
|
| 1181 | + * @return int |
|
| 1182 | + */ |
|
| 1183 | + public function get_count_of_all_registrations() |
|
| 1184 | + { |
|
| 1185 | + return EEM_Event::instance()->count_related($this, 'Registration'); |
|
| 1186 | + } |
|
| 1187 | + |
|
| 1188 | + |
|
| 1189 | + |
|
| 1190 | + /** |
|
| 1191 | + * This returns the ticket with the earliest start time that is available for this event (across all datetimes |
|
| 1192 | + * attached to the event) |
|
| 1193 | + * |
|
| 1194 | + * @return EE_Ticket |
|
| 1195 | + */ |
|
| 1196 | + public function get_ticket_with_earliest_start_time() |
|
| 1197 | + { |
|
| 1198 | + $where['Datetime.EVT_ID'] = $this->ID(); |
|
| 1199 | + $query_params = array($where, 'order_by' => array('TKT_start_date' => 'ASC')); |
|
| 1200 | + return EE_Registry::instance()->load_model('Ticket')->get_one($query_params); |
|
| 1201 | + } |
|
| 1202 | + |
|
| 1203 | + |
|
| 1204 | + |
|
| 1205 | + /** |
|
| 1206 | + * This returns the ticket with the latest end time that is available for this event (across all datetimes attached |
|
| 1207 | + * to the event) |
|
| 1208 | + * |
|
| 1209 | + * @return EE_Ticket |
|
| 1210 | + */ |
|
| 1211 | + public function get_ticket_with_latest_end_time() |
|
| 1212 | + { |
|
| 1213 | + $where['Datetime.EVT_ID'] = $this->ID(); |
|
| 1214 | + $query_params = array($where, 'order_by' => array('TKT_end_date' => 'DESC')); |
|
| 1215 | + return EE_Registry::instance()->load_model('Ticket')->get_one($query_params); |
|
| 1216 | + } |
|
| 1217 | + |
|
| 1218 | + |
|
| 1219 | + |
|
| 1220 | + /** |
|
| 1221 | + * This returns whether there are any tickets on sale for this event. |
|
| 1222 | + * |
|
| 1223 | + * @return bool true = YES tickets on sale. |
|
| 1224 | + */ |
|
| 1225 | + public function tickets_on_sale() |
|
| 1226 | + { |
|
| 1227 | + $earliest_ticket = $this->get_ticket_with_earliest_start_time(); |
|
| 1228 | + $latest_ticket = $this->get_ticket_with_latest_end_time(); |
|
| 1229 | + if ( ! $latest_ticket instanceof EE_Ticket && ! $earliest_ticket instanceof EE_Ticket) { |
|
| 1230 | + return false; |
|
| 1231 | + } |
|
| 1232 | + //check on sale for these two tickets. |
|
| 1233 | + if ($latest_ticket->is_on_sale() || $earliest_ticket->is_on_sale()) { |
|
| 1234 | + return true; |
|
| 1235 | + } |
|
| 1236 | + return false; |
|
| 1237 | + } |
|
| 1238 | + |
|
| 1239 | + |
|
| 1240 | + |
|
| 1241 | + /** |
|
| 1242 | + * Gets the URL for viewing this event on the front-end. Overrides parent |
|
| 1243 | + * to check for an external URL first |
|
| 1244 | + * |
|
| 1245 | + * @return string |
|
| 1246 | + */ |
|
| 1247 | + public function get_permalink() |
|
| 1248 | + { |
|
| 1249 | + if ($this->external_url()) { |
|
| 1250 | + return $this->external_url(); |
|
| 1251 | + } else { |
|
| 1252 | + return parent::get_permalink(); |
|
| 1253 | + } |
|
| 1254 | + } |
|
| 1255 | + |
|
| 1256 | + |
|
| 1257 | + |
|
| 1258 | + /** |
|
| 1259 | + * Gets the first term for 'espresso_event_categories' we can find |
|
| 1260 | + * |
|
| 1261 | + * @param array $query_params like EEM_Base::get_all |
|
| 1262 | + * @return EE_Term |
|
| 1263 | + */ |
|
| 1264 | + public function first_event_category($query_params = array()) |
|
| 1265 | + { |
|
| 1266 | + $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
| 1267 | + $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID(); |
|
| 1268 | + return EEM_Term::instance()->get_one($query_params); |
|
| 1269 | + } |
|
| 1270 | + |
|
| 1271 | + |
|
| 1272 | + |
|
| 1273 | + /** |
|
| 1274 | + * Gets all terms for 'espresso_event_categories' we can find |
|
| 1275 | + * |
|
| 1276 | + * @param array $query_params |
|
| 1277 | + * @return EE_Term[] |
|
| 1278 | + */ |
|
| 1279 | + public function get_all_event_categories($query_params = array()) |
|
| 1280 | + { |
|
| 1281 | + $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
| 1282 | + $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID(); |
|
| 1283 | + return EEM_Term::instance()->get_all($query_params); |
|
| 1284 | + } |
|
| 1285 | + |
|
| 1286 | + |
|
| 1287 | + |
|
| 1288 | + /** |
|
| 1289 | + * Gets all the question groups, ordering them by QSG_order ascending |
|
| 1290 | + * |
|
| 1291 | + * @param array $query_params @see EEM_Base::get_all |
|
| 1292 | + * @return EE_Question_Group[] |
|
| 1293 | + */ |
|
| 1294 | + public function question_groups($query_params = array()) |
|
| 1295 | + { |
|
| 1296 | + $query_params = ! empty($query_params) ? $query_params : array('order_by' => array('QSG_order' => 'ASC')); |
|
| 1297 | + return $this->get_many_related('Question_Group', $query_params); |
|
| 1298 | + } |
|
| 1299 | + |
|
| 1300 | + |
|
| 1301 | + |
|
| 1302 | + /** |
|
| 1303 | + * Implementation for EEI_Has_Icon interface method. |
|
| 1304 | + * |
|
| 1305 | + * @see EEI_Visual_Representation for comments |
|
| 1306 | + * @return string |
|
| 1307 | + */ |
|
| 1308 | + public function get_icon() |
|
| 1309 | + { |
|
| 1310 | + return '<span class="dashicons dashicons-flag"></span>'; |
|
| 1311 | + } |
|
| 1312 | + |
|
| 1313 | + |
|
| 1314 | + |
|
| 1315 | + /** |
|
| 1316 | + * Implementation for EEI_Admin_Links interface method. |
|
| 1317 | + * |
|
| 1318 | + * @see EEI_Admin_Links for comments |
|
| 1319 | + * @return string |
|
| 1320 | + */ |
|
| 1321 | + public function get_admin_details_link() |
|
| 1322 | + { |
|
| 1323 | + return $this->get_admin_edit_link(); |
|
| 1324 | + } |
|
| 1325 | + |
|
| 1326 | + |
|
| 1327 | + |
|
| 1328 | + /** |
|
| 1329 | + * Implementation for EEI_Admin_Links interface method. |
|
| 1330 | + * |
|
| 1331 | + * @see EEI_Admin_Links for comments |
|
| 1332 | + * @return string |
|
| 1333 | + */ |
|
| 1334 | + public function get_admin_edit_link() |
|
| 1335 | + { |
|
| 1336 | + return EEH_URL::add_query_args_and_nonce(array( |
|
| 1337 | + 'page' => 'espresso_events', |
|
| 1338 | + 'action' => 'edit', |
|
| 1339 | + 'post' => $this->ID(), |
|
| 1340 | + ), |
|
| 1341 | + admin_url('admin.php') |
|
| 1342 | + ); |
|
| 1343 | + } |
|
| 1344 | + |
|
| 1345 | + |
|
| 1346 | + |
|
| 1347 | + /** |
|
| 1348 | + * Implementation for EEI_Admin_Links interface method. |
|
| 1349 | + * |
|
| 1350 | + * @see EEI_Admin_Links for comments |
|
| 1351 | + * @return string |
|
| 1352 | + */ |
|
| 1353 | + public function get_admin_settings_link() |
|
| 1354 | + { |
|
| 1355 | + return EEH_URL::add_query_args_and_nonce(array( |
|
| 1356 | + 'page' => 'espresso_events', |
|
| 1357 | + 'action' => 'default_event_settings', |
|
| 1358 | + ), |
|
| 1359 | + admin_url('admin.php') |
|
| 1360 | + ); |
|
| 1361 | + } |
|
| 1362 | + |
|
| 1363 | + |
|
| 1364 | + |
|
| 1365 | + /** |
|
| 1366 | + * Implementation for EEI_Admin_Links interface method. |
|
| 1367 | + * |
|
| 1368 | + * @see EEI_Admin_Links for comments |
|
| 1369 | + * @return string |
|
| 1370 | + */ |
|
| 1371 | + public function get_admin_overview_link() |
|
| 1372 | + { |
|
| 1373 | + return EEH_URL::add_query_args_and_nonce(array( |
|
| 1374 | + 'page' => 'espresso_events', |
|
| 1375 | + 'action' => 'default' |
|
| 1376 | + ), |
|
| 1377 | + admin_url('admin.php') |
|
| 1378 | + ); |
|
| 1379 | + } |
|
| 1380 | 1380 | |
| 1381 | 1381 | } |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | */ |
| 301 | 301 | public function display_ticket_selector() |
| 302 | 302 | { |
| 303 | - return (bool)$this->get('EVT_display_ticket_selector'); |
|
| 303 | + return (bool) $this->get('EVT_display_ticket_selector'); |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | |
@@ -950,7 +950,7 @@ discard block |
||
| 950 | 950 | //ticket quantity by the number of datetimes on the ticket). For tie-breakers, then the next sort is based on the |
| 951 | 951 | //ticket with the greatest sum of all remaining datetime->spaces_remaining() ( or $datetime->reg_limit() if not |
| 952 | 952 | //$current_total_available ) for the datetimes on the ticket. |
| 953 | - usort($ticket_sums, function ($a, $b) { |
|
| 953 | + usort($ticket_sums, function($a, $b) { |
|
| 954 | 954 | if ($a['sum'] == $b['sum']) { |
| 955 | 955 | if ($a['datetime_sums'] == $b['datetime_sums']) { |
| 956 | 956 | return 0; |
@@ -970,7 +970,7 @@ discard block |
||
| 970 | 970 | $ticket_datetimes_remaining[$datetime->ID()]['rem'] = $datetime_limits[$datetime->ID()]; |
| 971 | 971 | $ticket_datetimes_remaining[$datetime->ID()]['datetime'] = $datetime; |
| 972 | 972 | } |
| 973 | - usort($ticket_datetimes_remaining, function ($a, $b) { |
|
| 973 | + usort($ticket_datetimes_remaining, function($a, $b) { |
|
| 974 | 974 | if ($a['rem'] == $b['rem']) { |
| 975 | 975 | return 0; |
| 976 | 976 | } |
@@ -1135,7 +1135,7 @@ |
||
| 1135 | 1135 | * |
| 1136 | 1136 | * @access public |
| 1137 | 1137 | * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE) |
| 1138 | - * @return mixed void|string |
|
| 1138 | + * @return string void|string |
|
| 1139 | 1139 | */ |
| 1140 | 1140 | public function pretty_active_status($echo = true) |
| 1141 | 1141 | { |
@@ -35,9 +35,9 @@ discard block |
||
| 35 | 35 | { |
| 36 | 36 | parent::__construct($routing); |
| 37 | 37 | if ( ! defined('REG_CAF_TEMPLATE_PATH')) { |
| 38 | - define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
| 39 | - define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
| 40 | - define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
| 38 | + define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'registrations/templates/'); |
|
| 39 | + define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'registrations/assets/'); |
|
| 40 | + define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registrations/assets/'); |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | protected function _extend_page_config() |
| 47 | 47 | { |
| 48 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
| 48 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'registrations'; |
|
| 49 | 49 | $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
| 50 | 50 | ? $this->_req_data['_REG_ID'] |
| 51 | 51 | : 0; |
@@ -178,14 +178,14 @@ discard block |
||
| 178 | 178 | //enqueue newsletter js |
| 179 | 179 | wp_enqueue_script( |
| 180 | 180 | 'ee-newsletter-trigger', |
| 181 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
| 181 | + REG_CAF_ASSETS_URL.'ee-newsletter-trigger.js', |
|
| 182 | 182 | array('ee-dialog'), |
| 183 | 183 | EVENT_ESPRESSO_VERSION, |
| 184 | 184 | true |
| 185 | 185 | ); |
| 186 | 186 | wp_enqueue_style( |
| 187 | 187 | 'ee-newsletter-trigger-css', |
| 188 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
| 188 | + REG_CAF_ASSETS_URL.'ee-newsletter-trigger.css', |
|
| 189 | 189 | array(), |
| 190 | 190 | EVENT_ESPRESSO_VERSION |
| 191 | 191 | ); |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | { |
| 205 | 205 | wp_register_script( |
| 206 | 206 | 'ee-reg-reports-js', |
| 207 | - REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
| 207 | + REG_CAF_ASSETS_URL.'ee-registration-admin-reports.js', |
|
| 208 | 208 | array('google-charts'), |
| 209 | 209 | EVENT_ESPRESSO_VERSION, |
| 210 | 210 | true |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | $codes[$field] = implode(', ', array_keys($shortcode_array)); |
| 410 | 410 | } |
| 411 | 411 | $shortcodes = $codes; |
| 412 | - $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
| 412 | + $form_template = REG_CAF_TEMPLATE_PATH.'newsletter-send-form.template.php'; |
|
| 413 | 413 | $form_template_args = array( |
| 414 | 414 | 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
| 415 | 415 | 'form_route' => 'newsletter_selected_send', |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | */ |
| 571 | 571 | protected function _registration_reports() |
| 572 | 572 | { |
| 573 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
| 573 | + $template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php'; |
|
| 574 | 574 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
| 575 | 575 | $template_path, |
| 576 | 576 | $this->_reports_template_data, |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | { |
| 593 | 593 | $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
| 594 | 594 | $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
| 595 | - $results = (array)$results; |
|
| 595 | + $results = (array) $results; |
|
| 596 | 596 | $regs = array(); |
| 597 | 597 | $subtitle = ''; |
| 598 | 598 | if ($results) { |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | $report_column_values = array(); |
| 603 | 603 | foreach ($result as $property_name => $property_value) { |
| 604 | 604 | $property_value = $property_name === 'Registration_REG_date' ? $property_value |
| 605 | - : (int)$property_value; |
|
| 605 | + : (int) $property_value; |
|
| 606 | 606 | $report_column_values[] = $property_value; |
| 607 | 607 | if ($tracker === 0) { |
| 608 | 608 | if ($property_name === 'Registration_REG_date') { |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | array_unshift($regs, $column_titles); |
| 620 | 620 | //setup the date range. |
| 621 | 621 | $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
| 622 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 622 | + $beginning_date = new DateTime("now ".$period, $DateTimeZone); |
|
| 623 | 623 | $ending_date = new DateTime("now", $DateTimeZone); |
| 624 | 624 | $subtitle = sprintf( |
| 625 | 625 | _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
@@ -639,7 +639,7 @@ discard block |
||
| 639 | 639 | '%sThere are currently no registration records in the last month for this report.%s', |
| 640 | 640 | 'event_espresso' |
| 641 | 641 | ), |
| 642 | - '<h2>' . $report_title . '</h2><p>', |
|
| 642 | + '<h2>'.$report_title.'</h2><p>', |
|
| 643 | 643 | '</p>' |
| 644 | 644 | ), |
| 645 | 645 | ); |
@@ -659,7 +659,7 @@ discard block |
||
| 659 | 659 | { |
| 660 | 660 | $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
| 661 | 661 | $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
| 662 | - $results = (array)$results; |
|
| 662 | + $results = (array) $results; |
|
| 663 | 663 | $regs = array(); |
| 664 | 664 | $subtitle = ''; |
| 665 | 665 | if ($results) { |
@@ -672,7 +672,7 @@ discard block |
||
| 672 | 672 | $property_value, |
| 673 | 673 | 4, |
| 674 | 674 | '...' |
| 675 | - ) : (int)$property_value; |
|
| 675 | + ) : (int) $property_value; |
|
| 676 | 676 | $report_column_values[] = $property_value; |
| 677 | 677 | if ($tracker === 0) { |
| 678 | 678 | if ($property_name === 'Registration_Event') { |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | array_unshift($regs, $column_titles); |
| 690 | 690 | //setup the date range. |
| 691 | 691 | $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
| 692 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 692 | + $beginning_date = new DateTime("now ".$period, $DateTimeZone); |
|
| 693 | 693 | $ending_date = new DateTime("now", $DateTimeZone); |
| 694 | 694 | $subtitle = sprintf( |
| 695 | 695 | _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
@@ -709,7 +709,7 @@ discard block |
||
| 709 | 709 | '%sThere are currently no registration records in the last month for this report.%s', |
| 710 | 710 | 'event_espresso' |
| 711 | 711 | ), |
| 712 | - '<h2>' . $report_title . '</h2><p>', |
|
| 712 | + '<h2>'.$report_title.'</h2><p>', |
|
| 713 | 713 | '</p>' |
| 714 | 714 | ), |
| 715 | 715 | ); |
@@ -759,31 +759,31 @@ discard block |
||
| 759 | 759 | $this->_admin_base_url |
| 760 | 760 | ) : ''; |
| 761 | 761 | $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
| 762 | - ? '<h2>' . sprintf( |
|
| 762 | + ? '<h2>'.sprintf( |
|
| 763 | 763 | __("%s's check in records for %s at the event, %s", 'event_espresso'), |
| 764 | 764 | '<span id="checkin-attendee-name">' |
| 765 | 765 | . EEM_Registration::instance() |
| 766 | 766 | ->get_one_by_ID($reg_id) |
| 767 | 767 | ->get_first_related('Attendee') |
| 768 | - ->full_name() . '</span>', |
|
| 769 | - '<span id="checkin-dtt"><a href="' . $go_back_url . '">' |
|
| 768 | + ->full_name().'</span>', |
|
| 769 | + '<span id="checkin-dtt"><a href="'.$go_back_url.'">' |
|
| 770 | 770 | . EEM_Datetime::instance() |
| 771 | 771 | ->get_one_by_ID($dtt_id) |
| 772 | - ->start_date_and_time() . ' - ' |
|
| 772 | + ->start_date_and_time().' - ' |
|
| 773 | 773 | . EEM_Datetime::instance() |
| 774 | 774 | ->get_one_by_ID($dtt_id) |
| 775 | - ->end_date_and_time() . '</a></span>', |
|
| 775 | + ->end_date_and_time().'</a></span>', |
|
| 776 | 776 | '<span id="checkin-event-name">' |
| 777 | 777 | . EEM_Datetime::instance() |
| 778 | 778 | ->get_one_by_ID($dtt_id) |
| 779 | 779 | ->get_first_related('Event') |
| 780 | - ->get('EVT_name') . '</span>' |
|
| 781 | - ) . '</h2>' |
|
| 780 | + ->get('EVT_name').'</span>' |
|
| 781 | + ).'</h2>' |
|
| 782 | 782 | : ''; |
| 783 | 783 | $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
| 784 | - ? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : ''; |
|
| 784 | + ? '<input type="hidden" name="_REGID" value="'.$reg_id.'">' : ''; |
|
| 785 | 785 | $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
| 786 | - ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
| 786 | + ? '<input type="hidden" name="DTT_ID" value="'.$dtt_id.'">' : ''; |
|
| 787 | 787 | $this->display_admin_list_table_page_with_no_sidebar(); |
| 788 | 788 | } |
| 789 | 789 | |
@@ -1024,37 +1024,37 @@ discard block |
||
| 1024 | 1024 | 'desc' => __('View All Check-in Records for this Registrant', 'event_espresso'), |
| 1025 | 1025 | ), |
| 1026 | 1026 | 'approved_status' => array( |
| 1027 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 1027 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved, |
|
| 1028 | 1028 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
| 1029 | 1029 | ), |
| 1030 | 1030 | 'cancelled_status' => array( |
| 1031 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 1031 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled, |
|
| 1032 | 1032 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
| 1033 | 1033 | ), |
| 1034 | 1034 | 'declined_status' => array( |
| 1035 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 1035 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined, |
|
| 1036 | 1036 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
| 1037 | 1037 | ), |
| 1038 | 1038 | 'not_approved' => array( |
| 1039 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 1039 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved, |
|
| 1040 | 1040 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
| 1041 | 1041 | ), |
| 1042 | 1042 | 'pending_status' => array( |
| 1043 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 1043 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment, |
|
| 1044 | 1044 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
| 1045 | 1045 | ), |
| 1046 | 1046 | 'wait_list' => array( |
| 1047 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 1047 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list, |
|
| 1048 | 1048 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
| 1049 | 1049 | ), |
| 1050 | 1050 | ); |
| 1051 | 1051 | $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
| 1052 | 1052 | $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
| 1053 | 1053 | $this->_template_args['before_list_table'] = ! empty($event_id) |
| 1054 | - ? '<h2>' . sprintf( |
|
| 1054 | + ? '<h2>'.sprintf( |
|
| 1055 | 1055 | __('Viewing Registrations for Event: %s', 'event_espresso'), |
| 1056 | 1056 | EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') |
| 1057 | - ) . '</h2>' |
|
| 1057 | + ).'</h2>' |
|
| 1058 | 1058 | : ''; |
| 1059 | 1059 | //need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on the event. |
| 1060 | 1060 | /** @var EE_Event $event */ |
@@ -1073,7 +1073,7 @@ discard block |
||
| 1073 | 1073 | $this->_template_args['before_list_table'] .= ' <span class="drk-grey-text">'; |
| 1074 | 1074 | $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>'; |
| 1075 | 1075 | $this->_template_args['before_list_table'] .= $datetime->name(); |
| 1076 | - $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
| 1076 | + $this->_template_args['before_list_table'] .= ' ( '.$datetime->date_and_time_range().' )'; |
|
| 1077 | 1077 | $this->_template_args['before_list_table'] .= '</span></h2>'; |
| 1078 | 1078 | } |
| 1079 | 1079 | //if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status column |
@@ -1141,11 +1141,11 @@ discard block |
||
| 1141 | 1141 | //normalize some request params that get setup by the parent `get_registrations` method. |
| 1142 | 1142 | $request = $this->_req_data; |
| 1143 | 1143 | $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby; |
| 1144 | - $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
| 1145 | - if($trash){ |
|
| 1144 | + $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
| 1145 | + if ($trash) { |
|
| 1146 | 1146 | $request['status'] = 'trash'; |
| 1147 | 1147 | } |
| 1148 | - $query_params = $this->_get_checkin_query_params_from_request( $request, $per_page, $count ); |
|
| 1148 | + $query_params = $this->_get_checkin_query_params_from_request($request, $per_page, $count); |
|
| 1149 | 1149 | |
| 1150 | 1150 | return $count |
| 1151 | 1151 | ? EEM_Registration::instance()->count($query_params) |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 3 | - exit('NO direct script access allowed'); |
|
| 3 | + exit('NO direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | |
@@ -17,1139 +17,1139 @@ discard block |
||
| 17 | 17 | { |
| 18 | 18 | |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * This is used to hold the reports template data which is setup early in the request. |
|
| 22 | - * |
|
| 23 | - * @type array |
|
| 24 | - */ |
|
| 25 | - protected $_reports_template_data = array(); |
|
| 26 | - |
|
| 27 | - |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Extend_Registrations_Admin_Page constructor. |
|
| 31 | - * |
|
| 32 | - * @param bool $routing |
|
| 33 | - */ |
|
| 34 | - public function __construct($routing = true) |
|
| 35 | - { |
|
| 36 | - parent::__construct($routing); |
|
| 37 | - if ( ! defined('REG_CAF_TEMPLATE_PATH')) { |
|
| 38 | - define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
| 39 | - define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
| 40 | - define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - protected function _extend_page_config() |
|
| 47 | - { |
|
| 48 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
| 49 | - $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
| 50 | - ? $this->_req_data['_REG_ID'] |
|
| 51 | - : 0; |
|
| 52 | - // $att_id = ! empty( $this->_req_data['ATT_ID'] ) ? ! is_array( $this->_req_data['ATT_ID'] ) : 0; |
|
| 53 | - // $att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] ) |
|
| 54 | - // ? $this->_req_data['post'] : $att_id; |
|
| 55 | - $new_page_routes = array( |
|
| 56 | - 'reports' => array( |
|
| 57 | - 'func' => '_registration_reports', |
|
| 58 | - 'capability' => 'ee_read_registrations', |
|
| 59 | - ), |
|
| 60 | - 'registration_checkins' => array( |
|
| 61 | - 'func' => '_registration_checkin_list_table', |
|
| 62 | - 'capability' => 'ee_read_checkins', |
|
| 63 | - ), |
|
| 64 | - 'newsletter_selected_send' => array( |
|
| 65 | - 'func' => '_newsletter_selected_send', |
|
| 66 | - 'noheader' => true, |
|
| 67 | - 'capability' => 'ee_send_message', |
|
| 68 | - ), |
|
| 69 | - 'delete_checkin_rows' => array( |
|
| 70 | - 'func' => '_delete_checkin_rows', |
|
| 71 | - 'noheader' => true, |
|
| 72 | - 'capability' => 'ee_delete_checkins', |
|
| 73 | - ), |
|
| 74 | - 'delete_checkin_row' => array( |
|
| 75 | - 'func' => '_delete_checkin_row', |
|
| 76 | - 'noheader' => true, |
|
| 77 | - 'capability' => 'ee_delete_checkin', |
|
| 78 | - 'obj_id' => $reg_id, |
|
| 79 | - ), |
|
| 80 | - 'toggle_checkin_status' => array( |
|
| 81 | - 'func' => '_toggle_checkin_status', |
|
| 82 | - 'noheader' => true, |
|
| 83 | - 'capability' => 'ee_edit_checkin', |
|
| 84 | - 'obj_id' => $reg_id, |
|
| 85 | - ), |
|
| 86 | - 'event_registrations' => array( |
|
| 87 | - 'func' => '_event_registrations_list_table', |
|
| 88 | - 'capability' => 'ee_read_checkins', |
|
| 89 | - ), |
|
| 90 | - 'registrations_checkin_report' => array( |
|
| 91 | - 'func' => '_registrations_checkin_report', |
|
| 92 | - 'noheader' => true, |
|
| 93 | - 'capability' => 'ee_read_registrations', |
|
| 94 | - ), |
|
| 95 | - ); |
|
| 96 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
| 97 | - $new_page_config = array( |
|
| 98 | - 'reports' => array( |
|
| 99 | - 'nav' => array( |
|
| 100 | - 'label' => __('Reports', 'event_espresso'), |
|
| 101 | - 'order' => 30, |
|
| 102 | - ), |
|
| 103 | - 'help_tabs' => array( |
|
| 104 | - 'registrations_reports_help_tab' => array( |
|
| 105 | - 'title' => __('Registration Reports', 'event_espresso'), |
|
| 106 | - 'filename' => 'registrations_reports', |
|
| 107 | - ), |
|
| 108 | - ), |
|
| 109 | - /*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/ |
|
| 110 | - 'require_nonce' => false, |
|
| 111 | - ), |
|
| 112 | - 'event_registrations' => array( |
|
| 113 | - 'nav' => array( |
|
| 114 | - 'label' => __('Event Check-In', 'event_espresso'), |
|
| 115 | - 'order' => 10, |
|
| 116 | - 'persistent' => true, |
|
| 117 | - ), |
|
| 118 | - 'help_tabs' => array( |
|
| 119 | - 'registrations_event_checkin_help_tab' => array( |
|
| 120 | - 'title' => __('Registrations Event Check-In', 'event_espresso'), |
|
| 121 | - 'filename' => 'registrations_event_checkin', |
|
| 122 | - ), |
|
| 123 | - 'registrations_event_checkin_table_column_headings_help_tab' => array( |
|
| 124 | - 'title' => __('Event Check-In Table Column Headings', 'event_espresso'), |
|
| 125 | - 'filename' => 'registrations_event_checkin_table_column_headings', |
|
| 126 | - ), |
|
| 127 | - 'registrations_event_checkin_filters_help_tab' => array( |
|
| 128 | - 'title' => __('Event Check-In Filters', 'event_espresso'), |
|
| 129 | - 'filename' => 'registrations_event_checkin_filters', |
|
| 130 | - ), |
|
| 131 | - 'registrations_event_checkin_views_help_tab' => array( |
|
| 132 | - 'title' => __('Event Check-In Views', 'event_espresso'), |
|
| 133 | - 'filename' => 'registrations_event_checkin_views', |
|
| 134 | - ), |
|
| 135 | - 'registrations_event_checkin_other_help_tab' => array( |
|
| 136 | - 'title' => __('Event Check-In Other', 'event_espresso'), |
|
| 137 | - 'filename' => 'registrations_event_checkin_other', |
|
| 138 | - ), |
|
| 139 | - ), |
|
| 140 | - 'help_tour' => array('Event_Checkin_Help_Tour'), |
|
| 141 | - 'qtips' => array('Registration_List_Table_Tips'), |
|
| 142 | - 'list_table' => 'EE_Event_Registrations_List_Table', |
|
| 143 | - 'metaboxes' => array(), |
|
| 144 | - 'require_nonce' => false, |
|
| 145 | - ), |
|
| 146 | - 'registration_checkins' => array( |
|
| 147 | - 'nav' => array( |
|
| 148 | - 'label' => __('Check-In Records', 'event_espresso'), |
|
| 149 | - 'order' => 15, |
|
| 150 | - 'persistent' => false, |
|
| 151 | - ), |
|
| 152 | - 'list_table' => 'EE_Registration_CheckIn_List_Table', |
|
| 153 | - //'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ), |
|
| 154 | - 'metaboxes' => array(), |
|
| 155 | - 'require_nonce' => false, |
|
| 156 | - ), |
|
| 157 | - ); |
|
| 158 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
| 159 | - $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
|
| 160 | - $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - |
|
| 164 | - |
|
| 165 | - protected function _ajax_hooks() |
|
| 166 | - { |
|
| 167 | - parent::_ajax_hooks(); |
|
| 168 | - add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - |
|
| 172 | - |
|
| 173 | - public function load_scripts_styles() |
|
| 174 | - { |
|
| 175 | - parent::load_scripts_styles(); |
|
| 176 | - //if newsletter message type is active then let's add filter and load js for it. |
|
| 177 | - if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
| 178 | - //enqueue newsletter js |
|
| 179 | - wp_enqueue_script( |
|
| 180 | - 'ee-newsletter-trigger', |
|
| 181 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
| 182 | - array('ee-dialog'), |
|
| 183 | - EVENT_ESPRESSO_VERSION, |
|
| 184 | - true |
|
| 185 | - ); |
|
| 186 | - wp_enqueue_style( |
|
| 187 | - 'ee-newsletter-trigger-css', |
|
| 188 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
| 189 | - array(), |
|
| 190 | - EVENT_ESPRESSO_VERSION |
|
| 191 | - ); |
|
| 192 | - //hook in buttons for newsletter message type trigger. |
|
| 193 | - add_action( |
|
| 194 | - 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
| 195 | - array($this, 'add_newsletter_action_buttons'), |
|
| 196 | - 10 |
|
| 197 | - ); |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - |
|
| 202 | - |
|
| 203 | - public function load_scripts_styles_reports() |
|
| 204 | - { |
|
| 205 | - wp_register_script( |
|
| 206 | - 'ee-reg-reports-js', |
|
| 207 | - REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
| 208 | - array('google-charts'), |
|
| 209 | - EVENT_ESPRESSO_VERSION, |
|
| 210 | - true |
|
| 211 | - ); |
|
| 212 | - wp_enqueue_script('ee-reg-reports-js'); |
|
| 213 | - $this->_registration_reports_js_setup(); |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - |
|
| 217 | - |
|
| 218 | - protected function _add_screen_options_event_registrations() |
|
| 219 | - { |
|
| 220 | - $this->_per_page_screen_option(); |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - |
|
| 224 | - |
|
| 225 | - protected function _add_screen_options_registration_checkins() |
|
| 226 | - { |
|
| 227 | - $page_title = $this->_admin_page_title; |
|
| 228 | - $this->_admin_page_title = __('Check-In Records', 'event_espresso'); |
|
| 229 | - $this->_per_page_screen_option(); |
|
| 230 | - $this->_admin_page_title = $page_title; |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - |
|
| 234 | - |
|
| 235 | - protected function _set_list_table_views_event_registrations() |
|
| 236 | - { |
|
| 237 | - $this->_views = array( |
|
| 238 | - 'all' => array( |
|
| 239 | - 'slug' => 'all', |
|
| 240 | - 'label' => __('All', 'event_espresso'), |
|
| 241 | - 'count' => 0, |
|
| 242 | - 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
| 243 | - ? array() |
|
| 244 | - : array( |
|
| 245 | - 'toggle_checkin_status' => __('Toggle Check-In', 'event_espresso'), |
|
| 246 | - //'trash_registrations' => __('Trash Registrations', 'event_espresso') |
|
| 247 | - ), |
|
| 248 | - ), |
|
| 249 | - ); |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - |
|
| 253 | - |
|
| 254 | - protected function _set_list_table_views_registration_checkins() |
|
| 255 | - { |
|
| 256 | - $this->_views = array( |
|
| 257 | - 'all' => array( |
|
| 258 | - 'slug' => 'all', |
|
| 259 | - 'label' => __('All', 'event_espresso'), |
|
| 260 | - 'count' => 0, |
|
| 261 | - 'bulk_action' => array('delete_checkin_rows' => __('Delete Check-In Rows', 'event_espresso')), |
|
| 262 | - ), |
|
| 263 | - ); |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - |
|
| 267 | - |
|
| 268 | - /** |
|
| 269 | - * callback for ajax action. |
|
| 270 | - * |
|
| 271 | - * @since 4.3.0 |
|
| 272 | - * @return void (JSON) |
|
| 273 | - * @throws \EE_Error |
|
| 274 | - */ |
|
| 275 | - public function get_newsletter_form_content() |
|
| 276 | - { |
|
| 277 | - //do a nonce check cause we're not coming in from an normal route here. |
|
| 278 | - $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
| 279 | - $this->_req_data['get_newsletter_form_content_nonce'] |
|
| 280 | - ) : ''; |
|
| 281 | - $nonce_ref = 'get_newsletter_form_content_nonce'; |
|
| 282 | - $this->_verify_nonce($nonce, $nonce_ref); |
|
| 283 | - //let's get the mtp for the incoming MTP_ ID |
|
| 284 | - if ( ! isset($this->_req_data['GRP_ID'])) { |
|
| 285 | - EE_Error::add_error( |
|
| 286 | - __( |
|
| 287 | - 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
|
| 288 | - 'event_espresso' |
|
| 289 | - ), |
|
| 290 | - __FILE__, |
|
| 291 | - __FUNCTION__, |
|
| 292 | - __LINE__ |
|
| 293 | - ); |
|
| 294 | - $this->_template_args['success'] = false; |
|
| 295 | - $this->_template_args['error'] = true; |
|
| 296 | - $this->_return_json(); |
|
| 297 | - } |
|
| 298 | - $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
| 299 | - if ( ! $MTPG instanceof EE_Message_Template_Group) { |
|
| 300 | - EE_Error::add_error( |
|
| 301 | - sprintf( |
|
| 302 | - __( |
|
| 303 | - 'The GRP_ID given (%d) does not appear to have a corresponding row in the database.', |
|
| 304 | - 'event_espresso' |
|
| 305 | - ), |
|
| 306 | - $this->_req_data['GRP_ID'] |
|
| 307 | - ), |
|
| 308 | - __FILE__, |
|
| 309 | - __FUNCTION__, |
|
| 310 | - __LINE__ |
|
| 311 | - ); |
|
| 312 | - $this->_template_args['success'] = false; |
|
| 313 | - $this->_template_args['error'] = true; |
|
| 314 | - $this->_return_json(); |
|
| 315 | - } |
|
| 316 | - $MTPs = $MTPG->context_templates(); |
|
| 317 | - $MTPs = $MTPs['attendee']; |
|
| 318 | - $template_fields = array(); |
|
| 319 | - /** @var EE_Message_Template $MTP */ |
|
| 320 | - foreach ($MTPs as $MTP) { |
|
| 321 | - $field = $MTP->get('MTP_template_field'); |
|
| 322 | - if ($field === 'content') { |
|
| 323 | - $content = $MTP->get('MTP_content'); |
|
| 324 | - if ( ! empty($content['newsletter_content'])) { |
|
| 325 | - $template_fields['newsletter_content'] = $content['newsletter_content']; |
|
| 326 | - } |
|
| 327 | - continue; |
|
| 328 | - } |
|
| 329 | - $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content'); |
|
| 330 | - } |
|
| 331 | - $this->_template_args['success'] = true; |
|
| 332 | - $this->_template_args['error'] = false; |
|
| 333 | - $this->_template_args['data'] = array( |
|
| 334 | - 'batch_message_from' => isset($template_fields['from']) |
|
| 335 | - ? $template_fields['from'] |
|
| 336 | - : '', |
|
| 337 | - 'batch_message_subject' => isset($template_fields['subject']) |
|
| 338 | - ? $template_fields['subject'] |
|
| 339 | - : '', |
|
| 340 | - 'batch_message_content' => isset($template_fields['newsletter_content']) |
|
| 341 | - ? $template_fields['newsletter_content'] |
|
| 342 | - : '', |
|
| 343 | - ); |
|
| 344 | - $this->_return_json(); |
|
| 345 | - } |
|
| 346 | - |
|
| 347 | - |
|
| 348 | - |
|
| 349 | - /** |
|
| 350 | - * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
|
| 351 | - * |
|
| 352 | - * @since 4.3.0 |
|
| 353 | - * @param EE_Admin_List_Table $list_table |
|
| 354 | - * @return void |
|
| 355 | - */ |
|
| 356 | - public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
|
| 357 | - { |
|
| 358 | - if ( ! EE_Registry::instance()->CAP->current_user_can( |
|
| 359 | - 'ee_send_message', |
|
| 360 | - 'espresso_registrations_newsletter_selected_send' |
|
| 361 | - ) |
|
| 362 | - ) { |
|
| 363 | - return; |
|
| 364 | - } |
|
| 365 | - $routes_to_add_to = array( |
|
| 366 | - 'contact_list', |
|
| 367 | - 'event_registrations', |
|
| 368 | - 'default', |
|
| 369 | - ); |
|
| 370 | - if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
| 371 | - if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
| 372 | - || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
| 373 | - ) { |
|
| 374 | - echo ''; |
|
| 375 | - } else { |
|
| 376 | - $button_text = sprintf( |
|
| 377 | - __('Send Batch Message (%s selected)', 'event_espresso'), |
|
| 378 | - '<span class="send-selected-newsletter-count">0</span>' |
|
| 379 | - ); |
|
| 380 | - echo '<button id="selected-batch-send-trigger" class="button secondary-button"><span class="dashicons dashicons-email "></span>' |
|
| 381 | - . $button_text |
|
| 382 | - . '</button>'; |
|
| 383 | - add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
| 384 | - } |
|
| 385 | - } |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - |
|
| 389 | - |
|
| 390 | - public function newsletter_send_form_skeleton() |
|
| 391 | - { |
|
| 392 | - $list_table = $this->_list_table_object; |
|
| 393 | - $codes = array(); |
|
| 394 | - //need to templates for the newsletter message type for the template selector. |
|
| 395 | - $values[] = array('text' => __('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
| 396 | - $mtps = EEM_Message_Template_Group::instance()->get_all( |
|
| 397 | - array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email')) |
|
| 398 | - ); |
|
| 399 | - foreach ($mtps as $mtp) { |
|
| 400 | - $name = $mtp->name(); |
|
| 401 | - $values[] = array( |
|
| 402 | - 'text' => empty($name) ? __('Global', 'event_espresso') : $name, |
|
| 403 | - 'id' => $mtp->ID(), |
|
| 404 | - ); |
|
| 405 | - } |
|
| 406 | - //need to get a list of shortcodes that are available for the newsletter message type. |
|
| 407 | - $shortcodes = EEH_MSG_Template::get_shortcodes('newsletter', 'email', array(), 'attendee', false); |
|
| 408 | - foreach ($shortcodes as $field => $shortcode_array) { |
|
| 409 | - $codes[$field] = implode(', ', array_keys($shortcode_array)); |
|
| 410 | - } |
|
| 411 | - $shortcodes = $codes; |
|
| 412 | - $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
| 413 | - $form_template_args = array( |
|
| 414 | - 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
| 415 | - 'form_route' => 'newsletter_selected_send', |
|
| 416 | - 'form_nonce_name' => 'newsletter_selected_send_nonce', |
|
| 417 | - 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
| 418 | - 'redirect_back_to' => $this->_req_action, |
|
| 419 | - 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
| 420 | - 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
| 421 | - 'shortcodes' => $shortcodes, |
|
| 422 | - 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration', |
|
| 423 | - ); |
|
| 424 | - EEH_Template::display_template($form_template, $form_template_args); |
|
| 425 | - } |
|
| 426 | - |
|
| 427 | - |
|
| 428 | - |
|
| 429 | - /** |
|
| 430 | - * Handles sending selected registrations/contacts a newsletter. |
|
| 431 | - * |
|
| 432 | - * @since 4.3.0 |
|
| 433 | - * @return void |
|
| 434 | - * @throws \EE_Error |
|
| 435 | - */ |
|
| 436 | - protected function _newsletter_selected_send() |
|
| 437 | - { |
|
| 438 | - $success = true; |
|
| 439 | - //first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
|
| 440 | - if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
| 441 | - EE_Error::add_error( |
|
| 442 | - __( |
|
| 443 | - 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
|
| 444 | - 'event_espresso' |
|
| 445 | - ), |
|
| 446 | - __FILE__, |
|
| 447 | - __FUNCTION__, |
|
| 448 | - __LINE__ |
|
| 449 | - ); |
|
| 450 | - $success = false; |
|
| 451 | - } |
|
| 452 | - if ($success) { |
|
| 453 | - //update Message template in case there are any changes |
|
| 454 | - $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
|
| 455 | - $this->_req_data['newsletter_mtp_selected'] |
|
| 456 | - ); |
|
| 457 | - $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
|
| 458 | - ? $Message_Template_Group->context_templates() |
|
| 459 | - : array(); |
|
| 460 | - if (empty($Message_Templates)) { |
|
| 461 | - EE_Error::add_error( |
|
| 462 | - __( |
|
| 463 | - 'Unable to retrieve message template fields from the db. Messages not sent.', |
|
| 464 | - 'event_espresso' |
|
| 465 | - ), |
|
| 466 | - __FILE__, |
|
| 467 | - __FUNCTION__, |
|
| 468 | - __LINE__ |
|
| 469 | - ); |
|
| 470 | - } |
|
| 471 | - //let's just update the specific fields |
|
| 472 | - foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
| 473 | - if ($Message_Template instanceof EE_Message_Template) { |
|
| 474 | - $field = $Message_Template->get('MTP_template_field'); |
|
| 475 | - $content = $Message_Template->get('MTP_content'); |
|
| 476 | - $new_content = $content; |
|
| 477 | - switch ($field) { |
|
| 478 | - case 'from' : |
|
| 479 | - $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
| 480 | - ? $this->_req_data['batch_message']['from'] |
|
| 481 | - : $content; |
|
| 482 | - break; |
|
| 483 | - case 'subject' : |
|
| 484 | - $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
| 485 | - ? $this->_req_data['batch_message']['subject'] |
|
| 486 | - : $content; |
|
| 487 | - break; |
|
| 488 | - case 'content' : |
|
| 489 | - $new_content = $content; |
|
| 490 | - $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
| 491 | - ? $this->_req_data['batch_message']['content'] |
|
| 492 | - : $content['newsletter_content']; |
|
| 493 | - break; |
|
| 494 | - default : |
|
| 495 | - //continue the foreach loop, we don't want to set $new_content nor save. |
|
| 496 | - continue 2; |
|
| 497 | - } |
|
| 498 | - $Message_Template->set('MTP_content', $new_content); |
|
| 499 | - $Message_Template->save(); |
|
| 500 | - } |
|
| 501 | - } |
|
| 502 | - //great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
|
| 503 | - $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
| 504 | - ? $this->_req_data['batch_message']['id_type'] |
|
| 505 | - : 'registration'; |
|
| 506 | - //id_type will affect how we assemble the ids. |
|
| 507 | - $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
| 508 | - ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
| 509 | - : array(); |
|
| 510 | - $registrations_used_for_contact_data = array(); |
|
| 511 | - //using switch because eventually we'll have other contexts that will be used for generating messages. |
|
| 512 | - switch ($id_type) { |
|
| 513 | - case 'registration' : |
|
| 514 | - $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
|
| 515 | - array( |
|
| 516 | - array( |
|
| 517 | - 'REG_ID' => array('IN', $ids), |
|
| 518 | - ), |
|
| 519 | - ) |
|
| 520 | - ); |
|
| 521 | - break; |
|
| 522 | - case 'contact' : |
|
| 523 | - $registrations_used_for_contact_data = EEM_Registration::instance() |
|
| 524 | - ->get_latest_registration_for_each_of_given_contacts($ids); |
|
| 525 | - break; |
|
| 526 | - } |
|
| 527 | - do_action( |
|
| 528 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
| 529 | - $registrations_used_for_contact_data, |
|
| 530 | - $Message_Template_Group->ID() |
|
| 531 | - ); |
|
| 532 | - //kept for backward compat, internally we no longer use this action. |
|
| 533 | - //@deprecated 4.8.36.rc.002 |
|
| 534 | - $contacts = $id_type === 'registration' |
|
| 535 | - ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
| 536 | - : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
| 537 | - do_action( |
|
| 538 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
|
| 539 | - $contacts, |
|
| 540 | - $Message_Template_Group->ID() |
|
| 541 | - ); |
|
| 542 | - } |
|
| 543 | - $query_args = array( |
|
| 544 | - 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
| 545 | - ? $this->_req_data['redirect_back_to'] |
|
| 546 | - : 'default', |
|
| 547 | - ); |
|
| 548 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 549 | - } |
|
| 550 | - |
|
| 551 | - |
|
| 552 | - |
|
| 553 | - /** |
|
| 554 | - * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
| 555 | - * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method. |
|
| 556 | - */ |
|
| 557 | - protected function _registration_reports_js_setup() |
|
| 558 | - { |
|
| 559 | - $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report(); |
|
| 560 | - $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report(); |
|
| 561 | - } |
|
| 562 | - |
|
| 563 | - |
|
| 564 | - |
|
| 565 | - /** |
|
| 566 | - * generates Business Reports regarding Registrations |
|
| 567 | - * |
|
| 568 | - * @access protected |
|
| 569 | - * @return void |
|
| 570 | - */ |
|
| 571 | - protected function _registration_reports() |
|
| 572 | - { |
|
| 573 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
| 574 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 575 | - $template_path, |
|
| 576 | - $this->_reports_template_data, |
|
| 577 | - true |
|
| 578 | - ); |
|
| 579 | - // the final template wrapper |
|
| 580 | - $this->display_admin_page_with_no_sidebar(); |
|
| 581 | - } |
|
| 582 | - |
|
| 583 | - |
|
| 584 | - |
|
| 585 | - /** |
|
| 586 | - * Generates Business Report showing total registrations per day. |
|
| 587 | - * |
|
| 588 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
| 589 | - * @return string |
|
| 590 | - */ |
|
| 591 | - private function _registrations_per_day_report($period = '-1 month') |
|
| 592 | - { |
|
| 593 | - $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
|
| 594 | - $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
| 595 | - $results = (array)$results; |
|
| 596 | - $regs = array(); |
|
| 597 | - $subtitle = ''; |
|
| 598 | - if ($results) { |
|
| 599 | - $column_titles = array(); |
|
| 600 | - $tracker = 0; |
|
| 601 | - foreach ($results as $result) { |
|
| 602 | - $report_column_values = array(); |
|
| 603 | - foreach ($result as $property_name => $property_value) { |
|
| 604 | - $property_value = $property_name === 'Registration_REG_date' ? $property_value |
|
| 605 | - : (int)$property_value; |
|
| 606 | - $report_column_values[] = $property_value; |
|
| 607 | - if ($tracker === 0) { |
|
| 608 | - if ($property_name === 'Registration_REG_date') { |
|
| 609 | - $column_titles[] = __('Date (only days with registrations are shown)', 'event_espresso'); |
|
| 610 | - } else { |
|
| 611 | - $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
| 612 | - } |
|
| 613 | - } |
|
| 614 | - } |
|
| 615 | - $tracker++; |
|
| 616 | - $regs[] = $report_column_values; |
|
| 617 | - } |
|
| 618 | - //make sure the column_titles is pushed to the beginning of the array |
|
| 619 | - array_unshift($regs, $column_titles); |
|
| 620 | - //setup the date range. |
|
| 621 | - $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
| 622 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 623 | - $ending_date = new DateTime("now", $DateTimeZone); |
|
| 624 | - $subtitle = sprintf( |
|
| 625 | - _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
| 626 | - $beginning_date->format('Y-m-d'), |
|
| 627 | - $ending_date->format('Y-m-d') |
|
| 628 | - ); |
|
| 629 | - } |
|
| 630 | - $report_title = __('Total Registrations per Day', 'event_espresso'); |
|
| 631 | - $report_params = array( |
|
| 632 | - 'title' => $report_title, |
|
| 633 | - 'subtitle' => $subtitle, |
|
| 634 | - 'id' => $report_ID, |
|
| 635 | - 'regs' => $regs, |
|
| 636 | - 'noResults' => empty($regs), |
|
| 637 | - 'noRegsMsg' => sprintf( |
|
| 638 | - __( |
|
| 639 | - '%sThere are currently no registration records in the last month for this report.%s', |
|
| 640 | - 'event_espresso' |
|
| 641 | - ), |
|
| 642 | - '<h2>' . $report_title . '</h2><p>', |
|
| 643 | - '</p>' |
|
| 644 | - ), |
|
| 645 | - ); |
|
| 646 | - wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
| 647 | - return $report_ID; |
|
| 648 | - } |
|
| 649 | - |
|
| 650 | - |
|
| 651 | - |
|
| 652 | - /** |
|
| 653 | - * Generates Business Report showing total registrations per event. |
|
| 654 | - * |
|
| 655 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
| 656 | - * @return string |
|
| 657 | - */ |
|
| 658 | - private function _registrations_per_event_report($period = '-1 month') |
|
| 659 | - { |
|
| 660 | - $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
|
| 661 | - $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
| 662 | - $results = (array)$results; |
|
| 663 | - $regs = array(); |
|
| 664 | - $subtitle = ''; |
|
| 665 | - if ($results) { |
|
| 666 | - $column_titles = array(); |
|
| 667 | - $tracker = 0; |
|
| 668 | - foreach ($results as $result) { |
|
| 669 | - $report_column_values = array(); |
|
| 670 | - foreach ($result as $property_name => $property_value) { |
|
| 671 | - $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
| 672 | - $property_value, |
|
| 673 | - 4, |
|
| 674 | - '...' |
|
| 675 | - ) : (int)$property_value; |
|
| 676 | - $report_column_values[] = $property_value; |
|
| 677 | - if ($tracker === 0) { |
|
| 678 | - if ($property_name === 'Registration_Event') { |
|
| 679 | - $column_titles[] = __('Event', 'event_espresso'); |
|
| 680 | - } else { |
|
| 681 | - $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
| 682 | - } |
|
| 683 | - } |
|
| 684 | - } |
|
| 685 | - $tracker++; |
|
| 686 | - $regs[] = $report_column_values; |
|
| 687 | - } |
|
| 688 | - //make sure the column_titles is pushed to the beginning of the array |
|
| 689 | - array_unshift($regs, $column_titles); |
|
| 690 | - //setup the date range. |
|
| 691 | - $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
| 692 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 693 | - $ending_date = new DateTime("now", $DateTimeZone); |
|
| 694 | - $subtitle = sprintf( |
|
| 695 | - _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
| 696 | - $beginning_date->format('Y-m-d'), |
|
| 697 | - $ending_date->format('Y-m-d') |
|
| 698 | - ); |
|
| 699 | - } |
|
| 700 | - $report_title = __('Total Registrations per Event', 'event_espresso'); |
|
| 701 | - $report_params = array( |
|
| 702 | - 'title' => $report_title, |
|
| 703 | - 'subtitle' => $subtitle, |
|
| 704 | - 'id' => $report_ID, |
|
| 705 | - 'regs' => $regs, |
|
| 706 | - 'noResults' => empty($regs), |
|
| 707 | - 'noRegsMsg' => sprintf( |
|
| 708 | - __( |
|
| 709 | - '%sThere are currently no registration records in the last month for this report.%s', |
|
| 710 | - 'event_espresso' |
|
| 711 | - ), |
|
| 712 | - '<h2>' . $report_title . '</h2><p>', |
|
| 713 | - '</p>' |
|
| 714 | - ), |
|
| 715 | - ); |
|
| 716 | - wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
| 717 | - return $report_ID; |
|
| 718 | - } |
|
| 719 | - |
|
| 720 | - |
|
| 721 | - |
|
| 722 | - /** |
|
| 723 | - * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
|
| 724 | - * |
|
| 725 | - * @access protected |
|
| 726 | - * @return void |
|
| 727 | - * @throws \EE_Error |
|
| 728 | - */ |
|
| 729 | - protected function _registration_checkin_list_table() |
|
| 730 | - { |
|
| 731 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 732 | - $reg_id = isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : null; |
|
| 733 | - /** @var EE_Registration $reg */ |
|
| 734 | - $reg = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
| 735 | - $this->_admin_page_title .= $this->get_action_link_or_button( |
|
| 736 | - 'new_registration', |
|
| 737 | - 'add-registrant', |
|
| 738 | - array('event_id' => $reg->event_ID()), |
|
| 739 | - 'add-new-h2' |
|
| 740 | - ); |
|
| 741 | - $legend_items = array( |
|
| 742 | - 'checkin' => array( |
|
| 743 | - 'class' => 'ee-icon ee-icon-check-in', |
|
| 744 | - 'desc' => __('This indicates the attendee has been checked in', 'event_espresso'), |
|
| 745 | - ), |
|
| 746 | - 'checkout' => array( |
|
| 747 | - 'class' => 'ee-icon ee-icon-check-out', |
|
| 748 | - 'desc' => __('This indicates the attendee has been checked out', 'event_espresso'), |
|
| 749 | - ), |
|
| 750 | - ); |
|
| 751 | - $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
| 752 | - $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
| 753 | - $go_back_url = ! empty($reg_id) ? EE_Admin_Page::add_query_args_and_nonce( |
|
| 754 | - array( |
|
| 755 | - 'action' => 'event_registrations', |
|
| 756 | - 'event_id' => EEM_Registration::instance()->get_one_by_ID($reg_id)->get_first_related('Event')->ID(), |
|
| 757 | - 'DTT_ID' => $dtt_id, |
|
| 758 | - ), |
|
| 759 | - $this->_admin_base_url |
|
| 760 | - ) : ''; |
|
| 761 | - $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
|
| 762 | - ? '<h2>' . sprintf( |
|
| 763 | - __("%s's check in records for %s at the event, %s", 'event_espresso'), |
|
| 764 | - '<span id="checkin-attendee-name">' |
|
| 765 | - . EEM_Registration::instance() |
|
| 766 | - ->get_one_by_ID($reg_id) |
|
| 767 | - ->get_first_related('Attendee') |
|
| 768 | - ->full_name() . '</span>', |
|
| 769 | - '<span id="checkin-dtt"><a href="' . $go_back_url . '">' |
|
| 770 | - . EEM_Datetime::instance() |
|
| 771 | - ->get_one_by_ID($dtt_id) |
|
| 772 | - ->start_date_and_time() . ' - ' |
|
| 773 | - . EEM_Datetime::instance() |
|
| 774 | - ->get_one_by_ID($dtt_id) |
|
| 775 | - ->end_date_and_time() . '</a></span>', |
|
| 776 | - '<span id="checkin-event-name">' |
|
| 777 | - . EEM_Datetime::instance() |
|
| 778 | - ->get_one_by_ID($dtt_id) |
|
| 779 | - ->get_first_related('Event') |
|
| 780 | - ->get('EVT_name') . '</span>' |
|
| 781 | - ) . '</h2>' |
|
| 782 | - : ''; |
|
| 783 | - $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
|
| 784 | - ? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : ''; |
|
| 785 | - $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
|
| 786 | - ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
| 787 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 788 | - } |
|
| 789 | - |
|
| 790 | - |
|
| 791 | - |
|
| 792 | - /** |
|
| 793 | - * toggle the Check-in status for the given registration (coming from ajax) |
|
| 794 | - * |
|
| 795 | - * @return void (JSON) |
|
| 796 | - */ |
|
| 797 | - public function toggle_checkin_status() |
|
| 798 | - { |
|
| 799 | - //first make sure we have the necessary data |
|
| 800 | - if ( ! isset($this->_req_data['_regid'])) { |
|
| 801 | - EE_Error::add_error( |
|
| 802 | - __( |
|
| 803 | - 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
|
| 804 | - 'event_espresso' |
|
| 805 | - ), |
|
| 806 | - __FILE__, |
|
| 807 | - __FUNCTION__, |
|
| 808 | - __LINE__ |
|
| 809 | - ); |
|
| 810 | - $this->_template_args['success'] = false; |
|
| 811 | - $this->_template_args['error'] = true; |
|
| 812 | - $this->_return_json(); |
|
| 813 | - }; |
|
| 814 | - //do a nonce check cause we're not coming in from an normal route here. |
|
| 815 | - $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
| 816 | - : ''; |
|
| 817 | - $nonce_ref = 'checkin_nonce'; |
|
| 818 | - $this->_verify_nonce($nonce, $nonce_ref); |
|
| 819 | - //beautiful! Made it this far so let's get the status. |
|
| 820 | - $new_status = $this->_toggle_checkin_status(); |
|
| 821 | - //setup new class to return via ajax |
|
| 822 | - $this->_template_args['admin_page_content'] = 'clickable trigger-checkin checkin-icons checkedin-status-' |
|
| 823 | - . $new_status; |
|
| 824 | - $this->_template_args['success'] = true; |
|
| 825 | - $this->_return_json(); |
|
| 826 | - } |
|
| 827 | - |
|
| 828 | - |
|
| 829 | - |
|
| 830 | - /** |
|
| 831 | - * handles toggling the checkin status for the registration, |
|
| 832 | - * |
|
| 833 | - * @access protected |
|
| 834 | - * @return int|void |
|
| 835 | - */ |
|
| 836 | - protected function _toggle_checkin_status() |
|
| 837 | - { |
|
| 838 | - //first let's get the query args out of the way for the redirect |
|
| 839 | - $query_args = array( |
|
| 840 | - 'action' => 'event_registrations', |
|
| 841 | - 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
| 842 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null, |
|
| 843 | - ); |
|
| 844 | - $new_status = false; |
|
| 845 | - // bulk action check in toggle |
|
| 846 | - if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 847 | - // cycle thru checkboxes |
|
| 848 | - while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 849 | - $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
| 850 | - $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
| 851 | - } |
|
| 852 | - } elseif (isset($this->_req_data['_regid'])) { |
|
| 853 | - //coming from ajax request |
|
| 854 | - $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null; |
|
| 855 | - $query_args['DTT_ID'] = $DTT_ID; |
|
| 856 | - $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
| 857 | - } else { |
|
| 858 | - EE_Error::add_error( |
|
| 859 | - __('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
| 860 | - __FILE__, |
|
| 861 | - __FUNCTION__, |
|
| 862 | - __LINE__ |
|
| 863 | - ); |
|
| 864 | - } |
|
| 865 | - if (defined('DOING_AJAX')) { |
|
| 866 | - return $new_status; |
|
| 867 | - } |
|
| 868 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 869 | - } |
|
| 870 | - |
|
| 871 | - |
|
| 872 | - |
|
| 873 | - /** |
|
| 874 | - * This is toggles a single Check-in for the given registration and datetime. |
|
| 875 | - * |
|
| 876 | - * @param int $REG_ID The registration we're toggling |
|
| 877 | - * @param int $DTT_ID The datetime we're toggling |
|
| 878 | - * @return int The new status toggled to. |
|
| 879 | - * @throws \EE_Error |
|
| 880 | - */ |
|
| 881 | - private function _toggle_checkin($REG_ID, $DTT_ID) |
|
| 882 | - { |
|
| 883 | - /** @var EE_Registration $REG */ |
|
| 884 | - $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 885 | - $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
| 886 | - if ($new_status !== false) { |
|
| 887 | - EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
| 888 | - } else { |
|
| 889 | - EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
| 890 | - $new_status = false; |
|
| 891 | - } |
|
| 892 | - return $new_status; |
|
| 893 | - } |
|
| 894 | - |
|
| 895 | - |
|
| 896 | - |
|
| 897 | - /** |
|
| 898 | - * Takes care of deleting multiple EE_Checkin table rows |
|
| 899 | - * |
|
| 900 | - * @access protected |
|
| 901 | - * @return void |
|
| 902 | - * @throws \EE_Error |
|
| 903 | - */ |
|
| 904 | - protected function _delete_checkin_rows() |
|
| 905 | - { |
|
| 906 | - $query_args = array( |
|
| 907 | - 'action' => 'registration_checkins', |
|
| 908 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
| 909 | - '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0, |
|
| 910 | - ); |
|
| 911 | - $errors = 0; |
|
| 912 | - if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 913 | - while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 914 | - if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
| 915 | - $errors++; |
|
| 916 | - } |
|
| 917 | - } |
|
| 918 | - } else { |
|
| 919 | - EE_Error::add_error( |
|
| 920 | - __( |
|
| 921 | - 'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', |
|
| 922 | - 'event_espresso' |
|
| 923 | - ), |
|
| 924 | - __FILE__, |
|
| 925 | - __FUNCTION__, |
|
| 926 | - __LINE__ |
|
| 927 | - ); |
|
| 928 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 929 | - } |
|
| 930 | - if ($errors > 0) { |
|
| 931 | - EE_Error::add_error( |
|
| 932 | - sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors), |
|
| 933 | - __FILE__, |
|
| 934 | - __FUNCTION__, |
|
| 935 | - __LINE__ |
|
| 936 | - ); |
|
| 937 | - } else { |
|
| 938 | - EE_Error::add_success(__('Records were successfully deleted', 'event_espresso')); |
|
| 939 | - } |
|
| 940 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 941 | - } |
|
| 942 | - |
|
| 943 | - |
|
| 944 | - |
|
| 945 | - /** |
|
| 946 | - * Deletes a single EE_Checkin row |
|
| 947 | - * |
|
| 948 | - * @return void |
|
| 949 | - * @throws \EE_Error |
|
| 950 | - */ |
|
| 951 | - protected function _delete_checkin_row() |
|
| 952 | - { |
|
| 953 | - $query_args = array( |
|
| 954 | - 'action' => 'registration_checkins', |
|
| 955 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
| 956 | - '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0, |
|
| 957 | - ); |
|
| 958 | - if ( ! empty($this->_req_data['CHK_ID'])) { |
|
| 959 | - if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
| 960 | - EE_Error::add_error( |
|
| 961 | - __('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
| 962 | - __FILE__, |
|
| 963 | - __FUNCTION__, |
|
| 964 | - __LINE__ |
|
| 965 | - ); |
|
| 966 | - } else { |
|
| 967 | - EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso')); |
|
| 968 | - } |
|
| 969 | - } else { |
|
| 970 | - EE_Error::add_error( |
|
| 971 | - __( |
|
| 972 | - 'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', |
|
| 973 | - 'event_espresso' |
|
| 974 | - ), |
|
| 975 | - __FILE__, |
|
| 976 | - __FUNCTION__, |
|
| 977 | - __LINE__ |
|
| 978 | - ); |
|
| 979 | - } |
|
| 980 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 981 | - } |
|
| 982 | - |
|
| 983 | - |
|
| 984 | - |
|
| 985 | - /** |
|
| 986 | - * generates HTML for the Event Registrations List Table |
|
| 987 | - * |
|
| 988 | - * @access protected |
|
| 989 | - * @return void |
|
| 990 | - * @throws \EE_Error |
|
| 991 | - */ |
|
| 992 | - protected function _event_registrations_list_table() |
|
| 993 | - { |
|
| 994 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 995 | - $this->_admin_page_title .= isset($this->_req_data['event_id']) |
|
| 996 | - ? $this->get_action_link_or_button( |
|
| 997 | - 'new_registration', |
|
| 998 | - 'add-registrant', |
|
| 999 | - array('event_id' => $this->_req_data['event_id']), |
|
| 1000 | - 'add-new-h2', |
|
| 1001 | - '', |
|
| 1002 | - false |
|
| 1003 | - ) |
|
| 1004 | - : ''; |
|
| 1005 | - $legend_items = array( |
|
| 1006 | - 'star-icon' => array( |
|
| 1007 | - 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
| 1008 | - 'desc' => __('This Registrant is the Primary Registrant', 'event_espresso'), |
|
| 1009 | - ), |
|
| 1010 | - 'checkin' => array( |
|
| 1011 | - 'class' => 'ee-icon ee-icon-check-in', |
|
| 1012 | - 'desc' => __('This Registrant has been Checked In', 'event_espresso'), |
|
| 1013 | - ), |
|
| 1014 | - 'checkout' => array( |
|
| 1015 | - 'class' => 'ee-icon ee-icon-check-out', |
|
| 1016 | - 'desc' => __('This Registrant has been Checked Out', 'event_espresso'), |
|
| 1017 | - ), |
|
| 1018 | - 'nocheckinrecord' => array( |
|
| 1019 | - 'class' => 'dashicons dashicons-no', |
|
| 1020 | - 'desc' => __('No Check-in Record has been Created for this Registrant', 'event_espresso'), |
|
| 1021 | - ), |
|
| 1022 | - 'view_details' => array( |
|
| 1023 | - 'class' => 'dashicons dashicons-search', |
|
| 1024 | - 'desc' => __('View All Check-in Records for this Registrant', 'event_espresso'), |
|
| 1025 | - ), |
|
| 1026 | - 'approved_status' => array( |
|
| 1027 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 1028 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
| 1029 | - ), |
|
| 1030 | - 'cancelled_status' => array( |
|
| 1031 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 1032 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
| 1033 | - ), |
|
| 1034 | - 'declined_status' => array( |
|
| 1035 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 1036 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
| 1037 | - ), |
|
| 1038 | - 'not_approved' => array( |
|
| 1039 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 1040 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
| 1041 | - ), |
|
| 1042 | - 'pending_status' => array( |
|
| 1043 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 1044 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
| 1045 | - ), |
|
| 1046 | - 'wait_list' => array( |
|
| 1047 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 1048 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
| 1049 | - ), |
|
| 1050 | - ); |
|
| 1051 | - $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
| 1052 | - $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
| 1053 | - $this->_template_args['before_list_table'] = ! empty($event_id) |
|
| 1054 | - ? '<h2>' . sprintf( |
|
| 1055 | - __('Viewing Registrations for Event: %s', 'event_espresso'), |
|
| 1056 | - EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') |
|
| 1057 | - ) . '</h2>' |
|
| 1058 | - : ''; |
|
| 1059 | - //need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on the event. |
|
| 1060 | - /** @var EE_Event $event */ |
|
| 1061 | - $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
| 1062 | - $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0; |
|
| 1063 | - $datetime = null; |
|
| 1064 | - if ($event instanceof EE_Event) { |
|
| 1065 | - $datetimes_on_event = $event->datetimes(); |
|
| 1066 | - if (count($datetimes_on_event) === 1) { |
|
| 1067 | - $datetime = reset($datetimes_on_event); |
|
| 1068 | - } |
|
| 1069 | - } |
|
| 1070 | - $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 1071 | - if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') { |
|
| 1072 | - $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5); |
|
| 1073 | - $this->_template_args['before_list_table'] .= ' <span class="drk-grey-text">'; |
|
| 1074 | - $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
| 1075 | - $this->_template_args['before_list_table'] .= $datetime->name(); |
|
| 1076 | - $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
| 1077 | - $this->_template_args['before_list_table'] .= '</span></h2>'; |
|
| 1078 | - } |
|
| 1079 | - //if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status column |
|
| 1080 | - //represents |
|
| 1081 | - if ( ! $datetime instanceof EE_Datetime) { |
|
| 1082 | - $this->_template_args['before_list_table'] .= '<br><p class="description">' |
|
| 1083 | - . __('In this view, the check-in status represents the latest check-in record for the registration in that row.', |
|
| 1084 | - 'event_espresso') |
|
| 1085 | - . '</p>'; |
|
| 1086 | - } |
|
| 1087 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 1088 | - } |
|
| 1089 | - |
|
| 1090 | - /** |
|
| 1091 | - * Download the registrations check-in report (same as the normal registration report, but with different where |
|
| 1092 | - * conditions) |
|
| 1093 | - * |
|
| 1094 | - * @return void ends the request by a redirect or download |
|
| 1095 | - */ |
|
| 1096 | - public function _registrations_checkin_report() |
|
| 1097 | - { |
|
| 1098 | - $this->_registrations_report_base('_get_checkin_query_params_from_request'); |
|
| 1099 | - } |
|
| 1100 | - |
|
| 1101 | - /** |
|
| 1102 | - * Gets the query params from the request, plus adds a where condition for the registration status, |
|
| 1103 | - * because on the checkin page we only ever want to see approved and pending-approval registrations |
|
| 1104 | - * |
|
| 1105 | - * @param array $request |
|
| 1106 | - * @param int $per_page |
|
| 1107 | - * @param bool $count |
|
| 1108 | - * @return array |
|
| 1109 | - */ |
|
| 1110 | - protected function _get_checkin_query_params_from_request( |
|
| 1111 | - $request, |
|
| 1112 | - $per_page = 10, |
|
| 1113 | - $count = false |
|
| 1114 | - ) { |
|
| 1115 | - $query_params = $this->_get_registration_query_parameters($request, $per_page, $count); |
|
| 1116 | - //unlike the regular registrations list table, |
|
| 1117 | - $status_ids_array = apply_filters( |
|
| 1118 | - 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
| 1119 | - array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
| 1120 | - ); |
|
| 1121 | - $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
| 1122 | - return $query_params; |
|
| 1123 | - } |
|
| 1124 | - |
|
| 1125 | - |
|
| 1126 | - |
|
| 1127 | - |
|
| 1128 | - /** |
|
| 1129 | - * Gets registrations for an event |
|
| 1130 | - * |
|
| 1131 | - * @param int $per_page |
|
| 1132 | - * @param bool $count whether to return count or data. |
|
| 1133 | - * @param bool $trash |
|
| 1134 | - * @param string $orderby |
|
| 1135 | - * @return EE_Registration[]|int |
|
| 1136 | - * @throws \EE_Error |
|
| 1137 | - */ |
|
| 1138 | - public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname') |
|
| 1139 | - { |
|
| 1140 | - //normalize some request params that get setup by the parent `get_registrations` method. |
|
| 1141 | - $request = $this->_req_data; |
|
| 1142 | - $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby; |
|
| 1143 | - $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
| 1144 | - if($trash){ |
|
| 1145 | - $request['status'] = 'trash'; |
|
| 1146 | - } |
|
| 1147 | - $query_params = $this->_get_checkin_query_params_from_request( $request, $per_page, $count ); |
|
| 1148 | - |
|
| 1149 | - return $count |
|
| 1150 | - ? EEM_Registration::instance()->count($query_params) |
|
| 1151 | - /** @type EE_Registration[] */ |
|
| 1152 | - : EEM_Registration::instance()->get_all($query_params); |
|
| 1153 | - } |
|
| 20 | + /** |
|
| 21 | + * This is used to hold the reports template data which is setup early in the request. |
|
| 22 | + * |
|
| 23 | + * @type array |
|
| 24 | + */ |
|
| 25 | + protected $_reports_template_data = array(); |
|
| 26 | + |
|
| 27 | + |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Extend_Registrations_Admin_Page constructor. |
|
| 31 | + * |
|
| 32 | + * @param bool $routing |
|
| 33 | + */ |
|
| 34 | + public function __construct($routing = true) |
|
| 35 | + { |
|
| 36 | + parent::__construct($routing); |
|
| 37 | + if ( ! defined('REG_CAF_TEMPLATE_PATH')) { |
|
| 38 | + define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
| 39 | + define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
| 40 | + define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + protected function _extend_page_config() |
|
| 47 | + { |
|
| 48 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
| 49 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
| 50 | + ? $this->_req_data['_REG_ID'] |
|
| 51 | + : 0; |
|
| 52 | + // $att_id = ! empty( $this->_req_data['ATT_ID'] ) ? ! is_array( $this->_req_data['ATT_ID'] ) : 0; |
|
| 53 | + // $att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] ) |
|
| 54 | + // ? $this->_req_data['post'] : $att_id; |
|
| 55 | + $new_page_routes = array( |
|
| 56 | + 'reports' => array( |
|
| 57 | + 'func' => '_registration_reports', |
|
| 58 | + 'capability' => 'ee_read_registrations', |
|
| 59 | + ), |
|
| 60 | + 'registration_checkins' => array( |
|
| 61 | + 'func' => '_registration_checkin_list_table', |
|
| 62 | + 'capability' => 'ee_read_checkins', |
|
| 63 | + ), |
|
| 64 | + 'newsletter_selected_send' => array( |
|
| 65 | + 'func' => '_newsletter_selected_send', |
|
| 66 | + 'noheader' => true, |
|
| 67 | + 'capability' => 'ee_send_message', |
|
| 68 | + ), |
|
| 69 | + 'delete_checkin_rows' => array( |
|
| 70 | + 'func' => '_delete_checkin_rows', |
|
| 71 | + 'noheader' => true, |
|
| 72 | + 'capability' => 'ee_delete_checkins', |
|
| 73 | + ), |
|
| 74 | + 'delete_checkin_row' => array( |
|
| 75 | + 'func' => '_delete_checkin_row', |
|
| 76 | + 'noheader' => true, |
|
| 77 | + 'capability' => 'ee_delete_checkin', |
|
| 78 | + 'obj_id' => $reg_id, |
|
| 79 | + ), |
|
| 80 | + 'toggle_checkin_status' => array( |
|
| 81 | + 'func' => '_toggle_checkin_status', |
|
| 82 | + 'noheader' => true, |
|
| 83 | + 'capability' => 'ee_edit_checkin', |
|
| 84 | + 'obj_id' => $reg_id, |
|
| 85 | + ), |
|
| 86 | + 'event_registrations' => array( |
|
| 87 | + 'func' => '_event_registrations_list_table', |
|
| 88 | + 'capability' => 'ee_read_checkins', |
|
| 89 | + ), |
|
| 90 | + 'registrations_checkin_report' => array( |
|
| 91 | + 'func' => '_registrations_checkin_report', |
|
| 92 | + 'noheader' => true, |
|
| 93 | + 'capability' => 'ee_read_registrations', |
|
| 94 | + ), |
|
| 95 | + ); |
|
| 96 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
| 97 | + $new_page_config = array( |
|
| 98 | + 'reports' => array( |
|
| 99 | + 'nav' => array( |
|
| 100 | + 'label' => __('Reports', 'event_espresso'), |
|
| 101 | + 'order' => 30, |
|
| 102 | + ), |
|
| 103 | + 'help_tabs' => array( |
|
| 104 | + 'registrations_reports_help_tab' => array( |
|
| 105 | + 'title' => __('Registration Reports', 'event_espresso'), |
|
| 106 | + 'filename' => 'registrations_reports', |
|
| 107 | + ), |
|
| 108 | + ), |
|
| 109 | + /*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/ |
|
| 110 | + 'require_nonce' => false, |
|
| 111 | + ), |
|
| 112 | + 'event_registrations' => array( |
|
| 113 | + 'nav' => array( |
|
| 114 | + 'label' => __('Event Check-In', 'event_espresso'), |
|
| 115 | + 'order' => 10, |
|
| 116 | + 'persistent' => true, |
|
| 117 | + ), |
|
| 118 | + 'help_tabs' => array( |
|
| 119 | + 'registrations_event_checkin_help_tab' => array( |
|
| 120 | + 'title' => __('Registrations Event Check-In', 'event_espresso'), |
|
| 121 | + 'filename' => 'registrations_event_checkin', |
|
| 122 | + ), |
|
| 123 | + 'registrations_event_checkin_table_column_headings_help_tab' => array( |
|
| 124 | + 'title' => __('Event Check-In Table Column Headings', 'event_espresso'), |
|
| 125 | + 'filename' => 'registrations_event_checkin_table_column_headings', |
|
| 126 | + ), |
|
| 127 | + 'registrations_event_checkin_filters_help_tab' => array( |
|
| 128 | + 'title' => __('Event Check-In Filters', 'event_espresso'), |
|
| 129 | + 'filename' => 'registrations_event_checkin_filters', |
|
| 130 | + ), |
|
| 131 | + 'registrations_event_checkin_views_help_tab' => array( |
|
| 132 | + 'title' => __('Event Check-In Views', 'event_espresso'), |
|
| 133 | + 'filename' => 'registrations_event_checkin_views', |
|
| 134 | + ), |
|
| 135 | + 'registrations_event_checkin_other_help_tab' => array( |
|
| 136 | + 'title' => __('Event Check-In Other', 'event_espresso'), |
|
| 137 | + 'filename' => 'registrations_event_checkin_other', |
|
| 138 | + ), |
|
| 139 | + ), |
|
| 140 | + 'help_tour' => array('Event_Checkin_Help_Tour'), |
|
| 141 | + 'qtips' => array('Registration_List_Table_Tips'), |
|
| 142 | + 'list_table' => 'EE_Event_Registrations_List_Table', |
|
| 143 | + 'metaboxes' => array(), |
|
| 144 | + 'require_nonce' => false, |
|
| 145 | + ), |
|
| 146 | + 'registration_checkins' => array( |
|
| 147 | + 'nav' => array( |
|
| 148 | + 'label' => __('Check-In Records', 'event_espresso'), |
|
| 149 | + 'order' => 15, |
|
| 150 | + 'persistent' => false, |
|
| 151 | + ), |
|
| 152 | + 'list_table' => 'EE_Registration_CheckIn_List_Table', |
|
| 153 | + //'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ), |
|
| 154 | + 'metaboxes' => array(), |
|
| 155 | + 'require_nonce' => false, |
|
| 156 | + ), |
|
| 157 | + ); |
|
| 158 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
| 159 | + $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
|
| 160 | + $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + |
|
| 164 | + |
|
| 165 | + protected function _ajax_hooks() |
|
| 166 | + { |
|
| 167 | + parent::_ajax_hooks(); |
|
| 168 | + add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + |
|
| 172 | + |
|
| 173 | + public function load_scripts_styles() |
|
| 174 | + { |
|
| 175 | + parent::load_scripts_styles(); |
|
| 176 | + //if newsletter message type is active then let's add filter and load js for it. |
|
| 177 | + if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
| 178 | + //enqueue newsletter js |
|
| 179 | + wp_enqueue_script( |
|
| 180 | + 'ee-newsletter-trigger', |
|
| 181 | + REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
| 182 | + array('ee-dialog'), |
|
| 183 | + EVENT_ESPRESSO_VERSION, |
|
| 184 | + true |
|
| 185 | + ); |
|
| 186 | + wp_enqueue_style( |
|
| 187 | + 'ee-newsletter-trigger-css', |
|
| 188 | + REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
| 189 | + array(), |
|
| 190 | + EVENT_ESPRESSO_VERSION |
|
| 191 | + ); |
|
| 192 | + //hook in buttons for newsletter message type trigger. |
|
| 193 | + add_action( |
|
| 194 | + 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
| 195 | + array($this, 'add_newsletter_action_buttons'), |
|
| 196 | + 10 |
|
| 197 | + ); |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + |
|
| 202 | + |
|
| 203 | + public function load_scripts_styles_reports() |
|
| 204 | + { |
|
| 205 | + wp_register_script( |
|
| 206 | + 'ee-reg-reports-js', |
|
| 207 | + REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
| 208 | + array('google-charts'), |
|
| 209 | + EVENT_ESPRESSO_VERSION, |
|
| 210 | + true |
|
| 211 | + ); |
|
| 212 | + wp_enqueue_script('ee-reg-reports-js'); |
|
| 213 | + $this->_registration_reports_js_setup(); |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + |
|
| 217 | + |
|
| 218 | + protected function _add_screen_options_event_registrations() |
|
| 219 | + { |
|
| 220 | + $this->_per_page_screen_option(); |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + |
|
| 224 | + |
|
| 225 | + protected function _add_screen_options_registration_checkins() |
|
| 226 | + { |
|
| 227 | + $page_title = $this->_admin_page_title; |
|
| 228 | + $this->_admin_page_title = __('Check-In Records', 'event_espresso'); |
|
| 229 | + $this->_per_page_screen_option(); |
|
| 230 | + $this->_admin_page_title = $page_title; |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + |
|
| 234 | + |
|
| 235 | + protected function _set_list_table_views_event_registrations() |
|
| 236 | + { |
|
| 237 | + $this->_views = array( |
|
| 238 | + 'all' => array( |
|
| 239 | + 'slug' => 'all', |
|
| 240 | + 'label' => __('All', 'event_espresso'), |
|
| 241 | + 'count' => 0, |
|
| 242 | + 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
| 243 | + ? array() |
|
| 244 | + : array( |
|
| 245 | + 'toggle_checkin_status' => __('Toggle Check-In', 'event_espresso'), |
|
| 246 | + //'trash_registrations' => __('Trash Registrations', 'event_espresso') |
|
| 247 | + ), |
|
| 248 | + ), |
|
| 249 | + ); |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + |
|
| 253 | + |
|
| 254 | + protected function _set_list_table_views_registration_checkins() |
|
| 255 | + { |
|
| 256 | + $this->_views = array( |
|
| 257 | + 'all' => array( |
|
| 258 | + 'slug' => 'all', |
|
| 259 | + 'label' => __('All', 'event_espresso'), |
|
| 260 | + 'count' => 0, |
|
| 261 | + 'bulk_action' => array('delete_checkin_rows' => __('Delete Check-In Rows', 'event_espresso')), |
|
| 262 | + ), |
|
| 263 | + ); |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + |
|
| 267 | + |
|
| 268 | + /** |
|
| 269 | + * callback for ajax action. |
|
| 270 | + * |
|
| 271 | + * @since 4.3.0 |
|
| 272 | + * @return void (JSON) |
|
| 273 | + * @throws \EE_Error |
|
| 274 | + */ |
|
| 275 | + public function get_newsletter_form_content() |
|
| 276 | + { |
|
| 277 | + //do a nonce check cause we're not coming in from an normal route here. |
|
| 278 | + $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
| 279 | + $this->_req_data['get_newsletter_form_content_nonce'] |
|
| 280 | + ) : ''; |
|
| 281 | + $nonce_ref = 'get_newsletter_form_content_nonce'; |
|
| 282 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
| 283 | + //let's get the mtp for the incoming MTP_ ID |
|
| 284 | + if ( ! isset($this->_req_data['GRP_ID'])) { |
|
| 285 | + EE_Error::add_error( |
|
| 286 | + __( |
|
| 287 | + 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
|
| 288 | + 'event_espresso' |
|
| 289 | + ), |
|
| 290 | + __FILE__, |
|
| 291 | + __FUNCTION__, |
|
| 292 | + __LINE__ |
|
| 293 | + ); |
|
| 294 | + $this->_template_args['success'] = false; |
|
| 295 | + $this->_template_args['error'] = true; |
|
| 296 | + $this->_return_json(); |
|
| 297 | + } |
|
| 298 | + $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
| 299 | + if ( ! $MTPG instanceof EE_Message_Template_Group) { |
|
| 300 | + EE_Error::add_error( |
|
| 301 | + sprintf( |
|
| 302 | + __( |
|
| 303 | + 'The GRP_ID given (%d) does not appear to have a corresponding row in the database.', |
|
| 304 | + 'event_espresso' |
|
| 305 | + ), |
|
| 306 | + $this->_req_data['GRP_ID'] |
|
| 307 | + ), |
|
| 308 | + __FILE__, |
|
| 309 | + __FUNCTION__, |
|
| 310 | + __LINE__ |
|
| 311 | + ); |
|
| 312 | + $this->_template_args['success'] = false; |
|
| 313 | + $this->_template_args['error'] = true; |
|
| 314 | + $this->_return_json(); |
|
| 315 | + } |
|
| 316 | + $MTPs = $MTPG->context_templates(); |
|
| 317 | + $MTPs = $MTPs['attendee']; |
|
| 318 | + $template_fields = array(); |
|
| 319 | + /** @var EE_Message_Template $MTP */ |
|
| 320 | + foreach ($MTPs as $MTP) { |
|
| 321 | + $field = $MTP->get('MTP_template_field'); |
|
| 322 | + if ($field === 'content') { |
|
| 323 | + $content = $MTP->get('MTP_content'); |
|
| 324 | + if ( ! empty($content['newsletter_content'])) { |
|
| 325 | + $template_fields['newsletter_content'] = $content['newsletter_content']; |
|
| 326 | + } |
|
| 327 | + continue; |
|
| 328 | + } |
|
| 329 | + $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content'); |
|
| 330 | + } |
|
| 331 | + $this->_template_args['success'] = true; |
|
| 332 | + $this->_template_args['error'] = false; |
|
| 333 | + $this->_template_args['data'] = array( |
|
| 334 | + 'batch_message_from' => isset($template_fields['from']) |
|
| 335 | + ? $template_fields['from'] |
|
| 336 | + : '', |
|
| 337 | + 'batch_message_subject' => isset($template_fields['subject']) |
|
| 338 | + ? $template_fields['subject'] |
|
| 339 | + : '', |
|
| 340 | + 'batch_message_content' => isset($template_fields['newsletter_content']) |
|
| 341 | + ? $template_fields['newsletter_content'] |
|
| 342 | + : '', |
|
| 343 | + ); |
|
| 344 | + $this->_return_json(); |
|
| 345 | + } |
|
| 346 | + |
|
| 347 | + |
|
| 348 | + |
|
| 349 | + /** |
|
| 350 | + * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
|
| 351 | + * |
|
| 352 | + * @since 4.3.0 |
|
| 353 | + * @param EE_Admin_List_Table $list_table |
|
| 354 | + * @return void |
|
| 355 | + */ |
|
| 356 | + public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
|
| 357 | + { |
|
| 358 | + if ( ! EE_Registry::instance()->CAP->current_user_can( |
|
| 359 | + 'ee_send_message', |
|
| 360 | + 'espresso_registrations_newsletter_selected_send' |
|
| 361 | + ) |
|
| 362 | + ) { |
|
| 363 | + return; |
|
| 364 | + } |
|
| 365 | + $routes_to_add_to = array( |
|
| 366 | + 'contact_list', |
|
| 367 | + 'event_registrations', |
|
| 368 | + 'default', |
|
| 369 | + ); |
|
| 370 | + if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
| 371 | + if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
| 372 | + || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
| 373 | + ) { |
|
| 374 | + echo ''; |
|
| 375 | + } else { |
|
| 376 | + $button_text = sprintf( |
|
| 377 | + __('Send Batch Message (%s selected)', 'event_espresso'), |
|
| 378 | + '<span class="send-selected-newsletter-count">0</span>' |
|
| 379 | + ); |
|
| 380 | + echo '<button id="selected-batch-send-trigger" class="button secondary-button"><span class="dashicons dashicons-email "></span>' |
|
| 381 | + . $button_text |
|
| 382 | + . '</button>'; |
|
| 383 | + add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
| 384 | + } |
|
| 385 | + } |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + |
|
| 389 | + |
|
| 390 | + public function newsletter_send_form_skeleton() |
|
| 391 | + { |
|
| 392 | + $list_table = $this->_list_table_object; |
|
| 393 | + $codes = array(); |
|
| 394 | + //need to templates for the newsletter message type for the template selector. |
|
| 395 | + $values[] = array('text' => __('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
| 396 | + $mtps = EEM_Message_Template_Group::instance()->get_all( |
|
| 397 | + array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email')) |
|
| 398 | + ); |
|
| 399 | + foreach ($mtps as $mtp) { |
|
| 400 | + $name = $mtp->name(); |
|
| 401 | + $values[] = array( |
|
| 402 | + 'text' => empty($name) ? __('Global', 'event_espresso') : $name, |
|
| 403 | + 'id' => $mtp->ID(), |
|
| 404 | + ); |
|
| 405 | + } |
|
| 406 | + //need to get a list of shortcodes that are available for the newsletter message type. |
|
| 407 | + $shortcodes = EEH_MSG_Template::get_shortcodes('newsletter', 'email', array(), 'attendee', false); |
|
| 408 | + foreach ($shortcodes as $field => $shortcode_array) { |
|
| 409 | + $codes[$field] = implode(', ', array_keys($shortcode_array)); |
|
| 410 | + } |
|
| 411 | + $shortcodes = $codes; |
|
| 412 | + $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
| 413 | + $form_template_args = array( |
|
| 414 | + 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
| 415 | + 'form_route' => 'newsletter_selected_send', |
|
| 416 | + 'form_nonce_name' => 'newsletter_selected_send_nonce', |
|
| 417 | + 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
| 418 | + 'redirect_back_to' => $this->_req_action, |
|
| 419 | + 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
| 420 | + 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
| 421 | + 'shortcodes' => $shortcodes, |
|
| 422 | + 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration', |
|
| 423 | + ); |
|
| 424 | + EEH_Template::display_template($form_template, $form_template_args); |
|
| 425 | + } |
|
| 426 | + |
|
| 427 | + |
|
| 428 | + |
|
| 429 | + /** |
|
| 430 | + * Handles sending selected registrations/contacts a newsletter. |
|
| 431 | + * |
|
| 432 | + * @since 4.3.0 |
|
| 433 | + * @return void |
|
| 434 | + * @throws \EE_Error |
|
| 435 | + */ |
|
| 436 | + protected function _newsletter_selected_send() |
|
| 437 | + { |
|
| 438 | + $success = true; |
|
| 439 | + //first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
|
| 440 | + if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
| 441 | + EE_Error::add_error( |
|
| 442 | + __( |
|
| 443 | + 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
|
| 444 | + 'event_espresso' |
|
| 445 | + ), |
|
| 446 | + __FILE__, |
|
| 447 | + __FUNCTION__, |
|
| 448 | + __LINE__ |
|
| 449 | + ); |
|
| 450 | + $success = false; |
|
| 451 | + } |
|
| 452 | + if ($success) { |
|
| 453 | + //update Message template in case there are any changes |
|
| 454 | + $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
|
| 455 | + $this->_req_data['newsletter_mtp_selected'] |
|
| 456 | + ); |
|
| 457 | + $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
|
| 458 | + ? $Message_Template_Group->context_templates() |
|
| 459 | + : array(); |
|
| 460 | + if (empty($Message_Templates)) { |
|
| 461 | + EE_Error::add_error( |
|
| 462 | + __( |
|
| 463 | + 'Unable to retrieve message template fields from the db. Messages not sent.', |
|
| 464 | + 'event_espresso' |
|
| 465 | + ), |
|
| 466 | + __FILE__, |
|
| 467 | + __FUNCTION__, |
|
| 468 | + __LINE__ |
|
| 469 | + ); |
|
| 470 | + } |
|
| 471 | + //let's just update the specific fields |
|
| 472 | + foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
| 473 | + if ($Message_Template instanceof EE_Message_Template) { |
|
| 474 | + $field = $Message_Template->get('MTP_template_field'); |
|
| 475 | + $content = $Message_Template->get('MTP_content'); |
|
| 476 | + $new_content = $content; |
|
| 477 | + switch ($field) { |
|
| 478 | + case 'from' : |
|
| 479 | + $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
| 480 | + ? $this->_req_data['batch_message']['from'] |
|
| 481 | + : $content; |
|
| 482 | + break; |
|
| 483 | + case 'subject' : |
|
| 484 | + $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
| 485 | + ? $this->_req_data['batch_message']['subject'] |
|
| 486 | + : $content; |
|
| 487 | + break; |
|
| 488 | + case 'content' : |
|
| 489 | + $new_content = $content; |
|
| 490 | + $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
| 491 | + ? $this->_req_data['batch_message']['content'] |
|
| 492 | + : $content['newsletter_content']; |
|
| 493 | + break; |
|
| 494 | + default : |
|
| 495 | + //continue the foreach loop, we don't want to set $new_content nor save. |
|
| 496 | + continue 2; |
|
| 497 | + } |
|
| 498 | + $Message_Template->set('MTP_content', $new_content); |
|
| 499 | + $Message_Template->save(); |
|
| 500 | + } |
|
| 501 | + } |
|
| 502 | + //great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
|
| 503 | + $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
| 504 | + ? $this->_req_data['batch_message']['id_type'] |
|
| 505 | + : 'registration'; |
|
| 506 | + //id_type will affect how we assemble the ids. |
|
| 507 | + $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
| 508 | + ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
| 509 | + : array(); |
|
| 510 | + $registrations_used_for_contact_data = array(); |
|
| 511 | + //using switch because eventually we'll have other contexts that will be used for generating messages. |
|
| 512 | + switch ($id_type) { |
|
| 513 | + case 'registration' : |
|
| 514 | + $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
|
| 515 | + array( |
|
| 516 | + array( |
|
| 517 | + 'REG_ID' => array('IN', $ids), |
|
| 518 | + ), |
|
| 519 | + ) |
|
| 520 | + ); |
|
| 521 | + break; |
|
| 522 | + case 'contact' : |
|
| 523 | + $registrations_used_for_contact_data = EEM_Registration::instance() |
|
| 524 | + ->get_latest_registration_for_each_of_given_contacts($ids); |
|
| 525 | + break; |
|
| 526 | + } |
|
| 527 | + do_action( |
|
| 528 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
| 529 | + $registrations_used_for_contact_data, |
|
| 530 | + $Message_Template_Group->ID() |
|
| 531 | + ); |
|
| 532 | + //kept for backward compat, internally we no longer use this action. |
|
| 533 | + //@deprecated 4.8.36.rc.002 |
|
| 534 | + $contacts = $id_type === 'registration' |
|
| 535 | + ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
| 536 | + : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
| 537 | + do_action( |
|
| 538 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
|
| 539 | + $contacts, |
|
| 540 | + $Message_Template_Group->ID() |
|
| 541 | + ); |
|
| 542 | + } |
|
| 543 | + $query_args = array( |
|
| 544 | + 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
| 545 | + ? $this->_req_data['redirect_back_to'] |
|
| 546 | + : 'default', |
|
| 547 | + ); |
|
| 548 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 549 | + } |
|
| 550 | + |
|
| 551 | + |
|
| 552 | + |
|
| 553 | + /** |
|
| 554 | + * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
| 555 | + * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method. |
|
| 556 | + */ |
|
| 557 | + protected function _registration_reports_js_setup() |
|
| 558 | + { |
|
| 559 | + $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report(); |
|
| 560 | + $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report(); |
|
| 561 | + } |
|
| 562 | + |
|
| 563 | + |
|
| 564 | + |
|
| 565 | + /** |
|
| 566 | + * generates Business Reports regarding Registrations |
|
| 567 | + * |
|
| 568 | + * @access protected |
|
| 569 | + * @return void |
|
| 570 | + */ |
|
| 571 | + protected function _registration_reports() |
|
| 572 | + { |
|
| 573 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
| 574 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 575 | + $template_path, |
|
| 576 | + $this->_reports_template_data, |
|
| 577 | + true |
|
| 578 | + ); |
|
| 579 | + // the final template wrapper |
|
| 580 | + $this->display_admin_page_with_no_sidebar(); |
|
| 581 | + } |
|
| 582 | + |
|
| 583 | + |
|
| 584 | + |
|
| 585 | + /** |
|
| 586 | + * Generates Business Report showing total registrations per day. |
|
| 587 | + * |
|
| 588 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
| 589 | + * @return string |
|
| 590 | + */ |
|
| 591 | + private function _registrations_per_day_report($period = '-1 month') |
|
| 592 | + { |
|
| 593 | + $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
|
| 594 | + $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
| 595 | + $results = (array)$results; |
|
| 596 | + $regs = array(); |
|
| 597 | + $subtitle = ''; |
|
| 598 | + if ($results) { |
|
| 599 | + $column_titles = array(); |
|
| 600 | + $tracker = 0; |
|
| 601 | + foreach ($results as $result) { |
|
| 602 | + $report_column_values = array(); |
|
| 603 | + foreach ($result as $property_name => $property_value) { |
|
| 604 | + $property_value = $property_name === 'Registration_REG_date' ? $property_value |
|
| 605 | + : (int)$property_value; |
|
| 606 | + $report_column_values[] = $property_value; |
|
| 607 | + if ($tracker === 0) { |
|
| 608 | + if ($property_name === 'Registration_REG_date') { |
|
| 609 | + $column_titles[] = __('Date (only days with registrations are shown)', 'event_espresso'); |
|
| 610 | + } else { |
|
| 611 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
| 612 | + } |
|
| 613 | + } |
|
| 614 | + } |
|
| 615 | + $tracker++; |
|
| 616 | + $regs[] = $report_column_values; |
|
| 617 | + } |
|
| 618 | + //make sure the column_titles is pushed to the beginning of the array |
|
| 619 | + array_unshift($regs, $column_titles); |
|
| 620 | + //setup the date range. |
|
| 621 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
| 622 | + $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 623 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
| 624 | + $subtitle = sprintf( |
|
| 625 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
| 626 | + $beginning_date->format('Y-m-d'), |
|
| 627 | + $ending_date->format('Y-m-d') |
|
| 628 | + ); |
|
| 629 | + } |
|
| 630 | + $report_title = __('Total Registrations per Day', 'event_espresso'); |
|
| 631 | + $report_params = array( |
|
| 632 | + 'title' => $report_title, |
|
| 633 | + 'subtitle' => $subtitle, |
|
| 634 | + 'id' => $report_ID, |
|
| 635 | + 'regs' => $regs, |
|
| 636 | + 'noResults' => empty($regs), |
|
| 637 | + 'noRegsMsg' => sprintf( |
|
| 638 | + __( |
|
| 639 | + '%sThere are currently no registration records in the last month for this report.%s', |
|
| 640 | + 'event_espresso' |
|
| 641 | + ), |
|
| 642 | + '<h2>' . $report_title . '</h2><p>', |
|
| 643 | + '</p>' |
|
| 644 | + ), |
|
| 645 | + ); |
|
| 646 | + wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
| 647 | + return $report_ID; |
|
| 648 | + } |
|
| 649 | + |
|
| 650 | + |
|
| 651 | + |
|
| 652 | + /** |
|
| 653 | + * Generates Business Report showing total registrations per event. |
|
| 654 | + * |
|
| 655 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
| 656 | + * @return string |
|
| 657 | + */ |
|
| 658 | + private function _registrations_per_event_report($period = '-1 month') |
|
| 659 | + { |
|
| 660 | + $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
|
| 661 | + $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
| 662 | + $results = (array)$results; |
|
| 663 | + $regs = array(); |
|
| 664 | + $subtitle = ''; |
|
| 665 | + if ($results) { |
|
| 666 | + $column_titles = array(); |
|
| 667 | + $tracker = 0; |
|
| 668 | + foreach ($results as $result) { |
|
| 669 | + $report_column_values = array(); |
|
| 670 | + foreach ($result as $property_name => $property_value) { |
|
| 671 | + $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
| 672 | + $property_value, |
|
| 673 | + 4, |
|
| 674 | + '...' |
|
| 675 | + ) : (int)$property_value; |
|
| 676 | + $report_column_values[] = $property_value; |
|
| 677 | + if ($tracker === 0) { |
|
| 678 | + if ($property_name === 'Registration_Event') { |
|
| 679 | + $column_titles[] = __('Event', 'event_espresso'); |
|
| 680 | + } else { |
|
| 681 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
| 682 | + } |
|
| 683 | + } |
|
| 684 | + } |
|
| 685 | + $tracker++; |
|
| 686 | + $regs[] = $report_column_values; |
|
| 687 | + } |
|
| 688 | + //make sure the column_titles is pushed to the beginning of the array |
|
| 689 | + array_unshift($regs, $column_titles); |
|
| 690 | + //setup the date range. |
|
| 691 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
| 692 | + $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 693 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
| 694 | + $subtitle = sprintf( |
|
| 695 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
| 696 | + $beginning_date->format('Y-m-d'), |
|
| 697 | + $ending_date->format('Y-m-d') |
|
| 698 | + ); |
|
| 699 | + } |
|
| 700 | + $report_title = __('Total Registrations per Event', 'event_espresso'); |
|
| 701 | + $report_params = array( |
|
| 702 | + 'title' => $report_title, |
|
| 703 | + 'subtitle' => $subtitle, |
|
| 704 | + 'id' => $report_ID, |
|
| 705 | + 'regs' => $regs, |
|
| 706 | + 'noResults' => empty($regs), |
|
| 707 | + 'noRegsMsg' => sprintf( |
|
| 708 | + __( |
|
| 709 | + '%sThere are currently no registration records in the last month for this report.%s', |
|
| 710 | + 'event_espresso' |
|
| 711 | + ), |
|
| 712 | + '<h2>' . $report_title . '</h2><p>', |
|
| 713 | + '</p>' |
|
| 714 | + ), |
|
| 715 | + ); |
|
| 716 | + wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
| 717 | + return $report_ID; |
|
| 718 | + } |
|
| 719 | + |
|
| 720 | + |
|
| 721 | + |
|
| 722 | + /** |
|
| 723 | + * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
|
| 724 | + * |
|
| 725 | + * @access protected |
|
| 726 | + * @return void |
|
| 727 | + * @throws \EE_Error |
|
| 728 | + */ |
|
| 729 | + protected function _registration_checkin_list_table() |
|
| 730 | + { |
|
| 731 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 732 | + $reg_id = isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : null; |
|
| 733 | + /** @var EE_Registration $reg */ |
|
| 734 | + $reg = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
| 735 | + $this->_admin_page_title .= $this->get_action_link_or_button( |
|
| 736 | + 'new_registration', |
|
| 737 | + 'add-registrant', |
|
| 738 | + array('event_id' => $reg->event_ID()), |
|
| 739 | + 'add-new-h2' |
|
| 740 | + ); |
|
| 741 | + $legend_items = array( |
|
| 742 | + 'checkin' => array( |
|
| 743 | + 'class' => 'ee-icon ee-icon-check-in', |
|
| 744 | + 'desc' => __('This indicates the attendee has been checked in', 'event_espresso'), |
|
| 745 | + ), |
|
| 746 | + 'checkout' => array( |
|
| 747 | + 'class' => 'ee-icon ee-icon-check-out', |
|
| 748 | + 'desc' => __('This indicates the attendee has been checked out', 'event_espresso'), |
|
| 749 | + ), |
|
| 750 | + ); |
|
| 751 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
| 752 | + $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
| 753 | + $go_back_url = ! empty($reg_id) ? EE_Admin_Page::add_query_args_and_nonce( |
|
| 754 | + array( |
|
| 755 | + 'action' => 'event_registrations', |
|
| 756 | + 'event_id' => EEM_Registration::instance()->get_one_by_ID($reg_id)->get_first_related('Event')->ID(), |
|
| 757 | + 'DTT_ID' => $dtt_id, |
|
| 758 | + ), |
|
| 759 | + $this->_admin_base_url |
|
| 760 | + ) : ''; |
|
| 761 | + $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
|
| 762 | + ? '<h2>' . sprintf( |
|
| 763 | + __("%s's check in records for %s at the event, %s", 'event_espresso'), |
|
| 764 | + '<span id="checkin-attendee-name">' |
|
| 765 | + . EEM_Registration::instance() |
|
| 766 | + ->get_one_by_ID($reg_id) |
|
| 767 | + ->get_first_related('Attendee') |
|
| 768 | + ->full_name() . '</span>', |
|
| 769 | + '<span id="checkin-dtt"><a href="' . $go_back_url . '">' |
|
| 770 | + . EEM_Datetime::instance() |
|
| 771 | + ->get_one_by_ID($dtt_id) |
|
| 772 | + ->start_date_and_time() . ' - ' |
|
| 773 | + . EEM_Datetime::instance() |
|
| 774 | + ->get_one_by_ID($dtt_id) |
|
| 775 | + ->end_date_and_time() . '</a></span>', |
|
| 776 | + '<span id="checkin-event-name">' |
|
| 777 | + . EEM_Datetime::instance() |
|
| 778 | + ->get_one_by_ID($dtt_id) |
|
| 779 | + ->get_first_related('Event') |
|
| 780 | + ->get('EVT_name') . '</span>' |
|
| 781 | + ) . '</h2>' |
|
| 782 | + : ''; |
|
| 783 | + $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
|
| 784 | + ? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : ''; |
|
| 785 | + $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
|
| 786 | + ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
| 787 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 788 | + } |
|
| 789 | + |
|
| 790 | + |
|
| 791 | + |
|
| 792 | + /** |
|
| 793 | + * toggle the Check-in status for the given registration (coming from ajax) |
|
| 794 | + * |
|
| 795 | + * @return void (JSON) |
|
| 796 | + */ |
|
| 797 | + public function toggle_checkin_status() |
|
| 798 | + { |
|
| 799 | + //first make sure we have the necessary data |
|
| 800 | + if ( ! isset($this->_req_data['_regid'])) { |
|
| 801 | + EE_Error::add_error( |
|
| 802 | + __( |
|
| 803 | + 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
|
| 804 | + 'event_espresso' |
|
| 805 | + ), |
|
| 806 | + __FILE__, |
|
| 807 | + __FUNCTION__, |
|
| 808 | + __LINE__ |
|
| 809 | + ); |
|
| 810 | + $this->_template_args['success'] = false; |
|
| 811 | + $this->_template_args['error'] = true; |
|
| 812 | + $this->_return_json(); |
|
| 813 | + }; |
|
| 814 | + //do a nonce check cause we're not coming in from an normal route here. |
|
| 815 | + $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
| 816 | + : ''; |
|
| 817 | + $nonce_ref = 'checkin_nonce'; |
|
| 818 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
| 819 | + //beautiful! Made it this far so let's get the status. |
|
| 820 | + $new_status = $this->_toggle_checkin_status(); |
|
| 821 | + //setup new class to return via ajax |
|
| 822 | + $this->_template_args['admin_page_content'] = 'clickable trigger-checkin checkin-icons checkedin-status-' |
|
| 823 | + . $new_status; |
|
| 824 | + $this->_template_args['success'] = true; |
|
| 825 | + $this->_return_json(); |
|
| 826 | + } |
|
| 827 | + |
|
| 828 | + |
|
| 829 | + |
|
| 830 | + /** |
|
| 831 | + * handles toggling the checkin status for the registration, |
|
| 832 | + * |
|
| 833 | + * @access protected |
|
| 834 | + * @return int|void |
|
| 835 | + */ |
|
| 836 | + protected function _toggle_checkin_status() |
|
| 837 | + { |
|
| 838 | + //first let's get the query args out of the way for the redirect |
|
| 839 | + $query_args = array( |
|
| 840 | + 'action' => 'event_registrations', |
|
| 841 | + 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
| 842 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null, |
|
| 843 | + ); |
|
| 844 | + $new_status = false; |
|
| 845 | + // bulk action check in toggle |
|
| 846 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 847 | + // cycle thru checkboxes |
|
| 848 | + while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 849 | + $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
| 850 | + $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
| 851 | + } |
|
| 852 | + } elseif (isset($this->_req_data['_regid'])) { |
|
| 853 | + //coming from ajax request |
|
| 854 | + $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null; |
|
| 855 | + $query_args['DTT_ID'] = $DTT_ID; |
|
| 856 | + $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
| 857 | + } else { |
|
| 858 | + EE_Error::add_error( |
|
| 859 | + __('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
| 860 | + __FILE__, |
|
| 861 | + __FUNCTION__, |
|
| 862 | + __LINE__ |
|
| 863 | + ); |
|
| 864 | + } |
|
| 865 | + if (defined('DOING_AJAX')) { |
|
| 866 | + return $new_status; |
|
| 867 | + } |
|
| 868 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 869 | + } |
|
| 870 | + |
|
| 871 | + |
|
| 872 | + |
|
| 873 | + /** |
|
| 874 | + * This is toggles a single Check-in for the given registration and datetime. |
|
| 875 | + * |
|
| 876 | + * @param int $REG_ID The registration we're toggling |
|
| 877 | + * @param int $DTT_ID The datetime we're toggling |
|
| 878 | + * @return int The new status toggled to. |
|
| 879 | + * @throws \EE_Error |
|
| 880 | + */ |
|
| 881 | + private function _toggle_checkin($REG_ID, $DTT_ID) |
|
| 882 | + { |
|
| 883 | + /** @var EE_Registration $REG */ |
|
| 884 | + $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 885 | + $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
| 886 | + if ($new_status !== false) { |
|
| 887 | + EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
| 888 | + } else { |
|
| 889 | + EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
| 890 | + $new_status = false; |
|
| 891 | + } |
|
| 892 | + return $new_status; |
|
| 893 | + } |
|
| 894 | + |
|
| 895 | + |
|
| 896 | + |
|
| 897 | + /** |
|
| 898 | + * Takes care of deleting multiple EE_Checkin table rows |
|
| 899 | + * |
|
| 900 | + * @access protected |
|
| 901 | + * @return void |
|
| 902 | + * @throws \EE_Error |
|
| 903 | + */ |
|
| 904 | + protected function _delete_checkin_rows() |
|
| 905 | + { |
|
| 906 | + $query_args = array( |
|
| 907 | + 'action' => 'registration_checkins', |
|
| 908 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
| 909 | + '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0, |
|
| 910 | + ); |
|
| 911 | + $errors = 0; |
|
| 912 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 913 | + while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 914 | + if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
| 915 | + $errors++; |
|
| 916 | + } |
|
| 917 | + } |
|
| 918 | + } else { |
|
| 919 | + EE_Error::add_error( |
|
| 920 | + __( |
|
| 921 | + 'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', |
|
| 922 | + 'event_espresso' |
|
| 923 | + ), |
|
| 924 | + __FILE__, |
|
| 925 | + __FUNCTION__, |
|
| 926 | + __LINE__ |
|
| 927 | + ); |
|
| 928 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 929 | + } |
|
| 930 | + if ($errors > 0) { |
|
| 931 | + EE_Error::add_error( |
|
| 932 | + sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors), |
|
| 933 | + __FILE__, |
|
| 934 | + __FUNCTION__, |
|
| 935 | + __LINE__ |
|
| 936 | + ); |
|
| 937 | + } else { |
|
| 938 | + EE_Error::add_success(__('Records were successfully deleted', 'event_espresso')); |
|
| 939 | + } |
|
| 940 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 941 | + } |
|
| 942 | + |
|
| 943 | + |
|
| 944 | + |
|
| 945 | + /** |
|
| 946 | + * Deletes a single EE_Checkin row |
|
| 947 | + * |
|
| 948 | + * @return void |
|
| 949 | + * @throws \EE_Error |
|
| 950 | + */ |
|
| 951 | + protected function _delete_checkin_row() |
|
| 952 | + { |
|
| 953 | + $query_args = array( |
|
| 954 | + 'action' => 'registration_checkins', |
|
| 955 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
| 956 | + '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0, |
|
| 957 | + ); |
|
| 958 | + if ( ! empty($this->_req_data['CHK_ID'])) { |
|
| 959 | + if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
| 960 | + EE_Error::add_error( |
|
| 961 | + __('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
| 962 | + __FILE__, |
|
| 963 | + __FUNCTION__, |
|
| 964 | + __LINE__ |
|
| 965 | + ); |
|
| 966 | + } else { |
|
| 967 | + EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso')); |
|
| 968 | + } |
|
| 969 | + } else { |
|
| 970 | + EE_Error::add_error( |
|
| 971 | + __( |
|
| 972 | + 'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', |
|
| 973 | + 'event_espresso' |
|
| 974 | + ), |
|
| 975 | + __FILE__, |
|
| 976 | + __FUNCTION__, |
|
| 977 | + __LINE__ |
|
| 978 | + ); |
|
| 979 | + } |
|
| 980 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 981 | + } |
|
| 982 | + |
|
| 983 | + |
|
| 984 | + |
|
| 985 | + /** |
|
| 986 | + * generates HTML for the Event Registrations List Table |
|
| 987 | + * |
|
| 988 | + * @access protected |
|
| 989 | + * @return void |
|
| 990 | + * @throws \EE_Error |
|
| 991 | + */ |
|
| 992 | + protected function _event_registrations_list_table() |
|
| 993 | + { |
|
| 994 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 995 | + $this->_admin_page_title .= isset($this->_req_data['event_id']) |
|
| 996 | + ? $this->get_action_link_or_button( |
|
| 997 | + 'new_registration', |
|
| 998 | + 'add-registrant', |
|
| 999 | + array('event_id' => $this->_req_data['event_id']), |
|
| 1000 | + 'add-new-h2', |
|
| 1001 | + '', |
|
| 1002 | + false |
|
| 1003 | + ) |
|
| 1004 | + : ''; |
|
| 1005 | + $legend_items = array( |
|
| 1006 | + 'star-icon' => array( |
|
| 1007 | + 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
| 1008 | + 'desc' => __('This Registrant is the Primary Registrant', 'event_espresso'), |
|
| 1009 | + ), |
|
| 1010 | + 'checkin' => array( |
|
| 1011 | + 'class' => 'ee-icon ee-icon-check-in', |
|
| 1012 | + 'desc' => __('This Registrant has been Checked In', 'event_espresso'), |
|
| 1013 | + ), |
|
| 1014 | + 'checkout' => array( |
|
| 1015 | + 'class' => 'ee-icon ee-icon-check-out', |
|
| 1016 | + 'desc' => __('This Registrant has been Checked Out', 'event_espresso'), |
|
| 1017 | + ), |
|
| 1018 | + 'nocheckinrecord' => array( |
|
| 1019 | + 'class' => 'dashicons dashicons-no', |
|
| 1020 | + 'desc' => __('No Check-in Record has been Created for this Registrant', 'event_espresso'), |
|
| 1021 | + ), |
|
| 1022 | + 'view_details' => array( |
|
| 1023 | + 'class' => 'dashicons dashicons-search', |
|
| 1024 | + 'desc' => __('View All Check-in Records for this Registrant', 'event_espresso'), |
|
| 1025 | + ), |
|
| 1026 | + 'approved_status' => array( |
|
| 1027 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 1028 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
| 1029 | + ), |
|
| 1030 | + 'cancelled_status' => array( |
|
| 1031 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 1032 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
| 1033 | + ), |
|
| 1034 | + 'declined_status' => array( |
|
| 1035 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 1036 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
| 1037 | + ), |
|
| 1038 | + 'not_approved' => array( |
|
| 1039 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 1040 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
| 1041 | + ), |
|
| 1042 | + 'pending_status' => array( |
|
| 1043 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 1044 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
| 1045 | + ), |
|
| 1046 | + 'wait_list' => array( |
|
| 1047 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 1048 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
| 1049 | + ), |
|
| 1050 | + ); |
|
| 1051 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
| 1052 | + $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
| 1053 | + $this->_template_args['before_list_table'] = ! empty($event_id) |
|
| 1054 | + ? '<h2>' . sprintf( |
|
| 1055 | + __('Viewing Registrations for Event: %s', 'event_espresso'), |
|
| 1056 | + EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') |
|
| 1057 | + ) . '</h2>' |
|
| 1058 | + : ''; |
|
| 1059 | + //need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on the event. |
|
| 1060 | + /** @var EE_Event $event */ |
|
| 1061 | + $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
| 1062 | + $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0; |
|
| 1063 | + $datetime = null; |
|
| 1064 | + if ($event instanceof EE_Event) { |
|
| 1065 | + $datetimes_on_event = $event->datetimes(); |
|
| 1066 | + if (count($datetimes_on_event) === 1) { |
|
| 1067 | + $datetime = reset($datetimes_on_event); |
|
| 1068 | + } |
|
| 1069 | + } |
|
| 1070 | + $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 1071 | + if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') { |
|
| 1072 | + $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5); |
|
| 1073 | + $this->_template_args['before_list_table'] .= ' <span class="drk-grey-text">'; |
|
| 1074 | + $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
| 1075 | + $this->_template_args['before_list_table'] .= $datetime->name(); |
|
| 1076 | + $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
| 1077 | + $this->_template_args['before_list_table'] .= '</span></h2>'; |
|
| 1078 | + } |
|
| 1079 | + //if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status column |
|
| 1080 | + //represents |
|
| 1081 | + if ( ! $datetime instanceof EE_Datetime) { |
|
| 1082 | + $this->_template_args['before_list_table'] .= '<br><p class="description">' |
|
| 1083 | + . __('In this view, the check-in status represents the latest check-in record for the registration in that row.', |
|
| 1084 | + 'event_espresso') |
|
| 1085 | + . '</p>'; |
|
| 1086 | + } |
|
| 1087 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 1088 | + } |
|
| 1089 | + |
|
| 1090 | + /** |
|
| 1091 | + * Download the registrations check-in report (same as the normal registration report, but with different where |
|
| 1092 | + * conditions) |
|
| 1093 | + * |
|
| 1094 | + * @return void ends the request by a redirect or download |
|
| 1095 | + */ |
|
| 1096 | + public function _registrations_checkin_report() |
|
| 1097 | + { |
|
| 1098 | + $this->_registrations_report_base('_get_checkin_query_params_from_request'); |
|
| 1099 | + } |
|
| 1100 | + |
|
| 1101 | + /** |
|
| 1102 | + * Gets the query params from the request, plus adds a where condition for the registration status, |
|
| 1103 | + * because on the checkin page we only ever want to see approved and pending-approval registrations |
|
| 1104 | + * |
|
| 1105 | + * @param array $request |
|
| 1106 | + * @param int $per_page |
|
| 1107 | + * @param bool $count |
|
| 1108 | + * @return array |
|
| 1109 | + */ |
|
| 1110 | + protected function _get_checkin_query_params_from_request( |
|
| 1111 | + $request, |
|
| 1112 | + $per_page = 10, |
|
| 1113 | + $count = false |
|
| 1114 | + ) { |
|
| 1115 | + $query_params = $this->_get_registration_query_parameters($request, $per_page, $count); |
|
| 1116 | + //unlike the regular registrations list table, |
|
| 1117 | + $status_ids_array = apply_filters( |
|
| 1118 | + 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
| 1119 | + array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
| 1120 | + ); |
|
| 1121 | + $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
| 1122 | + return $query_params; |
|
| 1123 | + } |
|
| 1124 | + |
|
| 1125 | + |
|
| 1126 | + |
|
| 1127 | + |
|
| 1128 | + /** |
|
| 1129 | + * Gets registrations for an event |
|
| 1130 | + * |
|
| 1131 | + * @param int $per_page |
|
| 1132 | + * @param bool $count whether to return count or data. |
|
| 1133 | + * @param bool $trash |
|
| 1134 | + * @param string $orderby |
|
| 1135 | + * @return EE_Registration[]|int |
|
| 1136 | + * @throws \EE_Error |
|
| 1137 | + */ |
|
| 1138 | + public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname') |
|
| 1139 | + { |
|
| 1140 | + //normalize some request params that get setup by the parent `get_registrations` method. |
|
| 1141 | + $request = $this->_req_data; |
|
| 1142 | + $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby; |
|
| 1143 | + $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
| 1144 | + if($trash){ |
|
| 1145 | + $request['status'] = 'trash'; |
|
| 1146 | + } |
|
| 1147 | + $query_params = $this->_get_checkin_query_params_from_request( $request, $per_page, $count ); |
|
| 1148 | + |
|
| 1149 | + return $count |
|
| 1150 | + ? EEM_Registration::instance()->count($query_params) |
|
| 1151 | + /** @type EE_Registration[] */ |
|
| 1152 | + : EEM_Registration::instance()->get_all($query_params); |
|
| 1153 | + } |
|
| 1154 | 1154 | |
| 1155 | 1155 | } //end class Registrations Admin Page |