Completed
Branch fix/kses-6 (dd7b82)
by
unknown
09:41 queued 07:30
created
form_sections/strategies/display/EE_Select_Display_Strategy.strategy.php 2 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -15,78 +15,78 @@
 block discarded – undo
15 15
 class EE_Select_Display_Strategy extends EE_Display_Strategy_Base
16 16
 {
17 17
 
18
-    /**
19
-     *
20
-     * @throws EE_Error
21
-     * @return string of html to display the field
22
-     */
23
-    public function display()
24
-    {
25
-        if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
26
-            throw new EE_Error(sprintf(esc_html__('Cannot use Select Display Strategy with an input that doesn\'t have options', 'event_espresso')));
27
-        }
18
+	/**
19
+	 *
20
+	 * @throws EE_Error
21
+	 * @return string of html to display the field
22
+	 */
23
+	public function display()
24
+	{
25
+		if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
26
+			throw new EE_Error(sprintf(esc_html__('Cannot use Select Display Strategy with an input that doesn\'t have options', 'event_espresso')));
27
+		}
28 28
 
29
-        $html = EEH_HTML::nl(0, 'select');
30
-        $html .= '<select';
31
-        $html .= $this->_attributes_string(
32
-            $this->_standard_attributes_array()
33
-        );
34
-        $html .= '>';
29
+		$html = EEH_HTML::nl(0, 'select');
30
+		$html .= '<select';
31
+		$html .= $this->_attributes_string(
32
+			$this->_standard_attributes_array()
33
+		);
34
+		$html .= '>';
35 35
 
36
-        if (EEH_Array::is_multi_dimensional_array($this->_input->options())) {
37
-            EEH_HTML::indent(1, 'optgroup');
38
-            foreach ($this->_input->options() as $opt_group_label => $opt_group) {
39
-                if (! empty($opt_group_label)) {
40
-                    $html .= EEH_HTML::nl(0, 'optgroup') . '<optgroup label="' . esc_attr($opt_group_label) . '">';
41
-                }
42
-                EEH_HTML::indent(1, 'option');
43
-                $html .= $this->_display_options($opt_group);
44
-                EEH_HTML::indent(-1, 'option');
45
-                if (! empty($opt_group_label)) {
46
-                    $html .= EEH_HTML::nl(0, 'optgroup') . '</optgroup>';
47
-                }
48
-            }
49
-            EEH_HTML::indent(-1, 'optgroup');
50
-        } else {
51
-            $html .= $this->_display_options($this->_input->options());
52
-        }
36
+		if (EEH_Array::is_multi_dimensional_array($this->_input->options())) {
37
+			EEH_HTML::indent(1, 'optgroup');
38
+			foreach ($this->_input->options() as $opt_group_label => $opt_group) {
39
+				if (! empty($opt_group_label)) {
40
+					$html .= EEH_HTML::nl(0, 'optgroup') . '<optgroup label="' . esc_attr($opt_group_label) . '">';
41
+				}
42
+				EEH_HTML::indent(1, 'option');
43
+				$html .= $this->_display_options($opt_group);
44
+				EEH_HTML::indent(-1, 'option');
45
+				if (! empty($opt_group_label)) {
46
+					$html .= EEH_HTML::nl(0, 'optgroup') . '</optgroup>';
47
+				}
48
+			}
49
+			EEH_HTML::indent(-1, 'optgroup');
50
+		} else {
51
+			$html .= $this->_display_options($this->_input->options());
52
+		}
53 53
 
54
-        $html .= EEH_HTML::nl(0, 'select') . '</select>';
55
-        return $html;
56
-    }
54
+		$html .= EEH_HTML::nl(0, 'select') . '</select>';
55
+		return $html;
56
+	}
57 57
 
58 58
 
59 59
 
60
-    /**
61
-     * Displays a flat list of options as option tags
62
-     * @param array $options
63
-     * @return string
64
-     */
65
-    protected function _display_options($options)
66
-    {
67
-        $html = '';
68
-        EEH_HTML::indent(1, 'option');
69
-        foreach ($options as $value => $display_text) {
70
-            // even if this input uses EE_Text_Normalization if one of the array keys is a numeric string, like "123",
71
-            // PHP will have converted it to a PHP integer (eg 123). So we need to make sure it's a string
72
-            $unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one($value);
73
-            $selected = $this->_check_if_option_selected($unnormalized_value) ? ' selected' : '';
74
-            $html .= EEH_HTML::nl(0, 'option') . '<option value="' . esc_attr($unnormalized_value) . '"' . $selected . '>' . $display_text . '</option>';
75
-        }
76
-        EEH_HTML::indent(-1, 'option');
77
-        return $html;
78
-    }
60
+	/**
61
+	 * Displays a flat list of options as option tags
62
+	 * @param array $options
63
+	 * @return string
64
+	 */
65
+	protected function _display_options($options)
66
+	{
67
+		$html = '';
68
+		EEH_HTML::indent(1, 'option');
69
+		foreach ($options as $value => $display_text) {
70
+			// even if this input uses EE_Text_Normalization if one of the array keys is a numeric string, like "123",
71
+			// PHP will have converted it to a PHP integer (eg 123). So we need to make sure it's a string
72
+			$unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one($value);
73
+			$selected = $this->_check_if_option_selected($unnormalized_value) ? ' selected' : '';
74
+			$html .= EEH_HTML::nl(0, 'option') . '<option value="' . esc_attr($unnormalized_value) . '"' . $selected . '>' . $display_text . '</option>';
75
+		}
76
+		EEH_HTML::indent(-1, 'option');
77
+		return $html;
78
+	}
79 79
 
80 80
 
81 81
 
82
-    /**
83
-     * Checks if that value is the one selected
84
-     *
85
-     * @param string|int $option_value unnormalized value option (string). How it will appear in the HTML.
86
-     * @return string
87
-     */
88
-    protected function _check_if_option_selected($option_value)
89
-    {
90
-        return $option_value === $this->_input->raw_value();
91
-    }
82
+	/**
83
+	 * Checks if that value is the one selected
84
+	 *
85
+	 * @param string|int $option_value unnormalized value option (string). How it will appear in the HTML.
86
+	 * @return string
87
+	 */
88
+	protected function _check_if_option_selected($option_value)
89
+	{
90
+		return $option_value === $this->_input->raw_value();
91
+	}
92 92
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      */
23 23
     public function display()
24 24
     {
25
-        if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
25
+        if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base) {
26 26
             throw new EE_Error(sprintf(esc_html__('Cannot use Select Display Strategy with an input that doesn\'t have options', 'event_espresso')));
27 27
         }
28 28
 
@@ -36,14 +36,14 @@  discard block
 block discarded – undo
36 36
         if (EEH_Array::is_multi_dimensional_array($this->_input->options())) {
37 37
             EEH_HTML::indent(1, 'optgroup');
38 38
             foreach ($this->_input->options() as $opt_group_label => $opt_group) {
39
-                if (! empty($opt_group_label)) {
40
-                    $html .= EEH_HTML::nl(0, 'optgroup') . '<optgroup label="' . esc_attr($opt_group_label) . '">';
39
+                if ( ! empty($opt_group_label)) {
40
+                    $html .= EEH_HTML::nl(0, 'optgroup').'<optgroup label="'.esc_attr($opt_group_label).'">';
41 41
                 }
42 42
                 EEH_HTML::indent(1, 'option');
43 43
                 $html .= $this->_display_options($opt_group);
44 44
                 EEH_HTML::indent(-1, 'option');
45
-                if (! empty($opt_group_label)) {
46
-                    $html .= EEH_HTML::nl(0, 'optgroup') . '</optgroup>';
45
+                if ( ! empty($opt_group_label)) {
46
+                    $html .= EEH_HTML::nl(0, 'optgroup').'</optgroup>';
47 47
                 }
48 48
             }
49 49
             EEH_HTML::indent(-1, 'optgroup');
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
             $html .= $this->_display_options($this->_input->options());
52 52
         }
53 53
 
54
-        $html .= EEH_HTML::nl(0, 'select') . '</select>';
54
+        $html .= EEH_HTML::nl(0, 'select').'</select>';
55 55
         return $html;
56 56
     }
57 57
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
             // PHP will have converted it to a PHP integer (eg 123). So we need to make sure it's a string
72 72
             $unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one($value);
73 73
             $selected = $this->_check_if_option_selected($unnormalized_value) ? ' selected' : '';
74
-            $html .= EEH_HTML::nl(0, 'option') . '<option value="' . esc_attr($unnormalized_value) . '"' . $selected . '>' . $display_text . '</option>';
74
+            $html .= EEH_HTML::nl(0, 'option').'<option value="'.esc_attr($unnormalized_value).'"'.$selected.'>'.$display_text.'</option>';
75 75
         }
76 76
         EEH_HTML::indent(-1, 'option');
77 77
         return $html;
Please login to merge, or discard this patch.
admin/new/pricing/templates/event_tickets_metabox_main.template.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
               class="clickable ee-collapsible <?php echo sanitize_html_class($ee_collapsible_status); ?>">
27 27
             <span class="dashicons dashicons-clock ee-icon-size-20"></span>
28 28
             <?php
29
-                esc_html_e(
30
-                    'Event Datetimes',
31
-                    'event_espresso'
32
-                );
33
-                ?>
29
+				esc_html_e(
30
+					'Event Datetimes',
31
+					'event_espresso'
32
+				);
33
+				?>
34 34
         </span>
35 35
     </h3>
36 36
     <?php echo wp_kses($event_datetime_help_link, AllowedTags::getAllowedTags()); ?>
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
     </div> <!-- end .event-datetimes-container -->
68 68
     <div id="add-event-datetime" class="event-datetime-row add-dtt-row" style="display:none;">
69 69
         <h4 class="datetime-tickets-heading"><?php
70
-            esc_html_e(
71
-                'Add New Datetime',
72
-                'event_espresso'
73
-            ); ?></h4><?php echo wp_kses($add_new_dtt_help_link, AllowedTags::getAllowedTags()); ?>
70
+			esc_html_e(
71
+				'Add New Datetime',
72
+				'event_espresso'
73
+			); ?></h4><?php echo wp_kses($add_new_dtt_help_link, AllowedTags::getAllowedTags()); ?>
74 74
         <div>
75 75
             <table id="add-new-event-datetime-table" class="datetime-edit-table">
76 76
                 <tr>
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
                     <td class="event-datetime-column date-column">
85 85
                         <label class="add-new-event-datetime-DTT_EVT_start_label"
86 86
                                for="add-new-event-datetime-DTT_EVT_start"><?php
87
-                                esc_html_e(
88
-                                    'Event Start',
89
-                                    'event_espresso'
90
-                                ); ?></label>
87
+								esc_html_e(
88
+									'Event Start',
89
+									'event_espresso'
90
+								); ?></label>
91 91
                         <input type="text" name="add_new_datetime[DTT_EVT_start]"
92 92
                                id="add-new-event-datetime-DTT_EVT_start" class="ee-text-inp ee-datepicker"
93 93
                                data-context="start-dtt" data-date-field-context="#add-event-datetime"
@@ -97,10 +97,10 @@  discard block
 block discarded – undo
97 97
                     <td class="event-datetime-column date-column">
98 98
                         <label class="add-new-event-datetime-DTT_EVT_end_label"
99 99
                                for="add-new-event-datetime-DTT_EVT_end"><?php
100
-                                esc_html_e(
101
-                                    'Event End',
102
-                                    'event_espresso'
103
-                                ); ?></label>
100
+								esc_html_e(
101
+									'Event End',
102
+									'event_espresso'
103
+								); ?></label>
104 104
                         <input type="text" name="add_new_datetime[DTT_EVT_end]" id="add-new-event-datetime-DTT_EVT_end"
105 105
                                class="ee-text-inp ee-datepicker" data-context="end-dtt"
106 106
                                data-date-field-context="#add-event-datetime"
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
110 110
                     <td class="event-datetime-column reg-limit-column">
111 111
                         <label class="add-new-event-datetime-DTT_EVT_end_label"
112 112
                                for="add-new-event-datetime-DTT_reg_limit"><?php
113
-                                esc_html_e(
114
-                                    'Limit',
115
-                                    'event_espresso'
116
-                                ); ?></label>
113
+								esc_html_e(
114
+									'Limit',
115
+									'event_espresso'
116
+								); ?></label>
117 117
                         <input type="text" name="add_new_datetime[DTT_reg_limit]"
118 118
                                id="add-new-event-datetime-DTT_reg_limit" class="ee-numeric ee-small-text-inp">
119 119
                     </td>
@@ -136,16 +136,16 @@  discard block
 block discarded – undo
136 136
         <h3 class="event-tickets-datetimes-title"><span data-target=".event-tickets-container"
137 137
                                                         class="clickable ee-collapsible <?php echo sanitize_html_class($ee_collapsible_status); ?>"><span
138 138
                     class="ee-icon ee-icon-tickets ee-icon-size-20"></span><?php
139
-                    esc_html_e(
140
-                        'Available Tickets',
141
-                        'event_espresso'
142
-                    ); ?></span></h3>
139
+					esc_html_e(
140
+						'Available Tickets',
141
+						'event_espresso'
142
+					); ?></span></h3>
143 143
         <div class="event-tickets-container ee-create-ticket-button"<?php echo $show_tickets_container; ?>>
144 144
             <button class="ee-create-ticket-button button-secondary ee-create-button" data-context="ticket"><?php
145
-                esc_html_e(
146
-                    'Create Ticket',
147
-                    'event_espresso'
148
-                ); ?></button>
145
+				esc_html_e(
146
+					'Create Ticket',
147
+					'event_espresso'
148
+				); ?></button>
149 149
         </div>
150 150
         <div style="clear:both"></div>
151 151
         <div class="event-tickets-container"<?php echo $show_tickets_container; ?>>
Please login to merge, or discard this patch.
pricing/templates/event_tickets_datetime_attached_tickets_row.template.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
                           placeholder="Datetime Description (optional)"><?php echo esc_textarea($DTT_description); ?></textarea>
26 26
             </div>
27 27
             <?php do_action(
28
-                'AHEE__event_tickets_datetime_attached_tickets_row_template__advanced_details_after_dtt_description',
29
-                $dtt_row,
30
-                $DTT_ID
31
-            ); ?>
28
+				'AHEE__event_tickets_datetime_attached_tickets_row_template__advanced_details_after_dtt_description',
29
+				$dtt_row,
30
+				$DTT_ID
31
+			); ?>
32 32
             <h4 class="datetime-tickets-heading"><?php esc_html_e('Assigned Tickets', 'event_espresso'); ?></h4>
33 33
 
34 34
             <ul class="datetime-tickets-list">
@@ -38,28 +38,28 @@  discard block
 block discarded – undo
38 38
 
39 39
             <div class="add-datetime-ticket-container">
40 40
                 <h4 class="datetime-tickets-heading"><?php
41
-                    esc_html_e(
42
-                        'Add New Ticket',
43
-                        'event_espresso'
44
-                    ); ?></h4><?php echo wp_kses($add_new_datetime_ticket_help_link, AllowedTags::getAllowedTags()); ?><br>
41
+					esc_html_e(
42
+						'Add New Ticket',
43
+						'event_espresso'
44
+					); ?></h4><?php echo wp_kses($add_new_datetime_ticket_help_link, AllowedTags::getAllowedTags()); ?><br>
45 45
                 <table class="add-new-ticket-table">
46 46
                     <thead>
47 47
                     <tr valign="top">
48 48
                         <td><span class="ANT_TKT_name_label"><?php
49
-                                esc_html_e(
50
-                                    'Ticket Name',
51
-                                    'event_espresso'
52
-                                ); ?></span></td>
49
+								esc_html_e(
50
+									'Ticket Name',
51
+									'event_espresso'
52
+								); ?></span></td>
53 53
                         <td><span class="ANT_TKT_goes_on_sale_label"><?php
54
-                                esc_html_e(
55
-                                    'Sale Starts',
56
-                                    'event_espresso'
57
-                                ); ?></span></td>
54
+								esc_html_e(
55
+									'Sale Starts',
56
+									'event_espresso'
57
+								); ?></span></td>
58 58
                         <td><span class="ANT_TKT_sell_until_label"><?php
59
-                                esc_html_e(
60
-                                    'Sell Until',
61
-                                    'event_espresso'
62
-                                ); ?></span></td>
59
+								esc_html_e(
60
+									'Sell Until',
61
+									'event_espresso'
62
+								); ?></span></td>
63 63
                         <td><span class="ANT_TKT_price_label"><?php esc_html_e('Price', 'event_espresso'); ?></span>
64 64
                         </td>
65 65
                         <td><span class="ANT_TKT_qty_label"><?php esc_html_e('Qty', 'event_espresso'); ?></span></td>
@@ -109,12 +109,12 @@  discard block
 block discarded – undo
109 109
                 <div class="ee-editor-footer-container">
110 110
                     <div class="ee-editor-id-container">
111 111
                         <span class="ee-item-id"><?php
112
-                            echo ($DTT_ID
113
-                                ? sprintf(
114
-                                    esc_html__('Datetime ID: %d', 'event_espresso'),
115
-                                    $DTT_ID
116
-                                )
117
-                                : ''); ?></span>
112
+							echo ($DTT_ID
113
+								? sprintf(
114
+									esc_html__('Datetime ID: %d', 'event_espresso'),
115
+									$DTT_ID
116
+								)
117
+								: ''); ?></span>
118 118
                     </div>
119 119
                     <div class="save-cancel-button-container">
120 120
                         <button data-context="short-ticket" data-datetime-row="<?php echo esc_attr($dtt_row); ?>"
Please login to merge, or discard this patch.
admin/new/pricing/templates/pricing_type_details_main_meta_box.template.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
                 <?php echo wp_kses($base_type_select, AllowedTags::getWithFormTags()); ?><br/>
23 23
                 <p class="description">
24 24
                     <?php
25
-                    printf(
26
-                        esc_html__(
27
-                            'Choosing a basic type allows us to quickly configure a bunch of other options for you.%1$sAll events need to have at least one Base Price type option.%1$sDiscounts reduce the price of an event, Surcharges increase the price.%1$sTaxes are applied to the final total.',
28
-                            'event_espresso'
29
-                        ),
30
-                        '<br/>'
31
-                    ); ?>
25
+					printf(
26
+						esc_html__(
27
+							'Choosing a basic type allows us to quickly configure a bunch of other options for you.%1$sAll events need to have at least one Base Price type option.%1$sDiscounts reduce the price of an event, Surcharges increase the price.%1$sTaxes are applied to the final total.',
28
+							'event_espresso'
29
+						),
30
+						'<br/>'
31
+					); ?>
32 32
                 </p>
33 33
             </td>
34 34
         </tr>
@@ -60,20 +60,20 @@  discard block
 block discarded – undo
60 60
                     <?php esc_html_e('Fixed', 'event_espresso'); ?>
61 61
                 </label>
62 62
                 <p class="description"><?php
63
-                    esc_html_e(
64
-                        'Whether this Price Type will be applied as a percentage or applied as a set fixed amount.',
65
-                        'event_espresso'
66
-                    ); ?></p>
63
+					esc_html_e(
64
+						'Whether this Price Type will be applied as a percentage or applied as a set fixed amount.',
65
+						'event_espresso'
66
+					); ?></p>
67 67
                 <?php if ($price_type->base_type() == EEM_Price_Type::base_type_tax) :
68
-                    // base type is tax so let's just let the user know that taxes are always percentage.
69
-                    ?>
68
+					// base type is tax so let's just let the user know that taxes are always percentage.
69
+					?>
70 70
                     <p class="description" style="color:#E44064">
71 71
                         <?php
72
-                            esc_html_e(
73
-                                'The selected base type for this price type is "Tax".  Taxes are always assumed to be a percentage.  If you want to use a fixed value for a tax then please change the base type to a surcharge.',
74
-                                'event_espresso'
75
-                            );
76
-                        ?></p>
72
+							esc_html_e(
73
+								'The selected base type for this price type is "Tax".  Taxes are always assumed to be a percentage.  If you want to use a fixed value for a tax then please change the base type to a surcharge.',
74
+								'event_espresso'
75
+							);
76
+						?></p>
77 77
                 <?php endif; ?>
78 78
             </td>
79 79
         </tr>
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
                     <?php esc_html_e('The order that Price Types are applied.', 'event_espresso'); ?></p>
89 89
                 <p class="description">
90 90
                     <?php
91
-                    printf(
92
-                        esc_html__(
93
-                            'Price types are applied sequentially according to their Order, where higher ordered Price Types will affect lower ordered Price Types.%1$sPrice types with equal Orders will be applied in parallel to whatever total precedes them and will not affect each other. Actual Prices will be set to "0" so that they are processed first. Taxes will be always be applied last but their order will still determine if they are applied in parallel or as compound taxes (one tax on top of the other).',
94
-                            'event_espresso'
95
-                        ),
96
-                        '<br/>'
97
-                    ); ?>
91
+					printf(
92
+						esc_html__(
93
+							'Price types are applied sequentially according to their Order, where higher ordered Price Types will affect lower ordered Price Types.%1$sPrice types with equal Orders will be applied in parallel to whatever total precedes them and will not affect each other. Actual Prices will be set to "0" so that they are processed first. Taxes will be always be applied last but their order will still determine if they are applied in parallel or as compound taxes (one tax on top of the other).',
94
+							'event_espresso'
95
+						),
96
+						'<br/>'
97
+					); ?>
98 98
                 </p>
99 99
             </td>
100 100
         </tr>
Please login to merge, or discard this patch.
new/pricing/templates/event_tickets_datetime_ticket_price_row.template.php 1 patch
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -64,9 +64,12 @@  discard block
 block discarded – undo
64 64
             <input type="text" size="1" class="edit-price-PRC_amount ee-numeric"
65 65
                    name="prices_archive[<?php echo esc_attr($tkt_row); ?>][<?php echo esc_attr($PRC_order); ?>][PRC_amount]"
66 66
                    value="<?php echo esc_attr($PRC_amount); ?>" disabled>
67
-        <?php else : ?>
67
+        <?php else {
68
+	: ?>
68 69
             <input type="text" size="1" class="edit-price-PRC_amount ee-numeric"
69
-                   name="<?php echo esc_attr($edit_prices_name); ?>[<?php echo esc_attr($tkt_row); ?>][<?php echo esc_attr($PRC_order); ?>][PRC_amount]"
70
+                   name="<?php echo esc_attr($edit_prices_name);
71
+}
72
+?>[<?php echo esc_attr($tkt_row); ?>][<?php echo esc_attr($PRC_order); ?>][PRC_amount]"
70 73
                    value="<?php echo esc_attr($PRC_amount); ?>">
71 74
         <?php endif; ?>
72 75
     </td>
@@ -77,8 +80,11 @@  discard block
 block discarded – undo
77 80
     <td>
78 81
         <?php if ($disabled) : ?>
79 82
             <span class="ee-lock-icon"></span>
80
-        <?php else : ?>
81
-            <span class="trash-icon dashicons dashicons-post-trash clickable" data-ticket-row="<?php echo esc_attr($tkt_row); ?>"
83
+        <?php else {
84
+	: ?>
85
+            <span class="trash-icon dashicons dashicons-post-trash clickable" data-ticket-row="<?php echo esc_attr($tkt_row);
86
+}
87
+?>"
82 88
                   data-context="price" data-price-row="<?php echo esc_attr($PRC_order); ?>"<?php echo wp_kses($show_trash_icon, AllowedTags::getWithFormTags()); ?>></span>
83 89
             <button data-ticket-row="<?php echo esc_attr($tkt_row); ?>" data-price-row="<?php echo esc_attr($PRC_order); ?>"
84 90
                     data-context="price" class="ee-create-button"<?php echo wp_kses($show_create_button, AllowedTags::getWithFormTags()); ?>><strong>+</strong>
Please login to merge, or discard this patch.
admin/new/pricing/templates/event_tickets_datetime_ticket_row.template.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
                maxlength='245'
82 82
                name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo esc_attr($tkt_row); ?>][TKT_name]"
83 83
                placeholder="<?php
84
-               esc_html_e('Ticket Title', 'event_espresso') ?>"
84
+			   esc_html_e('Ticket Title', 'event_espresso') ?>"
85 85
                value="<?php echo esc_attr($TKT_name); ?>"
86 86
         />
87 87
     </td>
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
                                        for='edit-ticket-TKT_uses-<?php echo esc_attr($tkt_row); ?>'
328 328
                                 >
329 329
                                     <?php
330
-                                    esc_html_e('Ticket Uses', 'event_espresso') ?>
330
+									esc_html_e('Ticket Uses', 'event_espresso') ?>
331 331
                                 </label>
332 332
                                 <input type="text"
333 333
                                        class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric"
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
                                 />
347 347
                                 <label class='screen-reader-text' for='disabled-ticket-TKT_min-<?php echo esc_attr($tkt_row);?>'>
348 348
                                     <?php
349
-                                    esc_html_e('Minimum Quantity', 'event_espresso') ?>
349
+									esc_html_e('Minimum Quantity', 'event_espresso') ?>
350 350
                                 </label>
351 351
                                 <input type="text" disabled
352 352
                                        class="edit-ticket-TKT_min ee-small-text-inp ee-numeric"
@@ -408,14 +408,14 @@  discard block
 block discarded – undo
408 408
                                id="edit-ticket-TKT_required-<?php echo esc_attr($tkt_row); ?>"
409 409
                                value="1"
410 410
                             <?php
411
-                                echo ($TKT_required ? ' checked' : '');
412
-                                echo ($disabled ? ' disabled' : '');
413
-                            ?>
411
+								echo ($TKT_required ? ' checked' : '');
412
+								echo ($disabled ? ' disabled' : '');
413
+							?>
414 414
                         />
415 415
                         <?php esc_html_e(
416
-                            'This ticket is required (will appear first in frontend ticket lists).',
417
-                            'event_espresso'
418
-                        ); ?>
416
+							'This ticket is required (will appear first in frontend ticket lists).',
417
+							'event_espresso'
418
+						); ?>
419 419
                     </label>
420 420
                 </div>
421 421
                 <div class="ticket-is-taxable-container">
@@ -517,32 +517,32 @@  discard block
 block discarded – undo
517 517
             <h4 class="tickets-heading"><?php esc_html_e('Event Datetimes', 'event_espresso'); ?></h4>
518 518
             <p>
519 519
             <?php  esc_html_e(
520
-                'This ticket will be usable (allow entrance) for the following selected event datetimes (click to select).  The "# Datetimes" amount (above) indicates how many of the assigned datetimes the ticket holder can gain access to:',
521
-                'event_espresso'
522
-            ); ?>
520
+				'This ticket will be usable (allow entrance) for the following selected event datetimes (click to select).  The "# Datetimes" amount (above) indicates how many of the assigned datetimes the ticket holder can gain access to:',
521
+				'event_espresso'
522
+			); ?>
523 523
             </p>
524 524
             <ul class="datetime-tickets-list">
525 525
                 <?php echo wp_kses($ticket_datetimes_list, AllowedTags::getWithFormTags()); ?>
526 526
             </ul>
527 527
 
528 528
             <?php do_action(
529
-                'AHEE__event_tickets_datetime_ticket_row_template__advanced_details_end',
530
-                $tkt_row,
531
-                $TKT_ID
532
-            ); ?>
529
+				'AHEE__event_tickets_datetime_ticket_row_template__advanced_details_end',
530
+				$tkt_row,
531
+				$TKT_ID
532
+			); ?>
533 533
             <div class="ee-editor-footer-container">
534 534
                 <div class="ee-editor-id-container">
535 535
                     <span class="ee-item-id"><?php
536
-                        echo ($TKT_ID
537
-                            ? sprintf(esc_html__('Ticket ID: %d', 'event_espresso'), $TKT_ID)
538
-                            : ''); ?></span>
536
+						echo ($TKT_ID
537
+							? sprintf(esc_html__('Ticket ID: %d', 'event_espresso'), $TKT_ID)
538
+							: ''); ?></span>
539 539
                 </div>
540 540
                 <div class="save-cancel-button-container">
541 541
                     <label for="edit-ticket-TKT_is_default_selector-<?php echo esc_attr($tkt_row); ?>">
542 542
                         <?php esc_html_e(
543
-                            'use this new ticket as a default ticket for any new events',
544
-                            'event_espresso'
545
-                        ); ?>
543
+							'use this new ticket as a default ticket for any new events',
544
+							'event_espresso'
545
+						); ?>
546 546
                         <input type="checkbox"
547 547
                                name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo esc_attr($tkt_row); ?>][TKT_is_default_selector]"
548 548
                                class="edit-ticket-TKT_is_default_selector"
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
 $ticket_archive_class .= WP_DEBUG ? ' ee-wp-debug' : '';
61 61
 ?>
62
-<tr class="ee-ticket-sortable ticket-row <?php echo sanitize_html_class($ticket_archive_class);?>"
62
+<tr class="ee-ticket-sortable ticket-row <?php echo sanitize_html_class($ticket_archive_class); ?>"
63 63
     id="display-ticketrow-<?php echo esc_attr($tkt_row); ?>">
