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