diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index 3aaaaabd..ea9c7fc0 100755
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -551,6 +551,13 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
$routes->get("claimView", "EmployeeRestController::claimView");
$routes->get("exportCashDepositData", "EmployeeRestController::exportCashDepositData");
+
+ //thz_master's
+ $routes->post("ticketSave", "ThzController::ticketSave");
+ $routes->get("ticketList", "ThzController::ticketList");
+ $routes->post("ticketConversationSave", "ThzController::ticketConversationSave");
+ $routes->get("ticketConversationList", "ThzController::ticketConversationList");
+
});
$routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy");
$routes->get("sendPushNotification", "EmployeeRestController::sendPushNotification");
@@ -636,6 +643,7 @@ $routes->post('enrollment','VidalApiController::enrollment');
$routes->post("ticketSave", "ThzController::ticketSave");
-$routes->post("ticketList", "ThzController::ticketList");
+$routes->get("ticketList", "ThzController::ticketList");
$routes->post("ticketConversationSave", "ThzController::ticketConversationSave");
-$routes->post("ticketConversationList", "ThzController::ticketConversationList");
\ No newline at end of file
+$routes->get("ticketConversationList", "ThzController::ticketConversationList");
+$routes->get('ticketAssigning',"ThzController::ticketAssigning");
\ No newline at end of file
diff --git a/app/Controllers/ThzController.php b/app/Controllers/ThzController.php
index be2d0f5f..fd2f424f 100644
--- a/app/Controllers/ThzController.php
+++ b/app/Controllers/ThzController.php
@@ -8,6 +8,7 @@ use CodeIgniter\HTTP\ResponseInterface;
use App\Models\ThzMasterModel;
use App\Models\ThzMasterNotesModel;
use App\ControllerCleaners\ThzControllerCleaner;
+use App\Models\UserModel;
class ThzController extends BaseController
{
@@ -17,11 +18,14 @@ class ThzController extends BaseController
protected $thzControllerCleaner;
+ protected $userModel;
+
public function __construct()
{
$this->thzMasterModel = new ThzMasterModel();
$this->thzMasterNotesModel = new ThzMasterNotesModel();
$this->thzControllerCleaner = new ThzControllerCleaner();
+ $this->userModel = new UserModel();
}
public function index()
@@ -31,136 +35,203 @@ class ThzController extends BaseController
public function ticketSave(){
- $data = $this->request->getJSON(true);
-
- if (!empty($data['thz_id'])) {
- $data['updated_by'] = get_session_userid();
- $ticket_id = $data['thz_id'];
- $text = "update";
-
- $result = $this->thzMasterModel->where('thz_id', $ticket_id)->set($data)->update();
- } else {
- $data['created_by'] = get_session_userid();
- $text = "create";
-
- $result = $this->thzMasterModel->insert($data);
- }
-
- return $this->response->setJSON(([ 'status' => $result ? 'success' : 'error' ,
- 'message' => $result ? "Ticket {$text}d successfully" : "Unable to {$text} ticket. Please try again." ]));
-
-
-
+ $data = $this->request->getPost();
+ // $data = $this->request->getJSON(true);
+ // $return_type = isset($data['return_type']) ? $data['return_type'] : 'api';
+ if (!empty($data['thz_id'])) {
+ $text = "update";
+ $result = $this->updateTicket($data);
+ } else {
+ $text = "create";
+ $result = $this->insertTicket($data);
+ }
+ return $this->response->setJSON([
+ 'status' => $result ? 'success' : 'error',
+ 'message' => $result ? "Ticket {$text}d successfully" : "Unable to {$text} ticket. Please try again."
+ ])->setStatusCode($result ? 200 : 400);
}
-
public function ticketList()
{
$returnType = strtolower($this->request->getGet('return_type') ?? 'api');
- $data = $this->request->getJSON(true);
+ $data = $this->request->getGet();
$tickets = $this->fetchTicketsBasedOnrole($data);
-
-
if ($returnType === 'api') {
if (empty($tickets)) {
- return $this->response->setJSON([ 'status' => 'error','message' => 'No tickets found',])->setStatusCode(404);
+ return $this->response->setJSON([ 'status' => 'error','message' => 'No tickets found'])->setStatusCode(404);
}
}else{
$data['page_name'] = "Ticket List";
$data['ticket_data'] = $tickets;
- $data['assigner'] = $this->userModel->where('is_active', 1)->findAll();
- return $this->loadLayout('ticket_list_web', $data);
- }
-
-
+ $data['assignee'] = $this->userModel->where('is_active', 1)->whereIn('role', ['1', '5'])->findAll(); // enga 5-"head" and 1-"admin" role person thaan assignee..
+ return $this->loadLayout('thz_list', $data);
+ }
return $this->response->setJSON([
'status' => 'success',
'data' => $tickets,
- ]);
+ ])->setStatusCode(200);
}
-
public function ticketConversationSave(){
$data = $this->request->getJSON(true);
$result = $this->thzMasterNotesModel->insert($data);
- if(empty($result)){
- return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']));
- }
-
- return $this->response->setJSON((['status' => 'success', 'data' => $result]));
+ if(empty($result)){
+ return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']))->setStatusCode(404);
+ }
+
+ return $this->response->setJSON([
+ 'status' => $result ? 'success' : 'error',
+ 'message' => $result ? "Ticket Notes created successfully" : "Unable to create ticket notes. Please try again."
+ ])->setStatusCode($result ? 200 : 400);
}
public function ticketConversationList(){
- $data = $this->request->getJSON(true);
+ $data = $this->request->getGet();
$thz_id = $data['thz_id'] ?? null;
- $result = $this->thzMasterNotesModel->ticketConversationList($thz_id);
+ if($thz_id){
+ $result['master'] = $this->thzMasterModel
+ ->select('thz_master.*, CONCAT(user_profiles.first_name, " ", user_profiles.last_name) as assignee_name')
+ ->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
+ ->where('thz_master.thz_id', $thz_id)
+ ->findAll();
- if(empty($result)){
- return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']));
- }
-
- return $this->response->setJSON((['status' => 'success', 'data' => $result]));
+ $notes = $this->thzMasterNotesModel->ticketConversationList($thz_id);
+ $result['notes'] = !empty($notes) ? $notes : [];
+
+ }else{
+ return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']))->setStatusCode(404);
+ }
+
+ return $this->response->setJSON((['status' => 'success', 'data' => $result]))->setStatusCode(400);
}
+ public function ticketSaveNotification($data){
+
+ }
+ public function ticketConversationSaveNotification($data){
+
+ }
+
+ public function ticketAssigning(){
+
+ $returnType = strtolower($this->request->getGet('return_type') ?? 'api');
+
+ $data = $this->request->getVar();
+
+ $assignee_id = $data['assignee_id'];
+
+ $thz_id = $data['thz_id'];
+
+ $result = $this->thzMasterModel->set('assign_to',$assignee_id)->where('thz_id',$thz_id)->update();
+
+ if($returnType === 'api'){
+
+ if(empty($result)){
+ return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']));
+ }
+
+ return $this->response->setJSON((['status' => 'success', 'data' => $result]));
+
+ }else{
+
+
+
+ }
+
+
+
+
+
+ }
/************************************************** PRIVATE FUNCTIONS ********************************************************/
- private function checkGeneralUserOrEmployee($data){
-
- if($data['empcode']){
- return $data['empcode'];
- } elseif ($data['mobile']) {
- return $data['mobile'];
- } elseif ($data['email']) {
- return $data['email'];
- } else {
- return null;
- }
-
- }
-
private function fetchTicketsBasedOnrole(array $data): array
{
- $id = $data['thz_id'] ?? null;
+ // $id = $data['thz_id'] ?? null;
$assign_to = $data['assign_to'] ?? null;
$mobile = $data['mobile'] ?? null;
if (!empty($assign_to)) {
// Tickets assigned to a staff
return $this->thzMasterModel
- ->where('assign_to', $assign_to)
+ ->select('thz_master.*, CONCAT(user_profiles.first_name, " ", user_profiles.last_name) as assignee_name')
+ ->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
+ ->where('thz_master.assign_to', $assign_to)
->findAll();
}
- if (!empty($id) && !empty($mobile)) {
+ // if (!empty($id) && !empty($mobile)) {
+ if (!empty($mobile)) {
// Specific ticket by ID and mobile
return $this->thzMasterModel
- ->where('thz_id', $id)
- ->where('mobile', $mobile)
+ ->select('thz_master.*, CONCAT(user_profiles.first_name, " ", user_profiles.last_name) as assignee_name')
+ ->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
+ // ->where('thz_id', $id)
+ ->where('thz_master.mobile', $mobile)
->findAll();
}
// All tickets (e.g., for managers)
- return $this->thzMasterModel->findAll();
+ return $this->thzMasterModel
+ ->select('thz_master.*, CONCAT(user_profiles.first_name, " ", user_profiles.last_name) as assignee_name')
+ ->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
+ ->findAll();
+ }
+
+ private function notificationBasedOnRole($data){
+
+ $id = $data['thz_id'] ?? null;
+ $assign_to = $data['assign_to'] ?? null;
+ $mobile = $data['mobile'] ?? null;
+
+ if (!empty($assign_to)) {
+
+ }
+
+ if (!empty($id) && !empty($mobile)) {
+
+ }
+
+
+ }
+
+ private function updateTicket($data){
+
+ $data['updated_by'] = get_session_userid();
+ $ticket_id = $data['thz_id'];
+ $result = $this->thzMasterModel->where('thz_id', $ticket_id)->set($data)->update();
+
+ return $result;
+
+ }
+
+ private function insertTicket($data){
+
+ $data['created_by'] = get_session_userid();
+ $result = $this->thzMasterModel->insert($data);
+
+ return $result;
+
}
diff --git a/app/Models/ThzMasterModel.php b/app/Models/ThzMasterModel.php
index 410a84ba..580c6181 100644
--- a/app/Models/ThzMasterModel.php
+++ b/app/Models/ThzMasterModel.php
@@ -12,7 +12,7 @@ class ThzMasterModel extends Model
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $protectFields = true;
- protected $allowedFields = ['name','mobile','email','empcode','policy_no','ticket_type','subject','message','status','assign_to','created_at','updated_at'];
+ protected $allowedFields = ['name','mobile','email','empcode','policy_no','ticket_type','subject','message','status','assign_to','created_at','updated_at','created_by','updated_by' ,'client_id' ,'policy_id' ,'branch_id'];
protected bool $allowEmptyInserts = false;
diff --git a/app/Models/ThzMasterNotesModel.php b/app/Models/ThzMasterNotesModel.php
index 769b505d..6b738219 100644
--- a/app/Models/ThzMasterNotesModel.php
+++ b/app/Models/ThzMasterNotesModel.php
@@ -40,7 +40,7 @@ class ThzMasterNotesModel extends Model
protected $beforeDelete = [];
protected $afterDelete = [];
- public function ticketConversationList($thz_id){
+ public function ticketConversationLists($thz_id){
if(empty($thz_id)){
@@ -76,5 +76,33 @@ class ThzMasterNotesModel extends Model
}
+ public function ticketConversationList($thz_id)
+ {
+
+ $notes_sql = "SELECT
+ thz_master_notes.*,
+ CASE
+ WHEN LOWER(thz_master_notes.notes_by) = 'staff'
+ THEN CONCAT(user_profiles.first_name, ' ', user_profiles.last_name)
+ WHEN LOWER(thz_master_notes.notes_by) = 'user'
+ THEN thz_master.name
+ ELSE thz_master_notes.notes_by
+ END AS name
+ FROM thz_master_notes
+ LEFT JOIN user_profiles
+ ON user_profiles.id = thz_master_notes.created_by
+ AND LOWER(thz_master_notes.notes_by) = 'staff'
+ LEFT JOIN thz_master
+ ON thz_master.thz_id = thz_master_notes.thz_id
+ AND LOWER(thz_master_notes.notes_by) = 'user'
+ WHERE thz_master_notes.thz_id = " . (int)$thz_id . "
+ ORDER BY thz_master_notes.created_at ASC";
+
+ $result = $this->db->query($notes_sql)->getResultArray();
+
+ return $result;
+ }
+
+
}
diff --git a/app/Views/DashBoard.php b/app/Views/DashBoard.php
index b0cefc4e..b9e1294c 100755
--- a/app/Views/DashBoard.php
+++ b/app/Views/DashBoard.php
@@ -193,6 +193,10 @@
min-height: 70vh !important;
}
+ .active{
+ color : white !important ;
+ }
+
@@ -212,12 +216,12 @@
+ class="nav-link px-3 py-1 dash-anchor" id="pending_actions_tab">
/assets/images/inactive_pending_actions.png" alt="Logo" height="14" class="inactive_pending" >
/assets/images/active_pending_actions.png" alt="Logo" height="14"
class="active_pending" style="display:none;">
- Pending Actions
+ Pending Actions
@@ -226,12 +230,12 @@
-
+
/assets/images/inactive_bds.png" alt="Logo" height="14" class="inactive_bds">
/assets/images/active_bds.png" alt="Logo" height="14"
- class="active_bds" style="display:none;">
+ class="active_bds " style="display:none;">
- BDS
+ BDS
@@ -242,12 +246,12 @@
$isActive = get_role_id() == STAFF_ROLE_ID && in_array(CLAIMS_TEAM_ID,user_team()) ? 'active show' : '';
?>
-
+
/assets/images/inactive_claims.png" alt="Logo" height="14" class="inactive_claims">
/assets/images/active_claims.png" alt="Logo" height="14"
- class="active_claims" style="display:none;">
+ class="active_claims " style="display:none;">
- Claims
+ Claims
@@ -256,13 +260,13 @@
-
-
+
+
/assets/images/inactive_leads_and_bds_renewal.png" alt="Logo" height="14" class="inactive_leads">
/assets/images/active_leads_and_bds_renewal.png" alt="Logo" height="14"
- class="active_leads" style="display:none;">
+ class="active_leads " style="display:none;">
- Leads and BDS Renewals
+ Leads and BDS Renewals
@@ -375,3 +379,20 @@ $(document).ready(function(){
});
+
+
diff --git a/app/Views/UserList.php b/app/Views/UserList.php
index b7de1d73..5f8d59f2 100755
--- a/app/Views/UserList.php
+++ b/app/Views/UserList.php
@@ -223,6 +223,20 @@ table.dataTable tbody td {
.text-danger {
color: #dc3545;
}
+
+ .btn-color{
+ background-color: rgba(52, 174, 178, 1);
+ color: white;
+ border:1px solid rgba(52, 174, 178, 1);
+ }
+
+ .btn-color:hover{
+ background-color: rgba(41, 139, 142, 1);
+ color: white;
+ border:1px solid rgba(41, 139, 142, 1);
+ }
+
+
@@ -234,9 +248,6 @@ table.dataTable tbody td {
User List
-
-
-
@@ -372,7 +383,7 @@ table.dataTable tbody td {