64 64
     <!-- TKT_order -->
65 65
     <td class="ee-tkt-order-field">
@@ -344,23 +344,23 @@  discard block
 block discarded – undo
344 344
                                        name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo esc_attr($tkt_row); ?>][TKT_min]"
345 345
                                        value="<?php echo esc_attr($TKT_min); ?>"
346 346
                                 />
347
-                                <label class='screen-reader-text' for='disabled-ticket-TKT_min-<?php echo esc_attr($tkt_row);?>'>
347
+                                <label class='screen-reader-text' for='disabled-ticket-TKT_min-<?php echo esc_attr($tkt_row); ?>'>
348 348
                                     <?php
349 349
                                     esc_html_e('Minimum Quantity', 'event_espresso') ?>
350 350
                                 </label>
351 351
                                 <input type="text" disabled
352 352
                                        class="edit-ticket-TKT_min ee-small-text-inp ee-numeric"
353
-                                       id='disabled-ticket-TKT_min-<?php echo esc_attr($tkt_row);?>'
353
+                                       id='disabled-ticket-TKT_min-<?php echo esc_attr($tkt_row); ?>'
354 354
                                        name="archived_ticket[<?php echo esc_attr($tkt_row); ?>][TKT_min]"
355 355
                                        value="<?php echo esc_attr($TKT_min); ?>"
356 356
                                 />
357 357
                             <?php else : ?>
358
-                                <label class='screen-reader-text' for='edit-ticket-TKT_min-<?php echo esc_attr($tkt_row);?>'>
358
+                                <label class='screen-reader-text' for='edit-ticket-TKT_min-<?php echo esc_attr($tkt_row); ?>'>
359 359
                                     <?php esc_html_e('Minimum Quantity', 'event_espresso') ?>
360 360
                                 </label>
361 361
                                 <input type="text"
362 362
                                        class="edit-ticket-TKT_min ee-small-text-inp ee-numeric"
363
-                                       id='edit-ticket-TKT_min-<?php echo esc_attr($tkt_row);?>'
363
+                                       id='edit-ticket-TKT_min-<?php echo esc_attr($tkt_row); ?>'
364 364
                                        name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo esc_attr($tkt_row); ?>][TKT_min]"
365 365
                                        value="<?php echo esc_attr($TKT_min); ?>"
366 366
                                 />
@@ -372,22 +372,22 @@  discard block
 block discarded – undo
372 372
                                        name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo esc_attr($tkt_row); ?>][TKT_max]"
373 373
                                        value="<?php echo esc_attr($TKT_max); ?>"
374 374
                                 />
375
-                                <label class='screen-reader-text' for='disabled-ticket-TKT_max-<?php echo esc_attr($tkt_row);?>'>
375
+                                <label class='screen-reader-text' for='disabled-ticket-TKT_max-<?php echo esc_attr($tkt_row); ?>'>
376 376
                                     <?php esc_html_e('Maximum Quantity', 'event_espresso') ?>
377 377
                                 </label>
378 378
                                 <input type="text" disabled
379 379
                                        class="edit-ticket-TKT_max ee-small-text-inp ee-numeric"
380
-                                       id='disabled-ticket-TKT_max-<?php echo esc_attr($tkt_row);?>'
380
+                                       id='disabled-ticket-TKT_max-<?php echo esc_attr($tkt_row); ?>'
381 381
                                        name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo esc_attr($tkt_row); ?>][TKT_max]"
382 382
                                        value="<?php echo esc_attr($TKT_max); ?>"
383 383
                                 />
384 384
                             <?php else : ?>
385
-                                <label class='screen-reader-text' for='edit-ticket-TKT_max-<?php echo esc_attr($tkt_row);?>'>
385
+                                <label class='screen-reader-text' for='edit-ticket-TKT_max-<?php echo esc_attr($tkt_row); ?>'>
386 386
                                     <?php esc_html_e('Maximum Quantity', 'event_espresso') ?>
387 387
                                 </label>
388 388
                                 <input type="text"
389 389
                                        class="edit-ticket-TKT_max ee-small-text-inp ee-numeric"
390
-                                       id='edit-ticket-TKT_max-<?php echo esc_attr($tkt_row);?>'
390
+                                       id='edit-ticket-TKT_max-<?php echo esc_attr($tkt_row); ?>'
391 391
                                        name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo esc_attr($tkt_row); ?>][TKT_max]"
392 392
                                        value="<?php echo esc_attr($TKT_max); ?>"
393 393
                                 />
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
                     </label>
420 420
                 </div>
421 421
                 <div class="ticket-is-taxable-container">
422
-                    <?php if (! empty($tax_rows)) { ?>
422
+                    <?php if ( ! empty($tax_rows)) { ?>
423 423
                         <label for="edit-ticket-TKT_taxable-<?php echo esc_attr($tkt_row); ?>">
424 424
                         <?php if ($disabled) : ?>
425 425
                             <?php $tax_value = ! empty($TKT_taxable) ? 1 : 0; ?>
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/espresso_events_Pricing_Hooks.class.php 1 patch
Indentation   +2141 added lines, -2141 removed lines patch added patch discarded remove patch
@@ -15,2201 +15,2201 @@
 block discarded – undo
15 15
 class espresso_events_Pricing_Hooks extends EE_Admin_Hooks
16 16
 {
17 17
 
18
-    /**
19
-     * This property is just used to hold the status of whether an event is currently being
20
-     * created (true) or edited (false)
21
-     *
22
-     * @access protected
23
-     * @var bool
24
-     */
25
-    protected $_is_creating_event;
18
+	/**
19
+	 * This property is just used to hold the status of whether an event is currently being
20
+	 * created (true) or edited (false)
21
+	 *
22
+	 * @access protected
23
+	 * @var bool
24
+	 */
25
+	protected $_is_creating_event;
26 26
 
27
-    /**
28
-     * Used to contain the format strings for date and time that will be used for php date and
29
-     * time.
30
-     * Is set in the _set_hooks_properties() method.
31
-     *
32
-     * @var array
33
-     */
34
-    protected $_date_format_strings;
27
+	/**
28
+	 * Used to contain the format strings for date and time that will be used for php date and
29
+	 * time.
30
+	 * Is set in the _set_hooks_properties() method.
31
+	 *
32
+	 * @var array
33
+	 */
34
+	protected $_date_format_strings;
35 35
 
36
-    /**
37
-     * @var string $_date_time_format
38
-     */
39
-    protected $_date_time_format;
36
+	/**
37
+	 * @var string $_date_time_format
38
+	 */
39
+	protected $_date_time_format;
40 40
 
41 41
 
42
-    /**
43
-     * @throws InvalidArgumentException
44
-     * @throws InvalidInterfaceException
45
-     * @throws InvalidDataTypeException
46
-     */
47
-    protected function _set_hooks_properties()
48
-    {
49
-        $this->_name = 'pricing';
50
-        // capability check
51
-        if (
52
-            ! EE_Registry::instance()->CAP->current_user_can(
53
-                'ee_read_default_prices',
54
-                'advanced_ticket_datetime_metabox'
55
-            )
56
-        ) {
57
-            return;
58
-        }
59
-        $this->_setup_metaboxes();
60
-        $this->_set_date_time_formats();
61
-        $this->_validate_format_strings();
62
-        $this->_set_scripts_styles();
63
-        // commented out temporarily until logic is implemented in callback
64
-        // add_action(
65
-        //     'AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page',
66
-        //     array($this, 'autosave_handling')
67
-        // );
68
-        add_filter(
69
-            'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
70
-            array($this, 'caf_updates')
71
-        );
72
-    }
42
+	/**
43
+	 * @throws InvalidArgumentException
44
+	 * @throws InvalidInterfaceException
45
+	 * @throws InvalidDataTypeException
46
+	 */
47
+	protected function _set_hooks_properties()
48
+	{
49
+		$this->_name = 'pricing';
50
+		// capability check
51
+		if (
52
+			! EE_Registry::instance()->CAP->current_user_can(
53
+				'ee_read_default_prices',
54
+				'advanced_ticket_datetime_metabox'
55
+			)
56
+		) {
57
+			return;
58
+		}
59
+		$this->_setup_metaboxes();
60
+		$this->_set_date_time_formats();
61
+		$this->_validate_format_strings();
62
+		$this->_set_scripts_styles();
63
+		// commented out temporarily until logic is implemented in callback
64
+		// add_action(
65
+		//     'AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page',
66
+		//     array($this, 'autosave_handling')
67
+		// );
68
+		add_filter(
69
+			'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
70
+			array($this, 'caf_updates')
71
+		);
72
+	}
73 73
 
74 74
 
75
-    /**
76
-     * @return void
77
-     */
78
-    protected function _setup_metaboxes()
79
-    {
80
-        // if we were going to add our own metaboxes we'd use the below.
81
-        $this->_metaboxes = array(
82
-            0 => array(
83
-                'page_route' => array('edit', 'create_new'),
84
-                'func'       => 'pricing_metabox',
85
-                'label'      => esc_html__('Event Tickets & Datetimes', 'event_espresso'),
86
-                'priority'   => 'high',
87
-                'context'    => 'normal',
88
-            ),
89
-        );
90
-        $this->_remove_metaboxes = array(
91
-            0 => array(
92
-                'page_route' => array('edit', 'create_new'),
93
-                'id'         => 'espresso_event_editor_tickets',
94
-                'context'    => 'normal',
95
-            ),
96
-        );
97
-    }
75
+	/**
76
+	 * @return void
77
+	 */
78
+	protected function _setup_metaboxes()
79
+	{
80
+		// if we were going to add our own metaboxes we'd use the below.
81
+		$this->_metaboxes = array(
82
+			0 => array(
83
+				'page_route' => array('edit', 'create_new'),
84
+				'func'       => 'pricing_metabox',
85
+				'label'      => esc_html__('Event Tickets & Datetimes', 'event_espresso'),
86
+				'priority'   => 'high',
87
+				'context'    => 'normal',
88
+			),
89
+		);
90
+		$this->_remove_metaboxes = array(
91
+			0 => array(
92
+				'page_route' => array('edit', 'create_new'),
93
+				'id'         => 'espresso_event_editor_tickets',
94
+				'context'    => 'normal',
95
+			),
96
+		);
97
+	}
98 98
 
99 99
 
100
-    /**
101
-     * @return void
102
-     */
103
-    protected function _set_date_time_formats()
104
-    {
105
-        /**
106
-         * Format strings for date and time.  Defaults are existing behaviour from 4.1.
107
-         * Note, that if you return null as the value for 'date', and 'time' in the array, then
108
-         * EE will automatically use the set wp_options, 'date_format', and 'time_format'.
109
-         *
110
-         * @since 4.6.7
111
-         * @var array  Expected an array returned with 'date' and 'time' keys.
112
-         */
113
-        $this->_date_format_strings = apply_filters(
114
-            'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings',
115
-            array(
116
-                'date' => 'Y-m-d',
117
-                'time' => 'h:i a',
118
-            )
119
-        );
120
-        // validate
121
-        $this->_date_format_strings['date'] = isset($this->_date_format_strings['date'])
122
-            ? $this->_date_format_strings['date']
123
-            : null;
124
-        $this->_date_format_strings['time'] = isset($this->_date_format_strings['time'])
125
-            ? $this->_date_format_strings['time']
126
-            : null;
127
-        $this->_date_time_format = $this->_date_format_strings['date']
128
-                                   . ' '
129
-                                   . $this->_date_format_strings['time'];
130
-    }
100
+	/**
101
+	 * @return void
102
+	 */
103
+	protected function _set_date_time_formats()
104
+	{
105
+		/**
106
+		 * Format strings for date and time.  Defaults are existing behaviour from 4.1.
107
+		 * Note, that if you return null as the value for 'date', and 'time' in the array, then
108
+		 * EE will automatically use the set wp_options, 'date_format', and 'time_format'.
109
+		 *
110
+		 * @since 4.6.7
111
+		 * @var array  Expected an array returned with 'date' and 'time' keys.
112
+		 */
113
+		$this->_date_format_strings = apply_filters(
114
+			'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings',
115
+			array(
116
+				'date' => 'Y-m-d',
117
+				'time' => 'h:i a',
118
+			)
119
+		);
120
+		// validate
121
+		$this->_date_format_strings['date'] = isset($this->_date_format_strings['date'])
122
+			? $this->_date_format_strings['date']
123
+			: null;
124
+		$this->_date_format_strings['time'] = isset($this->_date_format_strings['time'])
125
+			? $this->_date_format_strings['time']
126
+			: null;
127
+		$this->_date_time_format = $this->_date_format_strings['date']
128
+								   . ' '
129
+								   . $this->_date_format_strings['time'];
130
+	}
131 131
 
132 132
 
133
-    /**
134
-     * @return void
135
-     */
136
-    protected function _validate_format_strings()
137
-    {
138
-        // validate format strings
139
-        $format_validation = EEH_DTT_Helper::validate_format_string(
140
-            $this->_date_time_format
141
-        );
142
-        if (is_array($format_validation)) {
143
-            $msg = '<p>';
144
-            $msg .= sprintf(
145
-                esc_html__(
146
-                    'The format "%s" was likely added via a filter and is invalid for the following reasons:',
147
-                    'event_espresso'
148
-                ),
149
-                $this->_date_time_format
150
-            );
151
-            $msg .= '</p><ul>';
152
-            foreach ($format_validation as $error) {
153
-                $msg .= '<li>' . $error . '</li>';
154
-            }
155
-            $msg .= '</ul><p>';
156
-            $msg .= sprintf(
157
-                esc_html__(
158
-                    '%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s',
159
-                    'event_espresso'
160
-                ),
161
-                '<span style="color:#D54E21;">',
162
-                '</span>'
163
-            );
164
-            $msg .= '</p>';
165
-            EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
166
-            $this->_date_format_strings = array(
167
-                'date' => 'Y-m-d',
168
-                'time' => 'h:i a',
169
-            );
170
-        }
171
-    }
133
+	/**
134
+	 * @return void
135
+	 */
136
+	protected function _validate_format_strings()
137
+	{
138
+		// validate format strings
139
+		$format_validation = EEH_DTT_Helper::validate_format_string(
140
+			$this->_date_time_format
141
+		);
142
+		if (is_array($format_validation)) {
143
+			$msg = '<p>';
144
+			$msg .= sprintf(
145
+				esc_html__(
146
+					'The format "%s" was likely added via a filter and is invalid for the following reasons:',
147
+					'event_espresso'
148
+				),
149
+				$this->_date_time_format
150
+			);
151
+			$msg .= '</p><ul>';
152
+			foreach ($format_validation as $error) {
153
+				$msg .= '<li>' . $error . '</li>';
154
+			}
155
+			$msg .= '</ul><p>';
156
+			$msg .= sprintf(
157
+				esc_html__(
158
+					'%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s',
159
+					'event_espresso'
160
+				),
161
+				'<span style="color:#D54E21;">',
162
+				'</span>'
163
+			);
164
+			$msg .= '</p>';
165
+			EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
166
+			$this->_date_format_strings = array(
167
+				'date' => 'Y-m-d',
168
+				'time' => 'h:i a',
169
+			);
170
+		}
171
+	}
172 172
 
173 173
 
174
-    /**
175
-     * @return void
176
-     */
177
-    protected function _set_scripts_styles()
178
-    {
179
-        $this->_scripts_styles = array(
180
-            'registers'   => array(
181
-                'ee-tickets-datetimes-css' => array(
182
-                    'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
183
-                    'type' => 'css',
184
-                ),
185
-                'ee-dtt-ticket-metabox'    => array(
186
-                    'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
187
-                    'depends' => array('ee-datepicker', 'ee-dialog', 'underscore'),
188
-                ),
189
-            ),
190
-            'deregisters' => array(
191
-                'event-editor-css'       => array('type' => 'css'),
192
-                'event-datetime-metabox' => array('type' => 'js'),
193
-            ),
194
-            'enqueues'    => array(
195
-                'ee-tickets-datetimes-css' => array('edit', 'create_new'),
196
-                'ee-dtt-ticket-metabox'    => array('edit', 'create_new'),
197
-            ),
198
-            'localize'    => array(
199
-                'ee-dtt-ticket-metabox' => array(
200
-                    'DTT_TRASH_BLOCK'       => array(
201
-                        'main_warning'            => esc_html__(
202
-                            'The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):',
203
-                            'event_espresso'
204
-                        ),
205
-                        'after_warning'           => esc_html__(
206
-                            'In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.',
207
-                            'event_espresso'
208
-                        ),
209
-                        'cancel_button'           => '<button class="button-secondary ee-modal-cancel">'
210
-                                                     . esc_html__('Cancel', 'event_espresso') . '</button>',
211
-                        'close_button'            => '<button class="button-secondary ee-modal-cancel">'
212
-                                                     . esc_html__('Close', 'event_espresso') . '</button>',
213
-                        'single_warning_from_tkt' => esc_html__(
214
-                            'The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.',
215
-                            'event_espresso'
216
-                        ),
217
-                        'single_warning_from_dtt' => esc_html__(
218
-                            'The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket.  Tickets must always have at least one datetime assigned to them.',
219
-                            'event_espresso'
220
-                        ),
221
-                        'dismiss_button'          => '<button class="button-secondary ee-modal-cancel">'
222
-                                                     . esc_html__('Dismiss', 'event_espresso') . '</button>',
223
-                    ),
224
-                    'DTT_ERROR_MSG'         => array(
225
-                        'no_ticket_name' => esc_html__('General Admission', 'event_espresso'),
226
-                        'dismiss_button' => '<div class="save-cancel-button-container">'
227
-                                            . '<button class="button-secondary ee-modal-cancel">'
228
-                                            . esc_html__('Dismiss', 'event_espresso')
229
-                                            . '</button></div>',
230
-                    ),
231
-                    'DTT_OVERSELL_WARNING'  => array(
232
-                        'datetime_ticket' => esc_html__(
233
-                            'You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.',
234
-                            'event_espresso'
235
-                        ),
236
-                        'ticket_datetime' => esc_html__(
237
-                            'You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.',
238
-                            'event_espresso'
239
-                        ),
240
-                    ),
241
-                    'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats(
242
-                        $this->_date_format_strings['date'],
243
-                        $this->_date_format_strings['time']
244
-                    ),
245
-                    'DTT_START_OF_WEEK'     => array('dayValue' => (int) get_option('start_of_week')),
246
-                ),
247
-            ),
248
-        );
249
-    }
174
+	/**
175
+	 * @return void
176
+	 */
177
+	protected function _set_scripts_styles()
178
+	{
179
+		$this->_scripts_styles = array(
180
+			'registers'   => array(
181
+				'ee-tickets-datetimes-css' => array(
182
+					'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
183
+					'type' => 'css',
184
+				),
185
+				'ee-dtt-ticket-metabox'    => array(
186
+					'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
187
+					'depends' => array('ee-datepicker', 'ee-dialog', 'underscore'),
188
+				),
189
+			),
190
+			'deregisters' => array(
191
+				'event-editor-css'       => array('type' => 'css'),
192
+				'event-datetime-metabox' => array('type' => 'js'),
193
+			),
194
+			'enqueues'    => array(
195
+				'ee-tickets-datetimes-css' => array('edit', 'create_new'),
196
+				'ee-dtt-ticket-metabox'    => array('edit', 'create_new'),
197
+			),
198
+			'localize'    => array(
199
+				'ee-dtt-ticket-metabox' => array(
200
+					'DTT_TRASH_BLOCK'       => array(
201
+						'main_warning'            => esc_html__(
202
+							'The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):',
203
+							'event_espresso'
204
+						),
205
+						'after_warning'           => esc_html__(
206
+							'In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.',
207
+							'event_espresso'
208
+						),
209
+						'cancel_button'           => '<button class="button-secondary ee-modal-cancel">'
210
+													 . esc_html__('Cancel', 'event_espresso') . '</button>',
211
+						'close_button'            => '<button class="button-secondary ee-modal-cancel">'
212
+													 . esc_html__('Close', 'event_espresso') . '</button>',
213
+						'single_warning_from_tkt' => esc_html__(
214
+							'The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.',
215
+							'event_espresso'
216
+						),
217
+						'single_warning_from_dtt' => esc_html__(
218
+							'The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket.  Tickets must always have at least one datetime assigned to them.',
219
+							'event_espresso'
220
+						),
221
+						'dismiss_button'          => '<button class="button-secondary ee-modal-cancel">'
222
+													 . esc_html__('Dismiss', 'event_espresso') . '</button>',
223
+					),
224
+					'DTT_ERROR_MSG'         => array(
225
+						'no_ticket_name' => esc_html__('General Admission', 'event_espresso'),
226
+						'dismiss_button' => '<div class="save-cancel-button-container">'
227
+											. '<button class="button-secondary ee-modal-cancel">'
228
+											. esc_html__('Dismiss', 'event_espresso')
229
+											. '</button></div>',
230
+					),
231
+					'DTT_OVERSELL_WARNING'  => array(
232
+						'datetime_ticket' => esc_html__(
233
+							'You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.',
234
+							'event_espresso'
235
+						),
236
+						'ticket_datetime' => esc_html__(
237
+							'You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.',
238
+							'event_espresso'
239
+						),
240
+					),
241
+					'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats(
242
+						$this->_date_format_strings['date'],
243
+						$this->_date_format_strings['time']
244
+					),
245
+					'DTT_START_OF_WEEK'     => array('dayValue' => (int) get_option('start_of_week')),
246
+				),
247
+			),
248
+		);
249
+	}
250 250
 
251 251
 
252
-    /**
253
-     * @param array $update_callbacks
254
-     * @return array
255
-     */
256
-    public function caf_updates(array $update_callbacks)
257
-    {
258
-        foreach ($update_callbacks as $key => $callback) {
259
-            if ($callback[1] === '_default_tickets_update') {
260
-                unset($update_callbacks[ $key ]);
261
-            }
262
-        }
263
-        $update_callbacks[] = array($this, 'datetime_and_tickets_caf_update');
264
-        return $update_callbacks;
265
-    }
252
+	/**
253
+	 * @param array $update_callbacks
254
+	 * @return array
255
+	 */
256
+	public function caf_updates(array $update_callbacks)
257
+	{
258
+		foreach ($update_callbacks as $key => $callback) {
259
+			if ($callback[1] === '_default_tickets_update') {
260
+				unset($update_callbacks[ $key ]);
261
+			}
262
+		}
263
+		$update_callbacks[] = array($this, 'datetime_and_tickets_caf_update');
264
+		return $update_callbacks;
265
+	}
266 266
 
267 267
 
268
-    /**
269
-     * Handles saving everything related to Tickets (datetimes, tickets, prices)
270
-     *
271
-     * @param  EE_Event $event The Event object we're attaching data to
272
-     * @param  array    $data  The request data from the form
273
-     * @throws ReflectionException
274
-     * @throws Exception
275
-     * @throws InvalidInterfaceException
276
-     * @throws InvalidDataTypeException
277
-     * @throws EE_Error
278
-     * @throws InvalidArgumentException
279
-     */
280
-    public function datetime_and_tickets_caf_update($event, $data)
281
-    {
282
-        // first we need to start with datetimes cause they are the "root" items attached to events.
283
-        $saved_datetimes = $this->_update_datetimes($event, $data);
284
-        // next tackle the tickets (and prices?)
285
-        $this->_update_tickets($event, $saved_datetimes, $data);
286
-    }
268
+	/**
269
+	 * Handles saving everything related to Tickets (datetimes, tickets, prices)
270
+	 *
271
+	 * @param  EE_Event $event The Event object we're attaching data to
272
+	 * @param  array    $data  The request data from the form
273
+	 * @throws ReflectionException
274
+	 * @throws Exception
275
+	 * @throws InvalidInterfaceException
276
+	 * @throws InvalidDataTypeException
277
+	 * @throws EE_Error
278
+	 * @throws InvalidArgumentException
279
+	 */
280
+	public function datetime_and_tickets_caf_update($event, $data)
281
+	{
282
+		// first we need to start with datetimes cause they are the "root" items attached to events.
283
+		$saved_datetimes = $this->_update_datetimes($event, $data);
284
+		// next tackle the tickets (and prices?)
285
+		$this->_update_tickets($event, $saved_datetimes, $data);
286
+	}
287 287
 
288 288
 
289
-    /**
290
-     * update event_datetimes
291
-     *
292
-     * @param  EE_Event $event Event being updated
293
-     * @param  array    $data  the request data from the form
294
-     * @return EE_Datetime[]
295
-     * @throws Exception
296
-     * @throws ReflectionException
297
-     * @throws InvalidInterfaceException
298
-     * @throws InvalidDataTypeException
299
-     * @throws InvalidArgumentException
300
-     * @throws EE_Error
301
-     */
302
-    protected function _update_datetimes($event, $data)
303
-    {
304
-        $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : null;
305
-        $saved_dtt_ids = array();
306
-        $saved_dtt_objs = array();
307
-        if (empty($data['edit_event_datetimes']) || ! is_array($data['edit_event_datetimes'])) {
308
-            throw new InvalidArgumentException(
309
-                esc_html__(
310
-                    'The "edit_event_datetimes" array is invalid therefore the event can not be updated.',
311
-                    'event_espresso'
312
-                )
313
-            );
314
-        }
315
-        foreach ($data['edit_event_datetimes'] as $row => $datetime_data) {
316
-            // trim all values to ensure any excess whitespace is removed.
317
-            $datetime_data = array_map(
318
-                function ($datetime_data) {
319
-                    return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
320
-                },
321
-                $datetime_data
322
-            );
323
-            $datetime_data['DTT_EVT_end'] = isset($datetime_data['DTT_EVT_end'])
324
-                                            && ! empty($datetime_data['DTT_EVT_end'])
325
-                ? $datetime_data['DTT_EVT_end']
326
-                : $datetime_data['DTT_EVT_start'];
327
-            $datetime_values = array(
328
-                'DTT_ID'          => ! empty($datetime_data['DTT_ID'])
329
-                    ? $datetime_data['DTT_ID']
330
-                    : null,
331
-                'DTT_name'        => ! empty($datetime_data['DTT_name'])
332
-                    ? $datetime_data['DTT_name']
333
-                    : '',
334
-                'DTT_description' => ! empty($datetime_data['DTT_description'])
335
-                    ? $datetime_data['DTT_description']
336
-                    : '',
337
-                'DTT_EVT_start'   => $datetime_data['DTT_EVT_start'],
338
-                'DTT_EVT_end'     => $datetime_data['DTT_EVT_end'],
339
-                'DTT_reg_limit'   => empty($datetime_data['DTT_reg_limit'])
340
-                    ? EE_INF
341
-                    : $datetime_data['DTT_reg_limit'],
342
-                'DTT_order'       => ! isset($datetime_data['DTT_order'])
343
-                    ? $row
344
-                    : $datetime_data['DTT_order'],
345
-            );
346
-            // if we have an id then let's get existing object first and then set the new values.
347
-            // Otherwise we instantiate a new object for save.
348
-            if (! empty($datetime_data['DTT_ID'])) {
349
-                $datetime = EE_Registry::instance()
350
-                                       ->load_model('Datetime', array($timezone))
351
-                                       ->get_one_by_ID($datetime_data['DTT_ID']);
352
-                // set date and time format according to what is set in this class.
353
-                $datetime->set_date_format($this->_date_format_strings['date']);
354
-                $datetime->set_time_format($this->_date_format_strings['time']);
355
-                foreach ($datetime_values as $field => $value) {
356
-                    $datetime->set($field, $value);
357
-                }
358
-                // make sure the $dtt_id here is saved just in case
359
-                // after the add_relation_to() the autosave replaces it.
360
-                // We need to do this so we dont' TRASH the parent DTT.
361
-                // (save the ID for both key and value to avoid duplications)
362
-                $saved_dtt_ids[ $datetime->ID() ] = $datetime->ID();
363
-            } else {
364
-                $datetime = EE_Registry::instance()->load_class(
365
-                    'Datetime',
366
-                    array(
367
-                        $datetime_values,
368
-                        $timezone,
369
-                        array($this->_date_format_strings['date'], $this->_date_format_strings['time']),
370
-                    ),
371
-                    false,
372
-                    false
373
-                );
374
-                foreach ($datetime_values as $field => $value) {
375
-                    $datetime->set($field, $value);
376
-                }
377
-            }
378
-            $datetime->save();
379
-            do_action(
380
-                'AHEE__espresso_events_Pricing_Hooks___update_datetimes_after_save',
381
-                $datetime,
382
-                $row,
383
-                $datetime_data,
384
-                $data
385
-            );
386
-            $datetime = $event->_add_relation_to($datetime, 'Datetime');
387
-            // before going any further make sure our dates are setup correctly
388
-            // so that the end date is always equal or greater than the start date.
389
-            if ($datetime->get_raw('DTT_EVT_start') > $datetime->get_raw('DTT_EVT_end')) {
390
-                $datetime->set('DTT_EVT_end', $datetime->get('DTT_EVT_start'));
391
-                $datetime = EEH_DTT_Helper::date_time_add($datetime, 'DTT_EVT_end', 'days');
392
-                $datetime->save();
393
-            }
394
-            // now we have to make sure we add the new DTT_ID to the $saved_dtt_ids array
395
-            // because it is possible there was a new one created for the autosave.
396
-            // (save the ID for both key and value to avoid duplications)
397
-            $DTT_ID = $datetime->ID();
398
-            $saved_dtt_ids[ $DTT_ID ] = $DTT_ID;
399
-            $saved_dtt_objs[ $row ] = $datetime;
400
-            // @todo if ANY of these updates fail then we want the appropriate global error message.
401
-        }
402
-        $event->save();
403
-        // now we need to REMOVE any datetimes that got deleted.
404
-        // Keep in mind that this process will only kick in for datetimes that don't have any DTT_sold on them.
405
-        // So its safe to permanently delete at this point.
406
-        $old_datetimes = explode(',', $data['datetime_IDs']);
407
-        $old_datetimes = $old_datetimes[0] === '' ? array() : $old_datetimes;
408
-        if (is_array($old_datetimes)) {
409
-            $datetimes_to_delete = array_diff($old_datetimes, $saved_dtt_ids);
410
-            foreach ($datetimes_to_delete as $id) {
411
-                $id = absint($id);
412
-                if (empty($id)) {
413
-                    continue;
414
-                }
415
-                $dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id);
416
-                // remove tkt relationships.
417
-                $related_tickets = $dtt_to_remove->get_many_related('Ticket');
418
-                foreach ($related_tickets as $tkt) {
419
-                    $dtt_to_remove->_remove_relation_to($tkt, 'Ticket');
420
-                }
421
-                $event->_remove_relation_to($id, 'Datetime');
422
-                $dtt_to_remove->refresh_cache_of_related_objects();
423
-            }
424
-        }
425
-        return $saved_dtt_objs;
426
-    }
289
+	/**
290
+	 * update event_datetimes
291
+	 *
292
+	 * @param  EE_Event $event Event being updated
293
+	 * @param  array    $data  the request data from the form
294
+	 * @return EE_Datetime[]
295
+	 * @throws Exception
296
+	 * @throws ReflectionException
297
+	 * @throws InvalidInterfaceException
298
+	 * @throws InvalidDataTypeException
299
+	 * @throws InvalidArgumentException
300
+	 * @throws EE_Error
301
+	 */
302
+	protected function _update_datetimes($event, $data)
303
+	{
304
+		$timezone = isset($data['timezone_string']) ? $data['timezone_string'] : null;
305
+		$saved_dtt_ids = array();
306
+		$saved_dtt_objs = array();
307
+		if (empty($data['edit_event_datetimes']) || ! is_array($data['edit_event_datetimes'])) {
308
+			throw new InvalidArgumentException(
309
+				esc_html__(
310
+					'The "edit_event_datetimes" array is invalid therefore the event can not be updated.',
311
+					'event_espresso'
312
+				)
313
+			);
314
+		}
315
+		foreach ($data['edit_event_datetimes'] as $row => $datetime_data) {
316
+			// trim all values to ensure any excess whitespace is removed.
317
+			$datetime_data = array_map(
318
+				function ($datetime_data) {
319
+					return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
320
+				},
321
+				$datetime_data
322
+			);
323
+			$datetime_data['DTT_EVT_end'] = isset($datetime_data['DTT_EVT_end'])
324
+											&& ! empty($datetime_data['DTT_EVT_end'])
325
+				? $datetime_data['DTT_EVT_end']
326
+				: $datetime_data['DTT_EVT_start'];
327
+			$datetime_values = array(
328
+				'DTT_ID'          => ! empty($datetime_data['DTT_ID'])
329
+					? $datetime_data['DTT_ID']
330
+					: null,
331
+				'DTT_name'        => ! empty($datetime_data['DTT_name'])
332
+					? $datetime_data['DTT_name']
333
+					: '',
334
+				'DTT_description' => ! empty($datetime_data['DTT_description'])
335
+					? $datetime_data['DTT_description']
336
+					: '',
337
+				'DTT_EVT_start'   => $datetime_data['DTT_EVT_start'],
338
+				'DTT_EVT_end'     => $datetime_data['DTT_EVT_end'],
339
+				'DTT_reg_limit'   => empty($datetime_data['DTT_reg_limit'])
340
+					? EE_INF
341
+					: $datetime_data['DTT_reg_limit'],
342
+				'DTT_order'       => ! isset($datetime_data['DTT_order'])
343
+					? $row
344
+					: $datetime_data['DTT_order'],
345
+			);
346
+			// if we have an id then let's get existing object first and then set the new values.
347
+			// Otherwise we instantiate a new object for save.
348
+			if (! empty($datetime_data['DTT_ID'])) {
349
+				$datetime = EE_Registry::instance()
350
+									   ->load_model('Datetime', array($timezone))
351
+									   ->get_one_by_ID($datetime_data['DTT_ID']);
352
+				// set date and time format according to what is set in this class.
353
+				$datetime->set_date_format($this->_date_format_strings['date']);
354
+				$datetime->set_time_format($this->_date_format_strings['time']);
355
+				foreach ($datetime_values as $field => $value) {
356
+					$datetime->set($field, $value);
357
+				}
358
+				// make sure the $dtt_id here is saved just in case
359
+				// after the add_relation_to() the autosave replaces it.
360
+				// We need to do this so we dont' TRASH the parent DTT.
361
+				// (save the ID for both key and value to avoid duplications)
362
+				$saved_dtt_ids[ $datetime->ID() ] = $datetime->ID();
363
+			} else {
364
+				$datetime = EE_Registry::instance()->load_class(
365
+					'Datetime',
366
+					array(
367
+						$datetime_values,
368
+						$timezone,
369
+						array($this->_date_format_strings['date'], $this->_date_format_strings['time']),
370
+					),
371
+					false,
372
+					false
373
+				);
374
+				foreach ($datetime_values as $field => $value) {
375
+					$datetime->set($field, $value);
376
+				}
377
+			}
378
+			$datetime->save();
379
+			do_action(
380
+				'AHEE__espresso_events_Pricing_Hooks___update_datetimes_after_save',
381
+				$datetime,
382
+				$row,
383
+				$datetime_data,
384
+				$data
385
+			);
386
+			$datetime = $event->_add_relation_to($datetime, 'Datetime');
387
+			// before going any further make sure our dates are setup correctly
388
+			// so that the end date is always equal or greater than the start date.
389
+			if ($datetime->get_raw('DTT_EVT_start') > $datetime->get_raw('DTT_EVT_end')) {
390
+				$datetime->set('DTT_EVT_end', $datetime->get('DTT_EVT_start'));
391
+				$datetime = EEH_DTT_Helper::date_time_add($datetime, 'DTT_EVT_end', 'days');
392
+				$datetime->save();
393
+			}
394
+			// now we have to make sure we add the new DTT_ID to the $saved_dtt_ids array
395
+			// because it is possible there was a new one created for the autosave.
396
+			// (save the ID for both key and value to avoid duplications)
397
+			$DTT_ID = $datetime->ID();
398
+			$saved_dtt_ids[ $DTT_ID ] = $DTT_ID;
399
+			$saved_dtt_objs[ $row ] = $datetime;
400
+			// @todo if ANY of these updates fail then we want the appropriate global error message.
401
+		}
402
+		$event->save();
403
+		// now we need to REMOVE any datetimes that got deleted.
404
+		// Keep in mind that this process will only kick in for datetimes that don't have any DTT_sold on them.
405
+		// So its safe to permanently delete at this point.
406
+		$old_datetimes = explode(',', $data['datetime_IDs']);
407
+		$old_datetimes = $old_datetimes[0] === '' ? array() : $old_datetimes;
408
+		if (is_array($old_datetimes)) {
409
+			$datetimes_to_delete = array_diff($old_datetimes, $saved_dtt_ids);
410
+			foreach ($datetimes_to_delete as $id) {
411
+				$id = absint($id);
412
+				if (empty($id)) {
413
+					continue;
414
+				}
415
+				$dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id);
416
+				// remove tkt relationships.
417
+				$related_tickets = $dtt_to_remove->get_many_related('Ticket');
418
+				foreach ($related_tickets as $tkt) {
419
+					$dtt_to_remove->_remove_relation_to($tkt, 'Ticket');
420
+				}
421
+				$event->_remove_relation_to($id, 'Datetime');
422
+				$dtt_to_remove->refresh_cache_of_related_objects();
423
+			}
424
+		}
425
+		return $saved_dtt_objs;
426
+	}
427 427
 
