Completed
Branch Gutenberg/event-attendees-bloc... (011228)
by
unknown
66:29 queued 53:26
created
acceptance_tests/tests/b-TestRegistrationSummaryCept.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
 
15 15
 //need the MER plugin active for this test (we'll deactivate it after).
16 16
 $I->ensurePluginActive(
17
-    'event-espresso-mer-multi-event-registration',
18
-    'activated'
17
+	'event-espresso-mer-multi-event-registration',
18
+	'activated'
19 19
 );
20 20
 
21 21
 //k now we need to make sure the registration multi-status message type is active because it isn't by default
@@ -73,38 +73,38 @@  discard block
 block discarded – undo
73 73
 $I->loginAsAdmin();
74 74
 $I->amOnMessagesActivityListTablePage();
75 75
 $I->see(
76
-    '[email protected]',
77
-    MessagesAdmin::messagesActivityListTableCellSelectorFor(
78
-        'to',
79
-        'Registration Multi-status Summary',
80
-        MessagesAdmin::MESSAGE_STATUS_SENT,
81
-        '',
82
-        'Primary Registrant'
83
-    )
76
+	'[email protected]',
77
+	MessagesAdmin::messagesActivityListTableCellSelectorFor(
78
+		'to',
79
+		'Registration Multi-status Summary',
80
+		MessagesAdmin::MESSAGE_STATUS_SENT,
81
+		'',
82
+		'Primary Registrant'
83
+	)
84 84
 );
85 85
 $I->see(
86
-    '[email protected]',
87
-    MessagesAdmin::messagesActivityListTableCellSelectorFor(
88
-        'to',
89
-        'Registration Multi-status Summary',
90
-        MessagesAdmin::MESSAGE_STATUS_SENT
91
-    )
86
+	'[email protected]',
87
+	MessagesAdmin::messagesActivityListTableCellSelectorFor(
88
+		'to',
89
+		'Registration Multi-status Summary',
90
+		MessagesAdmin::MESSAGE_STATUS_SENT
91
+	)
92 92
 );
93 93
 //verify count
94 94
 $I->verifyMatchingCountofTextInMessageActivityListTableFor(
95
-    1,
96
-    '[email protected]',
97
-    'to',
98
-    'Registration Multi-status Summary',
99
-    MessagesAdmin::MESSAGE_STATUS_SENT,
100
-    'Email',
101
-    'Primary Registrant'
95
+	1,
96
+	'[email protected]',
97
+	'to',
98
+	'Registration Multi-status Summary',
99
+	MessagesAdmin::MESSAGE_STATUS_SENT,
100
+	'Email',
101
+	'Primary Registrant'
102 102
 );
103 103
 $I->verifyMatchingCountofTextInMessageActivityListTableFor(
104
-    1,
105
-    '[email protected]',
106
-    'to',
107
-    'Registration Multi-status Summary'
104
+	1,
105
+	'[email protected]',
106
+	'to',
107
+	'Registration Multi-status Summary'
108 108
 );
109 109
 
110 110
 //okay now let's do some registrations for just the first event and verify that registration multi-status summary is NOT
@@ -134,25 +134,25 @@  discard block
 block discarded – undo
134 134
 $I->loginAsAdmin();
135 135
 $I->amOnMessagesActivityListTablePage();
136 136
 $I->dontSee(
137
-    '[email protected]',
138
-    MessagesAdmin::messagesActivityListTableCellSelectorFor(
139
-        'to',
140
-        'Registration Multi-status Summary',
141
-        MessagesAdmin::MESSAGE_STATUS_SENT,
142
-        '',
143
-        'Primary Registrant'
144
-    )
137
+	'[email protected]',
138
+	MessagesAdmin::messagesActivityListTableCellSelectorFor(
139
+		'to',
140
+		'Registration Multi-status Summary',
141
+		MessagesAdmin::MESSAGE_STATUS_SENT,
142
+		'',
143
+		'Primary Registrant'
144
+	)
145 145
 );
146 146
 //there should still only be one admin multi-status summary thing.
147 147
 $I->verifyMatchingCountofTextInMessageActivityListTableFor(
148
-    1,
149
-    '[email protected]',
150
-    'to',
151
-    'Registration Multi-status Summary'
148
+	1,
149
+	'[email protected]',
150
+	'to',
151
+	'Registration Multi-status Summary'
152 152
 );
153 153
 
154 154
 //deactivate MER plugin so its not active for future tests
155 155
 $I->ensurePluginDeactivated(
156
-    'event-espresso-mer-multi-event-registration',
157
-    'plugins deactivated'
156
+	'event-espresso-mer-multi-event-registration',
157
+	'plugins deactivated'
158 158
 );
159 159
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/tests/c-TestCustomMessageTemplateCept.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 $event_one_link = $event_two_link = $event_three_link = '';
19 19
 
20 20
 $I->wantTo(
21
-    'Test that when registrations for multiple events are completed, and those events share the same custom'
22
-    . 'template, that that custom template will be used.'
21
+	'Test that when registrations for multiple events are completed, and those events share the same custom'
22
+	. 'template, that that custom template will be used.'
23 23
 );
24 24
 
25 25
 //need the MER plugin active for this test (we'll deactivate it after).
26 26
 $I->ensurePluginActive(
27
-    'event-espresso-mer-multi-event-registration',
28
-    'activated'
27
+	'event-espresso-mer-multi-event-registration',
28
+	'activated'
29 29
 );
30 30
 
31 31
 $I->loginAsAdmin();
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 
81 81
 
82 82
 $test_registration_details = array(
83
-    'fname' => 'CTGuy',
84
-    'lname' => 'Dude',
85
-    'email' => '[email protected]'
83
+	'fname' => 'CTGuy',
84
+	'lname' => 'Dude',
85
+	'email' => '[email protected]'
86 86
 );
87 87
 
88 88
 $I->amGoingTo('Register for Event One and Event Two and verify Custom Template A was used.');
@@ -108,23 +108,23 @@  discard block
 block discarded – undo
108 108
 $I->loginAsAdmin();
109 109
 $I->amOnMessagesActivityListTablePage();
110 110
 $I->viewMessageInMessagesListTableFor(
111
-    'Registration Approved',
112
-    MessagesAdmin::MESSAGE_STATUS_SENT,
113
-    'Email',
114
-    'Registrant'
111
+	'Registration Approved',
112
+	MessagesAdmin::MESSAGE_STATUS_SENT,
113
+	'Email',
114
+	'Registrant'
115 115
 );
116 116
 $I->seeTextInViewMessageModal($custom_template_a_label);
117 117
 $I->dismissMessageModal();
118 118
 $I->deleteMessageInMessagesListTableFor(
119
-    'Registration Approved',
120
-    MessagesAdmin::MESSAGE_STATUS_SENT,
121
-    'Email',
122
-    'Registrant'
119
+	'Registration Approved',
120
+	MessagesAdmin::MESSAGE_STATUS_SENT,
121
+	'Email',
122
+	'Registrant'
123 123
 );
124 124
 
125 125
 //verify admin context
126 126
 $I->viewMessageInMessagesListTableFor(
127
-    'Registration Approved'
127
+	'Registration Approved'
128 128
 );
129 129
 $I->seeTextInViewMessageModal($custom_template_a_label);
130 130
 $I->dismissMessageModal();
@@ -153,25 +153,25 @@  discard block
 block discarded – undo
153 153
 $I->loginAsAdmin();
154 154
 $I->amOnMessagesActivityListTablePage();
155 155
 $I->viewMessageInMessagesListTableFor(
156
-    'Registration Approved',
157
-    MessagesAdmin::MESSAGE_STATUS_SENT,
158
-    'Email',
159
-    'Registrant'
156
+	'Registration Approved',
157
+	MessagesAdmin::MESSAGE_STATUS_SENT,
158
+	'Email',
159
+	'Registrant'
160 160
 );
161 161
 $I->waitForElementVisible(MessagesAdmin::MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR);
162 162
 $I->dontSeeTextInViewMessageModal($custom_template_a_label);
163 163
 $I->dontSeeTextInViewMessageModal($custom_template_b_label);
164 164
 $I->dismissMessageModal();
165 165
 $I->deleteMessageInMessagesListTableFor(
166
-    'Registration Approved',
167
-    MessagesAdmin::MESSAGE_STATUS_SENT,
168
-    'Email',
169
-    'Registrant'
166
+	'Registration Approved',
167
+	MessagesAdmin::MESSAGE_STATUS_SENT,
168
+	'Email',
169
+	'Registrant'
170 170
 );
171 171
 
172 172
 //verify admin context
173 173
 $I->viewMessageInMessagesListTableFor(
174
-    'Registration Approved'
174
+	'Registration Approved'
175 175
 );
176 176
 $I->waitForElementVisible(MessagesAdmin::MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR);
177 177
 $I->dontSee($custom_template_a_label);
@@ -183,6 +183,6 @@  discard block
 block discarded – undo
183 183
 
184 184
 //deactivate MER plugin so its not active for future tests
185 185
 $I->ensurePluginDeactivated(
186
-    'event-espresso-mer-multi-event-registration',
187
-    'plugins deactivated'
186
+	'event-espresso-mer-multi-event-registration',
187
+	'plugins deactivated'
188 188
 );
189 189
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Helpers/RegistrationsAdmin.php 1 patch
Indentation   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -15,139 +15,139 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
acceptance_tests/Helpers/Checkout.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -13,75 +13,75 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
acceptance_tests/Page/TicketSelector.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -12,27 +12,27 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
acceptance_tests/Page/RegistrationsAdmin.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -12,47 +12,47 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
acceptance_tests/Page/Checkout.php 1 patch
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -13,71 +13,71 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
admin_pages/transactions/Transactions_Admin_Page.core.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -2166,6 +2166,7 @@
 block discarded – undo
2166 2166
      *
2167 2167
      * @access protected
2168 2168
      * @param \EE_Payment | null $payment
2169
+     * @param EE_Payment $payment
2169 2170
      */
2170 2171
     protected function _maybe_send_notifications($payment = null)
