FIX_TICKET_MASTER_MAIL

This commit is contained in:
Srinivas-Saravanan 2025-02-17 15:49:37 +05:30
parent e049db83b5
commit 9568260f65
4 changed files with 120 additions and 14 deletions

View File

@ -26,6 +26,7 @@ use App\Models\InsurerModel;
use App\Models\ClientDepositModel;
use App\Models\PolicyPremium2Model;
use App\Models\AuditHistoryModel;
use App\Models\UserModel;
use App\Controllers\Jobs;
@ -66,6 +67,7 @@ class EmployeeController extends AdminController
protected $cashDepositModel;
protected $PolicyPremium2Model;
protected $auditHistory;
protected $userModel;
public function __construct()
{
@ -87,6 +89,7 @@ class EmployeeController extends AdminController
$this->cashDepositModel = new ClientDepositModel();
$this->PolicyPremium2Model = new PolicyPremium2Model();
$this->auditHistory = new AuditHistoryModel();
$this->userModel = new userModel();
}
public function list()
@ -2732,8 +2735,20 @@ class EmployeeController extends AdminController
$emp_id = $this->request->getPost('emp_id');
$data['emp_history'] = $this->auditHistory->select('field_name,old_value,new_value,created_by,created_at')->where('pk',$emp_id)->where('table_name','employees')->findAll();
$data['emp_history'] = $this->auditHistory->select('field_name,old_value,new_value,created_by,created_at')->where('pk',$emp_id)->where('table_name','employees')->orderBy('created_at', 'DESC')->findAll();
foreach ($data['emp_history'] as &$emp_history) {
$emp_history['field_name'] = $this->formatFieldName($emp_history['field_name']);
$user = $emp_history['created_by'];
if ($user != null && $user != ''){
$userData = $this->userModel->select('first_name, last_name')->where('id', $user)->where('is_active', 1)->first();
$emp_history['created_by'] = ucwords($userData['first_name'] . ' ' . $userData['last_name']);
}else{
$emp_history['created_by'] = '-';
}
}
unset($emp_history);
$emp_pol_pk = $this->employeePolicyModel->select('id')->where('employee_id',$emp_id)->first()['id'];
$data['emp_pol_history'] = $this->auditHistory->select('field_name,old_value,new_value,created_by,created_at')->where('pk',$emp_pol_pk)->where('table_name','employee_polices')->findAll();
@ -2742,4 +2757,18 @@ class EmployeeController extends AdminController
}
public function formatFieldName($unformattedString){
if (str_contains($unformattedString, '_')) {
$data = str_replace('_', ' ', $unformattedString);
}else{
$data = $unformattedString;
}
$format = ucwords($data);
return $format;
}
}

View File

