-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinc.trip-guest-sheet.php
142 lines (118 loc) · 5.42 KB
/
inc.trip-guest-sheet.php
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
<?php
require_once 'autoload.php';
use Transport\{ Config, Trip };
if (!isset($trip)) {
$id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE);
$id = $id === false ? null : $id;
$trip = new Trip($id);
}
$config = Config::get('organization');
$pdf = new PDF('P', 'pt', 'letter');
$pdf->AddPage();
$pageWidth = $pdf->GetPageWidth() - $pdf->lm - $pdf->rm;
$pdf->setFillColor(230, 230, 230);
$pdf->Image(dirname(__FILE__).'/images/organization/logo.png', $pdf->GetPageWidth() - $pdf->rm - 250, $pdf->GetY(), 250, 0, 'PNG');
$pdf->SetY(60);
$pdf->SetFont('Helvetica', 'B', 16);
$pdf->Cell($pageWidth, $pdf->row_height, 'Transportation: Guest Sheet');
$pdf->ln(30);
// Include guest information also...
$pdf->SetFont('Helvetica', 'B', 14);
$pdf->Cell($pageWidth, 30, 'Group / Guest', 1, 1, 'L', true);
$pdf->SetFont('Helvetica', '', 11);
$pdf->MultiCell($pageWidth, 18, $trip->guests.' / '.(($trip->guest) ? $trip->guest->getName() : ''), 1, 'L');
$pdf->ln();
$pdf->SetFont('Helvetica', 'B', 14);
$pdf->Cell($pageWidth, 30, 'Your Driver', 1, 30, 'L', true);
$pdf->SetFont('Helvetica', '', 11);
$pdf->ln(2);
$saveY = $pdf->GetY();
if ($trip->driver->username) {
$pdf->Image(dirname(__FILE__).'/images/drivers/'.$trip->driver->username.'.jpg', $pdf->GetX(), $pdf->GetY(), 100, 0, 'JPG');
}
$pdf->SetX($pdf->GetX() + 110);
$pdf->SetFont('Helvetica', 'B', 12);
$pdf->MultiCell($pageWidth - 110, 20, $trip->driver ? $trip->driver->getName() : '', 0, 'L', false);
$pdf->SetFont('Helvetica', '', 11);
$pdf->SetX($pdf->GetX() + 110);
$pdf->MultiCell($pageWidth - 110, 20, $trip->driver->phoneNumber, 0, 'L', false);
$xCenter = $pdf->GetPageWidth() /2;
$pdf->SetFont('Helvetica', '', 11);
$pdf->SetY($saveY);
$pdf->SetX($xCenter);
$pdf->MultiCell($xCenter - $pdf->rm, 20, 'Vehicle: '.$trip->vehicle->description, 0, 'L', false);
$pdf->SetX($xCenter);
$pdf->MultiCell($xCenter - $pdf->rm, 20, 'License Plate: '.$trip->vehicle->licensePlate, 0, 'L', false);
$pdf->SetY($saveY + 120);
$pdf->SetFont('Helvetica', 'B', 14);
$pdf->Cell($pageWidth, 30, 'Pick up information', 1, 1, 'L', true); $pdf->SetY($pdf->GetY() - 30);
$pdf->Cell($pageWidth, 30, Date('D F j', strtotime($trip->pickupDate)), 1, 1, 'R', false);
$pdf->SetFont('Helvetica', '', 11);
if ($trip->ETA) {
// We will be picking up the guest(s) from the airport
$instructions .= "Your flight is estimated to arrive at ".Date('g:ia', strtotime($trip->ETA))." (local time) at ".$trip->airport->name.".\n\n";
if ((int)$trip->passengers > 4) {
$instructions .= $trip->airport->arrivalInstructionsGroup;
} else {
if ($config->guestInstructions->airportRegularPickup) $instructions .= $config->guestInstructions->airportRegularPickup."\n\n";
$instructions .= $trip->airport->arrivalInstructions;
}
} else {
$instructions .= "Your driver will be at your pick up location (".$trip->puLocation->name.") shortly before ".Date('g:ia', strtotime($trip->pickupDate));
}
$pdf->MultiCell($pageWidth, 18, $instructions, 1, 'L');
$pdf->ln();
$pdf->SetFont('Helvetica', 'B', 14);
$pdf->Cell($pageWidth, 30, 'Drop off information', 1, 1, 'L', true);
$pdf->SetFont('Helvetica', '', 11);
$info = "Your driver will be taking you to ".$trip->doLocation->name;
if ($trip->vehicleDOOptions === 'leave vehicle with guest') $info .= " and leaving the vehicle with you.";
if ($trip->ETD) {
if ((int)$trip->passengers >4) {
// Group going to the airport
if ($config->guestInstructions->airportGroupDropoff) $info .= "\n\n".$config->guestInstructions->airportGroupDropoff;
}
} else {
if ((int)$trip->passengers <=4) {
// Not going to the airport and not a group
if ($config->guestInstructions->dropOff) $info .= "\n\n".$config->guestInstructions->dropOff;
}
}
$pdf->MultiCell($pageWidth, 18, $info, 1, 'L');
$pdf->ln();
if ($trip->flightNumber) {
$pdf->SetFont('Helvetica', 'B', 14);
$pdf->Cell($pageWidth, 30, 'Your Flight Info', 1, 30, 'L', true);
$pdf->Rect($pdf->GetX(), $pdf->GetY(), $pageWidth, 3*17);
if ($trip->airline->imageFilename) {
$pdf->Image(dirname(__FILE__).'/images/airlines/'.$trip->airline->imageFilename, $pdf->GetX() +5, $pdf->GetY() +10, 140, 0);
}
$pdf->SetFont('Helvetica', '', 11);
$pdf->SetAligns(['L', 'L']);
$pdf->SetWidths([150, $pageWidth - 150 - 152]);
$pdf->SetX($pdf->lm + 150);
$pdf->Row(['Airline', $trip->airline->name]);
$pdf->SetX($pdf->lm + 150);
$pdf->Row(['Flight Number', $trip->airline->flightNumberPrefix.' '.$trip->flightNumber]);
$pdf->SetX($pdf->lm + 150);
if ($trip->ETA) {
$pdf->Row(['ETA', Date('g:i a', strtotime($trip->ETA)).' - '.$trip->airport->name]);
} elseif ($trip->ETD) {
$pdf->Row(['ETD', Date('g:i a', strtotime($trip->ETD)).' - '.$trip->airport->name]);
}
$pdf->ln();
}
if ($trip->guestNotes) {
$pdf->SetFont('Helvetica', 'B', 14);
$pdf->Cell($pageWidth, 30, 'Guest Notes', 1, 30, 'L', true);
$pdf->SetFont('Helvetica', '', 11);
$pdf->MultiCell($pageWidth, 18, $trip->guestNotes, 1);
}
// We don't want the content to clash with the QR code.
if ($pdf->GetY() > ($pdf->GetPageHeight() - 160)) $pdf->AddPage();
$qrcode = new QRcode('https://transport.obrienware.com/opt-in');
$qrcode->disableBorder();
$pdf->SetY(-160);
$qrcode->displayFPDF($pdf, $pdf->GetPageWidth() - $pdf->rm - 100, $pdf->GetY(), 100);
$pdf->SetY(-160);
$pdf->MultiCell($pageWidth - 110, 15, "We aim to provide excellent service.\nWe can text you real-time updates\n regarding your pickup.\n\nPlease SCAN to opt-in to text updates", 0,'R', false);