diff --git a/app/Config/Constants.php b/app/Config/Constants.php index fb86b921..eee4bdcd 100755 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -103,6 +103,8 @@ define('BUSINESS_TEAM_ID', '3'); define('FINANCE_TEAM_ID', '4'); define('SALES_TEAM_ID', '5'); define('MANAGEMENT_TEAM_ID', '6'); +define('BUSINESS_SUPPORT_TEAM_ID', '7'); +define('POS_TEAM_ID', '8'); /** * @User Teams Constant diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index d1a48afb..f4eb8d34 100755 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -100,8 +100,10 @@ class DashboardController extends AdminController $data = []; - $db = db_connect(); - $sql = "SELECT + if (in_array(get_role_id(), [1,2,3,5]) || (in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()))) { + + $db = db_connect(); + $sql = "SELECT clients.id AS client_id, clients.client_name, clients.short_name, @@ -144,30 +146,32 @@ class DashboardController extends AdminController GROUP BY clients.id, client_branch.id"; - $query = $db->query($sql); - $results = $query->getResultArray(); + $query = $db->query($sql); + $results = $query->getResultArray(); - $pendingActionsController = new PendingActionsController; - $pendingActionsData = $pendingActionsController->getPendingActionsForDashBoard(); - $businessTeamData = $this->policyTransactionModel->getBusinessReportList(); - $financeTeamData = $this->policyTransactionModel->getFinanceReportList(); - $businessTeamStatusData = $this->data_construct_for_bds($businessTeamData); - $financeTeamStatusData = $this->data_construct_for_bds($financeTeamData); + $pendingActionsController = new PendingActionsController; + $pendingActionsData = $pendingActionsController->getPendingActionsForDashBoard(); + $businessTeamData = $this->policyTransactionModel->getBusinessReportList(); + $financeTeamData = $this->policyTransactionModel->getFinanceReportList(); + $businessTeamStatusData = $this->data_construct_for_bds($businessTeamData); + $financeTeamStatusData = $this->data_construct_for_bds($financeTeamData); - $data['client_branch_emp_list'] = $results; - $session = \Config\Services::session(); - $session->set('enrollment_data', json_encode($data)); - - // echo "
";
-        $data['pendingActionsData'] = $pendingActionsData;
-        $data['businessTeamCount'] = count($businessTeamData) ?? 0;
-        $data['financeTeamCount'] = count($financeTeamData) ?? 0;
-        $data['businessTeamStatusData'] = $businessTeamStatusData;
-        $data['financeTeamStatusData'] = $financeTeamStatusData;
-        $data['policyStatus'] =  $this->policyStatus;
-        $data['colorShades'] =  $this->colorShades;
-        // print_r($data);die;
+            $data['client_branch_emp_list'] = $results;
+            $session = \Config\Services::session();
+            $session->set('enrollment_data', json_encode($data));
+
+            // echo "
";
+            $data['pendingActionsData'] = $pendingActionsData;
+            $data['businessTeamCount'] = count($businessTeamData) ?? 0;
+            $data['financeTeamCount'] = count($financeTeamData) ?? 0;
+            $data['businessTeamStatusData'] = $businessTeamStatusData;
+            $data['financeTeamStatusData'] = $financeTeamStatusData;
+            $data['policyStatus'] =  $this->policyStatus;
+            $data['colorShades'] =  $this->colorShades;
+            // print_r($data);die;
+
+        }
 
         $data['page_name'] = 'Dashboard';
 
diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php
index 4a2a59d6..2c40bd30 100644
--- a/app/Controllers/PolicyTransactionController.php
+++ b/app/Controllers/PolicyTransactionController.php
@@ -790,13 +790,24 @@ class PolicyTransactionController extends BaseController
                 ->whereIn('client_policy.policy_type_id', [2, 3])
                 ->where('client_policy.is_active', 1)
                 ->findAll();
-        
-        $data['pt_files'] = $this->PTFileModel
-                ->join('policy_transaction', 'pt_files.pt_id = policy_transaction.id')
-                ->where('pt_files.pt_id', $id)
-                ->where('pt_files.is_active', 1)
-                ->findAll();
-                
+
+
+        $ptFileQuery = $this->PTFileModel
+            ->join('policy_transaction', 'pt_files.pt_id = policy_transaction.id')
+            ->where('pt_files.pt_id', $id)
+            ->where('pt_files.is_active', 1);
+
+        if (!in_array(get_role_id(), [1, 5]) && empty(array_intersect(user_team(), [MANAGEMENT_TEAM_ID, FINANCE_TEAM_ID, BUSINESS_TEAM_ID]))) {
+            
+            if (get_role_id() == 4 && in_array(POS_TEAM_ID, user_team())) {
+                $ptFileQuery->where('pt_files.created_by', get_session_userid());
+            }
+        }
+
+        $data['pt_files'] = $ptFileQuery->findAll();
+
+
+
         $data['pt_co_share_details'] = $this->PTCOShareDetailsModel
                 ->select("
                     pt_co_share_details.*,
@@ -1501,11 +1512,19 @@ class PolicyTransactionController extends BaseController
         
         if (!empty($uploadData)) {
 
-            $data['pt_files'] = $this->PTFileModel
-                ->join('policy_transaction', 'pt_files.pt_id = policy_transaction.id')
-                ->where('pt_files.pt_id', $pt_id)
-                ->where('pt_files.is_active', 1)
-                ->findAll();           
+        $ptFileQuery = $this->PTFileModel
+            ->join('policy_transaction', 'pt_files.pt_id = policy_transaction.id')
+            ->where('pt_files.pt_id', $pt_id)
+            ->where('pt_files.is_active', 1);
+
+        if (!in_array(get_role_id(), [1, 5]) && empty(array_intersect(user_team(), [MANAGEMENT_TEAM_ID, FINANCE_TEAM_ID, BUSINESS_TEAM_ID]))) {
+            
+            if (get_role_id() == 4 && in_array(POS_TEAM_ID, user_team())) {
+                $ptFileQuery->where('pt_files.created_by', get_session_userid());
+            }
+        }
+
+        $data['pt_files'] = $ptFileQuery->findAll();        
                  
             return $this->respond(['status' => true, 'message' => 'File uploaded successfully in G-Drive', 'data' => $data]);
         } else {
diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php
index 136529d6..2a77d201 100644
--- a/app/Models/PolicyTransactionModel.php
+++ b/app/Models/PolicyTransactionModel.php
@@ -973,6 +973,19 @@ class PolicyTransactionModel extends Model
             ->where('policy_transaction.is_active', 1)
             ->where('policy_transaction.action_type', 'inception');
 
+        if (
+            (!in_array(get_role_id(), [1, 5])) &&
+            !(
+                in_array(MANAGEMENT_TEAM_ID, user_team()) ||
+                in_array(FINANCE_TEAM_ID, user_team()) ||
+                in_array(BUSINESS_TEAM_ID, user_team())
+            )
+        ) {
+            if (get_role_id() == 4 && in_array(POS_TEAM_ID, user_team())) {
+                $builder->where('policy_transaction.created_by', get_session_userid());
+            }
+        }
+
         // Optimize Date Filtering
         if (!empty($start_date) && !empty($end_date) && !empty($date_type)) {
             $builder->where("policy_transaction.$date_type >=", date('Y-m-d 00:00:00', strtotime($start_date)))
@@ -1034,6 +1047,19 @@ class PolicyTransactionModel extends Model
             ->where('policy_transaction.is_active', 1)
             ->where('policy_transaction.action_type !=', 'inception');
 
+        if (
+            (!in_array(get_role_id(), [1, 5])) &&
+            !(
+                in_array(MANAGEMENT_TEAM_ID, user_team()) ||
+                in_array(FINANCE_TEAM_ID, user_team()) ||
+                in_array(BUSINESS_TEAM_ID, user_team())
+            )
+        ) {
+            if (get_role_id() == 4 && in_array(POS_TEAM_ID, user_team())) {
+                $builder->where('policy_transaction.created_by', get_session_userid());
+            }
+        }
+            
 
         if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
 
diff --git a/app/Views/DashBoard.php b/app/Views/DashBoard.php
index 4da6b9c0..3102ab15 100755
--- a/app/Views/DashBoard.php
+++ b/app/Views/DashBoard.php
@@ -139,40 +139,41 @@
 
 
 
+
 
 
 
 
+
 
 
 
diff --git a/app/Views/bds_dash.php b/app/Views/bds_dash.php
index 89a92413..c6711ec9 100644
--- a/app/Views/bds_dash.php
+++ b/app/Views/bds_dash.php
@@ -125,7 +125,12 @@ body{
 }
 
 
-
+ + + + + +
- +
-
+ + + + + +
  • + + + 2 + App Content Management + + +
  • + + + +
    + +
    + -
    - - -
    - - - - +