2171 2172
     {
Please login to merge, or discard this patch.
Indentation   +2456 added lines, -2456 removed lines patch added patch discarded remove patch
@@ -14,2460 +14,2460 @@
 block discarded – undo
14 14
 class Transactions_Admin_Page extends EE_Admin_Page
15 15
 {
16 16
 
17
-    /**
18
-     * @var EE_Transaction
19
-     */
20
-    private $_transaction;
21
-
22
-    /**
23
-     * @var EE_Session
24
-     */
25
-    private $_session;
26
-
27
-    /**
28
-     * @var array $_txn_status
29
-     */
30
-    private static $_txn_status;
31
-
32
-    /**
33
-     * @var array $_pay_status
34
-     */
35
-    private static $_pay_status;
36
-
37
-    /**
38
-     * @var array $_existing_reg_payment_REG_IDs
39
-     */
40
-    protected $_existing_reg_payment_REG_IDs = null;
41
-
42
-
43
-    /**
44
-     * @Constructor
45
-     * @access public
46
-     * @param bool $routing
47
-     * @throws EE_Error
48
-     * @throws InvalidArgumentException
49
-     * @throws ReflectionException
50
-     * @throws InvalidDataTypeException
51
-     * @throws InvalidInterfaceException
52
-     */
53
-    public function __construct($routing = true)
54
-    {
55
-        parent::__construct($routing);
56
-    }
57
-
58
-
59
-    /**
60
-     *    _init_page_props
61
-     *
62
-     * @return void
63
-     */
64
-    protected function _init_page_props()
65
-    {
66
-        $this->page_slug = TXN_PG_SLUG;
67
-        $this->page_label = esc_html__('Transactions', 'event_espresso');
68
-        $this->_admin_base_url = TXN_ADMIN_URL;
69
-        $this->_admin_base_path = TXN_ADMIN;
70
-    }
71
-
72
-
73
-    /**
74
-     *    _ajax_hooks
75
-     *
76
-     * @return void
77
-     */
78
-    protected function _ajax_hooks()
79
-    {
80
-        add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds'));
81
-        add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds'));
82
-        add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment'));
83
-    }
84
-
85
-
86
-    /**
87
-     *    _define_page_props
88
-     *
89
-     * @return void
90
-     */
91
-    protected function _define_page_props()
92
-    {
93
-        $this->_admin_page_title = $this->page_label;
94
-        $this->_labels = array(
95
-            'buttons' => array(
96
-                'add'    => esc_html__('Add New Transaction', 'event_espresso'),
97
-                'edit'   => esc_html__('Edit Transaction', 'event_espresso'),
98
-                'delete' => esc_html__('Delete Transaction', 'event_espresso'),
99
-            ),
100
-        );
101
-    }
102
-
103
-
104
-    /**
105
-     *        grab url requests and route them
106
-     *
107
-     * @access private
108
-     * @return void
109
-     * @throws EE_Error
110
-     * @throws InvalidArgumentException
111
-     * @throws InvalidDataTypeException
112
-     * @throws InvalidInterfaceException
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'])
120
-                  && ! is_array($this->_req_data['TXN_ID'])
121
-            ? $this->_req_data['TXN_ID']
122
-            : 0;
123
-
124
-        $this->_page_routes = array(
125
-
126
-            'default' => array(
127
-                'func'       => '_transactions_overview_list_table',
128
-                'capability' => 'ee_read_transactions',
129
-            ),
130
-
131
-            'view_transaction' => array(
132
-                'func'       => '_transaction_details',
133
-                'capability' => 'ee_read_transaction',
134
-                'obj_id'     => $txn_id,
135
-            ),
136
-
137
-            'send_payment_reminder' => array(
138
-                'func'       => '_send_payment_reminder',
139
-                'noheader'   => true,
140
-                'capability' => 'ee_send_message',
141
-            ),
142
-
143
-            'espresso_apply_payment' => array(
144
-                'func'       => 'apply_payments_or_refunds',
145
-                'noheader'   => true,
146
-                'capability' => 'ee_edit_payments',
147
-            ),
148
-
149
-            'espresso_apply_refund' => array(
150
-                'func'       => 'apply_payments_or_refunds',
151
-                'noheader'   => true,
152
-                'capability' => 'ee_edit_payments',
153
-            ),
154
-
155
-            'espresso_delete_payment' => array(
156
-                'func'       => 'delete_payment',
157
-                'noheader'   => true,
158
-                'capability' => 'ee_delete_payments',
159
-            ),
160
-
161
-        );
162
-    }
163
-
164
-
165
-    protected function _set_page_config()
166
-    {
167
-        $this->_page_config = array(
168
-            'default'          => array(
169
-                'nav'           => array(
170
-                    'label' => esc_html__('Overview', 'event_espresso'),
171
-                    'order' => 10,
172
-                ),
173
-                'list_table'    => 'EE_Admin_Transactions_List_Table',
174
-                'help_tabs'     => array(
175
-                    'transactions_overview_help_tab'                       => array(
176
-                        'title'    => esc_html__('Transactions Overview', 'event_espresso'),
177
-                        'filename' => 'transactions_overview',
178
-                    ),
179
-                    'transactions_overview_table_column_headings_help_tab' => array(
180
-                        'title'    => esc_html__('Transactions Table Column Headings', 'event_espresso'),
181
-                        'filename' => 'transactions_overview_table_column_headings',
182
-                    ),
183
-                    'transactions_overview_views_filters_help_tab'         => array(
184
-                        'title'    => esc_html__('Transaction Views & Filters & Search', 'event_espresso'),
185
-                        'filename' => 'transactions_overview_views_filters_search',
186
-                    ),
187
-                ),
188
-                'help_tour'     => array('Transactions_Overview_Help_Tour'),
189
-                /**
190
-                 * commented out because currently we are not displaying tips for transaction list table status but this
191
-                 * may change in a later iteration so want to keep the code for then.
192
-                 */
193
-                // 'qtips' => array( 'Transactions_List_Table_Tips' ),
194
-                'require_nonce' => false,
195
-            ),
196
-            'view_transaction' => array(
197
-                'nav'       => array(
198
-                    'label'      => esc_html__('View Transaction', 'event_espresso'),
199
-                    'order'      => 5,
200
-                    'url'        => isset($this->_req_data['TXN_ID'])
201
-                        ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']), $this->_current_page_view_url)
202
-                        : $this->_admin_base_url,
203
-                    'persistent' => false,
204
-                ),
205
-                'help_tabs' => array(
206
-                    'transactions_view_transaction_help_tab'                                              => array(
207
-                        'title'    => esc_html__('View Transaction', 'event_espresso'),
208
-                        'filename' => 'transactions_view_transaction',
209
-                    ),
210
-                    'transactions_view_transaction_transaction_details_table_help_tab'                    => array(
211
-                        'title'    => esc_html__('Transaction Details Table', 'event_espresso'),
212
-                        'filename' => 'transactions_view_transaction_transaction_details_table',
213
-                    ),
214
-                    'transactions_view_transaction_attendees_registered_help_tab'                         => array(
215
-                        'title'    => esc_html__('Attendees Registered', 'event_espresso'),
216
-                        'filename' => 'transactions_view_transaction_attendees_registered',
217
-                    ),
218
-                    'transactions_view_transaction_views_primary_registrant_billing_information_help_tab' => array(
219
-                        'title'    => esc_html__('Primary Registrant & Billing Information', 'event_espresso'),
220
-                        'filename' => 'transactions_view_transaction_primary_registrant_billing_information',
221
-                    ),
222
-                ),
223
-                'qtips'     => array('Transaction_Details_Tips'),
224
-                'help_tour' => array('Transaction_Details_Help_Tour'),
225
-                'metaboxes' => array('_transaction_details_metaboxes'),
226
-
227
-                'require_nonce' => false,
228
-            ),
229
-        );
230
-    }
231
-
232
-
233
-    /**
234
-     * The below methods aren't used by this class currently
235
-     */
236
-    protected function _add_screen_options()
237
-    {
238
-        // noop
239
-    }
240
-
241
-    protected function _add_feature_pointers()
242
-    {
243
-        // noop
244
-    }
245
-
246
-    public function admin_init()
247
-    {
248
-        // IF a registration was JUST added via the admin...
249
-        if (isset(
250
-            $this->_req_data['redirect_from'],
251
-            $this->_req_data['EVT_ID'],
252
-            $this->_req_data['event_name']
253
-        )) {
254
-            // then set a cookie so that we can block any attempts to use
255
-            // the back button as a way to enter another registration.
256
-            setcookie(
257
-                'ee_registration_added',
258
-                $this->_req_data['EVT_ID'],
259
-                time() + WEEK_IN_SECONDS,
260
-                '/'
261
-            );
262
-            // and update the global
263
-            $_COOKIE['ee_registration_added'] = $this->_req_data['EVT_ID'];
264
-        }
265
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__(
266
-            '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.',
267
-            'event_espresso'
268
-        );
269
-        EE_Registry::$i18n_js_strings['error_occurred'] = esc_html__(
270
-            'An error occurred! Please refresh the page and try again.',
271
-            'event_espresso'
272
-        );
273
-        EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status;
274
-        EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status;
275
-        EE_Registry::$i18n_js_strings['payments_total'] = esc_html__('Payments Total', 'event_espresso');
276
-        EE_Registry::$i18n_js_strings['transaction_overpaid'] = esc_html__(
277
-            'This transaction has been overpaid ! Payments Total',
278
-            'event_espresso'
279
-        );
280
-    }
281
-
282
-    public function admin_notices()
283
-    {
284
-        // noop
285
-    }
286
-
287
-    public function admin_footer_scripts()
288
-    {
289
-        // noop
290
-    }
291
-
292
-
293
-    /**
294
-     * _set_transaction_status_array
295
-     * sets list of transaction statuses
296
-     *
297
-     * @access private
298
-     * @return void
299
-     * @throws EE_Error
300
-     * @throws InvalidArgumentException
301
-     * @throws InvalidDataTypeException
302
-     * @throws InvalidInterfaceException
303
-     */
304
-    private function _set_transaction_status_array()
305
-    {
306
-        self::$_txn_status = EEM_Transaction::instance()->status_array(true);
307
-    }
308
-
309
-
310
-    /**
311
-     * get_transaction_status_array
312
-     * return the transaction status array for wp_list_table
313
-     *
314
-     * @access public
315
-     * @return array
316
-     */
317
-    public function get_transaction_status_array()
318
-    {
319
-        return self::$_txn_status;
320
-    }
321
-
322
-
323
-    /**
324
-     *    get list of payment statuses
325
-     *
326
-     * @access private
327
-     * @return void
328
-     * @throws EE_Error
329
-     * @throws InvalidArgumentException
330
-     * @throws InvalidDataTypeException
331
-     * @throws InvalidInterfaceException
332
-     */
333
-    private function _get_payment_status_array()
334
-    {
335
-        self::$_pay_status = EEM_Payment::instance()->status_array(true);
336
-        $this->_template_args['payment_status'] = self::$_pay_status;
337
-    }
338
-
339
-
340
-    /**
341
-     *    _add_screen_options_default
342
-     *
343
-     * @access protected
344
-     * @return void
345
-     * @throws InvalidArgumentException
346
-     * @throws InvalidDataTypeException
347
-     * @throws InvalidInterfaceException
348
-     */
349
-    protected function _add_screen_options_default()
350
-    {
351
-        $this->_per_page_screen_option();
352
-    }
353
-
354
-
355
-    /**
356
-     * load_scripts_styles
357
-     *
358
-     * @access public
359
-     * @return void
360
-     */
361
-    public function load_scripts_styles()
362
-    {
363
-        // enqueue style
364
-        wp_register_style(
365
-            'espresso_txn',
366
-            TXN_ASSETS_URL . 'espresso_transactions_admin.css',
367
-            array(),
368
-            EVENT_ESPRESSO_VERSION
369
-        );
370
-        wp_enqueue_style('espresso_txn');
371
-        // scripts
372
-        wp_register_script(
373
-            'espresso_txn',
374
-            TXN_ASSETS_URL . 'espresso_transactions_admin.js',
375
-            array(
376
-                'ee_admin_js',
377
-                'ee-datepicker',
378
-                'jquery-ui-datepicker',
379
-                'jquery-ui-draggable',
380
-                'ee-dialog',
381
-                'ee-accounting',
382
-                'ee-serialize-full-array',
383
-            ),
384
-            EVENT_ESPRESSO_VERSION,
385
-            true
386
-        );
387
-        wp_enqueue_script('espresso_txn');
388
-    }
389
-
390
-
391
-    /**
392
-     *    load_scripts_styles_view_transaction
393
-     *
394
-     * @access public
395
-     * @return void
396
-     */
397
-    public function load_scripts_styles_view_transaction()
398
-    {
399
-        // styles
400
-        wp_enqueue_style('espresso-ui-theme');
401
-    }
402
-
403
-
404
-    /**
405
-     *    load_scripts_styles_default
406
-     *
407
-     * @access public
408
-     * @return void
409
-     */
410
-    public function load_scripts_styles_default()
411
-    {
412
-        // styles
413
-        wp_enqueue_style('espresso-ui-theme');
414
-    }
415
-
416
-
417
-    /**
418
-     *    _set_list_table_views_default
419
-     *
420
-     * @access protected
421
-     * @return void
422
-     */
423
-    protected function _set_list_table_views_default()
424
-    {
425
-        $this->_views = array(
426
-            'all'       => array(
427
-                'slug'  => 'all',
428
-                'label' => esc_html__('View All Transactions', 'event_espresso'),
429
-                'count' => 0,
430
-            ),
431
-            'abandoned' => array(
432
-                'slug'  => 'abandoned',
433
-                'label' => esc_html__('Abandoned Transactions', 'event_espresso'),
434
-                'count' => 0,
435
-            ),
436
-            'failed'    => array(
437
-                'slug'  => 'failed',
438
-                'label' => esc_html__('Failed Transactions', 'event_espresso'),
439
-                'count' => 0,
440
-            ),
441
-        );
442
-    }
443
-
444
-
445
-    /**
446
-     * _set_transaction_object
447
-     * This sets the _transaction property for the transaction details screen
448
-     *
449
-     * @access private
450
-     * @return void
451
-     * @throws EE_Error
452
-     * @throws InvalidArgumentException
453
-     * @throws RuntimeException
454
-     * @throws InvalidDataTypeException
455
-     * @throws InvalidInterfaceException
456
-     * @throws ReflectionException
457
-     */
458
-    private function _set_transaction_object()
459
-    {
460
-        if ($this->_transaction instanceof EE_Transaction) {
461
-            return;
462
-        } //get out we've already set the object
463
-
464
-        $TXN_ID = ! empty($this->_req_data['TXN_ID'])
465
-            ? absint($this->_req_data['TXN_ID'])
466
-            : false;
467
-
468
-        // get transaction object
469
-        $this->_transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
470
-        $this->_session = $this->_transaction instanceof EE_Transaction
471
-            ? $this->_transaction->get('TXN_session_data')
472
-            : null;
473
-        $this->_transaction->verify_abandoned_transaction_status();
474
-
475
-        if (! $this->_transaction instanceof EE_Transaction) {
476
-            $error_msg = sprintf(
477
-                esc_html__(
478
-                    'An error occurred and the details for the transaction with the ID # %d could not be retrieved.',
479
-                    'event_espresso'
480
-                ),
481
-                $TXN_ID
482
-            );
483
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
484
-        }
485
-    }
486
-
487
-
488
-    /**
489
-     *    _transaction_legend_items
490
-     *
491
-     * @access protected
492
-     * @return array
493
-     * @throws EE_Error
494
-     * @throws InvalidArgumentException
495
-     * @throws ReflectionException
496
-     * @throws InvalidDataTypeException
497
-     * @throws InvalidInterfaceException
498
-     */
499
-    protected function _transaction_legend_items()
500
-    {
501
-        EE_Registry::instance()->load_helper('MSG_Template');
502
-        $items = array();
503
-
504
-        if (EE_Registry::instance()->CAP->current_user_can(
505
-            'ee_read_global_messages',
506
-            'view_filtered_messages'
507
-        )) {
508
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
509
-            if (is_array($related_for_icon)
510
-                && isset($related_for_icon['css_class'], $related_for_icon['label'])
511
-            ) {
512
-                $items['view_related_messages'] = array(
513
-                    'class' => $related_for_icon['css_class'],
514
-                    'desc'  => $related_for_icon['label'],
515
-                );
516
-            }
517
-        }
518
-
519
-        $items = apply_filters(
520
-            'FHEE__Transactions_Admin_Page___transaction_legend_items__items',
521
-            array_merge(
522
-                $items,
523
-                array(
524
-                    'view_details'          => array(
525
-                        'class' => 'dashicons dashicons-cart',
526
-                        'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
527
-                    ),
528
-                    'view_invoice'          => array(
529
-                        'class' => 'dashicons dashicons-media-spreadsheet',
530
-                        'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
531
-                    ),
532
-                    'view_receipt'          => array(
533
-                        'class' => 'dashicons dashicons-media-default',
534
-                        'desc'  => esc_html__('View Transaction Receipt', 'event_espresso'),
535
-                    ),
536
-                    'view_registration'     => array(
537
-                        'class' => 'dashicons dashicons-clipboard',
538
-                        'desc'  => esc_html__('View Registration Details', 'event_espresso'),
539
-                    ),
540
-                    'payment_overview_link' => array(
541
-                        'class' => 'dashicons dashicons-money',
542
-                        'desc'  => esc_html__('Make Payment on Frontend', 'event_espresso'),
543
-                    ),
544
-                )
545
-            )
546
-        );
547
-
548
-        if (EE_Registry::instance()->CAP->current_user_can(
549
-            'ee_send_message',
550
-            'espresso_transactions_send_payment_reminder'
551
-        )) {
552
-            if (EEH_MSG_Template::is_mt_active('payment_reminder')) {
553
-                $items['send_payment_reminder'] = array(
554
-                    'class' => 'dashicons dashicons-email-alt',
555
-                    'desc'  => esc_html__('Send Payment Reminder', 'event_espresso'),
556
-                );
557
-            } else {
558
-                $items['blank*'] = array(
559
-                    'class' => '',
560
-                    'desc'  => '',
561
-                );
562
-            }
563
-        } else {
564
-            $items['blank*'] = array(
565
-                'class' => '',
566
-                'desc'  => '',
567
-            );
568
-        }
569
-        $more_items = apply_filters(
570
-            'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items',
571
-            array(
572
-                'overpaid'   => array(
573
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code,
574
-                    'desc'  => EEH_Template::pretty_status(
575
-                        EEM_Transaction::overpaid_status_code,
576
-                        false,
577
-                        'sentence'
578
-                    ),
579
-                ),
580
-                'complete'   => array(
581
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code,
582
-                    'desc'  => EEH_Template::pretty_status(
583
-                        EEM_Transaction::complete_status_code,
584
-                        false,
585
-                        'sentence'
586
-                    ),
587
-                ),
588
-                'incomplete' => array(
589
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code,
590
-                    'desc'  => EEH_Template::pretty_status(
591
-                        EEM_Transaction::incomplete_status_code,
592
-                        false,
593
-                        'sentence'
594
-                    ),
595
-                ),
596
-                'abandoned'  => array(
597
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code,
598
-                    'desc'  => EEH_Template::pretty_status(
599
-                        EEM_Transaction::abandoned_status_code,
600
-                        false,
601
-                        'sentence'
602
-                    ),
603
-                ),
604
-                'failed'     => array(
605
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code,
606
-                    'desc'  => EEH_Template::pretty_status(
607
-                        EEM_Transaction::failed_status_code,
608
-                        false,
609
-                        'sentence'
610
-                    ),
611
-                ),
612
-            )
613
-        );
614
-
615
-        return array_merge($items, $more_items);
616
-    }
617
-
618
-
619
-    /**
620
-     *    _transactions_overview_list_table
621
-     *
622
-     * @access protected
623
-     * @return void
624
-     * @throws DomainException
625
-     * @throws EE_Error
626
-     * @throws InvalidArgumentException
627
-     * @throws InvalidDataTypeException
628
-     * @throws InvalidInterfaceException
629
-     * @throws ReflectionException
630
-     */
631
-    protected function _transactions_overview_list_table()
632
-    {
633
-        $this->_admin_page_title = esc_html__('Transactions', 'event_espresso');
634
-        $event = isset($this->_req_data['EVT_ID'])
635
-            ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID'])
636
-            : null;
637
-        $this->_template_args['admin_page_header'] = $event instanceof EE_Event
638
-            ? sprintf(
639
-                esc_html__(
640
-                    '%sViewing Transactions for the Event: %s%s',
641
-                    'event_espresso'
642
-                ),
643
-                '<h3>',
644
-                '<a href="'
645
-                . EE_Admin_Page::add_query_args_and_nonce(
646
-                    array('action' => 'edit', 'post' => $event->ID()),
647
-                    EVENTS_ADMIN_URL
648
-                )
649
-                . '" title="'
650
-                . esc_attr__(
651
-                    'Click to Edit event',
652
-                    'event_espresso'
653
-                )
654
-                . '">' . $event->get('EVT_name') . '</a>',
655
-                '</h3>'
656
-            )
657
-            : '';
658
-        $this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items());
659
-        $this->display_admin_list_table_page_with_no_sidebar();
660
-    }
661
-
662
-
663
-    /**
664
-     *    _transaction_details
665
-     * generates HTML for the View Transaction Details Admin page
666
-     *
667
-     * @access protected
668
-     * @return void
669
-     * @throws DomainException
670
-     * @throws EE_Error
671
-     * @throws InvalidArgumentException
672
-     * @throws InvalidDataTypeException
673
-     * @throws InvalidInterfaceException
674
-     * @throws RuntimeException
675
-     * @throws ReflectionException
676
-     */
677
-    protected function _transaction_details()
678
-    {
679
-        do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction);
680
-
681
-        $this->_set_transaction_status_array();
682
-
683
-        $this->_template_args = array();
684
-        $this->_template_args['transactions_page'] = $this->_wp_page_slug;
685
-
686
-        $this->_set_transaction_object();
687
-
688
-        $primary_registration = $this->_transaction->primary_registration();
689
-        $attendee = $primary_registration instanceof EE_Registration
690
-            ? $primary_registration->attendee()
691
-            : null;
692
-
693
-        $this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID();
694
-        $this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso');
695
-
696
-        $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp');
697
-        $this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso');
698
-
699
-        $this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->get('STS_ID') ];
700
-        $this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso');
701
-        $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID');
702
-
703
-        $this->_template_args['grand_total'] = $this->_transaction->get('TXN_total');
704
-        $this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid');
705
-
706
-        $amount_due = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid');
707
-        $this->_template_args['amount_due'] = EEH_Template::format_currency(
708
-            $amount_due,
709
-            true
710
-        );
711
-        if (EE_Registry::instance()->CFG->currency->sign_b4) {
712
-            $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign
713
-                                                  . $this->_template_args['amount_due'];
714
-        } else {
715
-            $this->_template_args['amount_due'] .= EE_Registry::instance()->CFG->currency->sign;
716
-        }
717
-        $this->_template_args['amount_due_class'] = '';
718
-
719
-        if ($this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total')) {
720
-            // paid in full
721
-            $this->_template_args['amount_due'] = false;
722
-        } elseif ($this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total')) {
723
-            // overpaid
724
-            $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
725
-        } elseif ($this->_transaction->get('TXN_total') > 0
726
-                  && $this->_transaction->get('TXN_paid') > 0
727
-        ) {
728
-            // monies owing
729
-            $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn';
730
-        } elseif ($this->_transaction->get('TXN_total') > 0
731
-                  && $this->_transaction->get('TXN_paid') == 0
732
-        ) {
733
-            // no payments made yet
734
-            $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
735
-        } elseif ($this->_transaction->get('TXN_total') == 0) {
736
-            // free event
737
-            $this->_template_args['amount_due'] = false;
738
-        }
739
-
740
-        $payment_method = $this->_transaction->payment_method();
741
-
742
-        $this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method
743
-            ? $payment_method->admin_name()
744
-            : esc_html__('Unknown', 'event_espresso');
745
-
746
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
747
-        // link back to overview
748
-        $this->_template_args['txn_overview_url'] = ! empty($_SERVER['HTTP_REFERER'])
749
-            ? $_SERVER['HTTP_REFERER']
750
-            : TXN_ADMIN_URL;
751
-
752
-
753
-        // next link
754
-        $next_txn = $this->_transaction->next(
755
-            null,
756
-            array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
757
-            'TXN_ID'
758
-        );
759
-        $this->_template_args['next_transaction'] = $next_txn
760
-            ? $this->_next_link(
761
-                EE_Admin_Page::add_query_args_and_nonce(
762
-                    array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']),
763
-                    TXN_ADMIN_URL
764
-                ),
765
-                'dashicons dashicons-arrow-right ee-icon-size-22'
766
-            )
767
-            : '';
768
-        // previous link
769
-        $previous_txn = $this->_transaction->previous(
770
-            null,
771
-            array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
772
-            'TXN_ID'
773
-        );
774
-        $this->_template_args['previous_transaction'] = $previous_txn
775
-            ? $this->_previous_link(
776
-                EE_Admin_Page::add_query_args_and_nonce(
777
-                    array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']),
778
-                    TXN_ADMIN_URL
779
-                ),
780
-                'dashicons dashicons-arrow-left ee-icon-size-22'
781
-            )
782
-            : '';
783
-
784
-        // were we just redirected here after adding a new registration ???
785
-        if (isset(
786
-            $this->_req_data['redirect_from'],
787
-            $this->_req_data['EVT_ID'],
788
-            $this->_req_data['event_name']
789
-        )) {
790
-            if (EE_Registry::instance()->CAP->current_user_can(
791
-                'ee_edit_registrations',
792
-                'espresso_registrations_new_registration',
793
-                $this->_req_data['EVT_ID']
794
-            )) {
795
-                $this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="';
796
-                $this->_admin_page_title .= EE_Admin_Page::add_query_args_and_nonce(
797
-                    array(
798
-                        'page'     => 'espresso_registrations',
799
-                        'action'   => 'new_registration',
800
-                        'return'   => 'default',
801
-                        'TXN_ID'   => $this->_transaction->ID(),
802
-                        'event_id' => $this->_req_data['EVT_ID'],
803
-                    ),
804
-                    REG_ADMIN_URL
805
-                );
806
-                $this->_admin_page_title .= '">';
807
-
808
-                $this->_admin_page_title .= sprintf(
809
-                    esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'),
810
-                    htmlentities(urldecode($this->_req_data['event_name']), ENT_QUOTES, 'UTF-8')
811
-                );
812
-                $this->_admin_page_title .= '</a>';
813
-            }
814
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
815
-        }
816
-        // grab messages at the last second
817
-        $this->_template_args['notices'] = EE_Error::get_notices();
818
-        // path to template
819
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
820
-        $this->_template_args['admin_page_header'] = EEH_Template::display_template(
821
-            $template_path,
822
-            $this->_template_args,
823
-            true
824
-        );
825
-
826
-        // the details template wrapper
827
-        $this->display_admin_page_with_sidebar();
828
-    }
829
-
830
-
831
-    /**
832
-     *        _transaction_details_metaboxes
833
-     *
834
-     * @access protected
835
-     * @return void
836
-     * @throws EE_Error
837
-     * @throws InvalidArgumentException
838
-     * @throws InvalidDataTypeException
839
-     * @throws InvalidInterfaceException
840
-     * @throws RuntimeException
841
-     * @throws ReflectionException
842
-     */
843
-    protected function _transaction_details_metaboxes()
844
-    {
845
-
846
-        $this->_set_transaction_object();
847
-
848
-        add_meta_box(
849
-            'edit-txn-details-mbox',
850
-            esc_html__('Transaction Details', 'event_espresso'),
851
-            array($this, 'txn_details_meta_box'),
852
-            $this->_wp_page_slug,
853
-            'normal',
854
-            'high'
855
-        );
856
-        add_meta_box(
857
-            'edit-txn-attendees-mbox',
858
-            esc_html__('Attendees Registered in this Transaction', 'event_espresso'),
859
-            array($this, 'txn_attendees_meta_box'),
860
-            $this->_wp_page_slug,
861
-            'normal',
862
-            'high',
863
-            array('TXN_ID' => $this->_transaction->ID())
864
-        );
865
-        add_meta_box(
866
-            'edit-txn-registrant-mbox',
867
-            esc_html__('Primary Contact', 'event_espresso'),
868
-            array($this, 'txn_registrant_side_meta_box'),
869
-            $this->_wp_page_slug,
870
-            'side',
871
-            'high'
872
-        );
873
-        add_meta_box(
874
-            'edit-txn-billing-info-mbox',
875
-            esc_html__('Billing Information', 'event_espresso'),
876
-            array($this, 'txn_billing_info_side_meta_box'),
877
-            $this->_wp_page_slug,
878
-            'side',
879
-            'high'
880
-        );
881
-    }
882
-
883
-
884
-    /**
885
-     * Callback for transaction actions metabox.
886
-     *
887
-     * @param EE_Transaction|null $transaction
888
-     * @throws DomainException
889
-     * @throws EE_Error
890
-     * @throws InvalidArgumentException
891
-     * @throws InvalidDataTypeException
892
-     * @throws InvalidInterfaceException
893
-     * @throws ReflectionException
894
-     * @throws RuntimeException
895
-     */
896
-    public function getActionButtons(EE_Transaction $transaction = null)
897
-    {
898
-        $content = '';
899
-        $actions = array();
900
-        if (! $transaction instanceof EE_Transaction) {
901
-            return $content;
902
-        }
903
-        /** @var EE_Registration $primary_registration */
904
-        $primary_registration = $transaction->primary_registration();
905
-        $attendee = $primary_registration instanceof EE_Registration
906
-            ? $primary_registration->attendee()
907
-            : null;
908
-
909
-        if ($attendee instanceof EE_Attendee
910
-            && EE_Registry::instance()->CAP->current_user_can(
911
-                'ee_send_message',
912
-                'espresso_transactions_send_payment_reminder'
913
-            )
914
-        ) {
915
-            $actions['payment_reminder'] =
916
-                EEH_MSG_Template::is_mt_active('payment_reminder')
917
-                && $this->_transaction->get('STS_ID') !== EEM_Transaction::complete_status_code
918
-                && $this->_transaction->get('STS_ID') !== EEM_Transaction::overpaid_status_code
919
-                    ? EEH_Template::get_button_or_link(
920
-                        EE_Admin_Page::add_query_args_and_nonce(
921
-                            array(
922
-                                'action'      => 'send_payment_reminder',
923
-                                'TXN_ID'      => $this->_transaction->ID(),
924
-                                'redirect_to' => 'view_transaction',
925
-                            ),
926
-                            TXN_ADMIN_URL
927
-                        ),
928
-                        esc_html__(' Send Payment Reminder', 'event_espresso'),
929
-                        'button secondary-button',
930
-                        'dashicons dashicons-email-alt'
931
-                    )
932
-                    : '';
933
-        }
934
-
935
-        if ($primary_registration instanceof EE_Registration
936
-            && EEH_MSG_Template::is_mt_active('receipt')
937
-        ) {
938
-            $actions['receipt'] = EEH_Template::get_button_or_link(
939
-                $primary_registration->receipt_url(),
940
-                esc_html__('View Receipt', 'event_espresso'),
941
-                'button secondary-button',
942
-                'dashicons dashicons-media-default'
943
-            );
944
-        }
945
-
946
-        if ($primary_registration instanceof EE_Registration
947
-            && EEH_MSG_Template::is_mt_active('invoice')
948
-        ) {
949
-            $actions['invoice'] = EEH_Template::get_button_or_link(
950
-                $primary_registration->invoice_url(),
951
-                esc_html__('View Invoice', 'event_espresso'),
952
-                'button secondary-button',
953
-                'dashicons dashicons-media-spreadsheet'
954
-            );
955
-        }
956
-        $actions = array_filter(
957
-            apply_filters('FHEE__Transactions_Admin_Page__getActionButtons__actions', $actions, $transaction)
958
-        );
959
-        if ($actions) {
960
-            $content = '<ul>';
961
-            $content .= '<li>' . implode('</li><li>', $actions) . '</li>';
962
-            $content .= '</uL>';
963
-        }
964
-        return $content;
965
-    }
966
-
967
-
968
-    /**
969
-     * txn_details_meta_box
970
-     * generates HTML for the Transaction main meta box
971
-     *
972
-     * @return void
973
-     * @throws DomainException
974
-     * @throws EE_Error
975
-     * @throws InvalidArgumentException
976
-     * @throws InvalidDataTypeException
977
-     * @throws InvalidInterfaceException
978
-     * @throws RuntimeException
979
-     * @throws ReflectionException
980
-     */
981
-    public function txn_details_meta_box()
982
-    {
983
-        $this->_set_transaction_object();
984
-        $this->_template_args['TXN_ID'] = $this->_transaction->ID();
985
-        $this->_template_args['attendee'] = $this->_transaction->primary_registration() instanceof EE_Registration
986
-            ? $this->_transaction->primary_registration()->attendee()
987
-            : null;
988
-        $this->_template_args['can_edit_payments'] = EE_Registry::instance()->CAP->current_user_can(
989
-            'ee_edit_payments',
990
-            'apply_payment_or_refund_from_registration_details'
991
-        );
992
-        $this->_template_args['can_delete_payments'] = EE_Registry::instance()->CAP->current_user_can(
993
-            'ee_delete_payments',
994
-            'delete_payment_from_registration_details'
995
-        );
996
-
997
-        // get line table
998
-        EEH_Autoloader::register_line_item_display_autoloaders();
999
-        $Line_Item_Display = new EE_Line_Item_Display(
1000
-            'admin_table',
1001
-            'EE_Admin_Table_Line_Item_Display_Strategy'
1002
-        );
1003
-        $this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item(
1004
-            $this->_transaction->total_line_item()
1005
-        );
1006
-        $this->_template_args['REG_code'] = $this->_transaction->get_first_related('Registration')
1007
-                                                               ->get('REG_code');
1008
-
1009
-        // process taxes
1010
-        $taxes = $this->_transaction->get_many_related(
1011
-            'Line_Item',
1012
-            array(array('LIN_type' => EEM_Line_Item::type_tax))
1013
-        );
1014
-        $this->_template_args['taxes'] = ! empty($taxes) ? $taxes : false;
1015
-
1016
-        $this->_template_args['grand_total'] = EEH_Template::format_currency(
1017
-            $this->_transaction->get('TXN_total'),
1018
-            false,
1019
-            false
1020
-        );
1021
-        $this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total');
1022
-        $this->_template_args['TXN_status'] = $this->_transaction->get('STS_ID');
1023
-
1024
-        // process payment details
1025
-        $payments = $this->_transaction->get_many_related('Payment');
1026
-        if (! empty($payments)) {
1027
-            $this->_template_args['payments'] = $payments;
1028
-            $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
1029
-        } else {
1030
-            $this->_template_args['payments'] = false;
1031
-            $this->_template_args['existing_reg_payments'] = array();
1032
-        }
1033
-
1034
-        $this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL);
1035
-        $this->_template_args['delete_payment_url'] = add_query_arg(
1036
-            array('action' => 'espresso_delete_payment'),
1037
-            TXN_ADMIN_URL
1038
-        );
1039
-
1040
-        if (isset($txn_details['invoice_number'])) {
1041
-            $this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code'];
1042
-            $this->_template_args['txn_details']['invoice_number']['label'] = esc_html__(
1043
-                'Invoice Number',
1044
-                'event_espresso'
1045
-            );
1046
-        }
1047
-
1048
-        $this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction
1049
-            ->get_first_related('Registration')
1050
-            ->get('REG_session');
1051
-        $this->_template_args['txn_details']['registration_session']['label'] = esc_html__(
1052
-            'Registration Session',
1053
-            'event_espresso'
1054
-        );
1055
-
1056
-        $this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address'])
1057
-            ? $this->_session['ip_address']
1058
-            : '';
1059
-        $this->_template_args['txn_details']['ip_address']['label'] = esc_html__(
1060
-            'Transaction placed from IP',
1061
-            'event_espresso'
1062
-        );
1063
-
1064
-        $this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent'])
1065
-            ? $this->_session['user_agent']
1066
-            : '';
1067
-        $this->_template_args['txn_details']['user_agent']['label'] = esc_html__(
1068
-            'Registrant User Agent',
1069
-            'event_espresso'
1070
-        );
1071
-
1072
-        $reg_steps = '<ul>';
1073
-        foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) {
1074
-            if ($reg_step_status === true) {
1075
-                $reg_steps .= '<li style="color:#70cc50">'
1076
-                              . sprintf(
1077
-                                  esc_html__('%1$s : Completed', 'event_espresso'),
1078
-                                  ucwords(str_replace('_', ' ', $reg_step))
1079
-                              )
1080
-                              . '</li>';
1081
-            } elseif (is_numeric($reg_step_status) && $reg_step_status !== false) {
1082
-                $reg_steps .= '<li style="color:#2EA2CC">'
1083
-                              . sprintf(
1084
-                                  esc_html__('%1$s : Initiated %2$s', 'event_espresso'),
1085
-                                  ucwords(str_replace('_', ' ', $reg_step)),
1086
-                                  date(
1087
-                                      get_option('date_format') . ' ' . get_option('time_format'),
1088
-                                      ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS))
1089
-                                  )
1090
-                              )
1091
-                              . '</li>';
1092
-            } else {
1093
-                $reg_steps .= '<li style="color:#E76700">'
1094
-                              . sprintf(
1095
-                                  esc_html__('%1$s : Never Initiated', 'event_espresso'),
1096
-                                  ucwords(str_replace('_', ' ', $reg_step))
1097
-                              )
1098
-                              . '</li>';
1099
-            }
1100
-        }
1101
-        $reg_steps .= '</ul>';
1102
-        $this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps;
1103
-        $this->_template_args['txn_details']['reg_steps']['label'] = esc_html__(
1104
-            'Registration Step Progress',
1105
-            'event_espresso'
1106
-        );
1107
-
1108
-
1109
-        $this->_get_registrations_to_apply_payment_to();
1110
-        $this->_get_payment_methods($payments);
1111
-        $this->_get_payment_status_array();
1112
-        $this->_get_reg_status_selection(); // sets up the template args for the reg status array for the transaction.
1113
-
1114
-        $this->_template_args['transaction_form_url'] = add_query_arg(
1115
-            array(
1116
-                'action'  => 'edit_transaction',
1117
-                'process' => 'transaction',
1118
-            ),
1119
-            TXN_ADMIN_URL
1120
-        );
1121
-        $this->_template_args['apply_payment_form_url'] = add_query_arg(
1122
-            array(
1123
-                'page'   => 'espresso_transactions',
1124
-                'action' => 'espresso_apply_payment',
1125
-            ),
1126
-            WP_AJAX_URL
1127
-        );
1128
-        $this->_template_args['delete_payment_form_url'] = add_query_arg(
1129
-            array(
1130
-                'page'   => 'espresso_transactions',
1131
-                'action' => 'espresso_delete_payment',
1132
-            ),
1133
-            WP_AJAX_URL
1134
-        );
1135
-
1136
-        $this->_template_args['action_buttons'] = $this->getActionButtons($this->_transaction);
1137
-
1138
-        // 'espresso_delete_payment_nonce'
1139
-
1140
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
1141
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
1142
-    }
1143
-
1144
-
1145
-    /**
1146
-     * _get_registration_payment_IDs
1147
-     *    generates an array of Payment IDs and their corresponding Registration IDs
1148
-     *
1149
-     * @access protected
1150
-     * @param EE_Payment[] $payments
1151
-     * @return array
1152
-     * @throws EE_Error
1153
-     * @throws InvalidArgumentException
1154
-     * @throws InvalidDataTypeException
1155
-     * @throws InvalidInterfaceException
1156
-     * @throws ReflectionException
1157
-     */
1158
-    protected function _get_registration_payment_IDs($payments = array())
1159
-    {
1160
-        $existing_reg_payments = array();
1161
-        // get all reg payments for these payments
1162
-        $reg_payments = EEM_Registration_Payment::instance()->get_all(
1163
-            array(
1164
-                array(
1165
-                    'PAY_ID' => array(
1166
-                        'IN',
1167
-                        array_keys($payments),
1168
-                    ),
1169
-                ),
1170
-            )
1171
-        );
1172
-        if (! empty($reg_payments)) {
1173
-            foreach ($payments as $payment) {
1174
-                if (! $payment instanceof EE_Payment) {
1175
-                    continue;
1176
-                } elseif (! isset($existing_reg_payments[ $payment->ID() ])) {
1177
-                    $existing_reg_payments[ $payment->ID() ] = array();
1178
-                }
1179
-                foreach ($reg_payments as $reg_payment) {
1180
-                    if ($reg_payment instanceof EE_Registration_Payment
1181
-                        && $reg_payment->payment_ID() === $payment->ID()
1182
-                    ) {
1183
-                        $existing_reg_payments[ $payment->ID() ][] = $reg_payment->registration_ID();
1184
-                    }
1185
-                }
1186
-            }
1187
-        }
1188
-
1189
-        return $existing_reg_payments;
1190
-    }
1191
-
1192
-
1193
-    /**
1194
-     * _get_registrations_to_apply_payment_to
1195
-     *    generates HTML for displaying a series of checkboxes in the admin payment modal window
1196
-     * which allows the admin to only apply the payment to the specific registrations
1197
-     *
1198
-     * @access protected
1199
-     * @return void
1200
-     * @throws \EE_Error
1201
-     */
1202
-    protected function _get_registrations_to_apply_payment_to()
1203
-    {
1204
-        // we want any registration with an active status (ie: not deleted or cancelled)
1205
-        $query_params = array(
1206
-            array(
1207
-                'STS_ID' => array(
1208
-                    'IN',
1209
-                    array(
1210
-                        EEM_Registration::status_id_approved,
1211
-                        EEM_Registration::status_id_pending_payment,
1212
-                        EEM_Registration::status_id_not_approved,
1213
-                    ),
1214
-                ),
1215
-            ),
1216
-        );
1217
-        $registrations_to_apply_payment_to = EEH_HTML::br()
1218
-                                             . EEH_HTML::div(
1219
-                                                 '',
1220
-                                                 'txn-admin-apply-payment-to-registrations-dv',
1221
-                                                 '',
1222
-                                                 'clear: both; margin: 1.5em 0 0; display: none;'
1223
-                                             );
1224
-        $registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
1225
-        $registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl');
1226
-        $registrations_to_apply_payment_to .= EEH_HTML::thead(
1227
-            EEH_HTML::tr(
1228
-                EEH_HTML::th(esc_html__('ID', 'event_espresso')) .
1229
-                EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) .
1230
-                EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) .
1231
-                EEH_HTML::th(esc_html__('Event', 'event_espresso')) .
1232
-                EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') .
1233
-                EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') .
1234
-                EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr')
1235
-            )
1236
-        );
1237
-        $registrations_to_apply_payment_to .= EEH_HTML::tbody();
1238
-        // get registrations for TXN
1239
-        $registrations = $this->_transaction->registrations($query_params);
1240
-        $existing_reg_payments = $this->_template_args['existing_reg_payments'];
1241
-        foreach ($registrations as $registration) {
1242
-            if ($registration instanceof EE_Registration) {
1243
-                $attendee_name = $registration->attendee() instanceof EE_Attendee
1244
-                    ? $registration->attendee()->full_name()
1245
-                    : esc_html__('Unknown Attendee', 'event_espresso');
1246
-                $owing = $registration->final_price() - $registration->paid();
1247
-                $taxable = $registration->ticket()->taxable()
1248
-                    ? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>'
1249
-                    : '';
1250
-                $checked = empty($existing_reg_payments) || in_array($registration->ID(), $existing_reg_payments)
1251
-                    ? ' checked="checked"'
1252
-                    : '';
1253
-                $disabled = $registration->final_price() > 0 ? '' : ' disabled';
1254
-                $registrations_to_apply_payment_to .= EEH_HTML::tr(
1255
-                    EEH_HTML::td($registration->ID()) .
1256
-                    EEH_HTML::td($attendee_name) .
1257
-                    EEH_HTML::td(
1258
-                        $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable
1259
-                    ) .
1260
-                    EEH_HTML::td($registration->event_name()) .
1261
-                    EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') .
1262
-                    EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr') .
1263
-                    EEH_HTML::td(
1264
-                        '<input type="checkbox" value="' . $registration->ID()
1265
-                        . '" name="txn_admin_payment[registrations]"'
1266
-                        . $checked . $disabled . '>',
1267
-                        '',
1268
-                        'jst-cntr'
1269
-                    ),
1270
-                    'apply-payment-registration-row-' . $registration->ID()
1271
-                );
1272
-            }
1273
-        }
1274
-        $registrations_to_apply_payment_to .= EEH_HTML::tbodyx();
1275
-        $registrations_to_apply_payment_to .= EEH_HTML::tablex();
1276
-        $registrations_to_apply_payment_to .= EEH_HTML::divx();
1277
-        $registrations_to_apply_payment_to .= EEH_HTML::p(
1278
-            esc_html__(
1279
-                '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.',
1280
-                'event_espresso'
1281
-            ),
1282
-            '',
1283
-            'clear description'
1284
-        );
1285
-        $registrations_to_apply_payment_to .= EEH_HTML::divx();
1286
-        $this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to;
1287
-    }
1288
-
1289
-
1290
-    /**
1291
-     * _get_reg_status_selection
1292
-     *
1293
-     * @todo   this will need to be adjusted either once MER comes along OR we move default reg status to tickets
1294
-     *         instead of events.
1295
-     * @access protected
1296
-     * @return void
1297
-     * @throws EE_Error
1298
-     */
1299
-    protected function _get_reg_status_selection()
1300
-    {
1301
-        // first get all possible statuses
1302
-        $statuses = EEM_Registration::reg_status_array(array(), true);
1303
-        // let's add a "don't change" option.
1304
-        $status_array['NAN'] = esc_html__('Leave the Same', 'event_espresso');
1305
-        $status_array = array_merge($status_array, $statuses);
1306
-        $this->_template_args['status_change_select'] = EEH_Form_Fields::select_input(
1307
-            'txn_reg_status_change[reg_status]',
1308
-            $status_array,
1309
-            'NAN',
1310
-            'id="txn-admin-payment-reg-status-inp"',
1311
-            'txn-reg-status-change-reg-status'
1312
-        );
1313
-        $this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input(
1314
-            'delete_txn_reg_status_change[reg_status]',
1315
-            $status_array,
1316
-            'NAN',
1317
-            'delete-txn-admin-payment-reg-status-inp',
1318
-            'delete-txn-reg-status-change-reg-status'
1319
-        );
1320
-    }
1321
-
1322
-
1323
-    /**
1324
-     *    _get_payment_methods
1325
-     * Gets all the payment methods available generally, or the ones that are already
1326
-     * selected on these payments (in case their payment methods are no longer active).
1327
-     * Has the side-effect of updating the template args' payment_methods item
1328
-     *
1329
-     * @access private
1330
-     * @param EE_Payment[] to show on this page
1331
-     * @return void
1332
-     * @throws EE_Error
1333
-     * @throws InvalidArgumentException
1334
-     * @throws InvalidDataTypeException
1335
-     * @throws InvalidInterfaceException
1336
-     * @throws ReflectionException
1337
-     */
1338
-    private function _get_payment_methods($payments = array())
1339
-    {
1340
-        $payment_methods_of_payments = array();
1341
-        foreach ($payments as $payment) {
1342
-            if ($payment instanceof EE_Payment) {
1343
-                $payment_methods_of_payments[] = $payment->get('PMD_ID');
1344
-            }
1345
-        }
1346
-        if ($payment_methods_of_payments) {
1347
-            $query_args = array(
1348
-                array(
1349
-                    'OR*payment_method_for_payment' => array(
1350
-                        'PMD_ID'    => array('IN', $payment_methods_of_payments),
1351
-                        'PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%'),
1352
-                    ),
1353
-                ),
1354
-            );
1355
-        } else {
1356
-            $query_args = array(array('PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%')));
1357
-        }
1358
-        $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
1359
-    }
1360
-
1361
-
1362
-    /**
1363
-     * txn_attendees_meta_box
1364
-     *    generates HTML for the Attendees Transaction main meta box
1365
-     *
1366
-     * @access public
1367
-     * @param WP_Post $post
1368
-     * @param array   $metabox
1369
-     * @return void
1370
-     * @throws DomainException
1371
-     * @throws EE_Error
1372
-     */
1373
-    public function txn_attendees_meta_box($post, $metabox = array('args' => array()))
1374
-    {
1375
-
1376
-        /** @noinspection NonSecureExtractUsageInspection */
1377
-        extract($metabox['args']);
1378
-        $this->_template_args['post'] = $post;
1379
-        $this->_template_args['event_attendees'] = array();
1380
-        // process items in cart
1381
-        $line_items = $this->_transaction->get_many_related(
1382
-            'Line_Item',
1383
-            array(array('LIN_type' => 'line-item'))
1384
-        );
1385
-        if (! empty($line_items)) {
1386
-            foreach ($line_items as $item) {
1387
-                if ($item instanceof EE_Line_Item) {
1388
-                    switch ($item->OBJ_type()) {
1389
-                        case 'Event':
1390
-                            break;
1391
-                        case 'Ticket':
1392
-                            $ticket = $item->ticket();
1393
-                            // right now we're only handling tickets here.
1394
-                            // Cause its expected that only tickets will have attendees right?
1395
-                            if (! $ticket instanceof EE_Ticket) {
1396
-                                continue;
1397
-                            }
1398
-                            try {
1399
-                                $event_name = $ticket->get_event_name();
1400
-                            } catch (Exception $e) {
1401
-                                EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1402
-                                $event_name = esc_html__('Unknown Event', 'event_espresso');
1403
-                            }
1404
-                            $event_name .= ' - ' . $item->get('LIN_name');
1405
-                            $ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price'));
1406
-                            // now get all of the registrations for this transaction that use this ticket
1407
-                            $registrations = $ticket->get_many_related(
1408
-                                'Registration',
1409
-                                array(array('TXN_ID' => $this->_transaction->ID()))
1410
-                            );
1411
-                            foreach ($registrations as $registration) {
1412
-                                if (! $registration instanceof EE_Registration) {
1413
-                                    continue;
1414
-                                }
1415
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['STS_ID']
1416
-                                    = $registration->status_ID();
1417
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['att_num']
1418
-                                    = $registration->count();
1419
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['event_ticket_name']
1420
-                                    = $event_name;
1421
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['ticket_price']
1422
-                                    = $ticket_price;
1423
-                                // attendee info
1424
-                                $attendee = $registration->get_first_related('Attendee');
1425
-                                if ($attendee instanceof EE_Attendee) {
1426
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['att_id']
1427
-                                        = $attendee->ID();
1428
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['attendee']
1429
-                                        = $attendee->full_name();
1430
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['email']
1431
-                                        = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name
1432
-                                          . esc_html__(
1433
-                                              ' Event',
1434
-                                              'event_espresso'
1435
-                                          )
1436
-                                          . '">' . $attendee->email() . '</a>';
1437
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['address']
1438
-                                        = EEH_Address::format($attendee, 'inline', false, false);
1439
-                                } else {
1440
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['att_id'] = '';
1441
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['attendee'] = '';
1442
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['email'] = '';
1443
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['address'] = '';
1444
-                                }
1445
-                            }
1446
-                            break;
1447
-                    }
1448
-                }
1449
-            }
1450
-
1451
-            $this->_template_args['transaction_form_url'] = add_query_arg(
1452
-                array(
1453
-                    'action'  => 'edit_transaction',
1454
-                    'process' => 'attendees',
1455
-                ),
1456
-                TXN_ADMIN_URL
1457
-            );
1458
-            echo EEH_Template::display_template(
1459
-                TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php',
1460
-                $this->_template_args,
1461
-                true
1462
-            );
1463
-        } else {
1464
-            echo sprintf(
1465
-                esc_html__(
1466
-                    '%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s',
1467
-                    'event_espresso'
1468
-                ),
1469
-                '<p class="important-notice">',
1470
-                '</p>'
1471
-            );
1472
-        }
1473
-    }
1474
-
1475
-
1476
-    /**
1477
-     * txn_registrant_side_meta_box
1478
-     * generates HTML for the Edit Transaction side meta box
1479
-     *
1480
-     * @access public
1481
-     * @return void
1482
-     * @throws DomainException
1483
-     * @throws EE_Error
1484
-     * @throws InvalidArgumentException
1485
-     * @throws InvalidDataTypeException
1486
-     * @throws InvalidInterfaceException
1487
-     * @throws ReflectionException
1488
-     */
1489
-    public function txn_registrant_side_meta_box()
1490
-    {
1491
-        $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration
1492
-            ? $this->_transaction->primary_registration()->get_first_related('Attendee')
1493
-            : null;
1494
-        if (! $primary_att instanceof EE_Attendee) {
1495
-            $this->_template_args['no_attendee_message'] = esc_html__(
1496
-                'There is no attached contact for this transaction.  The transaction either failed due to an error or was abandoned.',
1497
-                'event_espresso'
1498
-            );
1499
-            $primary_att = EEM_Attendee::instance()->create_default_object();
1500
-        }
1501
-        $this->_template_args['ATT_ID'] = $primary_att->ID();
1502
-        $this->_template_args['prime_reg_fname'] = $primary_att->fname();
1503
-        $this->_template_args['prime_reg_lname'] = $primary_att->lname();
1504
-        $this->_template_args['prime_reg_email'] = $primary_att->email();
1505
-        $this->_template_args['prime_reg_phone'] = $primary_att->phone();
1506
-        $this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(
1507
-            array(
1508
-                'action' => 'edit_attendee',
1509
-                'post'   => $primary_att->ID(),
1510
-            ),
1511
-            REG_ADMIN_URL
1512
-        );
1513
-        // get formatted address for registrant
1514
-        $this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
1515
-        echo EEH_Template::display_template(
1516
-            TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php',
1517
-            $this->_template_args,
1518
-            true
1519
-        );
1520
-    }
1521
-
1522
-
1523
-    /**
1524
-     * txn_billing_info_side_meta_box
1525
-     *    generates HTML for the Edit Transaction side meta box
1526
-     *
1527
-     * @access public
1528
-     * @return void
1529
-     * @throws DomainException
1530
-     * @throws EE_Error
1531
-     */
1532
-    public function txn_billing_info_side_meta_box()
1533
-    {
1534
-
1535
-        $this->_template_args['billing_form'] = $this->_transaction->billing_info();
1536
-        $this->_template_args['billing_form_url'] = add_query_arg(
1537
-            array('action' => 'edit_transaction', 'process' => 'billing'),
1538
-            TXN_ADMIN_URL
1539
-        );
1540
-
1541
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php';
1542
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);/**/
1543
-    }
1544
-
1545
-
1546
-    /**
1547
-     * apply_payments_or_refunds
1548
-     *    registers a payment or refund made towards a transaction
1549
-     *
1550
-     * @access public
1551
-     * @return void
1552
-     * @throws EE_Error
1553
-     * @throws InvalidArgumentException
1554
-     * @throws ReflectionException
1555
-     * @throws RuntimeException
1556
-     * @throws InvalidDataTypeException
1557
-     * @throws InvalidInterfaceException
1558
-     */
1559
-    public function apply_payments_or_refunds()
1560
-    {
1561
-        $json_response_data = array('return_data' => false);
1562
-        $valid_data = $this->_validate_payment_request_data();
1563
-        $has_access = EE_Registry::instance()->CAP->current_user_can(
1564
-            'ee_edit_payments',
1565
-            'apply_payment_or_refund_from_registration_details'
1566
-        );
1567
-        if (! empty($valid_data) && $has_access) {
1568
-            $PAY_ID = $valid_data['PAY_ID'];
1569
-            // save  the new payment
1570
-            $payment = $this->_create_payment_from_request_data($valid_data);
1571
-            // get the TXN for this payment
1572
-            $transaction = $payment->transaction();
1573
-            // verify transaction
1574
-            if ($transaction instanceof EE_Transaction) {
1575
-                // calculate_total_payments_and_update_status
1576
-                $this->_process_transaction_payments($transaction);
1577
-                $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment);
1578
-                $this->_remove_existing_registration_payments($payment, $PAY_ID);
1579
-                // apply payment to registrations (if applicable)
1580
-                if (! empty($REG_IDs)) {
1581
-                    $this->_update_registration_payments($transaction, $payment, $REG_IDs);
1582
-                    $this->_maybe_send_notifications();
1583
-                    // now process status changes for the same registrations
1584
-                    $this->_process_registration_status_change($transaction, $REG_IDs);
1585
-                }
1586
-                $this->_maybe_send_notifications($payment);
1587
-                // prepare to render page
1588
-                $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs);
1589
-                do_action(
1590
-                    'AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording',
1591
-                    $transaction,
1592
-                    $payment
1593
-                );
1594
-            } else {
1595
-                EE_Error::add_error(
1596
-                    esc_html__(
1597
-                        'A valid Transaction for this payment could not be retrieved.',
1598
-                        'event_espresso'
1599
-                    ),
1600
-                    __FILE__,
1601
-                    __FUNCTION__,
1602
-                    __LINE__
1603
-                );
1604
-            }
1605
-        } else {
1606
-            if ($has_access) {
1607
-                EE_Error::add_error(
1608
-                    esc_html__(
1609
-                        'The payment form data could not be processed. Please try again.',
1610
-                        'event_espresso'
1611
-                    ),
1612
-                    __FILE__,
1613
-                    __FUNCTION__,
1614
-                    __LINE__
1615
-                );
1616
-            } else {
1617
-                EE_Error::add_error(
1618
-                    esc_html__(
1619
-                        'You do not have access to apply payments or refunds to a registration.',
1620
-                        'event_espresso'
1621
-                    ),
1622
-                    __FILE__,
1623
-                    __FUNCTION__,
1624
-                    __LINE__
1625
-                );
1626
-            }
1627
-        }
1628
-        $notices = EE_Error::get_notices(
1629
-            false,
1630
-            false,
1631
-            false
1632
-        );
1633
-        $this->_template_args = array(
1634
-            'data'    => $json_response_data,
1635
-            'error'   => $notices['errors'],
1636
-            'success' => $notices['success'],
1637
-        );
1638
-        $this->_return_json();
1639
-    }
1640
-
1641
-
1642
-    /**
1643
-     * _validate_payment_request_data
1644
-     *
1645
-     * @return array
1646
-     * @throws EE_Error
1647
-     */
1648
-    protected function _validate_payment_request_data()
1649
-    {
1650
-        if (! isset($this->_req_data['txn_admin_payment'])) {
1651
-            return false;
1652
-        }
1653
-        $payment_form = $this->_generate_payment_form_section();
1654
-        try {
1655
-            if ($payment_form->was_submitted()) {
1656
-                $payment_form->receive_form_submission();
1657
-                if (! $payment_form->is_valid()) {
1658
-                    $submission_error_messages = array();
1659
-                    foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) {
1660
-                        if ($validation_error instanceof EE_Validation_Error) {
1661
-                            $submission_error_messages[] = sprintf(
1662
-                                _x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'),
1663
-                                $validation_error->get_form_section()->html_label_text(),
1664
-                                $validation_error->getMessage()
1665
-                            );
1666
-                        }
1667
-                    }
1668
-                    EE_Error::add_error(
1669
-                        implode('<br />', $submission_error_messages),
1670
-                        __FILE__,
1671
-                        __FUNCTION__,
1672
-                        __LINE__
1673
-                    );
1674
-
1675
-                    return array();
1676
-                }
1677
-            }
1678
-        } catch (EE_Error $e) {
1679
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1680
-
1681
-            return array();
1682
-        }
1683
-
1684
-        return $payment_form->valid_data();
1685
-    }
1686
-
1687
-
1688
-    /**
1689
-     * _generate_payment_form_section
1690
-     *
1691
-     * @return EE_Form_Section_Proper
1692
-     * @throws EE_Error
1693
-     */
1694
-    protected function _generate_payment_form_section()
1695
-    {
1696
-        return new EE_Form_Section_Proper(
1697
-            array(
1698
-                'name'        => 'txn_admin_payment',
1699
-                'subsections' => array(
1700
-                    'PAY_ID'          => new EE_Text_Input(
1701
-                        array(
1702
-                            'default'               => 0,
1703
-                            'required'              => false,
1704
-                            'html_label_text'       => esc_html__('Payment ID', 'event_espresso'),
1705
-                            'validation_strategies' => array(new EE_Int_Normalization()),
1706
-                        )
1707
-                    ),
1708
-                    'TXN_ID'          => new EE_Text_Input(
1709
-                        array(
1710
-                            'default'               => 0,
1711
-                            'required'              => true,
1712
-                            'html_label_text'       => esc_html__('Transaction ID', 'event_espresso'),
1713
-                            'validation_strategies' => array(new EE_Int_Normalization()),
1714
-                        )
1715
-                    ),
1716
-                    'type'            => new EE_Text_Input(
1717
-                        array(
1718
-                            'default'               => 1,
1719
-                            'required'              => true,
1720
-                            'html_label_text'       => esc_html__('Payment or Refund', 'event_espresso'),
1721
-                            'validation_strategies' => array(new EE_Int_Normalization()),
1722
-                        )
1723
-                    ),
1724
-                    'amount'          => new EE_Text_Input(
1725
-                        array(
1726
-                            'default'               => 0,
1727
-                            'required'              => true,
1728
-                            'html_label_text'       => esc_html__('Payment amount', 'event_espresso'),
1729
-                            'validation_strategies' => array(new EE_Float_Normalization()),
1730
-                        )
1731
-                    ),
1732
-                    'status'          => new EE_Text_Input(
1733
-                        array(
1734
-                            'default'         => EEM_Payment::status_id_approved,
1735
-                            'required'        => true,
1736
-                            'html_label_text' => esc_html__('Payment status', 'event_espresso'),
1737
-                        )
1738
-                    ),
1739
-                    'PMD_ID'          => new EE_Text_Input(
1740
-                        array(
1741
-                            'default'               => 2,
1742
-                            'required'              => true,
1743
-                            'html_label_text'       => esc_html__('Payment Method', 'event_espresso'),
1744
-                            'validation_strategies' => array(new EE_Int_Normalization()),
1745
-                        )
1746
-                    ),
1747
-                    'date'            => new EE_Text_Input(
1748
-                        array(
1749
-                            'default'         => time(),
1750
-                            'required'        => true,
1751
-                            'html_label_text' => esc_html__('Payment date', 'event_espresso'),
1752
-                        )
1753
-                    ),
1754
-                    'txn_id_chq_nmbr' => new EE_Text_Input(
1755
-                        array(
1756
-                            'default'               => '',
1757
-                            'required'              => false,
1758
-                            'html_label_text'       => esc_html__('Transaction or Cheque Number', 'event_espresso'),
1759
-                            'validation_strategies' => array(
1760
-                                new EE_Max_Length_Validation_Strategy(
1761
-                                    esc_html__('Input too long', 'event_espresso'),
1762
-                                    100
1763
-                                ),
1764
-                            ),
1765
-                        )
1766
-                    ),
1767
-                    'po_number'       => new EE_Text_Input(
1768
-                        array(
1769
-                            'default'               => '',
1770
-                            'required'              => false,
1771
-                            'html_label_text'       => esc_html__('Purchase Order Number', 'event_espresso'),
1772
-                            'validation_strategies' => array(
1773
-                                new EE_Max_Length_Validation_Strategy(
1774
-                                    esc_html__('Input too long', 'event_espresso'),
1775
-                                    100
1776
-                                ),
1777
-                            ),
1778
-                        )
1779
-                    ),
1780
-                    'accounting'      => new EE_Text_Input(
1781
-                        array(
1782
-                            'default'               => '',
1783
-                            'required'              => false,
1784
-                            'html_label_text'       => esc_html__('Extra Field for Accounting', 'event_espresso'),
1785
-                            'validation_strategies' => array(
1786
-                                new EE_Max_Length_Validation_Strategy(
1787
-                                    esc_html__('Input too long', 'event_espresso'),
1788
-                                    100
1789
-                                ),
1790
-                            ),
1791
-                        )
1792
-                    ),
1793
-                ),
1794
-            )
1795
-        );
1796
-    }
1797
-
1798
-
1799
-    /**
1800
-     * _create_payment_from_request_data
1801
-     *
1802
-     * @param array $valid_data
1803
-     * @return EE_Payment
1804
-     * @throws EE_Error
1805
-     */
1806
-    protected function _create_payment_from_request_data($valid_data)
1807
-    {
1808
-        $PAY_ID = $valid_data['PAY_ID'];
1809
-        // get payment amount
1810
-        $amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0;
1811
-        // payments have a type value of 1 and refunds have a type value of -1
1812
-        // so multiplying amount by type will give a positive value for payments, and negative values for refunds
1813
-        $amount = $valid_data['type'] < 0 ? $amount * -1 : $amount;
1814
-        // for some reason the date string coming in has extra spaces between the date and time.  This fixes that.
1815
-        $date = $valid_data['date']
1816
-            ? preg_replace('/\s+/', ' ', $valid_data['date'])
1817
-            : date('Y-m-d g:i a', current_time('timestamp'));
1818
-        $payment = EE_Payment::new_instance(
1819
-            array(
1820
-                'TXN_ID'              => $valid_data['TXN_ID'],
1821
-                'STS_ID'              => $valid_data['status'],
1822
-                'PAY_timestamp'       => $date,
1823
-                'PAY_source'          => EEM_Payment_Method::scope_admin,
1824
-                'PMD_ID'              => $valid_data['PMD_ID'],
1825
-                'PAY_amount'          => $amount,
1826
-                'PAY_txn_id_chq_nmbr' => $valid_data['txn_id_chq_nmbr'],
1827
-                'PAY_po_number'       => $valid_data['po_number'],
1828
-                'PAY_extra_accntng'   => $valid_data['accounting'],
1829
-                'PAY_details'         => $valid_data,
1830
-                'PAY_ID'              => $PAY_ID,
1831
-            ),
1832
-            '',
1833
-            array('Y-m-d', 'g:i a')
1834
-        );
1835
-
1836
-        if (! $payment->save()) {
1837
-            EE_Error::add_error(
1838
-                sprintf(
1839
-                    esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'),
1840
-                    $payment->ID()
1841
-                ),
1842
-                __FILE__,
1843
-                __FUNCTION__,
1844
-                __LINE__
1845
-            );
1846
-        }
1847
-
1848
-        return $payment;
1849
-    }
1850
-
1851
-
1852
-    /**
1853
-     * _process_transaction_payments
1854
-     *
1855
-     * @param \EE_Transaction $transaction
1856
-     * @return void
1857
-     * @throws EE_Error
1858
-     * @throws InvalidArgumentException
1859
-     * @throws ReflectionException
1860
-     * @throws InvalidDataTypeException
1861
-     * @throws InvalidInterfaceException
1862
-     */
1863
-    protected function _process_transaction_payments(EE_Transaction $transaction)
1864
-    {
1865
-        /** @type EE_Transaction_Payments $transaction_payments */
1866
-        $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1867
-        // update the transaction with this payment
1868
-        if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) {
1869
-            EE_Error::add_success(
1870
-                esc_html__(
1871
-                    'The payment has been processed successfully.',
1872
-                    'event_espresso'
1873
-                ),
1874
-                __FILE__,
1875
-                __FUNCTION__,
1876
-                __LINE__
1877
-            );
1878
-        } else {
1879
-            EE_Error::add_error(
1880
-                esc_html__(
1881
-                    'The payment was processed successfully but the amount paid for the transaction was not updated.',
1882
-                    'event_espresso'
1883
-                ),
1884
-                __FILE__,
1885
-                __FUNCTION__,
1886
-                __LINE__
1887
-            );
1888
-        }
1889
-    }
1890
-
1891
-
1892
-    /**
1893
-     * _get_REG_IDs_to_apply_payment_to
1894
-     * returns a list of registration IDs that the payment will apply to
1895
-     *
1896
-     * @param \EE_Payment $payment
1897
-     * @return array
1898
-     * @throws EE_Error
1899
-     */
1900
-    protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment)
1901
-    {
1902
-        $REG_IDs = array();
1903
-        // grab array of IDs for specific registrations to apply changes to
1904
-        if (isset($this->_req_data['txn_admin_payment']['registrations'])) {
1905
-            $REG_IDs = (array) $this->_req_data['txn_admin_payment']['registrations'];
1906
-        }
1907
-        // nothing specified ? then get all reg IDs
1908
-        if (empty($REG_IDs)) {
1909
-            $registrations = $payment->transaction()->registrations();
1910
-            $REG_IDs = ! empty($registrations)
1911
-                ? array_keys($registrations)
1912
-                : $this->_get_existing_reg_payment_REG_IDs($payment);
1913
-        }
1914
-
1915
-        // ensure that REG_IDs are integers and NOT strings
1916
-        return array_map('intval', $REG_IDs);
1917
-    }
1918
-
1919
-
1920
-    /**
1921
-     * @return array
1922
-     */
1923
-    public function existing_reg_payment_REG_IDs()
1924
-    {
1925
-        return $this->_existing_reg_payment_REG_IDs;
1926
-    }
1927
-
1928
-
1929
-    /**
1930
-     * @param array $existing_reg_payment_REG_IDs
1931
-     */
1932
-    public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null)
1933
-    {
1934
-        $this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs;
1935
-    }
1936
-
1937
-
1938
-    /**
1939
-     * _get_existing_reg_payment_REG_IDs
1940
-     * returns a list of registration IDs that the payment is currently related to
1941
-     * as recorded in the database
1942
-     *
1943
-     * @param \EE_Payment $payment
1944
-     * @return array
1945
-     * @throws EE_Error
1946
-     */
1947
-    protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment)
1948
-    {
1949
-        if ($this->existing_reg_payment_REG_IDs() === null) {
1950
-            // let's get any existing reg payment records for this payment
1951
-            $existing_reg_payment_REG_IDs = $payment->get_many_related('Registration');
1952
-            // but we only want the REG IDs, so grab the array keys
1953
-            $existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs)
1954
-                ? array_keys($existing_reg_payment_REG_IDs)
1955
-                : array();
1956
-            $this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs);
1957
-        }
1958
-
1959
-        return $this->existing_reg_payment_REG_IDs();
1960
-    }
1961
-
1962
-
1963
-    /**
1964
-     * _remove_existing_registration_payments
1965
-     * this calculates the difference between existing relations
1966
-     * to the supplied payment and the new list registration IDs,
1967
-     * removes any related registrations that no longer apply,
1968
-     * and then updates the registration paid fields
1969
-     *
1970
-     * @param \EE_Payment $payment
1971
-     * @param int         $PAY_ID
1972
-     * @return bool;
1973
-     * @throws EE_Error
1974
-     * @throws InvalidArgumentException
1975
-     * @throws ReflectionException
1976
-     * @throws InvalidDataTypeException
1977
-     * @throws InvalidInterfaceException
1978
-     */
1979
-    protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0)
1980
-    {
1981
-        // newly created payments will have nothing recorded for $PAY_ID
1982
-        if ($PAY_ID == 0) {
1983
-            return false;
1984
-        }
1985
-        $existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
1986
-        if (empty($existing_reg_payment_REG_IDs)) {
1987
-            return false;
1988
-        }
1989
-        /** @type EE_Transaction_Payments $transaction_payments */
1990
-        $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1991
-
1992
-        return $transaction_payments->delete_registration_payments_and_update_registrations(
1993
-            $payment,
1994
-            array(
1995
-                array(
1996
-                    'PAY_ID' => $payment->ID(),
1997
-                    'REG_ID' => array('IN', $existing_reg_payment_REG_IDs),
1998
-                ),
1999
-            )
2000
-        );
2001
-    }
2002
-
2003
-
2004
-    /**
2005
-     * _update_registration_payments
2006
-     * this applies the payments to the selected registrations
2007
-     * but only if they have not already been paid for
2008
-     *
2009
-     * @param  EE_Transaction $transaction
2010
-     * @param \EE_Payment     $payment
2011
-     * @param array           $REG_IDs
2012
-     * @return void
2013
-     * @throws EE_Error
2014
-     * @throws InvalidArgumentException
2015
-     * @throws ReflectionException
2016
-     * @throws RuntimeException
2017
-     * @throws InvalidDataTypeException
2018
-     * @throws InvalidInterfaceException
2019
-     */
2020
-    protected function _update_registration_payments(
2021
-        EE_Transaction $transaction,
2022
-        EE_Payment $payment,
2023
-        $REG_IDs = array()
2024
-    ) {
2025
-        // we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments()
2026
-        // so let's do that using our set of REG_IDs from the form
2027
-        $registration_query_where_params = array(
2028
-            'REG_ID' => array('IN', $REG_IDs),
2029
-        );
2030
-        // but add in some conditions regarding payment,
2031
-        // so that we don't apply payments to registrations that are free or have already been paid for
2032
-        // but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative )
2033
-        if (! $payment->is_a_refund()) {
2034
-            $registration_query_where_params['REG_final_price'] = array('!=', 0);
2035
-            $registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true);
2036
-        }
2037
-        $registrations = $transaction->registrations(array($registration_query_where_params));
2038
-        if (! empty($registrations)) {
2039
-            /** @type EE_Payment_Processor $payment_processor */
2040
-            $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2041
-            $payment_processor->process_registration_payments($transaction, $payment, $registrations);
2042
-        }
2043
-    }
2044
-
2045
-
2046
-    /**
2047
-     * _process_registration_status_change
2048
-     * This processes requested registration status changes for all the registrations
2049
-     * on a given transaction and (optionally) sends out notifications for the changes.
2050
-     *
2051
-     * @param  EE_Transaction $transaction
2052
-     * @param array           $REG_IDs
2053
-     * @return bool
2054
-     * @throws EE_Error
2055
-     * @throws InvalidArgumentException
2056
-     * @throws ReflectionException
2057
-     * @throws InvalidDataTypeException
2058
-     * @throws InvalidInterfaceException
2059
-     */
2060
-    protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array())
2061
-    {
2062
-        // first if there is no change in status then we get out.
2063
-        if (! isset($this->_req_data['txn_reg_status_change']['reg_status'])
2064
-            || $this->_req_data['txn_reg_status_change']['reg_status'] === 'NAN'
2065
-        ) {
2066
-            // no error message, no change requested, just nothing to do man.
2067
-            return false;
2068
-        }
2069
-        /** @type EE_Transaction_Processor $transaction_processor */
2070
-        $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
2071
-
2072
-        // made it here dude?  Oh WOW.  K, let's take care of changing the statuses
2073
-        return $transaction_processor->manually_update_registration_statuses(
2074
-            $transaction,
2075
-            sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']),
2076
-            array(array('REG_ID' => array('IN', $REG_IDs)))
2077
-        );
2078
-    }
2079
-
2080
-
2081
-    /**
2082
-     * _build_payment_json_response
2083
-     *
2084
-     * @access public
2085
-     * @param \EE_Payment $payment
2086
-     * @param array       $REG_IDs
2087
-     * @param bool | null $delete_txn_reg_status_change
2088
-     * @return array
2089
-     * @throws EE_Error
2090
-     * @throws InvalidArgumentException
2091
-     * @throws InvalidDataTypeException
2092
-     * @throws InvalidInterfaceException
2093
-     * @throws ReflectionException
2094
-     */
2095
-    protected function _build_payment_json_response(
2096
-        EE_Payment $payment,
2097
-        $REG_IDs = array(),
2098
-        $delete_txn_reg_status_change = null
2099
-    ) {
2100
-        // was the payment deleted ?
2101
-        if (is_bool($delete_txn_reg_status_change)) {
2102
-            return array(
2103
-                'PAY_ID'                       => $payment->ID(),
2104
-                'amount'                       => $payment->amount(),
2105
-                'total_paid'                   => $payment->transaction()->paid(),
2106
-                'txn_status'                   => $payment->transaction()->status_ID(),
2107
-                'pay_status'                   => $payment->STS_ID(),
2108
-                'registrations'                => $this->_registration_payment_data_array($REG_IDs),
2109
-                'delete_txn_reg_status_change' => $delete_txn_reg_status_change,
2110
-            );
2111
-        } else {
2112
-            $this->_get_payment_status_array();
2113
-
2114
-            return array(
2115
-                'amount'           => $payment->amount(),
2116
-                'total_paid'       => $payment->transaction()->paid(),
2117
-                'txn_status'       => $payment->transaction()->status_ID(),
2118
-                'pay_status'       => $payment->STS_ID(),
2119
-                'PAY_ID'           => $payment->ID(),
2120
-                'STS_ID'           => $payment->STS_ID(),
2121
-                'status'           => self::$_pay_status[ $payment->STS_ID() ],
2122
-                'date'             => $payment->timestamp('Y-m-d', 'h:i a'),
2123
-                'method'           => strtoupper($payment->source()),
2124
-                'PM_ID'            => $payment->payment_method() ? $payment->payment_method()->ID() : 1,
2125
-                'gateway'          => $payment->payment_method()
2126
-                    ? $payment->payment_method()->admin_name()
2127
-                    : esc_html__("Unknown", 'event_espresso'),
2128
-                'gateway_response' => $payment->gateway_response(),
2129
-                'txn_id_chq_nmbr'  => $payment->txn_id_chq_nmbr(),
2130
-                'po_number'        => $payment->po_number(),
2131
-                'extra_accntng'    => $payment->extra_accntng(),
2132
-                'registrations'    => $this->_registration_payment_data_array($REG_IDs),
2133
-            );
2134
-        }
2135
-    }
2136
-
2137
-
2138
-    /**
2139
-     * delete_payment
2140
-     *    delete a payment or refund made towards a transaction
2141
-     *
2142
-     * @access public
2143
-     * @return void
2144
-     * @throws EE_Error
2145
-     * @throws InvalidArgumentException
2146
-     * @throws ReflectionException
2147
-     * @throws InvalidDataTypeException
2148
-     * @throws InvalidInterfaceException
2149
-     */
2150
-    public function delete_payment()
2151
-    {
2152
-        $json_response_data = array('return_data' => false);
2153
-        $PAY_ID = isset($this->_req_data['delete_txn_admin_payment']['PAY_ID'])
2154
-            ? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID'])
2155
-            : 0;
2156
-        $can_delete = EE_Registry::instance()->CAP->current_user_can(
2157
-            'ee_delete_payments',
2158
-            'delete_payment_from_registration_details'
2159
-        );
2160
-        if ($PAY_ID && $can_delete) {
2161
-            $delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change'])
2162
-                ? $this->_req_data['delete_txn_reg_status_change']
2163
-                : false;
2164
-            $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
2165
-            if ($payment instanceof EE_Payment) {
2166
-                $REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
2167
-                /** @type EE_Transaction_Payments $transaction_payments */
2168
-                $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
2169
-                if ($transaction_payments->delete_payment_and_update_transaction($payment)) {
2170
-                    $json_response_data['return_data'] = $this->_build_payment_json_response(
2171
-                        $payment,
2172
-                        $REG_IDs,
2173
-                        $delete_txn_reg_status_change
2174
-                    );
2175
-                    if ($delete_txn_reg_status_change) {
2176
-                        $this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change;
2177
-                        // MAKE sure we also add the delete_txn_req_status_change to the
2178
-                        // $_REQUEST global because that's how messages will be looking for it.
2179
-                        $_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change;
2180
-                        $this->_maybe_send_notifications();
2181
-                        $this->_process_registration_status_change($payment->transaction(), $REG_IDs);
2182
-                    }
2183
-                }
2184
-            } else {
2185
-                EE_Error::add_error(
2186
-                    esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'),
2187
-                    __FILE__,
2188
-                    __FUNCTION__,
2189
-                    __LINE__
2190
-                );
2191
-            }
2192
-        } else {
2193
-            if ($can_delete) {
2194
-                EE_Error::add_error(
2195
-                    esc_html__(
2196
-                        'A valid Payment ID was not received, therefore payment form data could not be loaded.',
2197
-                        'event_espresso'
2198
-                    ),
2199
-                    __FILE__,
2200
-                    __FUNCTION__,
2201
-                    __LINE__
2202
-                );
2203
-            } else {
2204
-                EE_Error::add_error(
2205
-                    esc_html__(
2206
-                        'You do not have access to delete a payment.',
2207
-                        'event_espresso'
2208
-                    ),
2209
-                    __FILE__,
2210
-                    __FUNCTION__,
2211
-                    __LINE__
2212
-                );
2213
-            }
2214
-        }
2215
-        $notices = EE_Error::get_notices(false, false, false);
2216
-        $this->_template_args = array(
2217
-            'data'      => $json_response_data,
2218
-            'success'   => $notices['success'],
2219
-            'error'     => $notices['errors'],
2220
-            'attention' => $notices['attention'],
2221
-        );
2222
-        $this->_return_json();
2223
-    }
2224
-
2225
-
2226
-    /**
2227
-     * _registration_payment_data_array
2228
-     * adds info for 'owing' and 'paid' for each registration to the json response
2229
-     *
2230
-     * @access protected
2231
-     * @param array $REG_IDs
2232
-     * @return array
2233
-     * @throws EE_Error
2234
-     * @throws InvalidArgumentException
2235
-     * @throws InvalidDataTypeException
2236
-     * @throws InvalidInterfaceException
2237
-     * @throws ReflectionException
2238
-     */
2239
-    protected function _registration_payment_data_array($REG_IDs)
2240
-    {
2241
-        $registration_payment_data = array();
2242
-        // if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
2243
-        if (! empty($REG_IDs)) {
2244
-            $registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs))));
2245
-            foreach ($registrations as $registration) {
2246
-                if ($registration instanceof EE_Registration) {
2247
-                    $registration_payment_data[ $registration->ID() ] = array(
2248
-                        'paid'  => $registration->pretty_paid(),
2249
-                        'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()),
2250
-                    );
2251
-                }
2252
-            }
2253
-        }
2254
-
2255
-        return $registration_payment_data;
2256
-    }
2257
-
2258
-
2259
-    /**
2260
-     * _maybe_send_notifications
2261
-     * determines whether or not the admin has indicated that notifications should be sent.
2262
-     * If so, will toggle a filter switch for delivering registration notices.
2263
-     * If passed an EE_Payment object, then it will trigger payment notifications instead.
2264
-     *
2265
-     * @access protected
2266
-     * @param \EE_Payment | null $payment
2267
-     */
2268
-    protected function _maybe_send_notifications($payment = null)
2269
-    {
2270
-        switch ($payment instanceof EE_Payment) {
2271
-            // payment notifications
2272
-            case true:
2273
-                if (isset(
2274
-                    $this->_req_data['txn_payments'],
2275
-                    $this->_req_data['txn_payments']['send_notifications']
2276
-                )
2277
-                    && filter_var($this->_req_data['txn_payments']['send_notifications'], FILTER_VALIDATE_BOOLEAN)
2278
-                ) {
2279
-                    $this->_process_payment_notification($payment);
2280
-                }
2281
-                break;
2282
-            // registration notifications
2283
-            case false:
2284
-                if (isset(
2285
-                    $this->_req_data['txn_reg_status_change'],
2286
-                    $this->_req_data['txn_reg_status_change']['send_notifications']
2287
-                )
2288
-                    && filter_var($this->_req_data['txn_reg_status_change']['send_notifications'], FILTER_VALIDATE_BOOLEAN)
2289
-                ) {
2290
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
2291
-                }
2292
-                break;
2293
-        }
2294
-    }
2295
-
2296
-
2297
-    /**
2298
-     * _send_payment_reminder
2299
-     *    generates HTML for the View Transaction Details Admin page
2300
-     *
2301
-     * @access protected
2302
-     * @return void
2303
-     * @throws EE_Error
2304
-     * @throws InvalidArgumentException
2305
-     * @throws InvalidDataTypeException
2306
-     * @throws InvalidInterfaceException
2307
-     */
2308
-    protected function _send_payment_reminder()
2309
-    {
2310
-        $TXN_ID = ! empty($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : false;
2311
-        $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2312
-        $query_args = isset($this->_req_data['redirect_to']) ? array(
2313
-            'action' => $this->_req_data['redirect_to'],
2314
-            'TXN_ID' => $this->_req_data['TXN_ID'],
2315
-        ) : array();
2316
-        do_action(
2317
-            'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder',
2318
-            $transaction
2319
-        );
2320
-        $this->_redirect_after_action(
2321
-            false,
2322
-            esc_html__('payment reminder', 'event_espresso'),
2323
-            esc_html__('sent', 'event_espresso'),
2324
-            $query_args,
2325
-            true
2326
-        );
2327
-    }
2328
-
2329
-
2330
-    /**
2331
-     *  get_transactions
2332
-     *    get transactions for given parameters (used by list table)
2333
-     *
2334
-     * @param  int     $perpage how many transactions displayed per page
2335
-     * @param  boolean $count   return the count or objects
2336
-     * @param string   $view
2337
-     * @return mixed int = count || array of transaction objects
2338
-     * @throws EE_Error
2339
-     * @throws InvalidArgumentException
2340
-     * @throws InvalidDataTypeException
2341
-     * @throws InvalidInterfaceException
2342
-     */
2343
-    public function get_transactions($perpage, $count = false, $view = '')
2344
-    {
2345
-
2346
-        $TXN = EEM_Transaction::instance();
2347
-
2348
-        $start_date = isset($this->_req_data['txn-filter-start-date'])
2349
-            ? wp_strip_all_tags($this->_req_data['txn-filter-start-date'])
2350
-            : date(
2351
-                'm/d/Y',
2352
-                strtotime('-10 year')
2353
-            );
2354
-        $end_date = isset($this->_req_data['txn-filter-end-date'])
2355
-            ? wp_strip_all_tags($this->_req_data['txn-filter-end-date'])
2356
-            : date('m/d/Y');
2357
-
2358
-        // make sure our timestamps start and end right at the boundaries for each day
2359
-        $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
2360
-        $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
2361
-
2362
-
2363
-        // convert to timestamps
2364
-        $start_date = strtotime($start_date);
2365
-        $end_date = strtotime($end_date);
2366
-
2367
-        // makes sure start date is the lowest value and vice versa
2368
-        $start_date = min($start_date, $end_date);
2369
-        $end_date = max($start_date, $end_date);
2370
-
2371
-        // convert to correct format for query
2372
-        $start_date = EEM_Transaction::instance()->convert_datetime_for_query(
2373
-            'TXN_timestamp',
2374
-            date('Y-m-d H:i:s', $start_date),
2375
-            'Y-m-d H:i:s'
2376
-        );
2377
-        $end_date = EEM_Transaction::instance()->convert_datetime_for_query(
2378
-            'TXN_timestamp',
2379
-            date('Y-m-d H:i:s', $end_date),
2380
-            'Y-m-d H:i:s'
2381
-        );
2382
-
2383
-
2384
-        // set orderby
2385
-        $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
2386
-
2387
-        switch ($this->_req_data['orderby']) {
2388
-            case 'TXN_ID':
2389
-                $orderby = 'TXN_ID';
2390
-                break;
2391
-            case 'ATT_fname':
2392
-                $orderby = 'Registration.Attendee.ATT_fname';
2393
-                break;
2394
-            case 'event_name':
2395
-                $orderby = 'Registration.Event.EVT_name';
2396
-                break;
2397
-            default: // 'TXN_timestamp'
2398
-                $orderby = 'TXN_timestamp';
2399
-        }
2400
-
2401
-        $sort = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2402
-        $current_page = ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
2403
-        $per_page = ! empty($perpage) ? $perpage : 10;
2404
-        $per_page = ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
2405
-
2406
-        $offset = ($current_page - 1) * $per_page;
2407
-        $limit = array($offset, $per_page);
2408
-
2409
-        $_where = array(
2410
-            'TXN_timestamp'          => array('BETWEEN', array($start_date, $end_date)),
2411
-            'Registration.REG_count' => 1,
2412
-        );
2413
-
2414
-        if (isset($this->_req_data['EVT_ID'])) {
2415
-            $_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID'];
2416
-        }
2417
-
2418
-        if (isset($this->_req_data['s'])) {
2419
-            $search_string = '%' . $this->_req_data['s'] . '%';
2420
-            $_where['OR'] = array(
2421
-                'Registration.Event.EVT_name'         => array('LIKE', $search_string),
2422
-                'Registration.Event.EVT_desc'         => array('LIKE', $search_string),
2423
-                'Registration.Event.EVT_short_desc'   => array('LIKE', $search_string),
2424
-                'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string),
2425
-                'Registration.Attendee.ATT_fname'     => array('LIKE', $search_string),
2426
-                'Registration.Attendee.ATT_lname'     => array('LIKE', $search_string),
2427
-                'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string),
2428
-                'Registration.Attendee.ATT_email'     => array('LIKE', $search_string),
2429
-                'Registration.Attendee.ATT_address'   => array('LIKE', $search_string),
2430
-                'Registration.Attendee.ATT_address2'  => array('LIKE', $search_string),
2431
-                'Registration.Attendee.ATT_city'      => array('LIKE', $search_string),
2432
-                'Registration.REG_final_price'        => array('LIKE', $search_string),
2433
-                'Registration.REG_code'               => array('LIKE', $search_string),
2434
-                'Registration.REG_count'              => array('LIKE', $search_string),
2435
-                'Registration.REG_group_size'         => array('LIKE', $search_string),
2436
-                'Registration.Ticket.TKT_name'        => array('LIKE', $search_string),
2437
-                'Registration.Ticket.TKT_description' => array('LIKE', $search_string),
2438
-                'Payment.PAY_source'                  => array('LIKE', $search_string),
2439
-                'Payment.Payment_Method.PMD_name'     => array('LIKE', $search_string),
2440
-                'TXN_session_data'                    => array('LIKE', $search_string),
2441
-                'Payment.PAY_txn_id_chq_nmbr'         => array('LIKE', $search_string),
2442
-            );
2443
-        }
2444
-
2445
-        // failed transactions
2446
-        $failed = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'failed' && ! $count)
2447
-                  || ($count && $view === 'failed');
2448
-        $abandoned = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'abandoned' && ! $count)
2449
-                     || ($count && $view === 'abandoned');
2450
-
2451
-        if ($failed) {
2452
-            $_where['STS_ID'] = EEM_Transaction::failed_status_code;
2453
-        } elseif ($abandoned) {
2454
-            $_where['STS_ID'] = EEM_Transaction::abandoned_status_code;
2455
-        } else {
2456
-            $_where['STS_ID'] = array('!=', EEM_Transaction::failed_status_code);
2457
-            $_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code);
2458
-        }
2459
-
2460
-        $query_params = array(
2461
-            $_where,
2462
-            'order_by'                 => array($orderby => $sort),
2463
-            'limit'                    => $limit,
2464
-            'default_where_conditions' => EEM_Base::default_where_conditions_this_only,
2465
-        );
2466
-
2467
-        $transactions = $count
2468
-            ? $TXN->count(array($_where), 'TXN_ID', true)
2469
-            : $TXN->get_all($query_params);
2470
-
2471
-        return $transactions;
2472
-    }
17
+	/**
18
+	 * @var EE_Transaction
19
+	 */
20
+	private $_transaction;
21
+
22
+	/**
23
+	 * @var EE_Session
24
+	 */
25
+	private $_session;
26
+
27
+	/**
28
+	 * @var array $_txn_status
29
+	 */
30
+	private static $_txn_status;
31
+
32
+	/**
33
+	 * @var array $_pay_status
34
+	 */
35
+	private static $_pay_status;
36
+
37
+	/**
38
+	 * @var array $_existing_reg_payment_REG_IDs
39
+	 */
40
+	protected $_existing_reg_payment_REG_IDs = null;
41
+
42
+
43
+	/**
44
+	 * @Constructor
45
+	 * @access public
46
+	 * @param bool $routing
47
+	 * @throws EE_Error
48
+	 * @throws InvalidArgumentException
49
+	 * @throws ReflectionException
50
+	 * @throws InvalidDataTypeException
51
+	 * @throws InvalidInterfaceException
52
+	 */
53
+	public function __construct($routing = true)
54
+	{
55
+		parent::__construct($routing);
56
+	}
57
+
58
+
59
+	/**
60
+	 *    _init_page_props
61
+	 *
62
+	 * @return void
63
+	 */
64
+	protected function _init_page_props()
65
+	{
66
+		$this->page_slug = TXN_PG_SLUG;
67
+		$this->page_label = esc_html__('Transactions', 'event_espresso');
68
+		$this->_admin_base_url = TXN_ADMIN_URL;
69
+		$this->_admin_base_path = TXN_ADMIN;
70
+	}
71
+
72
+
73
+	/**
74
+	 *    _ajax_hooks
75
+	 *
76
+	 * @return void
77
+	 */
78
+	protected function _ajax_hooks()
79
+	{
80
+		add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds'));
81
+		add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds'));
82
+		add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment'));
83
+	}
84
+
85
+
86
+	/**
87
+	 *    _define_page_props
88
+	 *
89
+	 * @return void
90
+	 */
91
+	protected function _define_page_props()
92
+	{
93
+		$this->_admin_page_title = $this->page_label;
94
+		$this->_labels = array(
95
+			'buttons' => array(
96
+				'add'    => esc_html__('Add New Transaction', 'event_espresso'),
97
+				'edit'   => esc_html__('Edit Transaction', 'event_espresso'),
98
+				'delete' => esc_html__('Delete Transaction', 'event_espresso'),
99
+			),
100
+		);
101
+	}
102
+
103
+
104
+	/**
105
+	 *        grab url requests and route them
106
+	 *
107
+	 * @access private
108
+	 * @return void
109
+	 * @throws EE_Error
110
+	 * @throws InvalidArgumentException
111
+	 * @throws InvalidDataTypeException
112
+	 * @throws InvalidInterfaceException
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'])
120
+				  && ! is_array($this->_req_data['TXN_ID'])
121
+			? $this->_req_data['TXN_ID']
122
+			: 0;
123
+
124
+		$this->_page_routes = array(
125
+
126
+			'default' => array(
127
+				'func'       => '_transactions_overview_list_table',
128
+				'capability' => 'ee_read_transactions',
129
+			),
130
+
131
+			'view_transaction' => array(
132
+				'func'       => '_transaction_details',
133
+				'capability' => 'ee_read_transaction',
134
+				'obj_id'     => $txn_id,
135
+			),
136
+
137
+			'send_payment_reminder' => array(
138
+				'func'       => '_send_payment_reminder',
139
+				'noheader'   => true,
140
+				'capability' => 'ee_send_message',
141
+			),
142
+
143
+			'espresso_apply_payment' => array(
144
+				'func'       => 'apply_payments_or_refunds',
145
+				'noheader'   => true,
146
+				'capability' => 'ee_edit_payments',
147
+			),
148
+
149
+			'espresso_apply_refund' => array(
150
+				'func'       => 'apply_payments_or_refunds',
151
+				'noheader'   => true,
152
+				'capability' => 'ee_edit_payments',
153
+			),
154
+
155
+			'espresso_delete_payment' => array(
156
+				'func'       => 'delete_payment',
157
+				'noheader'   => true,
158
+				'capability' => 'ee_delete_payments',
159
+			),
160
+
161
+		);
162
+	}
163
+
164
+
165
+	protected function _set_page_config()
166
+	{
167
+		$this->_page_config = array(
168
+			'default'          => array(
169
+				'nav'           => array(
170
+					'label' => esc_html__('Overview', 'event_espresso'),
171
+					'order' => 10,
172
+				),
173
+				'list_table'    => 'EE_Admin_Transactions_List_Table',
174
+				'help_tabs'     => array(
175
+					'transactions_overview_help_tab'                       => array(
176
+						'title'    => esc_html__('Transactions Overview', 'event_espresso'),
177
+						'filename' => 'transactions_overview',
178
+					),
179
+					'transactions_overview_table_column_headings_help_tab' => array(
180
+						'title'    => esc_html__('Transactions Table Column Headings', 'event_espresso'),
181
+						'filename' => 'transactions_overview_table_column_headings',
182
+					),
183
+					'transactions_overview_views_filters_help_tab'         => array(
184
+						'title'    => esc_html__('Transaction Views & Filters & Search', 'event_espresso'),
185
+						'filename' => 'transactions_overview_views_filters_search',
186
+					),
187
+				),
188
+				'help_tour'     => array('Transactions_Overview_Help_Tour'),
189
+				/**
190
+				 * commented out because currently we are not displaying tips for transaction list table status but this
191
+				 * may change in a later iteration so want to keep the code for then.
192
+				 */
193
+				// 'qtips' => array( 'Transactions_List_Table_Tips' ),
194
+				'require_nonce' => false,
195
+			),
196
+			'view_transaction' => array(
197
+				'nav'       => array(
198
+					'label'      => esc_html__('View Transaction', 'event_espresso'),
199
+					'order'      => 5,
200
+					'url'        => isset($this->_req_data['TXN_ID'])
201
+						? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']), $this->_current_page_view_url)
202
+						: $this->_admin_base_url,
203
+					'persistent' => false,
204
+				),
205
+				'help_tabs' => array(
206
+					'transactions_view_transaction_help_tab'                                              => array(
207
+						'title'    => esc_html__('View Transaction', 'event_espresso'),
208
+						'filename' => 'transactions_view_transaction',
209
+					),
210
+					'transactions_view_transaction_transaction_details_table_help_tab'                    => array(
211
+						'title'    => esc_html__('Transaction Details Table', 'event_espresso'),
212
+						'filename' => 'transactions_view_transaction_transaction_details_table',
213
+					),
214
+					'transactions_view_transaction_attendees_registered_help_tab'                         => array(
215
+						'title'    => esc_html__('Attendees Registered', 'event_espresso'),
216
+						'filename' => 'transactions_view_transaction_attendees_registered',
217
+					),
218
+					'transactions_view_transaction_views_primary_registrant_billing_information_help_tab' => array(
219
+						'title'    => esc_html__('Primary Registrant & Billing Information', 'event_espresso'),
220
+						'filename' => 'transactions_view_transaction_primary_registrant_billing_information',
221
+					),
222
+				),
223
+				'qtips'     => array('Transaction_Details_Tips'),
224
+				'help_tour' => array('Transaction_Details_Help_Tour'),
225
+				'metaboxes' => array('_transaction_details_metaboxes'),
226
+
227
+				'require_nonce' => false,
228
+			),
229
+		);
230
+	}
231
+
232
+
233
+	/**
234
+	 * The below methods aren't used by this class currently
235
+	 */
236
+	protected function _add_screen_options()
237
+	{
238
+		// noop
239
+	}
240
+
241
+	protected function _add_feature_pointers()
242
+	{
243
+		// noop
244
+	}
245
+
246
+	public function admin_init()
247
+	{
248
+		// IF a registration was JUST added via the admin...
249
+		if (isset(
250
+			$this->_req_data['redirect_from'],
251
+			$this->_req_data['EVT_ID'],
252
+			$this->_req_data['event_name']
253
+		)) {
254
+			// then set a cookie so that we can block any attempts to use
255
+			// the back button as a way to enter another registration.
256
+			setcookie(
257
+				'ee_registration_added',
258
+				$this->_req_data['EVT_ID'],
259
+				time() + WEEK_IN_SECONDS,
260
+				'/'
261
+			);
262
+			// and update the global
263
+			$_COOKIE['ee_registration_added'] = $this->_req_data['EVT_ID'];
264
+		}
265
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__(
266
+			'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.',
267
+			'event_espresso'
268
+		);
269
+		EE_Registry::$i18n_js_strings['error_occurred'] = esc_html__(
270
+			'An error occurred! Please refresh the page and try again.',
271
+			'event_espresso'
272
+		);
273
+		EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status;
274
+		EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status;
275
+		EE_Registry::$i18n_js_strings['payments_total'] = esc_html__('Payments Total', 'event_espresso');
276
+		EE_Registry::$i18n_js_strings['transaction_overpaid'] = esc_html__(
277
+			'This transaction has been overpaid ! Payments Total',
278
+			'event_espresso'
279
+		);
280
+	}
281
+
282
+	public function admin_notices()
283
+	{
284
+		// noop
285
+	}
286
+
287
+	public function admin_footer_scripts()
288
+	{
289
+		// noop
290
+	}
291
+
292
+
293
+	/**
294
+	 * _set_transaction_status_array
295
+	 * sets list of transaction statuses
296
+	 *
297
+	 * @access private
298
+	 * @return void
299
+	 * @throws EE_Error
300
+	 * @throws InvalidArgumentException
301
+	 * @throws InvalidDataTypeException
302
+	 * @throws InvalidInterfaceException
303
+	 */
304
+	private function _set_transaction_status_array()
305
+	{
306
+		self::$_txn_status = EEM_Transaction::instance()->status_array(true);
307
+	}
308
+
309
+
310
+	/**
311
+	 * get_transaction_status_array
312
+	 * return the transaction status array for wp_list_table
313
+	 *
314
+	 * @access public
315
+	 * @return array
316
+	 */
317
+	public function get_transaction_status_array()
318
+	{
319
+		return self::$_txn_status;
320
+	}
321
+
322
+
323
+	/**
324
+	 *    get list of payment statuses
325
+	 *
326
+	 * @access private
327
+	 * @return void
328
+	 * @throws EE_Error
329
+	 * @throws InvalidArgumentException
330
+	 * @throws InvalidDataTypeException
331
+	 * @throws InvalidInterfaceException
332
+	 */
333
+	private function _get_payment_status_array()
334
+	{
335
+		self::$_pay_status = EEM_Payment::instance()->status_array(true);
336
+		$this->_template_args['payment_status'] = self::$_pay_status;
337
+	}
338
+
339
+
340
+	/**
341
+	 *    _add_screen_options_default
342
+	 *
343
+	 * @access protected
344
+	 * @return void
345
+	 * @throws InvalidArgumentException
346
+	 * @throws InvalidDataTypeException
347
+	 * @throws InvalidInterfaceException
348
+	 */
349
+	protected function _add_screen_options_default()
350
+	{
351
+		$this->_per_page_screen_option();
352
+	}
353
+
354
+
355
+	/**
356
+	 * load_scripts_styles
357
+	 *
358
+	 * @access public
359
+	 * @return void
360
+	 */
361
+	public function load_scripts_styles()
362
+	{
363
+		// enqueue style
364
+		wp_register_style(
365
+			'espresso_txn',
366
+			TXN_ASSETS_URL . 'espresso_transactions_admin.css',
367
+			array(),
368
+			EVENT_ESPRESSO_VERSION
369
+		);
370
+		wp_enqueue_style('espresso_txn');
371
+		// scripts
372
+		wp_register_script(
373
+			'espresso_txn',
374
+			TXN_ASSETS_URL . 'espresso_transactions_admin.js',
375
+			array(
376
+				'ee_admin_js',
377
+				'ee-datepicker',
378
+				'jquery-ui-datepicker',
379
+				'jquery-ui-draggable',
380
+				'ee-dialog',
381
+				'ee-accounting',
382
+				'ee-serialize-full-array',
383
+			),
384
+			EVENT_ESPRESSO_VERSION,
385
+			true
386
+		);
387
+		wp_enqueue_script('espresso_txn');
388
+	}
389
+
390
+
391
+	/**
392
+	 *    load_scripts_styles_view_transaction
393
+	 *
394
+	 * @access public
395
+	 * @return void
396
+	 */
397
+	public function load_scripts_styles_view_transaction()
398
+	{
399
+		// styles
400
+		wp_enqueue_style('espresso-ui-theme');
401
+	}
402
+
403
+
404
+	/**
405
+	 *    load_scripts_styles_default
406
+	 *
407
+	 * @access public
408
+	 * @return void
409
+	 */
410
+	public function load_scripts_styles_default()
411
+	{
412
+		// styles
413
+		wp_enqueue_style('espresso-ui-theme');
414
+	}
415
+
416
+
417
+	/**
418
+	 *    _set_list_table_views_default
419
+	 *
420
+	 * @access protected
421
+	 * @return void
422
+	 */
423
+	protected function _set_list_table_views_default()
424
+	{
425
+		$this->_views = array(
426
+			'all'       => array(
427
+				'slug'  => 'all',
428
+				'label' => esc_html__('View All Transactions', 'event_espresso'),
429
+				'count' => 0,
430
+			),
431
+			'abandoned' => array(
432
+				'slug'  => 'abandoned',
433
+				'label' => esc_html__('Abandoned Transactions', 'event_espresso'),
434
+				'count' => 0,
435
+			),
436
+			'failed'    => array(
437
+				'slug'  => 'failed',
438
+				'label' => esc_html__('Failed Transactions', 'event_espresso'),
439
+				'count' => 0,
440
+			),
441
+		);
442
+	}
443
+
444
+
445
+	/**
446
+	 * _set_transaction_object
447
+	 * This sets the _transaction property for the transaction details screen
448
+	 *
449
+	 * @access private
450
+	 * @return void
451
+	 * @throws EE_Error
452
+	 * @throws InvalidArgumentException
453
+	 * @throws RuntimeException
454
+	 * @throws InvalidDataTypeException
455
+	 * @throws InvalidInterfaceException
456
+	 * @throws ReflectionException
457
+	 */
458
+	private function _set_transaction_object()
459
+	{
460
+		if ($this->_transaction instanceof EE_Transaction) {
461
+			return;
462
+		} //get out we've already set the object
463
+
464
+		$TXN_ID = ! empty($this->_req_data['TXN_ID'])
465
+			? absint($this->_req_data['TXN_ID'])
466
+			: false;
467
+
468
+		// get transaction object
469
+		$this->_transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
470
+		$this->_session = $this->_transaction instanceof EE_Transaction
471
+			? $this->_transaction->get('TXN_session_data')
472
+			: null;
473
+		$this->_transaction->verify_abandoned_transaction_status();
474
+
475
+		if (! $this->_transaction instanceof EE_Transaction) {
476
+			$error_msg = sprintf(
477
+				esc_html__(
478
+					'An error occurred and the details for the transaction with the ID # %d could not be retrieved.',
479
+					'event_espresso'
480
+				),
481
+				$TXN_ID
482
+			);
483
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
484
+		}
485
+	}
486
+
487
+
488
+	/**
489
+	 *    _transaction_legend_items
490
+	 *
491
+	 * @access protected
492
+	 * @return array
493
+	 * @throws EE_Error
494
+	 * @throws InvalidArgumentException
495
+	 * @throws ReflectionException
496
+	 * @throws InvalidDataTypeException
497
+	 * @throws InvalidInterfaceException
498
+	 */
499
+	protected function _transaction_legend_items()
500
+	{
501
+		EE_Registry::instance()->load_helper('MSG_Template');
502
+		$items = array();
503
+
504
+		if (EE_Registry::instance()->CAP->current_user_can(
505
+			'ee_read_global_messages',
506
+			'view_filtered_messages'
507
+		)) {
508
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
509
+			if (is_array($related_for_icon)
510
+				&& isset($related_for_icon['css_class'], $related_for_icon['label'])
511
+			) {
512
+				$items['view_related_messages'] = array(
513
+					'class' => $related_for_icon['css_class'],
514
+					'desc'  => $related_for_icon['label'],
515
+				);
516
+			}
517
+		}
518
+
519
+		$items = apply_filters(
520
+			'FHEE__Transactions_Admin_Page___transaction_legend_items__items',
521
+			array_merge(
522
+				$items,
523
+				array(
524
+					'view_details'          => array(
525
+						'class' => 'dashicons dashicons-cart',
526
+						'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
527
+					),
528
+					'view_invoice'          => array(
529
+						'class' => 'dashicons dashicons-media-spreadsheet',
530
+						'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
531
+					),
532
+					'view_receipt'          => array(
533
+						'class' => 'dashicons dashicons-media-default',
534
+						'desc'  => esc_html__('View Transaction Receipt', 'event_espresso'),
535
+					),
536
+					'view_registration'     => array(
537
+						'class' => 'dashicons dashicons-clipboard',
538
+						'desc'  => esc_html__('View Registration Details', 'event_espresso'),
539
+					),
540
+					'payment_overview_link' => array(
541
+						'class' => 'dashicons dashicons-money',
542
+						'desc'  => esc_html__('Make Payment on Frontend', 'event_espresso'),
543
+					),
544
+				)
545
+			)
546
+		);
547
+
548
+		if (EE_Registry::instance()->CAP->current_user_can(
549
+			'ee_send_message',
550
+			'espresso_transactions_send_payment_reminder'
551
+		)) {
552
+			if (EEH_MSG_Template::is_mt_active('payment_reminder')) {
553
+				$items['send_payment_reminder'] = array(
554
+					'class' => 'dashicons dashicons-email-alt',
555
+					'desc'  => esc_html__('Send Payment Reminder', 'event_espresso'),
556
+				);
557
+			} else {
558
+				$items['blank*'] = array(
559
+					'class' => '',
560
+					'desc'  => '',
561
+				);
562
+			}
563
+		} else {
564
+			$items['blank*'] = array(
565
+				'class' => '',
566
+				'desc'  => '',
567
+			);
568
+		}
569
+		$more_items = apply_filters(
570
+			'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items',
571
+			array(
572
+				'overpaid'   => array(
573
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code,
574
+					'desc'  => EEH_Template::pretty_status(
575
+						EEM_Transaction::overpaid_status_code,
576
+						false,
577
+						'sentence'
578
+					),
579
+				),
580
+				'complete'   => array(
581
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code,
582
+					'desc'  => EEH_Template::pretty_status(
583
+						EEM_Transaction::complete_status_code,
584
+						false,
585
+						'sentence'
586
+					),
587
+				),
588
+				'incomplete' => array(
589
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code,
590
+					'desc'  => EEH_Template::pretty_status(
591
+						EEM_Transaction::incomplete_status_code,
592
+						false,
593
+						'sentence'
594
+					),
595
+				),
596
+				'abandoned'  => array(
597
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code,
598
+					'desc'  => EEH_Template::pretty_status(
599
+						EEM_Transaction::abandoned_status_code,
600
+						false,
601
+						'sentence'
602
+					),
603
+				),
604
+				'failed'     => array(
605
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code,
606
+					'desc'  => EEH_Template::pretty_status(
607
+						EEM_Transaction::failed_status_code,
608
+						false,
609
+						'sentence'
610
+					),
611
+				),
612
+			)
613
+		);
614
+
615
+		return array_merge($items, $more_items);
616
+	}
617
+
618
+
619
+	/**
620
+	 *    _transactions_overview_list_table
621
+	 *
622
+	 * @access protected
623
+	 * @return void
624
+	 * @throws DomainException
625
+	 * @throws EE_Error
626
+	 * @throws InvalidArgumentException
627
+	 * @throws InvalidDataTypeException
628
+	 * @throws InvalidInterfaceException
629
+	 * @throws ReflectionException
630
+	 */
631
+	protected function _transactions_overview_list_table()
632
+	{
633
+		$this->_admin_page_title = esc_html__('Transactions', 'event_espresso');
634
+		$event = isset($this->_req_data['EVT_ID'])
635
+			? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID'])
636
+			: null;
637
+		$this->_template_args['admin_page_header'] = $event instanceof EE_Event
638
+			? sprintf(
639
+				esc_html__(
640
+					'%sViewing Transactions for the Event: %s%s',
641
+					'event_espresso'
642
+				),
643
+				'<h3>',
644
+				'<a href="'
645
+				. EE_Admin_Page::add_query_args_and_nonce(
646
+					array('action' => 'edit', 'post' => $event->ID()),
647
+					EVENTS_ADMIN_URL
648
+				)
649
+				. '" title="'
650
+				. esc_attr__(
651
+					'Click to Edit event',
652
+					'event_espresso'
653
+				)
654
+				. '">' . $event->get('EVT_name') . '</a>',
655
+				'</h3>'
656
+			)
657
+			: '';
658
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items());
659
+		$this->display_admin_list_table_page_with_no_sidebar();
660
+	}
661
+
662
+
663
+	/**
664
+	 *    _transaction_details
665
+	 * generates HTML for the View Transaction Details Admin page
666
+	 *
667
+	 * @access protected
668
+	 * @return void
669
+	 * @throws DomainException
670
+	 * @throws EE_Error
671
+	 * @throws InvalidArgumentException
672
+	 * @throws InvalidDataTypeException
673
+	 * @throws InvalidInterfaceException
674
+	 * @throws RuntimeException
675
+	 * @throws ReflectionException
676
+	 */
677
+	protected function _transaction_details()
678
+	{
679
+		do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction);
680
+
681
+		$this->_set_transaction_status_array();
682
+
683
+		$this->_template_args = array();
684
+		$this->_template_args['transactions_page'] = $this->_wp_page_slug;
685
+
686
+		$this->_set_transaction_object();
687
+
688
+		$primary_registration = $this->_transaction->primary_registration();
689
+		$attendee = $primary_registration instanceof EE_Registration
690
+			? $primary_registration->attendee()
691
+			: null;
692
+
693
+		$this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID();
694
+		$this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso');
695
+
696
+		$this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp');
697
+		$this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso');
698
+
699
+		$this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->get('STS_ID') ];
700
+		$this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso');
701
+		$this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID');
702
+
703
+		$this->_template_args['grand_total'] = $this->_transaction->get('TXN_total');
704
+		$this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid');
705
+
706
+		$amount_due = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid');
707
+		$this->_template_args['amount_due'] = EEH_Template::format_currency(
708
+			$amount_due,
709
+			true
710
+		);
711
+		if (EE_Registry::instance()->CFG->currency->sign_b4) {
712
+			$this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign
713
+												  . $this->_template_args['amount_due'];
714
+		} else {
715
+			$this->_template_args['amount_due'] .= EE_Registry::instance()->CFG->currency->sign;
716
+		}
717
+		$this->_template_args['amount_due_class'] = '';
718
+
719
+		if ($this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total')) {
720
+			// paid in full
721
+			$this->_template_args['amount_due'] = false;
722
+		} elseif ($this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total')) {
723
+			// overpaid
724
+			$this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
725
+		} elseif ($this->_transaction->get('TXN_total') > 0
726
+				  && $this->_transaction->get('TXN_paid') > 0
727
+		) {
728
+			// monies owing
729
+			$this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn';
730
+		} elseif ($this->_transaction->get('TXN_total') > 0
731
+				  && $this->_transaction->get('TXN_paid') == 0
732
+		) {
733
+			// no payments made yet
734
+			$this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
735
+		} elseif ($this->_transaction->get('TXN_total') == 0) {
736
+			// free event
737
+			$this->_template_args['amount_due'] = false;
738
+		}
739
+
740
+		$payment_method = $this->_transaction->payment_method();
741
+
742
+		$this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method
743
+			? $payment_method->admin_name()
744
+			: esc_html__('Unknown', 'event_espresso');
745
+
746
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
747
+		// link back to overview
748
+		$this->_template_args['txn_overview_url'] = ! empty($_SERVER['HTTP_REFERER'])
749
+			? $_SERVER['HTTP_REFERER']
750
+			: TXN_ADMIN_URL;
751
+
752
+
753
+		// next link
754
+		$next_txn = $this->_transaction->next(
755
+			null,
756
+			array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
757
+			'TXN_ID'
758
+		);
759
+		$this->_template_args['next_transaction'] = $next_txn
760
+			? $this->_next_link(
761
+				EE_Admin_Page::add_query_args_and_nonce(
762
+					array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']),
763
+					TXN_ADMIN_URL
764
+				),
765
+				'dashicons dashicons-arrow-right ee-icon-size-22'
766
+			)
767
+			: '';
768
+		// previous link
769
+		$previous_txn = $this->_transaction->previous(
770
+			null,
771
+			array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
772
+			'TXN_ID'
773
+		);
774
+		$this->_template_args['previous_transaction'] = $previous_txn
775
+			? $this->_previous_link(
776
+				EE_Admin_Page::add_query_args_and_nonce(
777
+					array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']),
778
+					TXN_ADMIN_URL
779
+				),
780
+				'dashicons dashicons-arrow-left ee-icon-size-22'
781
+			)
782
+			: '';
783
+
784
+		// were we just redirected here after adding a new registration ???
785
+		if (isset(
786
+			$this->_req_data['redirect_from'],
787
+			$this->_req_data['EVT_ID'],
788
+			$this->_req_data['event_name']
789
+		)) {
790
+			if (EE_Registry::instance()->CAP->current_user_can(
791
+				'ee_edit_registrations',
792
+				'espresso_registrations_new_registration',
793
+				$this->_req_data['EVT_ID']
794
+			)) {
795
+				$this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="';
796
+				$this->_admin_page_title .= EE_Admin_Page::add_query_args_and_nonce(
797
+					array(
798
+						'page'     => 'espresso_registrations',
799
+						'action'   => 'new_registration',
800
+						'return'   => 'default',
801
+						'TXN_ID'   => $this->_transaction->ID(),
802
+						'event_id' => $this->_req_data['EVT_ID'],
803
+					),
804
+					REG_ADMIN_URL
805
+				);
806
+				$this->_admin_page_title .= '">';
807
+
808
+				$this->_admin_page_title .= sprintf(
809
+					esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'),
810
+					htmlentities(urldecode($this->_req_data['event_name']), ENT_QUOTES, 'UTF-8')
811
+				);
812
+				$this->_admin_page_title .= '</a>';
813
+			}
814
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
815
+		}
816
+		// grab messages at the last second
817
+		$this->_template_args['notices'] = EE_Error::get_notices();
818
+		// path to template
819
+		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
820
+		$this->_template_args['admin_page_header'] = EEH_Template::display_template(
821
+			$template_path,
822
+			$this->_template_args,
823
+			true
824
+		);
825
+
826
+		// the details template wrapper
827
+		$this->display_admin_page_with_sidebar();
828
+	}
829
+
830
+
831
+	/**
832
+	 *        _transaction_details_metaboxes
833
+	 *
834
+	 * @access protected
835
+	 * @return void
836
+	 * @throws EE_Error
837
+	 * @throws InvalidArgumentException
838
+	 * @throws InvalidDataTypeException
839
+	 * @throws InvalidInterfaceException
840
+	 * @throws RuntimeException
841
+	 * @throws ReflectionException
842
+	 */
843
+	protected function _transaction_details_metaboxes()
844
+	{
845
+
846
+		$this->_set_transaction_object();
847
+
848
+		add_meta_box(
849
+			'edit-txn-details-mbox',
850
+			esc_html__('Transaction Details', 'event_espresso'),
851
+			array($this, 'txn_details_meta_box'),
852
+			$this->_wp_page_slug,
853
+			'normal',
854
+			'high'
855
+		);
856
+		add_meta_box(
857
+			'edit-txn-attendees-mbox',
858
+			esc_html__('Attendees Registered in this Transaction', 'event_espresso'),
859
+			array($this, 'txn_attendees_meta_box'),
860
+			$this->_wp_page_slug,
861
+			'normal',
862
+			'high',
863
+			array('TXN_ID' => $this->_transaction->ID())
864
+		);
865
+		add_meta_box(
866
+			'edit-txn-registrant-mbox',
867
+			esc_html__('Primary Contact', 'event_espresso'),
868
+			array($this, 'txn_registrant_side_meta_box'),
869
+			$this->_wp_page_slug,
870
+			'side',
871
+			'high'
872
+		);
873
+		add_meta_box(
874
+			'edit-txn-billing-info-mbox',
875
+			esc_html__('Billing Information', 'event_espresso'),
876
+			array($this, 'txn_billing_info_side_meta_box'),
877
+			$this->_wp_page_slug,
878
+			'side',
879
+			'high'
880
+		);
881
+	}
882
+
883
+
884
+	/**
885
+	 * Callback for transaction actions metabox.
886
+	 *
887
+	 * @param EE_Transaction|null $transaction
888
+	 * @throws DomainException
889
+	 * @throws EE_Error
890
+	 * @throws InvalidArgumentException
891
+	 * @throws InvalidDataTypeException
892
+	 * @throws InvalidInterfaceException
893
+	 * @throws ReflectionException
894
+	 * @throws RuntimeException
895
+	 */
896
+	public function getActionButtons(EE_Transaction $transaction = null)
897
+	{
898
+		$content = '';
899
+		$actions = array();
900
+		if (! $transaction instanceof EE_Transaction) {
901
+			return $content;
902
+		}
903
+		/** @var EE_Registration $primary_registration */
904
+		$primary_registration = $transaction->primary_registration();
905
+		$attendee = $primary_registration instanceof EE_Registration
906
+			? $primary_registration->attendee()
907
+			: null;
908
+
909
+		if ($attendee instanceof EE_Attendee
910
+			&& EE_Registry::instance()->CAP->current_user_can(
911
+				'ee_send_message',
912
+				'espresso_transactions_send_payment_reminder'
913
+			)
914
+		) {
915
+			$actions['payment_reminder'] =
916
+				EEH_MSG_Template::is_mt_active('payment_reminder')
917
+				&& $this->_transaction->get('STS_ID') !== EEM_Transaction::complete_status_code
918
+				&& $this->_transaction->get('STS_ID') !== EEM_Transaction::overpaid_status_code
919
+					? EEH_Template::get_button_or_link(
920
+						EE_Admin_Page::add_query_args_and_nonce(
921
+							array(
922
+								'action'      => 'send_payment_reminder',
923
+								'TXN_ID'      => $this->_transaction->ID(),
924
+								'redirect_to' => 'view_transaction',
925
+							),
926
+							TXN_ADMIN_URL
927
+						),
928
+						esc_html__(' Send Payment Reminder', 'event_espresso'),
929
+						'button secondary-button',
930
+						'dashicons dashicons-email-alt'
931
+					)
932
+					: '';
933
+		}
934
+
935
+		if ($primary_registration instanceof EE_Registration
936
+			&& EEH_MSG_Template::is_mt_active('receipt')
937
+		) {
938
+			$actions['receipt'] = EEH_Template::get_button_or_link(
939
+				$primary_registration->receipt_url(),
940
+				esc_html__('View Receipt', 'event_espresso'),
941
+				'button secondary-button',
942
+				'dashicons dashicons-media-default'
943
+			);
944
+		}
945
+
946
+		if ($primary_registration instanceof EE_Registration
947
+			&& EEH_MSG_Template::is_mt_active('invoice')
948
+		) {
949
+			$actions['invoice'] = EEH_Template::get_button_or_link(
950
+				$primary_registration->invoice_url(),
951
+				esc_html__('View Invoice', 'event_espresso'),
952
+				'button secondary-button',
953
+				'dashicons dashicons-media-spreadsheet'
954
+			);
955
+		}
956
+		$actions = array_filter(
957
+			apply_filters('FHEE__Transactions_Admin_Page__getActionButtons__actions', $actions, $transaction)
958
+		);
959
+		if ($actions) {
960
+			$content = '<ul>';
961
+			$content .= '<li>' . implode('</li><li>', $actions) . '</li>';
962
+			$content .= '</uL>';
963
+		}
964
+		return $content;
965
+	}
966
+
967
+
968
+	/**
969
+	 * txn_details_meta_box
970
+	 * generates HTML for the Transaction main meta box
971
+	 *
972
+	 * @return void
973
+	 * @throws DomainException
974
+	 * @throws EE_Error
975
+	 * @throws InvalidArgumentException
976
+	 * @throws InvalidDataTypeException
977
+	 * @throws InvalidInterfaceException
978
+	 * @throws RuntimeException
979
+	 * @throws ReflectionException
980
+	 */
981
+	public function txn_details_meta_box()
982
+	{
983
+		$this->_set_transaction_object();
984
+		$this->_template_args['TXN_ID'] = $this->_transaction->ID();
985
+		$this->_template_args['attendee'] = $this->_transaction->primary_registration() instanceof EE_Registration
986
+			? $this->_transaction->primary_registration()->attendee()
987
+			: null;
988
+		$this->_template_args['can_edit_payments'] = EE_Registry::instance()->CAP->current_user_can(
989
+			'ee_edit_payments',
990
+			'apply_payment_or_refund_from_registration_details'
991
+		);
992
+		$this->_template_args['can_delete_payments'] = EE_Registry::instance()->CAP->current_user_can(
993
+			'ee_delete_payments',
994
+			'delete_payment_from_registration_details'
995
+		);
996
+
997
+		// get line table
998
+		EEH_Autoloader::register_line_item_display_autoloaders();
999
+		$Line_Item_Display = new EE_Line_Item_Display(
1000
+			'admin_table',
1001
+			'EE_Admin_Table_Line_Item_Display_Strategy'
1002
+		);
1003
+		$this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item(
1004
+			$this->_transaction->total_line_item()
1005
+		);
1006
+		$this->_template_args['REG_code'] = $this->_transaction->get_first_related('Registration')
1007
+															   ->get('REG_code');
1008
+
1009
+		// process taxes
1010
+		$taxes = $this->_transaction->get_many_related(
1011
+			'Line_Item',
1012
+			array(array('LIN_type' => EEM_Line_Item::type_tax))
1013
+		);
1014
+		$this->_template_args['taxes'] = ! empty($taxes) ? $taxes : false;
1015
+
1016
+		$this->_template_args['grand_total'] = EEH_Template::format_currency(
1017
+			$this->_transaction->get('TXN_total'),
1018
+			false,
1019
+			false
1020
+		);
1021
+		$this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total');
1022
+		$this->_template_args['TXN_status'] = $this->_transaction->get('STS_ID');
1023
+
1024
+		// process payment details
1025
+		$payments = $this->_transaction->get_many_related('Payment');
1026
+		if (! empty($payments)) {
1027
+			$this->_template_args['payments'] = $payments;
1028
+			$this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
1029
+		} else {
1030
+			$this->_template_args['payments'] = false;
1031
+			$this->_template_args['existing_reg_payments'] = array();
1032
+		}
1033
+
1034
+		$this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL);
1035
+		$this->_template_args['delete_payment_url'] = add_query_arg(
1036
+			array('action' => 'espresso_delete_payment'),
1037
+			TXN_ADMIN_URL
1038
+		);
1039
+
1040
+		if (isset($txn_details['invoice_number'])) {
1041
+			$this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code'];
1042
+			$this->_template_args['txn_details']['invoice_number']['label'] = esc_html__(
1043
+				'Invoice Number',
1044
+				'event_espresso'
1045
+			);
1046
+		}
1047
+
1048
+		$this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction
1049
+			->get_first_related('Registration')
1050
+			->get('REG_session');
1051
+		$this->_template_args['txn_details']['registration_session']['label'] = esc_html__(
1052
+			'Registration Session',
1053
+			'event_espresso'
1054
+		);
1055
+
1056
+		$this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address'])
1057
+			? $this->_session['ip_address']
1058
+			: '';
1059
+		$this->_template_args['txn_details']['ip_address']['label'] = esc_html__(
1060
+			'Transaction placed from IP',
1061
+			'event_espresso'
1062
+		);
1063
+
1064
+		$this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent'])
1065
+			? $this->_session['user_agent']
1066
+			: '';
1067
+		$this->_template_args['txn_details']['user_agent']['label'] = esc_html__(
1068
+			'Registrant User Agent',
1069
+			'event_espresso'
1070
+		);
1071
+
1072
+		$reg_steps = '<ul>';
1073
+		foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) {
1074
+			if ($reg_step_status === true) {
1075
+				$reg_steps .= '<li style="color:#70cc50">'
1076
+							  . sprintf(
1077
+								  esc_html__('%1$s : Completed', 'event_espresso'),
1078
+								  ucwords(str_replace('_', ' ', $reg_step))
1079
+							  )
1080
+							  . '</li>';
1081
+			} elseif (is_numeric($reg_step_status) && $reg_step_status !== false) {
1082
+				$reg_steps .= '<li style="color:#2EA2CC">'
1083
+							  . sprintf(
1084
+								  esc_html__('%1$s : Initiated %2$s', 'event_espresso'),
1085
+								  ucwords(str_replace('_', ' ', $reg_step)),
1086
+								  date(
1087
+									  get_option('date_format') . ' ' . get_option('time_format'),
1088
+									  ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS))
1089
+								  )
1090
+							  )
1091
+							  . '</li>';
1092
+			} else {
1093
+				$reg_steps .= '<li style="color:#E76700">'
1094
+							  . sprintf(
1095
+								  esc_html__('%1$s : Never Initiated', 'event_espresso'),
1096
+								  ucwords(str_replace('_', ' ', $reg_step))
1097
+							  )
1098
+							  . '</li>';
1099
+			}
1100
+		}
1101
+		$reg_steps .= '</ul>';
1102
+		$this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps;
1103
+		$this->_template_args['txn_details']['reg_steps']['label'] = esc_html__(
1104
+			'Registration Step Progress',
1105
+			'event_espresso'
1106
+		);
1107
+
1108
+
1109
+		$this->_get_registrations_to_apply_payment_to();
1110
+		$this->_get_payment_methods($payments);
1111
+		$this->_get_payment_status_array();
1112
+		$this->_get_reg_status_selection(); // sets up the template args for the reg status array for the transaction.
1113
+
1114
+		$this->_template_args['transaction_form_url'] = add_query_arg(
1115
+			array(
1116
+				'action'  => 'edit_transaction',
1117
+				'process' => 'transaction',
1118
+			),
1119
+			TXN_ADMIN_URL
1120
+		);
1121
+		$this->_template_args['apply_payment_form_url'] = add_query_arg(
1122
+			array(
1123
+				'page'   => 'espresso_transactions',
1124
+				'action' => 'espresso_apply_payment',
1125
+			),
1126
+			WP_AJAX_URL
1127
+		);
1128
+		$this->_template_args['delete_payment_form_url'] = add_query_arg(
1129
+			array(
1130
+				'page'   => 'espresso_transactions',
1131
+				'action' => 'espresso_delete_payment',
1132
+			),
1133
+			WP_AJAX_URL
1134
+		);
1135
+
1136
+		$this->_template_args['action_buttons'] = $this->getActionButtons($this->_transaction);
1137
+
1138
+		// 'espresso_delete_payment_nonce'
1139
+
1140
+		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
1141
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
1142
+	}
1143
+
1144
+
1145
+	/**
1146
+	 * _get_registration_payment_IDs
1147
+	 *    generates an array of Payment IDs and their corresponding Registration IDs
1148
+	 *
1149
+	 * @access protected
1150
+	 * @param EE_Payment[] $payments
1151
+	 * @return array
1152
+	 * @throws EE_Error
1153
+	 * @throws InvalidArgumentException
1154
+	 * @throws InvalidDataTypeException
1155
+	 * @throws InvalidInterfaceException
1156
+	 * @throws ReflectionException
1157
+	 */
1158
+	protected function _get_registration_payment_IDs($payments = array())
1159
+	{
1160
+		$existing_reg_payments = array();
1161
+		// get all reg payments for these payments
1162
+		$reg_payments = EEM_Registration_Payment::instance()->get_all(
1163
+			array(
1164
+				array(
1165
+					'PAY_ID' => array(
1166
+						'IN',
1167
+						array_keys($payments),
1168
+					),
1169
+				),
1170
+			)
1171
+		);
1172
+		if (! empty($reg_payments)) {
1173
+			foreach ($payments as $payment) {
1174
+				if (! $payment instanceof EE_Payment) {
1175
+					continue;
1176
+				} elseif (! isset($existing_reg_payments[ $payment->ID() ])) {
1177
+					$existing_reg_payments[ $payment->ID() ] = array();
1178
+				}
1179
+				foreach ($reg_payments as $reg_payment) {
1180
+					if ($reg_payment instanceof EE_Registration_Payment
1181
+						&& $reg_payment->payment_ID() === $payment->ID()
1182
+					) {
1183
+						$existing_reg_payments[ $payment->ID() ][] = $reg_payment->registration_ID();
1184
+					}
1185
+				}
1186
+			}
1187
+		}
1188
+
1189
+		return $existing_reg_payments;
1190
+	}
1191
+
1192
+
1193
+	/**
1194
+	 * _get_registrations_to_apply_payment_to
1195
+	 *    generates HTML for displaying a series of checkboxes in the admin payment modal window
1196
+	 * which allows the admin to only apply the payment to the specific registrations
1197
+	 *
1198
+	 * @access protected
1199
+	 * @return void
1200
+	 * @throws \EE_Error
1201
+	 */
1202
+	protected function _get_registrations_to_apply_payment_to()
1203
+	{
1204
+		// we want any registration with an active status (ie: not deleted or cancelled)
1205
+		$query_params = array(
1206
+			array(
1207
+				'STS_ID' => array(
1208
+					'IN',
1209
+					array(
1210
+						EEM_Registration::status_id_approved,
1211
+						EEM_Registration::status_id_pending_payment,
1212
+						EEM_Registration::status_id_not_approved,
1213
+					),
1214
+				),
1215
+			),
1216
+		);
1217
+		$registrations_to_apply_payment_to = EEH_HTML::br()
1218
+											 . EEH_HTML::div(
1219
+												 '',
1220
+												 'txn-admin-apply-payment-to-registrations-dv',
1221
+												 '',
1222
+												 'clear: both; margin: 1.5em 0 0; display: none;'
1223
+											 );
1224
+		$registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
1225
+		$registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl');
1226
+		$registrations_to_apply_payment_to .= EEH_HTML::thead(
1227
+			EEH_HTML::tr(
1228
+				EEH_HTML::th(esc_html__('ID', 'event_espresso')) .
1229
+				EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) .
1230
+				EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) .
1231
+				EEH_HTML::th(esc_html__('Event', 'event_espresso')) .
1232
+				EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') .
1233
+				EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') .
1234
+				EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr')
1235
+			)
1236
+		);
1237
+		$registrations_to_apply_payment_to .= EEH_HTML::tbody();
1238
+		// get registrations for TXN
1239
+		$registrations = $this->_transaction->registrations($query_params);
1240
+		$existing_reg_payments = $this->_template_args['existing_reg_payments'];
1241
+		foreach ($registrations as $registration) {
1242
+			if ($registration instanceof EE_Registration) {
1243
+				$attendee_name = $registration->attendee() instanceof EE_Attendee
1244
+					? $registration->attendee()->full_name()
1245
+					: esc_html__('Unknown Attendee', 'event_espresso');
1246
+				$owing = $registration->final_price() - $registration->paid();
1247
+				$taxable = $registration->ticket()->taxable()
1248
+					? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>'
1249
+					: '';
1250
+				$checked = empty($existing_reg_payments) || in_array($registration->ID(), $existing_reg_payments)
1251
+					? ' checked="checked"'
1252
+					: '';
1253
+				$disabled = $registration->final_price() > 0 ? '' : ' disabled';
1254
+				$registrations_to_apply_payment_to .= EEH_HTML::tr(
1255
+					EEH_HTML::td($registration->ID()) .
1256
+					EEH_HTML::td($attendee_name) .
1257
+					EEH_HTML::td(
1258
+						$registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable
1259
+					) .
1260
+					EEH_HTML::td($registration->event_name()) .
1261
+					EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') .
1262
+					EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr') .
1263
+					EEH_HTML::td(
1264
+						'<input type="checkbox" value="' . $registration->ID()
1265
+						. '" name="txn_admin_payment[registrations]"'
1266
+						. $checked . $disabled . '>',
1267
+						'',
1268
+						'jst-cntr'
1269
+					),
1270
+					'apply-payment-registration-row-' . $registration->ID()
1271
+				);
1272
+			}
1273
+		}
1274
+		$registrations_to_apply_payment_to .= EEH_HTML::tbodyx();
1275
+		$registrations_to_apply_payment_to .= EEH_HTML::tablex();
1276
+		$registrations_to_apply_payment_to .= EEH_HTML::divx();
1277
+		$registrations_to_apply_payment_to .= EEH_HTML::p(
1278
+			esc_html__(
1279
+				'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.',
1280
+				'event_espresso'
1281
+			),
1282
+			'',
1283
+			'clear description'
1284
+		);
1285
+		$registrations_to_apply_payment_to .= EEH_HTML::divx();
1286
+		$this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to;
1287
+	}
1288
+
1289
+
1290
+	/**
1291
+	 * _get_reg_status_selection
1292
+	 *
1293
+	 * @todo   this will need to be adjusted either once MER comes along OR we move default reg status to tickets
1294
+	 *         instead of events.
1295
+	 * @access protected
1296
+	 * @return void
1297
+	 * @throws EE_Error
1298
+	 */
1299
+	protected function _get_reg_status_selection()
1300
+	{
1301
+		// first get all possible statuses
1302
+		$statuses = EEM_Registration::reg_status_array(array(), true);
1303
+		// let's add a "don't change" option.
1304
+		$status_array['NAN'] = esc_html__('Leave the Same', 'event_espresso');
1305
+		$status_array = array_merge($status_array, $statuses);
1306
+		$this->_template_args['status_change_select'] = EEH_Form_Fields::select_input(
1307
+			'txn_reg_status_change[reg_status]',
1308
+			$status_array,
1309
+			'NAN',
1310
+			'id="txn-admin-payment-reg-status-inp"',
1311
+			'txn-reg-status-change-reg-status'
1312
+		);
1313
+		$this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input(
1314
+			'delete_txn_reg_status_change[reg_status]',
1315
+			$status_array,
1316
+			'NAN',
1317
+			'delete-txn-admin-payment-reg-status-inp',
1318
+			'delete-txn-reg-status-change-reg-status'
1319
+		);
1320
+	}
1321
+
1322
+
1323
+	/**
1324
+	 *    _get_payment_methods
1325
+	 * Gets all the payment methods available generally, or the ones that are already
1326
+	 * selected on these payments (in case their payment methods are no longer active).
1327
+	 * Has the side-effect of updating the template args' payment_methods item
1328
+	 *
1329
+	 * @access private
1330
+	 * @param EE_Payment[] to show on this page
1331
+	 * @return void
1332
+	 * @throws EE_Error
1333
+	 * @throws InvalidArgumentException
1334
+	 * @throws InvalidDataTypeException
1335
+	 * @throws InvalidInterfaceException
1336
+	 * @throws ReflectionException
1337
+	 */
1338
+	private function _get_payment_methods($payments = array())
1339
+	{
1340
+		$payment_methods_of_payments = array();
1341
+		foreach ($payments as $payment) {
1342
+			if ($payment instanceof EE_Payment) {
1343
+				$payment_methods_of_payments[] = $payment->get('PMD_ID');
1344
+			}
1345
+		}
1346
+		if ($payment_methods_of_payments) {
1347
+			$query_args = array(
1348
+				array(
1349
+					'OR*payment_method_for_payment' => array(
1350
+						'PMD_ID'    => array('IN', $payment_methods_of_payments),
1351
+						'PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%'),
1352
+					),
1353
+				),
1354
+			);
1355
+		} else {
1356
+			$query_args = array(array('PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%')));
1357
+		}
1358
+		$this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
1359
+	}
1360
+
1361
+
1362
+	/**
1363
+	 * txn_attendees_meta_box
1364
+	 *    generates HTML for the Attendees Transaction main meta box
1365
+	 *
1366
+	 * @access public
1367
+	 * @param WP_Post $post
1368
+	 * @param array   $metabox
1369
+	 * @return void
1370
+	 * @throws DomainException
1371
+	 * @throws EE_Error
1372
+	 */
1373
+	public function txn_attendees_meta_box($post, $metabox = array('args' => array()))
1374
+	{
1375
+
1376
+		/** @noinspection NonSecureExtractUsageInspection */
1377
+		extract($metabox['args']);
1378
+		$this->_template_args['post'] = $post;
1379
+		$this->_template_args['event_attendees'] = array();
1380
+		// process items in cart
1381
+		$line_items = $this->_transaction->get_many_related(
1382
+			'Line_Item',
1383
+			array(array('LIN_type' => 'line-item'))
1384
+		);
1385
+		if (! empty($line_items)) {
1386
+			foreach ($line_items as $item) {
1387
+				if ($item instanceof EE_Line_Item) {
1388
+					switch ($item->OBJ_type()) {
1389
+						case 'Event':
1390
+							break;
1391
+						case 'Ticket':
1392
+							$ticket = $item->ticket();
1393
+							// right now we're only handling tickets here.
1394
+							// Cause its expected that only tickets will have attendees right?
1395
+							if (! $ticket instanceof EE_Ticket) {
1396
+								continue;
1397
+							}
1398
+							try {
1399
+								$event_name = $ticket->get_event_name();
1400
+							} catch (Exception $e) {
1401
+								EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1402
+								$event_name = esc_html__('Unknown Event', 'event_espresso');
1403
+							}
1404
+							$event_name .= ' - ' . $item->get('LIN_name');
1405
+							$ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price'));
1406
+							// now get all of the registrations for this transaction that use this ticket
1407
+							$registrations = $ticket->get_many_related(
1408
+								'Registration',
1409
+								array(array('TXN_ID' => $this->_transaction->ID()))
1410
+							);
1411
+							foreach ($registrations as $registration) {
1412
+								if (! $registration instanceof EE_Registration) {
1413
+									continue;
1414
+								}
1415
+								$this->_template_args['event_attendees'][ $registration->ID() ]['STS_ID']
1416
+									= $registration->status_ID();
1417
+								$this->_template_args['event_attendees'][ $registration->ID() ]['att_num']
1418
+									= $registration->count();
1419
+								$this->_template_args['event_attendees'][ $registration->ID() ]['event_ticket_name']
1420
+									= $event_name;
1421
+								$this->_template_args['event_attendees'][ $registration->ID() ]['ticket_price']
1422
+									= $ticket_price;
1423
+								// attendee info
1424
+								$attendee = $registration->get_first_related('Attendee');
1425
+								if ($attendee instanceof EE_Attendee) {
1426
+									$this->_template_args['event_attendees'][ $registration->ID() ]['att_id']
1427
+										= $attendee->ID();
1428
+									$this->_template_args['event_attendees'][ $registration->ID() ]['attendee']
1429
+										= $attendee->full_name();
1430
+									$this->_template_args['event_attendees'][ $registration->ID() ]['email']
1431
+										= '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name
1432
+										  . esc_html__(
1433
+											  ' Event',
1434
+											  'event_espresso'
1435
+										  )
1436
+										  . '">' . $attendee->email() . '</a>';
1437
+									$this->_template_args['event_attendees'][ $registration->ID() ]['address']
1438
+										= EEH_Address::format($attendee, 'inline', false, false);
1439
+								} else {
1440
+									$this->_template_args['event_attendees'][ $registration->ID() ]['att_id'] = '';
1441
+									$this->_template_args['event_attendees'][ $registration->ID() ]['attendee'] = '';
1442
+									$this->_template_args['event_attendees'][ $registration->ID() ]['email'] = '';
1443
+									$this->_template_args['event_attendees'][ $registration->ID() ]['address'] = '';
1444
+								}
1445
+							}
1446
+							break;
1447
+					}
1448
+				}
1449
+			}
1450
+
1451
+			$this->_template_args['transaction_form_url'] = add_query_arg(
1452
+				array(
1453
+					'action'  => 'edit_transaction',
1454
+					'process' => 'attendees',
1455
+				),
1456
+				TXN_ADMIN_URL
1457
+			);
1458
+			echo EEH_Template::display_template(
1459
+				TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php',
1460
+				$this->_template_args,
1461
+				true
1462
+			);
1463
+		} else {
1464
+			echo sprintf(
1465
+				esc_html__(
1466
+					'%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s',
1467
+					'event_espresso'
1468
+				),
1469
+				'<p class="important-notice">',
1470
+				'</p>'
1471
+			);
1472
+		}
1473
+	}
1474
+
1475
+
1476
+	/**
1477
+	 * txn_registrant_side_meta_box
1478
+	 * generates HTML for the Edit Transaction side meta box
1479
+	 *
1480
+	 * @access public
1481
+	 * @return void
1482
+	 * @throws DomainException
1483
+	 * @throws EE_Error
1484
+	 * @throws InvalidArgumentException
1485
+	 * @throws InvalidDataTypeException
1486
+	 * @throws InvalidInterfaceException
1487
+	 * @throws ReflectionException
1488
+	 */
1489
+	public function txn_registrant_side_meta_box()
1490
+	{
1491
+		$primary_att = $this->_transaction->primary_registration() instanceof EE_Registration
1492
+			? $this->_transaction->primary_registration()->get_first_related('Attendee')
1493
+			: null;
1494
+		if (! $primary_att instanceof EE_Attendee) {
1495
+			$this->_template_args['no_attendee_message'] = esc_html__(
1496
+				'There is no attached contact for this transaction.  The transaction either failed due to an error or was abandoned.',
1497
+				'event_espresso'
1498
+			);
1499
+			$primary_att = EEM_Attendee::instance()->create_default_object();
1500
+		}
1501
+		$this->_template_args['ATT_ID'] = $primary_att->ID();
1502
+		$this->_template_args['prime_reg_fname'] = $primary_att->fname();
1503
+		$this->_template_args['prime_reg_lname'] = $primary_att->lname();
1504
+		$this->_template_args['prime_reg_email'] = $primary_att->email();
1505
+		$this->_template_args['prime_reg_phone'] = $primary_att->phone();
1506
+		$this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(
1507
+			array(
1508
+				'action' => 'edit_attendee',
1509
+				'post'   => $primary_att->ID(),
1510
+			),
1511
+			REG_ADMIN_URL
1512
+		);
1513
+		// get formatted address for registrant
1514
+		$this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
1515
+		echo EEH_Template::display_template(
1516
+			TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php',
1517
+			$this->_template_args,
1518
+			true
1519
+		);
1520
+	}
1521
+
1522
+
1523
+	/**
1524
+	 * txn_billing_info_side_meta_box
1525
+	 *    generates HTML for the Edit Transaction side meta box
1526
+	 *
1527
+	 * @access public
1528
+	 * @return void
1529
+	 * @throws DomainException
1530
+	 * @throws EE_Error
1531
+	 */
1532
+	public function txn_billing_info_side_meta_box()
1533
+	{
1534
+
1535
+		$this->_template_args['billing_form'] = $this->_transaction->billing_info();
1536
+		$this->_template_args['billing_form_url'] = add_query_arg(
1537
+			array('action' => 'edit_transaction', 'process' => 'billing'),
1538
+			TXN_ADMIN_URL
1539
+		);
1540
+
1541
+		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php';
1542
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);/**/
1543
+	}
1544
+
1545
+
1546
+	/**
1547
+	 * apply_payments_or_refunds
1548
+	 *    registers a payment or refund made towards a transaction
1549
+	 *
1550
+	 * @access public
1551
+	 * @return void
1552
+	 * @throws EE_Error
1553
+	 * @throws InvalidArgumentException
1554
+	 * @throws ReflectionException
1555
+	 * @throws RuntimeException
1556
+	 * @throws InvalidDataTypeException
1557
+	 * @throws InvalidInterfaceException
1558
+	 */
1559
+	public function apply_payments_or_refunds()
1560
+	{
1561
+		$json_response_data = array('return_data' => false);
1562
+		$valid_data = $this->_validate_payment_request_data();
1563
+		$has_access = EE_Registry::instance()->CAP->current_user_can(
1564
+			'ee_edit_payments',
1565
+			'apply_payment_or_refund_from_registration_details'
1566
+		);
1567
+		if (! empty($valid_data) && $has_access) {
1568
+			$PAY_ID = $valid_data['PAY_ID'];
1569
+			// save  the new payment
1570
+			$payment = $this->_create_payment_from_request_data($valid_data);
1571
+			// get the TXN for this payment
1572
+			$transaction = $payment->transaction();
1573
+			// verify transaction
1574
+			if ($transaction instanceof EE_Transaction) {
1575
+				// calculate_total_payments_and_update_status
1576
+				$this->_process_transaction_payments($transaction);
1577
+				$REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment);
1578
+				$this->_remove_existing_registration_payments($payment, $PAY_ID);
1579
+				// apply payment to registrations (if applicable)
1580
+				if (! empty($REG_IDs)) {
1581
+					$this->_update_registration_payments($transaction, $payment, $REG_IDs);
1582
+					$this->_maybe_send_notifications();
1583
+					// now process status changes for the same registrations
1584
+					$this->_process_registration_status_change($transaction, $REG_IDs);
1585
+				}
1586
+				$this->_maybe_send_notifications($payment);
1587
+				// prepare to render page
1588
+				$json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs);
1589
+				do_action(
1590
+					'AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording',
1591
+					$transaction,
1592
+					$payment
1593
+				);
1594
+			} else {
1595
+				EE_Error::add_error(
1596
+					esc_html__(
1597
+						'A valid Transaction for this payment could not be retrieved.',
1598
+						'event_espresso'
1599
+					),
1600
+					__FILE__,
1601
+					__FUNCTION__,
1602
+					__LINE__
1603
+				);
1604
+			}
1605
+		} else {
1606
+			if ($has_access) {
1607
+				EE_Error::add_error(
1608
+					esc_html__(
1609
+						'The payment form data could not be processed. Please try again.',
1610
+						'event_espresso'
1611
+					),
1612
+					__FILE__,
1613
+					__FUNCTION__,
1614
+					__LINE__
1615
+				);
1616
+			} else {
1617
+				EE_Error::add_error(
1618
+					esc_html__(
1619
+						'You do not have access to apply payments or refunds to a registration.',
1620
+						'event_espresso'
1621
+					),
1622
+					__FILE__,
1623
+					__FUNCTION__,
1624
+					__LINE__
1625
+				);
1626
+			}
1627
+		}
1628
+		$notices = EE_Error::get_notices(
1629
+			false,
1630
+			false,
1631
+			false
1632
+		);
1633
+		$this->_template_args = array(
1634
+			'data'    => $json_response_data,
1635
+			'error'   => $notices['errors'],
1636
+			'success' => $notices['success'],
1637
+		);
1638
+		$this->_return_json();
1639
+	}
1640
+
1641
+
1642
+	/**
1643
+	 * _validate_payment_request_data
1644
+	 *
1645
+	 * @return array
1646
+	 * @throws EE_Error
1647
+	 */
1648
+	protected function _validate_payment_request_data()
1649
+	{
1650
+		if (! isset($this->_req_data['txn_admin_payment'])) {
1651
+			return false;
1652
+		}
1653
+		$payment_form = $this->_generate_payment_form_section();
1654
+		try {
1655
+			if ($payment_form->was_submitted()) {
1656
+				$payment_form->receive_form_submission();
1657
+				if (! $payment_form->is_valid()) {
1658
+					$submission_error_messages = array();
1659
+					foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) {
1660
+						if ($validation_error instanceof EE_Validation_Error) {
1661
+							$submission_error_messages[] = sprintf(
1662
+								_x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'),
1663
+								$validation_error->get_form_section()->html_label_text(),
1664
+								$validation_error->getMessage()
1665
+							);
1666
+						}
1667
+					}
1668
+					EE_Error::add_error(
1669
+						implode('<br />', $submission_error_messages),
1670
+						__FILE__,
1671
+						__FUNCTION__,
1672
+						__LINE__
1673
+					);
1674
+
1675
+					return array();
1676
+				}
1677
+			}
1678
+		} catch (EE_Error $e) {
1679
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1680
+
1681
+			return array();
1682
+		}
1683
+
1684
+		return $payment_form->valid_data();
1685
+	}
1686
+
1687
+
1688
+	/**
1689
+	 * _generate_payment_form_section
1690
+	 *
1691
+	 * @return EE_Form_Section_Proper
1692
+	 * @throws EE_Error
1693
+	 */
1694
+	protected function _generate_payment_form_section()
1695
+	{
1696
+		return new EE_Form_Section_Proper(
1697
+			array(
1698
+				'name'        => 'txn_admin_payment',
1699
+				'subsections' => array(
1700
+					'PAY_ID'          => new EE_Text_Input(
1701
+						array(
1702
+							'default'               => 0,
1703
+							'required'              => false,
1704
+							'html_label_text'       => esc_html__('Payment ID', 'event_espresso'),
1705
+							'validation_strategies' => array(new EE_Int_Normalization()),
1706
+						)
1707
+					),
1708
+					'TXN_ID'          => new EE_Text_Input(
1709
+						array(
1710
+							'default'               => 0,
1711
+							'required'              => true,
1712
+							'html_label_text'       => esc_html__('Transaction ID', 'event_espresso'),
1713
+							'validation_strategies' => array(new EE_Int_Normalization()),
1714
+						)
1715
+					),
1716
+					'type'            => new EE_Text_Input(
1717
+						array(
1718
+							'default'               => 1,
1719
+							'required'              => true,
1720
+							'html_label_text'       => esc_html__('Payment or Refund', 'event_espresso'),
1721
+							'validation_strategies' => array(new EE_Int_Normalization()),
1722
+						)
1723
+					),
1724
+					'amount'          => new EE_Text_Input(
1725
+						array(
1726
+							'default'               => 0,
1727
+							'required'              => true,
1728
+							'html_label_text'       => esc_html__('Payment amount', 'event_espresso'),
1729
+							'validation_strategies' => array(new EE_Float_Normalization()),
1730
+						)
1731
+					),
1732
+					'status'          => new EE_Text_Input(
1733
+						array(
1734
+							'default'         => EEM_Payment::status_id_approved,
1735
+							'required'        => true,
1736
+							'html_label_text' => esc_html__('Payment status', 'event_espresso'),
1737
+						)
1738
+					),
1739
+					'PMD_ID'          => new EE_Text_Input(
1740
+						array(
1741
+							'default'               => 2,
1742
+							'required'              => true,
1743
+							'html_label_text'       => esc_html__('Payment Method', 'event_espresso'),
1744
+							'validation_strategies' => array(new EE_Int_Normalization()),
1745
+						)
1746
+					),
1747
+					'date'            => new EE_Text_Input(
1748
+						array(
1749
+							'default'         => time(),
1750
+							'required'        => true,
1751
+							'html_label_text' => esc_html__('Payment date', 'event_espresso'),
1752
+						)
1753
+					),
1754
+					'txn_id_chq_nmbr' => new EE_Text_Input(
1755
+						array(
1756
+							'default'               => '',
1757
+							'required'              => false,
1758
+							'html_label_text'       => esc_html__('Transaction or Cheque Number', 'event_espresso'),
1759
+							'validation_strategies' => array(
1760
+								new EE_Max_Length_Validation_Strategy(
1761
+									esc_html__('Input too long', 'event_espresso'),
1762
+									100
1763
+								),
1764
+							),
1765
+						)
1766
+					),
1767
+					'po_number'       => new EE_Text_Input(
1768
+						array(
1769
+							'default'               => '',
1770
+							'required'              => false,
1771
+							'html_label_text'       => esc_html__('Purchase Order Number', 'event_espresso'),
1772
+							'validation_strategies' => array(
1773
+								new EE_Max_Length_Validation_Strategy(
1774
+									esc_html__('Input too long', 'event_espresso'),
1775
+									100
1776
+								),
1777
+							),
1778
+						)
1779
+					),
1780
+					'accounting'      => new EE_Text_Input(
1781
+						array(
1782
+							'default'               => '',
1783
+							'required'              => false,
1784
+							'html_label_text'       => esc_html__('Extra Field for Accounting', 'event_espresso'),
1785
+							'validation_strategies' => array(
1786
+								new EE_Max_Length_Validation_Strategy(
1787
+									esc_html__('Input too long', 'event_espresso'),
1788
+									100
1789
+								),
1790
+							),
1791
+						)
1792
+					),
1793
+				),
1794
+			)
1795
+		);
1796
+	}
1797
+
1798
+
1799
+	/**
1800
+	 * _create_payment_from_request_data
1801
+	 *
1802
+	 * @param array $valid_data
1803
+	 * @return EE_Payment
1804
+	 * @throws EE_Error
1805
+	 */
1806
+	protected function _create_payment_from_request_data($valid_data)
1807
+	{
1808
+		$PAY_ID = $valid_data['PAY_ID'];
1809
+		// get payment amount
1810
+		$amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0;
1811
+		// payments have a type value of 1 and refunds have a type value of -1
1812
+		// so multiplying amount by type will give a positive value for payments, and negative values for refunds
1813
+		$amount = $valid_data['type'] < 0 ? $amount * -1 : $amount;
1814
+		// for some reason the date string coming in has extra spaces between the date and time.  This fixes that.
1815
+		$date = $valid_data['date']
1816
+			? preg_replace('/\s+/', ' ', $valid_data['date'])
1817
+			: date('Y-m-d g:i a', current_time('timestamp'));
1818
+		$payment = EE_Payment::new_instance(
1819
+			array(
1820
+				'TXN_ID'              => $valid_data['TXN_ID'],
1821
+				'STS_ID'              => $valid_data['status'],
1822
+				'PAY_timestamp'       => $date,
1823
+				'PAY_source'          => EEM_Payment_Method::scope_admin,
1824
+				'PMD_ID'              => $valid_data['PMD_ID'],
1825
+				'PAY_amount'          => $amount,
1826
+				'PAY_txn_id_chq_nmbr' => $valid_data['txn_id_chq_nmbr'],
1827
+				'PAY_po_number'       => $valid_data['po_number'],
1828
+				'PAY_extra_accntng'   => $valid_data['accounting'],
1829
+				'PAY_details'         => $valid_data,
1830
+				'PAY_ID'              => $PAY_ID,
1831
+			),
1832
+			'',
1833
+			array('Y-m-d', 'g:i a')
1834
+		);
1835
+
1836
+		if (! $payment->save()) {
1837
+			EE_Error::add_error(
1838
+				sprintf(
1839
+					esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'),
1840
+					$payment->ID()
1841
+				),
1842
+				__FILE__,
1843
+				__FUNCTION__,
1844
+				__LINE__
1845
+			);
1846
+		}
1847
+
1848
+		return $payment;
1849
+	}
1850
+
1851
+
1852
+	/**
1853
+	 * _process_transaction_payments
1854
+	 *
1855
+	 * @param \EE_Transaction $transaction
1856
+	 * @return void
1857
+	 * @throws EE_Error
1858
+	 * @throws InvalidArgumentException
1859
+	 * @throws ReflectionException
1860
+	 * @throws InvalidDataTypeException
1861
+	 * @throws InvalidInterfaceException
1862
+	 */
1863
+	protected function _process_transaction_payments(EE_Transaction $transaction)
1864
+	{
1865
+		/** @type EE_Transaction_Payments $transaction_payments */
1866
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1867
+		// update the transaction with this payment
1868
+		if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) {
1869
+			EE_Error::add_success(
1870
+				esc_html__(
1871
+					'The payment has been processed successfully.',
1872
+					'event_espresso'
1873
+				),
1874
+				__FILE__,
1875
+				__FUNCTION__,
1876
+				__LINE__
1877
+			);
1878
+		} else {
1879
+			EE_Error::add_error(
1880
+				esc_html__(
1881
+					'The payment was processed successfully but the amount paid for the transaction was not updated.',
1882
+					'event_espresso'
1883
+				),
1884
+				__FILE__,
1885
+				__FUNCTION__,
1886
+				__LINE__
1887
+			);
1888
+		}
1889
+	}
1890
+
1891
+
1892
+	/**
1893
+	 * _get_REG_IDs_to_apply_payment_to
1894
+	 * returns a list of registration IDs that the payment will apply to
1895
+	 *
1896
+	 * @param \EE_Payment $payment
1897
+	 * @return array
1898
+	 * @throws EE_Error
1899
+	 */
1900
+	protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment)
1901
+	{
1902
+		$REG_IDs = array();
1903
+		// grab array of IDs for specific registrations to apply changes to
1904
+		if (isset($this->_req_data['txn_admin_payment']['registrations'])) {
1905
+			$REG_IDs = (array) $this->_req_data['txn_admin_payment']['registrations'];
1906
+		}
1907
+		// nothing specified ? then get all reg IDs
1908
+		if (empty($REG_IDs)) {
1909
+			$registrations = $payment->transaction()->registrations();
1910
+			$REG_IDs = ! empty($registrations)
1911
+				? array_keys($registrations)
1912
+				: $this->_get_existing_reg_payment_REG_IDs($payment);
1913
+		}
1914
+
1915
+		// ensure that REG_IDs are integers and NOT strings
1916
+		return array_map('intval', $REG_IDs);
1917
+	}
1918
+
1919
+
1920
+	/**
1921
+	 * @return array
1922
+	 */
1923
+	public function existing_reg_payment_REG_IDs()
1924
+	{
1925
+		return $this->_existing_reg_payment_REG_IDs;
1926
+	}
1927
+
1928
+
1929
+	/**
1930
+	 * @param array $existing_reg_payment_REG_IDs
1931
+	 */
1932
+	public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null)
1933
+	{
1934
+		$this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs;
1935
+	}
1936
+
1937
+
1938
+	/**
1939
+	 * _get_existing_reg_payment_REG_IDs
1940
+	 * returns a list of registration IDs that the payment is currently related to
1941
+	 * as recorded in the database
1942
+	 *
1943
+	 * @param \EE_Payment $payment
1944
+	 * @return array
1945
+	 * @throws EE_Error
1946
+	 */
1947
+	protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment)
1948
+	{
1949
+		if ($this->existing_reg_payment_REG_IDs() === null) {
1950
+			// let's get any existing reg payment records for this payment
1951
+			$existing_reg_payment_REG_IDs = $payment->get_many_related('Registration');
1952
+			// but we only want the REG IDs, so grab the array keys
1953
+			$existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs)
1954
+				? array_keys($existing_reg_payment_REG_IDs)
1955
+				: array();
1956
+			$this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs);
1957
+		}
1958
+
1959
+		return $this->existing_reg_payment_REG_IDs();
1960
+	}
1961
+
1962
+
1963
+	/**
1964
+	 * _remove_existing_registration_payments
1965
+	 * this calculates the difference between existing relations
1966
+	 * to the supplied payment and the new list registration IDs,
1967
+	 * removes any related registrations that no longer apply,
1968
+	 * and then updates the registration paid fields
1969
+	 *
1970
+	 * @param \EE_Payment $payment
1971
+	 * @param int         $PAY_ID
1972
+	 * @return bool;
1973
+	 * @throws EE_Error
1974
+	 * @throws InvalidArgumentException
1975
+	 * @throws ReflectionException
1976
+	 * @throws InvalidDataTypeException
1977
+	 * @throws InvalidInterfaceException
1978
+	 */
1979
+	protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0)
1980
+	{
1981
+		// newly created payments will have nothing recorded for $PAY_ID
1982
+		if ($PAY_ID == 0) {
1983
+			return false;
1984
+		}
1985
+		$existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
1986
+		if (empty($existing_reg_payment_REG_IDs)) {
1987
+			return false;
1988
+		}
1989
+		/** @type EE_Transaction_Payments $transaction_payments */
1990
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1991
+
1992
+		return $transaction_payments->delete_registration_payments_and_update_registrations(
1993
+			$payment,
1994
+			array(
1995
+				array(
1996
+					'PAY_ID' => $payment->ID(),
1997
+					'REG_ID' => array('IN', $existing_reg_payment_REG_IDs),
1998
+				),
1999
+			)
2000
+		);
2001
+	}
2002
+
2003
+
2004
+	/**
2005
+	 * _update_registration_payments
2006
+	 * this applies the payments to the selected registrations
2007
+	 * but only if they have not already been paid for
2008
+	 *
2009
+	 * @param  EE_Transaction $transaction
2010
+	 * @param \EE_Payment     $payment
2011
+	 * @param array           $REG_IDs
2012
+	 * @return void
2013
+	 * @throws EE_Error
2014
+	 * @throws InvalidArgumentException
2015
+	 * @throws ReflectionException
2016
+	 * @throws RuntimeException
2017
+	 * @throws InvalidDataTypeException
2018
+	 * @throws InvalidInterfaceException
2019
+	 */
2020
+	protected function _update_registration_payments(
2021
+		EE_Transaction $transaction,
2022
+		EE_Payment $payment,
2023
+		$REG_IDs = array()
2024
+	) {
2025
+		// we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments()
2026
+		// so let's do that using our set of REG_IDs from the form
2027
+		$registration_query_where_params = array(
2028
+			'REG_ID' => array('IN', $REG_IDs),
2029
+		);
2030
+		// but add in some conditions regarding payment,
2031
+		// so that we don't apply payments to registrations that are free or have already been paid for
2032
+		// but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative )
2033
+		if (! $payment->is_a_refund()) {
2034
+			$registration_query_where_params['REG_final_price'] = array('!=', 0);
2035
+			$registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true);
2036
+		}
2037
+		$registrations = $transaction->registrations(array($registration_query_where_params));
2038
+		if (! empty($registrations)) {
2039
+			/** @type EE_Payment_Processor $payment_processor */
2040
+			$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2041
+			$payment_processor->process_registration_payments($transaction, $payment, $registrations);
2042
+		}
2043
+	}
2044
+
2045
+
2046
+	/**
2047
+	 * _process_registration_status_change
2048
+	 * This processes requested registration status changes for all the registrations
2049
+	 * on a given transaction and (optionally) sends out notifications for the changes.
2050
+	 *
2051
+	 * @param  EE_Transaction $transaction
2052
+	 * @param array           $REG_IDs
2053
+	 * @return bool
2054
+	 * @throws EE_Error
2055
+	 * @throws InvalidArgumentException
2056
+	 * @throws ReflectionException
2057
+	 * @throws InvalidDataTypeException
2058
+	 * @throws InvalidInterfaceException
2059
+	 */
2060
+	protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array())
2061
+	{
2062
+		// first if there is no change in status then we get out.
2063
+		if (! isset($this->_req_data['txn_reg_status_change']['reg_status'])
2064
+			|| $this->_req_data['txn_reg_status_change']['reg_status'] === 'NAN'
2065
+		) {
2066
+			// no error message, no change requested, just nothing to do man.
2067
+			return false;
2068
+		}
2069
+		/** @type EE_Transaction_Processor $transaction_processor */
2070
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
2071
+
2072
+		// made it here dude?  Oh WOW.  K, let's take care of changing the statuses
2073
+		return $transaction_processor->manually_update_registration_statuses(
2074
+			$transaction,
2075
+			sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']),
2076
+			array(array('REG_ID' => array('IN', $REG_IDs)))
2077
+		);
2078
+	}
2079
+
2080
+
2081
+	/**
2082
+	 * _build_payment_json_response
2083
+	 *
2084
+	 * @access public
2085
+	 * @param \EE_Payment $payment
2086
+	 * @param array       $REG_IDs
2087
+	 * @param bool | null $delete_txn_reg_status_change
2088
+	 * @return array
2089
+	 * @throws EE_Error
2090
+	 * @throws InvalidArgumentException
2091
+	 * @throws InvalidDataTypeException
2092
+	 * @throws InvalidInterfaceException
2093
+	 * @throws ReflectionException
2094
+	 */
2095
+	protected function _build_payment_json_response(
2096
+		EE_Payment $payment,
2097
+		$REG_IDs = array(),
2098
+		$delete_txn_reg_status_change = null
2099
+	) {
2100
+		// was the payment deleted ?
2101
+		if (is_bool($delete_txn_reg_status_change)) {
2102
+			return array(
2103
+				'PAY_ID'                       => $payment->ID(),
2104
+				'amount'                       => $payment->amount(),
2105
+				'total_paid'                   => $payment->transaction()->paid(),
2106
+				'txn_status'                   => $payment->transaction()->status_ID(),
2107
+				'pay_status'                   => $payment->STS_ID(),
2108
+				'registrations'                => $this->_registration_payment_data_array($REG_IDs),
2109
+				'delete_txn_reg_status_change' => $delete_txn_reg_status_change,
2110
+			);
2111
+		} else {
2112
+			$this->_get_payment_status_array();
2113
+
2114
+			return array(
2115
+				'amount'           => $payment->amount(),
2116
+				'total_paid'       => $payment->transaction()->paid(),
2117
+				'txn_status'       => $payment->transaction()->status_ID(),
2118
+				'pay_status'       => $payment->STS_ID(),
2119
+				'PAY_ID'           => $payment->ID(),
2120
+				'STS_ID'           => $payment->STS_ID(),
2121
+				'status'           => self::$_pay_status[ $payment->STS_ID() ],
2122
+				'date'             => $payment->timestamp('Y-m-d', 'h:i a'),
2123
+				'method'           => strtoupper($payment->source()),
2124
+				'PM_ID'            => $payment->payment_method() ? $payment->payment_method()->ID() : 1,
2125
+				'gateway'          => $payment->payment_method()
2126
+					? $payment->payment_method()->admin_name()
2127
+					: esc_html__("Unknown", 'event_espresso'),
2128
+				'gateway_response' => $payment->gateway_response(),
2129
+				'txn_id_chq_nmbr'  => $payment->txn_id_chq_nmbr(),
2130
+				'po_number'        => $payment->po_number(),
2131
+				'extra_accntng'    => $payment->extra_accntng(),
2132
+				'registrations'    => $this->_registration_payment_data_array($REG_IDs),
2133
+			);
2134
+		}
2135
+	}
2136
+
2137
+
2138
+	/**
2139
+	 * delete_payment
2140
+	 *    delete a payment or refund made towards a transaction
2141
+	 *
2142
+	 * @access public
2143
+	 * @return void
2144
+	 * @throws EE_Error
2145
+	 * @throws InvalidArgumentException
2146
+	 * @throws ReflectionException
2147
+	 * @throws InvalidDataTypeException
2148
+	 * @throws InvalidInterfaceException
2149
+	 */
2150
+	public function delete_payment()
2151
+	{
2152
+		$json_response_data = array('return_data' => false);
2153
+		$PAY_ID = isset($this->_req_data['delete_txn_admin_payment']['PAY_ID'])
2154
+			? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID'])
2155
+			: 0;
2156
+		$can_delete = EE_Registry::instance()->CAP->current_user_can(
2157
+			'ee_delete_payments',
2158
+			'delete_payment_from_registration_details'
2159
+		);
2160
+		if ($PAY_ID && $can_delete) {
2161
+			$delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change'])
2162
+				? $this->_req_data['delete_txn_reg_status_change']
2163
+				: false;
2164
+			$payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
2165
+			if ($payment instanceof EE_Payment) {
2166
+				$REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
2167
+				/** @type EE_Transaction_Payments $transaction_payments */
2168
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
2169
+				if ($transaction_payments->delete_payment_and_update_transaction($payment)) {
2170
+					$json_response_data['return_data'] = $this->_build_payment_json_response(
2171
+						$payment,
2172
+						$REG_IDs,
2173
+						$delete_txn_reg_status_change
2174
+					);
2175
+					if ($delete_txn_reg_status_change) {
2176
+						$this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change;
2177
+						// MAKE sure we also add the delete_txn_req_status_change to the
2178
+						// $_REQUEST global because that's how messages will be looking for it.
2179
+						$_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change;
2180
+						$this->_maybe_send_notifications();
2181
+						$this->_process_registration_status_change($payment->transaction(), $REG_IDs);
2182
+					}
2183
+				}
2184
+			} else {
2185
+				EE_Error::add_error(
2186
+					esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'),
2187
+					__FILE__,
2188
+					__FUNCTION__,
2189
+					__LINE__
2190
+				);
2191
+			}
2192
+		} else {
2193
+			if ($can_delete) {
2194
+				EE_Error::add_error(
2195
+					esc_html__(
2196
+						'A valid Payment ID was not received, therefore payment form data could not be loaded.',
2197
+						'event_espresso'
2198
+					),
2199
+					__FILE__,
2200
+					__FUNCTION__,
2201
+					__LINE__
2202
+				);
2203
+			} else {
2204
+				EE_Error::add_error(
2205
+					esc_html__(
2206
+						'You do not have access to delete a payment.',
2207
+						'event_espresso'
2208
+					),
2209
+					__FILE__,
2210
+					__FUNCTION__,
2211
+					__LINE__
2212
+				);
2213
+			}
2214
+		}
2215
+		$notices = EE_Error::get_notices(false, false, false);
2216
+		$this->_template_args = array(
2217
+			'data'      => $json_response_data,
2218
+			'success'   => $notices['success'],
2219
+			'error'     => $notices['errors'],
2220
+			'attention' => $notices['attention'],
2221
+		);
2222
+		$this->_return_json();
2223
+	}
2224
+
2225
+
2226
+	/**
2227
+	 * _registration_payment_data_array
2228
+	 * adds info for 'owing' and 'paid' for each registration to the json response
2229
+	 *
2230
+	 * @access protected
2231
+	 * @param array $REG_IDs
2232
+	 * @return array
2233
+	 * @throws EE_Error
2234
+	 * @throws InvalidArgumentException
2235
+	 * @throws InvalidDataTypeException
2236
+	 * @throws InvalidInterfaceException
2237
+	 * @throws ReflectionException
2238
+	 */
2239
+	protected function _registration_payment_data_array($REG_IDs)
2240
+	{
2241
+		$registration_payment_data = array();
2242
+		// if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
2243
+		if (! empty($REG_IDs)) {
2244
+			$registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs))));
2245
+			foreach ($registrations as $registration) {
2246
+				if ($registration instanceof EE_Registration) {
2247
+					$registration_payment_data[ $registration->ID() ] = array(
2248
+						'paid'  => $registration->pretty_paid(),
2249
+						'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()),
2250
+					);
2251
+				}
2252
+			}
2253
+		}
2254
+
2255
+		return $registration_payment_data;
2256
+	}
2257
+
2258
+
2259
+	/**
2260
+	 * _maybe_send_notifications
2261
+	 * determines whether or not the admin has indicated that notifications should be sent.
2262
+	 * If so, will toggle a filter switch for delivering registration notices.
2263
+	 * If passed an EE_Payment object, then it will trigger payment notifications instead.
2264
+	 *
2265
+	 * @access protected
2266
+	 * @param \EE_Payment | null $payment
2267
+	 */
2268
+	protected function _maybe_send_notifications($payment = null)
2269
+	{
2270
+		switch ($payment instanceof EE_Payment) {
2271
+			// payment notifications
2272
+			case true:
2273
+				if (isset(
2274
+					$this->_req_data['txn_payments'],
2275
+					$this->_req_data['txn_payments']['send_notifications']
2276
+				)
2277
+					&& filter_var($this->_req_data['txn_payments']['send_notifications'], FILTER_VALIDATE_BOOLEAN)
2278
+				) {
2279
+					$this->_process_payment_notification($payment);
2280
+				}
2281
+				break;
2282
+			// registration notifications
2283
+			case false:
2284
+				if (isset(
2285
+					$this->_req_data['txn_reg_status_change'],
2286
+					$this->_req_data['txn_reg_status_change']['send_notifications']
2287
+				)
2288
+					&& filter_var($this->_req_data['txn_reg_status_change']['send_notifications'], FILTER_VALIDATE_BOOLEAN)
2289
+				) {
2290
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
2291
+				}
2292
+				break;
2293
+		}
2294
+	}
2295
+
2296
+
2297
+	/**
2298
+	 * _send_payment_reminder
2299
+	 *    generates HTML for the View Transaction Details Admin page
2300
+	 *
2301
+	 * @access protected
2302
+	 * @return void
2303
+	 * @throws EE_Error
2304
+	 * @throws InvalidArgumentException
2305
+	 * @throws InvalidDataTypeException
2306
+	 * @throws InvalidInterfaceException
2307
+	 */
2308
+	protected function _send_payment_reminder()
2309
+	{
2310
+		$TXN_ID = ! empty($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : false;
2311
+		$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2312
+		$query_args = isset($this->_req_data['redirect_to']) ? array(
2313
+			'action' => $this->_req_data['redirect_to'],
2314
+			'TXN_ID' => $this->_req_data['TXN_ID'],
2315
+		) : array();
2316
+		do_action(
2317
+			'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder',
2318
+			$transaction
2319
+		);
2320
+		$this->_redirect_after_action(
2321
+			false,
2322
+			esc_html__('payment reminder', 'event_espresso'),
2323
+			esc_html__('sent', 'event_espresso'),
2324
+			$query_args,
2325
+			true
2326
+		);
2327
+	}
2328
+
2329
+
2330
+	/**
2331
+	 *  get_transactions
2332
+	 *    get transactions for given parameters (used by list table)
2333
+	 *
2334
+	 * @param  int     $perpage how many transactions displayed per page
2335
+	 * @param  boolean $count   return the count or objects
2336
+	 * @param string   $view
2337
+	 * @return mixed int = count || array of transaction objects
2338
+	 * @throws EE_Error
2339
+	 * @throws InvalidArgumentException
2340
+	 * @throws InvalidDataTypeException
2341
+	 * @throws InvalidInterfaceException
2342
+	 */
2343
+	public function get_transactions($perpage, $count = false, $view = '')
2344
+	{
2345
+
2346
+		$TXN = EEM_Transaction::instance();
2347
+
2348
+		$start_date = isset($this->_req_data['txn-filter-start-date'])
2349
+			? wp_strip_all_tags($this->_req_data['txn-filter-start-date'])
2350
+			: date(
2351
+				'm/d/Y',
2352
+				strtotime('-10 year')
2353
+			);
2354
+		$end_date = isset($this->_req_data['txn-filter-end-date'])
2355
+			? wp_strip_all_tags($this->_req_data['txn-filter-end-date'])
2356
+			: date('m/d/Y');
2357
+
2358
+		// make sure our timestamps start and end right at the boundaries for each day
2359
+		$start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
2360
+		$end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
2361
+
2362
+
2363
+		// convert to timestamps
2364
+		$start_date = strtotime($start_date);
2365
+		$end_date = strtotime($end_date);
2366
+
2367
+		// makes sure start date is the lowest value and vice versa
2368
+		$start_date = min($start_date, $end_date);
2369
+		$end_date = max($start_date, $end_date);
2370
+
2371
+		// convert to correct format for query
2372
+		$start_date = EEM_Transaction::instance()->convert_datetime_for_query(
2373
+			'TXN_timestamp',
2374
+			date('Y-m-d H:i:s', $start_date),
2375
+			'Y-m-d H:i:s'
2376
+		);
2377
+		$end_date = EEM_Transaction::instance()->convert_datetime_for_query(
2378
+			'TXN_timestamp',
2379
+			date('Y-m-d H:i:s', $end_date),
2380
+			'Y-m-d H:i:s'
2381
+		);
2382
+
2383
+
2384
+		// set orderby
2385
+		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
2386
+
2387
+		switch ($this->_req_data['orderby']) {
2388
+			case 'TXN_ID':
2389
+				$orderby = 'TXN_ID';
2390
+				break;
2391
+			case 'ATT_fname':
2392
+				$orderby = 'Registration.Attendee.ATT_fname';
2393
+				break;
2394
+			case 'event_name':
2395
+				$orderby = 'Registration.Event.EVT_name';
2396
+				break;
2397
+			default: // 'TXN_timestamp'
2398
+				$orderby = 'TXN_timestamp';
2399
+		}
2400
+
2401
+		$sort = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2402
+		$current_page = ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
2403
+		$per_page = ! empty($perpage) ? $perpage : 10;
2404
+		$per_page = ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
2405
+
2406
+		$offset = ($current_page - 1) * $per_page;
2407
+		$limit = array($offset, $per_page);
2408
+
2409
+		$_where = array(
2410
+			'TXN_timestamp'          => array('BETWEEN', array($start_date, $end_date)),
2411
+			'Registration.REG_count' => 1,
2412
+		);
2413
+
2414
+		if (isset($this->_req_data['EVT_ID'])) {
2415
+			$_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID'];
2416
+		}
2417
+
2418
+		if (isset($this->_req_data['s'])) {
2419
+			$search_string = '%' . $this->_req_data['s'] . '%';
2420
+			$_where['OR'] = array(
2421
+				'Registration.Event.EVT_name'         => array('LIKE', $search_string),
2422
+				'Registration.Event.EVT_desc'         => array('LIKE', $search_string),
2423
+				'Registration.Event.EVT_short_desc'   => array('LIKE', $search_string),
2424
+				'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string),
2425
+				'Registration.Attendee.ATT_fname'     => array('LIKE', $search_string),
2426
+				'Registration.Attendee.ATT_lname'     => array('LIKE', $search_string),
2427
+				'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string),
2428
+				'Registration.Attendee.ATT_email'     => array('LIKE', $search_string),
2429
+				'Registration.Attendee.ATT_address'   => array('LIKE', $search_string),
2430
+				'Registration.Attendee.ATT_address2'  => array('LIKE', $search_string),
2431
+				'Registration.Attendee.ATT_city'      => array('LIKE', $search_string),
2432
+				'Registration.REG_final_price'        => array('LIKE', $search_string),
2433
+				'Registration.REG_code'               => array('LIKE', $search_string),
2434
+				'Registration.REG_count'              => array('LIKE', $search_string),
2435
+				'Registration.REG_group_size'         => array('LIKE', $search_string),
2436
+				'Registration.Ticket.TKT_name'        => array('LIKE', $search_string),
2437
+				'Registration.Ticket.TKT_description' => array('LIKE', $search_string),
2438
+				'Payment.PAY_source'                  => array('LIKE', $search_string),
2439
+				'Payment.Payment_Method.PMD_name'     => array('LIKE', $search_string),
2440
+				'TXN_session_data'                    => array('LIKE', $search_string),
2441
+				'Payment.PAY_txn_id_chq_nmbr'         => array('LIKE', $search_string),
2442
+			);
2443
+		}
2444
+
2445
+		// failed transactions
2446
+		$failed = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'failed' && ! $count)
2447
+				  || ($count && $view === 'failed');
2448
+		$abandoned = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'abandoned' && ! $count)
2449
+					 || ($count && $view === 'abandoned');
2450
+
2451
+		if ($failed) {
2452
+			$_where['STS_ID'] = EEM_Transaction::failed_status_code;
2453
+		} elseif ($abandoned) {
2454
+			$_where['STS_ID'] = EEM_Transaction::abandoned_status_code;
2455
+		} else {
2456
+			$_where['STS_ID'] = array('!=', EEM_Transaction::failed_status_code);
2457
+			$_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code);
2458
+		}
2459
+
2460
+		$query_params = array(
2461
+			$_where,
2462
+			'order_by'                 => array($orderby => $sort),
2463
+			'limit'                    => $limit,
2464
+			'default_where_conditions' => EEM_Base::default_where_conditions_this_only,
2465
+		);
2466
+
2467
+		$transactions = $count
2468
+			? $TXN->count(array($_where), 'TXN_ID', true)
2469
+			: $TXN->get_all($query_params);
2470
+
2471
+		return $transactions;
2472
+	}
2473 2473
 }
