Git Repository Public Repository

namibia

URLs

Copy to Clipboard
 
df0489e1eeeeab5a9bd44e1d84fce49924fe1bac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
<?php
namespace Valuation\Pdf;



class Complete extends \Utility\Service\PdfTemplate
{


	/**
	 * PDF title.
	 * @var string
	 */
	protected $_title = 'Stock Information';
	/**
	 * @var \Stock\Entity\Stock
	 */
	protected $jobRecord;
	/**
	 * @var boolean
	 */
	protected $showSalesDataOnly = false;
	/**
	 * @var boolean
	 */
	protected $showTradeDataOnly = false;
	/**
	 * @var boolean
	 */
	protected $showShortVehicleDetails = false;
	/**
	 * @var boolean
	 */
	protected $showCustomerDetails = true;
	/**
	 * @var boolean
	 */
	protected $showValuationDetails = true;
	/**
	 * @var boolean
	 */
	protected $showPricingDetails = true;
	/**
	 * @var boolean
	 */
	protected $showVehicleDetails = true;
	/**
	 * @var boolean
	 */
	protected $showVehicleNotes = true;
	/**
	 * @var boolean
	 */
	protected $showDamageDetails = true;
	/**
	 * @var boolean
	 */
	protected $showAccessoryDetails = true;
	/**
	 * @var boolean
	 */
	protected $showSignatureLines = true;
	/**
	 * @var boolean
	 */
	protected $showTermsAndConditions = true;
	/**
	 * @var boolean
	 */
	protected $showOffersReceived = true;
	/**
	 * @var boolean
	 */
	protected $showOfferMade = true;


	/**
	 * Utility for easy parameter retrieval.
	 * @param string $param
	 * @param unknown $default
	 * @return unknown
	 */
	protected function getStockParam($param, $default)
	{
		return !is_null($this->jobRecord->$param)
			? $this->jobRecord->$param
			: $default;
	}

	/**
	 * Utility for easy parameter retrieval.
	 * @param string $param
	 * @param unknown $default
	 * @return unknown
	 */
	protected function getStockSubParam($ref, $param, $default)
	{
		$ref = !is_null($this->jobRecord->$ref)
			? $this->jobRecord->$ref
			: null;
		return is_object($ref)
			? $ref->$param
			: $default;
	}

	/**
	 * Utility for easy parameter retrieval.
	 * @param string $param
	 * @param unknown $default
	 * @return unknown
	 */
	protected function getValuationParam($param, $default)
	{
		return !is_null($this->jobRecord->valuation)
				&& !is_null($this->jobRecord->valuation->$param)
			? $this->jobRecord->valuation->$param
			: $default;
	}


