f653d3e3b9ecd4b9f3458fa0bdf22e6cf13f3c5a
[civicrm-core.git] / CRM / Event / Cart / Form / Checkout / ThankYou.php
1 <?php
2 class CRM_Event_Cart_Form_Checkout_ThankYou extends CRM_Event_Cart_Form_Cart {
3 public $line_items = NULL;
4 public $sub_total = 0;
5
6 function buildLineItems() {
7 foreach ($this->cart->events_in_carts as $event_in_cart) {
8 $event_in_cart->load_location();
9 }
10 $line_items = $this->get('line_items');
11 foreach ($line_items as $line_item) {
12 $event_in_cart = $this->cart->get_event_in_cart_by_event_id($line_item['event_id']);
13
14 $not_waiting_participants = array();
15 foreach ($event_in_cart->not_waiting_participants() as $participant) {
16 $not_waiting_participants[] = array(
17 'display_name' => CRM_Contact_BAO_Contact::displayName($participant->contact_id),
18 );
19 }
20 $waiting_participants = array();
21 foreach ($event_in_cart->waiting_participants() as $participant) {
22 $waiting_participants[] = array(
23 'display_name' => CRM_Contact_BAO_Contact::displayName($participant->contact_id),
24 );
25 }
26
27 $line_item['event'] = $event_in_cart->event;
28 $line_item['num_participants'] = count($not_waiting_participants);
29 $line_item['participants'] = $not_waiting_participants;
30 $line_item['num_waiting_participants'] = count($waiting_participants);
31 $line_item['waiting_participants'] = $waiting_participants;
32 $line_item['location'] = $event_in_cart->location;
33 $line_item['class'] = $event_in_cart->event->parent_event_id ? 'subevent' : NULL;
34
35 $this->sub_total += $line_item['amount'];
36 $this->line_items[] = $line_item;
37 }
38 $this->assign('line_items', $this->line_items);
39 }
40
41 function buildQuickForm() {
42 $defaults = array();
43 $ids = array();
44 $template_params_to_copy = array(
45 'billing_name',
46 'billing_city',
47 'billing_country',
48 'billing_postal_code',
49 'billing_state',
50 'billing_street_address',
51 'credit_card_exp_date',
52 'credit_card_type',
53 'credit_card_number',
54 );
55 foreach ($template_params_to_copy as $template_param_to_copy) {
56 $this->assign($template_param_to_copy, $this->get($template_param_to_copy));
57 }
58 $this->buildLineItems();
59 $this->assign('discounts', $this->get('discounts'));
60 $this->assign('events_in_carts', $this->cart->events_in_carts);
61 $this->assign('transaction_id', $this->get('trxn_id'));
62 $this->assign('transaction_date', $this->get('trxn_date'));
63 $this->assign('payment_required', $this->get('payment_required'));
64 $this->assign('is_pay_later', $this->get('is_pay_later'));
65 $this->assign('pay_later_receipt', $this->get('pay_later_receipt'));
66 $this->assign('sub_total', $this->sub_total);
67 $this->assign('total', $this->get('total'));
68 // XXX Configure yourself
69 //$this->assign( 'site_name', "" );
70 //$this->assign( 'site_contact', "" );
71 }
72
73 function preProcess() {
74 $this->event_cart_id = $this->get('last_event_cart_id');
75 $this->loadCart();
76 //$this->loadParticipants( );
77 }
78 }
79