428 428
 
429
-    /**
430
-     * update tickets
431
-     *
432
-     * @param  EE_Event      $event           Event object being updated
433
-     * @param  EE_Datetime[] $saved_datetimes an array of datetime ids being updated
434
-     * @param  array         $data            incoming request data
435
-     * @return EE_Ticket[]
436
-     * @throws Exception
437
-     * @throws ReflectionException
438
-     * @throws InvalidInterfaceException
439
-     * @throws InvalidDataTypeException
440
-     * @throws InvalidArgumentException
441
-     * @throws EE_Error
442
-     */
443
-    protected function _update_tickets($event, $saved_datetimes, $data)
444
-    {
445
-        $new_tkt = null;
446
-        // stripslashes because WP filtered the $_POST ($data) array to add slashes
447
-        $data = stripslashes_deep($data);
448
-        $timezone = $data['timezone_string'] ?? null;
449
-        $saved_tickets = array();
450
-        $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
451
-        if (empty($data['edit_tickets']) || ! is_array($data['edit_tickets'])) {
452
-            throw new InvalidArgumentException(
453
-                esc_html__(
454
-                    'The "edit_tickets" array is invalid therefore the event can not be updated.',
455
-                    'event_espresso'
456
-                )
457
-            );
458
-        }
459
-        foreach ($data['edit_tickets'] as $row => $tkt) {
460
-            $update_prices = $create_new_TKT = false;
461
-            // figure out what datetimes were added to the ticket
462
-            // and what datetimes were removed from the ticket in the session.
463
-            $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][ $row ]);
464
-            $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][ $row ]);
465
-            $datetimes_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
466
-            $datetimes_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
467
-            // trim inputs to ensure any excess whitespace is removed.
468
-            $tkt = array_map(
469
-                function ($ticket_data) {
470
-                    return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
471
-                },
472
-                $tkt
473
-            );
474
-            // note we are doing conversions to floats here instead of allowing EE_Money_Field to handle
475
-            // because we're doing calculations prior to using the models.
476
-            // note incoming ['TKT_price'] value is already in standard notation (via js).
477
-            $ticket_price = isset($tkt['TKT_price'])
478
-                ? round((float) $tkt['TKT_price'], 3)
479
-                : 0;
480
-            // note incoming base price needs converted from localized value.
481
-            $base_price = isset($tkt['TKT_base_price'])
482
-                ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price'])
483
-                : 0;
484
-            // if ticket price == 0 and $base_price != 0 then ticket price == base_price
485
-            $ticket_price = $ticket_price === 0 && $base_price !== 0
486
-                ? $base_price
487
-                : $ticket_price;
488
-            $base_price_id = $tkt['TKT_base_price_ID'] ?? 0;
489
-            $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][ $row ])
490
-                ? $data['edit_prices'][ $row ]
491
-                : array();
492
-            $now = null;
493
-            if (empty($tkt['TKT_start_date'])) {
494
-                // lets' use now in the set timezone.
495
-                $now = new DateTime('now', new DateTimeZone($event->get_timezone()));
496
-                $tkt['TKT_start_date'] = $now->format($this->_date_time_format);
497
-            }
498
-            if (empty($tkt['TKT_end_date'])) {
499
-                /**
500
-                 * set the TKT_end_date to the first datetime attached to the ticket.
501
-                 */
502
-                $first_dtt = $saved_datetimes[ reset($tkt_dtt_rows) ];
503
-                $tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_time_format);
504
-            }
505
-            $TKT_values = array(
506
-                'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
507
-                'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
508
-                'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
509
-                'TKT_description' => ! empty($tkt['TKT_description'])
510
-                                     && $tkt['TKT_description'] !== esc_html__(
511
-                                         'You can modify this description',
512
-                                         'event_espresso'
513
-                                     )
514
-                    ? $tkt['TKT_description']
515
-                    : '',
516
-                'TKT_start_date'  => $tkt['TKT_start_date'],
517
-                'TKT_end_date'    => $tkt['TKT_end_date'],
518
-                'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === ''
519
-                    ? EE_INF
520
-                    : $tkt['TKT_qty'],
521
-                'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === ''
522
-                    ? EE_INF
523
-                    : $tkt['TKT_uses'],
524
-                'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
525
-                'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
526
-                'TKT_row'         => $row,
527
-                'TKT_order'       => $tkt['TKT_order'] ?? 0,
528
-                'TKT_taxable'     => ! empty($tkt['TKT_taxable']) ? 1 : 0,
529
-                'TKT_required'    => ! empty($tkt['TKT_required']) ? 1 : 0,
530
-                'TKT_price'       => $ticket_price,
531
-            );
532
-            // if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly,
533
-            // which means in turn that the prices will become new prices as well.
534
-            if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
535
-                $TKT_values['TKT_ID'] = 0;
536
-                $TKT_values['TKT_is_default'] = 0;
537
-                $update_prices = true;
538
-            }
539
-            // if we have a TKT_ID then we need to get that existing TKT_obj and update it
540
-            // we actually do our saves ahead of doing any add_relations to
541
-            // because its entirely possible that this ticket wasn't removed or added to any datetime in the session
542
-            // but DID have it's items modified.
543
-            // keep in mind that if the TKT has been sold (and we have changed pricing information),
544
-            // then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
545
-            if (absint($TKT_values['TKT_ID'])) {
546
-                $ticket = EE_Registry::instance()
547
-                                     ->load_model('Ticket', array($timezone))
548
-                                     ->get_one_by_ID($tkt['TKT_ID']);
549
-                if ($ticket instanceof EE_Ticket) {
550
-                    $ticket = $this->_update_ticket_datetimes(
551
-                        $ticket,
552
-                        $saved_datetimes,
553
-                        $datetimes_added,
554
-                        $datetimes_removed
555
-                    );
556
-                    // are there any registrations using this ticket ?
557
-                    $tickets_sold = $ticket->count_related(
558
-                        'Registration',
559
-                        array(
560
-                            array(
561
-                                'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete)),
562
-                            ),
563
-                        )
564
-                    );
565
-                    // set ticket formats
566
-                    $ticket->set_date_format($this->_date_format_strings['date']);
567
-                    $ticket->set_time_format($this->_date_format_strings['time']);
568
-                    // let's just check the total price for the existing ticket
569
-                    // and determine if it matches the new total price.
570
-                    // if they are different then we create a new ticket (if tickets sold)
571
-                    // if they aren't different then we go ahead and modify existing ticket.
572
-                    $create_new_TKT = $tickets_sold > 0 && $ticket_price !== $ticket->price() && ! $ticket->deleted();
573
-                    // set new values
574
-                    foreach ($TKT_values as $field => $value) {
575
-                        if ($field === 'TKT_qty') {
576
-                            $ticket->set_qty($value);
577
-                        } else {
578
-                            $ticket->set($field, $value);
579
-                        }
580
-                    }
581
-                    // if $create_new_TKT is false then we can safely update the existing ticket.
582
-                    // Otherwise we have to create a new ticket.
583
-                    if ($create_new_TKT) {
584
-                        $new_tkt = $this->_duplicate_ticket(
585
-                            $ticket,
586
-                            $price_rows,
587
-                            $ticket_price,
588
-                            $base_price,
589
-                            $base_price_id
590
-                        );
591
-                    }
592
-                }
593
-            } else {
594
-                // no TKT_id so a new TKT
595
-                $ticket = EE_Ticket::new_instance(
596
-                    $TKT_values,
597
-                    $timezone,
598
-                    array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
599
-                );
600
-                if ($ticket instanceof EE_Ticket) {
601
-                    // make sure ticket has an ID of setting relations won't work
602
-                    $ticket->save();
603
-                    $ticket = $this->_update_ticket_datetimes(
604
-                        $ticket,
605
-                        $saved_datetimes,
606
-                        $datetimes_added,
607
-                        $datetimes_removed
608
-                    );
609
-                    $update_prices = true;
610
-                }
611
-            }
612
-            // make sure any current values have been saved.
613
-            // $ticket->save();
614
-            // before going any further make sure our dates are setup correctly
615
-            // so that the end date is always equal or greater than the start date.
616
-            if ($ticket->get_raw('TKT_start_date') > $ticket->get_raw('TKT_end_date')) {
617
-                $ticket->set('TKT_end_date', $ticket->get('TKT_start_date'));
618
-                $ticket = EEH_DTT_Helper::date_time_add($ticket, 'TKT_end_date', 'days');
619
-            }
620
-            // let's make sure the base price is handled
621
-            $ticket = ! $create_new_TKT
622
-                ? $this->_add_prices_to_ticket(
623
-                    array(),
624
-                    $ticket,
625
-                    $update_prices,
626
-                    $base_price,
627
-                    $base_price_id
628
-                )
629
-                : $ticket;
630
-            // add/update price_modifiers
631
-            $ticket = ! $create_new_TKT
632
-                ? $this->_add_prices_to_ticket($price_rows, $ticket, $update_prices)
633
-                : $ticket;
634
-            // need to make sue that the TKT_price is accurate after saving the prices.
635
-            $ticket->ensure_TKT_Price_correct();
636
-            // handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
637
-            if (! defined('DOING_AUTOSAVE') && ! empty($tkt['TKT_is_default_selector'])) {
638
-                $update_prices = true;
639
-                $new_default = clone $ticket;
640
-                $new_default->set('TKT_ID', 0);
641
-                $new_default->set('TKT_is_default', 1);
642
-                $new_default->set('TKT_row', 1);
643
-                $new_default->set('TKT_price', $ticket_price);
644
-                // remove any dtt relations cause we DON'T want dtt relations attached
645
-                // (note this is just removing the cached relations in the object)
646
-                $new_default->_remove_relations('Datetime');
647
-                // @todo we need to add the current attached prices as new prices to the new default ticket.
648
-                $new_default = $this->_add_prices_to_ticket(
649
-                    $price_rows,
650
-                    $new_default,
651
-                    $update_prices
652
-                );
653
-                // don't forget the base price!
654
-                $new_default = $this->_add_prices_to_ticket(
655
-                    array(),
656
-                    $new_default,
657
-                    $update_prices,
658
-                    $base_price,
659
-                    $base_price_id
660
-                );
661
-                $new_default->save();
662
-                do_action(
663
-                    'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket',
664
-                    $new_default,
665
-                    $row,
666
-                    $ticket,
667
-                    $data
668
-                );
669
-            }
670
-            // DO ALL dtt relationships for both current tickets and any archived tickets
671
-            // for the given dtt that are related to the current ticket.
672
-            // TODO... not sure exactly how we're going to do this considering we don't know
673
-            // what current ticket the archived tickets are related to
674
-            // (and TKT_parent is used for autosaves so that's not a field we can reliably use).
675
-            // let's assign any tickets that have been setup to the saved_tickets tracker
676
-            // save existing TKT
677
-            $ticket->save();
678
-            if ($create_new_TKT && $new_tkt instanceof EE_Ticket) {
679
-                // save new TKT
680
-                $new_tkt->save();
681
-                // add new ticket to array
682
-                $saved_tickets[ $new_tkt->ID() ] = $new_tkt;
683
-                do_action(
684
-                    'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket',
685
-                    $new_tkt,
686
-                    $row,
687
-                    $tkt,
688
-                    $data
689
-                );
690
-            } else {
691
-                // add tkt to saved tkts
692
-                $saved_tickets[ $ticket->ID() ] = $ticket;
693
-                do_action(
694
-                    'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket',
695
-                    $ticket,
696
-                    $row,
697
-                    $tkt,
698
-                    $data
699
-                );
700
-            }
701
-        }
702
-        // now we need to handle tickets actually "deleted permanently".
703
-        // There are cases where we'd want this to happen
704
-        // (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
705
-        // Or a draft event was saved and in the process of editing a ticket is trashed.
706
-        // No sense in keeping all the related data in the db!
707
-        $old_tickets = isset($old_tickets[0]) && $old_tickets[0] === '' ? array() : $old_tickets;
708
-        $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
709
-        foreach ($tickets_removed as $id) {
710
-            $id = absint($id);
711
-            // get the ticket for this id
712
-            $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
713
-            // if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
714
-            if ($tkt_to_remove->get('TKT_is_default')) {
715
-                continue;
716
-            }
717
-            // if this tkt has any registrations attached so then we just ARCHIVE
718
-            // because we don't actually permanently delete these tickets.
719
-            if ($tkt_to_remove->count_related('Registration') > 0) {
720
-                $tkt_to_remove->delete();
721
-                continue;
722
-            }
723
-            // need to get all the related datetimes on this ticket and remove from every single one of them
724
-            // (remember this process can ONLY kick off if there are NO tkts_sold)
725
-            $datetimes = $tkt_to_remove->get_many_related('Datetime');
726
-            foreach ($datetimes as $datetime) {
727
-                $tkt_to_remove->_remove_relation_to($datetime, 'Datetime');
728
-            }
729
-            // need to do the same for prices (except these prices can also be deleted because again,
730
-            // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
731
-            $tkt_to_remove->delete_related_permanently('Price');
732
-            do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove);
733
-            // finally let's delete this ticket
734
-            // (which should not be blocked at this point b/c we've removed all our relationships)
735
-            $tkt_to_remove->delete_permanently();
736
-        }
737
-        return $saved_tickets;
738
-    }
429
+	/**
430
+	 * update tickets
431
+	 *
432
+	 * @param  EE_Event      $event           Event object being updated
433
+	 * @param  EE_Datetime[] $saved_datetimes an array of datetime ids being updated
434
+	 * @param  array         $data            incoming request data
435
+	 * @return EE_Ticket[]
436
+	 * @throws Exception
437
+	 * @throws ReflectionException
438
+	 * @throws InvalidInterfaceException
439
+	 * @throws InvalidDataTypeException
440
+	 * @throws InvalidArgumentException
441
+	 * @throws EE_Error
442
+	 */
443
+	protected function _update_tickets($event, $saved_datetimes, $data)
444
+	{
445
+		$new_tkt = null;
446
+		// stripslashes because WP filtered the $_POST ($data) array to add slashes
447
+		$data = stripslashes_deep($data);
448
+		$timezone = $data['timezone_string'] ?? null;
449
+		$saved_tickets = array();
450
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
451
+		if (empty($data['edit_tickets']) || ! is_array($data['edit_tickets'])) {
452
+			throw new InvalidArgumentException(
453
+				esc_html__(
454
+					'The "edit_tickets" array is invalid therefore the event can not be updated.',
455
+					'event_espresso'
456
+				)
457
+			);
458
+		}
459
+		foreach ($data['edit_tickets'] as $row => $tkt) {
460
+			$update_prices = $create_new_TKT = false;
461
+			// figure out what datetimes were added to the ticket
462
+			// and what datetimes were removed from the ticket in the session.
463
+			$starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][ $row ]);
464
+			$tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][ $row ]);
465
+			$datetimes_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
466
+			$datetimes_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
467
+			// trim inputs to ensure any excess whitespace is removed.
468
+			$tkt = array_map(
469
+				function ($ticket_data) {
470
+					return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
471
+				},
472
+				$tkt
473
+			);
474
+			// note we are doing conversions to floats here instead of allowing EE_Money_Field to handle
475
+			// because we're doing calculations prior to using the models.
476
+			// note incoming ['TKT_price'] value is already in standard notation (via js).
477
+			$ticket_price = isset($tkt['TKT_price'])
478
+				? round((float) $tkt['TKT_price'], 3)
479
+				: 0;
480
+			// note incoming base price needs converted from localized value.
481
+			$base_price = isset($tkt['TKT_base_price'])
482
+				? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price'])
483
+				: 0;
484
+			// if ticket price == 0 and $base_price != 0 then ticket price == base_price
485
+			$ticket_price = $ticket_price === 0 && $base_price !== 0
486
+				? $base_price
487
+				: $ticket_price;
488
+			$base_price_id = $tkt['TKT_base_price_ID'] ?? 0;
489
+			$price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][ $row ])
490
+				? $data['edit_prices'][ $row ]
491
+				: array();
492
+			$now = null;
493
+			if (empty($tkt['TKT_start_date'])) {
494
+				// lets' use now in the set timezone.
495
+				$now = new DateTime('now', new DateTimeZone($event->get_timezone()));
496
+				$tkt['TKT_start_date'] = $now->format($this->_date_time_format);
497
+			}
498
+			if (empty($tkt['TKT_end_date'])) {
499
+				/**
500
+				 * set the TKT_end_date to the first datetime attached to the ticket.
501
+				 */
502
+				$first_dtt = $saved_datetimes[ reset($tkt_dtt_rows) ];
503
+				$tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_time_format);
504
+			}
505
+			$TKT_values = array(
506
+				'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
507
+				'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
508
+				'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
509
+				'TKT_description' => ! empty($tkt['TKT_description'])
510
+									 && $tkt['TKT_description'] !== esc_html__(
511
+										 'You can modify this description',
512
+										 'event_espresso'
513
+									 )
514
+					? $tkt['TKT_description']
515
+					: '',
516
+				'TKT_start_date'  => $tkt['TKT_start_date'],
517
+				'TKT_end_date'    => $tkt['TKT_end_date'],
518
+				'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === ''
519
+					? EE_INF
520
+					: $tkt['TKT_qty'],
521
+				'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === ''
522
+					? EE_INF
523
+					: $tkt['TKT_uses'],
524
+				'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
525
+				'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
526
+				'TKT_row'         => $row,
527
+				'TKT_order'       => $tkt['TKT_order'] ?? 0,
528
+				'TKT_taxable'     => ! empty($tkt['TKT_taxable']) ? 1 : 0,
529
+				'TKT_required'    => ! empty($tkt['TKT_required']) ? 1 : 0,
530
+				'TKT_price'       => $ticket_price,
531
+			);
532
+			// if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly,
533
+			// which means in turn that the prices will become new prices as well.
534
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
535
+				$TKT_values['TKT_ID'] = 0;
536
+				$TKT_values['TKT_is_default'] = 0;
537
+				$update_prices = true;
538
+			}
539
+			// if we have a TKT_ID then we need to get that existing TKT_obj and update it
540
+			// we actually do our saves ahead of doing any add_relations to
541
+			// because its entirely possible that this ticket wasn't removed or added to any datetime in the session
542
+			// but DID have it's items modified.
543
+			// keep in mind that if the TKT has been sold (and we have changed pricing information),
544
+			// then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
545
+			if (absint($TKT_values['TKT_ID'])) {
546
+				$ticket = EE_Registry::instance()
547
+									 ->load_model('Ticket', array($timezone))
548
+									 ->get_one_by_ID($tkt['TKT_ID']);
549
+				if ($ticket instanceof EE_Ticket) {
550
+					$ticket = $this->_update_ticket_datetimes(
551
+						$ticket,
552
+						$saved_datetimes,
553
+						$datetimes_added,
554
+						$datetimes_removed
555
+					);
556
+					// are there any registrations using this ticket ?
557
+					$tickets_sold = $ticket->count_related(
558
+						'Registration',
559
+						array(
560
+							array(
561
+								'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete)),
562
+							),
563
+						)
564
+					);
565
+					// set ticket formats
566
+					$ticket->set_date_format($this->_date_format_strings['date']);
567
+					$ticket->set_time_format($this->_date_format_strings['time']);
568
+					// let's just check the total price for the existing ticket
569
+					// and determine if it matches the new total price.
570
+					// if they are different then we create a new ticket (if tickets sold)
571
+					// if they aren't different then we go ahead and modify existing ticket.
572
+					$create_new_TKT = $tickets_sold > 0 && $ticket_price !== $ticket->price() && ! $ticket->deleted();
573
+					// set new values
574
+					foreach ($TKT_values as $field => $value) {
575
+						if ($field === 'TKT_qty') {
576
+							$ticket->set_qty($value);
577
+						} else {
578
+							$ticket->set($field, $value);
579
+						}
580
+					}
581
+					// if $create_new_TKT is false then we can safely update the existing ticket.
582
+					// Otherwise we have to create a new ticket.
583
+					if ($create_new_TKT) {
584
+						$new_tkt = $this->_duplicate_ticket(
585
+							$ticket,
586
+							$price_rows,
587
+							$ticket_price,
588
+							$base_price,
589
+							$base_price_id
590
+						);
591
+					}
592
+				}
593
+			} else {
594
+				// no TKT_id so a new TKT
595
+				$ticket = EE_Ticket::new_instance(
596
+					$TKT_values,
597
+					$timezone,
598
+					array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
599
+				);
600
+				if ($ticket instanceof EE_Ticket) {
601
+					// make sure ticket has an ID of setting relations won't work
602
+					$ticket->save();
603
+					$ticket = $this->_update_ticket_datetimes(
604
+						$ticket,
605
+						$saved_datetimes,
606
+						$datetimes_added,
607
+						$datetimes_removed
608
+					);
609
+					$update_prices = true;
610
+				}
611
+			}
612
+			// make sure any current values have been saved.
613
+			// $ticket->save();
614
+			// before going any further make sure our dates are setup correctly
615
+			// so that the end date is always equal or greater than the start date.
616
+			if ($ticket->get_raw('TKT_start_date') > $ticket->get_raw('TKT_end_date')) {
617
+				$ticket->set('TKT_end_date', $ticket->get('TKT_start_date'));
618
+				$ticket = EEH_DTT_Helper::date_time_add($ticket, 'TKT_end_date', 'days');
619
+			}
620
+			// let's make sure the base price is handled
621
+			$ticket = ! $create_new_TKT
622
+				? $this->_add_prices_to_ticket(
623
+					array(),
624
+					$ticket,
625
+					$update_prices,
626
+					$base_price,
627
+					$base_price_id
628
+				)
629
+				: $ticket;
630
+			// add/update price_modifiers
631
+			$ticket = ! $create_new_TKT
632
+				? $this->_add_prices_to_ticket($price_rows, $ticket, $update_prices)
633
+				: $ticket;
634
+			// need to make sue that the TKT_price is accurate after saving the prices.
635
+			$ticket->ensure_TKT_Price_correct();
636
+			// handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
637
+			if (! defined('DOING_AUTOSAVE') && ! empty($tkt['TKT_is_default_selector'])) {
638
+				$update_prices = true;
639
+				$new_default = clone $ticket;
640
+				$new_default->set('TKT_ID', 0);
641
+				$new_default->set('TKT_is_default', 1);
642
+				$new_default->set('TKT_row', 1);
643
+				$new_default->set('TKT_price', $ticket_price);
644
+				// remove any dtt relations cause we DON'T want dtt relations attached
645
+				// (note this is just removing the cached relations in the object)
646
+				$new_default->_remove_relations('Datetime');
647
+				// @todo we need to add the current attached prices as new prices to the new default ticket.
648
+				$new_default = $this->_add_prices_to_ticket(
649
+					$price_rows,
650
+					$new_default,
651
+					$update_prices
652
+				);
653
+				// don't forget the base price!
654
+				$new_default = $this->_add_prices_to_ticket(
655
+					array(),
656
+					$new_default,
657
+					$update_prices,
658
+					$base_price,
659
+					$base_price_id
660
+				);
661
+				$new_default->save();
662
+				do_action(
663
+					'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket',
664
+					$new_default,
665
+					$row,
666
+					$ticket,
667
+					$data
668
+				);
669
+			}
670
+			// DO ALL dtt relationships for both current tickets and any archived tickets
671
+			// for the given dtt that are related to the current ticket.
672
+			// TODO... not sure exactly how we're going to do this considering we don't know
673
+			// what current ticket the archived tickets are related to
674
+			// (and TKT_parent is used for autosaves so that's not a field we can reliably use).
675
+			// let's assign any tickets that have been setup to the saved_tickets tracker
676
+			// save existing TKT
677
+			$ticket->save();
678
+			if ($create_new_TKT && $new_tkt instanceof EE_Ticket) {
679
+				// save new TKT
680
+				$new_tkt->save();
681
+				// add new ticket to array
682
+				$saved_tickets[ $new_tkt->ID() ] = $new_tkt;
683
+				do_action(
684
+					'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket',
685
+					$new_tkt,
686
+					$row,
687
+					$tkt,
688
+					$data
689
+				);
690
+			} else {
691
+				// add tkt to saved tkts
692
+				$saved_tickets[ $ticket->ID() ] = $ticket;
693
+				do_action(
694
+					'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket',
695
+					$ticket,
696
+					$row,
697
+					$tkt,
698
+					$data
699
+				);
700
+			}
701
+		}
702
+		// now we need to handle tickets actually "deleted permanently".
703
+		// There are cases where we'd want this to happen
704
+		// (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
705
+		// Or a draft event was saved and in the process of editing a ticket is trashed.
706
+		// No sense in keeping all the related data in the db!
707
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] === '' ? array() : $old_tickets;
708
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
709
+		foreach ($tickets_removed as $id) {
710
+			$id = absint($id);
711
+			// get the ticket for this id
712
+			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
713
+			// if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
714
+			if ($tkt_to_remove->get('TKT_is_default')) {
715
+				continue;
716
+			}
717
+			// if this tkt has any registrations attached so then we just ARCHIVE
718
+			// because we don't actually permanently delete these tickets.
719
+			if ($tkt_to_remove->count_related('Registration') > 0) {
720
+				$tkt_to_remove->delete();
721
+				continue;
722
+			}
723
+			// need to get all the related datetimes on this ticket and remove from every single one of them
724
+			// (remember this process can ONLY kick off if there are NO tkts_sold)
725
+			$datetimes = $tkt_to_remove->get_many_related('Datetime');
726
+			foreach ($datetimes as $datetime) {
727
+				$tkt_to_remove->_remove_relation_to($datetime, 'Datetime');
728
+			}
729
+			// need to do the same for prices (except these prices can also be deleted because again,
730
+			// tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
731
+			$tkt_to_remove->delete_related_permanently('Price');
732
+			do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove);
733
+			// finally let's delete this ticket
734
+			// (which should not be blocked at this point b/c we've removed all our relationships)
735
+			$tkt_to_remove->delete_permanently();
736
+		}
737
+		return $saved_tickets;
738
+	}
739 739
 
