|
|
@@ -1,5 +1,4 @@
|
|
|
-<?php /** @noinspection PhpIncludeInspection */
|
|
|
-/** @noinspection PhpUnhandledExceptionInspection */
|
|
|
+<?php /** @noinspection PhpUnhandledExceptionInspection */
|
|
|
|
|
|
Core::addScript("public/js/app-reports.js");
|
|
|
|
|
|
@@ -7,7 +6,9 @@ Core::addBreadcrumb("/account", "Account");
|
|
|
Core::addBreadcrumb("/account/reports", "Reports");
|
|
|
|
|
|
$customer = Customer::getForAdmin();
|
|
|
-if(!$customer) throw new Exception("You do not have permission to access this page.");
|
|
|
+if(!$customer) {
|
|
|
+ throw new RuntimeException("You do not have permission to access this page.");
|
|
|
+}
|
|
|
|
|
|
$customer_slug = Util::slug($customer->name);
|
|
|
$customer_slug = str_replace("-", "_", $customer_slug);
|
|
|
@@ -42,6 +43,8 @@ if(!empty($location_ids)) {
|
|
|
|
|
|
$exclude_categories = http::value("exclude_categories");
|
|
|
|
|
|
+$project_id = http::value("project_id", "int");
|
|
|
+
|
|
|
$retests = http::value("retests", "int");
|
|
|
|
|
|
$location_filters = [
|
|
|
@@ -101,13 +104,24 @@ if($submit) {
|
|
|
try {
|
|
|
Core::validateCSRFToken($submit);
|
|
|
|
|
|
- $form_exception = new FormException;
|
|
|
+ $form_exception = new FormException();
|
|
|
|
|
|
- // Get all projects
|
|
|
- $projects = Project::query([
|
|
|
- "customer_id" => $customer->id,
|
|
|
- "id" => Constraint::notIn($exclude_project_ids)
|
|
|
- ]);
|
|
|
+ // Specific project
|
|
|
+ if($project_id) {
|
|
|
+ $projects = Project::query([
|
|
|
+ "customer_id" => $customer->id,
|
|
|
+ "id" => $project_id
|
|
|
+ ]);
|
|
|
+ if(!$projects) {
|
|
|
+ $form_exception->addError("Project not found.");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $projects = Project::query([
|
|
|
+ "customer_id" => $customer->id,
|
|
|
+ "id" => Constraint::notIn($exclude_project_ids)
|
|
|
+ ]);
|
|
|
+ }
|
|
|
|
|
|
$project_ids = array_intersect($all_project_ids, array_column($projects, "id"));
|
|
|
|
|
|
@@ -212,7 +226,14 @@ if($submit) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- $tests = $test_result_set->filterByDateRange($min_dts, $max_dts);
|
|
|
+ if($project_id) {
|
|
|
+ $tests = $test_result_set->getTests();
|
|
|
+ $project = $projects[0];
|
|
|
+ $date_range_label = $project->getDisplayReportMonth();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $tests = $test_result_set->filterByDateRange($min_dts, $max_dts);
|
|
|
+ }
|
|
|
|
|
|
// Load locations
|
|
|
$locations = Location::load(array_column($tests, "location_id"));
|
|
|
@@ -342,10 +363,13 @@ if($submit) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @var object $empty_data
|
|
|
+ */
|
|
|
+
|
|
|
foreach($keys as $index => $key) {
|
|
|
$label = $key_labels[$index];
|
|
|
|
|
|
- /** @var object $empty_data */
|
|
|
$data[$key] = clone $empty_data;
|
|
|
$data[$key]->label = $label;
|
|
|
|
|
|
@@ -518,7 +542,7 @@ if($submit) {
|
|
|
}
|
|
|
|
|
|
View::includeOnce("header", compact("page_title"));
|
|
|
-View::include("reports", compact("customer", "date_range", "date_start", "date_end", "date_resolution", "all_projects", "project_table_data", "exclude_project_ids", "location_ids", "retests", "charts", "data", "total_data", "locations_missing_region", "locations_missing_area_manager", "locations_missing_operations_manager", "locations_missing_brand", "region_data", "area_manager_data", "brand_data", "operations_manager_data", "key_labels", "has_pass_fail", "template_config", "exclude_categories"));
|
|
|
+View::include("reports", compact("customer", "project_id", "date_range", "date_start", "date_end", "date_resolution", "all_projects", "project_table_data", "exclude_project_ids", "location_ids", "retests", "charts", "data", "total_data", "locations_missing_region", "locations_missing_area_manager", "locations_missing_operations_manager", "locations_missing_brand", "region_data", "area_manager_data", "brand_data", "operations_manager_data", "key_labels", "has_pass_fail", "template_config", "exclude_categories"));
|
|
|
View::includeOnce("footer");
|
|
|
|
|
|
file_put_contents("periodic_data.bin", serialize($data));
|