CHANGE DASHBOARD THEME NEW - VADIVEL J 2025-08-16

This commit is contained in:
vadivelJ96 2025-08-16 18:55:49 +05:30
parent f02686d59a
commit 2e737499f9
3 changed files with 79 additions and 29 deletions

View File

@ -634,7 +634,7 @@ $routes->post('newClaim','VidalApiController::newClaim');
$routes->post('enrollment','VidalApiController::enrollment');
$routes->post("ticketCreation", "ThzController::ticketCreation");
$routes->post("ticketSave", "ThzController::ticketSave");
$routes->post("ticketList", "ThzController::ticketList");
$routes->post("ticketConversationSave", "ThzController::ticketConversationSave");
$routes->post("conversationListPerTicket", "ThzController::conversationListPerTicket");
$routes->post("ticketConversationList", "ThzController::ticketConversationList");

View File

@ -29,43 +29,67 @@ class ThzController extends BaseController
//
}
public function ticketCreation(){
public function ticketSave(){
$data = $this->request->getJSON(true);
$result = $this->thzMasterModel->insert($data);
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." ]));
return $this->response->setJSON((['status' => 'success', 'message' => 'Ticket created successfully']));
}
public function ticketList(){
public function ticketList()
{
$data = $this->request->getJson(true);
$id = $data['id'] ?? null;
if ( isset($id) && !empty($id) ) {
//Find Specific Ticket per id
$mobile = $data['mobile'] ?? null;
$result = $this->thzMasterModel->where('mobile',$mobile)->findAll();
}else{
// Find all the Ticket For the Manager who can see all the Tickets
$result = $this->thzMasterModel->findAll();
}
if(empty($result)){
return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']));
}
return $this->response->setJSON((['status' => 'success', 'data' => $result]));
$returnType = strtolower($this->request->getGet('return_type') ?? 'api');
$data = $this->request->getJSON(true);
$tickets = $this->fetchTicketsBasedOnrole($data);
if ($returnType === 'api') {
if (empty($tickets)) {
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);
}
return $this->response->setJSON([
'status' => 'success',
'data' => $tickets,
]);
}
public function ticketConversationSave(){
$data = $this->request->getJson(true);
$data = $this->request->getJSON(true);
$result = $this->thzMasterNotesModel->insert($data);
@ -78,13 +102,13 @@ class ThzController extends BaseController
}
public function conversationListPerTicket(){
public function ticketConversationList(){
$data = $this->request->getJson(true);
$data = $this->request->getJSON(true);
$thz_id = $data['thz_id'] ?? null;
$result = $this->thzMasterNotesModel->conversationListPerTicket($thz_id);
$result = $this->thzMasterNotesModel->ticketConversationList($thz_id);
if(empty($result)){
return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']));
@ -114,6 +138,32 @@ class ThzController extends BaseController
}
private function fetchTicketsBasedOnrole(array $data): array
{
$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)
->findAll();
}
if (!empty($id) && !empty($mobile)) {
// Specific ticket by ID and mobile
return $this->thzMasterModel
->where('thz_id', $id)
->where('mobile', $mobile)
->findAll();
}
// All tickets (e.g., for managers)
return $this->thzMasterModel->findAll();
}
}

View File

@ -40,7 +40,7 @@ class ThzMasterNotesModel extends Model
protected $beforeDelete = [];
protected $afterDelete = [];
public function conversationListPerTicket($thz_id){
public function ticketConversationList($thz_id){
if(empty($thz_id)){