|
|
@@ -8,10 +8,17 @@ if(Core::$user->id != $test->tester_id && !Core::$user->canAdmin()) throw new Ex
|
|
|
$project = $test->getProject();
|
|
|
$location = $test->getLocation();
|
|
|
$tester = $test->getTester();
|
|
|
+$values = $test->getValues(true);
|
|
|
|
|
|
$location_address = $location->name . ", " . $location->getDisplayAddress(["address_1", "address_2", "city", "postal_code"]);
|
|
|
|
|
|
-$fee = !empty($test->test_fee) ? $test->test_fee : $project->default_tester_fee;
|
|
|
+$fee = floatval($test->test_fee) > 0 ? $test->test_fee : $project->default_tester_fee;
|
|
|
+$fee = (float) $fee;
|
|
|
+
|
|
|
+$play_spent = (float) ($values["play_spent"] ?? 0);
|
|
|
+$travel_cost = (float) http::value("travel_cost", "float");
|
|
|
+
|
|
|
+$invoice_total = $fee + $play_spent + $travel_cost;
|
|
|
|
|
|
$address = $tester->getInvoiceAddress();
|
|
|
if(!$address) throw new Exception("Invoice address not found. Please set an address as the invoice address then try again.");
|
|
|
@@ -91,7 +98,7 @@ $pdf->Cell(45, 8, date("d/m/Y", time() + 2592000), 0, 1, "R");
|
|
|
$pdf->Rect(110, $pdf->GetY(), 90, 8, "F");
|
|
|
$pdf->Cell(45, 8, "Balance Due:", 0, 0, "R");
|
|
|
$pdf->SetTextColor(0);
|
|
|
-$pdf->Cell(45, 8, utf8_decode("£") . number_format($fee, 2), 0, 1, "R");
|
|
|
+$pdf->Cell(45, 8, utf8_decode("£") . number_format($invoice_total, 2), 0, 1, "R");
|
|
|
|
|
|
// Left addresses
|
|
|
$pdf->SetXY(10, 10);
|
|
|
@@ -141,16 +148,36 @@ $pdf->Cell(30, 5, utf8_decode("£") . number_format($fee, 2), 0, 0, "R");
|
|
|
$pdf->Cell(30, 5, utf8_decode("£") . number_format($fee, 2), 0, 0, "R");
|
|
|
$pdf->SetXY(10, $next_y);
|
|
|
|
|
|
-// TODO: Amount Spent field
|
|
|
+if($play_spent) {
|
|
|
+ $pdf->MoveY(5);
|
|
|
+ $y = $pdf->GetY();
|
|
|
+ $pdf->MultiCell(115, 5, "Play Costs", 0, "L");
|
|
|
+ $next_y = $pdf->GetY();
|
|
|
+ $pdf->SetXY(125, $y);
|
|
|
+ $pdf->Cell(15, 5, 1, 0, 0, "R");
|
|
|
+ $pdf->Cell(30, 5, utf8_decode("£") . number_format($play_spent, 2), 0, 0, "R");
|
|
|
+ $pdf->Cell(30, 5, utf8_decode("£") . number_format($play_spent, 2), 0, 0, "R");
|
|
|
+ $pdf->SetXY(10, $next_y);
|
|
|
+}
|
|
|
|
|
|
-// TODO: Travel costs
|
|
|
+if($travel_cost) {
|
|
|
+ $pdf->MoveY(5);
|
|
|
+ $y = $pdf->GetY();
|
|
|
+ $pdf->MultiCell(115, 5, "Travel Costs", 0, "L");
|
|
|
+ $next_y = $pdf->GetY();
|
|
|
+ $pdf->SetXY(125, $y);
|
|
|
+ $pdf->Cell(15, 5, 1, 0, 0, "R");
|
|
|
+ $pdf->Cell(30, 5, utf8_decode("£") . number_format($travel_cost, 2), 0, 0, "R");
|
|
|
+ $pdf->Cell(30, 5, utf8_decode("£") . number_format($travel_cost, 2), 0, 0, "R");
|
|
|
+ $pdf->SetXY(10, $next_y);
|
|
|
+}
|
|
|
|
|
|
$pdf->MoveY(10);
|
|
|
|
|
|
$pdf->SetTextColor(128);
|
|
|
$pdf->Cell(150, 5, "Total:", 0, 0, "R");
|
|
|
$pdf->SetTextColor(0);
|
|
|
-$pdf->Cell(40, 5, utf8_decode("£") . number_format($fee, 2), 0, 1, "R");
|
|
|
+$pdf->Cell(40, 5, utf8_decode("£") . number_format($invoice_total, 2), 0, 1, "R");
|
|
|
|
|
|
$pdf->MoveY(10);
|
|
|
|