|
|
@@ -15,8 +15,6 @@ Core::addBreadcrumb("/account/performance?customer_id=$customer->id", $page_titl
|
|
|
|
|
|
$date_range = http::value("date_range");
|
|
|
$date_resolution = http::value("date_resolution");
|
|
|
-$project_ids = http::value("project_ids", "int");
|
|
|
-if(!is_array($project_ids)) $project_ids = [];
|
|
|
|
|
|
$all_projects = Project::query([
|
|
|
"customer_id" => $customer->id
|
|
|
@@ -32,6 +30,28 @@ $locations_missing_area_manager = [];
|
|
|
|
|
|
$charts = [];
|
|
|
|
|
|
+$colours = [
|
|
|
+ "#f44336",
|
|
|
+ "#673ab7",
|
|
|
+ "#03a9f4",
|
|
|
+ "#4caf50",
|
|
|
+ "#ffeb3b",
|
|
|
+ "#ff5722",
|
|
|
+ "#607d8b",
|
|
|
+ "#e91e63",
|
|
|
+ "#3f51b5",
|
|
|
+ "#00bcd4",
|
|
|
+ "#8bc34a",
|
|
|
+ "#ffc107",
|
|
|
+ "#795548",
|
|
|
+ "#9c27b0",
|
|
|
+ "#2196f3",
|
|
|
+ "#009688",
|
|
|
+ "#cddc39",
|
|
|
+ "#ff9800",
|
|
|
+ "#9e9e9e",
|
|
|
+];
|
|
|
+
|
|
|
$submit = http::value("submit");
|
|
|
if($submit) {
|
|
|
try {
|
|
|
@@ -43,10 +63,11 @@ if($submit) {
|
|
|
|
|
|
// Get all tests
|
|
|
$projects = Project::query([
|
|
|
- "customer_id" => $customer->id,
|
|
|
- "id" => $project_ids,
|
|
|
+ "customer_id" => $customer->id
|
|
|
]);
|
|
|
|
|
|
+ $project_ids = array_column($projects, "id");
|
|
|
+
|
|
|
$tests = Test::query([
|
|
|
"project_id" => $project_ids,
|
|
|
"status" => Test::STATUS_COMPLETED
|
|
|
@@ -152,6 +173,9 @@ if($submit) {
|
|
|
$resolution_name = "";
|
|
|
|
|
|
// Initialise date-array based on date range and resolution
|
|
|
+ $keys = [];
|
|
|
+ $key_labels = [];
|
|
|
+
|
|
|
for($year = $min_year; $year <= $max_year; $year++) {
|
|
|
switch($date_resolution) {
|
|
|
case "monthly":
|
|
|
@@ -177,6 +201,8 @@ if($submit) {
|
|
|
$a[$key]->label = $label;
|
|
|
}
|
|
|
|
|
|
+ $keys[] = $key;
|
|
|
+ $key_labels[] = $label;
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
@@ -203,11 +229,13 @@ if($submit) {
|
|
|
$a[$key] = clone $empty_data;
|
|
|
$a[$key]->label = $label;
|
|
|
}
|
|
|
+
|
|
|
+ $keys[] = $key;
|
|
|
+ $key_labels[] = $label;
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
$max_unix = 0;
|
|
|
@@ -244,6 +272,8 @@ if($submit) {
|
|
|
}
|
|
|
|
|
|
$data[$key]->testCount++;
|
|
|
+ if($region) $region_data[$region][$key]->testCount++;
|
|
|
+ if($area_manager) $area_manager_data[$area_manager][$key]->testCount++;
|
|
|
|
|
|
$stage_key = "stage" . $test->challenge_stage . "Count";
|
|
|
$data[$key]->$stage_key++;
|
|
|
@@ -446,10 +476,95 @@ if($submit) {
|
|
|
]);
|
|
|
$charts[] = $chart;
|
|
|
|
|
|
+ $pass_counts = array_column($data, "passCount");
|
|
|
+ $fail_counts = array_column($data, "failCount");
|
|
|
+
|
|
|
+
|
|
|
if($has_regions) {
|
|
|
+
|
|
|
+ $x_data_labels = array_map(function($key) {
|
|
|
+ return "Region $key";
|
|
|
+ }, $regions);
|
|
|
+
|
|
|
+ // Region Performance (Selected Date Range)
|
|
|
+ $data_values = [];
|
|
|
+ foreach($region_data as $region => $r_data) {
|
|
|
+ $total_region_test_count = array_sum(array_column($r_data, "testCount"));
|
|
|
+ $total_region_pass_count = array_sum(array_column($r_data, "passCount"));
|
|
|
+
|
|
|
+ $data_values[] = ($total_region_test_count == 0) ? 0 : round(($total_region_pass_count * 100) / $total_region_test_count);
|
|
|
+ }
|
|
|
+
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->setType("bar");
|
|
|
+ $chart->setTitle("Region Performance");
|
|
|
+ $chart->setLabels($x_data_labels);
|
|
|
+ $chart->addDataset("Performance", $data_values , [
|
|
|
+ "background_colours" => "#2196F3"
|
|
|
+ ]);
|
|
|
+ $charts[] = $chart;
|
|
|
+
|
|
|
+ // Region Performance by Period
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->setType("bar");
|
|
|
+ $chart->setTitle("Region Performance by $resolution_name");
|
|
|
+ $chart->setLabels($x_data_labels);
|
|
|
+
|
|
|
+ foreach($keys as $index => $key) {
|
|
|
+ $data_values = [];
|
|
|
+ foreach($regions as $region) {
|
|
|
+ $r_data = $region_data[$region][$key];
|
|
|
+ $data_values[] = ($r_data->testCount == 0) ? 0 : round(($r_data->passCount * 100) / $r_data->testCount);
|
|
|
+ }
|
|
|
+ $chart->addDataset($key_labels[$index], $data_values, ["background_colours" => $colours[$index]]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $charts[] = $chart;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if($has_area_managers) {
|
|
|
+
|
|
|
+ $x_data_labels = array_map(function($key) {
|
|
|
+ return "$key";
|
|
|
+ }, $area_managers);
|
|
|
+
|
|
|
+ // Area Performance (Selected Date Range)
|
|
|
+ $data_values = [];
|
|
|
+ foreach($area_manager_data as $area_manager => $a_data) {
|
|
|
+ $total_area_manager_test_count = array_sum(array_column($a_data, "testCount"));
|
|
|
+ $total_area_manager_pass_count = array_sum(array_column($a_data, "passCount"));
|
|
|
+ $total_area_manager_fail_count = array_sum(array_column($a_data, "failCount"));
|
|
|
+
|
|
|
+ $data_values[] = ($total_region_test_count == 0) ? 0 : round(($total_area_manager_pass_count * 100) / $total_area_manager_test_count);
|
|
|
+ }
|
|
|
+
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->setType("bar");
|
|
|
+ $chart->setTitle("Area Manager Performance");
|
|
|
+ $chart->setLabels($x_data_labels);
|
|
|
+ $chart->addDataset("Performance", $data_values , [
|
|
|
+ "background_colours" => "#2196F3"
|
|
|
+ ]);
|
|
|
+ $charts[] = $chart;
|
|
|
+
|
|
|
+ // Area Performance by Period
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->setType("bar");
|
|
|
+ $chart->setTitle("Area Manager Performance by $resolution_name");
|
|
|
+ $chart->setLabels($x_data_labels);
|
|
|
+
|
|
|
+ foreach($keys as $index => $key) {
|
|
|
+ $data_values = [];
|
|
|
+ foreach($area_managers as $area_manager) {
|
|
|
+ $a_data = $area_manager_data[$area_manager][$key];
|
|
|
+ $data_values[] = ($a_data->testCount == 0) ? 0 : round(($a_data->passCount * 100) / $a_data->testCount);
|
|
|
+ }
|
|
|
+ $chart->addDataset($key_labels[$index], $data_values, ["background_colours" => $colours[$index]]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $charts[] = $chart;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -466,7 +581,7 @@ if($submit) {
|
|
|
|
|
|
|
|
|
View::includeOnce("header", compact("page_title"));
|
|
|
-View::include("performance", compact("customer", "date_range", "date_resolution", "all_projects", "project_ids", "charts", "data", "total_data", "locations_missing_region", "locations_missing_area_manager"));
|
|
|
+View::include("performance", compact("customer", "date_range", "date_resolution", "all_projects", "project_ids", "charts", "data", "total_data", "locations_missing_region", "locations_missing_area_manager", "region_data"));
|
|
|
View::includeOnce("footer");
|
|
|
|
|
|
?>
|