diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index 8642c0a5..43ebcb94 100644 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -11,12 +11,14 @@ use CodeIgniter\API\ResponseTrait; use App\Models\MessageModel; use App\Models\UserMessageModel; +use App\Models\ClientModel; class DashboardController extends AdminController { use ResponseTrait; protected $messageModel; + protected $clientModel; protected $userMessageModel; protected $myLogger; @@ -26,12 +28,97 @@ class DashboardController extends AdminController $this->messageModel = new MessageModel(); $this->userMessageModel = new UserMessageModel(); $this->myLogger = \Config\Services::mylogger(); + $this->clientModel = new ClientModel(); } public function dashboard() { + $data = []; + + + $results = $this->clientModel->select('clients.id as client_id, clients.client_name, clients.short_name, + client_branch.id as client_branch_id, client_branch.branch_name, + client_branch.branch_code, employees.id as employee_id, + employees.name as employee_name, employees.relationship, + employees.emp_code, employees.emp_status, auth_history.user_type') + ->join('client_branch','clients.id = client_branch.client_id', 'left') + ->join('employees','client_branch.id = employees.client_branch_id', 'left') + ->join('auth_history', 'employees.id = auth_history.user_id AND "employee" = auth_history.user_type', 'left') + ->findAll(); + + $groupedData = []; + $employeeId = ''; + foreach ($results as $row) { + $clientId = $row['client_id']; + $clientName = $row['client_name']; + $shortName = $row['short_name']; + $branchId = $row['client_branch_id']; + $branchName = $row['branch_name']; + $branchCode = $row['branch_code']; + if($employeeId != $row['employee_id']){ + $employeeId = $row['employee_id']; + }else{ + $employeeId = null; + } + $employeeName = $row['employee_name'] ; + $employeeRelationship = $row['relationship'] ; + $employeeEmpCode = $row['emp_code'] ; + $employeeEmpStatus = $row['emp_status']; + $employeeUserType = $row['user_type']; + + // Initialize the client entry if it doesn't exist + if (!isset($groupedData[$clientId])) { + $groupedData[$clientId] = [ + 'client_id' => $clientId, + 'client_name' => $clientName, + 'short_name' => $shortName, + 'branches' => [] + ]; + } + + // Initialize the branch entry if it doesn't exist + if (!isset($groupedData[$clientId]['branches'][$branchId])) { + $groupedData[$clientId]['branches'][$branchId] = [ + 'client_branch_id' => $branchId, + 'branch_name' => $branchName, + 'branch_code' => $branchCode, + 'emp_login' => 0, + 'emp_enroll' => 0, + 'employees' => [] + ]; + } + if ($employeeId !== null && $employeeRelationship == 'Self') { + // Append employee info to the branch's employees list + $groupedData[$clientId]['branches'][$branchId]['employees'][] = [ + 'employee_id' => $employeeId, + 'employee_name' => $employeeName, + 'relationship' => $employeeRelationship, + 'emp_code' => $employeeEmpCode, + 'emp_status' => $employeeEmpStatus, + 'user_type' => $employeeUserType + ]; + if (!empty($employeeUserType)) { + $groupedData[$clientId]['branches'][$branchId]['emp_login']++; + } + + // Increment emp_enroll if emp_status is not 'draft' + if ($employeeEmpStatus !== 'draft') { + $groupedData[$clientId]['branches'][$branchId]['emp_enroll']++; + } + } + $employeeId = $row['employee_id']; + } + + // Re-index the arrays to match the expected structure + foreach ($groupedData as &$client) { + $client['branches'] = array_values($client['branches']); + } + // echo "
";
+        $data['client_branch_emp_list'] = $groupedData;
+        // print_r($data);die;
+
         echo view('layout/header');
-        echo view('DashBoard');
+        echo view('DashBoard', $data);
         echo view('layout/footer');
     }
 
diff --git a/app/Views/DashBoard.php b/app/Views/DashBoard.php
index fc335f73..7d8243a5 100644
--- a/app/Views/DashBoard.php
+++ b/app/Views/DashBoard.php
@@ -1 +1,80 @@
-

Welcome !

+ + + +
+
+
+
+
+
+
+
+
+
+ +
+ + +
+ + + + +
+
+
+
+
+ + + + + diff --git a/app/Views/endorsement_dash.php b/app/Views/endorsement_dash.php new file mode 100644 index 00000000..a097be06 --- /dev/null +++ b/app/Views/endorsement_dash.php @@ -0,0 +1,4 @@ +
+ +

Endorsement

+
\ No newline at end of file diff --git a/app/Views/enrollment_dash.php b/app/Views/enrollment_dash.php new file mode 100644 index 00000000..c5a339ab --- /dev/null +++ b/app/Views/enrollment_dash.php @@ -0,0 +1,115 @@ + + +
+ +
+
+
+
+
+
+ + +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+
+ +
+ + +
+
+ +
+
+
+ +
+
+
+
+
+ + +
+
+
+
+
+
+ diff --git a/app/Views/enrollment_list.php b/app/Views/enrollment_list.php new file mode 100644 index 00000000..f35d7753 --- /dev/null +++ b/app/Views/enrollment_list.php @@ -0,0 +1,422 @@ + + +
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+ Search +
+
+
+ + +
+
+
+
+
+
+
+
+
+
+
+
Emp Count
+

0

+
+ +
+
+
+
+
+
+
+
+
+
Enrolled
+

0

+
+ +
+
+
+
+
+
+
+
+
+
Not Enrolled
+

0

+
+ +
+
+
+
+
+
+
+
+
+
Logged-In
+

0

+
+ +
+
+
+
+
+
+
+
+
+
Not Logged-In
+

0

+
+ +
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+ + + + + + + + + + + + + +
SNONameEmp CodeEnrolledLogged-In
+
+
+
+
+ + + + diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index 61788461..f430ce9e 100644 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -55,6 +55,8 @@ + + @@ -69,6 +71,10 @@ }); } + + + +