CHANGE TICKETING SYSTEM - VADIVEL J 2025-08-17
This commit is contained in:
parent
5133838a8b
commit
d607afe5ed
@ -636,6 +636,6 @@ $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");
|
||||
$routes->get("ticketConversationList", "ThzController::ticketConversationList");
|
||||
@ -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()
|
||||
@ -33,34 +37,26 @@ class ThzController extends BaseController
|
||||
|
||||
$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();
|
||||
if (!empty($data['thz_id'])) {
|
||||
$text = "update";
|
||||
$result = $this->updateTicket($data);
|
||||
} else {
|
||||
$data['created_by'] = get_session_userid();
|
||||
$text = "create";
|
||||
|
||||
$result = $this->thzMasterModel->insert($data);
|
||||
$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." ]));
|
||||
|
||||
|
||||
|
||||
|
||||
return $this->response->setJSON([
|
||||
'status' => $result ? 'success' : 'error',
|
||||
'message' => $result ? "Ticket {$text}d successfully" : "Unable to {$text} ticket. Please try again."
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function ticketList()
|
||||
{
|
||||
|
||||
$returnType = strtolower($this->request->getGet('return_type') ?? 'api');
|
||||
|
||||
$data = $this->request->getJSON(true);
|
||||
$data = $this->request->getGet();
|
||||
|
||||
$tickets = $this->fetchTicketsBasedOnrole($data);
|
||||
|
||||
@ -86,16 +82,15 @@ class ThzController extends BaseController
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
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']));
|
||||
}
|
||||
if(empty($result)){
|
||||
return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']));
|
||||
}
|
||||
|
||||
return $this->response->setJSON((['status' => 'success', 'data' => $result]));
|
||||
|
||||
@ -104,40 +99,24 @@ class ThzController extends BaseController
|
||||
|
||||
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(empty($result)){
|
||||
return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']));
|
||||
}
|
||||
if(empty($result)){
|
||||
return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']));
|
||||
}
|
||||
|
||||
return $this->response->setJSON((['status' => 'success', 'data' => $result]));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************** 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;
|
||||
@ -163,6 +142,25 @@ class ThzController extends BaseController
|
||||
return $this->thzMasterModel->findAll();
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user