	/**
	 * Build the content.
	 */
	public function build()
	{
		#-> Set data item to work with.
		$this->jobRecord = $this->_input['jobRecord']->stock;
		$dateTimeFormat = \Utility\Definitions\Locale::getDateTimeFormat();
		$currencyPrefix = \Utility\Definitions\Locale::getCurrencyPrefix();
		$authData = \Utility\Registry::getAuthData();
		$dateOfPrint = 'Date of print: <span style="color:#333;">' . date('Y-m-d H:i:s') . '</span>';
		$printedBy   = 'Printed by: <span style="color:#333;">' . $authData['firstName']
					 . ' ' . $authData['familyName'] . '</span>';
		$referenceNo = 'Reference no.: <span style="color:#333;">' . $this->jobRecord->referenceNumber . '</span>';


		/* --------------------------------- CUSTOMER, VALUATION, PRICING --------------------------------- */
		$type = $this->jobRecord->type;
		$this->append(
				'<br /><div style="font-size:16px;font-weight:bold;">'
				. $type->model->make->name . ' '
				. $type->model->name . ' '
				. $type->name . ' ('
				. $type->introYear->name . ' - '
				. (!is_null($type->discYear) ? $type->discYear->name : 'Current') . ')'
				. '</div><hr /><br />'
				);


		/* --------------------------------- CUSTOMER, VALUATION, PRICING --------------------------------- */
		#-> Customer
		$customerDetail = '&nbsp;';
		if ($this->showCustomerDetails)
		{
			$table = $this->newTable(
					array(60, 40),
					'padding:0;margin:0;font-size:10px;',
					'',
					'padding:2px 3px 2px 0;margin:0;'
			);
			$department = $this->getValuationParam('department', null);
			$department = !is_null($department)
				? $department
				: '&nbsp;';
			$table
				->addTitle('Customer', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
				->addKeyValueDataSet(array(
						'Customer name:'    => $this->getValuationParam('firstName', ''),
						'Customer surname:' => $this->getValuationParam('familyName', ''),
						'ID:'               => $this->getValuationParam('idNumber', ''),
						'Mobile:'           => $this->getValuationParam('mobile', ''),
						'Email:'            => $this->getValuationParam('email', ''),
						'Department:'       => $department,
						'&nbsp;'       		=> '&nbsp;',
						'Address:'       	=> '&nbsp;',
						'<span style="color:#FFF;font-size:20px;">a1</span>'       		=> '&nbsp;',
						'<span style="color:#FFF;font-size:10px;">1</span><span style="color:#000;font-size:10px;">______________________________________</span>'       			=> '&nbsp;',
						'<span style="color:#FFF;font-size:20px;">a</span>'       		=> '&nbsp;',
						'<span style="color:#FFF;font-size:10px;">2</span><span style="color:#000;font-size:10px;">______________________________________</span>'       			=> '&nbsp;',
						'<span style="color:#FFF;font-size:20px;">b</span>'       		=> '&nbsp;',
						'<span style="color:#FFF;font-size:10px;">3</span><span style="color:#000;font-size:10px;">______________________________________</span>'       			=> '&nbsp;'
						
				), 0, 'font-weight:bold;', 'color:#000;');
			$customerDetail = $table->publish();
		}
		#-> Customer alternated with dealership details for traders.
		if ($this->showTradeDataOnly)
		{
			$table = $this->newTable(
					array(60, 40),
					'padding:0;margin:0;font-size:10px;',
					'',
					'padding:2px 3px 2px 0;margin:0;'
			);
			$department = $this->getValuationParam('department', null);
			$department = !is_null($department)
				? $department
				: '&nbsp;';
			$contact = $this->getStockSubParam('company', 'contact', null);
			$table
				->addTitle('Dealership', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
				->addKeyValueDataSet(array(
						'Dealership name:'  => $this->getStockSubParam('company', 'name', ''),
						'Contact:' 	        => !is_null($contact) ? $contact->firstName . ' ' . $contact->familyName : '',
						'Mobile:'           => !is_null($contact) ? $contact->mobile : '',
						'Email:'            => !is_null($contact) ? $contact->email : ''
				), 0, 'font-weight:bold;', 'color:#000;');
			$customerDetail = $table->publish();
		}

		#-> Valuation
		$valuationDetail = '&nbsp;';
		if ($this->showValuationDetails)
		{
			$table = $this->newTable(
					array(55, 45),
					'padding:0;margin:0;font-size:10px;',
					'',
					'padding:2px 3px 2px 0;margin:0;'
			);
			$pgItem = $this->em
				->getRepository('\PriceGuide\Entity\PriceGuide')
				->findOneBy(array('stock' => $this->jobRecord));
			$pgLoaded = !is_null($pgItem)
				? $pgItem->created->format($dateTimeFormat)
				: '&nbsp;';
			$valCreated = $this->getValuationParam('created', null);
			$valCreated = !is_null($valCreated)
				? $valCreated->format($dateTimeFormat)
				: '&nbsp;';
			$createdBy = $this->getValuationParam('createdBy', null);
			$createdBy = !is_null($createdBy)
				? $createdBy->firstName . ' ' . $createdBy->familyName
				: '';
			$valuatedBy = $this->getValuationParam('valuatedBy', null);
			$valuatedBy = !is_null($valuatedBy)
				? $valuatedBy->firstName . ' ' . $valuatedBy->familyName
				: '';
			$salesProfile = $this->getValuationParam('salesProfile', null);
			$salesProfile = !is_null($salesProfile)
				? $salesProfile->firstName . ' ' . $salesProfile->familyName
				: '';
			$managerProfile = $this->getValuationParam('managerProfile', null);
			$managerProfile = !is_null($managerProfile)
				? $managerProfile->firstName . ' ' . $managerProfile->familyName
				: '';
			if ($this->showSalesDataOnly)
			{
				$dSet = array(
						'Date created:'               => $valCreated,
						'Valuation no.:'              => $this->getValuationParam('valuationNumber', ''),
						'Reference no.:'              => $this->getStockParam('referenceNumber', ''),
						'Created by:'                 => $createdBy,
						'Valuator:'                   => $valuatedBy,
						'Sales person:'               => $salesProfile,
						'Manager:'                    => $managerProfile
				);
			}
			elseif ($this->showTradeDataOnly)
			{
				$dSet = array(
						'Date created:'               => $valCreated,
						'Date loaded on price guide:' => $pgLoaded
				);
			}
			elseif ($this->showShortVehicleDetails)
			{
				$dSet = array(
						'Date created:'               => $valCreated,
						'Valuation no.:'              => $this->getValuationParam('valuationNumber', ''),
						'Reference no.:'              => $this->getStockParam('referenceNumber', ''),
						'Vehicle status:'             => $this->getValuationParam('jobState', ''),
						'Created by:'                 => $createdBy,
						'Valuator:'                   => $valuatedBy,
						'Sales person:'               => $salesProfile,
						'Manager:'                    => $managerProfile
				);
			}
			else
			{
				$dSet = array(
						'Date created:'               => $valCreated,
						'Valuation no.:'              => $this->getValuationParam('valuationNumber', ''),
						'Reference no.:'              => $this->getStockParam('referenceNumber', ''),
						'Vehicle status:'             => $this->getValuationParam('jobState', ''),
						'Created by:'                 => $createdBy,
						'Valuator:'                   => $valuatedBy,
						'Sales person:'               => $salesProfile,
						'Manager:'                    => $managerProfile,
						'Date loaded on price guide:' => $pgLoaded,
						'Cover Received:'             => $this->getStockParam('coverReceived', '')
				);
			}
			$table
				->addTitle('Valuation details', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
				->addKeyValueDataSet($dSet, 0, 'font-weight:bold;', 'color:#F00;');
			$valuationDetail = $table->publish();
		}

		#-> Pricing details
		$pricingDetail = '&nbsp;';
		$total = $this->getValuationParam('overAllowance', '0.00') + $this->getValuationParam('amountOffered', '0.00');
		$total = number_format($total, 2, '.', '');
		if ($this->showPricingDetails)
		{
			$table = $this->newTable(
					array(60, 40),
					'padding:0;margin:0;font-size:10px;',
					'',
					'padding:2px 3px 2px 0;margin:0;'
			);
			if ($this->showSalesDataOnly)
			{
				$dSet = array(
						'Trade:'                     => $currencyPrefix . $this->getStockParam('tradePrice', '0.00'),
						'Retail:'                    => $currencyPrefix . $this->getStockParam('retailPrice', '0.00'),
                        'List:'                     => $currencyPrefix . $this->getStockParam('listPrice', '0.00'),
						'Amount offered:'            => $currencyPrefix . $this->getValuationParam('amountOffered', '0.00'),
						'O.A.:'                      => $currencyPrefix . $this->getValuationParam('overAllowance', '0.00'),
						'Total offer:'            	 => $currencyPrefix . $total, // total offer =  amount offered + O.A
						'Bank settlement:'           => $currencyPrefix . $this->getValuationParam('bankSettlement', '0.00')
				);
			}
			elseif ($this->showTradeDataOnly)
			{
				$dSet = array(
						'Trade:'                     => $currencyPrefix . $this->getStockParam('tradePrice', '0.00'),
						'Retail:'                    => $currencyPrefix . $this->getStockParam('retailPrice', '0.00'),
                        'List:'                     => $currencyPrefix . $this->getStockParam('listPrice', '0.00'),
						'Amount offered:'            => $currencyPrefix . $this->getValuationParam('amountOffered', '0.00'),
						'O.A.:'                      => $currencyPrefix . $this->getValuationParam('overAllowance', '0.00'),
						'Total offer:'            	 => $currencyPrefix . $total, // total offer =  amount offered + O.A
				);
			}
			elseif ($this->showShortVehicleDetails)
			{
				$dSet = array(
						'Trade:'                     => $currencyPrefix . $this->getStockParam('tradePrice', '0.00'),
						'Retail:'                    => $currencyPrefix . $this->getStockParam('retailPrice', '0.00'),
                        'List:'                     => $currencyPrefix . $this->getStockParam('listPrice', '0.00'),
						'Amount offered:'            => $currencyPrefix . $this->getValuationParam('amountOffered', '0.00'),
						'O.A.:'                      => $currencyPrefix . $this->getValuationParam('overAllowance', '0.00'),
						'Total offer:'            	 => $currencyPrefix . $total, // total offer =  amount offered + O.A
						'Bank settlement:'           => $currencyPrefix . $this->getValuationParam('bankSettlement', '0.00')
				);
			}
			else
			{
				$dSet = array(
						'Trade:'                     => $currencyPrefix . $this->getStockParam('tradePrice', '0.00'),
						'Retail:'                    => $currencyPrefix . $this->getStockParam('retailPrice', '0.00'),
                        'List:'                     => $currencyPrefix . $this->getStockParam('listPrice', '0.00'),
						'Amount offered:'            => $currencyPrefix . $this->getValuationParam('amountOffered', '0.00'),
						'O.A.:'                      => $currencyPrefix . $this->getValuationParam('overAllowance', '0.00'),
						'Total offer:'            	 => $currencyPrefix . $total , // total offer =  amount offered + O.A
						'Projected retail:'          => $currencyPrefix . $this->getValuationParam('projectedRetail', '0.00'),
						'Planned margin:'            => $currencyPrefix . $this->getValuationParam('plannedMargin', '0.00'),
						'Price guide highest offer:' => $currencyPrefix . $this->getStockParam('highestOffer', '0.00'),
						'Bank settlement:'           => $currencyPrefix . $this->getValuationParam('bankSettlement', '0.00')
				);
			}
			$table
				->addTitle('Pricing details', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
				->addKeyValueDataSet($dSet, 0, 'font-weight:bold;', 'color:#F00;');
			$pricingDetail = $table->publish();
		}

		#-> First row of data-blocks.
		if ($this->showCustomerDetails
			|| $this->showValuationDetails
			|| $this->showPricingDetails)
		{
			$container = $this
				->newTable(
					array(30, 5, 30, 5, 30),
					'margin:0;font-size:10px;vertical-align:top;',
					'',
					'padding:10px 0 0 0;'
					)
				->setCellValue(0, 0, $customerDetail)
				->setCellValue(0, 2, $valuationDetail)
				->setCellValue(0, 4, $pricingDetail);
			$this->append($container->publish() . '<br />');
		}
		
		
		/* --------------------------------- VEHICLE, DAMAGES, ACCESSORIES --------------------------------- */

		#-> Vehicle details
		$vehicleDetail = '&nbsp;';
		if ($this->showVehicleDetails)
		{
			$table = $this->newTable(
					array(55, 45),
					'padding:0;margin:0;font-size:10px;',
					'',
					'padding:2px 3px 2px 0;margin:0;'
			);
			if ($this->showShortVehicleDetails)
			{
				$dSet = array(
						'Year:'                 => $this->getStockSubParam('vehicleYear', 'name', ''),
						'Category:'             => $type->category->name,
						'Make:'                 => $type->model->make->name,
						'Model:'                => $type->model->name,
						'Type:'                 => $type->name,
						'Registration no.:'     => $this->getStockParam('registrationNumber', ''),
						'Model code:'           => ''
				);
			}
			else
			{
                $licenseDiscExpired = $this->getValuationParam('licenseDiscExpired', null);
                if (is_null($licenseDiscExpired))
                {
                    $licenseDiscExpired = '';
                }
                else
                {
                    $licenseDiscExpired = $licenseDiscExpired
                        ? 'Yes'
                        : 'No';
                }


				$keys = $this->getStockParam('spareKeys', null);
				if (is_null($keys))
				{
					$keys = '';
				}
				else
				{
					$keys = $keys
						? 'Yes'
						: 'No';
				}
				$dSet = array(
						'Year:'                 => $this->getStockSubParam('vehicleYear', 'name', ''),
						'Category:'             => $type->category->name,
						'Make:'                 => $type->model->make->name,
						'Model:'                => $type->model->name,
						'Type:'                 => $type->name,
						'Registration no.:'     => $this->getStockParam('registrationNumber', ''),
						'Fuel type:'            => $this->getStockSubParam('fuelType', 'name', ''),
						'Transmission type:'    => $this->getStockSubParam('transmissionType', 'name', ''),
						'VIN no.:'              => $this->getStockParam('vinNumber', ''),
						'Engine no.:'           => $this->getStockParam('engineNumber', ''),
                        'License Disc Expired:'         => $licenseDiscExpired,
						'MM code:'              => $type->mmCode,
						'Model code:'           => '',
						'Kms:'                  => $this->getStockParam('km', ''),
						'Condition:'            => $this->getStockSubParam('condition', 'name', ''),
						'Main exterior colour:' => $this->getStockSubParam('exteriorColour', 'name', ''),
						'Main interior colour:' => $this->getStockSubParam('interiorColour', 'name', ''),
						'Upholstery:'           => $this->getStockSubParam('upholstery', 'name', ''),
						'Papers:'               => $this->getStockSubParam('papers', 'name', ''),
						'Papers comments:'      => $this->getStockParam('papersNotes', ''),
						'Natis:'                => $this->getStockSubParam('natis', 'name', ''),
						'Spare keys:'           => $keys,
						'FSH:'                  => $this->getStockSubParam('fullServiceHistory', 'name', ''),
						'FSH comments:'         => $this->getStockParam('fshNotes', '')

						
				);
			}
			$table
				->addTitle('Vehicle specifications', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
				->addKeyValueDataSet($dSet, 0, '', 'color:#000;');
			$vehicleDetail = $table->publish();
		}
		
		#-> Damages
		$damagesDetail = '&nbsp;';
		if ($this->showDamageDetails)
		{
			$damageData = array();
			$damages = $this->jobRecord->damagesToArray();
			foreach ($damages as $damage)
			{
				$damageData[$damage['damage']['name'] . ':'] = $currencyPrefix . $damage['amount'];
			}
			$damageData['Total estimated repair cost:']  =
				'<span style="color:#F00;">' . $currencyPrefix . $this->getStockParam('damageTotal', '') . '</span>';
			$damageData['Damages comments:']             = $this->getStockParam('damageNotes', '');
			$damageData['Previous repairs noted:']       = $this->getStockParam('previousRepairsNoted', false)
				? 'Yes'
				: 'No';
			$damageData['Previous repairs comments:']    = $this->getStockParam('previousRepairsNotes', '');
			$table = $this->newTable(
					array(50, 50),
					'padding:0;margin:0;font-size:10px;',
					'',
					'padding:2px 3px 2px 0;margin:0;'
			);
			$type = $this->jobRecord->type;
			$table
				->addTitle('Damages', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
				->addKeyValueDataSet($damageData, 0, '', 'color:#000;');
			$damagesDetail = $table->publish();
		}
		
		#-> Accessories
		$accessoriesDetail = '&nbsp;';
		if ($this->showAccessoryDetails)
		{
			$accs = array();
			$accData = array();
			$accessories = $this->jobRecord->accessoriesToArray();
			foreach ($accessories as $accessory)
			{
				$accs[] = $accessory['accessory']['name'];
			}
			if (!empty($accs))
			{
				for ($i = 0; $i <= count($accs); $i += 2)
				{
					if (isset($accs[$i]))
					{
						$accData[$accs[$i]] = isset($accs[$i + 1])
							? $accs[$i + 1]
							: '';
					}
				}
			}
			$accData['<span style="color:#000;font-size:10px;">Comments:</span>'] =
				'<span style="color:#000;font-size:10px;">' . $this->getStockParam('accessoryNotes', '') . '</span>';
			$table = $this->newTable(
					array(50, 50),
					'padding:0;margin:0;font-size:9px;',
					'',
					'padding:2px 3px 2px 0;margin:0;'
			);
			$type = $this->jobRecord->type;
			$table
				->addTitle('Accessories', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
				->addKeyValueDataSet($accData, 0, 'color:#000;', 'color:#000;');
			$accessoriesDetail = $table->publish();
		}

		#-> Second row of data-blocks.
		if ($this->showVehicleDetails
			|| $this->showDamageDetails
			|| $this->showAccessoryDetails)
		{
			$container = $this
				->newTable(
					array(30, 5, 30, 5, 30),
					'margin:0;font-size:10px;vertical-align:top;',
					'',
					'padding:10px 0 0 0;'
					)
				->setCellValue(0, 0, $vehicleDetail)
				->setCellValue(0, 2, $damagesDetail)
				->setCellValue(0, 4, $accessoriesDetail);
			$this->append($container->publish() . '<br />');
		}
		
		/* --------------------------------- VEHICLE NOTES --------------------------------- */
		#-> Vehicle Notes
		$VehicleNotes = '&nbsp;';
		if ($this->showVehicleNotes)
		{
			$table = $this->newTable(
					array(55, 45),
					'padding:0;margin:0;font-size:10px;',
					'',
					'padding:15px 15px 15px 0;margin:0;'
			);
				
			$dSet = array(
					'1______________________________________________________________________________________________________________________________________'         => '&nbsp;',
					'2______________________________________________________________________________________________________________________________________'         => '&nbsp;',
					'3______________________________________________________________________________________________________________________________________'         => '&nbsp;'
			);
				
			$table
			->addTitle('Notes:', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
			->addKeyValueDataSet($dSet, 0, '', 'color:#000;');
			$VehicleNotes = $table->publish();
		}
		#-> Third row of data-blocks.
		if ($this->showVehicleNotes)
		{
			$container = $this
			->newTable(
					array(30, 5, 30, 5, 30),
					'margin:0;font-size:10px;vertical-align:top;',
					'',
					'padding:10px 0 0 0;'
			)
			->setCellValue(0, 0, $VehicleNotes);
			$this->append($container->publish() . '<br />');
		}



		/* --------------------------------- SIGNATURES --------------------------------- */
		#-> Signatures.
		if ($this->showSignatureLines)
		{
			$this->append(
					$this->newSignatureLine()
						->addSignatureLine('Customer (name)', 'Signature', 'Date')
						->addSignatureLine('Manager (name)', 'Signature', 'Date')
						->publish()
					);
		}

		$this->append(
				'<div style="position:absolute;bottom:0;left:0;padding:0;margin:0;width:100%;">'
				. '<table cellpadding="0px" cellspacing="0px" style="border:0px;width:100%;">'
				. '<tr>'
				. '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#000;"><i>'
				. $dateOfPrint . '</i></td>'
				. '<td style="width:5%">&nbsp;</td>'
				. '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#000;"><i>'
				. $printedBy . '</i></td>'
				. '<td style="width:5%">&nbsp;</td>'
				. '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#000;"><i>'
				. $referenceNo . '</i></td>'
				. '</tr>'
				. '</table>'
				. '</div>'
				);




		/* --------------------------------- OFFERS RECEIVED/MADE --------------------------------- */
		#-> Offers received.
		if ($this->showOffersReceived || $this->showOfferMade)
		{
			$this->nextPage();
			$this->append('<br/>');

			if ($this->showOffersReceived)
			{
				$offers = array();
				$pgItems = $this->em
					->getRepository('\PriceGuide\Entity\PriceGuide')
					->findBy(array('stock' => $this->jobRecord));
				if (!empty($pgItems))
				{
					foreach ($pgItems as $pgItem)
					{
						$iterator = $pgItem->offers->getIterator();
						foreach ($iterator as $offer)
						{
							$status = $offer->status;
							$offers[] = array(
									$offer->company->name,
									$offer->created->format($dateTimeFormat),
									$currencyPrefix . $offer->amount,
									$offer->profile->mobile,
									$offer->profile->email,
									$status
							);
						}
					}
				}
				$table = $this->newTable(
						array(20, 15, 15, 10, 30, 10),
						'padding:0;margin:0;font-size:10px;',
						'',
						'padding:2px 5px 2px 2px;margin:0;'
				);
				$table
					->addTitle('Offers received', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
					->setColumnHeaders(array(
									'Buyer', 'Date', 'Offer', 'Mobile', 'Email', 'Status'
							), array(20, 15, 15, 10, 30, 10),
							'padding:2px 2px 2px 5px;background-color:#F00;color:#FFF;font-weight:bold;font-size:10px;')
					->setDataSet($offers);
				$this->append($table->publish() . '<br />');
			}

			#-> Offer made.
			if ($this->showOfferMade)
			{
				$offers = array();
				$pgItem = $this->em
					->getRepository('\PriceGuide\Entity\PriceGuide')
					->findOneBy(array('stock' => $this->jobRecord));
				if (!is_null($pgItem))
				{
					$companyId = \Utility\Registry::resolveCompanyContext();
					$iterator = $pgItem->offers->getIterator();
					foreach ($iterator as $offer)
					{
						$status = $offer->status;
						if ('Valid' != $status && 'Archived' != $status
							&& $offer->company->id = $companyId)
						{
							continue;
						}
						$offers[] = array(
								$offer->company->name,
								$offer->created->format($dateTimeFormat),
								$currencyPrefix . $offer->amount,
								$offer->profile->mobile,
								$offer->profile->email,
								$status
						);
					}
				}
				$table = $this->newTable(
						array(20, 15, 15, 10, 30, 10),
						'padding:0;margin:0;font-size:10px;',
						'',
						'padding:2px 5px 2px 2px;margin:0;'
				);
				$table
					->addTitle('Offers made', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
					->setColumnHeaders(array(
							'Buyer', 'Date', 'Offer', 'Mobile', 'Email', 'Status'
					), array(20, 15, 15, 10, 30, 10),
					'padding:2px 2px 2px 5px;background-color:#F00;color:#FFF;font-weight:bold;font-size:10px;')
					->setDataSet($offers);
				$this->append($table->publish() . '<br />');
			}

			$this->append(
					'<div style="position:absolute;bottom:0;left:0;padding:0;margin:0;width:100%;">'
					. '<table cellpadding="0px" cellspacing="0px" style="border:0px;width:100%;">'
					. '<tr>'
					. '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#000;"><i>'
					. $dateOfPrint . '</i></td>'
					. '<td style="width:5%">&nbsp;</td>'
					. '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#000;"><i>'
					. $printedBy . '</i></td>'
					. '<td style="width:5%">&nbsp;</td>'
					. '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#000;"><i>'
					. $referenceNo . '</i></td>'
					. '</tr>'
					. '</table>'
					. '</div>'
			);
		}




		/* --------------------------------- TERMS AND CONDITIONS --------------------------------- */
		#-> Terms and Conditions.
		if ($this->showTermsAndConditions)
		{
			$this->nextPage();
			$this->append('<br/>');

			$table = $this->newTable(
					array(90, 10),
					'padding:0;margin:0;font-size:9px;',
					'',
					'padding:2px 3px 2px 0;margin:0;'
			);
			$type = $this->jobRecord->type;
			$table
				->addTitle('Terms and Conditions', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
				->addKeyValueDataSet(array(
						'I acknowledge, confirm and agree that:' => '',
						'1. Ownership' => '',
						'1.1. I am the owner of my trade-in vehicle and I am legally allowed to sell my trade-in vehicle.' => 'Yes / No',
						'1.2. I am a South African resident.' => 'Yes / No',
						'1.3. My trade-in vehicle is not subject to a claim of any nature whatsoever by any other person or entity and I '
						. 'indemnify the Dealer against any claims of any ' => 'Yes / No',
						'1.4. If my trade-in vehicle is subject to any claim by any other person or entity, the Dealer will not be bound '
						. 'to this valuation.' => 'Yes / No',
						'2. VAT Registration' => '',
						'This transaction is subject to the payment of VAT.' => 'Yes / No',
						'3. Status of the Vehicle' => '',
						'3.1. My trade-in vehicle was new when I purchased it.' => 'Yes / No',
						'3.2. My trade-in vehicle has been used for self-drive hire or taxi work.' => 'Yes / No',
						'3.3. My trade-in vehicle has a full service history.' => 'Yes / No',
						'3.4. My trade in vehicle has not been involved in any accident.' => 'Yes / No',
						'3.5. If my trade-in vehicle has been involved in an accident, there was a total loss claim made (Stolen & Recovered).' => 'Yes / No',
						'3.6. A current registration paper has been handed over by me.' => 'Yes / No',
						'3.7. I have supplied the owners and service manuals to the Dealer.' => 'Yes / No',
						'3.8. My trade-in vehicle is subject to a service and/or maintenance plan and/or warranty.' => 'Yes / No',
						'4. Status of the Vehicle' => '',
						'The Dealer will only be bound by its appraised trade-in value of my trade-in vehicle as far as the trade-in has '
						. 'been approved and accepted in writing by either the dealer principle, designated sales manager or used car manager'
						. ' and the parties have entered into the Dealer\'s standard Offer to Purchase in respect of my trade-in vehicle.' => '',
						'5. Outstanding Finance' => '',
						'5.1. The Dealer, in its absolute and sole discretion, may agree to settle the existing finance in lieu of payment '
						. '(or part payment) of the trade-in vehicle to me.' => '',
						'5.2. If the agreed trade-in allowance of the trade-in vehicle is lower than the settlement figure in clause 5.1 above, '
						. 'I must pay the Registered Credit Provider the difference between the settlement figure and the trade-in allowance with '
						. 'proof of such payment (made to the registered Credit Provider) submitted to the Dealer prior to the signing of the Offer to Purchase.' => '',
						'5.3. I will remain liable to the registered Credit Provider in respect of the related finance at all times until the '
						. 'credit Agreement has been legally terminated.' => '',
						'5.4. For purposes of clarity, the Dealer does not accept any liability with respect to the related finance set out in '
						. 'clause 5.4 above at any time or for any reason.' => '',
						'5.5. The Dealer will use its best endeavors to pay the trade-in allowance to the registered Credit Provider as soon as '
						. 'is reasonably possible. However the Dealer accepts no liability for any costs or liability incurred by me as a result '
						. 'of any delay in the payment by the Dealer.' => '',
						'6. No Financial Advice' => '',
						'This trade-in valuation does not constitute financial advice to me as contemplated in the Financial Advisory and '
						. 'Intermediary Services Act 37 of 2002 but is subject to the Consumer Protection Act 68 of 2008.' => '',
						'7. Risk' => '',
						'The risk of damage or loss in and to the trade-in vehicle will pass from me to the Dealer only once the Dealer has '
						. 'taken possession of my trade-in vehicle and has received the proper documentation from me to enable it to re-register my trade-in vehicle.' => '',
						'8. The Dealer\'s right to withdraw from the offer' => '',
						'The Dealer is bound by this offer only in so far as:' => '',
						'8.1. I have signed an Offer to Purchase with the same Dealer in respect of this valuation; and' => '',
						'8.2. Fewer than 7 (seven) days have passed since the issuing of this valuation; and' => '',
						'8.3. My trade-in vehicle is in the same condition as the date of inspection; and' => '',
						'8.4. This trade-in valuation was signed by the Valuator and the Manager of the Dealer.' => '',
						'&nbsp;<br />&nbsp;' => '',
						'I HAVE READ THE ABOVE TERMS AND CONDITIONS AND CONFIRM MY UNDERSTANDING AND AGREE TO BE BOUND THERETO.' => '',
						'&nbsp;<br />&nbsp;' => '',
						'Acceptance' => '',
						'By signing this form, I agree to the [Dealership Name] valuation terms and conditions above.' => '',
						'&nbsp;<br />&nbsp;<br />&nbsp;<br />&nbsp;<br />&nbsp;<br />' => '',
						'<b>Signature:</b>' => '',
						'&nbsp;' => '',
						'Date: ' . date('Y-m-d') => ''
				), 0, 'color:#333;', 'color:#000;');
			$this->append($table->publish() . '<br />');

			$this->append(
					'<div style="position:absolute;bottom:0;left:0;padding:0;margin:0;width:100%;">'
					. '<table cellpadding="0px" cellspacing="0px" style="border:0px;width:100%;">'
					. '<tr>'
					. '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#000;"><i>'
					. $dateOfPrint . '</i></td>'
					. '<td style="width:5%">&nbsp;</td>'
					. '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#000;"><i>'
					. $printedBy . '</i></td>'
					. '<td style="width:5%">&nbsp;</td>'
					. '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#000;"><i>'
					. $referenceNo . '</i></td>'
					. '</tr>'
					. '</table>'
					. '</div>'
			);
		}

		return;
	}


}

Commits for namibiamodule/Valuation/src/Valuation/Pdf/Complete.php

Diff revisions: vs.
Revision Author Commited Message
df0489 ... Mark Fri 14 Oct, 2016 10:01:00 +0000

initial commit