| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457 |
- <?php
- $date_resolutions = [
- "quarterly" => "Quarterly",
- "monthly" => "Monthly",
- ];
- $date_ranges = [
- "ytd" => "Year to Date",
- //"unbound" => "Unbound",
- "custom" => "Custom",
- ];
- $years = range(2018, date("Y"));
- $date_range_custom_style = ($date_range == "custom") ? "" : "display: none";
- ?>
- <div class="container">
- <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="row mb-1">
- <label class="col-sm-4 text-sm-right">
- Date Range
- </label>
- <div class="col-sm">
- <?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">
- <div class="input-group">
- <div class="input-group-prepend">
- <span class="input-group-text">
- From
- </span>
- </div>
- <select class="form-control" name="from_quarter">
- <?php
- foreach($years as $year) {
- foreach(range(1, 4) as $quarter) {
- $value = "$year-$quarter";
- $selected = ($value == $from_quarter) ? "selected" : "";
- switch($quarter) {
- case 1: $quarter_text = "Q1 (Jan-Mar)"; break;
- case 2: $quarter_text = "Q2 (Apr-Jun)"; break;
- case 3: $quarter_text = "Q3 (Jul-Sep)"; break;
- case 4: $quarter_text = "Q4 (Oct-Dec)"; break;
- }
- ?>
- <option value="<?=$value?>" <?=$selected?>><?=$year?> <?=$quarter_text?></option>
- <?php
- }
- }
- ?>
- </select>
- </div>
- </div>
- <div class="col-lg">
- <div class="input-group">
- <div class="input-group-prepend">
- <span class="input-group-text">
- To
- </span>
- </div>
- <select class="form-control" name="to_quarter">
- <?php
- foreach($years as $year) {
- foreach(range(1, 4) as $quarter) {
- $value = "$year-$quarter";
- $selected = ($value == $to_quarter) ? "selected" : "";
- switch($quarter) {
- case 1: $quarter_text = "Q1 (Jan-Mar)"; break;
- case 2: $quarter_text = "Q2 (Apr-Jun)"; break;
- case 3: $quarter_text = "Q3 (Jul-Sep)"; break;
- case 4: $quarter_text = "Q4 (Oct-Dec)"; break;
- }
- ?>
- <option value="<?=$value?>" <?=$selected?>><?=$year?> <?=$quarter_text?></option>
- <?php
- }
- }
- ?>
- </select>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="row mb-1">
- <label class="col-sm-4 text-sm-right" for="date-resolution">
- Date Resolution
- </label>
- <div class="col-sm">
- <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>
- <div class="row mb-1">
- <label class="col-sm-4 text-sm-right" for="project-ids">
- Projects
- </label>
- <div class="col-sm">
- <select class="form-control" name="project_ids[]" id="project-ids" multiple size="8">
- <?php
- foreach($all_projects as $project) {
- $selected = in_array($project->id, $project_ids) ? "selected" : "";
- ?>
- <option value="<?=$project->id?>" <?=$selected?>><?=htmlspecialchars($project->name)?></option>
- <?php
- }
- ?>
- </select>
- <small class="form-text text-muted">Hint: Ctrl+Click / Cmd+Click to select multiple projects.</small>
- </div>
- </div>
- <div class="row mb-1">
- <label class="col-sm-4 text-sm-right" for="location-ids">
- Location IDs
- </label>
- <div class="col-sm">
- <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. Leave blank to generate a report for all locations.</small>
- </div>
- </div>
- <div class="row">
- <div class="col-sm offset-sm-4">
- <button class="btn btn-primary" type="submit" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>">
- Submit
- </button>
- </div>
- </div>
- </div>
- </div>
- </form>
- <?php
- if(Core::$user->isAdmin()) {
- if($locations_missing_region) {
- ?>
- <div class="alert alert-warning 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 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
- }
- }
- ?>
- <?php
- if($charts) {
- ?>
- <h2>Charts / Statistics</h2>
- <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)) {
- ?>
- <div class="card card-body mb-3">
- Pass/Fail Count
- <div class="stat">
- <?=$total_data->passCount?> /
- <?=$total_data->failCount?>
- </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" 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">
- <?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="from_quarter" value="<?=htmlspecialchars($from_quarter)?>" />
- <input type="hidden" name="to_quarter" value="<?=htmlspecialchars($to_quarter)?>" />
- <input type="hidden" name="date_resolution" value="<?=htmlspecialchars($date_resolution)?>" />
- <?php
- foreach($project_ids as $project_id) {
- ?>
- <input type="hidden" name="project_ids[]" value="<?=intval($project_id)?>" />
- <?php
- }
- ?>
- <input type="submit" value="Submit" class="d-none" />
- </form>
- <?php
- }
- if($has_pass_fail) {
- ?>
- <div class="d-print-none">
- <h2>Extra Information</h2>
- <h3>Region Data</h3>
- <?php
- foreach($region_data as $region => $rows) {
- ?>
- <h4>Region: <?=htmlspecialchars($region)?></h4>
- <table class="table">
- <col style="width: 20%" />
- <col style="width: 20%" />
- <col style="width: 20%" />
- <col style="width: 20%" />
- <col style="width: 20%" />
- <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
- }
- ?>
- <h3>Area Manager Data</h3>
- <?php
- foreach($area_manager_data as $area_manager => $rows) {
- ?>
- <h4>Area Manager: <?=htmlspecialchars($area_manager)?></h4>
- <table class="table">
- <col style="width: 20%" />
- <col style="width: 20%" />
- <col style="width: 20%" />
- <col style="width: 20%" />
- <col style="width: 20%" />
- <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>
|