MERGE_TEST_ECARD_SEND_MAIL

This commit is contained in:
Venba 2024-11-07 09:56:31 +00:00
commit 9385e1957d
15 changed files with 641 additions and 154 deletions

View File

@ -19,7 +19,7 @@ $routes->get("update_rack_rate_json", "ClientController::updateRackRateJson");
$routes->get("updatajson", "EmpDataServiceController::updatajson");
$routes->get("view", "EmployeeController::viewECard/$1");
// $routes->get("exportQCRandRFQ", "LeadsController::exportQCRandRFQ");
$routes->get("smapletest", "ClientController::smapletest");
$routes->post("add_advertise_image", "AppContentManagementController::add_advertise_image");
@ -298,10 +298,10 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->get("base_policy_for_policy_inception/(:any)", "PolicyTransactionController::getBasePolicy/$1");
$routes->get("sentTestMail/(:any)", "NotificationController::sentTestMail/$1");
$routes->get("send_manual_reminder/(:any)", "DashboardController::sendManualReminder/$1");
$routes->get("send_manual_ecard/(:any)", "DashboardController::sendManualEcard/$1");
$routes->get("get_client_policy_list_for_remainder/(:any)", "EmployeeController::get_client_policy_list_for_remainder/$1");
$routes->get("get_client_branch_data/(:any)", "ClientController::get_client_branch_data/$1");
$routes->get("getLevelContects", "LeadsController::getLevelContects");
});
$routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
@ -347,6 +347,7 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) {
$routes->get("list/(:any)", "LeadsController::getLeadDataForEdit/$1");
$routes->get("sendMail", "LeadsController::sendMailWithAttachement");
$routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1");
$routes->get("featchLeadDataAndInsertClient/(:any)", "LeadsController::featchLeadDataAndInsertClient/$1");
});
$routes->group("rfq", ["filter" => "authMVC"], function ($routes) {
@ -371,12 +372,12 @@ $routes->cli('cli/check_bounce_mail_cli', 'MasterController::testCheckBounceMail
$routes->cli('cli/app_check_list', 'MasterController::appCheckList');
$routes->cli('cli/new_gdrive_token', 'GoogleDriveController::generateNewGoogleDriveAccessToken');
//Employee login api's
$routes->post("/employeeRest/verifyEmployeeNumber", "RestAuthenticationController::verifyEmployeeWithMobileNumber");
$routes->post("/employeeRest/getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData");
$routes->post("/employeeRest/verifyMpin", "RestAuthenticationController::verifyMpin");
$routes->post("/employeeRest/checkMpin", "RestAuthenticationController::checkMpin");
//HR login api's
$routes->post("/employeeRest/verifyHrWithMobileNumber", "RestAuthenticationController::verifyHrWithMobileNumber");
$routes->post("/employeeRest/getVerifiedHrData", "RestAuthenticationController::getVerifiedHrData");
@ -386,9 +387,6 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) {
$routes->post("getId", "RestAuthenticationController::getUserIdFromToken");
});
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
$routes->post("getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData");
@ -431,17 +429,9 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
});
$routes->get("sendPushNotification", "EmployeeRestController::sendPushNotification");
$routes->post("sendEmail", "EmployeeRestController::send_email");
// Ticketing System
// Ticketing System End's

View File

