FIX_little changes

This commit is contained in:
venba-Inspriron-3558 2025-08-26 18:25:24 +05:30
parent f8b507ec3e
commit cb06e7799b
5 changed files with 175 additions and 15 deletions

View File

@ -659,4 +659,5 @@ $routes->post("ticketSave", "ThzController::ticketSave");
$routes->get("ticketList", "ThzController::ticketList");
$routes->post("ticketConversationSave", "ThzController::ticketConversationSave");
$routes->get("ticketConversationList", "ThzController::ticketConversationList");
$routes->post('ticketAutoFetchDetails',"ThzController::ticketAutoFetchDetails");
$routes->post('ticketAutoFetchDetails',"ThzController::ticketAutoFetchDetails");
// $routes->match(['get','post','put'], 'ticketType', 'ThzController::ticketType');

View File

@ -13,6 +13,7 @@ use App\Models\UserModel;
use App\Models\ClientPolicyModel;
use App\Models\ClientModel;
use App\Models\TicketMailTemplateModel;
// use App\Models\TicketTypesModel;
class ThzController extends BaseController
@ -28,6 +29,7 @@ class ThzController extends BaseController
protected $clientModel;
protected $ticketMailTemplateModel;
// protected $ticketTypesModel;
public function __construct()
{
@ -226,6 +228,43 @@ class ThzController extends BaseController
}
// public function ticketType()
// {
// $method = $this->request->getMethod(); // get, post
// 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);
// }
// 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;
// }
// $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);
// }
/************************************************** PRIVATE FUNCTIONS ********************************************************/

View File

@ -0,0 +1,44 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class TicketTypesModel extends Model
{
protected $table = 'ticket_types';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = ['name','created_at','updated_at','created_by','updated_by' ,'is_active'];
protected bool $allowEmptyInserts = false;
// Dates
protected $useTimestamps = false;
protected $dateFormat = 'datetime';
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
protected $deletedField = 'deleted_at';
// Validation
protected $validationRules = [];
protected $validationMessages = [];
protected $skipValidation = false;
protected $cleanValidationRules = true;
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = [];
protected $afterInsert = [];
protected $beforeUpdate = [];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
}

View File

