| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520 |
- <?php /** @noinspection PhpUnhandledExceptionInspection */
- /**
- * @var int $filter_count
- * @var array $sorts
- * @var string $sort
- * @var int $status
- * @var int $status_tester_invoice
- * @var Customer[] $customers
- * @var int $customer_id
- * @var Project[] $projects
- * @var int $project_id
- * @var bool $pass
- * @var int $retest
- * @var int $test_id
- * @var int $tester_id
- * @var int $location_id
- * @var string $location_internal_id
- * @var string $location_name
- * @var int $min_days_overdue
- * @var int $custom
- * @var object $pagination_object
- */
- $filters_collapse = $filter_count ? "collapse show" : "collapse";
- $query = $_GET;
- unset($query["path"]);
- $query["sort"] = "SORT";
- $result_options = [
- "1" => "Pass",
- "0" => "Fail",
- ];
- $retest_options = [
- "" => "Any",
- "0" => "Tests Only",
- "1" => "Retests Only"
- ];
- $custom_filters = [
- "overdue_project" => "Overdue (Project Deadline)",
- "overdue_test" => "Overdue (Test Due Date)",
- "declined" => "Declined",
- ];
- $customer_options = [];
- foreach($customers as $customer) {
- $customer_options[$customer->id] = $customer->name;
- }
- $project_options = [];
- foreach($projects as $project) {
- $project_options[$project->id] = $project->name;
- }
- ?>
- <div class="mt-3 py-4">
- <div class="container-fluid">
- <div class="row">
- <div class="col-sm">
- <h2>
- Tests
- </h2>
- </div>
- <div class="col-sm-auto">
- <div class="row">
- <div class="col-auto">
- <a class="btn btn-outline-primary" href="#filters" data-toggle="collapse">
- Toggle Filters <span class="badge badge-pill badge-danger"><?=$filter_count?></span>
- </a>
- </div>
- <div class="col">
- <div class="input-group">
- <div class="input-group-prepend">
- <label for="sort-dropdown" class="input-group-text">
- Sort
- </label>
- </div>
- <select class="form-control" id="sort-dropdown" data-url-template="/account/tests?<?=htmlspecialchars(http_build_query($query))?>">
- <?php
- HtmlHelper::renderOptions($sorts, $sort);
- ?>
- </select>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="form-row my-3">
- <div class="col-xl col-6 col-lg-4 mb-1">
- <a class="btn btn-block btn-primary" href="/account/tests">Show All</a>
- </div>
- <div class="col-xl col-6 col-lg-4 mb-1">
- <a class="btn btn-block btn-secondary" href="/account/tests?status=<?=Test::STATUS_UNASSIGNED?>">Unassigned</a>
- </div>
- <div class="col-xl col-6 col-lg-4 mb-1">
- <a class="btn btn-block btn-warning" href="/account/tests?status=<?=Test::STATUS_CONFIRMED?>">Confirmed</a>
- </div>
- <div class="col-xl col-6 col-lg-4 mb-1">
- <a class="btn btn-block btn-success" href="/account/tests?status=<?=Test::STATUS_PENDING_VERIFICATION?>&sort=end">Pending Verification</a>
- </div>
- <div class="col-xl col-6 col-lg-4 mb-1">
- <a class="btn btn-block btn-danger" href="/account/tests?pass=0">Fails</a>
- </div>
- <div class="col-xl col-6 col-lg-4 mb-1">
- <a class="btn btn-block btn-secondary" href="/account/tests?status=<?=Test::STATUS_CANCELLED?>">Cancelled / Rejected</a>
- </div>
- </div>
- <div class="<?=$filters_collapse?>" id="filters">
- <form method="get">
- <div class="card card-body bg-light text-dark mb-3">
- <h3>Filters</h3>
- <div class="row mb-1">
- <div class="col-lg-6">
- <div class="row mb-1">
- <label class="col-form-label col-sm-4" for="status">Status</label>
- <div class="col-sm">
- <select class="form-control" name="status" id="status">
- <option value="">Any not rejected</option>
- <?php
- foreach(Test::STATUSES as $value => $display) {
- $selected = ($value === $status) ? "selected" : "";
- ?>
- <option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
- <?php
- }
- ?>
- </select>
- </div>
- </div>
- <div class="row mb-1">
- <label class="col-form-label col-sm-4" for="status-tester-invoice">Tester Invoice Status</label>
- <div class="col-sm">
- <select class="form-control" name="status_tester_invoice" id="status-tester-invoice">
- <option value="">Any</option>
- <?php
- foreach(Test::STATUSES_TESTER_INVOICE as $value) {
- $display = Test::getStatusTesterInvoiceText($value);
- $selected = ($value === $status_tester_invoice) ? "selected" : "";
- ?>
- <option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
- <?php
- }
- ?>
- </select>
- </div>
- </div>
- <div class="row mb-1">
- <label class="col-form-label col-sm-4" for="customer-id">Customer</label>
- <div class="col-sm">
- <select class="form-control" name="customer_id" id="customer-id">
- <option value="">Select customer</option>
- <?php
- HtmlHelper::renderOptions($customer_options, $customer_id);
- ?>
- </select>
- </div>
- </div>
- <div class="row mb-1">
- <label class="col-form-label col-sm-4" for="project-id">Project</label>
- <div class="col-sm">
- <select class="form-control" name="project_id" id="project-id">
- <option value="">Select project</option>
- <?php
- HtmlHelper::renderOptions($project_options, $project_id);
- ?>
- </select>
- </div>
- </div>
- <div class="row mb-1">
- <label class="col-sm-4 col-form-label" for="pass">Result</label>
- <div class="col-sm">
- <select class="form-control" name="pass" id="pass">
- <option value=""><?=htmlspecialchars(__("Any"))?></option>
- <?php
- HtmlHelper::renderOptions($result_options, $pass);
- ?>
- </select>
- </div>
- </div>
- <div class="row mb-1">
- <label class="col-sm-4 col-form-label" for="retest">Retest</label>
- <div class="col-sm">
- <select class="form-control" name="retest" id="retest">
- <?php
- HtmlHelper::renderOptions($retest_options, $retest);
- ?>
- </select>
- </div>
- </div>
- </div>
- <div class="col-lg">
- <div class="row mb-1">
- <label class="col-sm-4 col-form-label" for="test-id">Test ID</label>
- <div class="col-sm">
- <input class="form-control" type="text" name="test_id" id="test-id" placeholder="Enter test ID" value="<?=$test_id?>" />
- </div>
- </div>
- <div class="row mb-1">
- <label class="col-sm-4 col-form-label" for="tester-id">Tester ID</label>
- <div class="col-sm">
- <input class="form-control" type="text" name="tester_id" id="tester-id" placeholder="Enter tester ID" value="<?=$tester_id?>" />
- </div>
- </div>
- <div class="row mb-1">
- <label class="col-sm-4 col-form-label" for="location-id">Location ID</label>
- <div class="col-sm">
- <input class="form-control" type="text" name="location_id" id="location-id" placeholder="Enter location ID" value="<?=$location_id?>" />
- </div>
- </div>
- <div class="row mb-1">
- <label class="col-sm-4 col-form-label" for="location-internal-id">Internal ID</label>
- <div class="col-sm">
- <input class="form-control" type="text" name="location_internal_id" id="location-internal-id" placeholder="Enter location internal ID" value="<?=htmlspecialchars($location_internal_id)?>" />
- </div>
- </div>
- <div class="row mb-1">
- <label class="col-sm-4 col-form-label" for="location-name">Location Name</label>
- <div class="col-sm">
- <input class="form-control" type="text" name="location_name" id="location-name" placeholder="Enter location name" value="<?=htmlspecialchars($location_name)?>" />
- </div>
- </div>
- <div class="row mb-1">
- <label class="col-sm-4 col-form-label" for="min-days-overdue">
- <?=htmlspecialchars(__("Min. Days Overdue"))?>
- </label>
- <div class="col-sm">
- <input class="form-control" type="number" name="min_days_overdue" id="min-days-overdue" placeholder="<?=htmlspecialchars(__("Enter days"))?>" value="<?=$min_days_overdue?>" />
- </div>
- </div>
- <div class="row mb-1">
- <label class="col-sm-4 col-form-label" for="custom">Custom Filter</label>
- <div class="col-sm">
- <select class="form-control" name="custom" id="custom">
- <option value="">Select custom filter</option>
- <?php
- HtmlHelper::renderOptions($custom_filters, $custom);
- ?>
- </select>
- </div>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-lg">
- <div class="row">
- <div class="col-sm offset-sm-4">
- <button class="btn btn-primary" type="submit">Filter</button>
- <a class="btn btn-secondary" href="/account/tests">Clear Filters</a>
- </div>
- </div>
- </div>
- <div class="col-lg">
- </div>
- </div>
- </div>
- <input type="hidden" name="sort" value="<?=$sort?>" />
- </form>
- </div>
- <?php
- if(empty($tests)) {
- ?>
- <div class="alert alert-info">
- There are no tests to display.
- </div>
- <?php
- }
- else {
- ?>
- <div class="mb-3">
- <?php
- View::include("pagination", compact("pagination_object"));
- ?>
- </div>
- <form method="post">
- <div class="table-responsive mb-3" style="min-height: 224px;">
- <table class="table table-sm table-sm-text table-hover" style="min-width: 1024px;">
- <thead>
- <tr>
- <th>
- <label for="tests-table-select-all" class="sr-only">
- <?=htmlspecialchars(__("Select All"))?>
- </label>
- <input type="checkbox" id="tests-table-select-all" />
- </th>
- <th>ID</th>
- <th>Location</th>
- <th>Project</th>
- <th>Tester</th>
- <th>Due Date</th>
- <th>Test Date</th>
- <th>T. Costs</th>
- <th>P. Costs</th>
- <th>Status</th>
- <th>Result</th>
- <th>Retest</th>
- <th>Actions</th>
- </tr>
- </thead>
- <tbody>
- <?php
- foreach($tests as $test) {
- $location = $test->getLocation();
- $project = $test->getProject();
- $tester = $test->getTester();
- $dt_due = $test->getDateTimeDue();
- $is_overdue = $test->isOverdue();
- $due_class = $is_overdue ? "text-danger" : "";
- $dt_end = $test->getDateTimeEnd();
- ?>
- <tr>
- <td>
- <label for="test-checkbox-<?=$test->id?>" class="sr-only">
- <?=htmlspecialchars(__("Select Test ID %d", $test->id))?>
- </label>
- <input type="checkbox" name="test_ids[]" id="test-checkbox-<?=$test->id?>" value="<?=$test->id?>" />
- </td>
- <td>
- <?=$test->id?>
- </td>
- <td class="align-middle">
- <a href="/account/locations/<?=$location->id?>">
- <?=htmlspecialchars($location->name)?>
- <?php
- if($location->internal_id) {
- ?>
- (Internal ID: <?=htmlspecialchars($location->internal_id)?>)
- <?php
- }
- ?>
- </a><br />
- <?=htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city"]))?>
- </td>
- <td class="align-middle">
- <a href="/account/projects/<?=$project->id?>?location_id=<?=$test->location_id?>">
- <?=htmlspecialchars($project->name)?>
- </a><br />
- <strong>Deadline:</strong> <?=date("d/m/Y", strtotime($project->dts_deadline . " UTC"))?>
- </td>
- <td class="align-middle">
- <?php
- if($tester) {
- ?>
- <a href="/account/users/<?=$tester->id?>"><?=htmlspecialchars($tester->getDisplayName())?></a>
- <?php
- if($test->status_tester_invoice > 0) {
- $time = Util::getUnixTimeFromUTC($test->dts_tester_invoice_generated);
- $dts = Util::getDisplayDateTime($time);
- ?>
- <br />
- <span class="badge badge-<?=Test::getStatusTesterInvoiceClass($test->status_tester_invoice)?>" title="Generated on <?=$dts?>"><?=Test::getStatusTesterInvoiceText($test->status_tester_invoice)?></span>
- <?php
- }
- }
- else {
- ?>
- <small class="text-muted">N/A</small>
- <?php
- }
- ?>
- </td>
- <td class="align-middle <?=$due_class?>">
- <?php
- if($dt_due) {
- $days_overdue = $dt_due->diffInDays();
- ?>
- <strong><?=$dt_due->format("d/m/Y")?></strong>
- <?php
- if($is_overdue && !$test->isDone()) {
- ?><br />
- <small>
- <?=htmlspecialchars(n__("%d day overdue", "%d days overdue", $days_overdue, $days_overdue))?>
- </small>
- <?php
- }
- }
- else {
- ?>
- <small class="text-muted">N/A</small>
- <?php
- }
- ?>
- </td>
- <td>
- <?php
- if($dt_end) {
- $dt_end = $dt_end->setTimezone(TIMEZONE);
- ?>
- <strong>
- <?=$dt_end->format("d/m/Y")?>
- </strong>
- <?php
- }
- ?>
- </td>
- <td class="text-right align-middle">
- <?php
- if($test->test_travel_cost > 0) {
- ?>
- £<?=number_format($test->test_travel_cost, 2)?>
- <?php
- }
- ?>
- </td>
- <td class="text-right align-middle">
- <?php
- $tester_invoice_costs = $test->getTesterInvoiceCosts();
- if($tester_invoice_costs > 0) {
- ?>
- £<?=number_format($tester_invoice_costs, 2)?>
- <?php
- }
- ?>
- </td>
- <td class="text-center align-middle">
- <span class="badge badge-<?=$test->getStatusClass()?>"><?=$test->getStatusText()?></span>
- </td>
- <td class="text-center align-middle text-<?=$test->getPassClass()?>">
- <div title="<?=$test->getPassText()?>">
- <i class="fas fa-2x fa-fw fa-<?=$test->getPassIcon()?>"></i>
- </div>
- </td>
- <td class="text-center align-middle">
- <?php
- if($test->retest) {
- ?>
- <i class="fa fa-fw fa-check fa-2x text-success"></i>
- <?php
- }
- ?>
- </td>
- <td class="text-right align-middle">
- <div class="dropdown">
- <button class="btn btn-sm btn-secondary dropdown-toggle" type="button" id="test-dropdown-<?=$test->id?>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
- Actions
- </button>
- <div class="dropdown-menu" aria-labelledby="test-dropdown-<?=$test->id?>">
- <a class="dropdown-item" href="/account/tests/<?=$test->id?>">View</a>
- <?php
- if($test->hasTesterInvoicePDF()) {
- ?>
- <a class="dropdown-item" href="/account/tests/<?=$test->id?>/invoice">Download Tester Invoice</a>
- <?php
- }
- if($test->hasTravelCostsPhoto()) {
- ?>
- <a class="dropdown-item" href="/account/tests/<?=$test->id?>/files/travel_costs">View Travel Costs Photo</a>
- <?php
- }
- ?>
- </div>
- </div>
- </td>
- </tr>
- <?php
- }
- ?>
- </tbody>
- </table>
- </div>
- <div class="row">
- <div class="col-md">
- </div>
- <div class="col-md-auto">
- <div class="input-group">
- <div class="input-group-prepend">
- <label class="input-group-text" for="batch-action">
- Batch Action
- </label>
- </div>
- <select class="form-control" name="batch_action" id="batch-action" required>
- <option value="">Select Action</option>
- <option value="unassign">Unassign</option>
- <option value="mark_tester_invoice_paid">Mark Tester Invoice as Paid</option>
- <option value="reject_tester_invoice">Reject Tester Invoices</option>
- <option value="send_test_assigned_email">Send Test Assigned Email</option>
- </select>
- <div class="input-group-append">
- <button type="submit" class="btn btn-primary" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>">
- Submit
- </button>
- </div>
- </div>
- </div>
- </div>
- </form>
- <div class="mt-3">
- <?php
- View::include("pagination", compact("pagination_object"));
- ?>
- </div>
- <?php
- }
- ?>
- </div>
- </div>
|