740 740
 
741
-    /**
742
-     * @access  protected
743
-     * @param EE_Ticket      $ticket
744
-     * @param \EE_Datetime[] $saved_datetimes
745
-     * @param \EE_Datetime[] $added_datetimes
746
-     * @param \EE_Datetime[] $removed_datetimes
747
-     * @return EE_Ticket
748
-     * @throws EE_Error
749
-     */
750
-    protected function _update_ticket_datetimes(
751
-        EE_Ticket $ticket,
752
-        $saved_datetimes = array(),
753
-        $added_datetimes = array(),
754
-        $removed_datetimes = array()
755
-    ) {
756
-        // to start we have to add the ticket to all the datetimes its supposed to be with,
757
-        // and removing the ticket from datetimes it got removed from.
758
-        // first let's add datetimes
759
-        if (! empty($added_datetimes) && is_array($added_datetimes)) {
760
-            foreach ($added_datetimes as $row_id) {
761
-                $row_id = (int) $row_id;
762
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
763
-                    $ticket->_add_relation_to($saved_datetimes[ $row_id ], 'Datetime');
764
-                    // Is this an existing ticket (has an ID) and does it have any sold?
765
-                    // If so, then we need to add that to the DTT sold because this DTT is getting added.
766
-                    if ($ticket->ID() && $ticket->sold() > 0) {
767
-                        $saved_datetimes[ $row_id ]->increaseSold($ticket->sold(), false);
768
-                    }
769
-                }
770
-            }
771
-        }
772
-        // then remove datetimes
773
-        if (! empty($removed_datetimes) && is_array($removed_datetimes)) {
774
-            foreach ($removed_datetimes as $row_id) {
775
-                $row_id = (int) $row_id;
776
-                // its entirely possible that a datetime got deleted (instead of just removed from relationship.
777
-                // So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
778
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
779
-                    $ticket->_remove_relation_to($saved_datetimes[ $row_id ], 'Datetime');
780
-                    // Is this an existing ticket (has an ID) and does it have any sold?
781
-                    // If so, then we need to remove it's sold from the DTT_sold.
782
-                    if ($ticket->ID() && $ticket->sold() > 0) {
783
-                        $saved_datetimes[ $row_id ]->decreaseSold($ticket->sold());
784
-                    }
785
-                }
786
-            }
787
-        }
788
-        // cap ticket qty by datetime reg limits
789
-        $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
790
-        return $ticket;
791
-    }
741
+	/**
742
+	 * @access  protected
743
+	 * @param EE_Ticket      $ticket
744
+	 * @param \EE_Datetime[] $saved_datetimes
745
+	 * @param \EE_Datetime[] $added_datetimes
746
+	 * @param \EE_Datetime[] $removed_datetimes
747
+	 * @return EE_Ticket
748
+	 * @throws EE_Error
749
+	 */
750
+	protected function _update_ticket_datetimes(
751
+		EE_Ticket $ticket,
752
+		$saved_datetimes = array(),
753
+		$added_datetimes = array(),
754
+		$removed_datetimes = array()
755
+	) {
756
+		// to start we have to add the ticket to all the datetimes its supposed to be with,
757
+		// and removing the ticket from datetimes it got removed from.
758
+		// first let's add datetimes
759
+		if (! empty($added_datetimes) && is_array($added_datetimes)) {
760
+			foreach ($added_datetimes as $row_id) {
761
+				$row_id = (int) $row_id;
762
+				if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
763
+					$ticket->_add_relation_to($saved_datetimes[ $row_id ], 'Datetime');
764
+					// Is this an existing ticket (has an ID) and does it have any sold?
765
+					// If so, then we need to add that to the DTT sold because this DTT is getting added.
766
+					if ($ticket->ID() && $ticket->sold() > 0) {
767
+						$saved_datetimes[ $row_id ]->increaseSold($ticket->sold(), false);
768
+					}
769
+				}
770
+			}
771
+		}
772
+		// then remove datetimes
773
+		if (! empty($removed_datetimes) && is_array($removed_datetimes)) {
774
+			foreach ($removed_datetimes as $row_id) {
775
+				$row_id = (int) $row_id;
776
+				// its entirely possible that a datetime got deleted (instead of just removed from relationship.
777
+				// So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
778
+				if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
779
+					$ticket->_remove_relation_to($saved_datetimes[ $row_id ], 'Datetime');
780
+					// Is this an existing ticket (has an ID) and does it have any sold?
781
+					// If so, then we need to remove it's sold from the DTT_sold.
782
+					if ($ticket->ID() && $ticket->sold() > 0) {
783
+						$saved_datetimes[ $row_id ]->decreaseSold($ticket->sold());
784
+					}
785
+				}
786
+			}
787
+		}
788
+		// cap ticket qty by datetime reg limits
789
+		$ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
790
+		return $ticket;
791
+	}
792 792
 
793 793
 
794
-    /**
795
-     * @access  protected
796
-     * @param EE_Ticket $ticket
797
-     * @param array     $price_rows
798
-     * @param int       $ticket_price
799
-     * @param int       $base_price
800
-     * @param int       $base_price_id
801
-     * @return EE_Ticket
802
-     * @throws ReflectionException
803
-     * @throws InvalidArgumentException
804
-     * @throws InvalidInterfaceException
805
-     * @throws InvalidDataTypeException
806
-     * @throws EE_Error
807
-     */
808
-    protected function _duplicate_ticket(
809
-        EE_Ticket $ticket,
810
-        $price_rows = array(),
811
-        $ticket_price = 0,
812
-        $base_price = 0,
813
-        $base_price_id = 0
814
-    ) {
815
-        // create new ticket that's a copy of the existing
816
-        // except a new id of course (and not archived)
817
-        // AND has the new TKT_price associated with it.
818
-        $new_ticket = clone $ticket;
819
-        $new_ticket->set('TKT_ID', 0);
820
-        $new_ticket->set_deleted(0);
821
-        $new_ticket->set_price($ticket_price);
822
-        $new_ticket->set_sold(0);
823
-        // let's get a new ID for this ticket
824
-        $new_ticket->save();
825
-        // we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
826
-        $datetimes_on_existing = $ticket->datetimes();
827
-        $new_ticket = $this->_update_ticket_datetimes(
828
-            $new_ticket,
829
-            $datetimes_on_existing,
830
-            array_keys($datetimes_on_existing)
831
-        );
832
-        // $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
833
-        // if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
834
-        // available.
835
-        if ($ticket->sold() > 0) {
836
-            $new_qty = $ticket->qty() - $ticket->sold();
837
-            $new_ticket->set_qty($new_qty);
838
-        }
839
-        // now we update the prices just for this ticket
840
-        $new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
841
-        // and we update the base price
842
-        $new_ticket = $this->_add_prices_to_ticket(
843
-            array(),
844
-            $new_ticket,
845
-            true,
846
-            $base_price,
847
-            $base_price_id
848
-        );
849
-        return $new_ticket;
850
-    }
794
+	/**
795
+	 * @access  protected
796
+	 * @param EE_Ticket $ticket
797
+	 * @param array     $price_rows
798
+	 * @param int       $ticket_price
799
+	 * @param int       $base_price
800
+	 * @param int       $base_price_id
801
+	 * @return EE_Ticket
802
+	 * @throws ReflectionException
803
+	 * @throws InvalidArgumentException
804
+	 * @throws InvalidInterfaceException
805
+	 * @throws InvalidDataTypeException
806
+	 * @throws EE_Error
807
+	 */
808
+	protected function _duplicate_ticket(
809
+		EE_Ticket $ticket,
810
+		$price_rows = array(),
811
+		$ticket_price = 0,
812
+		$base_price = 0,
813
+		$base_price_id = 0
814
+	) {
815
+		// create new ticket that's a copy of the existing
816
+		// except a new id of course (and not archived)
817
+		// AND has the new TKT_price associated with it.
818
+		$new_ticket = clone $ticket;
819
+		$new_ticket->set('TKT_ID', 0);
820
+		$new_ticket->set_deleted(0);
821
+		$new_ticket->set_price($ticket_price);
822
+		$new_ticket->set_sold(0);
823
+		// let's get a new ID for this ticket
824
+		$new_ticket->save();
825
+		// we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
826
+		$datetimes_on_existing = $ticket->datetimes();
827
+		$new_ticket = $this->_update_ticket_datetimes(
828
+			$new_ticket,
829
+			$datetimes_on_existing,
830
+			array_keys($datetimes_on_existing)
831
+		);
832
+		// $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
833
+		// if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
834
+		// available.
835
+		if ($ticket->sold() > 0) {
836
+			$new_qty = $ticket->qty() - $ticket->sold();
837
+			$new_ticket->set_qty($new_qty);
838
+		}
839
+		// now we update the prices just for this ticket
840
+		$new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
841
+		// and we update the base price
842
+		$new_ticket = $this->_add_prices_to_ticket(
843
+			array(),
844
+			$new_ticket,
845
+			true,
846
+			$base_price,
847
+			$base_price_id
848
+		);
849
+		return $new_ticket;
850
+	}
851 851
 
852 852
 
853
-    /**
854
-     * This attaches a list of given prices to a ticket.
855
-     * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
856
-     * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
857
-     * price info and prices are automatically "archived" via the ticket.
858
-     *
859
-     * @access  private
860
-     * @param array     $prices        Array of prices from the form.
861
-     * @param EE_Ticket $ticket        EE_Ticket object that prices are being attached to.
862
-     * @param bool      $new_prices    Whether attach existing incoming prices or create new ones.
863
-     * @param int|bool  $base_price    if FALSE then NOT doing a base price add.
864
-     * @param int|bool  $base_price_id if present then this is the base_price_id being updated.
865
-     * @return EE_Ticket
866
-     * @throws ReflectionException
867
-     * @throws InvalidArgumentException
868
-     * @throws InvalidInterfaceException
869
-     * @throws InvalidDataTypeException
870
-     * @throws EE_Error
871
-     */
872
-    protected function _add_prices_to_ticket(
873
-        $prices = array(),
874
-        EE_Ticket $ticket,
875
-        $new_prices = false,
876
-        $base_price = false,
877
-        $base_price_id = false
878
-    ) {
879
-        // let's just get any current prices that may exist on the given ticket
880
-        // so we can remove any prices that got trashed in this session.
881
-        $current_prices_on_ticket = $base_price !== false
882
-            ? $ticket->base_price(true)
883
-            : $ticket->price_modifiers();
884
-        $updated_prices = array();
885
-        // if $base_price ! FALSE then updating a base price.
886
-        if ($base_price !== false) {
887
-            $prices[1] = array(
888
-                'PRC_ID'     => $new_prices || $base_price_id === 1 ? null : $base_price_id,
889
-                'PRT_ID'     => 1,
890
-                'PRC_amount' => $base_price,
891
-                'PRC_name'   => $ticket->get('TKT_name'),
892
-                'PRC_desc'   => $ticket->get('TKT_description'),
893
-            );
894
-        }
895
-        // possibly need to save tkt
896
-        if (! $ticket->ID()) {
897
-            $ticket->save();
898
-        }
899
-        foreach ($prices as $row => $prc) {
900
-            $prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null;
901
-            if (empty($prt_id)) {
902
-                continue;
903
-            } //prices MUST have a price type id.
904
-            $PRC_values = array(
905
-                'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
906
-                'PRT_ID'         => $prt_id,
907
-                'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
908
-                'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
909
-                'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
910
-                'PRC_is_default' => false,
911
-                // make sure we set PRC_is_default to false for all ticket saves from event_editor
912
-                'PRC_order'      => $row,
913
-            );
914
-            if ($new_prices || empty($PRC_values['PRC_ID'])) {
915
-                $PRC_values['PRC_ID'] = 0;
916
-                $price = EE_Registry::instance()->load_class(
917
-                    'Price',
918
-                    array($PRC_values),
919
-                    false,
920
-                    false
921
-                );
922
-            } else {
923
-                $price = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
924
-                // update this price with new values
925
-                foreach ($PRC_values as $field => $value) {
926
-                    $price->set($field, $value);
927
-                }
928
-            }
929
-            $price->save();
930
-            $updated_prices[ $price->ID() ] = $price;
931
-            $ticket->_add_relation_to($price, 'Price');
932
-        }
933
-        // now let's remove any prices that got removed from the ticket
934
-        if (! empty($current_prices_on_ticket)) {
935
-            $current = array_keys($current_prices_on_ticket);
936
-            $updated = array_keys($updated_prices);
937
-            $prices_to_remove = array_diff($current, $updated);
938
-            if (! empty($prices_to_remove)) {
939
-                foreach ($prices_to_remove as $prc_id) {
940
-                    $p = $current_prices_on_ticket[ $prc_id ];
941
-                    $ticket->_remove_relation_to($p, 'Price');
942
-                    // delete permanently the price
943
-                    $p->delete_permanently();
944
-                }
945
-            }
946
-        }
947
-        return $ticket;
948
-    }
853
+	/**
854
+	 * This attaches a list of given prices to a ticket.
855
+	 * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
856
+	 * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
857
+	 * price info and prices are automatically "archived" via the ticket.
858
+	 *
859
+	 * @access  private
860
+	 * @param array     $prices        Array of prices from the form.
861
+	 * @param EE_Ticket $ticket        EE_Ticket object that prices are being attached to.
862
+	 * @param bool      $new_prices    Whether attach existing incoming prices or create new ones.
863
+	 * @param int|bool  $base_price    if FALSE then NOT doing a base price add.
864
+	 * @param int|bool  $base_price_id if present then this is the base_price_id being updated.
865
+	 * @return EE_Ticket
866
+	 * @throws ReflectionException
867
+	 * @throws InvalidArgumentException
868
+	 * @throws InvalidInterfaceException
869
+	 * @throws InvalidDataTypeException
870
+	 * @throws EE_Error
871
+	 */
872
+	protected function _add_prices_to_ticket(
873
+		$prices = array(),
874
+		EE_Ticket $ticket,
875
+		$new_prices = false,
876
+		$base_price = false,
877
+		$base_price_id = false
878
+	) {
879
+		// let's just get any current prices that may exist on the given ticket
880
+		// so we can remove any prices that got trashed in this session.
881
+		$current_prices_on_ticket = $base_price !== false
882
+			? $ticket->base_price(true)
883
+			: $ticket->price_modifiers();
884
+		$updated_prices = array();
885
+		// if $base_price ! FALSE then updating a base price.
886
+		if ($base_price !== false) {
887
+			$prices[1] = array(
888
+				'PRC_ID'     => $new_prices || $base_price_id === 1 ? null : $base_price_id,
889
+				'PRT_ID'     => 1,
890
+				'PRC_amount' => $base_price,
891
+				'PRC_name'   => $ticket->get('TKT_name'),
892
+				'PRC_desc'   => $ticket->get('TKT_description'),
893
+			);
894
+		}
895
+		// possibly need to save tkt
896
+		if (! $ticket->ID()) {
897
+			$ticket->save();
898
+		}
899
+		foreach ($prices as $row => $prc) {
900
+			$prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null;
901
+			if (empty($prt_id)) {
902
+				continue;
903
+			} //prices MUST have a price type id.
904
+			$PRC_values = array(
905
+				'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
906
+				'PRT_ID'         => $prt_id,
907
+				'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
908
+				'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
909
+				'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
910
+				'PRC_is_default' => false,
911
+				// make sure we set PRC_is_default to false for all ticket saves from event_editor
912
+				'PRC_order'      => $row,
913
+			);
914
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
915
+				$PRC_values['PRC_ID'] = 0;
916
+				$price = EE_Registry::instance()->load_class(
917
+					'Price',
918
+					array($PRC_values),
919
+					false,
920
+					false
921
+				);
922
+			} else {
923
+				$price = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
924
+				// update this price with new values
925
+				foreach ($PRC_values as $field => $value) {
926
+					$price->set($field, $value);
927
+				}
928
+			}
929
+			$price->save();
930
+			$updated_prices[ $price->ID() ] = $price;
931
+			$ticket->_add_relation_to($price, 'Price');
932
+		}
933
+		// now let's remove any prices that got removed from the ticket
934
+		if (! empty($current_prices_on_ticket)) {
935
+			$current = array_keys($current_prices_on_ticket);
936
+			$updated = array_keys($updated_prices);
937
+			$prices_to_remove = array_diff($current, $updated);
938
+			if (! empty($prices_to_remove)) {
939
+				foreach ($prices_to_remove as $prc_id) {
940
+					$p = $current_prices_on_ticket[ $prc_id ];
941
+					$ticket->_remove_relation_to($p, 'Price');
942
+					// delete permanently the price
943
+					$p->delete_permanently();
944
+				}
945
+			}
946
+		}
947
+		return $ticket;
948
+	}
949 949
 
950 950
 
951
-    /**
952
-     * @param Events_Admin_Page $event_admin_obj
953
-     * @return Events_Admin_Page
954
-     */
955
-    public function autosave_handling(Events_Admin_Page $event_admin_obj)
956
-    {
957
-        return $event_admin_obj;
958
-        // doing nothing for the moment.
959
-        // todo when I get to this remember that I need to set the template args on the $event_admin_obj
960
-        // (use the set_template_args() method)
961
-        /**
962
-         * need to remember to handle TICKET DEFAULT saves correctly:  I've got two input fields in the dom:
963
-         * 1. TKT_is_default_selector (visible)
964
-         * 2. TKT_is_default (hidden)
965
-         * I think we'll use the TKT_is_default for recording whether the ticket displayed IS a default ticket
966
-         * (on new event creations). Whereas the TKT_is_default_selector is for the user to indicate they want
967
-         * this ticket to be saved as a default.
968
-         * The tricky part is, on an initial display on create or edit (or after manually updating),
969
-         * the TKT_is_default_selector will always be unselected and the TKT_is_default will only be true
970
-         * if this is a create.  However, after an autosave, users will want some sort of indicator that
971
-         * the TKT HAS been saved as a default..
972
-         * in other words we don't want to remove the check on TKT_is_default_selector. So here's what I'm thinking.
973
-         * On Autosave:
974
-         * 1. If TKT_is_default is true: we create a new TKT, send back the new id and add id to related elements,
975
-         * then set the TKT_is_default to false.
976
-         * 2. If TKT_is_default_selector is true: we create/edit existing ticket (following conditions above as well).
977
-         *  We do NOT create a new default ticket.  The checkbox stays selected after autosave.
978
-         * 3. only on MANUAL update do we check for the selection and if selected create the new default ticket.
979
-         */
980
-    }
951
+	/**
952
+	 * @param Events_Admin_Page $event_admin_obj
953
+	 * @return Events_Admin_Page
954
+	 */
955
+	public function autosave_handling(Events_Admin_Page $event_admin_obj)
956
+	{
957
+		return $event_admin_obj;
958
+		// doing nothing for the moment.
959
+		// todo when I get to this remember that I need to set the template args on the $event_admin_obj
960
+		// (use the set_template_args() method)
961
+		/**
962
+		 * need to remember to handle TICKET DEFAULT saves correctly:  I've got two input fields in the dom:
963
+		 * 1. TKT_is_default_selector (visible)
964
+		 * 2. TKT_is_default (hidden)
965
+		 * I think we'll use the TKT_is_default for recording whether the ticket displayed IS a default ticket
966
+		 * (on new event creations). Whereas the TKT_is_default_selector is for the user to indicate they want
967
+		 * this ticket to be saved as a default.
968
+		 * The tricky part is, on an initial display on create or edit (or after manually updating),
969
+		 * the TKT_is_default_selector will always be unselected and the TKT_is_default will only be true
970
+		 * if this is a create.  However, after an autosave, users will want some sort of indicator that
971
+		 * the TKT HAS been saved as a default..
972
+		 * in other words we don't want to remove the check on TKT_is_default_selector. So here's what I'm thinking.
973
+		 * On Autosave:
974
+		 * 1. If TKT_is_default is true: we create a new TKT, send back the new id and add id to related elements,
975
+		 * then set the TKT_is_default to false.
976
+		 * 2. If TKT_is_default_selector is true: we create/edit existing ticket (following conditions above as well).
977
+		 *  We do NOT create a new default ticket.  The checkbox stays selected after autosave.
978
+		 * 3. only on MANUAL update do we check for the selection and if selected create the new default ticket.
979
+		 */
980
+	}
981 981
 
982 982
 
