initial commit
[namibia] / module / Auction / src / Auction / Pdf / Declaration.php
1 <?php
2 namespace Auction\Pdf;
3
4
5
6 class Declaration extends \Utility\Service\PdfTemplate
7 {
8
9         protected function getStockParam($param, $default)
10         {
11                 return !is_null($this->jobRecord->stock->$param)
12                         ? $this->jobRecord->stock->$param
13                         : $default;
14         }
15
16         /**
17          * Utility for easy parameter retrieval.
18          * @param string $param
19          * @param unknown $default
20          * @return unknown
21          */
22         protected function getStockSubParam($ref, $param, $default)
23         {
24                 $ref = !is_null($this->jobRecord->stock->$ref)
25                         ? $this->jobRecord->stock->$ref
26                         : null;
27                 return is_object($ref)
28                         ? $ref->$param
29                         : $default;
30         }
31
32         /**
33          * Utility for easy parameter retrieval.
34          * @param string $param
35          * @param unknown $default
36          * @return unknown
37          */
38         protected function getValuationParam($param, $default)
39         {
40                 return !is_null($this->jobRecord->stock->valuation)
41                                 && !is_null($this->jobRecord->stock->valuation->$param)
42                         ? $this->jobRecord->stock->valuation->$param
43                         : $default;
44         }
45
46
47         /**
48          * Build the content.
49          */
50         public function build()
51         {
52                 #-> Set data item to work with.
53                 $this->jobRecord = $this->_input['jobRecord'];
54                 $dateTimeFormat = \Utility\Definitions\Locale::getDateTimeFormat();
55                 $dateFormat = \Utility\Definitions\Locale::getDateFormat();
56                 $currencyPrefix = \Utility\Definitions\Locale::getCurrencyPrefix();
57                 $authData = \Utility\Registry::getAuthData();
58                 
59                 $auctionDate = $this->jobRecord->endDate->format($dateFormat);
60                 $dateOfPrint = 'Date of print: <span style="color:#333;">' . date('Y-m-d H:i:s') . '</span>';
61                 $printedBy   = 'Printed by: <span style="color:#333;">' . $authData['firstName']
62                                          . ' ' . $authData['familyName'] . '</span>';
63                 $referenceNo = 'Reference no.: <span style="color:#333;">' . $this->jobRecord->stock->referenceNumber . '</span>';
64
65                 /* --------------------------------- Buyer & Seller details --------------------------------- */
66                 #-> Buyer & Seller details
67                 $table = $this->newTable(
68                                         array(60, 40),
69                                         'padding:0;margin:0;font-size:10px;',
70                                         '',
71                                         'padding:2px 3px 2px 0;margin:0;'
72                         );
73                         $table
74                                 ->addTitle('Buyer', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
75                                 ->addKeyValueDataSet(array(
76                                                 'Buyer dealership:'     => $this->jobRecord->soldToCompany->name,
77                                                 'Buyer name:'                   => $this->jobRecord->soldToCompany->contact->firstName,
78                                                 'Buyer surname:'                => $this->jobRecord->soldToCompany->contact->familyName,
79                                                 'Buyer Mobile:'         => $this->jobRecord->soldToCompany->contact->mobile,
80                                                 'Buyer Email:'          => $this->jobRecord->soldToCompany->contact->email,
81                                 ), 0, 'font-weight:bold;', 'color:#666;');
82                         $buyerDetail = $table->publish();
83                 
84                 
85                         $table = $this->newTable(
86                                         array(60, 40),
87                                         'padding:0;margin:0;font-size:10px;',
88                                         '',
89                                         'padding:2px 3px 2px 0;margin:0;'
90                         );
91                         $table
92                         ->addTitle('Seller', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
93                         ->addKeyValueDataSet(array(
94                                         'Seller dealership:'    => $this->jobRecord->company->name,
95                                         'Seller name:'                  => $this->jobRecord->company->contact->firstName,
96                                         'Seller surname:'               => $this->jobRecord->company->contact->familyName,
97                                         'Seller Mobile:'        => $this->jobRecord->company->contact->mobile,
98                                         'Seller Email:'         => $this->jobRecord->company->contact->email,
99                         ), 0, 'font-weight:bold;', 'color:#666;');
100                         $sellerDetail = $table->publish();
101                         
102                         $container = $this
103                         ->newTable(
104                                         array(45, 10, 45),
105                                         'margin:0;font-size:10px;vertical-align:top;',
106                                         '',
107                                         'padding:10px 0 0 0;'
108                         )
109                         ->setCellValue(0, 0, $buyerDetail)
110                         ->setCellValue(0, 2, $sellerDetail);
111                         $this->append($container->publish() . '<br />');
112                         
113                  /* --------------------------------- DECLARATION --------------------------------- */
114
115                         $this->append(
116                                         '<div>'
117                                         . '<h2>DECLARATION</h2>'
118                                         . 'We, the undersigned, declare that:' . '<br><br>'
119                                         . '1.   The Purchaser purchased the abovementioned vehicle from the Seller by web-auction conducted by Bid4Cars on the '
120                                         . $auctionDate . '<br>'
121                                         . '2.   The Purchaser hereby acknowledges having taken delivery of the vehicle from the Seller and being satisfied that the vehicle is as described in the Seller\92s Regulation 32 Notice.'
122                                         . '<br>'
123                                         . '3.   We confirm and acknowledge that we are bound by the terms and conditions of auction and sale, as set out on the Bid4Cars site.'
124                                         . '<br>'
125                                         . '4.   The provisions of the terms are to be read as if specifically set out and incorporated herein.' . '<br><br><br>'
126                                         . 'DATED at: ' . $auctionDate . '<br>'
127                                         . '</div>'
128                         );
129                 
130
131                 /* --------------------------------- SIGNATURES --------------------------------- */
132                 
133                         #-> Signatures.
134                 
135                         $this->append(
136                                         $this->newSignatureLine()
137                                                 ->addSignatureLine('Purchaser', 'Signature', 'Date')
138                                                 ->addSignatureText('a', 'Who warrants being the authorized representative of the Purchaser.')
139                                                 ->addSignatureLine('Seller', 'Signature', 'Date')
140                                                 ->addSignatureText('b', 'Who warrants being the authorized representative of the Seller.')
141                                                 ->publish()
142                                         );      
143                         
144                 $this->append(
145                                 '<div style="position:absolute;bottom:0;left:0;padding:0;margin:0;width:100%;">'
146                                 . '<table cellpadding="0px" cellspacing="0px" style="border:0px;width:100%;">'
147                                 . '<tr>'
148                                 . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
149                                 . $dateOfPrint . '</i></td>'
150                                 . '<td style="width:5%">&nbsp;</td>'
151                                 . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
152                                 . $printedBy . '</i></td>'
153                                 . '<td style="width:5%">&nbsp;</td>'
154                                 . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
155                                 . $referenceNo . '</i></td>'
156                                 . '</tr>'
157                                 . '</table>'
158                                 . '</div>'
159                                 );
160         }
161 }