| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451 |
- <?php
- /**
- * @var Customer $customer
- * @var Chart[] $charts
- * @var string[] $key_labels
- * @var bool $has_pass_fail
- *
- * @var string $date_range
- * @var string $date_resolution
- * @var string $date_start
- * @var string $date_end
- *
- * @var int[] $location_ids
- * @var int $retests
- * @var int[] $exclude_project_ids
- *
- * @var array $project_table_data
- * @var Location[] $locations_missing_region
- * @var Location[] $locations_missing_area_manager
- *
- * @var array $total_data
- * @var array $region_data
- * @var array $area_manager_data
- */
- $user = Core::$user;
- $date_resolutions = [
- "quarterly" => "Quarterly",
- "monthly" => "Monthly",
- ];
- $date_ranges = [
- "ytd" => "Year to Date",
- //"unbound" => "Unbound",
- "custom" => "Custom",
- ];
- $retests_options = [
- 0 => "Exclude",
- 1 => "Retests Only"
- ];
- $years = range(2018, date("Y"));
- $date_range_custom_style = ($date_range === "custom") ? "" : "display: none";
- $date_range_value = "";
- if($date_start && $date_end) {
- list($min_year, $min_month, $min_day) = explode("-", $date_start);
- list($max_year, $max_month, $max_day) = explode("-", $date_end);
- $date_range_value = "$min_day/$min_month/$min_year - $max_day/$max_month/$max_year";
- }
- ?>
- <script>
- let selectedProjectIds = <?=json_encode($exclude_project_ids)?>;
- let projectData = <?=json_encode($project_table_data)?>;
- </script>
- <div class="container mt-3 py-4">
- <div class="row d-print-none">
- <div class="col">
- <h2><?=htmlspecialchars($customer->name)?> Reports</h2>
- </div>
- <div class="col-auto">
- <?php
- if($charts) {
- ?>
- <div class="dropdown">
- <button type="button" class="btn btn-secondary dropdown-toggle" id="actions-button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
- Actions
- </button>
- <div class="dropdown-menu" aria-labelledby="actions-button">
- <a class="dropdown-item" href="#" id="export-pptx-action">Export PPTX</a>
- </div>
- </div>
- <?php
- }
- ?>
- </div>
- </div>
- <form class="mb-4 d-print-none" method="post">
- <input type="hidden" name="customer_id" value="<?=htmlspecialchars($customer->id)?>" />
- <div class="row">
- <div class="col-md">
- <div class="form-group">
- <label class="form-label" for="date-range">
- Date Range
- </label><br / >
- <?php
- foreach($date_ranges as $value => $display) {
- $checked = ($value === $date_range) ? "checked" : "";
- ?>
- <div class="form-check form-check-inline">
- <input class="form-check-input" type="radio" name="date_range" id="date-range-<?=htmlspecialchars($value)?>" value="<?=htmlspecialchars($value)?>" <?=$checked?> data-date-range-radio-input />
- <label class="form-check-label" for="date-range-<?=htmlspecialchars($value)?>"><?=htmlspecialchars($display)?></label>
- </div>
- <?php
- }
- ?>
- <div class="row mt-1" id="date-range-custom-fields" style="<?=$date_range_custom_style?>">
- <div class="col-lg">
- <input class="form-control" type="text" id="date-range" value="<?=htmlspecialchars($date_range_value)?>" />
- <input type="hidden" name="date_start" id="date-start" value="<?=htmlspecialchars($date_start)?>" />
- <input type="hidden" name="date_end" id="date-end" value="<?=htmlspecialchars($date_end)?>" />
- </div>
- </div>
- </div>
- <div class="form-group">
- <label for="date-resolution">
- Date Resolution
- </label>
- <select class="form-control" name="date_resolution" id="date-resolution">
- <?php
- foreach($date_resolutions as $value => $display) {
- $selected = ($value === $date_resolution) ? "selected" : "";
- ?>
- <option value="<?=htmlspecialchars($value)?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
- <?php
- }
- ?>
- </select>
- </div>
- <div class="form-group">
- <label for="location-ids">
- Location IDs
- </label>
- <input class="form-control" name="location_ids" type="text" id="location-ids" value="<?=htmlspecialchars(implode(" ", $location_ids))?>" placeholder="Enter location IDs" />
- <small class="form-text text-muted">Separate each location ID with a space.<br />Leave blank to generate a report for all locations.</small>
- </div>
- <div class="form-group">
- <label for="retests">Retests</label>
- <select name="retests" id="retests" class="form-control">
- <option value="">Include</option>
- <?php
- foreach($retests_options as $value => $display) {
- $selected = $value === $retests ? "selected" : "";
- ?>
- <option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
- <?php
- }
- ?>
- </select>
- </div>
- <button class="btn btn-primary" type="submit" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>">
- Submit
- </button>
- </div>
- <div class="col-md">
- <div class="form-group">
- <label class="d-block">
- Exclude Projects
- </label>
- <button id="show-projects-list-button" type="button" class="btn btn-secondary">
- <?=htmlspecialchars(__("Show project list"))?>
- </button>
- <div id="projects-table-wrapper" style="display: none;">
- <table class="table table-sm table-sm-text table-hover table-pointer" id="projects-table">
- <thead>
- <tr>
- <th></th>
- <th>ID</th>
- <th>Name</th>
- <th><span title="Time of Day" data-toggle="tooltip">TOD</span></th>
- <th>Tests</th>
- <th>Report Month</th>
- </tr>
- </thead>
- </table>
- </div>
- </div>
- </div>
- </div>
- </form>
- <?php
- if($user->canSeeMissingData()) {
- if($locations_missing_region) {
- ?>
- <div class="alert alert-warning limit-height-1 d-print-none">
- There are some locations that are missing "region" information:
- <ul class="mb-0">
- <?php
- foreach($locations_missing_region as $location) {
- $url = (Core::$user->canAdmin()) ? "/account/locations/$location->id/edit" : "#";
- ?>
- <li>
- <a href="<?=htmlspecialchars($url)?>"><?=htmlspecialchars($location->name)?></a>
- <?php
- if($location->internal_id) {
- ?>
- <small class="text-info">(Internal ID: <?=htmlspecialchars($location->internal_id)?>)</small>
- <?php
- }
- ?>
- </li>
- <?php
- }
- ?>
- </ul>
- </div>
- <?php
- }
- if($locations_missing_area_manager) {
- ?>
- <div class="alert alert-warning limit-height-1 d-print-none">
- There are some locations that are missing "area manager" information:
- <ul class="mb-0">
- <?php
- foreach($locations_missing_area_manager as $location) {
- $url = (Core::$user->canAdmin()) ? "/account/locations/$location->id/edit" : "#";
- ?>
- <li>
- <a href="<?=htmlspecialchars($url)?>"><?=htmlspecialchars($location->name)?></a>
- <?php
- if($location->internal_id) {
- ?>
- <small class="text-info">(Internal ID: <?=htmlspecialchars($location->internal_id)?>)</small>
- <?php
- }
- ?>
- </li>
- <?php
- }
- ?>
- </ul>
- </div>
- <?php
- }
- }
- if($charts) {
- ?>
- <h2>
- Report
- </h2>
- <p>
- <?php
- if($retests === 0) {
- ?>
- <span class="badge badge-warning">Retests Excluded</span>
- <?php
- }
- else if($retests === 1) {
- ?>
- <span class="badge badge-warning">Retests Only</span>
- <?php
- }
- else {
- ?>
- <span class="badge badge-success">Retests Included</span>
- <?php
- }
- ?>
- </p>
- <div class="row">
- <div class="col-md-6">
- <div class="card card-body mb-3">
- Test Count
- <div class="stat">
- <?=$total_data->testCount?>
- </div>
- </div>
- </div>
- <div class="col-md-6">
- <?php
- if(isset($total_data->passCount)) {
- $pass_percentage = 0;
- if($total_data->testCount > 0) {
- $pass_percentage = number_format(($total_data->passCount * 100) / $total_data->testCount, 2);
- }
- ?>
- <div class="card card-body mb-3">
- Pass/Fail Count
- <div class="stat">
- <?=$total_data->passCount?> /
- <?=$total_data->failCount?> (<?=$pass_percentage?>%)
- </div>
- </div>
- <?php
- }
- ?>
- </div>
- </div>
- <div class="row mb-4">
- <div class="col-md-4 d-print-none" style="position: relative;">
- <h3>Chart List</h3>
- <div class="list-group limit-height-2" style="position: sticky; top: 7rem;">
- <?php
- foreach($charts as $index => $chart) {
- ?>
- <a class="list-group-item list-group-item-action" href="#chart-<?=$index?>">
- <?=htmlspecialchars($chart->getTitle())?>
- </a>
- <?php
- }
- ?>
- </div>
- </div>
- <div class="col-md-8">
- <?php
- foreach($charts as $index => $chart) {
- if($index > 0) {
- ?>
- <br />
- <?php
- }
- if($chart->beforeHtml) {
- echo $chart->beforeHtml;
- }
- ?>
- <a id="chart-<?=$index?>" style="display: block; position: relative; top: -7rem; visibility: hidden;"></a>
- <canvas id="<?=$chart->getID()?>" data-chart="<?=htmlspecialchars($chart->getJSON())?>" width="400" height="300">
- </canvas>
- <?php
- if($chart->print) {
- $chart->printDataTable();
- }
- if($chart->afterHtml) {
- echo $chart->afterHtml;
- }
- }
- ?>
- </div>
- </div>
- <?php
- foreach(["pptx", "odp"] as $format) {
- ?>
- <form id="form-<?=$format?>" method="post" action="/account/reports/export-<?=$format?>" data-rendered="0">
- <input type="hidden" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>" />
- <input type="hidden" name="customer_id" value="<?=intval($customer->id)?>" />
- <input type="hidden" name="date_range" value="<?=htmlspecialchars($date_range)?>" />
- <input type="hidden" name="date_start" id="date-start" value="<?=htmlspecialchars($date_start)?>" />
- <input type="hidden" name="date_end" id="date-end" value="<?=htmlspecialchars($date_end)?>" />
- <input type="hidden" name="date_resolution" value="<?=htmlspecialchars($date_resolution)?>" />
- <input type="hidden" name="retests" value="<?=htmlspecialchars($retests)?>" />
- <?php
- foreach($exclude_project_ids as $project_id) {
- ?>
- <input type="hidden" name="exclude_project_ids[]" value="<?=intval($project_id)?>" />
- <?php
- }
- ?>
- <input type="submit" value="Submit" class="d-none" />
- </form>
- <?php
- }
- if($has_pass_fail) {
- $tables = [
- (object) [
- "name" => "Region",
- "data" => $region_data
- ],
- (object) [
- "name" => "Area Manager",
- "data" => $area_manager_data
- ],
- ]
- ?>
- <div class="d-print-none">
- <h2>Extra Information</h2>
- <?php
- foreach($tables as $table) {
- $title = $table->name . " Data";
- $entity_type = $table->name;
- ?>
- <h3><?=htmlspecialchars($title)?></h3>
- <?php
- foreach($table->data as $entity_name => $rows) {
- ?>
- <h4><?=htmlspecialchars($entity_type)?>: <?=htmlspecialchars($entity_name)?></h4>
- <table class="table">
- <colgroup>
- <col style="width: 20%" />
- <col style="width: 20%" />
- <col style="width: 20%" />
- <col style="width: 20%" />
- <col style="width: 20%" />
- </colgroup>
- <thead>
- <tr>
- <th>Period</th>
- <th>Tests</th>
- <th>Passes</th>
- <th>Fails</th>
- <th>Rate</th>
- </tr>
- </thead>
- <tbody>
- <?php
- $index = 0;
- foreach($rows as $key => $data) {
- $rate = ($data->testCount == 0) ? "0.00" : number_format(($data->passCount * 100) / $data->testCount, 2);
- $label = $key_labels[$index];
- ?>
- <tr>
- <td><?=htmlspecialchars($label)?></td>
- <td><?=number_format($data->testCount)?></td>
- <td><?=number_format($data->passCount)?></td>
- <td><?=number_format($data->failCount)?></td>
- <td><?=$rate?>%</td>
- </tr>
- <?php
- $index++;
- }
- ?>
- </tbody>
- </table>
- <?php
- }
- }
- ?>
- ?>
- </div>
- <?php
- }
- ?>
- <?php
- }
- ?>
- </div>
|