Completed
Pull Request — master (#1264)
by Darren
09:05
created
EE_Admin_Table_Registration_Line_Item_Display_Strategy.strategy.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      *
70 70
      * @param EE_Line_Item $line_item
71 71
      * @param array        $options
72
-     * @return mixed
72
+     * @return string
73 73
      * @throws EE_Error
74 74
      * @throws InvalidArgumentException
75 75
      * @throws InvalidDataTypeException
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      *
169 169
      * @param EE_Line_Item $line_item
170 170
      * @param array        $options
171
-     * @return mixed
171
+     * @return string
172 172
      */
173 173
     protected function _tax_row(EE_Line_Item $line_item, $options = array())
174 174
     {
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
      *
193 193
      * @param EE_Line_Item $line_item
194 194
      * @param array        $options
195
-     * @return mixed
195
+     * @return string
196 196
      */
197 197
     protected function _total_row(EE_Line_Item $line_item, $options = array())
198 198
     {
Please login to merge, or discard this patch.
Indentation   +212 added lines, -212 removed lines patch added patch discarded remove patch
@@ -17,216 +17,216 @@
 block discarded – undo
17 17
 class EE_Admin_Table_Registration_Line_Item_Display_Strategy extends EE_Admin_Table_Line_Item_Display_Strategy
18 18
 {
19 19
 
20
-    /**
21
-     * Table header for display.
22
-     * @since   4.8
23
-     * @param array $options
24
-     * @return string
25
-     */
26
-    protected function _table_header($options)
27
-    {
28
-        $html = EEH_HTML::table('', '', $options['table_css_class']);
29
-        $html .= EEH_HTML::thead();
30
-        $html .= EEH_HTML::tr();
31
-        $html .= EEH_HTML::th(__('Name', 'event_espresso'), '', 'jst-left');
32
-        $html .= EEH_HTML::th(__('Type', 'event_espresso'), '', 'jst-left');
33
-        $html .= EEH_HTML::th(__('Date(s)', 'event_espresso'), '', 'jst-left');
34
-        $html .= EEH_HTML::th(__('Amount', 'event_espresso'), '', 'jst-cntr');
35
-        $html .= EEH_HTML::tbody();
36
-        return $html;
37
-    }
38
-
39
-
40
-    /**
41
-     * @param EE_Registration $registration
42
-     * @param EE_Base_Class   $line_item_object
43
-     * @param EE_Base_Class   $parent_line_item_object
44
-     * @return bool
45
-     * @throws EE_Error
46
-     * @throws InvalidArgumentException
47
-     * @throws ReflectionException
48
-     * @throws InvalidDataTypeException
49
-     * @throws InvalidInterfaceException
50
-     */
51
-    private function shouldSkipLineItemRow($registration, $line_item_object, $parent_line_item_object)
52
-    {
53
-        return ! $registration instanceof EE_Registration
54
-               || ($line_item_object instanceof EE_Ticket && $line_item_object->ID() !== $registration->ticket_ID())
55
-               || ($line_item_object instanceof EE_Event && $line_item_object->ID() !== $registration->event_ID())
56
-               || (
57
-                   $parent_line_item_object instanceof EE_Ticket
58
-                   && $parent_line_item_object->ID() !== $registration->ticket_ID()
59
-               )
60
-               || (
61
-                   $parent_line_item_object instanceof EE_Event
62
-                   && $parent_line_item_object->ID() !== $registration->event_ID()
63
-               );
64
-    }
65
-
66
-
67
-    /**
68
-     *    _item_row
69
-     *
70
-     * @param EE_Line_Item $line_item
71
-     * @param array        $options
72
-     * @return mixed
73
-     * @throws EE_Error
74
-     * @throws InvalidArgumentException
75
-     * @throws InvalidDataTypeException
76
-     * @throws InvalidInterfaceException
77
-     * @throws ReflectionException
78
-     */
79
-    protected function _item_row(EE_Line_Item $line_item, $options = array())
80
-    {
81
-        $line_item_related_object = $line_item->get_object();
82
-        $registration = isset($options['EE_Registration']) ? $options['EE_Registration'] : null;
83
-        $parent_line_item_related_object = $line_item->parent() instanceof EE_Line_Item
84
-            ? $line_item->parent()->get_object()
85
-            : null;
86
-        if ($this->shouldSkipLineItemRow($registration, $line_item_related_object, $parent_line_item_related_object)) {
87
-            return '';
88
-        }
89
-        // start of row
90
-        $row_class = $options['odd'] ? 'item odd' : 'item';
91
-        $html = EEH_HTML::tr('', '', $row_class);
92
-
93
-
94
-        // Name Column
95
-        $name_link = $line_item_related_object instanceof EEI_Admin_Links ? $line_item_related_object->get_admin_details_link() : '';
96
-
97
-        // related object scope.
98
-        $parent_related_object_name = $parent_line_item_related_object instanceof EEI_Line_Item_Object
99
-            ? $parent_line_item_related_object->name()
100
-            : '';
101
-        $parent_related_object_name = empty($parent_related_object_name) && $line_item->parent() instanceof EE_Line_Item
102
-            ? $line_item->parent()->name()
103
-            : $parent_related_object_name;
104
-        $parent_related_object_link = $parent_line_item_related_object instanceof EEI_Admin_Links
105
-            ? $parent_line_item_related_object->get_admin_details_link()
106
-            : '';
107
-
108
-
109
-        $name_html = $line_item_related_object instanceof EEI_Line_Item_Object
110
-            ? $line_item_related_object->name() : $line_item->name();
111
-        $name_html = $name_link ? '<a href="' . $name_link . '">' . $name_html . '</a>'
112
-            : $name_html;
113
-        $name_html .= $line_item->is_taxable() ? ' *' : '';
114
-        // maybe preface with icon?
115
-        $name_html = $line_item_related_object instanceof EEI_Has_Icon
116
-            ? $line_item_related_object->get_icon() . $name_html
117
-            : $name_html;
118
-        $name_html = '<span class="ee-line-item-name linked">' . $name_html . '</span><br>';
119
-        $name_html .=  sprintf(
120
-            _x('%1$sfor the %2$s: %3$s%4$s', 'eg. "for the Event: My Cool Event"', 'event_espresso'),
121
-            '<span class="ee-line-item-related-parent-object">',
122
-            $line_item->parent() instanceof EE_Line_Item
123
-                ? $line_item->parent()->OBJ_type_i18n()
124
-                : __('Item:', 'event_espresso'),
125
-            $parent_related_object_link
126
-                ? '<a href="' . $parent_related_object_link . '">' . $parent_related_object_name . '</a>'
127
-                : $parent_related_object_name,
128
-            '</span>'
129
-        );
130
-        $html .= EEH_HTML::td($name_html, '', 'jst-left');
131
-        // Type Column
132
-        $type_html = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() : '';
133
-        $type_html .= $this->_get_cancellations($line_item);
134
-        $type_html .= $line_item->OBJ_type() ? '<br />' : '';
135
-        $code = $line_item_related_object instanceof EEI_Has_Code ? $line_item_related_object->code() : '';
136
-        $type_html .= ! empty($code) ? '<span class="ee-line-item-id">' . sprintf(__('Code: %s', 'event_espresso'), $code) . '</span>' : '';
137
-        $html .= EEH_HTML::td($type_html, '', 'jst-left');
138
-
139
-        // Date column
140
-        $datetime_content = '';
141
-        if ($line_item_related_object instanceof EE_Ticket) {
142
-            $datetimes = $line_item_related_object->datetimes();
143
-            foreach ($datetimes as $datetime) {
144
-                if ($datetime instanceof EE_Datetime) {
145
-                    $datetime_content .= $datetime->get_dtt_display_name() . '<br>';
146
-                }
147
-            }
148
-        }
149
-        $html .= EEH_HTML::td($datetime_content, '', 'jst-left');
150
-
151
-        // Amount Column
152
-        if ($line_item->is_percent()) {
153
-            $html .= EEH_HTML::td($line_item->percent() . '%', '', 'jst-rght');
154
-        } else {
155
-            $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'jst-rght');
156
-        }
157
-
158
-
159
-        // finish things off and return
160
-        $html .= EEH_HTML::trx();
161
-        return $html;
162
-    }
163
-
164
-
165
-
166
-    /**
167
-     *  _tax_row
168
-     *
169
-     * @param EE_Line_Item $line_item
170
-     * @param array        $options
171
-     * @return mixed
172
-     */
173
-    protected function _tax_row(EE_Line_Item $line_item, $options = array())
174
-    {
175
-        // start of row
176
-        $html = EEH_HTML::tr('', 'admin-primary-mbox-taxes-tr');
177
-        // name th
178
-        $html .= EEH_HTML::th($line_item->name() . '(' . $line_item->get_pretty('LIN_percent') . '%)', '', 'jst-rght', '', ' colspan="3"');
179
-        // total th
180
-        $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght');
181
-        // end of row
182
-        $html .= EEH_HTML::trx();
183
-        return $html;
184
-    }
185
-
186
-
187
-
188
-
189
-
190
-    /**
191
-     *  _total_row
192
-     *
193
-     * @param EE_Line_Item $line_item
194
-     * @param array        $options
195
-     * @return mixed
196
-     */
197
-    protected function _total_row(EE_Line_Item $line_item, $options = array())
198
-    {
199
-
200
-        $registration = isset($options['EE_Registration']) ? $options['EE_Registration'] : null;
201
-        $registration_total = $registration instanceof EE_Registration ? $registration->pretty_final_price() : 0;
202
-        // if no valid registration object then we're not going to show the approximate text.
203
-        $total_match = $registration instanceof EE_Registration
204
-            ? $registration->final_price() === $line_item->total()
205
-            : true;
206
-
207
-        // start of row
208
-        $html = EEH_HTML::tr('', '', 'admin-primary-mbox-total-tr');
209
-        // Total th label
210
-        if ($total_match) {
211
-            $total_label = sprintf(__('This registration\'s total %s:', 'event_espresso'), '(' . EE_Registry::instance()->CFG->currency->code . ')');
212
-        } else {
213
-            $total_label = sprintf(__('This registration\'s approximate total %s', 'event_espresso'), '(' . EE_Registry::instance()->CFG->currency->code . ')');
214
-            $total_label .= '<br>';
215
-            $total_label .= '<p class="ee-footnote-text">'
216
-                            . sprintf(
217
-                                __('The registrations\' share of the transaction total is approximate because it might not be possible to evenly divide the transaction total among each registration, and so some registrations may need to pay a penny more than others.  This registration\'s final share is actually %1$s%2$s%3$s.', 'event_espresso'),
218
-                                '<strong>',
219
-                                $registration_total,
220
-                                '</strong>'
221
-                            )
222
-                            . '</p>';
223
-        }
224
-        $html .= EEH_HTML::th($total_label, '', 'jst-rght', '', ' colspan="3"');
225
-        // total th
226
-
227
-        $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght');
228
-        // end of row
229
-        $html .= EEH_HTML::trx();
230
-        return $html;
231
-    }
20
+	/**
21
+	 * Table header for display.
22
+	 * @since   4.8
23
+	 * @param array $options
24
+	 * @return string
25
+	 */
26
+	protected function _table_header($options)
27
+	{
28
+		$html = EEH_HTML::table('', '', $options['table_css_class']);
29
+		$html .= EEH_HTML::thead();
30
+		$html .= EEH_HTML::tr();
31
+		$html .= EEH_HTML::th(__('Name', 'event_espresso'), '', 'jst-left');
32
+		$html .= EEH_HTML::th(__('Type', 'event_espresso'), '', 'jst-left');
33
+		$html .= EEH_HTML::th(__('Date(s)', 'event_espresso'), '', 'jst-left');
34
+		$html .= EEH_HTML::th(__('Amount', 'event_espresso'), '', 'jst-cntr');
35
+		$html .= EEH_HTML::tbody();
36
+		return $html;
37
+	}
38
+
39
+
40
+	/**
41
+	 * @param EE_Registration $registration
42
+	 * @param EE_Base_Class   $line_item_object
43
+	 * @param EE_Base_Class   $parent_line_item_object
44
+	 * @return bool
45
+	 * @throws EE_Error
46
+	 * @throws InvalidArgumentException
47
+	 * @throws ReflectionException
48
+	 * @throws InvalidDataTypeException
49
+	 * @throws InvalidInterfaceException
50
+	 */
51
+	private function shouldSkipLineItemRow($registration, $line_item_object, $parent_line_item_object)
52
+	{
53
+		return ! $registration instanceof EE_Registration
54
+			   || ($line_item_object instanceof EE_Ticket && $line_item_object->ID() !== $registration->ticket_ID())
55
+			   || ($line_item_object instanceof EE_Event && $line_item_object->ID() !== $registration->event_ID())
56
+			   || (
57
+				   $parent_line_item_object instanceof EE_Ticket
58
+				   && $parent_line_item_object->ID() !== $registration->ticket_ID()
59
+			   )
60
+			   || (
61
+				   $parent_line_item_object instanceof EE_Event
62
+				   && $parent_line_item_object->ID() !== $registration->event_ID()
63
+			   );
64
+	}
65
+
66
+
67
+	/**
68
+	 *    _item_row
69
+	 *
70
+	 * @param EE_Line_Item $line_item
71
+	 * @param array        $options
72
+	 * @return mixed
73
+	 * @throws EE_Error
74
+	 * @throws InvalidArgumentException
75
+	 * @throws InvalidDataTypeException
76
+	 * @throws InvalidInterfaceException
77
+	 * @throws ReflectionException
78
+	 */
79
+	protected function _item_row(EE_Line_Item $line_item, $options = array())
80
+	{
81
+		$line_item_related_object = $line_item->get_object();
82
+		$registration = isset($options['EE_Registration']) ? $options['EE_Registration'] : null;
83
+		$parent_line_item_related_object = $line_item->parent() instanceof EE_Line_Item
84
+			? $line_item->parent()->get_object()
85
+			: null;
86
+		if ($this->shouldSkipLineItemRow($registration, $line_item_related_object, $parent_line_item_related_object)) {
87
+			return '';
88
+		}
89
+		// start of row
90
+		$row_class = $options['odd'] ? 'item odd' : 'item';
91
+		$html = EEH_HTML::tr('', '', $row_class);
92
+
93
+
94
+		// Name Column
95
+		$name_link = $line_item_related_object instanceof EEI_Admin_Links ? $line_item_related_object->get_admin_details_link() : '';
96
+
97
+		// related object scope.
98
+		$parent_related_object_name = $parent_line_item_related_object instanceof EEI_Line_Item_Object
99
+			? $parent_line_item_related_object->name()
100
+			: '';
101
+		$parent_related_object_name = empty($parent_related_object_name) && $line_item->parent() instanceof EE_Line_Item
102
+			? $line_item->parent()->name()
103
+			: $parent_related_object_name;
104
+		$parent_related_object_link = $parent_line_item_related_object instanceof EEI_Admin_Links
105
+			? $parent_line_item_related_object->get_admin_details_link()
106
+			: '';
107
+
108
+
109
+		$name_html = $line_item_related_object instanceof EEI_Line_Item_Object
110
+			? $line_item_related_object->name() : $line_item->name();
111
+		$name_html = $name_link ? '<a href="' . $name_link . '">' . $name_html . '</a>'
112
+			: $name_html;
113
+		$name_html .= $line_item->is_taxable() ? ' *' : '';
114
+		// maybe preface with icon?
115
+		$name_html = $line_item_related_object instanceof EEI_Has_Icon
116
+			? $line_item_related_object->get_icon() . $name_html
117
+			: $name_html;
118
+		$name_html = '<span class="ee-line-item-name linked">' . $name_html . '</span><br>';
119
+		$name_html .=  sprintf(
120
+			_x('%1$sfor the %2$s: %3$s%4$s', 'eg. "for the Event: My Cool Event"', 'event_espresso'),
121
+			'<span class="ee-line-item-related-parent-object">',
122
+			$line_item->parent() instanceof EE_Line_Item
123
+				? $line_item->parent()->OBJ_type_i18n()
124
+				: __('Item:', 'event_espresso'),
125
+			$parent_related_object_link
126
+				? '<a href="' . $parent_related_object_link . '">' . $parent_related_object_name . '</a>'
127
+				: $parent_related_object_name,
128
+			'</span>'
129
+		);
130
+		$html .= EEH_HTML::td($name_html, '', 'jst-left');
131
+		// Type Column
132
+		$type_html = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() : '';
133
+		$type_html .= $this->_get_cancellations($line_item);
134
+		$type_html .= $line_item->OBJ_type() ? '<br />' : '';
135
+		$code = $line_item_related_object instanceof EEI_Has_Code ? $line_item_related_object->code() : '';
136
+		$type_html .= ! empty($code) ? '<span class="ee-line-item-id">' . sprintf(__('Code: %s', 'event_espresso'), $code) . '</span>' : '';
137
+		$html .= EEH_HTML::td($type_html, '', 'jst-left');
138
+
139
+		// Date column
140
+		$datetime_content = '';
141
+		if ($line_item_related_object instanceof EE_Ticket) {
142
+			$datetimes = $line_item_related_object->datetimes();
143
+			foreach ($datetimes as $datetime) {
144
+				if ($datetime instanceof EE_Datetime) {
145
+					$datetime_content .= $datetime->get_dtt_display_name() . '<br>';
146
+				}
147
+			}
148
+		}
149
+		$html .= EEH_HTML::td($datetime_content, '', 'jst-left');
150
+
151
+		// Amount Column
152
+		if ($line_item->is_percent()) {
153
+			$html .= EEH_HTML::td($line_item->percent() . '%', '', 'jst-rght');
154
+		} else {
155
+			$html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'jst-rght');
156
+		}
157
+
158
+
159
+		// finish things off and return
160
+		$html .= EEH_HTML::trx();
161
+		return $html;
162
+	}
163
+
164
+
165
+
166
+	/**
167
+	 *  _tax_row
168
+	 *
169
+	 * @param EE_Line_Item $line_item
170
+	 * @param array        $options
171
+	 * @return mixed
172
+	 */
173
+	protected function _tax_row(EE_Line_Item $line_item, $options = array())
174
+	{
175
+		// start of row
176
+		$html = EEH_HTML::tr('', 'admin-primary-mbox-taxes-tr');
177
+		// name th
178
+		$html .= EEH_HTML::th($line_item->name() . '(' . $line_item->get_pretty('LIN_percent') . '%)', '', 'jst-rght', '', ' colspan="3"');
179
+		// total th
180
+		$html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght');
181
+		// end of row
182
+		$html .= EEH_HTML::trx();
183
+		return $html;
184
+	}
185
+
186
+
187
+
188
+
189
+
190
+	/**
191
+	 *  _total_row
192
+	 *
193
+	 * @param EE_Line_Item $line_item
194
+	 * @param array        $options
195
+	 * @return mixed
196
+	 */
197
+	protected function _total_row(EE_Line_Item $line_item, $options = array())
198
+	{
199
+
200
+		$registration = isset($options['EE_Registration']) ? $options['EE_Registration'] : null;
201
+		$registration_total = $registration instanceof EE_Registration ? $registration->pretty_final_price() : 0;
202
+		// if no valid registration object then we're not going to show the approximate text.
203
+		$total_match = $registration instanceof EE_Registration
204
+			? $registration->final_price() === $line_item->total()
205
+			: true;
206
+
207
+		// start of row
208
+		$html = EEH_HTML::tr('', '', 'admin-primary-mbox-total-tr');
209
+		// Total th label
210
+		if ($total_match) {
211
+			$total_label = sprintf(__('This registration\'s total %s:', 'event_espresso'), '(' . EE_Registry::instance()->CFG->currency->code . ')');
212
+		} else {
213
+			$total_label = sprintf(__('This registration\'s approximate total %s', 'event_espresso'), '(' . EE_Registry::instance()->CFG->currency->code . ')');
214
+			$total_label .= '<br>';
215
+			$total_label .= '<p class="ee-footnote-text">'
216
+							. sprintf(
217
+								__('The registrations\' share of the transaction total is approximate because it might not be possible to evenly divide the transaction total among each registration, and so some registrations may need to pay a penny more than others.  This registration\'s final share is actually %1$s%2$s%3$s.', 'event_espresso'),
218
+								'<strong>',
219
+								$registration_total,
220
+								'</strong>'
221
+							)
222
+							. '</p>';
223
+		}
224
+		$html .= EEH_HTML::th($total_label, '', 'jst-rght', '', ' colspan="3"');
225
+		// total th
226
+
227
+		$html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght');
228
+		// end of row
229
+		$html .= EEH_HTML::trx();
230
+		return $html;
231
+	}
232 232
 }
Please login to merge, or discard this patch.