983
-    /**
984
-     * @throws ReflectionException
985
-     * @throws InvalidArgumentException
986
-     * @throws InvalidInterfaceException
987
-     * @throws InvalidDataTypeException
988
-     * @throws DomainException
989
-     * @throws EE_Error
990
-     */
991
-    public function pricing_metabox()
992
-    {
993
-        $existing_datetime_ids = $existing_ticket_ids = $datetime_tickets = $ticket_datetimes = array();
994
-        $event = $this->_adminpage_obj->get_cpt_model_obj();
995
-        // set is_creating_event property.
996
-        $EVT_ID = $event->ID();
997
-        $this->_is_creating_event = empty($this->_req_data['post']);
998
-        // default main template args
999
-        $main_template_args = array(
1000
-            'event_datetime_help_link' => EEH_Template::get_help_tab_link(
1001
-                'event_editor_event_datetimes_help_tab',
1002
-                $this->_adminpage_obj->page_slug,
1003
-                $this->_adminpage_obj->get_req_action(),
1004
-                false,
1005
-                false
1006
-            ),
1007
-            // todo need to add a filter to the template for the help text
1008
-            // in the Events_Admin_Page core file so we can add further help
1009
-            'existing_datetime_ids'    => '',
1010
-            'total_dtt_rows'           => 1,
1011
-            'add_new_dtt_help_link'    => EEH_Template::get_help_tab_link(
1012
-                'add_new_dtt_info',
1013
-                $this->_adminpage_obj->page_slug,
1014
-                $this->_adminpage_obj->get_req_action(),
1015
-                false,
1016
-                false
1017
-            ),
1018
-            // todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1019
-            'datetime_rows'            => '',
1020
-            'show_tickets_container'   => '',
1021
-            // $this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
1022
-            'ticket_rows'              => '',
1023
-            'existing_ticket_ids'      => '',
1024
-            'total_ticket_rows'        => 1,
1025
-            'ticket_js_structure'      => '',
1026
-            'ee_collapsible_status'    => ' ee-collapsible-open'
1027
-            // $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' ee-collapsible-closed' : ' ee-collapsible-open'
1028
-        );
1029
-        $timezone = $event instanceof EE_Event ? $event->timezone_string() : null;
1030
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1031
-        /**
1032
-         * 1. Start with retrieving Datetimes
1033
-         * 2. For each datetime get related tickets
1034
-         * 3. For each ticket get related prices
1035
-         */
1036
-        /** @var EEM_Datetime $datetime_model */
1037
-        $datetime_model = EE_Registry::instance()->load_model('Datetime', array($timezone));
1038
-        $datetimes = $datetime_model->get_all_event_dates($EVT_ID);
1039
-        $main_template_args['total_dtt_rows'] = count($datetimes);
1040
-        /**
1041
-         * @see https://events.codebasehq.com/projects/event-espresso/tickets/9486
1042
-         * for why we are counting $datetime_row and then setting that on the Datetime object
1043
-         */
1044
-        $datetime_row = 1;
1045
-        foreach ($datetimes as $datetime) {
1046
-            $DTT_ID = $datetime->get('DTT_ID');
1047
-            $datetime->set('DTT_order', $datetime_row);
1048
-            $existing_datetime_ids[] = $DTT_ID;
1049
-            // tickets attached
1050
-            $related_tickets = $datetime->ID() > 0
1051
-                ? $datetime->get_many_related(
1052
-                    'Ticket',
1053
-                    array(
1054
-                        array(
1055
-                            'OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0),
1056
-                        ),
1057
-                        'default_where_conditions' => 'none',
1058
-                        'order_by'                 => array('TKT_order' => 'ASC'),
1059
-                    )
1060
-                )
1061
-                : array();
1062
-            // if there are no related tickets this is likely a new event OR autodraft
1063
-            // event so we need to generate the default tickets because datetimes
1064
-            // ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
1065
-            // datetime on the event.
1066
-            if (empty($related_tickets) && count($datetimes) < 2) {
1067
-                /** @var EEM_Ticket $ticket_model */
1068
-                $ticket_model = EE_Registry::instance()->load_model('Ticket');
1069
-                $related_tickets = $ticket_model->get_all_default_tickets();
1070
-                // this should be ordered by TKT_ID, so let's grab the first default ticket
1071
-                // (which will be the main default) and ensure it has any default prices added to it (but do NOT save).
1072
-                $default_prices = EEM_Price::instance()->get_all_default_prices();
1073
-                $main_default_ticket = reset($related_tickets);
1074
-                if ($main_default_ticket instanceof EE_Ticket) {
1075
-                    foreach ($default_prices as $default_price) {
1076
-                        if ($default_price instanceof EE_Price && $default_price->is_base_price()) {
1077
-                            continue;
1078
-                        }
1079
-                        $main_default_ticket->cache('Price', $default_price);
1080
-                    }
1081
-                }
1082
-            }
1083
-            // we can't actually setup rows in this loop yet cause we don't know all
1084
-            // the unique tickets for this event yet (tickets are linked through all datetimes).
1085
-            // So we're going to temporarily cache some of that information.
1086
-            // loop through and setup the ticket rows and make sure the order is set.
1087
-            foreach ($related_tickets as $ticket) {
1088
-                $TKT_ID = $ticket->get('TKT_ID');
1089
-                $ticket_row = $ticket->get('TKT_row');
1090
-                // we only want unique tickets in our final display!!
1091
-                if (! in_array($TKT_ID, $existing_ticket_ids, true)) {
1092
-                    $existing_ticket_ids[] = $TKT_ID;
1093
-                    $all_tickets[] = $ticket;
1094
-                }
1095
-                // temporary cache of this ticket info for this datetime for later processing of datetime rows.
1096
-                $datetime_tickets[ $DTT_ID ][] = $ticket_row;
1097
-                // temporary cache of this datetime info for this ticket for later processing of ticket rows.
1098
-                if (
1099
-                    ! isset($ticket_datetimes[ $TKT_ID ])
1100
-                    || ! in_array($datetime_row, $ticket_datetimes[ $TKT_ID ], true)
1101
-                ) {
1102
-                    $ticket_datetimes[ $TKT_ID ][] = $datetime_row;
1103
-                }
1104
-            }
1105
-            $datetime_row++;
1106
-        }
1107
-        $main_template_args['total_ticket_rows'] = count($existing_ticket_ids);
1108
-        $main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1109
-        $main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1110
-        // sort $all_tickets by order
1111
-        usort(
1112
-            $all_tickets,
1113
-            function (EE_Ticket $a, EE_Ticket $b) {
1114
-                $a_order = (int) $a->get('TKT_order');
1115
-                $b_order = (int) $b->get('TKT_order');
1116
-                if ($a_order === $b_order) {
1117
-                    return 0;
1118
-                }
1119
-                return ($a_order < $b_order) ? -1 : 1;
1120
-            }
1121
-        );
1122
-        // k NOW we have all the data we need for setting up the dtt rows
1123
-        // and ticket rows so we start our dtt loop again.
1124
-        $datetime_row = 1;
1125
-        foreach ($datetimes as $datetime) {
1126
-            $main_template_args['datetime_rows'] .= $this->_get_datetime_row(
1127
-                $datetime_row,
1128
-                $datetime,
1129
-                $datetime_tickets,
1130
-                $all_tickets,
1131
-                false,
1132
-                $datetimes
1133
-            );
1134
-            $datetime_row++;
1135
-        }
1136
-        // then loop through all tickets for the ticket rows.
1137
-        $ticket_row = 1;
1138
-        foreach ($all_tickets as $ticket) {
1139
-            $main_template_args['ticket_rows'] .= $this->_get_ticket_row(
1140
-                $ticket_row,
1141
-                $ticket,
1142
-                $ticket_datetimes,
1143
-                $datetimes,
1144
-                false,
1145
-                $all_tickets
1146
-            );
1147
-            $ticket_row++;
1148
-        }
1149
-        $main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($datetimes, $all_tickets);
1150
-        EEH_Template::display_template(
1151
-            PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php',
1152
-            $main_template_args
1153
-        );
1154
-    }
983
+	/**
984
+	 * @throws ReflectionException
985
+	 * @throws InvalidArgumentException
986
+	 * @throws InvalidInterfaceException
987
+	 * @throws InvalidDataTypeException
988
+	 * @throws DomainException
989
+	 * @throws EE_Error
990
+	 */
991
+	public function pricing_metabox()
992
+	{
993
+		$existing_datetime_ids = $existing_ticket_ids = $datetime_tickets = $ticket_datetimes = array();
994
+		$event = $this->_adminpage_obj->get_cpt_model_obj();
995
+		// set is_creating_event property.
996
+		$EVT_ID = $event->ID();
997
+		$this->_is_creating_event = empty($this->_req_data['post']);
998
+		// default main template args
999
+		$main_template_args = array(
1000
+			'event_datetime_help_link' => EEH_Template::get_help_tab_link(
1001
+				'event_editor_event_datetimes_help_tab',
1002
+				$this->_adminpage_obj->page_slug,
1003
+				$this->_adminpage_obj->get_req_action(),
1004
+				false,
1005
+				false
1006
+			),
1007
+			// todo need to add a filter to the template for the help text
1008
+			// in the Events_Admin_Page core file so we can add further help
1009
+			'existing_datetime_ids'    => '',
1010
+			'total_dtt_rows'           => 1,
1011
+			'add_new_dtt_help_link'    => EEH_Template::get_help_tab_link(
1012
+				'add_new_dtt_info',
1013
+				$this->_adminpage_obj->page_slug,
1014
+				$this->_adminpage_obj->get_req_action(),
1015
+				false,
1016
+				false
1017
+			),
1018
+			// todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1019
+			'datetime_rows'            => '',
1020
+			'show_tickets_container'   => '',
1021
+			// $this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
1022
+			'ticket_rows'              => '',
1023
+			'existing_ticket_ids'      => '',
1024
+			'total_ticket_rows'        => 1,
1025
+			'ticket_js_structure'      => '',
1026
+			'ee_collapsible_status'    => ' ee-collapsible-open'
1027
+			// $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' ee-collapsible-closed' : ' ee-collapsible-open'
1028
+		);
1029
+		$timezone = $event instanceof EE_Event ? $event->timezone_string() : null;
1030
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1031
+		/**
1032
+		 * 1. Start with retrieving Datetimes
1033
+		 * 2. For each datetime get related tickets
1034
+		 * 3. For each ticket get related prices
1035
+		 */
1036
+		/** @var EEM_Datetime $datetime_model */
1037
+		$datetime_model = EE_Registry::instance()->load_model('Datetime', array($timezone));
1038
+		$datetimes = $datetime_model->get_all_event_dates($EVT_ID);
1039
+		$main_template_args['total_dtt_rows'] = count($datetimes);
1040
+		/**
1041
+		 * @see https://events.codebasehq.com/projects/event-espresso/tickets/9486
1042
+		 * for why we are counting $datetime_row and then setting that on the Datetime object
1043
+		 */
1044
+		$datetime_row = 1;
1045
+		foreach ($datetimes as $datetime) {
1046
+			$DTT_ID = $datetime->get('DTT_ID');
1047
+			$datetime->set('DTT_order', $datetime_row);
1048
+			$existing_datetime_ids[] = $DTT_ID;
1049
+			// tickets attached
1050
+			$related_tickets = $datetime->ID() > 0
1051
+				? $datetime->get_many_related(
1052
+					'Ticket',
1053
+					array(
1054
+						array(
1055
+							'OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0),
1056
+						),
1057
+						'default_where_conditions' => 'none',
1058
+						'order_by'                 => array('TKT_order' => 'ASC'),
1059
+					)
1060
+				)
1061
+				: array();
1062
+			// if there are no related tickets this is likely a new event OR autodraft
1063
+			// event so we need to generate the default tickets because datetimes
1064
+			// ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
1065
+			// datetime on the event.
1066
+			if (empty($related_tickets) && count($datetimes) < 2) {
1067
+				/** @var EEM_Ticket $ticket_model */
1068
+				$ticket_model = EE_Registry::instance()->load_model('Ticket');
1069
+				$related_tickets = $ticket_model->get_all_default_tickets();
1070
+				// this should be ordered by TKT_ID, so let's grab the first default ticket
1071
+				// (which will be the main default) and ensure it has any default prices added to it (but do NOT save).
1072
+				$default_prices = EEM_Price::instance()->get_all_default_prices();
1073
+				$main_default_ticket = reset($related_tickets);
1074
+				if ($main_default_ticket instanceof EE_Ticket) {
1075
+					foreach ($default_prices as $default_price) {
1076
+						if ($default_price instanceof EE_Price && $default_price->is_base_price()) {
1077
+							continue;
1078
+						}
1079
+						$main_default_ticket->cache('Price', $default_price);
1080
+					}
1081
+				}
1082
+			}
1083
+			// we can't actually setup rows in this loop yet cause we don't know all
1084
+			// the unique tickets for this event yet (tickets are linked through all datetimes).
1085
+			// So we're going to temporarily cache some of that information.
1086
+			// loop through and setup the ticket rows and make sure the order is set.
1087
+			foreach ($related_tickets as $ticket) {
1088
+				$TKT_ID = $ticket->get('TKT_ID');
1089
+				$ticket_row = $ticket->get('TKT_row');
1090
+				// we only want unique tickets in our final display!!
1091
+				if (! in_array($TKT_ID, $existing_ticket_ids, true)) {
1092
+					$existing_ticket_ids[] = $TKT_ID;
1093
+					$all_tickets[] = $ticket;
1094
+				}
1095
+				// temporary cache of this ticket info for this datetime for later processing of datetime rows.
1096
+				$datetime_tickets[ $DTT_ID ][] = $ticket_row;
1097
+				// temporary cache of this datetime info for this ticket for later processing of ticket rows.
1098
+				if (
1099
+					! isset($ticket_datetimes[ $TKT_ID ])
1100
+					|| ! in_array($datetime_row, $ticket_datetimes[ $TKT_ID ], true)
1101
+				) {
1102
+					$ticket_datetimes[ $TKT_ID ][] = $datetime_row;
1103
+				}
1104
+			}
1105
+			$datetime_row++;
1106
+		}
1107
+		$main_template_args['total_ticket_rows'] = count($existing_ticket_ids);
1108
+		$main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1109
+		$main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1110
+		// sort $all_tickets by order
1111
+		usort(
1112
+			$all_tickets,
1113
+			function (EE_Ticket $a, EE_Ticket $b) {
1114
+				$a_order = (int) $a->get('TKT_order');
1115
+				$b_order = (int) $b->get('TKT_order');
1116
+				if ($a_order === $b_order) {
1117
+					return 0;
1118
+				}
1119
+				return ($a_order < $b_order) ? -1 : 1;
1120
+			}
1121
+		);
1122
+		// k NOW we have all the data we need for setting up the dtt rows
1123
+		// and ticket rows so we start our dtt loop again.
1124
+		$datetime_row = 1;
1125
+		foreach ($datetimes as $datetime) {
1126
+			$main_template_args['datetime_rows'] .= $this->_get_datetime_row(
1127
+				$datetime_row,
1128
+				$datetime,
1129
+				$datetime_tickets,
1130
+				$all_tickets,
1131
+				false,
1132
+				$datetimes
1133
+			);
1134
+			$datetime_row++;
1135
+		}
1136
+		// then loop through all tickets for the ticket rows.
1137
+		$ticket_row = 1;
1138
+		foreach ($all_tickets as $ticket) {
1139
+			$main_template_args['ticket_rows'] .= $this->_get_ticket_row(
1140
+				$ticket_row,
1141
+				$ticket,
1142
+				$ticket_datetimes,
1143
+				$datetimes,
1144
+				false,
1145
+				$all_tickets
1146
+			);
1147
+			$ticket_row++;
1148
+		}
1149
+		$main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($datetimes, $all_tickets);
1150
+		EEH_Template::display_template(
1151
+			PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php',
1152
+			$main_template_args
1153
+		);
1154
+	}
1155 1155
 
1156 1156
 
1157
-    /**
1158
-     * @param int         $datetime_row
1159
-     * @param EE_Datetime $datetime
1160
-     * @param array       $datetime_tickets
1161
-     * @param array       $all_tickets
1162
-     * @param bool        $default
1163
-     * @param array       $all_datetimes
1164
-     * @return mixed
1165
-     * @throws DomainException
1166
-     * @throws EE_Error
1167
-     */
1168
-    protected function _get_datetime_row(
1169
-        $datetime_row,
1170
-        EE_Datetime $datetime,
1171
-        $datetime_tickets = array(),
1172
-        $all_tickets = array(),
1173
-        $default = false,
1174
-        $all_datetimes = array()
1175
-    ) {
1176
-        $dtt_display_template_args = array(
1177
-            'dtt_edit_row'             => $this->_get_dtt_edit_row(
1178
-                $datetime_row,
1179
-                $datetime,
1180
-                $default,
1181
-                $all_datetimes
1182
-            ),
1183
-            'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row(
1184
-                $datetime_row,
1185
-                $datetime,
1186
-                $datetime_tickets,
1187
-                $all_tickets,
1188
-                $default
1189
-            ),
1190
-            'dtt_row'                  => $default ? 'DTTNUM' : $datetime_row,
1191
-        );
1192
-        return EEH_Template::display_template(
1193
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php',
1194
-            $dtt_display_template_args,
1195
-            true
1196
-        );
1197
-    }
1157
+	/**
1158
+	 * @param int         $datetime_row
1159
+	 * @param EE_Datetime $datetime
1160
+	 * @param array       $datetime_tickets
1161
+	 * @param array       $all_tickets
1162
+	 * @param bool        $default
1163
+	 * @param array       $all_datetimes
1164
+	 * @return mixed
1165
+	 * @throws DomainException
1166
+	 * @throws EE_Error
1167
+	 */
1168
+	protected function _get_datetime_row(
1169
+		$datetime_row,
1170
+		EE_Datetime $datetime,
1171
+		$datetime_tickets = array(),
1172
+		$all_tickets = array(),
1173
+		$default = false,
1174
+		$all_datetimes = array()
1175
+	) {
1176
+		$dtt_display_template_args = array(
1177
+			'dtt_edit_row'             => $this->_get_dtt_edit_row(
1178
+				$datetime_row,
1179
+				$datetime,
1180
+				$default,
1181
+				$all_datetimes
1182
+			),
1183
+			'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row(
1184
+				$datetime_row,
1185
+				$datetime,
1186
+				$datetime_tickets,
1187
+				$all_tickets,
1188
+				$default
1189
+			),
1190
+			'dtt_row'                  => $default ? 'DTTNUM' : $datetime_row,
1191
+		);
1192
+		return EEH_Template::display_template(
1193
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php',
1194
+			$dtt_display_template_args,
1195
+			true
1196
+		);
1197
+	}
1198 1198
 
1199 1199
 
1200
-    /**
1201
-     * This method is used to generate a dtt fields  edit row.
1202
-     * The same row is used to generate a row with valid DTT objects
1203
-     * and the default row that is used as the skeleton by the js.
1204
-     *
1205
-     * @param int           $datetime_row  The row number for the row being generated.
1206
-     * @param EE_Datetime   $datetime
1207
-     * @param bool          $default       Whether a default row is being generated or not.
1208
-     * @param EE_Datetime[] $all_datetimes This is the array of all datetimes used in the editor.
1209
-     * @return string
1210
-     * @throws DomainException
1211
-     * @throws EE_Error
1212
-     */
1213
-    protected function _get_dtt_edit_row($datetime_row, $datetime, $default, $all_datetimes)
1214
-    {
1215
-        // if the incoming $datetime object is NOT an instance of EE_Datetime then force default to true.
1216
-        $default = ! $datetime instanceof EE_Datetime ? true : $default;
1217
-        $template_args = array(
1218
-            'dtt_row'              => $default ? 'DTTNUM' : $datetime_row,
1219
-            'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1220
-            'edit_dtt_expanded'    => '',
1221
-            'DTT_ID'               => $default ? '' : $datetime->ID(),
1222
-            'DTT_name'             => $default ? '' : $datetime->get_f('DTT_name'),
1223
-            'DTT_description'      => $default ? '' : $datetime->get_f('DTT_description'),
1224
-            'DTT_EVT_start'        => $default ? '' : $datetime->start_date($this->_date_time_format),
1225
-            'DTT_EVT_end'          => $default ? '' : $datetime->end_date($this->_date_time_format),
1226
-            'DTT_reg_limit'        => $default
1227
-                ? ''
1228
-                : $datetime->get_pretty(
1229
-                    'DTT_reg_limit',
1230
-                    'input'
1231
-                ),
1232
-            'DTT_order'            => $default ? 'DTTNUM' : $datetime_row,
1233
-            'dtt_sold'             => $default ? '0' : $datetime->get('DTT_sold'),
1234
-            'dtt_reserved'         => $default ? '0' : $datetime->reserved(),
1235
-            'clone_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1236
-                ? ''
1237
-                : 'clone-icon ee-icon ee-icon-clone clickable',
1238
-            'trash_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1239
-                ? 'ee-lock-icon'
1240
-                : 'trash-icon dashicons dashicons-post-trash clickable',
1241
-            'reg_list_url'         => $default || ! $datetime->event() instanceof \EE_Event
1242
-                ? ''
1243
-                : EE_Admin_Page::add_query_args_and_nonce(
1244
-                    array('event_id' => $datetime->event()->ID(), 'datetime_id' => $datetime->ID()),
1245
-                    REG_ADMIN_URL
1246
-                ),
1247
-        );
1248
-        $template_args['show_trash'] = count($all_datetimes) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon'
1249
-            ? ' style="display:none"'
1250
-            : '';
1251
-        // allow filtering of template args at this point.
1252
-        $template_args = apply_filters(
1253
-            'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args',
1254
-            $template_args,
1255
-            $datetime_row,
1256
-            $datetime,
1257
-            $default,
1258
-            $all_datetimes,
1259
-            $this->_is_creating_event
1260
-        );
1261
-        return EEH_Template::display_template(
1262
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php',
1263
-            $template_args,
1264
-            true
1265
-        );
1266
-    }
1200
+	/**
1201
+	 * This method is used to generate a dtt fields  edit row.
1202
+	 * The same row is used to generate a row with valid DTT objects
1203
+	 * and the default row that is used as the skeleton by the js.
1204
+	 *
1205
+	 * @param int           $datetime_row  The row number for the row being generated.
1206
+	 * @param EE_Datetime   $datetime
1207
+	 * @param bool          $default       Whether a default row is being generated or not.
1208
+	 * @param EE_Datetime[] $all_datetimes This is the array of all datetimes used in the editor.
1209
+	 * @return string
1210
+	 * @throws DomainException
1211
+	 * @throws EE_Error
1212
+	 */
1213
+	protected function _get_dtt_edit_row($datetime_row, $datetime, $default, $all_datetimes)
1214
+	{
1215
+		// if the incoming $datetime object is NOT an instance of EE_Datetime then force default to true.
1216
+		$default = ! $datetime instanceof EE_Datetime ? true : $default;
1217
+		$template_args = array(
1218
+			'dtt_row'              => $default ? 'DTTNUM' : $datetime_row,
1219
+			'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1220
+			'edit_dtt_expanded'    => '',
1221
+			'DTT_ID'               => $default ? '' : $datetime->ID(),
1222
+			'DTT_name'             => $default ? '' : $datetime->get_f('DTT_name'),
1223
+			'DTT_description'      => $default ? '' : $datetime->get_f('DTT_description'),
1224
+			'DTT_EVT_start'        => $default ? '' : $datetime->start_date($this->_date_time_format),
1225
+			'DTT_EVT_end'          => $default ? '' : $datetime->end_date($this->_date_time_format),
1226
+			'DTT_reg_limit'        => $default
1227
+				? ''
1228
+				: $datetime->get_pretty(
1229
+					'DTT_reg_limit',
1230
+					'input'
1231
+				),
1232
+			'DTT_order'            => $default ? 'DTTNUM' : $datetime_row,
1233
+			'dtt_sold'             => $default ? '0' : $datetime->get('DTT_sold'),
1234
+			'dtt_reserved'         => $default ? '0' : $datetime->reserved(),
1235
+			'clone_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1236
+				? ''
1237
+				: 'clone-icon ee-icon ee-icon-clone clickable',
1238
+			'trash_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1239
+				? 'ee-lock-icon'
1240
+				: 'trash-icon dashicons dashicons-post-trash clickable',
1241
+			'reg_list_url'         => $default || ! $datetime->event() instanceof \EE_Event
1242
+				? ''
1243
+				: EE_Admin_Page::add_query_args_and_nonce(
1244
+					array('event_id' => $datetime->event()->ID(), 'datetime_id' => $datetime->ID()),
1245
+					REG_ADMIN_URL
1246
+				),
1247
+		);
1248
+		$template_args['show_trash'] = count($all_datetimes) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon'
1249
+			? ' style="display:none"'
1250
+			: '';
1251
+		// allow filtering of template args at this point.
1252
+		$template_args = apply_filters(
1253
+			'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args',
1254
+			$template_args,
1255
+			$datetime_row,
1256
+			$datetime,
1257
+			$default,
1258
+			$all_datetimes,
1259
+			$this->_is_creating_event
1260
+		);
1261
+		return EEH_Template::display_template(
1262
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php',
1263
+			$template_args,
1264
+			true
1265
+		);
1266
+	}
1267 1267
 
1268 1268
 
1269
-    /**
1270
-     * @param int         $datetime_row
1271
-     * @param EE_Datetime $datetime
1272
-     * @param array       $datetime_tickets
1273
-     * @param array       $all_tickets
1274
-     * @param bool        $default
1275
-     * @return mixed
1276
-     * @throws DomainException
1277
-     * @throws EE_Error
1278
-     */
1279
-    protected function _get_dtt_attached_tickets_row(
1280
-        $datetime_row,
1281
-        $datetime,
1282
-        $datetime_tickets = array(),
1283
-        $all_tickets = array(),
1284
-        $default
1285
-    ) {
1286
-        $template_args = array(
1287
-            'dtt_row'                           => $default ? 'DTTNUM' : $datetime_row,
1288
-            'event_datetimes_name'              => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1289
-            'DTT_description'                   => $default ? '' : $datetime->get_f('DTT_description'),
1290
-            'datetime_tickets_list'             => $default ? '<li class="hidden"></li>' : '',
1291
-            'show_tickets_row'                  => ' style="display:none;"',
1292
-            'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link(
1293
-                'add_new_ticket_via_datetime',
1294
-                $this->_adminpage_obj->page_slug,
1295
-                $this->_adminpage_obj->get_req_action(),
1296
-                false,
1297
-                false
1298
-            ),
1299
-            // todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1300
-            'DTT_ID'                            => $default ? '' : $datetime->ID(),
1301
-        );
1302
-        // need to setup the list items (but only if this isn't a default skeleton setup)
1303
-        if (! $default) {
1304
-            $ticket_row = 1;
1305
-            foreach ($all_tickets as $ticket) {
1306
-                $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
1307
-                    $datetime_row,
1308
-                    $ticket_row,
1309
-                    $datetime,
1310
-                    $ticket,
1311
-                    $datetime_tickets,
1312
-                    $default
1313
-                );
1314
-                $ticket_row++;
1315
-            }
1316
-        }
1317
-        // filter template args at this point
1318
-        $template_args = apply_filters(
1319
-            'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args',
1320
-            $template_args,
1321
-            $datetime_row,
1322
-            $datetime,
1323
-            $datetime_tickets,
1324
-            $all_tickets,
1325
-            $default,
1326
-            $this->_is_creating_event
1327
-        );
1328
-        return EEH_Template::display_template(
1329
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php',
1330
-            $template_args,
1331
-            true
1332
-        );
1333
-    }
1269
+	/**
1270
+	 * @param int         $datetime_row
1271
+	 * @param EE_Datetime $datetime
1272
+	 * @param array       $datetime_tickets
1273
+	 * @param array       $all_tickets
1274
+	 * @param bool        $default
1275
+	 * @return mixed
1276
+	 * @throws DomainException
1277
+	 * @throws EE_Error
1278
+	 */
1279
+	protected function _get_dtt_attached_tickets_row(
1280
+		$datetime_row,
1281
+		$datetime,
1282
+		$datetime_tickets = array(),
1283
+		$all_tickets = array(),
1284
+		$default
1285
+	) {
1286
+		$template_args = array(
1287
+			'dtt_row'                           => $default ? 'DTTNUM' : $datetime_row,
1288
+			'event_datetimes_name'              => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1289
+			'DTT_description'                   => $default ? '' : $datetime->get_f('DTT_description'),
1290
+			'datetime_tickets_list'             => $default ? '<li class="hidden"></li>' : '',
1291
+			'show_tickets_row'                  => ' style="display:none;"',
1292
+			'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link(
1293
+				'add_new_ticket_via_datetime',
1294
+				$this->_adminpage_obj->page_slug,
1295
+				$this->_adminpage_obj->get_req_action(),
1296
+				false,
1297
+				false
1298
+			),
1299
+			// todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1300
+			'DTT_ID'                            => $default ? '' : $datetime->ID(),
1301
+		);
1302
+		// need to setup the list items (but only if this isn't a default skeleton setup)
1303
+		if (! $default) {
1304
+			$ticket_row = 1;
1305
+			foreach ($all_tickets as $ticket) {
1306
+				$template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
1307
+					$datetime_row,
1308
+					$ticket_row,
1309
+					$datetime,
1310
+					$ticket,
1311
+					$datetime_tickets,
1312
+					$default
1313
+				);
1314
+				$ticket_row++;
1315
+			}
1316
+		}
1317
+		// filter template args at this point
1318
+		$template_args = apply_filters(
1319
+			'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args',
1320
+			$template_args,
1321
+			$datetime_row,
1322
+			$datetime,
1323
+			$datetime_tickets,
1324
+			$all_tickets,
1325
+			$default,
1326
+			$this->_is_creating_event
1327
+		);
1328
+		return EEH_Template::display_template(
1329
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php',
1330
+			$template_args,
1331
+			true
1332
+		);
1333
+	}
1334 1334
 
1335 1335
 
