|
|
@@ -13,16 +13,7 @@
|
|
|
$customer = $project->getCustomer();
|
|
|
$tester = $test->getTester();
|
|
|
|
|
|
-$json = json_decode($template->getJSON());
|
|
|
-$fields = array_merge($json->beforeTest, [(object) ["type" => "hr"]], $json->duringTest);
|
|
|
-$values = $test->getValues();
|
|
|
-
|
|
|
-$names = array_map(function($value) { return $value->name; }, $values);
|
|
|
-
|
|
|
-$values = array_combine(
|
|
|
- array_map(function($value) { return $value->name; }, $values),
|
|
|
- array_map(function($value) { return $value->value; }, $values)
|
|
|
-);
|
|
|
+$fields = $test->getFieldsForVerifyForm();
|
|
|
|
|
|
$directory = $test->getDirectory();
|
|
|
|
|
|
@@ -40,7 +31,7 @@ if($submit) {
|
|
|
$accept_tester_invoice = http::value("accept_tester_invoice");
|
|
|
$reject_tester_invoice = http::value("reject_tester_invoice");
|
|
|
|
|
|
- if(($accept || $reject) && $test->status != Test::STATUS_PENDING_VERIFICATION) {
|
|
|
+ if(($accept || $reject) && $test->getStatus() !== Test::STATUS_PENDING_VERIFICATION) {
|
|
|
throw new Exception("This test is no longer pending verification.");
|
|
|
}
|
|
|
|
|
|
@@ -71,14 +62,16 @@ if($submit) {
|
|
|
$test->pass = $pass_override;
|
|
|
}
|
|
|
|
|
|
- $start_override = http::getDateTimeFromFields("start_override");
|
|
|
+ $start_override = HTTP::value("start_override");
|
|
|
if($start_override) {
|
|
|
- $unix_start = strtotime($start_override);
|
|
|
+ $dt_start = new DateTime($start_override, new DateTimeZone(TIMEZONE));
|
|
|
+ $unix_start = $dt_start->format("U");
|
|
|
}
|
|
|
|
|
|
- $end_override = http::getDateTimeFromFields("end_override");
|
|
|
+ $end_override = HTTP::value("end_override");
|
|
|
if($end_override) {
|
|
|
- $unix_end = strtotime($end_override);
|
|
|
+ $dt_end = new DateTime($end_override, new DateTimeZone(TIMEZONE));
|
|
|
+ $unix_end = $dt_end->format("U");
|
|
|
}
|
|
|
|
|
|
if($unix_start > $unix_end) {
|
|
|
@@ -101,7 +94,7 @@ if($submit) {
|
|
|
$test->test_fee = $tester_fee;
|
|
|
}
|
|
|
|
|
|
- $test->test_travel_cost = HTTP::value("travel_cost", "float");
|
|
|
+ $test->test_travel_cost = HTTP::value("travel_cost", "float") ?? 0;
|
|
|
if($test->test_travel_cost < 0 || $test->test_travel_cost > 999.99) $form_exception->addError("Travel costs must be between 0 and 999.99.");
|
|
|
|
|
|
// Test forms
|
|
|
@@ -116,7 +109,7 @@ if($submit) {
|
|
|
|
|
|
$value = http::value($field->name, "trim");
|
|
|
|
|
|
- if(in_array($field->name, Test::TEST_FIELDS)) {
|
|
|
+ if(in_array($field->name, Test::TEST_FIELDS, true)) {
|
|
|
$test->{$field->name} = $value;
|
|
|
}
|
|
|
else {
|
|
|
@@ -177,39 +170,40 @@ if($submit) {
|
|
|
$tester->score++;
|
|
|
$tester->commit();
|
|
|
|
|
|
- // Save PDF
|
|
|
- $mpdf = $test->getMPDF();
|
|
|
- $pdf_string = $mpdf->Output("", "S");
|
|
|
- $pdf_path = $directory . "/pdf.pdf";
|
|
|
+ if($test->isVoid() === false) {
|
|
|
+ $mpdf = $test->getMPDF();
|
|
|
+ $pdf_string = $mpdf->Output("", "S");
|
|
|
+ $pdf_path = $directory . "/pdf.pdf";
|
|
|
|
|
|
- $success = file_put_contents($pdf_path, $pdf_string);
|
|
|
+ $success = file_put_contents($pdf_path, $pdf_string);
|
|
|
|
|
|
- $email_customer = http::value("email_customer");
|
|
|
- $email_location = http::value("email_location");
|
|
|
- $email_location_area_manager = http::value("email_location_area_manager");
|
|
|
+ $email_customer = http::value("email_customer");
|
|
|
+ $email_location = http::value("email_location");
|
|
|
+ $email_location_area_manager = http::value("email_location_area_manager");
|
|
|
|
|
|
- if($email_customer && $customer->email_after_test && $customer->email) {
|
|
|
- $test->sendResultEmail($customer->email);
|
|
|
- }
|
|
|
+ if($email_customer && $customer->email_after_test && $customer->email) {
|
|
|
+ $test->sendResultEmail($customer->email);
|
|
|
+ }
|
|
|
|
|
|
- if($email_location && $customer->email_locations_after_test && $location->email) {
|
|
|
- $test->sendResultEmail($location->email);
|
|
|
- }
|
|
|
+ if($email_location && $customer->email_locations_after_test && $location->email) {
|
|
|
+ $test->sendResultEmail($location->email);
|
|
|
+ }
|
|
|
|
|
|
- if($email_location_area_manager && $customer->email_locations_after_test && $location->area_manager_email) {
|
|
|
- $test->sendResultEmail($location->area_manager_email);
|
|
|
- }
|
|
|
+ if($email_location_area_manager && $customer->email_locations_after_test && $location->area_manager_email) {
|
|
|
+ $test->sendResultEmail($location->area_manager_email);
|
|
|
+ }
|
|
|
|
|
|
- if(EMAIL_TEST_RESULT) {
|
|
|
- $test->sendResultEmail(EMAIL_TEST_RESULT);
|
|
|
- }
|
|
|
+ if(EMAIL_TEST_RESULT) {
|
|
|
+ $test->sendResultEmail(EMAIL_TEST_RESULT);
|
|
|
+ }
|
|
|
|
|
|
- if(EMAIL_TEST_RESULT_COPY) {
|
|
|
- $test->sendResultEmail(EMAIL_TEST_RESULT_COPY);
|
|
|
+ if(EMAIL_TEST_RESULT_COPY) {
|
|
|
+ $test->sendResultEmail(EMAIL_TEST_RESULT_COPY);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if($test->status_tester_invoice == Test::STATUS_TESTER_INVOICE_PENDING) {
|
|
|
+ if($test->getTesterInvoiceStatus() === Test::STATUS_TESTER_INVOICE_PENDING) {
|
|
|
|
|
|
if($accept_tester_invoice) {
|
|
|
$success = $test->markTesterInvoicePaid();
|
|
|
@@ -236,7 +230,7 @@ if($submit) {
|
|
|
|
|
|
$projects = $customer->getProjects();
|
|
|
|
|
|
-$future_projects = array_filter($projects, function($p) use ($project) {
|
|
|
+$future_projects = array_filter($projects, static function(Project $p) use ($project) {
|
|
|
if($p->id == $project->id) return false;
|
|
|
if($p->template_id != $project->template_id) return false;
|
|
|
$unix_deadline = Util::getUnixTimeFromUTC($p->dts_deadline);
|
|
|
@@ -244,5 +238,5 @@ $future_projects = array_filter($projects, function($p) use ($project) {
|
|
|
});
|
|
|
|
|
|
View::includeOnce("header", compact("page_title"));
|
|
|
-View::include("test_verify_form", compact("test", "tester", "location", "project", "future_projects", "customer", "template", "fields", "values", "tester_message"));
|
|
|
+View::include("test_verify_form", compact("test", "tester", "location", "project", "future_projects", "customer", "template", "fields", "tester_message"));
|
|
|
View::includeOnce("footer");
|