@ -362,7 +362,7 @@ table thead th {
</div>
</div>
<div class="modal-body" style="padding: 15px !important;">
<div class="modal-body" style="padding: 12px 15px 0px 15px !important;">
<div class="form-row">
<input type="hidden" id="thz_id" name="thz_id">
<input type="hidden" id="return_type" name="return_type">
@ -396,6 +396,7 @@ table thead th {
<option value="">Select Ticket Type</option>
<option value="Sales" selected >Sales</option>
<option value="Service">Service</option>
<!-- <option value="0">+ Add New</option> -->
</select>
</div>
@ -420,31 +421,43 @@ table thead th {
<!-- // enga 5-"head" and 1-"admin" assign pannvaga dropdown-data la varakudhathu. but dropdown display aganum
// 2,3,4 dropdown data'va varannum but dropdown hide pannanum -->
<?php if(in_array(get_role_id(), [1,5]) ) { ?>
<?php if (in_array(get_role_id(), [1,5])): ?>
<div class="form-group col-md-4">
<label for="assign_to">Assign To</label>
<select class="form-control" id="assign_to" name="assign_to">
<option value="">Select Assign To</option>
<?php if(isset($assignee)) { ?>
<?php foreach ($assignee as $a) { ?>
<option value="<?= $a['id']?>"><?= $a['emp_code'] ?> - <?= $a['first_name'] ?> <?= $a['last_name'] ?></option>
<?php } ?>
<?php } ?>
<?php if (!empty($assignee)): ?>
<?php foreach ($assignee as $a): ?>
<option value="<?= esc($a['id']) ?>">
<?= esc($a['emp_code']) ?> - <?= esc($a['first_name']) ?> <?= esc($a['last_name']) ?>
</option>
<?php endforeach; ?>
<?php endif; ?>
</select>
</div>
<?php } ?>
<?php else: ?>
<input type="hidden" id="hide_assign_to" name="assign_to" value="<?= esc(get_session_userid()); ?>">
<?php endif; ?>
<div class="form-group col-md-12 app-font-family">
<!-- <div class="form-group col-md-12 app-font-family">
<label for="subject">Subject<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="subject" name="subject" placeholder="Enter Subject" required maxlength="150">
<small id="subjectCounter" class="form-text text-muted app-text-right">0/150</small>
</div> -->
<div class="form-group col-md-12 app-font-family">
<div class="d-flex justify-content-between">
<label for="subject" class="mb-1">Subject <span class="text-danger">*</span></label>
<small id="subjectCounter" class="form-text text-muted">0/150</small>
</div>
<input type="text" class="form-control" id="subject" name="subject" placeholder="Enter Subject" required maxlength="150">
</div>
<div class="form-group col-md-12 app-font-family">
<label for="message">Message<span class="text-danger">*</span></label>
<div class="d-flex justify-content-between">
<label for="message">Message<span class="text-danger">*</span></label>
<small id="messageCounter" class="form-text text-muted text-end app-text-right">0/1500</small>
</div>
<!-- <input type="text" class="form-control" id="message" name="message" placeholder="Enter Message"> -->
<textarea class="form-control" id="message" name="message" placeholder="Enter Message" rows="4" required maxlength="1500"></textarea>
<small id="messageCounter" class="form-text text-muted text-end app-text-right">0/1500</small>
<textarea class="form-control" id="message" name="message" placeholder="Enter Message" rows="3" required maxlength="1500"></textarea>
</div>
</div>
@ -495,6 +508,8 @@ table thead th {
function openTicket(){
var form = document.getElementById('ticketForm');
form.reset();
$("#client_id").select2();
$("#ticket_type").select2();
document.getElementById('thz_id').value = '';
document.getElementById('modalLabel').innerText = "New Ticket";
document.getElementById('return_type').innerText = "Web";
@ -505,6 +520,8 @@ table thead th {
function resetTicket(){
var form = document.getElementById('ticketForm');
form.reset();
$("#client_id").select2();
$("#ticket_type").select2();
}
function submitTicket() {
@ -678,6 +695,50 @@ table thead th {
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() !== "") {
// $.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 = "";
// }
// }
</script>
<script>

View File

@ -297,7 +297,7 @@ hr{
<input type="hidden" id="notes_by" name="notes_by" value="Staff">
<input type="hidden" id="created_by" name="created_by" value="<?= get_session_userid(); ?>">
<div class="notes-box">
<textarea class="form-control" id="notes" name="notes" placeholder="Write your notes here..." required></textarea>
<textarea class="form-control" id="notes" name="notes" placeholder="Write your notes here..." required maxlength="1500"></textarea>
<div class="icon-buttons">
<!-- save btn means local - internal -->
<button type="button" class="btn-icon" onclick="submitConverstionTicket('Internal')"><i class="mdi mdi-content-save"></i></button>
@ -305,6 +305,7 @@ hr{
<button type="button" class="btn-icon" onclick="submitConverstionTicket('External')"><i class="mdi mdi-email"></i></button>
</div>
</div>
<small id="messageCounter" class="form-text text-muted text-end app-text-right">0/1500</small>
</form>
</div>
@ -455,6 +456,20 @@ hr{
$("#ticket_type").select2();
$("#status").select2();
$("#assign_to").select2();
const messageInput = document.getElementById("notes");
const messageCounter = document.getElementById("messageCounter");
messageInput.addEventListener("input", function () {
const messageLength = messageInput.value.length;
messageCounter.textContent = `${messageLength}/1500`;
if (messageLength > 1500) {
toastr.error('Message cannot exceed 1500 characters', 'Warning');
messageInput.classList.add('is-invalid');
} else {
messageInput.classList.remove('is-invalid');
}
});
});