1336
-    /**
1337
-     * @param int         $datetime_row
1338
-     * @param int         $ticket_row
1339
-     * @param EE_Datetime $datetime
1340
-     * @param EE_Ticket   $ticket
1341
-     * @param array       $datetime_tickets
1342
-     * @param bool        $default
1343
-     * @return mixed
1344
-     * @throws DomainException
1345
-     * @throws EE_Error
1346
-     */
1347
-    protected function _get_datetime_tickets_list_item(
1348
-        $datetime_row,
1349
-        $ticket_row,
1350
-        $datetime,
1351
-        $ticket,
1352
-        $datetime_tickets = array(),
1353
-        $default
1354
-    ) {
1355
-        $dtt_tkts = $datetime instanceof EE_Datetime && isset($datetime_tickets[ $datetime->ID() ])
1356
-            ? $datetime_tickets[ $datetime->ID() ]
1357
-            : array();
1358
-        $display_row = $ticket instanceof EE_Ticket ? $ticket->get('TKT_row') : 0;
1359
-        $no_ticket = $default && empty($ticket);
1360
-        $template_args = array(
1361
-            'dtt_row'                 => $default
1362
-                ? 'DTTNUM'
1363
-                : $datetime_row,
1364
-            'tkt_row'                 => $no_ticket
1365
-                ? 'TICKETNUM'
1366
-                : $ticket_row,
1367
-            'datetime_ticket_checked' => in_array($display_row, $dtt_tkts, true)
1368
-                ? ' checked'
1369
-                : '',
1370
-            'ticket_selected'         => in_array($display_row, $dtt_tkts, true)
1371
-                ? ' ticket-selected'
1372
-                : '',
1373
-            'TKT_name'                => $no_ticket
1374
-                ? 'TKTNAME'
1375
-                : $ticket->get('TKT_name'),
1376
-            'tkt_status_class'        => $no_ticket || $this->_is_creating_event
1377
-                ? ' tkt-status-' . EE_Ticket::onsale
1378
-                : ' tkt-status-' . $ticket->ticket_status(),
1379
-        );
1380
-        // filter template args
1381
-        $template_args = apply_filters(
1382
-            'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args',
1383
-            $template_args,
1384
-            $datetime_row,
1385
-            $ticket_row,
1386
-            $datetime,
1387
-            $ticket,
1388
-            $datetime_tickets,
1389
-            $default,
1390
-            $this->_is_creating_event
1391
-        );
1392
-        return EEH_Template::display_template(
1393
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php',
1394
-            $template_args,
1395
-            true
1396
-        );
1397
-    }
1336
+	/**
1337
+	 * @param int         $datetime_row
1338
+	 * @param int         $ticket_row
1339
+	 * @param EE_Datetime $datetime
1340
+	 * @param EE_Ticket   $ticket
1341
+	 * @param array       $datetime_tickets
1342
+	 * @param bool        $default
1343
+	 * @return mixed
1344
+	 * @throws DomainException
1345
+	 * @throws EE_Error
1346
+	 */
1347
+	protected function _get_datetime_tickets_list_item(
1348
+		$datetime_row,
1349
+		$ticket_row,
1350
+		$datetime,
1351
+		$ticket,
1352
+		$datetime_tickets = array(),
1353
+		$default
1354
+	) {
1355
+		$dtt_tkts = $datetime instanceof EE_Datetime && isset($datetime_tickets[ $datetime->ID() ])
1356
+			? $datetime_tickets[ $datetime->ID() ]
1357
+			: array();
1358
+		$display_row = $ticket instanceof EE_Ticket ? $ticket->get('TKT_row') : 0;
1359
+		$no_ticket = $default && empty($ticket);
1360
+		$template_args = array(
1361
+			'dtt_row'                 => $default
1362
+				? 'DTTNUM'
1363
+				: $datetime_row,
1364
+			'tkt_row'                 => $no_ticket
1365
+				? 'TICKETNUM'
1366
+				: $ticket_row,
1367
+			'datetime_ticket_checked' => in_array($display_row, $dtt_tkts, true)
1368
+				? ' checked'
1369
+				: '',
1370
+			'ticket_selected'         => in_array($display_row, $dtt_tkts, true)
1371
+				? ' ticket-selected'
1372
+				: '',
1373
+			'TKT_name'                => $no_ticket
1374
+				? 'TKTNAME'
1375
+				: $ticket->get('TKT_name'),
1376
+			'tkt_status_class'        => $no_ticket || $this->_is_creating_event
1377
+				? ' tkt-status-' . EE_Ticket::onsale
1378
+				: ' tkt-status-' . $ticket->ticket_status(),
1379
+		);
1380
+		// filter template args
1381
+		$template_args = apply_filters(
1382
+			'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args',
1383
+			$template_args,
1384
+			$datetime_row,
1385
+			$ticket_row,
1386
+			$datetime,
1387
+			$ticket,
1388
+			$datetime_tickets,
1389
+			$default,
1390
+			$this->_is_creating_event
1391
+		);
1392
+		return EEH_Template::display_template(
1393
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php',
1394
+			$template_args,
1395
+			true
1396
+		);
1397
+	}
1398 1398
 
1399 1399
 
1400
-    /**
1401
-     * This generates the ticket row for tickets.
1402
-     * This same method is used to generate both the actual rows and the js skeleton row
1403
-     * (when default === true)
1404
-     *
1405
-     * @param int           $ticket_row       Represents the row number being generated.
1406
-     * @param               $ticket
1407
-     * @param EE_Datetime[] $ticket_datetimes Either an array of all datetimes on all tickets indexed by each ticket
1408
-     *                                        or empty for default
1409
-     * @param EE_Datetime[] $all_datetimes    All Datetimes on the event or empty for default.
1410
-     * @param bool          $default          Whether default row being generated or not.
1411
-     * @param EE_Ticket[]   $all_tickets      This is an array of all tickets attached to the event
1412
-     *                                        (or empty in the case of defaults)
1413
-     * @return mixed
1414
-     * @throws InvalidArgumentException
1415
-     * @throws InvalidInterfaceException
1416
-     * @throws InvalidDataTypeException
1417
-     * @throws DomainException
1418
-     * @throws EE_Error
1419
-     * @throws ReflectionException
1420
-     */
1421
-    protected function _get_ticket_row(
1422
-        $ticket_row,
1423
-        $ticket,
1424
-        $ticket_datetimes,
1425
-        $all_datetimes,
1426
-        $default = false,
1427
-        $all_tickets = array()
1428
-    ) {
1429
-        // if $ticket is not an instance of EE_Ticket then force default to true.
1430
-        $default = ! $ticket instanceof EE_Ticket ? true : $default;
1431
-        $prices = ! empty($ticket) && ! $default
1432
-            ? $ticket->get_many_related(
1433
-                'Price',
1434
-                array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))
1435
-            )
1436
-            : array();
1437
-        // if there is only one price (which would be the base price)
1438
-        // or NO prices and this ticket is a default ticket,
1439
-        // let's just make sure there are no cached default prices on the object.
1440
-        // This is done by not including any query_params.
1441
-        if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) {
1442
-            $prices = $ticket->prices();
1443
-        }
1444
-        // check if we're dealing with a default ticket in which case
1445
-        // we don't want any starting_ticket_datetime_row values set
1446
-        // (otherwise there won't be any new relationships created for tickets based off of the default ticket).
1447
-        // This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1448
-        $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->is_default());
1449
-        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
1450
-            ? $ticket_datetimes[ $ticket->ID() ]
1451
-            : array();
1452
-        $ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal();
1453
-        $base_price = $default ? null : $ticket->base_price();
1454
-        $count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1455
-        // breaking out complicated condition for ticket_status
1456
-        if ($default) {
1457
-            $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1458
-        } else {
1459
-            $ticket_status_class = $ticket->is_default()
1460
-                ? ' tkt-status-' . EE_Ticket::onsale
1461
-                : ' tkt-status-' . $ticket->ticket_status();
1462
-        }
1463
-        // breaking out complicated condition for TKT_taxable
1464
-        if ($default) {
1465
-            $TKT_taxable = '';
1466
-        } else {
1467
-            $TKT_taxable = $ticket->taxable()
1468
-                ? ' checked'
1469
-                : '';
1470
-        }
1471
-        if ($default) {
1472
-            $TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1473
-        } elseif ($ticket->is_default()) {
1474
-            $TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1475
-        } else {
1476
-            $TKT_status = $ticket->ticket_status(true);
1477
-        }
1478
-        if ($default) {
1479
-            $TKT_min = '';
1480
-        } else {
1481
-            $TKT_min = $ticket->min();
1482
-            if ($TKT_min === -1 || $TKT_min === 0) {
1483
-                $TKT_min = '';
1484
-            }
1485
-        }
1486
-        $template_args = array(
1487
-            'tkt_row'                       => $default ? 'TICKETNUM' : $ticket_row,
1488
-            'TKT_order'                     => $default ? 'TICKETNUM' : $ticket_row,
1489
-            // on initial page load this will always be the correct order.
1490
-            'tkt_status_class'              => $ticket_status_class,
1491
-            'display_edit_tkt_row'          => ' style="display:none;"',
1492
-            'edit_tkt_expanded'             => '',
1493
-            'edit_tickets_name'             => $default ? 'TICKETNAMEATTR' : 'edit_tickets',
1494
-            'TKT_name'                      => $default ? '' : $ticket->get_f('TKT_name'),
1495
-            'TKT_start_date'                => $default
1496
-                ? ''
1497
-                : $ticket->get_date('TKT_start_date', $this->_date_time_format),
1498
-            'TKT_end_date'                  => $default
1499
-                ? ''
1500
-                : $ticket->get_date('TKT_end_date', $this->_date_time_format),
1501
-            'TKT_status'                    => $TKT_status,
1502
-            'TKT_price'                     => $default
1503
-                ? ''
1504
-                : EEH_Template::format_currency(
1505
-                    $ticket->get_ticket_total_with_taxes(),
1506
-                    false,
1507
-                    false
1508
-                ),
1509
-            'TKT_price_code'                => EE_Registry::instance()->CFG->currency->code,
1510
-            'TKT_price_amount'              => $default ? 0 : $ticket_subtotal,
1511
-            'TKT_qty'                       => $default
1512
-                ? ''
1513
-                : $ticket->get_pretty('TKT_qty', 'symbol'),
1514
-            'TKT_qty_for_input'             => $default
1515
-                ? ''
1516
-                : $ticket->get_pretty('TKT_qty', 'input'),
1517
-            'TKT_uses'                      => $default
1518
-                ? ''
1519
-                : $ticket->get_pretty('TKT_uses', 'input'),
1520
-            'TKT_min'                       => $TKT_min,
1521
-            'TKT_max'                       => $default
1522
-                ? ''
1523
-                : $ticket->get_pretty('TKT_max', 'input'),
1524
-            'TKT_sold'                      => $default ? 0 : $ticket->tickets_sold('ticket'),
1525
-            'TKT_reserved'                  => $default ? 0 : $ticket->reserved(),
1526
-            'TKT_registrations'             => $default
1527
-                ? 0
1528
-                : $ticket->count_registrations(
1529
-                    array(
1530
-                        array(
1531
-                            'STS_ID' => array(
1532
-                                '!=',
1533
-                                EEM_Registration::status_id_incomplete,
1534
-                            ),
1535
-                        ),
1536
-                    )
1537
-                ),
1538
-            'TKT_ID'                        => $default ? 0 : $ticket->ID(),
1539
-            'TKT_description'               => $default ? '' : $ticket->get_f('TKT_description'),
1540
-            'TKT_is_default'                => $default ? 0 : $ticket->is_default(),
1541
-            'TKT_required'                  => $default ? 0 : $ticket->required(),
1542
-            'TKT_is_default_selector'       => '',
1543
-            'ticket_price_rows'             => '',
1544
-            'TKT_base_price'                => $default || ! $base_price instanceof EE_Price
1545
-                ? ''
1546
-                : $base_price->get_pretty('PRC_amount', 'localized_float'),
1547
-            'TKT_base_price_ID'             => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(),
1548
-            'show_price_modifier'           => count($prices) > 1 || ($default && $count_price_mods > 0)
1549
-                ? ''
1550
-                : ' style="display:none;"',
1551
-            'show_price_mod_button'         => count($prices) > 1
1552
-                                               || ($default && $count_price_mods > 0)
1553
-                                               || (! $default && $ticket->deleted())
1554
-                ? ' style="display:none;"'
1555
-                : '',
1556
-            'total_price_rows'              => count($prices) > 1 ? count($prices) : 1,
1557
-            'ticket_datetimes_list'         => $default ? '<li class="hidden"></li>' : '',
1558
-            'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_datetimes),
1559
-            'ticket_datetime_rows'          => $default ? '' : implode(',', $tkt_datetimes),
1560
-            'existing_ticket_price_ids'     => $default ? '' : implode(',', array_keys($prices)),
1561
-            'ticket_template_id'            => $default ? 0 : $ticket->get('TTM_ID'),
1562
-            'TKT_taxable'                   => $TKT_taxable,
1563
-            'display_subtotal'              => $ticket instanceof EE_Ticket && $ticket->taxable()
1564
-                ? ''
1565
-                : ' style="display:none"',
1566
-            'price_currency_symbol'         => EE_Registry::instance()->CFG->currency->sign,
1567
-            'TKT_subtotal_amount_display'   => EEH_Template::format_currency(
1568
-                $ticket_subtotal,
1569
-                false,
1570
-                false
1571
-            ),
1572
-            'TKT_subtotal_amount'           => $ticket_subtotal,
1573
-            'tax_rows'                      => $this->_get_tax_rows($ticket_row, $ticket),
1574
-            'disabled'                      => $ticket instanceof EE_Ticket && $ticket->deleted(),
1575
-            'ticket_archive_class'          => $ticket instanceof EE_Ticket && $ticket->deleted()
1576
-                ? ' ticket-archived'
1577
-                : '',
1578
-            'trash_icon'                    => $ticket instanceof EE_Ticket
1579
-                                               && $ticket->deleted()
1580
-                                               && ! $ticket->is_permanently_deleteable()
1581
-                ? 'ee-lock-icon '
1582
-                : 'trash-icon dashicons dashicons-post-trash clickable',
1583
-            'clone_icon'                    => $ticket instanceof EE_Ticket && $ticket->deleted()
1584
-                ? ''
1585
-                : 'clone-icon ee-icon ee-icon-clone clickable',
1586
-        );
1587
-        $template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon'
1588
-            ? ' style="display:none"'
1589
-            : '';
1590
-        // handle rows that should NOT be empty
1591
-        if (empty($template_args['TKT_start_date'])) {
1592
-            // if empty then the start date will be now.
1593
-            $template_args['TKT_start_date'] = date(
1594
-                $this->_date_time_format,
1595
-                current_time('timestamp')
1596
-            );
1597
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1598
-        }
1599
-        if (empty($template_args['TKT_end_date'])) {
1600
-            // get the earliest datetime (if present);
1601
-            $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0
1602
-                ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related(
1603
-                    'Datetime',
1604
-                    array('order_by' => array('DTT_EVT_start' => 'ASC'))
1605
-                )
1606
-                : null;
1607
-            if (! empty($earliest_dtt)) {
1608
-                $template_args['TKT_end_date'] = $earliest_dtt->get_datetime(
1609
-                    'DTT_EVT_start',
1610
-                    $this->_date_time_format
1611
-                );
1612
-            } else {
1613
-                // default so let's just use what's been set for the default date-time which is 30 days from now.
1614
-                $template_args['TKT_end_date'] = date(
1615
-                    $this->_date_time_format,
1616
-                    mktime(
1617
-                        24,
1618
-                        0,
1619
-                        0,
1620
-                        date('m'),
1621
-                        date('d') + 29,
1622
-                        date('Y')
1623
-                    )
1624
-                );
1625
-            }
1626
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1627
-        }
1628
-        // generate ticket_datetime items
1629
-        if (! $default) {
1630
-            $datetime_row = 1;
1631
-            foreach ($all_datetimes as $datetime) {
1632
-                $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
1633
-                    $datetime_row,
1634
-                    $ticket_row,
1635
-                    $datetime,
1636
-                    $ticket,
1637
-                    $ticket_datetimes,
1638
-                    $default
1639
-                );
1640
-                $datetime_row++;
1641
-            }
1642
-        }
1643
-        $price_row = 1;
1644
-        foreach ($prices as $price) {
1645
-            if (! $price instanceof EE_Price) {
1646
-                continue;
1647
-            }
1648
-            if ($price->is_base_price()) {
1649
-                $price_row++;
1650
-                continue;
1651
-            }
1652
-            $show_trash = ! ((count($prices) > 1 && $price_row === 1) || count($prices) === 1);
1653
-            $show_create = ! (count($prices) > 1 && count($prices) !== $price_row);
1654
-            $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row(
1655
-                $ticket_row,
1656
-                $price_row,
1657
-                $price,
1658
-                $default,
1659
-                $ticket,
1660
-                $show_trash,
1661
-                $show_create
1662
-            );
1663
-            $price_row++;
1664
-        }
1665
-        // filter $template_args
1666
-        $template_args = apply_filters(
1667
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args',
1668
-            $template_args,
1669
-            $ticket_row,
1670
-            $ticket,
1671
-            $ticket_datetimes,
1672
-            $all_datetimes,
1673
-            $default,
1674
-            $all_tickets,
1675
-            $this->_is_creating_event
1676
-        );
1677
-        return EEH_Template::display_template(
1678
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php',
1679
-            $template_args,
1680
-            true
1681
-        );
1682
-    }
1400
+	/**
1401
+	 * This generates the ticket row for tickets.
1402
+	 * This same method is used to generate both the actual rows and the js skeleton row
1403
+	 * (when default === true)
1404
+	 *
1405
+	 * @param int           $ticket_row       Represents the row number being generated.
1406
+	 * @param               $ticket
1407
+	 * @param EE_Datetime[] $ticket_datetimes Either an array of all datetimes on all tickets indexed by each ticket
1408
+	 *                                        or empty for default
1409
+	 * @param EE_Datetime[] $all_datetimes    All Datetimes on the event or empty for default.
1410
+	 * @param bool          $default          Whether default row being generated or not.
1411
+	 * @param EE_Ticket[]   $all_tickets      This is an array of all tickets attached to the event
1412
+	 *                                        (or empty in the case of defaults)
1413
+	 * @return mixed
1414
+	 * @throws InvalidArgumentException
1415
+	 * @throws InvalidInterfaceException
1416
+	 * @throws InvalidDataTypeException
1417
+	 * @throws DomainException
1418
+	 * @throws EE_Error
1419
+	 * @throws ReflectionException
1420
+	 */
1421
+	protected function _get_ticket_row(
1422
+		$ticket_row,
1423
+		$ticket,
1424
+		$ticket_datetimes,
1425
+		$all_datetimes,
1426
+		$default = false,
1427
+		$all_tickets = array()
1428
+	) {
1429
+		// if $ticket is not an instance of EE_Ticket then force default to true.
1430
+		$default = ! $ticket instanceof EE_Ticket ? true : $default;
1431
+		$prices = ! empty($ticket) && ! $default
1432
+			? $ticket->get_many_related(
1433
+				'Price',
1434
+				array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))
1435
+			)
1436
+			: array();
1437
+		// if there is only one price (which would be the base price)
1438
+		// or NO prices and this ticket is a default ticket,
1439
+		// let's just make sure there are no cached default prices on the object.
1440
+		// This is done by not including any query_params.
1441
+		if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) {
1442
+			$prices = $ticket->prices();
1443
+		}
1444
+		// check if we're dealing with a default ticket in which case
1445
+		// we don't want any starting_ticket_datetime_row values set
1446
+		// (otherwise there won't be any new relationships created for tickets based off of the default ticket).
1447
+		// This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1448
+		$default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->is_default());
1449
+		$tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
1450
+			? $ticket_datetimes[ $ticket->ID() ]
1451
+			: array();
1452
+		$ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal();
1453
+		$base_price = $default ? null : $ticket->base_price();
1454
+		$count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1455
+		// breaking out complicated condition for ticket_status
1456
+		if ($default) {
1457
+			$ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1458
+		} else {
1459
+			$ticket_status_class = $ticket->is_default()
1460
+				? ' tkt-status-' . EE_Ticket::onsale
1461
+				: ' tkt-status-' . $ticket->ticket_status();
1462
+		}
1463
+		// breaking out complicated condition for TKT_taxable
1464
+		if ($default) {
1465
+			$TKT_taxable = '';
1466
+		} else {
1467
+			$TKT_taxable = $ticket->taxable()
1468
+				? ' checked'
1469
+				: '';
1470
+		}
1471
+		if ($default) {
1472
+			$TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1473
+		} elseif ($ticket->is_default()) {
1474
+			$TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1475
+		} else {
1476
+			$TKT_status = $ticket->ticket_status(true);
1477
+		}
1478
+		if ($default) {
1479
+			$TKT_min = '';
1480
+		} else {
1481
+			$TKT_min = $ticket->min();
1482
+			if ($TKT_min === -1 || $TKT_min === 0) {
1483
+				$TKT_min = '';
1484
+			}
1485
+		}
1486
+		$template_args = array(
1487
+			'tkt_row'                       => $default ? 'TICKETNUM' : $ticket_row,
1488
+			'TKT_order'                     => $default ? 'TICKETNUM' : $ticket_row,
1489
+			// on initial page load this will always be the correct order.
1490
+			'tkt_status_class'              => $ticket_status_class,
1491
+			'display_edit_tkt_row'          => ' style="display:none;"',
1492
+			'edit_tkt_expanded'             => '',
1493
+			'edit_tickets_name'             => $default ? 'TICKETNAMEATTR' : 'edit_tickets',
1494
+			'TKT_name'                      => $default ? '' : $ticket->get_f('TKT_name'),
1495
+			'TKT_start_date'                => $default
1496
+				? ''
1497
+				: $ticket->get_date('TKT_start_date', $this->_date_time_format),
1498
+			'TKT_end_date'                  => $default
1499
+				? ''
1500
+				: $ticket->get_date('TKT_end_date', $this->_date_time_format),
1501
+			'TKT_status'                    => $TKT_status,
1502
+			'TKT_price'                     => $default
1503
+				? ''
1504
+				: EEH_Template::format_currency(
1505
+					$ticket->get_ticket_total_with_taxes(),
1506
+					false,
1507
+					false
1508
+				),
1509
+			'TKT_price_code'                => EE_Registry::instance()->CFG->currency->code,
1510
+			'TKT_price_amount'              => $default ? 0 : $ticket_subtotal,
1511
+			'TKT_qty'                       => $default
1512
+				? ''
1513
+				: $ticket->get_pretty('TKT_qty', 'symbol'),
1514
+			'TKT_qty_for_input'             => $default
1515
+				? ''
1516
+				: $ticket->get_pretty('TKT_qty', 'input'),
1517
+			'TKT_uses'                      => $default
1518
+				? ''
1519
+				: $ticket->get_pretty('TKT_uses', 'input'),
1520
+			'TKT_min'                       => $TKT_min,
1521
+			'TKT_max'                       => $default
1522
+				? ''
1523
+				: $ticket->get_pretty('TKT_max', 'input'),
1524
+			'TKT_sold'                      => $default ? 0 : $ticket->tickets_sold('ticket'),
1525
+			'TKT_reserved'                  => $default ? 0 : $ticket->reserved(),
1526
+			'TKT_registrations'             => $default
1527
+				? 0
1528
+				: $ticket->count_registrations(
1529
+					array(
1530
+						array(
1531
+							'STS_ID' => array(
1532
+								'!=',
1533
+								EEM_Registration::status_id_incomplete,
1534
+							),
1535
+						),
1536
+					)
1537
+				),
1538
+			'TKT_ID'                        => $default ? 0 : $ticket->ID(),
1539
+			'TKT_description'               => $default ? '' : $ticket->get_f('TKT_description'),
1540
+			'TKT_is_default'                => $default ? 0 : $ticket->is_default(),
1541
+			'TKT_required'                  => $default ? 0 : $ticket->required(),
1542
+			'TKT_is_default_selector'       => '',
1543
+			'ticket_price_rows'             => '',
1544
+			'TKT_base_price'                => $default || ! $base_price instanceof EE_Price
1545
+				? ''
1546
+				: $base_price->get_pretty('PRC_amount', 'localized_float'),
1547
+			'TKT_base_price_ID'             => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(),
1548
+			'show_price_modifier'           => count($prices) > 1 || ($default && $count_price_mods > 0)
1549
+				? ''
1550
+				: ' style="display:none;"',
1551
+			'show_price_mod_button'         => count($prices) > 1
1552
+											   || ($default && $count_price_mods > 0)
1553
+											   || (! $default && $ticket->deleted())
1554
+				? ' style="display:none;"'
1555
+				: '',
1556
+			'total_price_rows'              => count($prices) > 1 ? count($prices) : 1,
1557
+			'ticket_datetimes_list'         => $default ? '<li class="hidden"></li>' : '',
1558
+			'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_datetimes),
1559
+			'ticket_datetime_rows'          => $default ? '' : implode(',', $tkt_datetimes),
1560
+			'existing_ticket_price_ids'     => $default ? '' : implode(',', array_keys($prices)),
1561
+			'ticket_template_id'            => $default ? 0 : $ticket->get('TTM_ID'),
1562
+			'TKT_taxable'                   => $TKT_taxable,
1563
+			'display_subtotal'              => $ticket instanceof EE_Ticket && $ticket->taxable()
1564
+				? ''
1565
+				: ' style="display:none"',
1566
+			'price_currency_symbol'         => EE_Registry::instance()->CFG->currency->sign,
1567
+			'TKT_subtotal_amount_display'   => EEH_Template::format_currency(
1568
+				$ticket_subtotal,
1569
+				false,
1570
+				false
1571
+			),
1572
+			'TKT_subtotal_amount'           => $ticket_subtotal,
1573
+			'tax_rows'                      => $this->_get_tax_rows($ticket_row, $ticket),
1574
+			'disabled'                      => $ticket instanceof EE_Ticket && $ticket->deleted(),
1575
+			'ticket_archive_class'          => $ticket instanceof EE_Ticket && $ticket->deleted()
1576
+				? ' ticket-archived'
1577
+				: '',
1578
+			'trash_icon'                    => $ticket instanceof EE_Ticket
1579
+											   && $ticket->deleted()
1580
+											   && ! $ticket->is_permanently_deleteable()
1581
+				? 'ee-lock-icon '
1582
+				: 'trash-icon dashicons dashicons-post-trash clickable',
1583
+			'clone_icon'                    => $ticket instanceof EE_Ticket && $ticket->deleted()
1584
+				? ''
1585
+				: 'clone-icon ee-icon ee-icon-clone clickable',
1586
+		);
1587
+		$template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon'
1588
+			? ' style="display:none"'
1589
+			: '';
1590
+		// handle rows that should NOT be empty
1591
+		if (empty($template_args['TKT_start_date'])) {
1592
+			// if empty then the start date will be now.
1593
+			$template_args['TKT_start_date'] = date(
1594
+				$this->_date_time_format,
1595
+				current_time('timestamp')
1596
+			);
1597
+			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1598
+		}
1599
+		if (empty($template_args['TKT_end_date'])) {
1600
+			// get the earliest datetime (if present);
1601
+			$earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0
1602
+				? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related(
1603
+					'Datetime',
1604
+					array('order_by' => array('DTT_EVT_start' => 'ASC'))
1605
+				)
1606
+				: null;
1607
+			if (! empty($earliest_dtt)) {
1608
+				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime(
1609
+					'DTT_EVT_start',
1610
+					$this->_date_time_format
1611
+				);
1612
+			} else {
1613
+				// default so let's just use what's been set for the default date-time which is 30 days from now.
1614
+				$template_args['TKT_end_date'] = date(
1615
+					$this->_date_time_format,
1616
+					mktime(
1617
+						24,
1618
+						0,
1619
+						0,
1620
+						date('m'),
1621
+						date('d') + 29,
1622
+						date('Y')
1623
+					)
1624
+				);
1625
+			}
1626
+			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1627
+		}
1628
+		// generate ticket_datetime items
1629
+		if (! $default) {
1630
+			$datetime_row = 1;
1631
+			foreach ($all_datetimes as $datetime) {
1632
+				$template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
1633
+					$datetime_row,
1634
+					$ticket_row,
1635
+					$datetime,
1636
+					$ticket,
1637
+					$ticket_datetimes,
1638
+					$default
1639
+				);
1640
+				$datetime_row++;
1641
+			}
1642
+		}
1643
+		$price_row = 1;
1644
+		foreach ($prices as $price) {
1645
+			if (! $price instanceof EE_Price) {
1646
+				continue;
1647
+			}
1648
+			if ($price->is_base_price()) {
1649
+				$price_row++;
1650
+				continue;
1651
+			}
1652
+			$show_trash = ! ((count($prices) > 1 && $price_row === 1) || count($prices) === 1);
1653
+			$show_create = ! (count($prices) > 1 && count($prices) !== $price_row);
1654
+			$template_args['ticket_price_rows'] .= $this->_get_ticket_price_row(
1655
+				$ticket_row,
1656
+				$price_row,
1657
+				$price,
1658
+				$default,
1659
+				$ticket,
1660
+				$show_trash,
1661
+				$show_create
1662
+			);
1663
+			$price_row++;
1664
+		}
1665
+		// filter $template_args
1666
+		$template_args = apply_filters(
1667
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args',
1668
+			$template_args,
1669
+			$ticket_row,
1670
+			$ticket,
1671
+			$ticket_datetimes,
1672
+			$all_datetimes,
1673
+			$default,
1674
+			$all_tickets,
1675
+			$this->_is_creating_event
1676
+		);
1677
+		return EEH_Template::display_template(
1678
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php',
1679
+			$template_args,
1680
+			true
1681
+		);
1682
+	}
1683 1683
 
1684 1684
 