@ -38,6 +38,7 @@ use App\Models\PolicyTypeModel;
use App\Models\PolicyTransactionModel;
use App\Models\PolicyTransactionStatusModel;
use App\Models\VehicleModel;
use App\Models\LeadsModel;
use App\Controllers\EmpDataServiceController;
use App\Controllers\GoogleDriveController;
@ -78,6 +79,7 @@ class ClientController extends AdminController
protected $policyTransactionModel;
protected $policyTransactionStatusModel;
protected $vehicleModel;
protected $leadsModel;
@ -113,6 +115,14 @@ class ClientController extends AdminController
$this->policyTransactionModel = new PolicyTransactionModel();
$this->policyTransactionStatusModel = new PolicyTransactionStatusModel();
$this->vehicleModel = new VehicleModel();
$this->leadsModel = new LeadsModel();
}
public function smapletest(){
$headers = ['S.No','EMP ID','EMP NAME','DOB','GENDER','RELATIONSHIP','SUM INSURED','Date of Leaving','Policy End Date','No Of Days','Premium','Pro Rata Premium','GST','Total','Claim Status','ENDORSEMENT_ID'];
$filePath = generateExcelWithHeader($headers);
echo "Excel file created at: $filePath";
}
public function testingForReviewMail($client_id = 77, $emp_code = 'MGL-004', $mail_active = 0) //this function for only tsesting some logics not use for business logic
@ -238,6 +248,7 @@ class ClientController extends AdminController
$headerData['page_name'] = 'Client List';
$data['clientList'] = $this->clientModel->getCreatedByUserName();
$data['client_rm'] = $this->clientRMModel->getAllClientRM();
$data['lead_data'] = $this->leadsModel->getLeadForInsertClientList();
// dd($data);
@ -1705,15 +1716,6 @@ class ClientController extends AdminController
}
public function editUploadVehicleFile() {}
public function listVehicleFiles() {}
public function deleteVehicleFiles() {}
public function getKycDocsById($id = null)
{

View File

@ -20,6 +20,7 @@ use App\Models\ClientPolicyModel;
use App\Models\NotificationModel;
use App\Models\EmployeePolicyModel;
use App\Controllers\PendingActionsContrller;
use App\Controllers\EmpDataServiceController;
class DashboardController extends AdminController
{
@ -544,6 +545,35 @@ class DashboardController extends AdminController
}
}
public function sendManualEcard($client_id, $client_branch_id, $policy_id)
{
$this->myLogger->logme('error', "sendManualEcard called with client_id: {$client_id}, client_branch_id: {$client_branch_id}, policy id : {$policy_id}");
$notification = $this->notificationModel->where('client_id', $client_id)->where('template_name', 'member_ecard_mail')->first();
// print_r(($notification)); die;
if($notification && $notification['enabled'] == 0 && $notification['mail_content'] == '')
{
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No template found','message2' => 'Failed' ], 200);
}
$emp_data = $this->employeePolicyModel->getEmployeePolicyForEcard($policy_id);
if(count($emp_data) == 0)
{
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No employees found','message2' => 'Failed' ], 200);
}
$ids = array_column($emp_data, 'id');
// print_r(($ids)); die;
// print_r($this->clientPolicyModel->getLastQuery()); die;
// $this->myLogger->logme('error', "Policy details fetched: " . json_encode($client_policy_data));
Jobs::addJob(['job_name' => 'sendMailForDownloadingECard', 'payload' => $ids]);
// $empEmpDataServiceController = new EmpDataServiceController();
// $empEmpDataServiceController->sendMailForDownloadingECard($ids);
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Mail Queued'], 200);
}
public function data_construct_for_bds($data){
$groupedData = [

View File

@ -168,19 +168,23 @@ class EmpDataServiceController extends BaseController
$cash_balance['balance'] = $balance['opening_bal'];
}
// Calculate the total amount from the objects
$totals = 0;
foreach ($objects as $item) {
$totals = $totals + $item->total;
}
$totals = round($totals, 2);
if (!empty($cash_balance)) {
if ((int) $cash_balance['balance'] < (int) $totals) {
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.');
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]);
return 0;
// Calculate the total amount from the objects
$totals = 0;
foreach ($objects as $item) {
$totals = $totals + $item->total;
}
$totals = round($totals, 2);
if($export_data['insurer_or_tpa'] == 'insurer') //check CD amt related issue for only insurer, not tpa
{
if (!empty($cash_balance)) {
if ((int) $cash_balance['balance'] < (int) $totals) {
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.');
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]);
return 0;
}
}
}
@ -408,7 +412,7 @@ class EmpDataServiceController extends BaseController
],
[
'column_index' => 18,
'column_name' => 'PR0 RATA PREMIUM',
'column_name' => 'PRO RATA PREMIUM',
'db_column_name' => 'pro_rata_premium'
],
[
@ -921,18 +925,23 @@ class EmpDataServiceController extends BaseController
$cash_balance['balance'] = $balance['opening_bal'];
}
// Calculate the total amount from the objects
$totals = 0;
foreach ($inceptionData as $item) {
$totals = $totals + $item->total;
}
$totals = round($totals, 2);
if (!empty($cash_balance)) {
if ((int) $cash_balance['balance'] < (int) $totals) {
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.');
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]);
return 0;
// Calculate the total amount from the objects
$totals = 0;
foreach ($inceptionData as $item) {
$totals = $totals + $item->total;
}
$totals = round($totals, 2);
if($export_data['insurer_or_tpa'] != 'tpa')// check overal emp premium amt with cd balance only for insurer export, not tpa export
{
if (!empty($cash_balance)) {
if ((int) $cash_balance['balance'] < (int) $totals) {
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.');
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]);
return 0;
}
}
}
}

View File

