diff --git a/app/Config/Routes.php b/app/Config/Routes.php index acb156bd..42964439 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -562,6 +562,7 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->get("ticketList", "ThzController::ticketList"); $routes->post("ticketConversationSave", "ThzController::ticketConversationSave"); $routes->get("ticketConversationList", "ThzController::ticketConversationList"); + $routes->get("ticketHistoryList", "ThzController::ticketHistoryList"); $routes->get("hrFileList", "EmployeeRestController::hrFileList"); $routes->get("hrFileUploadMasters", "EmployeeRestController::hrFileUploadMasters"); @@ -660,4 +661,5 @@ $routes->get("ticketList", "ThzController::ticketList"); $routes->post("ticketConversationSave", "ThzController::ticketConversationSave"); $routes->get("ticketConversationList", "ThzController::ticketConversationList"); $routes->post('ticketAutoFetchDetails',"ThzController::ticketAutoFetchDetails"); -// $routes->match(['get','post','put'], 'ticketType', 'ThzController::ticketType'); \ No newline at end of file +$routes->match(['get','post','put'], 'ticketType', 'ThzController::ticketType'); +$routes->get("ticketHistoryList", "ThzController::ticketHistoryList"); \ No newline at end of file diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index fc4a4e86..dfee8dc0 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -2746,7 +2746,7 @@ class LeadsController extends BaseController } // print_r($subject); die; - + $common = ['module' => "leads", 'pk' =>$lead_id]; if ($recipient_data) { foreach ($recipient_data as $recipient) { @@ -2761,7 +2761,7 @@ class LeadsController extends BaseController $string = implode(", ", $cc_mails); $bcc_string = implode(", ", $bcc_mails); - $res = MailHelper::send_email(['from_mail' => $from_mail, 'mail' => $recipient['email'], 'cc' => $string, 'subject' => $subject, 'message' => $message, 'attachments' => $attachments, 'reply_to' => $reply_to, 'bcc' => $bcc_string]); + $res = MailHelper::send_email(['from_mail' => $from_mail, 'mail' => $recipient['email'], 'cc' => $string, 'subject' => $subject, 'message' => $message, 'attachments' => $attachments, 'reply_to' => $reply_to, 'bcc' => $bcc_string, 'common' => $common]); // !dd($res); $result_data[] = ['mail' => $recipient['email'], 'status' => $res]; } diff --git a/app/Controllers/ThzController.php b/app/Controllers/ThzController.php index e286d651..fe6ad35b 100644 --- a/app/Controllers/ThzController.php +++ b/app/Controllers/ThzController.php @@ -8,12 +8,13 @@ use CodeIgniter\HTTP\ResponseInterface; use App\Models\ThzMasterModel; use App\Models\ThzMasterNotesModel; +use App\Models\ThzTypeModel; +use App\Models\ThzHistoryModel; use App\ControllerCleaners\ThzControllerCleaner; use App\Models\UserModel; use App\Models\ClientPolicyModel; use App\Models\ClientModel; use App\Models\TicketMailTemplateModel; -// use App\Models\TicketTypesModel; class ThzController extends BaseController @@ -21,7 +22,8 @@ class ThzController extends BaseController protected $thzMasterModel; protected $thzMasterNotesModel; - + protected $thzTypeModel; + protected $thzHistoryModel; protected $thzControllerCleaner; protected $userModel; @@ -29,16 +31,17 @@ class ThzController extends BaseController protected $clientModel; protected $ticketMailTemplateModel; - // protected $ticketTypesModel; public function __construct() { $this->thzMasterModel = new ThzMasterModel(); $this->thzMasterNotesModel = new ThzMasterNotesModel(); + $this->thzTypeModel = new thzTypeModel(); + $this->thzHistoryModel = new ThzHistoryModel(); $this->thzControllerCleaner = new ThzControllerCleaner(); $this->userModel = new UserModel(); $this->clientPolicyModel = new ClientPolicyModel(); - $this->clientModel = new ClientModel(); + $this->clientModel = new ClientModel(); $this->ticketMailTemplateModel = new TicketMailTemplateModel(); } @@ -55,6 +58,28 @@ class ThzController extends BaseController $text = "update"; $result = $this->updateTicket($data); + // here insert history Status. + $old = $this->thzMasterModel->where('thz_id', $data['thz_id'])->get()->getRowArray(); + + if ($old && isset($data['status'])) { + if ($old['status'] != $data['status']) { + $history = [ + 'thz_id' => $data['thz_id'], + 'field_name' => 'status', + 'display_name' => 'Status', + 'old_value' => $old['status'], + 'new_value' => $data['status'], + 'is_active' => 1 + ]; + + if (!empty(get_session_userid())) { + $history['created_by'] = get_session_userid(); + } + + $this->thzHistoryModel->insert($history); + } + } + $updateID = $data['thz_id']; } else { @@ -228,43 +253,63 @@ class ThzController extends BaseController } - // public function ticketType() - // { - // $method = $this->request->getMethod(); // get, post + public function ticketType() + { + $method = $this->request->getMethod(); // get, post - // if ($method === 'get') { + if ($method === 'get') { - // $types = $this->ticketTypesModel->where('is_active', 1)->findAll(); - // if (empty($types)) { - // return $this->response->setJSON(['status' => 'error','message' => 'No ticket types found'])->setStatusCode(404); - // } - // return $this->response->setJSON(['status' => 'success','data' => $types])->setStatusCode(200); + $types = $this->thzTypeModel->where('is_active', 1)->findAll(); + if (empty($types)) { + return $this->response->setJSON(['status' => 'error','message' => 'No ticket types found'])->setStatusCode(404); + } + return $this->response->setJSON(['status' => 'success','data' => $types])->setStatusCode(200); - // } + } - // if ($method === 'post') { + if ($method === 'post') { - // $data = $this->request->getPost(); - // if (!empty($data['id'])) { - // $text = "update"; - // $result = $this->ticketTypesModel->update($data['id'], $data); - // $updateID = $data['id']; - // } else { - // $text = "create"; - // $insertID = $this->ticketTypesModel->insert($data); - // $result = true; - // } + $data = $this->request->getPost(); + if (!empty($data['id'])) { + $text = "update"; + $result = $this->thzTypeModel->update($data['id'], $data); + $updateID = $data['id']; + } else { + $text = "create"; + $insertID = $this->thzTypeModel->insert($data); + $result = true; + } - // $id = isset($insertID) && !empty($insertID) ? $insertID : $updateID ; + $id = isset($insertID) && !empty($insertID) ? $insertID : $updateID ; - // return $this->response->setJSON([ - // 'status' => $id ? 'success' : 'error', - // 'message' => $id ? "Ticket Type {$text}d successfully " : "Unable to {$text} ticket type. Please try again." , - // 'id' => $id - // ])->setStatusCode($id ? 200 : 400); - // } - // return $this->response->setJSON(['status' => 'error','message' => 'No ticket types found'])->setStatusCode(404); - // } + return $this->response->setJSON([ + 'status' => $id ? 'success' : 'error', + 'message' => $id ? "Ticket Type {$text}d successfully " : "Unable to {$text} ticket type. Please try again." , + 'id' => $id + ])->setStatusCode($id ? 200 : 400); + } + return $this->response->setJSON(['status' => 'error','message' => 'No ticket types found'])->setStatusCode(404); + } + + public function ticketHistoryList() + { + + $data = $this->request->getGet(); + $thz_id = $data['thz_id']; + // $details = $this->thzHistoryModal->whereIn('thz_id', $thz_id)->where('is_active', 1)->get()->getResultArray(); + $details = $this->thzHistoryModel->select('thz_history.*, CONCAT(user_profiles.first_name, " ", user_profiles.last_name) as created_name') + ->join('user_profiles', 'user_profiles.id = thz_history.created_by', 'left') + ->where('thz_history.thz_id', $thz_id)->where('thz_history.is_active', 1)->get()->getResultArray(); + + + + if (empty($details)) { + return $this->response->setJSON([ 'status' => 'error','message' => 'No History found'])->setStatusCode(404); + } + + + return $this->response->setJSON(['status' => 'success','data' => $details])->setStatusCode(200); + } /************************************************** PRIVATE FUNCTIONS ********************************************************/ diff --git a/app/Helpers/MailHelper.php b/app/Helpers/MailHelper.php index cce74a9a..89e90262 100755 --- a/app/Helpers/MailHelper.php +++ b/app/Helpers/MailHelper.php @@ -322,6 +322,7 @@ class MailHelper $from_address = isset($params['from_mail']) && !empty($params['from_mail']) ? $params['from_mail'] : getenv('email.fromEmail'); // $from_address = "claims@nhanceindia.in"; + if(isset($params['common'])){ $params['common']['from_mail'] = $from_address; } try { $curl = curl_init(); diff --git a/app/Models/GmailSentHistoryModel.php b/app/Models/GmailSentHistoryModel.php index 9a0ae8ea..d26486e8 100644 --- a/app/Models/GmailSentHistoryModel.php +++ b/app/Models/GmailSentHistoryModel.php @@ -7,5 +7,5 @@ use CodeIgniter\Model; class GmailSentHistoryModel extends Model{ protected $table = 'gmail_sent_history'; protected $primaryKey = 'id'; - protected $allowedFields = ["id", "mail", "bcc", "cc", "message", "attachments", "client_id", "client_branch_id", "client_policy_id", "employee_policy_id", "employee_id", "mail_type", "gmail_api_status", "gmail_api_id", "created_by", "created_at", "updated_by", "updated_at", "isactive","received_message"]; + protected $allowedFields = ["id", "mail", "bcc", "cc", "message", "attachments", "client_id", "client_branch_id", "client_policy_id", "employee_policy_id", "employee_id", "mail_type", "gmail_api_status", "gmail_api_id", "module", "pk", "from_mail", "created_by", "created_at", "updated_by", "updated_at", "isactive","received_message"]; } \ No newline at end of file diff --git a/app/Models/ThzHistoryModel.php b/app/Models/ThzHistoryModel.php new file mode 100644 index 00000000..f7dd22d2 --- /dev/null +++ b/app/Models/ThzHistoryModel.php @@ -0,0 +1,45 @@ + diff --git a/app/Views/thz_list.php b/app/Views/thz_list.php index cde116e0..44cecd6f 100644 --- a/app/Views/thz_list.php +++ b/app/Views/thz_list.php @@ -7,52 +7,17 @@ width: 100%; } -/* HEADER */ -thead th { - background-color: #00999E; - color: #fff !important; - border-top: 0px solid #fff !important; - border-bottom: 0px solid #fff !important; -} - /* .table thead th { vertical-align: bottom; border-bottom: 2px solid #fff; } */ -/* Rounded header corners */ -thead th:first-child { - border-top-left-radius: 15px !important; - border-bottom-left-radius: 15px !important; -} -thead th:last-child { - border-top-right-radius: 15px !important; - border-bottom-right-radius: 15px !important; -} - -/* BODY ROWS */ -tbody td { - background: #F5FFFF; /* apply bg to td not tr */ - padding: 12px; - border-top: 1px solid #eee; - border-bottom: 1px solid #eee; -} /* Add shadow + spacing row "card" effect */ tbody tr { /* box-shadow: 0 2px 5px rgba(0,0,0,0.08); */ } -/* Rounded corners for first + last cell of each row */ -tbody tr td:first-child { - border-top-left-radius: 15px !important; - border-bottom-left-radius: 15px !important; -} -tbody tr td:last-child { - border-top-right-radius: 15px !important; - border-bottom-right-radius: 15px !important; -} - /* Hover effect */ #scroll-horizontal-datatable tbody tr:hover td { background-color: #e0e0e0; @@ -123,10 +88,6 @@ tbody tr td:last-child { white-space: nowrap !important; } */ - -.text-custom-black{ - color: #000000 !important; -} .text-custom-grey{ font-size: 0.85em; color: #6c757d !important; @@ -252,7 +213,7 @@ table thead th {
| Ticket ID | Name | @@ -265,7 +226,7 @@ table thead th {Updated At |
format('d/m/Y') . " " . $cdt->format('h:i a') . ""; + $cd = date("j F Y", strtotime($row['created_at'])); + $ct = date("h:i a", strtotime($row['created_at'])); + echo $cd . " " . $ct . ""; endif; ?> |
format('d/m/Y') . " " . $udt->format('h:i a') . ""; + $ud = date("j F Y", strtotime($row['updated_at'])); + $ut = date("h:i a", strtotime($row['updated_at'])); + echo $ud . " " . $ut . ""; endif; ?> |
@@ -396,7 +359,15 @@ table thead th {
-
+
@@ -683,62 +654,66 @@ table thead th {
document.getElementById('policy_id').value = policyId || "";
}
- function hideandshowpolicy() {
- var select = document.getElementById('ticket_type').value;
- var policyContainer = document.getElementById('policy_container');
+ // function hideandshowpolicy() {
+ // var select = document.getElementById('ticket_type').value;
+ // var policyContainer = document.getElementById('policy_container');
- if (select === 'Service') {
- policyContainer.style.display = "block"; // show
+ // if (select === 'Service') {
+ // policyContainer.style.display = "block"; // show
+ // } else {
+ // policyContainer.style.display = "none"; // hide
+ // document.getElementById('policy_no').value = "";
+ // document.getElementById('policy_id').value = "";
+ // }
+ // }
+
+function hideandshowpolicy() {
+ var select = document.getElementById('ticket_type');
+ var value = select.value;
+ var policyContainer = document.getElementById('policy_container');
+
+ if (value === "0") {
+ let newType = prompt("Enter new ticket type:");
+ if (newType && newType.trim() !== "") {
+
+ var formData = new FormData(form);
+
+ $.ajax({
+ url: "= base_url('ticketType') ?>",
+ type: "POST",
+ data: formData,
+ processData: false,
+ contentType: false,
+ dataType: 'json',
+ success: function(response) {
+ if (response.status === "success") {
+
+ let option = new Option(newType, newType);
+ let addNewOption = select.querySelector('option[value="0"]');
+ select.insertBefore(option, addNewOption);
+ select.value = newType;
+ value = newType;
+ console.log(response.message);
+
+ } else { console.log(response.message); value = ""; }
+ },
+ error: function(xhr) { console.log("Error: " + xhr.statusText); value = ""; }
+ });
} else {
- policyContainer.style.display = "none"; // hide
- document.getElementById('policy_no').value = "";
- document.getElementById('policy_id').value = "";
+ select.value = "";
+ value = "";
}
}
-// function hideandshowpolicy() {
-// var select = document.getElementById('ticket_type');
-// var value = select.value;
-// var policyContainer = document.getElementById('policy_container');
+ if (value === 'Service') {
+ policyContainer.style.display = "block";
+ } else {
+ policyContainer.style.display = "none";
+ document.getElementById('policy_no').value = "";
+ document.getElementById('policy_id').value = "";
+ }
-// if (value === "0") {
-// let newType = prompt("Enter new ticket type:");
-// if (newType && newType.trim() !== "") {
-
-// $.ajax({
-// url: "= base_url('ticketType') ?>",
-// type: "POST",
-// data: { name: newType },
-// dataType: 'json',
-// success: function(response) {
-// if (response.status === "success") {
-
-// let option = new Option(newType, newType);
-// let addNewOption = select.querySelector('option[value="0"]');
-// select.insertBefore(option, addNewOption);
-// select.value = newType;
-// value = newType;
-// console.log(response.message);
-
-// } else { console.log(response.message); value = ""; }
-// },
-// error: function(xhr) { console.log("Error: " + xhr.statusText); value = ""; }
-// });
-// } else {
-// select.value = "";
-// value = "";
-// }
-// }
-
-// if (value === 'Service') {
-// policyContainer.style.display = "block";
-// } else {
-// policyContainer.style.display = "none";
-// document.getElementById('policy_no').value = "";
-// document.getElementById('policy_id').value = "";
-// }
-
-// }
+}
+
\ No newline at end of file
|---|