1685
-    /**
1686
-     * @param int            $ticket_row
1687
-     * @param EE_Ticket|null $ticket
1688
-     * @return string
1689
-     * @throws DomainException
1690
-     * @throws EE_Error
1691
-     */
1692
-    protected function _get_tax_rows($ticket_row, $ticket)
1693
-    {
1694
-        $tax_rows = '';
1695
-        /** @var EE_Price[] $taxes */
1696
-        $taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1697
-        foreach ($taxes as $tax) {
1698
-            $tax_added = $this->_get_tax_added($tax, $ticket);
1699
-            $template_args = array(
1700
-                'display_tax'       => ! empty($ticket) && $ticket->get('TKT_taxable')
1701
-                    ? ''
1702
-                    : ' style="display:none;"',
1703
-                'tax_id'            => $tax->ID(),
1704
-                'tkt_row'           => $ticket_row,
1705
-                'tax_label'         => $tax->get('PRC_name'),
1706
-                'tax_added'         => $tax_added,
1707
-                'tax_added_display' => EEH_Template::format_currency($tax_added, false, false),
1708
-                'tax_amount'        => $tax->get('PRC_amount'),
1709
-            );
1710
-            $template_args = apply_filters(
1711
-                'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args',
1712
-                $template_args,
1713
-                $ticket_row,
1714
-                $ticket,
1715
-                $this->_is_creating_event
1716
-            );
1717
-            $tax_rows .= EEH_Template::display_template(
1718
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php',
1719
-                $template_args,
1720
-                true
1721
-            );
1722
-        }
1723
-        return $tax_rows;
1724
-    }
1685
+	/**
1686
+	 * @param int            $ticket_row
1687
+	 * @param EE_Ticket|null $ticket
1688
+	 * @return string
1689
+	 * @throws DomainException
1690
+	 * @throws EE_Error
1691
+	 */
1692
+	protected function _get_tax_rows($ticket_row, $ticket)
1693
+	{
1694
+		$tax_rows = '';
1695
+		/** @var EE_Price[] $taxes */
1696
+		$taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1697
+		foreach ($taxes as $tax) {
1698
+			$tax_added = $this->_get_tax_added($tax, $ticket);
1699
+			$template_args = array(
1700
+				'display_tax'       => ! empty($ticket) && $ticket->get('TKT_taxable')
1701
+					? ''
1702
+					: ' style="display:none;"',
1703
+				'tax_id'            => $tax->ID(),
1704
+				'tkt_row'           => $ticket_row,
1705
+				'tax_label'         => $tax->get('PRC_name'),
1706
+				'tax_added'         => $tax_added,
1707
+				'tax_added_display' => EEH_Template::format_currency($tax_added, false, false),
1708
+				'tax_amount'        => $tax->get('PRC_amount'),
1709
+			);
1710
+			$template_args = apply_filters(
1711
+				'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args',
1712
+				$template_args,
1713
+				$ticket_row,
1714
+				$ticket,
1715
+				$this->_is_creating_event
1716
+			);
1717
+			$tax_rows .= EEH_Template::display_template(
1718
+				PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php',
1719
+				$template_args,
1720
+				true
1721
+			);
1722
+		}
1723
+		return $tax_rows;
1724
+	}
1725 1725
 
1726 1726
 
1727
-    /**
1728
-     * @param EE_Price       $tax
1729
-     * @param EE_Ticket|null $ticket
1730
-     * @return float|int
1731
-     * @throws EE_Error
1732
-     */
1733
-    protected function _get_tax_added(EE_Price $tax, $ticket)
1734
-    {
1735
-        $subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal();
1736
-        return $subtotal * $tax->get('PRC_amount') / 100;
1737
-    }
1727
+	/**
1728
+	 * @param EE_Price       $tax
1729
+	 * @param EE_Ticket|null $ticket
1730
+	 * @return float|int
1731
+	 * @throws EE_Error
1732
+	 */
1733
+	protected function _get_tax_added(EE_Price $tax, $ticket)
1734
+	{
1735
+		$subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal();
1736
+		return $subtotal * $tax->get('PRC_amount') / 100;
1737
+	}
1738 1738
 
1739 1739
 
1740
-    /**
1741
-     * @param int            $ticket_row
1742
-     * @param int            $price_row
1743
-     * @param EE_Price|null  $price
1744
-     * @param bool           $default
1745
-     * @param EE_Ticket|null $ticket
1746
-     * @param bool           $show_trash
1747
-     * @param bool           $show_create
1748
-     * @return mixed
1749
-     * @throws InvalidArgumentException
1750
-     * @throws InvalidInterfaceException
1751
-     * @throws InvalidDataTypeException
1752
-     * @throws DomainException
1753
-     * @throws EE_Error
1754
-     * @throws ReflectionException
1755
-     */
1756
-    protected function _get_ticket_price_row(
1757
-        $ticket_row,
1758
-        $price_row,
1759
-        $price,
1760
-        $default,
1761
-        $ticket,
1762
-        $show_trash = true,
1763
-        $show_create = true
1764
-    ) {
1765
-        $send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted');
1766
-        $template_args = array(
1767
-            'tkt_row'               => $default && empty($ticket)
1768
-                ? 'TICKETNUM'
1769
-                : $ticket_row,
1770
-            'PRC_order'             => $default && empty($price)
1771
-                ? 'PRICENUM'
1772
-                : $price_row,
1773
-            'edit_prices_name'      => $default && empty($price)
1774
-                ? 'PRICENAMEATTR'
1775
-                : 'edit_prices',
1776
-            'price_type_selector'   => $default && empty($price)
1777
-                ? $this->_get_base_price_template($ticket_row, $price_row, $price, $default)
1778
-                : $this->_get_price_type_selector(
1779
-                    $ticket_row,
1780
-                    $price_row,
1781
-                    $price,
1782
-                    $default,
1783
-                    $send_disabled
1784
-                ),
1785
-            'PRC_ID'                => $default && empty($price)
1786
-                ? 0
1787
-                : $price->ID(),
1788
-            'PRC_is_default'        => $default && empty($price)
1789
-                ? 0
1790
-                : $price->get('PRC_is_default'),
1791
-            'PRC_name'              => $default && empty($price)
1792
-                ? ''
1793
-                : $price->get('PRC_name'),
1794
-            'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1795
-            'show_plus_or_minus'    => $default && empty($price)
1796
-                ? ''
1797
-                : ' style="display:none;"',
1798
-            'show_plus'             => ($default && empty($price)) || ($price->is_discount() || $price->is_base_price())
1799
-                ? ' style="display:none;"'
1800
-                : '',
1801
-            'show_minus'            => ($default && empty($price)) || ! $price->is_discount()
1802
-                ? ' style="display:none;"'
1803
-                : '',
1804
-            'show_currency_symbol'  => ($default && empty($price)) || $price->is_percent()
1805
-                ? ' style="display:none"'
1806
-                : '',
1807
-            'PRC_amount'            => $default && empty($price)
1808
-                ? 0
1809
-                : $price->get_pretty('PRC_amount', 'localized_float'),
1810
-            'show_percentage'       => ($default && empty($price)) || ! $price->is_percent()
1811
-                ? ' style="display:none;"'
1812
-                : '',
1813
-            'show_trash_icon'       => $show_trash
1814
-                ? ''
1815
-                : ' style="display:none;"',
1816
-            'show_create_button'    => $show_create
1817
-                ? ''
1818
-                : ' style="display:none;"',
1819
-            'PRC_desc'              => $default && empty($price)
1820
-                ? ''
1821
-                : $price->get('PRC_desc'),
1822
-            'disabled'              => ! empty($ticket) && $ticket->get('TKT_deleted'),
1823
-        );
1824
-        $template_args = apply_filters(
1825
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args',
1826
-            $template_args,
1827
-            $ticket_row,
1828
-            $price_row,
1829
-            $price,
1830
-            $default,
1831
-            $ticket,
1832
-            $show_trash,
1833
-            $show_create,
1834
-            $this->_is_creating_event
1835
-        );
1836
-        return EEH_Template::display_template(
1837
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php',
1838
-            $template_args,
1839
-            true
1840
-        );
1841
-    }
1740
+	/**
1741
+	 * @param int            $ticket_row
1742
+	 * @param int            $price_row
1743
+	 * @param EE_Price|null  $price
1744
+	 * @param bool           $default
1745
+	 * @param EE_Ticket|null $ticket
1746
+	 * @param bool           $show_trash
1747
+	 * @param bool           $show_create
1748
+	 * @return mixed
1749
+	 * @throws InvalidArgumentException
1750
+	 * @throws InvalidInterfaceException
1751
+	 * @throws InvalidDataTypeException
1752
+	 * @throws DomainException
1753
+	 * @throws EE_Error
1754
+	 * @throws ReflectionException
1755
+	 */
1756
+	protected function _get_ticket_price_row(
1757
+		$ticket_row,
1758
+		$price_row,
1759
+		$price,
1760
+		$default,
1761
+		$ticket,
1762
+		$show_trash = true,
1763
+		$show_create = true
1764
+	) {
1765
+		$send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted');
1766
+		$template_args = array(
1767
+			'tkt_row'               => $default && empty($ticket)
1768
+				? 'TICKETNUM'
1769
+				: $ticket_row,
1770
+			'PRC_order'             => $default && empty($price)
1771
+				? 'PRICENUM'
1772
+				: $price_row,
1773
+			'edit_prices_name'      => $default && empty($price)
1774
+				? 'PRICENAMEATTR'
1775
+				: 'edit_prices',
1776
+			'price_type_selector'   => $default && empty($price)
1777
+				? $this->_get_base_price_template($ticket_row, $price_row, $price, $default)
1778
+				: $this->_get_price_type_selector(
1779
+					$ticket_row,
1780
+					$price_row,
1781
+					$price,
1782
+					$default,
1783
+					$send_disabled
1784
+				),
1785
+			'PRC_ID'                => $default && empty($price)
1786
+				? 0
1787
+				: $price->ID(),
1788
+			'PRC_is_default'        => $default && empty($price)
1789
+				? 0
1790
+				: $price->get('PRC_is_default'),
1791
+			'PRC_name'              => $default && empty($price)
1792
+				? ''
1793
+				: $price->get('PRC_name'),
1794
+			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1795
+			'show_plus_or_minus'    => $default && empty($price)
1796
+				? ''
1797
+				: ' style="display:none;"',
1798
+			'show_plus'             => ($default && empty($price)) || ($price->is_discount() || $price->is_base_price())
1799
+				? ' style="display:none;"'
1800
+				: '',
1801
+			'show_minus'            => ($default && empty($price)) || ! $price->is_discount()
1802
+				? ' style="display:none;"'
1803
+				: '',
1804
+			'show_currency_symbol'  => ($default && empty($price)) || $price->is_percent()
1805
+				? ' style="display:none"'
1806
+				: '',
1807
+			'PRC_amount'            => $default && empty($price)
1808
+				? 0
1809
+				: $price->get_pretty('PRC_amount', 'localized_float'),
1810
+			'show_percentage'       => ($default && empty($price)) || ! $price->is_percent()
1811
+				? ' style="display:none;"'
1812
+				: '',
1813
+			'show_trash_icon'       => $show_trash
1814
+				? ''
1815
+				: ' style="display:none;"',
1816
+			'show_create_button'    => $show_create
1817
+				? ''
1818
+				: ' style="display:none;"',
1819
+			'PRC_desc'              => $default && empty($price)
1820
+				? ''
1821
+				: $price->get('PRC_desc'),
1822
+			'disabled'              => ! empty($ticket) && $ticket->get('TKT_deleted'),
1823
+		);
1824
+		$template_args = apply_filters(
1825
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args',
1826
+			$template_args,
1827
+			$ticket_row,
1828
+			$price_row,
1829
+			$price,
1830
+			$default,
1831
+			$ticket,
1832
+			$show_trash,
1833
+			$show_create,
1834
+			$this->_is_creating_event
1835
+		);
1836
+		return EEH_Template::display_template(
1837
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php',
1838
+			$template_args,
1839
+			true
1840
+		);
1841
+	}
1842 1842
 
1843 1843
 
1844
-    /**
1845
-     * @param int      $ticket_row
1846
-     * @param int      $price_row
1847
-     * @param EE_Price $price
1848
-     * @param bool     $default
1849
-     * @param bool     $disabled
1850
-     * @return mixed
1851
-     * @throws ReflectionException
1852
-     * @throws InvalidArgumentException
1853
-     * @throws InvalidInterfaceException
1854
-     * @throws InvalidDataTypeException
1855
-     * @throws DomainException
1856
-     * @throws EE_Error
1857
-     */
1858
-    protected function _get_price_type_selector($ticket_row, $price_row, $price, $default, $disabled = false)
1859
-    {
1860
-        if ($price->is_base_price()) {
1861
-            return $this->_get_base_price_template(
1862
-                $ticket_row,
1863
-                $price_row,
1864
-                $price,
1865
-                $default
1866
-            );
1867
-        }
1868
-        return $this->_get_price_modifier_template(
1869
-            $ticket_row,
1870
-            $price_row,
1871
-            $price,
1872
-            $default,
1873
-            $disabled
1874
-        );
1875
-    }
1844
+	/**
1845
+	 * @param int      $ticket_row
1846
+	 * @param int      $price_row
1847
+	 * @param EE_Price $price
1848
+	 * @param bool     $default
1849
+	 * @param bool     $disabled
1850
+	 * @return mixed
1851
+	 * @throws ReflectionException
1852
+	 * @throws InvalidArgumentException
1853
+	 * @throws InvalidInterfaceException
1854
+	 * @throws InvalidDataTypeException
1855
+	 * @throws DomainException
1856
+	 * @throws EE_Error
1857
+	 */
1858
+	protected function _get_price_type_selector($ticket_row, $price_row, $price, $default, $disabled = false)
1859
+	{
1860
+		if ($price->is_base_price()) {
1861
+			return $this->_get_base_price_template(
1862
+				$ticket_row,
1863
+				$price_row,
1864
+				$price,
1865
+				$default
1866
+			);
1867
+		}
1868
+		return $this->_get_price_modifier_template(
1869
+			$ticket_row,
1870
+			$price_row,
1871
+			$price,
1872
+			$default,
1873
+			$disabled
1874
+		);
1875
+	}
1876 1876
 
1877 1877
 
1878
-    /**
1879
-     * @param int      $ticket_row
1880
-     * @param int      $price_row
1881
-     * @param EE_Price $price
1882
-     * @param bool     $default
1883
-     * @return mixed
1884
-     * @throws DomainException
1885
-     * @throws EE_Error
1886
-     */
1887
-    protected function _get_base_price_template($ticket_row, $price_row, $price, $default)
1888
-    {
1889
-        $template_args = array(
1890
-            'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1891
-            'PRC_order'                 => $default && empty($price) ? 'PRICENUM' : $price_row,
1892
-            'PRT_ID'                    => $default && empty($price) ? 1 : $price->get('PRT_ID'),
1893
-            'PRT_name'                  => esc_html__('Price', 'event_espresso'),
1894
-            'price_selected_operator'   => '+',
1895
-            'price_selected_is_percent' => 0,
1896
-        );
1897
-        $template_args = apply_filters(
1898
-            'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args',
1899
-            $template_args,
1900
-            $ticket_row,
1901
-            $price_row,
1902
-            $price,
1903
-            $default,
1904
-            $this->_is_creating_event
1905
-        );
1906
-        return EEH_Template::display_template(
1907
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php',
1908
-            $template_args,
1909
-            true
1910
-        );
1911
-    }
1878
+	/**
1879
+	 * @param int      $ticket_row
1880
+	 * @param int      $price_row
1881
+	 * @param EE_Price $price
1882
+	 * @param bool     $default
1883
+	 * @return mixed
1884
+	 * @throws DomainException
1885
+	 * @throws EE_Error
1886
+	 */
1887
+	protected function _get_base_price_template($ticket_row, $price_row, $price, $default)
1888
+	{
1889
+		$template_args = array(
1890
+			'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1891
+			'PRC_order'                 => $default && empty($price) ? 'PRICENUM' : $price_row,
1892
+			'PRT_ID'                    => $default && empty($price) ? 1 : $price->get('PRT_ID'),
1893
+			'PRT_name'                  => esc_html__('Price', 'event_espresso'),
1894
+			'price_selected_operator'   => '+',
1895
+			'price_selected_is_percent' => 0,
1896
+		);
1897
+		$template_args = apply_filters(
1898
+			'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args',
1899
+			$template_args,
1900
+			$ticket_row,
1901
+			$price_row,
1902
+			$price,
1903
+			$default,
1904
+			$this->_is_creating_event
1905
+		);
1906
+		return EEH_Template::display_template(
1907
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php',
1908
+			$template_args,
1909
+			true
1910
+		);
1911
+	}
1912 1912
 
1913 1913
 
1914
-    /**
1915
-     * @param int      $ticket_row
1916
-     * @param int      $price_row
1917
-     * @param EE_Price $price
1918
-     * @param bool     $default
1919
-     * @param bool     $disabled
1920
-     * @return mixed
1921
-     * @throws ReflectionException
1922
-     * @throws InvalidArgumentException
1923
-     * @throws InvalidInterfaceException
1924
-     * @throws InvalidDataTypeException
1925
-     * @throws DomainException
1926
-     * @throws EE_Error
1927
-     */
1928
-    protected function _get_price_modifier_template(
1929
-        $ticket_row,
1930
-        $price_row,
1931
-        $price,
1932
-        $default,
1933
-        $disabled = false
1934
-    ) {
1935
-        $select_name = $default && ! $price instanceof EE_Price
1936
-            ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]'
1937
-            : 'edit_prices[' . esc_attr($ticket_row) . '][' . esc_attr($price_row) . '][PRT_ID]';
1938
-        /** @var EEM_Price_Type $price_type_model */
1939
-        $price_type_model = EE_Registry::instance()->load_model('Price_Type');
1940
-        $price_types = $price_type_model->get_all(array(
1941
-            array(
1942
-                'OR' => array(
1943
-                    'PBT_ID'  => '2',
1944
-                    'PBT_ID*' => '3',
1945
-                ),
1946
-            ),
1947
-        ));
1948
-        $all_price_types = $default && ! $price instanceof EE_Price
1949
-            ? array(esc_html__('Select Modifier', 'event_espresso'))
1950
-            : array();
1951
-        $selected_price_type_id = $default && ! $price instanceof EE_Price ? 0 : $price->type();
1952
-        $price_option_spans = '';
1953
-        // setup price types for selector
1954
-        foreach ($price_types as $price_type) {
1955
-            if (! $price_type instanceof EE_Price_Type) {
1956
-                continue;
1957
-            }
1958
-            $all_price_types[ $price_type->ID() ] = $price_type->get('PRT_name');
1959
-            // while we're in the loop let's setup the option spans used by js
1960
-            $span_args = array(
1961
-                'PRT_ID'         => $price_type->ID(),
1962
-                'PRT_operator'   => $price_type->is_discount() ? '-' : '+',
1963
-                'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0,
1964
-            );
1965
-            $price_option_spans .= EEH_Template::display_template(
1966
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php',
1967
-                $span_args,
1968
-                true
1969
-            );
1970
-        }
1971
-        $select_name = $disabled ? 'archive_price[' . $ticket_row . '][' . $price_row . '][PRT_ID]'
1972
-            : $select_name;
1973
-        $select_input = new EE_Select_Input(
1974
-            $all_price_types,
1975
-            array(
1976
-                'default'               => $selected_price_type_id,
1977
-                'html_name'             => $select_name,
1978
-                'html_class'            => 'edit-price-PRT_ID',
1979
-                'other_html_attributes' => $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"',
1980
-            )
1981
-        );
1982
-        $price_selected_operator = $price instanceof EE_Price && $price->is_discount() ? '-' : '+';
1983
-        $price_selected_operator = $default && ! $price instanceof EE_Price ? '' : $price_selected_operator;
1984
-        $price_selected_is_percent = $price instanceof EE_Price && $price->is_percent() ? 1 : 0;
1985
-        $price_selected_is_percent = $default && ! $price instanceof EE_Price ? '' : $price_selected_is_percent;
1986
-        $template_args = array(
1987
-            'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1988
-            'PRC_order'                 => $default && ! $price instanceof EE_Price ? 'PRICENUM' : $price_row,
1989
-            'price_modifier_selector'   => $select_input->get_html_for_input(),
1990
-            'main_name'                 => $select_name,
1991
-            'selected_price_type_id'    => $selected_price_type_id,
1992
-            'price_option_spans'        => $price_option_spans,
1993
-            'price_selected_operator'   => $price_selected_operator,
1994
-            'price_selected_is_percent' => $price_selected_is_percent,
1995
-            'disabled'                  => $disabled,
1996
-        );
1997
-        $template_args = apply_filters(
1998
-            'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args',
1999
-            $template_args,
2000
-            $ticket_row,
2001
-            $price_row,
2002
-            $price,
2003
-            $default,
2004
-            $disabled,
2005
-            $this->_is_creating_event
2006
-        );
2007
-        return EEH_Template::display_template(
2008
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php',
2009
-            $template_args,
2010
-            true
2011
-        );
2012
-    }
1914
+	/**
1915
+	 * @param int      $ticket_row
1916
+	 * @param int      $price_row
1917
+	 * @param EE_Price $price
1918
+	 * @param bool     $default
1919
+	 * @param bool     $disabled
1920
+	 * @return mixed
1921
+	 * @throws ReflectionException
1922
+	 * @throws InvalidArgumentException
1923
+	 * @throws InvalidInterfaceException
1924
+	 * @throws InvalidDataTypeException
1925
+	 * @throws DomainException
1926
+	 * @throws EE_Error
1927
+	 */
1928
+	protected function _get_price_modifier_template(
1929
+		$ticket_row,
1930
+		$price_row,
1931
+		$price,
1932
+		$default,
1933
+		$disabled = false
1934
+	) {
1935
+		$select_name = $default && ! $price instanceof EE_Price
1936
+			? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]'
1937
+			: 'edit_prices[' . esc_attr($ticket_row) . '][' . esc_attr($price_row) . '][PRT_ID]';
1938
+		/** @var EEM_Price_Type $price_type_model */
1939
+		$price_type_model = EE_Registry::instance()->load_model('Price_Type');
1940
+		$price_types = $price_type_model->get_all(array(
1941
+			array(
1942
+				'OR' => array(
1943
+					'PBT_ID'  => '2',
1944
+					'PBT_ID*' => '3',
1945
+				),
1946
+			),
1947
+		));
1948
+		$all_price_types = $default && ! $price instanceof EE_Price
1949
+			? array(esc_html__('Select Modifier', 'event_espresso'))
1950
+			: array();
1951
+		$selected_price_type_id = $default && ! $price instanceof EE_Price ? 0 : $price->type();
1952
+		$price_option_spans = '';
1953
+		// setup price types for selector
1954
+		foreach ($price_types as $price_type) {
1955
+			if (! $price_type instanceof EE_Price_Type) {
1956
+				continue;
1957
+			}
1958
+			$all_price_types[ $price_type->ID() ] = $price_type->get('PRT_name');
1959
+			// while we're in the loop let's setup the option spans used by js
1960
+			$span_args = array(
1961
+				'PRT_ID'         => $price_type->ID(),
1962
+				'PRT_operator'   => $price_type->is_discount() ? '-' : '+',
1963
+				'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0,
1964
+			);
1965
+			$price_option_spans .= EEH_Template::display_template(
1966
+				PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php',
1967
+				$span_args,
1968
+				true
1969
+			);
1970
+		}
1971
+		$select_name = $disabled ? 'archive_price[' . $ticket_row . '][' . $price_row . '][PRT_ID]'
1972
+			: $select_name;
1973
+		$select_input = new EE_Select_Input(
1974
+			$all_price_types,
1975
+			array(
1976
+				'default'               => $selected_price_type_id,
1977
+				'html_name'             => $select_name,
1978
+				'html_class'            => 'edit-price-PRT_ID',
1979
+				'other_html_attributes' => $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"',
1980
+			)
1981
+		);
1982
+		$price_selected_operator = $price instanceof EE_Price && $price->is_discount() ? '-' : '+';
1983
+		$price_selected_operator = $default && ! $price instanceof EE_Price ? '' : $price_selected_operator;
1984
+		$price_selected_is_percent = $price instanceof EE_Price && $price->is_percent() ? 1 : 0;
1985
+		$price_selected_is_percent = $default && ! $price instanceof EE_Price ? '' : $price_selected_is_percent;
1986
+		$template_args = array(
1987
+			'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1988
+			'PRC_order'                 => $default && ! $price instanceof EE_Price ? 'PRICENUM' : $price_row,
1989
+			'price_modifier_selector'   => $select_input->get_html_for_input(),
1990
+			'main_name'                 => $select_name,
1991
+			'selected_price_type_id'    => $selected_price_type_id,
1992
+			'price_option_spans'        => $price_option_spans,
1993
+			'price_selected_operator'   => $price_selected_operator,
1994
+			'price_selected_is_percent' => $price_selected_is_percent,
1995
+			'disabled'                  => $disabled,
1996
+		);
1997
+		$template_args = apply_filters(
1998
+			'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args',
1999
+			$template_args,
2000
+			$ticket_row,
2001
+			$price_row,
2002
+			$price,
2003
+			$default,
2004
+			$disabled,
2005
+			$this->_is_creating_event
2006
+		);
2007
+		return EEH_Template::display_template(
2008
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php',
2009
+			$template_args,
2010
+			true
2011
+		);
2012
+	}
2013 2013
 
2014 2014
 
2015
-    /**
2016
-     * @param int              $datetime_row
2017
-     * @param int              $ticket_row
2018
-     * @param EE_Datetime|null $datetime
2019
-     * @param EE_Ticket|null   $ticket
2020
-     * @param array            $ticket_datetimes
2021
-     * @param bool             $default
2022
-     * @return mixed
2023
-     * @throws DomainException
2024
-     * @throws EE_Error
2025
-     */
2026
-    protected function _get_ticket_datetime_list_item(
2027
-        $datetime_row,
2028
-        $ticket_row,
2029
-        $datetime,
2030
-        $ticket,
2031
-        $ticket_datetimes = array(),
2032
-        $default
2033
-    ) {
2034
-        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
2035
-            ? $ticket_datetimes[ $ticket->ID() ]
2036
-            : array();
2037
-        $template_args = array(
2038
-            'dtt_row'                  => $default && ! $datetime instanceof EE_Datetime
2039
-                ? 'DTTNUM'
2040
-                : $datetime_row,
2041
-            'tkt_row'                  => $default
2042
-                ? 'TICKETNUM'
2043
-                : $ticket_row,
2044
-            'ticket_datetime_selected' => in_array($datetime_row, $tkt_datetimes, true)
2045
-                ? ' ticket-selected'
2046
-                : '',
2047
-            'ticket_datetime_checked'  => in_array($datetime_row, $tkt_datetimes, true)
2048
-                ? ' checked'
2049
-                : '',
2050
-            'DTT_name'                 => $default && empty($datetime)
2051
-                ? 'DTTNAME'
2052
-                : $datetime->get_dtt_display_name(true),
2053
-            'tkt_status_class'         => '',
2054
-        );
2055
-        $template_args = apply_filters(
2056
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args',
2057
-            $template_args,
2058
-            $datetime_row,
2059
-            $ticket_row,
2060
-            $datetime,
2061
-            $ticket,
2062
-            $ticket_datetimes,
2063
-            $default,
2064
-            $this->_is_creating_event
2065
-        );
2066
-        return EEH_Template::display_template(
2067
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2068
-            $template_args,
2069
-            true
2070
-        );
2071
-    }
2015
+	/**
2016
+	 * @param int              $datetime_row
2017
+	 * @param int              $ticket_row
2018
+	 * @param EE_Datetime|null $datetime
2019
+	 * @param EE_Ticket|null   $ticket
2020
+	 * @param array            $ticket_datetimes
2021
+	 * @param bool             $default
2022
+	 * @return mixed
2023
+	 * @throws DomainException
2024
+	 * @throws EE_Error
2025
+	 */
2026
+	protected function _get_ticket_datetime_list_item(
2027
+		$datetime_row,
2028
+		$ticket_row,
2029
+		$datetime,
2030
+		$ticket,
2031
+		$ticket_datetimes = array(),
2032
+		$default
2033
+	) {
2034
+		$tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
2035
+			? $ticket_datetimes[ $ticket->ID() ]
2036
+			: array();
2037
+		$template_args = array(
2038
+			'dtt_row'                  => $default && ! $datetime instanceof EE_Datetime
2039
+				? 'DTTNUM'
2040
+				: $datetime_row,
2041
+			'tkt_row'                  => $default
2042
+				? 'TICKETNUM'
2043
+				: $ticket_row,
2044
+			'ticket_datetime_selected' => in_array($datetime_row, $tkt_datetimes, true)
2045
+				? ' ticket-selected'
2046
+				: '',
2047
+			'ticket_datetime_checked'  => in_array($datetime_row, $tkt_datetimes, true)
2048
+				? ' checked'
2049
+				: '',
2050
+			'DTT_name'                 => $default && empty($datetime)
2051
+				? 'DTTNAME'
2052
+				: $datetime->get_dtt_display_name(true),
2053
+			'tkt_status_class'         => '',
2054
+		);
2055
+		$template_args = apply_filters(
2056
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args',
2057
+			$template_args,
2058
+			$datetime_row,
2059
+			$ticket_row,
2060
+			$datetime,
2061
+			$ticket,
2062
+			$ticket_datetimes,
2063
+			$default,
2064
+			$this->_is_creating_event
2065
+		);
2066
+		return EEH_Template::display_template(
2067
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2068
+			$template_args,
2069
+			true
2070
+		);
2071
+	}
2072 2072
 
2073 2073
 