@ -445,28 +445,25 @@ class EmployeeController extends AdminController
'actions' => $actions,
'file_name' => $file_name,
];
if ($actions == 'export') {
if ($event_type == 'inception' || $event_type == 'addition' || $event_type == 'dependent_addition' || $event_type == 'missed_inception') {
if ($event_type == 'inception' || $event_type == 'addition' || $event_type == 'dependent_addition' || $event_type == 'missed_inception' || ($event_type == 'MultipleEvents' && $insurer_or_tpa == 'tpa')) {
$return = $empDataServiceController->generateExcelForAdditionandInception($batch_data);
if ($return === 0) {
session()->setFlashdata('error', "Insufficient deposit amount.");
return redirect()->to(base_url('employee/upload'));
if ($return === 0) {
}else if($return === 5){
session()->setFlashdata('error', "Insufficient deposit amount.");
return redirect()->to(base_url('employee/upload'));
session()->setFlashdata('error', "The policy does not have a CD account number.");
return redirect()->to(base_url('employee/upload'));
}
else if($return === 6){
}else if($return === 5){
session()->setFlashdata('error', "The policy does not have a CD account number.");
return redirect()->to(base_url('employee/upload'));
}
else if($return === 6){
session()->setFlashdata('error', "The Insurer does not have an Excel export template format.");
return redirect()->to(base_url('employee/upload'));
}
session()->setFlashdata('error', "The Insurer does not have an Excel export template format.");
return redirect()->to(base_url('employee/upload'));
}
if (!$return) {
@ -1111,6 +1108,7 @@ class EmployeeController extends AdminController
$htmlContent = $tmplt_data;
$placeholders = [
'{CLIENT_NAME}' => $value['client_name'],
'{TPA_ID}' => $value['tpa_id'],
'{NAME}' => $value['name'],
'{UHID}' => $value['uhid'],
@ -1417,7 +1415,11 @@ class EmployeeController extends AdminController
$excelErrorData['excel_header'] = $excel_data[0];
unset($excel_data[0]);
if($event_type == 'inception' || $event_type == 'deletion'){
// if($event_type == 'inception' || $event_type == 'deletion'){
// array_pop($excel_data);
// }
if($event_type == 'deletion'){
array_pop($excel_data);
}

View File

@ -49,7 +49,7 @@ class Jobs extends AdminController
}
$uuid = generate_uuid();
$jobid = $jobModel->insert(['name' => $payload['job_name'],'uuid' => $uuid,'payload' => json_encode($payload['payload'])]);
$jobid = $jobModel->insert(['name' => $payload['job_name'],'uuid' => $uuid,'payload' => json_encode($payload['payload']), 'status' => isset($payload['status']) ? $payload['status'] : 'queued']);
// echo $jobid;
$myLogger->logme('error','new job {jobid} added to queue',['jobid' => $jobid]);
return ['id' => $jobid,'uuid' => $uuid,'job_name' => $payload['job_name']];

View File

@ -215,6 +215,7 @@ class LeadsController extends BaseController
'branch_code' => $data['branch_code'],
'contact_person_name' => $data['contact_person_name'],
'contact_person_mobile' => $data['contact_person_mobile'],
'contact_person_email' => $data['contact_person_email'],
'client_id' => $data['client_id'] ?? 0,
'client_branch_id' => $data['client_branch_id'] ?? 0,
'source_policy_id' => $data['source_policy_id'] ?? 0,
@ -394,8 +395,10 @@ class LeadsController extends BaseController
return $this->respond(['status' => false, 'id' => $result, 'message' => "Failed to create QCR", 'data' =>$data], 200);
}
//-----RFQ and QCR EXPORT------------------------------------------------------------------------------------------------
//export main route function
public function exportQCRandRFQ($lead_id, $type, $export_type){
@ -654,7 +657,8 @@ class LeadsController extends BaseController
}
public function getLevelContects(){
public function getLevelContects()
{
$data = $this->levelContactModel->getContectForRFQ();
@ -667,4 +671,134 @@ class LeadsController extends BaseController
}
//----- Featch Lead data and insert Client -------------------------------------------------------------------------------------------
public function featchLeadDataAndInsertClient($lead_id)
{
$data = $this->leadsModel->where('leads.id', $lead_id)->where('leads.is_active', 1)->first();
if (!$data) {
return $this->respond(['status' => false, 'message' => 'Failed to create Client', 'data' => null], 200);
}
$result = $this->createClientWithLeadData($data);
if ($result) {
return $this->respond(['status' => true, 'message' => 'New Client created successfully', 'client_id' => $result, 'data' => $data], 200);
}
return $this->respond(['status' => false, 'message' => 'Failed to create client', 'data' => $data], 200);
}
public function createClientWithLeadData($data)
{
$client_data = $this->prepareClientData($data);
$client_id = $this->clientModel->insert($client_data);
if ($client_id) {
$this->createClientBranchAndContactWithLeadData($data, $client_id);
}
return $client_id;
}
private function prepareClientData($data)
{
return [
'client_type' => $data['client_type'],
'entity_type_id' => $data['entity_type_id'],
'client_code' => $data['client_code'],
'client_name' => $data['client_name'],
'short_name' => $data['client_short_name'],
'pan' => $data['pan'],
];
}
public function createClientBranchAndContactWithLeadData($data, $client_id)
{
$branch_data = $this->prepareClientBranchData($data, $client_id);
$branch_id = $this->clientBranchModel->insert($branch_data);
if ($branch_id) {
$contact_data = $this->prepareContactData($data, $branch_id);
$this->levelContactModel->insert($contact_data);
$this->createClientPolicyWithLeadData($data, $client_id, $branch_id);
}
return $branch_id;
}
private function prepareClientBranchData($data, $client_id)
{
$default_unit = trim(($data['client_short_name'] ?? '') . '-' . ($data['branch_code'] ?? ''), '-');
return [
'client_id' => $client_id,
'branch_name' => $data['branch_name'],
'branch_code' => $data['branch_code'],
'gst' => $data['gst'],
'units' => json_encode([$default_unit]),
];
}
private function prepareContactData($data, $branch_id)
{
return [
'name' => $data['contact_person_name'],
'mobile' => $data['contact_person_mobile'],
'email' => $data['contact_person_email'],
'contact_type' => 'client',
'ref_id' => $branch_id,
];
}
public function createClientPolicyWithLeadData($data, $client_id, $branch_id)
{
$client_policy_data = $this->prepareClientPolicyData($data, $client_id, $branch_id);
return $this->clientPolicyModel->insert($client_policy_data);
}
private function prepareClientPolicyData($data, $client_id, $branch_id)
{
$client_policy_data = [
'client_id' => $client_id,
'client_branch_id' => $branch_id,
'policy_type_id' => $data['policy_type_id'],
'insurer_id' => $data['insurer_id'],
'insurer_branch_id' => $data['insurer_branch_id'],
'tpa_id' => $data['tpa_id'],
'tpa_branch_id' => $data['tpa_branch_id'],
'policy_start_date' => $data['policy_start_date'],
'policy_end_date' => $data['policy_end_date'],
'policy_status' => 1,
];
$policy_type_id = $data['policy_type_id'];
if (in_array($policy_type_id, [1, 2, 6, 7])) {
$client_policy_data['is_addon'] = 1; // Base Policy
} elseif (in_array($policy_type_id, [4, 5])) {
$client_policy_data['is_addon'] = 2; // SI TOPUP
} elseif ($policy_type_id == 3) {
// if ($base_policy) {
// $data['is_addon'] = 3; // Dependent Addon
// } else {
$data['is_addon'] = 1;
// }
}
return $client_policy_data;
}
private function preparePolicyTermsFromRFQ($data)
{
}
}

View File

@ -972,3 +972,39 @@ if(!function_exists('query_construct_second_stage')){
}
}
if (!function_exists('generateExcelWithHeader')) {
/**
* Generate an Excel file with the specified headers
*
* @param array $header The header row for the Excel file
* @param string $filename The name of the Excel file to be created
* @return string Path to the generated Excel file
*/
function generateExcelWithHeader(array $header, string $filename = 'InceptionHeader.xlsx')
{
// Create a new Spreadsheet
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
// Set header row
$column = 'A';
foreach ($header as $headerText) {
$sheet->setCellValue($column . '1', $headerText);
$column++;
}
// // Style the header row (optional)
// $sheet->getStyle('A1:' . $column . '1')->getFont()->setBold(true);
// $sheet->getStyle('A1:' . $column . '1')->getAlignment()->setHorizontal('center');
// Define the file path
$filePath = WRITEPATH . 'uploads/' . $filename; // WRITEPATH is typically for writable directories
// Save the file
$writer = new Xlsx($spreadsheet);
$writer->save($filePath);
return $filePath;
}
}

View File

@ -157,6 +157,27 @@ class EmployeePolicyModel extends Model
return $result->findAll();
}
public function getEmployeePolicyForEcard($policy_id = 0)
{
$result = $this->select([
'employee_polices.id'
])
->join('employees emp', 'employee_polices.employee_id = emp.id AND emp.relationship = "Self" ');
if ($policy_id !=0 && !empty($policy_id)) {
$result->where('employee_polices.client_policy_id', $policy_id);
}
// Always check these conditions
$result->where('employee_polices.is_active', 1)
->where('employee_polices.status', 'active')
->where('employee_polices.tpa_id is not null')
->where('emp.relationship','Self');
return $result->findAll();
// $result->findAll();
// print_r($this->db->getLastQuery());die();
}
//for emp onboard do not change
public function checkExistingEmpPolicy($arr)
{
@ -845,7 +866,7 @@ class EmployeePolicyModel extends Model
e.doj,
e.band,
TIMESTAMPDIFF(YEAR, e.dob, CURDATE()) AS emp_age,
(SELECT name FROM employees WHERE relationship = "Self" and emp_code = ' . $this->db->escape($emp_code) . ' and client_id = '.$client_id.') AS self,
(SELECT name FROM employees WHERE relationship = "Self" and emp_code = ' . $this->db->escape($emp_code) . ' and client_id = '.$client_id.' LIMIT 1) AS self,
ep.tpa_id,
@ -910,7 +931,7 @@ class EmployeePolicyModel extends Model
e.doj,
e.band,
TIMESTAMPDIFF(YEAR, e.dob, CURDATE()) AS emp_age,
(SELECT name FROM employees WHERE relationship = "Self" and emp_code = ' . $this->db->escape($emp_code) . ' and client_id = '.$client_id.') AS self,
(SELECT name FROM employees WHERE relationship = "Self" and emp_code = ' . $this->db->escape($emp_code) . ' and client_id = '.$client_id.' LIMIT 1) AS self,
ep.tpa_id,

View File

@ -24,6 +24,7 @@ class LeadsModel extends Model
'branch_code',
'contact_person_name',
'contact_person_mobile',
'contact_person_email',
'client_id',
'client_branch_id',
'source_policy_id',
@ -85,7 +86,8 @@ class LeadsModel extends Model
return $data;
}
public function getLeadDataForLising(){
public function getLeadDataForLising()
{
return $this->select('
leads.*,
@ -116,6 +118,14 @@ class LeadsModel extends Model
->findAll();
}
public function getLeadForInsertClientList()
{
return $this
->where('leads.is_active', 1)
->where('leads.status', 'won')
->findAll();
}
}

View File

@ -26,8 +26,11 @@ table.dataTable thead th {
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">Client List</h4>
</div>
<div class="col-6" style="text-align: right; position: relative;top: 56px;">
<a href="<?= base_url("client/create"); ?>" type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" data-toggle="" data-placement="top" title="Add" data-trigger="hover">ADD</a>
<div class="col-2" style="text-align: right; position: relative;top: 56px; left: 303px;">
<a class="btn btn-primary waves-effect waves-light" onclick="showModal()">Add From Lead</a>
</div>
<div class="col-1" style="text-align: right; position: relative;top: 56px; left: 294px;">
<a href="<?= base_url("client/create"); ?>" type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" data-toggle="" data-placement="top" title="Add" data-trigger="hover">Add</a>
</div>
</div>
<table class="table table-sm table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="0"
@ -81,13 +84,47 @@ table.dataTable thead th {
<div id="append_client_info"></div>
<!-- Center modal content -->
<div class="modal fade" id="lead_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="false">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myCenterModalLabel">Lead List</h4>
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<div class="form-group col-md-12">
<label for="lead_id"> Lead List <span class="text-danger">*</span></label>
<select class="form-control" id="lead_id" name="lead_id" required>
<option value="">Select Lead</option>
<?php if(isset($lead_data)) { ?>
<?php foreach ($lead_data as $value) { ?>
<option value="<?= $value['id']?>"><?= $value['client_name'] ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
<button type="submit" class="btn btn-primary" onclick="featchClient()">Featch Client</button>
</div>
</div>
</div><!-- /.modal-content -->
</div>
</div><!-- /.modal -->
<script>
$(document).ready(function(){
$('#lead_id').select2();
})
$(document).ready(function()
{
$('#tickets-table').DataTable({
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" +
dom: "<'row'<'col-sm-0'f><'col-sm-7 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
buttons: [{
@ -214,8 +251,47 @@ $(document).on('click', '.client_info_close', function() {
$('#client_list').show();
});
function showModal(){
var myModal = new bootstrap.Modal(document.getElementById('lead_modal'));
myModal.show();
}
function featchClient(){
let lead_id = $('#lead_id').val();
console.log('lead_id : ', lead_id)
let url = '<?= base_url('leads/featchLeadDataAndInsertClient/') ?>' + lead_id
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
url: url,
type: "GET",
dataType: 'json',
success: function (res) {
console.log(res);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if(res.status == true){
let client_url = '<?= base_url('client/list/') ?>'+res.client_id;
toastr.success(res.message, 'SUCCESS')
window.location.href = client_url
}else{
toastr.success(res.message, 'WARNING')
}
$('.close').click()
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
$('.close').click()
}
});
}
</script>

View File

@ -70,8 +70,13 @@ table.dataTable tbody td {
</div>
</div>
<div class="row">
<div class="col-12" style="text-align: right;">
<div class="row justify-content-end">
<div class="col-auto">
<!-- <div id="categoryFilter_12"> -->
<a href="#" class="btn btn-primary waves-effect waves-light" onclick="sendManualEcard(this)">Send Ecard</a>
<!-- </div> -->
</div>
<div class="col-auto">
<a href="<?= base_url("employee/list"); ?>"
class="btn btn-primary waves-effect waves-light" id="get-emp-list"
onclick="fetchEmpolyeeList(event);">Submit</a>
@ -371,4 +376,69 @@ document.getElementById('toggleIcon').addEventListener('click', function() {
icon.classList.toggle('mdi-chevron-up');
});
function sendManualEcard(input)
{
console.log('sendManualEcard function called');
var client_id = $('#clients').val()
var client_branch_id = $('#branch_id').val()
var policy_id = $('#policies').val()
console.log('input', input);
console.log('client_id', client_id);
console.log('client_branch_id', client_branch_id);
if(client_id == 0 || client_branch_id == 0 || policy_id == 0)
{
Swal.fire({
title: "warning!",
text: 'Please select the Client, Client Branch and Policy.',
icon: "warning"
});
return false
}
Swal.fire({
title: "Do you want to send Ecard Mail?",
showDenyButton: true,
showCancelButton: false,
confirmButtonText: "Yes,Send",
denyButtonText: "Don't Send"
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
url: '<?= base_url("util/send_manual_ecard/") ?>' + client_id + '/' + client_branch_id+'/'+policy_id,
type: "GET",
dataType: 'json',
success: function(res) {
console.log('send_manual_ecard', res)
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if(res.status == false){
toastr.info(res.message, 'INFO');
}else{
toastr.success(res.message, 'SUCCESS');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
});
// Swal.fire("Saved!", "", "success");
}
});
}
</script>

View File

@ -66,7 +66,7 @@
</div>
<div class="col-1">
<div id="categoryFilter_11">
<a href="#" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="fetchEmpolyeeList(event);">Search</a>
<a href="#" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="fetchEmpolyeeList(event);"><i class="fa fa-search" aria-hidden="true"></i></a>
</div>
</div>
<div class="col-2">
@ -74,17 +74,22 @@
<a href="#" class="btn btn-primary waves-effect waves-light" onclick="sendManualReminder(this)">Send Reminder</a>
</div>
</div>
<div class="col-2">
<div class="col-1">
<div id="categoryFilter_13">
<a class="btn btn-primary waves-effect waves-light" onclick="uploadEnrollmentFile(this)" >Upload File</a>
<a class="btn btn-primary waves-effect waves-light" onclick="uploadEnrollmentFile(this)" ><i class="fas fa-file-upload" ></i></a>
</div>
</div>
<div class="col-1 text-right view-status-btn" style="position: relative;bottom: 7px;">
<!-- </div> -->
<!-- <div class="row" style="margin-bottom: 44px;"> -->
<div class="col-1 text-right view-status-btn" style="position: relative;bottom: 7px;">
<button type="button" class="btn btn-link visa_status_button" onclick="toggleContent()" style="color: #000;">
Status <i id="toggleIcon" class="fas fa-minus"></i>
</button>
</div>
</div>
</div>
<div class="card-body status-option" id="statusContent" style="padding: 1.5rem !important;background-color: darkgrey;">
@ -713,31 +718,44 @@
return false
}
$.ajax({
url: '<?= base_url("util/send_manual_reminder/") ?>' + client_id + '/' + client_branch_id,
type: "GET",
dataType: 'json',
success: function(res) {
Swal.fire({
title: "Do you want to send reminder mail?",
showDenyButton: true,
showCancelButton: false,
confirmButtonText: "Yes,Send",
denyButtonText: "Don't Send"
}).then((result) => {
console.log('send_manual_reminder', res)
if (result.isConfirmed) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
$.ajax({
url: '<?= base_url("util/send_manual_reminder/") ?>' + client_id + '/' + client_branch_id,
type: "GET",
dataType: 'json',
success: function(res) {
if(res.status == false){
toastr.info(res.message, 'INFO');
}else{
toastr.success(res.message, 'SUCCESS');
console.log('send_manual_reminder', res)
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if(res.status == false){
toastr.info(res.message, 'INFO');
}else{
toastr.success(res.message, 'SUCCESS');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
});
});
// Swal.fire("Saved!", "", "success");
}
});
}
</script>

View File

@ -193,24 +193,30 @@
placeholder="Enter Branch Name" required>
</div>
<div class="form-group col-md-2">
<div class="form-group col-md-3">
<label for="client_branch">Branch Code<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="branch_code" name="branch_code"
placeholder="Enter Branch Code" required>
</div>
<div class="form-group col-md-2">
<div class="form-group col-md-3">
<label for="client_branch">Contact Person Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="contact_person_name" name="contact_person_name"
placeholder="Enter Contact Name" required>
</div>
<div class="form-group col-md-2">
<label for="client_branch">Contact Person Mobile<span class="text-danger">*</span></label>
<div class="form-group col-md-3">
<label for="contact_person_mobile">Contact Person Mobile<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="contact_person_mobile" name="contact_person_mobile"
placeholder="Enter Contact Mobile" required>
</div>
<div class="form-group col-md-3">
<label for="contact_person_email">Contact Person Email<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="contact_person_email" name="contact_person_email"
placeholder="Enter Contact Email" required>
</div>
</div>
<!-- policy row -->
@ -374,10 +380,9 @@ function getLeadsDataForEdit(input) {
$('#gst').val(res.data.gst);
$('#branch_name').val(res.data.branch_name);
$('#branch_code').val(res.data.branch_code);
$('#contact_person_name').val(res.data
.contact_person_name);
$('#contact_person_mobile').val(res.data
.contact_person_mobile);
$('#contact_person_name').val(res.data.contact_person_name);
$('#contact_person_mobile').val(res.data.contact_person_mobile);
$('#contact_person_email').val(res.data.contact_person_email);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
@ -461,6 +466,7 @@ function getBranchData(input) {
$('#branch_code').val(res.data.branch_code);
$('#contact_person_name').val(res.contact.name);
$('#contact_person_mobile').val(res.contact.mobile);
$('#contact_person_email').val(res.contact.email);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
@ -473,6 +479,7 @@ function getBranchData(input) {
$('#branch_code').val('');
$('#contact_person_name').val('');
$('#contact_person_mobile').val('');
$('#contact_person_email').val('');
console.log(res.message, 'warning');
}
@ -512,6 +519,7 @@ function getPolicyData(input) {
$('#branch_code').val(res.data.branch_code);
$('#contact_person_name').val(res.contact.name);
$('#contact_person_mobile').val(res.contact.mobile);
$('#contact_person_email').val(res.contact.email);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
@ -524,6 +532,7 @@ function getPolicyData(input) {
$('#branch_code').val('');
$('#contact_person_name').val('');
$('#contact_person_mobile').val('');
$('#contact_person_email').val('');
console.log(res.message, 'warning');
}
@ -827,6 +836,7 @@ $('#lead_type').change(function() {
$('#branch_code').val('');
$('#contact_person_name').val('');
$('#contact_person_mobile').val('');
$('#contact_person_email').val('');
} else {
@ -842,6 +852,7 @@ $('#lead_type').change(function() {
$('#branch_code').val('');
$('#contact_person_name').val('');
$('#contact_person_mobile').val('');
$('#contact_person_email').val('');
$('#client_type').val('');
$('#client_name').val('');

View File

@ -179,6 +179,17 @@ body {
color:red;
}
.select2-selection__choice {
background-color: #0a8794 !important;
color: white !important;
font-weight: bold;
}
.select2-selection__choice__remove {
color: white !important;
margin-right: 5px;
}
</style>
@ -297,13 +308,13 @@ body {
<label for="otherMembers">Other Members:</label>
<select class="form-control" id="family_other_members" onchange="setEldersCount(this)">
<option value="0">Select</option>
<option data-value="1" value="oneparent">oneparent</option>
<option data-value="2" value="twoparent">twoparent</option>
<option data-value="1" value="onepil">onepil</option>
<option data-value="2" value="twopil">twopil</option>
<option data-value="2" value="either_par_pil">Either Parents or PILs</option>
<option data-value="2" value="any_two">Any Two Eldres(cross)</option>
<option data-value="4" value="all">All</option>
<option data-value="1" value="oneparent">Only one parent (Either Father / Mother)</option>
<option data-value="2" value="twoparent">Only two parents (Father+Mother)</option>
<option data-value="1" value="onepil">Only one parent in law (Either MIL / FIL)</option>
<option data-value="2" value="twopil">Only two parents in law (FIL + MIL)</option>
<option data-value="2" value="either_par_pil">Parents or PIL (Any two of Father, Mother, MIl, FIL)</option>
<option data-value="2" value="any_two">Either Parents or PIL (Parents or Parents In Law)</option>
<option data-value="4" value="all">Parents + PIL (Father + Mother + MIL + FIL)</option>
</select><br>
<label for="eldersCount">Elders Count:</label>
<input class="form-control" type="text" id="family_elders_count" readonly>
@ -374,6 +385,7 @@ $(document).ready(function() {
$('#submitMail').attr('data-url', mail_url);
console.log('RFQ_or_QCR:', RFQ_or_QCR);
});
$(document).ready(function() {
@ -430,13 +442,14 @@ const closeDialogBtn = document.getElementById('closeDialogBtn');
$('.remove-icon').on('click', function() {
$('#familyFloaterDialog').css('display', 'none');
});
var currentThrdottedMenu = '';
var proposal_colum_count = 1;
var over_all_column_data = {
"Proposal 1": {
"qcr": 0,
"stc": 0,
"qcr": 1,
"stc": 1,
'insurers': []
}
};
@ -468,7 +481,7 @@ function showFamilyFloaterDialogBox(target) {
let hiddenInput = target.querySelector('input[type="hidden"]');
// alert(hiddenInput);
let inputValue = hiddenInput ? hiddenInput.value : null;
console.log('hidden input value');
// console.log('hidden input value');
console.log(inputValue);
if (inputValue !== null && inputValue !== '') {
//get stored familiy composition json if any in hidden input and display it
@ -731,12 +744,23 @@ function addSuggestionsToTable() {
// Function to move add row button to last row
function moveAddRowButton() {
console.log('table', rfqTable)
const lastRow = rfqTable.rows[rfqTable.rows.length - 1];
const actionCell = lastRow.cells[lastRow.cells.length - 1];
actionCell.innerHTML =
'<input type="checkbox" name="qcr" checked> QCR <input type="checkbox" name="client" checked> Client <button class="btn btn-danger btn-sm removeRow"></button> <button id="addRow" class="btn btn-primary btn-sm">+</button>';
document.getElementById('addRow').addEventListener('click', addRow);
const actionCell = lastRow.querySelector('.action');
if (actionCell && !actionCell.querySelector('#addRow')) {
actionCell.innerHTML += ' <button id="addRow" class="btn btn-primary btn-sm">+</button>';
document.getElementById('addRow').addEventListener('click', addRow);
}
// const actionCell = lastRow.cells[lastRow.cells.length - 1];
// actionCell.innerHTML =
// '<input type="checkbox" name="qcr"> QCR <input type="checkbox" name="client"> Client <button class="btn btn-danger btn-sm removeRow"></button> <button id="addRow" class="btn btn-primary btn-sm">+</button>';
// document.getElementById('addRow').addEventListener('click', addRow);
// const lastRow = rows[rows.length - 1];
}
// Event listener to handle row removal
@ -807,8 +831,8 @@ addQuoteButton.addEventListener('click', function() {
//add new proposal in gobal array
var new_proposal_array = {}
over_all_column_data[new_proposal_name] = {
"ocr": 0,
"stc": 0,
"qcr": 1,
"stc": 1,
'insurers': []
};
console.log(over_all_column_data);
@ -1014,6 +1038,7 @@ function hideSuggestionBox() {
}
function addRow(e) {
let columnCount = rfqTable.rows[1].cells.length;
const newRow = rfqTable.insertRow();
@ -1254,8 +1279,8 @@ function addInsurer(event) {
//add insurer into over all column data
pushInsurerInArray(proposal_name, {
'ins_name': (insurerName.split('-')[0]),
'qcr': 0,
'stc': 0,
'qcr': 1,
'stc': 1,
'display_name': insurerName
});
}
@ -1532,6 +1557,9 @@ function checkExistingInsurer(proposal_name, insurer_name) {
}
function pushInsurerInArray(proposal_name, insurer_arr) {
console.log('pushInsurerInArray function called');
proposal_name = proposal_name.trim();
if (over_all_column_data[proposal_name]) {
over_all_column_data[proposal_name].insurers.push(insurer_arr);
@ -1646,6 +1674,7 @@ function changeState(event) {
console.log(type);
if (['qcrProposal', 'sendClientProposal'].includes(type)) {
console.log('Proposal');
const closestTh = event.target.closest('th');
let proposal_name = closestTh.innerText.split('⋮')[0].trim();
@ -2174,15 +2203,15 @@ function appendInput(data) {
const url = '<?= base_url('leads/list') ?>?lead_id=' +lead_id;
html = `
<div class="form-group col-md-8">
<div class="form-group col-md-12">
<label for="contact_mail">Client Contact Mail</label>
<input value="${data.contact_person_email || ''}" type="text" id="contact_mail" class="form-control" placeholder="Contact Mail">
<input value="${data.contact_person_email || ''}" type="text" id="contact_mail" class="form-control" placeholder="Contact Mail" readonly>
</div>
`;
if (!data.contact_person_email) {
html += `
<div class="form-group col-md-8">
<div class="form-group col-md-12">
<a href="${url}">Click here to add mail</a>
</div>
`;
@ -2216,7 +2245,13 @@ function appendInput(data) {
// Initialize select2 for the dropdown if insurerContact is present
if ($('#insurerContact').length) {
$('#insurerContact').select2();
$('#insurerContact').select2({
placeholder: 'Select an insurer',
});
$("textarea.select2-search__field").attr('rows', '1');
$("textarea.select2-search__field").css('resize', 'none');
}
}
@ -2274,6 +2309,7 @@ function ajaxRequest(url){
});
}
//--------------------------------------------------------------------------------------------------------------------------------------------
function tableToJson() {
@ -2371,7 +2407,7 @@ function tableToJson() {
if (input) {
content = input.value;
console.log('hidden input value', content);
// console.log('hidden input value', content);
} else {
content = cells[dataIndex].innerText;
}
@ -2443,10 +2479,12 @@ function tableToJson() {
});
localStorage.setItem('data', d);
console.log({
headers,
data
});
jsonToTable(JSON.parse(d));
}
@ -2605,7 +2643,7 @@ function jsonToTable(json) {
});
});
console.log('proposel_color_count', proposel_color_count);
// console.log('proposel_color_count', proposel_color_count);
thead.appendChild(parentHeaderRow);
thead.appendChild(subHeaderRow);
@ -2712,6 +2750,8 @@ function jsonToTable(json) {
$(document).ready(function () {
$('#submitData').on('click', async function () {
console.log(over_all_column_data);
try {
// $('.loader').fadeIn();
@ -2769,8 +2809,11 @@ function jsonToTable(json) {
});
});
$(document).ready(function () {
$(document).ready(function () {
$('#submitQCRData').on('click', async function () {
console.log(over_all_column_data);
try {
$('.loader').fadeIn();
@ -2829,7 +2872,6 @@ function jsonToTable(json) {
async function tableToJsonForFormSubmit() {
return new Promise((resolve) => {
const headers = [];
const data = [];
const table = document.getElementById('rfqTable');
@ -2870,7 +2912,9 @@ function jsonToTable(json) {
header.subHeaders.forEach(subHeader => {
const cell = cells[dataIndex];
let content = cells[dataIndex]?.innerText || '';
const inputType = suggestions[rowId]['type'];
// Ensure suggestions[rowId] exists
const inputType = suggestions[rowId]?.type;
// Handle 'text' input types
if (inputType === "text") {
@ -2883,11 +2927,9 @@ function jsonToTable(json) {
};
} else {
const input = cell.querySelector('input');
// console.log('input cell', input)
if (input) {
content = input.value;
console.log('hidden input value', content);
// console.log('hidden input value', content);
} else {
content = cells[dataIndex].innerText;
}
@ -2945,10 +2987,13 @@ function jsonToTable(json) {
const first_json = JSON.parse(JSON.stringify(json)); // Deep copy
console.log("Original JSON:", json);
let rowIndexArray = [];
let rowIndexArray2 = [];
// Column-wise Check: Remove headers and relevant data if qcr == 0
Object.entries(json.proposal_data.over_all_column_data).forEach(([proposalKey, proposalData], index) => {
console.log(index);
// console.log('over_all_column_data index', index);
if (proposalData.qcr == 0 || proposalData.qcr == false) {
@ -2956,42 +3001,75 @@ function jsonToTable(json) {
const headerIndex = first_json.table_data.headers.findIndex(header => header.parentHeader === proposalKey);
if (headerIndex !== -1) first_json.table_data.headers.splice(headerIndex, 1);
// Remove data entries with matching parentth
Object.values(first_json.table_data.data).forEach(dataEntry => {
const dataArray = dataEntry.data;
if (dataArray) {
const dataIndex = dataArray.findIndex(dataItem => dataItem.parentth === proposalKey);
if (dataIndex !== -1) dataArray.splice(dataIndex, 1);
}
first_json.table_data.data.forEach(item => {
item.data = item.data.filter(entry => entry.parentth !== proposalKey);
});
// Remove data entries with matching parentth
// Object.values(first_json.table_data.data).forEach(dataEntry => {
// const dataArray = dataEntry.data;
// if (dataArray) {
// const dataIndex = dataArray.findIndex(dataItem => dataItem.parentth === proposalKey);
// if (dataIndex !== -1) dataArray.splice(dataIndex, 1);
// }
// });
// Remove proposalKey from over_all_column_data
// console.log()
// Object.entries(first_json.proposal_data.over_all_column_data).splice(index, 1);
const updatedData = Object.keys(first_json.proposal_data.over_all_column_data)
.filter(key => key !== proposalKey)
.reduce((acc, key) => {
acc[key] = first_json.proposal_data.over_all_column_data[key];
return acc;
}, {});
// Assign the updated data back if needed
first_json.proposal_data.over_all_column_data = updatedData;
}
// Insurer Check: Remove subHeaders and relevant data for insurers with qcr == 0
proposalData.insurers.forEach((insurer, insurerIndex) => {
if (insurer.qcr === 0) {
// console.log('insurer', insurer)
if (insurer.qcr === 0 || insurer.qcr == false) {
console.log(insurer.qcr)
first_json.table_data.headers.forEach(header => {
const subHeaderIndex = header.subHeaders.findIndex(sub => sub === insurer.display_name);
if (subHeaderIndex !== -1) header.subHeaders.splice(subHeaderIndex, 1);
});
Object.values(first_json.table_data.data).forEach(dataEntry => {
const dataArray = dataEntry.data;
if (dataArray) {
const dataIndex = dataArray.findIndex(dataItem => dataItem.subth === insurer.display_name);
if (dataIndex !== -1) dataArray.splice(dataIndex, 1);
}
first_json.table_data.data.forEach(item => {
item.data = item.data.filter(entry => entry.subth !== insurer.display_name);
});
// Object.values(first_json.table_data.data).forEach(dataEntry => {
// const dataArray = dataEntry.data;
// if (dataArray) {
// const dataIndex = dataArray.findIndex(dataItem => dataItem.subth === insurer.display_name);
// if (dataIndex !== -1) dataArray.splice(dataIndex, 1);
// }
// });
// Remove insurer from proposal's insurers array
console.log('insurerIndex', insurerIndex)
first_json.proposal_data.over_all_column_data[proposalKey].insurers.splice(insurerIndex, 1);
}
});
});
// rowIndexArray.sort((a, b) => b - a);
// rowIndexArray2.forEach((index) => {
// rowIndexArray.forEach((index2) => {
// first_json.table_data.data[index].data.splice(index2, 1);
// })
// });
// Row-wise Check: Remove rows if qcr == 0 for actions
Object.entries(first_json.table_data.data).forEach(([rowKey, rowData]) => {
const actionData = rowData.data.find(data => data.parentth === "Action" && data.input_value.qcr === 0);