@@ -20,585 +20,585 @@ |
||
20 | 20 | class EE_Messages_Preview_incoming_data extends EE_Messages_incoming_data |
21 | 21 | { |
22 | 22 | |
23 | - // some specific properties we need for this class |
|
24 | - private $_events = array(); |
|
25 | - private $_attendees = array(); |
|
26 | - private $_registrations = array(); |
|
23 | + // some specific properties we need for this class |
|
24 | + private $_events = array(); |
|
25 | + private $_attendees = array(); |
|
26 | + private $_registrations = array(); |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * For the constructor of this special preview class. We're either looking for an event id or empty data. If we |
|
31 | - * have an event id (or ids) then we'll use that as the source for the "dummy" data. If the data is empty then |
|
32 | - * we'll get the first three published events from the users database and use that as a source. |
|
33 | - * |
|
34 | - * @param array $data |
|
35 | - */ |
|
36 | - public function __construct($data = array()) |
|
37 | - { |
|
38 | - $this->_data = isset($data['event_ids']) ? $data['event_ids'] : array(); |
|
39 | - $this->_setup_attendees_events(); |
|
40 | - parent::__construct($data); |
|
41 | - } |
|
29 | + /** |
|
30 | + * For the constructor of this special preview class. We're either looking for an event id or empty data. If we |
|
31 | + * have an event id (or ids) then we'll use that as the source for the "dummy" data. If the data is empty then |
|
32 | + * we'll get the first three published events from the users database and use that as a source. |
|
33 | + * |
|
34 | + * @param array $data |
|
35 | + */ |
|
36 | + public function __construct($data = array()) |
|
37 | + { |
|
38 | + $this->_data = isset($data['event_ids']) ? $data['event_ids'] : array(); |
|
39 | + $this->_setup_attendees_events(); |
|
40 | + parent::__construct($data); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * Returns database safe representation of the data later used to when instantiating this object. |
|
46 | - * |
|
47 | - * @param array $data The incoming data to be prepped. |
|
48 | - * |
|
49 | - * @return array The prepped data for db |
|
50 | - */ |
|
51 | - public static function convert_data_for_persistent_storage($data) |
|
52 | - { |
|
53 | - return $data; |
|
54 | - } |
|
44 | + /** |
|
45 | + * Returns database safe representation of the data later used to when instantiating this object. |
|
46 | + * |
|
47 | + * @param array $data The incoming data to be prepped. |
|
48 | + * |
|
49 | + * @return array The prepped data for db |
|
50 | + */ |
|
51 | + public static function convert_data_for_persistent_storage($data) |
|
52 | + { |
|
53 | + return $data; |
|
54 | + } |
|
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage |
|
59 | - * can be sent into this method and converted back into the format used for instantiating with this data handler. |
|
60 | - * |
|
61 | - * @param array $data |
|
62 | - * |
|
63 | - * @return array |
|
64 | - */ |
|
65 | - public static function convert_data_from_persistent_storage($data) |
|
66 | - { |
|
67 | - return $data; |
|
68 | - } |
|
57 | + /** |
|
58 | + * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage |
|
59 | + * can be sent into this method and converted back into the format used for instantiating with this data handler. |
|
60 | + * |
|
61 | + * @param array $data |
|
62 | + * |
|
63 | + * @return array |
|
64 | + */ |
|
65 | + public static function convert_data_from_persistent_storage($data) |
|
66 | + { |
|
67 | + return $data; |
|
68 | + } |
|
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * This will just setup the _events property in the expected format. |
|
73 | - * |
|
74 | - * @throws \EE_Error |
|
75 | - */ |
|
76 | - private function _setup_attendees_events() |
|
77 | - { |
|
78 | - |
|
79 | - // setup some attendee objects |
|
80 | - $attendees = $this->_get_some_attendees(); |
|
81 | - |
|
82 | - // if empty $data we'll do a query to get some events from the server. otherwise we'll retrieve the event data for the given ids. |
|
83 | - $events = $this->_get_some_events($this->_data); |
|
84 | - |
|
85 | - $answers_n_questions = $this->_get_some_q_and_as(); |
|
86 | - |
|
87 | - if (count($events) < 1) { |
|
88 | - throw new EE_Error(__( |
|
89 | - 'We can\'t generate a preview for you because there are no active events in your database', |
|
90 | - 'event_espresso' |
|
91 | - )); |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - // now let's loop and set up the _events property. At the same time we'll set up attendee properties. |
|
96 | - |
|
97 | - |
|
98 | - // we'll actually use the generated line_item identifiers for our loop |
|
99 | - $dtts = $tkts = array(); |
|
100 | - foreach ($events as $id => $event) { |
|
101 | - if (! $event instanceof EE_Event) { |
|
102 | - continue; |
|
103 | - } |
|
104 | - $this->_events[ $id ]['ID'] = $id; |
|
105 | - $this->_events[ $id ]['name'] = $event->get('EVT_name'); |
|
106 | - $datetime = $event->get_first_related('Datetime'); |
|
107 | - $tickets = $datetime instanceof EE_Datetime ? $datetime->get_many_related( |
|
108 | - 'Ticket', |
|
109 | - array('default_where_conditions' => 'none') |
|
110 | - ) : array(); |
|
111 | - $this->_events[ $id ]['event'] = $event; |
|
112 | - $this->_events[ $id ]['reg_objs'] = array(); |
|
113 | - $this->_events[ $id ]['tkt_objs'] = $tickets; |
|
114 | - $this->_events[ $id ]['dtt_objs'] = array(); |
|
71 | + /** |
|
72 | + * This will just setup the _events property in the expected format. |
|
73 | + * |
|
74 | + * @throws \EE_Error |
|
75 | + */ |
|
76 | + private function _setup_attendees_events() |
|
77 | + { |
|
78 | + |
|
79 | + // setup some attendee objects |
|
80 | + $attendees = $this->_get_some_attendees(); |
|
81 | + |
|
82 | + // if empty $data we'll do a query to get some events from the server. otherwise we'll retrieve the event data for the given ids. |
|
83 | + $events = $this->_get_some_events($this->_data); |
|
84 | + |
|
85 | + $answers_n_questions = $this->_get_some_q_and_as(); |
|
86 | + |
|
87 | + if (count($events) < 1) { |
|
88 | + throw new EE_Error(__( |
|
89 | + 'We can\'t generate a preview for you because there are no active events in your database', |
|
90 | + 'event_espresso' |
|
91 | + )); |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + // now let's loop and set up the _events property. At the same time we'll set up attendee properties. |
|
96 | + |
|
97 | + |
|
98 | + // we'll actually use the generated line_item identifiers for our loop |
|
99 | + $dtts = $tkts = array(); |
|
100 | + foreach ($events as $id => $event) { |
|
101 | + if (! $event instanceof EE_Event) { |
|
102 | + continue; |
|
103 | + } |
|
104 | + $this->_events[ $id ]['ID'] = $id; |
|
105 | + $this->_events[ $id ]['name'] = $event->get('EVT_name'); |
|
106 | + $datetime = $event->get_first_related('Datetime'); |
|
107 | + $tickets = $datetime instanceof EE_Datetime ? $datetime->get_many_related( |
|
108 | + 'Ticket', |
|
109 | + array('default_where_conditions' => 'none') |
|
110 | + ) : array(); |
|
111 | + $this->_events[ $id ]['event'] = $event; |
|
112 | + $this->_events[ $id ]['reg_objs'] = array(); |
|
113 | + $this->_events[ $id ]['tkt_objs'] = $tickets; |
|
114 | + $this->_events[ $id ]['dtt_objs'] = array(); |
|
115 | 115 | |
116 | - $dttcache = array(); |
|
117 | - $tkts = array(); |
|
118 | - foreach ($tickets as $ticket) { |
|
119 | - if (! $ticket instanceof EE_Ticket) { |
|
120 | - continue; |
|
121 | - } |
|
122 | - $reldatetime = $ticket->datetimes(); |
|
123 | - $tkts[ $ticket->ID() ] = array(); |
|
124 | - $tkts[ $ticket->ID() ]['ticket'] = $ticket; |
|
125 | - $tkts[ $ticket->ID() ]['dtt_objs'] = $reldatetime; |
|
126 | - $tkts[ $ticket->ID() ]['att_objs'] = $attendees; |
|
127 | - $tkts[ $ticket->ID() ]['count'] = count($attendees); |
|
128 | - $tkts[ $ticket->ID() ]['EE_Event'] = $event; |
|
129 | - foreach ($reldatetime as $datetime) { |
|
130 | - if ($datetime instanceof EE_Datetime && ! isset($dtts[ $datetime->ID() ])) { |
|
131 | - $this->_events[ $id ]['dtt_objs'][ $datetime->ID() ] = $datetime; |
|
132 | - $dtts[ $datetime->ID() ]['datetime'] = $datetime; |
|
133 | - $dtts[ $datetime->ID() ]['tkt_objs'][] = $ticket; |
|
134 | - $dtts[ $datetime->ID() ]['evt_objs'][] = $event; |
|
135 | - $dttcache[ $datetime->ID() ] = $datetime; |
|
136 | - } |
|
137 | - } |
|
138 | - } |
|
116 | + $dttcache = array(); |
|
117 | + $tkts = array(); |
|
118 | + foreach ($tickets as $ticket) { |
|
119 | + if (! $ticket instanceof EE_Ticket) { |
|
120 | + continue; |
|
121 | + } |
|
122 | + $reldatetime = $ticket->datetimes(); |
|
123 | + $tkts[ $ticket->ID() ] = array(); |
|
124 | + $tkts[ $ticket->ID() ]['ticket'] = $ticket; |
|
125 | + $tkts[ $ticket->ID() ]['dtt_objs'] = $reldatetime; |
|
126 | + $tkts[ $ticket->ID() ]['att_objs'] = $attendees; |
|
127 | + $tkts[ $ticket->ID() ]['count'] = count($attendees); |
|
128 | + $tkts[ $ticket->ID() ]['EE_Event'] = $event; |
|
129 | + foreach ($reldatetime as $datetime) { |
|
130 | + if ($datetime instanceof EE_Datetime && ! isset($dtts[ $datetime->ID() ])) { |
|
131 | + $this->_events[ $id ]['dtt_objs'][ $datetime->ID() ] = $datetime; |
|
132 | + $dtts[ $datetime->ID() ]['datetime'] = $datetime; |
|
133 | + $dtts[ $datetime->ID() ]['tkt_objs'][] = $ticket; |
|
134 | + $dtts[ $datetime->ID() ]['evt_objs'][] = $event; |
|
135 | + $dttcache[ $datetime->ID() ] = $datetime; |
|
136 | + } |
|
137 | + } |
|
138 | + } |
|
139 | 139 | |
140 | - $this->_events[ $id ]['total_attendees'] = count($attendees); |
|
141 | - $this->_events[ $id ]['att_objs'] = $attendees; |
|
140 | + $this->_events[ $id ]['total_attendees'] = count($attendees); |
|
141 | + $this->_events[ $id ]['att_objs'] = $attendees; |
|
142 | 142 | |
143 | - // let's also setup the dummy attendees property! |
|
144 | - foreach ($attendees as $att_key => $attendee) { |
|
145 | - if (! $attendee instanceof EE_Attendee) { |
|
146 | - continue; |
|
147 | - } |
|
148 | - $this->_attendees[ $att_key ]['line_ref'][] = $id; // so later it can be determined what events this attendee registered for! |
|
149 | - $this->_attendees[ $att_key ]['evt_objs'][] = $event; |
|
150 | - $this->_attendees[ $att_key ]['att_obj'] = $attendee; |
|
151 | - // $this->_attendees[$att_key]['registration_id'] = 0; |
|
152 | - $this->_attendees[ $att_key ]['attendee_email'] = $attendee->email(); |
|
153 | - $this->_attendees[ $att_key ]['tkt_objs'] = $tickets; |
|
154 | - if ($att_key == 999999991) { |
|
155 | - $this->_attendees[ $att_key ]['ans_objs'][999] = $answers_n_questions['answers'][999]; |
|
156 | - $this->_attendees[ $att_key ]['ans_objs'][1002] = $answers_n_questions['answers'][1002]; |
|
157 | - $this->_attendees[ $att_key ]['ans_objs'][1005] = $answers_n_questions['answers'][1005]; |
|
158 | - } elseif ($att_key == 999999992) { |
|
159 | - $this->_attendees[ $att_key ]['ans_objs'][1000] = $answers_n_questions['answers'][1000]; |
|
160 | - $this->_attendees[ $att_key ]['ans_objs'][1003] = $answers_n_questions['answers'][1003]; |
|
161 | - $this->_attendees[ $att_key ]['ans_objs'][1006] = $answers_n_questions['answers'][1006]; |
|
162 | - } elseif ($att_key == 999999993) { |
|
163 | - $this->_attendees[ $att_key ]['ans_objs'][1001] = $answers_n_questions['answers'][1001]; |
|
164 | - $this->_attendees[ $att_key ]['ans_objs'][1004] = $answers_n_questions['answers'][1004]; |
|
165 | - $this->_attendees[ $att_key ]['ans_objs'][1007] = $answers_n_questions['answers'][1007]; |
|
166 | - } |
|
167 | - } |
|
168 | - } |
|
169 | - |
|
170 | - $this->tickets = $tkts; |
|
171 | - $this->datetimes = $dtts; |
|
172 | - $this->answers = $answers_n_questions['answers']; |
|
173 | - $this->questions = $answers_n_questions['questions']; |
|
174 | - $this->total_ticket_count = count($tkts) * count($this->_attendees); |
|
175 | - } |
|
143 | + // let's also setup the dummy attendees property! |
|
144 | + foreach ($attendees as $att_key => $attendee) { |
|
145 | + if (! $attendee instanceof EE_Attendee) { |
|
146 | + continue; |
|
147 | + } |
|
148 | + $this->_attendees[ $att_key ]['line_ref'][] = $id; // so later it can be determined what events this attendee registered for! |
|
149 | + $this->_attendees[ $att_key ]['evt_objs'][] = $event; |
|
150 | + $this->_attendees[ $att_key ]['att_obj'] = $attendee; |
|
151 | + // $this->_attendees[$att_key]['registration_id'] = 0; |
|
152 | + $this->_attendees[ $att_key ]['attendee_email'] = $attendee->email(); |
|
153 | + $this->_attendees[ $att_key ]['tkt_objs'] = $tickets; |
|
154 | + if ($att_key == 999999991) { |
|
155 | + $this->_attendees[ $att_key ]['ans_objs'][999] = $answers_n_questions['answers'][999]; |
|
156 | + $this->_attendees[ $att_key ]['ans_objs'][1002] = $answers_n_questions['answers'][1002]; |
|
157 | + $this->_attendees[ $att_key ]['ans_objs'][1005] = $answers_n_questions['answers'][1005]; |
|
158 | + } elseif ($att_key == 999999992) { |
|
159 | + $this->_attendees[ $att_key ]['ans_objs'][1000] = $answers_n_questions['answers'][1000]; |
|
160 | + $this->_attendees[ $att_key ]['ans_objs'][1003] = $answers_n_questions['answers'][1003]; |
|
161 | + $this->_attendees[ $att_key ]['ans_objs'][1006] = $answers_n_questions['answers'][1006]; |
|
162 | + } elseif ($att_key == 999999993) { |
|
163 | + $this->_attendees[ $att_key ]['ans_objs'][1001] = $answers_n_questions['answers'][1001]; |
|
164 | + $this->_attendees[ $att_key ]['ans_objs'][1004] = $answers_n_questions['answers'][1004]; |
|
165 | + $this->_attendees[ $att_key ]['ans_objs'][1007] = $answers_n_questions['answers'][1007]; |
|
166 | + } |
|
167 | + } |
|
168 | + } |
|
169 | + |
|
170 | + $this->tickets = $tkts; |
|
171 | + $this->datetimes = $dtts; |
|
172 | + $this->answers = $answers_n_questions['answers']; |
|
173 | + $this->questions = $answers_n_questions['questions']; |
|
174 | + $this->total_ticket_count = count($tkts) * count($this->_attendees); |
|
175 | + } |
|
176 | 176 | |
177 | 177 | |
178 | - /** |
|
179 | - * This just returns an array of dummy attendee objects that we'll use to attach to events for our preview data |
|
180 | - * |
|
181 | - * @access private |
|
182 | - * @return array an array of attendee objects |
|
183 | - */ |
|
184 | - private function _get_some_attendees() |
|
185 | - { |
|
186 | - // let's just setup a dummy array of various attendee details |
|
187 | - $dummy_attendees = array( |
|
188 | - 0 => array( |
|
189 | - 'Luke', |
|
190 | - 'Skywalker', |
|
191 | - '[email protected]', |
|
192 | - '804 Bantha Dr.', |
|
193 | - 'Complex 8', |
|
194 | - 'Mos Eisley', |
|
195 | - 32, |
|
196 | - 'US', |
|
197 | - 'f0r3e', |
|
198 | - '222-333-4763', |
|
199 | - false, |
|
200 | - '999999991' |
|
201 | - ), |
|
202 | - 1 => array( |
|
203 | - 'Princess', |
|
204 | - 'Leia', |
|
205 | - '[email protected]', |
|
206 | - '1456 Valley Way Boulevard', |
|
207 | - 'Suite 9', |
|
208 | - 'Alderaan', |
|
209 | - 15, |
|
210 | - 'US', |
|
211 | - 'c1h2c', |
|
212 | - '78-123-111-1111', |
|
213 | - false, |
|
214 | - '999999992' |
|
215 | - ), |
|
216 | - 2 => array( |
|
217 | - 'Yoda', |
|
218 | - 'I Am', |
|
219 | - '[email protected]', |
|
220 | - '4th Tree', |
|
221 | - '5th Knot', |
|
222 | - 'Marsh', |
|
223 | - 22, |
|
224 | - 'US', |
|
225 | - 'l18n', |
|
226 | - '999-999-9999', |
|
227 | - false, |
|
228 | - '999999993' |
|
229 | - ), |
|
230 | - ); |
|
231 | - |
|
232 | - // let's generate the attendee objects |
|
233 | - $attendees = array(); |
|
234 | - $var_array = array( |
|
235 | - 'fname', |
|
236 | - 'lname', |
|
237 | - 'email', |
|
238 | - 'address', |
|
239 | - 'address2', |
|
240 | - 'city', |
|
241 | - 'staid', |
|
242 | - 'cntry', |
|
243 | - 'zip', |
|
244 | - 'phone', |
|
245 | - 'deleted', |
|
246 | - 'attid' |
|
247 | - ); |
|
248 | - |
|
249 | - // EE_Registry::instance()->load_class( 'Attendee', array(), FALSE, false, TRUE ); |
|
250 | - foreach ($dummy_attendees as $dummy) { |
|
251 | - $att = array_combine($var_array, $dummy); |
|
252 | - extract($att); |
|
253 | - /** @var $fname string */ |
|
254 | - /** @var $lname string */ |
|
255 | - /** @var $address string */ |
|
256 | - /** @var $address2 string */ |
|
257 | - /** @var $city string */ |
|
258 | - /** @var $staid string */ |
|
259 | - /** @var $cntry string */ |
|
260 | - /** @var $zip string */ |
|
261 | - /** @var $email string */ |
|
262 | - /** @var $phone string */ |
|
263 | - /** @var $attid string */ |
|
264 | - $attendees[ $attid ] = EE_Attendee::new_instance( |
|
265 | - array( |
|
266 | - 'ATT_fname' => $fname, |
|
267 | - 'ATT_lname' => $lname, |
|
268 | - 'ATT_address' => $address, |
|
269 | - 'ATT_address2' => $address2, |
|
270 | - 'ATT_city' => $city, |
|
271 | - 'STA_ID' => $staid, |
|
272 | - 'CNT_ISO' => $cntry, |
|
273 | - 'ATT_zip' => $zip, |
|
274 | - 'ATT_email' => $email, |
|
275 | - 'ATT_phone' => $phone, |
|
276 | - 'ATT_ID' => $attid |
|
277 | - ) |
|
278 | - ); |
|
279 | - } |
|
280 | - |
|
281 | - return $attendees; |
|
282 | - } |
|
178 | + /** |
|
179 | + * This just returns an array of dummy attendee objects that we'll use to attach to events for our preview data |
|
180 | + * |
|
181 | + * @access private |
|
182 | + * @return array an array of attendee objects |
|
183 | + */ |
|
184 | + private function _get_some_attendees() |
|
185 | + { |
|
186 | + // let's just setup a dummy array of various attendee details |
|
187 | + $dummy_attendees = array( |
|
188 | + 0 => array( |
|
189 | + 'Luke', |
|
190 | + 'Skywalker', |
|
191 | + '[email protected]', |
|
192 | + '804 Bantha Dr.', |
|
193 | + 'Complex 8', |
|
194 | + 'Mos Eisley', |
|
195 | + 32, |
|
196 | + 'US', |
|
197 | + 'f0r3e', |
|
198 | + '222-333-4763', |
|
199 | + false, |
|
200 | + '999999991' |
|
201 | + ), |
|
202 | + 1 => array( |
|
203 | + 'Princess', |
|
204 | + 'Leia', |
|
205 | + '[email protected]', |
|
206 | + '1456 Valley Way Boulevard', |
|
207 | + 'Suite 9', |
|
208 | + 'Alderaan', |
|
209 | + 15, |
|
210 | + 'US', |
|
211 | + 'c1h2c', |
|
212 | + '78-123-111-1111', |
|
213 | + false, |
|
214 | + '999999992' |
|
215 | + ), |
|
216 | + 2 => array( |
|
217 | + 'Yoda', |
|
218 | + 'I Am', |
|
219 | + '[email protected]', |
|
220 | + '4th Tree', |
|
221 | + '5th Knot', |
|
222 | + 'Marsh', |
|
223 | + 22, |
|
224 | + 'US', |
|
225 | + 'l18n', |
|
226 | + '999-999-9999', |
|
227 | + false, |
|
228 | + '999999993' |
|
229 | + ), |
|
230 | + ); |
|
231 | + |
|
232 | + // let's generate the attendee objects |
|
233 | + $attendees = array(); |
|
234 | + $var_array = array( |
|
235 | + 'fname', |
|
236 | + 'lname', |
|
237 | + 'email', |
|
238 | + 'address', |
|
239 | + 'address2', |
|
240 | + 'city', |
|
241 | + 'staid', |
|
242 | + 'cntry', |
|
243 | + 'zip', |
|
244 | + 'phone', |
|
245 | + 'deleted', |
|
246 | + 'attid' |
|
247 | + ); |
|
248 | + |
|
249 | + // EE_Registry::instance()->load_class( 'Attendee', array(), FALSE, false, TRUE ); |
|
250 | + foreach ($dummy_attendees as $dummy) { |
|
251 | + $att = array_combine($var_array, $dummy); |
|
252 | + extract($att); |
|
253 | + /** @var $fname string */ |
|
254 | + /** @var $lname string */ |
|
255 | + /** @var $address string */ |
|
256 | + /** @var $address2 string */ |
|
257 | + /** @var $city string */ |
|
258 | + /** @var $staid string */ |
|
259 | + /** @var $cntry string */ |
|
260 | + /** @var $zip string */ |
|
261 | + /** @var $email string */ |
|
262 | + /** @var $phone string */ |
|
263 | + /** @var $attid string */ |
|
264 | + $attendees[ $attid ] = EE_Attendee::new_instance( |
|
265 | + array( |
|
266 | + 'ATT_fname' => $fname, |
|
267 | + 'ATT_lname' => $lname, |
|
268 | + 'ATT_address' => $address, |
|
269 | + 'ATT_address2' => $address2, |
|
270 | + 'ATT_city' => $city, |
|
271 | + 'STA_ID' => $staid, |
|
272 | + 'CNT_ISO' => $cntry, |
|
273 | + 'ATT_zip' => $zip, |
|
274 | + 'ATT_email' => $email, |
|
275 | + 'ATT_phone' => $phone, |
|
276 | + 'ATT_ID' => $attid |
|
277 | + ) |
|
278 | + ); |
|
279 | + } |
|
280 | + |
|
281 | + return $attendees; |
|
282 | + } |
|
283 | 283 | |
284 | 284 | |
285 | - /** |
|
286 | - * Return an array of dummy question objects indexed by answer id and dummy answer objects indexed by answer id. |
|
287 | - * This will be used in our dummy data setup |
|
288 | - * @return array |
|
289 | - */ |
|
290 | - private function _get_some_q_and_as() |
|
291 | - { |
|
292 | - |
|
293 | - |
|
294 | - $quests_array = array( |
|
295 | - 0 => array( |
|
296 | - 555, |
|
297 | - __('What is your favorite planet?', 'event_espresso'), |
|
298 | - 0 |
|
299 | - ), |
|
300 | - 1 => array( |
|
301 | - 556, |
|
302 | - __('What is your favorite food?', 'event_espresso'), |
|
303 | - 0 |
|
304 | - ), |
|
305 | - 2 => array( |
|
306 | - 557, |
|
307 | - __('How many lightyears have you travelled', 'event_espresso'), |
|
308 | - 0 |
|
309 | - ) |
|
310 | - ); |
|
311 | - |
|
312 | - |
|
313 | - $ans_array = array( |
|
314 | - 0 => array( |
|
315 | - 999, |
|
316 | - 555, |
|
317 | - 'Tattoine' |
|
318 | - ), |
|
319 | - 1 => array( |
|
320 | - 1000, |
|
321 | - 555, |
|
322 | - 'Alderaan' |
|
323 | - ), |
|
324 | - 2 => array( |
|
325 | - 1001, |
|
326 | - 555, |
|
327 | - 'Dantooine' |
|
328 | - ), |
|
329 | - 3 => array( |
|
330 | - 1002, |
|
331 | - 556, |
|
332 | - 'Fish Fingers' |
|
333 | - ), |
|
334 | - 4 => array( |
|
335 | - 1003, |
|
336 | - 556, |
|
337 | - 'Sushi' |
|
338 | - ), |
|
339 | - 5 => array( |
|
340 | - 1004, |
|
341 | - 556, |
|
342 | - 'Water' |
|
343 | - ), |
|
344 | - 6 => array( |
|
345 | - 1005, |
|
346 | - 557, |
|
347 | - 'A lot', |
|
348 | - ), |
|
349 | - 7 => array( |
|
350 | - 1006, |
|
351 | - 557, |
|
352 | - "That's none of your business." |
|
353 | - ), |
|
354 | - 8 => array( |
|
355 | - 1007, |
|
356 | - 557, |
|
357 | - "People less travel me then." |
|
358 | - ) |
|
359 | - ); |
|
360 | - |
|
361 | - $qst_columns = array('QST_ID', 'QST_display_text', 'QST_system'); |
|
362 | - $ans_columns = array('ANS_ID', 'QST_ID', 'ANS_value'); |
|
363 | - |
|
364 | - // EE_Registry::instance()->load_class( 'Question', array(), FALSE, TRUE, TRUE ); |
|
365 | - // EE_Registry::instance()->load_class( 'Answer', array(), FALSE, TRUE, TRUE ); |
|
366 | - |
|
367 | - $qsts = array(); |
|
368 | - // first the questions |
|
369 | - foreach ($quests_array as $qst) { |
|
370 | - $qstobj = array_combine($qst_columns, $qst); |
|
371 | - $qsts[ $qstobj['QST_ID'] ] = EE_Question::new_instance($qstobj); |
|
372 | - } |
|
373 | - |
|
374 | - // now the answers (and we'll setup our arrays) |
|
375 | - $q_n_as = array(); |
|
376 | - foreach ($ans_array as $ans) { |
|
377 | - $ansobj = array_combine($ans_columns, $ans); |
|
378 | - $ansobj = EE_Answer::new_instance($ansobj); |
|
379 | - $q_n_as['answers'][ $ansobj->ID() ] = $ansobj; |
|
380 | - $q_n_as['questions'][ $ansobj->ID() ] = $qsts[ $ansobj->get('QST_ID') ]; |
|
381 | - } |
|
382 | - |
|
383 | - return $q_n_as; |
|
384 | - } |
|
285 | + /** |
|
286 | + * Return an array of dummy question objects indexed by answer id and dummy answer objects indexed by answer id. |
|
287 | + * This will be used in our dummy data setup |
|
288 | + * @return array |
|
289 | + */ |
|
290 | + private function _get_some_q_and_as() |
|
291 | + { |
|
292 | + |
|
293 | + |
|
294 | + $quests_array = array( |
|
295 | + 0 => array( |
|
296 | + 555, |
|
297 | + __('What is your favorite planet?', 'event_espresso'), |
|
298 | + 0 |
|
299 | + ), |
|
300 | + 1 => array( |
|
301 | + 556, |
|
302 | + __('What is your favorite food?', 'event_espresso'), |
|
303 | + 0 |
|
304 | + ), |
|
305 | + 2 => array( |
|
306 | + 557, |
|
307 | + __('How many lightyears have you travelled', 'event_espresso'), |
|
308 | + 0 |
|
309 | + ) |
|
310 | + ); |
|
311 | + |
|
312 | + |
|
313 | + $ans_array = array( |
|
314 | + 0 => array( |
|
315 | + 999, |
|
316 | + 555, |
|
317 | + 'Tattoine' |
|
318 | + ), |
|
319 | + 1 => array( |
|
320 | + 1000, |
|
321 | + 555, |
|
322 | + 'Alderaan' |
|
323 | + ), |
|
324 | + 2 => array( |
|
325 | + 1001, |
|
326 | + 555, |
|
327 | + 'Dantooine' |
|
328 | + ), |
|
329 | + 3 => array( |
|
330 | + 1002, |
|
331 | + 556, |
|
332 | + 'Fish Fingers' |
|
333 | + ), |
|
334 | + 4 => array( |
|
335 | + 1003, |
|
336 | + 556, |
|
337 | + 'Sushi' |
|
338 | + ), |
|
339 | + 5 => array( |
|
340 | + 1004, |
|
341 | + 556, |
|
342 | + 'Water' |
|
343 | + ), |
|
344 | + 6 => array( |
|
345 | + 1005, |
|
346 | + 557, |
|
347 | + 'A lot', |
|
348 | + ), |
|
349 | + 7 => array( |
|
350 | + 1006, |
|
351 | + 557, |
|
352 | + "That's none of your business." |
|
353 | + ), |
|
354 | + 8 => array( |
|
355 | + 1007, |
|
356 | + 557, |
|
357 | + "People less travel me then." |
|
358 | + ) |
|
359 | + ); |
|
360 | + |
|
361 | + $qst_columns = array('QST_ID', 'QST_display_text', 'QST_system'); |
|
362 | + $ans_columns = array('ANS_ID', 'QST_ID', 'ANS_value'); |
|
363 | + |
|
364 | + // EE_Registry::instance()->load_class( 'Question', array(), FALSE, TRUE, TRUE ); |
|
365 | + // EE_Registry::instance()->load_class( 'Answer', array(), FALSE, TRUE, TRUE ); |
|
366 | + |
|
367 | + $qsts = array(); |
|
368 | + // first the questions |
|
369 | + foreach ($quests_array as $qst) { |
|
370 | + $qstobj = array_combine($qst_columns, $qst); |
|
371 | + $qsts[ $qstobj['QST_ID'] ] = EE_Question::new_instance($qstobj); |
|
372 | + } |
|
373 | + |
|
374 | + // now the answers (and we'll setup our arrays) |
|
375 | + $q_n_as = array(); |
|
376 | + foreach ($ans_array as $ans) { |
|
377 | + $ansobj = array_combine($ans_columns, $ans); |
|
378 | + $ansobj = EE_Answer::new_instance($ansobj); |
|
379 | + $q_n_as['answers'][ $ansobj->ID() ] = $ansobj; |
|
380 | + $q_n_as['questions'][ $ansobj->ID() ] = $qsts[ $ansobj->get('QST_ID') ]; |
|
381 | + } |
|
382 | + |
|
383 | + return $q_n_as; |
|
384 | + } |
|
385 | 385 | |
386 | 386 | |
387 | - /** |
|
388 | - * Return an array of event objects from the database |
|
389 | - * |
|
390 | - * If event ids are not included then we'll just retrieve the first published event from the database. |
|
391 | - * |
|
392 | - * @param array $event_ids if set, this will be an array of event ids to obtain events for. |
|
393 | - * |
|
394 | - * @return array An array of event objects from the db. |
|
395 | - */ |
|
396 | - private function _get_some_events($event_ids = array()) |
|
397 | - { |
|
398 | - |
|
399 | - // HEY, if we have an evt_id then we want to make sure we use that for the preview (because a specific event template is being viewed); |
|
400 | - $event_ids = isset($_REQUEST['evt_id']) && ! empty($_REQUEST['evt_id']) |
|
401 | - ? array($_REQUEST['evt_id']) |
|
402 | - : $event_ids; |
|
403 | - |
|
404 | - $limit = ! empty($event_ids) |
|
405 | - ? null |
|
406 | - : apply_filters('FHEE__EE_Messages_Preview_incoming_data___get_some_events__limit', '0,1'); |
|
407 | - |
|
408 | - $where = ! empty($event_ids) |
|
409 | - ? array( |
|
410 | - 'EVT_ID' => array('IN', $event_ids), |
|
411 | - 'Datetime.Ticket.TKT_ID' => array('>', 1) |
|
412 | - ) |
|
413 | - : array('Datetime.Ticket.TKT_ID' => array('>', 1)); |
|
414 | - |
|
415 | - $events = EE_Registry::instance()->load_model('Event')->get_all(array($where, 'limit' => $limit)); |
|
416 | - |
|
417 | - return $events; |
|
418 | - } |
|
387 | + /** |
|
388 | + * Return an array of event objects from the database |
|
389 | + * |
|
390 | + * If event ids are not included then we'll just retrieve the first published event from the database. |
|
391 | + * |
|
392 | + * @param array $event_ids if set, this will be an array of event ids to obtain events for. |
|
393 | + * |
|
394 | + * @return array An array of event objects from the db. |
|
395 | + */ |
|
396 | + private function _get_some_events($event_ids = array()) |
|
397 | + { |
|
398 | + |
|
399 | + // HEY, if we have an evt_id then we want to make sure we use that for the preview (because a specific event template is being viewed); |
|
400 | + $event_ids = isset($_REQUEST['evt_id']) && ! empty($_REQUEST['evt_id']) |
|
401 | + ? array($_REQUEST['evt_id']) |
|
402 | + : $event_ids; |
|
403 | + |
|
404 | + $limit = ! empty($event_ids) |
|
405 | + ? null |
|
406 | + : apply_filters('FHEE__EE_Messages_Preview_incoming_data___get_some_events__limit', '0,1'); |
|
407 | + |
|
408 | + $where = ! empty($event_ids) |
|
409 | + ? array( |
|
410 | + 'EVT_ID' => array('IN', $event_ids), |
|
411 | + 'Datetime.Ticket.TKT_ID' => array('>', 1) |
|
412 | + ) |
|
413 | + : array('Datetime.Ticket.TKT_ID' => array('>', 1)); |
|
414 | + |
|
415 | + $events = EE_Registry::instance()->load_model('Event')->get_all(array($where, 'limit' => $limit)); |
|
416 | + |
|
417 | + return $events; |
|
418 | + } |
|
419 | 419 | |
420 | 420 | |
421 | - protected function _setup_data() |
|
422 | - { |
|
423 | - |
|
424 | - // need to figure out the running total for test purposes so... we're going to create a temp cart and add the tickets to it! |
|
425 | - if (EE_Registry::instance()->SSN instanceof EE_Session) { |
|
426 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
427 | - $session = EE_Registry::instance()->SSN; |
|
428 | - } else { |
|
429 | - $session = EE_Registry::instance()->load_core('Session'); |
|
430 | - } |
|
431 | - $cart = EE_Cart::instance(null, $session); |
|
432 | - |
|
433 | - |
|
434 | - // add tickets to cart |
|
435 | - foreach ($this->tickets as $ticket) { |
|
436 | - $cart->add_ticket_to_cart($ticket['ticket']); |
|
437 | - } |
|
438 | - |
|
439 | - |
|
440 | - // setup txn property |
|
441 | - $this->txn = EE_Transaction::new_instance( |
|
442 | - array( |
|
443 | - 'TXN_timestamp' => time(), // unix timestamp |
|
444 | - 'TXN_total' => 0, // txn_total |
|
445 | - 'TXN_paid' => 0, // txn_paid |
|
446 | - 'STS_ID' => EEM_Transaction::incomplete_status_code, // sts_id |
|
447 | - 'TXN_session_data' => null, // dump of txn session object (we're just going to leave blank here) |
|
448 | - 'TXN_hash_salt' => null, // hash salt blank as well |
|
449 | - 'TXN_ID' => 999999 |
|
450 | - ) |
|
451 | - ); |
|
452 | - |
|
453 | - |
|
454 | - // setup reg_objects |
|
455 | - // note we're setting up a reg object for each attendee in each event but ALSO adding to the reg_object array. |
|
456 | - $this->reg_objs = array(); |
|
457 | - $regid = 9999990; |
|
458 | - foreach ($this->_attendees as $key => $attendee) { |
|
459 | - // note we need to setup reg_objects for each event this attendee belongs to |
|
460 | - $regatt = $attendee['att_obj'] instanceof EE_Attendee ? $attendee['att_obj']->ID() : null; |
|
461 | - $regtxn = $this->txn->ID(); |
|
462 | - $regcnt = 1; |
|
463 | - foreach ($attendee['line_ref'] as $evtid) { |
|
464 | - foreach ($this->_events[ $evtid ]['tkt_objs'] as $ticket) { |
|
465 | - if (! $ticket instanceof EE_Ticket) { |
|
466 | - continue; |
|
467 | - } |
|
468 | - $reg_array = array( |
|
469 | - 'EVT_ID' => $evtid, |
|
470 | - 'ATT_ID' => $regatt, |
|
471 | - 'TXN_ID' => $regtxn, |
|
472 | - 'TKT_ID' => $ticket->ID(), |
|
473 | - 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
474 | - 'REG_date' => time(), |
|
475 | - 'REG_final_price' => $ticket->get('TKT_price'), |
|
476 | - 'REG_session' => 'dummy_session_id', |
|
477 | - 'REG_code' => $regid . '-dummy-generated-code', |
|
478 | - 'REG_url_link' => $regcnt . '-daafpapasdlfakasdfpqasdfasdf', |
|
479 | - 'REG_count' => $regcnt, |
|
480 | - 'REG_group_size' => $this->_events[ $evtid ]['total_attendees'], |
|
481 | - 'REG_att_is_going' => true, |
|
482 | - 'REG_ID' => $regid |
|
483 | - ); |
|
484 | - $REG_OBJ = EE_Registration::new_instance($reg_array); |
|
485 | - $this->_attendees[ $key ]['reg_objs'][ $regid ] = $REG_OBJ; |
|
486 | - $this->_events[ $evtid ]['reg_objs'][] = $REG_OBJ; |
|
487 | - $this->reg_objs[] = $REG_OBJ; |
|
488 | - $this->tickets[ $ticket->ID() ]['reg_objs'][ $regid ] = $REG_OBJ; |
|
421 | + protected function _setup_data() |
|
422 | + { |
|
423 | + |
|
424 | + // need to figure out the running total for test purposes so... we're going to create a temp cart and add the tickets to it! |
|
425 | + if (EE_Registry::instance()->SSN instanceof EE_Session) { |
|
426 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
427 | + $session = EE_Registry::instance()->SSN; |
|
428 | + } else { |
|
429 | + $session = EE_Registry::instance()->load_core('Session'); |
|
430 | + } |
|
431 | + $cart = EE_Cart::instance(null, $session); |
|
432 | + |
|
433 | + |
|
434 | + // add tickets to cart |
|
435 | + foreach ($this->tickets as $ticket) { |
|
436 | + $cart->add_ticket_to_cart($ticket['ticket']); |
|
437 | + } |
|
438 | + |
|
439 | + |
|
440 | + // setup txn property |
|
441 | + $this->txn = EE_Transaction::new_instance( |
|
442 | + array( |
|
443 | + 'TXN_timestamp' => time(), // unix timestamp |
|
444 | + 'TXN_total' => 0, // txn_total |
|
445 | + 'TXN_paid' => 0, // txn_paid |
|
446 | + 'STS_ID' => EEM_Transaction::incomplete_status_code, // sts_id |
|
447 | + 'TXN_session_data' => null, // dump of txn session object (we're just going to leave blank here) |
|
448 | + 'TXN_hash_salt' => null, // hash salt blank as well |
|
449 | + 'TXN_ID' => 999999 |
|
450 | + ) |
|
451 | + ); |
|
452 | + |
|
453 | + |
|
454 | + // setup reg_objects |
|
455 | + // note we're setting up a reg object for each attendee in each event but ALSO adding to the reg_object array. |
|
456 | + $this->reg_objs = array(); |
|
457 | + $regid = 9999990; |
|
458 | + foreach ($this->_attendees as $key => $attendee) { |
|
459 | + // note we need to setup reg_objects for each event this attendee belongs to |
|
460 | + $regatt = $attendee['att_obj'] instanceof EE_Attendee ? $attendee['att_obj']->ID() : null; |
|
461 | + $regtxn = $this->txn->ID(); |
|
462 | + $regcnt = 1; |
|
463 | + foreach ($attendee['line_ref'] as $evtid) { |
|
464 | + foreach ($this->_events[ $evtid ]['tkt_objs'] as $ticket) { |
|
465 | + if (! $ticket instanceof EE_Ticket) { |
|
466 | + continue; |
|
467 | + } |
|
468 | + $reg_array = array( |
|
469 | + 'EVT_ID' => $evtid, |
|
470 | + 'ATT_ID' => $regatt, |
|
471 | + 'TXN_ID' => $regtxn, |
|
472 | + 'TKT_ID' => $ticket->ID(), |
|
473 | + 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
474 | + 'REG_date' => time(), |
|
475 | + 'REG_final_price' => $ticket->get('TKT_price'), |
|
476 | + 'REG_session' => 'dummy_session_id', |
|
477 | + 'REG_code' => $regid . '-dummy-generated-code', |
|
478 | + 'REG_url_link' => $regcnt . '-daafpapasdlfakasdfpqasdfasdf', |
|
479 | + 'REG_count' => $regcnt, |
|
480 | + 'REG_group_size' => $this->_events[ $evtid ]['total_attendees'], |
|
481 | + 'REG_att_is_going' => true, |
|
482 | + 'REG_ID' => $regid |
|
483 | + ); |
|
484 | + $REG_OBJ = EE_Registration::new_instance($reg_array); |
|
485 | + $this->_attendees[ $key ]['reg_objs'][ $regid ] = $REG_OBJ; |
|
486 | + $this->_events[ $evtid ]['reg_objs'][] = $REG_OBJ; |
|
487 | + $this->reg_objs[] = $REG_OBJ; |
|
488 | + $this->tickets[ $ticket->ID() ]['reg_objs'][ $regid ] = $REG_OBJ; |
|
489 | 489 | |
490 | - $regcnt++; |
|
491 | - $regid++; |
|
492 | - } |
|
493 | - } |
|
494 | - } |
|
495 | - |
|
496 | - |
|
497 | - // setup line items! |
|
498 | - $line_item_total = EEH_Line_Item::create_total_line_item($this->txn); |
|
499 | - |
|
500 | - // add tickets |
|
501 | - foreach ($this->tickets as $tktid => $item) { |
|
502 | - $qty = $item['count']; |
|
503 | - $ticket = $item['ticket']; |
|
504 | - EEH_Line_Item::add_ticket_purchase($line_item_total, $ticket, $qty); |
|
505 | - } |
|
506 | - |
|
507 | - $shipping_line_item = EE_Line_Item::new_instance(array( |
|
508 | - 'LIN_name' => __('Shipping Surcharge', 'event_espresso'), |
|
509 | - 'LIN_desc' => __('Sent via Millenium Falcon', 'event_espresso'), |
|
510 | - 'LIN_unit_price' => 20, |
|
511 | - 'LIN_quantity' => 1, |
|
512 | - 'LIN_is_taxable' => true, |
|
513 | - 'LIN_total' => 20, |
|
514 | - 'LIN_type' => EEM_Line_Item::type_line_item |
|
515 | - )); |
|
516 | - EEH_Line_Item::add_item($line_item_total, $shipping_line_item); |
|
517 | - $this->additional_line_items = array($shipping_line_item); |
|
518 | - |
|
519 | - // now let's add taxes |
|
520 | - EEH_Line_Item::apply_taxes($line_item_total); |
|
521 | - |
|
522 | - // now we should be able to get the items we need from this object |
|
523 | - $event_line_items = EEH_Line_Item::get_pre_tax_subtotal($line_item_total)->children(); |
|
524 | - $line_items = array(); |
|
525 | - foreach ($event_line_items as $line_id => $line_item) { |
|
526 | - if (! $line_item instanceof EE_Line_Item || $line_item->OBJ_type() !== 'Event') { |
|
527 | - continue; |
|
528 | - } |
|
529 | - $ticket_line_items = EEH_Line_Item::get_ticket_line_items($line_item); |
|
530 | - foreach ($ticket_line_items as $ticket_line_id => $ticket_line_item) { |
|
531 | - if (! $ticket_line_item instanceof EE_Line_Item) { |
|
532 | - continue; |
|
533 | - } |
|
534 | - $this->tickets[ $ticket_line_item->OBJ_ID() ]['line_item'] = $ticket_line_item; |
|
535 | - $this->tickets[ $ticket_line_item->OBJ_ID() ]['sub_line_items'] = $ticket_line_item->children(); |
|
536 | - $line_items[ $ticket_line_item->ID() ]['children'] = $ticket_line_item->children(); |
|
537 | - $line_items[ $ticket_line_item->ID() ]['EE_Ticket'] = $this->tickets[ $ticket_line_item->OBJ_ID() ]['ticket']; |
|
538 | - } |
|
539 | - } |
|
540 | - |
|
541 | - $this->line_items_with_children = $line_items; |
|
542 | - $this->tax_line_items = $line_item_total->tax_descendants(); |
|
543 | - |
|
544 | - // add proper total to transaction object. |
|
545 | - $grand_total = $line_item_total->recalculate_total_including_taxes(); |
|
546 | - $this->grand_total_line_item = $line_item_total; |
|
547 | - $this->txn->set_total($grand_total); |
|
548 | - |
|
549 | - |
|
550 | - // add additional details for each registration |
|
551 | - foreach ($this->reg_objs as $reg) { |
|
552 | - if (! $reg instanceof EE_Registration) { |
|
553 | - continue; |
|
554 | - } |
|
555 | - $this->_registrations[ $reg->ID() ]['tkt_obj'] = $this->tickets[ $reg->get('TKT_ID') ]['ticket']; |
|
556 | - $this->_registrations[ $reg->ID() ]['evt_obj'] = $this->_events[ $reg->get('EVT_ID') ]['event']; |
|
557 | - $this->_registrations[ $reg->ID() ]['reg_obj'] = $reg; |
|
558 | - $this->_registrations[ $reg->ID() ]['ans_objs'] = $this->_attendees[ $reg->get('ATT_ID') ]['ans_objs']; |
|
559 | - $this->_registrations[ $reg->ID() ]['att_obj'] = $this->_attendees[ $reg->get('ATT_ID') ]['att_obj']; |
|
560 | - $this->_registrations[ $reg->ID() ]['dtt_objs'] = $this->tickets[ $reg->get('TKT_ID') ]['dtt_objs']; |
|
561 | - } |
|
562 | - |
|
563 | - |
|
564 | - // events and attendees |
|
565 | - $this->events = $this->_events; |
|
566 | - $this->attendees = $this->_attendees; |
|
567 | - $this->registrations = $this->_registrations; |
|
568 | - |
|
569 | - $attendees_to_shift = $this->_attendees; |
|
570 | - |
|
571 | - // setup primary attendee property |
|
572 | - $this->primary_attendee_data = array( |
|
573 | - 'fname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
574 | - ? $this->_attendees[999999991]['att_obj']->fname() |
|
575 | - : '', |
|
490 | + $regcnt++; |
|
491 | + $regid++; |
|
492 | + } |
|
493 | + } |
|
494 | + } |
|
495 | + |
|
496 | + |
|
497 | + // setup line items! |
|
498 | + $line_item_total = EEH_Line_Item::create_total_line_item($this->txn); |
|
499 | + |
|
500 | + // add tickets |
|
501 | + foreach ($this->tickets as $tktid => $item) { |
|
502 | + $qty = $item['count']; |
|
503 | + $ticket = $item['ticket']; |
|
504 | + EEH_Line_Item::add_ticket_purchase($line_item_total, $ticket, $qty); |
|
505 | + } |
|
506 | + |
|
507 | + $shipping_line_item = EE_Line_Item::new_instance(array( |
|
508 | + 'LIN_name' => __('Shipping Surcharge', 'event_espresso'), |
|
509 | + 'LIN_desc' => __('Sent via Millenium Falcon', 'event_espresso'), |
|
510 | + 'LIN_unit_price' => 20, |
|
511 | + 'LIN_quantity' => 1, |
|
512 | + 'LIN_is_taxable' => true, |
|
513 | + 'LIN_total' => 20, |
|
514 | + 'LIN_type' => EEM_Line_Item::type_line_item |
|
515 | + )); |
|
516 | + EEH_Line_Item::add_item($line_item_total, $shipping_line_item); |
|
517 | + $this->additional_line_items = array($shipping_line_item); |
|
518 | + |
|
519 | + // now let's add taxes |
|
520 | + EEH_Line_Item::apply_taxes($line_item_total); |
|
521 | + |
|
522 | + // now we should be able to get the items we need from this object |
|
523 | + $event_line_items = EEH_Line_Item::get_pre_tax_subtotal($line_item_total)->children(); |
|
524 | + $line_items = array(); |
|
525 | + foreach ($event_line_items as $line_id => $line_item) { |
|
526 | + if (! $line_item instanceof EE_Line_Item || $line_item->OBJ_type() !== 'Event') { |
|
527 | + continue; |
|
528 | + } |
|
529 | + $ticket_line_items = EEH_Line_Item::get_ticket_line_items($line_item); |
|
530 | + foreach ($ticket_line_items as $ticket_line_id => $ticket_line_item) { |
|
531 | + if (! $ticket_line_item instanceof EE_Line_Item) { |
|
532 | + continue; |
|
533 | + } |
|
534 | + $this->tickets[ $ticket_line_item->OBJ_ID() ]['line_item'] = $ticket_line_item; |
|
535 | + $this->tickets[ $ticket_line_item->OBJ_ID() ]['sub_line_items'] = $ticket_line_item->children(); |
|
536 | + $line_items[ $ticket_line_item->ID() ]['children'] = $ticket_line_item->children(); |
|
537 | + $line_items[ $ticket_line_item->ID() ]['EE_Ticket'] = $this->tickets[ $ticket_line_item->OBJ_ID() ]['ticket']; |
|
538 | + } |
|
539 | + } |
|
540 | + |
|
541 | + $this->line_items_with_children = $line_items; |
|
542 | + $this->tax_line_items = $line_item_total->tax_descendants(); |
|
543 | + |
|
544 | + // add proper total to transaction object. |
|
545 | + $grand_total = $line_item_total->recalculate_total_including_taxes(); |
|
546 | + $this->grand_total_line_item = $line_item_total; |
|
547 | + $this->txn->set_total($grand_total); |
|
548 | + |
|
549 | + |
|
550 | + // add additional details for each registration |
|
551 | + foreach ($this->reg_objs as $reg) { |
|
552 | + if (! $reg instanceof EE_Registration) { |
|
553 | + continue; |
|
554 | + } |
|
555 | + $this->_registrations[ $reg->ID() ]['tkt_obj'] = $this->tickets[ $reg->get('TKT_ID') ]['ticket']; |
|
556 | + $this->_registrations[ $reg->ID() ]['evt_obj'] = $this->_events[ $reg->get('EVT_ID') ]['event']; |
|
557 | + $this->_registrations[ $reg->ID() ]['reg_obj'] = $reg; |
|
558 | + $this->_registrations[ $reg->ID() ]['ans_objs'] = $this->_attendees[ $reg->get('ATT_ID') ]['ans_objs']; |
|
559 | + $this->_registrations[ $reg->ID() ]['att_obj'] = $this->_attendees[ $reg->get('ATT_ID') ]['att_obj']; |
|
560 | + $this->_registrations[ $reg->ID() ]['dtt_objs'] = $this->tickets[ $reg->get('TKT_ID') ]['dtt_objs']; |
|
561 | + } |
|
562 | + |
|
563 | + |
|
564 | + // events and attendees |
|
565 | + $this->events = $this->_events; |
|
566 | + $this->attendees = $this->_attendees; |
|
567 | + $this->registrations = $this->_registrations; |
|
568 | + |
|
569 | + $attendees_to_shift = $this->_attendees; |
|
570 | + |
|
571 | + // setup primary attendee property |
|
572 | + $this->primary_attendee_data = array( |
|
573 | + 'fname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
574 | + ? $this->_attendees[999999991]['att_obj']->fname() |
|
575 | + : '', |
|
576 | 576 | |
577 | - 'lname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
578 | - ? $this->_attendees[999999991]['att_obj']->lname() |
|
579 | - : '', |
|
577 | + 'lname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
578 | + ? $this->_attendees[999999991]['att_obj']->lname() |
|
579 | + : '', |
|
580 | 580 | |
581 | - 'email' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
582 | - ? $this->_attendees[999999991]['att_obj']->email() |
|
583 | - : '', |
|
581 | + 'email' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
582 | + ? $this->_attendees[999999991]['att_obj']->email() |
|
583 | + : '', |
|
584 | 584 | |
585 | - 'att_obj' => $this->_attendees[999999991]['att_obj'], |
|
585 | + 'att_obj' => $this->_attendees[999999991]['att_obj'], |
|
586 | 586 | |
587 | - 'reg_obj' => array_shift($attendees_to_shift[999999991]['reg_objs']) |
|
588 | - ); |
|
589 | - |
|
590 | - // reg_info property |
|
591 | - // note this isn't referenced by any shortcode parsers so we'll ignore for now. |
|
592 | - $this->reg_info = array(); |
|
593 | - |
|
594 | - // let's set a reg_obj for messengers expecting one. |
|
595 | - $this->reg_obj = array_shift($this->_attendees[999999991]['reg_objs']); |
|
596 | - |
|
597 | - // the below are just dummy items. |
|
598 | - $this->user_id = 1; |
|
599 | - $this->ip_address = '192.0.2.1'; |
|
600 | - $this->user_agent = ''; |
|
601 | - $this->init_access = time(); |
|
602 | - $this->last_access = time(); |
|
603 | - } |
|
587 | + 'reg_obj' => array_shift($attendees_to_shift[999999991]['reg_objs']) |
|
588 | + ); |
|
589 | + |
|
590 | + // reg_info property |
|
591 | + // note this isn't referenced by any shortcode parsers so we'll ignore for now. |
|
592 | + $this->reg_info = array(); |
|
593 | + |
|
594 | + // let's set a reg_obj for messengers expecting one. |
|
595 | + $this->reg_obj = array_shift($this->_attendees[999999991]['reg_objs']); |
|
596 | + |
|
597 | + // the below are just dummy items. |
|
598 | + $this->user_id = 1; |
|
599 | + $this->ip_address = '192.0.2.1'; |
|
600 | + $this->user_agent = ''; |
|
601 | + $this->init_access = time(); |
|
602 | + $this->last_access = time(); |
|
603 | + } |
|
604 | 604 | } |