@@ -15,139 +15,139 @@ |
||
| 15 | 15 | trait RegistrationsAdmin |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * This will select all checkboxes on a registration list table for the given array of |
|
| 20 | - * registration ids. |
|
| 21 | - * Assumes the actor is on a list table page for registrations. |
|
| 22 | - * @param $registration_ids |
|
| 23 | - */ |
|
| 24 | - public function selectBulkActionCheckboxesForRegistrationIds(array $registration_ids) |
|
| 25 | - { |
|
| 26 | - foreach ($registration_ids as $registration_id) { |
|
| 27 | - $this->actor()->checkOption( |
|
| 28 | - RegistrationsAdminPage::listTableCheckBoxSelectorForRegistrationId($registration_id) |
|
| 29 | - ); |
|
| 30 | - } |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Navigates the actor to the default registration list table page. |
|
| 36 | - * @param string $additional_params |
|
| 37 | - */ |
|
| 38 | - public function amOnDefaultRegistrationsListTableAdminPage($additional_params = '') |
|
| 39 | - { |
|
| 40 | - $this->actor()->amOnAdminPage( |
|
| 41 | - RegistrationsAdminPage::registrationsDefaultAdminListTableUrl($additional_params) |
|
| 42 | - ); |
|
| 43 | - //wait for page to fully load |
|
| 44 | - $this->actor()->wait(5); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Will enter the provided value in the registration list table search field and execute a search for that value. |
|
| 50 | - * @param string $search_text |
|
| 51 | - */ |
|
| 52 | - public function searchForRegistrationOnRegistrationListTableWithText($search_text) |
|
| 53 | - { |
|
| 54 | - $this->amOnDefaultRegistrationsListTableAdminPage(); |
|
| 55 | - $this->actor()->fillField(RegistrationsAdminPage::SEARCH_INPUT_SELECTOR_LIST_TABLE_REGISTRATION, $search_text); |
|
| 56 | - $this->actor()->click(CoreAdmin::LIST_TABLE_SEARCH_SUBMIT_SELECTOR); |
|
| 57 | - $this->actor()->waitForText('Displaying search results for'); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * This will filter the registration list table to view registrations for the given event id. |
|
| 64 | - * Assumption is made that you are logged into the admin but you do not need to be on the registration list table |
|
| 65 | - * page. |
|
| 66 | - * |
|
| 67 | - * @param int $event_id The id of the event viewing registrations for. |
|
| 68 | - */ |
|
| 69 | - public function amViewingRegistrationsForEvent($event_id) |
|
| 70 | - { |
|
| 71 | - $this->actor()->amOnDefaultEventsListTablePage(); |
|
| 72 | - $this->actor()->click(EventsAdmin::listTableActionLinkRegistrationsForEvent($event_id)); |
|
| 73 | - $this->actor()->waitForText('Viewing registrations for the event'); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * This helper will initiate registering for the given event via the backend. |
|
| 79 | - * @param int $event_id The event to initiate registration for. |
|
| 80 | - */ |
|
| 81 | - public function amOnAdminRegistrationPageForEvent($event_id) |
|
| 82 | - { |
|
| 83 | - $this->actor()->amViewingRegistrationsForEvent($event_id); |
|
| 84 | - $this->actor()->click(RegistrationsAdminPage::BUTTON_ADD_NEW_REGISTRATION); |
|
| 85 | - $this->actor()->waitForText('Adding Registration For'); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * This clicks the View Details Link for Registration with the given Id |
|
| 92 | - * @param $registration_id |
|
| 93 | - */ |
|
| 94 | - public function clickViewDetailsLinkForRegistrationWithId($registration_id) |
|
| 95 | - { |
|
| 96 | - $this->actor()->click(RegistrationsAdminPage::viewDetailsLinkSelectorForRegistrationId($registration_id)); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * /** |
|
| 102 | - * This assumes you are on the admin details page for a registration in EE. It selects the given status in the |
|
| 103 | - * dropdown for changing registration status. |
|
| 104 | - * |
|
| 105 | - * @param string $status_label_or_value Either the label for the dropdown option or the value for the option. |
|
| 106 | - * @param $status_label_or_value |
|
| 107 | - */ |
|
| 108 | - public function selectRegistrationStatusOnRegistrationDetailsPageFor($status_label_or_value) |
|
| 109 | - { |
|
| 110 | - $this->actor()->selectOption( |
|
| 111 | - RegistrationsAdminPage::DROPDOWN_REGISTRATION_STATUS, |
|
| 112 | - $status_label_or_value |
|
| 113 | - ); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * This selects (or deselects) the "Send Related Messages" checkbox on the Registration Details page. |
|
| 119 | - * @param bool $send_related_messages |
|
| 120 | - */ |
|
| 121 | - public function selectSendRelatedMessagesOptionOnRegistrationDetailsPage($send_related_messages = true) |
|
| 122 | - { |
|
| 123 | - $send_related_messages |
|
| 124 | - ? $this->actor()->selectOption( |
|
| 125 | - RegistrationsAdminPage::DROPDOWN_SEND_RELATED_MESSAGES, |
|
| 126 | - 'Yes' |
|
| 127 | - ) |
|
| 128 | - : $this->actor()->selecOption( |
|
| 129 | - RegistrationsAdminPage::DROPDOWN_SEND_RELATED_MESSAGES, |
|
| 130 | - 'No' |
|
| 131 | - ); |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * This assumes you are on the admin details page for a registration in EE. It selects the given status in the |
|
| 138 | - * dropdown for changing registration status and submits the change. |
|
| 139 | - * |
|
| 140 | - * @param string $status_label_or_value Either the label for the dropdown option or the value for the option. |
|
| 141 | - * @param bool $send_related_messages Whether or not to send related messages after changing the bulk action. |
|
| 142 | - */ |
|
| 143 | - public function changeRegistrationStatusOnRegistrationDetailsPageTo( |
|
| 144 | - $status_label_or_value, |
|
| 145 | - $send_related_messages = true |
|
| 146 | - ) { |
|
| 147 | - $this->actor()->selectRegistrationStatusOnRegistrationDetailsPageFor($status_label_or_value); |
|
| 148 | - $this->actor()->selectSendRelatedMessagesOptionOnRegistrationDetailsPage($send_related_messages); |
|
| 149 | - $this->actor()->click(RegistrationsAdminPage::BUTTON_UPDATE_REGISTRATION_STATUS); |
|
| 150 | - $this->actor()->waitForText('Registration status has been set to'); |
|
| 151 | - } |
|
| 18 | + /** |
|
| 19 | + * This will select all checkboxes on a registration list table for the given array of |
|
| 20 | + * registration ids. |
|
| 21 | + * Assumes the actor is on a list table page for registrations. |
|
| 22 | + * @param $registration_ids |
|
| 23 | + */ |
|
| 24 | + public function selectBulkActionCheckboxesForRegistrationIds(array $registration_ids) |
|
| 25 | + { |
|
| 26 | + foreach ($registration_ids as $registration_id) { |
|
| 27 | + $this->actor()->checkOption( |
|
| 28 | + RegistrationsAdminPage::listTableCheckBoxSelectorForRegistrationId($registration_id) |
|
| 29 | + ); |
|
| 30 | + } |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Navigates the actor to the default registration list table page. |
|
| 36 | + * @param string $additional_params |
|
| 37 | + */ |
|
| 38 | + public function amOnDefaultRegistrationsListTableAdminPage($additional_params = '') |
|
| 39 | + { |
|
| 40 | + $this->actor()->amOnAdminPage( |
|
| 41 | + RegistrationsAdminPage::registrationsDefaultAdminListTableUrl($additional_params) |
|
| 42 | + ); |
|
| 43 | + //wait for page to fully load |
|
| 44 | + $this->actor()->wait(5); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * Will enter the provided value in the registration list table search field and execute a search for that value. |
|
| 50 | + * @param string $search_text |
|
| 51 | + */ |
|
| 52 | + public function searchForRegistrationOnRegistrationListTableWithText($search_text) |
|
| 53 | + { |
|
| 54 | + $this->amOnDefaultRegistrationsListTableAdminPage(); |
|
| 55 | + $this->actor()->fillField(RegistrationsAdminPage::SEARCH_INPUT_SELECTOR_LIST_TABLE_REGISTRATION, $search_text); |
|
| 56 | + $this->actor()->click(CoreAdmin::LIST_TABLE_SEARCH_SUBMIT_SELECTOR); |
|
| 57 | + $this->actor()->waitForText('Displaying search results for'); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * This will filter the registration list table to view registrations for the given event id. |
|
| 64 | + * Assumption is made that you are logged into the admin but you do not need to be on the registration list table |
|
| 65 | + * page. |
|
| 66 | + * |
|
| 67 | + * @param int $event_id The id of the event viewing registrations for. |
|
| 68 | + */ |
|
| 69 | + public function amViewingRegistrationsForEvent($event_id) |
|
| 70 | + { |
|
| 71 | + $this->actor()->amOnDefaultEventsListTablePage(); |
|
| 72 | + $this->actor()->click(EventsAdmin::listTableActionLinkRegistrationsForEvent($event_id)); |
|
| 73 | + $this->actor()->waitForText('Viewing registrations for the event'); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * This helper will initiate registering for the given event via the backend. |
|
| 79 | + * @param int $event_id The event to initiate registration for. |
|
| 80 | + */ |
|
| 81 | + public function amOnAdminRegistrationPageForEvent($event_id) |
|
| 82 | + { |
|
| 83 | + $this->actor()->amViewingRegistrationsForEvent($event_id); |
|
| 84 | + $this->actor()->click(RegistrationsAdminPage::BUTTON_ADD_NEW_REGISTRATION); |
|
| 85 | + $this->actor()->waitForText('Adding Registration For'); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * This clicks the View Details Link for Registration with the given Id |
|
| 92 | + * @param $registration_id |
|
| 93 | + */ |
|
| 94 | + public function clickViewDetailsLinkForRegistrationWithId($registration_id) |
|
| 95 | + { |
|
| 96 | + $this->actor()->click(RegistrationsAdminPage::viewDetailsLinkSelectorForRegistrationId($registration_id)); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * /** |
|
| 102 | + * This assumes you are on the admin details page for a registration in EE. It selects the given status in the |
|
| 103 | + * dropdown for changing registration status. |
|
| 104 | + * |
|
| 105 | + * @param string $status_label_or_value Either the label for the dropdown option or the value for the option. |
|
| 106 | + * @param $status_label_or_value |
|
| 107 | + */ |
|
| 108 | + public function selectRegistrationStatusOnRegistrationDetailsPageFor($status_label_or_value) |
|
| 109 | + { |
|
| 110 | + $this->actor()->selectOption( |
|
| 111 | + RegistrationsAdminPage::DROPDOWN_REGISTRATION_STATUS, |
|
| 112 | + $status_label_or_value |
|
| 113 | + ); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * This selects (or deselects) the "Send Related Messages" checkbox on the Registration Details page. |
|
| 119 | + * @param bool $send_related_messages |
|
| 120 | + */ |
|
| 121 | + public function selectSendRelatedMessagesOptionOnRegistrationDetailsPage($send_related_messages = true) |
|
| 122 | + { |
|
| 123 | + $send_related_messages |
|
| 124 | + ? $this->actor()->selectOption( |
|
| 125 | + RegistrationsAdminPage::DROPDOWN_SEND_RELATED_MESSAGES, |
|
| 126 | + 'Yes' |
|
| 127 | + ) |
|
| 128 | + : $this->actor()->selecOption( |
|
| 129 | + RegistrationsAdminPage::DROPDOWN_SEND_RELATED_MESSAGES, |
|
| 130 | + 'No' |
|
| 131 | + ); |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * This assumes you are on the admin details page for a registration in EE. It selects the given status in the |
|
| 138 | + * dropdown for changing registration status and submits the change. |
|
| 139 | + * |
|
| 140 | + * @param string $status_label_or_value Either the label for the dropdown option or the value for the option. |
|
| 141 | + * @param bool $send_related_messages Whether or not to send related messages after changing the bulk action. |
|
| 142 | + */ |
|
| 143 | + public function changeRegistrationStatusOnRegistrationDetailsPageTo( |
|
| 144 | + $status_label_or_value, |
|
| 145 | + $send_related_messages = true |
|
| 146 | + ) { |
|
| 147 | + $this->actor()->selectRegistrationStatusOnRegistrationDetailsPageFor($status_label_or_value); |
|
| 148 | + $this->actor()->selectSendRelatedMessagesOptionOnRegistrationDetailsPage($send_related_messages); |
|
| 149 | + $this->actor()->click(RegistrationsAdminPage::BUTTON_UPDATE_REGISTRATION_STATUS); |
|
| 150 | + $this->actor()->waitForText('Registration status has been set to'); |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | 153 | } |
| 154 | 154 | \ No newline at end of file |
@@ -13,75 +13,75 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | trait Checkout |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * @param $value |
|
| 18 | - * @param int $attendee_number |
|
| 19 | - * @param bool $admin Used to indicate whether we're filling out the field from the context of the admin or not. |
|
| 20 | - */ |
|
| 21 | - public function fillOutFirstNameFieldForAttendee($value, $attendee_number = 1, $admin = false) |
|
| 22 | - { |
|
| 23 | - $this->actor()->fillField(CheckoutPage::firstNameFieldSelectorForAttendeeNumber($attendee_number, $admin), $value); |
|
| 24 | - } |
|
| 16 | + /** |
|
| 17 | + * @param $value |
|
| 18 | + * @param int $attendee_number |
|
| 19 | + * @param bool $admin Used to indicate whether we're filling out the field from the context of the admin or not. |
|
| 20 | + */ |
|
| 21 | + public function fillOutFirstNameFieldForAttendee($value, $attendee_number = 1, $admin = false) |
|
| 22 | + { |
|
| 23 | + $this->actor()->fillField(CheckoutPage::firstNameFieldSelectorForAttendeeNumber($attendee_number, $admin), $value); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @param $value |
|
| 28 | - * @param int $attendee_number |
|
| 29 | - * @param bool $admin Used to indicate whether we're filling out the field from the context of the admin or not. |
|
| 30 | - */ |
|
| 31 | - public function fillOutLastNameFieldForAttendee($value, $attendee_number = 1, $admin = false) |
|
| 32 | - { |
|
| 33 | - $this->actor()->fillField(CheckoutPage::lastNameFieldSelectorForAttendeeNumber($attendee_number, $admin), $value); |
|
| 34 | - } |
|
| 26 | + /** |
|
| 27 | + * @param $value |
|
| 28 | + * @param int $attendee_number |
|
| 29 | + * @param bool $admin Used to indicate whether we're filling out the field from the context of the admin or not. |
|
| 30 | + */ |
|
| 31 | + public function fillOutLastNameFieldForAttendee($value, $attendee_number = 1, $admin = false) |
|
| 32 | + { |
|
| 33 | + $this->actor()->fillField(CheckoutPage::lastNameFieldSelectorForAttendeeNumber($attendee_number, $admin), $value); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @param $value |
|
| 38 | - * @param int $attendee_number |
|
| 39 | - * @param bool $admin Used to indicate whether we're filling out the field from the context of the admin or not. |
|
| 40 | - */ |
|
| 41 | - public function fillOutEmailFieldForAttendee($value, $attendee_number = 1, $admin = false) |
|
| 42 | - { |
|
| 43 | - $this->actor()->fillField(CheckoutPage::emailFieldSelectorForAttendeeNumber($attendee_number, $admin), $value); |
|
| 44 | - } |
|
| 36 | + /** |
|
| 37 | + * @param $value |
|
| 38 | + * @param int $attendee_number |
|
| 39 | + * @param bool $admin Used to indicate whether we're filling out the field from the context of the admin or not. |
|
| 40 | + */ |
|
| 41 | + public function fillOutEmailFieldForAttendee($value, $attendee_number = 1, $admin = false) |
|
| 42 | + { |
|
| 43 | + $this->actor()->fillField(CheckoutPage::emailFieldSelectorForAttendeeNumber($attendee_number, $admin), $value); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Clicks the next registration step button. |
|
| 49 | - */ |
|
| 50 | - public function goToNextRegistrationStep() |
|
| 51 | - { |
|
| 52 | - $this->actor()->click(CheckoutPage::NEXT_STEP_BUTTON_SELECTOR); |
|
| 53 | - } |
|
| 47 | + /** |
|
| 48 | + * Clicks the next registration step button. |
|
| 49 | + */ |
|
| 50 | + public function goToNextRegistrationStep() |
|
| 51 | + { |
|
| 52 | + $this->actor()->click(CheckoutPage::NEXT_STEP_BUTTON_SELECTOR); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Selects the payment option for the given payment method slug. |
|
| 58 | - * |
|
| 59 | - * @param string $payment_method_slug |
|
| 60 | - * @param bool $verify_selected If true, this will wait for the "Important Information" info box after the |
|
| 61 | - * payment option select box is complete. Otherwise its up to calling code to |
|
| 62 | - * wait for whatever is needed after selecting the payment method. |
|
| 63 | - */ |
|
| 64 | - public function selectPaymentOptionFor($payment_method_slug = 'invoice', $verify_selected = true) |
|
| 65 | - { |
|
| 66 | - $this->waitForElementVisible(CheckoutPage::SELECTOR_PAYMENT_OPTIONS_CONTAINER); |
|
| 67 | - $this->wait(5); |
|
| 68 | - $this->actor()->selectOption( |
|
| 69 | - CheckoutPage::PAYMENT_METHOD_STEP_FORM, |
|
| 70 | - $payment_method_slug |
|
| 71 | - ); |
|
| 72 | - if ($verify_selected) { |
|
| 73 | - $this->actor()->waitForText('Important information regarding your payment'); |
|
| 74 | - } |
|
| 75 | - } |
|
| 56 | + /** |
|
| 57 | + * Selects the payment option for the given payment method slug. |
|
| 58 | + * |
|
| 59 | + * @param string $payment_method_slug |
|
| 60 | + * @param bool $verify_selected If true, this will wait for the "Important Information" info box after the |
|
| 61 | + * payment option select box is complete. Otherwise its up to calling code to |
|
| 62 | + * wait for whatever is needed after selecting the payment method. |
|
| 63 | + */ |
|
| 64 | + public function selectPaymentOptionFor($payment_method_slug = 'invoice', $verify_selected = true) |
|
| 65 | + { |
|
| 66 | + $this->waitForElementVisible(CheckoutPage::SELECTOR_PAYMENT_OPTIONS_CONTAINER); |
|
| 67 | + $this->wait(5); |
|
| 68 | + $this->actor()->selectOption( |
|
| 69 | + CheckoutPage::PAYMENT_METHOD_STEP_FORM, |
|
| 70 | + $payment_method_slug |
|
| 71 | + ); |
|
| 72 | + if ($verify_selected) { |
|
| 73 | + $this->actor()->waitForText('Important information regarding your payment'); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Submits the payment options step form. |
|
| 80 | - * Assumes the actor is in the context of the payment options SPCO step. |
|
| 81 | - */ |
|
| 82 | - public function submitPaymentOptionsRegistrationStepForm() |
|
| 83 | - { |
|
| 84 | - $this->actor()->submitForm(CheckoutPage::PAYMENT_METHOD_STEP_FORM, array()); |
|
| 85 | - } |
|
| 78 | + /** |
|
| 79 | + * Submits the payment options step form. |
|
| 80 | + * Assumes the actor is in the context of the payment options SPCO step. |
|
| 81 | + */ |
|
| 82 | + public function submitPaymentOptionsRegistrationStepForm() |
|
| 83 | + { |
|
| 84 | + $this->actor()->submitForm(CheckoutPage::PAYMENT_METHOD_STEP_FORM, array()); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | 87 | } |
| 88 | 88 | \ No newline at end of file |
@@ -14,280 +14,280 @@ |
||
| 14 | 14 | class EventsAdmin extends CoreAdmin |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Selector for the Add new Event button in the admin. |
|
| 19 | - * @var string |
|
| 20 | - */ |
|
| 21 | - const ADD_NEW_EVENT_BUTTON_SELECTOR = '#add-new-event'; |
|
| 22 | - |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * Selector for the Event Title field in the event editor |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 28 | - const EVENT_EDITOR_TITLE_FIELD_SELECTOR = ['xpath' => "//input[@id='title']"]; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * Selector for the publish submit button in the event editor. |
|
| 32 | - * @var string |
|
| 33 | - */ |
|
| 34 | - const EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR = ['xpath'=>"//div[@id='major-publishing-actions']//input[@id='publish']"]; |
|
| 35 | - |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * Selector for the save button in the event editor |
|
| 39 | - */ |
|
| 40 | - const EVENT_EDITOR_SAVE_BUTTON_SELECTOR = ['xpath' => "//div[@id='minor-publishing-actions']//input[@id='save-post']"]; |
|
| 41 | - |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @var string |
|
| 45 | - */ |
|
| 46 | - const EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR = '#EVT_default_registration_status'; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Selector for the view link after publishing an event. |
|
| 50 | - * @var string |
|
| 51 | - */ |
|
| 52 | - const EVENT_EDITOR_VIEW_LINK_AFTER_PUBLISH_SELECTOR = "//span[@id='sample-permalink']/a"; |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Selector for the ID of the event in the event editor |
|
| 57 | - * @var string |
|
| 58 | - */ |
|
| 59 | - const EVENT_EDITOR_EVT_ID_SELECTOR = "//input[@id='post_ID']"; |
|
| 60 | - |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * Selector for the search input on the event list table page. |
|
| 64 | - * @var string |
|
| 65 | - */ |
|
| 66 | - const EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR = '#toplevel_page_espresso_events-search-input'; |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @param string $additional_params |
|
| 73 | - * @return string |
|
| 74 | - */ |
|
| 75 | - public static function defaultEventsListTableUrl($additional_params = '') |
|
| 76 | - { |
|
| 77 | - return self::adminUrl('espresso_events', 'default', $additional_params); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * The selector for the DTTname field for the given row in the event editor. |
|
| 83 | - * @param int $row_number |
|
| 84 | - * @return string |
|
| 85 | - */ |
|
| 86 | - public static function eventEditorDatetimeNameFieldSelector($row_number = 1) |
|
| 87 | - { |
|
| 88 | - return self::eventEditorDatetimeFieldSelectorForField('DTT_name', $row_number); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * The selector for the DTT_EVT_start field for the given row in the event editor.d |
|
| 94 | - * @param int $row_number |
|
| 95 | - * @return string |
|
| 96 | - */ |
|
| 97 | - public static function eventEditorDatetimeStartDateFieldSelector($row_number = 1) |
|
| 98 | - { |
|
| 99 | - return self::eventEditorDatetimeFieldSelectorForField('DTT_EVT_start', $row_number); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * Wrapper for getting the selector for a given field and given row of a datetime in the event editor. |
|
| 105 | - * |
|
| 106 | - * @param string $field_name |
|
| 107 | - * @param int $row_number |
|
| 108 | - * @return string |
|
| 109 | - */ |
|
| 110 | - public static function eventEditorDatetimeFieldSelectorForField($field_name, $row_number = 1) |
|
| 111 | - { |
|
| 112 | - return "//input[@id='event-datetime-$field_name-$row_number']"; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * The selector for the TKT_name field for the given display row in the event editor. |
|
| 118 | - * @param int $row_number |
|
| 119 | - * @return string |
|
| 120 | - */ |
|
| 121 | - public static function eventEditorTicketNameFieldSelector($row_number = 1) |
|
| 122 | - { |
|
| 123 | - return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_name', $row_number); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * Selector for the TKT_base_price field for the given display row in the event editor. |
|
| 129 | - * @param int $row_number |
|
| 130 | - * @return string |
|
| 131 | - */ |
|
| 132 | - public static function eventEditorTicketPriceFieldSelector($row_number = 1) |
|
| 133 | - { |
|
| 134 | - return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_base_price', $row_number); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * Selector for the TKT_qty field for the given display row in the event editor. |
|
| 140 | - * @param int $row_number |
|
| 141 | - * @return string |
|
| 142 | - */ |
|
| 143 | - public static function eventEditorTicketQuantityFieldSelector($row_number = 1) |
|
| 144 | - { |
|
| 145 | - return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_qty', $row_number); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * Selector for the advanced details toggle for the ticket for the given display row in the event editor. |
|
| 151 | - * @param int $row_number |
|
| 152 | - * @return string |
|
| 153 | - */ |
|
| 154 | - public static function eventEditorTicketAdvancedDetailsSelector($row_number = 1) |
|
| 155 | - { |
|
| 156 | - return "//tr[@id='display-ticketrow-$row_number']//span[contains(@class, 'gear-icon')]"; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * Selector for the subtotal amount for the given display row of the ticket in the event editor. |
|
| 162 | - * @param int $row_number |
|
| 163 | - * @return string |
|
| 164 | - */ |
|
| 165 | - public static function eventEditorTicketAdvancedDetailsSubtotalSelector($row_number = 1) |
|
| 166 | - { |
|
| 167 | - return "//span[@id='price-total-amount-$row_number']"; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * Selector for the Total element for the given display row of the ticket in the event editor. |
|
| 173 | - * @param int $row_number |
|
| 174 | - * @return string |
|
| 175 | - */ |
|
| 176 | - public static function eventEditorTicketAdvancedDetailsTotalSelector($row_number = 1) |
|
| 177 | - { |
|
| 178 | - return "//span[@id='price-total-amount-$row_number']"; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * Selector for the taxable selector for the ticket for the given display row in the event editor. |
|
| 184 | - * @param int $row_number |
|
| 185 | - * @return string |
|
| 186 | - */ |
|
| 187 | - public static function eventEditorTicketTaxableCheckboxSelector($row_number = 1) |
|
| 188 | - { |
|
| 189 | - return "//input[@id='edit-ticket-TKT_taxable-$row_number']"; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - |
|
| 193 | - /** |
|
| 194 | - * This returns the xpath locater for the Tax amount display container within the advanced settings view for the |
|
| 195 | - * given ticket (row) and the given tax id (PRC_ID). |
|
| 196 | - * |
|
| 197 | - * @param int $tax_id The PRC_ID for the tax you want the locater for. Note, this defaults to the default tax |
|
| 198 | - * setup on a fresh install. |
|
| 199 | - * @param int $row_number What row representing the ticket you want the locator for. |
|
| 200 | - * @return string |
|
| 201 | - */ |
|
| 202 | - public static function eventEditorTicketTaxAmountDisplayForTaxIdAndTicketRowSelector($tax_id = 2, $row_number = 1) |
|
| 203 | - { |
|
| 204 | - return "//span[@id='TKT-tax-amount-display-$tax_id-$row_number']"; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - |
|
| 208 | - /** |
|
| 209 | - * Wrapper for getting the selector for a given field and given display row of a ticket in the event editor. |
|
| 210 | - * @param $field_name |
|
| 211 | - * @param int $row_number |
|
| 212 | - * @return string |
|
| 213 | - */ |
|
| 214 | - public static function eventEditorTicketFieldSelectorForFieldInDisplayRow($field_name, $row_number = 1) |
|
| 215 | - { |
|
| 216 | - return "//tr[@id='display-ticketrow-$row_number']//input[contains(@class, 'edit-ticket-$field_name')]"; |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * Returns the selector for the event title edit link in the events list table for the given Event Title. |
|
| 222 | - * @param string $event_title |
|
| 223 | - * @return string |
|
| 224 | - */ |
|
| 225 | - public static function eventListTableEventTitleEditLinkSelectorForTitle($event_title) |
|
| 226 | - { |
|
| 227 | - return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"; |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * Locator for for the ID column in the event list table for a given event title. |
|
| 233 | - * @param string $event_title |
|
| 234 | - * @return string |
|
| 235 | - */ |
|
| 236 | - public static function eventListTableEventIdSelectorForTitle($event_title) |
|
| 237 | - { |
|
| 238 | - return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']" |
|
| 239 | - . "//ancestor::tr/th[contains(@class, 'check-column')]/input"; |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * Locator for the view link in the row of an event list table for the given event title. |
|
| 245 | - * @param string $event_title |
|
| 246 | - * @return string |
|
| 247 | - */ |
|
| 248 | - public static function eventListTableEventTitleViewLinkSelectorForTitle($event_title) |
|
| 249 | - { |
|
| 250 | - return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']" |
|
| 251 | - . "//ancestor::td//span[@class='view']/a"; |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - |
|
| 255 | - /** |
|
| 256 | - * Locator for the messenger tab in the Notifications metabox in the event editor. |
|
| 257 | - * @param string $messenger_slug The slug for the messenger (it's reference slug). |
|
| 258 | - * @return string |
|
| 259 | - */ |
|
| 260 | - public static function eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug) |
|
| 261 | - { |
|
| 262 | - return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']" |
|
| 263 | - . "//a[@rel='ee-tab-$messenger_slug']"; |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - |
|
| 267 | - /** |
|
| 268 | - * Locator for the select input within the notifications metabox. |
|
| 269 | - * Note, this assumes the tab content for the related messenger is already visible. |
|
| 270 | - * @param string $message_type_label The message type label (visible string in the table) you want the selector for. |
|
| 271 | - * @return string |
|
| 272 | - */ |
|
| 273 | - public static function eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label) |
|
| 274 | - { |
|
| 275 | - return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']" |
|
| 276 | - . "//table[@class='messages-custom-template-switcher']" |
|
| 277 | - . "//tr/td[contains(.,'Registration Approved')]" |
|
| 278 | - . "//ancestor::tr//select[contains(@class,'message-template-selector')]"; |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - |
|
| 282 | - /** |
|
| 283 | - * Returns the selector for the action link to the registrations list table view filtered by the given event_id. |
|
| 284 | - * Assumes one is in the context of the Events List Table |
|
| 285 | - * @param int $event_id |
|
| 286 | - * @return string |
|
| 287 | - */ |
|
| 288 | - public static function listTableActionLinkRegistrationsForEvent($event_id) |
|
| 289 | - { |
|
| 290 | - return "//tbody[@id='the-list']/tr/td[contains(@class, 'column-id') and contains(.,$event_id)]" |
|
| 291 | - . "//ancestor::tr/td//a[div[contains(@class, 'dashicons-groups')]]"; |
|
| 292 | - } |
|
| 17 | + /** |
|
| 18 | + * Selector for the Add new Event button in the admin. |
|
| 19 | + * @var string |
|
| 20 | + */ |
|
| 21 | + const ADD_NEW_EVENT_BUTTON_SELECTOR = '#add-new-event'; |
|
| 22 | + |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * Selector for the Event Title field in the event editor |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | + const EVENT_EDITOR_TITLE_FIELD_SELECTOR = ['xpath' => "//input[@id='title']"]; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * Selector for the publish submit button in the event editor. |
|
| 32 | + * @var string |
|
| 33 | + */ |
|
| 34 | + const EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR = ['xpath'=>"//div[@id='major-publishing-actions']//input[@id='publish']"]; |
|
| 35 | + |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * Selector for the save button in the event editor |
|
| 39 | + */ |
|
| 40 | + const EVENT_EDITOR_SAVE_BUTTON_SELECTOR = ['xpath' => "//div[@id='minor-publishing-actions']//input[@id='save-post']"]; |
|
| 41 | + |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @var string |
|
| 45 | + */ |
|
| 46 | + const EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR = '#EVT_default_registration_status'; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * Selector for the view link after publishing an event. |
|
| 50 | + * @var string |
|
| 51 | + */ |
|
| 52 | + const EVENT_EDITOR_VIEW_LINK_AFTER_PUBLISH_SELECTOR = "//span[@id='sample-permalink']/a"; |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Selector for the ID of the event in the event editor |
|
| 57 | + * @var string |
|
| 58 | + */ |
|
| 59 | + const EVENT_EDITOR_EVT_ID_SELECTOR = "//input[@id='post_ID']"; |
|
| 60 | + |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * Selector for the search input on the event list table page. |
|
| 64 | + * @var string |
|
| 65 | + */ |
|
| 66 | + const EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR = '#toplevel_page_espresso_events-search-input'; |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @param string $additional_params |
|
| 73 | + * @return string |
|
| 74 | + */ |
|
| 75 | + public static function defaultEventsListTableUrl($additional_params = '') |
|
| 76 | + { |
|
| 77 | + return self::adminUrl('espresso_events', 'default', $additional_params); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * The selector for the DTTname field for the given row in the event editor. |
|
| 83 | + * @param int $row_number |
|
| 84 | + * @return string |
|
| 85 | + */ |
|
| 86 | + public static function eventEditorDatetimeNameFieldSelector($row_number = 1) |
|
| 87 | + { |
|
| 88 | + return self::eventEditorDatetimeFieldSelectorForField('DTT_name', $row_number); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * The selector for the DTT_EVT_start field for the given row in the event editor.d |
|
| 94 | + * @param int $row_number |
|
| 95 | + * @return string |
|
| 96 | + */ |
|
| 97 | + public static function eventEditorDatetimeStartDateFieldSelector($row_number = 1) |
|
| 98 | + { |
|
| 99 | + return self::eventEditorDatetimeFieldSelectorForField('DTT_EVT_start', $row_number); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * Wrapper for getting the selector for a given field and given row of a datetime in the event editor. |
|
| 105 | + * |
|
| 106 | + * @param string $field_name |
|
| 107 | + * @param int $row_number |
|
| 108 | + * @return string |
|
| 109 | + */ |
|
| 110 | + public static function eventEditorDatetimeFieldSelectorForField($field_name, $row_number = 1) |
|
| 111 | + { |
|
| 112 | + return "//input[@id='event-datetime-$field_name-$row_number']"; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * The selector for the TKT_name field for the given display row in the event editor. |
|
| 118 | + * @param int $row_number |
|
| 119 | + * @return string |
|
| 120 | + */ |
|
| 121 | + public static function eventEditorTicketNameFieldSelector($row_number = 1) |
|
| 122 | + { |
|
| 123 | + return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_name', $row_number); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * Selector for the TKT_base_price field for the given display row in the event editor. |
|
| 129 | + * @param int $row_number |
|
| 130 | + * @return string |
|
| 131 | + */ |
|
| 132 | + public static function eventEditorTicketPriceFieldSelector($row_number = 1) |
|
| 133 | + { |
|
| 134 | + return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_base_price', $row_number); |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * Selector for the TKT_qty field for the given display row in the event editor. |
|
| 140 | + * @param int $row_number |
|
| 141 | + * @return string |
|
| 142 | + */ |
|
| 143 | + public static function eventEditorTicketQuantityFieldSelector($row_number = 1) |
|
| 144 | + { |
|
| 145 | + return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_qty', $row_number); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * Selector for the advanced details toggle for the ticket for the given display row in the event editor. |
|
| 151 | + * @param int $row_number |
|
| 152 | + * @return string |
|
| 153 | + */ |
|
| 154 | + public static function eventEditorTicketAdvancedDetailsSelector($row_number = 1) |
|
| 155 | + { |
|
| 156 | + return "//tr[@id='display-ticketrow-$row_number']//span[contains(@class, 'gear-icon')]"; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * Selector for the subtotal amount for the given display row of the ticket in the event editor. |
|
| 162 | + * @param int $row_number |
|
| 163 | + * @return string |
|
| 164 | + */ |
|
| 165 | + public static function eventEditorTicketAdvancedDetailsSubtotalSelector($row_number = 1) |
|
| 166 | + { |
|
| 167 | + return "//span[@id='price-total-amount-$row_number']"; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * Selector for the Total element for the given display row of the ticket in the event editor. |
|
| 173 | + * @param int $row_number |
|
| 174 | + * @return string |
|
| 175 | + */ |
|
| 176 | + public static function eventEditorTicketAdvancedDetailsTotalSelector($row_number = 1) |
|
| 177 | + { |
|
| 178 | + return "//span[@id='price-total-amount-$row_number']"; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * Selector for the taxable selector for the ticket for the given display row in the event editor. |
|
| 184 | + * @param int $row_number |
|
| 185 | + * @return string |
|
| 186 | + */ |
|
| 187 | + public static function eventEditorTicketTaxableCheckboxSelector($row_number = 1) |
|
| 188 | + { |
|
| 189 | + return "//input[@id='edit-ticket-TKT_taxable-$row_number']"; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + |
|
| 193 | + /** |
|
| 194 | + * This returns the xpath locater for the Tax amount display container within the advanced settings view for the |
|
| 195 | + * given ticket (row) and the given tax id (PRC_ID). |
|
| 196 | + * |
|
| 197 | + * @param int $tax_id The PRC_ID for the tax you want the locater for. Note, this defaults to the default tax |
|
| 198 | + * setup on a fresh install. |
|
| 199 | + * @param int $row_number What row representing the ticket you want the locator for. |
|
| 200 | + * @return string |
|
| 201 | + */ |
|
| 202 | + public static function eventEditorTicketTaxAmountDisplayForTaxIdAndTicketRowSelector($tax_id = 2, $row_number = 1) |
|
| 203 | + { |
|
| 204 | + return "//span[@id='TKT-tax-amount-display-$tax_id-$row_number']"; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + |
|
| 208 | + /** |
|
| 209 | + * Wrapper for getting the selector for a given field and given display row of a ticket in the event editor. |
|
| 210 | + * @param $field_name |
|
| 211 | + * @param int $row_number |
|
| 212 | + * @return string |
|
| 213 | + */ |
|
| 214 | + public static function eventEditorTicketFieldSelectorForFieldInDisplayRow($field_name, $row_number = 1) |
|
| 215 | + { |
|
| 216 | + return "//tr[@id='display-ticketrow-$row_number']//input[contains(@class, 'edit-ticket-$field_name')]"; |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * Returns the selector for the event title edit link in the events list table for the given Event Title. |
|
| 222 | + * @param string $event_title |
|
| 223 | + * @return string |
|
| 224 | + */ |
|
| 225 | + public static function eventListTableEventTitleEditLinkSelectorForTitle($event_title) |
|
| 226 | + { |
|
| 227 | + return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"; |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * Locator for for the ID column in the event list table for a given event title. |
|
| 233 | + * @param string $event_title |
|
| 234 | + * @return string |
|
| 235 | + */ |
|
| 236 | + public static function eventListTableEventIdSelectorForTitle($event_title) |
|
| 237 | + { |
|
| 238 | + return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']" |
|
| 239 | + . "//ancestor::tr/th[contains(@class, 'check-column')]/input"; |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * Locator for the view link in the row of an event list table for the given event title. |
|
| 245 | + * @param string $event_title |
|
| 246 | + * @return string |
|
| 247 | + */ |
|
| 248 | + public static function eventListTableEventTitleViewLinkSelectorForTitle($event_title) |
|
| 249 | + { |
|
| 250 | + return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']" |
|
| 251 | + . "//ancestor::td//span[@class='view']/a"; |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + |
|
| 255 | + /** |
|
| 256 | + * Locator for the messenger tab in the Notifications metabox in the event editor. |
|
| 257 | + * @param string $messenger_slug The slug for the messenger (it's reference slug). |
|
| 258 | + * @return string |
|
| 259 | + */ |
|
| 260 | + public static function eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug) |
|
| 261 | + { |
|
| 262 | + return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']" |
|
| 263 | + . "//a[@rel='ee-tab-$messenger_slug']"; |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * Locator for the select input within the notifications metabox. |
|
| 269 | + * Note, this assumes the tab content for the related messenger is already visible. |
|
| 270 | + * @param string $message_type_label The message type label (visible string in the table) you want the selector for. |
|
| 271 | + * @return string |
|
| 272 | + */ |
|
| 273 | + public static function eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label) |
|
| 274 | + { |
|
| 275 | + return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']" |
|
| 276 | + . "//table[@class='messages-custom-template-switcher']" |
|
| 277 | + . "//tr/td[contains(.,'Registration Approved')]" |
|
| 278 | + . "//ancestor::tr//select[contains(@class,'message-template-selector')]"; |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + |
|
| 282 | + /** |
|
| 283 | + * Returns the selector for the action link to the registrations list table view filtered by the given event_id. |
|
| 284 | + * Assumes one is in the context of the Events List Table |
|
| 285 | + * @param int $event_id |
|
| 286 | + * @return string |
|
| 287 | + */ |
|
| 288 | + public static function listTableActionLinkRegistrationsForEvent($event_id) |
|
| 289 | + { |
|
| 290 | + return "//tbody[@id='the-list']/tr/td[contains(@class, 'column-id') and contains(.,$event_id)]" |
|
| 291 | + . "//ancestor::tr/td//a[div[contains(@class, 'dashicons-groups')]]"; |
|
| 292 | + } |
|
| 293 | 293 | } |
@@ -12,27 +12,27 @@ |
||
| 12 | 12 | class TicketSelector |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Return the selector for the ticket option select input for the given event id. |
|
| 17 | - * @param int|string $event_id |
|
| 18 | - * @return string |
|
| 19 | - */ |
|
| 20 | - public static function ticketOptionByEventIdSelector($event_id) |
|
| 21 | - { |
|
| 22 | - return "//select[@id='ticket-selector-tbl-qty-slct-$event_id-1']"; |
|
| 23 | - } |
|
| 15 | + /** |
|
| 16 | + * Return the selector for the ticket option select input for the given event id. |
|
| 17 | + * @param int|string $event_id |
|
| 18 | + * @return string |
|
| 19 | + */ |
|
| 20 | + public static function ticketOptionByEventIdSelector($event_id) |
|
| 21 | + { |
|
| 22 | + return "//select[@id='ticket-selector-tbl-qty-slct-$event_id-1']"; |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Return the selector for the submit button for the ticket selector for the given event id. |
|
| 28 | - * @param int|string $event_id |
|
| 29 | - * @param bool $admin Used to return the selector from the context of the admin (true) or frontend (false) |
|
| 30 | - * @return string |
|
| 31 | - */ |
|
| 32 | - public static function ticketSelectionSubmitSelectorByEventId($event_id, $admin = false) |
|
| 33 | - { |
|
| 34 | - return $admin |
|
| 35 | - ? "#ee-new-registration-step-button" |
|
| 36 | - : "#ticket-selector-submit-$event_id-btn"; |
|
| 37 | - } |
|
| 26 | + /** |
|
| 27 | + * Return the selector for the submit button for the ticket selector for the given event id. |
|
| 28 | + * @param int|string $event_id |
|
| 29 | + * @param bool $admin Used to return the selector from the context of the admin (true) or frontend (false) |
|
| 30 | + * @return string |
|
| 31 | + */ |
|
| 32 | + public static function ticketSelectionSubmitSelectorByEventId($event_id, $admin = false) |
|
| 33 | + { |
|
| 34 | + return $admin |
|
| 35 | + ? "#ee-new-registration-step-button" |
|
| 36 | + : "#ticket-selector-submit-$event_id-btn"; |
|
| 37 | + } |
|
| 38 | 38 | } |
| 39 | 39 | \ No newline at end of file |
@@ -12,47 +12,47 @@ |
||
| 12 | 12 | class RegistrationsAdmin extends CoreAdmin |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - const REGISTRATION_STATUS_NOT_APPROVED = 'RNA'; |
|
| 16 | - const REGISTRATION_STATUS_APPROVED = 'RAP'; |
|
| 17 | - const REGISTRATION_STATUS_PENDING_PAYMENT = 'RPP'; |
|
| 18 | - const SEARCH_INPUT_SELECTOR_LIST_TABLE_REGISTRATION = '#event-espresso_page_espresso_registrations-search-input'; |
|
| 19 | - const BUTTON_ADD_NEW_REGISTRATION = '#add-new-registration'; |
|
| 20 | - const DROPDOWN_REGISTRATION_STATUS = '#reg-status-change-form-reg-status'; |
|
| 21 | - const BUTTON_UPDATE_REGISTRATION_STATUS = '#reg-status-change-form-submit-submit'; |
|
| 22 | - const DROPDOWN_SEND_RELATED_MESSAGES = '#reg-status-change-form-send-notifications'; |
|
| 23 | - |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * @param string $additional_params |
|
| 27 | - * @return string |
|
| 28 | - */ |
|
| 29 | - public static function registrationsDefaultAdminListTableUrl($additional_params = '') |
|
| 30 | - { |
|
| 31 | - return self::adminUrl('espresso_registrations', 'default', $additional_params); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * Given a registration id, this will return the selector for all the checkbox for that id. |
|
| 37 | - * Assumes the view is the default registrations list table. |
|
| 38 | - * @param int $registration_id |
|
| 39 | - * @return string |
|
| 40 | - */ |
|
| 41 | - public static function listTableCheckBoxSelectorForRegistrationId($registration_id) |
|
| 42 | - { |
|
| 43 | - return "//input[@name='_REG_ID[]' and @value='{$registration_id}']"; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Given a registration id, this will return the selector for the link to the registration details. |
|
| 49 | - * Assumes the view is the default registrations list table. |
|
| 50 | - * @param int $registration_id |
|
| 51 | - * @return string |
|
| 52 | - */ |
|
| 53 | - public static function viewDetailsLinkSelectorForRegistrationId($registration_id) |
|
| 54 | - { |
|
| 55 | - return "//tbody[@id='the-list']/tr/td[contains(@class, 'column-_REG_ID') and contains(., $registration_id)]" |
|
| 56 | - . "//ancestor::tr/td[contains(@class, 'column-ATT_fname')]/a[1]"; |
|
| 57 | - } |
|
| 15 | + const REGISTRATION_STATUS_NOT_APPROVED = 'RNA'; |
|
| 16 | + const REGISTRATION_STATUS_APPROVED = 'RAP'; |
|
| 17 | + const REGISTRATION_STATUS_PENDING_PAYMENT = 'RPP'; |
|
| 18 | + const SEARCH_INPUT_SELECTOR_LIST_TABLE_REGISTRATION = '#event-espresso_page_espresso_registrations-search-input'; |
|
| 19 | + const BUTTON_ADD_NEW_REGISTRATION = '#add-new-registration'; |
|
| 20 | + const DROPDOWN_REGISTRATION_STATUS = '#reg-status-change-form-reg-status'; |
|
| 21 | + const BUTTON_UPDATE_REGISTRATION_STATUS = '#reg-status-change-form-submit-submit'; |
|
| 22 | + const DROPDOWN_SEND_RELATED_MESSAGES = '#reg-status-change-form-send-notifications'; |
|
| 23 | + |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * @param string $additional_params |
|
| 27 | + * @return string |
|
| 28 | + */ |
|
| 29 | + public static function registrationsDefaultAdminListTableUrl($additional_params = '') |
|
| 30 | + { |
|
| 31 | + return self::adminUrl('espresso_registrations', 'default', $additional_params); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * Given a registration id, this will return the selector for all the checkbox for that id. |
|
| 37 | + * Assumes the view is the default registrations list table. |
|
| 38 | + * @param int $registration_id |
|
| 39 | + * @return string |
|
| 40 | + */ |
|
| 41 | + public static function listTableCheckBoxSelectorForRegistrationId($registration_id) |
|
| 42 | + { |
|
| 43 | + return "//input[@name='_REG_ID[]' and @value='{$registration_id}']"; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Given a registration id, this will return the selector for the link to the registration details. |
|
| 49 | + * Assumes the view is the default registrations list table. |
|
| 50 | + * @param int $registration_id |
|
| 51 | + * @return string |
|
| 52 | + */ |
|
| 53 | + public static function viewDetailsLinkSelectorForRegistrationId($registration_id) |
|
| 54 | + { |
|
| 55 | + return "//tbody[@id='the-list']/tr/td[contains(@class, 'column-_REG_ID') and contains(., $registration_id)]" |
|
| 56 | + . "//ancestor::tr/td[contains(@class, 'column-ATT_fname')]/a[1]"; |
|
| 57 | + } |
|
| 58 | 58 | } |
| 59 | 59 | \ No newline at end of file |
@@ -13,71 +13,71 @@ |
||
| 13 | 13 | class Checkout |
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * The class selector for the next step button in the checkout. |
|
| 18 | - * @var string |
|
| 19 | - */ |
|
| 20 | - const NEXT_STEP_BUTTON_SELECTOR = '.spco-next-step-btn'; |
|
| 21 | - |
|
| 22 | - |
|
| 23 | - const PAYMENT_METHOD_STEP_FORM = '#ee-spco-payment_options-reg-step-form'; |
|
| 24 | - |
|
| 25 | - |
|
| 26 | - const SELECTOR_PAYMENT_OPTIONS_CONTAINER = '#spco-available-methods-of-payment-dv'; |
|
| 27 | - |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @param int $attendee_number |
|
| 31 | - * @param bool $admin Used to indicate whether we're retrieving the selector from the context of the admin or not. |
|
| 32 | - * @return string |
|
| 33 | - */ |
|
| 34 | - public static function firstNameFieldSelectorForAttendeeNumber($attendee_number = 1, $admin = false) |
|
| 35 | - { |
|
| 36 | - return self::fieldSelectorForAttendeeNumber('fname', $attendee_number, $admin); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @param int $attendee_number |
|
| 42 | - * @param bool $admin Used to indicate whether we're retrieving the selector from the context of the admin or not. |
|
| 43 | - * @return string |
|
| 44 | - */ |
|
| 45 | - public static function lastNameFieldSelectorForAttendeeNumber($attendee_number = 1, $admin = false) |
|
| 46 | - { |
|
| 47 | - return self::fieldSelectorForAttendeeNumber('lname', $attendee_number, $admin); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * @param int $attendee_number |
|
| 53 | - * @param bool $admin Used to indicate whether we're retrieving the selector from the context of the admin or not. |
|
| 54 | - * @return string |
|
| 55 | - */ |
|
| 56 | - public static function emailFieldSelectorForAttendeeNumber($attendee_number = 1, $admin = false) |
|
| 57 | - { |
|
| 58 | - return self::fieldSelectorForAttendeeNumber('email', $attendee_number, $admin); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * @param string $field_name |
|
| 63 | - * @param int $attendee_number |
|
| 64 | - * @param bool $admin Used to indicate whether we're retrieving the selector from the context of the admin or not. |
|
| 65 | - * @return string |
|
| 66 | - */ |
|
| 67 | - public static function fieldSelectorForAttendeeNumber($field_name, $attendee_number = 1, $admin = false) |
|
| 68 | - { |
|
| 69 | - return $admin |
|
| 70 | - ? "//fieldset[starts-with(@id, 'ee-registration-$attendee_number')]//input[contains(@class, 'ee-reg-qstn-$field_name')]" |
|
| 71 | - : "//div[starts-with(@id, 'spco-attendee-panel-dv-$attendee_number')]//input[contains(@class, 'ee-reg-qstn-$field_name')]"; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * @param string $payment_method_slug Slug for the payment method. |
|
| 77 | - * @return string |
|
| 78 | - */ |
|
| 79 | - public static function fieldSelectorForPaymentOption($payment_method_slug) |
|
| 80 | - { |
|
| 81 | - return "#ee-available-payment-method-inputs-{$payment_method_slug}"; |
|
| 82 | - } |
|
| 16 | + /** |
|
| 17 | + * The class selector for the next step button in the checkout. |
|
| 18 | + * @var string |
|
| 19 | + */ |
|
| 20 | + const NEXT_STEP_BUTTON_SELECTOR = '.spco-next-step-btn'; |
|
| 21 | + |
|
| 22 | + |
|
| 23 | + const PAYMENT_METHOD_STEP_FORM = '#ee-spco-payment_options-reg-step-form'; |
|
| 24 | + |
|
| 25 | + |
|
| 26 | + const SELECTOR_PAYMENT_OPTIONS_CONTAINER = '#spco-available-methods-of-payment-dv'; |
|
| 27 | + |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @param int $attendee_number |
|
| 31 | + * @param bool $admin Used to indicate whether we're retrieving the selector from the context of the admin or not. |
|
| 32 | + * @return string |
|
| 33 | + */ |
|
| 34 | + public static function firstNameFieldSelectorForAttendeeNumber($attendee_number = 1, $admin = false) |
|
| 35 | + { |
|
| 36 | + return self::fieldSelectorForAttendeeNumber('fname', $attendee_number, $admin); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @param int $attendee_number |
|
| 42 | + * @param bool $admin Used to indicate whether we're retrieving the selector from the context of the admin or not. |
|
| 43 | + * @return string |
|
| 44 | + */ |
|
| 45 | + public static function lastNameFieldSelectorForAttendeeNumber($attendee_number = 1, $admin = false) |
|
| 46 | + { |
|
| 47 | + return self::fieldSelectorForAttendeeNumber('lname', $attendee_number, $admin); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * @param int $attendee_number |
|
| 53 | + * @param bool $admin Used to indicate whether we're retrieving the selector from the context of the admin or not. |
|
| 54 | + * @return string |
|
| 55 | + */ |
|
| 56 | + public static function emailFieldSelectorForAttendeeNumber($attendee_number = 1, $admin = false) |
|
| 57 | + { |
|
| 58 | + return self::fieldSelectorForAttendeeNumber('email', $attendee_number, $admin); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * @param string $field_name |
|
| 63 | + * @param int $attendee_number |
|
| 64 | + * @param bool $admin Used to indicate whether we're retrieving the selector from the context of the admin or not. |
|
| 65 | + * @return string |
|
| 66 | + */ |
|
| 67 | + public static function fieldSelectorForAttendeeNumber($field_name, $attendee_number = 1, $admin = false) |
|
| 68 | + { |
|
| 69 | + return $admin |
|
| 70 | + ? "//fieldset[starts-with(@id, 'ee-registration-$attendee_number')]//input[contains(@class, 'ee-reg-qstn-$field_name')]" |
|
| 71 | + : "//div[starts-with(@id, 'spco-attendee-panel-dv-$attendee_number')]//input[contains(@class, 'ee-reg-qstn-$field_name')]"; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * @param string $payment_method_slug Slug for the payment method. |
|
| 77 | + * @return string |
|
| 78 | + */ |
|
| 79 | + public static function fieldSelectorForPaymentOption($payment_method_slug) |
|
| 80 | + { |
|
| 81 | + return "#ee-available-payment-method-inputs-{$payment_method_slug}"; |
|
| 82 | + } |
|
| 83 | 83 | } |
@@ -1596,7 +1596,7 @@ discard block |
||
| 1596 | 1596 | * @param EE_Transaction $transaction |
| 1597 | 1597 | * @param \EE_Payment $payment |
| 1598 | 1598 | * @param array $REG_IDs |
| 1599 | - * @return bool |
|
| 1599 | + * @return boolean|null |
|
| 1600 | 1600 | */ |
| 1601 | 1601 | protected function _update_registration_payments( |
| 1602 | 1602 | EE_Transaction $transaction, |
@@ -1797,6 +1797,7 @@ discard block |
||
| 1797 | 1797 | * |
| 1798 | 1798 | * @access protected |
| 1799 | 1799 | * @param \EE_Payment | null $payment |
| 1800 | + * @param EE_Payment $payment |
|
| 1800 | 1801 | */ |
| 1801 | 1802 | protected function _maybe_send_notifications($payment = null) |
| 1802 | 1803 | { |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | /** |
@@ -22,1960 +22,1960 @@ discard block |
||
| 22 | 22 | class Transactions_Admin_Page extends EE_Admin_Page |
| 23 | 23 | { |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var EE_Transaction |
|
| 27 | - */ |
|
| 28 | - private $_transaction; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @var EE_Session |
|
| 32 | - */ |
|
| 33 | - private $_session; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @var array $_txn_status |
|
| 37 | - */ |
|
| 38 | - private static $_txn_status; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @var array $_pay_status |
|
| 42 | - */ |
|
| 43 | - private static $_pay_status; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * @var array $_existing_reg_payment_REG_IDs |
|
| 47 | - */ |
|
| 48 | - protected $_existing_reg_payment_REG_IDs = null; |
|
| 49 | - |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * @Constructor |
|
| 53 | - * @access public |
|
| 54 | - * @param bool $routing |
|
| 55 | - * @return Transactions_Admin_Page |
|
| 56 | - */ |
|
| 57 | - public function __construct($routing = true) |
|
| 58 | - { |
|
| 59 | - parent::__construct($routing); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * _init_page_props |
|
| 65 | - * |
|
| 66 | - * @return void |
|
| 67 | - */ |
|
| 68 | - protected function _init_page_props() |
|
| 69 | - { |
|
| 70 | - $this->page_slug = TXN_PG_SLUG; |
|
| 71 | - $this->page_label = esc_html__('Transactions', 'event_espresso'); |
|
| 72 | - $this->_admin_base_url = TXN_ADMIN_URL; |
|
| 73 | - $this->_admin_base_path = TXN_ADMIN; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * _ajax_hooks |
|
| 79 | - * |
|
| 80 | - * @return void |
|
| 81 | - */ |
|
| 82 | - protected function _ajax_hooks() |
|
| 83 | - { |
|
| 84 | - add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds')); |
|
| 85 | - add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds')); |
|
| 86 | - add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment')); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * _define_page_props |
|
| 92 | - * |
|
| 93 | - * @return void |
|
| 94 | - */ |
|
| 95 | - protected function _define_page_props() |
|
| 96 | - { |
|
| 97 | - $this->_admin_page_title = $this->page_label; |
|
| 98 | - $this->_labels = array( |
|
| 99 | - 'buttons' => array( |
|
| 100 | - 'add' => esc_html__('Add New Transaction', 'event_espresso'), |
|
| 101 | - 'edit' => esc_html__('Edit Transaction', 'event_espresso'), |
|
| 102 | - 'delete' => esc_html__('Delete Transaction', 'event_espresso'), |
|
| 103 | - ), |
|
| 104 | - ); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * grab url requests and route them |
|
| 110 | - * |
|
| 111 | - * @access private |
|
| 112 | - * @return void |
|
| 113 | - */ |
|
| 114 | - public function _set_page_routes() |
|
| 115 | - { |
|
| 116 | - |
|
| 117 | - $this->_set_transaction_status_array(); |
|
| 118 | - |
|
| 119 | - $txn_id = ! empty($this->_req_data['TXN_ID']) && ! is_array($this->_req_data['TXN_ID']) ? $this->_req_data['TXN_ID'] : 0; |
|
| 120 | - |
|
| 121 | - $this->_page_routes = array( |
|
| 122 | - |
|
| 123 | - 'default' => array( |
|
| 124 | - 'func' => '_transactions_overview_list_table', |
|
| 125 | - 'capability' => 'ee_read_transactions', |
|
| 126 | - ), |
|
| 127 | - |
|
| 128 | - 'view_transaction' => array( |
|
| 129 | - 'func' => '_transaction_details', |
|
| 130 | - 'capability' => 'ee_read_transaction', |
|
| 131 | - 'obj_id' => $txn_id, |
|
| 132 | - ), |
|
| 133 | - |
|
| 134 | - 'send_payment_reminder' => array( |
|
| 135 | - 'func' => '_send_payment_reminder', |
|
| 136 | - 'noheader' => true, |
|
| 137 | - 'capability' => 'ee_send_message', |
|
| 138 | - ), |
|
| 139 | - |
|
| 140 | - 'espresso_apply_payment' => array( |
|
| 141 | - 'func' => 'apply_payments_or_refunds', |
|
| 142 | - 'noheader' => true, |
|
| 143 | - 'capability' => 'ee_edit_payments', |
|
| 144 | - ), |
|
| 145 | - |
|
| 146 | - 'espresso_apply_refund' => array( |
|
| 147 | - 'func' => 'apply_payments_or_refunds', |
|
| 148 | - 'noheader' => true, |
|
| 149 | - 'capability' => 'ee_edit_payments', |
|
| 150 | - ), |
|
| 151 | - |
|
| 152 | - 'espresso_delete_payment' => array( |
|
| 153 | - 'func' => 'delete_payment', |
|
| 154 | - 'noheader' => true, |
|
| 155 | - 'capability' => 'ee_delete_payments', |
|
| 156 | - ), |
|
| 157 | - |
|
| 158 | - ); |
|
| 159 | - |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - |
|
| 163 | - protected function _set_page_config() |
|
| 164 | - { |
|
| 165 | - $this->_page_config = array( |
|
| 166 | - 'default' => array( |
|
| 167 | - 'nav' => array( |
|
| 168 | - 'label' => esc_html__('Overview', 'event_espresso'), |
|
| 169 | - 'order' => 10, |
|
| 170 | - ), |
|
| 171 | - 'list_table' => 'EE_Admin_Transactions_List_Table', |
|
| 172 | - 'help_tabs' => array( |
|
| 173 | - 'transactions_overview_help_tab' => array( |
|
| 174 | - 'title' => esc_html__('Transactions Overview', 'event_espresso'), |
|
| 175 | - 'filename' => 'transactions_overview', |
|
| 176 | - ), |
|
| 177 | - 'transactions_overview_table_column_headings_help_tab' => array( |
|
| 178 | - 'title' => esc_html__('Transactions Table Column Headings', 'event_espresso'), |
|
| 179 | - 'filename' => 'transactions_overview_table_column_headings', |
|
| 180 | - ), |
|
| 181 | - 'transactions_overview_views_filters_help_tab' => array( |
|
| 182 | - 'title' => esc_html__('Transaction Views & Filters & Search', 'event_espresso'), |
|
| 183 | - 'filename' => 'transactions_overview_views_filters_search', |
|
| 184 | - ), |
|
| 185 | - ), |
|
| 186 | - 'help_tour' => array('Transactions_Overview_Help_Tour'), |
|
| 187 | - /** |
|
| 188 | - * commented out because currently we are not displaying tips for transaction list table status but this |
|
| 189 | - * may change in a later iteration so want to keep the code for then. |
|
| 190 | - */ |
|
| 191 | - //'qtips' => array( 'Transactions_List_Table_Tips' ), |
|
| 192 | - 'require_nonce' => false, |
|
| 193 | - ), |
|
| 194 | - 'view_transaction' => array( |
|
| 195 | - 'nav' => array( |
|
| 196 | - 'label' => esc_html__('View Transaction', 'event_espresso'), |
|
| 197 | - 'order' => 5, |
|
| 198 | - 'url' => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']), |
|
| 199 | - $this->_current_page_view_url) : $this->_admin_base_url, |
|
| 200 | - 'persistent' => false, |
|
| 201 | - ), |
|
| 202 | - 'help_tabs' => array( |
|
| 203 | - 'transactions_view_transaction_help_tab' => array( |
|
| 204 | - 'title' => esc_html__('View Transaction', 'event_espresso'), |
|
| 205 | - 'filename' => 'transactions_view_transaction', |
|
| 206 | - ), |
|
| 207 | - 'transactions_view_transaction_transaction_details_table_help_tab' => array( |
|
| 208 | - 'title' => esc_html__('Transaction Details Table', 'event_espresso'), |
|
| 209 | - 'filename' => 'transactions_view_transaction_transaction_details_table', |
|
| 210 | - ), |
|
| 211 | - 'transactions_view_transaction_attendees_registered_help_tab' => array( |
|
| 212 | - 'title' => esc_html__('Attendees Registered', 'event_espresso'), |
|
| 213 | - 'filename' => 'transactions_view_transaction_attendees_registered', |
|
| 214 | - ), |
|
| 215 | - 'transactions_view_transaction_views_primary_registrant_billing_information_help_tab' => array( |
|
| 216 | - 'title' => esc_html__('Primary Registrant & Billing Information', 'event_espresso'), |
|
| 217 | - 'filename' => 'transactions_view_transaction_primary_registrant_billing_information', |
|
| 218 | - ), |
|
| 219 | - ), |
|
| 220 | - 'qtips' => array('Transaction_Details_Tips'), |
|
| 221 | - 'help_tour' => array('Transaction_Details_Help_Tour'), |
|
| 222 | - 'metaboxes' => array('_transaction_details_metaboxes'), |
|
| 223 | - |
|
| 224 | - 'require_nonce' => false, |
|
| 225 | - ), |
|
| 226 | - ); |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * The below methods aren't used by this class currently |
|
| 232 | - */ |
|
| 233 | - protected function _add_screen_options() |
|
| 234 | - { |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - protected function _add_feature_pointers() |
|
| 238 | - { |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - public function admin_init() |
|
| 242 | - { |
|
| 243 | - // IF a registration was JUST added via the admin... |
|
| 244 | - if ( |
|
| 245 | - isset( |
|
| 246 | - $this->_req_data['redirect_from'], |
|
| 247 | - $this->_req_data['EVT_ID'], |
|
| 248 | - $this->_req_data['event_name'] |
|
| 249 | - ) |
|
| 250 | - ) { |
|
| 251 | - // then set a cookie so that we can block any attempts to use |
|
| 252 | - // the back button as a way to enter another registration. |
|
| 253 | - setcookie('ee_registration_added', $this->_req_data['EVT_ID'], time() + WEEK_IN_SECONDS, '/'); |
|
| 254 | - // and update the global |
|
| 255 | - $_COOKIE['ee_registration_added'] = $this->_req_data['EVT_ID']; |
|
| 256 | - } |
|
| 257 | - EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__('An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', |
|
| 258 | - 'event_espresso'); |
|
| 259 | - EE_Registry::$i18n_js_strings['error_occurred'] = esc_html__('An error occurred! Please refresh the page and try again.', |
|
| 260 | - 'event_espresso'); |
|
| 261 | - EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status; |
|
| 262 | - EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status; |
|
| 263 | - EE_Registry::$i18n_js_strings['payments_total'] = esc_html__('Payments Total', 'event_espresso'); |
|
| 264 | - EE_Registry::$i18n_js_strings['transaction_overpaid'] = esc_html__('This transaction has been overpaid ! Payments Total', |
|
| 265 | - 'event_espresso'); |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - public function admin_notices() |
|
| 269 | - { |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - public function admin_footer_scripts() |
|
| 273 | - { |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - |
|
| 277 | - /** |
|
| 278 | - * _set_transaction_status_array |
|
| 279 | - * sets list of transaction statuses |
|
| 280 | - * |
|
| 281 | - * @access private |
|
| 282 | - * @return void |
|
| 283 | - */ |
|
| 284 | - private function _set_transaction_status_array() |
|
| 285 | - { |
|
| 286 | - self::$_txn_status = EEM_Transaction::instance()->status_array(true); |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - |
|
| 290 | - /** |
|
| 291 | - * get_transaction_status_array |
|
| 292 | - * return the transaction status array for wp_list_table |
|
| 293 | - * |
|
| 294 | - * @access public |
|
| 295 | - * @return array |
|
| 296 | - */ |
|
| 297 | - public function get_transaction_status_array() |
|
| 298 | - { |
|
| 299 | - return self::$_txn_status; |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - |
|
| 303 | - /** |
|
| 304 | - * get list of payment statuses |
|
| 305 | - * |
|
| 306 | - * @access private |
|
| 307 | - * @return void |
|
| 308 | - */ |
|
| 309 | - private function _get_payment_status_array() |
|
| 310 | - { |
|
| 311 | - self::$_pay_status = EEM_Payment::instance()->status_array(true); |
|
| 312 | - $this->_template_args['payment_status'] = self::$_pay_status; |
|
| 313 | - |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - |
|
| 317 | - /** |
|
| 318 | - * _add_screen_options_default |
|
| 319 | - * |
|
| 320 | - * @access protected |
|
| 321 | - * @return void |
|
| 322 | - */ |
|
| 323 | - protected function _add_screen_options_default() |
|
| 324 | - { |
|
| 325 | - $this->_per_page_screen_option(); |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - |
|
| 329 | - /** |
|
| 330 | - * load_scripts_styles |
|
| 331 | - * |
|
| 332 | - * @access public |
|
| 333 | - * @return void |
|
| 334 | - */ |
|
| 335 | - public function load_scripts_styles() |
|
| 336 | - { |
|
| 337 | - //enqueue style |
|
| 338 | - wp_register_style('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.css', array(), |
|
| 339 | - EVENT_ESPRESSO_VERSION); |
|
| 340 | - wp_enqueue_style('espresso_txn'); |
|
| 341 | - //scripts |
|
| 342 | - wp_register_script('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.js', array( |
|
| 343 | - 'ee_admin_js', |
|
| 344 | - 'ee-datepicker', |
|
| 345 | - 'jquery-ui-datepicker', |
|
| 346 | - 'jquery-ui-draggable', |
|
| 347 | - 'ee-dialog', |
|
| 348 | - 'ee-accounting', |
|
| 349 | - 'ee-serialize-full-array', |
|
| 350 | - ), EVENT_ESPRESSO_VERSION, true); |
|
| 351 | - wp_enqueue_script('espresso_txn'); |
|
| 352 | - |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * load_scripts_styles_view_transaction |
|
| 358 | - * |
|
| 359 | - * @access public |
|
| 360 | - * @return void |
|
| 361 | - */ |
|
| 362 | - public function load_scripts_styles_view_transaction() |
|
| 363 | - { |
|
| 364 | - //styles |
|
| 365 | - wp_enqueue_style('espresso-ui-theme'); |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - |
|
| 369 | - /** |
|
| 370 | - * load_scripts_styles_default |
|
| 371 | - * |
|
| 372 | - * @access public |
|
| 373 | - * @return void |
|
| 374 | - */ |
|
| 375 | - public function load_scripts_styles_default() |
|
| 376 | - { |
|
| 377 | - //styles |
|
| 378 | - wp_enqueue_style('espresso-ui-theme'); |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - |
|
| 382 | - /** |
|
| 383 | - * _set_list_table_views_default |
|
| 384 | - * |
|
| 385 | - * @access protected |
|
| 386 | - * @return void |
|
| 387 | - */ |
|
| 388 | - protected function _set_list_table_views_default() |
|
| 389 | - { |
|
| 390 | - $this->_views = array( |
|
| 391 | - 'all' => array( |
|
| 392 | - 'slug' => 'all', |
|
| 393 | - 'label' => esc_html__('View All Transactions', 'event_espresso'), |
|
| 394 | - 'count' => 0, |
|
| 395 | - ), |
|
| 396 | - 'abandoned' => array( |
|
| 397 | - 'slug' => 'abandoned', |
|
| 398 | - 'label' => esc_html__('Abandoned Transactions', 'event_espresso'), |
|
| 399 | - 'count' => 0, |
|
| 400 | - ), |
|
| 401 | - 'failed' => array( |
|
| 402 | - 'slug' => 'failed', |
|
| 403 | - 'label' => esc_html__('Failed Transactions', 'event_espresso'), |
|
| 404 | - 'count' => 0, |
|
| 405 | - ), |
|
| 406 | - ); |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - |
|
| 410 | - /** |
|
| 411 | - * _set_transaction_object |
|
| 412 | - * This sets the _transaction property for the transaction details screen |
|
| 413 | - * |
|
| 414 | - * @access private |
|
| 415 | - * @return void |
|
| 416 | - */ |
|
| 417 | - private function _set_transaction_object() |
|
| 418 | - { |
|
| 419 | - if (is_object($this->_transaction)) { |
|
| 420 | - return; |
|
| 421 | - } //get out we've already set the object |
|
| 422 | - |
|
| 423 | - $TXN = EEM_Transaction::instance(); |
|
| 424 | - |
|
| 425 | - $TXN_ID = (! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : false; |
|
| 426 | - |
|
| 427 | - //get transaction object |
|
| 428 | - $this->_transaction = $TXN->get_one_by_ID($TXN_ID); |
|
| 429 | - $this->_session = ! empty($this->_transaction) ? $this->_transaction->get('TXN_session_data') : null; |
|
| 430 | - $this->_transaction->verify_abandoned_transaction_status(); |
|
| 431 | - |
|
| 432 | - if (empty($this->_transaction)) { |
|
| 433 | - $error_msg = esc_html__('An error occurred and the details for Transaction ID #', |
|
| 434 | - 'event_espresso') . $TXN_ID . esc_html__(' could not be retrieved.', 'event_espresso'); |
|
| 435 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 436 | - } |
|
| 437 | - } |
|
| 438 | - |
|
| 439 | - |
|
| 440 | - /** |
|
| 441 | - * _transaction_legend_items |
|
| 442 | - * |
|
| 443 | - * @access protected |
|
| 444 | - * @return array |
|
| 445 | - */ |
|
| 446 | - protected function _transaction_legend_items() |
|
| 447 | - { |
|
| 448 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 449 | - $items = array(); |
|
| 450 | - |
|
| 451 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
| 452 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
| 453 | - if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
| 454 | - $items['view_related_messages'] = array( |
|
| 455 | - 'class' => $related_for_icon['css_class'], |
|
| 456 | - 'desc' => $related_for_icon['label'], |
|
| 457 | - ); |
|
| 458 | - } |
|
| 459 | - } |
|
| 460 | - |
|
| 461 | - $items = apply_filters( |
|
| 462 | - 'FHEE__Transactions_Admin_Page___transaction_legend_items__items', |
|
| 463 | - array_merge($items, |
|
| 464 | - array( |
|
| 465 | - 'view_details' => array( |
|
| 466 | - 'class' => 'dashicons dashicons-cart', |
|
| 467 | - 'desc' => esc_html__('View Transaction Details', 'event_espresso'), |
|
| 468 | - ), |
|
| 469 | - 'view_invoice' => array( |
|
| 470 | - 'class' => 'dashicons dashicons-media-spreadsheet', |
|
| 471 | - 'desc' => esc_html__('View Transaction Invoice', 'event_espresso'), |
|
| 472 | - ), |
|
| 473 | - 'view_receipt' => array( |
|
| 474 | - 'class' => 'dashicons dashicons-media-default', |
|
| 475 | - 'desc' => esc_html__('View Transaction Receipt', 'event_espresso'), |
|
| 476 | - ), |
|
| 477 | - 'view_registration' => array( |
|
| 478 | - 'class' => 'dashicons dashicons-clipboard', |
|
| 479 | - 'desc' => esc_html__('View Registration Details', 'event_espresso'), |
|
| 480 | - ), |
|
| 481 | - 'payment_overview_link' => array( |
|
| 482 | - 'class' => 'dashicons dashicons-money', |
|
| 483 | - 'desc' => esc_html__('Make Payment on Frontend', 'event_espresso'), |
|
| 484 | - ), |
|
| 485 | - ) |
|
| 486 | - ) |
|
| 487 | - ); |
|
| 488 | - |
|
| 489 | - if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
| 490 | - 'espresso_transactions_send_payment_reminder') |
|
| 491 | - ) { |
|
| 492 | - if (EEH_MSG_Template::is_mt_active('payment_reminder')) { |
|
| 493 | - $items['send_payment_reminder'] = array( |
|
| 494 | - 'class' => 'dashicons dashicons-email-alt', |
|
| 495 | - 'desc' => esc_html__('Send Payment Reminder', 'event_espresso'), |
|
| 496 | - ); |
|
| 497 | - } else { |
|
| 498 | - $items['blank*'] = array( |
|
| 499 | - 'class' => '', |
|
| 500 | - 'desc' => '', |
|
| 501 | - ); |
|
| 502 | - } |
|
| 503 | - } else { |
|
| 504 | - $items['blank*'] = array( |
|
| 505 | - 'class' => '', |
|
| 506 | - 'desc' => '', |
|
| 507 | - ); |
|
| 508 | - } |
|
| 509 | - $more_items = apply_filters( |
|
| 510 | - 'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items', |
|
| 511 | - array( |
|
| 512 | - 'overpaid' => array( |
|
| 513 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code, |
|
| 514 | - 'desc' => EEH_Template::pretty_status(EEM_Transaction::overpaid_status_code, false, 'sentence'), |
|
| 515 | - ), |
|
| 516 | - 'complete' => array( |
|
| 517 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code, |
|
| 518 | - 'desc' => EEH_Template::pretty_status(EEM_Transaction::complete_status_code, false, 'sentence'), |
|
| 519 | - ), |
|
| 520 | - 'incomplete' => array( |
|
| 521 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code, |
|
| 522 | - 'desc' => EEH_Template::pretty_status(EEM_Transaction::incomplete_status_code, false, 'sentence'), |
|
| 523 | - ), |
|
| 524 | - 'abandoned' => array( |
|
| 525 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code, |
|
| 526 | - 'desc' => EEH_Template::pretty_status(EEM_Transaction::abandoned_status_code, false, 'sentence'), |
|
| 527 | - ), |
|
| 528 | - 'failed' => array( |
|
| 529 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code, |
|
| 530 | - 'desc' => EEH_Template::pretty_status(EEM_Transaction::failed_status_code, false, 'sentence'), |
|
| 531 | - ), |
|
| 532 | - ) |
|
| 533 | - ); |
|
| 534 | - |
|
| 535 | - return array_merge($items, $more_items); |
|
| 536 | - } |
|
| 537 | - |
|
| 538 | - |
|
| 539 | - /** |
|
| 540 | - * _transactions_overview_list_table |
|
| 541 | - * |
|
| 542 | - * @access protected |
|
| 543 | - * @return void |
|
| 544 | - */ |
|
| 545 | - protected function _transactions_overview_list_table() |
|
| 546 | - { |
|
| 547 | - $this->_admin_page_title = esc_html__('Transactions', 'event_espresso'); |
|
| 548 | - $event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']) : null; |
|
| 549 | - $this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf(esc_html__('%sViewing Transactions for the Event: %s%s', |
|
| 550 | - 'event_espresso'), '<h3>', |
|
| 551 | - '<a href="' . EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), |
|
| 552 | - EVENTS_ADMIN_URL) . '" title="' . esc_attr__('Click to Edit event', |
|
| 553 | - 'event_espresso') . '">' . $event->get('EVT_name') . '</a>', '</h3>') : ''; |
|
| 554 | - $this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items()); |
|
| 555 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 556 | - } |
|
| 557 | - |
|
| 558 | - |
|
| 559 | - /** |
|
| 560 | - * _transaction_details |
|
| 561 | - * generates HTML for the View Transaction Details Admin page |
|
| 562 | - * |
|
| 563 | - * @access protected |
|
| 564 | - * @return void |
|
| 565 | - */ |
|
| 566 | - protected function _transaction_details() |
|
| 567 | - { |
|
| 568 | - do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction); |
|
| 569 | - |
|
| 570 | - $this->_set_transaction_status_array(); |
|
| 571 | - |
|
| 572 | - $this->_template_args = array(); |
|
| 573 | - $this->_template_args['transactions_page'] = $this->_wp_page_slug; |
|
| 574 | - |
|
| 575 | - $this->_set_transaction_object(); |
|
| 576 | - |
|
| 577 | - $primary_registration = $this->_transaction->primary_registration(); |
|
| 578 | - $attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : null; |
|
| 579 | - |
|
| 580 | - $this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID(); |
|
| 581 | - $this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso'); |
|
| 582 | - |
|
| 583 | - $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp'); |
|
| 584 | - $this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso'); |
|
| 585 | - |
|
| 586 | - $this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')]; |
|
| 587 | - $this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso'); |
|
| 588 | - $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID'); |
|
| 589 | - |
|
| 590 | - $this->_template_args['grand_total'] = $this->_transaction->get('TXN_total'); |
|
| 591 | - $this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid'); |
|
| 592 | - |
|
| 593 | - if ( |
|
| 594 | - $attendee instanceof EE_Attendee |
|
| 595 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 596 | - 'ee_send_message', |
|
| 597 | - 'espresso_transactions_send_payment_reminder' |
|
| 598 | - ) |
|
| 599 | - ) { |
|
| 600 | - $this->_template_args['send_payment_reminder_button'] = |
|
| 601 | - EEH_MSG_Template::is_mt_active('payment_reminder') |
|
| 602 | - && $this->_transaction->get('STS_ID') != EEM_Transaction::complete_status_code |
|
| 603 | - && $this->_transaction->get('STS_ID') != EEM_Transaction::overpaid_status_code |
|
| 604 | - ? EEH_Template::get_button_or_link( |
|
| 605 | - EE_Admin_Page::add_query_args_and_nonce( |
|
| 606 | - array( |
|
| 607 | - 'action' => 'send_payment_reminder', |
|
| 608 | - 'TXN_ID' => $this->_transaction->ID(), |
|
| 609 | - 'redirect_to' => 'view_transaction', |
|
| 610 | - ), |
|
| 611 | - TXN_ADMIN_URL |
|
| 612 | - ), |
|
| 613 | - __(' Send Payment Reminder', 'event_espresso'), |
|
| 614 | - 'button secondary-button right', |
|
| 615 | - 'dashicons dashicons-email-alt' |
|
| 616 | - ) |
|
| 617 | - : ''; |
|
| 618 | - } else { |
|
| 619 | - $this->_template_args['send_payment_reminder_button'] = ''; |
|
| 620 | - } |
|
| 621 | - |
|
| 622 | - $amount_due = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid'); |
|
| 623 | - $this->_template_args['amount_due'] = EEH_Template::format_currency($amount_due, true); |
|
| 624 | - if (EE_Registry::instance()->CFG->currency->sign_b4) { |
|
| 625 | - $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign . $this->_template_args['amount_due']; |
|
| 626 | - } else { |
|
| 627 | - $this->_template_args['amount_due'] = $this->_template_args['amount_due'] . EE_Registry::instance()->CFG->currency->sign; |
|
| 628 | - } |
|
| 629 | - $this->_template_args['amount_due_class'] = ''; |
|
| 630 | - |
|
| 631 | - if ($this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total')) { |
|
| 632 | - // paid in full |
|
| 633 | - $this->_template_args['amount_due'] = false; |
|
| 634 | - } elseif ($this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total')) { |
|
| 635 | - // overpaid |
|
| 636 | - $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
| 637 | - } elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') > 0)) { |
|
| 638 | - // monies owing |
|
| 639 | - $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn'; |
|
| 640 | - } elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') == 0)) { |
|
| 641 | - // no payments made yet |
|
| 642 | - $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
| 643 | - } elseif ($this->_transaction->get('TXN_total') == 0) { |
|
| 644 | - // free event |
|
| 645 | - $this->_template_args['amount_due'] = false; |
|
| 646 | - } |
|
| 647 | - |
|
| 648 | - $payment_method = $this->_transaction->payment_method(); |
|
| 649 | - |
|
| 650 | - $this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method |
|
| 651 | - ? $payment_method->admin_name() |
|
| 652 | - : esc_html__('Unknown', 'event_espresso'); |
|
| 653 | - |
|
| 654 | - $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 655 | - // link back to overview |
|
| 656 | - $this->_template_args['txn_overview_url'] = ! empty ($_SERVER['HTTP_REFERER']) |
|
| 657 | - ? $_SERVER['HTTP_REFERER'] |
|
| 658 | - : TXN_ADMIN_URL; |
|
| 659 | - |
|
| 660 | - |
|
| 661 | - // next link |
|
| 662 | - $next_txn = $this->_transaction->next( |
|
| 663 | - null, |
|
| 664 | - array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), |
|
| 665 | - 'TXN_ID' |
|
| 666 | - ); |
|
| 667 | - $this->_template_args['next_transaction'] = $next_txn |
|
| 668 | - ? $this->_next_link( |
|
| 669 | - EE_Admin_Page::add_query_args_and_nonce( |
|
| 670 | - array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']), |
|
| 671 | - TXN_ADMIN_URL |
|
| 672 | - ), |
|
| 673 | - 'dashicons dashicons-arrow-right ee-icon-size-22' |
|
| 674 | - ) |
|
| 675 | - : ''; |
|
| 676 | - // previous link |
|
| 677 | - $previous_txn = $this->_transaction->previous( |
|
| 678 | - null, |
|
| 679 | - array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), |
|
| 680 | - 'TXN_ID' |
|
| 681 | - ); |
|
| 682 | - $this->_template_args['previous_transaction'] = $previous_txn |
|
| 683 | - ? $this->_previous_link( |
|
| 684 | - EE_Admin_Page::add_query_args_and_nonce( |
|
| 685 | - array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']), |
|
| 686 | - TXN_ADMIN_URL |
|
| 687 | - ), |
|
| 688 | - 'dashicons dashicons-arrow-left ee-icon-size-22' |
|
| 689 | - ) |
|
| 690 | - : ''; |
|
| 691 | - |
|
| 692 | - // were we just redirected here after adding a new registration ??? |
|
| 693 | - if ( |
|
| 694 | - isset( |
|
| 695 | - $this->_req_data['redirect_from'], |
|
| 696 | - $this->_req_data['EVT_ID'], |
|
| 697 | - $this->_req_data['event_name'] |
|
| 698 | - ) |
|
| 699 | - ) { |
|
| 700 | - if ( |
|
| 701 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 702 | - 'ee_edit_registrations', |
|
| 703 | - 'espresso_registrations_new_registration', |
|
| 704 | - $this->_req_data['EVT_ID'] |
|
| 705 | - ) |
|
| 706 | - ) { |
|
| 707 | - $this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="'; |
|
| 708 | - $this->_admin_page_title .= EE_Admin_Page::add_query_args_and_nonce( |
|
| 709 | - array( |
|
| 710 | - 'page' => 'espresso_registrations', |
|
| 711 | - 'action' => 'new_registration', |
|
| 712 | - 'return' => 'default', |
|
| 713 | - 'TXN_ID' => $this->_transaction->ID(), |
|
| 714 | - 'event_id' => $this->_req_data['EVT_ID'], |
|
| 715 | - ), |
|
| 716 | - REG_ADMIN_URL |
|
| 717 | - ); |
|
| 718 | - $this->_admin_page_title .= '">'; |
|
| 719 | - |
|
| 720 | - $this->_admin_page_title .= sprintf( |
|
| 721 | - esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'), |
|
| 722 | - htmlentities(urldecode($this->_req_data['event_name']), ENT_QUOTES, 'UTF-8') |
|
| 723 | - ); |
|
| 724 | - $this->_admin_page_title .= '</a>'; |
|
| 725 | - } |
|
| 726 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 727 | - } |
|
| 728 | - // grab messages at the last second |
|
| 729 | - $this->_template_args['notices'] = EE_Error::get_notices(); |
|
| 730 | - // path to template |
|
| 731 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php'; |
|
| 732 | - $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, |
|
| 733 | - $this->_template_args, true); |
|
| 734 | - |
|
| 735 | - // the details template wrapper |
|
| 736 | - $this->display_admin_page_with_sidebar(); |
|
| 737 | - |
|
| 738 | - } |
|
| 739 | - |
|
| 740 | - |
|
| 741 | - /** |
|
| 742 | - * _transaction_details_metaboxes |
|
| 743 | - * |
|
| 744 | - * @access protected |
|
| 745 | - * @return void |
|
| 746 | - */ |
|
| 747 | - protected function _transaction_details_metaboxes() |
|
| 748 | - { |
|
| 749 | - |
|
| 750 | - $this->_set_transaction_object(); |
|
| 751 | - |
|
| 752 | - add_meta_box('edit-txn-details-mbox', esc_html__('Transaction Details', 'event_espresso'), |
|
| 753 | - array($this, 'txn_details_meta_box'), $this->_wp_page_slug, 'normal', 'high'); |
|
| 754 | - add_meta_box( |
|
| 755 | - 'edit-txn-attendees-mbox', |
|
| 756 | - esc_html__('Attendees Registered in this Transaction', 'event_espresso'), |
|
| 757 | - array($this, 'txn_attendees_meta_box'), |
|
| 758 | - $this->_wp_page_slug, |
|
| 759 | - 'normal', |
|
| 760 | - 'high', |
|
| 761 | - array('TXN_ID' => $this->_transaction->ID()) |
|
| 762 | - ); |
|
| 763 | - add_meta_box('edit-txn-registrant-mbox', esc_html__('Primary Contact', 'event_espresso'), |
|
| 764 | - array($this, 'txn_registrant_side_meta_box'), $this->_wp_page_slug, 'side', 'high'); |
|
| 765 | - add_meta_box('edit-txn-billing-info-mbox', esc_html__('Billing Information', 'event_espresso'), |
|
| 766 | - array($this, 'txn_billing_info_side_meta_box'), $this->_wp_page_slug, 'side', 'high'); |
|
| 767 | - |
|
| 768 | - } |
|
| 769 | - |
|
| 770 | - |
|
| 771 | - /** |
|
| 772 | - * txn_details_meta_box |
|
| 773 | - * generates HTML for the Transaction main meta box |
|
| 774 | - * |
|
| 775 | - * @access public |
|
| 776 | - * @return void |
|
| 777 | - */ |
|
| 778 | - public function txn_details_meta_box() |
|
| 779 | - { |
|
| 780 | - |
|
| 781 | - $this->_set_transaction_object(); |
|
| 782 | - $this->_template_args['TXN_ID'] = $this->_transaction->ID(); |
|
| 783 | - $this->_template_args['attendee'] = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->attendee() : null; |
|
| 784 | - |
|
| 785 | - //get line table |
|
| 786 | - EEH_Autoloader::register_line_item_display_autoloaders(); |
|
| 787 | - $Line_Item_Display = new EE_Line_Item_Display('admin_table', |
|
| 788 | - 'EE_Admin_Table_Line_Item_Display_Strategy'); |
|
| 789 | - $this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item($this->_transaction->total_line_item()); |
|
| 790 | - $this->_template_args['REG_code'] = $this->_transaction->get_first_related('Registration')->get('REG_code'); |
|
| 791 | - |
|
| 792 | - // process taxes |
|
| 793 | - $taxes = $this->_transaction->get_many_related('Line_Item', |
|
| 794 | - array(array('LIN_type' => EEM_Line_Item::type_tax))); |
|
| 795 | - $this->_template_args['taxes'] = ! empty($taxes) ? $taxes : false; |
|
| 796 | - |
|
| 797 | - $this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), |
|
| 798 | - false, false); |
|
| 799 | - $this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total'); |
|
| 800 | - $this->_template_args['TXN_status'] = $this->_transaction->get('STS_ID'); |
|
| 25 | + /** |
|
| 26 | + * @var EE_Transaction |
|
| 27 | + */ |
|
| 28 | + private $_transaction; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @var EE_Session |
|
| 32 | + */ |
|
| 33 | + private $_session; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @var array $_txn_status |
|
| 37 | + */ |
|
| 38 | + private static $_txn_status; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @var array $_pay_status |
|
| 42 | + */ |
|
| 43 | + private static $_pay_status; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @var array $_existing_reg_payment_REG_IDs |
|
| 47 | + */ |
|
| 48 | + protected $_existing_reg_payment_REG_IDs = null; |
|
| 49 | + |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * @Constructor |
|
| 53 | + * @access public |
|
| 54 | + * @param bool $routing |
|
| 55 | + * @return Transactions_Admin_Page |
|
| 56 | + */ |
|
| 57 | + public function __construct($routing = true) |
|
| 58 | + { |
|
| 59 | + parent::__construct($routing); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * _init_page_props |
|
| 65 | + * |
|
| 66 | + * @return void |
|
| 67 | + */ |
|
| 68 | + protected function _init_page_props() |
|
| 69 | + { |
|
| 70 | + $this->page_slug = TXN_PG_SLUG; |
|
| 71 | + $this->page_label = esc_html__('Transactions', 'event_espresso'); |
|
| 72 | + $this->_admin_base_url = TXN_ADMIN_URL; |
|
| 73 | + $this->_admin_base_path = TXN_ADMIN; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * _ajax_hooks |
|
| 79 | + * |
|
| 80 | + * @return void |
|
| 81 | + */ |
|
| 82 | + protected function _ajax_hooks() |
|
| 83 | + { |
|
| 84 | + add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds')); |
|
| 85 | + add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds')); |
|
| 86 | + add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment')); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * _define_page_props |
|
| 92 | + * |
|
| 93 | + * @return void |
|
| 94 | + */ |
|
| 95 | + protected function _define_page_props() |
|
| 96 | + { |
|
| 97 | + $this->_admin_page_title = $this->page_label; |
|
| 98 | + $this->_labels = array( |
|
| 99 | + 'buttons' => array( |
|
| 100 | + 'add' => esc_html__('Add New Transaction', 'event_espresso'), |
|
| 101 | + 'edit' => esc_html__('Edit Transaction', 'event_espresso'), |
|
| 102 | + 'delete' => esc_html__('Delete Transaction', 'event_espresso'), |
|
| 103 | + ), |
|
| 104 | + ); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * grab url requests and route them |
|
| 110 | + * |
|
| 111 | + * @access private |
|
| 112 | + * @return void |
|
| 113 | + */ |
|
| 114 | + public function _set_page_routes() |
|
| 115 | + { |
|
| 116 | + |
|
| 117 | + $this->_set_transaction_status_array(); |
|
| 118 | + |
|
| 119 | + $txn_id = ! empty($this->_req_data['TXN_ID']) && ! is_array($this->_req_data['TXN_ID']) ? $this->_req_data['TXN_ID'] : 0; |
|
| 120 | + |
|
| 121 | + $this->_page_routes = array( |
|
| 122 | + |
|
| 123 | + 'default' => array( |
|
| 124 | + 'func' => '_transactions_overview_list_table', |
|
| 125 | + 'capability' => 'ee_read_transactions', |
|
| 126 | + ), |
|
| 127 | + |
|
| 128 | + 'view_transaction' => array( |
|
| 129 | + 'func' => '_transaction_details', |
|
| 130 | + 'capability' => 'ee_read_transaction', |
|
| 131 | + 'obj_id' => $txn_id, |
|
| 132 | + ), |
|
| 133 | + |
|
| 134 | + 'send_payment_reminder' => array( |
|
| 135 | + 'func' => '_send_payment_reminder', |
|
| 136 | + 'noheader' => true, |
|
| 137 | + 'capability' => 'ee_send_message', |
|
| 138 | + ), |
|
| 139 | + |
|
| 140 | + 'espresso_apply_payment' => array( |
|
| 141 | + 'func' => 'apply_payments_or_refunds', |
|
| 142 | + 'noheader' => true, |
|
| 143 | + 'capability' => 'ee_edit_payments', |
|
| 144 | + ), |
|
| 145 | + |
|
| 146 | + 'espresso_apply_refund' => array( |
|
| 147 | + 'func' => 'apply_payments_or_refunds', |
|
| 148 | + 'noheader' => true, |
|
| 149 | + 'capability' => 'ee_edit_payments', |
|
| 150 | + ), |
|
| 151 | + |
|
| 152 | + 'espresso_delete_payment' => array( |
|
| 153 | + 'func' => 'delete_payment', |
|
| 154 | + 'noheader' => true, |
|
| 155 | + 'capability' => 'ee_delete_payments', |
|
| 156 | + ), |
|
| 157 | + |
|
| 158 | + ); |
|
| 159 | + |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + |
|
| 163 | + protected function _set_page_config() |
|
| 164 | + { |
|
| 165 | + $this->_page_config = array( |
|
| 166 | + 'default' => array( |
|
| 167 | + 'nav' => array( |
|
| 168 | + 'label' => esc_html__('Overview', 'event_espresso'), |
|
| 169 | + 'order' => 10, |
|
| 170 | + ), |
|
| 171 | + 'list_table' => 'EE_Admin_Transactions_List_Table', |
|
| 172 | + 'help_tabs' => array( |
|
| 173 | + 'transactions_overview_help_tab' => array( |
|
| 174 | + 'title' => esc_html__('Transactions Overview', 'event_espresso'), |
|
| 175 | + 'filename' => 'transactions_overview', |
|
| 176 | + ), |
|
| 177 | + 'transactions_overview_table_column_headings_help_tab' => array( |
|
| 178 | + 'title' => esc_html__('Transactions Table Column Headings', 'event_espresso'), |
|
| 179 | + 'filename' => 'transactions_overview_table_column_headings', |
|
| 180 | + ), |
|
| 181 | + 'transactions_overview_views_filters_help_tab' => array( |
|
| 182 | + 'title' => esc_html__('Transaction Views & Filters & Search', 'event_espresso'), |
|
| 183 | + 'filename' => 'transactions_overview_views_filters_search', |
|
| 184 | + ), |
|
| 185 | + ), |
|
| 186 | + 'help_tour' => array('Transactions_Overview_Help_Tour'), |
|
| 187 | + /** |
|
| 188 | + * commented out because currently we are not displaying tips for transaction list table status but this |
|
| 189 | + * may change in a later iteration so want to keep the code for then. |
|
| 190 | + */ |
|
| 191 | + //'qtips' => array( 'Transactions_List_Table_Tips' ), |
|
| 192 | + 'require_nonce' => false, |
|
| 193 | + ), |
|
| 194 | + 'view_transaction' => array( |
|
| 195 | + 'nav' => array( |
|
| 196 | + 'label' => esc_html__('View Transaction', 'event_espresso'), |
|
| 197 | + 'order' => 5, |
|
| 198 | + 'url' => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']), |
|
| 199 | + $this->_current_page_view_url) : $this->_admin_base_url, |
|
| 200 | + 'persistent' => false, |
|
| 201 | + ), |
|
| 202 | + 'help_tabs' => array( |
|
| 203 | + 'transactions_view_transaction_help_tab' => array( |
|
| 204 | + 'title' => esc_html__('View Transaction', 'event_espresso'), |
|
| 205 | + 'filename' => 'transactions_view_transaction', |
|
| 206 | + ), |
|
| 207 | + 'transactions_view_transaction_transaction_details_table_help_tab' => array( |
|
| 208 | + 'title' => esc_html__('Transaction Details Table', 'event_espresso'), |
|
| 209 | + 'filename' => 'transactions_view_transaction_transaction_details_table', |
|
| 210 | + ), |
|
| 211 | + 'transactions_view_transaction_attendees_registered_help_tab' => array( |
|
| 212 | + 'title' => esc_html__('Attendees Registered', 'event_espresso'), |
|
| 213 | + 'filename' => 'transactions_view_transaction_attendees_registered', |
|
| 214 | + ), |
|
| 215 | + 'transactions_view_transaction_views_primary_registrant_billing_information_help_tab' => array( |
|
| 216 | + 'title' => esc_html__('Primary Registrant & Billing Information', 'event_espresso'), |
|
| 217 | + 'filename' => 'transactions_view_transaction_primary_registrant_billing_information', |
|
| 218 | + ), |
|
| 219 | + ), |
|
| 220 | + 'qtips' => array('Transaction_Details_Tips'), |
|
| 221 | + 'help_tour' => array('Transaction_Details_Help_Tour'), |
|
| 222 | + 'metaboxes' => array('_transaction_details_metaboxes'), |
|
| 223 | + |
|
| 224 | + 'require_nonce' => false, |
|
| 225 | + ), |
|
| 226 | + ); |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * The below methods aren't used by this class currently |
|
| 232 | + */ |
|
| 233 | + protected function _add_screen_options() |
|
| 234 | + { |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + protected function _add_feature_pointers() |
|
| 238 | + { |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + public function admin_init() |
|
| 242 | + { |
|
| 243 | + // IF a registration was JUST added via the admin... |
|
| 244 | + if ( |
|
| 245 | + isset( |
|
| 246 | + $this->_req_data['redirect_from'], |
|
| 247 | + $this->_req_data['EVT_ID'], |
|
| 248 | + $this->_req_data['event_name'] |
|
| 249 | + ) |
|
| 250 | + ) { |
|
| 251 | + // then set a cookie so that we can block any attempts to use |
|
| 252 | + // the back button as a way to enter another registration. |
|
| 253 | + setcookie('ee_registration_added', $this->_req_data['EVT_ID'], time() + WEEK_IN_SECONDS, '/'); |
|
| 254 | + // and update the global |
|
| 255 | + $_COOKIE['ee_registration_added'] = $this->_req_data['EVT_ID']; |
|
| 256 | + } |
|
| 257 | + EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__('An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', |
|
| 258 | + 'event_espresso'); |
|
| 259 | + EE_Registry::$i18n_js_strings['error_occurred'] = esc_html__('An error occurred! Please refresh the page and try again.', |
|
| 260 | + 'event_espresso'); |
|
| 261 | + EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status; |
|
| 262 | + EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status; |
|
| 263 | + EE_Registry::$i18n_js_strings['payments_total'] = esc_html__('Payments Total', 'event_espresso'); |
|
| 264 | + EE_Registry::$i18n_js_strings['transaction_overpaid'] = esc_html__('This transaction has been overpaid ! Payments Total', |
|
| 265 | + 'event_espresso'); |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + public function admin_notices() |
|
| 269 | + { |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + public function admin_footer_scripts() |
|
| 273 | + { |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + |
|
| 277 | + /** |
|
| 278 | + * _set_transaction_status_array |
|
| 279 | + * sets list of transaction statuses |
|
| 280 | + * |
|
| 281 | + * @access private |
|
| 282 | + * @return void |
|
| 283 | + */ |
|
| 284 | + private function _set_transaction_status_array() |
|
| 285 | + { |
|
| 286 | + self::$_txn_status = EEM_Transaction::instance()->status_array(true); |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + |
|
| 290 | + /** |
|
| 291 | + * get_transaction_status_array |
|
| 292 | + * return the transaction status array for wp_list_table |
|
| 293 | + * |
|
| 294 | + * @access public |
|
| 295 | + * @return array |
|
| 296 | + */ |
|
| 297 | + public function get_transaction_status_array() |
|
| 298 | + { |
|
| 299 | + return self::$_txn_status; |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * get list of payment statuses |
|
| 305 | + * |
|
| 306 | + * @access private |
|
| 307 | + * @return void |
|
| 308 | + */ |
|
| 309 | + private function _get_payment_status_array() |
|
| 310 | + { |
|
| 311 | + self::$_pay_status = EEM_Payment::instance()->status_array(true); |
|
| 312 | + $this->_template_args['payment_status'] = self::$_pay_status; |
|
| 313 | + |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + |
|
| 317 | + /** |
|
| 318 | + * _add_screen_options_default |
|
| 319 | + * |
|
| 320 | + * @access protected |
|
| 321 | + * @return void |
|
| 322 | + */ |
|
| 323 | + protected function _add_screen_options_default() |
|
| 324 | + { |
|
| 325 | + $this->_per_page_screen_option(); |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + |
|
| 329 | + /** |
|
| 330 | + * load_scripts_styles |
|
| 331 | + * |
|
| 332 | + * @access public |
|
| 333 | + * @return void |
|
| 334 | + */ |
|
| 335 | + public function load_scripts_styles() |
|
| 336 | + { |
|
| 337 | + //enqueue style |
|
| 338 | + wp_register_style('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.css', array(), |
|
| 339 | + EVENT_ESPRESSO_VERSION); |
|
| 340 | + wp_enqueue_style('espresso_txn'); |
|
| 341 | + //scripts |
|
| 342 | + wp_register_script('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.js', array( |
|
| 343 | + 'ee_admin_js', |
|
| 344 | + 'ee-datepicker', |
|
| 345 | + 'jquery-ui-datepicker', |
|
| 346 | + 'jquery-ui-draggable', |
|
| 347 | + 'ee-dialog', |
|
| 348 | + 'ee-accounting', |
|
| 349 | + 'ee-serialize-full-array', |
|
| 350 | + ), EVENT_ESPRESSO_VERSION, true); |
|
| 351 | + wp_enqueue_script('espresso_txn'); |
|
| 352 | + |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * load_scripts_styles_view_transaction |
|
| 358 | + * |
|
| 359 | + * @access public |
|
| 360 | + * @return void |
|
| 361 | + */ |
|
| 362 | + public function load_scripts_styles_view_transaction() |
|
| 363 | + { |
|
| 364 | + //styles |
|
| 365 | + wp_enqueue_style('espresso-ui-theme'); |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + |
|
| 369 | + /** |
|
| 370 | + * load_scripts_styles_default |
|
| 371 | + * |
|
| 372 | + * @access public |
|
| 373 | + * @return void |
|
| 374 | + */ |
|
| 375 | + public function load_scripts_styles_default() |
|
| 376 | + { |
|
| 377 | + //styles |
|
| 378 | + wp_enqueue_style('espresso-ui-theme'); |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + |
|
| 382 | + /** |
|
| 383 | + * _set_list_table_views_default |
|
| 384 | + * |
|
| 385 | + * @access protected |
|
| 386 | + * @return void |
|
| 387 | + */ |
|
| 388 | + protected function _set_list_table_views_default() |
|
| 389 | + { |
|
| 390 | + $this->_views = array( |
|
| 391 | + 'all' => array( |
|
| 392 | + 'slug' => 'all', |
|
| 393 | + 'label' => esc_html__('View All Transactions', 'event_espresso'), |
|
| 394 | + 'count' => 0, |
|
| 395 | + ), |
|
| 396 | + 'abandoned' => array( |
|
| 397 | + 'slug' => 'abandoned', |
|
| 398 | + 'label' => esc_html__('Abandoned Transactions', 'event_espresso'), |
|
| 399 | + 'count' => 0, |
|
| 400 | + ), |
|
| 401 | + 'failed' => array( |
|
| 402 | + 'slug' => 'failed', |
|
| 403 | + 'label' => esc_html__('Failed Transactions', 'event_espresso'), |
|
| 404 | + 'count' => 0, |
|
| 405 | + ), |
|
| 406 | + ); |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + |
|
| 410 | + /** |
|
| 411 | + * _set_transaction_object |
|
| 412 | + * This sets the _transaction property for the transaction details screen |
|
| 413 | + * |
|
| 414 | + * @access private |
|
| 415 | + * @return void |
|
| 416 | + */ |
|
| 417 | + private function _set_transaction_object() |
|
| 418 | + { |
|
| 419 | + if (is_object($this->_transaction)) { |
|
| 420 | + return; |
|
| 421 | + } //get out we've already set the object |
|
| 422 | + |
|
| 423 | + $TXN = EEM_Transaction::instance(); |
|
| 424 | + |
|
| 425 | + $TXN_ID = (! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : false; |
|
| 426 | + |
|
| 427 | + //get transaction object |
|
| 428 | + $this->_transaction = $TXN->get_one_by_ID($TXN_ID); |
|
| 429 | + $this->_session = ! empty($this->_transaction) ? $this->_transaction->get('TXN_session_data') : null; |
|
| 430 | + $this->_transaction->verify_abandoned_transaction_status(); |
|
| 431 | + |
|
| 432 | + if (empty($this->_transaction)) { |
|
| 433 | + $error_msg = esc_html__('An error occurred and the details for Transaction ID #', |
|
| 434 | + 'event_espresso') . $TXN_ID . esc_html__(' could not be retrieved.', 'event_espresso'); |
|
| 435 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 436 | + } |
|
| 437 | + } |
|
| 438 | + |
|
| 439 | + |
|
| 440 | + /** |
|
| 441 | + * _transaction_legend_items |
|
| 442 | + * |
|
| 443 | + * @access protected |
|
| 444 | + * @return array |
|
| 445 | + */ |
|
| 446 | + protected function _transaction_legend_items() |
|
| 447 | + { |
|
| 448 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 449 | + $items = array(); |
|
| 450 | + |
|
| 451 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
| 452 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
| 453 | + if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
| 454 | + $items['view_related_messages'] = array( |
|
| 455 | + 'class' => $related_for_icon['css_class'], |
|
| 456 | + 'desc' => $related_for_icon['label'], |
|
| 457 | + ); |
|
| 458 | + } |
|
| 459 | + } |
|
| 460 | + |
|
| 461 | + $items = apply_filters( |
|
| 462 | + 'FHEE__Transactions_Admin_Page___transaction_legend_items__items', |
|
| 463 | + array_merge($items, |
|
| 464 | + array( |
|
| 465 | + 'view_details' => array( |
|
| 466 | + 'class' => 'dashicons dashicons-cart', |
|
| 467 | + 'desc' => esc_html__('View Transaction Details', 'event_espresso'), |
|
| 468 | + ), |
|
| 469 | + 'view_invoice' => array( |
|
| 470 | + 'class' => 'dashicons dashicons-media-spreadsheet', |
|
| 471 | + 'desc' => esc_html__('View Transaction Invoice', 'event_espresso'), |
|
| 472 | + ), |
|
| 473 | + 'view_receipt' => array( |
|
| 474 | + 'class' => 'dashicons dashicons-media-default', |
|
| 475 | + 'desc' => esc_html__('View Transaction Receipt', 'event_espresso'), |
|
| 476 | + ), |
|
| 477 | + 'view_registration' => array( |
|
| 478 | + 'class' => 'dashicons dashicons-clipboard', |
|
| 479 | + 'desc' => esc_html__('View Registration Details', 'event_espresso'), |
|
| 480 | + ), |
|
| 481 | + 'payment_overview_link' => array( |
|
| 482 | + 'class' => 'dashicons dashicons-money', |
|
| 483 | + 'desc' => esc_html__('Make Payment on Frontend', 'event_espresso'), |
|
| 484 | + ), |
|
| 485 | + ) |
|
| 486 | + ) |
|
| 487 | + ); |
|
| 488 | + |
|
| 489 | + if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
| 490 | + 'espresso_transactions_send_payment_reminder') |
|
| 491 | + ) { |
|
| 492 | + if (EEH_MSG_Template::is_mt_active('payment_reminder')) { |
|
| 493 | + $items['send_payment_reminder'] = array( |
|
| 494 | + 'class' => 'dashicons dashicons-email-alt', |
|
| 495 | + 'desc' => esc_html__('Send Payment Reminder', 'event_espresso'), |
|
| 496 | + ); |
|
| 497 | + } else { |
|
| 498 | + $items['blank*'] = array( |
|
| 499 | + 'class' => '', |
|
| 500 | + 'desc' => '', |
|
| 501 | + ); |
|
| 502 | + } |
|
| 503 | + } else { |
|
| 504 | + $items['blank*'] = array( |
|
| 505 | + 'class' => '', |
|
| 506 | + 'desc' => '', |
|
| 507 | + ); |
|
| 508 | + } |
|
| 509 | + $more_items = apply_filters( |
|
| 510 | + 'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items', |
|
| 511 | + array( |
|
| 512 | + 'overpaid' => array( |
|
| 513 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code, |
|
| 514 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::overpaid_status_code, false, 'sentence'), |
|
| 515 | + ), |
|
| 516 | + 'complete' => array( |
|
| 517 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code, |
|
| 518 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::complete_status_code, false, 'sentence'), |
|
| 519 | + ), |
|
| 520 | + 'incomplete' => array( |
|
| 521 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code, |
|
| 522 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::incomplete_status_code, false, 'sentence'), |
|
| 523 | + ), |
|
| 524 | + 'abandoned' => array( |
|
| 525 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code, |
|
| 526 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::abandoned_status_code, false, 'sentence'), |
|
| 527 | + ), |
|
| 528 | + 'failed' => array( |
|
| 529 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code, |
|
| 530 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::failed_status_code, false, 'sentence'), |
|
| 531 | + ), |
|
| 532 | + ) |
|
| 533 | + ); |
|
| 534 | + |
|
| 535 | + return array_merge($items, $more_items); |
|
| 536 | + } |
|
| 537 | + |
|
| 538 | + |
|
| 539 | + /** |
|
| 540 | + * _transactions_overview_list_table |
|
| 541 | + * |
|
| 542 | + * @access protected |
|
| 543 | + * @return void |
|
| 544 | + */ |
|
| 545 | + protected function _transactions_overview_list_table() |
|
| 546 | + { |
|
| 547 | + $this->_admin_page_title = esc_html__('Transactions', 'event_espresso'); |
|
| 548 | + $event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']) : null; |
|
| 549 | + $this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf(esc_html__('%sViewing Transactions for the Event: %s%s', |
|
| 550 | + 'event_espresso'), '<h3>', |
|
| 551 | + '<a href="' . EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), |
|
| 552 | + EVENTS_ADMIN_URL) . '" title="' . esc_attr__('Click to Edit event', |
|
| 553 | + 'event_espresso') . '">' . $event->get('EVT_name') . '</a>', '</h3>') : ''; |
|
| 554 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items()); |
|
| 555 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 556 | + } |
|
| 557 | + |
|
| 558 | + |
|
| 559 | + /** |
|
| 560 | + * _transaction_details |
|
| 561 | + * generates HTML for the View Transaction Details Admin page |
|
| 562 | + * |
|
| 563 | + * @access protected |
|
| 564 | + * @return void |
|
| 565 | + */ |
|
| 566 | + protected function _transaction_details() |
|
| 567 | + { |
|
| 568 | + do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction); |
|
| 569 | + |
|
| 570 | + $this->_set_transaction_status_array(); |
|
| 571 | + |
|
| 572 | + $this->_template_args = array(); |
|
| 573 | + $this->_template_args['transactions_page'] = $this->_wp_page_slug; |
|
| 574 | + |
|
| 575 | + $this->_set_transaction_object(); |
|
| 576 | + |
|
| 577 | + $primary_registration = $this->_transaction->primary_registration(); |
|
| 578 | + $attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : null; |
|
| 579 | + |
|
| 580 | + $this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID(); |
|
| 581 | + $this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso'); |
|
| 582 | + |
|
| 583 | + $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp'); |
|
| 584 | + $this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso'); |
|
| 585 | + |
|
| 586 | + $this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')]; |
|
| 587 | + $this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso'); |
|
| 588 | + $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID'); |
|
| 589 | + |
|
| 590 | + $this->_template_args['grand_total'] = $this->_transaction->get('TXN_total'); |
|
| 591 | + $this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid'); |
|
| 592 | + |
|
| 593 | + if ( |
|
| 594 | + $attendee instanceof EE_Attendee |
|
| 595 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 596 | + 'ee_send_message', |
|
| 597 | + 'espresso_transactions_send_payment_reminder' |
|
| 598 | + ) |
|
| 599 | + ) { |
|
| 600 | + $this->_template_args['send_payment_reminder_button'] = |
|
| 601 | + EEH_MSG_Template::is_mt_active('payment_reminder') |
|
| 602 | + && $this->_transaction->get('STS_ID') != EEM_Transaction::complete_status_code |
|
| 603 | + && $this->_transaction->get('STS_ID') != EEM_Transaction::overpaid_status_code |
|
| 604 | + ? EEH_Template::get_button_or_link( |
|
| 605 | + EE_Admin_Page::add_query_args_and_nonce( |
|
| 606 | + array( |
|
| 607 | + 'action' => 'send_payment_reminder', |
|
| 608 | + 'TXN_ID' => $this->_transaction->ID(), |
|
| 609 | + 'redirect_to' => 'view_transaction', |
|
| 610 | + ), |
|
| 611 | + TXN_ADMIN_URL |
|
| 612 | + ), |
|
| 613 | + __(' Send Payment Reminder', 'event_espresso'), |
|
| 614 | + 'button secondary-button right', |
|
| 615 | + 'dashicons dashicons-email-alt' |
|
| 616 | + ) |
|
| 617 | + : ''; |
|
| 618 | + } else { |
|
| 619 | + $this->_template_args['send_payment_reminder_button'] = ''; |
|
| 620 | + } |
|
| 621 | + |
|
| 622 | + $amount_due = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid'); |
|
| 623 | + $this->_template_args['amount_due'] = EEH_Template::format_currency($amount_due, true); |
|
| 624 | + if (EE_Registry::instance()->CFG->currency->sign_b4) { |
|
| 625 | + $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign . $this->_template_args['amount_due']; |
|
| 626 | + } else { |
|
| 627 | + $this->_template_args['amount_due'] = $this->_template_args['amount_due'] . EE_Registry::instance()->CFG->currency->sign; |
|
| 628 | + } |
|
| 629 | + $this->_template_args['amount_due_class'] = ''; |
|
| 630 | + |
|
| 631 | + if ($this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total')) { |
|
| 632 | + // paid in full |
|
| 633 | + $this->_template_args['amount_due'] = false; |
|
| 634 | + } elseif ($this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total')) { |
|
| 635 | + // overpaid |
|
| 636 | + $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
| 637 | + } elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') > 0)) { |
|
| 638 | + // monies owing |
|
| 639 | + $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn'; |
|
| 640 | + } elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') == 0)) { |
|
| 641 | + // no payments made yet |
|
| 642 | + $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
| 643 | + } elseif ($this->_transaction->get('TXN_total') == 0) { |
|
| 644 | + // free event |
|
| 645 | + $this->_template_args['amount_due'] = false; |
|
| 646 | + } |
|
| 647 | + |
|
| 648 | + $payment_method = $this->_transaction->payment_method(); |
|
| 649 | + |
|
| 650 | + $this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method |
|
| 651 | + ? $payment_method->admin_name() |
|
| 652 | + : esc_html__('Unknown', 'event_espresso'); |
|
| 653 | + |
|
| 654 | + $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
| 655 | + // link back to overview |
|
| 656 | + $this->_template_args['txn_overview_url'] = ! empty ($_SERVER['HTTP_REFERER']) |
|
| 657 | + ? $_SERVER['HTTP_REFERER'] |
|
| 658 | + : TXN_ADMIN_URL; |
|
| 659 | + |
|
| 660 | + |
|
| 661 | + // next link |
|
| 662 | + $next_txn = $this->_transaction->next( |
|
| 663 | + null, |
|
| 664 | + array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), |
|
| 665 | + 'TXN_ID' |
|
| 666 | + ); |
|
| 667 | + $this->_template_args['next_transaction'] = $next_txn |
|
| 668 | + ? $this->_next_link( |
|
| 669 | + EE_Admin_Page::add_query_args_and_nonce( |
|
| 670 | + array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']), |
|
| 671 | + TXN_ADMIN_URL |
|
| 672 | + ), |
|
| 673 | + 'dashicons dashicons-arrow-right ee-icon-size-22' |
|
| 674 | + ) |
|
| 675 | + : ''; |
|
| 676 | + // previous link |
|
| 677 | + $previous_txn = $this->_transaction->previous( |
|
| 678 | + null, |
|
| 679 | + array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), |
|
| 680 | + 'TXN_ID' |
|
| 681 | + ); |
|
| 682 | + $this->_template_args['previous_transaction'] = $previous_txn |
|
| 683 | + ? $this->_previous_link( |
|
| 684 | + EE_Admin_Page::add_query_args_and_nonce( |
|
| 685 | + array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']), |
|
| 686 | + TXN_ADMIN_URL |
|
| 687 | + ), |
|
| 688 | + 'dashicons dashicons-arrow-left ee-icon-size-22' |
|
| 689 | + ) |
|
| 690 | + : ''; |
|
| 691 | + |
|
| 692 | + // were we just redirected here after adding a new registration ??? |
|
| 693 | + if ( |
|
| 694 | + isset( |
|
| 695 | + $this->_req_data['redirect_from'], |
|
| 696 | + $this->_req_data['EVT_ID'], |
|
| 697 | + $this->_req_data['event_name'] |
|
| 698 | + ) |
|
| 699 | + ) { |
|
| 700 | + if ( |
|
| 701 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 702 | + 'ee_edit_registrations', |
|
| 703 | + 'espresso_registrations_new_registration', |
|
| 704 | + $this->_req_data['EVT_ID'] |
|
| 705 | + ) |
|
| 706 | + ) { |
|
| 707 | + $this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="'; |
|
| 708 | + $this->_admin_page_title .= EE_Admin_Page::add_query_args_and_nonce( |
|
| 709 | + array( |
|
| 710 | + 'page' => 'espresso_registrations', |
|
| 711 | + 'action' => 'new_registration', |
|
| 712 | + 'return' => 'default', |
|
| 713 | + 'TXN_ID' => $this->_transaction->ID(), |
|
| 714 | + 'event_id' => $this->_req_data['EVT_ID'], |
|
| 715 | + ), |
|
| 716 | + REG_ADMIN_URL |
|
| 717 | + ); |
|
| 718 | + $this->_admin_page_title .= '">'; |
|
| 719 | + |
|
| 720 | + $this->_admin_page_title .= sprintf( |
|
| 721 | + esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'), |
|
| 722 | + htmlentities(urldecode($this->_req_data['event_name']), ENT_QUOTES, 'UTF-8') |
|
| 723 | + ); |
|
| 724 | + $this->_admin_page_title .= '</a>'; |
|
| 725 | + } |
|
| 726 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 727 | + } |
|
| 728 | + // grab messages at the last second |
|
| 729 | + $this->_template_args['notices'] = EE_Error::get_notices(); |
|
| 730 | + // path to template |
|
| 731 | + $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php'; |
|
| 732 | + $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, |
|
| 733 | + $this->_template_args, true); |
|
| 734 | + |
|
| 735 | + // the details template wrapper |
|
| 736 | + $this->display_admin_page_with_sidebar(); |
|
| 737 | + |
|
| 738 | + } |
|
| 739 | + |
|
| 740 | + |
|
| 741 | + /** |
|
| 742 | + * _transaction_details_metaboxes |
|
| 743 | + * |
|
| 744 | + * @access protected |
|
| 745 | + * @return void |
|
| 746 | + */ |
|
| 747 | + protected function _transaction_details_metaboxes() |
|
| 748 | + { |
|
| 749 | + |
|
| 750 | + $this->_set_transaction_object(); |
|
| 751 | + |
|
| 752 | + add_meta_box('edit-txn-details-mbox', esc_html__('Transaction Details', 'event_espresso'), |
|
| 753 | + array($this, 'txn_details_meta_box'), $this->_wp_page_slug, 'normal', 'high'); |
|
| 754 | + add_meta_box( |
|
| 755 | + 'edit-txn-attendees-mbox', |
|
| 756 | + esc_html__('Attendees Registered in this Transaction', 'event_espresso'), |
|
| 757 | + array($this, 'txn_attendees_meta_box'), |
|
| 758 | + $this->_wp_page_slug, |
|
| 759 | + 'normal', |
|
| 760 | + 'high', |
|
| 761 | + array('TXN_ID' => $this->_transaction->ID()) |
|
| 762 | + ); |
|
| 763 | + add_meta_box('edit-txn-registrant-mbox', esc_html__('Primary Contact', 'event_espresso'), |
|
| 764 | + array($this, 'txn_registrant_side_meta_box'), $this->_wp_page_slug, 'side', 'high'); |
|
| 765 | + add_meta_box('edit-txn-billing-info-mbox', esc_html__('Billing Information', 'event_espresso'), |
|
| 766 | + array($this, 'txn_billing_info_side_meta_box'), $this->_wp_page_slug, 'side', 'high'); |
|
| 767 | + |
|
| 768 | + } |
|
| 769 | + |
|
| 770 | + |
|
| 771 | + /** |
|
| 772 | + * txn_details_meta_box |
|
| 773 | + * generates HTML for the Transaction main meta box |
|
| 774 | + * |
|
| 775 | + * @access public |
|
| 776 | + * @return void |
|
| 777 | + */ |
|
| 778 | + public function txn_details_meta_box() |
|
| 779 | + { |
|
| 780 | + |
|
| 781 | + $this->_set_transaction_object(); |
|
| 782 | + $this->_template_args['TXN_ID'] = $this->_transaction->ID(); |
|
| 783 | + $this->_template_args['attendee'] = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->attendee() : null; |
|
| 784 | + |
|
| 785 | + //get line table |
|
| 786 | + EEH_Autoloader::register_line_item_display_autoloaders(); |
|
| 787 | + $Line_Item_Display = new EE_Line_Item_Display('admin_table', |
|
| 788 | + 'EE_Admin_Table_Line_Item_Display_Strategy'); |
|
| 789 | + $this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item($this->_transaction->total_line_item()); |
|
| 790 | + $this->_template_args['REG_code'] = $this->_transaction->get_first_related('Registration')->get('REG_code'); |
|
| 791 | + |
|
| 792 | + // process taxes |
|
| 793 | + $taxes = $this->_transaction->get_many_related('Line_Item', |
|
| 794 | + array(array('LIN_type' => EEM_Line_Item::type_tax))); |
|
| 795 | + $this->_template_args['taxes'] = ! empty($taxes) ? $taxes : false; |
|
| 796 | + |
|
| 797 | + $this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), |
|
| 798 | + false, false); |
|
| 799 | + $this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total'); |
|
| 800 | + $this->_template_args['TXN_status'] = $this->_transaction->get('STS_ID'); |
|
| 801 | 801 | |
| 802 | 802 | // $txn_status_class = 'status-' . $this->_transaction->get('STS_ID'); |
| 803 | 803 | |
| 804 | - // process payment details |
|
| 805 | - $payments = $this->_transaction->get_many_related('Payment'); |
|
| 806 | - if (! empty($payments)) { |
|
| 807 | - $this->_template_args['payments'] = $payments; |
|
| 808 | - $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments); |
|
| 809 | - } else { |
|
| 810 | - $this->_template_args['payments'] = false; |
|
| 811 | - $this->_template_args['existing_reg_payments'] = array(); |
|
| 812 | - } |
|
| 813 | - |
|
| 814 | - $this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL); |
|
| 815 | - $this->_template_args['delete_payment_url'] = add_query_arg(array('action' => 'espresso_delete_payment'), |
|
| 816 | - TXN_ADMIN_URL); |
|
| 817 | - |
|
| 818 | - if (isset($txn_details['invoice_number'])) { |
|
| 819 | - $this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code']; |
|
| 820 | - $this->_template_args['txn_details']['invoice_number']['label'] = esc_html__('Invoice Number', |
|
| 821 | - 'event_espresso'); |
|
| 822 | - } |
|
| 823 | - |
|
| 824 | - $this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction->get_first_related('Registration')->get('REG_session'); |
|
| 825 | - $this->_template_args['txn_details']['registration_session']['label'] = esc_html__('Registration Session', |
|
| 826 | - 'event_espresso'); |
|
| 827 | - |
|
| 828 | - $this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address']) ? $this->_session['ip_address'] : ''; |
|
| 829 | - $this->_template_args['txn_details']['ip_address']['label'] = esc_html__('Transaction placed from IP', |
|
| 830 | - 'event_espresso'); |
|
| 831 | - |
|
| 832 | - $this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent']) ? $this->_session['user_agent'] : ''; |
|
| 833 | - $this->_template_args['txn_details']['user_agent']['label'] = esc_html__('Registrant User Agent', |
|
| 834 | - 'event_espresso'); |
|
| 835 | - |
|
| 836 | - $reg_steps = '<ul>'; |
|
| 837 | - foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) { |
|
| 838 | - if ($reg_step_status === true) { |
|
| 839 | - $reg_steps .= '<li style="color:#70cc50">' . sprintf(esc_html__('%1$s : Completed', 'event_espresso'), |
|
| 840 | - ucwords(str_replace('_', ' ', $reg_step))) . '</li>'; |
|
| 841 | - } else if (is_numeric($reg_step_status) && $reg_step_status !== false) { |
|
| 842 | - $reg_steps .= '<li style="color:#2EA2CC">' . sprintf( |
|
| 843 | - esc_html__('%1$s : Initiated %2$s', 'event_espresso'), |
|
| 844 | - ucwords(str_replace('_', ' ', $reg_step)), |
|
| 845 | - date(get_option('date_format') . ' ' . get_option('time_format'), |
|
| 846 | - ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS))) |
|
| 847 | - ) . '</li>'; |
|
| 848 | - } else { |
|
| 849 | - $reg_steps .= '<li style="color:#E76700">' . sprintf(esc_html__('%1$s : Never Initiated', |
|
| 850 | - 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))) . '</li>'; |
|
| 851 | - } |
|
| 852 | - } |
|
| 853 | - $reg_steps .= '</ul>'; |
|
| 854 | - $this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps; |
|
| 855 | - $this->_template_args['txn_details']['reg_steps']['label'] = esc_html__('Registration Step Progress', |
|
| 856 | - 'event_espresso'); |
|
| 857 | - |
|
| 858 | - |
|
| 859 | - $this->_get_registrations_to_apply_payment_to(); |
|
| 860 | - $this->_get_payment_methods($payments); |
|
| 861 | - $this->_get_payment_status_array(); |
|
| 862 | - $this->_get_reg_status_selection(); //sets up the template args for the reg status array for the transaction. |
|
| 863 | - |
|
| 864 | - $this->_template_args['transaction_form_url'] = add_query_arg(array( |
|
| 865 | - 'action' => 'edit_transaction', |
|
| 866 | - 'process' => 'transaction', |
|
| 867 | - ), TXN_ADMIN_URL); |
|
| 868 | - $this->_template_args['apply_payment_form_url'] = add_query_arg(array( |
|
| 869 | - 'page' => 'espresso_transactions', |
|
| 870 | - 'action' => 'espresso_apply_payment', |
|
| 871 | - ), WP_AJAX_URL); |
|
| 872 | - $this->_template_args['delete_payment_form_url'] = add_query_arg(array( |
|
| 873 | - 'page' => 'espresso_transactions', |
|
| 874 | - 'action' => 'espresso_delete_payment', |
|
| 875 | - ), WP_AJAX_URL); |
|
| 876 | - |
|
| 877 | - // 'espresso_delete_payment_nonce' |
|
| 878 | - |
|
| 879 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php'; |
|
| 880 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 881 | - |
|
| 882 | - } |
|
| 883 | - |
|
| 884 | - |
|
| 885 | - /** |
|
| 886 | - * _get_registration_payment_IDs |
|
| 887 | - * generates an array of Payment IDs and their corresponding Registration IDs |
|
| 888 | - * |
|
| 889 | - * @access protected |
|
| 890 | - * @param EE_Payment[] $payments |
|
| 891 | - * @return array |
|
| 892 | - */ |
|
| 893 | - protected function _get_registration_payment_IDs($payments = array()) |
|
| 894 | - { |
|
| 895 | - $existing_reg_payments = array(); |
|
| 896 | - // get all reg payments for these payments |
|
| 897 | - $reg_payments = EEM_Registration_Payment::instance()->get_all(array( |
|
| 898 | - array( |
|
| 899 | - 'PAY_ID' => array( |
|
| 900 | - 'IN', |
|
| 901 | - array_keys($payments), |
|
| 902 | - ), |
|
| 903 | - ), |
|
| 904 | - )); |
|
| 905 | - if (! empty($reg_payments)) { |
|
| 906 | - foreach ($payments as $payment) { |
|
| 907 | - if (! $payment instanceof EE_Payment) { |
|
| 908 | - continue; |
|
| 909 | - } else if (! isset($existing_reg_payments[$payment->ID()])) { |
|
| 910 | - $existing_reg_payments[$payment->ID()] = array(); |
|
| 911 | - } |
|
| 912 | - foreach ($reg_payments as $reg_payment) { |
|
| 913 | - if ($reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID()) { |
|
| 914 | - $existing_reg_payments[$payment->ID()][] = $reg_payment->registration_ID(); |
|
| 915 | - } |
|
| 916 | - } |
|
| 917 | - } |
|
| 918 | - } |
|
| 919 | - |
|
| 920 | - return $existing_reg_payments; |
|
| 921 | - } |
|
| 922 | - |
|
| 923 | - |
|
| 924 | - /** |
|
| 925 | - * _get_registrations_to_apply_payment_to |
|
| 926 | - * generates HTML for displaying a series of checkboxes in the admin payment modal window |
|
| 927 | - * which allows the admin to only apply the payment to the specific registrations |
|
| 928 | - * |
|
| 929 | - * @access protected |
|
| 930 | - * @return void |
|
| 931 | - * @throws \EE_Error |
|
| 932 | - */ |
|
| 933 | - protected function _get_registrations_to_apply_payment_to() |
|
| 934 | - { |
|
| 935 | - // we want any registration with an active status (ie: not deleted or cancelled) |
|
| 936 | - $query_params = array( |
|
| 937 | - array( |
|
| 938 | - 'STS_ID' => array( |
|
| 939 | - 'IN', |
|
| 940 | - array( |
|
| 941 | - EEM_Registration::status_id_approved, |
|
| 942 | - EEM_Registration::status_id_pending_payment, |
|
| 943 | - EEM_Registration::status_id_not_approved, |
|
| 944 | - ), |
|
| 945 | - ), |
|
| 946 | - ), |
|
| 947 | - ); |
|
| 948 | - $registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div( |
|
| 949 | - '', 'txn-admin-apply-payment-to-registrations-dv', '', 'clear: both; margin: 1.5em 0 0; display: none;' |
|
| 950 | - ); |
|
| 951 | - $registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap'); |
|
| 952 | - $registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl'); |
|
| 953 | - $registrations_to_apply_payment_to .= EEH_HTML::thead( |
|
| 954 | - EEH_HTML::tr( |
|
| 955 | - EEH_HTML::th(esc_html__('ID', 'event_espresso')) . |
|
| 956 | - EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) . |
|
| 957 | - EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) . |
|
| 958 | - EEH_HTML::th(esc_html__('Event', 'event_espresso')) . |
|
| 959 | - EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') . |
|
| 960 | - EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') . |
|
| 961 | - EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr') |
|
| 962 | - ) |
|
| 963 | - ); |
|
| 964 | - $registrations_to_apply_payment_to .= EEH_HTML::tbody(); |
|
| 965 | - // get registrations for TXN |
|
| 966 | - $registrations = $this->_transaction->registrations($query_params); |
|
| 967 | - foreach ($registrations as $registration) { |
|
| 968 | - if ($registration instanceof EE_Registration) { |
|
| 969 | - $attendee_name = $registration->attendee() instanceof EE_Attendee |
|
| 970 | - ? $registration->attendee()->full_name() |
|
| 971 | - : esc_html__('Unknown Attendee', 'event_espresso'); |
|
| 972 | - $owing = $registration->final_price() - $registration->paid(); |
|
| 973 | - $taxable = $registration->ticket()->taxable() |
|
| 974 | - ? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>' |
|
| 975 | - : ''; |
|
| 976 | - $checked = empty($existing_reg_payments) || in_array($registration->ID(), |
|
| 977 | - $existing_reg_payments) |
|
| 978 | - ? ' checked="checked"' |
|
| 979 | - : ''; |
|
| 980 | - $disabled = $registration->final_price() > 0 ? '' : ' disabled'; |
|
| 981 | - $registrations_to_apply_payment_to .= EEH_HTML::tr( |
|
| 982 | - EEH_HTML::td($registration->ID()) . |
|
| 983 | - EEH_HTML::td($attendee_name) . |
|
| 984 | - EEH_HTML::td( |
|
| 985 | - $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable |
|
| 986 | - ) . |
|
| 987 | - EEH_HTML::td($registration->event_name()) . |
|
| 988 | - EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') . |
|
| 989 | - EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr') . |
|
| 990 | - EEH_HTML::td( |
|
| 991 | - '<input type="checkbox" value="' . $registration->ID() |
|
| 992 | - . '" name="txn_admin_payment[registrations]"' |
|
| 993 | - . $checked . $disabled . '>', |
|
| 994 | - '', 'jst-cntr' |
|
| 995 | - ), |
|
| 996 | - 'apply-payment-registration-row-' . $registration->ID() |
|
| 997 | - ); |
|
| 998 | - } |
|
| 999 | - } |
|
| 1000 | - $registrations_to_apply_payment_to .= EEH_HTML::tbodyx(); |
|
| 1001 | - $registrations_to_apply_payment_to .= EEH_HTML::tablex(); |
|
| 1002 | - $registrations_to_apply_payment_to .= EEH_HTML::divx(); |
|
| 1003 | - $registrations_to_apply_payment_to .= EEH_HTML::p( |
|
| 1004 | - esc_html__( |
|
| 1005 | - 'The payment will only be applied to the registrations that have a check mark in their corresponding check box. Checkboxes for free registrations have been disabled.', |
|
| 1006 | - 'event_espresso' |
|
| 1007 | - ), |
|
| 1008 | - '', 'clear description' |
|
| 1009 | - ); |
|
| 1010 | - $registrations_to_apply_payment_to .= EEH_HTML::divx(); |
|
| 1011 | - $this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to; |
|
| 1012 | - } |
|
| 1013 | - |
|
| 1014 | - |
|
| 1015 | - /** |
|
| 1016 | - * _get_reg_status_selection |
|
| 1017 | - * |
|
| 1018 | - * @todo this will need to be adjusted either once MER comes along OR we move default reg status to tickets |
|
| 1019 | - * instead of events. |
|
| 1020 | - * @access protected |
|
| 1021 | - * @return void |
|
| 1022 | - */ |
|
| 1023 | - protected function _get_reg_status_selection() |
|
| 1024 | - { |
|
| 1025 | - //first get all possible statuses |
|
| 1026 | - $statuses = EEM_Registration::reg_status_array(array(), true); |
|
| 1027 | - //let's add a "don't change" option. |
|
| 1028 | - $status_array['NAN'] = esc_html__('Leave the Same', 'event_espresso'); |
|
| 1029 | - $status_array = array_merge($status_array, $statuses); |
|
| 1030 | - $this->_template_args['status_change_select'] = EEH_Form_Fields::select_input('txn_reg_status_change[reg_status]', |
|
| 1031 | - $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status'); |
|
| 1032 | - $this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input('delete_txn_reg_status_change[reg_status]', |
|
| 1033 | - $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status'); |
|
| 1034 | - |
|
| 1035 | - } |
|
| 1036 | - |
|
| 1037 | - |
|
| 1038 | - /** |
|
| 1039 | - * _get_payment_methods |
|
| 1040 | - * Gets all the payment methods available generally, or the ones that are already |
|
| 1041 | - * selected on these payments (in case their payment methods are no longer active). |
|
| 1042 | - * Has the side-effect of updating the template args' payment_methods item |
|
| 1043 | - * |
|
| 1044 | - * @access private |
|
| 1045 | - * @param EE_Payment[] to show on this page |
|
| 1046 | - * @return void |
|
| 1047 | - */ |
|
| 1048 | - private function _get_payment_methods($payments = array()) |
|
| 1049 | - { |
|
| 1050 | - $payment_methods_of_payments = array(); |
|
| 1051 | - foreach ($payments as $payment) { |
|
| 1052 | - if ($payment instanceof EE_Payment) { |
|
| 1053 | - $payment_methods_of_payments[] = $payment->get('PMD_ID'); |
|
| 1054 | - } |
|
| 1055 | - } |
|
| 1056 | - if ($payment_methods_of_payments) { |
|
| 1057 | - $query_args = array( |
|
| 1058 | - array( |
|
| 1059 | - 'OR*payment_method_for_payment' => array( |
|
| 1060 | - 'PMD_ID' => array('IN', $payment_methods_of_payments), |
|
| 1061 | - 'PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%'), |
|
| 1062 | - ), |
|
| 1063 | - ), |
|
| 1064 | - ); |
|
| 1065 | - } else { |
|
| 1066 | - $query_args = array(array('PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%'))); |
|
| 1067 | - } |
|
| 1068 | - $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args); |
|
| 1069 | - } |
|
| 1070 | - |
|
| 1071 | - |
|
| 1072 | - /** |
|
| 1073 | - * txn_attendees_meta_box |
|
| 1074 | - * generates HTML for the Attendees Transaction main meta box |
|
| 1075 | - * |
|
| 1076 | - * @access public |
|
| 1077 | - * @param WP_Post $post |
|
| 1078 | - * @param array $metabox |
|
| 1079 | - * @return void |
|
| 1080 | - */ |
|
| 1081 | - public function txn_attendees_meta_box($post, $metabox = array('args' => array())) |
|
| 1082 | - { |
|
| 1083 | - |
|
| 1084 | - extract($metabox['args']); |
|
| 1085 | - $this->_template_args['post'] = $post; |
|
| 1086 | - $this->_template_args['event_attendees'] = array(); |
|
| 1087 | - // process items in cart |
|
| 1088 | - $line_items = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item'))); |
|
| 1089 | - if (! empty($line_items)) { |
|
| 1090 | - foreach ($line_items as $item) { |
|
| 1091 | - if ($item instanceof EE_Line_Item) { |
|
| 1092 | - switch ($item->OBJ_type()) { |
|
| 1093 | - |
|
| 1094 | - case 'Event' : |
|
| 1095 | - break; |
|
| 1096 | - |
|
| 1097 | - case 'Ticket' : |
|
| 1098 | - $ticket = $item->ticket(); |
|
| 1099 | - //right now we're only handling tickets here. Cause its expected that only tickets will have attendees right? |
|
| 1100 | - if (! $ticket instanceof EE_Ticket) { |
|
| 1101 | - continue; |
|
| 1102 | - } |
|
| 1103 | - try { |
|
| 1104 | - $event_name = $ticket->get_event_name(); |
|
| 1105 | - } catch (Exception $e) { |
|
| 1106 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 1107 | - $event_name = esc_html__('Unknown Event', 'event_espresso'); |
|
| 1108 | - } |
|
| 1109 | - $event_name .= ' - ' . $item->get('LIN_name'); |
|
| 1110 | - $ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price')); |
|
| 1111 | - // now get all of the registrations for this transaction that use this ticket |
|
| 1112 | - $registrations = $ticket->get_many_related('Registration', |
|
| 1113 | - array(array('TXN_ID' => $this->_transaction->ID()))); |
|
| 1114 | - foreach ($registrations as $registration) { |
|
| 1115 | - if (! $registration instanceof EE_Registration) { |
|
| 1116 | - continue; |
|
| 1117 | - } |
|
| 1118 | - $this->_template_args['event_attendees'][$registration->ID()]['STS_ID'] = $registration->status_ID(); |
|
| 1119 | - $this->_template_args['event_attendees'][$registration->ID()]['att_num'] = $registration->count(); |
|
| 1120 | - $this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] = $event_name; |
|
| 1121 | - $this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] = $ticket_price; |
|
| 1122 | - // attendee info |
|
| 1123 | - $attendee = $registration->get_first_related('Attendee'); |
|
| 1124 | - if ($attendee instanceof EE_Attendee) { |
|
| 1125 | - $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = $attendee->ID(); |
|
| 1126 | - $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = $attendee->full_name(); |
|
| 1127 | - $this->_template_args['event_attendees'][$registration->ID()]['email'] = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name . esc_html__(' Event', |
|
| 1128 | - 'event_espresso') . '">' . $attendee->email() . '</a>'; |
|
| 1129 | - $this->_template_args['event_attendees'][$registration->ID()]['address'] = EEH_Address::format($attendee, |
|
| 1130 | - 'inline', false, false); |
|
| 1131 | - } else { |
|
| 1132 | - $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = ''; |
|
| 1133 | - $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = ''; |
|
| 1134 | - $this->_template_args['event_attendees'][$registration->ID()]['email'] = ''; |
|
| 1135 | - $this->_template_args['event_attendees'][$registration->ID()]['address'] = ''; |
|
| 1136 | - } |
|
| 1137 | - } |
|
| 1138 | - break; |
|
| 1139 | - |
|
| 1140 | - } |
|
| 1141 | - } |
|
| 1142 | - } |
|
| 1143 | - |
|
| 1144 | - $this->_template_args['transaction_form_url'] = add_query_arg(array( |
|
| 1145 | - 'action' => 'edit_transaction', |
|
| 1146 | - 'process' => 'attendees', |
|
| 1147 | - ), TXN_ADMIN_URL); |
|
| 1148 | - echo EEH_Template::display_template(TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php', |
|
| 1149 | - $this->_template_args, true); |
|
| 1150 | - |
|
| 1151 | - } else { |
|
| 1152 | - echo sprintf( |
|
| 1153 | - esc_html__('%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', |
|
| 1154 | - 'event_espresso'), |
|
| 1155 | - '<p class="important-notice">', |
|
| 1156 | - '</p>' |
|
| 1157 | - ); |
|
| 1158 | - } |
|
| 1159 | - } |
|
| 1160 | - |
|
| 1161 | - |
|
| 1162 | - /** |
|
| 1163 | - * txn_registrant_side_meta_box |
|
| 1164 | - * generates HTML for the Edit Transaction side meta box |
|
| 1165 | - * |
|
| 1166 | - * @access public |
|
| 1167 | - * @throws \EE_Error |
|
| 1168 | - * @return void |
|
| 1169 | - */ |
|
| 1170 | - public function txn_registrant_side_meta_box() |
|
| 1171 | - { |
|
| 1172 | - $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->get_first_related('Attendee') : null; |
|
| 1173 | - if (! $primary_att instanceof EE_Attendee) { |
|
| 1174 | - $this->_template_args['no_attendee_message'] = esc_html__('There is no attached contact for this transaction. The transaction either failed due to an error or was abandoned.', |
|
| 1175 | - 'event_espresso'); |
|
| 1176 | - $primary_att = EEM_Attendee::instance()->create_default_object(); |
|
| 1177 | - } |
|
| 1178 | - $this->_template_args['ATT_ID'] = $primary_att->ID(); |
|
| 1179 | - $this->_template_args['prime_reg_fname'] = $primary_att->fname(); |
|
| 1180 | - $this->_template_args['prime_reg_lname'] = $primary_att->lname(); |
|
| 1181 | - $this->_template_args['prime_reg_email'] = $primary_att->email(); |
|
| 1182 | - $this->_template_args['prime_reg_phone'] = $primary_att->phone(); |
|
| 1183 | - $this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1184 | - 'action' => 'edit_attendee', |
|
| 1185 | - 'post' => $primary_att->ID(), |
|
| 1186 | - ), REG_ADMIN_URL); |
|
| 1187 | - // get formatted address for registrant |
|
| 1188 | - $this->_template_args['formatted_address'] = EEH_Address::format($primary_att); |
|
| 1189 | - echo EEH_Template::display_template(TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php', |
|
| 1190 | - $this->_template_args, true); |
|
| 1191 | - } |
|
| 1192 | - |
|
| 1193 | - |
|
| 1194 | - /** |
|
| 1195 | - * txn_billing_info_side_meta_box |
|
| 1196 | - * generates HTML for the Edit Transaction side meta box |
|
| 1197 | - * |
|
| 1198 | - * @access public |
|
| 1199 | - * @return void |
|
| 1200 | - */ |
|
| 1201 | - public function txn_billing_info_side_meta_box() |
|
| 1202 | - { |
|
| 1203 | - |
|
| 1204 | - $this->_template_args['billing_form'] = $this->_transaction->billing_info(); |
|
| 1205 | - $this->_template_args['billing_form_url'] = add_query_arg( |
|
| 1206 | - array('action' => 'edit_transaction', 'process' => 'billing'), |
|
| 1207 | - TXN_ADMIN_URL |
|
| 1208 | - ); |
|
| 1209 | - |
|
| 1210 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php'; |
|
| 1211 | - echo EEH_Template::display_template($template_path, $this->_template_args, true);/**/ |
|
| 1212 | - } |
|
| 1213 | - |
|
| 1214 | - |
|
| 1215 | - /** |
|
| 1216 | - * apply_payments_or_refunds |
|
| 1217 | - * registers a payment or refund made towards a transaction |
|
| 1218 | - * |
|
| 1219 | - * @access public |
|
| 1220 | - * @return void |
|
| 1221 | - */ |
|
| 1222 | - public function apply_payments_or_refunds() |
|
| 1223 | - { |
|
| 1224 | - $json_response_data = array('return_data' => false); |
|
| 1225 | - $valid_data = $this->_validate_payment_request_data(); |
|
| 1226 | - if (! empty($valid_data) |
|
| 1227 | - |
|
| 1228 | - ) { |
|
| 1229 | - $PAY_ID = $valid_data['PAY_ID']; |
|
| 1230 | - //save the new payment |
|
| 1231 | - $payment = $this->_create_payment_from_request_data($valid_data); |
|
| 1232 | - // get the TXN for this payment |
|
| 1233 | - $transaction = $payment->transaction(); |
|
| 1234 | - // verify transaction |
|
| 1235 | - if ($transaction instanceof EE_Transaction) { |
|
| 1236 | - // calculate_total_payments_and_update_status |
|
| 1237 | - $this->_process_transaction_payments($transaction); |
|
| 1238 | - $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment); |
|
| 1239 | - $this->_remove_existing_registration_payments($payment, $PAY_ID); |
|
| 1240 | - // apply payment to registrations (if applicable) |
|
| 1241 | - if (! empty($REG_IDs)) { |
|
| 1242 | - $this->_update_registration_payments($transaction, $payment, $REG_IDs); |
|
| 1243 | - $this->_maybe_send_notifications(); |
|
| 1244 | - // now process status changes for the same registrations |
|
| 1245 | - $this->_process_registration_status_change($transaction, $REG_IDs); |
|
| 1246 | - } |
|
| 1247 | - $this->_maybe_send_notifications($payment); |
|
| 1248 | - //prepare to render page |
|
| 1249 | - $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs); |
|
| 1250 | - do_action('AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction, |
|
| 1251 | - $payment); |
|
| 1252 | - } else { |
|
| 1253 | - EE_Error::add_error( |
|
| 1254 | - esc_html__('A valid Transaction for this payment could not be retrieved.', 'event_espresso'), |
|
| 1255 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 1256 | - ); |
|
| 1257 | - } |
|
| 1258 | - } else { |
|
| 1259 | - EE_Error::add_error(esc_html__('The payment form data could not be processed. Please try again.', |
|
| 1260 | - 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 1261 | - } |
|
| 1262 | - |
|
| 1263 | - $notices = EE_Error::get_notices(false, false, false); |
|
| 1264 | - $this->_template_args = array( |
|
| 1265 | - 'data' => $json_response_data, |
|
| 1266 | - 'error' => $notices['errors'], |
|
| 1267 | - 'success' => $notices['success'], |
|
| 1268 | - ); |
|
| 1269 | - $this->_return_json(); |
|
| 1270 | - } |
|
| 1271 | - |
|
| 1272 | - |
|
| 1273 | - /** |
|
| 1274 | - * _validate_payment_request_data |
|
| 1275 | - * |
|
| 1276 | - * @return array |
|
| 1277 | - */ |
|
| 1278 | - protected function _validate_payment_request_data() |
|
| 1279 | - { |
|
| 1280 | - if (! isset($this->_req_data['txn_admin_payment'])) { |
|
| 1281 | - return false; |
|
| 1282 | - } |
|
| 1283 | - $payment_form = $this->_generate_payment_form_section(); |
|
| 1284 | - try { |
|
| 1285 | - if ($payment_form->was_submitted()) { |
|
| 1286 | - $payment_form->receive_form_submission(); |
|
| 1287 | - if (! $payment_form->is_valid()) { |
|
| 1288 | - $submission_error_messages = array(); |
|
| 1289 | - foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) { |
|
| 1290 | - if ($validation_error instanceof EE_Validation_Error) { |
|
| 1291 | - $submission_error_messages[] = sprintf( |
|
| 1292 | - _x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'), |
|
| 1293 | - $validation_error->get_form_section()->html_label_text(), |
|
| 1294 | - $validation_error->getMessage() |
|
| 1295 | - ); |
|
| 1296 | - } |
|
| 1297 | - } |
|
| 1298 | - EE_Error::add_error(join('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
| 1299 | - |
|
| 1300 | - return array(); |
|
| 1301 | - } |
|
| 1302 | - } |
|
| 1303 | - } catch (EE_Error $e) { |
|
| 1304 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 1305 | - |
|
| 1306 | - return array(); |
|
| 1307 | - } |
|
| 1308 | - |
|
| 1309 | - return $payment_form->valid_data(); |
|
| 1310 | - } |
|
| 1311 | - |
|
| 1312 | - |
|
| 1313 | - /** |
|
| 1314 | - * _generate_payment_form_section |
|
| 1315 | - * |
|
| 1316 | - * @return EE_Form_Section_Proper |
|
| 1317 | - */ |
|
| 1318 | - protected function _generate_payment_form_section() |
|
| 1319 | - { |
|
| 1320 | - return new EE_Form_Section_Proper( |
|
| 1321 | - array( |
|
| 1322 | - 'name' => 'txn_admin_payment', |
|
| 1323 | - 'subsections' => array( |
|
| 1324 | - 'PAY_ID' => new EE_Text_Input( |
|
| 1325 | - array( |
|
| 1326 | - 'default' => 0, |
|
| 1327 | - 'required' => false, |
|
| 1328 | - 'html_label_text' => esc_html__('Payment ID', 'event_espresso'), |
|
| 1329 | - 'validation_strategies' => array(new EE_Int_Normalization()), |
|
| 1330 | - ) |
|
| 1331 | - ), |
|
| 1332 | - 'TXN_ID' => new EE_Text_Input( |
|
| 1333 | - array( |
|
| 1334 | - 'default' => 0, |
|
| 1335 | - 'required' => true, |
|
| 1336 | - 'html_label_text' => esc_html__('Transaction ID', 'event_espresso'), |
|
| 1337 | - 'validation_strategies' => array(new EE_Int_Normalization()), |
|
| 1338 | - ) |
|
| 1339 | - ), |
|
| 1340 | - 'type' => new EE_Text_Input( |
|
| 1341 | - array( |
|
| 1342 | - 'default' => 1, |
|
| 1343 | - 'required' => true, |
|
| 1344 | - 'html_label_text' => esc_html__('Payment or Refund', 'event_espresso'), |
|
| 1345 | - 'validation_strategies' => array(new EE_Int_Normalization()), |
|
| 1346 | - ) |
|
| 1347 | - ), |
|
| 1348 | - 'amount' => new EE_Text_Input( |
|
| 1349 | - array( |
|
| 1350 | - 'default' => 0, |
|
| 1351 | - 'required' => true, |
|
| 1352 | - 'html_label_text' => esc_html__('Payment amount', 'event_espresso'), |
|
| 1353 | - 'validation_strategies' => array(new EE_Float_Normalization()), |
|
| 1354 | - ) |
|
| 1355 | - ), |
|
| 1356 | - 'status' => new EE_Text_Input( |
|
| 1357 | - array( |
|
| 1358 | - 'default' => EEM_Payment::status_id_approved, |
|
| 1359 | - 'required' => true, |
|
| 1360 | - 'html_label_text' => esc_html__('Payment status', 'event_espresso'), |
|
| 1361 | - ) |
|
| 1362 | - ), |
|
| 1363 | - 'PMD_ID' => new EE_Text_Input( |
|
| 1364 | - array( |
|
| 1365 | - 'default' => 2, |
|
| 1366 | - 'required' => true, |
|
| 1367 | - 'html_label_text' => esc_html__('Payment Method', 'event_espresso'), |
|
| 1368 | - 'validation_strategies' => array(new EE_Int_Normalization()), |
|
| 1369 | - ) |
|
| 1370 | - ), |
|
| 1371 | - 'date' => new EE_Text_Input( |
|
| 1372 | - array( |
|
| 1373 | - 'default' => time(), |
|
| 1374 | - 'required' => true, |
|
| 1375 | - 'html_label_text' => esc_html__('Payment date', 'event_espresso'), |
|
| 1376 | - ) |
|
| 1377 | - ), |
|
| 1378 | - 'txn_id_chq_nmbr' => new EE_Text_Input( |
|
| 1379 | - array( |
|
| 1380 | - 'default' => '', |
|
| 1381 | - 'required' => false, |
|
| 1382 | - 'html_label_text' => esc_html__('Transaction or Cheque Number', 'event_espresso'), |
|
| 1383 | - 'validation_strategies' => array( |
|
| 1384 | - new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), |
|
| 1385 | - 100), |
|
| 1386 | - ), |
|
| 1387 | - ) |
|
| 1388 | - ), |
|
| 1389 | - 'po_number' => new EE_Text_Input( |
|
| 1390 | - array( |
|
| 1391 | - 'default' => '', |
|
| 1392 | - 'required' => false, |
|
| 1393 | - 'html_label_text' => esc_html__('Purchase Order Number', 'event_espresso'), |
|
| 1394 | - 'validation_strategies' => array( |
|
| 1395 | - new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), |
|
| 1396 | - 100), |
|
| 1397 | - ), |
|
| 1398 | - ) |
|
| 1399 | - ), |
|
| 1400 | - 'accounting' => new EE_Text_Input( |
|
| 1401 | - array( |
|
| 1402 | - 'default' => '', |
|
| 1403 | - 'required' => false, |
|
| 1404 | - 'html_label_text' => esc_html__('Extra Field for Accounting', 'event_espresso'), |
|
| 1405 | - 'validation_strategies' => array( |
|
| 1406 | - new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), |
|
| 1407 | - 100), |
|
| 1408 | - ), |
|
| 1409 | - ) |
|
| 1410 | - ), |
|
| 1411 | - ), |
|
| 1412 | - ) |
|
| 1413 | - ); |
|
| 1414 | - } |
|
| 1415 | - |
|
| 1416 | - |
|
| 1417 | - /** |
|
| 1418 | - * _create_payment_from_request_data |
|
| 1419 | - * |
|
| 1420 | - * @param array $valid_data |
|
| 1421 | - * @return EE_Payment |
|
| 1422 | - */ |
|
| 1423 | - protected function _create_payment_from_request_data($valid_data) |
|
| 1424 | - { |
|
| 1425 | - $PAY_ID = $valid_data['PAY_ID']; |
|
| 1426 | - // get payment amount |
|
| 1427 | - $amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0; |
|
| 1428 | - // payments have a type value of 1 and refunds have a type value of -1 |
|
| 1429 | - // so multiplying amount by type will give a positive value for payments, and negative values for refunds |
|
| 1430 | - $amount = $valid_data['type'] < 0 ? $amount * -1 : $amount; |
|
| 1431 | - // for some reason the date string coming in has extra spaces between the date and time. This fixes that. |
|
| 1432 | - $date = $valid_data['date'] ? preg_replace('/\s+/', ' ', $valid_data['date']) : date('Y-m-d g:i a', |
|
| 1433 | - current_time('timestamp')); |
|
| 1434 | - $payment = EE_Payment::new_instance( |
|
| 1435 | - array( |
|
| 1436 | - 'TXN_ID' => $valid_data['TXN_ID'], |
|
| 1437 | - 'STS_ID' => $valid_data['status'], |
|
| 1438 | - 'PAY_timestamp' => $date, |
|
| 1439 | - 'PAY_source' => EEM_Payment_Method::scope_admin, |
|
| 1440 | - 'PMD_ID' => $valid_data['PMD_ID'], |
|
| 1441 | - 'PAY_amount' => $amount, |
|
| 1442 | - 'PAY_txn_id_chq_nmbr' => $valid_data['txn_id_chq_nmbr'], |
|
| 1443 | - 'PAY_po_number' => $valid_data['po_number'], |
|
| 1444 | - 'PAY_extra_accntng' => $valid_data['accounting'], |
|
| 1445 | - 'PAY_details' => $valid_data, |
|
| 1446 | - 'PAY_ID' => $PAY_ID, |
|
| 1447 | - ), |
|
| 1448 | - '', |
|
| 1449 | - array('Y-m-d', 'g:i a') |
|
| 1450 | - ); |
|
| 1451 | - |
|
| 1452 | - if (! $payment->save()) { |
|
| 1453 | - EE_Error::add_error( |
|
| 1454 | - sprintf( |
|
| 1455 | - esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'), |
|
| 1456 | - $payment->ID() |
|
| 1457 | - ), |
|
| 1458 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 1459 | - ); |
|
| 1460 | - } |
|
| 1461 | - |
|
| 1462 | - return $payment; |
|
| 1463 | - } |
|
| 1464 | - |
|
| 1465 | - |
|
| 1466 | - /** |
|
| 1467 | - * _process_transaction_payments |
|
| 1468 | - * |
|
| 1469 | - * @param \EE_Transaction $transaction |
|
| 1470 | - * @return array |
|
| 1471 | - */ |
|
| 1472 | - protected function _process_transaction_payments(EE_Transaction $transaction) |
|
| 1473 | - { |
|
| 1474 | - /** @type EE_Transaction_Payments $transaction_payments */ |
|
| 1475 | - $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
| 1476 | - //update the transaction with this payment |
|
| 1477 | - if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) { |
|
| 1478 | - EE_Error::add_success(esc_html__('The payment has been processed successfully.', 'event_espresso'), |
|
| 1479 | - __FILE__, __FUNCTION__, __LINE__); |
|
| 1480 | - } else { |
|
| 1481 | - EE_Error::add_error( |
|
| 1482 | - esc_html__('The payment was processed successfully but the amount paid for the transaction was not updated.', |
|
| 1483 | - 'event_espresso') |
|
| 1484 | - , __FILE__, __FUNCTION__, __LINE__ |
|
| 1485 | - ); |
|
| 1486 | - } |
|
| 1487 | - } |
|
| 1488 | - |
|
| 1489 | - |
|
| 1490 | - /** |
|
| 1491 | - * _get_REG_IDs_to_apply_payment_to |
|
| 1492 | - * returns a list of registration IDs that the payment will apply to |
|
| 1493 | - * |
|
| 1494 | - * @param \EE_Payment $payment |
|
| 1495 | - * @return array |
|
| 1496 | - */ |
|
| 1497 | - protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment) |
|
| 1498 | - { |
|
| 1499 | - $REG_IDs = array(); |
|
| 1500 | - // grab array of IDs for specific registrations to apply changes to |
|
| 1501 | - if (isset($this->_req_data['txn_admin_payment']['registrations'])) { |
|
| 1502 | - $REG_IDs = (array)$this->_req_data['txn_admin_payment']['registrations']; |
|
| 1503 | - } |
|
| 1504 | - //nothing specified ? then get all reg IDs |
|
| 1505 | - if (empty($REG_IDs)) { |
|
| 1506 | - $registrations = $payment->transaction()->registrations(); |
|
| 1507 | - $REG_IDs = ! empty($registrations) ? array_keys($registrations) : $this->_get_existing_reg_payment_REG_IDs($payment); |
|
| 1508 | - } |
|
| 1509 | - |
|
| 1510 | - // ensure that REG_IDs are integers and NOT strings |
|
| 1511 | - return array_map('intval', $REG_IDs); |
|
| 1512 | - } |
|
| 1513 | - |
|
| 1514 | - |
|
| 1515 | - /** |
|
| 1516 | - * @return array |
|
| 1517 | - */ |
|
| 1518 | - public function existing_reg_payment_REG_IDs() |
|
| 1519 | - { |
|
| 1520 | - return $this->_existing_reg_payment_REG_IDs; |
|
| 1521 | - } |
|
| 1522 | - |
|
| 1523 | - |
|
| 1524 | - /** |
|
| 1525 | - * @param array $existing_reg_payment_REG_IDs |
|
| 1526 | - */ |
|
| 1527 | - public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null) |
|
| 1528 | - { |
|
| 1529 | - $this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs; |
|
| 1530 | - } |
|
| 1531 | - |
|
| 1532 | - |
|
| 1533 | - /** |
|
| 1534 | - * _get_existing_reg_payment_REG_IDs |
|
| 1535 | - * returns a list of registration IDs that the payment is currently related to |
|
| 1536 | - * as recorded in the database |
|
| 1537 | - * |
|
| 1538 | - * @param \EE_Payment $payment |
|
| 1539 | - * @return array |
|
| 1540 | - */ |
|
| 1541 | - protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment) |
|
| 1542 | - { |
|
| 1543 | - if ($this->existing_reg_payment_REG_IDs() === null) { |
|
| 1544 | - // let's get any existing reg payment records for this payment |
|
| 1545 | - $existing_reg_payment_REG_IDs = $payment->get_many_related('Registration'); |
|
| 1546 | - // but we only want the REG IDs, so grab the array keys |
|
| 1547 | - $existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs) ? array_keys($existing_reg_payment_REG_IDs) : array(); |
|
| 1548 | - $this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs); |
|
| 1549 | - } |
|
| 1550 | - |
|
| 1551 | - return $this->existing_reg_payment_REG_IDs(); |
|
| 1552 | - } |
|
| 1553 | - |
|
| 1554 | - |
|
| 1555 | - /** |
|
| 1556 | - * _remove_existing_registration_payments |
|
| 1557 | - * this calculates the difference between existing relations |
|
| 1558 | - * to the supplied payment and the new list registration IDs, |
|
| 1559 | - * removes any related registrations that no longer apply, |
|
| 1560 | - * and then updates the registration paid fields |
|
| 1561 | - * |
|
| 1562 | - * @param \EE_Payment $payment |
|
| 1563 | - * @param int $PAY_ID |
|
| 1564 | - * @return bool; |
|
| 1565 | - */ |
|
| 1566 | - protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0) |
|
| 1567 | - { |
|
| 1568 | - // newly created payments will have nothing recorded for $PAY_ID |
|
| 1569 | - if ($PAY_ID == 0) { |
|
| 1570 | - return false; |
|
| 1571 | - } |
|
| 1572 | - $existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment); |
|
| 1573 | - if (empty($existing_reg_payment_REG_IDs)) { |
|
| 1574 | - return false; |
|
| 1575 | - } |
|
| 1576 | - /** @type EE_Transaction_Payments $transaction_payments */ |
|
| 1577 | - $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
| 1578 | - |
|
| 1579 | - return $transaction_payments->delete_registration_payments_and_update_registrations( |
|
| 1580 | - $payment, |
|
| 1581 | - array( |
|
| 1582 | - array( |
|
| 1583 | - 'PAY_ID' => $payment->ID(), |
|
| 1584 | - 'REG_ID' => array('IN', $existing_reg_payment_REG_IDs), |
|
| 1585 | - ), |
|
| 1586 | - ) |
|
| 1587 | - ); |
|
| 1588 | - } |
|
| 1589 | - |
|
| 1590 | - |
|
| 1591 | - /** |
|
| 1592 | - * _update_registration_payments |
|
| 1593 | - * this applies the payments to the selected registrations |
|
| 1594 | - * but only if they have not already been paid for |
|
| 1595 | - * |
|
| 1596 | - * @param EE_Transaction $transaction |
|
| 1597 | - * @param \EE_Payment $payment |
|
| 1598 | - * @param array $REG_IDs |
|
| 1599 | - * @return bool |
|
| 1600 | - */ |
|
| 1601 | - protected function _update_registration_payments( |
|
| 1602 | - EE_Transaction $transaction, |
|
| 1603 | - EE_Payment $payment, |
|
| 1604 | - $REG_IDs = array() |
|
| 1605 | - ) { |
|
| 1606 | - // we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments() |
|
| 1607 | - // so let's do that using our set of REG_IDs from the form |
|
| 1608 | - $registration_query_where_params = array( |
|
| 1609 | - 'REG_ID' => array('IN', $REG_IDs), |
|
| 1610 | - ); |
|
| 1611 | - // but add in some conditions regarding payment, |
|
| 1612 | - // so that we don't apply payments to registrations that are free or have already been paid for |
|
| 1613 | - // but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative ) |
|
| 1614 | - if (! $payment->is_a_refund()) { |
|
| 1615 | - $registration_query_where_params['REG_final_price'] = array('!=', 0); |
|
| 1616 | - $registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true); |
|
| 1617 | - } |
|
| 1618 | - //EEH_Debug_Tools::printr( $registration_query_where_params, '$registration_query_where_params', __FILE__, __LINE__ ); |
|
| 1619 | - $registrations = $transaction->registrations(array($registration_query_where_params)); |
|
| 1620 | - if (! empty($registrations)) { |
|
| 1621 | - /** @type EE_Payment_Processor $payment_processor */ |
|
| 1622 | - $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
| 1623 | - $payment_processor->process_registration_payments($transaction, $payment, $registrations); |
|
| 1624 | - } |
|
| 1625 | - } |
|
| 1626 | - |
|
| 1627 | - |
|
| 1628 | - /** |
|
| 1629 | - * _process_registration_status_change |
|
| 1630 | - * This processes requested registration status changes for all the registrations |
|
| 1631 | - * on a given transaction and (optionally) sends out notifications for the changes. |
|
| 1632 | - * |
|
| 1633 | - * @param EE_Transaction $transaction |
|
| 1634 | - * @param array $REG_IDs |
|
| 1635 | - * @return bool |
|
| 1636 | - */ |
|
| 1637 | - protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array()) |
|
| 1638 | - { |
|
| 1639 | - // first if there is no change in status then we get out. |
|
| 1640 | - if ( |
|
| 1641 | - ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['reg_status']) |
|
| 1642 | - || $this->_req_data['txn_reg_status_change']['reg_status'] == 'NAN' |
|
| 1643 | - ) { |
|
| 1644 | - //no error message, no change requested, just nothing to do man. |
|
| 1645 | - return false; |
|
| 1646 | - } |
|
| 1647 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
| 1648 | - $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
| 1649 | - |
|
| 1650 | - // made it here dude? Oh WOW. K, let's take care of changing the statuses |
|
| 1651 | - return $transaction_processor->manually_update_registration_statuses( |
|
| 1652 | - $transaction, |
|
| 1653 | - sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']), |
|
| 1654 | - array(array('REG_ID' => array('IN', $REG_IDs))) |
|
| 1655 | - ); |
|
| 1656 | - } |
|
| 1657 | - |
|
| 1658 | - |
|
| 1659 | - /** |
|
| 1660 | - * _build_payment_json_response |
|
| 1661 | - * |
|
| 1662 | - * @access public |
|
| 1663 | - * @param \EE_Payment $payment |
|
| 1664 | - * @param array $REG_IDs |
|
| 1665 | - * @param bool | null $delete_txn_reg_status_change |
|
| 1666 | - * @return array |
|
| 1667 | - */ |
|
| 1668 | - protected function _build_payment_json_response( |
|
| 1669 | - EE_Payment $payment, |
|
| 1670 | - $REG_IDs = array(), |
|
| 1671 | - $delete_txn_reg_status_change = null |
|
| 1672 | - ) { |
|
| 1673 | - // was the payment deleted ? |
|
| 1674 | - if (is_bool($delete_txn_reg_status_change)) { |
|
| 1675 | - return array( |
|
| 1676 | - 'PAY_ID' => $payment->ID(), |
|
| 1677 | - 'amount' => $payment->amount(), |
|
| 1678 | - 'total_paid' => $payment->transaction()->paid(), |
|
| 1679 | - 'txn_status' => $payment->transaction()->status_ID(), |
|
| 1680 | - 'pay_status' => $payment->STS_ID(), |
|
| 1681 | - 'registrations' => $this->_registration_payment_data_array($REG_IDs), |
|
| 1682 | - 'delete_txn_reg_status_change' => $delete_txn_reg_status_change, |
|
| 1683 | - ); |
|
| 1684 | - } else { |
|
| 1685 | - $this->_get_payment_status_array(); |
|
| 1686 | - |
|
| 1687 | - return array( |
|
| 1688 | - 'amount' => $payment->amount(), |
|
| 1689 | - 'total_paid' => $payment->transaction()->paid(), |
|
| 1690 | - 'txn_status' => $payment->transaction()->status_ID(), |
|
| 1691 | - 'pay_status' => $payment->STS_ID(), |
|
| 1692 | - 'PAY_ID' => $payment->ID(), |
|
| 1693 | - 'STS_ID' => $payment->STS_ID(), |
|
| 1694 | - 'status' => self::$_pay_status[$payment->STS_ID()], |
|
| 1695 | - 'date' => $payment->timestamp('Y-m-d', 'h:i a'), |
|
| 1696 | - 'method' => strtoupper($payment->source()), |
|
| 1697 | - 'PM_ID' => $payment->payment_method() ? $payment->payment_method()->ID() : 1, |
|
| 1698 | - 'gateway' => $payment->payment_method() ? $payment->payment_method()->admin_name() : esc_html__("Unknown", |
|
| 1699 | - 'event_espresso'), |
|
| 1700 | - 'gateway_response' => $payment->gateway_response(), |
|
| 1701 | - 'txn_id_chq_nmbr' => $payment->txn_id_chq_nmbr(), |
|
| 1702 | - 'po_number' => $payment->po_number(), |
|
| 1703 | - 'extra_accntng' => $payment->extra_accntng(), |
|
| 1704 | - 'registrations' => $this->_registration_payment_data_array($REG_IDs), |
|
| 1705 | - ); |
|
| 1706 | - } |
|
| 1707 | - } |
|
| 1708 | - |
|
| 1709 | - |
|
| 1710 | - /** |
|
| 1711 | - * delete_payment |
|
| 1712 | - * delete a payment or refund made towards a transaction |
|
| 1713 | - * |
|
| 1714 | - * @access public |
|
| 1715 | - * @return void |
|
| 1716 | - */ |
|
| 1717 | - public function delete_payment() |
|
| 1718 | - { |
|
| 1719 | - $json_response_data = array('return_data' => false); |
|
| 1720 | - $PAY_ID = isset($this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID']) ? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID']) : 0; |
|
| 1721 | - if ($PAY_ID) { |
|
| 1722 | - $delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change']) ? $this->_req_data['delete_txn_reg_status_change'] : false; |
|
| 1723 | - $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID); |
|
| 1724 | - if ($payment instanceof EE_Payment) { |
|
| 1725 | - $REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment); |
|
| 1726 | - /** @type EE_Transaction_Payments $transaction_payments */ |
|
| 1727 | - $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
| 1728 | - if ($transaction_payments->delete_payment_and_update_transaction($payment)) { |
|
| 1729 | - $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs, |
|
| 1730 | - $delete_txn_reg_status_change); |
|
| 1731 | - if ($delete_txn_reg_status_change) { |
|
| 1732 | - $this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change; |
|
| 1733 | - //MAKE sure we also add the delete_txn_req_status_change to the |
|
| 1734 | - //$_REQUEST global because that's how messages will be looking for it. |
|
| 1735 | - $_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change; |
|
| 1736 | - $this->_maybe_send_notifications(); |
|
| 1737 | - $this->_process_registration_status_change($payment->transaction(), $REG_IDs); |
|
| 1738 | - } |
|
| 1739 | - } |
|
| 1740 | - } else { |
|
| 1741 | - EE_Error::add_error( |
|
| 1742 | - esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'), |
|
| 1743 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 1744 | - ); |
|
| 1745 | - } |
|
| 1746 | - } else { |
|
| 1747 | - EE_Error::add_error( |
|
| 1748 | - esc_html__('A valid Payment ID was not received, therefore payment form data could not be loaded.', |
|
| 1749 | - 'event_espresso'), |
|
| 1750 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 1751 | - ); |
|
| 1752 | - } |
|
| 1753 | - $notices = EE_Error::get_notices(false, false, false); |
|
| 1754 | - $this->_template_args = array( |
|
| 1755 | - 'data' => $json_response_data, |
|
| 1756 | - 'success' => $notices['success'], |
|
| 1757 | - 'error' => $notices['errors'], |
|
| 1758 | - 'attention' => $notices['attention'], |
|
| 1759 | - ); |
|
| 1760 | - $this->_return_json(); |
|
| 1761 | - } |
|
| 1762 | - |
|
| 1763 | - |
|
| 1764 | - /** |
|
| 1765 | - * _registration_payment_data_array |
|
| 1766 | - * adds info for 'owing' and 'paid' for each registration to the json response |
|
| 1767 | - * |
|
| 1768 | - * @access protected |
|
| 1769 | - * @param array $REG_IDs |
|
| 1770 | - * @return array |
|
| 1771 | - */ |
|
| 1772 | - protected function _registration_payment_data_array($REG_IDs) |
|
| 1773 | - { |
|
| 1774 | - $registration_payment_data = array(); |
|
| 1775 | - //if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows. |
|
| 1776 | - if (! empty($REG_IDs)) { |
|
| 1777 | - $registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs)))); |
|
| 1778 | - foreach ($registrations as $registration) { |
|
| 1779 | - if ($registration instanceof EE_Registration) { |
|
| 1780 | - $registration_payment_data[$registration->ID()] = array( |
|
| 1781 | - 'paid' => $registration->pretty_paid(), |
|
| 1782 | - 'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()), |
|
| 1783 | - ); |
|
| 1784 | - } |
|
| 1785 | - } |
|
| 1786 | - } |
|
| 1787 | - |
|
| 1788 | - return $registration_payment_data; |
|
| 1789 | - } |
|
| 1790 | - |
|
| 1791 | - |
|
| 1792 | - /** |
|
| 1793 | - * _maybe_send_notifications |
|
| 1794 | - * determines whether or not the admin has indicated that notifications should be sent. |
|
| 1795 | - * If so, will toggle a filter switch for delivering registration notices. |
|
| 1796 | - * If passed an EE_Payment object, then it will trigger payment notifications instead. |
|
| 1797 | - * |
|
| 1798 | - * @access protected |
|
| 1799 | - * @param \EE_Payment | null $payment |
|
| 1800 | - */ |
|
| 1801 | - protected function _maybe_send_notifications($payment = null) |
|
| 1802 | - { |
|
| 1803 | - switch ($payment instanceof EE_Payment) { |
|
| 1804 | - // payment notifications |
|
| 1805 | - case true : |
|
| 1806 | - if ( |
|
| 1807 | - isset( |
|
| 1808 | - $this->_req_data['txn_payments'], |
|
| 1809 | - $this->_req_data['txn_payments']['send_notifications'] |
|
| 1810 | - ) && |
|
| 1811 | - filter_var($this->_req_data['txn_payments']['send_notifications'], FILTER_VALIDATE_BOOLEAN) |
|
| 1812 | - ) { |
|
| 1813 | - $this->_process_payment_notification($payment); |
|
| 1814 | - } |
|
| 1815 | - break; |
|
| 1816 | - // registration notifications |
|
| 1817 | - case false : |
|
| 1818 | - if ( |
|
| 1819 | - isset( |
|
| 1820 | - $this->_req_data['txn_reg_status_change'], |
|
| 1821 | - $this->_req_data['txn_reg_status_change']['send_notifications'] |
|
| 1822 | - ) && |
|
| 1823 | - filter_var($this->_req_data['txn_reg_status_change']['send_notifications'], FILTER_VALIDATE_BOOLEAN) |
|
| 1824 | - ) { |
|
| 1825 | - add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
| 1826 | - } |
|
| 1827 | - break; |
|
| 1828 | - } |
|
| 1829 | - } |
|
| 1830 | - |
|
| 1831 | - |
|
| 1832 | - /** |
|
| 1833 | - * _send_payment_reminder |
|
| 1834 | - * generates HTML for the View Transaction Details Admin page |
|
| 1835 | - * |
|
| 1836 | - * @access protected |
|
| 1837 | - * @return void |
|
| 1838 | - */ |
|
| 1839 | - protected function _send_payment_reminder() |
|
| 1840 | - { |
|
| 1841 | - $TXN_ID = (! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : false; |
|
| 1842 | - $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
| 1843 | - $query_args = isset($this->_req_data['redirect_to']) ? array( |
|
| 1844 | - 'action' => $this->_req_data['redirect_to'], |
|
| 1845 | - 'TXN_ID' => $this->_req_data['TXN_ID'], |
|
| 1846 | - ) : array(); |
|
| 1847 | - do_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', |
|
| 1848 | - $transaction); |
|
| 1849 | - $this->_redirect_after_action(false, esc_html__('payment reminder', 'event_espresso'), |
|
| 1850 | - esc_html__('sent', 'event_espresso'), $query_args, true); |
|
| 1851 | - } |
|
| 1852 | - |
|
| 1853 | - |
|
| 1854 | - /** |
|
| 1855 | - * get_transactions |
|
| 1856 | - * get transactions for given parameters (used by list table) |
|
| 1857 | - * |
|
| 1858 | - * @param int $perpage how many transactions displayed per page |
|
| 1859 | - * @param boolean $count return the count or objects |
|
| 1860 | - * @param string $view |
|
| 1861 | - * @return mixed int = count || array of transaction objects |
|
| 1862 | - */ |
|
| 1863 | - public function get_transactions($perpage, $count = false, $view = '') |
|
| 1864 | - { |
|
| 1865 | - |
|
| 1866 | - $TXN = EEM_Transaction::instance(); |
|
| 1867 | - |
|
| 1868 | - $start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y', |
|
| 1869 | - strtotime('-10 year')); |
|
| 1870 | - $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y'); |
|
| 1871 | - |
|
| 1872 | - //make sure our timestamps start and end right at the boundaries for each day |
|
| 1873 | - $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00'; |
|
| 1874 | - $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59'; |
|
| 1875 | - |
|
| 1876 | - |
|
| 1877 | - //convert to timestamps |
|
| 1878 | - $start_date = strtotime($start_date); |
|
| 1879 | - $end_date = strtotime($end_date); |
|
| 1880 | - |
|
| 1881 | - //makes sure start date is the lowest value and vice versa |
|
| 1882 | - $start_date = min($start_date, $end_date); |
|
| 1883 | - $end_date = max($start_date, $end_date); |
|
| 1884 | - |
|
| 1885 | - //convert to correct format for query |
|
| 1886 | - $start_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', |
|
| 1887 | - date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s'); |
|
| 1888 | - $end_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', |
|
| 1889 | - date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s'); |
|
| 1890 | - |
|
| 1891 | - |
|
| 1892 | - //set orderby |
|
| 1893 | - $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
|
| 1894 | - |
|
| 1895 | - switch ($this->_req_data['orderby']) { |
|
| 1896 | - case 'TXN_ID': |
|
| 1897 | - $orderby = 'TXN_ID'; |
|
| 1898 | - break; |
|
| 1899 | - case 'ATT_fname': |
|
| 1900 | - $orderby = 'Registration.Attendee.ATT_fname'; |
|
| 1901 | - break; |
|
| 1902 | - case 'event_name': |
|
| 1903 | - $orderby = 'Registration.Event.EVT_name'; |
|
| 1904 | - break; |
|
| 1905 | - default: //'TXN_timestamp' |
|
| 1906 | - $orderby = 'TXN_timestamp'; |
|
| 1907 | - } |
|
| 1908 | - |
|
| 1909 | - $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC'; |
|
| 1910 | - $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
| 1911 | - $per_page = isset($perpage) && ! empty($perpage) ? $perpage : 10; |
|
| 1912 | - $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
| 1913 | - |
|
| 1914 | - $offset = ($current_page - 1) * $per_page; |
|
| 1915 | - $limit = array($offset, $per_page); |
|
| 1916 | - |
|
| 1917 | - $_where = array( |
|
| 1918 | - 'TXN_timestamp' => array('BETWEEN', array($start_date, $end_date)), |
|
| 1919 | - 'Registration.REG_count' => 1, |
|
| 1920 | - ); |
|
| 1921 | - |
|
| 1922 | - if (isset($this->_req_data['EVT_ID'])) { |
|
| 1923 | - $_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID']; |
|
| 1924 | - } |
|
| 1925 | - |
|
| 1926 | - if (isset($this->_req_data['s'])) { |
|
| 1927 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
| 1928 | - $_where['OR'] = array( |
|
| 1929 | - 'Registration.Event.EVT_name' => array('LIKE', $search_string), |
|
| 1930 | - 'Registration.Event.EVT_desc' => array('LIKE', $search_string), |
|
| 1931 | - 'Registration.Event.EVT_short_desc' => array('LIKE', $search_string), |
|
| 1932 | - 'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string), |
|
| 1933 | - 'Registration.Attendee.ATT_fname' => array('LIKE', $search_string), |
|
| 1934 | - 'Registration.Attendee.ATT_lname' => array('LIKE', $search_string), |
|
| 1935 | - 'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string), |
|
| 1936 | - 'Registration.Attendee.ATT_email' => array('LIKE', $search_string), |
|
| 1937 | - 'Registration.Attendee.ATT_address' => array('LIKE', $search_string), |
|
| 1938 | - 'Registration.Attendee.ATT_address2' => array('LIKE', $search_string), |
|
| 1939 | - 'Registration.Attendee.ATT_city' => array('LIKE', $search_string), |
|
| 1940 | - 'Registration.REG_final_price' => array('LIKE', $search_string), |
|
| 1941 | - 'Registration.REG_code' => array('LIKE', $search_string), |
|
| 1942 | - 'Registration.REG_count' => array('LIKE', $search_string), |
|
| 1943 | - 'Registration.REG_group_size' => array('LIKE', $search_string), |
|
| 1944 | - 'Registration.Ticket.TKT_name' => array('LIKE', $search_string), |
|
| 1945 | - 'Registration.Ticket.TKT_description' => array('LIKE', $search_string), |
|
| 1946 | - 'Payment.PAY_source' => array('LIKE', $search_string), |
|
| 1947 | - 'Payment.Payment_Method.PMD_name' => array('LIKE', $search_string), |
|
| 1948 | - 'TXN_session_data' => array('LIKE', $search_string), |
|
| 1949 | - 'Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string), |
|
| 1950 | - ); |
|
| 1951 | - } |
|
| 1952 | - |
|
| 1953 | - //failed transactions |
|
| 1954 | - $failed = (! empty($this->_req_data['status']) && $this->_req_data['status'] == 'failed' && ! $count) || ($count && $view == 'failed') ? true : false; |
|
| 1955 | - $abandoned = (! empty($this->_req_data['status']) && $this->_req_data['status'] == 'abandoned' && ! $count) || ($count && $view == 'abandoned') ? true : false; |
|
| 1956 | - |
|
| 1957 | - if ($failed) { |
|
| 1958 | - $_where['STS_ID'] = EEM_Transaction::failed_status_code; |
|
| 1959 | - } else if ($abandoned) { |
|
| 1960 | - $_where['STS_ID'] = EEM_Transaction::abandoned_status_code; |
|
| 1961 | - } else { |
|
| 1962 | - $_where['STS_ID'] = array('!=', EEM_Transaction::failed_status_code); |
|
| 1963 | - $_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code); |
|
| 1964 | - } |
|
| 1965 | - |
|
| 1966 | - $query_params = array( |
|
| 1967 | - $_where, |
|
| 1968 | - 'order_by' => array($orderby => $sort), |
|
| 1969 | - 'limit' => $limit, |
|
| 1970 | - 'default_where_conditions' => EEM_Base::default_where_conditions_this_only, |
|
| 1971 | - ); |
|
| 1972 | - |
|
| 1973 | - $transactions = $count ? $TXN->count(array($_where), 'TXN_ID', true) : $TXN->get_all($query_params); |
|
| 1974 | - |
|
| 1975 | - |
|
| 1976 | - return $transactions; |
|
| 1977 | - |
|
| 1978 | - } |
|
| 804 | + // process payment details |
|
| 805 | + $payments = $this->_transaction->get_many_related('Payment'); |
|
| 806 | + if (! empty($payments)) { |
|
| 807 | + $this->_template_args['payments'] = $payments; |
|
| 808 | + $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments); |
|
| 809 | + } else { |
|
| 810 | + $this->_template_args['payments'] = false; |
|
| 811 | + $this->_template_args['existing_reg_payments'] = array(); |
|
| 812 | + } |
|
| 813 | + |
|
| 814 | + $this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL); |
|
| 815 | + $this->_template_args['delete_payment_url'] = add_query_arg(array('action' => 'espresso_delete_payment'), |
|
| 816 | + TXN_ADMIN_URL); |
|
| 817 | + |
|
| 818 | + if (isset($txn_details['invoice_number'])) { |
|
| 819 | + $this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code']; |
|
| 820 | + $this->_template_args['txn_details']['invoice_number']['label'] = esc_html__('Invoice Number', |
|
| 821 | + 'event_espresso'); |
|
| 822 | + } |
|
| 823 | + |
|
| 824 | + $this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction->get_first_related('Registration')->get('REG_session'); |
|
| 825 | + $this->_template_args['txn_details']['registration_session']['label'] = esc_html__('Registration Session', |
|
| 826 | + 'event_espresso'); |
|
| 827 | + |
|
| 828 | + $this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address']) ? $this->_session['ip_address'] : ''; |
|
| 829 | + $this->_template_args['txn_details']['ip_address']['label'] = esc_html__('Transaction placed from IP', |
|
| 830 | + 'event_espresso'); |
|
| 831 | + |
|
| 832 | + $this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent']) ? $this->_session['user_agent'] : ''; |
|
| 833 | + $this->_template_args['txn_details']['user_agent']['label'] = esc_html__('Registrant User Agent', |
|
| 834 | + 'event_espresso'); |
|
| 835 | + |
|
| 836 | + $reg_steps = '<ul>'; |
|
| 837 | + foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) { |
|
| 838 | + if ($reg_step_status === true) { |
|
| 839 | + $reg_steps .= '<li style="color:#70cc50">' . sprintf(esc_html__('%1$s : Completed', 'event_espresso'), |
|
| 840 | + ucwords(str_replace('_', ' ', $reg_step))) . '</li>'; |
|
| 841 | + } else if (is_numeric($reg_step_status) && $reg_step_status !== false) { |
|
| 842 | + $reg_steps .= '<li style="color:#2EA2CC">' . sprintf( |
|
| 843 | + esc_html__('%1$s : Initiated %2$s', 'event_espresso'), |
|
| 844 | + ucwords(str_replace('_', ' ', $reg_step)), |
|
| 845 | + date(get_option('date_format') . ' ' . get_option('time_format'), |
|
| 846 | + ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS))) |
|
| 847 | + ) . '</li>'; |
|
| 848 | + } else { |
|
| 849 | + $reg_steps .= '<li style="color:#E76700">' . sprintf(esc_html__('%1$s : Never Initiated', |
|
| 850 | + 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))) . '</li>'; |
|
| 851 | + } |
|
| 852 | + } |
|
| 853 | + $reg_steps .= '</ul>'; |
|
| 854 | + $this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps; |
|
| 855 | + $this->_template_args['txn_details']['reg_steps']['label'] = esc_html__('Registration Step Progress', |
|
| 856 | + 'event_espresso'); |
|
| 857 | + |
|
| 858 | + |
|
| 859 | + $this->_get_registrations_to_apply_payment_to(); |
|
| 860 | + $this->_get_payment_methods($payments); |
|
| 861 | + $this->_get_payment_status_array(); |
|
| 862 | + $this->_get_reg_status_selection(); //sets up the template args for the reg status array for the transaction. |
|
| 863 | + |
|
| 864 | + $this->_template_args['transaction_form_url'] = add_query_arg(array( |
|
| 865 | + 'action' => 'edit_transaction', |
|
| 866 | + 'process' => 'transaction', |
|
| 867 | + ), TXN_ADMIN_URL); |
|
| 868 | + $this->_template_args['apply_payment_form_url'] = add_query_arg(array( |
|
| 869 | + 'page' => 'espresso_transactions', |
|
| 870 | + 'action' => 'espresso_apply_payment', |
|
| 871 | + ), WP_AJAX_URL); |
|
| 872 | + $this->_template_args['delete_payment_form_url'] = add_query_arg(array( |
|
| 873 | + 'page' => 'espresso_transactions', |
|
| 874 | + 'action' => 'espresso_delete_payment', |
|
| 875 | + ), WP_AJAX_URL); |
|
| 876 | + |
|
| 877 | + // 'espresso_delete_payment_nonce' |
|
| 878 | + |
|
| 879 | + $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php'; |
|
| 880 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 881 | + |
|
| 882 | + } |
|
| 883 | + |
|
| 884 | + |
|
| 885 | + /** |
|
| 886 | + * _get_registration_payment_IDs |
|
| 887 | + * generates an array of Payment IDs and their corresponding Registration IDs |
|
| 888 | + * |
|
| 889 | + * @access protected |
|
| 890 | + * @param EE_Payment[] $payments |
|
| 891 | + * @return array |
|
| 892 | + */ |
|
| 893 | + protected function _get_registration_payment_IDs($payments = array()) |
|
| 894 | + { |
|
| 895 | + $existing_reg_payments = array(); |
|
| 896 | + // get all reg payments for these payments |
|
| 897 | + $reg_payments = EEM_Registration_Payment::instance()->get_all(array( |
|
| 898 | + array( |
|
| 899 | + 'PAY_ID' => array( |
|
| 900 | + 'IN', |
|
| 901 | + array_keys($payments), |
|
| 902 | + ), |
|
| 903 | + ), |
|
| 904 | + )); |
|
| 905 | + if (! empty($reg_payments)) { |
|
| 906 | + foreach ($payments as $payment) { |
|
| 907 | + if (! $payment instanceof EE_Payment) { |
|
| 908 | + continue; |
|
| 909 | + } else if (! isset($existing_reg_payments[$payment->ID()])) { |
|
| 910 | + $existing_reg_payments[$payment->ID()] = array(); |
|
| 911 | + } |
|
| 912 | + foreach ($reg_payments as $reg_payment) { |
|
| 913 | + if ($reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID()) { |
|
| 914 | + $existing_reg_payments[$payment->ID()][] = $reg_payment->registration_ID(); |
|
| 915 | + } |
|
| 916 | + } |
|
| 917 | + } |
|
| 918 | + } |
|
| 919 | + |
|
| 920 | + return $existing_reg_payments; |
|
| 921 | + } |
|
| 922 | + |
|
| 923 | + |
|
| 924 | + /** |
|
| 925 | + * _get_registrations_to_apply_payment_to |
|
| 926 | + * generates HTML for displaying a series of checkboxes in the admin payment modal window |
|
| 927 | + * which allows the admin to only apply the payment to the specific registrations |
|
| 928 | + * |
|
| 929 | + * @access protected |
|
| 930 | + * @return void |
|
| 931 | + * @throws \EE_Error |
|
| 932 | + */ |
|
| 933 | + protected function _get_registrations_to_apply_payment_to() |
|
| 934 | + { |
|
| 935 | + // we want any registration with an active status (ie: not deleted or cancelled) |
|
| 936 | + $query_params = array( |
|
| 937 | + array( |
|
| 938 | + 'STS_ID' => array( |
|
| 939 | + 'IN', |
|
| 940 | + array( |
|
| 941 | + EEM_Registration::status_id_approved, |
|
| 942 | + EEM_Registration::status_id_pending_payment, |
|
| 943 | + EEM_Registration::status_id_not_approved, |
|
| 944 | + ), |
|
| 945 | + ), |
|
| 946 | + ), |
|
| 947 | + ); |
|
| 948 | + $registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div( |
|
| 949 | + '', 'txn-admin-apply-payment-to-registrations-dv', '', 'clear: both; margin: 1.5em 0 0; display: none;' |
|
| 950 | + ); |
|
| 951 | + $registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap'); |
|
| 952 | + $registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl'); |
|
| 953 | + $registrations_to_apply_payment_to .= EEH_HTML::thead( |
|
| 954 | + EEH_HTML::tr( |
|
| 955 | + EEH_HTML::th(esc_html__('ID', 'event_espresso')) . |
|
| 956 | + EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) . |
|
| 957 | + EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) . |
|
| 958 | + EEH_HTML::th(esc_html__('Event', 'event_espresso')) . |
|
| 959 | + EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') . |
|
| 960 | + EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') . |
|
| 961 | + EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr') |
|
| 962 | + ) |
|
| 963 | + ); |
|
| 964 | + $registrations_to_apply_payment_to .= EEH_HTML::tbody(); |
|
| 965 | + // get registrations for TXN |
|
| 966 | + $registrations = $this->_transaction->registrations($query_params); |
|
| 967 | + foreach ($registrations as $registration) { |
|
| 968 | + if ($registration instanceof EE_Registration) { |
|
| 969 | + $attendee_name = $registration->attendee() instanceof EE_Attendee |
|
| 970 | + ? $registration->attendee()->full_name() |
|
| 971 | + : esc_html__('Unknown Attendee', 'event_espresso'); |
|
| 972 | + $owing = $registration->final_price() - $registration->paid(); |
|
| 973 | + $taxable = $registration->ticket()->taxable() |
|
| 974 | + ? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>' |
|
| 975 | + : ''; |
|
| 976 | + $checked = empty($existing_reg_payments) || in_array($registration->ID(), |
|
| 977 | + $existing_reg_payments) |
|
| 978 | + ? ' checked="checked"' |
|
| 979 | + : ''; |
|
| 980 | + $disabled = $registration->final_price() > 0 ? '' : ' disabled'; |
|
| 981 | + $registrations_to_apply_payment_to .= EEH_HTML::tr( |
|
| 982 | + EEH_HTML::td($registration->ID()) . |
|
| 983 | + EEH_HTML::td($attendee_name) . |
|
| 984 | + EEH_HTML::td( |
|
| 985 | + $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable |
|
| 986 | + ) . |
|
| 987 | + EEH_HTML::td($registration->event_name()) . |
|
| 988 | + EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') . |
|
| 989 | + EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr') . |
|
| 990 | + EEH_HTML::td( |
|
| 991 | + '<input type="checkbox" value="' . $registration->ID() |
|
| 992 | + . '" name="txn_admin_payment[registrations]"' |
|
| 993 | + . $checked . $disabled . '>', |
|
| 994 | + '', 'jst-cntr' |
|
| 995 | + ), |
|
| 996 | + 'apply-payment-registration-row-' . $registration->ID() |
|
| 997 | + ); |
|
| 998 | + } |
|
| 999 | + } |
|
| 1000 | + $registrations_to_apply_payment_to .= EEH_HTML::tbodyx(); |
|
| 1001 | + $registrations_to_apply_payment_to .= EEH_HTML::tablex(); |
|
| 1002 | + $registrations_to_apply_payment_to .= EEH_HTML::divx(); |
|
| 1003 | + $registrations_to_apply_payment_to .= EEH_HTML::p( |
|
| 1004 | + esc_html__( |
|
| 1005 | + 'The payment will only be applied to the registrations that have a check mark in their corresponding check box. Checkboxes for free registrations have been disabled.', |
|
| 1006 | + 'event_espresso' |
|
| 1007 | + ), |
|
| 1008 | + '', 'clear description' |
|
| 1009 | + ); |
|
| 1010 | + $registrations_to_apply_payment_to .= EEH_HTML::divx(); |
|
| 1011 | + $this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to; |
|
| 1012 | + } |
|
| 1013 | + |
|
| 1014 | + |
|
| 1015 | + /** |
|
| 1016 | + * _get_reg_status_selection |
|
| 1017 | + * |
|
| 1018 | + * @todo this will need to be adjusted either once MER comes along OR we move default reg status to tickets |
|
| 1019 | + * instead of events. |
|
| 1020 | + * @access protected |
|
| 1021 | + * @return void |
|
| 1022 | + */ |
|
| 1023 | + protected function _get_reg_status_selection() |
|
| 1024 | + { |
|
| 1025 | + //first get all possible statuses |
|
| 1026 | + $statuses = EEM_Registration::reg_status_array(array(), true); |
|
| 1027 | + //let's add a "don't change" option. |
|
| 1028 | + $status_array['NAN'] = esc_html__('Leave the Same', 'event_espresso'); |
|
| 1029 | + $status_array = array_merge($status_array, $statuses); |
|
| 1030 | + $this->_template_args['status_change_select'] = EEH_Form_Fields::select_input('txn_reg_status_change[reg_status]', |
|
| 1031 | + $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status'); |
|
| 1032 | + $this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input('delete_txn_reg_status_change[reg_status]', |
|
| 1033 | + $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status'); |
|
| 1034 | + |
|
| 1035 | + } |
|
| 1036 | + |
|
| 1037 | + |
|
| 1038 | + /** |
|
| 1039 | + * _get_payment_methods |
|
| 1040 | + * Gets all the payment methods available generally, or the ones that are already |
|
| 1041 | + * selected on these payments (in case their payment methods are no longer active). |
|
| 1042 | + * Has the side-effect of updating the template args' payment_methods item |
|
| 1043 | + * |
|
| 1044 | + * @access private |
|
| 1045 | + * @param EE_Payment[] to show on this page |
|
| 1046 | + * @return void |
|
| 1047 | + */ |
|
| 1048 | + private function _get_payment_methods($payments = array()) |
|
| 1049 | + { |
|
| 1050 | + $payment_methods_of_payments = array(); |
|
| 1051 | + foreach ($payments as $payment) { |
|
| 1052 | + if ($payment instanceof EE_Payment) { |
|
| 1053 | + $payment_methods_of_payments[] = $payment->get('PMD_ID'); |
|
| 1054 | + } |
|
| 1055 | + } |
|
| 1056 | + if ($payment_methods_of_payments) { |
|
| 1057 | + $query_args = array( |
|
| 1058 | + array( |
|
| 1059 | + 'OR*payment_method_for_payment' => array( |
|
| 1060 | + 'PMD_ID' => array('IN', $payment_methods_of_payments), |
|
| 1061 | + 'PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%'), |
|
| 1062 | + ), |
|
| 1063 | + ), |
|
| 1064 | + ); |
|
| 1065 | + } else { |
|
| 1066 | + $query_args = array(array('PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%'))); |
|
| 1067 | + } |
|
| 1068 | + $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args); |
|
| 1069 | + } |
|
| 1070 | + |
|
| 1071 | + |
|
| 1072 | + /** |
|
| 1073 | + * txn_attendees_meta_box |
|
| 1074 | + * generates HTML for the Attendees Transaction main meta box |
|
| 1075 | + * |
|
| 1076 | + * @access public |
|
| 1077 | + * @param WP_Post $post |
|
| 1078 | + * @param array $metabox |
|
| 1079 | + * @return void |
|
| 1080 | + */ |
|
| 1081 | + public function txn_attendees_meta_box($post, $metabox = array('args' => array())) |
|
| 1082 | + { |
|
| 1083 | + |
|
| 1084 | + extract($metabox['args']); |
|
| 1085 | + $this->_template_args['post'] = $post; |
|
| 1086 | + $this->_template_args['event_attendees'] = array(); |
|
| 1087 | + // process items in cart |
|
| 1088 | + $line_items = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item'))); |
|
| 1089 | + if (! empty($line_items)) { |
|
| 1090 | + foreach ($line_items as $item) { |
|
| 1091 | + if ($item instanceof EE_Line_Item) { |
|
| 1092 | + switch ($item->OBJ_type()) { |
|
| 1093 | + |
|
| 1094 | + case 'Event' : |
|
| 1095 | + break; |
|
| 1096 | + |
|
| 1097 | + case 'Ticket' : |
|
| 1098 | + $ticket = $item->ticket(); |
|
| 1099 | + //right now we're only handling tickets here. Cause its expected that only tickets will have attendees right? |
|
| 1100 | + if (! $ticket instanceof EE_Ticket) { |
|
| 1101 | + continue; |
|
| 1102 | + } |
|
| 1103 | + try { |
|
| 1104 | + $event_name = $ticket->get_event_name(); |
|
| 1105 | + } catch (Exception $e) { |
|
| 1106 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 1107 | + $event_name = esc_html__('Unknown Event', 'event_espresso'); |
|
| 1108 | + } |
|
| 1109 | + $event_name .= ' - ' . $item->get('LIN_name'); |
|
| 1110 | + $ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price')); |
|
| 1111 | + // now get all of the registrations for this transaction that use this ticket |
|
| 1112 | + $registrations = $ticket->get_many_related('Registration', |
|
| 1113 | + array(array('TXN_ID' => $this->_transaction->ID()))); |
|
| 1114 | + foreach ($registrations as $registration) { |
|
| 1115 | + if (! $registration instanceof EE_Registration) { |
|
| 1116 | + continue; |
|
| 1117 | + } |
|
| 1118 | + $this->_template_args['event_attendees'][$registration->ID()]['STS_ID'] = $registration->status_ID(); |
|
| 1119 | + $this->_template_args['event_attendees'][$registration->ID()]['att_num'] = $registration->count(); |
|
| 1120 | + $this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] = $event_name; |
|
| 1121 | + $this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] = $ticket_price; |
|
| 1122 | + // attendee info |
|
| 1123 | + $attendee = $registration->get_first_related('Attendee'); |
|
| 1124 | + if ($attendee instanceof EE_Attendee) { |
|
| 1125 | + $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = $attendee->ID(); |
|
| 1126 | + $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = $attendee->full_name(); |
|
| 1127 | + $this->_template_args['event_attendees'][$registration->ID()]['email'] = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name . esc_html__(' Event', |
|
| 1128 | + 'event_espresso') . '">' . $attendee->email() . '</a>'; |
|
| 1129 | + $this->_template_args['event_attendees'][$registration->ID()]['address'] = EEH_Address::format($attendee, |
|
| 1130 | + 'inline', false, false); |
|
| 1131 | + } else { |
|
| 1132 | + $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = ''; |
|
| 1133 | + $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = ''; |
|
| 1134 | + $this->_template_args['event_attendees'][$registration->ID()]['email'] = ''; |
|
| 1135 | + $this->_template_args['event_attendees'][$registration->ID()]['address'] = ''; |
|
| 1136 | + } |
|
| 1137 | + } |
|
| 1138 | + break; |
|
| 1139 | + |
|
| 1140 | + } |
|
| 1141 | + } |
|
| 1142 | + } |
|
| 1143 | + |
|
| 1144 | + $this->_template_args['transaction_form_url'] = add_query_arg(array( |
|
| 1145 | + 'action' => 'edit_transaction', |
|
| 1146 | + 'process' => 'attendees', |
|
| 1147 | + ), TXN_ADMIN_URL); |
|
| 1148 | + echo EEH_Template::display_template(TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php', |
|
| 1149 | + $this->_template_args, true); |
|
| 1150 | + |
|
| 1151 | + } else { |
|
| 1152 | + echo sprintf( |
|
| 1153 | + esc_html__('%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', |
|
| 1154 | + 'event_espresso'), |
|
| 1155 | + '<p class="important-notice">', |
|
| 1156 | + '</p>' |
|
| 1157 | + ); |
|
| 1158 | + } |
|
| 1159 | + } |
|
| 1160 | + |
|
| 1161 | + |
|
| 1162 | + /** |
|
| 1163 | + * txn_registrant_side_meta_box |
|
| 1164 | + * generates HTML for the Edit Transaction side meta box |
|
| 1165 | + * |
|
| 1166 | + * @access public |
|
| 1167 | + * @throws \EE_Error |
|
| 1168 | + * @return void |
|
| 1169 | + */ |
|
| 1170 | + public function txn_registrant_side_meta_box() |
|
| 1171 | + { |
|
| 1172 | + $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->get_first_related('Attendee') : null; |
|
| 1173 | + if (! $primary_att instanceof EE_Attendee) { |
|
| 1174 | + $this->_template_args['no_attendee_message'] = esc_html__('There is no attached contact for this transaction. The transaction either failed due to an error or was abandoned.', |
|
| 1175 | + 'event_espresso'); |
|
| 1176 | + $primary_att = EEM_Attendee::instance()->create_default_object(); |
|
| 1177 | + } |
|
| 1178 | + $this->_template_args['ATT_ID'] = $primary_att->ID(); |
|
| 1179 | + $this->_template_args['prime_reg_fname'] = $primary_att->fname(); |
|
| 1180 | + $this->_template_args['prime_reg_lname'] = $primary_att->lname(); |
|
| 1181 | + $this->_template_args['prime_reg_email'] = $primary_att->email(); |
|
| 1182 | + $this->_template_args['prime_reg_phone'] = $primary_att->phone(); |
|
| 1183 | + $this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1184 | + 'action' => 'edit_attendee', |
|
| 1185 | + 'post' => $primary_att->ID(), |
|
| 1186 | + ), REG_ADMIN_URL); |
|
| 1187 | + // get formatted address for registrant |
|
| 1188 | + $this->_template_args['formatted_address'] = EEH_Address::format($primary_att); |
|
| 1189 | + echo EEH_Template::display_template(TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php', |
|
| 1190 | + $this->_template_args, true); |
|
| 1191 | + } |
|
| 1192 | + |
|
| 1193 | + |
|
| 1194 | + /** |
|
| 1195 | + * txn_billing_info_side_meta_box |
|
| 1196 | + * generates HTML for the Edit Transaction side meta box |
|
| 1197 | + * |
|
| 1198 | + * @access public |
|
| 1199 | + * @return void |
|
| 1200 | + */ |
|
| 1201 | + public function txn_billing_info_side_meta_box() |
|
| 1202 | + { |
|
| 1203 | + |
|
| 1204 | + $this->_template_args['billing_form'] = $this->_transaction->billing_info(); |
|
| 1205 | + $this->_template_args['billing_form_url'] = add_query_arg( |
|
| 1206 | + array('action' => 'edit_transaction', 'process' => 'billing'), |
|
| 1207 | + TXN_ADMIN_URL |
|
| 1208 | + ); |
|
| 1209 | + |
|
| 1210 | + $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php'; |
|
| 1211 | + echo EEH_Template::display_template($template_path, $this->_template_args, true);/**/ |
|
| 1212 | + } |
|
| 1213 | + |
|
| 1214 | + |
|
| 1215 | + /** |
|
| 1216 | + * apply_payments_or_refunds |
|
| 1217 | + * registers a payment or refund made towards a transaction |
|
| 1218 | + * |
|
| 1219 | + * @access public |
|
| 1220 | + * @return void |
|
| 1221 | + */ |
|
| 1222 | + public function apply_payments_or_refunds() |
|
| 1223 | + { |
|
| 1224 | + $json_response_data = array('return_data' => false); |
|
| 1225 | + $valid_data = $this->_validate_payment_request_data(); |
|
| 1226 | + if (! empty($valid_data) |
|
| 1227 | + |
|
| 1228 | + ) { |
|
| 1229 | + $PAY_ID = $valid_data['PAY_ID']; |
|
| 1230 | + //save the new payment |
|
| 1231 | + $payment = $this->_create_payment_from_request_data($valid_data); |
|
| 1232 | + // get the TXN for this payment |
|
| 1233 | + $transaction = $payment->transaction(); |
|
| 1234 | + // verify transaction |
|
| 1235 | + if ($transaction instanceof EE_Transaction) { |
|
| 1236 | + // calculate_total_payments_and_update_status |
|
| 1237 | + $this->_process_transaction_payments($transaction); |
|
| 1238 | + $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment); |
|
| 1239 | + $this->_remove_existing_registration_payments($payment, $PAY_ID); |
|
| 1240 | + // apply payment to registrations (if applicable) |
|
| 1241 | + if (! empty($REG_IDs)) { |
|
| 1242 | + $this->_update_registration_payments($transaction, $payment, $REG_IDs); |
|
| 1243 | + $this->_maybe_send_notifications(); |
|
| 1244 | + // now process status changes for the same registrations |
|
| 1245 | + $this->_process_registration_status_change($transaction, $REG_IDs); |
|
| 1246 | + } |
|
| 1247 | + $this->_maybe_send_notifications($payment); |
|
| 1248 | + //prepare to render page |
|
| 1249 | + $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs); |
|
| 1250 | + do_action('AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction, |
|
| 1251 | + $payment); |
|
| 1252 | + } else { |
|
| 1253 | + EE_Error::add_error( |
|
| 1254 | + esc_html__('A valid Transaction for this payment could not be retrieved.', 'event_espresso'), |
|
| 1255 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 1256 | + ); |
|
| 1257 | + } |
|
| 1258 | + } else { |
|
| 1259 | + EE_Error::add_error(esc_html__('The payment form data could not be processed. Please try again.', |
|
| 1260 | + 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 1261 | + } |
|
| 1262 | + |
|
| 1263 | + $notices = EE_Error::get_notices(false, false, false); |
|
| 1264 | + $this->_template_args = array( |
|
| 1265 | + 'data' => $json_response_data, |
|
| 1266 | + 'error' => $notices['errors'], |
|
| 1267 | + 'success' => $notices['success'], |
|
| 1268 | + ); |
|
| 1269 | + $this->_return_json(); |
|
| 1270 | + } |
|
| 1271 | + |
|
| 1272 | + |
|
| 1273 | + /** |
|
| 1274 | + * _validate_payment_request_data |
|
| 1275 | + * |
|
| 1276 | + * @return array |
|
| 1277 | + */ |
|
| 1278 | + protected function _validate_payment_request_data() |
|
| 1279 | + { |
|
| 1280 | + if (! isset($this->_req_data['txn_admin_payment'])) { |
|
| 1281 | + return false; |
|
| 1282 | + } |
|
| 1283 | + $payment_form = $this->_generate_payment_form_section(); |
|
| 1284 | + try { |
|
| 1285 | + if ($payment_form->was_submitted()) { |
|
| 1286 | + $payment_form->receive_form_submission(); |
|
| 1287 | + if (! $payment_form->is_valid()) { |
|
| 1288 | + $submission_error_messages = array(); |
|
| 1289 | + foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) { |
|
| 1290 | + if ($validation_error instanceof EE_Validation_Error) { |
|
| 1291 | + $submission_error_messages[] = sprintf( |
|
| 1292 | + _x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'), |
|
| 1293 | + $validation_error->get_form_section()->html_label_text(), |
|
| 1294 | + $validation_error->getMessage() |
|
| 1295 | + ); |
|
| 1296 | + } |
|
| 1297 | + } |
|
| 1298 | + EE_Error::add_error(join('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
| 1299 | + |
|
| 1300 | + return array(); |
|
| 1301 | + } |
|
| 1302 | + } |
|
| 1303 | + } catch (EE_Error $e) { |
|
| 1304 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 1305 | + |
|
| 1306 | + return array(); |
|
| 1307 | + } |
|
| 1308 | + |
|
| 1309 | + return $payment_form->valid_data(); |
|
| 1310 | + } |
|
| 1311 | + |
|
| 1312 | + |
|
| 1313 | + /** |
|
| 1314 | + * _generate_payment_form_section |
|
| 1315 | + * |
|
| 1316 | + * @return EE_Form_Section_Proper |
|
| 1317 | + */ |
|
| 1318 | + protected function _generate_payment_form_section() |
|
| 1319 | + { |
|
| 1320 | + return new EE_Form_Section_Proper( |
|
| 1321 | + array( |
|
| 1322 | + 'name' => 'txn_admin_payment', |
|
| 1323 | + 'subsections' => array( |
|
| 1324 | + 'PAY_ID' => new EE_Text_Input( |
|
| 1325 | + array( |
|
| 1326 | + 'default' => 0, |
|
| 1327 | + 'required' => false, |
|
| 1328 | + 'html_label_text' => esc_html__('Payment ID', 'event_espresso'), |
|
| 1329 | + 'validation_strategies' => array(new EE_Int_Normalization()), |
|
| 1330 | + ) |
|
| 1331 | + ), |
|
| 1332 | + 'TXN_ID' => new EE_Text_Input( |
|
| 1333 | + array( |
|
| 1334 | + 'default' => 0, |
|
| 1335 | + 'required' => true, |
|
| 1336 | + 'html_label_text' => esc_html__('Transaction ID', 'event_espresso'), |
|
| 1337 | + 'validation_strategies' => array(new EE_Int_Normalization()), |
|
| 1338 | + ) |
|
| 1339 | + ), |
|
| 1340 | + 'type' => new EE_Text_Input( |
|
| 1341 | + array( |
|
| 1342 | + 'default' => 1, |
|
| 1343 | + 'required' => true, |
|
| 1344 | + 'html_label_text' => esc_html__('Payment or Refund', 'event_espresso'), |
|
| 1345 | + 'validation_strategies' => array(new EE_Int_Normalization()), |
|
| 1346 | + ) |
|
| 1347 | + ), |
|
| 1348 | + 'amount' => new EE_Text_Input( |
|
| 1349 | + array( |
|
| 1350 | + 'default' => 0, |
|
| 1351 | + 'required' => true, |
|
| 1352 | + 'html_label_text' => esc_html__('Payment amount', 'event_espresso'), |
|
| 1353 | + 'validation_strategies' => array(new EE_Float_Normalization()), |
|
| 1354 | + ) |
|
| 1355 | + ), |
|
| 1356 | + 'status' => new EE_Text_Input( |
|
| 1357 | + array( |
|
| 1358 | + 'default' => EEM_Payment::status_id_approved, |
|
| 1359 | + 'required' => true, |
|
| 1360 | + 'html_label_text' => esc_html__('Payment status', 'event_espresso'), |
|
| 1361 | + ) |
|
| 1362 | + ), |
|
| 1363 | + 'PMD_ID' => new EE_Text_Input( |
|
| 1364 | + array( |
|
| 1365 | + 'default' => 2, |
|
| 1366 | + 'required' => true, |
|
| 1367 | + 'html_label_text' => esc_html__('Payment Method', 'event_espresso'), |
|
| 1368 | + 'validation_strategies' => array(new EE_Int_Normalization()), |
|
| 1369 | + ) |
|
| 1370 | + ), |
|
| 1371 | + 'date' => new EE_Text_Input( |
|
| 1372 | + array( |
|
| 1373 | + 'default' => time(), |
|
| 1374 | + 'required' => true, |
|
| 1375 | + 'html_label_text' => esc_html__('Payment date', 'event_espresso'), |
|
| 1376 | + ) |
|
| 1377 | + ), |
|
| 1378 | + 'txn_id_chq_nmbr' => new EE_Text_Input( |
|
| 1379 | + array( |
|
| 1380 | + 'default' => '', |
|
| 1381 | + 'required' => false, |
|
| 1382 | + 'html_label_text' => esc_html__('Transaction or Cheque Number', 'event_espresso'), |
|
| 1383 | + 'validation_strategies' => array( |
|
| 1384 | + new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), |
|
| 1385 | + 100), |
|
| 1386 | + ), |
|
| 1387 | + ) |
|
| 1388 | + ), |
|
| 1389 | + 'po_number' => new EE_Text_Input( |
|
| 1390 | + array( |
|
| 1391 | + 'default' => '', |
|
| 1392 | + 'required' => false, |
|
| 1393 | + 'html_label_text' => esc_html__('Purchase Order Number', 'event_espresso'), |
|
| 1394 | + 'validation_strategies' => array( |
|
| 1395 | + new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), |
|
| 1396 | + 100), |
|
| 1397 | + ), |
|
| 1398 | + ) |
|
| 1399 | + ), |
|
| 1400 | + 'accounting' => new EE_Text_Input( |
|
| 1401 | + array( |
|
| 1402 | + 'default' => '', |
|
| 1403 | + 'required' => false, |
|
| 1404 | + 'html_label_text' => esc_html__('Extra Field for Accounting', 'event_espresso'), |
|
| 1405 | + 'validation_strategies' => array( |
|
| 1406 | + new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), |
|
| 1407 | + 100), |
|
| 1408 | + ), |
|
| 1409 | + ) |
|
| 1410 | + ), |
|
| 1411 | + ), |
|
| 1412 | + ) |
|
| 1413 | + ); |
|
| 1414 | + } |
|
| 1415 | + |
|
| 1416 | + |
|
| 1417 | + /** |
|
| 1418 | + * _create_payment_from_request_data |
|
| 1419 | + * |
|
| 1420 | + * @param array $valid_data |
|
| 1421 | + * @return EE_Payment |
|
| 1422 | + */ |
|
| 1423 | + protected function _create_payment_from_request_data($valid_data) |
|
| 1424 | + { |
|
| 1425 | + $PAY_ID = $valid_data['PAY_ID']; |
|
| 1426 | + // get payment amount |
|
| 1427 | + $amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0; |
|
| 1428 | + // payments have a type value of 1 and refunds have a type value of -1 |
|
| 1429 | + // so multiplying amount by type will give a positive value for payments, and negative values for refunds |
|
| 1430 | + $amount = $valid_data['type'] < 0 ? $amount * -1 : $amount; |
|
| 1431 | + // for some reason the date string coming in has extra spaces between the date and time. This fixes that. |
|
| 1432 | + $date = $valid_data['date'] ? preg_replace('/\s+/', ' ', $valid_data['date']) : date('Y-m-d g:i a', |
|
| 1433 | + current_time('timestamp')); |
|
| 1434 | + $payment = EE_Payment::new_instance( |
|
| 1435 | + array( |
|
| 1436 | + 'TXN_ID' => $valid_data['TXN_ID'], |
|
| 1437 | + 'STS_ID' => $valid_data['status'], |
|
| 1438 | + 'PAY_timestamp' => $date, |
|
| 1439 | + 'PAY_source' => EEM_Payment_Method::scope_admin, |
|
| 1440 | + 'PMD_ID' => $valid_data['PMD_ID'], |
|
| 1441 | + 'PAY_amount' => $amount, |
|
| 1442 | + 'PAY_txn_id_chq_nmbr' => $valid_data['txn_id_chq_nmbr'], |
|
| 1443 | + 'PAY_po_number' => $valid_data['po_number'], |
|
| 1444 | + 'PAY_extra_accntng' => $valid_data['accounting'], |
|
| 1445 | + 'PAY_details' => $valid_data, |
|
| 1446 | + 'PAY_ID' => $PAY_ID, |
|
| 1447 | + ), |
|
| 1448 | + '', |
|
| 1449 | + array('Y-m-d', 'g:i a') |
|
| 1450 | + ); |
|
| 1451 | + |
|
| 1452 | + if (! $payment->save()) { |
|
| 1453 | + EE_Error::add_error( |
|
| 1454 | + sprintf( |
|
| 1455 | + esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'), |
|
| 1456 | + $payment->ID() |
|
| 1457 | + ), |
|
| 1458 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 1459 | + ); |
|
| 1460 | + } |
|
| 1461 | + |
|
| 1462 | + return $payment; |
|
| 1463 | + } |
|
| 1464 | + |
|
| 1465 | + |
|
| 1466 | + /** |
|
| 1467 | + * _process_transaction_payments |
|
| 1468 | + * |
|
| 1469 | + * @param \EE_Transaction $transaction |
|
| 1470 | + * @return array |
|
| 1471 | + */ |
|
| 1472 | + protected function _process_transaction_payments(EE_Transaction $transaction) |
|
| 1473 | + { |
|
| 1474 | + /** @type EE_Transaction_Payments $transaction_payments */ |
|
| 1475 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
| 1476 | + //update the transaction with this payment |
|
| 1477 | + if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) { |
|
| 1478 | + EE_Error::add_success(esc_html__('The payment has been processed successfully.', 'event_espresso'), |
|
| 1479 | + __FILE__, __FUNCTION__, __LINE__); |
|
| 1480 | + } else { |
|
| 1481 | + EE_Error::add_error( |
|
| 1482 | + esc_html__('The payment was processed successfully but the amount paid for the transaction was not updated.', |
|
| 1483 | + 'event_espresso') |
|
| 1484 | + , __FILE__, __FUNCTION__, __LINE__ |
|
| 1485 | + ); |
|
| 1486 | + } |
|
| 1487 | + } |
|
| 1488 | + |
|
| 1489 | + |
|
| 1490 | + /** |
|
| 1491 | + * _get_REG_IDs_to_apply_payment_to |
|
| 1492 | + * returns a list of registration IDs that the payment will apply to |
|
| 1493 | + * |
|
| 1494 | + * @param \EE_Payment $payment |
|
| 1495 | + * @return array |
|
| 1496 | + */ |
|
| 1497 | + protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment) |
|
| 1498 | + { |
|
| 1499 | + $REG_IDs = array(); |
|
| 1500 | + // grab array of IDs for specific registrations to apply changes to |
|
| 1501 | + if (isset($this->_req_data['txn_admin_payment']['registrations'])) { |
|
| 1502 | + $REG_IDs = (array)$this->_req_data['txn_admin_payment']['registrations']; |
|
| 1503 | + } |
|
| 1504 | + //nothing specified ? then get all reg IDs |
|
| 1505 | + if (empty($REG_IDs)) { |
|
| 1506 | + $registrations = $payment->transaction()->registrations(); |
|
| 1507 | + $REG_IDs = ! empty($registrations) ? array_keys($registrations) : $this->_get_existing_reg_payment_REG_IDs($payment); |
|
| 1508 | + } |
|
| 1509 | + |
|
| 1510 | + // ensure that REG_IDs are integers and NOT strings |
|
| 1511 | + return array_map('intval', $REG_IDs); |
|
| 1512 | + } |
|
| 1513 | + |
|
| 1514 | + |
|
| 1515 | + /** |
|
| 1516 | + * @return array |
|
| 1517 | + */ |
|
| 1518 | + public function existing_reg_payment_REG_IDs() |
|
| 1519 | + { |
|
| 1520 | + return $this->_existing_reg_payment_REG_IDs; |
|
| 1521 | + } |
|
| 1522 | + |
|
| 1523 | + |
|
| 1524 | + /** |
|
| 1525 | + * @param array $existing_reg_payment_REG_IDs |
|
| 1526 | + */ |
|
| 1527 | + public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null) |
|
| 1528 | + { |
|
| 1529 | + $this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs; |
|
| 1530 | + } |
|
| 1531 | + |
|
| 1532 | + |
|
| 1533 | + /** |
|
| 1534 | + * _get_existing_reg_payment_REG_IDs |
|
| 1535 | + * returns a list of registration IDs that the payment is currently related to |
|
| 1536 | + * as recorded in the database |
|
| 1537 | + * |
|
| 1538 | + * @param \EE_Payment $payment |
|
| 1539 | + * @return array |
|
| 1540 | + */ |
|
| 1541 | + protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment) |
|
| 1542 | + { |
|
| 1543 | + if ($this->existing_reg_payment_REG_IDs() === null) { |
|
| 1544 | + // let's get any existing reg payment records for this payment |
|
| 1545 | + $existing_reg_payment_REG_IDs = $payment->get_many_related('Registration'); |
|
| 1546 | + // but we only want the REG IDs, so grab the array keys |
|
| 1547 | + $existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs) ? array_keys($existing_reg_payment_REG_IDs) : array(); |
|
| 1548 | + $this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs); |
|
| 1549 | + } |
|
| 1550 | + |
|
| 1551 | + return $this->existing_reg_payment_REG_IDs(); |
|
| 1552 | + } |
|
| 1553 | + |
|
| 1554 | + |
|
| 1555 | + /** |
|
| 1556 | + * _remove_existing_registration_payments |
|
| 1557 | + * this calculates the difference between existing relations |
|
| 1558 | + * to the supplied payment and the new list registration IDs, |
|
| 1559 | + * removes any related registrations that no longer apply, |
|
| 1560 | + * and then updates the registration paid fields |
|
| 1561 | + * |
|
| 1562 | + * @param \EE_Payment $payment |
|
| 1563 | + * @param int $PAY_ID |
|
| 1564 | + * @return bool; |
|
| 1565 | + */ |
|
| 1566 | + protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0) |
|
| 1567 | + { |
|
| 1568 | + // newly created payments will have nothing recorded for $PAY_ID |
|
| 1569 | + if ($PAY_ID == 0) { |
|
| 1570 | + return false; |
|
| 1571 | + } |
|
| 1572 | + $existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment); |
|
| 1573 | + if (empty($existing_reg_payment_REG_IDs)) { |
|
| 1574 | + return false; |
|
| 1575 | + } |
|
| 1576 | + /** @type EE_Transaction_Payments $transaction_payments */ |
|
| 1577 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
| 1578 | + |
|
| 1579 | + return $transaction_payments->delete_registration_payments_and_update_registrations( |
|
| 1580 | + $payment, |
|
| 1581 | + array( |
|
| 1582 | + array( |
|
| 1583 | + 'PAY_ID' => $payment->ID(), |
|
| 1584 | + 'REG_ID' => array('IN', $existing_reg_payment_REG_IDs), |
|
| 1585 | + ), |
|
| 1586 | + ) |
|
| 1587 | + ); |
|
| 1588 | + } |
|
| 1589 | + |
|
| 1590 | + |
|
| 1591 | + /** |
|
| 1592 | + * _update_registration_payments |
|
| 1593 | + * this applies the payments to the selected registrations |
|
| 1594 | + * but only if they have not already been paid for |
|
| 1595 | + * |
|
| 1596 | + * @param EE_Transaction $transaction |
|
| 1597 | + * @param \EE_Payment $payment |
|
| 1598 | + * @param array $REG_IDs |
|
| 1599 | + * @return bool |
|
| 1600 | + */ |
|
| 1601 | + protected function _update_registration_payments( |
|
| 1602 | + EE_Transaction $transaction, |
|
| 1603 | + EE_Payment $payment, |
|
| 1604 | + $REG_IDs = array() |
|
| 1605 | + ) { |
|
| 1606 | + // we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments() |
|
| 1607 | + // so let's do that using our set of REG_IDs from the form |
|
| 1608 | + $registration_query_where_params = array( |
|
| 1609 | + 'REG_ID' => array('IN', $REG_IDs), |
|
| 1610 | + ); |
|
| 1611 | + // but add in some conditions regarding payment, |
|
| 1612 | + // so that we don't apply payments to registrations that are free or have already been paid for |
|
| 1613 | + // but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative ) |
|
| 1614 | + if (! $payment->is_a_refund()) { |
|
| 1615 | + $registration_query_where_params['REG_final_price'] = array('!=', 0); |
|
| 1616 | + $registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true); |
|
| 1617 | + } |
|
| 1618 | + //EEH_Debug_Tools::printr( $registration_query_where_params, '$registration_query_where_params', __FILE__, __LINE__ ); |
|
| 1619 | + $registrations = $transaction->registrations(array($registration_query_where_params)); |
|
| 1620 | + if (! empty($registrations)) { |
|
| 1621 | + /** @type EE_Payment_Processor $payment_processor */ |
|
| 1622 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
| 1623 | + $payment_processor->process_registration_payments($transaction, $payment, $registrations); |
|
| 1624 | + } |
|
| 1625 | + } |
|
| 1626 | + |
|
| 1627 | + |
|
| 1628 | + /** |
|
| 1629 | + * _process_registration_status_change |
|
| 1630 | + * This processes requested registration status changes for all the registrations |
|
| 1631 | + * on a given transaction and (optionally) sends out notifications for the changes. |
|
| 1632 | + * |
|
| 1633 | + * @param EE_Transaction $transaction |
|
| 1634 | + * @param array $REG_IDs |
|
| 1635 | + * @return bool |
|
| 1636 | + */ |
|
| 1637 | + protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array()) |
|
| 1638 | + { |
|
| 1639 | + // first if there is no change in status then we get out. |
|
| 1640 | + if ( |
|
| 1641 | + ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['reg_status']) |
|
| 1642 | + || $this->_req_data['txn_reg_status_change']['reg_status'] == 'NAN' |
|
| 1643 | + ) { |
|
| 1644 | + //no error message, no change requested, just nothing to do man. |
|
| 1645 | + return false; |
|
| 1646 | + } |
|
| 1647 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
| 1648 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
| 1649 | + |
|
| 1650 | + // made it here dude? Oh WOW. K, let's take care of changing the statuses |
|
| 1651 | + return $transaction_processor->manually_update_registration_statuses( |
|
| 1652 | + $transaction, |
|
| 1653 | + sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']), |
|
| 1654 | + array(array('REG_ID' => array('IN', $REG_IDs))) |
|
| 1655 | + ); |
|
| 1656 | + } |
|
| 1657 | + |
|
| 1658 | + |
|
| 1659 | + /** |
|
| 1660 | + * _build_payment_json_response |
|
| 1661 | + * |
|
| 1662 | + * @access public |
|
| 1663 | + * @param \EE_Payment $payment |
|
| 1664 | + * @param array $REG_IDs |
|
| 1665 | + * @param bool | null $delete_txn_reg_status_change |
|
| 1666 | + * @return array |
|
| 1667 | + */ |
|
| 1668 | + protected function _build_payment_json_response( |
|
| 1669 | + EE_Payment $payment, |
|
| 1670 | + $REG_IDs = array(), |
|
| 1671 | + $delete_txn_reg_status_change = null |
|
| 1672 | + ) { |
|
| 1673 | + // was the payment deleted ? |
|
| 1674 | + if (is_bool($delete_txn_reg_status_change)) { |
|
| 1675 | + return array( |
|
| 1676 | + 'PAY_ID' => $payment->ID(), |
|
| 1677 | + 'amount' => $payment->amount(), |
|
| 1678 | + 'total_paid' => $payment->transaction()->paid(), |
|
| 1679 | + 'txn_status' => $payment->transaction()->status_ID(), |
|
| 1680 | + 'pay_status' => $payment->STS_ID(), |
|
| 1681 | + 'registrations' => $this->_registration_payment_data_array($REG_IDs), |
|
| 1682 | + 'delete_txn_reg_status_change' => $delete_txn_reg_status_change, |
|
| 1683 | + ); |
|
| 1684 | + } else { |
|
| 1685 | + $this->_get_payment_status_array(); |
|
| 1686 | + |
|
| 1687 | + return array( |
|
| 1688 | + 'amount' => $payment->amount(), |
|
| 1689 | + 'total_paid' => $payment->transaction()->paid(), |
|
| 1690 | + 'txn_status' => $payment->transaction()->status_ID(), |
|
| 1691 | + 'pay_status' => $payment->STS_ID(), |
|
| 1692 | + 'PAY_ID' => $payment->ID(), |
|
| 1693 | + 'STS_ID' => $payment->STS_ID(), |
|
| 1694 | + 'status' => self::$_pay_status[$payment->STS_ID()], |
|
| 1695 | + 'date' => $payment->timestamp('Y-m-d', 'h:i a'), |
|
| 1696 | + 'method' => strtoupper($payment->source()), |
|
| 1697 | + 'PM_ID' => $payment->payment_method() ? $payment->payment_method()->ID() : 1, |
|
| 1698 | + 'gateway' => $payment->payment_method() ? $payment->payment_method()->admin_name() : esc_html__("Unknown", |
|
| 1699 | + 'event_espresso'), |
|
| 1700 | + 'gateway_response' => $payment->gateway_response(), |
|
| 1701 | + 'txn_id_chq_nmbr' => $payment->txn_id_chq_nmbr(), |
|
| 1702 | + 'po_number' => $payment->po_number(), |
|
| 1703 | + 'extra_accntng' => $payment->extra_accntng(), |
|
| 1704 | + 'registrations' => $this->_registration_payment_data_array($REG_IDs), |
|
| 1705 | + ); |
|
| 1706 | + } |
|
| 1707 | + } |
|
| 1708 | + |
|
| 1709 | + |
|
| 1710 | + /** |
|
| 1711 | + * delete_payment |
|
| 1712 | + * delete a payment or refund made towards a transaction |
|
| 1713 | + * |
|
| 1714 | + * @access public |
|
| 1715 | + * @return void |
|
| 1716 | + */ |
|
| 1717 | + public function delete_payment() |
|
| 1718 | + { |
|
| 1719 | + $json_response_data = array('return_data' => false); |
|
| 1720 | + $PAY_ID = isset($this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID']) ? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID']) : 0; |
|
| 1721 | + if ($PAY_ID) { |
|
| 1722 | + $delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change']) ? $this->_req_data['delete_txn_reg_status_change'] : false; |
|
| 1723 | + $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID); |
|
| 1724 | + if ($payment instanceof EE_Payment) { |
|
| 1725 | + $REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment); |
|
| 1726 | + /** @type EE_Transaction_Payments $transaction_payments */ |
|
| 1727 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
| 1728 | + if ($transaction_payments->delete_payment_and_update_transaction($payment)) { |
|
| 1729 | + $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs, |
|
| 1730 | + $delete_txn_reg_status_change); |
|
| 1731 | + if ($delete_txn_reg_status_change) { |
|
| 1732 | + $this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change; |
|
| 1733 | + //MAKE sure we also add the delete_txn_req_status_change to the |
|
| 1734 | + //$_REQUEST global because that's how messages will be looking for it. |
|
| 1735 | + $_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change; |
|
| 1736 | + $this->_maybe_send_notifications(); |
|
| 1737 | + $this->_process_registration_status_change($payment->transaction(), $REG_IDs); |
|
| 1738 | + } |
|
| 1739 | + } |
|
| 1740 | + } else { |
|
| 1741 | + EE_Error::add_error( |
|
| 1742 | + esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'), |
|
| 1743 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 1744 | + ); |
|
| 1745 | + } |
|
| 1746 | + } else { |
|
| 1747 | + EE_Error::add_error( |
|
| 1748 | + esc_html__('A valid Payment ID was not received, therefore payment form data could not be loaded.', |
|
| 1749 | + 'event_espresso'), |
|
| 1750 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 1751 | + ); |
|
| 1752 | + } |
|
| 1753 | + $notices = EE_Error::get_notices(false, false, false); |
|
| 1754 | + $this->_template_args = array( |
|
| 1755 | + 'data' => $json_response_data, |
|
| 1756 | + 'success' => $notices['success'], |
|
| 1757 | + 'error' => $notices['errors'], |
|
| 1758 | + 'attention' => $notices['attention'], |
|
| 1759 | + ); |
|
| 1760 | + $this->_return_json(); |
|
| 1761 | + } |
|
| 1762 | + |
|
| 1763 | + |
|
| 1764 | + /** |
|
| 1765 | + * _registration_payment_data_array |
|
| 1766 | + * adds info for 'owing' and 'paid' for each registration to the json response |
|
| 1767 | + * |
|
| 1768 | + * @access protected |
|
| 1769 | + * @param array $REG_IDs |
|
| 1770 | + * @return array |
|
| 1771 | + */ |
|
| 1772 | + protected function _registration_payment_data_array($REG_IDs) |
|
| 1773 | + { |
|
| 1774 | + $registration_payment_data = array(); |
|
| 1775 | + //if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows. |
|
| 1776 | + if (! empty($REG_IDs)) { |
|
| 1777 | + $registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs)))); |
|
| 1778 | + foreach ($registrations as $registration) { |
|
| 1779 | + if ($registration instanceof EE_Registration) { |
|
| 1780 | + $registration_payment_data[$registration->ID()] = array( |
|
| 1781 | + 'paid' => $registration->pretty_paid(), |
|
| 1782 | + 'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()), |
|
| 1783 | + ); |
|
| 1784 | + } |
|
| 1785 | + } |
|
| 1786 | + } |
|
| 1787 | + |
|
| 1788 | + return $registration_payment_data; |
|
| 1789 | + } |
|
| 1790 | + |
|
| 1791 | + |
|
| 1792 | + /** |
|
| 1793 | + * _maybe_send_notifications |
|
| 1794 | + * determines whether or not the admin has indicated that notifications should be sent. |
|
| 1795 | + * If so, will toggle a filter switch for delivering registration notices. |
|
| 1796 | + * If passed an EE_Payment object, then it will trigger payment notifications instead. |
|
| 1797 | + * |
|
| 1798 | + * @access protected |
|
| 1799 | + * @param \EE_Payment | null $payment |
|
| 1800 | + */ |
|
| 1801 | + protected function _maybe_send_notifications($payment = null) |
|
| 1802 | + { |
|
| 1803 | + switch ($payment instanceof EE_Payment) { |
|
| 1804 | + // payment notifications |
|
| 1805 | + case true : |
|
| 1806 | + if ( |
|
| 1807 | + isset( |
|
| 1808 | + $this->_req_data['txn_payments'], |
|
| 1809 | + $this->_req_data['txn_payments']['send_notifications'] |
|
| 1810 | + ) && |
|
| 1811 | + filter_var($this->_req_data['txn_payments']['send_notifications'], FILTER_VALIDATE_BOOLEAN) |
|
| 1812 | + ) { |
|
| 1813 | + $this->_process_payment_notification($payment); |
|
| 1814 | + } |
|
| 1815 | + break; |
|
| 1816 | + // registration notifications |
|
| 1817 | + case false : |
|
| 1818 | + if ( |
|
| 1819 | + isset( |
|
| 1820 | + $this->_req_data['txn_reg_status_change'], |
|
| 1821 | + $this->_req_data['txn_reg_status_change']['send_notifications'] |
|
| 1822 | + ) && |
|
| 1823 | + filter_var($this->_req_data['txn_reg_status_change']['send_notifications'], FILTER_VALIDATE_BOOLEAN) |
|
| 1824 | + ) { |
|
| 1825 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
| 1826 | + } |
|
| 1827 | + break; |
|
| 1828 | + } |
|
| 1829 | + } |
|
| 1830 | + |
|
| 1831 | + |
|
| 1832 | + /** |
|
| 1833 | + * _send_payment_reminder |
|
| 1834 | + * generates HTML for the View Transaction Details Admin page |
|
| 1835 | + * |
|
| 1836 | + * @access protected |
|
| 1837 | + * @return void |
|
| 1838 | + */ |
|
| 1839 | + protected function _send_payment_reminder() |
|
| 1840 | + { |
|
| 1841 | + $TXN_ID = (! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : false; |
|
| 1842 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
| 1843 | + $query_args = isset($this->_req_data['redirect_to']) ? array( |
|
| 1844 | + 'action' => $this->_req_data['redirect_to'], |
|
| 1845 | + 'TXN_ID' => $this->_req_data['TXN_ID'], |
|
| 1846 | + ) : array(); |
|
| 1847 | + do_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', |
|
| 1848 | + $transaction); |
|
| 1849 | + $this->_redirect_after_action(false, esc_html__('payment reminder', 'event_espresso'), |
|
| 1850 | + esc_html__('sent', 'event_espresso'), $query_args, true); |
|
| 1851 | + } |
|
| 1852 | + |
|
| 1853 | + |
|
| 1854 | + /** |
|
| 1855 | + * get_transactions |
|
| 1856 | + * get transactions for given parameters (used by list table) |
|
| 1857 | + * |
|
| 1858 | + * @param int $perpage how many transactions displayed per page |
|
| 1859 | + * @param boolean $count return the count or objects |
|
| 1860 | + * @param string $view |
|
| 1861 | + * @return mixed int = count || array of transaction objects |
|
| 1862 | + */ |
|
| 1863 | + public function get_transactions($perpage, $count = false, $view = '') |
|
| 1864 | + { |
|
| 1865 | + |
|
| 1866 | + $TXN = EEM_Transaction::instance(); |
|
| 1867 | + |
|
| 1868 | + $start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y', |
|
| 1869 | + strtotime('-10 year')); |
|
| 1870 | + $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y'); |
|
| 1871 | + |
|
| 1872 | + //make sure our timestamps start and end right at the boundaries for each day |
|
| 1873 | + $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00'; |
|
| 1874 | + $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59'; |
|
| 1875 | + |
|
| 1876 | + |
|
| 1877 | + //convert to timestamps |
|
| 1878 | + $start_date = strtotime($start_date); |
|
| 1879 | + $end_date = strtotime($end_date); |
|
| 1880 | + |
|
| 1881 | + //makes sure start date is the lowest value and vice versa |
|
| 1882 | + $start_date = min($start_date, $end_date); |
|
| 1883 | + $end_date = max($start_date, $end_date); |
|
| 1884 | + |
|
| 1885 | + //convert to correct format for query |
|
| 1886 | + $start_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', |
|
| 1887 | + date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s'); |
|
| 1888 | + $end_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', |
|
| 1889 | + date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s'); |
|
| 1890 | + |
|
| 1891 | + |
|
| 1892 | + //set orderby |
|
| 1893 | + $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
|
| 1894 | + |
|
| 1895 | + switch ($this->_req_data['orderby']) { |
|
| 1896 | + case 'TXN_ID': |
|
| 1897 | + $orderby = 'TXN_ID'; |
|
| 1898 | + break; |
|
| 1899 | + case 'ATT_fname': |
|
| 1900 | + $orderby = 'Registration.Attendee.ATT_fname'; |
|
| 1901 | + break; |
|
| 1902 | + case 'event_name': |
|
| 1903 | + $orderby = 'Registration.Event.EVT_name'; |
|
| 1904 | + break; |
|
| 1905 | + default: //'TXN_timestamp' |
|
| 1906 | + $orderby = 'TXN_timestamp'; |
|
| 1907 | + } |
|
| 1908 | + |
|
| 1909 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC'; |
|
| 1910 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
| 1911 | + $per_page = isset($perpage) && ! empty($perpage) ? $perpage : 10; |
|
| 1912 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
| 1913 | + |
|
| 1914 | + $offset = ($current_page - 1) * $per_page; |
|
| 1915 | + $limit = array($offset, $per_page); |
|
| 1916 | + |
|
| 1917 | + $_where = array( |
|
| 1918 | + 'TXN_timestamp' => array('BETWEEN', array($start_date, $end_date)), |
|
| 1919 | + 'Registration.REG_count' => 1, |
|
| 1920 | + ); |
|
| 1921 | + |
|
| 1922 | + if (isset($this->_req_data['EVT_ID'])) { |
|
| 1923 | + $_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID']; |
|
| 1924 | + } |
|
| 1925 | + |
|
| 1926 | + if (isset($this->_req_data['s'])) { |
|
| 1927 | + $search_string = '%' . $this->_req_data['s'] . '%'; |
|
| 1928 | + $_where['OR'] = array( |
|
| 1929 | + 'Registration.Event.EVT_name' => array('LIKE', $search_string), |
|
| 1930 | + 'Registration.Event.EVT_desc' => array('LIKE', $search_string), |
|
| 1931 | + 'Registration.Event.EVT_short_desc' => array('LIKE', $search_string), |
|
| 1932 | + 'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string), |
|
| 1933 | + 'Registration.Attendee.ATT_fname' => array('LIKE', $search_string), |
|
| 1934 | + 'Registration.Attendee.ATT_lname' => array('LIKE', $search_string), |
|
| 1935 | + 'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string), |
|
| 1936 | + 'Registration.Attendee.ATT_email' => array('LIKE', $search_string), |
|
| 1937 | + 'Registration.Attendee.ATT_address' => array('LIKE', $search_string), |
|
| 1938 | + 'Registration.Attendee.ATT_address2' => array('LIKE', $search_string), |
|
| 1939 | + 'Registration.Attendee.ATT_city' => array('LIKE', $search_string), |
|
| 1940 | + 'Registration.REG_final_price' => array('LIKE', $search_string), |
|
| 1941 | + 'Registration.REG_code' => array('LIKE', $search_string), |
|
| 1942 | + 'Registration.REG_count' => array('LIKE', $search_string), |
|
| 1943 | + 'Registration.REG_group_size' => array('LIKE', $search_string), |
|
| 1944 | + 'Registration.Ticket.TKT_name' => array('LIKE', $search_string), |
|
| 1945 | + 'Registration.Ticket.TKT_description' => array('LIKE', $search_string), |
|
| 1946 | + 'Payment.PAY_source' => array('LIKE', $search_string), |
|
| 1947 | + 'Payment.Payment_Method.PMD_name' => array('LIKE', $search_string), |
|
| 1948 | + 'TXN_session_data' => array('LIKE', $search_string), |
|
| 1949 | + 'Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string), |
|
| 1950 | + ); |
|
| 1951 | + } |
|
| 1952 | + |
|
| 1953 | + //failed transactions |
|
| 1954 | + $failed = (! empty($this->_req_data['status']) && $this->_req_data['status'] == 'failed' && ! $count) || ($count && $view == 'failed') ? true : false; |
|
| 1955 | + $abandoned = (! empty($this->_req_data['status']) && $this->_req_data['status'] == 'abandoned' && ! $count) || ($count && $view == 'abandoned') ? true : false; |
|
| 1956 | + |
|
| 1957 | + if ($failed) { |
|
| 1958 | + $_where['STS_ID'] = EEM_Transaction::failed_status_code; |
|
| 1959 | + } else if ($abandoned) { |
|
| 1960 | + $_where['STS_ID'] = EEM_Transaction::abandoned_status_code; |
|
| 1961 | + } else { |
|
| 1962 | + $_where['STS_ID'] = array('!=', EEM_Transaction::failed_status_code); |
|
| 1963 | + $_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code); |
|
| 1964 | + } |
|
| 1965 | + |
|
| 1966 | + $query_params = array( |
|
| 1967 | + $_where, |
|
| 1968 | + 'order_by' => array($orderby => $sort), |
|
| 1969 | + 'limit' => $limit, |
|
| 1970 | + 'default_where_conditions' => EEM_Base::default_where_conditions_this_only, |
|
| 1971 | + ); |
|
| 1972 | + |
|
| 1973 | + $transactions = $count ? $TXN->count(array($_where), 'TXN_ID', true) : $TXN->get_all($query_params); |
|
| 1974 | + |
|
| 1975 | + |
|
| 1976 | + return $transactions; |
|
| 1977 | + |
|
| 1978 | + } |
|
| 1979 | 1979 | |
| 1980 | 1980 | |
| 1981 | 1981 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | 2 | exit('No direct script access allowed'); |
| 3 | 3 | } |
| 4 | 4 | |
@@ -335,11 +335,11 @@ discard block |
||
| 335 | 335 | public function load_scripts_styles() |
| 336 | 336 | { |
| 337 | 337 | //enqueue style |
| 338 | - wp_register_style('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.css', array(), |
|
| 338 | + wp_register_style('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.css', array(), |
|
| 339 | 339 | EVENT_ESPRESSO_VERSION); |
| 340 | 340 | wp_enqueue_style('espresso_txn'); |
| 341 | 341 | //scripts |
| 342 | - wp_register_script('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.js', array( |
|
| 342 | + wp_register_script('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.js', array( |
|
| 343 | 343 | 'ee_admin_js', |
| 344 | 344 | 'ee-datepicker', |
| 345 | 345 | 'jquery-ui-datepicker', |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | |
| 423 | 423 | $TXN = EEM_Transaction::instance(); |
| 424 | 424 | |
| 425 | - $TXN_ID = (! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : false; |
|
| 425 | + $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : false; |
|
| 426 | 426 | |
| 427 | 427 | //get transaction object |
| 428 | 428 | $this->_transaction = $TXN->get_one_by_ID($TXN_ID); |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | |
| 432 | 432 | if (empty($this->_transaction)) { |
| 433 | 433 | $error_msg = esc_html__('An error occurred and the details for Transaction ID #', |
| 434 | - 'event_espresso') . $TXN_ID . esc_html__(' could not be retrieved.', 'event_espresso'); |
|
| 434 | + 'event_espresso').$TXN_ID.esc_html__(' could not be retrieved.', 'event_espresso'); |
|
| 435 | 435 | EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
| 436 | 436 | } |
| 437 | 437 | } |
@@ -510,23 +510,23 @@ discard block |
||
| 510 | 510 | 'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items', |
| 511 | 511 | array( |
| 512 | 512 | 'overpaid' => array( |
| 513 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code, |
|
| 513 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::overpaid_status_code, |
|
| 514 | 514 | 'desc' => EEH_Template::pretty_status(EEM_Transaction::overpaid_status_code, false, 'sentence'), |
| 515 | 515 | ), |
| 516 | 516 | 'complete' => array( |
| 517 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code, |
|
| 517 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::complete_status_code, |
|
| 518 | 518 | 'desc' => EEH_Template::pretty_status(EEM_Transaction::complete_status_code, false, 'sentence'), |
| 519 | 519 | ), |
| 520 | 520 | 'incomplete' => array( |
| 521 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code, |
|
| 521 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::incomplete_status_code, |
|
| 522 | 522 | 'desc' => EEH_Template::pretty_status(EEM_Transaction::incomplete_status_code, false, 'sentence'), |
| 523 | 523 | ), |
| 524 | 524 | 'abandoned' => array( |
| 525 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code, |
|
| 525 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::abandoned_status_code, |
|
| 526 | 526 | 'desc' => EEH_Template::pretty_status(EEM_Transaction::abandoned_status_code, false, 'sentence'), |
| 527 | 527 | ), |
| 528 | 528 | 'failed' => array( |
| 529 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code, |
|
| 529 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::failed_status_code, |
|
| 530 | 530 | 'desc' => EEH_Template::pretty_status(EEM_Transaction::failed_status_code, false, 'sentence'), |
| 531 | 531 | ), |
| 532 | 532 | ) |
@@ -548,10 +548,10 @@ discard block |
||
| 548 | 548 | $event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']) : null; |
| 549 | 549 | $this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf(esc_html__('%sViewing Transactions for the Event: %s%s', |
| 550 | 550 | 'event_espresso'), '<h3>', |
| 551 | - '<a href="' . EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), |
|
| 552 | - EVENTS_ADMIN_URL) . '" title="' . esc_attr__('Click to Edit event', |
|
| 553 | - 'event_espresso') . '">' . $event->get('EVT_name') . '</a>', '</h3>') : ''; |
|
| 554 | - $this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items()); |
|
| 551 | + '<a href="'.EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), |
|
| 552 | + EVENTS_ADMIN_URL).'" title="'.esc_attr__('Click to Edit event', |
|
| 553 | + 'event_espresso').'">'.$event->get('EVT_name').'</a>', '</h3>') : ''; |
|
| 554 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items()); |
|
| 555 | 555 | $this->display_admin_list_table_page_with_no_sidebar(); |
| 556 | 556 | } |
| 557 | 557 | |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | |
| 586 | 586 | $this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')]; |
| 587 | 587 | $this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso'); |
| 588 | - $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID'); |
|
| 588 | + $this->_template_args['txn_status']['class'] = 'status-'.$this->_transaction->get('STS_ID'); |
|
| 589 | 589 | |
| 590 | 590 | $this->_template_args['grand_total'] = $this->_transaction->get('TXN_total'); |
| 591 | 591 | $this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid'); |
@@ -622,9 +622,9 @@ discard block |
||
| 622 | 622 | $amount_due = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid'); |
| 623 | 623 | $this->_template_args['amount_due'] = EEH_Template::format_currency($amount_due, true); |
| 624 | 624 | if (EE_Registry::instance()->CFG->currency->sign_b4) { |
| 625 | - $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign . $this->_template_args['amount_due']; |
|
| 625 | + $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign.$this->_template_args['amount_due']; |
|
| 626 | 626 | } else { |
| 627 | - $this->_template_args['amount_due'] = $this->_template_args['amount_due'] . EE_Registry::instance()->CFG->currency->sign; |
|
| 627 | + $this->_template_args['amount_due'] = $this->_template_args['amount_due'].EE_Registry::instance()->CFG->currency->sign; |
|
| 628 | 628 | } |
| 629 | 629 | $this->_template_args['amount_due_class'] = ''; |
| 630 | 630 | |
@@ -659,7 +659,7 @@ discard block |
||
| 659 | 659 | |
| 660 | 660 | |
| 661 | 661 | // next link |
| 662 | - $next_txn = $this->_transaction->next( |
|
| 662 | + $next_txn = $this->_transaction->next( |
|
| 663 | 663 | null, |
| 664 | 664 | array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), |
| 665 | 665 | 'TXN_ID' |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | ) |
| 675 | 675 | : ''; |
| 676 | 676 | // previous link |
| 677 | - $previous_txn = $this->_transaction->previous( |
|
| 677 | + $previous_txn = $this->_transaction->previous( |
|
| 678 | 678 | null, |
| 679 | 679 | array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), |
| 680 | 680 | 'TXN_ID' |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | // grab messages at the last second |
| 729 | 729 | $this->_template_args['notices'] = EE_Error::get_notices(); |
| 730 | 730 | // path to template |
| 731 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php'; |
|
| 731 | + $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_header.template.php'; |
|
| 732 | 732 | $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, |
| 733 | 733 | $this->_template_args, true); |
| 734 | 734 | |
@@ -803,7 +803,7 @@ discard block |
||
| 803 | 803 | |
| 804 | 804 | // process payment details |
| 805 | 805 | $payments = $this->_transaction->get_many_related('Payment'); |
| 806 | - if (! empty($payments)) { |
|
| 806 | + if ( ! empty($payments)) { |
|
| 807 | 807 | $this->_template_args['payments'] = $payments; |
| 808 | 808 | $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments); |
| 809 | 809 | } else { |
@@ -836,21 +836,21 @@ discard block |
||
| 836 | 836 | $reg_steps = '<ul>'; |
| 837 | 837 | foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) { |
| 838 | 838 | if ($reg_step_status === true) { |
| 839 | - $reg_steps .= '<li style="color:#70cc50">' . sprintf(esc_html__('%1$s : Completed', 'event_espresso'), |
|
| 840 | - ucwords(str_replace('_', ' ', $reg_step))) . '</li>'; |
|
| 839 | + $reg_steps .= '<li style="color:#70cc50">'.sprintf(esc_html__('%1$s : Completed', 'event_espresso'), |
|
| 840 | + ucwords(str_replace('_', ' ', $reg_step))).'</li>'; |
|
| 841 | 841 | } else if (is_numeric($reg_step_status) && $reg_step_status !== false) { |
| 842 | - $reg_steps .= '<li style="color:#2EA2CC">' . sprintf( |
|
| 842 | + $reg_steps .= '<li style="color:#2EA2CC">'.sprintf( |
|
| 843 | 843 | esc_html__('%1$s : Initiated %2$s', 'event_espresso'), |
| 844 | 844 | ucwords(str_replace('_', ' ', $reg_step)), |
| 845 | - date(get_option('date_format') . ' ' . get_option('time_format'), |
|
| 845 | + date(get_option('date_format').' '.get_option('time_format'), |
|
| 846 | 846 | ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS))) |
| 847 | - ) . '</li>'; |
|
| 847 | + ).'</li>'; |
|
| 848 | 848 | } else { |
| 849 | - $reg_steps .= '<li style="color:#E76700">' . sprintf(esc_html__('%1$s : Never Initiated', |
|
| 850 | - 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))) . '</li>'; |
|
| 849 | + $reg_steps .= '<li style="color:#E76700">'.sprintf(esc_html__('%1$s : Never Initiated', |
|
| 850 | + 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))).'</li>'; |
|
| 851 | 851 | } |
| 852 | 852 | } |
| 853 | - $reg_steps .= '</ul>'; |
|
| 853 | + $reg_steps .= '</ul>'; |
|
| 854 | 854 | $this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps; |
| 855 | 855 | $this->_template_args['txn_details']['reg_steps']['label'] = esc_html__('Registration Step Progress', |
| 856 | 856 | 'event_espresso'); |
@@ -861,11 +861,11 @@ discard block |
||
| 861 | 861 | $this->_get_payment_status_array(); |
| 862 | 862 | $this->_get_reg_status_selection(); //sets up the template args for the reg status array for the transaction. |
| 863 | 863 | |
| 864 | - $this->_template_args['transaction_form_url'] = add_query_arg(array( |
|
| 864 | + $this->_template_args['transaction_form_url'] = add_query_arg(array( |
|
| 865 | 865 | 'action' => 'edit_transaction', |
| 866 | 866 | 'process' => 'transaction', |
| 867 | 867 | ), TXN_ADMIN_URL); |
| 868 | - $this->_template_args['apply_payment_form_url'] = add_query_arg(array( |
|
| 868 | + $this->_template_args['apply_payment_form_url'] = add_query_arg(array( |
|
| 869 | 869 | 'page' => 'espresso_transactions', |
| 870 | 870 | 'action' => 'espresso_apply_payment', |
| 871 | 871 | ), WP_AJAX_URL); |
@@ -876,7 +876,7 @@ discard block |
||
| 876 | 876 | |
| 877 | 877 | // 'espresso_delete_payment_nonce' |
| 878 | 878 | |
| 879 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php'; |
|
| 879 | + $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_txn_details.template.php'; |
|
| 880 | 880 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
| 881 | 881 | |
| 882 | 882 | } |
@@ -902,11 +902,11 @@ discard block |
||
| 902 | 902 | ), |
| 903 | 903 | ), |
| 904 | 904 | )); |
| 905 | - if (! empty($reg_payments)) { |
|
| 905 | + if ( ! empty($reg_payments)) { |
|
| 906 | 906 | foreach ($payments as $payment) { |
| 907 | - if (! $payment instanceof EE_Payment) { |
|
| 907 | + if ( ! $payment instanceof EE_Payment) { |
|
| 908 | 908 | continue; |
| 909 | - } else if (! isset($existing_reg_payments[$payment->ID()])) { |
|
| 909 | + } else if ( ! isset($existing_reg_payments[$payment->ID()])) { |
|
| 910 | 910 | $existing_reg_payments[$payment->ID()] = array(); |
| 911 | 911 | } |
| 912 | 912 | foreach ($reg_payments as $reg_payment) { |
@@ -933,7 +933,7 @@ discard block |
||
| 933 | 933 | protected function _get_registrations_to_apply_payment_to() |
| 934 | 934 | { |
| 935 | 935 | // we want any registration with an active status (ie: not deleted or cancelled) |
| 936 | - $query_params = array( |
|
| 936 | + $query_params = array( |
|
| 937 | 937 | array( |
| 938 | 938 | 'STS_ID' => array( |
| 939 | 939 | 'IN', |
@@ -945,19 +945,19 @@ discard block |
||
| 945 | 945 | ), |
| 946 | 946 | ), |
| 947 | 947 | ); |
| 948 | - $registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div( |
|
| 948 | + $registrations_to_apply_payment_to = EEH_HTML::br().EEH_HTML::div( |
|
| 949 | 949 | '', 'txn-admin-apply-payment-to-registrations-dv', '', 'clear: both; margin: 1.5em 0 0; display: none;' |
| 950 | 950 | ); |
| 951 | - $registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap'); |
|
| 951 | + $registrations_to_apply_payment_to .= EEH_HTML::br().EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap'); |
|
| 952 | 952 | $registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl'); |
| 953 | 953 | $registrations_to_apply_payment_to .= EEH_HTML::thead( |
| 954 | 954 | EEH_HTML::tr( |
| 955 | - EEH_HTML::th(esc_html__('ID', 'event_espresso')) . |
|
| 956 | - EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) . |
|
| 957 | - EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) . |
|
| 958 | - EEH_HTML::th(esc_html__('Event', 'event_espresso')) . |
|
| 959 | - EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') . |
|
| 960 | - EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') . |
|
| 955 | + EEH_HTML::th(esc_html__('ID', 'event_espresso')). |
|
| 956 | + EEH_HTML::th(esc_html__('Registrant', 'event_espresso')). |
|
| 957 | + EEH_HTML::th(esc_html__('Ticket', 'event_espresso')). |
|
| 958 | + EEH_HTML::th(esc_html__('Event', 'event_espresso')). |
|
| 959 | + EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr'). |
|
| 960 | + EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr'). |
|
| 961 | 961 | EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr') |
| 962 | 962 | ) |
| 963 | 963 | ); |
@@ -971,29 +971,29 @@ discard block |
||
| 971 | 971 | : esc_html__('Unknown Attendee', 'event_espresso'); |
| 972 | 972 | $owing = $registration->final_price() - $registration->paid(); |
| 973 | 973 | $taxable = $registration->ticket()->taxable() |
| 974 | - ? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>' |
|
| 974 | + ? ' <span class="smaller-text lt-grey-text"> '.esc_html__('+ tax', 'event_espresso').'</span>' |
|
| 975 | 975 | : ''; |
| 976 | 976 | $checked = empty($existing_reg_payments) || in_array($registration->ID(), |
| 977 | 977 | $existing_reg_payments) |
| 978 | 978 | ? ' checked="checked"' |
| 979 | 979 | : ''; |
| 980 | - $disabled = $registration->final_price() > 0 ? '' : ' disabled'; |
|
| 980 | + $disabled = $registration->final_price() > 0 ? '' : ' disabled'; |
|
| 981 | 981 | $registrations_to_apply_payment_to .= EEH_HTML::tr( |
| 982 | - EEH_HTML::td($registration->ID()) . |
|
| 983 | - EEH_HTML::td($attendee_name) . |
|
| 982 | + EEH_HTML::td($registration->ID()). |
|
| 983 | + EEH_HTML::td($attendee_name). |
|
| 984 | 984 | EEH_HTML::td( |
| 985 | - $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable |
|
| 986 | - ) . |
|
| 987 | - EEH_HTML::td($registration->event_name()) . |
|
| 988 | - EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') . |
|
| 989 | - EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr') . |
|
| 985 | + $registration->ticket()->name().' : '.$registration->ticket()->pretty_price().$taxable |
|
| 986 | + ). |
|
| 987 | + EEH_HTML::td($registration->event_name()). |
|
| 988 | + EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr'). |
|
| 989 | + EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr'). |
|
| 990 | 990 | EEH_HTML::td( |
| 991 | - '<input type="checkbox" value="' . $registration->ID() |
|
| 991 | + '<input type="checkbox" value="'.$registration->ID() |
|
| 992 | 992 | . '" name="txn_admin_payment[registrations]"' |
| 993 | - . $checked . $disabled . '>', |
|
| 993 | + . $checked.$disabled.'>', |
|
| 994 | 994 | '', 'jst-cntr' |
| 995 | 995 | ), |
| 996 | - 'apply-payment-registration-row-' . $registration->ID() |
|
| 996 | + 'apply-payment-registration-row-'.$registration->ID() |
|
| 997 | 997 | ); |
| 998 | 998 | } |
| 999 | 999 | } |
@@ -1007,7 +1007,7 @@ discard block |
||
| 1007 | 1007 | ), |
| 1008 | 1008 | '', 'clear description' |
| 1009 | 1009 | ); |
| 1010 | - $registrations_to_apply_payment_to .= EEH_HTML::divx(); |
|
| 1010 | + $registrations_to_apply_payment_to .= EEH_HTML::divx(); |
|
| 1011 | 1011 | $this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to; |
| 1012 | 1012 | } |
| 1013 | 1013 | |
@@ -1058,12 +1058,12 @@ discard block |
||
| 1058 | 1058 | array( |
| 1059 | 1059 | 'OR*payment_method_for_payment' => array( |
| 1060 | 1060 | 'PMD_ID' => array('IN', $payment_methods_of_payments), |
| 1061 | - 'PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%'), |
|
| 1061 | + 'PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%'), |
|
| 1062 | 1062 | ), |
| 1063 | 1063 | ), |
| 1064 | 1064 | ); |
| 1065 | 1065 | } else { |
| 1066 | - $query_args = array(array('PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%'))); |
|
| 1066 | + $query_args = array(array('PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%'))); |
|
| 1067 | 1067 | } |
| 1068 | 1068 | $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args); |
| 1069 | 1069 | } |
@@ -1086,7 +1086,7 @@ discard block |
||
| 1086 | 1086 | $this->_template_args['event_attendees'] = array(); |
| 1087 | 1087 | // process items in cart |
| 1088 | 1088 | $line_items = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item'))); |
| 1089 | - if (! empty($line_items)) { |
|
| 1089 | + if ( ! empty($line_items)) { |
|
| 1090 | 1090 | foreach ($line_items as $item) { |
| 1091 | 1091 | if ($item instanceof EE_Line_Item) { |
| 1092 | 1092 | switch ($item->OBJ_type()) { |
@@ -1097,7 +1097,7 @@ discard block |
||
| 1097 | 1097 | case 'Ticket' : |
| 1098 | 1098 | $ticket = $item->ticket(); |
| 1099 | 1099 | //right now we're only handling tickets here. Cause its expected that only tickets will have attendees right? |
| 1100 | - if (! $ticket instanceof EE_Ticket) { |
|
| 1100 | + if ( ! $ticket instanceof EE_Ticket) { |
|
| 1101 | 1101 | continue; |
| 1102 | 1102 | } |
| 1103 | 1103 | try { |
@@ -1106,13 +1106,13 @@ discard block |
||
| 1106 | 1106 | EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
| 1107 | 1107 | $event_name = esc_html__('Unknown Event', 'event_espresso'); |
| 1108 | 1108 | } |
| 1109 | - $event_name .= ' - ' . $item->get('LIN_name'); |
|
| 1109 | + $event_name .= ' - '.$item->get('LIN_name'); |
|
| 1110 | 1110 | $ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price')); |
| 1111 | 1111 | // now get all of the registrations for this transaction that use this ticket |
| 1112 | 1112 | $registrations = $ticket->get_many_related('Registration', |
| 1113 | 1113 | array(array('TXN_ID' => $this->_transaction->ID()))); |
| 1114 | 1114 | foreach ($registrations as $registration) { |
| 1115 | - if (! $registration instanceof EE_Registration) { |
|
| 1115 | + if ( ! $registration instanceof EE_Registration) { |
|
| 1116 | 1116 | continue; |
| 1117 | 1117 | } |
| 1118 | 1118 | $this->_template_args['event_attendees'][$registration->ID()]['STS_ID'] = $registration->status_ID(); |
@@ -1124,8 +1124,8 @@ discard block |
||
| 1124 | 1124 | if ($attendee instanceof EE_Attendee) { |
| 1125 | 1125 | $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = $attendee->ID(); |
| 1126 | 1126 | $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = $attendee->full_name(); |
| 1127 | - $this->_template_args['event_attendees'][$registration->ID()]['email'] = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name . esc_html__(' Event', |
|
| 1128 | - 'event_espresso') . '">' . $attendee->email() . '</a>'; |
|
| 1127 | + $this->_template_args['event_attendees'][$registration->ID()]['email'] = '<a href="mailto:'.$attendee->email().'?subject='.$event_name.esc_html__(' Event', |
|
| 1128 | + 'event_espresso').'">'.$attendee->email().'</a>'; |
|
| 1129 | 1129 | $this->_template_args['event_attendees'][$registration->ID()]['address'] = EEH_Address::format($attendee, |
| 1130 | 1130 | 'inline', false, false); |
| 1131 | 1131 | } else { |
@@ -1145,7 +1145,7 @@ discard block |
||
| 1145 | 1145 | 'action' => 'edit_transaction', |
| 1146 | 1146 | 'process' => 'attendees', |
| 1147 | 1147 | ), TXN_ADMIN_URL); |
| 1148 | - echo EEH_Template::display_template(TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php', |
|
| 1148 | + echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_attendees.template.php', |
|
| 1149 | 1149 | $this->_template_args, true); |
| 1150 | 1150 | |
| 1151 | 1151 | } else { |
@@ -1170,7 +1170,7 @@ discard block |
||
| 1170 | 1170 | public function txn_registrant_side_meta_box() |
| 1171 | 1171 | { |
| 1172 | 1172 | $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->get_first_related('Attendee') : null; |
| 1173 | - if (! $primary_att instanceof EE_Attendee) { |
|
| 1173 | + if ( ! $primary_att instanceof EE_Attendee) { |
|
| 1174 | 1174 | $this->_template_args['no_attendee_message'] = esc_html__('There is no attached contact for this transaction. The transaction either failed due to an error or was abandoned.', |
| 1175 | 1175 | 'event_espresso'); |
| 1176 | 1176 | $primary_att = EEM_Attendee::instance()->create_default_object(); |
@@ -1186,7 +1186,7 @@ discard block |
||
| 1186 | 1186 | ), REG_ADMIN_URL); |
| 1187 | 1187 | // get formatted address for registrant |
| 1188 | 1188 | $this->_template_args['formatted_address'] = EEH_Address::format($primary_att); |
| 1189 | - echo EEH_Template::display_template(TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php', |
|
| 1189 | + echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_registrant.template.php', |
|
| 1190 | 1190 | $this->_template_args, true); |
| 1191 | 1191 | } |
| 1192 | 1192 | |
@@ -1207,8 +1207,8 @@ discard block |
||
| 1207 | 1207 | TXN_ADMIN_URL |
| 1208 | 1208 | ); |
| 1209 | 1209 | |
| 1210 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php'; |
|
| 1211 | - echo EEH_Template::display_template($template_path, $this->_template_args, true);/**/ |
|
| 1210 | + $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_billing_info.template.php'; |
|
| 1211 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); /**/ |
|
| 1212 | 1212 | } |
| 1213 | 1213 | |
| 1214 | 1214 | |
@@ -1223,7 +1223,7 @@ discard block |
||
| 1223 | 1223 | { |
| 1224 | 1224 | $json_response_data = array('return_data' => false); |
| 1225 | 1225 | $valid_data = $this->_validate_payment_request_data(); |
| 1226 | - if (! empty($valid_data) |
|
| 1226 | + if ( ! empty($valid_data) |
|
| 1227 | 1227 | |
| 1228 | 1228 | ) { |
| 1229 | 1229 | $PAY_ID = $valid_data['PAY_ID']; |
@@ -1238,7 +1238,7 @@ discard block |
||
| 1238 | 1238 | $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment); |
| 1239 | 1239 | $this->_remove_existing_registration_payments($payment, $PAY_ID); |
| 1240 | 1240 | // apply payment to registrations (if applicable) |
| 1241 | - if (! empty($REG_IDs)) { |
|
| 1241 | + if ( ! empty($REG_IDs)) { |
|
| 1242 | 1242 | $this->_update_registration_payments($transaction, $payment, $REG_IDs); |
| 1243 | 1243 | $this->_maybe_send_notifications(); |
| 1244 | 1244 | // now process status changes for the same registrations |
@@ -1277,14 +1277,14 @@ discard block |
||
| 1277 | 1277 | */ |
| 1278 | 1278 | protected function _validate_payment_request_data() |
| 1279 | 1279 | { |
| 1280 | - if (! isset($this->_req_data['txn_admin_payment'])) { |
|
| 1280 | + if ( ! isset($this->_req_data['txn_admin_payment'])) { |
|
| 1281 | 1281 | return false; |
| 1282 | 1282 | } |
| 1283 | 1283 | $payment_form = $this->_generate_payment_form_section(); |
| 1284 | 1284 | try { |
| 1285 | 1285 | if ($payment_form->was_submitted()) { |
| 1286 | 1286 | $payment_form->receive_form_submission(); |
| 1287 | - if (! $payment_form->is_valid()) { |
|
| 1287 | + if ( ! $payment_form->is_valid()) { |
|
| 1288 | 1288 | $submission_error_messages = array(); |
| 1289 | 1289 | foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) { |
| 1290 | 1290 | if ($validation_error instanceof EE_Validation_Error) { |
@@ -1449,7 +1449,7 @@ discard block |
||
| 1449 | 1449 | array('Y-m-d', 'g:i a') |
| 1450 | 1450 | ); |
| 1451 | 1451 | |
| 1452 | - if (! $payment->save()) { |
|
| 1452 | + if ( ! $payment->save()) { |
|
| 1453 | 1453 | EE_Error::add_error( |
| 1454 | 1454 | sprintf( |
| 1455 | 1455 | esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'), |
@@ -1499,7 +1499,7 @@ discard block |
||
| 1499 | 1499 | $REG_IDs = array(); |
| 1500 | 1500 | // grab array of IDs for specific registrations to apply changes to |
| 1501 | 1501 | if (isset($this->_req_data['txn_admin_payment']['registrations'])) { |
| 1502 | - $REG_IDs = (array)$this->_req_data['txn_admin_payment']['registrations']; |
|
| 1502 | + $REG_IDs = (array) $this->_req_data['txn_admin_payment']['registrations']; |
|
| 1503 | 1503 | } |
| 1504 | 1504 | //nothing specified ? then get all reg IDs |
| 1505 | 1505 | if (empty($REG_IDs)) { |
@@ -1611,13 +1611,13 @@ discard block |
||
| 1611 | 1611 | // but add in some conditions regarding payment, |
| 1612 | 1612 | // so that we don't apply payments to registrations that are free or have already been paid for |
| 1613 | 1613 | // but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative ) |
| 1614 | - if (! $payment->is_a_refund()) { |
|
| 1614 | + if ( ! $payment->is_a_refund()) { |
|
| 1615 | 1615 | $registration_query_where_params['REG_final_price'] = array('!=', 0); |
| 1616 | 1616 | $registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true); |
| 1617 | 1617 | } |
| 1618 | 1618 | //EEH_Debug_Tools::printr( $registration_query_where_params, '$registration_query_where_params', __FILE__, __LINE__ ); |
| 1619 | 1619 | $registrations = $transaction->registrations(array($registration_query_where_params)); |
| 1620 | - if (! empty($registrations)) { |
|
| 1620 | + if ( ! empty($registrations)) { |
|
| 1621 | 1621 | /** @type EE_Payment_Processor $payment_processor */ |
| 1622 | 1622 | $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
| 1623 | 1623 | $payment_processor->process_registration_payments($transaction, $payment, $registrations); |
@@ -1773,7 +1773,7 @@ discard block |
||
| 1773 | 1773 | { |
| 1774 | 1774 | $registration_payment_data = array(); |
| 1775 | 1775 | //if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows. |
| 1776 | - if (! empty($REG_IDs)) { |
|
| 1776 | + if ( ! empty($REG_IDs)) { |
|
| 1777 | 1777 | $registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs)))); |
| 1778 | 1778 | foreach ($registrations as $registration) { |
| 1779 | 1779 | if ($registration instanceof EE_Registration) { |
@@ -1838,7 +1838,7 @@ discard block |
||
| 1838 | 1838 | */ |
| 1839 | 1839 | protected function _send_payment_reminder() |
| 1840 | 1840 | { |
| 1841 | - $TXN_ID = (! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : false; |
|
| 1841 | + $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : false; |
|
| 1842 | 1842 | $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
| 1843 | 1843 | $query_args = isset($this->_req_data['redirect_to']) ? array( |
| 1844 | 1844 | 'action' => $this->_req_data['redirect_to'], |
@@ -1870,8 +1870,8 @@ discard block |
||
| 1870 | 1870 | $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y'); |
| 1871 | 1871 | |
| 1872 | 1872 | //make sure our timestamps start and end right at the boundaries for each day |
| 1873 | - $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00'; |
|
| 1874 | - $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59'; |
|
| 1873 | + $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00'; |
|
| 1874 | + $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59'; |
|
| 1875 | 1875 | |
| 1876 | 1876 | |
| 1877 | 1877 | //convert to timestamps |
@@ -1924,7 +1924,7 @@ discard block |
||
| 1924 | 1924 | } |
| 1925 | 1925 | |
| 1926 | 1926 | if (isset($this->_req_data['s'])) { |
| 1927 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
| 1927 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
| 1928 | 1928 | $_where['OR'] = array( |
| 1929 | 1929 | 'Registration.Event.EVT_name' => array('LIKE', $search_string), |
| 1930 | 1930 | 'Registration.Event.EVT_desc' => array('LIKE', $search_string), |
@@ -1951,8 +1951,8 @@ discard block |
||
| 1951 | 1951 | } |
| 1952 | 1952 | |
| 1953 | 1953 | //failed transactions |
| 1954 | - $failed = (! empty($this->_req_data['status']) && $this->_req_data['status'] == 'failed' && ! $count) || ($count && $view == 'failed') ? true : false; |
|
| 1955 | - $abandoned = (! empty($this->_req_data['status']) && $this->_req_data['status'] == 'abandoned' && ! $count) || ($count && $view == 'abandoned') ? true : false; |
|
| 1954 | + $failed = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'failed' && ! $count) || ($count && $view == 'failed') ? true : false; |
|
| 1955 | + $abandoned = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'abandoned' && ! $count) || ($count && $view == 'abandoned') ? true : false; |
|
| 1956 | 1956 | |
| 1957 | 1957 | if ($failed) { |
| 1958 | 1958 | $_where['STS_ID'] = EEM_Transaction::failed_status_code; |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $this->_columns = array_merge( $columns, $this->_columns ); |
| 91 | 91 | $this->_primary_column = '_REG_att_checked_in'; |
| 92 | 92 | if ( ! empty( $evt_id ) |
| 93 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 93 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 94 | 94 | 'ee_read_registrations', |
| 95 | 95 | 'espresso_registrations_registrations_reports', |
| 96 | 96 | $evt_id |
@@ -107,44 +107,44 @@ discard block |
||
| 107 | 107 | ), |
| 108 | 108 | ); |
| 109 | 109 | } |
| 110 | - $this->_bottom_buttons['report_filtered'] = array( |
|
| 111 | - 'route' => 'registrations_checkin_report', |
|
| 112 | - 'extra_request' => array( |
|
| 113 | - 'use_filters' => true, |
|
| 114 | - 'filters' => array_merge( |
|
| 115 | - array( |
|
| 116 | - 'EVT_ID' => $evt_id, |
|
| 117 | - ), |
|
| 118 | - array_diff_key( |
|
| 119 | - $this->_req_data, |
|
| 120 | - array_flip( |
|
| 121 | - array( |
|
| 122 | - 'page', |
|
| 123 | - 'action', |
|
| 124 | - 'default_nonce', |
|
| 125 | - ) |
|
| 126 | - ) |
|
| 127 | - ) |
|
| 128 | - ), |
|
| 129 | - 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
| 130 | - ), |
|
| 131 | - ); |
|
| 110 | + $this->_bottom_buttons['report_filtered'] = array( |
|
| 111 | + 'route' => 'registrations_checkin_report', |
|
| 112 | + 'extra_request' => array( |
|
| 113 | + 'use_filters' => true, |
|
| 114 | + 'filters' => array_merge( |
|
| 115 | + array( |
|
| 116 | + 'EVT_ID' => $evt_id, |
|
| 117 | + ), |
|
| 118 | + array_diff_key( |
|
| 119 | + $this->_req_data, |
|
| 120 | + array_flip( |
|
| 121 | + array( |
|
| 122 | + 'page', |
|
| 123 | + 'action', |
|
| 124 | + 'default_nonce', |
|
| 125 | + ) |
|
| 126 | + ) |
|
| 127 | + ) |
|
| 128 | + ), |
|
| 129 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
| 130 | + ), |
|
| 131 | + ); |
|
| 132 | 132 | $this->_sortable_columns = array( |
| 133 | - /** |
|
| 134 | - * Allows users to change the default sort if they wish. |
|
| 135 | - * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
|
| 136 | - * |
|
| 137 | - * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to |
|
| 138 | - * change the sorts on any list table involving registration contacts. If you want to only change the filter |
|
| 139 | - * for a specific list table you can use the provided reference to this object instance. |
|
| 140 | - */ |
|
| 133 | + /** |
|
| 134 | + * Allows users to change the default sort if they wish. |
|
| 135 | + * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
|
| 136 | + * |
|
| 137 | + * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to |
|
| 138 | + * change the sorts on any list table involving registration contacts. If you want to only change the filter |
|
| 139 | + * for a specific list table you can use the provided reference to this object instance. |
|
| 140 | + */ |
|
| 141 | 141 | 'ATT_name' => array( |
| 142 | - 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
| 143 | - true, |
|
| 144 | - $this |
|
| 145 | - ) |
|
| 146 | - ? array( 'ATT_lname' => true ) |
|
| 147 | - : array( 'ATT_fname' => true ), |
|
| 142 | + 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
| 143 | + true, |
|
| 144 | + $this |
|
| 145 | + ) |
|
| 146 | + ? array( 'ATT_lname' => true ) |
|
| 147 | + : array( 'ATT_fname' => true ), |
|
| 148 | 148 | 'Event' => array( 'Event.EVT.Name' => false ), |
| 149 | 149 | ); |
| 150 | 150 | $this->_hidden_columns = array(); |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | if ( ! $evt->get_count_of_all_registrations() ) { |
| 204 | 204 | continue; |
| 205 | 205 | } |
| 206 | - $evts[] = array( |
|
| 206 | + $evts[] = array( |
|
| 207 | 207 | 'id' => $evt->ID(), |
| 208 | 208 | 'text' => apply_filters('FHEE__EE_Event_Registrations___get_table_filters__event_name', $evt->get( 'EVT_name' ), $evt), |
| 209 | 209 | 'class' => $evt->is_expired() ? 'ee-expired-event' : '', |
@@ -227,8 +227,8 @@ discard block |
||
| 227 | 227 | if ( count( $this->_dtts_for_event ) > 1 ) { |
| 228 | 228 | $dtts[0] = __( 'To toggle check-in status, select a datetime.', 'event_espresso' ); |
| 229 | 229 | foreach ( $this->_dtts_for_event as $dtt ) { |
| 230 | - $datetime_string = $dtt->name(); |
|
| 231 | - $datetime_string = ! empty($datetime_string ) ? ' (' . $datetime_string . ')' : ''; |
|
| 230 | + $datetime_string = $dtt->name(); |
|
| 231 | + $datetime_string = ! empty($datetime_string ) ? ' (' . $datetime_string . ')' : ''; |
|
| 232 | 232 | $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string; |
| 233 | 233 | $dtts[ $dtt->ID() ] = $datetime_string; |
| 234 | 234 | } |
@@ -301,16 +301,16 @@ discard block |
||
| 301 | 301 | |
| 302 | 302 | |
| 303 | 303 | |
| 304 | - /** |
|
| 305 | - * column_REG_att_checked_in |
|
| 306 | - * |
|
| 307 | - * @param EE_Registration $item |
|
| 308 | - * @return string |
|
| 309 | - * @throws EE_Error |
|
| 310 | - * @throws InvalidArgumentException |
|
| 311 | - * @throws InvalidDataTypeException |
|
| 312 | - * @throws InvalidInterfaceException |
|
| 313 | - */ |
|
| 304 | + /** |
|
| 305 | + * column_REG_att_checked_in |
|
| 306 | + * |
|
| 307 | + * @param EE_Registration $item |
|
| 308 | + * @return string |
|
| 309 | + * @throws EE_Error |
|
| 310 | + * @throws InvalidArgumentException |
|
| 311 | + * @throws InvalidDataTypeException |
|
| 312 | + * @throws InvalidInterfaceException |
|
| 313 | + */ |
|
| 314 | 314 | public function column__REG_att_checked_in( EE_Registration $item ) { |
| 315 | 315 | $attendee = $item->attendee(); |
| 316 | 316 | $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
@@ -321,13 +321,13 @@ discard block |
||
| 321 | 321 | $this->_cur_dtt_id = $latest_related_datetime->ID(); |
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | - $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId( |
|
| 325 | - $item, |
|
| 326 | - $this->_cur_dtt_id |
|
| 327 | - ); |
|
| 324 | + $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId( |
|
| 325 | + $item, |
|
| 326 | + $this->_cur_dtt_id |
|
| 327 | + ); |
|
| 328 | 328 | $nonce = wp_create_nonce( 'checkin_nonce' ); |
| 329 | 329 | $toggle_active = ! empty ( $this->_cur_dtt_id ) |
| 330 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 330 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 331 | 331 | 'ee_edit_checkin', |
| 332 | 332 | 'espresso_registrations_toggle_checkin_status', |
| 333 | 333 | $item->ID() |
@@ -336,11 +336,11 @@ discard block |
||
| 336 | 336 | : ''; |
| 337 | 337 | $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
| 338 | 338 | return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"' |
| 339 | - . ' data-_regid="' . $item->ID() . '"' |
|
| 340 | - . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
| 341 | - . ' data-nonce="' . $nonce . '">' |
|
| 342 | - . '</span>' |
|
| 343 | - . $mobile_view_content; |
|
| 339 | + . ' data-_regid="' . $item->ID() . '"' |
|
| 340 | + . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
| 341 | + . ' data-nonce="' . $nonce . '">' |
|
| 342 | + . '</span>' |
|
| 343 | + . $mobile_view_content; |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | |
@@ -365,8 +365,8 @@ discard block |
||
| 365 | 365 | 'espresso_registrations_edit_attendee' |
| 366 | 366 | ) |
| 367 | 367 | ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">' |
| 368 | - . $item->attendee()->full_name() |
|
| 369 | - . '</a>' |
|
| 368 | + . $item->attendee()->full_name() |
|
| 369 | + . '</a>' |
|
| 370 | 370 | : $item->attendee()->full_name(); |
| 371 | 371 | $name_link .= $item->count() === 1 |
| 372 | 372 | ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup> ' |
@@ -401,14 +401,14 @@ discard block |
||
| 401 | 401 | ? $latest_related_datetime->ID() |
| 402 | 402 | : $DTT_ID; |
| 403 | 403 | if ( ! empty( $DTT_ID ) |
| 404 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 404 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 405 | 405 | 'ee_read_checkins', |
| 406 | 406 | 'espresso_registrations_registration_checkins' |
| 407 | 407 | ) |
| 408 | 408 | ) { |
| 409 | 409 | $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce( |
| 410 | 410 | array( 'action' => 'registration_checkins', '_REG_ID' => $item->ID(), 'DTT_ID' => $DTT_ID ), |
| 411 | - REG_ADMIN_URL |
|
| 411 | + REG_ADMIN_URL |
|
| 412 | 412 | ); |
| 413 | 413 | // get the timestamps for this registration's checkins, related to the selected datetime |
| 414 | 414 | $timestamps = $item->get_many_related( 'Checkin', array( array( 'DTT_ID' => $DTT_ID ) ) ); |
@@ -516,15 +516,15 @@ discard block |
||
| 516 | 516 | ) ? ' |
| 517 | 517 | <span class="reg-pad-rght"> |
| 518 | 518 | <a class="status-' |
| 519 | - . $item->transaction()->status_ID() |
|
| 520 | - . '" href="' |
|
| 521 | - . $view_txn_lnk_url |
|
| 522 | - . '" title="' |
|
| 523 | - . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
| 524 | - . '"> |
|
| 519 | + . $item->transaction()->status_ID() |
|
| 520 | + . '" href="' |
|
| 521 | + . $view_txn_lnk_url |
|
| 522 | + . '" title="' |
|
| 523 | + . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
| 524 | + . '"> |
|
| 525 | 525 | ' |
| 526 | - . $item->transaction()->pretty_paid() |
|
| 527 | - . ' |
|
| 526 | + . $item->transaction()->pretty_paid() |
|
| 527 | + . ' |
|
| 528 | 528 | </a> |
| 529 | 529 | <span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
| 530 | 530 | } |
@@ -557,12 +557,12 @@ discard block |
||
| 557 | 557 | 'ee_read_transaction', |
| 558 | 558 | 'espresso_transactions_view_transaction' |
| 559 | 559 | ) ? '<a href="' |
| 560 | - . $view_txn_url |
|
| 561 | - . '" title="' |
|
| 562 | - . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
| 563 | - . '"><span class="reg-pad-rght">' |
|
| 564 | - . $txn_total |
|
| 565 | - . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
| 560 | + . $view_txn_url |
|
| 561 | + . '" title="' |
|
| 562 | + . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
| 563 | + . '"><span class="reg-pad-rght">' |
|
| 564 | + . $txn_total |
|
| 565 | + . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
| 566 | 566 | } else { |
| 567 | 567 | return '<span class="reg-pad-rght"></span>'; |
| 568 | 568 | } |
@@ -45,51 +45,51 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @param \Registrations_Admin_Page $admin_page |
| 47 | 47 | */ |
| 48 | - public function __construct( $admin_page ) { |
|
| 49 | - parent::__construct( $admin_page ); |
|
| 48 | + public function __construct($admin_page) { |
|
| 49 | + parent::__construct($admin_page); |
|
| 50 | 50 | $this->_status = $this->_admin_page->get_registration_status_array(); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | protected function _setup_data() { |
| 56 | - $this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees( $this->_per_page ) |
|
| 57 | - : $this->_admin_page->get_event_attendees( $this->_per_page, false, true ); |
|
| 56 | + $this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees($this->_per_page) |
|
| 57 | + : $this->_admin_page->get_event_attendees($this->_per_page, false, true); |
|
| 58 | 58 | $this->_all_data_count = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees( |
| 59 | 59 | $this->_per_page, |
| 60 | 60 | true |
| 61 | - ) : $this->_admin_page->get_event_attendees( $this->_per_page, true, true ); |
|
| 61 | + ) : $this->_admin_page->get_event_attendees($this->_per_page, true, true); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
| 65 | 65 | |
| 66 | 66 | protected function _set_properties() { |
| 67 | - $evt_id = isset( $this->_req_data['event_id'] ) ? $this->_req_data['event_id'] : null; |
|
| 67 | + $evt_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
| 68 | 68 | $this->_wp_list_args = array( |
| 69 | - 'singular' => __( 'registrant', 'event_espresso' ), |
|
| 70 | - 'plural' => __( 'registrants', 'event_espresso' ), |
|
| 69 | + 'singular' => __('registrant', 'event_espresso'), |
|
| 70 | + 'plural' => __('registrants', 'event_espresso'), |
|
| 71 | 71 | 'ajax' => true, |
| 72 | 72 | 'screen' => $this->_admin_page->get_current_screen()->id, |
| 73 | 73 | ); |
| 74 | 74 | $columns = array(); |
| 75 | 75 | //$columns['_Reg_Status'] = ''; |
| 76 | - if ( ! empty( $evt_id ) ) { |
|
| 76 | + if ( ! empty($evt_id)) { |
|
| 77 | 77 | $columns['cb'] = '<input type="checkbox" />'; //Render a checkbox instead of text |
| 78 | 78 | $this->_has_checkbox_column = true; |
| 79 | 79 | } |
| 80 | 80 | $this->_columns = array( |
| 81 | 81 | '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>', |
| 82 | - 'ATT_name' => __( 'Registrant', 'event_espresso' ), |
|
| 83 | - 'ATT_email' => __( 'Email Address', 'event_espresso' ), |
|
| 84 | - 'Event' => __( 'Event', 'event_espresso' ), |
|
| 85 | - 'PRC_name' => __( 'TKT Option', 'event_espresso' ), |
|
| 86 | - '_REG_final_price' => __( 'Price', 'event_espresso' ), |
|
| 87 | - 'TXN_paid' => __( 'Paid', 'event_espresso' ), |
|
| 88 | - 'TXN_total' => __( 'Total', 'event_espresso' ), |
|
| 82 | + 'ATT_name' => __('Registrant', 'event_espresso'), |
|
| 83 | + 'ATT_email' => __('Email Address', 'event_espresso'), |
|
| 84 | + 'Event' => __('Event', 'event_espresso'), |
|
| 85 | + 'PRC_name' => __('TKT Option', 'event_espresso'), |
|
| 86 | + '_REG_final_price' => __('Price', 'event_espresso'), |
|
| 87 | + 'TXN_paid' => __('Paid', 'event_espresso'), |
|
| 88 | + 'TXN_total' => __('Total', 'event_espresso'), |
|
| 89 | 89 | ); |
| 90 | - $this->_columns = array_merge( $columns, $this->_columns ); |
|
| 90 | + $this->_columns = array_merge($columns, $this->_columns); |
|
| 91 | 91 | $this->_primary_column = '_REG_att_checked_in'; |
| 92 | - if ( ! empty( $evt_id ) |
|
| 92 | + if ( ! empty($evt_id) |
|
| 93 | 93 | && EE_Registry::instance()->CAP->current_user_can( |
| 94 | 94 | 'ee_read_registrations', |
| 95 | 95 | 'espresso_registrations_registrations_reports', |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | 'extra_request' => |
| 103 | 103 | array( |
| 104 | 104 | 'EVT_ID' => $evt_id, |
| 105 | - 'return_url' => urlencode( "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" ), |
|
| 105 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
| 106 | 106 | ), |
| 107 | 107 | ), |
| 108 | 108 | ); |
@@ -143,12 +143,12 @@ discard block |
||
| 143 | 143 | true, |
| 144 | 144 | $this |
| 145 | 145 | ) |
| 146 | - ? array( 'ATT_lname' => true ) |
|
| 147 | - : array( 'ATT_fname' => true ), |
|
| 148 | - 'Event' => array( 'Event.EVT.Name' => false ), |
|
| 146 | + ? array('ATT_lname' => true) |
|
| 147 | + : array('ATT_fname' => true), |
|
| 148 | + 'Event' => array('Event.EVT.Name' => false), |
|
| 149 | 149 | ); |
| 150 | 150 | $this->_hidden_columns = array(); |
| 151 | - $this->_evt = EEM_Event::instance()->get_one_by_ID( $evt_id ); |
|
| 151 | + $this->_evt = EEM_Event::instance()->get_one_by_ID($evt_id); |
|
| 152 | 152 | $this->_dtts_for_event = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : array(); |
| 153 | 153 | } |
| 154 | 154 | |
@@ -158,11 +158,11 @@ discard block |
||
| 158 | 158 | * @param \EE_Registration $item |
| 159 | 159 | * @return string |
| 160 | 160 | */ |
| 161 | - protected function _get_row_class( $item ) { |
|
| 162 | - $class = parent::_get_row_class( $item ); |
|
| 161 | + protected function _get_row_class($item) { |
|
| 162 | + $class = parent::_get_row_class($item); |
|
| 163 | 163 | //add status class |
| 164 | - $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
| 165 | - if ( $this->_has_checkbox_column ) { |
|
| 164 | + $class .= ' ee-status-strip reg-status-'.$item->status_ID(); |
|
| 165 | + if ($this->_has_checkbox_column) { |
|
| 166 | 166 | $class .= ' has-checkbox-column'; |
| 167 | 167 | } |
| 168 | 168 | return $class; |
@@ -176,61 +176,61 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | protected function _get_table_filters() { |
| 178 | 178 | $filters = $where = array(); |
| 179 | - $current_EVT_ID = isset( $this->_req_data['event_id'] ) ? (int) $this->_req_data['event_id'] : 0; |
|
| 180 | - if ( empty( $this->_dtts_for_event ) || count( $this->_dtts_for_event ) === 1 ) { |
|
| 179 | + $current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0; |
|
| 180 | + if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) { |
|
| 181 | 181 | //this means we don't have an event so let's setup a filter dropdown for all the events to select |
| 182 | 182 | //note possible capability restrictions |
| 183 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) { |
|
| 184 | - $where['status**'] = array( '!=', 'private' ); |
|
| 183 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
| 184 | + $where['status**'] = array('!=', 'private'); |
|
| 185 | 185 | } |
| 186 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
| 186 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
| 187 | 187 | $where['EVT_wp_user'] = get_current_user_id(); |
| 188 | 188 | } |
| 189 | 189 | $events = EEM_Event::instance()->get_all( |
| 190 | 190 | array( |
| 191 | 191 | $where, |
| 192 | - 'order_by' => array( 'Datetime.DTT_EVT_start' => 'DESC' ), |
|
| 192 | + 'order_by' => array('Datetime.DTT_EVT_start' => 'DESC'), |
|
| 193 | 193 | ) |
| 194 | 194 | ); |
| 195 | 195 | $evts[] = array( |
| 196 | 196 | 'id' => 0, |
| 197 | - 'text' => __( 'To toggle Check-in status, select an event', 'event_espresso' ), |
|
| 197 | + 'text' => __('To toggle Check-in status, select an event', 'event_espresso'), |
|
| 198 | 198 | ); |
| 199 | 199 | $checked = 'checked'; |
| 200 | 200 | /** @var EE_Event $evt */ |
| 201 | - foreach ( $events as $evt ) { |
|
| 201 | + foreach ($events as $evt) { |
|
| 202 | 202 | //any registrations for this event? |
| 203 | - if ( ! $evt->get_count_of_all_registrations() ) { |
|
| 203 | + if ( ! $evt->get_count_of_all_registrations()) { |
|
| 204 | 204 | continue; |
| 205 | 205 | } |
| 206 | 206 | $evts[] = array( |
| 207 | 207 | 'id' => $evt->ID(), |
| 208 | - 'text' => apply_filters('FHEE__EE_Event_Registrations___get_table_filters__event_name', $evt->get( 'EVT_name' ), $evt), |
|
| 208 | + 'text' => apply_filters('FHEE__EE_Event_Registrations___get_table_filters__event_name', $evt->get('EVT_name'), $evt), |
|
| 209 | 209 | 'class' => $evt->is_expired() ? 'ee-expired-event' : '', |
| 210 | 210 | ); |
| 211 | - if ( $evt->ID() === $current_EVT_ID && $evt->is_expired() ) { |
|
| 211 | + if ($evt->ID() === $current_EVT_ID && $evt->is_expired()) { |
|
| 212 | 212 | $checked = ''; |
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | $event_filter = '<div class="ee-event-filter">'; |
| 216 | - $event_filter .= EEH_Form_Fields::select_input( 'event_id', $evts, $current_EVT_ID ); |
|
| 216 | + $event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID); |
|
| 217 | 217 | $event_filter .= '<span class="ee-event-filter-toggle">'; |
| 218 | - $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> '; |
|
| 219 | - $event_filter .= __( 'Hide Expired Events', 'event_espresso' ); |
|
| 218 | + $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" '.$checked.'> '; |
|
| 219 | + $event_filter .= __('Hide Expired Events', 'event_espresso'); |
|
| 220 | 220 | $event_filter .= '</span>'; |
| 221 | 221 | $event_filter .= '</div>'; |
| 222 | 222 | $filters[] = $event_filter; |
| 223 | 223 | } |
| 224 | - if ( ! empty( $this->_dtts_for_event ) ) { |
|
| 224 | + if ( ! empty($this->_dtts_for_event)) { |
|
| 225 | 225 | //DTT datetimes filter |
| 226 | - $this->_cur_dtt_id = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : 0; |
|
| 227 | - if ( count( $this->_dtts_for_event ) > 1 ) { |
|
| 228 | - $dtts[0] = __( 'To toggle check-in status, select a datetime.', 'event_espresso' ); |
|
| 229 | - foreach ( $this->_dtts_for_event as $dtt ) { |
|
| 226 | + $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0; |
|
| 227 | + if (count($this->_dtts_for_event) > 1) { |
|
| 228 | + $dtts[0] = __('To toggle check-in status, select a datetime.', 'event_espresso'); |
|
| 229 | + foreach ($this->_dtts_for_event as $dtt) { |
|
| 230 | 230 | $datetime_string = $dtt->name(); |
| 231 | - $datetime_string = ! empty($datetime_string ) ? ' (' . $datetime_string . ')' : ''; |
|
| 232 | - $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string; |
|
| 233 | - $dtts[ $dtt->ID() ] = $datetime_string; |
|
| 231 | + $datetime_string = ! empty($datetime_string) ? ' ('.$datetime_string.')' : ''; |
|
| 232 | + $datetime_string = $dtt->start_date_and_time().' - '.$dtt->end_date_and_time().$datetime_string; |
|
| 233 | + $dtts[$dtt->ID()] = $datetime_string; |
|
| 234 | 234 | } |
| 235 | 235 | $input = new EE_Select_Input( |
| 236 | 236 | $dtts, |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | ) |
| 242 | 242 | ); |
| 243 | 243 | $filters[] = $input->get_html_for_input(); |
| 244 | - $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">'; |
|
| 244 | + $filters[] = '<input type="hidden" name="event_id" value="'.$current_EVT_ID.'">'; |
|
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | return $filters; |
@@ -260,22 +260,22 @@ discard block |
||
| 260 | 260 | * @throws \EE_Error |
| 261 | 261 | */ |
| 262 | 262 | protected function _get_total_event_attendees() { |
| 263 | - $EVT_ID = isset( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : false; |
|
| 263 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
| 264 | 264 | $DTT_ID = $this->_cur_dtt_id; |
| 265 | 265 | $query_params = array(); |
| 266 | - if ( $EVT_ID ) { |
|
| 266 | + if ($EVT_ID) { |
|
| 267 | 267 | $query_params[0]['EVT_ID'] = $EVT_ID; |
| 268 | 268 | } |
| 269 | 269 | //if DTT is included we only show for that datetime. Otherwise we're showing for all datetimes (the event). |
| 270 | - if ( $DTT_ID ) { |
|
| 270 | + if ($DTT_ID) { |
|
| 271 | 271 | $query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID; |
| 272 | 272 | } |
| 273 | 273 | $status_ids_array = apply_filters( |
| 274 | 274 | 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
| 275 | - array( EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved ) |
|
| 275 | + array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
| 276 | 276 | ); |
| 277 | - $query_params[0]['STS_ID'] = array( 'IN', $status_ids_array ); |
|
| 278 | - return EEM_Registration::instance()->count( $query_params ); |
|
| 277 | + $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
| 278 | + return EEM_Registration::instance()->count($query_params); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | |
@@ -284,8 +284,8 @@ discard block |
||
| 284 | 284 | * @param \EE_Registration $item |
| 285 | 285 | * @return string |
| 286 | 286 | */ |
| 287 | - public function column__Reg_Status( EE_Registration $item ) { |
|
| 288 | - return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>'; |
|
| 287 | + public function column__Reg_Status(EE_Registration $item) { |
|
| 288 | + return '<span class="ee-status-strip ee-status-strip-td reg-status-'.$item->status_ID().'"></span>'; |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | |
@@ -295,8 +295,8 @@ discard block |
||
| 295 | 295 | * @return string |
| 296 | 296 | * @throws \EE_Error |
| 297 | 297 | */ |
| 298 | - public function column_cb( $item ) { |
|
| 299 | - return sprintf( '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID() ); |
|
| 298 | + public function column_cb($item) { |
|
| 299 | + return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID()); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | |
@@ -311,13 +311,13 @@ discard block |
||
| 311 | 311 | * @throws InvalidDataTypeException |
| 312 | 312 | * @throws InvalidInterfaceException |
| 313 | 313 | */ |
| 314 | - public function column__REG_att_checked_in( EE_Registration $item ) { |
|
| 314 | + public function column__REG_att_checked_in(EE_Registration $item) { |
|
| 315 | 315 | $attendee = $item->attendee(); |
| 316 | 316 | $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
| 317 | 317 | |
| 318 | - if ( $this->_cur_dtt_id === 0 && count( $this->_dtts_for_event ) === 1 ) { |
|
| 318 | + if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) { |
|
| 319 | 319 | $latest_related_datetime = $item->get_latest_related_datetime(); |
| 320 | - if ( $latest_related_datetime instanceof EE_Datetime ) { |
|
| 320 | + if ($latest_related_datetime instanceof EE_Datetime) { |
|
| 321 | 321 | $this->_cur_dtt_id = $latest_related_datetime->ID(); |
| 322 | 322 | } |
| 323 | 323 | } |
@@ -325,8 +325,8 @@ discard block |
||
| 325 | 325 | $item, |
| 326 | 326 | $this->_cur_dtt_id |
| 327 | 327 | ); |
| 328 | - $nonce = wp_create_nonce( 'checkin_nonce' ); |
|
| 329 | - $toggle_active = ! empty ( $this->_cur_dtt_id ) |
|
| 328 | + $nonce = wp_create_nonce('checkin_nonce'); |
|
| 329 | + $toggle_active = ! empty ($this->_cur_dtt_id) |
|
| 330 | 330 | && EE_Registry::instance()->CAP->current_user_can( |
| 331 | 331 | 'ee_edit_checkin', |
| 332 | 332 | 'espresso_registrations_toggle_checkin_status', |
@@ -334,11 +334,11 @@ discard block |
||
| 334 | 334 | ) |
| 335 | 335 | ? ' clickable trigger-checkin' |
| 336 | 336 | : ''; |
| 337 | - $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
|
| 338 | - return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"' |
|
| 339 | - . ' data-_regid="' . $item->ID() . '"' |
|
| 340 | - . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
| 341 | - . ' data-nonce="' . $nonce . '">' |
|
| 337 | + $mobile_view_content = ' <span class="show-on-mobile-view-only">'.$attendee_name.'</span>'; |
|
| 338 | + return '<span class="'.$checkin_status_dashicon->cssClasses().$toggle_active.'"' |
|
| 339 | + . ' data-_regid="'.$item->ID().'"' |
|
| 340 | + . ' data-dttid="'.$this->_cur_dtt_id.'"' |
|
| 341 | + . ' data-nonce="'.$nonce.'">' |
|
| 342 | 342 | . '</span>' |
| 343 | 343 | . $mobile_view_content; |
| 344 | 344 | } |
@@ -350,21 +350,21 @@ discard block |
||
| 350 | 350 | * @return mixed|string|void |
| 351 | 351 | * @throws \EE_Error |
| 352 | 352 | */ |
| 353 | - public function column_ATT_name( EE_Registration $item ) { |
|
| 353 | + public function column_ATT_name(EE_Registration $item) { |
|
| 354 | 354 | $attendee = $item->attendee(); |
| 355 | - if ( ! $attendee instanceof EE_Attendee ) { |
|
| 356 | - return __( 'No contact record for this registration.', 'event_espresso' ); |
|
| 355 | + if ( ! $attendee instanceof EE_Attendee) { |
|
| 356 | + return __('No contact record for this registration.', 'event_espresso'); |
|
| 357 | 357 | } |
| 358 | 358 | // edit attendee link |
| 359 | 359 | $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
| 360 | - array( 'action' => 'view_registration', '_REG_ID' => $item->ID() ), |
|
| 360 | + array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
|
| 361 | 361 | REG_ADMIN_URL |
| 362 | 362 | ); |
| 363 | 363 | $name_link = EE_Registry::instance()->CAP->current_user_can( |
| 364 | 364 | 'ee_edit_contacts', |
| 365 | 365 | 'espresso_registrations_edit_attendee' |
| 366 | 366 | ) |
| 367 | - ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">' |
|
| 367 | + ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">' |
|
| 368 | 368 | . $item->attendee()->full_name() |
| 369 | 369 | . '</a>' |
| 370 | 370 | : $item->attendee()->full_name(); |
@@ -372,10 +372,10 @@ discard block |
||
| 372 | 372 | ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup> ' |
| 373 | 373 | : ''; |
| 374 | 374 | //add group details |
| 375 | - $name_link .= ' ' . sprintf( __( '(%s of %s)', 'event_espresso' ), $item->count(), $item->group_size() ); |
|
| 375 | + $name_link .= ' '.sprintf(__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 376 | 376 | //add regcode |
| 377 | 377 | $link = EE_Admin_Page::add_query_args_and_nonce( |
| 378 | - array( 'action' => 'view_registration', '_REG_ID' => $item->ID() ), |
|
| 378 | + array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
|
| 379 | 379 | REG_ADMIN_URL |
| 380 | 380 | ); |
| 381 | 381 | $name_link .= '<br>'; |
@@ -384,51 +384,51 @@ discard block |
||
| 384 | 384 | 'view_registration', |
| 385 | 385 | $item->ID() |
| 386 | 386 | ) |
| 387 | - ? '<a href="' . $link . '" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">' |
|
| 387 | + ? '<a href="'.$link.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">' |
|
| 388 | 388 | . $item->reg_code() |
| 389 | 389 | . '</a>' |
| 390 | 390 | : $item->reg_code(); |
| 391 | 391 | //status |
| 392 | 392 | $name_link .= '<br><span class="ee-status-text-small">'; |
| 393 | - $name_link .= EEH_Template::pretty_status( $item->status_ID(), false, 'sentence' ); |
|
| 393 | + $name_link .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence'); |
|
| 394 | 394 | $name_link .= '</span>'; |
| 395 | 395 | $actions = array(); |
| 396 | 396 | $DTT_ID = $this->_cur_dtt_id; |
| 397 | - $latest_related_datetime = empty( $DTT_ID ) && ! empty( $this->_req_data['event_id'] ) && $item instanceof EE_Registration |
|
| 397 | + $latest_related_datetime = empty($DTT_ID) && ! empty($this->_req_data['event_id']) && $item instanceof EE_Registration |
|
| 398 | 398 | ? $item->get_latest_related_datetime() |
| 399 | 399 | : null; |
| 400 | 400 | $DTT_ID = $latest_related_datetime instanceof EE_Datetime |
| 401 | 401 | ? $latest_related_datetime->ID() |
| 402 | 402 | : $DTT_ID; |
| 403 | - if ( ! empty( $DTT_ID ) |
|
| 403 | + if ( ! empty($DTT_ID) |
|
| 404 | 404 | && EE_Registry::instance()->CAP->current_user_can( |
| 405 | 405 | 'ee_read_checkins', |
| 406 | 406 | 'espresso_registrations_registration_checkins' |
| 407 | 407 | ) |
| 408 | 408 | ) { |
| 409 | 409 | $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce( |
| 410 | - array( 'action' => 'registration_checkins', '_REG_ID' => $item->ID(), 'DTT_ID' => $DTT_ID ), |
|
| 410 | + array('action' => 'registration_checkins', '_REG_ID' => $item->ID(), 'DTT_ID' => $DTT_ID), |
|
| 411 | 411 | REG_ADMIN_URL |
| 412 | 412 | ); |
| 413 | 413 | // get the timestamps for this registration's checkins, related to the selected datetime |
| 414 | - $timestamps = $item->get_many_related( 'Checkin', array( array( 'DTT_ID' => $DTT_ID ) ) ); |
|
| 415 | - if( ! empty( $timestamps ) ) { |
|
| 414 | + $timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID))); |
|
| 415 | + if ( ! empty($timestamps)) { |
|
| 416 | 416 | // get the last timestamp |
| 417 | - $last_timestamp = end( $timestamps ); |
|
| 417 | + $last_timestamp = end($timestamps); |
|
| 418 | 418 | // checked in or checked out? |
| 419 | - $checkin_status = $last_timestamp->get( 'CHK_in' ) |
|
| 420 | - ? esc_html__( 'Checked In', 'event_espresso' ) |
|
| 421 | - : esc_html__( 'Checked Out', 'event_espresso' ); |
|
| 419 | + $checkin_status = $last_timestamp->get('CHK_in') |
|
| 420 | + ? esc_html__('Checked In', 'event_espresso') |
|
| 421 | + : esc_html__('Checked Out', 'event_espresso'); |
|
| 422 | 422 | // get timestamp string |
| 423 | - $timestamp_string = $last_timestamp->get_datetime( 'CHK_timestamp' ); |
|
| 424 | - $actions['checkin'] = '<a href="' . $checkin_list_url . '" title="' . esc_attr__( |
|
| 423 | + $timestamp_string = $last_timestamp->get_datetime('CHK_timestamp'); |
|
| 424 | + $actions['checkin'] = '<a href="'.$checkin_list_url.'" title="'.esc_attr__( |
|
| 425 | 425 | 'View this registrant\'s check-ins/checkouts for the datetime', |
| 426 | 426 | 'event_espresso' |
| 427 | - ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>'; |
|
| 427 | + ).'">'.$checkin_status.': '.$timestamp_string.'</a>'; |
|
| 428 | 428 | } |
| 429 | 429 | } |
| 430 | - return ( ! empty( $DTT_ID ) && ! empty( $timestamps ) ) |
|
| 431 | - ? sprintf( '%1$s %2$s', $name_link, $this->row_actions( $actions, true ) ) |
|
| 430 | + return ( ! empty($DTT_ID) && ! empty($timestamps)) |
|
| 431 | + ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true)) |
|
| 432 | 432 | : $name_link; |
| 433 | 433 | } |
| 434 | 434 | |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | * @param \EE_Registration $item |
| 439 | 439 | * @return string |
| 440 | 440 | */ |
| 441 | - public function column_ATT_email( EE_Registration $item ) { |
|
| 441 | + public function column_ATT_email(EE_Registration $item) { |
|
| 442 | 442 | $attendee = $item->attendee(); |
| 443 | 443 | return $attendee instanceof EE_Attendee ? $attendee->email() : ''; |
| 444 | 444 | } |
@@ -450,22 +450,22 @@ discard block |
||
| 450 | 450 | * @return bool|string |
| 451 | 451 | * @throws \EE_Error |
| 452 | 452 | */ |
| 453 | - public function column_Event( EE_Registration $item ) { |
|
| 453 | + public function column_Event(EE_Registration $item) { |
|
| 454 | 454 | try { |
| 455 | 455 | $event = $this->_evt instanceof EE_Event ? $this->_evt : $item->event(); |
| 456 | 456 | $chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
| 457 | - array( 'action' => 'event_registrations', 'event_id' => $event->ID() ), |
|
| 457 | + array('action' => 'event_registrations', 'event_id' => $event->ID()), |
|
| 458 | 458 | REG_ADMIN_URL |
| 459 | 459 | ); |
| 460 | 460 | $event_label = EE_Registry::instance()->CAP->current_user_can( |
| 461 | 461 | 'ee_read_checkins', |
| 462 | 462 | 'espresso_registrations_registration_checkins' |
| 463 | - ) ? '<a href="' . $chkin_lnk_url . '" title="' . esc_attr__( |
|
| 463 | + ) ? '<a href="'.$chkin_lnk_url.'" title="'.esc_attr__( |
|
| 464 | 464 | 'View Checkins for this Event', |
| 465 | 465 | 'event_espresso' |
| 466 | - ) . '">' . $event->name() . '</a>' : $event->name(); |
|
| 467 | - } catch ( \EventEspresso\core\exceptions\EntityNotFoundException $e ) { |
|
| 468 | - $event_label = esc_html__( 'Unknown', 'event_espresso' ); |
|
| 466 | + ).'">'.$event->name().'</a>' : $event->name(); |
|
| 467 | + } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) { |
|
| 468 | + $event_label = esc_html__('Unknown', 'event_espresso'); |
|
| 469 | 469 | } |
| 470 | 470 | return $event_label; |
| 471 | 471 | } |
@@ -476,8 +476,8 @@ discard block |
||
| 476 | 476 | * @param \EE_Registration $item |
| 477 | 477 | * @return mixed|string|void |
| 478 | 478 | */ |
| 479 | - public function column_PRC_name( EE_Registration $item ) { |
|
| 480 | - return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : __( "Unknown", "event_espresso" ); |
|
| 479 | + public function column_PRC_name(EE_Registration $item) { |
|
| 480 | + return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : __("Unknown", "event_espresso"); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | |
@@ -488,8 +488,8 @@ discard block |
||
| 488 | 488 | * @param \EE_Registration $item |
| 489 | 489 | * @return string |
| 490 | 490 | */ |
| 491 | - public function column__REG_final_price( EE_Registration $item ) { |
|
| 492 | - return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>'; |
|
| 491 | + public function column__REG_final_price(EE_Registration $item) { |
|
| 492 | + return '<span class="reg-pad-rght">'.' '.$item->pretty_final_price().'</span>'; |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | |
@@ -501,13 +501,13 @@ discard block |
||
| 501 | 501 | * @return string |
| 502 | 502 | * @throws \EE_Error |
| 503 | 503 | */ |
| 504 | - public function column_TXN_paid( EE_Registration $item ) { |
|
| 505 | - if ( $item->count() === 1 ) { |
|
| 506 | - if ( $item->transaction()->paid() >= $item->transaction()->total() ) { |
|
| 504 | + public function column_TXN_paid(EE_Registration $item) { |
|
| 505 | + if ($item->count() === 1) { |
|
| 506 | + if ($item->transaction()->paid() >= $item->transaction()->total()) { |
|
| 507 | 507 | return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
| 508 | 508 | } else { |
| 509 | 509 | $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
| 510 | - array( 'action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID() ), |
|
| 510 | + array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()), |
|
| 511 | 511 | TXN_ADMIN_URL |
| 512 | 512 | ); |
| 513 | 513 | return EE_Registry::instance()->CAP->current_user_can( |
@@ -520,13 +520,13 @@ discard block |
||
| 520 | 520 | . '" href="' |
| 521 | 521 | . $view_txn_lnk_url |
| 522 | 522 | . '" title="' |
| 523 | - . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
| 523 | + . esc_attr__('View Transaction', 'event_espresso') |
|
| 524 | 524 | . '"> |
| 525 | 525 | ' |
| 526 | 526 | . $item->transaction()->pretty_paid() |
| 527 | 527 | . ' |
| 528 | 528 | </a> |
| 529 | - <span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
|
| 529 | + <span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>'; |
|
| 530 | 530 | } |
| 531 | 531 | } else { |
| 532 | 532 | return '<span class="reg-pad-rght"></span>'; |
@@ -542,13 +542,13 @@ discard block |
||
| 542 | 542 | * @return string |
| 543 | 543 | * @throws \EE_Error |
| 544 | 544 | */ |
| 545 | - public function column_TXN_total( EE_Registration $item ) { |
|
| 545 | + public function column_TXN_total(EE_Registration $item) { |
|
| 546 | 546 | $txn = $item->transaction(); |
| 547 | - $view_txn_url = add_query_arg( array( 'action' => 'view_transaction', 'TXN_ID' => $txn->ID() ), TXN_ADMIN_URL ); |
|
| 548 | - if ( $item->get( 'REG_count' ) === 1 ) { |
|
| 547 | + $view_txn_url = add_query_arg(array('action' => 'view_transaction', 'TXN_ID' => $txn->ID()), TXN_ADMIN_URL); |
|
| 548 | + if ($item->get('REG_count') === 1) { |
|
| 549 | 549 | $line_total_obj = $txn->total_line_item(); |
| 550 | 550 | $txn_total = $line_total_obj instanceof EE_Line_Item |
| 551 | - ? $line_total_obj->get_pretty( 'LIN_total' ) |
|
| 551 | + ? $line_total_obj->get_pretty('LIN_total') |
|
| 552 | 552 | : __( |
| 553 | 553 | 'View Transaction', |
| 554 | 554 | 'event_espresso' |
@@ -559,10 +559,10 @@ discard block |
||
| 559 | 559 | ) ? '<a href="' |
| 560 | 560 | . $view_txn_url |
| 561 | 561 | . '" title="' |
| 562 | - . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
| 562 | + . esc_attr__('View Transaction', 'event_espresso') |
|
| 563 | 563 | . '"><span class="reg-pad-rght">' |
| 564 | 564 | . $txn_total |
| 565 | - . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
| 565 | + . '</span></a>' : '<span class="reg-pad-rght">'.$txn_total.'</span>'; |
|
| 566 | 566 | } else { |
| 567 | 567 | return '<span class="reg-pad-rght"></span>'; |
| 568 | 568 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | |
| 33 | - public function __construct( $admin_page ) { |
|
| 33 | + public function __construct($admin_page) { |
|
| 34 | 34 | parent::__construct($admin_page); |
| 35 | 35 | } |
| 36 | 36 | |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | protected function _setup_data() { |
| 41 | - $this->_data = $this->_get_checkins( $this->_per_page ); |
|
| 42 | - $this->_all_data_count = $this->_get_checkins( $this->_per_page, TRUE ); |
|
| 41 | + $this->_data = $this->_get_checkins($this->_per_page); |
|
| 42 | + $this->_all_data_count = $this->_get_checkins($this->_per_page, TRUE); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | ); |
| 61 | 61 | |
| 62 | 62 | $this->_sortable_columns = array( |
| 63 | - 'CHK_timestamp' => array( 'CHK_timestamp' => TRUE ) |
|
| 63 | + 'CHK_timestamp' => array('CHK_timestamp' => TRUE) |
|
| 64 | 64 | ); |
| 65 | 65 | |
| 66 | 66 | $this->_primary_column = 'CHK_in'; |
@@ -84,24 +84,24 @@ discard block |
||
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | |
| 87 | - function column_cb($item ) { |
|
| 88 | - return sprintf( '<input type="checkbox" name="checkbox[%1$s]" />', $item->ID() ); |
|
| 87 | + function column_cb($item) { |
|
| 88 | + return sprintf('<input type="checkbox" name="checkbox[%1$s]" />', $item->ID()); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | |
| 92 | - public function column_CHK_in( EE_Checkin $item ) { |
|
| 92 | + public function column_CHK_in(EE_Checkin $item) { |
|
| 93 | 93 | $checkin_status_dashicon = CheckinStatusDashicon::fromCheckin($item); |
| 94 | - return '<span class="' . $checkin_status_dashicon->cssClasses() . '"></span><span class="show-on-mobile-view-only">' . $item->get_datetime('CHK_timestamp') . '</span>'; |
|
| 94 | + return '<span class="'.$checkin_status_dashicon->cssClasses().'"></span><span class="show-on-mobile-view-only">'.$item->get_datetime('CHK_timestamp').'</span>'; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | |
| 98 | 98 | |
| 99 | - function column_CHK_timestamp( EE_Checkin $item ) { |
|
| 99 | + function column_CHK_timestamp(EE_Checkin $item) { |
|
| 100 | 100 | $actions = array(); |
| 101 | - $delete_url = EE_Admin_Page::add_query_args_and_nonce( array('action' => 'delete_checkin_row', 'DTT_ID' => $this->_req_data['DTT_ID'], '_REG_ID' => $this->_req_data['_REG_ID'], 'CHK_ID' => $item->ID() ) ); |
|
| 102 | - $actions['delete_checkin'] = EE_Registry::instance()->CAP->current_user_can( 'ee_delete_checkins', 'espresso_registrations_delete_checkin_row' ) ? '<a href="' . $delete_url . '" title="' . esc_attr__('Click here to delete this check-in record', 'event_espresso') . '">' . __('Delete', 'event_espresso') . '</a>' : ''; |
|
| 101 | + $delete_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'delete_checkin_row', 'DTT_ID' => $this->_req_data['DTT_ID'], '_REG_ID' => $this->_req_data['_REG_ID'], 'CHK_ID' => $item->ID())); |
|
| 102 | + $actions['delete_checkin'] = EE_Registry::instance()->CAP->current_user_can('ee_delete_checkins', 'espresso_registrations_delete_checkin_row') ? '<a href="'.$delete_url.'" title="'.esc_attr__('Click here to delete this check-in record', 'event_espresso').'">'.__('Delete', 'event_espresso').'</a>' : ''; |
|
| 103 | 103 | |
| 104 | - return sprintf( '%1$s %2$s', $item->get_datetime('CHK_timestamp'), $this->row_actions($actions) ); |
|
| 104 | + return sprintf('%1$s %2$s', $item->get_datetime('CHK_timestamp'), $this->row_actions($actions)); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | |
@@ -116,30 +116,30 @@ discard block |
||
| 116 | 116 | * @param bool $count Whether to return a count or not |
| 117 | 117 | * @return EE_Checkin[]|int |
| 118 | 118 | */ |
| 119 | - protected function _get_checkins( $per_page = 10, $count = FALSE ) { |
|
| 120 | - $REG_ID = isset( $this->_req_data['_REG_ID'] ) ? $this->_req_data['_REG_ID'] : FALSE; |
|
| 121 | - $DTT_ID = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : FALSE; |
|
| 119 | + protected function _get_checkins($per_page = 10, $count = FALSE) { |
|
| 120 | + $REG_ID = isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : FALSE; |
|
| 121 | + $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : FALSE; |
|
| 122 | 122 | |
| 123 | 123 | //if user does not have the capability for the checkins for this registration then get out! |
| 124 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_checkin', 'espresso_registrations_registration_checkins', $REG_ID ) ) { |
|
| 124 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_checkin', 'espresso_registrations_registration_checkins', $REG_ID)) { |
|
| 125 | 125 | return $count ? 0 : array(); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | //if no reg id then get out cause need a reg id |
| 129 | - if ( empty( $REG_ID ) || empty( $DTT_ID ) ) |
|
| 130 | - throw new EE_Error(__('This route cannot be viewed unless registration and datetime IDs are included in the request (via REG_ID and DTT_ID parameters)', 'event_espresso') ); |
|
| 129 | + if (empty($REG_ID) || empty($DTT_ID)) |
|
| 130 | + throw new EE_Error(__('This route cannot be viewed unless registration and datetime IDs are included in the request (via REG_ID and DTT_ID parameters)', 'event_espresso')); |
|
| 131 | 131 | |
| 132 | 132 | //set orderby |
| 133 | 133 | $orderby = 'CHK_timestamp'; //note that with this table we're only providing the option to orderby the timestamp value. |
| 134 | 134 | |
| 135 | - $order = !empty( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'ASC'; |
|
| 135 | + $order = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
| 136 | 136 | |
| 137 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
| 138 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
| 137 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
| 138 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
| 139 | 139 | $limit = NULL; |
| 140 | - if ( !$count ) { |
|
| 141 | - $offset = ($current_page-1)*$per_page; |
|
| 142 | - $limit = array( $offset, $per_page ); |
|
| 140 | + if ( ! $count) { |
|
| 141 | + $offset = ($current_page - 1) * $per_page; |
|
| 142 | + $limit = array($offset, $per_page); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | $_where = array( |
@@ -147,13 +147,13 @@ discard block |
||
| 147 | 147 | 'DTT_ID' => $DTT_ID |
| 148 | 148 | ); |
| 149 | 149 | |
| 150 | - $query_params = array( $_where, 'order_by' => array( $orderby => $order ), 'limit' => $limit ); |
|
| 150 | + $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit); |
|
| 151 | 151 | |
| 152 | 152 | //if no per_page value then we just want to return a count of all Check-ins |
| 153 | - if ( $count ) |
|
| 154 | - return EEM_Checkin::instance()->count( array( $_where ) ); |
|
| 153 | + if ($count) |
|
| 154 | + return EEM_Checkin::instance()->count(array($_where)); |
|
| 155 | 155 | |
| 156 | - return $count ? EEM_Checkin::instance()->count( array( $_where ) ) : EEM_Checkin::instance()->get_all($query_params); |
|
| 156 | + return $count ? EEM_Checkin::instance()->count(array($_where)) : EEM_Checkin::instance()->get_all($query_params); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | } //end class EE_Registration_CheckIn_List_Table |