initial commit
[namibia] / module / Auction / src / Auction / Pdf / HPI.php
1 <?php
2 namespace Auction\Pdf;
3
4
5
6 class HPI extends \Utility\Service\PdfTemplate
7 {
8         /**
9          * Utility for easy parameter retrieval.
10          * @param string $param
11          * @param unknown $default
12          * @return unknown
13          */
14         protected function getStockParam($param, $default)
15         {
16                 return !is_null($this->jobRecord->stock->$param)
17                 ? $this->jobRecord->stock->$param
18                 : $default;
19         }
20
21         /**
22          * Utility for easy parameter retrieval.
23          * @param string $param
24          * @param unknown $default
25          * @return unknown
26          */
27         protected function getStockSubParam($ref, $param, $default)
28         {
29                 $ref = !is_null($this->jobRecord->stock->$ref)
30                 ? $this->jobRecord->stock->$ref
31                 : null;
32                 return is_object($ref)
33                 ? $ref->$param
34                 : $default;
35         }
36
37
38
39         /**
40          * Build the content.
41          */
42         public function build()
43         {
44                 #-> Set data item to work with.
45                 $this->jobRecord = $this->_input['jobRecord'];
46                 $dateTimeFormat = \Utility\Definitions\Locale::getDateTimeFormat();
47                 $dateFormat = \Utility\Definitions\Locale::getDateFormat();
48                 $currencyPrefix = \Utility\Definitions\Locale::getCurrencyPrefix();
49                 $authData = \Utility\Registry::getAuthData();
50                 $auctionDate = $this->jobRecord->endDate->format($dateFormat);
51                 $dateOfPrint = 'Report date: <span style="color:#333;">' . date('Y-m-d H:i:s') . '</span>';
52                 
53                 
54                 
55                 /* $authData['firstName'];
56                 $authData['familyName']; */
57                 $referenceNo = 'Reference no.: <span style="color:#333;">' . $this->jobRecord->stock->referenceNumber . '</span>';
58
59
60                 /* --------------------------------- TRANSUNION REPORT --------------------------------- */
61                 $type = $this->jobRecord->stock->type;
62                 $this->append(
63                                 '<br /> <div style="font-size:24px;font-weight:bold;text-align:center">'
64                                 . 'TRANSUNION REPORT </div>' . '<br><br>' .
65                                 ' '
66                 );
67
68                 #-> Receipt Detail
69                 $ReceiptDetail = '&nbsp;';
70
71                 $seller = $this->jobRecord->company->name;
72                         
73                 $this->append(
74                                 'I, the undersigned  '
75                         . $buyer
76                                 . ' (known hereinafter as \93The Purchaser\94) declare that:- '
77                         . '<br>'
78                         . '1.   I am The Purchaser of the below-mentioned vehicle which was purchased from '
79                         . $seller . ' (\93The Seller\94)'
80                         . 'by web-auction conducted by Bid4Cars on the '
81                         . $auctionDate
82                                         .'<br>'
83                         . '2.   I hereby acknowledge having taken delivery from \93The Seller\94 of the vehicle, the specifics of which are summarized here:-'
84                         . '<br>'
85                         );
86                                                 
87                         /* --------------------------------- VEHICLE, DAMAGES, ACCESSORIES --------------------------------- */
88
89                         #-> Vehicle details
90                         $vehicleDetail = '&nbsp;';
91
92                         $keys = $this->getStockParam('spareKeys', null);
93                         if (is_null($keys))
94                         {
95                                 $keys = '';
96                         }
97                         else
98                         {
99                                 $keys = $keys
100                                 ? 'Yes'
101                                                 : 'No';
102                         }
103                         $table = $this->newTable(
104                                         array(55, 45),
105                                         'padding:0;margin:0;font-size:10px;',
106                                         '',
107                                         'padding:2px 3px 2px 0;margin:0;'
108                         );
109                         $table
110                         ->addTitle('Vehicle specifications', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
111                         ->addKeyValueDataSet(array(
112                                         'Year:'                 => $this->getStockSubParam('vehicleYear', 'name', ''),
113                                         'Category:'             => $type->category->name,
114                                         'Make:'                 => $type->model->make->name,
115                                         'Model:'                => $type->model->name,
116                                         'Type:'                 => $type->name,
117                                         'Registration no.:'     => $this->getStockParam('registrationNumber', ''),
118                                         'Fuel type:'            => $this->getStockSubParam('fuelType', 'name', ''),
119                                         'Transmission type:'    => $this->getStockSubParam('transmissionType', 'name', ''),
120                                         'VIN no.:'              => $this->getStockParam('vinNumber', ''),
121                                         'Engine no.:'           => $this->getStockParam('engineNumber', ''),
122                                         'MM code:'              => $type->mmCode,
123                                         'Kms:'                  => $this->getStockParam('km', ''),
124                                         'Condition:'            => $this->getStockSubParam('condition', 'name', ''),
125                                         'Main exterior colour:' => $this->getStockSubParam('exteriorColour', 'name', ''),
126                                         'Main interior colour:' => $this->getStockSubParam('interiorColour', 'name', ''),
127                                         'Upholstery:'           => $this->getStockSubParam('upholstery', 'name', ''),
128                                         'Papers:'               => $this->getStockSubParam('papers', 'name', ''),
129                                         'Papers comments:'      => $this->getStockParam('papersNotes', ''),
130                                         'Natis:'                => $this->getStockSubParam('natis', 'name', ''),
131                                         'Spare keys:'           => $keys,
132                                         'FSH:'                  => $this->getStockSubParam('fullServiceHistory', 'name', ''),
133                                         'FSH comments:'         => $this->getStockParam('fshNotes', '')
134                         ), 0, '', 'color:#666;');
135                         $vehicleDetail = $table->publish();
136
137
138
139                         #-> Second row of data-blocks.
140                         $container = $this
141                         ->newTable(
142                         array(30, 5, 30, 5, 30),
143                         'margin:0;font-size:10px;vertical-align:top;',
144                                         '',
145                                         'padding:10px 0 0 0;'
146                                 )
147                                 ->setCellValue(0, 0, $vehicleDetail);
148                                 $this->append($container->publish() . '<br />');
149
150                                 /* --------------------------------- DELIVERY RECEIPT CONTINUE --------------------------------- */
151
152
153                                 $this->append(
154                                                 '<div>'
155                                         . '3.   I confirm and acknowledge that I am bound by the terms and conditions of auction and sale, as set out on the Bid4Cars website.'
156                                         . '<br>'
157                                         . '4.   The provisions of the terms are to be read as if specifically set out and incorporated herein.'
158                                         . '<br><br><br><br>'
159                                         . 'DATED at ____________________________________________ on ' . $auctionDate
160                                                 . '<br><br><br><br>'
161                                         . 'Signature    :       ____________________________'
162                                         . '<br>'
163                                         . 'Print Name   :       ' . $buyer
164                                                 . '<br>'
165                                         . 'Who warrants being the authorized representative of the Purchaser.'
166                                         . '<br>'
167                         
168                                         . '</div>'
169                         );
170
171
172
173                         $this->append(
174                                         '<div style="position:absolute;bottom:0;left:0;padding:0;margin:0;width:100%;">'
175                                         . '<table cellpadding="0px" cellspacing="0px" style="border:0px;width:100%;">'
176                                         . '<tr>'
177                                         . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
178                                         . $dateOfPrint . '</i></td>'
179                                         . '<td style="width:5%">&nbsp;</td>'
180                                         . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
181                                         . $printedBy . '</i></td>'
182                                         . '<td style="width:5%">&nbsp;</td>'
183                                         . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
184                                         . $referenceNo . '</i></td>'
185                                         . '</tr>'
186                                         . '</table>'
187                                         . '<br>'
188                                         . '</div>'
189                                 );
190                                                 
191                                         
192
193         }
194
195
196 }