2074
-    /**
2075
-     * @param array $all_datetimes
2076
-     * @param array $all_tickets
2077
-     * @return mixed
2078
-     * @throws ReflectionException
2079
-     * @throws InvalidArgumentException
2080
-     * @throws InvalidInterfaceException
2081
-     * @throws InvalidDataTypeException
2082
-     * @throws DomainException
2083
-     * @throws EE_Error
2084
-     */
2085
-    protected function _get_ticket_js_structure($all_datetimes = array(), $all_tickets = array())
2086
-    {
2087
-        $template_args = array(
2088
-            'default_datetime_edit_row'                => $this->_get_dtt_edit_row(
2089
-                'DTTNUM',
2090
-                null,
2091
-                true,
2092
-                $all_datetimes
2093
-            ),
2094
-            'default_ticket_row'                       => $this->_get_ticket_row(
2095
-                'TICKETNUM',
2096
-                null,
2097
-                array(),
2098
-                array(),
2099
-                true
2100
-            ),
2101
-            'default_price_row'                        => $this->_get_ticket_price_row(
2102
-                'TICKETNUM',
2103
-                'PRICENUM',
2104
-                null,
2105
-                true,
2106
-                null
2107
-            ),
2108
-            'default_price_rows'                       => '',
2109
-            'default_base_price_amount'                => 0,
2110
-            'default_base_price_name'                  => '',
2111
-            'default_base_price_description'           => '',
2112
-            'default_price_modifier_selector_row'      => $this->_get_price_modifier_template(
2113
-                'TICKETNUM',
2114
-                'PRICENUM',
2115
-                null,
2116
-                true
2117
-            ),
2118
-            'default_available_tickets_for_datetime'   => $this->_get_dtt_attached_tickets_row(
2119
-                'DTTNUM',
2120
-                null,
2121
-                array(),
2122
-                array(),
2123
-                true
2124
-            ),
2125
-            'existing_available_datetime_tickets_list' => '',
2126
-            'existing_available_ticket_datetimes_list' => '',
2127
-            'new_available_datetime_ticket_list_item'  => $this->_get_datetime_tickets_list_item(
2128
-                'DTTNUM',
2129
-                'TICKETNUM',
2130
-                null,
2131
-                null,
2132
-                array(),
2133
-                true
2134
-            ),
2135
-            'new_available_ticket_datetime_list_item'  => $this->_get_ticket_datetime_list_item(
2136
-                'DTTNUM',
2137
-                'TICKETNUM',
2138
-                null,
2139
-                null,
2140
-                array(),
2141
-                true
2142
-            ),
2143
-        );
2144
-        $ticket_row = 1;
2145
-        foreach ($all_tickets as $ticket) {
2146
-            $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
2147
-                'DTTNUM',
2148
-                $ticket_row,
2149
-                null,
2150
-                $ticket,
2151
-                array(),
2152
-                true
2153
-            );
2154
-            $ticket_row++;
2155
-        }
2156
-        $datetime_row = 1;
2157
-        foreach ($all_datetimes as $datetime) {
2158
-            $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
2159
-                $datetime_row,
2160
-                'TICKETNUM',
2161
-                $datetime,
2162
-                null,
2163
-                array(),
2164
-                true
2165
-            );
2166
-            $datetime_row++;
2167
-        }
2168
-        /** @var EEM_Price $price_model */
2169
-        $price_model = EE_Registry::instance()->load_model('Price');
2170
-        $default_prices = $price_model->get_all_default_prices();
2171
-        $price_row = 1;
2172
-        foreach ($default_prices as $price) {
2173
-            if (! $price instanceof EE_Price) {
2174
-                continue;
2175
-            }
2176
-            if ($price->is_base_price()) {
2177
-                $template_args['default_base_price_amount'] = $price->get_pretty(
2178
-                    'PRC_amount',
2179
-                    'localized_float'
2180
-                );
2181
-                $template_args['default_base_price_name'] = $price->get('PRC_name');
2182
-                $template_args['default_base_price_description'] = $price->get('PRC_desc');
2183
-                $price_row++;
2184
-                continue;
2185
-            }
2186
-            $show_trash = ! ((count($default_prices) > 1 && $price_row === 1)
2187
-                             || count($default_prices) === 1);
2188
-            $show_create = ! (count($default_prices) > 1
2189
-                              && count($default_prices)
2190
-                                 !== $price_row);
2191
-            $template_args['default_price_rows'] .= $this->_get_ticket_price_row(
2192
-                'TICKETNUM',
2193
-                $price_row,
2194
-                $price,
2195
-                true,
2196
-                null,
2197
-                $show_trash,
2198
-                $show_create
2199
-            );
2200
-            $price_row++;
2201
-        }
2202
-        $template_args = apply_filters(
2203
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args',
2204
-            $template_args,
2205
-            $all_datetimes,
2206
-            $all_tickets,
2207
-            $this->_is_creating_event
2208
-        );
2209
-        return EEH_Template::display_template(
2210
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php',
2211
-            $template_args,
2212
-            true
2213
-        );
2214
-    }
2074
+	/**
2075
+	 * @param array $all_datetimes
2076
+	 * @param array $all_tickets
2077
+	 * @return mixed
2078
+	 * @throws ReflectionException
2079
+	 * @throws InvalidArgumentException
2080
+	 * @throws InvalidInterfaceException
2081
+	 * @throws InvalidDataTypeException
2082
+	 * @throws DomainException
2083
+	 * @throws EE_Error
2084
+	 */
2085
+	protected function _get_ticket_js_structure($all_datetimes = array(), $all_tickets = array())
2086
+	{
2087
+		$template_args = array(
2088
+			'default_datetime_edit_row'                => $this->_get_dtt_edit_row(
2089
+				'DTTNUM',
2090
+				null,
2091
+				true,
2092
+				$all_datetimes
2093
+			),
2094
+			'default_ticket_row'                       => $this->_get_ticket_row(
2095
+				'TICKETNUM',
2096
+				null,
2097
+				array(),
2098
+				array(),
2099
+				true
2100
+			),
2101
+			'default_price_row'                        => $this->_get_ticket_price_row(
2102
+				'TICKETNUM',
2103
+				'PRICENUM',
2104
+				null,
2105
+				true,
2106
+				null
2107
+			),
2108
+			'default_price_rows'                       => '',
2109
+			'default_base_price_amount'                => 0,
2110
+			'default_base_price_name'                  => '',
2111
+			'default_base_price_description'           => '',
2112
+			'default_price_modifier_selector_row'      => $this->_get_price_modifier_template(
2113
+				'TICKETNUM',
2114
+				'PRICENUM',
2115
+				null,
2116
+				true
2117
+			),
2118
+			'default_available_tickets_for_datetime'   => $this->_get_dtt_attached_tickets_row(
2119
+				'DTTNUM',
2120
+				null,
2121
+				array(),
2122
+				array(),
2123
+				true
2124
+			),
2125
+			'existing_available_datetime_tickets_list' => '',
2126
+			'existing_available_ticket_datetimes_list' => '',
2127
+			'new_available_datetime_ticket_list_item'  => $this->_get_datetime_tickets_list_item(
2128
+				'DTTNUM',
2129
+				'TICKETNUM',
2130
+				null,
2131
+				null,
2132
+				array(),
2133
+				true
2134
+			),
2135
+			'new_available_ticket_datetime_list_item'  => $this->_get_ticket_datetime_list_item(
2136
+				'DTTNUM',
2137
+				'TICKETNUM',
2138
+				null,
2139
+				null,
2140
+				array(),
2141
+				true
2142
+			),
2143
+		);
2144
+		$ticket_row = 1;
2145
+		foreach ($all_tickets as $ticket) {
2146
+			$template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
2147
+				'DTTNUM',
2148
+				$ticket_row,
2149
+				null,
2150
+				$ticket,
2151
+				array(),
2152
+				true
2153
+			);
2154
+			$ticket_row++;
2155
+		}
2156
+		$datetime_row = 1;
2157
+		foreach ($all_datetimes as $datetime) {
2158
+			$template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
2159
+				$datetime_row,
2160
+				'TICKETNUM',
2161
+				$datetime,
2162
+				null,
2163
+				array(),
2164
+				true
2165
+			);
2166
+			$datetime_row++;
2167
+		}
2168
+		/** @var EEM_Price $price_model */
2169
+		$price_model = EE_Registry::instance()->load_model('Price');
2170
+		$default_prices = $price_model->get_all_default_prices();
2171
+		$price_row = 1;
2172
+		foreach ($default_prices as $price) {
2173
+			if (! $price instanceof EE_Price) {
2174
+				continue;
2175
+			}
2176
+			if ($price->is_base_price()) {
2177
+				$template_args['default_base_price_amount'] = $price->get_pretty(
2178
+					'PRC_amount',
2179
+					'localized_float'
2180
+				);
2181
+				$template_args['default_base_price_name'] = $price->get('PRC_name');
2182
+				$template_args['default_base_price_description'] = $price->get('PRC_desc');
2183
+				$price_row++;
2184
+				continue;
2185
+			}
2186
+			$show_trash = ! ((count($default_prices) > 1 && $price_row === 1)
2187
+							 || count($default_prices) === 1);
2188
+			$show_create = ! (count($default_prices) > 1
2189
+							  && count($default_prices)
2190
+								 !== $price_row);
2191
+			$template_args['default_price_rows'] .= $this->_get_ticket_price_row(
2192
+				'TICKETNUM',
2193
+				$price_row,
2194
+				$price,
2195
+				true,
2196
+				null,
2197
+				$show_trash,
2198
+				$show_create
2199
+			);
2200
+			$price_row++;
2201
+		}
2202
+		$template_args = apply_filters(
2203
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args',
2204
+			$template_args,
2205
+			$all_datetimes,
2206
+			$all_tickets,
2207
+			$this->_is_creating_event
2208
+		);
2209
+		return EEH_Template::display_template(
2210
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php',
2211
+			$template_args,
2212
+			true
2213
+		);
2214
+	}
2215 2215
 }
Please login to merge, or discard this patch.
registration_form/espresso_events_Registration_Form_Hooks_Extend.class.php 2 patches
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -17,208 +17,208 @@
 block discarded – undo
17 17
 class espresso_events_Registration_Form_Hooks_Extend extends espresso_events_Registration_Form_Hooks
18 18
 {
19 19
 
20
-    /**
21
-     * extending the properties set in espresso_events_Registration_From_Hooks
22
-     *
23
-     * @access protected
24
-     * @return void
25
-     */
26
-    protected function _extend_properties()
27
-    {
28
-        $this->_metaboxes = array_merge(
29
-            $this->_metaboxes,
30
-            array(
31
-                1 => array(
32
-                    'page_route' => array('create_new', 'edit'),
33
-                    'func'       => 'additional_questions',
34
-                    'label'      => esc_html__('Questions for Additional Registrants', 'event_espresso'),
35
-                    'priority'   => 'default',
36
-                    'context'    => 'side',
37
-                ),
38
-            )
39
-        );
40
-        $this->_scripts_styles = array(
41
-            'registers' => array(
42
-                'extended-event-editor' => array(
43
-                    'url'     => EE_CORE_CAF_ADMIN_EXTEND_URL
44
-                                 . 'registration_form/assets/event-editor-question-groups.js',
45
-                    'depends' => array('jquery'),
46
-                ),
47
-            ),
48
-            'enqueues'  => array(
49
-                'extended-event-editor' => array('edit', 'create_new'),
50
-            ),
51
-        );
52
-    }
53
-
54
-
55
-    /**
56
-     * @param Callable[] $callbacks
57
-     * @return array
58
-     */
59
-    public function modify_callbacks($callbacks)
60
-    {
61
-        $callbacks = parent::modify_callbacks($callbacks);
62
-        $callbacks[] = array($this, 'additional_question_group_update');
63
-        return $callbacks;
64
-    }
65
-
66
-
67
-    /**
68
-     * Call back hooked into revision restores.
69
-     *
70
-     * @param $post_id
71
-     * @param $revision_id
72
-     * @return EE_Base_Class|void
73
-     * @throws EE_Error
74
-     * @throws InvalidArgumentException
75
-     * @throws InvalidDataTypeException
76
-     * @throws InvalidInterfaceException
77
-     * @throws ReflectionException
78
-     */
79
-    public function restore_revision($post_id, $revision_id)
80
-    {
81
-        $post_evt = parent::restore_revision($post_id, $revision_id);
82
-
83
-        // restore revision for additional questions
84
-        $post_evt->restore_revision(
85
-            $revision_id,
86
-            ['Question_Group'],
87
-            [
88
-                'Question_Group' => ['Event_Question_Group.EQG_additional' => true],
89
-            ]
90
-        );
91
-    }
92
-
93
-
94
-    /**
95
-     * @param $post_id
96
-     * @param $post
97
-     * @throws EE_Error
98
-     * @throws InvalidArgumentException
99
-     * @throws InvalidDataTypeException
100
-     * @throws InvalidInterfaceException
101
-     */
102
-    public function additional_questions($post_id, $post)
103
-    {
104
-        $this->_event = $this->_adminpage_obj->get_event_object();
105
-        $event_id = $this->_event->ID();
106
-        ?>
20
+	/**
21
+	 * extending the properties set in espresso_events_Registration_From_Hooks
22
+	 *
23
+	 * @access protected
24
+	 * @return void
25
+	 */
26
+	protected function _extend_properties()
27
+	{
28
+		$this->_metaboxes = array_merge(
29
+			$this->_metaboxes,
30
+			array(
31
+				1 => array(
32
+					'page_route' => array('create_new', 'edit'),
33
+					'func'       => 'additional_questions',
34
+					'label'      => esc_html__('Questions for Additional Registrants', 'event_espresso'),
35
+					'priority'   => 'default',
36
+					'context'    => 'side',
37
+				),
38
+			)
39
+		);
40
+		$this->_scripts_styles = array(
41
+			'registers' => array(
42
+				'extended-event-editor' => array(
43
+					'url'     => EE_CORE_CAF_ADMIN_EXTEND_URL
44
+								 . 'registration_form/assets/event-editor-question-groups.js',
45
+					'depends' => array('jquery'),
46
+				),
47
+			),
48
+			'enqueues'  => array(
49
+				'extended-event-editor' => array('edit', 'create_new'),
50
+			),
51
+		);
52
+	}
53
+
54
+
55
+	/**
56
+	 * @param Callable[] $callbacks
57
+	 * @return array
58
+	 */
59
+	public function modify_callbacks($callbacks)
60
+	{
61
+		$callbacks = parent::modify_callbacks($callbacks);
62
+		$callbacks[] = array($this, 'additional_question_group_update');
63
+		return $callbacks;
64
+	}
65
+
66
+
67
+	/**
68
+	 * Call back hooked into revision restores.
69
+	 *
70
+	 * @param $post_id
71
+	 * @param $revision_id
72
+	 * @return EE_Base_Class|void
73
+	 * @throws EE_Error
74
+	 * @throws InvalidArgumentException
75
+	 * @throws InvalidDataTypeException
76
+	 * @throws InvalidInterfaceException
77
+	 * @throws ReflectionException
78
+	 */
79
+	public function restore_revision($post_id, $revision_id)
80
+	{
81
+		$post_evt = parent::restore_revision($post_id, $revision_id);
82
+
83
+		// restore revision for additional questions
84
+		$post_evt->restore_revision(
85
+			$revision_id,
86
+			['Question_Group'],
87
+			[
88
+				'Question_Group' => ['Event_Question_Group.EQG_additional' => true],
89
+			]
90
+		);
91
+	}
92
+
93
+
94
+	/**
95
+	 * @param $post_id
96
+	 * @param $post
97
+	 * @throws EE_Error
98
+	 * @throws InvalidArgumentException
99
+	 * @throws InvalidDataTypeException
100
+	 * @throws InvalidInterfaceException
101
+	 */
102
+	public function additional_questions($post_id, $post)
103
+	{
104
+		$this->_event = $this->_adminpage_obj->get_event_object();
105
+		$event_id = $this->_event->ID();
106
+		?>
107 107
         <div class="inside">
108 108
             <p><strong>
109 109
                     <?php esc_html_e('Question Groups', 'event_espresso'); ?>
110 110
                 </strong><br/>
111 111
                 <?php
112
-                printf(
113
-                    esc_html__(
114
-                        'Add a pre-populated %1$sgroup of questions%2$s to your event.',
115
-                        'event_espresso'
116
-                    ),
117
-                    '<a href="admin.php?page=espresso_registration_form" target="_blank">',
118
-                    '</a>'
119
-                );
120
-                ?>
112
+				printf(
113
+					esc_html__(
114
+						'Add a pre-populated %1$sgroup of questions%2$s to your event.',
115
+						'event_espresso'
116
+					),
117
+					'<a href="admin.php?page=espresso_registration_form" target="_blank">',
118
+					'</a>'
119
+				);
120
+				?>
121 121
             </p>
122 122
             <?php
123 123
 
124
-            $qsg_where['QSG_deleted'] = false;
125
-            $query_params = apply_filters(
126
-                'FHEE__espresso_events_Registration_Form_Hooks_Extend__additional_questions__question_group_query_parameters',
127
-                array($qsg_where, 'order_by' => array('QSG_order' => 'ASC'))
128
-            );
129
-            $QSGs = EEM_Question_Group::instance()->get_all($query_params);
130
-            $EQGs = ! empty($event_id)
131
-                ? $this->_event->get_many_related(
132
-                    'Question_Group',
133
-                    [['Event_Question_Group.EQG_additional' => true]]
134
-                )
135
-                : [];
136
-            $EQGids = array_keys($EQGs);
137
-
138
-            if (! empty($QSGs)) {
139
-                $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
140
-                foreach ($QSGs as $QSG) {
141
-                    $checked = in_array($QSG->ID(), $EQGids, true) ? ' checked ' : '';
142
-                    $edit_link = EE_Admin_Page::add_query_args_and_nonce(
143
-                        array(
144
-                            'action' => 'edit_question_group',
145
-                            'QSG_ID' => $QSG->ID(),
146
-                        ),
147
-                        EE_FORMS_ADMIN_URL
148
-                    );
149
-
150
-                    $html .= '
124
+			$qsg_where['QSG_deleted'] = false;
125
+			$query_params = apply_filters(
126
+				'FHEE__espresso_events_Registration_Form_Hooks_Extend__additional_questions__question_group_query_parameters',
127
+				array($qsg_where, 'order_by' => array('QSG_order' => 'ASC'))
128
+			);
129
+			$QSGs = EEM_Question_Group::instance()->get_all($query_params);
130
+			$EQGs = ! empty($event_id)
131
+				? $this->_event->get_many_related(
132
+					'Question_Group',
133
+					[['Event_Question_Group.EQG_additional' => true]]
134
+				)
135
+				: [];
136
+			$EQGids = array_keys($EQGs);
137
+
138
+			if (! empty($QSGs)) {
139
+				$html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
140
+				foreach ($QSGs as $QSG) {
141
+					$checked = in_array($QSG->ID(), $EQGids, true) ? ' checked ' : '';
142
+					$edit_link = EE_Admin_Page::add_query_args_and_nonce(
143
+						array(
144
+							'action' => 'edit_question_group',
145
+							'QSG_ID' => $QSG->ID(),
146
+						),
147
+						EE_FORMS_ADMIN_URL
148
+					);
149
+
150
+					$html .= '
151 151
 					<p id="event-question-group-' . $QSG->ID() . '">
152 152
 						<input value="' . $QSG->ID() . '"'
153
-                             . ' type="checkbox" name="add_attendee_question_groups[' . $QSG->ID() . ']"' . $checked . ' />
153
+							 . ' type="checkbox" name="add_attendee_question_groups[' . $QSG->ID() . ']"' . $checked . ' />
154 154
 						<a href="' . $edit_link . '" title="'
155
-                             . sprintf(
156
-                                 esc_attr__('Edit %s Group', 'event_espresso'),
157
-                                 $QSG->get('QSG_name')
158
-                             )
159
-                             . '" target="_blank">' . $QSG->get('QSG_name') . '</a>
155
+							 . sprintf(
156
+								 esc_attr__('Edit %s Group', 'event_espresso'),
157
+								 $QSG->get('QSG_name')
158
+							 )
159
+							 . '" target="_blank">' . $QSG->get('QSG_name') . '</a>
160 160
 					</p>';
161
-                    if ($QSG->ID() === 2) {
162
-                        $html .= '
161
+					if ($QSG->ID() === 2) {
162
+						$html .= '
163 163
 					<p id="question-group-requirements-notice-pg" class="important-notice small-text" style="display: none;">'
164
-                                 . esc_html__(
165
-                                     'The Personal Information question group is required whenever the Address Information question group is activated.',
166
-                                     'event_espresso'
167
-                                 )
168
-                                 . '</p>';
169
-                    }
170
-                }
171
-                $html .= count($QSGs) > 10 ? '</div>' : '';
172
-
173
-                echo wp_kses($html, AllowedTags::getWithFormTags());
174
-            } else {
175
-                esc_html_e(
176
-                    'There seems to be a problem with your questions. Please contact [email protected]',
177
-                    'event_espresso'
178
-                );
179
-            }
180
-            do_action('AHEE__espresso_events_Registration_Form_Hooks__additional_questions__after_content');
181
-            ?>
164
+								 . esc_html__(
165
+									 'The Personal Information question group is required whenever the Address Information question group is activated.',
166
+									 'event_espresso'
167
+								 )
168
+								 . '</p>';
169
+					}
170
+				}
171
+				$html .= count($QSGs) > 10 ? '</div>' : '';
172
+
173
+				echo wp_kses($html, AllowedTags::getWithFormTags());
174
+			} else {
175
+				esc_html_e(
176
+					'There seems to be a problem with your questions. Please contact [email protected]',
177
+					'event_espresso'
178
+				);
179
+			}
180
+			do_action('AHEE__espresso_events_Registration_Form_Hooks__additional_questions__after_content');
181
+			?>
182 182
         </div>
183 183
         <?php
184
-    }
185
-
186
-
187
-    public function additional_question_group_update($evtobj, $data)
188
-    {
189
-        $question_groups = ! empty($data['add_attendee_question_groups'])
190
-            ? (array) $data['add_attendee_question_groups']
191
-            : [];
192
-        $added_qgs = array_keys($question_groups);
193
-        $success = [];
194
-
195
-        // let's get all current question groups associated with this event.
196
-        $current_qgs = $evtobj->get_many_related(
197
-            'Question_Group',
198
-            [['Event_Question_Group.EQG_additional' => true]]
199
-        );
200
-        $current_qgs = array_keys($current_qgs); // we just want the ids
201
-
202
-        // now let's get the groups selected in the editor and update (IF we have data)
203
-        if (! empty($question_groups)) {
204
-            foreach ($question_groups as $qgid) {
205
-                // add to event
206
-                if ($qgid) {
207
-                    $qg = $evtobj->add_question_group($qgid, false);
208
-                }
209
-                $success[] = ! empty($qg) ? 1 : 0;
210
-            }
211
-        }
212
-
213
-        // wait a minute... are there question groups missing in the saved groups that ARE with the current event?
214
-        $removed_qgs = array_diff($current_qgs, $added_qgs);
215
-
216
-        foreach ($removed_qgs as $qgid) {
217
-            $qg = $evtobj->remove_question_group($qgid, false);
218
-            $success[] = ! empty($qg) ? 1 : 0;
219
-        }
220
-
221
-
222
-        return in_array(0, $success, true) ? false : true;
223
-    }
184
+	}
185
+
186
+
187
+	public function additional_question_group_update($evtobj, $data)
188
+	{
189
+		$question_groups = ! empty($data['add_attendee_question_groups'])
190
+			? (array) $data['add_attendee_question_groups']
191
+			: [];
192
+		$added_qgs = array_keys($question_groups);
193
+		$success = [];
194
+
195
+		// let's get all current question groups associated with this event.
196
+		$current_qgs = $evtobj->get_many_related(
197
+			'Question_Group',
198
+			[['Event_Question_Group.EQG_additional' => true]]
199
+		);
200
+		$current_qgs = array_keys($current_qgs); // we just want the ids
201
+
202
+		// now let's get the groups selected in the editor and update (IF we have data)
203
+		if (! empty($question_groups)) {
204
+			foreach ($question_groups as $qgid) {
205
+				// add to event
206
+				if ($qgid) {
207
+					$qg = $evtobj->add_question_group($qgid, false);
208
+				}
209
+				$success[] = ! empty($qg) ? 1 : 0;
210
+			}
211
+		}
212
+
213
+		// wait a minute... are there question groups missing in the saved groups that ARE with the current event?
214
+		$removed_qgs = array_diff($current_qgs, $added_qgs);
215
+
216
+		foreach ($removed_qgs as $qgid) {
217
+			$qg = $evtobj->remove_question_group($qgid, false);
218
+			$success[] = ! empty($qg) ? 1 : 0;
219
+		}
220
+
221
+
222
+		return in_array(0, $success, true) ? false : true;
223
+	}
224 224
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
                 : [];
136 136
             $EQGids = array_keys($EQGs);
137 137
 
138
-            if (! empty($QSGs)) {
138
+            if ( ! empty($QSGs)) {
139 139
                 $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
140 140
                 foreach ($QSGs as $QSG) {
141 141
                     $checked = in_array($QSG->ID(), $EQGids, true) ? ' checked ' : '';
@@ -148,15 +148,15 @@  discard block
 block discarded – undo
148 148
                     );
149 149
 
150 150
                     $html .= '
151
-					<p id="event-question-group-' . $QSG->ID() . '">
152
-						<input value="' . $QSG->ID() . '"'
153
-                             . ' type="checkbox" name="add_attendee_question_groups[' . $QSG->ID() . ']"' . $checked . ' />
154
-						<a href="' . $edit_link . '" title="'
151
+					<p id="event-question-group-' . $QSG->ID().'">
152
+						<input value="' . $QSG->ID().'"'
153
+                             . ' type="checkbox" name="add_attendee_question_groups['.$QSG->ID().']"'.$checked.' />
154
+						<a href="' . $edit_link.'" title="'
155 155
                              . sprintf(
156 156
                                  esc_attr__('Edit %s Group', 'event_espresso'),
157 157
                                  $QSG->get('QSG_name')
158 158
                              )
159
-                             . '" target="_blank">' . $QSG->get('QSG_name') . '</a>
159
+                             . '" target="_blank">'.$QSG->get('QSG_name').'</a>
160 160
 					</p>';
161 161
                     if ($QSG->ID() === 2) {
162 162
                         $html .= '
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
         $current_qgs = array_keys($current_qgs); // we just want the ids
201 201
 
202 202
         // now let's get the groups selected in the editor and update (IF we have data)
203
-        if (! empty($question_groups)) {
203
+        if ( ! empty($question_groups)) {
204 204
             foreach ($question_groups as $qgid) {
205 205
                 // add to event
206 206
                 if ($qgid) {
Please login to merge, or discard this patch.
admin/extend/events/templates/event_registration_options.template.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
 
20 20
 <?php
21 21
 $settings_array                = [
22
-    'max_registrants'                 => '<p>
22
+	'max_registrants'                 => '<p>
23 23
         <label for="max-registrants">
24 24
         ' . esc_html__(
25
-        'Maximum number of tickets allowed per order for this event: ',
26
-        'event_espresso'
27
-    ) . '
25
+		'Maximum number of tickets allowed per order for this event: ',
26
+		'event_espresso'
27
+	) . '
28 28
         </label>
29 29
         <input class="ee-numeric"
30 30
                 type="text" 
@@ -34,29 +34,29 @@  discard block
 block discarded – undo
34 34
                 size="4" 
35 35
                 />
36 36
         </p>',
37
-    'additional_registration_options' => $additional_registration_options,
38
-    'display_ticket_selector'         => '<p>
37
+	'additional_registration_options' => $additional_registration_options,
38
+	'display_ticket_selector'         => '<p>
39 39
             <label>' . esc_html__('Display Ticket Selector', 'event_espresso') . '</label>'
40
-            . $display_ticket_selector // already escaped
41
-            . '</p>',
42
-    'alternative_registration_page'   => '<p>
40
+			. $display_ticket_selector // already escaped
41
+			. '</p>',
42
+	'alternative_registration_page'   => '<p>
43 43
             <label>' . esc_html__('Alternative Registration Page', 'event_espresso') . '</label>
44 44
             <input name="externalURL" size="20" type="text" value="' . esc_url_raw($_event->external_url()) . '"> 
45 45
             </p>',
46
-    'event_phone_number'              => '<p>
46
+	'event_phone_number'              => '<p>
47 47
             <label>' . esc_html__('Event Phone Number', 'event_espresso') . '</label>
48 48
             <input name="event_phone" size="20" type="text" value="' . esc_attr($_event->phone()) . '">
49 49
             </p>',
50
-    'default_registration_status'     => '<p>
50
+	'default_registration_status'     => '<p>
51 51
             <label>' . esc_html__('Default Registration Status', 'event_espresso') . '</label>'
52
-             . EEH_Template::get_help_tab_link('event_editor_event_registration_options_help_tab')
53
-             . $EVT_default_registration_status // already escaped
54
-             . '</p>',
52
+			 . EEH_Template::get_help_tab_link('event_editor_event_registration_options_help_tab')
53
+			 . $EVT_default_registration_status // already escaped
54
+			 . '</p>',
55 55
 ];
56 56
 // filter
57 57
 $settings_array = apply_filters('FHEE__caffeinated_event_registration_options__template__settings', $settings_array);
58 58
 
59 59
 // echo
60 60
 foreach ($settings_array as $item) {
61
-    echo wp_kses($item, AllowedTags::getWithFormTags());
61
+	echo wp_kses($item, AllowedTags::getWithFormTags());
62 62
 }
Please login to merge, or discard this patch.