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