@ -123,12 +123,17 @@ class TicketMasterModel extends Model
public function getTemplateDataByTicketID($ticket_id)
{
$template_data = $this
->select("ticket_mail_template.*, ticket_master.emp_mail,ticket_master.claim_status_id")
->select("ticket_mail_template.*, CASE
WHEN employees.email_corporate IS NULL OR employees.email_corporate = ''
THEN ticket_master.emp_mail
ELSE employees.email_corporate
END as emp_mail, ,ticket_master.claim_status_id")
->join('ticket_claim_status', 'ticket_master.claim_status_id = ticket_claim_status.id and ticket_claim_status.is_active = 1')
->join('ticket_mail_template', '
ticket_claim_status.trigger_type = ticket_mail_template.trigger_type
and ticket_claim_status.ticket_type = ticket_mail_template.ticket_type
and ticket_mail_template.is_active = 1')
->join('employees','employees.id = ticket_master.emp_id and employees.is_active = 1')
->where('ticket_master.id', $ticket_id)
->where('ticket_master.is_active', 1)
->where('ticket_claim_status.is_active', 1)
@ -141,6 +146,11 @@ class TicketMasterModel extends Model
{
$ticket_data = $this->select("
ticket_master.*,
CASE
WHEN employees.email_corporate IS NULL OR employees.email_corporate = ''
THEN ticket_master.emp_mail
ELSE employees.email_corporate
END as emp_mail,
user_profiles.first_name as acm,
user_profiles.mobile as acm_mobile,
@ -158,6 +168,7 @@ class TicketMasterModel extends Model
->join('tpa', 'ticket_master.tpa_id = tpa.id', 'left')
->join('ticket_notes', 'ticket_master.id = ticket_notes.ticket_id and ticket_notes.is_active = 1 and ticket_notes.is_auto_query = 1','left')
->join('user_profiles', 'ticket_master.acm_id = user_profiles.id', 'left')
->join('employees','employees.id = ticket_master.emp_id and employees.is_active = 1')
->where('ticket_master.id', $ticket_id)
->where('ticket_master.is_active', 1)
->first();

View File

@ -310,8 +310,8 @@
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="emp_history_modal_label">Employee History</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div id = "emp_history_content"></div>
</div>
</div>
@ -591,10 +591,28 @@
if (charcode >= 48 && charcode <= 57 || charcode == 46) return true;
return false;
}
function showModal() {
var myModal = new bootstrap.Modal(document.getElementById('emp_history_modal'));
myModal.show();
var modalInstance; // Store the modal instance globally
function showModal() {
var myModalEl = document.getElementById('emp_history_modal');
modalInstance = new bootstrap.Modal(myModalEl, {
backdrop: true, // Ensures the backdrop is shown
keyboard: true // Allows closing with the Escape key
});
modalInstance.show();
}
function closeModal() {
if (modalInstance) {
modalInstance.hide(); // Hide the modal and its backdrop
// Manually remove backdrop if it's still visible
setTimeout(function () {
document.querySelector('.modal-backdrop').classList.remove('show');
}, 150); // Wait for animation to finish
}
}
function get_emp_history(input, emp_id) {
$('.loader').fadeIn();
@ -671,12 +689,12 @@
});
}
function closeModal(){
var myModalEl = document.getElementById('emp_history_modal');
var modalInstance = bootstrap.Modal.getInstance(myModalEl);
if (modalInstance) {
modalInstance.hide();
}
}
// function closeModal(){
// var myModalEl = document.getElementById('emp_history_modal');
// var modalInstance = bootstrap.Modal.getInstance(myModalEl);
// if (modalInstance) {
// modalInstance.hide();
// }
// }
</script>

View File

@ -1972,4 +1972,52 @@
});
}
}
$(document).on('click', '#notification_enable_form_submit', function() {
var formData = [];
console.log($('#hr_mail_id').val());
formData.push({name:'client_id', value: $('#general_PrimaryKey').val()})
formData.push({ name: 'nhance_team_mail_ids', value: $('#nhance_team_mail_ids').val() });
formData.push({ name: 'hr_mail_id', value: $('#hr_mail_id').val() });
formData.push({ name: 'mail_domain', value: $('#mail_domain').val() });
formData.push({ name: 'reply_to', value: $('#reply_to').val() });
formData.push({ name: 'member_welcome_mail_btn', value: $('#member_welcome_mail_btn').prop('checked') });
formData.push({ name: 'member_reminder_mail_btn', value: $('#member_reminder_mail_btn').prop('checked') });
formData.push({ name: 'member_ecard_mail_btn', value: $('#member_ecard_mail_btn').prop('checked') });
formData.push({ name: 'member_review_and_summary_mail_btn', value: $('#member_review_and_summary_mail_btn').prop('checked') });
formData.push({ name: 'account_maneger_summary_mail_btn', value: $('#account_maneger_summary_mail_btn').prop('checked') });
formData.push({ name: 'client_hr_summary_mail_btn', value: $('#client_hr_summary_mail_btn').prop('checked') });
var form_action = '<?= base_url("client/notification/update_enable") ?>';
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
url: form_action,
type: "POST",
data: formData,
dataType: 'json',
success: function(res)
{
console.log(res);
if (res)
{
toastr.success('Update Successfully');
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
},
error: function (xhr, status, error)
{
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function()
{
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Wrong!', 'warning');
}, 1000);
}
});
})
</script>