| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- <?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">
- <div class="col-auto">
- <h2><?=htmlspecialchars($customer->name)?> Performance</h2>
- </div>
- <div class="col">
- </div>
- </div>
- <form class="mb-4" 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 col-form-label 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 col-form-label 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 col-form-label 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">
- <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($locations_missing_region) {
- ?>
- <div class="alert alert-warning">
- 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
- }
- ?>
- <?php
- if($locations_missing_area_manager) {
- ?>
- <div class="alert alert-warning">
- 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">
- <div class="card card-body mb-3">
- Pass/Fail Count
- <div class="stat">
- <?=$total_data->passCount?> /
- <?=$total_data->failCount?>
- </div>
- </div>
- </div>
- </div>
- <div class="row mb-4">
- <div class="col-md-4" 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
- if(PRODUCTION == false) {
- ?>
- <h2>Debug 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>Key</th>
- <th>Tests</th>
- <th>Passes</th>
- <th>Fails</th>
- <th>Rate</th>
- </tr>
- </thead>
- <tbody>
- <?php
- foreach($rows as $key => $data) {
- $rate = ($data->testCount == 0) ? "0.00" : number_format(($data->passCount * 100) / $data->testCount, 2);
- ?>
- <tr>
- <td><?=htmlspecialchars($key)?></td>
- <td><?=number_format($data->testCount)?></td>
- <td><?=number_format($data->passCount)?></td>
- <td><?=number_format($data->failCount)?></td>
- <td><?=$rate?>%</td>
- </tr>
- <?php
- }
- ?>
- </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>Key</th>
- <th>Tests</th>
- <th>Passes</th>
- <th>Fails</th>
- <th>Rate</th>
- </tr>
- </thead>
- <tbody>
- <?php
- foreach($rows as $key => $data) {
- $rate = ($data->testCount == 0) ? "0.00" : number_format(($data->passCount * 100) / $data->testCount, 2);
- ?>
- <tr>
- <td><?=htmlspecialchars($key)?></td>
- <td><?=number_format($data->testCount)?></td>
- <td><?=number_format($data->passCount)?></td>
- <td><?=number_format($data->failCount)?></td>
- <td><?=$rate?>%</td>
- </tr>
- <?php
- }
- ?>
- </tbody>
- </table>
- <?php
- }
- }
- }
- ?>
- </div>
|