|
|
@@ -2,8 +2,64 @@
|
|
|
|
|
|
$page_title = __("Account");
|
|
|
|
|
|
+$customer = null;
|
|
|
+
|
|
|
+$test_count = 0;
|
|
|
+$pass_fail_test_count = 0;
|
|
|
+$completed_tests = null;
|
|
|
+$year_cycle_start_text = null;
|
|
|
+
|
|
|
+$pass_rate = null;
|
|
|
+$logo_path = null;
|
|
|
+
|
|
|
$user = Core::$user;
|
|
|
|
|
|
+if($user->isCustomer()) {
|
|
|
+ $customers = $user->getCustomers();
|
|
|
+
|
|
|
+ if($customers) {
|
|
|
+ $customer = $customers[0];
|
|
|
+
|
|
|
+ $logo_path = $customer->getLogoPath();
|
|
|
+
|
|
|
+ $page_title = __("%s Dashboard", $customer->name);
|
|
|
+ $year_cycle = $customer->getYearCycleDates();
|
|
|
+
|
|
|
+ list($start, $end) = $year_cycle;
|
|
|
+
|
|
|
+ $dt = new DateTime($start);
|
|
|
+ $year_cycle_start_text = $dt->format("d/m/Y");
|
|
|
+
|
|
|
+ $projects = $customer->getProjects();
|
|
|
+ $project_ids = array_column($projects, "id");
|
|
|
+
|
|
|
+ $tests = Test::query([
|
|
|
+ "project_id" => $project_ids,
|
|
|
+ "status" => Test::STATUS_COMPLETED,
|
|
|
+ "dts_start" => (new Constraint("BETWEEN"))->setValues(...$year_cycle)
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $test_count = count($tests);
|
|
|
+
|
|
|
+ $pass_fail_tests = array_filter($tests, function(Test $test) {
|
|
|
+ $project = $test->getProject();
|
|
|
+ $template = $project->getTemplate();
|
|
|
+ return $template->hasPassFail();
|
|
|
+ });
|
|
|
+
|
|
|
+ $pass_fail_test_count = count($pass_fail_tests);
|
|
|
+
|
|
|
+ $passed_tests = array_filter($pass_fail_tests, function(Test $test) {
|
|
|
+ return $test->pass;
|
|
|
+ });
|
|
|
+
|
|
|
+ $pass_count = count($passed_tests);
|
|
|
+
|
|
|
+ $pass_rate = $pass_count / $pass_fail_test_count;
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
Core::addBreadcrumb("/account", $page_title);
|
|
|
|
|
|
$users_pending_verification = 0;
|
|
|
@@ -105,7 +161,6 @@ if($tests_pending_verification) {
|
|
|
$referrals = $user->getReferrals();
|
|
|
|
|
|
View::includeOnce("header", compact("page_title"));
|
|
|
-View::include("account", compact("icons", "actions", "to_do", "referrals"));
|
|
|
+View::include("account", compact("page_title", "icons", "actions", "to_do", "referrals", "customer", "logo_path", "year_cycle_start_text", "pass_rate", "pass_count", "pass_fail_test_count", "test_count"));
|
|
|
View::includeOnce("footer");
|
|
|
|
|
|
-?>
|