|
|
@@ -74,23 +74,56 @@ if($submit) {
|
|
|
Core::validateCSRFToken($submit);
|
|
|
|
|
|
$form_exception = new FormException;
|
|
|
- if($form_exception->hasErrors()) throw $form_exception;
|
|
|
|
|
|
- // Get all tests
|
|
|
+ // Get all projects
|
|
|
$projects = Project::query([
|
|
|
"customer_id" => $customer->id,
|
|
|
"id" => $project_ids
|
|
|
]);
|
|
|
|
|
|
+ // Enforce unique template ID in selection
|
|
|
+ $template_ids = array_unique(array_column($projects, "template_id"));
|
|
|
+ if(count($template_ids) > 1) $form_exception->addError("Projects with different templates have been selected.");
|
|
|
+
|
|
|
+ // Check template exists
|
|
|
+ $template_id = array_shift($template_ids);
|
|
|
+ $template = Template::get($template_id);
|
|
|
+ if(!$template) $form_exception->addError("Template cannot be found.");
|
|
|
+
|
|
|
+ if($form_exception->hasErrors()) throw $form_exception;
|
|
|
+
|
|
|
+ // Get all completed tests
|
|
|
$tests = Test::query([
|
|
|
"project_id" => $project_ids,
|
|
|
"status" => Test::STATUS_COMPLETED
|
|
|
]);
|
|
|
$test_count = count($tests);
|
|
|
|
|
|
+ // Get test values
|
|
|
+ $test_ids = array_column($tests, "id");
|
|
|
+ $test_values = TestValue::query([
|
|
|
+ "test_id" => $test_ids,
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $test_values_map = [];
|
|
|
+ foreach($test_values as $test_value) {
|
|
|
+ $test_id = $test_value->test_id;
|
|
|
+ $name = $test_value->name;
|
|
|
+
|
|
|
+ if(!isset($test_values_map[$test_id])) {
|
|
|
+ $test_values_map[$test_id] = new stdClass;
|
|
|
+ }
|
|
|
+
|
|
|
+ $test_values_map[$test_id]->{$name} = $test_value->value;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Load users
|
|
|
User::load(array_column($tests, "tester_id"));
|
|
|
+
|
|
|
+ // Load locations
|
|
|
$locations = Location::load(array_column($tests, "location_id"));
|
|
|
|
|
|
+ // Get region and area manager IDs
|
|
|
$regions = array_filter(array_column($locations, "region"));
|
|
|
$area_managers = array_filter(array_column($locations, "area_manager"));
|
|
|
|
|
|
@@ -113,6 +146,7 @@ if($submit) {
|
|
|
if($has_area_managers && !$location->area_manager) $locations_missing_area_manager[] = $location;
|
|
|
}
|
|
|
|
|
|
+ // Calculate date ranges
|
|
|
$min_year = date("Y");
|
|
|
$max_year = date("Y");
|
|
|
|
|
|
@@ -173,6 +207,7 @@ if($submit) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
+ // Check if date range is same year
|
|
|
$same_year = ($min_year == $max_year);
|
|
|
|
|
|
// Filter tests based on date range
|
|
|
@@ -195,67 +230,10 @@ if($submit) {
|
|
|
return true;
|
|
|
});
|
|
|
|
|
|
+ // Empty data objects hook
|
|
|
+ require $template->getProcessingFilePath("reports_create_empty_objects.php");
|
|
|
|
|
|
- $empty_data = (object) [
|
|
|
- "label" => "",
|
|
|
- "testCount" => 0,
|
|
|
- "passCount" => 0,
|
|
|
- "failCount" => 0,
|
|
|
-
|
|
|
- "maleTesterCount" => 0,
|
|
|
- "femaleTesterCount" => 0,
|
|
|
-
|
|
|
- "maleChallengerCount" => 0,
|
|
|
- "femaleChallengerCount" => 0,
|
|
|
- "unspecifiedChallengerCount" => 0,
|
|
|
-
|
|
|
- "maleChallengeMaleCount" => 0,
|
|
|
- "maleChallengeMalePassCount" => 0,
|
|
|
- "maleChallengeMaleStages" => [0, 0, 0, 0, 0],
|
|
|
-
|
|
|
- "maleChallengeFemaleCount" => 0,
|
|
|
- "maleChallengeFemalePassCount" => 0,
|
|
|
- "maleChallengeFemaleStages" => [0, 0, 0, 0, 0],
|
|
|
-
|
|
|
- "femaleChallengeMaleCount" => 0,
|
|
|
- "femaleChallengeMalePassCount" => 0,
|
|
|
- "femaleChallengeMaleStages" => [0, 0, 0, 0, 0],
|
|
|
-
|
|
|
- "femaleChallengeFemaleCount" => 0,
|
|
|
- "femaleChallengeFemalePassCount" => 0,
|
|
|
- "femaleChallengeFemaleStages" => [0, 0, 0, 0, 0],
|
|
|
-
|
|
|
- "unknownChallengeCount" => 0,
|
|
|
- "unknownChallengePassCount" => 0,
|
|
|
- "unknownChallengeStages" => [0, 0, 0, 0, 0],
|
|
|
-
|
|
|
- "stage1Count" => 0,
|
|
|
- "stage2Count" => 0,
|
|
|
- "stage3Count" => 0,
|
|
|
- "stage4Count" => 0,
|
|
|
- "stage5Count" => 0,
|
|
|
- ];
|
|
|
-
|
|
|
- $total_data = (object) [
|
|
|
- "maleTesterCount" => 0,
|
|
|
- "femaleTesterCount" => 0,
|
|
|
-
|
|
|
- "maleChallengerCount" => 0,
|
|
|
- "femaleChallengerCount" => 0,
|
|
|
- "unspecifiedChallengerCount" => 0,
|
|
|
-
|
|
|
- "testCount" => 0,
|
|
|
- "passCount" => 0,
|
|
|
- "failCount" => 0,
|
|
|
-
|
|
|
- "stage1Count" => 0,
|
|
|
- "stage2Count" => 0,
|
|
|
- "stage3Count" => 0,
|
|
|
- "stage4Count" => 0,
|
|
|
- "stage5Count" => 0,
|
|
|
- ];
|
|
|
-
|
|
|
- $resolution_name = "";
|
|
|
+ $has_pass_fail = isset($empty_data->passCount);
|
|
|
|
|
|
// Initialise date-array based on date range and resolution
|
|
|
$keys = [];
|
|
|
@@ -327,13 +305,13 @@ if($submit) {
|
|
|
|
|
|
$max_unix = 0;
|
|
|
|
|
|
- // Increment counts based on test results
|
|
|
+ // Process test results
|
|
|
foreach($tests as $test) {
|
|
|
|
|
|
$tester = $test->getTester();
|
|
|
$location = $test->getLocation();
|
|
|
-
|
|
|
$project = $test->getProject();
|
|
|
+ $test_values = $test_values_map[$test->id] ?? new stdClass;
|
|
|
|
|
|
$region = $location->region;
|
|
|
$area_manager = $location->area_manager;
|
|
|
@@ -367,23 +345,6 @@ if($submit) {
|
|
|
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++;
|
|
|
- $total_data->{$stage_key}++;
|
|
|
-
|
|
|
- if($test->pass) {
|
|
|
- $data[$key]->passCount++;
|
|
|
- $total_data->passCount++;
|
|
|
- if($region) $region_data[$region][$key]->passCount++;
|
|
|
- if($area_manager) $area_manager_data[$area_manager][$key]->passCount++;
|
|
|
- }
|
|
|
- else {
|
|
|
- $data[$key]->failCount++;
|
|
|
- $total_data->failCount++;
|
|
|
- if($region) $region_data[$region][$key]->failCount++;
|
|
|
- if($area_manager) $area_manager_data[$area_manager][$key]->failCount++;
|
|
|
- }
|
|
|
-
|
|
|
if($tester->gender == "M") {
|
|
|
$data[$key]->maleTesterCount++;
|
|
|
$total_data->maleTesterCount++;
|
|
|
@@ -393,55 +354,8 @@ if($submit) {
|
|
|
$total_data->femaleTesterCount++;
|
|
|
}
|
|
|
|
|
|
- if($test->challenger_gender == "M") {
|
|
|
- $data[$key]->maleChallengerCount++;
|
|
|
- $total_data->maleChallengerCount++;
|
|
|
- }
|
|
|
- else if($test->challenger_gender == "F") {
|
|
|
- $data[$key]->femaleChallengerCount++;
|
|
|
- $total_data->femaleChallengerCount++;
|
|
|
- }
|
|
|
- else {
|
|
|
- $data[$key]->unspecifiedChallengerCount++;
|
|
|
- $total_data->unspecifiedChallengerCount++;
|
|
|
- }
|
|
|
-
|
|
|
- // Genders Comparison
|
|
|
- if($tester->gender == "M") {
|
|
|
- if($test->challenger_gender == "M") {
|
|
|
- $data[$key]->maleChallengeMaleCount++;
|
|
|
- $data[$key]->maleChallengeMaleStages[$test->challenge_stage - 1]++;
|
|
|
- if($test->pass) $data[$key]->maleChallengeMalePassCount++;
|
|
|
- }
|
|
|
- else if($test->challenger_gender == "F") {
|
|
|
- $data[$key]->femaleChallengeMaleCount++;
|
|
|
- $data[$key]->femaleChallengeMaleStages[$test->challenge_stage - 1]++;
|
|
|
- if($test->pass) $data[$key]->femaleChallengeMalePassCount++;
|
|
|
- }
|
|
|
- else {
|
|
|
- $data[$key]->unknownChallengeCount++;
|
|
|
- $data[$key]->unknownChallengeStages[$test->challenge_stage - 1]++;
|
|
|
- if($test->pass) $data[$key]->unknownChallengePassCount++;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if($tester->gender == "F") {
|
|
|
- if($test->challenger_gender == "M") {
|
|
|
- $data[$key]->maleChallengeFemaleCount++;
|
|
|
- $data[$key]->maleChallengeFemaleStages[$test->challenge_stage - 1]++;
|
|
|
- if($test->pass) $data[$key]->maleChallengeFemalePassCount++;
|
|
|
- }
|
|
|
- else if($test->challenger_gender == "F") {
|
|
|
- $data[$key]->femaleChallengeFemaleCount++;
|
|
|
- $data[$key]->femaleChallengeFemaleStages[$test->challenge_stage - 1]++;
|
|
|
- if($test->pass) $data[$key]->femaleChallengeFemalePassCount++;
|
|
|
- }
|
|
|
- else {
|
|
|
- $data[$key]->unknownChallengeCount++;
|
|
|
- $data[$key]->unknownChallengeStages[$test->challenge_stage - 1]++;
|
|
|
- if($test->pass) $data[$key]->unknownChallengePassCount++;
|
|
|
- }
|
|
|
- }
|
|
|
+ // Process test hook
|
|
|
+ require $template->getProcessingFilePath("reports_process_test.php");
|
|
|
}
|
|
|
|
|
|
$current_month = date("m", $max_unix);
|
|
|
@@ -451,582 +365,8 @@ if($submit) {
|
|
|
return $d->label;
|
|
|
}, $data));
|
|
|
|
|
|
- // Current Period
|
|
|
- if($date_resolution == "monthly") {
|
|
|
- $key = date("Y") . "-" . $current_month;
|
|
|
- $current_period_name = date("M Y", $max_unix);
|
|
|
- }
|
|
|
- if($date_resolution == "quarterly") {
|
|
|
- $key = date("Y") . "-" . $current_quarter;
|
|
|
- $current_period_name = "Q" . $current_quarter . " " . date("Y", $max_unix);
|
|
|
- }
|
|
|
-
|
|
|
- // Tests by Stage
|
|
|
-
|
|
|
- $chart = new Chart;
|
|
|
- $chart->setType("doughnut");
|
|
|
- $chart->setTitle("Tests by Stage $date_range_label");
|
|
|
- $chart->setLabels(["1 - On Entry", "2 - While Browsing", "3 - During Play", "4 - On Exit", "5 - No Challenge"]);
|
|
|
- $chart->addDataset("Tests", [
|
|
|
- $total_data->stage1Count,
|
|
|
- $total_data->stage2Count,
|
|
|
- $total_data->stage3Count,
|
|
|
- $total_data->stage4Count,
|
|
|
- $total_data->stage5Count,
|
|
|
- ], [
|
|
|
- "background_colours" => [
|
|
|
- "#4CAF50",
|
|
|
- "#FFEB3B",
|
|
|
- "#FBC02D",
|
|
|
- "#FFAB91",
|
|
|
- "#F44336",
|
|
|
- ],
|
|
|
- "datalabels" => Chart::DATALABELS_BOX,
|
|
|
- ]);
|
|
|
- $chart->setPrintSuffixes("");
|
|
|
- $chart->print = true;
|
|
|
- $chart->printPercentages = true;
|
|
|
- $chart->setPrintLabels(["Stage 1", "Stage 2", "Stage 3", "Stage 4", "Stage 5"]);
|
|
|
-
|
|
|
- $charts[] = $chart;
|
|
|
-
|
|
|
-
|
|
|
- // Challenger Gender
|
|
|
- $chart = new Chart;
|
|
|
- $chart->setType("pie");
|
|
|
- $chart->setTitle("Staff Gender $date_range_label");
|
|
|
- $chart->setLabels(["Male", "Female", "Unspecified"]);
|
|
|
- $chart->addDataset("Counts", [
|
|
|
- $total_data->maleChallengerCount,
|
|
|
- $total_data->femaleChallengerCount,
|
|
|
- $total_data->unspecifiedChallengerCount,
|
|
|
- ], [
|
|
|
- "background_colours" => [
|
|
|
- "#2196F3",
|
|
|
- "#E91E63",
|
|
|
- "#9E9E9E",
|
|
|
- ],
|
|
|
- "datalabels" => Chart::DATALABELS_BOX,
|
|
|
- ]);
|
|
|
- $charts[] = $chart;
|
|
|
-
|
|
|
- // Tester Gender
|
|
|
- $chart = new Chart;
|
|
|
- $chart->setType("pie");
|
|
|
- $chart->setTitle("Tester Gender $date_range_label");
|
|
|
- $chart->setLabels(["Male", "Female"]);
|
|
|
- $chart->addDataset("Counts", [
|
|
|
- $total_data->maleTesterCount,
|
|
|
- $total_data->femaleTesterCount,
|
|
|
- ], [
|
|
|
- "background_colours" => [
|
|
|
- "#2196F3",
|
|
|
- "#E91E63",
|
|
|
- ],
|
|
|
- "datalabels" => Chart::DATALABELS_BOX,
|
|
|
- ]);
|
|
|
- $charts[] = $chart;
|
|
|
-
|
|
|
- // Pass / Fail
|
|
|
- $chart = new Chart;
|
|
|
- $chart->setType("pie");
|
|
|
- $chart->setTitle("Pass / Fail $date_range_label");
|
|
|
- $chart->setLabels(["Pass", "Fail"]);
|
|
|
- $chart->addDataset("Counts", [
|
|
|
- $total_data->passCount,
|
|
|
- $total_data->failCount,
|
|
|
- ], [
|
|
|
- "background_colours" => [
|
|
|
- "#4CAF50",
|
|
|
- "#F44336",
|
|
|
- ],
|
|
|
- "datalabels" => Chart::DATALABELS_BOX,
|
|
|
- ]);
|
|
|
- $charts[] = $chart;
|
|
|
-
|
|
|
- // Pass Rate Period
|
|
|
- $pass_rates = array_values(array_map(function($d) {
|
|
|
- if($d->testCount == 0) return 0;
|
|
|
- return round(($d->passCount / $d->testCount) * 100);
|
|
|
- }, $data));
|
|
|
-
|
|
|
- $fail_rates = array_values(array_map(function($d) {
|
|
|
- if($d->testCount == 0) return 0;
|
|
|
- $pass_rate = round(($d->passCount / $d->testCount) * 100);
|
|
|
- return 100 - $pass_rate;
|
|
|
- }, $data));
|
|
|
-
|
|
|
- $chart = new Chart;
|
|
|
- $chart->addXAxis([
|
|
|
- "type" => "category",
|
|
|
- "stacked" => true,
|
|
|
- ]);
|
|
|
- $chart->addYAxis([
|
|
|
- "id" => "y-axis-1",
|
|
|
- "tick_config" => ["min" => 0, "max" => 100],
|
|
|
- "stacked" => true,
|
|
|
- ]);
|
|
|
-
|
|
|
- $chart->setType("bar");
|
|
|
- $chart->setTitle("Pass / Fail by $resolution_name");
|
|
|
- $chart->setLabels($x_data_labels);
|
|
|
- $chart->addDataset("Pass Rate (%)", $pass_rates, [
|
|
|
- "background_colours" => "#4CAF50"
|
|
|
- ]);
|
|
|
- $chart->addDataset("Fail Rate (%)", $fail_rates, [
|
|
|
- "background_colours" => "#F44336"
|
|
|
- ]);
|
|
|
- $chart->setDatalabelSuffixes("%", "%");
|
|
|
- $charts[] = $chart;
|
|
|
-
|
|
|
- // Totals by Period
|
|
|
-
|
|
|
- $test_counts = array_column($data, "testCount");
|
|
|
- $pass_counts = array_column($data, "passCount");
|
|
|
- $fail_counts = array_column($data, "failCount");
|
|
|
-
|
|
|
- $chart = new Chart;
|
|
|
- $chart->setType("bar");
|
|
|
- $chart->setTitle("Totals by $resolution_name");
|
|
|
- $chart->setLabels($x_data_labels);
|
|
|
- $chart->addYAxis([
|
|
|
- "id" => "y-axis-1",
|
|
|
- "tick_config" => ["min" => 0, "max" => ceil(max($test_counts) / 10) * 10]
|
|
|
- ]);
|
|
|
- $chart->addYAxis([
|
|
|
- "position" => "right",
|
|
|
- "id" => "y-axis-2",
|
|
|
- "grid_lines" => false,
|
|
|
- "tick_config" => ["min" => 0, "max" => 100]
|
|
|
- ]);
|
|
|
-
|
|
|
- $chart->addDataset("Pass Rate (%)", $pass_rates, [
|
|
|
- "border_colours" => "#FFEB3B",
|
|
|
- "background_colours" => "transparent",
|
|
|
- "type" => "line",
|
|
|
- "y_axis_id" => "y-axis-2",
|
|
|
- "datalabels" => [
|
|
|
- "display" => false
|
|
|
- ],
|
|
|
- "line_tension" => 0,
|
|
|
- ]);
|
|
|
- $chart->addDataset("Test Count", $test_counts, [
|
|
|
- "background_colours" => "#2196F3",
|
|
|
- "type" => "bar",
|
|
|
- "y_axis_id" => "y-axis-1",
|
|
|
- "datalabels" => [
|
|
|
- "display" => false
|
|
|
- ],
|
|
|
- ]);
|
|
|
- $chart->addDataset("Pass", $pass_counts, [
|
|
|
- "background_colours" => "#4CAF50",
|
|
|
- "type" => "bar",
|
|
|
- "y_axis_id" => "y-axis-1",
|
|
|
- "datalabels" => [
|
|
|
- "display" => false
|
|
|
- ],
|
|
|
- ]);
|
|
|
- $chart->addDataset("Fail", $fail_counts, [
|
|
|
- "background_colours" => "#F44336",
|
|
|
- "type" => "bar",
|
|
|
- "y_axis_id" => "y-axis-1",
|
|
|
- "datalabels" => [
|
|
|
- "display" => false
|
|
|
- ],
|
|
|
- ]);
|
|
|
- $chart->setDatalabelSuffixes("%", "", "", "");
|
|
|
- $chart->print = true;
|
|
|
- $charts[] = $chart;
|
|
|
-
|
|
|
- // Point of Challenge (Each Period)
|
|
|
-
|
|
|
- foreach($keys as $index => $key) {
|
|
|
- $key_label = $key_labels[$index];
|
|
|
-
|
|
|
- $period_data = $data[$key];
|
|
|
-
|
|
|
- if($period_data->testCount == 0) continue;
|
|
|
-
|
|
|
- $chart = new Chart;
|
|
|
- $chart->setType("pie");
|
|
|
- $chart->setTitle("$key_label Point of Challenge");
|
|
|
- $chart->setLabels(["On Entry", "While Browsing", "During Play", "On Exit", "No Challenge"]);
|
|
|
- $chart->addDataset("Counts", [
|
|
|
- $period_data->stage1Count,
|
|
|
- $period_data->stage2Count,
|
|
|
- $period_data->stage3Count,
|
|
|
- $period_data->stage4Count,
|
|
|
- $period_data->stage5Count,
|
|
|
- ], [
|
|
|
- "background_colours" => [
|
|
|
- "#4CAF50",
|
|
|
- "#FFEB3B",
|
|
|
- "#FBC02D",
|
|
|
- "#FFAB91",
|
|
|
- "#F44336",
|
|
|
- ],
|
|
|
- "datalabels" => Chart::DATALABELS_BOX,
|
|
|
- ]);
|
|
|
- $charts[] = $chart;
|
|
|
- }
|
|
|
-
|
|
|
- // Tester Genders by Period
|
|
|
- $male_counts = array_values(array_map(function($d) {
|
|
|
- return $d->maleTesterCount;
|
|
|
- }, $data));
|
|
|
-
|
|
|
- $female_counts = array_values(array_map(function($d) {
|
|
|
- return $d->femaleTesterCount;
|
|
|
- }, $data));
|
|
|
-
|
|
|
- $chart = new Chart;
|
|
|
- $chart->addYAxis([
|
|
|
- "id" => "y-axis-1",
|
|
|
- "tick_config" => ["min" => 0, "max" => ceil(max(max($male_counts), max($female_counts)) / 10) * 10]
|
|
|
- ]);
|
|
|
-
|
|
|
- $chart->setType("bar");
|
|
|
- $chart->setTitle("Tester Gender by $resolution_name");
|
|
|
- $chart->setLabels($x_data_labels);
|
|
|
- $chart->addDataset("Male", $male_counts, [
|
|
|
- "background_colours" => "#2196F3"
|
|
|
- ]);
|
|
|
- $chart->addDataset("Female", $female_counts, [
|
|
|
- "background_colours" => "#E91E63"
|
|
|
- ]);
|
|
|
- $charts[] = $chart;
|
|
|
-
|
|
|
- // Test Count by Period
|
|
|
- $test_counts = array_values(array_map(function($d) {
|
|
|
- return $d->testCount;
|
|
|
- }, $data));
|
|
|
-
|
|
|
- $chart = new Chart;
|
|
|
- $chart->addYAxis([
|
|
|
- "id" => "y-axis-1",
|
|
|
- "tick_config" => ["min" => 0, "max" => ceil(max($test_counts) / 10) * 10]
|
|
|
- ]);
|
|
|
- $chart->setType("bar");
|
|
|
- $chart->setTitle("Tests by $resolution_name");
|
|
|
- $chart->setLabels($x_data_labels);
|
|
|
- $chart->addDataset("Tests", $test_counts, [
|
|
|
- "background_colours" => "#2196F3"
|
|
|
- ]);
|
|
|
- $charts[] = $chart;
|
|
|
-
|
|
|
- // Gender Graphs
|
|
|
- $gender_keys = [
|
|
|
- "maleChallengeMale" => [
|
|
|
- "title" => "Male Challenge Male",
|
|
|
- "label" => "M Cha. M",
|
|
|
- ],
|
|
|
- "maleChallengeFemale" => [
|
|
|
- "title" => "Male Challenge Female",
|
|
|
- "label" => "M Cha. F",
|
|
|
- ],
|
|
|
- "femaleChallengeMale" => [
|
|
|
- "title" => "Female Challenge Male",
|
|
|
- "label" => "F Cha. M",
|
|
|
- ],
|
|
|
- "femaleChallengeFemale" => [
|
|
|
- "title" => "Female Challenge Female",
|
|
|
- "label" => "F Cha. F",
|
|
|
- ],
|
|
|
- "unknownChallenge" => [
|
|
|
- "title" => "Gender Not Specified",
|
|
|
- "label" => "Gender Not Specified",
|
|
|
- ],
|
|
|
- ];
|
|
|
-
|
|
|
- $gender_test_counts = [];
|
|
|
- foreach($gender_keys as $gk => $gv) {
|
|
|
- $gender_test_counts[] = array_sum(array_column($data, "{$gk}Count"));
|
|
|
- }
|
|
|
-
|
|
|
- // Gender Comparison by Date Range
|
|
|
- $chart = new Chart;
|
|
|
- $chart->addYAxis([
|
|
|
- "id" => "y-axis-1",
|
|
|
- "tick_config" => ["min" => 0, "max" => ceil(max($gender_test_counts) / 10) * 10]
|
|
|
- ]);
|
|
|
- $chart->setType("bar");
|
|
|
- $chart->setTitle("Gender Comparison $date_range_label");
|
|
|
- $chart->setLabels(array_column($gender_keys, "label"));
|
|
|
- $chart->addDataset("Tests", $gender_test_counts, [
|
|
|
- "background_colours" => "#2196F3"
|
|
|
- ]);
|
|
|
- $charts[] = $chart;
|
|
|
-
|
|
|
- // Gender Comparison by Resolution
|
|
|
- $mcm_counts = array_column($data, "maleChallengeMaleCount");
|
|
|
- $mcf_counts = array_column($data, "maleChallengeFemaleCount");
|
|
|
- $fcm_counts = array_column($data, "femaleChallengeMaleCount");
|
|
|
- $fcf_counts = array_column($data, "femaleChallengeFemaleCount");
|
|
|
- $ns_counts = array_column($data, "unknownChallengeCount");
|
|
|
-
|
|
|
- $chart = new Chart;
|
|
|
- $chart->addYAxis([
|
|
|
- "id" => "y-axis-1",
|
|
|
- "tick_config" => ["min" => 0, "max" => ceil(max(max($mcm_counts), max($mcf_counts), max($fcm_counts), max($fcf_counts)) / 10) * 10]
|
|
|
- ]);
|
|
|
- $chart->setType("bar");
|
|
|
- $chart->setTitle("Gender Comparison by $resolution_name");
|
|
|
- $chart->setLabels($x_data_labels);
|
|
|
- $chart->addDataset("M Cha. M", $mcm_counts, ["background_colours" => "#2196F3"]);
|
|
|
- $chart->addDataset("M Cha. F", $mcf_counts, ["background_colours" => "#3F51B5"]);
|
|
|
- $chart->addDataset("F Cha. M", $fcm_counts, ["background_colours" => "#9C27B0"]);
|
|
|
- $chart->addDataset("F Cha. F", $fcf_counts, ["background_colours" => "#E91E63"]);
|
|
|
- $chart->addDataset("Not Specified", $ns_counts, ["background_colours" => "#9E9E9E"]);
|
|
|
- $chart->print = true;
|
|
|
- $charts[] = $chart;
|
|
|
-
|
|
|
- // Gender Comparison Pass Rate by Resolution
|
|
|
- $mcm_pass_counts = array_column($data, "maleChallengeMalePassCount");
|
|
|
- $mcf_pass_counts = array_column($data, "maleChallengeFemalePassCount");
|
|
|
- $fcm_pass_counts = array_column($data, "femaleChallengeMalePassCount");
|
|
|
- $fcf_pass_counts = array_column($data, "femaleChallengeFemalePassCount");
|
|
|
- $ns_pass_counts = array_column($data, "unknownChallengePassCount");
|
|
|
-
|
|
|
- /*
|
|
|
- header("Content-Type: text/plain");
|
|
|
- print_r($fcf_counts);
|
|
|
- print_r($fcf_pass_counts);
|
|
|
-
|
|
|
- die();
|
|
|
- */
|
|
|
-
|
|
|
- foreach(["mcm", "mcf", "fcm", "fcf", "ns"] as $prefix) {
|
|
|
- $pass_rates = [];
|
|
|
- $pass_counts = ${$prefix . "_pass_counts"};
|
|
|
- $test_counts = ${$prefix . "_counts"};
|
|
|
-
|
|
|
- foreach($test_counts as $index => $test_count) {
|
|
|
- if($test_count == 0) {
|
|
|
- $pass_rates[] = 0;
|
|
|
- continue;
|
|
|
- }
|
|
|
- $pass_rates[] = number_format(($pass_counts[$index] * 100) / $test_count, 2);
|
|
|
- }
|
|
|
-
|
|
|
- ${$prefix . "_pass_rates"} = $pass_rates;
|
|
|
- }
|
|
|
-
|
|
|
- $chart = new Chart;
|
|
|
- $chart->addYAxis([
|
|
|
- "id" => "y-axis-1",
|
|
|
- "tick_config" => ["min" => 0, "max" => 100],
|
|
|
- ]);
|
|
|
- $chart->setType("bar");
|
|
|
- $chart->setTitle("Gender Comparison Pass Rate by $resolution_name");
|
|
|
- $chart->setLabels($x_data_labels);
|
|
|
- $chart->addDataset("M Cha. M", $mcm_pass_rates, ["background_colours" => "#2196F3", "datalabels" => ["display" => false], "line_tension" => 0]);
|
|
|
- $chart->addDataset("M Cha. F", $mcf_pass_rates, ["background_colours" => "#3F51B5", "datalabels" => ["display" => false], "line_tension" => 0]);
|
|
|
- $chart->addDataset("F Cha. M", $fcm_pass_rates, ["background_colours" => "#9C27B0", "datalabels" => ["display" => false], "line_tension" => 0]);
|
|
|
- $chart->addDataset("F Cha. F", $fcf_pass_rates, ["background_colours" => "#E91E63", "datalabels" => ["display" => false], "line_tension" => 0]);
|
|
|
- $chart->addDataset("Not Specified", $ns_pass_rates, ["background_colours" => "#9E9E9E", "datalabels" => ["display" => false], "line_tension" => 0]);
|
|
|
- $chart->print = true;
|
|
|
- $chart->setDatalabelSuffixes("%", "%", "%", "%", "%");
|
|
|
- $charts[] = $chart;
|
|
|
-
|
|
|
- // Gender Comparison Point of Challenge
|
|
|
- foreach($keys as $index => $key) {
|
|
|
- $key_label = $key_labels[$index];
|
|
|
- $period_data = $data[$key];
|
|
|
-
|
|
|
- foreach($gender_keys as $prefix => $gv) {
|
|
|
-
|
|
|
- $title = $gv["label"];
|
|
|
- $test_count = $period_data->{$prefix . "Count"};
|
|
|
- $stage_data = $period_data->{$prefix . "Stages"};
|
|
|
-
|
|
|
- if($test_count == 0) continue;
|
|
|
-
|
|
|
- $chart = new Chart;
|
|
|
- $chart->setType("pie");
|
|
|
- $chart->setTitle("$key_label $title Point of Challenge");
|
|
|
- $chart->setLabels(["On Entry", "While Browsing", "During Play", "On Exit", "No Challenge"]);
|
|
|
- $chart->addDataset("Counts", $stage_data, [
|
|
|
- "background_colours" => [
|
|
|
- "#4CAF50",
|
|
|
- "#FFEB3B",
|
|
|
- "#FBC02D",
|
|
|
- "#FFAB91",
|
|
|
- "#F44336",
|
|
|
- ],
|
|
|
- "datalabels" => Chart::DATALABELS_BOX,
|
|
|
- ]);
|
|
|
- $charts[] = $chart;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- // Region Graphs
|
|
|
- if($has_regions) {
|
|
|
-
|
|
|
- ksort($region_data, SORT_NATURAL);
|
|
|
-
|
|
|
- $region_keys = array_keys($region_data);
|
|
|
-
|
|
|
- $x_data_labels = array_map(function($key) {
|
|
|
- return "Region $key";
|
|
|
- }, $region_keys);
|
|
|
-
|
|
|
- // Region Pass Rate (Selected Date Range)
|
|
|
- $data_values = [];
|
|
|
-
|
|
|
- $test_counts = [];
|
|
|
- $pass_counts = [];
|
|
|
- $fail_counts = [];
|
|
|
-
|
|
|
- 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"));
|
|
|
-
|
|
|
- $test_counts[] = $total_region_test_count;
|
|
|
- $pass_counts[] = $total_region_pass_count;
|
|
|
- $fail_counts[] = $total_region_test_count - $total_region_pass_count;
|
|
|
-
|
|
|
- $data_values[] = ($total_region_test_count == 0) ? 0 : round(($total_region_pass_count * 100) / $total_region_test_count);
|
|
|
- }
|
|
|
-
|
|
|
- $chart = new Chart;
|
|
|
- $chart->addYAxis([
|
|
|
- "id" => "y-axis-1",
|
|
|
- "tick_config" => ["min" => 0, "max" => 100]
|
|
|
- ]);
|
|
|
- $chart->setType("bar");
|
|
|
- $chart->setTitle("Region Pass Rate $date_range_label");
|
|
|
- $chart->setLabels($x_data_labels);
|
|
|
- $chart->addDataset("Pass %", $data_values , [
|
|
|
- "background_colours" => "#2196F3"
|
|
|
- ]);
|
|
|
- $chart->addPrintDataset("Tests", $test_counts);
|
|
|
- $chart->addPrintDataset("Pass", $pass_counts);
|
|
|
- $chart->addPrintDataset("Fail", $fail_counts);
|
|
|
-
|
|
|
- $chart->setDatalabelSuffixes("%");
|
|
|
- $chart->print = true;
|
|
|
- $chart->printTotalColumn = true;
|
|
|
- $charts[] = $chart;
|
|
|
-
|
|
|
- // Region Pass Rate Period
|
|
|
- $chart = new Chart;
|
|
|
- $chart->addYAxis([
|
|
|
- "id" => "y-axis-1",
|
|
|
- "tick_config" => ["min" => 0, "max" => 100]
|
|
|
- ]);
|
|
|
- $chart->setType("bar");
|
|
|
- $chart->setTitle("Region Pass Rate by $resolution_name");
|
|
|
- $chart->setLabels($x_data_labels);
|
|
|
-
|
|
|
- foreach($keys as $index => $key) {
|
|
|
- $data_values = [];
|
|
|
- foreach($region_keys 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]]);
|
|
|
- }
|
|
|
- $chart->setDatalabelSuffixes(...array_fill(0, count($keys), "%"));
|
|
|
-
|
|
|
- $charts[] = $chart;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- // Area Manager Graphs
|
|
|
- if($has_area_managers) {
|
|
|
-
|
|
|
- ksort($area_manager_data, SORT_NATURAL);
|
|
|
-
|
|
|
- $area_manager_keys = array_keys($area_manager_data);
|
|
|
-
|
|
|
- $x_data_labels = array_map(function($key) {
|
|
|
- return "$key";
|
|
|
- }, $area_manager_keys);
|
|
|
-
|
|
|
- // Area Pass Rate (Selected Date Range)
|
|
|
- $data_values = [];
|
|
|
-
|
|
|
- $test_counts = [];
|
|
|
- $pass_counts = [];
|
|
|
- $fail_counts = [];
|
|
|
-
|
|
|
- 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"));
|
|
|
-
|
|
|
- $test_counts[] = $total_area_manager_test_count;
|
|
|
- $pass_counts[] = $total_area_manager_pass_count;
|
|
|
- $fail_counts[] = $total_area_manager_fail_count;
|
|
|
-
|
|
|
- $data_values[] = ($total_region_test_count == 0) ? 0 : round(($total_area_manager_pass_count * 100) / $total_area_manager_test_count);
|
|
|
- }
|
|
|
-
|
|
|
- $chart = new Chart;
|
|
|
- $chart->addXAxis([
|
|
|
- "type" => "category",
|
|
|
- "scale_label_config" => [
|
|
|
- "display" => true,
|
|
|
- "labelString" => "Area Manager",
|
|
|
- ]
|
|
|
- ]);
|
|
|
- $chart->addYAxis([
|
|
|
- "id" => "y-axis-1",
|
|
|
- "tick_config" => ["min" => 0, "max" => 100]
|
|
|
- ]);
|
|
|
- $chart->setType("bar");
|
|
|
- $chart->setTitle("Area Manager Pass Rate $date_range_label");
|
|
|
- $chart->setLabels($x_data_labels);
|
|
|
- $chart->addDataset("Pass %", $data_values , [
|
|
|
- "background_colours" => "#2196F3"
|
|
|
- ]);
|
|
|
- $chart->addPrintDataset("Tests", $test_counts);
|
|
|
- $chart->addPrintDataset("Pass", $pass_counts);
|
|
|
- $chart->addPrintDataset("Fail", $fail_counts);
|
|
|
- $chart->setDatalabelSuffixes("%");
|
|
|
- $chart->print = true;
|
|
|
- $chart->printTotalColumn = true;
|
|
|
- $charts[] = $chart;
|
|
|
-
|
|
|
- // Area Pass Rate Period
|
|
|
- $chart = new Chart;
|
|
|
- $chart->addXAxis([
|
|
|
- "type" => "category",
|
|
|
- "scale_label_config" => [
|
|
|
- "display" => true,
|
|
|
- "labelString" => "Area Manager",
|
|
|
- ]
|
|
|
- ]);
|
|
|
- $chart->addYAxis([
|
|
|
- "id" => "y-axis-1",
|
|
|
- "tick_config" => ["min" => 0, "max" => 100]
|
|
|
- ]);
|
|
|
- $chart->setType("bar");
|
|
|
- $chart->setTitle("Area Manager Pass Rate by $resolution_name");
|
|
|
- $chart->setLabels($x_data_labels);
|
|
|
-
|
|
|
- foreach($keys as $index => $key) {
|
|
|
- $data_values = [];
|
|
|
- foreach($area_manager_keys 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],
|
|
|
- "datalabels" => [
|
|
|
- "display" => false,
|
|
|
- ],
|
|
|
- ]);
|
|
|
- }
|
|
|
- $chart->setDatalabelSuffixes(...array_fill(0, count($keys), "%"));
|
|
|
-
|
|
|
- $charts[] = $chart;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ // Build charts hook
|
|
|
+ require $template->getProcessingFilePath("reports_build_charts.php");
|
|
|
}
|
|
|
catch(FormException $e) {
|
|
|
$e->generateAlerts();
|
|
|
@@ -1035,26 +375,21 @@ if($submit) {
|
|
|
Core::addAlert("danger", $e->getMessage());
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// Export hook
|
|
|
if(!empty($action)) {
|
|
|
switch($action) {
|
|
|
case "export-pptx":
|
|
|
case "export-odp":
|
|
|
-
|
|
|
require "reports_presentation.php";
|
|
|
-
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
View::includeOnce("header", compact("page_title"));
|
|
|
-View::include("reports", compact("customer", "date_range", "from_quarter", "to_quarter", "date_resolution", "all_projects", "project_ids", "charts", "data", "total_data", "locations_missing_region", "locations_missing_area_manager", "region_data", "area_manager_data", "key_labels"));
|
|
|
+View::include("reports", compact("customer", "date_range", "from_quarter", "to_quarter", "date_resolution", "all_projects", "project_ids", "charts", "data", "total_data", "locations_missing_region", "locations_missing_area_manager", "region_data", "area_manager_data", "key_labels", "has_pass_fail"));
|
|
|
View::includeOnce("footer");
|
|
|
|
|
|
-?>
|
|
|
+?>
|