@@ -14,1282 +14,1282 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class Extend_Registrations_Admin_Page extends Registrations_Admin_Page |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * This is used to hold the reports template data which is setup early in the request. |
|
| 19 | - * |
|
| 20 | - * @type array |
|
| 21 | - */ |
|
| 22 | - protected $_reports_template_data = array(); |
|
| 17 | + /** |
|
| 18 | + * This is used to hold the reports template data which is setup early in the request. |
|
| 19 | + * |
|
| 20 | + * @type array |
|
| 21 | + */ |
|
| 22 | + protected $_reports_template_data = array(); |
|
| 23 | 23 | |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Extend_Registrations_Admin_Page constructor. |
|
| 27 | - * |
|
| 28 | - * @param bool $routing |
|
| 29 | - */ |
|
| 30 | - public function __construct($routing = true) |
|
| 31 | - { |
|
| 32 | - parent::__construct($routing); |
|
| 33 | - if (! defined('REG_CAF_TEMPLATE_PATH')) { |
|
| 34 | - define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
| 35 | - define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
| 36 | - define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
| 37 | - } |
|
| 38 | - } |
|
| 25 | + /** |
|
| 26 | + * Extend_Registrations_Admin_Page constructor. |
|
| 27 | + * |
|
| 28 | + * @param bool $routing |
|
| 29 | + */ |
|
| 30 | + public function __construct($routing = true) |
|
| 31 | + { |
|
| 32 | + parent::__construct($routing); |
|
| 33 | + if (! defined('REG_CAF_TEMPLATE_PATH')) { |
|
| 34 | + define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
| 35 | + define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
| 36 | + define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Extending page configuration. |
|
| 43 | - */ |
|
| 44 | - protected function _extend_page_config() |
|
| 45 | - { |
|
| 46 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
| 47 | - $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
| 48 | - ? $this->_req_data['_REG_ID'] |
|
| 49 | - : 0; |
|
| 50 | - $EVT_ID = ! empty($this->_req_data['event_id']) && ! is_array($this->_req_data['event_id']) |
|
| 51 | - ? absint($this->_req_data['event_id']) |
|
| 52 | - : 0; |
|
| 53 | - $new_page_routes = array( |
|
| 54 | - 'reports' => array( |
|
| 55 | - 'func' => '_registration_reports', |
|
| 56 | - 'capability' => 'ee_read_registrations', |
|
| 57 | - ), |
|
| 58 | - 'registration_checkins' => array( |
|
| 59 | - 'func' => '_registration_checkin_list_table', |
|
| 60 | - 'capability' => 'ee_read_checkins', |
|
| 61 | - ), |
|
| 62 | - 'newsletter_selected_send' => array( |
|
| 63 | - 'func' => '_newsletter_selected_send', |
|
| 64 | - 'noheader' => true, |
|
| 65 | - 'capability' => 'ee_send_message', |
|
| 66 | - ), |
|
| 67 | - 'delete_checkin_rows' => array( |
|
| 68 | - 'func' => '_delete_checkin_rows', |
|
| 69 | - 'noheader' => true, |
|
| 70 | - 'capability' => 'ee_delete_checkins', |
|
| 71 | - ), |
|
| 72 | - 'delete_checkin_row' => array( |
|
| 73 | - 'func' => '_delete_checkin_row', |
|
| 74 | - 'noheader' => true, |
|
| 75 | - 'capability' => 'ee_delete_checkin', |
|
| 76 | - 'obj_id' => $reg_id, |
|
| 77 | - ), |
|
| 78 | - 'toggle_checkin_status' => array( |
|
| 79 | - 'func' => '_toggle_checkin_status', |
|
| 80 | - 'noheader' => true, |
|
| 81 | - 'capability' => 'ee_edit_checkin', |
|
| 82 | - 'obj_id' => $reg_id, |
|
| 83 | - ), |
|
| 84 | - 'toggle_checkin_status_bulk' => array( |
|
| 85 | - 'func' => '_toggle_checkin_status', |
|
| 86 | - 'noheader' => true, |
|
| 87 | - 'capability' => 'ee_edit_checkins', |
|
| 88 | - ), |
|
| 89 | - 'event_registrations' => array( |
|
| 90 | - 'func' => '_event_registrations_list_table', |
|
| 91 | - 'capability' => 'ee_read_checkins', |
|
| 92 | - ), |
|
| 93 | - 'registrations_checkin_report' => array( |
|
| 94 | - 'func' => '_registrations_checkin_report', |
|
| 95 | - 'noheader' => true, |
|
| 96 | - 'capability' => 'ee_read_registrations', |
|
| 97 | - ), |
|
| 98 | - ); |
|
| 99 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
| 100 | - $new_page_config = array( |
|
| 101 | - 'reports' => array( |
|
| 102 | - 'nav' => array( |
|
| 103 | - 'label' => esc_html__('Reports', 'event_espresso'), |
|
| 104 | - 'order' => 30, |
|
| 105 | - ), |
|
| 106 | - 'help_tabs' => array( |
|
| 107 | - 'registrations_reports_help_tab' => array( |
|
| 108 | - 'title' => esc_html__('Registration Reports', 'event_espresso'), |
|
| 109 | - 'filename' => 'registrations_reports', |
|
| 110 | - ), |
|
| 111 | - ), |
|
| 112 | - 'require_nonce' => false, |
|
| 113 | - ), |
|
| 114 | - 'event_registrations' => array( |
|
| 115 | - 'nav' => array( |
|
| 116 | - 'label' => esc_html__('Event Check-In', 'event_espresso'), |
|
| 117 | - 'order' => 10, |
|
| 118 | - 'persistent' => true, |
|
| 119 | - 'url' => !empty($EVT_ID) && $this->get_current_view() !== 'event_registrations' |
|
| 120 | - ? self::add_query_args_and_nonce(array('action' => 'event_registrations', 'event_id' => $EVT_ID), $this->_admin_base_url) |
|
| 121 | - : null, |
|
| 122 | - ), |
|
| 123 | - 'help_tabs' => array( |
|
| 124 | - 'registrations_event_checkin_help_tab' => array( |
|
| 125 | - 'title' => esc_html__('Registrations Event Check-In', 'event_espresso'), |
|
| 126 | - 'filename' => 'registrations_event_checkin', |
|
| 127 | - ), |
|
| 128 | - 'registrations_event_checkin_table_column_headings_help_tab' => array( |
|
| 129 | - 'title' => esc_html__('Event Check-In Table Column Headings', 'event_espresso'), |
|
| 130 | - 'filename' => 'registrations_event_checkin_table_column_headings', |
|
| 131 | - ), |
|
| 132 | - 'registrations_event_checkin_filters_help_tab' => array( |
|
| 133 | - 'title' => esc_html__('Event Check-In Filters', 'event_espresso'), |
|
| 134 | - 'filename' => 'registrations_event_checkin_filters', |
|
| 135 | - ), |
|
| 136 | - 'registrations_event_checkin_views_help_tab' => array( |
|
| 137 | - 'title' => esc_html__('Event Check-In Views', 'event_espresso'), |
|
| 138 | - 'filename' => 'registrations_event_checkin_views', |
|
| 139 | - ), |
|
| 140 | - 'registrations_event_checkin_other_help_tab' => array( |
|
| 141 | - 'title' => esc_html__('Event Check-In Other', 'event_espresso'), |
|
| 142 | - 'filename' => 'registrations_event_checkin_other', |
|
| 143 | - ), |
|
| 144 | - ), |
|
| 145 | - 'qtips' => array('Registration_List_Table_Tips'), |
|
| 146 | - 'list_table' => 'EE_Event_Registrations_List_Table', |
|
| 147 | - 'metaboxes' => array(), |
|
| 148 | - 'require_nonce' => false, |
|
| 149 | - ), |
|
| 150 | - 'registration_checkins' => array( |
|
| 151 | - 'nav' => array( |
|
| 152 | - 'label' => esc_html__('Check-In Records', 'event_espresso'), |
|
| 153 | - 'order' => 15, |
|
| 154 | - 'persistent' => false, |
|
| 155 | - 'url' => '', |
|
| 156 | - ), |
|
| 157 | - 'list_table' => 'EE_Registration_CheckIn_List_Table', |
|
| 158 | - 'metaboxes' => array(), |
|
| 159 | - 'require_nonce' => false, |
|
| 160 | - ), |
|
| 161 | - ); |
|
| 162 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
| 163 | - $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
|
| 164 | - $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
|
| 165 | - } |
|
| 41 | + /** |
|
| 42 | + * Extending page configuration. |
|
| 43 | + */ |
|
| 44 | + protected function _extend_page_config() |
|
| 45 | + { |
|
| 46 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
| 47 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
| 48 | + ? $this->_req_data['_REG_ID'] |
|
| 49 | + : 0; |
|
| 50 | + $EVT_ID = ! empty($this->_req_data['event_id']) && ! is_array($this->_req_data['event_id']) |
|
| 51 | + ? absint($this->_req_data['event_id']) |
|
| 52 | + : 0; |
|
| 53 | + $new_page_routes = array( |
|
| 54 | + 'reports' => array( |
|
| 55 | + 'func' => '_registration_reports', |
|
| 56 | + 'capability' => 'ee_read_registrations', |
|
| 57 | + ), |
|
| 58 | + 'registration_checkins' => array( |
|
| 59 | + 'func' => '_registration_checkin_list_table', |
|
| 60 | + 'capability' => 'ee_read_checkins', |
|
| 61 | + ), |
|
| 62 | + 'newsletter_selected_send' => array( |
|
| 63 | + 'func' => '_newsletter_selected_send', |
|
| 64 | + 'noheader' => true, |
|
| 65 | + 'capability' => 'ee_send_message', |
|
| 66 | + ), |
|
| 67 | + 'delete_checkin_rows' => array( |
|
| 68 | + 'func' => '_delete_checkin_rows', |
|
| 69 | + 'noheader' => true, |
|
| 70 | + 'capability' => 'ee_delete_checkins', |
|
| 71 | + ), |
|
| 72 | + 'delete_checkin_row' => array( |
|
| 73 | + 'func' => '_delete_checkin_row', |
|
| 74 | + 'noheader' => true, |
|
| 75 | + 'capability' => 'ee_delete_checkin', |
|
| 76 | + 'obj_id' => $reg_id, |
|
| 77 | + ), |
|
| 78 | + 'toggle_checkin_status' => array( |
|
| 79 | + 'func' => '_toggle_checkin_status', |
|
| 80 | + 'noheader' => true, |
|
| 81 | + 'capability' => 'ee_edit_checkin', |
|
| 82 | + 'obj_id' => $reg_id, |
|
| 83 | + ), |
|
| 84 | + 'toggle_checkin_status_bulk' => array( |
|
| 85 | + 'func' => '_toggle_checkin_status', |
|
| 86 | + 'noheader' => true, |
|
| 87 | + 'capability' => 'ee_edit_checkins', |
|
| 88 | + ), |
|
| 89 | + 'event_registrations' => array( |
|
| 90 | + 'func' => '_event_registrations_list_table', |
|
| 91 | + 'capability' => 'ee_read_checkins', |
|
| 92 | + ), |
|
| 93 | + 'registrations_checkin_report' => array( |
|
| 94 | + 'func' => '_registrations_checkin_report', |
|
| 95 | + 'noheader' => true, |
|
| 96 | + 'capability' => 'ee_read_registrations', |
|
| 97 | + ), |
|
| 98 | + ); |
|
| 99 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
| 100 | + $new_page_config = array( |
|
| 101 | + 'reports' => array( |
|
| 102 | + 'nav' => array( |
|
| 103 | + 'label' => esc_html__('Reports', 'event_espresso'), |
|
| 104 | + 'order' => 30, |
|
| 105 | + ), |
|
| 106 | + 'help_tabs' => array( |
|
| 107 | + 'registrations_reports_help_tab' => array( |
|
| 108 | + 'title' => esc_html__('Registration Reports', 'event_espresso'), |
|
| 109 | + 'filename' => 'registrations_reports', |
|
| 110 | + ), |
|
| 111 | + ), |
|
| 112 | + 'require_nonce' => false, |
|
| 113 | + ), |
|
| 114 | + 'event_registrations' => array( |
|
| 115 | + 'nav' => array( |
|
| 116 | + 'label' => esc_html__('Event Check-In', 'event_espresso'), |
|
| 117 | + 'order' => 10, |
|
| 118 | + 'persistent' => true, |
|
| 119 | + 'url' => !empty($EVT_ID) && $this->get_current_view() !== 'event_registrations' |
|
| 120 | + ? self::add_query_args_and_nonce(array('action' => 'event_registrations', 'event_id' => $EVT_ID), $this->_admin_base_url) |
|
| 121 | + : null, |
|
| 122 | + ), |
|
| 123 | + 'help_tabs' => array( |
|
| 124 | + 'registrations_event_checkin_help_tab' => array( |
|
| 125 | + 'title' => esc_html__('Registrations Event Check-In', 'event_espresso'), |
|
| 126 | + 'filename' => 'registrations_event_checkin', |
|
| 127 | + ), |
|
| 128 | + 'registrations_event_checkin_table_column_headings_help_tab' => array( |
|
| 129 | + 'title' => esc_html__('Event Check-In Table Column Headings', 'event_espresso'), |
|
| 130 | + 'filename' => 'registrations_event_checkin_table_column_headings', |
|
| 131 | + ), |
|
| 132 | + 'registrations_event_checkin_filters_help_tab' => array( |
|
| 133 | + 'title' => esc_html__('Event Check-In Filters', 'event_espresso'), |
|
| 134 | + 'filename' => 'registrations_event_checkin_filters', |
|
| 135 | + ), |
|
| 136 | + 'registrations_event_checkin_views_help_tab' => array( |
|
| 137 | + 'title' => esc_html__('Event Check-In Views', 'event_espresso'), |
|
| 138 | + 'filename' => 'registrations_event_checkin_views', |
|
| 139 | + ), |
|
| 140 | + 'registrations_event_checkin_other_help_tab' => array( |
|
| 141 | + 'title' => esc_html__('Event Check-In Other', 'event_espresso'), |
|
| 142 | + 'filename' => 'registrations_event_checkin_other', |
|
| 143 | + ), |
|
| 144 | + ), |
|
| 145 | + 'qtips' => array('Registration_List_Table_Tips'), |
|
| 146 | + 'list_table' => 'EE_Event_Registrations_List_Table', |
|
| 147 | + 'metaboxes' => array(), |
|
| 148 | + 'require_nonce' => false, |
|
| 149 | + ), |
|
| 150 | + 'registration_checkins' => array( |
|
| 151 | + 'nav' => array( |
|
| 152 | + 'label' => esc_html__('Check-In Records', 'event_espresso'), |
|
| 153 | + 'order' => 15, |
|
| 154 | + 'persistent' => false, |
|
| 155 | + 'url' => '', |
|
| 156 | + ), |
|
| 157 | + 'list_table' => 'EE_Registration_CheckIn_List_Table', |
|
| 158 | + 'metaboxes' => array(), |
|
| 159 | + 'require_nonce' => false, |
|
| 160 | + ), |
|
| 161 | + ); |
|
| 162 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
| 163 | + $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
|
| 164 | + $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * Ajax hooks for all routes in this page. |
|
| 170 | - */ |
|
| 171 | - protected function _ajax_hooks() |
|
| 172 | - { |
|
| 173 | - parent::_ajax_hooks(); |
|
| 174 | - add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
| 175 | - } |
|
| 168 | + /** |
|
| 169 | + * Ajax hooks for all routes in this page. |
|
| 170 | + */ |
|
| 171 | + protected function _ajax_hooks() |
|
| 172 | + { |
|
| 173 | + parent::_ajax_hooks(); |
|
| 174 | + add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | 177 | |
| 178 | - /** |
|
| 179 | - * Global scripts for all routes in this page. |
|
| 180 | - */ |
|
| 181 | - public function load_scripts_styles() |
|
| 182 | - { |
|
| 183 | - parent::load_scripts_styles(); |
|
| 184 | - // if newsletter message type is active then let's add filter and load js for it. |
|
| 185 | - if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
| 186 | - // enqueue newsletter js |
|
| 187 | - wp_enqueue_script( |
|
| 188 | - 'ee-newsletter-trigger', |
|
| 189 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
| 190 | - array('ee-dialog'), |
|
| 191 | - EVENT_ESPRESSO_VERSION, |
|
| 192 | - true |
|
| 193 | - ); |
|
| 194 | - wp_enqueue_style( |
|
| 195 | - 'ee-newsletter-trigger-css', |
|
| 196 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
| 197 | - array(), |
|
| 198 | - EVENT_ESPRESSO_VERSION |
|
| 199 | - ); |
|
| 200 | - // hook in buttons for newsletter message type trigger. |
|
| 201 | - add_action( |
|
| 202 | - 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
| 203 | - array($this, 'add_newsletter_action_buttons'), |
|
| 204 | - 10 |
|
| 205 | - ); |
|
| 206 | - } |
|
| 207 | - } |
|
| 178 | + /** |
|
| 179 | + * Global scripts for all routes in this page. |
|
| 180 | + */ |
|
| 181 | + public function load_scripts_styles() |
|
| 182 | + { |
|
| 183 | + parent::load_scripts_styles(); |
|
| 184 | + // if newsletter message type is active then let's add filter and load js for it. |
|
| 185 | + if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
| 186 | + // enqueue newsletter js |
|
| 187 | + wp_enqueue_script( |
|
| 188 | + 'ee-newsletter-trigger', |
|
| 189 | + REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
| 190 | + array('ee-dialog'), |
|
| 191 | + EVENT_ESPRESSO_VERSION, |
|
| 192 | + true |
|
| 193 | + ); |
|
| 194 | + wp_enqueue_style( |
|
| 195 | + 'ee-newsletter-trigger-css', |
|
| 196 | + REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
| 197 | + array(), |
|
| 198 | + EVENT_ESPRESSO_VERSION |
|
| 199 | + ); |
|
| 200 | + // hook in buttons for newsletter message type trigger. |
|
| 201 | + add_action( |
|
| 202 | + 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
| 203 | + array($this, 'add_newsletter_action_buttons'), |
|
| 204 | + 10 |
|
| 205 | + ); |
|
| 206 | + } |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | 209 | |
| 210 | - /** |
|
| 211 | - * Scripts and styles for just the reports route. |
|
| 212 | - */ |
|
| 213 | - public function load_scripts_styles_reports() |
|
| 214 | - { |
|
| 215 | - wp_register_script( |
|
| 216 | - 'ee-reg-reports-js', |
|
| 217 | - REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
| 218 | - array('google-charts'), |
|
| 219 | - EVENT_ESPRESSO_VERSION, |
|
| 220 | - true |
|
| 221 | - ); |
|
| 222 | - wp_enqueue_script('ee-reg-reports-js'); |
|
| 223 | - $this->_registration_reports_js_setup(); |
|
| 224 | - } |
|
| 210 | + /** |
|
| 211 | + * Scripts and styles for just the reports route. |
|
| 212 | + */ |
|
| 213 | + public function load_scripts_styles_reports() |
|
| 214 | + { |
|
| 215 | + wp_register_script( |
|
| 216 | + 'ee-reg-reports-js', |
|
| 217 | + REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
| 218 | + array('google-charts'), |
|
| 219 | + EVENT_ESPRESSO_VERSION, |
|
| 220 | + true |
|
| 221 | + ); |
|
| 222 | + wp_enqueue_script('ee-reg-reports-js'); |
|
| 223 | + $this->_registration_reports_js_setup(); |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | 226 | |
| 227 | - /** |
|
| 228 | - * Register screen options for event_registrations route. |
|
| 229 | - */ |
|
| 230 | - protected function _add_screen_options_event_registrations() |
|
| 231 | - { |
|
| 232 | - $this->_per_page_screen_option(); |
|
| 233 | - } |
|
| 227 | + /** |
|
| 228 | + * Register screen options for event_registrations route. |
|
| 229 | + */ |
|
| 230 | + protected function _add_screen_options_event_registrations() |
|
| 231 | + { |
|
| 232 | + $this->_per_page_screen_option(); |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | 235 | |
| 236 | - /** |
|
| 237 | - * Register screen options for registration_checkins route |
|
| 238 | - */ |
|
| 239 | - protected function _add_screen_options_registration_checkins() |
|
| 240 | - { |
|
| 241 | - $page_title = $this->_admin_page_title; |
|
| 242 | - $this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso'); |
|
| 243 | - $this->_per_page_screen_option(); |
|
| 244 | - $this->_admin_page_title = $page_title; |
|
| 245 | - } |
|
| 236 | + /** |
|
| 237 | + * Register screen options for registration_checkins route |
|
| 238 | + */ |
|
| 239 | + protected function _add_screen_options_registration_checkins() |
|
| 240 | + { |
|
| 241 | + $page_title = $this->_admin_page_title; |
|
| 242 | + $this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso'); |
|
| 243 | + $this->_per_page_screen_option(); |
|
| 244 | + $this->_admin_page_title = $page_title; |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | 247 | |
| 248 | - /** |
|
| 249 | - * Set views property for event_registrations route. |
|
| 250 | - */ |
|
| 251 | - protected function _set_list_table_views_event_registrations() |
|
| 252 | - { |
|
| 253 | - $this->_views = array( |
|
| 254 | - 'all' => array( |
|
| 255 | - 'slug' => 'all', |
|
| 256 | - 'label' => esc_html__('All', 'event_espresso'), |
|
| 257 | - 'count' => 0, |
|
| 258 | - 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
| 259 | - ? array() |
|
| 260 | - : array( |
|
| 261 | - 'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'), |
|
| 262 | - ), |
|
| 263 | - ), |
|
| 264 | - ); |
|
| 265 | - } |
|
| 248 | + /** |
|
| 249 | + * Set views property for event_registrations route. |
|
| 250 | + */ |
|
| 251 | + protected function _set_list_table_views_event_registrations() |
|
| 252 | + { |
|
| 253 | + $this->_views = array( |
|
| 254 | + 'all' => array( |
|
| 255 | + 'slug' => 'all', |
|
| 256 | + 'label' => esc_html__('All', 'event_espresso'), |
|
| 257 | + 'count' => 0, |
|
| 258 | + 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
| 259 | + ? array() |
|
| 260 | + : array( |
|
| 261 | + 'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'), |
|
| 262 | + ), |
|
| 263 | + ), |
|
| 264 | + ); |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | 267 | |
| 268 | - /** |
|
| 269 | - * Set views property for registration_checkins route. |
|
| 270 | - */ |
|
| 271 | - protected function _set_list_table_views_registration_checkins() |
|
| 272 | - { |
|
| 273 | - $this->_views = array( |
|
| 274 | - 'all' => array( |
|
| 275 | - 'slug' => 'all', |
|
| 276 | - 'label' => esc_html__('All', 'event_espresso'), |
|
| 277 | - 'count' => 0, |
|
| 278 | - 'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')), |
|
| 279 | - ), |
|
| 280 | - ); |
|
| 281 | - } |
|
| 268 | + /** |
|
| 269 | + * Set views property for registration_checkins route. |
|
| 270 | + */ |
|
| 271 | + protected function _set_list_table_views_registration_checkins() |
|
| 272 | + { |
|
| 273 | + $this->_views = array( |
|
| 274 | + 'all' => array( |
|
| 275 | + 'slug' => 'all', |
|
| 276 | + 'label' => esc_html__('All', 'event_espresso'), |
|
| 277 | + 'count' => 0, |
|
| 278 | + 'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')), |
|
| 279 | + ), |
|
| 280 | + ); |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | 283 | |
| 284 | - /** |
|
| 285 | - * callback for ajax action. |
|
| 286 | - * |
|
| 287 | - * @since 4.3.0 |
|
| 288 | - * @return void (JSON) |
|
| 289 | - * @throws EE_Error |
|
| 290 | - * @throws InvalidArgumentException |
|
| 291 | - * @throws InvalidDataTypeException |
|
| 292 | - * @throws InvalidInterfaceException |
|
| 293 | - */ |
|
| 294 | - public function get_newsletter_form_content() |
|
| 295 | - { |
|
| 296 | - // do a nonce check cause we're not coming in from an normal route here. |
|
| 297 | - $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
| 298 | - $this->_req_data['get_newsletter_form_content_nonce'] |
|
| 299 | - ) : ''; |
|
| 300 | - $nonce_ref = 'get_newsletter_form_content_nonce'; |
|
| 301 | - $this->_verify_nonce($nonce, $nonce_ref); |
|
| 302 | - // let's get the mtp for the incoming MTP_ ID |
|
| 303 | - if (! isset($this->_req_data['GRP_ID'])) { |
|
| 304 | - EE_Error::add_error( |
|
| 305 | - esc_html__( |
|
| 306 | - '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).', |
|
| 307 | - 'event_espresso' |
|
| 308 | - ), |
|
| 309 | - __FILE__, |
|
| 310 | - __FUNCTION__, |
|
| 311 | - __LINE__ |
|
| 312 | - ); |
|
| 313 | - $this->_template_args['success'] = false; |
|
| 314 | - $this->_template_args['error'] = true; |
|
| 315 | - $this->_return_json(); |
|
| 316 | - } |
|
| 317 | - $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
| 318 | - if (! $MTPG instanceof EE_Message_Template_Group) { |
|
| 319 | - EE_Error::add_error( |
|
| 320 | - sprintf( |
|
| 321 | - esc_html__( |
|
| 322 | - 'The GRP_ID given (%d) does not appear to have a corresponding row in the database.', |
|
| 323 | - 'event_espresso' |
|
| 324 | - ), |
|
| 325 | - $this->_req_data['GRP_ID'] |
|
| 326 | - ), |
|
| 327 | - __FILE__, |
|
| 328 | - __FUNCTION__, |
|
| 329 | - __LINE__ |
|
| 330 | - ); |
|
| 331 | - $this->_template_args['success'] = false; |
|
| 332 | - $this->_template_args['error'] = true; |
|
| 333 | - $this->_return_json(); |
|
| 334 | - } |
|
| 335 | - $MTPs = $MTPG->context_templates(); |
|
| 336 | - $MTPs = $MTPs['attendee']; |
|
| 337 | - $template_fields = array(); |
|
| 338 | - /** @var EE_Message_Template $MTP */ |
|
| 339 | - foreach ($MTPs as $MTP) { |
|
| 340 | - $field = $MTP->get('MTP_template_field'); |
|
| 341 | - if ($field === 'content') { |
|
| 342 | - $content = $MTP->get('MTP_content'); |
|
| 343 | - if (! empty($content['newsletter_content'])) { |
|
| 344 | - $template_fields['newsletter_content'] = $content['newsletter_content']; |
|
| 345 | - } |
|
| 346 | - continue; |
|
| 347 | - } |
|
| 348 | - $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content'); |
|
| 349 | - } |
|
| 350 | - $this->_template_args['success'] = true; |
|
| 351 | - $this->_template_args['error'] = false; |
|
| 352 | - $this->_template_args['data'] = array( |
|
| 353 | - 'batch_message_from' => isset($template_fields['from']) |
|
| 354 | - ? $template_fields['from'] |
|
| 355 | - : '', |
|
| 356 | - 'batch_message_subject' => isset($template_fields['subject']) |
|
| 357 | - ? $template_fields['subject'] |
|
| 358 | - : '', |
|
| 359 | - 'batch_message_content' => isset($template_fields['newsletter_content']) |
|
| 360 | - ? $template_fields['newsletter_content'] |
|
| 361 | - : '', |
|
| 362 | - ); |
|
| 363 | - $this->_return_json(); |
|
| 364 | - } |
|
| 284 | + /** |
|
| 285 | + * callback for ajax action. |
|
| 286 | + * |
|
| 287 | + * @since 4.3.0 |
|
| 288 | + * @return void (JSON) |
|
| 289 | + * @throws EE_Error |
|
| 290 | + * @throws InvalidArgumentException |
|
| 291 | + * @throws InvalidDataTypeException |
|
| 292 | + * @throws InvalidInterfaceException |
|
| 293 | + */ |
|
| 294 | + public function get_newsletter_form_content() |
|
| 295 | + { |
|
| 296 | + // do a nonce check cause we're not coming in from an normal route here. |
|
| 297 | + $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
| 298 | + $this->_req_data['get_newsletter_form_content_nonce'] |
|
| 299 | + ) : ''; |
|
| 300 | + $nonce_ref = 'get_newsletter_form_content_nonce'; |
|
| 301 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
| 302 | + // let's get the mtp for the incoming MTP_ ID |
|
| 303 | + if (! isset($this->_req_data['GRP_ID'])) { |
|
| 304 | + EE_Error::add_error( |
|
| 305 | + esc_html__( |
|
| 306 | + '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).', |
|
| 307 | + 'event_espresso' |
|
| 308 | + ), |
|
| 309 | + __FILE__, |
|
| 310 | + __FUNCTION__, |
|
| 311 | + __LINE__ |
|
| 312 | + ); |
|
| 313 | + $this->_template_args['success'] = false; |
|
| 314 | + $this->_template_args['error'] = true; |
|
| 315 | + $this->_return_json(); |
|
| 316 | + } |
|
| 317 | + $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
| 318 | + if (! $MTPG instanceof EE_Message_Template_Group) { |
|
| 319 | + EE_Error::add_error( |
|
| 320 | + sprintf( |
|
| 321 | + esc_html__( |
|
| 322 | + 'The GRP_ID given (%d) does not appear to have a corresponding row in the database.', |
|
| 323 | + 'event_espresso' |
|
| 324 | + ), |
|
| 325 | + $this->_req_data['GRP_ID'] |
|
| 326 | + ), |
|
| 327 | + __FILE__, |
|
| 328 | + __FUNCTION__, |
|
| 329 | + __LINE__ |
|
| 330 | + ); |
|
| 331 | + $this->_template_args['success'] = false; |
|
| 332 | + $this->_template_args['error'] = true; |
|
| 333 | + $this->_return_json(); |
|
| 334 | + } |
|
| 335 | + $MTPs = $MTPG->context_templates(); |
|
| 336 | + $MTPs = $MTPs['attendee']; |
|
| 337 | + $template_fields = array(); |
|
| 338 | + /** @var EE_Message_Template $MTP */ |
|
| 339 | + foreach ($MTPs as $MTP) { |
|
| 340 | + $field = $MTP->get('MTP_template_field'); |
|
| 341 | + if ($field === 'content') { |
|
| 342 | + $content = $MTP->get('MTP_content'); |
|
| 343 | + if (! empty($content['newsletter_content'])) { |
|
| 344 | + $template_fields['newsletter_content'] = $content['newsletter_content']; |
|
| 345 | + } |
|
| 346 | + continue; |
|
| 347 | + } |
|
| 348 | + $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content'); |
|
| 349 | + } |
|
| 350 | + $this->_template_args['success'] = true; |
|
| 351 | + $this->_template_args['error'] = false; |
|
| 352 | + $this->_template_args['data'] = array( |
|
| 353 | + 'batch_message_from' => isset($template_fields['from']) |
|
| 354 | + ? $template_fields['from'] |
|
| 355 | + : '', |
|
| 356 | + 'batch_message_subject' => isset($template_fields['subject']) |
|
| 357 | + ? $template_fields['subject'] |
|
| 358 | + : '', |
|
| 359 | + 'batch_message_content' => isset($template_fields['newsletter_content']) |
|
| 360 | + ? $template_fields['newsletter_content'] |
|
| 361 | + : '', |
|
| 362 | + ); |
|
| 363 | + $this->_return_json(); |
|
| 364 | + } |
|
| 365 | 365 | |
| 366 | 366 | |
| 367 | - /** |
|
| 368 | - * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
|
| 369 | - * |
|
| 370 | - * @since 4.3.0 |
|
| 371 | - * @param EE_Admin_List_Table $list_table |
|
| 372 | - * @return void |
|
| 373 | - * @throws InvalidArgumentException |
|
| 374 | - * @throws InvalidDataTypeException |
|
| 375 | - * @throws InvalidInterfaceException |
|
| 376 | - */ |
|
| 377 | - public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
|
| 378 | - { |
|
| 379 | - if ( |
|
| 380 | - ! EE_Registry::instance()->CAP->current_user_can( |
|
| 381 | - 'ee_send_message', |
|
| 382 | - 'espresso_registrations_newsletter_selected_send' |
|
| 383 | - ) |
|
| 384 | - ) { |
|
| 385 | - return; |
|
| 386 | - } |
|
| 387 | - $routes_to_add_to = array( |
|
| 388 | - 'contact_list', |
|
| 389 | - 'event_registrations', |
|
| 390 | - 'default', |
|
| 391 | - ); |
|
| 392 | - if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
| 393 | - if ( |
|
| 394 | - ($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
| 395 | - || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
| 396 | - ) { |
|
| 397 | - echo ''; |
|
| 398 | - } else { |
|
| 399 | - $button_text = sprintf( |
|
| 400 | - esc_html__('Send Batch Message (%s selected)', 'event_espresso'), |
|
| 401 | - '<span class="send-selected-newsletter-count">0</span>' |
|
| 402 | - ); |
|
| 403 | - echo '<button id="selected-batch-send-trigger" class="button secondary-button">' |
|
| 404 | - . '<span class="dashicons dashicons-email "></span>' |
|
| 405 | - . $button_text |
|
| 406 | - . '</button>'; |
|
| 407 | - add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
| 408 | - } |
|
| 409 | - } |
|
| 410 | - } |
|
| 367 | + /** |
|
| 368 | + * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
|
| 369 | + * |
|
| 370 | + * @since 4.3.0 |
|
| 371 | + * @param EE_Admin_List_Table $list_table |
|
| 372 | + * @return void |
|
| 373 | + * @throws InvalidArgumentException |
|
| 374 | + * @throws InvalidDataTypeException |
|
| 375 | + * @throws InvalidInterfaceException |
|
| 376 | + */ |
|
| 377 | + public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
|
| 378 | + { |
|
| 379 | + if ( |
|
| 380 | + ! EE_Registry::instance()->CAP->current_user_can( |
|
| 381 | + 'ee_send_message', |
|
| 382 | + 'espresso_registrations_newsletter_selected_send' |
|
| 383 | + ) |
|
| 384 | + ) { |
|
| 385 | + return; |
|
| 386 | + } |
|
| 387 | + $routes_to_add_to = array( |
|
| 388 | + 'contact_list', |
|
| 389 | + 'event_registrations', |
|
| 390 | + 'default', |
|
| 391 | + ); |
|
| 392 | + if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
| 393 | + if ( |
|
| 394 | + ($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
| 395 | + || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
| 396 | + ) { |
|
| 397 | + echo ''; |
|
| 398 | + } else { |
|
| 399 | + $button_text = sprintf( |
|
| 400 | + esc_html__('Send Batch Message (%s selected)', 'event_espresso'), |
|
| 401 | + '<span class="send-selected-newsletter-count">0</span>' |
|
| 402 | + ); |
|
| 403 | + echo '<button id="selected-batch-send-trigger" class="button secondary-button">' |
|
| 404 | + . '<span class="dashicons dashicons-email "></span>' |
|
| 405 | + . $button_text |
|
| 406 | + . '</button>'; |
|
| 407 | + add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
| 408 | + } |
|
| 409 | + } |
|
| 410 | + } |
|
| 411 | 411 | |
| 412 | 412 | |
| 413 | - /** |
|
| 414 | - * @throws DomainException |
|
| 415 | - * @throws EE_Error |
|
| 416 | - * @throws InvalidArgumentException |
|
| 417 | - * @throws InvalidDataTypeException |
|
| 418 | - * @throws InvalidInterfaceException |
|
| 419 | - */ |
|
| 420 | - public function newsletter_send_form_skeleton() |
|
| 421 | - { |
|
| 422 | - $list_table = $this->_list_table_object; |
|
| 423 | - $codes = array(); |
|
| 424 | - // need to templates for the newsletter message type for the template selector. |
|
| 425 | - $values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
| 426 | - $mtps = EEM_Message_Template_Group::instance()->get_all( |
|
| 427 | - array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email')) |
|
| 428 | - ); |
|
| 429 | - foreach ($mtps as $mtp) { |
|
| 430 | - $name = $mtp->name(); |
|
| 431 | - $values[] = array( |
|
| 432 | - 'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name, |
|
| 433 | - 'id' => $mtp->ID(), |
|
| 434 | - ); |
|
| 435 | - } |
|
| 436 | - // need to get a list of shortcodes that are available for the newsletter message type. |
|
| 437 | - $shortcodes = EEH_MSG_Template::get_shortcodes( |
|
| 438 | - 'newsletter', |
|
| 439 | - 'email', |
|
| 440 | - array(), |
|
| 441 | - 'attendee', |
|
| 442 | - false |
|
| 443 | - ); |
|
| 444 | - foreach ($shortcodes as $field => $shortcode_array) { |
|
| 445 | - $available_shortcodes = array(); |
|
| 446 | - foreach ($shortcode_array as $shortcode => $shortcode_details) { |
|
| 447 | - $field_id = $field === '[NEWSLETTER_CONTENT]' |
|
| 448 | - ? 'content' |
|
| 449 | - : $field; |
|
| 450 | - $field_id = 'batch-message-' . strtolower($field_id); |
|
| 451 | - $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="' |
|
| 452 | - . $shortcode |
|
| 453 | - . '" data-linked-input-id="' . $field_id . '">' |
|
| 454 | - . $shortcode |
|
| 455 | - . '</span>'; |
|
| 456 | - } |
|
| 457 | - $codes[ $field ] = implode(', ', $available_shortcodes); |
|
| 458 | - } |
|
| 459 | - $shortcodes = $codes; |
|
| 460 | - $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
| 461 | - $form_template_args = array( |
|
| 462 | - 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
| 463 | - 'form_route' => 'newsletter_selected_send', |
|
| 464 | - 'form_nonce_name' => 'newsletter_selected_send_nonce', |
|
| 465 | - 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
| 466 | - 'redirect_back_to' => $this->_req_action, |
|
| 467 | - 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
| 468 | - 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
| 469 | - 'shortcodes' => $shortcodes, |
|
| 470 | - 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration', |
|
| 471 | - ); |
|
| 472 | - EEH_Template::display_template($form_template, $form_template_args); |
|
| 473 | - } |
|
| 413 | + /** |
|
| 414 | + * @throws DomainException |
|
| 415 | + * @throws EE_Error |
|
| 416 | + * @throws InvalidArgumentException |
|
| 417 | + * @throws InvalidDataTypeException |
|
| 418 | + * @throws InvalidInterfaceException |
|
| 419 | + */ |
|
| 420 | + public function newsletter_send_form_skeleton() |
|
| 421 | + { |
|
| 422 | + $list_table = $this->_list_table_object; |
|
| 423 | + $codes = array(); |
|
| 424 | + // need to templates for the newsletter message type for the template selector. |
|
| 425 | + $values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
| 426 | + $mtps = EEM_Message_Template_Group::instance()->get_all( |
|
| 427 | + array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email')) |
|
| 428 | + ); |
|
| 429 | + foreach ($mtps as $mtp) { |
|
| 430 | + $name = $mtp->name(); |
|
| 431 | + $values[] = array( |
|
| 432 | + 'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name, |
|
| 433 | + 'id' => $mtp->ID(), |
|
| 434 | + ); |
|
| 435 | + } |
|
| 436 | + // need to get a list of shortcodes that are available for the newsletter message type. |
|
| 437 | + $shortcodes = EEH_MSG_Template::get_shortcodes( |
|
| 438 | + 'newsletter', |
|
| 439 | + 'email', |
|
| 440 | + array(), |
|
| 441 | + 'attendee', |
|
| 442 | + false |
|
| 443 | + ); |
|
| 444 | + foreach ($shortcodes as $field => $shortcode_array) { |
|
| 445 | + $available_shortcodes = array(); |
|
| 446 | + foreach ($shortcode_array as $shortcode => $shortcode_details) { |
|
| 447 | + $field_id = $field === '[NEWSLETTER_CONTENT]' |
|
| 448 | + ? 'content' |
|
| 449 | + : $field; |
|
| 450 | + $field_id = 'batch-message-' . strtolower($field_id); |
|
| 451 | + $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="' |
|
| 452 | + . $shortcode |
|
| 453 | + . '" data-linked-input-id="' . $field_id . '">' |
|
| 454 | + . $shortcode |
|
| 455 | + . '</span>'; |
|
| 456 | + } |
|
| 457 | + $codes[ $field ] = implode(', ', $available_shortcodes); |
|
| 458 | + } |
|
| 459 | + $shortcodes = $codes; |
|
| 460 | + $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
| 461 | + $form_template_args = array( |
|
| 462 | + 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
| 463 | + 'form_route' => 'newsletter_selected_send', |
|
| 464 | + 'form_nonce_name' => 'newsletter_selected_send_nonce', |
|
| 465 | + 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
| 466 | + 'redirect_back_to' => $this->_req_action, |
|
| 467 | + 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
| 468 | + 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
| 469 | + 'shortcodes' => $shortcodes, |
|
| 470 | + 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration', |
|
| 471 | + ); |
|
| 472 | + EEH_Template::display_template($form_template, $form_template_args); |
|
| 473 | + } |
|
| 474 | 474 | |
| 475 | 475 | |
| 476 | - /** |
|
| 477 | - * Handles sending selected registrations/contacts a newsletter. |
|
| 478 | - * |
|
| 479 | - * @since 4.3.0 |
|
| 480 | - * @return void |
|
| 481 | - * @throws EE_Error |
|
| 482 | - * @throws InvalidArgumentException |
|
| 483 | - * @throws InvalidDataTypeException |
|
| 484 | - * @throws InvalidInterfaceException |
|
| 485 | - */ |
|
| 486 | - protected function _newsletter_selected_send() |
|
| 487 | - { |
|
| 488 | - $success = true; |
|
| 489 | - // first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
|
| 490 | - if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
| 491 | - EE_Error::add_error( |
|
| 492 | - esc_html__( |
|
| 493 | - 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
|
| 494 | - 'event_espresso' |
|
| 495 | - ), |
|
| 496 | - __FILE__, |
|
| 497 | - __FUNCTION__, |
|
| 498 | - __LINE__ |
|
| 499 | - ); |
|
| 500 | - $success = false; |
|
| 501 | - } |
|
| 502 | - if ($success) { |
|
| 503 | - // update Message template in case there are any changes |
|
| 504 | - $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
|
| 505 | - $this->_req_data['newsletter_mtp_selected'] |
|
| 506 | - ); |
|
| 507 | - $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
|
| 508 | - ? $Message_Template_Group->context_templates() |
|
| 509 | - : array(); |
|
| 510 | - if (empty($Message_Templates)) { |
|
| 511 | - EE_Error::add_error( |
|
| 512 | - esc_html__( |
|
| 513 | - 'Unable to retrieve message template fields from the db. Messages not sent.', |
|
| 514 | - 'event_espresso' |
|
| 515 | - ), |
|
| 516 | - __FILE__, |
|
| 517 | - __FUNCTION__, |
|
| 518 | - __LINE__ |
|
| 519 | - ); |
|
| 520 | - } |
|
| 521 | - // let's just update the specific fields |
|
| 522 | - foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
| 523 | - if ($Message_Template instanceof EE_Message_Template) { |
|
| 524 | - $field = $Message_Template->get('MTP_template_field'); |
|
| 525 | - $content = $Message_Template->get('MTP_content'); |
|
| 526 | - $new_content = $content; |
|
| 527 | - switch ($field) { |
|
| 528 | - case 'from': |
|
| 529 | - $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
| 530 | - ? $this->_req_data['batch_message']['from'] |
|
| 531 | - : $content; |
|
| 532 | - break; |
|
| 533 | - case 'subject': |
|
| 534 | - $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
| 535 | - ? $this->_req_data['batch_message']['subject'] |
|
| 536 | - : $content; |
|
| 537 | - break; |
|
| 538 | - case 'content': |
|
| 539 | - $new_content = $content; |
|
| 540 | - $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
| 541 | - ? $this->_req_data['batch_message']['content'] |
|
| 542 | - : $content['newsletter_content']; |
|
| 543 | - break; |
|
| 544 | - default: |
|
| 545 | - // continue the foreach loop, we don't want to set $new_content nor save. |
|
| 546 | - continue 2; |
|
| 547 | - } |
|
| 548 | - $Message_Template->set('MTP_content', $new_content); |
|
| 549 | - $Message_Template->save(); |
|
| 550 | - } |
|
| 551 | - } |
|
| 552 | - // great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
|
| 553 | - $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
| 554 | - ? $this->_req_data['batch_message']['id_type'] |
|
| 555 | - : 'registration'; |
|
| 556 | - // id_type will affect how we assemble the ids. |
|
| 557 | - $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
| 558 | - ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
| 559 | - : array(); |
|
| 560 | - $registrations_used_for_contact_data = array(); |
|
| 561 | - // using switch because eventually we'll have other contexts that will be used for generating messages. |
|
| 562 | - switch ($id_type) { |
|
| 563 | - case 'registration': |
|
| 564 | - $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
|
| 565 | - array( |
|
| 566 | - array( |
|
| 567 | - 'REG_ID' => array('IN', $ids), |
|
| 568 | - ), |
|
| 569 | - ) |
|
| 570 | - ); |
|
| 571 | - break; |
|
| 572 | - case 'contact': |
|
| 573 | - $registrations_used_for_contact_data = EEM_Registration::instance() |
|
| 574 | - ->get_latest_registration_for_each_of_given_contacts( |
|
| 575 | - $ids |
|
| 576 | - ); |
|
| 577 | - break; |
|
| 578 | - } |
|
| 579 | - do_action_ref_array( |
|
| 580 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
| 581 | - array( |
|
| 582 | - $registrations_used_for_contact_data, |
|
| 583 | - $Message_Template_Group->ID(), |
|
| 584 | - ) |
|
| 585 | - ); |
|
| 586 | - // kept for backward compat, internally we no longer use this action. |
|
| 587 | - // @deprecated 4.8.36.rc.002 |
|
| 588 | - $contacts = $id_type === 'registration' |
|
| 589 | - ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
| 590 | - : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
| 591 | - do_action_ref_array( |
|
| 592 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
|
| 593 | - array( |
|
| 594 | - $contacts, |
|
| 595 | - $Message_Template_Group->ID(), |
|
| 596 | - ) |
|
| 597 | - ); |
|
| 598 | - } |
|
| 599 | - $query_args = array( |
|
| 600 | - 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
| 601 | - ? $this->_req_data['redirect_back_to'] |
|
| 602 | - : 'default', |
|
| 603 | - ); |
|
| 604 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 605 | - } |
|
| 476 | + /** |
|
| 477 | + * Handles sending selected registrations/contacts a newsletter. |
|
| 478 | + * |
|
| 479 | + * @since 4.3.0 |
|
| 480 | + * @return void |
|
| 481 | + * @throws EE_Error |
|
| 482 | + * @throws InvalidArgumentException |
|
| 483 | + * @throws InvalidDataTypeException |
|
| 484 | + * @throws InvalidInterfaceException |
|
| 485 | + */ |
|
| 486 | + protected function _newsletter_selected_send() |
|
| 487 | + { |
|
| 488 | + $success = true; |
|
| 489 | + // first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
|
| 490 | + if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
| 491 | + EE_Error::add_error( |
|
| 492 | + esc_html__( |
|
| 493 | + 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
|
| 494 | + 'event_espresso' |
|
| 495 | + ), |
|
| 496 | + __FILE__, |
|
| 497 | + __FUNCTION__, |
|
| 498 | + __LINE__ |
|
| 499 | + ); |
|
| 500 | + $success = false; |
|
| 501 | + } |
|
| 502 | + if ($success) { |
|
| 503 | + // update Message template in case there are any changes |
|
| 504 | + $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
|
| 505 | + $this->_req_data['newsletter_mtp_selected'] |
|
| 506 | + ); |
|
| 507 | + $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
|
| 508 | + ? $Message_Template_Group->context_templates() |
|
| 509 | + : array(); |
|
| 510 | + if (empty($Message_Templates)) { |
|
| 511 | + EE_Error::add_error( |
|
| 512 | + esc_html__( |
|
| 513 | + 'Unable to retrieve message template fields from the db. Messages not sent.', |
|
| 514 | + 'event_espresso' |
|
| 515 | + ), |
|
| 516 | + __FILE__, |
|
| 517 | + __FUNCTION__, |
|
| 518 | + __LINE__ |
|
| 519 | + ); |
|
| 520 | + } |
|
| 521 | + // let's just update the specific fields |
|
| 522 | + foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
| 523 | + if ($Message_Template instanceof EE_Message_Template) { |
|
| 524 | + $field = $Message_Template->get('MTP_template_field'); |
|
| 525 | + $content = $Message_Template->get('MTP_content'); |
|
| 526 | + $new_content = $content; |
|
| 527 | + switch ($field) { |
|
| 528 | + case 'from': |
|
| 529 | + $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
| 530 | + ? $this->_req_data['batch_message']['from'] |
|
| 531 | + : $content; |
|
| 532 | + break; |
|
| 533 | + case 'subject': |
|
| 534 | + $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
| 535 | + ? $this->_req_data['batch_message']['subject'] |
|
| 536 | + : $content; |
|
| 537 | + break; |
|
| 538 | + case 'content': |
|
| 539 | + $new_content = $content; |
|
| 540 | + $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
| 541 | + ? $this->_req_data['batch_message']['content'] |
|
| 542 | + : $content['newsletter_content']; |
|
| 543 | + break; |
|
| 544 | + default: |
|
| 545 | + // continue the foreach loop, we don't want to set $new_content nor save. |
|
| 546 | + continue 2; |
|
| 547 | + } |
|
| 548 | + $Message_Template->set('MTP_content', $new_content); |
|
| 549 | + $Message_Template->save(); |
|
| 550 | + } |
|
| 551 | + } |
|
| 552 | + // great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
|
| 553 | + $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
| 554 | + ? $this->_req_data['batch_message']['id_type'] |
|
| 555 | + : 'registration'; |
|
| 556 | + // id_type will affect how we assemble the ids. |
|
| 557 | + $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
| 558 | + ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
| 559 | + : array(); |
|
| 560 | + $registrations_used_for_contact_data = array(); |
|
| 561 | + // using switch because eventually we'll have other contexts that will be used for generating messages. |
|
| 562 | + switch ($id_type) { |
|
| 563 | + case 'registration': |
|
| 564 | + $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
|
| 565 | + array( |
|
| 566 | + array( |
|
| 567 | + 'REG_ID' => array('IN', $ids), |
|
| 568 | + ), |
|
| 569 | + ) |
|
| 570 | + ); |
|
| 571 | + break; |
|
| 572 | + case 'contact': |
|
| 573 | + $registrations_used_for_contact_data = EEM_Registration::instance() |
|
| 574 | + ->get_latest_registration_for_each_of_given_contacts( |
|
| 575 | + $ids |
|
| 576 | + ); |
|
| 577 | + break; |
|
| 578 | + } |
|
| 579 | + do_action_ref_array( |
|
| 580 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
| 581 | + array( |
|
| 582 | + $registrations_used_for_contact_data, |
|
| 583 | + $Message_Template_Group->ID(), |
|
| 584 | + ) |
|
| 585 | + ); |
|
| 586 | + // kept for backward compat, internally we no longer use this action. |
|
| 587 | + // @deprecated 4.8.36.rc.002 |
|
| 588 | + $contacts = $id_type === 'registration' |
|
| 589 | + ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
| 590 | + : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
| 591 | + do_action_ref_array( |
|
| 592 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
|
| 593 | + array( |
|
| 594 | + $contacts, |
|
| 595 | + $Message_Template_Group->ID(), |
|
| 596 | + ) |
|
| 597 | + ); |
|
| 598 | + } |
|
| 599 | + $query_args = array( |
|
| 600 | + 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
| 601 | + ? $this->_req_data['redirect_back_to'] |
|
| 602 | + : 'default', |
|
| 603 | + ); |
|
| 604 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 605 | + } |
|
| 606 | 606 | |
| 607 | 607 | |
| 608 | - /** |
|
| 609 | - * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
| 610 | - * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method. |
|
| 611 | - */ |
|
| 612 | - protected function _registration_reports_js_setup() |
|
| 613 | - { |
|
| 614 | - $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report(); |
|
| 615 | - $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report(); |
|
| 616 | - } |
|
| 608 | + /** |
|
| 609 | + * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
| 610 | + * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method. |
|
| 611 | + */ |
|
| 612 | + protected function _registration_reports_js_setup() |
|
| 613 | + { |
|
| 614 | + $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report(); |
|
| 615 | + $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report(); |
|
| 616 | + } |
|
| 617 | 617 | |
| 618 | 618 | |
| 619 | - /** |
|
| 620 | - * generates Business Reports regarding Registrations |
|
| 621 | - * |
|
| 622 | - * @access protected |
|
| 623 | - * @return void |
|
| 624 | - * @throws DomainException |
|
| 625 | - */ |
|
| 626 | - protected function _registration_reports() |
|
| 627 | - { |
|
| 628 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
| 629 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 630 | - $template_path, |
|
| 631 | - $this->_reports_template_data, |
|
| 632 | - true |
|
| 633 | - ); |
|
| 634 | - // the final template wrapper |
|
| 635 | - $this->display_admin_page_with_no_sidebar(); |
|
| 636 | - } |
|
| 619 | + /** |
|
| 620 | + * generates Business Reports regarding Registrations |
|
| 621 | + * |
|
| 622 | + * @access protected |
|
| 623 | + * @return void |
|
| 624 | + * @throws DomainException |
|
| 625 | + */ |
|
| 626 | + protected function _registration_reports() |
|
| 627 | + { |
|
| 628 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
| 629 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 630 | + $template_path, |
|
| 631 | + $this->_reports_template_data, |
|
| 632 | + true |
|
| 633 | + ); |
|
| 634 | + // the final template wrapper |
|
| 635 | + $this->display_admin_page_with_no_sidebar(); |
|
| 636 | + } |
|
| 637 | 637 | |
| 638 | 638 | |
| 639 | - /** |
|
| 640 | - * Generates Business Report showing total registrations per day. |
|
| 641 | - * |
|
| 642 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
| 643 | - * @return string |
|
| 644 | - * @throws EE_Error |
|
| 645 | - * @throws InvalidArgumentException |
|
| 646 | - * @throws InvalidDataTypeException |
|
| 647 | - * @throws InvalidInterfaceException |
|
| 648 | - */ |
|
| 649 | - private function _registrations_per_day_report($period = '-1 month') |
|
| 650 | - { |
|
| 651 | - $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
|
| 652 | - $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
| 653 | - $results = (array) $results; |
|
| 654 | - $regs = array(); |
|
| 655 | - $subtitle = ''; |
|
| 656 | - if ($results) { |
|
| 657 | - $column_titles = array(); |
|
| 658 | - $tracker = 0; |
|
| 659 | - foreach ($results as $result) { |
|
| 660 | - $report_column_values = array(); |
|
| 661 | - foreach ($result as $property_name => $property_value) { |
|
| 662 | - $property_value = $property_name === 'Registration_REG_date' ? $property_value |
|
| 663 | - : (int) $property_value; |
|
| 664 | - $report_column_values[] = $property_value; |
|
| 665 | - if ($tracker === 0) { |
|
| 666 | - if ($property_name === 'Registration_REG_date') { |
|
| 667 | - $column_titles[] = esc_html__( |
|
| 668 | - 'Date (only days with registrations are shown)', |
|
| 669 | - 'event_espresso' |
|
| 670 | - ); |
|
| 671 | - } else { |
|
| 672 | - $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
| 673 | - } |
|
| 674 | - } |
|
| 675 | - } |
|
| 676 | - $tracker++; |
|
| 677 | - $regs[] = $report_column_values; |
|
| 678 | - } |
|
| 679 | - // make sure the column_titles is pushed to the beginning of the array |
|
| 680 | - array_unshift($regs, $column_titles); |
|
| 681 | - // setup the date range. |
|
| 682 | - $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
| 683 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 684 | - $ending_date = new DateTime("now", $DateTimeZone); |
|
| 685 | - $subtitle = sprintf( |
|
| 686 | - wp_strip_all_tags( |
|
| 687 | - _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
| 688 | - ), |
|
| 689 | - $beginning_date->format('Y-m-d'), |
|
| 690 | - $ending_date->format('Y-m-d') |
|
| 691 | - ); |
|
| 692 | - } |
|
| 693 | - $report_title = wp_strip_all_tags(__('Total Registrations per Day', 'event_espresso')); |
|
| 694 | - $report_params = array( |
|
| 695 | - 'title' => $report_title, |
|
| 696 | - 'subtitle' => $subtitle, |
|
| 697 | - 'id' => $report_ID, |
|
| 698 | - 'regs' => $regs, |
|
| 699 | - 'noResults' => empty($regs), |
|
| 700 | - 'noRegsMsg' => sprintf( |
|
| 701 | - wp_strip_all_tags( |
|
| 702 | - __( |
|
| 703 | - '%sThere are currently no registration records in the last month for this report.%s', |
|
| 704 | - 'event_espresso' |
|
| 705 | - ) |
|
| 706 | - ), |
|
| 707 | - '<h2>' . $report_title . '</h2><p>', |
|
| 708 | - '</p>' |
|
| 709 | - ), |
|
| 710 | - ); |
|
| 711 | - wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
| 712 | - return $report_ID; |
|
| 713 | - } |
|
| 639 | + /** |
|
| 640 | + * Generates Business Report showing total registrations per day. |
|
| 641 | + * |
|
| 642 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
| 643 | + * @return string |
|
| 644 | + * @throws EE_Error |
|
| 645 | + * @throws InvalidArgumentException |
|
| 646 | + * @throws InvalidDataTypeException |
|
| 647 | + * @throws InvalidInterfaceException |
|
| 648 | + */ |
|
| 649 | + private function _registrations_per_day_report($period = '-1 month') |
|
| 650 | + { |
|
| 651 | + $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
|
| 652 | + $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
| 653 | + $results = (array) $results; |
|
| 654 | + $regs = array(); |
|
| 655 | + $subtitle = ''; |
|
| 656 | + if ($results) { |
|
| 657 | + $column_titles = array(); |
|
| 658 | + $tracker = 0; |
|
| 659 | + foreach ($results as $result) { |
|
| 660 | + $report_column_values = array(); |
|
| 661 | + foreach ($result as $property_name => $property_value) { |
|
| 662 | + $property_value = $property_name === 'Registration_REG_date' ? $property_value |
|
| 663 | + : (int) $property_value; |
|
| 664 | + $report_column_values[] = $property_value; |
|
| 665 | + if ($tracker === 0) { |
|
| 666 | + if ($property_name === 'Registration_REG_date') { |
|
| 667 | + $column_titles[] = esc_html__( |
|
| 668 | + 'Date (only days with registrations are shown)', |
|
| 669 | + 'event_espresso' |
|
| 670 | + ); |
|
| 671 | + } else { |
|
| 672 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
| 673 | + } |
|
| 674 | + } |
|
| 675 | + } |
|
| 676 | + $tracker++; |
|
| 677 | + $regs[] = $report_column_values; |
|
| 678 | + } |
|
| 679 | + // make sure the column_titles is pushed to the beginning of the array |
|
| 680 | + array_unshift($regs, $column_titles); |
|
| 681 | + // setup the date range. |
|
| 682 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
| 683 | + $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 684 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
| 685 | + $subtitle = sprintf( |
|
| 686 | + wp_strip_all_tags( |
|
| 687 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
| 688 | + ), |
|
| 689 | + $beginning_date->format('Y-m-d'), |
|
| 690 | + $ending_date->format('Y-m-d') |
|
| 691 | + ); |
|
| 692 | + } |
|
| 693 | + $report_title = wp_strip_all_tags(__('Total Registrations per Day', 'event_espresso')); |
|
| 694 | + $report_params = array( |
|
| 695 | + 'title' => $report_title, |
|
| 696 | + 'subtitle' => $subtitle, |
|
| 697 | + 'id' => $report_ID, |
|
| 698 | + 'regs' => $regs, |
|
| 699 | + 'noResults' => empty($regs), |
|
| 700 | + 'noRegsMsg' => sprintf( |
|
| 701 | + wp_strip_all_tags( |
|
| 702 | + __( |
|
| 703 | + '%sThere are currently no registration records in the last month for this report.%s', |
|
| 704 | + 'event_espresso' |
|
| 705 | + ) |
|
| 706 | + ), |
|
| 707 | + '<h2>' . $report_title . '</h2><p>', |
|
| 708 | + '</p>' |
|
| 709 | + ), |
|
| 710 | + ); |
|
| 711 | + wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
| 712 | + return $report_ID; |
|
| 713 | + } |
|
| 714 | 714 | |
| 715 | 715 | |
| 716 | - /** |
|
| 717 | - * Generates Business Report showing total registrations per event. |
|
| 718 | - * |
|
| 719 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
| 720 | - * @return string |
|
| 721 | - * @throws EE_Error |
|
| 722 | - * @throws InvalidArgumentException |
|
| 723 | - * @throws InvalidDataTypeException |
|
| 724 | - * @throws InvalidInterfaceException |
|
| 725 | - */ |
|
| 726 | - private function _registrations_per_event_report($period = '-1 month') |
|
| 727 | - { |
|
| 728 | - $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
|
| 729 | - $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
| 730 | - $results = (array) $results; |
|
| 731 | - $regs = array(); |
|
| 732 | - $subtitle = ''; |
|
| 733 | - if ($results) { |
|
| 734 | - $column_titles = array(); |
|
| 735 | - $tracker = 0; |
|
| 736 | - foreach ($results as $result) { |
|
| 737 | - $report_column_values = array(); |
|
| 738 | - foreach ($result as $property_name => $property_value) { |
|
| 739 | - $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
| 740 | - $property_value, |
|
| 741 | - 4, |
|
| 742 | - '...' |
|
| 743 | - ) : (int) $property_value; |
|
| 744 | - $report_column_values[] = $property_value; |
|
| 745 | - if ($tracker === 0) { |
|
| 746 | - if ($property_name === 'Registration_Event') { |
|
| 747 | - $column_titles[] = esc_html__('Event', 'event_espresso'); |
|
| 748 | - } else { |
|
| 749 | - $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
| 750 | - } |
|
| 751 | - } |
|
| 752 | - } |
|
| 753 | - $tracker++; |
|
| 754 | - $regs[] = $report_column_values; |
|
| 755 | - } |
|
| 756 | - // make sure the column_titles is pushed to the beginning of the array |
|
| 757 | - array_unshift($regs, $column_titles); |
|
| 758 | - // setup the date range. |
|
| 759 | - $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
| 760 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 761 | - $ending_date = new DateTime("now", $DateTimeZone); |
|
| 762 | - $subtitle = sprintf( |
|
| 763 | - wp_strip_all_tags( |
|
| 764 | - _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
| 765 | - ), |
|
| 766 | - $beginning_date->format('Y-m-d'), |
|
| 767 | - $ending_date->format('Y-m-d') |
|
| 768 | - ); |
|
| 769 | - } |
|
| 770 | - $report_title = wp_strip_all_tags(__('Total Registrations per Event', 'event_espresso')); |
|
| 771 | - $report_params = array( |
|
| 772 | - 'title' => $report_title, |
|
| 773 | - 'subtitle' => $subtitle, |
|
| 774 | - 'id' => $report_ID, |
|
| 775 | - 'regs' => $regs, |
|
| 776 | - 'noResults' => empty($regs), |
|
| 777 | - 'noRegsMsg' => sprintf( |
|
| 778 | - wp_strip_all_tags( |
|
| 779 | - __( |
|
| 780 | - '%sThere are currently no registration records in the last month for this report.%s', |
|
| 781 | - 'event_espresso' |
|
| 782 | - ) |
|
| 783 | - ), |
|
| 784 | - '<h2>' . $report_title . '</h2><p>', |
|
| 785 | - '</p>' |
|
| 786 | - ), |
|
| 787 | - ); |
|
| 788 | - wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
| 789 | - return $report_ID; |
|
| 790 | - } |
|
| 716 | + /** |
|
| 717 | + * Generates Business Report showing total registrations per event. |
|
| 718 | + * |
|
| 719 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
| 720 | + * @return string |
|
| 721 | + * @throws EE_Error |
|
| 722 | + * @throws InvalidArgumentException |
|
| 723 | + * @throws InvalidDataTypeException |
|
| 724 | + * @throws InvalidInterfaceException |
|
| 725 | + */ |
|
| 726 | + private function _registrations_per_event_report($period = '-1 month') |
|
| 727 | + { |
|
| 728 | + $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
|
| 729 | + $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
| 730 | + $results = (array) $results; |
|
| 731 | + $regs = array(); |
|
| 732 | + $subtitle = ''; |
|
| 733 | + if ($results) { |
|
| 734 | + $column_titles = array(); |
|
| 735 | + $tracker = 0; |
|
| 736 | + foreach ($results as $result) { |
|
| 737 | + $report_column_values = array(); |
|
| 738 | + foreach ($result as $property_name => $property_value) { |
|
| 739 | + $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
| 740 | + $property_value, |
|
| 741 | + 4, |
|
| 742 | + '...' |
|
| 743 | + ) : (int) $property_value; |
|
| 744 | + $report_column_values[] = $property_value; |
|
| 745 | + if ($tracker === 0) { |
|
| 746 | + if ($property_name === 'Registration_Event') { |
|
| 747 | + $column_titles[] = esc_html__('Event', 'event_espresso'); |
|
| 748 | + } else { |
|
| 749 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
| 750 | + } |
|
| 751 | + } |
|
| 752 | + } |
|
| 753 | + $tracker++; |
|
| 754 | + $regs[] = $report_column_values; |
|
| 755 | + } |
|
| 756 | + // make sure the column_titles is pushed to the beginning of the array |
|
| 757 | + array_unshift($regs, $column_titles); |
|
| 758 | + // setup the date range. |
|
| 759 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
| 760 | + $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 761 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
| 762 | + $subtitle = sprintf( |
|
| 763 | + wp_strip_all_tags( |
|
| 764 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
| 765 | + ), |
|
| 766 | + $beginning_date->format('Y-m-d'), |
|
| 767 | + $ending_date->format('Y-m-d') |
|
| 768 | + ); |
|
| 769 | + } |
|
| 770 | + $report_title = wp_strip_all_tags(__('Total Registrations per Event', 'event_espresso')); |
|
| 771 | + $report_params = array( |
|
| 772 | + 'title' => $report_title, |
|
| 773 | + 'subtitle' => $subtitle, |
|
| 774 | + 'id' => $report_ID, |
|
| 775 | + 'regs' => $regs, |
|
| 776 | + 'noResults' => empty($regs), |
|
| 777 | + 'noRegsMsg' => sprintf( |
|
| 778 | + wp_strip_all_tags( |
|
| 779 | + __( |
|
| 780 | + '%sThere are currently no registration records in the last month for this report.%s', |
|
| 781 | + 'event_espresso' |
|
| 782 | + ) |
|
| 783 | + ), |
|
| 784 | + '<h2>' . $report_title . '</h2><p>', |
|
| 785 | + '</p>' |
|
| 786 | + ), |
|
| 787 | + ); |
|
| 788 | + wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
| 789 | + return $report_ID; |
|
| 790 | + } |
|
| 791 | 791 | |
| 792 | 792 | |
| 793 | - /** |
|
| 794 | - * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
|
| 795 | - * |
|
| 796 | - * @access protected |
|
| 797 | - * @return void |
|
| 798 | - * @throws EE_Error |
|
| 799 | - * @throws InvalidArgumentException |
|
| 800 | - * @throws InvalidDataTypeException |
|
| 801 | - * @throws InvalidInterfaceException |
|
| 802 | - * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 803 | - */ |
|
| 804 | - protected function _registration_checkin_list_table() |
|
| 805 | - { |
|
| 806 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 807 | - $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null; |
|
| 808 | - /** @var EE_Registration $registration */ |
|
| 809 | - $registration = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
| 810 | - if (! $registration instanceof EE_Registration) { |
|
| 811 | - throw new EE_Error( |
|
| 812 | - sprintf( |
|
| 813 | - esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'), |
|
| 814 | - $reg_id |
|
| 815 | - ) |
|
| 816 | - ); |
|
| 817 | - } |
|
| 818 | - $attendee = $registration->attendee(); |
|
| 819 | - $this->_admin_page_title .= $this->get_action_link_or_button( |
|
| 820 | - 'new_registration', |
|
| 821 | - 'add-registrant', |
|
| 822 | - array('event_id' => $registration->event_ID()), |
|
| 823 | - 'add-new-h2' |
|
| 824 | - ); |
|
| 825 | - $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
| 826 | - $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
| 827 | - $legend_items = array( |
|
| 828 | - 'checkin' => array( |
|
| 829 | - 'class' => $checked_in->cssClasses(), |
|
| 830 | - 'desc' => $checked_in->legendLabel(), |
|
| 831 | - ), |
|
| 832 | - 'checkout' => array( |
|
| 833 | - 'class' => $checked_out->cssClasses(), |
|
| 834 | - 'desc' => $checked_out->legendLabel(), |
|
| 835 | - ), |
|
| 836 | - ); |
|
| 837 | - $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
| 838 | - $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
| 839 | - /** @var EE_Datetime $datetime */ |
|
| 840 | - $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id); |
|
| 841 | - $datetime_label = ''; |
|
| 842 | - if ($datetime instanceof EE_Datetime) { |
|
| 843 | - $datetime_label = $datetime->get_dtt_display_name(true); |
|
| 844 | - $datetime_label .= ! empty($datetime_label) |
|
| 845 | - ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
| 846 | - : $datetime->get_dtt_display_name(); |
|
| 847 | - } |
|
| 848 | - $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration |
|
| 849 | - ? EE_Admin_Page::add_query_args_and_nonce( |
|
| 850 | - array( |
|
| 851 | - 'action' => 'event_registrations', |
|
| 852 | - 'event_id' => $registration->event_ID(), |
|
| 853 | - 'DTT_ID' => $dtt_id, |
|
| 854 | - ), |
|
| 855 | - $this->_admin_base_url |
|
| 856 | - ) |
|
| 857 | - : ''; |
|
| 858 | - $datetime_link = ! empty($datetime_link) |
|
| 859 | - ? '<a href="' . $datetime_link . '">' |
|
| 860 | - . '<span id="checkin-dtt">' |
|
| 861 | - . $datetime_label |
|
| 862 | - . '</span></a>' |
|
| 863 | - : $datetime_label; |
|
| 864 | - $attendee_name = $attendee instanceof EE_Attendee |
|
| 865 | - ? $attendee->full_name() |
|
| 866 | - : ''; |
|
| 867 | - $attendee_link = $attendee instanceof EE_Attendee |
|
| 868 | - ? $attendee->get_admin_details_link() |
|
| 869 | - : ''; |
|
| 870 | - $attendee_link = ! empty($attendee_link) |
|
| 871 | - ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
| 872 | - . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
| 873 | - . '<span id="checkin-attendee-name">' |
|
| 874 | - . $attendee_name |
|
| 875 | - . '</span></a>' |
|
| 876 | - : ''; |
|
| 877 | - $event_link = $registration->event() instanceof EE_Event |
|
| 878 | - ? $registration->event()->get_admin_details_link() |
|
| 879 | - : ''; |
|
| 880 | - $event_link = ! empty($event_link) |
|
| 881 | - ? '<a href="' . $event_link . '"' |
|
| 882 | - . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
| 883 | - . '<span id="checkin-event-name">' |
|
| 884 | - . $registration->event_name() |
|
| 885 | - . '</span>' |
|
| 886 | - . '</a>' |
|
| 887 | - : ''; |
|
| 888 | - $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
|
| 889 | - ? '<h2>' . sprintf( |
|
| 890 | - esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
|
| 891 | - $attendee_link, |
|
| 892 | - $datetime_link, |
|
| 893 | - $event_link |
|
| 894 | - ) . '</h2>' |
|
| 895 | - : ''; |
|
| 896 | - $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
|
| 897 | - ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : ''; |
|
| 898 | - $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
|
| 899 | - ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
| 900 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 901 | - } |
|
| 793 | + /** |
|
| 794 | + * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
|
| 795 | + * |
|
| 796 | + * @access protected |
|
| 797 | + * @return void |
|
| 798 | + * @throws EE_Error |
|
| 799 | + * @throws InvalidArgumentException |
|
| 800 | + * @throws InvalidDataTypeException |
|
| 801 | + * @throws InvalidInterfaceException |
|
| 802 | + * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 803 | + */ |
|
| 804 | + protected function _registration_checkin_list_table() |
|
| 805 | + { |
|
| 806 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 807 | + $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null; |
|
| 808 | + /** @var EE_Registration $registration */ |
|
| 809 | + $registration = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
| 810 | + if (! $registration instanceof EE_Registration) { |
|
| 811 | + throw new EE_Error( |
|
| 812 | + sprintf( |
|
| 813 | + esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'), |
|
| 814 | + $reg_id |
|
| 815 | + ) |
|
| 816 | + ); |
|
| 817 | + } |
|
| 818 | + $attendee = $registration->attendee(); |
|
| 819 | + $this->_admin_page_title .= $this->get_action_link_or_button( |
|
| 820 | + 'new_registration', |
|
| 821 | + 'add-registrant', |
|
| 822 | + array('event_id' => $registration->event_ID()), |
|
| 823 | + 'add-new-h2' |
|
| 824 | + ); |
|
| 825 | + $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
| 826 | + $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
| 827 | + $legend_items = array( |
|
| 828 | + 'checkin' => array( |
|
| 829 | + 'class' => $checked_in->cssClasses(), |
|
| 830 | + 'desc' => $checked_in->legendLabel(), |
|
| 831 | + ), |
|
| 832 | + 'checkout' => array( |
|
| 833 | + 'class' => $checked_out->cssClasses(), |
|
| 834 | + 'desc' => $checked_out->legendLabel(), |
|
| 835 | + ), |
|
| 836 | + ); |
|
| 837 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
| 838 | + $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
| 839 | + /** @var EE_Datetime $datetime */ |
|
| 840 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id); |
|
| 841 | + $datetime_label = ''; |
|
| 842 | + if ($datetime instanceof EE_Datetime) { |
|
| 843 | + $datetime_label = $datetime->get_dtt_display_name(true); |
|
| 844 | + $datetime_label .= ! empty($datetime_label) |
|
| 845 | + ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
| 846 | + : $datetime->get_dtt_display_name(); |
|
| 847 | + } |
|
| 848 | + $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration |
|
| 849 | + ? EE_Admin_Page::add_query_args_and_nonce( |
|
| 850 | + array( |
|
| 851 | + 'action' => 'event_registrations', |
|
| 852 | + 'event_id' => $registration->event_ID(), |
|
| 853 | + 'DTT_ID' => $dtt_id, |
|
| 854 | + ), |
|
| 855 | + $this->_admin_base_url |
|
| 856 | + ) |
|
| 857 | + : ''; |
|
| 858 | + $datetime_link = ! empty($datetime_link) |
|
| 859 | + ? '<a href="' . $datetime_link . '">' |
|
| 860 | + . '<span id="checkin-dtt">' |
|
| 861 | + . $datetime_label |
|
| 862 | + . '</span></a>' |
|
| 863 | + : $datetime_label; |
|
| 864 | + $attendee_name = $attendee instanceof EE_Attendee |
|
| 865 | + ? $attendee->full_name() |
|
| 866 | + : ''; |
|
| 867 | + $attendee_link = $attendee instanceof EE_Attendee |
|
| 868 | + ? $attendee->get_admin_details_link() |
|
| 869 | + : ''; |
|
| 870 | + $attendee_link = ! empty($attendee_link) |
|
| 871 | + ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
| 872 | + . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
| 873 | + . '<span id="checkin-attendee-name">' |
|
| 874 | + . $attendee_name |
|
| 875 | + . '</span></a>' |
|
| 876 | + : ''; |
|
| 877 | + $event_link = $registration->event() instanceof EE_Event |
|
| 878 | + ? $registration->event()->get_admin_details_link() |
|
| 879 | + : ''; |
|
| 880 | + $event_link = ! empty($event_link) |
|
| 881 | + ? '<a href="' . $event_link . '"' |
|
| 882 | + . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
| 883 | + . '<span id="checkin-event-name">' |
|
| 884 | + . $registration->event_name() |
|
| 885 | + . '</span>' |
|
| 886 | + . '</a>' |
|
| 887 | + : ''; |
|
| 888 | + $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
|
| 889 | + ? '<h2>' . sprintf( |
|
| 890 | + esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
|
| 891 | + $attendee_link, |
|
| 892 | + $datetime_link, |
|
| 893 | + $event_link |
|
| 894 | + ) . '</h2>' |
|
| 895 | + : ''; |
|
| 896 | + $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
|
| 897 | + ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : ''; |
|
| 898 | + $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
|
| 899 | + ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
| 900 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 901 | + } |
|
| 902 | 902 | |
| 903 | 903 | |
| 904 | - /** |
|
| 905 | - * toggle the Check-in status for the given registration (coming from ajax) |
|
| 906 | - * |
|
| 907 | - * @return void (JSON) |
|
| 908 | - * @throws EE_Error |
|
| 909 | - * @throws InvalidArgumentException |
|
| 910 | - * @throws InvalidDataTypeException |
|
| 911 | - * @throws InvalidInterfaceException |
|
| 912 | - */ |
|
| 913 | - public function toggle_checkin_status() |
|
| 914 | - { |
|
| 915 | - // first make sure we have the necessary data |
|
| 916 | - if (! isset($this->_req_data['_regid'])) { |
|
| 917 | - EE_Error::add_error( |
|
| 918 | - esc_html__( |
|
| 919 | - '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', |
|
| 920 | - 'event_espresso' |
|
| 921 | - ), |
|
| 922 | - __FILE__, |
|
| 923 | - __FUNCTION__, |
|
| 924 | - __LINE__ |
|
| 925 | - ); |
|
| 926 | - $this->_template_args['success'] = false; |
|
| 927 | - $this->_template_args['error'] = true; |
|
| 928 | - $this->_return_json(); |
|
| 929 | - }; |
|
| 930 | - // do a nonce check cause we're not coming in from an normal route here. |
|
| 931 | - $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
| 932 | - : ''; |
|
| 933 | - $nonce_ref = 'checkin_nonce'; |
|
| 934 | - $this->_verify_nonce($nonce, $nonce_ref); |
|
| 935 | - // beautiful! Made it this far so let's get the status. |
|
| 936 | - $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status()); |
|
| 937 | - // setup new class to return via ajax |
|
| 938 | - $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses(); |
|
| 939 | - $this->_template_args['success'] = true; |
|
| 940 | - $this->_return_json(); |
|
| 941 | - } |
|
| 904 | + /** |
|
| 905 | + * toggle the Check-in status for the given registration (coming from ajax) |
|
| 906 | + * |
|
| 907 | + * @return void (JSON) |
|
| 908 | + * @throws EE_Error |
|
| 909 | + * @throws InvalidArgumentException |
|
| 910 | + * @throws InvalidDataTypeException |
|
| 911 | + * @throws InvalidInterfaceException |
|
| 912 | + */ |
|
| 913 | + public function toggle_checkin_status() |
|
| 914 | + { |
|
| 915 | + // first make sure we have the necessary data |
|
| 916 | + if (! isset($this->_req_data['_regid'])) { |
|
| 917 | + EE_Error::add_error( |
|
| 918 | + esc_html__( |
|
| 919 | + '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', |
|
| 920 | + 'event_espresso' |
|
| 921 | + ), |
|
| 922 | + __FILE__, |
|
| 923 | + __FUNCTION__, |
|
| 924 | + __LINE__ |
|
| 925 | + ); |
|
| 926 | + $this->_template_args['success'] = false; |
|
| 927 | + $this->_template_args['error'] = true; |
|
| 928 | + $this->_return_json(); |
|
| 929 | + }; |
|
| 930 | + // do a nonce check cause we're not coming in from an normal route here. |
|
| 931 | + $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
| 932 | + : ''; |
|
| 933 | + $nonce_ref = 'checkin_nonce'; |
|
| 934 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
| 935 | + // beautiful! Made it this far so let's get the status. |
|
| 936 | + $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status()); |
|
| 937 | + // setup new class to return via ajax |
|
| 938 | + $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses(); |
|
| 939 | + $this->_template_args['success'] = true; |
|
| 940 | + $this->_return_json(); |
|
| 941 | + } |
|
| 942 | 942 | |
| 943 | 943 | |
| 944 | - /** |
|
| 945 | - * handles toggling the checkin status for the registration, |
|
| 946 | - * |
|
| 947 | - * @access protected |
|
| 948 | - * @return int|void |
|
| 949 | - * @throws EE_Error |
|
| 950 | - * @throws InvalidArgumentException |
|
| 951 | - * @throws InvalidDataTypeException |
|
| 952 | - * @throws InvalidInterfaceException |
|
| 953 | - */ |
|
| 954 | - protected function _toggle_checkin_status() |
|
| 955 | - { |
|
| 956 | - // first let's get the query args out of the way for the redirect |
|
| 957 | - $query_args = array( |
|
| 958 | - 'action' => 'event_registrations', |
|
| 959 | - 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
| 960 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null, |
|
| 961 | - ); |
|
| 962 | - $new_status = false; |
|
| 963 | - // bulk action check in toggle |
|
| 964 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 965 | - // cycle thru checkboxes |
|
| 966 | - while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 967 | - $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
| 968 | - $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
| 969 | - } |
|
| 970 | - } elseif (isset($this->_req_data['_regid'])) { |
|
| 971 | - // coming from ajax request |
|
| 972 | - $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null; |
|
| 973 | - $query_args['DTT_ID'] = $DTT_ID; |
|
| 974 | - $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
| 975 | - } else { |
|
| 976 | - EE_Error::add_error( |
|
| 977 | - esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
| 978 | - __FILE__, |
|
| 979 | - __FUNCTION__, |
|
| 980 | - __LINE__ |
|
| 981 | - ); |
|
| 982 | - } |
|
| 983 | - if (defined('DOING_AJAX')) { |
|
| 984 | - return $new_status; |
|
| 985 | - } |
|
| 986 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 987 | - } |
|
| 944 | + /** |
|
| 945 | + * handles toggling the checkin status for the registration, |
|
| 946 | + * |
|
| 947 | + * @access protected |
|
| 948 | + * @return int|void |
|
| 949 | + * @throws EE_Error |
|
| 950 | + * @throws InvalidArgumentException |
|
| 951 | + * @throws InvalidDataTypeException |
|
| 952 | + * @throws InvalidInterfaceException |
|
| 953 | + */ |
|
| 954 | + protected function _toggle_checkin_status() |
|
| 955 | + { |
|
| 956 | + // first let's get the query args out of the way for the redirect |
|
| 957 | + $query_args = array( |
|
| 958 | + 'action' => 'event_registrations', |
|
| 959 | + 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
| 960 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null, |
|
| 961 | + ); |
|
| 962 | + $new_status = false; |
|
| 963 | + // bulk action check in toggle |
|
| 964 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 965 | + // cycle thru checkboxes |
|
| 966 | + while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 967 | + $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
| 968 | + $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
| 969 | + } |
|
| 970 | + } elseif (isset($this->_req_data['_regid'])) { |
|
| 971 | + // coming from ajax request |
|
| 972 | + $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null; |
|
| 973 | + $query_args['DTT_ID'] = $DTT_ID; |
|
| 974 | + $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
| 975 | + } else { |
|
| 976 | + EE_Error::add_error( |
|
| 977 | + esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
| 978 | + __FILE__, |
|
| 979 | + __FUNCTION__, |
|
| 980 | + __LINE__ |
|
| 981 | + ); |
|
| 982 | + } |
|
| 983 | + if (defined('DOING_AJAX')) { |
|
| 984 | + return $new_status; |
|
| 985 | + } |
|
| 986 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 987 | + } |
|
| 988 | 988 | |
| 989 | 989 | |
| 990 | - /** |
|
| 991 | - * This is toggles a single Check-in for the given registration and datetime. |
|
| 992 | - * |
|
| 993 | - * @param int $REG_ID The registration we're toggling |
|
| 994 | - * @param int $DTT_ID The datetime we're toggling |
|
| 995 | - * @return int The new status toggled to. |
|
| 996 | - * @throws EE_Error |
|
| 997 | - * @throws InvalidArgumentException |
|
| 998 | - * @throws InvalidDataTypeException |
|
| 999 | - * @throws InvalidInterfaceException |
|
| 1000 | - */ |
|
| 1001 | - private function _toggle_checkin($REG_ID, $DTT_ID) |
|
| 1002 | - { |
|
| 1003 | - /** @var EE_Registration $REG */ |
|
| 1004 | - $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 1005 | - $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
| 1006 | - if ($new_status !== false) { |
|
| 1007 | - EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
| 1008 | - } else { |
|
| 1009 | - EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
| 1010 | - $new_status = false; |
|
| 1011 | - } |
|
| 1012 | - return $new_status; |
|
| 1013 | - } |
|
| 990 | + /** |
|
| 991 | + * This is toggles a single Check-in for the given registration and datetime. |
|
| 992 | + * |
|
| 993 | + * @param int $REG_ID The registration we're toggling |
|
| 994 | + * @param int $DTT_ID The datetime we're toggling |
|
| 995 | + * @return int The new status toggled to. |
|
| 996 | + * @throws EE_Error |
|
| 997 | + * @throws InvalidArgumentException |
|
| 998 | + * @throws InvalidDataTypeException |
|
| 999 | + * @throws InvalidInterfaceException |
|
| 1000 | + */ |
|
| 1001 | + private function _toggle_checkin($REG_ID, $DTT_ID) |
|
| 1002 | + { |
|
| 1003 | + /** @var EE_Registration $REG */ |
|
| 1004 | + $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 1005 | + $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
| 1006 | + if ($new_status !== false) { |
|
| 1007 | + EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
| 1008 | + } else { |
|
| 1009 | + EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
| 1010 | + $new_status = false; |
|
| 1011 | + } |
|
| 1012 | + return $new_status; |
|
| 1013 | + } |
|
| 1014 | 1014 | |
| 1015 | 1015 | |
| 1016 | - /** |
|
| 1017 | - * Takes care of deleting multiple EE_Checkin table rows |
|
| 1018 | - * |
|
| 1019 | - * @access protected |
|
| 1020 | - * @return void |
|
| 1021 | - * @throws EE_Error |
|
| 1022 | - * @throws InvalidArgumentException |
|
| 1023 | - * @throws InvalidDataTypeException |
|
| 1024 | - * @throws InvalidInterfaceException |
|
| 1025 | - */ |
|
| 1026 | - protected function _delete_checkin_rows() |
|
| 1027 | - { |
|
| 1028 | - $query_args = array( |
|
| 1029 | - 'action' => 'registration_checkins', |
|
| 1030 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
| 1031 | - '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
| 1032 | - ); |
|
| 1033 | - $errors = 0; |
|
| 1034 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 1035 | - while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 1036 | - if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
| 1037 | - $errors++; |
|
| 1038 | - } |
|
| 1039 | - } |
|
| 1040 | - } else { |
|
| 1041 | - EE_Error::add_error( |
|
| 1042 | - esc_html__( |
|
| 1043 | - 'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', |
|
| 1044 | - 'event_espresso' |
|
| 1045 | - ), |
|
| 1046 | - __FILE__, |
|
| 1047 | - __FUNCTION__, |
|
| 1048 | - __LINE__ |
|
| 1049 | - ); |
|
| 1050 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 1051 | - } |
|
| 1052 | - if ($errors > 0) { |
|
| 1053 | - EE_Error::add_error( |
|
| 1054 | - sprintf(esc_html__('There were %d records that did not delete successfully', 'event_espresso'), $errors), |
|
| 1055 | - __FILE__, |
|
| 1056 | - __FUNCTION__, |
|
| 1057 | - __LINE__ |
|
| 1058 | - ); |
|
| 1059 | - } else { |
|
| 1060 | - EE_Error::add_success(esc_html__('Records were successfully deleted', 'event_espresso')); |
|
| 1061 | - } |
|
| 1062 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 1063 | - } |
|
| 1016 | + /** |
|
| 1017 | + * Takes care of deleting multiple EE_Checkin table rows |
|
| 1018 | + * |
|
| 1019 | + * @access protected |
|
| 1020 | + * @return void |
|
| 1021 | + * @throws EE_Error |
|
| 1022 | + * @throws InvalidArgumentException |
|
| 1023 | + * @throws InvalidDataTypeException |
|
| 1024 | + * @throws InvalidInterfaceException |
|
| 1025 | + */ |
|
| 1026 | + protected function _delete_checkin_rows() |
|
| 1027 | + { |
|
| 1028 | + $query_args = array( |
|
| 1029 | + 'action' => 'registration_checkins', |
|
| 1030 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
| 1031 | + '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
| 1032 | + ); |
|
| 1033 | + $errors = 0; |
|
| 1034 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 1035 | + while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 1036 | + if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
| 1037 | + $errors++; |
|
| 1038 | + } |
|
| 1039 | + } |
|
| 1040 | + } else { |
|
| 1041 | + EE_Error::add_error( |
|
| 1042 | + esc_html__( |
|
| 1043 | + 'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', |
|
| 1044 | + 'event_espresso' |
|
| 1045 | + ), |
|
| 1046 | + __FILE__, |
|
| 1047 | + __FUNCTION__, |
|
| 1048 | + __LINE__ |
|
| 1049 | + ); |
|
| 1050 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 1051 | + } |
|
| 1052 | + if ($errors > 0) { |
|
| 1053 | + EE_Error::add_error( |
|
| 1054 | + sprintf(esc_html__('There were %d records that did not delete successfully', 'event_espresso'), $errors), |
|
| 1055 | + __FILE__, |
|
| 1056 | + __FUNCTION__, |
|
| 1057 | + __LINE__ |
|
| 1058 | + ); |
|
| 1059 | + } else { |
|
| 1060 | + EE_Error::add_success(esc_html__('Records were successfully deleted', 'event_espresso')); |
|
| 1061 | + } |
|
| 1062 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 1063 | + } |
|
| 1064 | 1064 | |
| 1065 | 1065 | |
| 1066 | - /** |
|
| 1067 | - * Deletes a single EE_Checkin row |
|
| 1068 | - * |
|
| 1069 | - * @return void |
|
| 1070 | - * @throws EE_Error |
|
| 1071 | - * @throws InvalidArgumentException |
|
| 1072 | - * @throws InvalidDataTypeException |
|
| 1073 | - * @throws InvalidInterfaceException |
|
| 1074 | - */ |
|
| 1075 | - protected function _delete_checkin_row() |
|
| 1076 | - { |
|
| 1077 | - $query_args = array( |
|
| 1078 | - 'action' => 'registration_checkins', |
|
| 1079 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
| 1080 | - '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
| 1081 | - ); |
|
| 1082 | - if (! empty($this->_req_data['CHK_ID'])) { |
|
| 1083 | - if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
| 1084 | - EE_Error::add_error( |
|
| 1085 | - esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
| 1086 | - __FILE__, |
|
| 1087 | - __FUNCTION__, |
|
| 1088 | - __LINE__ |
|
| 1089 | - ); |
|
| 1090 | - } else { |
|
| 1091 | - EE_Error::add_success(esc_html__('Check-In record successfully deleted', 'event_espresso')); |
|
| 1092 | - } |
|
| 1093 | - } else { |
|
| 1094 | - EE_Error::add_error( |
|
| 1095 | - esc_html__( |
|
| 1096 | - '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', |
|
| 1097 | - 'event_espresso' |
|
| 1098 | - ), |
|
| 1099 | - __FILE__, |
|
| 1100 | - __FUNCTION__, |
|
| 1101 | - __LINE__ |
|
| 1102 | - ); |
|
| 1103 | - } |
|
| 1104 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 1105 | - } |
|
| 1066 | + /** |
|
| 1067 | + * Deletes a single EE_Checkin row |
|
| 1068 | + * |
|
| 1069 | + * @return void |
|
| 1070 | + * @throws EE_Error |
|
| 1071 | + * @throws InvalidArgumentException |
|
| 1072 | + * @throws InvalidDataTypeException |
|
| 1073 | + * @throws InvalidInterfaceException |
|
| 1074 | + */ |
|
| 1075 | + protected function _delete_checkin_row() |
|
| 1076 | + { |
|
| 1077 | + $query_args = array( |
|
| 1078 | + 'action' => 'registration_checkins', |
|
| 1079 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
| 1080 | + '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
| 1081 | + ); |
|
| 1082 | + if (! empty($this->_req_data['CHK_ID'])) { |
|
| 1083 | + if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
| 1084 | + EE_Error::add_error( |
|
| 1085 | + esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
| 1086 | + __FILE__, |
|
| 1087 | + __FUNCTION__, |
|
| 1088 | + __LINE__ |
|
| 1089 | + ); |
|
| 1090 | + } else { |
|
| 1091 | + EE_Error::add_success(esc_html__('Check-In record successfully deleted', 'event_espresso')); |
|
| 1092 | + } |
|
| 1093 | + } else { |
|
| 1094 | + EE_Error::add_error( |
|
| 1095 | + esc_html__( |
|
| 1096 | + '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', |
|
| 1097 | + 'event_espresso' |
|
| 1098 | + ), |
|
| 1099 | + __FILE__, |
|
| 1100 | + __FUNCTION__, |
|
| 1101 | + __LINE__ |
|
| 1102 | + ); |
|
| 1103 | + } |
|
| 1104 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 1105 | + } |
|
| 1106 | 1106 | |
| 1107 | 1107 | |
| 1108 | - /** |
|
| 1109 | - * generates HTML for the Event Registrations List Table |
|
| 1110 | - * |
|
| 1111 | - * @access protected |
|
| 1112 | - * @return void |
|
| 1113 | - * @throws EE_Error |
|
| 1114 | - * @throws InvalidArgumentException |
|
| 1115 | - * @throws InvalidDataTypeException |
|
| 1116 | - * @throws InvalidInterfaceException |
|
| 1117 | - */ |
|
| 1118 | - protected function _event_registrations_list_table() |
|
| 1119 | - { |
|
| 1120 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1121 | - $this->_admin_page_title .= isset($this->_req_data['event_id']) |
|
| 1122 | - ? $this->get_action_link_or_button( |
|
| 1123 | - 'new_registration', |
|
| 1124 | - 'add-registrant', |
|
| 1125 | - array('event_id' => $this->_req_data['event_id']), |
|
| 1126 | - 'add-new-h2', |
|
| 1127 | - '', |
|
| 1128 | - false |
|
| 1129 | - ) |
|
| 1130 | - : ''; |
|
| 1131 | - $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
| 1132 | - $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
| 1133 | - $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never); |
|
| 1134 | - $legend_items = array( |
|
| 1135 | - 'star-icon' => array( |
|
| 1136 | - 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
| 1137 | - 'desc' => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'), |
|
| 1138 | - ), |
|
| 1139 | - 'checkin' => array( |
|
| 1140 | - 'class' => $checked_in->cssClasses(), |
|
| 1141 | - 'desc' => $checked_in->legendLabel(), |
|
| 1142 | - ), |
|
| 1143 | - 'checkout' => array( |
|
| 1144 | - 'class' => $checked_out->cssClasses(), |
|
| 1145 | - 'desc' => $checked_out->legendLabel(), |
|
| 1146 | - ), |
|
| 1147 | - 'nocheckinrecord' => array( |
|
| 1148 | - 'class' => $checked_never->cssClasses(), |
|
| 1149 | - 'desc' => $checked_never->legendLabel(), |
|
| 1150 | - ), |
|
| 1151 | - 'approved_status' => array( |
|
| 1152 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 1153 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
| 1154 | - ), |
|
| 1155 | - 'cancelled_status' => array( |
|
| 1156 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 1157 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
| 1158 | - ), |
|
| 1159 | - 'declined_status' => array( |
|
| 1160 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 1161 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
| 1162 | - ), |
|
| 1163 | - 'not_approved' => array( |
|
| 1164 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 1165 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
| 1166 | - ), |
|
| 1167 | - 'pending_status' => array( |
|
| 1168 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 1169 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
| 1170 | - ), |
|
| 1171 | - 'wait_list' => array( |
|
| 1172 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 1173 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
| 1174 | - ), |
|
| 1175 | - ); |
|
| 1176 | - $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
| 1177 | - $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
| 1178 | - /** @var EE_Event $event */ |
|
| 1179 | - $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
| 1180 | - $this->_template_args['before_list_table'] = $event instanceof EE_Event |
|
| 1181 | - ? '<h2>' . sprintf( |
|
| 1182 | - esc_html__('Viewing Registrations for Event: %s', 'event_espresso'), |
|
| 1183 | - EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') |
|
| 1184 | - ) . '</h2>' |
|
| 1185 | - : ''; |
|
| 1186 | - // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on |
|
| 1187 | - // the event. |
|
| 1188 | - $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0; |
|
| 1189 | - $datetime = null; |
|
| 1190 | - if ($event instanceof EE_Event) { |
|
| 1191 | - $datetimes_on_event = $event->datetimes(); |
|
| 1192 | - if (count($datetimes_on_event) === 1) { |
|
| 1193 | - $datetime = reset($datetimes_on_event); |
|
| 1194 | - } |
|
| 1195 | - } |
|
| 1196 | - $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 1197 | - if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') { |
|
| 1198 | - $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5); |
|
| 1199 | - $this->_template_args['before_list_table'] .= ' <span class="drk-grey-text">'; |
|
| 1200 | - $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
| 1201 | - $this->_template_args['before_list_table'] .= $datetime->name(); |
|
| 1202 | - $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
| 1203 | - $this->_template_args['before_list_table'] .= '</span></h2>'; |
|
| 1204 | - } |
|
| 1205 | - // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status |
|
| 1206 | - // column represents |
|
| 1207 | - if (! $datetime instanceof EE_Datetime) { |
|
| 1208 | - $this->_template_args['before_list_table'] .= '<br><p class="description">' |
|
| 1209 | - . esc_html__( |
|
| 1210 | - 'In this view, the check-in status represents the latest check-in record for the registration in that row.', |
|
| 1211 | - 'event_espresso' |
|
| 1212 | - ) |
|
| 1213 | - . '</p>'; |
|
| 1214 | - } |
|
| 1215 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 1216 | - } |
|
| 1108 | + /** |
|
| 1109 | + * generates HTML for the Event Registrations List Table |
|
| 1110 | + * |
|
| 1111 | + * @access protected |
|
| 1112 | + * @return void |
|
| 1113 | + * @throws EE_Error |
|
| 1114 | + * @throws InvalidArgumentException |
|
| 1115 | + * @throws InvalidDataTypeException |
|
| 1116 | + * @throws InvalidInterfaceException |
|
| 1117 | + */ |
|
| 1118 | + protected function _event_registrations_list_table() |
|
| 1119 | + { |
|
| 1120 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1121 | + $this->_admin_page_title .= isset($this->_req_data['event_id']) |
|
| 1122 | + ? $this->get_action_link_or_button( |
|
| 1123 | + 'new_registration', |
|
| 1124 | + 'add-registrant', |
|
| 1125 | + array('event_id' => $this->_req_data['event_id']), |
|
| 1126 | + 'add-new-h2', |
|
| 1127 | + '', |
|
| 1128 | + false |
|
| 1129 | + ) |
|
| 1130 | + : ''; |
|
| 1131 | + $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
| 1132 | + $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
| 1133 | + $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never); |
|
| 1134 | + $legend_items = array( |
|
| 1135 | + 'star-icon' => array( |
|
| 1136 | + 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
| 1137 | + 'desc' => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'), |
|
| 1138 | + ), |
|
| 1139 | + 'checkin' => array( |
|
| 1140 | + 'class' => $checked_in->cssClasses(), |
|
| 1141 | + 'desc' => $checked_in->legendLabel(), |
|
| 1142 | + ), |
|
| 1143 | + 'checkout' => array( |
|
| 1144 | + 'class' => $checked_out->cssClasses(), |
|
| 1145 | + 'desc' => $checked_out->legendLabel(), |
|
| 1146 | + ), |
|
| 1147 | + 'nocheckinrecord' => array( |
|
| 1148 | + 'class' => $checked_never->cssClasses(), |
|
| 1149 | + 'desc' => $checked_never->legendLabel(), |
|
| 1150 | + ), |
|
| 1151 | + 'approved_status' => array( |
|
| 1152 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 1153 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
| 1154 | + ), |
|
| 1155 | + 'cancelled_status' => array( |
|
| 1156 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 1157 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
| 1158 | + ), |
|
| 1159 | + 'declined_status' => array( |
|
| 1160 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 1161 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
| 1162 | + ), |
|
| 1163 | + 'not_approved' => array( |
|
| 1164 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 1165 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
| 1166 | + ), |
|
| 1167 | + 'pending_status' => array( |
|
| 1168 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 1169 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
| 1170 | + ), |
|
| 1171 | + 'wait_list' => array( |
|
| 1172 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 1173 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
| 1174 | + ), |
|
| 1175 | + ); |
|
| 1176 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
| 1177 | + $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
| 1178 | + /** @var EE_Event $event */ |
|
| 1179 | + $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
| 1180 | + $this->_template_args['before_list_table'] = $event instanceof EE_Event |
|
| 1181 | + ? '<h2>' . sprintf( |
|
| 1182 | + esc_html__('Viewing Registrations for Event: %s', 'event_espresso'), |
|
| 1183 | + EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') |
|
| 1184 | + ) . '</h2>' |
|
| 1185 | + : ''; |
|
| 1186 | + // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on |
|
| 1187 | + // the event. |
|
| 1188 | + $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0; |
|
| 1189 | + $datetime = null; |
|
| 1190 | + if ($event instanceof EE_Event) { |
|
| 1191 | + $datetimes_on_event = $event->datetimes(); |
|
| 1192 | + if (count($datetimes_on_event) === 1) { |
|
| 1193 | + $datetime = reset($datetimes_on_event); |
|
| 1194 | + } |
|
| 1195 | + } |
|
| 1196 | + $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 1197 | + if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') { |
|
| 1198 | + $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5); |
|
| 1199 | + $this->_template_args['before_list_table'] .= ' <span class="drk-grey-text">'; |
|
| 1200 | + $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
| 1201 | + $this->_template_args['before_list_table'] .= $datetime->name(); |
|
| 1202 | + $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
| 1203 | + $this->_template_args['before_list_table'] .= '</span></h2>'; |
|
| 1204 | + } |
|
| 1205 | + // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status |
|
| 1206 | + // column represents |
|
| 1207 | + if (! $datetime instanceof EE_Datetime) { |
|
| 1208 | + $this->_template_args['before_list_table'] .= '<br><p class="description">' |
|
| 1209 | + . esc_html__( |
|
| 1210 | + 'In this view, the check-in status represents the latest check-in record for the registration in that row.', |
|
| 1211 | + 'event_espresso' |
|
| 1212 | + ) |
|
| 1213 | + . '</p>'; |
|
| 1214 | + } |
|
| 1215 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 1216 | + } |
|
| 1217 | 1217 | |
| 1218 | - /** |
|
| 1219 | - * Download the registrations check-in report (same as the normal registration report, but with different where |
|
| 1220 | - * conditions) |
|
| 1221 | - * |
|
| 1222 | - * @return void ends the request by a redirect or download |
|
| 1223 | - */ |
|
| 1224 | - public function _registrations_checkin_report() |
|
| 1225 | - { |
|
| 1226 | - $this->_registrations_report_base('_get_checkin_query_params_from_request'); |
|
| 1227 | - } |
|
| 1218 | + /** |
|
| 1219 | + * Download the registrations check-in report (same as the normal registration report, but with different where |
|
| 1220 | + * conditions) |
|
| 1221 | + * |
|
| 1222 | + * @return void ends the request by a redirect or download |
|
| 1223 | + */ |
|
| 1224 | + public function _registrations_checkin_report() |
|
| 1225 | + { |
|
| 1226 | + $this->_registrations_report_base('_get_checkin_query_params_from_request'); |
|
| 1227 | + } |
|
| 1228 | 1228 | |
| 1229 | - /** |
|
| 1230 | - * Gets the query params from the request, plus adds a where condition for the registration status, |
|
| 1231 | - * because on the checkin page we only ever want to see approved and pending-approval registrations |
|
| 1232 | - * |
|
| 1233 | - * @param array $request |
|
| 1234 | - * @param int $per_page |
|
| 1235 | - * @param bool $count |
|
| 1236 | - * @return array |
|
| 1237 | - * @throws EE_Error |
|
| 1238 | - */ |
|
| 1239 | - protected function _get_checkin_query_params_from_request( |
|
| 1240 | - $request, |
|
| 1241 | - $per_page = 10, |
|
| 1242 | - $count = false |
|
| 1243 | - ) { |
|
| 1244 | - $query_params = $this->_get_registration_query_parameters($request, $per_page, $count); |
|
| 1245 | - // unlike the regular registrations list table, |
|
| 1246 | - $status_ids_array = apply_filters( |
|
| 1247 | - 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
| 1248 | - array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
| 1249 | - ); |
|
| 1250 | - $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
| 1251 | - return $query_params; |
|
| 1252 | - } |
|
| 1229 | + /** |
|
| 1230 | + * Gets the query params from the request, plus adds a where condition for the registration status, |
|
| 1231 | + * because on the checkin page we only ever want to see approved and pending-approval registrations |
|
| 1232 | + * |
|
| 1233 | + * @param array $request |
|
| 1234 | + * @param int $per_page |
|
| 1235 | + * @param bool $count |
|
| 1236 | + * @return array |
|
| 1237 | + * @throws EE_Error |
|
| 1238 | + */ |
|
| 1239 | + protected function _get_checkin_query_params_from_request( |
|
| 1240 | + $request, |
|
| 1241 | + $per_page = 10, |
|
| 1242 | + $count = false |
|
| 1243 | + ) { |
|
| 1244 | + $query_params = $this->_get_registration_query_parameters($request, $per_page, $count); |
|
| 1245 | + // unlike the regular registrations list table, |
|
| 1246 | + $status_ids_array = apply_filters( |
|
| 1247 | + 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
| 1248 | + array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
| 1249 | + ); |
|
| 1250 | + $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
| 1251 | + return $query_params; |
|
| 1252 | + } |
|
| 1253 | 1253 | |
| 1254 | 1254 | |
| 1255 | - /** |
|
| 1256 | - * Gets registrations for an event |
|
| 1257 | - * |
|
| 1258 | - * @param int $per_page |
|
| 1259 | - * @param bool $count whether to return count or data. |
|
| 1260 | - * @param bool $trash |
|
| 1261 | - * @param string $orderby |
|
| 1262 | - * @return EE_Registration[]|int |
|
| 1263 | - * @throws EE_Error |
|
| 1264 | - * @throws InvalidArgumentException |
|
| 1265 | - * @throws InvalidDataTypeException |
|
| 1266 | - * @throws InvalidInterfaceException |
|
| 1267 | - */ |
|
| 1268 | - public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname') |
|
| 1269 | - { |
|
| 1270 | - // set some defaults, these will get overridden if included in the actual request parameters |
|
| 1271 | - $defaults = [ |
|
| 1272 | - 'orderby' => $orderby, |
|
| 1273 | - 'order' => 'ASC', |
|
| 1274 | - ]; |
|
| 1275 | - if ($trash) { |
|
| 1276 | - $defaults['status'] = 'trash'; |
|
| 1277 | - } |
|
| 1278 | - $query_params = $this->_get_checkin_query_params_from_request($defaults, $per_page, $count); |
|
| 1255 | + /** |
|
| 1256 | + * Gets registrations for an event |
|
| 1257 | + * |
|
| 1258 | + * @param int $per_page |
|
| 1259 | + * @param bool $count whether to return count or data. |
|
| 1260 | + * @param bool $trash |
|
| 1261 | + * @param string $orderby |
|
| 1262 | + * @return EE_Registration[]|int |
|
| 1263 | + * @throws EE_Error |
|
| 1264 | + * @throws InvalidArgumentException |
|
| 1265 | + * @throws InvalidDataTypeException |
|
| 1266 | + * @throws InvalidInterfaceException |
|
| 1267 | + */ |
|
| 1268 | + public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname') |
|
| 1269 | + { |
|
| 1270 | + // set some defaults, these will get overridden if included in the actual request parameters |
|
| 1271 | + $defaults = [ |
|
| 1272 | + 'orderby' => $orderby, |
|
| 1273 | + 'order' => 'ASC', |
|
| 1274 | + ]; |
|
| 1275 | + if ($trash) { |
|
| 1276 | + $defaults['status'] = 'trash'; |
|
| 1277 | + } |
|
| 1278 | + $query_params = $this->_get_checkin_query_params_from_request($defaults, $per_page, $count); |
|
| 1279 | 1279 | |
| 1280 | - /** |
|
| 1281 | - * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
| 1282 | - * |
|
| 1283 | - * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
| 1284 | - * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
| 1285 | - * or if you have the development copy of EE you can view this at the path: |
|
| 1286 | - * /docs/G--Model-System/model-query-params.md |
|
| 1287 | - */ |
|
| 1288 | - $query_params['group_by'] = ''; |
|
| 1280 | + /** |
|
| 1281 | + * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
| 1282 | + * |
|
| 1283 | + * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
| 1284 | + * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
| 1285 | + * or if you have the development copy of EE you can view this at the path: |
|
| 1286 | + * /docs/G--Model-System/model-query-params.md |
|
| 1287 | + */ |
|
| 1288 | + $query_params['group_by'] = ''; |
|
| 1289 | 1289 | |
| 1290 | - return $count |
|
| 1291 | - ? EEM_Registration::instance()->count($query_params) |
|
| 1292 | - /** @type EE_Registration[] */ |
|
| 1293 | - : EEM_Registration::instance()->get_all($query_params); |
|
| 1294 | - } |
|
| 1290 | + return $count |
|
| 1291 | + ? EEM_Registration::instance()->count($query_params) |
|
| 1292 | + /** @type EE_Registration[] */ |
|
| 1293 | + : EEM_Registration::instance()->get_all($query_params); |
|
| 1294 | + } |
|
| 1295 | 1295 | } |
@@ -30,10 +30,10 @@ discard block |
||
| 30 | 30 | public function __construct($routing = true) |
| 31 | 31 | { |
| 32 | 32 | parent::__construct($routing); |
| 33 | - if (! defined('REG_CAF_TEMPLATE_PATH')) { |
|
| 34 | - define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
| 35 | - define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
| 36 | - define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
| 33 | + if ( ! defined('REG_CAF_TEMPLATE_PATH')) { |
|
| 34 | + define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'registrations/templates/'); |
|
| 35 | + define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'registrations/assets/'); |
|
| 36 | + define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registrations/assets/'); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | protected function _extend_page_config() |
| 45 | 45 | { |
| 46 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
| 46 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'registrations'; |
|
| 47 | 47 | $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
| 48 | 48 | ? $this->_req_data['_REG_ID'] |
| 49 | 49 | : 0; |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | 'label' => esc_html__('Event Check-In', 'event_espresso'), |
| 117 | 117 | 'order' => 10, |
| 118 | 118 | 'persistent' => true, |
| 119 | - 'url' => !empty($EVT_ID) && $this->get_current_view() !== 'event_registrations' |
|
| 119 | + 'url' => ! empty($EVT_ID) && $this->get_current_view() !== 'event_registrations' |
|
| 120 | 120 | ? self::add_query_args_and_nonce(array('action' => 'event_registrations', 'event_id' => $EVT_ID), $this->_admin_base_url) |
| 121 | 121 | : null, |
| 122 | 122 | ), |
@@ -186,14 +186,14 @@ discard block |
||
| 186 | 186 | // enqueue newsletter js |
| 187 | 187 | wp_enqueue_script( |
| 188 | 188 | 'ee-newsletter-trigger', |
| 189 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
| 189 | + REG_CAF_ASSETS_URL.'ee-newsletter-trigger.js', |
|
| 190 | 190 | array('ee-dialog'), |
| 191 | 191 | EVENT_ESPRESSO_VERSION, |
| 192 | 192 | true |
| 193 | 193 | ); |
| 194 | 194 | wp_enqueue_style( |
| 195 | 195 | 'ee-newsletter-trigger-css', |
| 196 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
| 196 | + REG_CAF_ASSETS_URL.'ee-newsletter-trigger.css', |
|
| 197 | 197 | array(), |
| 198 | 198 | EVENT_ESPRESSO_VERSION |
| 199 | 199 | ); |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | { |
| 215 | 215 | wp_register_script( |
| 216 | 216 | 'ee-reg-reports-js', |
| 217 | - REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
| 217 | + REG_CAF_ASSETS_URL.'ee-registration-admin-reports.js', |
|
| 218 | 218 | array('google-charts'), |
| 219 | 219 | EVENT_ESPRESSO_VERSION, |
| 220 | 220 | true |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | $nonce_ref = 'get_newsletter_form_content_nonce'; |
| 301 | 301 | $this->_verify_nonce($nonce, $nonce_ref); |
| 302 | 302 | // let's get the mtp for the incoming MTP_ ID |
| 303 | - if (! isset($this->_req_data['GRP_ID'])) { |
|
| 303 | + if ( ! isset($this->_req_data['GRP_ID'])) { |
|
| 304 | 304 | EE_Error::add_error( |
| 305 | 305 | esc_html__( |
| 306 | 306 | '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).', |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | $this->_return_json(); |
| 316 | 316 | } |
| 317 | 317 | $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
| 318 | - if (! $MTPG instanceof EE_Message_Template_Group) { |
|
| 318 | + if ( ! $MTPG instanceof EE_Message_Template_Group) { |
|
| 319 | 319 | EE_Error::add_error( |
| 320 | 320 | sprintf( |
| 321 | 321 | esc_html__( |
@@ -340,12 +340,12 @@ discard block |
||
| 340 | 340 | $field = $MTP->get('MTP_template_field'); |
| 341 | 341 | if ($field === 'content') { |
| 342 | 342 | $content = $MTP->get('MTP_content'); |
| 343 | - if (! empty($content['newsletter_content'])) { |
|
| 343 | + if ( ! empty($content['newsletter_content'])) { |
|
| 344 | 344 | $template_fields['newsletter_content'] = $content['newsletter_content']; |
| 345 | 345 | } |
| 346 | 346 | continue; |
| 347 | 347 | } |
| 348 | - $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content'); |
|
| 348 | + $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content'); |
|
| 349 | 349 | } |
| 350 | 350 | $this->_template_args['success'] = true; |
| 351 | 351 | $this->_template_args['error'] = false; |
@@ -447,17 +447,17 @@ discard block |
||
| 447 | 447 | $field_id = $field === '[NEWSLETTER_CONTENT]' |
| 448 | 448 | ? 'content' |
| 449 | 449 | : $field; |
| 450 | - $field_id = 'batch-message-' . strtolower($field_id); |
|
| 450 | + $field_id = 'batch-message-'.strtolower($field_id); |
|
| 451 | 451 | $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="' |
| 452 | 452 | . $shortcode |
| 453 | - . '" data-linked-input-id="' . $field_id . '">' |
|
| 453 | + . '" data-linked-input-id="'.$field_id.'">' |
|
| 454 | 454 | . $shortcode |
| 455 | 455 | . '</span>'; |
| 456 | 456 | } |
| 457 | - $codes[ $field ] = implode(', ', $available_shortcodes); |
|
| 457 | + $codes[$field] = implode(', ', $available_shortcodes); |
|
| 458 | 458 | } |
| 459 | 459 | $shortcodes = $codes; |
| 460 | - $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
| 460 | + $form_template = REG_CAF_TEMPLATE_PATH.'newsletter-send-form.template.php'; |
|
| 461 | 461 | $form_template_args = array( |
| 462 | 462 | 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
| 463 | 463 | 'form_route' => 'newsletter_selected_send', |
@@ -625,7 +625,7 @@ discard block |
||
| 625 | 625 | */ |
| 626 | 626 | protected function _registration_reports() |
| 627 | 627 | { |
| 628 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
| 628 | + $template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php'; |
|
| 629 | 629 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
| 630 | 630 | $template_path, |
| 631 | 631 | $this->_reports_template_data, |
@@ -680,7 +680,7 @@ discard block |
||
| 680 | 680 | array_unshift($regs, $column_titles); |
| 681 | 681 | // setup the date range. |
| 682 | 682 | $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
| 683 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 683 | + $beginning_date = new DateTime("now ".$period, $DateTimeZone); |
|
| 684 | 684 | $ending_date = new DateTime("now", $DateTimeZone); |
| 685 | 685 | $subtitle = sprintf( |
| 686 | 686 | wp_strip_all_tags( |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | 'event_espresso' |
| 705 | 705 | ) |
| 706 | 706 | ), |
| 707 | - '<h2>' . $report_title . '</h2><p>', |
|
| 707 | + '<h2>'.$report_title.'</h2><p>', |
|
| 708 | 708 | '</p>' |
| 709 | 709 | ), |
| 710 | 710 | ); |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | array_unshift($regs, $column_titles); |
| 758 | 758 | // setup the date range. |
| 759 | 759 | $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
| 760 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 760 | + $beginning_date = new DateTime("now ".$period, $DateTimeZone); |
|
| 761 | 761 | $ending_date = new DateTime("now", $DateTimeZone); |
| 762 | 762 | $subtitle = sprintf( |
| 763 | 763 | wp_strip_all_tags( |
@@ -781,7 +781,7 @@ discard block |
||
| 781 | 781 | 'event_espresso' |
| 782 | 782 | ) |
| 783 | 783 | ), |
| 784 | - '<h2>' . $report_title . '</h2><p>', |
|
| 784 | + '<h2>'.$report_title.'</h2><p>', |
|
| 785 | 785 | '</p>' |
| 786 | 786 | ), |
| 787 | 787 | ); |
@@ -807,7 +807,7 @@ discard block |
||
| 807 | 807 | $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null; |
| 808 | 808 | /** @var EE_Registration $registration */ |
| 809 | 809 | $registration = EEM_Registration::instance()->get_one_by_ID($reg_id); |
| 810 | - if (! $registration instanceof EE_Registration) { |
|
| 810 | + if ( ! $registration instanceof EE_Registration) { |
|
| 811 | 811 | throw new EE_Error( |
| 812 | 812 | sprintf( |
| 813 | 813 | esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'), |
@@ -842,7 +842,7 @@ discard block |
||
| 842 | 842 | if ($datetime instanceof EE_Datetime) { |
| 843 | 843 | $datetime_label = $datetime->get_dtt_display_name(true); |
| 844 | 844 | $datetime_label .= ! empty($datetime_label) |
| 845 | - ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
| 845 | + ? ' ('.$datetime->get_dtt_display_name().')' |
|
| 846 | 846 | : $datetime->get_dtt_display_name(); |
| 847 | 847 | } |
| 848 | 848 | $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration |
@@ -856,7 +856,7 @@ discard block |
||
| 856 | 856 | ) |
| 857 | 857 | : ''; |
| 858 | 858 | $datetime_link = ! empty($datetime_link) |
| 859 | - ? '<a href="' . $datetime_link . '">' |
|
| 859 | + ? '<a href="'.$datetime_link.'">' |
|
| 860 | 860 | . '<span id="checkin-dtt">' |
| 861 | 861 | . $datetime_label |
| 862 | 862 | . '</span></a>' |
@@ -868,8 +868,8 @@ discard block |
||
| 868 | 868 | ? $attendee->get_admin_details_link() |
| 869 | 869 | : ''; |
| 870 | 870 | $attendee_link = ! empty($attendee_link) |
| 871 | - ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
| 872 | - . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
| 871 | + ? '<a href="'.$attendee->get_admin_details_link().'"' |
|
| 872 | + . ' title="'.esc_html__('Click for attendee details', 'event_espresso').'">' |
|
| 873 | 873 | . '<span id="checkin-attendee-name">' |
| 874 | 874 | . $attendee_name |
| 875 | 875 | . '</span></a>' |
@@ -878,25 +878,25 @@ discard block |
||
| 878 | 878 | ? $registration->event()->get_admin_details_link() |
| 879 | 879 | : ''; |
| 880 | 880 | $event_link = ! empty($event_link) |
| 881 | - ? '<a href="' . $event_link . '"' |
|
| 882 | - . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
| 881 | + ? '<a href="'.$event_link.'"' |
|
| 882 | + . ' title="'.esc_html__('Click here to edit event.', 'event_espresso').'">' |
|
| 883 | 883 | . '<span id="checkin-event-name">' |
| 884 | 884 | . $registration->event_name() |
| 885 | 885 | . '</span>' |
| 886 | 886 | . '</a>' |
| 887 | 887 | : ''; |
| 888 | 888 | $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
| 889 | - ? '<h2>' . sprintf( |
|
| 889 | + ? '<h2>'.sprintf( |
|
| 890 | 890 | esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
| 891 | 891 | $attendee_link, |
| 892 | 892 | $datetime_link, |
| 893 | 893 | $event_link |
| 894 | - ) . '</h2>' |
|
| 894 | + ).'</h2>' |
|
| 895 | 895 | : ''; |
| 896 | 896 | $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
| 897 | - ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : ''; |
|
| 897 | + ? '<input type="hidden" name="_REG_ID" value="'.$reg_id.'">' : ''; |
|
| 898 | 898 | $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
| 899 | - ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
| 899 | + ? '<input type="hidden" name="DTT_ID" value="'.$dtt_id.'">' : ''; |
|
| 900 | 900 | $this->display_admin_list_table_page_with_no_sidebar(); |
| 901 | 901 | } |
| 902 | 902 | |
@@ -913,7 +913,7 @@ discard block |
||
| 913 | 913 | public function toggle_checkin_status() |
| 914 | 914 | { |
| 915 | 915 | // first make sure we have the necessary data |
| 916 | - if (! isset($this->_req_data['_regid'])) { |
|
| 916 | + if ( ! isset($this->_req_data['_regid'])) { |
|
| 917 | 917 | EE_Error::add_error( |
| 918 | 918 | esc_html__( |
| 919 | 919 | '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', |
@@ -935,7 +935,7 @@ discard block |
||
| 935 | 935 | // beautiful! Made it this far so let's get the status. |
| 936 | 936 | $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status()); |
| 937 | 937 | // setup new class to return via ajax |
| 938 | - $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses(); |
|
| 938 | + $this->_template_args['admin_page_content'] = 'clickable trigger-checkin '.$new_status->cssClasses(); |
|
| 939 | 939 | $this->_template_args['success'] = true; |
| 940 | 940 | $this->_return_json(); |
| 941 | 941 | } |
@@ -961,7 +961,7 @@ discard block |
||
| 961 | 961 | ); |
| 962 | 962 | $new_status = false; |
| 963 | 963 | // bulk action check in toggle |
| 964 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 964 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 965 | 965 | // cycle thru checkboxes |
| 966 | 966 | while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
| 967 | 967 | $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
@@ -1031,9 +1031,9 @@ discard block |
||
| 1031 | 1031 | '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
| 1032 | 1032 | ); |
| 1033 | 1033 | $errors = 0; |
| 1034 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 1034 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 1035 | 1035 | while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
| 1036 | - if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
| 1036 | + if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
| 1037 | 1037 | $errors++; |
| 1038 | 1038 | } |
| 1039 | 1039 | } |
@@ -1079,8 +1079,8 @@ discard block |
||
| 1079 | 1079 | 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
| 1080 | 1080 | '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
| 1081 | 1081 | ); |
| 1082 | - if (! empty($this->_req_data['CHK_ID'])) { |
|
| 1083 | - if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
| 1082 | + if ( ! empty($this->_req_data['CHK_ID'])) { |
|
| 1083 | + if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
| 1084 | 1084 | EE_Error::add_error( |
| 1085 | 1085 | esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
| 1086 | 1086 | __FILE__, |
@@ -1149,27 +1149,27 @@ discard block |
||
| 1149 | 1149 | 'desc' => $checked_never->legendLabel(), |
| 1150 | 1150 | ), |
| 1151 | 1151 | 'approved_status' => array( |
| 1152 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 1152 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved, |
|
| 1153 | 1153 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
| 1154 | 1154 | ), |
| 1155 | 1155 | 'cancelled_status' => array( |
| 1156 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 1156 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled, |
|
| 1157 | 1157 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
| 1158 | 1158 | ), |
| 1159 | 1159 | 'declined_status' => array( |
| 1160 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 1160 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined, |
|
| 1161 | 1161 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
| 1162 | 1162 | ), |
| 1163 | 1163 | 'not_approved' => array( |
| 1164 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 1164 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved, |
|
| 1165 | 1165 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
| 1166 | 1166 | ), |
| 1167 | 1167 | 'pending_status' => array( |
| 1168 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 1168 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment, |
|
| 1169 | 1169 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
| 1170 | 1170 | ), |
| 1171 | 1171 | 'wait_list' => array( |
| 1172 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 1172 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list, |
|
| 1173 | 1173 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
| 1174 | 1174 | ), |
| 1175 | 1175 | ); |
@@ -1178,10 +1178,10 @@ discard block |
||
| 1178 | 1178 | /** @var EE_Event $event */ |
| 1179 | 1179 | $event = EEM_Event::instance()->get_one_by_ID($event_id); |
| 1180 | 1180 | $this->_template_args['before_list_table'] = $event instanceof EE_Event |
| 1181 | - ? '<h2>' . sprintf( |
|
| 1181 | + ? '<h2>'.sprintf( |
|
| 1182 | 1182 | esc_html__('Viewing Registrations for Event: %s', 'event_espresso'), |
| 1183 | 1183 | EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') |
| 1184 | - ) . '</h2>' |
|
| 1184 | + ).'</h2>' |
|
| 1185 | 1185 | : ''; |
| 1186 | 1186 | // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on |
| 1187 | 1187 | // the event. |
@@ -1199,12 +1199,12 @@ discard block |
||
| 1199 | 1199 | $this->_template_args['before_list_table'] .= ' <span class="drk-grey-text">'; |
| 1200 | 1200 | $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>'; |
| 1201 | 1201 | $this->_template_args['before_list_table'] .= $datetime->name(); |
| 1202 | - $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
| 1202 | + $this->_template_args['before_list_table'] .= ' ( '.$datetime->date_and_time_range().' )'; |
|
| 1203 | 1203 | $this->_template_args['before_list_table'] .= '</span></h2>'; |
| 1204 | 1204 | } |
| 1205 | 1205 | // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status |
| 1206 | 1206 | // column represents |
| 1207 | - if (! $datetime instanceof EE_Datetime) { |
|
| 1207 | + if ( ! $datetime instanceof EE_Datetime) { |
|
| 1208 | 1208 | $this->_template_args['before_list_table'] .= '<br><p class="description">' |
| 1209 | 1209 | . esc_html__( |
| 1210 | 1210 | 'In this view, the check-in status represents the latest check-in record for the registration in that row.', |