| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648 |
- <?php /** @noinspection PhpUnhandledExceptionInspection */
- /**
- * @controller test.php
- *
- * @var Test $test
- * @var User $tester
- * @var Location $location
- * @var Project $project
- * @var Project[] $future_projects
- * @var Customer $customer
- * @var Template $template
- * @var array $fields
- * @var string $tester_message
- */
- use Carbon\CarbonImmutable;
- $config = $template->getConfiguration();
- $values = $test->getValues(true);
- $get_test_details = static function(Test $test) use ($project, $location): array {
- $test_details = [];
- $test_details["Project"] = sprintf('<a href="/account/projects/%d">%s</a>', $test->project_id, $project->getNameHtml());
- $test_details["Status"] = "<span class=\"badge badge-lg badge-" . $test->getStatusClass() . "\">" . $test->getStatusText() . "</span>";
- if($test->isVoid()) {
- $test_details["Result"] = "<span class=\"badge badge-lg badge-secondary\">Void</span>";
- }
- else {
- $test_details["Result"] = "<span class=\"badge badge-lg badge-" . $test->getPassClass() . "\">" . $test->getPassText() . "</span>";
- }
- $test_details["Location"] = "<a href=\"/account/locations/$location->id\" target=\"_blank\">" . htmlspecialchars($location->name) . "</a>";
- $test_details["Address"] = htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city", "postal_code"]));
- if($test->dts_end) {
- $test_details = array_merge($test_details, [
- "Duration" => $test->getDisplayDuration(),
- "Start" => Util::getDisplayDateTime(strtotime($test->dts_start . " UTC")),
- "End" => Util::getDisplayDateTime(strtotime($test->dts_end . " UTC")),
- ]);
- }
- if(in_array($test->getStatus(), [Test::STATUS_CANCELLED, Test::STATUS_COMPLETED], true)) {
- $test_details["Verified"] = Util::getDisplayDateTime(strtotime($test->dts_verified . " UTC"));
- $test_details["Retest"] = $test->retest ? "Yes" : "No";
- }
- return $test_details;
- };
- $tester_details = [
- "Name" => "Unassigned"
- ];
- if($tester) {
- $tester_details = [
- "Name" => "<a href=\"/account/users/$tester->id\" target=\"_blank\">" . $tester->getDisplayName() . "</a>",
- "Date of Birth" => $tester->date_of_birth,
- "Gender" => $tester->getGenderText(),
- "Phone" => $tester->phone,
- "Score" => $tester->score,
- ];
- $tester_invoice_details = [
- "Status" => Test::getStatusTesterInvoiceText($test->status_tester_invoice),
- "Generated" => $test->dts_tester_invoice_generated ? Util::getDisplayDateTimeFromUTC($test->dts_tester_invoice_generated) : "N/A",
- "Paid" => $test->dts_tester_invoice_paid ? Util::getDisplayDateTimeFromUTC($test->dts_tester_invoice_paid) : "N/A",
- ];
- if($test->test_travel_cost) {
- $tester_invoice_details["Travel Costs"] = "£" . number_format($test->test_travel_cost, 2);
- }
- else {
- $tester_invoice_details["Travel Costs"] = "N/A";
- }
- if($test->test_travel_cost_description) {
- $tester_invoice_details["Travel Cost Description"] = htmlspecialchars($test->test_travel_cost_description);
- }
- else {
- $tester_invoice_details["Travel Cost Description"] = "N/A";
- }
- if($test->hasTesterInvoicePDF()) {
- $tester_invoice_details["PDF"] = "<a href=\"/account/tests/{$test->id}/invoice\" target=\"_blank\">Download Invoice</a>";
- }
- if($test->hasTravelCostsPhoto()) {
- $tester_invoice_details["Photo"] = "<a href=\"/account/tests/{$test->id}/files/travel_costs\" target=\"_blank\">View Photo</a>";
- }
- }
- function render_card_list_group($details) {
- ?>
- <div class="list-group list-group-flush">
- <?php
- foreach($details as $title => $html) {
- ?>
- <div class="list-group-item">
- <div class="row" style="overflow: hidden; text-overflow: ellipsis;">
- <div class="col-md-auto">
- <?=htmlspecialchars($title)?>
- </div>
- <div class="col-md text-right" style="width: auto; overflow: hidden; text-overflow: ellipsis;">
- <?=$html?>
- </div>
- </div>
- </div>
- <?php
- }
- ?>
- </div>
- <?php
- }
- ?>
- <div class="container mt-3 py-4">
- <div class="row">
- <div class="col">
- <h2>Edit/Verify Test</h2>
- </div>
- <div class="col-auto justify-self-center">
- <div class="dropdown">
- <button class="btn btn-secondary dropdown-toggle" type="button" id="actions-button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
- Actions
- </button>
- <div class="dropdown-menu dropdown-menu-right" aria-labelledby="actions-button">
- <a class="dropdown-item" href="/account/projects/<?=$test->project_id?>">View Project</a>
- <div class="dropdown-divider"></div>
- <a class="dropdown-item" href="/account/tests/<?=$test->id?>/pdf" target="_blank">Generate New PDF</a>
- <?php
- if($test->hasPDF()) {
- $pdf_url = $test->getPDFUrl();
- ?>
- <a class="dropdown-item" href="<?=$pdf_url?>" target="_blank">View Sent PDF</a>
- <?php
- }
- if($test->hasTesterInvoicePDF()) {
- ?>
- <a class="dropdown-item" href="/account/tests/<?=$test->id?>/invoice" target="_blank">Download Tester Invoice</a>
- <?php
- }
- if($test->hasTravelCostsPhoto()) {
- ?>
- <a class="dropdown-item" href="/account/tests/<?=$test->id?>/files/travel_costs" target="_blank">View Travel Costs Photo</a>
- <?php
- }
- ?>
- </div>
- </div>
- </div>
- </div>
- <form method="post">
- <input type="hidden" name="submit" value="<?=$_SESSION["csrf_token"]?>" />
- <div class="row">
- <div class="col-xl-6">
- <div class="card mb-3">
- <div class="card-header">
- Submitted Data
- </div>
- <div class="card-body">
- <?php
- $header_count = 0;
- foreach($fields as $field) {
- $field = $template->applyOverridesToField($field);
- if($field->type === "file") {
- $path = $test->getDirectory() . "/" . $field->name . ".jpg";
- ?>
- <div class="row mb-1">
- <label class="col-sm-8 col-form-label"><?=htmlspecialchars($field->label)?></label>
- <div class="col-sm-4">
- <a href="/account/tests/<?=$test->id?>/files/<?=$field->name?>" target="_blank">
- <img class="img-fluid rounded" src="/account/tests/<?=$test->id?>/files/<?=$field->name?>" alt="<?=htmlspecialchars($field->label)?>" />
- </a>
- </div>
- </div>
- <?php
- continue;
- }
- if(!empty($field->name)) {
- $name = $field->name;
- if(isset($test->$name)) $field->value = $test->$name;
- else if(isset($values[$name])) $field->value = $values[$name];
- }
- $field->template = $template;
- Form::renderField($field);
- if($field->type === "header") {
- $header_count++;
- }
- }
- ?>
- <hr/>
- <h3><?=htmlspecialchars(__("Void"))?></h3>
- <?php
- Form::renderField((object) [
- "type" => "checkbox",
- "name" => "void",
- "value" => $test->void,
- "label" => __("Void - All Tests / Venue Closed"),
- ]);
- if($config->hasAlcohol ?? false) {
- Form::renderField((object) [
- "type" => "checkbox",
- "name" => "void_primary",
- "value" => $test->void_primary,
- "label" => __("Void - Gaming Test"),
- ]);
- Form::renderField((object) [
- "type" => "checkbox",
- "name" => "void_secondary",
- "value" => $test->void_secondary,
- "label" => __("Void - Alcohol Test"),
- ]);
- }
- Form::renderField((object) [
- "type" => "textarea",
- "name" => "void_notes",
- "label" => __("Void Notes"),
- "value" => $test->void_notes,
- "maxLength" => 65535,
- "helpText" => __("You must fill in this field if any part of the test was void."),
- ]);
- ?>
- </div>
- </div>
- </div>
- <div class="col-xl-6">
- <div class="row">
- <div class="col-md col-xl-12">
- <div class="card mb-3">
- <div class="card-header">
- Info
- </div>
- <div class="card-body p-0">
- <div id="map" data-maps data-lat="<?=$location->latitude?>" data-lng="<?=$location->longitude?>" data-zoom="17" data-marker="true" style="height: 320px;">
- </div>
- </div>
- <?php
- render_card_list_group($get_test_details($test));
- ?>
- </div>
- </div>
- <div class="col-md col-xl-12">
- <div class="card mb-3">
- <div class="card-header">
- Tester
- </div>
- <?php
- render_card_list_group($tester_details);
- ?>
- </div>
- <?php
- if(isset($tester_invoice_details)) {
- ?>
- <div class="card mb-3">
- <div class="card-header">
- Tester Invoice
- </div>
- <?php
- render_card_list_group($tester_invoice_details);
- if($test->getTesterInvoiceStatus() === Test::STATUS_TESTER_INVOICE_PENDING) {
- ?>
- <div class="card-body text-center">
- <button class="btn btn-success" type="submit" name="accept_tester_invoice" value="1">
- Paid Invoice
- </button>
- <button class="btn btn-danger" type="submit" name="reject_tester_invoice" value="1">
- Reject Invoice
- </button>
- </div>
- <?php
- }
- ?>
- </div>
- <?php
- }
- ?>
- </div>
- </div>
- <?php
- if($test->verifier_id && $test->dts_verified) {
- $verifier = $test->getVerifier();
- $time_verified = CarbonImmutable::parse($test->dts_verified, "UTC")->getTimestamp();
- ?>
- <div class="card mb-3">
- <div class="card-header">
- <?=htmlspecialchars(__("Verification Info"))?>
- </div>
- <div class="list-group list-group-flush">
- <div class="list-group-item d-flex justify-content-between">
- <div>
- <?=htmlspecialchars(__("Verifier"))?>
- </div>
- <div>
- <?=htmlspecialchars($verifier->getDisplayName())?>
- </div>
- </div>
- <div class="list-group-item d-flex justify-content-between">
- <div>
- <?=htmlspecialchars(__("Verified Date/Time"))?>
- </div>
- <div>
- <?=htmlspecialchars(Util::getDisplayDateTime($time_verified))?>
- </div>
- </div>
- <div class="list-group-item d-flex justify-content-between">
- <div>
- <?=htmlspecialchars(__("Verifier Notes"))?>
- </div>
- <div>
- <?=$test->getVerifierNotesHtml()?>
- </div>
- </div>
- </div>
- </div>
- <?php
- }
- ?>
- <div class="card mb-3">
- <div class="card-header">
- Verification
- </div>
- <div class="card-body">
- <div class="row mb-1 align-items-center">
- <label class="col-sm-4 col-form-label col-form-label-sm">Verifier</label>
- <div class="col-sm">
- <?=htmlspecialchars(Core::$user->getDisplayName())?>
- </div>
- </div>
- <hr />
- <section class="mb-4">
- <h5><?=htmlspecialchars(__("Overrides"))?></h5>
- <?php
- if($template->hasPassFail()) {
- ?>
- <div class="row mb-1">
- <label class="col-sm-4 col-form-label col-form-label-sm" for="pass-override">Pass Override</label>
- <div class="col-sm">
- <select class="form-control form-control-sm" name="pass_override" id="pass-override">
- <option value="">None</option>
- <option value="1">Pass</option>
- <option value="0">Fail</option>
- </select>
- </div>
- </div>
- <?php
- }
- ?>
- <div class="row mb-1">
- <label class="col-sm-4 col-form-label col-form-label-sm" for="start-override">Start Override</label>
- <div class="col-sm">
- <input class="form-control form-control-sm" type="datetime-local" name="start_override" id="start-override" />
- </div>
- </div>
- <div class="row mb-1">
- <label class="col-sm-4 col-form-label col-form-label-sm" for="end-override">End Override</label>
- <div class="col-sm">
- <input class="form-control form-control-sm" type="datetime-local" name="end_override" id="end-override" />
- </div>
- </div>
- <div class="row mb-1">
- <label class="col-sm-4 col-form-label col-form-label-sm" for="customer-fee">Customer Fee Override</label>
- <div class="col-sm">
- <div class="input-group input-group-sm">
- <div class="input-group-prepend">
- <span class="input-group-text">£</span>
- </div>
- <input class="form-control" type="number" step="0.01" min="0" name="customer_fee" id="customer-fee" placeholder="Enter customer fee override" value="<?=htmlspecialchars($test->customer_fee)?>" />
- </div>
- </div>
- </div>
- <div class="row mb-1">
- <label class="col-sm-4 col-form-label col-form-label-sm" for="tester-fee">Tester Fee Override</label>
- <div class="col-sm">
- <div class="input-group input-group-sm">
- <div class="input-group-prepend">
- <span class="input-group-text">£</span>
- </div>
- <input class="form-control" type="number" step="0.01" min="0" name="tester_fee" id="tester-fee" placeholder="Enter tester fee override" value="<?=htmlspecialchars($test->test_fee)?>" />
- </div>
- </div>
- </div>
- </section>
- <section class="mb-4">
- <h5><?=htmlspecialchars(__("Costs & Notes"))?></h5>
- <div class="row mb-1">
- <label class="col-sm-4 col-form-label col-form-label-sm" for="travel-cost">Travel Costs</label>
- <div class="col-sm">
- <div class="input-group input-group-sm">
- <div class="input-group-prepend">
- <span class="input-group-text">£</span>
- </div>
- <input class="form-control" type="number" step="0.01" min="0" max="999.99" name="travel_cost" id="travel-cost" placeholder="Enter travel costs" value="<?=htmlspecialchars($test->test_travel_cost)?>" />
- </div>
- </div>
- </div>
- <div class="row mb-1">
- <label class="col-sm-4 col-form-label col-form-label-sm" for="verifier-notes">Verifier Notes</label>
- <div class="col-sm">
- <textarea class="form-control form-control-sm" name="verifier_notes" id="verifier-notes" placeholder="Enter verifier notes" rows="4"><?=htmlspecialchars($test->verifier_notes)?></textarea>
- </div>
- </div>
- <div class="row mb-1 align-items-center">
- <label class="col-sm-4 col-form-label col-form-label-sm" for="retest">Set As Retest</label>
- <div class="col-sm">
- <div class="custom-control custom-checkbox">
- <input class="custom-control-input" type="checkbox" name="retest" id="retest" value="1" <?=Form::checked($test->retest)?> />
- <label class="custom-control-label" for="retest">This test was a retest</label>
- </div>
- </div>
- </div>
- </section>
- <section class="mb-4">
- <h5><?=htmlspecialchars(__("New Test"))?></h5>
- <div class="row mb-1">
- <label class="col-sm-4 col-form-label col-form-label-sm" for="new-test-project-id">
- Create New Test
- </label>
- <div class="col-sm">
- <div class="input-group">
- <select class="form-control" name="new_test_project_id" id="new-test-project-id">
- <option value="0">Do not create</option>
- <?php
- foreach($future_projects as $future_project) {
- ?>
- <option value="<?=$future_project->id?>" data-customer-fee="<?=$future_project->default_customer_fee?>">
- <?=htmlspecialchars($future_project->name)?>
- </option>
- <?php
- }
- ?>
- </select>
- <div class="input-group-append">
- <div class="input-group-text">
- <div class="custom-control custom-checkbox">
- <input class="custom-control-input" type="checkbox" name="new_test_is_retest" id="new-test-is-retest" value="1" />
- <label class="custom-control-label" for="new-test-is-retest"><?=htmlspecialchars(__("Retest"))?></label>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <?php
- if($location->email) {
- ?>
- <div class="row mb-1 align-items-center">
- <label class="col-sm-4 col-form-label col-form-label-sm" for="payment-required">
- Invoice Location
- </label>
- <div class="col-sm">
- <div class="custom-control custom-switch">
- <input class="custom-control-input" id="payment-required" name="payment_required" type="checkbox" value="1" />
- <label class="custom-control-label" for="payment-required"><?=htmlspecialchars(__("Send Invoice"))?></label>
- </div>
- </div>
- </div>
- <div class="row mb-1 align-items-center">
- <label class="col-sm-4 col-form-label col-form-label-sm" for="invoice-amount">
- Invoice Amount
- </label>
- <div class="col-sm">
- <div class="input-group input-group-sm">
- <div class="input-group-prepend">
- <span class="input-group-text">£</span>
- </div>
- <input class="form-control" type="number" step="0.01" min="0" max="999.99" name="invoice_amount" id="invoice-amount" placeholder="Enter invoice amount" value="0.00" />
- </div>
- </div>
- </div>
- <?php
- }
- ?>
- </section>
- <?php
- if($test->getStatus() === Test::STATUS_PENDING_VERIFICATION) {
- ?>
- <section class="mb-4">
- <h5><?=htmlspecialchars(__("Notifications"))?></h5>
- <?php
- $customer_checked = $customer->email_after_test;
- $location_checked = $customer->email_locations_after_test;
- $email_address_configs = [
- ["email" => $customer->email, "label" => "Email Headquarters", "name" => "email_customer", "checked" => $customer_checked],
- ["email" => $location->email, "label" => "Email Venue", "name" => "email_location", "checked" => $location_checked],
- ["email" => $location->area_manager_email, "label" => "Email AM", "name" => "email_location_area_manager", "checked" => $location_checked],
- ["email" => $location->operations_manager_email, "label" => "Email OM", "name" => "email_location_operations_manager", "checked" => $location_checked],
- ["email" => $location->gaming_manager_email, "label" => "Email GM", "name" => "email_location_gaming_manager", "checked" => $location_checked],
- ["email" => $location->senior_gaming_manager_email, "label" => "Email SGM", "name" => "email_location_senior_gaming_manager", "checked" => $location_checked],
- ];
- foreach($email_address_configs as $email_address_config) {
- $email_address = $email_address_config["email"];
- if(!$email_address) {
- continue;
- }
- $label = $email_address_config["label"];
- $name = $email_address_config["name"];
- $checked = $email_address_config["checked"];
- $id = str_replace("_", "-", $name);
- ?>
- <div class="row mb-1">
- <label class="col-sm-4 col-form-label col-form-label-sm" for="<?= $id ?>">
- <?= htmlspecialchars($label) ?>
- </label>
- <div class="col-sm">
- <div class="custom-control custom-checkbox">
- <input class="custom-control-input" type="checkbox" name="<?= $name ?>"
- id="<?= $id ?>" value="1" <?= Form::checked($checked) ?> />
- <label class="custom-control-label"
- for="<?= $id ?>"><?= htmlspecialchars($email_address) ?></label>
- </div>
- </div>
- </div>
- <?php
- }
- ?>
- <div class="row mb-1">
- <label class="col-sm-4 col-form-label col-form-label-sm"
- for="include-previous-test"><?= htmlspecialchars(__("Previous Test")) ?></label>
- <div class="col-sm">
- <div class="custom-control custom-checkbox">
- <input class="custom-control-input" type="checkbox" name="include_previous_test"
- id="include-previous-test" value="1" checked/>
- <label class="custom-control-label" for="include-previous-test">
- <?= htmlspecialchars(__("Attach PDF")) ?>
- </label>
- </div>
- </div>
- </div>
- <div class="row mb-1">
- <label class="col-sm-4 col-form-label col-form-label-sm" for="tester-message">Message to Tester (if
- rejecting)</label>
- <div class="col-sm">
- <textarea class="form-control form-control-sm" name="tester_message"
- id="tester-message" placeholder="Enter message to tester"
- rows="4"><?= htmlspecialchars($tester_message) ?></textarea>
- </div>
- </div>
- </section>
- <?php
- }
- ?>
- <?php
- // Submit buttons
- if($test->getStatus() === Test::STATUS_PENDING_VERIFICATION) {
- ?>
- <div class="row mb-1">
- <div class="col-sm offset-sm-4">
- <button class="btn btn-success" type="submit" name="accept" value="1">Accept
- </button>
- <button class="btn btn-danger" type="submit" name="reject" value="1">Reject</button>
- </div>
- </div>
- <?php
- }
- else {
- ?>
- <div class="row mb-1">
- <div class="col-sm offset-sm-4">
- <button class="btn btn-primary" type="submit">Submit</button>
- </div>
- </div>
- <?php
- }
- ?>
- </div>
- </div>
- <?php
- $previous_test = $test->getPreviousTest();
- if($previous_test) {
- $dt = $previous_test->getDateTimeStart();
- $previous_test_details = $get_test_details($previous_test);
- $previous_test_details_subset = [
- "Date/Time" => $previous_test_details["Start"],
- "Result" => $previous_test_details["Result"],
- ];
- ?>
- <div class="card mb-3">
- <div class="card-header">
- <?=htmlspecialchars(__("Previous Test"))?>
- </div>
- <?php
- render_card_list_group($previous_test_details_subset);
- ?>
- </div>
- <?php
- }
- ?>
- </div>
- </div>
- </form>
- </div>
|