Please login to merge, or discard this patch.
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
         // enqueue style
364 364
         wp_register_style(
365 365
             'espresso_txn',
366
-            TXN_ASSETS_URL . 'espresso_transactions_admin.css',
366
+            TXN_ASSETS_URL.'espresso_transactions_admin.css',
367 367
             array(),
368 368
             EVENT_ESPRESSO_VERSION
369 369
         );
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         // scripts
372 372
         wp_register_script(
373 373
             'espresso_txn',
374
-            TXN_ASSETS_URL . 'espresso_transactions_admin.js',
374
+            TXN_ASSETS_URL.'espresso_transactions_admin.js',
375 375
             array(
376 376
                 'ee_admin_js',
377 377
                 'ee-datepicker',
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
             : null;
473 473
         $this->_transaction->verify_abandoned_transaction_status();
474 474
 
475
-        if (! $this->_transaction instanceof EE_Transaction) {
475
+        if ( ! $this->_transaction instanceof EE_Transaction) {
476 476
             $error_msg = sprintf(
477 477
                 esc_html__(
478 478
                     'An error occurred and the details for the transaction with the ID # %d could not be retrieved.',
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
             'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items',
571 571
             array(
572 572
                 'overpaid'   => array(
573
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code,
573
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::overpaid_status_code,
574 574
                     'desc'  => EEH_Template::pretty_status(
575 575
                         EEM_Transaction::overpaid_status_code,
576 576
                         false,
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
                     ),
579 579
                 ),
580 580
                 'complete'   => array(
581
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code,
581
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::complete_status_code,
582 582
                     'desc'  => EEH_Template::pretty_status(
583 583
                         EEM_Transaction::complete_status_code,
584 584
                         false,
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
                     ),
587 587
                 ),
588 588
                 'incomplete' => array(
589
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code,
589
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::incomplete_status_code,
590 590
                     'desc'  => EEH_Template::pretty_status(
591 591
                         EEM_Transaction::incomplete_status_code,
592 592
                         false,
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
                     ),
595 595
                 ),
596 596
                 'abandoned'  => array(
597
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code,
597
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::abandoned_status_code,
598 598
                     'desc'  => EEH_Template::pretty_status(
599 599
                         EEM_Transaction::abandoned_status_code,
600 600
                         false,
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
                     ),
603 603
                 ),
604 604
                 'failed'     => array(
605
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code,
605
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::failed_status_code,
606 606
                     'desc'  => EEH_Template::pretty_status(
607 607
                         EEM_Transaction::failed_status_code,
608 608
                         false,
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
                     'Click to Edit event',
652 652
                     'event_espresso'
653 653
                 )
654
-                . '">' . $event->get('EVT_name') . '</a>',
654
+                . '">'.$event->get('EVT_name').'</a>',
655 655
                 '</h3>'
656 656
             )
657 657
             : '';
@@ -696,9 +696,9 @@  discard block
 block discarded – undo
696 696
         $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp');
697 697
         $this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso');
698 698
 
699
-        $this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->get('STS_ID') ];
699
+        $this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')];
700 700
         $this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso');
701
-        $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID');
701
+        $this->_template_args['txn_status']['class'] = 'status-'.$this->_transaction->get('STS_ID');
702 702
 
703 703
         $this->_template_args['grand_total'] = $this->_transaction->get('TXN_total');
704 704
         $this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid');
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
         // grab messages at the last second
817 817
         $this->_template_args['notices'] = EE_Error::get_notices();
818 818
         // path to template
819
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
819
+        $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_header.template.php';
820 820
         $this->_template_args['admin_page_header'] = EEH_Template::display_template(
821 821
             $template_path,
822 822
             $this->_template_args,
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
     {
898 898
         $content = '';
899 899
         $actions = array();
900
-        if (! $transaction instanceof EE_Transaction) {
900
+        if ( ! $transaction instanceof EE_Transaction) {
901 901
             return $content;
902 902
         }
903 903
         /** @var EE_Registration $primary_registration */
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
         );
959 959
         if ($actions) {
960 960
             $content = '<ul>';
961
-            $content .= '<li>' . implode('</li><li>', $actions) . '</li>';
961
+            $content .= '<li>'.implode('</li><li>', $actions).'</li>';
962 962
             $content .= '</uL>';
963 963
         }
964 964
         return $content;
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
 
1024 1024
         // process payment details
1025 1025
         $payments = $this->_transaction->get_many_related('Payment');
1026
-        if (! empty($payments)) {
1026
+        if ( ! empty($payments)) {
1027 1027
             $this->_template_args['payments'] = $payments;
1028 1028
             $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
1029 1029
         } else {
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
                                   esc_html__('%1$s : Initiated %2$s', 'event_espresso'),
1085 1085
                                   ucwords(str_replace('_', ' ', $reg_step)),
1086 1086
                                   date(
1087
-                                      get_option('date_format') . ' ' . get_option('time_format'),
1087
+                                      get_option('date_format').' '.get_option('time_format'),
1088 1088
                                       ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS))
1089 1089
                                   )
1090 1090
                               )
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
 
1138 1138
         // 'espresso_delete_payment_nonce'
1139 1139
 
1140
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
1140
+        $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_txn_details.template.php';
1141 1141
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
1142 1142
     }
1143 1143
 
@@ -1169,18 +1169,18 @@  discard block
 block discarded – undo
1169 1169
                 ),
1170 1170
             )
1171 1171
         );
1172
-        if (! empty($reg_payments)) {
1172
+        if ( ! empty($reg_payments)) {
1173 1173
             foreach ($payments as $payment) {
1174
-                if (! $payment instanceof EE_Payment) {
1174
+                if ( ! $payment instanceof EE_Payment) {
1175 1175
                     continue;
1176
-                } elseif (! isset($existing_reg_payments[ $payment->ID() ])) {
1177
-                    $existing_reg_payments[ $payment->ID() ] = array();
1176
+                } elseif ( ! isset($existing_reg_payments[$payment->ID()])) {
1177
+                    $existing_reg_payments[$payment->ID()] = array();
1178 1178
                 }
1179 1179
                 foreach ($reg_payments as $reg_payment) {
1180 1180
                     if ($reg_payment instanceof EE_Registration_Payment
1181 1181
                         && $reg_payment->payment_ID() === $payment->ID()
1182 1182
                     ) {
1183
-                        $existing_reg_payments[ $payment->ID() ][] = $reg_payment->registration_ID();
1183
+                        $existing_reg_payments[$payment->ID()][] = $reg_payment->registration_ID();
1184 1184
                     }
1185 1185
                 }
1186 1186
             }
@@ -1221,16 +1221,16 @@  discard block
 block discarded – undo
1221 1221
                                                  '',
1222 1222
                                                  'clear: both; margin: 1.5em 0 0; display: none;'
1223 1223
                                              );
1224
-        $registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
1224
+        $registrations_to_apply_payment_to .= EEH_HTML::br().EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
1225 1225
         $registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl');
1226 1226
         $registrations_to_apply_payment_to .= EEH_HTML::thead(
1227 1227
             EEH_HTML::tr(
1228
-                EEH_HTML::th(esc_html__('ID', 'event_espresso')) .
1229
-                EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) .
1230
-                EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) .
1231
-                EEH_HTML::th(esc_html__('Event', 'event_espresso')) .
1232
-                EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') .
1233
-                EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') .
1228
+                EEH_HTML::th(esc_html__('ID', 'event_espresso')).
1229
+                EEH_HTML::th(esc_html__('Registrant', 'event_espresso')).
1230
+                EEH_HTML::th(esc_html__('Ticket', 'event_espresso')).
1231
+                EEH_HTML::th(esc_html__('Event', 'event_espresso')).
1232
+                EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr').
1233
+                EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr').
1234 1234
                 EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr')
1235 1235
             )
1236 1236
         );
@@ -1245,29 +1245,29 @@  discard block
 block discarded – undo
1245 1245
                     : esc_html__('Unknown Attendee', 'event_espresso');
1246 1246
                 $owing = $registration->final_price() - $registration->paid();
1247 1247
                 $taxable = $registration->ticket()->taxable()
1248
-                    ? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>'
1248
+                    ? ' <span class="smaller-text lt-grey-text"> '.esc_html__('+ tax', 'event_espresso').'</span>'
1249 1249
                     : '';
1250 1250
                 $checked = empty($existing_reg_payments) || in_array($registration->ID(), $existing_reg_payments)
1251 1251
                     ? ' checked="checked"'
1252 1252
                     : '';
1253 1253
                 $disabled = $registration->final_price() > 0 ? '' : ' disabled';
1254 1254
                 $registrations_to_apply_payment_to .= EEH_HTML::tr(
1255
-                    EEH_HTML::td($registration->ID()) .
1256
-                    EEH_HTML::td($attendee_name) .
1255
+                    EEH_HTML::td($registration->ID()).
1256
+                    EEH_HTML::td($attendee_name).
1257 1257
                     EEH_HTML::td(
1258
-                        $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable
1259
-                    ) .
1260
-                    EEH_HTML::td($registration->event_name()) .
1261
-                    EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') .
1262
-                    EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr') .
1258
+                        $registration->ticket()->name().' : '.$registration->ticket()->pretty_price().$taxable
1259
+                    ).
1260
+                    EEH_HTML::td($registration->event_name()).
1261
+                    EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr').
1262
+                    EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr').
1263 1263
                     EEH_HTML::td(
1264
-                        '<input type="checkbox" value="' . $registration->ID()
1264
+                        '<input type="checkbox" value="'.$registration->ID()
1265 1265
                         . '" name="txn_admin_payment[registrations]"'
1266
-                        . $checked . $disabled . '>',
1266
+                        . $checked.$disabled.'>',
1267 1267
                         '',
1268 1268
                         'jst-cntr'
1269 1269
                     ),
1270
-                    'apply-payment-registration-row-' . $registration->ID()
1270
+                    'apply-payment-registration-row-'.$registration->ID()
1271 1271
                 );
1272 1272
             }
1273 1273
         }
@@ -1348,12 +1348,12 @@  discard block
 block discarded – undo
1348 1348
                 array(
1349 1349
                     'OR*payment_method_for_payment' => array(
1350 1350
                         'PMD_ID'    => array('IN', $payment_methods_of_payments),
1351
-                        'PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%'),
1351
+                        'PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%'),
1352 1352
                     ),
1353 1353
                 ),
1354 1354
             );
1355 1355
         } else {
1356
-            $query_args = array(array('PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%')));
1356
+            $query_args = array(array('PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%')));
1357 1357
         }
1358 1358
         $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
1359 1359
     }
@@ -1382,7 +1382,7 @@  discard block
 block discarded – undo
1382 1382
             'Line_Item',
1383 1383
             array(array('LIN_type' => 'line-item'))
1384 1384
         );
1385
-        if (! empty($line_items)) {
1385
+        if ( ! empty($line_items)) {
1386 1386
             foreach ($line_items as $item) {
1387 1387
                 if ($item instanceof EE_Line_Item) {
1388 1388
                     switch ($item->OBJ_type()) {
@@ -1392,7 +1392,7 @@  discard block
 block discarded – undo
1392 1392
                             $ticket = $item->ticket();
1393 1393
                             // right now we're only handling tickets here.
1394 1394
                             // Cause its expected that only tickets will have attendees right?
1395
-                            if (! $ticket instanceof EE_Ticket) {
1395
+                            if ( ! $ticket instanceof EE_Ticket) {
1396 1396
                                 continue;
1397 1397
                             }
1398 1398
                             try {
@@ -1401,7 +1401,7 @@  discard block
 block discarded – undo
1401 1401
                                 EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1402 1402
                                 $event_name = esc_html__('Unknown Event', 'event_espresso');
1403 1403
                             }
1404
-                            $event_name .= ' - ' . $item->get('LIN_name');
1404
+                            $event_name .= ' - '.$item->get('LIN_name');
1405 1405
                             $ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price'));
1406 1406
                             // now get all of the registrations for this transaction that use this ticket
1407 1407
                             $registrations = $ticket->get_many_related(
@@ -1409,38 +1409,38 @@  discard block
 block discarded – undo
1409 1409
                                 array(array('TXN_ID' => $this->_transaction->ID()))
1410 1410
                             );
1411 1411
                             foreach ($registrations as $registration) {
1412
-                                if (! $registration instanceof EE_Registration) {
1412
+                                if ( ! $registration instanceof EE_Registration) {
1413 1413
                                     continue;
1414 1414
                                 }
1415
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['STS_ID']
1415
+                                $this->_template_args['event_attendees'][$registration->ID()]['STS_ID']
1416 1416
                                     = $registration->status_ID();
1417
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['att_num']
1417
+                                $this->_template_args['event_attendees'][$registration->ID()]['att_num']
1418 1418
                                     = $registration->count();
1419
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['event_ticket_name']
1419
+                                $this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name']
1420 1420
                                     = $event_name;
1421
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['ticket_price']
1421
+                                $this->_template_args['event_attendees'][$registration->ID()]['ticket_price']
1422 1422
                                     = $ticket_price;
1423 1423
                                 // attendee info
1424 1424
                                 $attendee = $registration->get_first_related('Attendee');
1425 1425
                                 if ($attendee instanceof EE_Attendee) {
1426
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['att_id']
1426
+                                    $this->_template_args['event_attendees'][$registration->ID()]['att_id']
1427 1427
                                         = $attendee->ID();
1428
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['attendee']
1428
+                                    $this->_template_args['event_attendees'][$registration->ID()]['attendee']
1429 1429
                                         = $attendee->full_name();
1430
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['email']
1431
-                                        = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name
1430
+                                    $this->_template_args['event_attendees'][$registration->ID()]['email']
1431
+                                        = '<a href="mailto:'.$attendee->email().'?subject='.$event_name
1432 1432
                                           . esc_html__(
1433 1433
                                               ' Event',
1434 1434
                                               'event_espresso'
1435 1435
                                           )
1436
-                                          . '">' . $attendee->email() . '</a>';
1437
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['address']
1436
+                                          . '">'.$attendee->email().'</a>';
1437
+                                    $this->_template_args['event_attendees'][$registration->ID()]['address']
1438 1438
                                         = EEH_Address::format($attendee, 'inline', false, false);
1439 1439
                                 } else {
1440
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['att_id'] = '';
1441
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['attendee'] = '';
1442
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['email'] = '';
1443
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['address'] = '';
1440
+                                    $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = '';
1441
+                                    $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = '';
1442
+                                    $this->_template_args['event_attendees'][$registration->ID()]['email'] = '';
1443
+                                    $this->_template_args['event_attendees'][$registration->ID()]['address'] = '';
1444 1444
                                 }
1445 1445
                             }
1446 1446
                             break;
@@ -1456,7 +1456,7 @@  discard block
 block discarded – undo
1456 1456
                 TXN_ADMIN_URL
1457 1457
             );
1458 1458
             echo EEH_Template::display_template(
1459
-                TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php',
1459
+                TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_attendees.template.php',
1460 1460
                 $this->_template_args,
1461 1461
                 true
1462 1462
             );
@@ -1491,7 +1491,7 @@  discard block
 block discarded – undo
1491 1491
         $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration
1492 1492
             ? $this->_transaction->primary_registration()->get_first_related('Attendee')
1493 1493
             : null;
1494
-        if (! $primary_att instanceof EE_Attendee) {
1494
+        if ( ! $primary_att instanceof EE_Attendee) {
1495 1495
             $this->_template_args['no_attendee_message'] = esc_html__(
1496 1496
                 'There is no attached contact for this transaction.  The transaction either failed due to an error or was abandoned.',
1497 1497
                 'event_espresso'
@@ -1513,7 +1513,7 @@  discard block
 block discarded – undo
1513 1513
         // get formatted address for registrant
1514 1514
         $this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
1515 1515
         echo EEH_Template::display_template(
1516
-            TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php',
1516
+            TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_registrant.template.php',
1517 1517
             $this->_template_args,
1518 1518
             true
1519 1519
         );
@@ -1538,8 +1538,8 @@  discard block
 block discarded – undo
1538 1538
             TXN_ADMIN_URL
1539 1539
         );
1540 1540
 
1541
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php';
1542
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);/**/
1541
+        $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_billing_info.template.php';
1542
+        echo EEH_Template::display_template($template_path, $this->_template_args, true); /**/
1543 1543
     }
1544 1544
 
1545 1545
 
@@ -1564,7 +1564,7 @@  discard block
 block discarded – undo
1564 1564
             'ee_edit_payments',
1565 1565
             'apply_payment_or_refund_from_registration_details'
1566 1566
         );
1567
-        if (! empty($valid_data) && $has_access) {
1567
+        if ( ! empty($valid_data) && $has_access) {
1568 1568
             $PAY_ID = $valid_data['PAY_ID'];
1569 1569
             // save  the new payment
1570 1570
             $payment = $this->_create_payment_from_request_data($valid_data);
@@ -1577,7 +1577,7 @@  discard block
 block discarded – undo
1577 1577
                 $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment);
1578 1578
                 $this->_remove_existing_registration_payments($payment, $PAY_ID);
1579 1579
                 // apply payment to registrations (if applicable)
1580
-                if (! empty($REG_IDs)) {
1580
+                if ( ! empty($REG_IDs)) {
1581 1581
                     $this->_update_registration_payments($transaction, $payment, $REG_IDs);
1582 1582
                     $this->_maybe_send_notifications();
1583 1583
                     // now process status changes for the same registrations
@@ -1647,14 +1647,14 @@  discard block
 block discarded – undo
1647 1647
      */
1648 1648
     protected function _validate_payment_request_data()
1649 1649
     {
1650
-        if (! isset($this->_req_data['txn_admin_payment'])) {
1650
+        if ( ! isset($this->_req_data['txn_admin_payment'])) {
1651 1651
             return false;
1652 1652
         }
1653 1653
         $payment_form = $this->_generate_payment_form_section();
1654 1654
         try {
1655 1655
             if ($payment_form->was_submitted()) {
1656 1656
                 $payment_form->receive_form_submission();
1657
-                if (! $payment_form->is_valid()) {
1657
+                if ( ! $payment_form->is_valid()) {
1658 1658
                     $submission_error_messages = array();
1659 1659
                     foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) {
1660 1660
                         if ($validation_error instanceof EE_Validation_Error) {
@@ -1833,7 +1833,7 @@  discard block
 block discarded – undo
1833 1833
             array('Y-m-d', 'g:i a')
1834 1834
         );
1835 1835
 
1836
-        if (! $payment->save()) {
1836
+        if ( ! $payment->save()) {
1837 1837
             EE_Error::add_error(
1838 1838
                 sprintf(
1839 1839
                     esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'),
@@ -2030,12 +2030,12 @@  discard block
 block discarded – undo
2030 2030
         // but add in some conditions regarding payment,
2031 2031
         // so that we don't apply payments to registrations that are free or have already been paid for
2032 2032
         // but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative )
2033
-        if (! $payment->is_a_refund()) {
2033
+        if ( ! $payment->is_a_refund()) {
2034 2034
             $registration_query_where_params['REG_final_price'] = array('!=', 0);
2035 2035
             $registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true);
2036 2036
         }
2037 2037
         $registrations = $transaction->registrations(array($registration_query_where_params));
2038
-        if (! empty($registrations)) {
2038
+        if ( ! empty($registrations)) {
2039 2039
             /** @type EE_Payment_Processor $payment_processor */
2040 2040
             $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2041 2041
             $payment_processor->process_registration_payments($transaction, $payment, $registrations);
@@ -2060,7 +2060,7 @@  discard block
 block discarded – undo
2060 2060
     protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array())
2061 2061
     {
2062 2062
         // first if there is no change in status then we get out.
2063
-        if (! isset($this->_req_data['txn_reg_status_change']['reg_status'])
2063
+        if ( ! isset($this->_req_data['txn_reg_status_change']['reg_status'])
2064 2064
             || $this->_req_data['txn_reg_status_change']['reg_status'] === 'NAN'
2065 2065
         ) {
2066 2066
             // no error message, no change requested, just nothing to do man.
@@ -2118,7 +2118,7 @@  discard block
 block discarded – undo
2118 2118
                 'pay_status'       => $payment->STS_ID(),
2119 2119
                 'PAY_ID'           => $payment->ID(),
2120 2120
                 'STS_ID'           => $payment->STS_ID(),
2121
-                'status'           => self::$_pay_status[ $payment->STS_ID() ],
2121
+                'status'           => self::$_pay_status[$payment->STS_ID()],
2122 2122
                 'date'             => $payment->timestamp('Y-m-d', 'h:i a'),
2123 2123
                 'method'           => strtoupper($payment->source()),
2124 2124
                 'PM_ID'            => $payment->payment_method() ? $payment->payment_method()->ID() : 1,
@@ -2240,11 +2240,11 @@  discard block
 block discarded – undo
2240 2240
     {
2241 2241
         $registration_payment_data = array();
2242 2242
         // if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
2243
-        if (! empty($REG_IDs)) {
2243
+        if ( ! empty($REG_IDs)) {
2244 2244
             $registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs))));
2245 2245
             foreach ($registrations as $registration) {
2246 2246
                 if ($registration instanceof EE_Registration) {
2247
-                    $registration_payment_data[ $registration->ID() ] = array(
2247
+                    $registration_payment_data[$registration->ID()] = array(
2248 2248
                         'paid'  => $registration->pretty_paid(),
2249 2249
                         'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()),
2250 2250
                     );
@@ -2356,8 +2356,8 @@  discard block
 block discarded – undo
2356 2356
             : date('m/d/Y');
2357 2357
 
2358 2358
         // make sure our timestamps start and end right at the boundaries for each day
2359
-        $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
2360
-        $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
2359
+        $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00';
2360
+        $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59';
2361 2361
 
2362 2362
 
2363 2363
         // convert to timestamps
@@ -2416,7 +2416,7 @@  discard block
 block discarded – undo
2416 2416
         }
2417 2417
 
2418 2418
         if (isset($this->_req_data['s'])) {
2419
-            $search_string = '%' . $this->_req_data['s'] . '%';
2419
+            $search_string = '%'.$this->_req_data['s'].'%';
2420 2420
             $_where['OR'] = array(
2421 2421
                 'Registration.Event.EVT_name'         => array('LIKE', $search_string),
2422 2422
                 'Registration.Event.EVT_desc'         => array('LIKE', $search_string),
@@ -2443,9 +2443,9 @@  discard block
 block discarded – undo
2443 2443
         }
2444 2444
 
2445 2445
         // failed transactions
2446
-        $failed = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'failed' && ! $count)
2446
+        $failed = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'failed' && ! $count)
2447 2447
                   || ($count && $view === 'failed');
2448
-        $abandoned = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'abandoned' && ! $count)
2448
+        $abandoned = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'abandoned' && ! $count)
2449 2449
                      || ($count && $view === 'abandoned');
2450 2450
 
2451 2451
         if ($failed) {
Please login to merge, or discard this patch.
core/domain/services/factories/CartFactory.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@
 block discarded – undo
23 23
 class CartFactory
24 24
 {
25 25
 
26
-    /**
27
-     * @return EE_Cart
28
-     * @throws InvalidArgumentException
29
-     * @throws InvalidInterfaceException
30
-     * @throws InvalidDataTypeException
31
-     */
32
-    public static function getCart()
33
-    {
34
-        return LoaderFactory::getLoader()->getShared('EE_Cart');
35
-    }
26
+	/**
27
+	 * @return EE_Cart
28
+	 * @throws InvalidArgumentException
29
+	 * @throws InvalidInterfaceException
30
+	 * @throws InvalidDataTypeException
31
+	 */
32
+	public static function getCart()
33
+	{
34
+		return LoaderFactory::getLoader()->getShared('EE_Cart');
35
+	}
36 36
 }
Please login to merge, or discard this patch.