Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
a6ab231c08
@ -20,7 +20,7 @@ $routes->get("updatajson", "EmpDataServiceController::updatajson");
|
||||
$routes->get("view", "EmployeeController::viewECard/$1");
|
||||
// $routes->get("exportQCRandRFQ", "LeadsController::exportQCRandRFQ");
|
||||
$routes->get("smapletest", "ClientController::smapletest");
|
||||
|
||||
$routes->get("testMailAttachments", "ClientController::testMailAttachments");
|
||||
|
||||
$routes->post("add_advertise_image", "AppContentManagementController::add_advertise_image");
|
||||
$routes->get("add_image_index", "AppContentManagementController::add_image_index");
|
||||
@ -74,7 +74,9 @@ $routes->group("/client", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->group("notification", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->post("create", "NotificationController::createNotification");
|
||||
$routes->post("update_enable", "NotificationController::update_enable");
|
||||
$routes->post("add_attachment", "NotificationController::insertAttachmentsForMailTemplates");
|
||||
$routes->get("getMailTemplateData/(:any)/(:any)", "NotificationController::getMailTemplateData/$1/$2");
|
||||
$routes->get("removeAttachment/(:any)", "NotificationController::removeAttachmentsForMailTemplates/$1");
|
||||
});
|
||||
|
||||
$routes->group("general", ["filter" => "authMVC"], function ($routes) {
|
||||
@ -302,6 +304,11 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$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->get("get_emp_master_data_for_update/(:any)", "EmployeeController::get_emp_master_data_for_update/$1");
|
||||
$routes->get("send_mail_for_individual_employee_ecard/(:any)", "EmployeeController::send_mail_for_individual_employee_ecard/$1");
|
||||
$routes->post("update_emp_data", "EmployeeController::update_emp_data");
|
||||
$routes->get("checkDeletionGetDataFunction", "EmployeeController::checkDeletionGetDataFunction");
|
||||
|
||||
});
|
||||
|
||||
$routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
|
||||
|
||||
@ -118,11 +118,28 @@ class ClientController extends AdminController
|
||||
$this->leadsModel = new LeadsModel();
|
||||
}
|
||||
|
||||
public function smapletest(){
|
||||
|
||||
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";
|
||||
echo "Excel file created at: $filePath";
|
||||
}
|
||||
|
||||
public function testMailAttachments($email = 'venkateshraman786@gmail.com')
|
||||
{
|
||||
$message = '<style>body{font-family:Arial,sans-serif;color:#333;line-height:1.6;margin:0;padding:0}.email-container{width:100%;max-width:600px;margin:0 auto;padding:20px;border:1px solid #e0e0e0;background-color:#f9f9f9}.header{background-color:#4a90e2;color:#fff;padding:15px;text-align:center}.header h1{margin:0;font-size:24px}.content{padding:20px;background-color:#fff}.content h2{color:#4a90e2;font-size:20px;margin-top:0}.content p{margin:10px 0}.details-table{width:100%;border-collapse:collapse;margin-top:20px}.details-table td,.details-table th{border:1px solid #ddd;padding:10px;text-align:left}.details-table th{background-color:#f2f2f2}.footer{margin-top:20px;font-size:12px;color:#777;text-align:center}.attachment-note{margin-top:20px;padding:10px;background-color:#f7f7f7;border-left:4px solid #4a90e2;font-style:italic}</style><div class=email-container><div class=header><h1>Request for Quotation (RFQ)</h1></div><div class=content><h2>Dear {{RECIPIENT_NAME}},</h2><p>We are reaching out to request a quotation for the following insurance coverage. Please review the details below and provide your quote at your earliest convenience.<h2>RFQ Details</h2><table class=details-table><tr><th>Client name<td>{{CLIENT_NAME}}<tr><th>Coverage Type<td>{{POLICY_LONG_NAME}}<tr><th>Policy Start Date<td>{{POLICY_START_DATE}}<tr><th>Policy Duration<td>{{DURATION}}</table><div class=attachment-note>Please note: Additional terms and details are included in the attachment for your reference.</div><p>Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.<p>Best regards,<p><strong>Nhance India Pvt Ltd</strong><br></div><div class=footer><p>© Nhance India Pvt Ltd. All rights reserved.</div></div>';
|
||||
|
||||
$attachments = [
|
||||
["filePath" => ROOTPATH."public/sample_excel/sample_addition.xls","fileName" => "sample_addition.xls"],
|
||||
["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.xls"],
|
||||
["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"]
|
||||
];
|
||||
|
||||
$res = MailHelper::send_email(['mail' => $email, 'subject' => 'Mail Via Attachment Testing URL', 'message' => $message,'attachments' => $attachments]);
|
||||
|
||||
print_rr($res);
|
||||
echo '------------------------------------------------------------------------------------------';
|
||||
print_rr($attachments);
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@ -640,11 +640,14 @@ class EmpDataServiceController extends BaseController
|
||||
// echo '<pre>';
|
||||
// print_r($ids); die;
|
||||
|
||||
if (!empty($cash_balance)) {
|
||||
if ((int) $cash_balance['balance'] < (int) $rounded_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;
|
||||
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) $rounded_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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -708,7 +711,6 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
|
||||
$excel_data_info = generate_insurer_based_excel($excel_header_columns, $objects);
|
||||
|
||||
// Generate Excel file
|
||||
@ -1667,6 +1669,7 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
$file_id = $params['file_id'];
|
||||
$file = $this->batchFileModel->find($file_id);
|
||||
|
||||
if (!$file) {
|
||||
|
||||
$data = [
|
||||
@ -1697,7 +1700,6 @@ class EmpDataServiceController extends BaseController
|
||||
->where('insurer_id', $insurer_id['insurer_id'])
|
||||
->first();
|
||||
|
||||
|
||||
$get_policy_type = $this->clientPolicyModel
|
||||
->select('policy_type.policy_type, policies.policy_type_id as policy_type_id')
|
||||
->join('policies', 'policies.id = client_policy.policy_id')
|
||||
@ -1780,12 +1782,11 @@ class EmpDataServiceController extends BaseController
|
||||
'amount' => $totals,
|
||||
]);
|
||||
|
||||
|
||||
$this->myLogger->logme('error', 'Inception Update TPA and UHID -- employee count : {data}', ['data' => $emp_count]);
|
||||
$this->myLogger->logme('error', 'Inception Update TPA and UHID -- batch file status : {data}', ['data' => $status_val]);
|
||||
$this->myLogger->logme('error', 'Inception Update TPA and UHID -- total amount for cash deposite : {data}', ['data' => $totals]);
|
||||
|
||||
|
||||
//update CD transaction entry if only insurer
|
||||
if ($file['insurer_or_tpa'] == 'insurer') {
|
||||
|
||||
$this->myLogger->logme('error', 'Inception Update TPA and UHID -- set cashDepositCalculationForInception and sendMailForDownloadingECard in JOB QUEUE');
|
||||
@ -1817,15 +1818,20 @@ class EmpDataServiceController extends BaseController
|
||||
'user_id' => $user_id,
|
||||
]]);
|
||||
|
||||
// $this->cashDepositCalculationForInception($depositeData);
|
||||
// $this->sendMailForDownloadingECard($emp_policy_ids);
|
||||
|
||||
}
|
||||
|
||||
//send ecard mail if the event is tpa only
|
||||
if ($file['insurer_or_tpa'] == 'tpa') {
|
||||
|
||||
if ($get_policy_type['policy_type_id'] != 1) {
|
||||
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'sendMailForDownloadingECard', 'payload' => $emp_policy_ids]);
|
||||
}
|
||||
|
||||
// $this->cashDepositCalculationForInception($depositeData);
|
||||
// $this->sendMailForDownloadingECard($emp_policy_ids);
|
||||
|
||||
}
|
||||
|
||||
$file_data = $this->getDataByFileId($file_id, 'success');
|
||||
@ -2854,27 +2860,29 @@ class EmpDataServiceController extends BaseController
|
||||
$this->myLogger->logme('error', 'SI Enhancement Update Endorsement ID -- Employee count : {data}', ['data' => $emp_count]);
|
||||
$this->myLogger->logme('error', 'SI Enhancement Update Endorsement ID -- Batch File status : {data}', ['data' => $status_val]);
|
||||
|
||||
//call the cash deposite function
|
||||
if ($file['insurer_or_tpa'] == 'insurer') {
|
||||
|
||||
$policy_name = $this->getPolicyNameUsingClientPolicyId($client_policy_id);
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'cashDepositCalculationForSIEnhancement','payload' => [
|
||||
'employeeIds' => $insertedIds,
|
||||
'client_id' => $client_id,
|
||||
'client_policy_id' => $client_policy_id,
|
||||
'client_branch_id' => $client_branch_id,
|
||||
'cd_ac_no' => $CD_Account_Number['cd_ac_no'] ?? null,
|
||||
'endorsement_no' => $endorsement_id ?? null,
|
||||
'count' => $emp_count,
|
||||
'event_name' => $file['event_type'],
|
||||
'policy_name' => $policy_name['policy_name'],
|
||||
'user_id' => $user_id,
|
||||
]]);
|
||||
|
||||
}
|
||||
|
||||
$file_data = $this->getDataByFileId($file_id, 'success');
|
||||
$this->setPullNotification($file_data);
|
||||
|
||||
//call the cash deposite function
|
||||
|
||||
$policy_name = $this->getPolicyNameUsingClientPolicyId($client_policy_id);
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'cashDepositCalculationForSIEnhancement','payload' => [
|
||||
'employeeIds' => $insertedIds,
|
||||
'client_id' => $client_id,
|
||||
'client_policy_id' => $client_policy_id,
|
||||
'client_branch_id' => $client_branch_id,
|
||||
'cd_ac_no' => $CD_Account_Number['cd_ac_no'] ?? null,
|
||||
'endorsement_no' => $endorsement_id ?? null,
|
||||
'count' => $emp_count,
|
||||
'event_name' => $file['event_type'],
|
||||
'policy_name' => $policy_name['policy_name'],
|
||||
'user_id' => $user_id,
|
||||
]]);
|
||||
|
||||
//import file to upload Google Drive
|
||||
// if(excelFileGDriveUpload($file_id, 'batch_file')){
|
||||
// $this->myLogger->logme('error', 'SI Enhancement File Update Google Drive File Upload -- File Uploaded Successfully');
|
||||
@ -3381,28 +3389,27 @@ class EmpDataServiceController extends BaseController
|
||||
$this->myLogger->logme('error', 'Deletion Update Endorsement ID -- Employee count : {data}', ['data' => $emp_count]);
|
||||
$this->myLogger->logme('error', 'Deletion Update Endorsement ID -- Batch File status : {data}', ['data' => $status_val]);
|
||||
|
||||
//call the cash deposite function
|
||||
if ($file['insurer_or_tpa'] == 'insurer') {
|
||||
$policy_name = $this->getPolicyNameUsingClientPolicyId($client_policy_id);
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'cashDepositCalculationForDeletion', 'payload' => [
|
||||
'employeeIds' => $employee_policy_table_primaryKey,
|
||||
'client_id' => $client_id,
|
||||
'client_policy_id' => $client_policy_id,
|
||||
'client_branch_id' => $client_branch_id,
|
||||
'cd_ac_no' => $CD_Account_Number['cd_ac_no'] ?? null,
|
||||
'endorsement_no' => $endorsement_id ?? null,
|
||||
'count' => $emp_count,
|
||||
'event_name' => $file['event_type'],
|
||||
'policy_name' => $policy_name['policy_name'],
|
||||
'user_id' => $user_id,
|
||||
]]);
|
||||
}
|
||||
|
||||
$file_data = $this->getDataByFileId($file_id, 'success');
|
||||
$this->setPullNotification($file_data);
|
||||
|
||||
//call the cash deposite function
|
||||
|
||||
$policy_name = $this->getPolicyNameUsingClientPolicyId($client_policy_id);
|
||||
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'cashDepositCalculationForDeletion', 'payload' => [
|
||||
'employeeIds' => $employee_policy_table_primaryKey,
|
||||
'client_id' => $client_id,
|
||||
'client_policy_id' => $client_policy_id,
|
||||
'client_branch_id' => $client_branch_id,
|
||||
'cd_ac_no' => $CD_Account_Number['cd_ac_no'] ?? null,
|
||||
'endorsement_no' => $endorsement_id ?? null,
|
||||
'count' => $emp_count,
|
||||
'event_name' => $file['event_type'],
|
||||
'policy_name' => $policy_name['policy_name'],
|
||||
'user_id' => $user_id,
|
||||
]]);
|
||||
|
||||
//import file to upload Google Drive
|
||||
// if(excelFileGDriveUpload($file_id, 'batch_file')){
|
||||
// $this->myLogger->logme('error', 'Deletion File Update Google Drive File Upload -- File Uploaded Successfully');
|
||||
@ -4224,7 +4231,7 @@ class EmpDataServiceController extends BaseController
|
||||
return true;
|
||||
}
|
||||
|
||||
public function sendMailForDownloadingECard(array $ids)
|
||||
public function sendMailForDownloadingECard(array $ids, $single_mail = null)
|
||||
{
|
||||
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - function called');
|
||||
@ -4269,7 +4276,6 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - Send Bulk Mail function inside if condition ',);
|
||||
|
||||
|
||||
$rand_string = $get_emp_email_and_other_details['rand_string'];
|
||||
$tpa_id = $get_emp_email_and_other_details['tpa_id'];
|
||||
|
||||
@ -4284,14 +4290,21 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
if (isset($get_emp_email_and_other_details['email_corporate']) && !empty($get_emp_email_and_other_details['email_corporate']) && $get_emp_email_and_other_details['relationship'] == 'Self') {
|
||||
$wholeData[] = sendMailNotification::sendMailNotification('member_ecard_mail', $params);
|
||||
|
||||
// print_r($wholeData);die;
|
||||
$count++;
|
||||
}
|
||||
|
||||
$counts++;
|
||||
|
||||
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - counts : {data}', ['data' => $counts]);
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - count : {data}', ['data' => $count]);
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - ids count : {data}', ['data' => count($ids)]);
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - whole count : {data}', ['data' => count($wholeData)]);
|
||||
|
||||
if ($count == 20 || $counts == count($ids) - 1) {
|
||||
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - ids count : {data}', ['data' => count($ids)]);
|
||||
|
||||
if(count($wholeData) > 0){
|
||||
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - create a job to bulk mail',);
|
||||
@ -4302,6 +4315,27 @@ class EmpDataServiceController extends BaseController
|
||||
$count = 0;
|
||||
|
||||
}
|
||||
}else{
|
||||
|
||||
// for view member individual employee send self and self family ecard
|
||||
if($single_mail){
|
||||
|
||||
if(count($wholeData) > 0){
|
||||
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - create a job for single mail to bulk mail function',);
|
||||
|
||||
$mail_send_return = MailHelper::send_email($wholeData[0]);
|
||||
$this->myLogger->logme("info", $mail_send_return);
|
||||
return $mail_send_return;
|
||||
|
||||
// $job_details = new Jobs();
|
||||
// $r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $wholeData]);
|
||||
// $wholeData = [];
|
||||
// $count = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4322,6 +4356,7 @@ class EmpDataServiceController extends BaseController
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - the client notification setup not created or not enabled the E-Card Notification');
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$this->myLogger->logme('error', 'sendMailForDownloadingECard - employee_policy_ids are empty');
|
||||
|
||||
@ -87,22 +87,33 @@ class EmployeeController extends AdminController
|
||||
{
|
||||
// $model = new UserModel();
|
||||
$data = [];
|
||||
$data['status'] = ['draft' => 'Draft', 'active' => 'Active', 'inactive' => 'In-Active', 'pending' => 'Pending'];
|
||||
$data['status'] = ['draft' => 'Draft', 'enrolled' => 'Enrolled', 'active' => 'Active', 'inactive' => 'In-Active', 'pending' => 'Pending'];
|
||||
|
||||
if (count($this->request->getGet())) {
|
||||
$filterData = $this->request->getGet();
|
||||
|
||||
// Convert the status field to an array if it exists in the request data
|
||||
if (isset($filterData['status']) && !empty($filterData['status'])) {
|
||||
$filterData['status'] = explode(",", $filterData['status']);
|
||||
}else{
|
||||
$filterData['status'] = [];
|
||||
}
|
||||
|
||||
// Fetch employees with the modified $filterData array
|
||||
$data['employees'] = $this->employeePolicyModel->getEmployeePolicy(
|
||||
client_id: $filterData['client_id'],
|
||||
policy_id: $filterData['policy_id'],
|
||||
branch_id: $filterData['branch_id'],
|
||||
emp_code : $filterData['emp_code'],
|
||||
emp_name : $filterData['emp_name'],
|
||||
status : $filterData['status'],
|
||||
client_id: $filterData['client_id'] ?? null,
|
||||
policy_id: $filterData['policy_id'] ?? null,
|
||||
branch_id: $filterData['branch_id'] ?? null,
|
||||
emp_code : $filterData['emp_code'] ?? null,
|
||||
emp_name : $filterData['emp_name'] ?? null,
|
||||
status : $filterData['status'] ?? [],
|
||||
);
|
||||
// dd($this->employeePolicyModel->getLastQuery());
|
||||
|
||||
|
||||
// Set getData in $data array with the processed $filterData
|
||||
$data['getData'] = $filterData;
|
||||
}
|
||||
|
||||
|
||||
// dd($this->employeeModel->getLastQuery());
|
||||
// dd( $data['getData']);
|
||||
|
||||
// dd($this->request->getGet());
|
||||
@ -1700,4 +1711,79 @@ class EmployeeController extends AdminController
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $policies], 200);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-------- Edit individual employee and View & Send E-card -----------------------------------------------------------------------------------------
|
||||
|
||||
public function get_emp_master_data_for_update($id)
|
||||
{
|
||||
$employee_data = $this->employeeModel->select("employees.*, DATE_FORMAT(dob, '%d/%m/%Y') AS formatted_dob,")->where('id', $id)->first();
|
||||
|
||||
if ($employee_data) {
|
||||
return $this->respond(['status' => true,'code' => 200,'data' => $employee_data,], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'No data found.'], 404);
|
||||
}
|
||||
}
|
||||
|
||||
public function update_emp_data()
|
||||
{
|
||||
$data = $this->request->getPost();
|
||||
|
||||
$data['dob'] = date('Y-m-d', strtotime($data['dob']));
|
||||
|
||||
// Fetch current employee data
|
||||
$employee_data = $this->employeeModel->where('id', $data['employee_primary_id'])->first();
|
||||
|
||||
if ($employee_data['relationship'] == 'Self') {
|
||||
|
||||
if ($employee_data['gender'] != $data['gender']) {
|
||||
|
||||
$spouse_gender = ($data['gender'] == 'M') ? 'F' : 'M';
|
||||
$this->employeeModel
|
||||
->where('emp_code', $employee_data['emp_code'])
|
||||
->where('relationship', 'Spouse')
|
||||
->set(['gender' => $spouse_gender])
|
||||
->update();
|
||||
}
|
||||
}
|
||||
|
||||
// Update the employee data
|
||||
$result = $this->employeeModel->where('id', $data['employee_primary_id'])->set($data)->update();
|
||||
|
||||
if ($result) {
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $data, 'message' => 'Employee updated successfully'], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to update employee.'], 404);
|
||||
}
|
||||
}
|
||||
|
||||
public function send_mail_for_individual_employee_ecard($id)
|
||||
{
|
||||
$ids[] = $id;
|
||||
$empDataServiceController = new EmpDataServiceController();
|
||||
$result = $empDataServiceController->sendMailForDownloadingECard($ids, 1);
|
||||
|
||||
if ($result) {
|
||||
return $this->respond(['status' => true,'code' => 200,'message' => 'Mail sent successfully', 'result' => $result,], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to sent mail.'], 404);
|
||||
}
|
||||
}
|
||||
|
||||
public function checkDeletionGetDataFunction()
|
||||
{
|
||||
$batch_data = [
|
||||
'client_id' => 77,
|
||||
'client_policy_id' => 203,
|
||||
'client_branch_id' => 53,
|
||||
'insurer_or_tpa' => 'tpa',
|
||||
];
|
||||
|
||||
$result = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($batch_data);
|
||||
|
||||
print_rr($result); die;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -500,26 +500,31 @@ class LeadsController extends BaseController
|
||||
|
||||
$rowNumber++;
|
||||
}
|
||||
|
||||
|
||||
// Leave two blank rows
|
||||
$rowNumber += 2;
|
||||
|
||||
|
||||
// Set headers and subheaders starting from current row
|
||||
$headers = $data['table_data']['headers'];
|
||||
$subHeaderRow = $rowNumber + 1;
|
||||
$columnLetter = 'A';
|
||||
|
||||
// Add headers in the first row and subheaders in the second row
|
||||
|
||||
// Set column width and apply word wrap to headers and subheaders
|
||||
foreach ($headers as $header) {
|
||||
if ($header['parentHeader'] === 'Item Key' || $header['parentHeader'] == 'Action') {
|
||||
continue; // Skip "Item Key" and "Action" columns
|
||||
}
|
||||
|
||||
if($header['parentHeader'] === 'Sno'){
|
||||
|
||||
if ($header['parentHeader'] === 'Sno') {
|
||||
$header['parentHeader'] = 'S.No.';
|
||||
}
|
||||
|
||||
|
||||
// Set the header cell value
|
||||
$sheet->setCellValue("{$columnLetter}{$rowNumber}", $header['parentHeader']);
|
||||
|
||||
// Set column width for header
|
||||
$sheet->getColumnDimension($columnLetter)->setWidth(20); // Adjust width as needed
|
||||
$sheet->getStyle("{$columnLetter}{$rowNumber}")->getAlignment()->setWrapText(true);
|
||||
|
||||
// Apply bold style to the header
|
||||
$sheet->getStyle("{$columnLetter}{$rowNumber}")->applyFromArray([
|
||||
@ -528,9 +533,13 @@ class LeadsController extends BaseController
|
||||
],
|
||||
]);
|
||||
|
||||
// Add subheaders in the second row
|
||||
foreach ($header['subHeaders'] as $subHeader) {
|
||||
$sheet->setCellValue("{$columnLetter}{$subHeaderRow}", $subHeader);
|
||||
|
||||
// Enable word wrap for subheaders
|
||||
$sheet->getStyle("{$columnLetter}{$subHeaderRow}")->getAlignment()->setWrapText(true);
|
||||
|
||||
// Apply bold style to the subheader
|
||||
$sheet->getStyle("{$columnLetter}{$subHeaderRow}")->applyFromArray([
|
||||
'font' => [
|
||||
@ -541,11 +550,11 @@ class LeadsController extends BaseController
|
||||
$columnLetter++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Move to next row for data entries
|
||||
$rowNumber = $subHeaderRow + 1;
|
||||
|
||||
// Add data rows
|
||||
|
||||
// Add data rows and enable word wrap for data cells
|
||||
foreach ($data['table_data']['data'] as $dataRow) {
|
||||
$columnLetter = 'A';
|
||||
foreach ($dataRow['data'] as $cellData) {
|
||||
@ -553,11 +562,20 @@ class LeadsController extends BaseController
|
||||
continue; // Skip "Item Key" data
|
||||
}
|
||||
$sheet->setCellValue("{$columnLetter}{$rowNumber}", $cellData['value']);
|
||||
|
||||
// Enable word wrap for data cells
|
||||
$sheet->getStyle("{$columnLetter}{$rowNumber}")->getAlignment()->setWrapText(true);
|
||||
|
||||
$columnLetter++;
|
||||
}
|
||||
$rowNumber++;
|
||||
}
|
||||
|
||||
|
||||
// Auto-size all columns after data is entered
|
||||
foreach ($sheet->getColumnIterator() as $column) {
|
||||
$sheet->getColumnDimension($column->getColumnIndex())->setAutoSize(true);
|
||||
}
|
||||
|
||||
// Set filename based on type
|
||||
$string = ($type == 2) ? 'QCR' : 'RFQ';
|
||||
$filename = $string . '_' . $rfq_data['client_short_name'] . '_' . $rfq_data['policy_type'] . '_' . date('Ymdhis') . '.xlsx';
|
||||
@ -586,7 +604,8 @@ class LeadsController extends BaseController
|
||||
$recipient_type = $params['recipient_type'];//insurer or client
|
||||
$recipient_mail = $params['recipient_mail'];// - only primary key of contacts
|
||||
$recipient_mail = json_decode($params['recipient_mail'], true);;// - only primary key of contacts
|
||||
$cc = 'velz1990@gmail.com,vitvelz@gmail.com';
|
||||
// $cc = 'velz1990@gmail.com,vitvelz@gmail.com';
|
||||
$cc = "";
|
||||
|
||||
$result_data = [];
|
||||
// dd($recipient_mail);
|
||||
|
||||
@ -1611,18 +1611,26 @@ class MasterController extends AdminController
|
||||
// $gmailapi = \Config\Services::gmailapi();
|
||||
$message = '<style>body{font-family:Arial,sans-serif;color:#333;line-height:1.6;margin:0;padding:0}.email-container{width:100%;max-width:600px;margin:0 auto;padding:20px;border:1px solid #e0e0e0;background-color:#f9f9f9}.header{background-color:#4a90e2;color:#fff;padding:15px;text-align:center}.header h1{margin:0;font-size:24px}.content{padding:20px;background-color:#fff}.content h2{color:#4a90e2;font-size:20px;margin-top:0}.content p{margin:10px 0}.details-table{width:100%;border-collapse:collapse;margin-top:20px}.details-table td,.details-table th{border:1px solid #ddd;padding:10px;text-align:left}.details-table th{background-color:#f2f2f2}.footer{margin-top:20px;font-size:12px;color:#777;text-align:center}.attachment-note{margin-top:20px;padding:10px;background-color:#f7f7f7;border-left:4px solid #4a90e2;font-style:italic}</style><div class=email-container><div class=header><h1>Request for Quotation (RFQ)</h1></div><div class=content><h2>Dear {{RECIPIENT_NAME}},</h2><p>We are reaching out to request a quotation for the following insurance coverage. Please review the details below and provide your quote at your earliest convenience.<h2>RFQ Details</h2><table class=details-table><tr><th>Client name<td>{{CLIENT_NAME}}<tr><th>Coverage Type<td>{{POLICY_LONG_NAME}}<tr><th>Policy Start Date<td>{{POLICY_START_DATE}}<tr><th>Policy Duration<td>{{DURATION}}</table><div class=attachment-note>Please note: Additional terms and details are included in the attachment for your reference.</div><p>Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.<p>Best regards,<p><strong>Nhance India Pvt Ltd</strong><br></div><div class=footer><p>© Nhance India Pvt Ltd. All rights reserved.</div></div>';
|
||||
|
||||
// $attachments = [
|
||||
// ["filePath" => WRITEPATH."uploads/excel/sample/correction.xls","fileName" => "correction.xls"],
|
||||
// ["filePath" => WRITEPATH."uploads/excel/sample/deletion.xls","fileName" => "deletion.xls"],
|
||||
// ["filePath" => "C:\\Users\\Venba\\Desktop\\IQ.pdf","fileName" => "Questions.pdf"],
|
||||
// ["filePath" => "C:\\Users\\Venba\\Desktop\\config_age.png","fileName" => "config_age.png"]
|
||||
// ];
|
||||
|
||||
$attachments = [
|
||||
["filePath" => WRITEPATH."uploads/excel/sample/correction.xls","fileName" => "correction.xls"],
|
||||
["filePath" => WRITEPATH."uploads/excel/sample/deletion.xls","fileName" => "deletion.xls"],
|
||||
["filePath" => "C:\\Users\\Venba\\Desktop\\IQ.pdf","fileName" => "Questions.pdf"],
|
||||
["filePath" => "C:\\Users\\Venba\\Desktop\\config_age.png","fileName" => "config_age.png"]
|
||||
["filePath" => ROOTPATH."public/sample_excel/sample_addition.xls","fileName" => "sample_addition.xls"],
|
||||
["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.xls"],
|
||||
["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"]
|
||||
];
|
||||
|
||||
|
||||
$email_id = CLI::getOption('to') ? CLI::getOption('to') : $email_id;
|
||||
$res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => $message,'attachments' => $attachments]);
|
||||
print_r($res);
|
||||
|
||||
}
|
||||
|
||||
public function testCheckBounceMails()
|
||||
{
|
||||
$gmailapi = \Config\Services::gmailapi();
|
||||
@ -1661,7 +1669,9 @@ class MasterController extends AdminController
|
||||
'uploads' => ROOTPATH . 'public/uploads',
|
||||
'add_image_upload' => ROOTPATH . 'public/uploads/add_image_upload/',//adverdisement images for enrollment app
|
||||
'logo' => ROOTPATH . 'public/uploads/logo/',
|
||||
'template_bg' => ROOTPATH . 'public/uploads/template_bg/'
|
||||
'template_bg' => ROOTPATH . 'public/uploads/template_bg/',
|
||||
'attachments' => WRITEPATH . 'uploads/attachments/',
|
||||
|
||||
];
|
||||
|
||||
foreach ($folders as $folderName => $folderPath) {
|
||||
|
||||
@ -16,6 +16,7 @@ use App\Models\NotificationModel;
|
||||
use App\Models\ClientModel;
|
||||
use App\Models\EmployeeModel;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\MailAttachmentModel;
|
||||
|
||||
use App\Helpers\sendMailNotification;
|
||||
use App\Helpers\MailHelper;
|
||||
@ -26,12 +27,14 @@ class NotificationController extends AdminController
|
||||
protected $myLogger;
|
||||
protected $notificationModel;
|
||||
protected $clientModel;
|
||||
protected $MailAttachmentModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->myLogger = \Config\Services::mylogger();
|
||||
$this->notificationModel = new NotificationModel();
|
||||
$this->clientModel = new ClientModel();
|
||||
$this->MailAttachmentModel = new MailAttachmentModel();
|
||||
}
|
||||
|
||||
// This is for Template Name Camel Case to Snake Case for store in DB
|
||||
@ -52,16 +55,21 @@ class NotificationController extends AdminController
|
||||
$notificationModel = new NotificationModel();
|
||||
|
||||
$find_notification = $notificationModel->where('client_id',$form_data['client_id'])->where('template_name',$form_data['template_name'])->first();
|
||||
|
||||
if ($find_notification) {
|
||||
|
||||
$id = $find_notification['id'];
|
||||
$form_data['updated_by'] = get_session_userid();
|
||||
$notificationModel->update($id,$form_data);
|
||||
$complete = "Update";
|
||||
|
||||
}else{
|
||||
|
||||
$form_data['created_by'] = get_session_userid();
|
||||
$notificationModel->insert($form_data);
|
||||
$complete = "Inserted";
|
||||
}
|
||||
|
||||
return json_encode($complete);
|
||||
|
||||
}
|
||||
@ -111,8 +119,11 @@ class NotificationController extends AdminController
|
||||
public function getMailTemplateData($template_name,$client_id)
|
||||
{
|
||||
$notificationModel = new NotificationModel();
|
||||
|
||||
$value = $notificationModel->where('client_id',$client_id)->where('template_name',$template_name)->first();
|
||||
if($value){
|
||||
$value['data'] = $this->MailAttachmentModel->where('notification_id', $value['id'])->where('is_active', 1)->findAll();
|
||||
}
|
||||
// return $this->respond(['status' => true, 'code' => 200, '' => 'Attachment deleted successfully'], 200);
|
||||
|
||||
return json_encode($value);
|
||||
}
|
||||
@ -198,4 +209,74 @@ class NotificationController extends AdminController
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function insertAttachmentsForMailTemplates()
|
||||
{
|
||||
$form_data = $this->request->getPost();
|
||||
|
||||
// Check if client_id and template_name are provided
|
||||
if (empty($form_data['client_id']) || empty($form_data['template_name'])) {
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => 'Client ID and template name are required.'], 400);
|
||||
}
|
||||
|
||||
// Attempt to find the notification
|
||||
$find_notification = $this->notificationModel->where('client_id', $form_data['client_id'])
|
||||
->where('template_name', $form_data['template_name'])
|
||||
->first();
|
||||
|
||||
if (!$find_notification) {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Notification data not found.'], 404);
|
||||
}
|
||||
|
||||
// Define upload path and attempt file upload
|
||||
$uploadFilePath = WRITEPATH . 'uploads/attachments';
|
||||
$uploadedFile = $this->request->getFile('file');
|
||||
$fileName = file_Upload($uploadedFile, $uploadFilePath); // Assume file_Upload handles file saving
|
||||
|
||||
if ($fileName) {
|
||||
// Prepare data for insertion
|
||||
$data = [
|
||||
'notification_id' => $find_notification['id'],
|
||||
'file_name' => $fileName,
|
||||
'file_path' => 'uploads/attachments/' . $fileName,
|
||||
];
|
||||
|
||||
|
||||
// Insert file attachment record
|
||||
if ($this->MailAttachmentModel->insert($data)) {
|
||||
// Retrieve active attachments to return in response
|
||||
$attachment_data = $this->MailAttachmentModel->where('is_active', 1)->findAll();
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'code' => 200,
|
||||
'data' => $attachment_data,
|
||||
'message' => 'File uploaded successfully'
|
||||
], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 500, 'message' => 'Failed to save file attachment data.'], 500);
|
||||
}
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => 'File upload failed.'], 400);
|
||||
}
|
||||
}
|
||||
|
||||
public function removeAttachmentsForMailTemplates($id, $client_id, $template_name)
|
||||
{
|
||||
$attachment_data_for_unlink_file = $this->MailAttachmentModel->where('id', $id)->first();
|
||||
$file_path = WRITEPATH . $attachment_data_for_unlink_file['file_path'];
|
||||
|
||||
if ($this->MailAttachmentModel->where('id', $id)->delete()) {
|
||||
|
||||
unlink($file_path);
|
||||
|
||||
$find_notification = $this->notificationModel->where('client_id', $client_id)->where('template_name', $template_name)->first();
|
||||
$attachmentDatas = $this->MailAttachmentModel->where('notification_id', $find_notification['id'])->where('is_active', 1)->findAll();
|
||||
|
||||
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Attachment deleted successfully', 'data' => $attachmentDatas], 200);
|
||||
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'The Client has active policy'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -10,6 +10,7 @@ use App\Models\UserModel;
|
||||
use App\Models\EmployeeModel;
|
||||
use App\Models\PolicyPremium1Model;
|
||||
use App\Models\PolicyPremium2Model;
|
||||
use App\Models\MailAttachmentModel;
|
||||
|
||||
class sendMailNotification
|
||||
{
|
||||
@ -22,6 +23,21 @@ class sendMailNotification
|
||||
$notification = $params['notification'];
|
||||
$client_data = $params['client_data'];
|
||||
|
||||
$mailAttachmentModel = new MailAttachmentModel();
|
||||
$attachment_data = $mailAttachmentModel
|
||||
->select('file_path, file_name')
|
||||
->where('notification_id', $notification['id'])
|
||||
->where('is_active', 1)
|
||||
->findAll();
|
||||
|
||||
$attachments = [];
|
||||
foreach ($attachment_data as $data) {
|
||||
$attachments[] = [
|
||||
"filePath" => WRITEPATH . $data['file_path'],
|
||||
"fileName" => $data['file_name']
|
||||
];
|
||||
}
|
||||
|
||||
$mail = $dataToInsert['email_corporate'];
|
||||
$subject = $notification['subject'];
|
||||
$app_link = $_ENV['App_Url'];
|
||||
@ -37,7 +53,7 @@ class sendMailNotification
|
||||
|
||||
$mail_content = str_replace("[[app_link]]", "<a href='$app_link'>Review Details</a>", $mail_content);
|
||||
if ($dataToInsert['relationship'] == 'Self' && $mail != null || $mail != '') {
|
||||
$wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']];
|
||||
$wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'attachments' => $attachments];
|
||||
}
|
||||
|
||||
return $wholeData;
|
||||
@ -799,7 +815,24 @@ class sendMailNotification
|
||||
$mail = $params['test_mail'];
|
||||
|
||||
$mail_content = $notification['mail_content'];
|
||||
$subject = $notification['subject'];
|
||||
$subject = $notification['subject'];
|
||||
|
||||
$mailAttachmentModel = new MailAttachmentModel();
|
||||
$attachment_data = $mailAttachmentModel
|
||||
->select('file_path, file_name')
|
||||
->where('notification_id', $notification['id'])
|
||||
->where('is_active', 1)
|
||||
->findAll();
|
||||
|
||||
$attachments = [];
|
||||
foreach ($attachment_data as $data) {
|
||||
$attachments[] = [
|
||||
"filePath" => WRITEPATH . $data['file_path'],
|
||||
"fileName" => $data['file_name']
|
||||
];
|
||||
}
|
||||
|
||||
// print_r($attachments); die;
|
||||
|
||||
$employee_name = 'John Doe';
|
||||
|
||||
@ -816,7 +849,7 @@ class sendMailNotification
|
||||
$mail_content = str_replace("[[app_link]]", "<a href='$app_link'>Review Details</a>", $mail_content);
|
||||
|
||||
if ($mail != null || $mail != '') {
|
||||
$wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']];
|
||||
$wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'attachments' => $attachments];
|
||||
}
|
||||
|
||||
return $wholeData;
|
||||
|
||||
@ -76,8 +76,9 @@ class EmployeePolicyModel extends Model
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
public function getEmployeePolicy($client_id = 0, $policy_id=0, $status=0, $branch_id=0, $emp_code="", $emp_name="")
|
||||
public function getEmployeePolicy($client_id = 0, $policy_id=0, $status=[], $branch_id=0, $emp_code="", $emp_name="")
|
||||
{
|
||||
// dd($status);
|
||||
|
||||
$result = $this->select([
|
||||
'employee_polices.*',
|
||||
@ -90,6 +91,7 @@ class EmployeePolicyModel extends Model
|
||||
'tpab.branch_code as tpa_branch_code',
|
||||
'cm.client_name',
|
||||
'cm.short_name as client_short_name',
|
||||
'emp.id as employee_primary_id',
|
||||
'emp.relationship',
|
||||
'emp.relationship_code',
|
||||
'emp.change_event',
|
||||
@ -97,6 +99,7 @@ class EmployeePolicyModel extends Model
|
||||
'emp.name',
|
||||
'emp.email_corporate',
|
||||
'emp.dob',
|
||||
'DATE_FORMAT(emp.dob, "%d/%m/%Y") AS formatted_dob',
|
||||
'emp.gender',
|
||||
'emp.emp_status',
|
||||
'emp.is_active as emp_is_active',
|
||||
@ -132,17 +135,39 @@ class EmployeePolicyModel extends Model
|
||||
if ($policy_id !=0 && !empty($policy_id)) {
|
||||
$result->where('employee_polices.client_policy_id', $policy_id);
|
||||
}
|
||||
if ($status !=0 && !empty($status)) {
|
||||
if($status == 'active'){
|
||||
|
||||
if (is_array($status) && count($status) > 0) {
|
||||
|
||||
$result->where('employee_polices.status !=', 'expired');
|
||||
|
||||
if (in_array("active", $status)) {
|
||||
|
||||
$result->where('employee_polices.tpa_id IS NOT NULL');
|
||||
$result->where('employee_polices.uhid IS NOT NULL');
|
||||
}else if($status == 'pending'){
|
||||
$status = 'active';
|
||||
$result->where('employee_polices.status', $status);
|
||||
}else{
|
||||
$result->where('employee_polices.status', $status);
|
||||
$result->where('employee_polices.uhid IS NOT NULL');
|
||||
$result->whereIn('employee_polices.status', $status);
|
||||
|
||||
} elseif (in_array("pending", $status)) {
|
||||
|
||||
$result->where('employee_polices.tpa_id IS NULL');
|
||||
$result->where('employee_polices.uhid IS NULL');
|
||||
$result->whereIn('employee_polices.status', array_merge($status, ['active']));
|
||||
|
||||
} else {
|
||||
|
||||
$result->whereIn('employee_polices.status', $status);
|
||||
}
|
||||
|
||||
// if($status == 'active'){
|
||||
// $result->where('employee_polices.tpa_id IS NOT NULL');
|
||||
// $result->where('employee_polices.uhid IS NOT NULL');
|
||||
// }else if($status == 'pending'){
|
||||
// $status = 'active';
|
||||
// $result->where('employee_polices.status', $status);
|
||||
// }else{
|
||||
// $result->where('employee_polices.status', $status);
|
||||
// }
|
||||
}
|
||||
|
||||
if (!empty($emp_code)) {
|
||||
$result->where('emp.emp_code', $emp_code);
|
||||
}
|
||||
@ -529,6 +554,27 @@ class EmployeePolicyModel extends Model
|
||||
$client_branch_id = $ref_data['client_branch_id'];
|
||||
$insurer_or_tpa = $ref_data['insurer_or_tpa'];
|
||||
|
||||
$get_insurer_id_from_client_policy = $this->db->table('client_policy')
|
||||
->select('insurer_id')
|
||||
->where('id', $client_policy_id)
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
$add_one_day = 0;
|
||||
|
||||
if (!empty($get_insurer_id_from_client_policy)) {
|
||||
|
||||
$get_the_insurer_add_one_for_delete = $this->db->table('insurers')
|
||||
->select('deletion_add_day')
|
||||
->where('id', $get_insurer_id_from_client_policy['insurer_id'])
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
if (!empty($get_the_insurer_add_one_for_delete) && $get_the_insurer_add_one_for_delete['deletion_add_day'] == 1) {
|
||||
$add_one_day = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$query = $this->db->query("
|
||||
SELECT DISTINCT
|
||||
a.id as endorsement_primarykey,
|
||||
@ -568,10 +614,10 @@ class EmployeePolicyModel extends Model
|
||||
deletiondata.reasonforexit,
|
||||
deletiondata.status,
|
||||
|
||||
DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + 1 AS no_of_days,
|
||||
ROUND((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + 1)) / 365, 2) AS pro_rata_premium,
|
||||
ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + 1)) / 365) * 0.18, 2) AS gst,
|
||||
ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + 1)) / 365) + (((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + 1)) / 365) * 0.18), 2) AS total
|
||||
DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + '$add_one_day' AS no_of_days,
|
||||
ROUND((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365, 2) AS pro_rata_premium,
|
||||
ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18, 2) AS gst,
|
||||
ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) + (((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18), 2) AS total
|
||||
FROM
|
||||
emp_endorsement a
|
||||
LEFT JOIN
|
||||
|
||||
56
app/Models/MailAttachmentModel.php
Normal file
56
app/Models/MailAttachmentModel.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class MailAttachmentModel extends Model
|
||||
{
|
||||
protected $table = 'mail_attachments';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
'id',
|
||||
'notification_id',
|
||||
'file_name',
|
||||
'file_path',
|
||||
'created_at',
|
||||
'created_by',
|
||||
'updated_at',
|
||||
'updated_by',
|
||||
'is_active'
|
||||
];
|
||||
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = ["checkAndADDCreatedByValue"];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
protected function checkAndADDCreatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['created_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['created_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['updated_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@ -78,6 +78,7 @@
|
||||
<th class="font-weight-medium">(₹)Premium</th>
|
||||
<th class="font-weight-medium" id="rata_premium" data-toggle="tooltip" data-placement="top">(₹)Pro Rata <br> Premium</th>
|
||||
<th class="font-weight-medium" id="gst" data-toggle="tooltip" data-placement="top">(₹)GST</th>
|
||||
<th class="font-weight-medium" > Action </th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@ -135,6 +136,26 @@
|
||||
<td><?php echo format_indian_number($employee['premium']); ?></td>
|
||||
<td><?php $pro_rata_total += $employee['rata_premimum']; echo format_indian_number($employee['rata_premimum']); ?></td>
|
||||
<td><?php $gst_total += $employee['gst']; echo format_indian_number($employee['gst']); ?></td>
|
||||
<td>
|
||||
<div class="btn-group dropdown">
|
||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
|
||||
<?php if(($employee['emp_status'] == 'draft' || $employee['emp_status'] == 'enrolled') && ($employee['status'] == 'draft' || $employee['status'] == 'enrolled')) { ?>
|
||||
<a class="dropdown-item" onclick="get_emp_master_data_for_update(this, '<?= $employee['employee_primary_id'];?>')" ><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
<?php } ?>
|
||||
|
||||
<?php if($employee['policy_type'] == 'GMC' && $employee['emp_status'] == 'active' && $employee['status'] == 'active' && !empty($employee['tpa_id'])) { ?>
|
||||
<a href="<?= base_url('download-e-card/'). $employee['rand_string'] ?>" class="dropdown-item" target="_blank"><i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>View E-Card</a>
|
||||
<?php } ?>
|
||||
|
||||
<?php if($employee['policy_type'] == 'GMC' && $employee['relationship'] == 'Self' && $employee['emp_status'] == 'active' && $employee['status'] == 'active' && !empty($employee['tpa_id'])) { ?>
|
||||
<a class="dropdown-item" onclick="send_mail_for_individual_employee_ecard('<?= $employee['id'];?>')" ><i class="mdi mdi-email-alert mr-2 text-muted font-18 vertical-middle"></i>Send E-Card Mail</a>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } } ?>
|
||||
</tbody>
|
||||
@ -159,9 +180,11 @@
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th>Total</th>
|
||||
<th><?php echo format_indian_number($pro_rata_total); ?></th>
|
||||
<th><?php echo format_indian_number($gst_total); ?></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
@ -170,7 +193,82 @@
|
||||
</div><!-- end col -->
|
||||
</div>
|
||||
|
||||
<!-- modal content -->
|
||||
|
||||
<div id="emp_modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Edit Employee</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body p-4">
|
||||
<form role="form" class="parsley-examples" id="empForm" onsubmit="update_emp_master_data_submit_function(event, this)" enctype="multipart/form-data">
|
||||
|
||||
<input type="hidden" name="employee_primary_id" id="employee_primary_id"/>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="emp_code">Employee Code<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="emp_code_for_edit" placeholder="Enter Code" readonly>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-8">
|
||||
<label for="name">Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="name" placeholder="Ente Name" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="gender">Gender <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="gender" name="gender" required disabled>
|
||||
<option value="">Select Gender</option>
|
||||
<option value="M">Male</option>
|
||||
<option value="F">Female</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="dob">Date of Birth<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="dob" placeholder="Enter DOB" name="dob" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="email">Email<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="email_corporate" placeholder="Enter Email" name="email_corporate" data-parsley-trigger="change" data-parsley-type="email" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="mobile">Mobile Number<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="mobile" placeholder="Enter Mobile Number" name="mobile" onkeypress = "return onlyNumbers(event)" maxlength="10" minlength="10" required>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnSubmit">Submit</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.modal -->
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
var dob = flatpickr("#dob", {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false
|
||||
});
|
||||
})
|
||||
|
||||
$(document).ready(function() {
|
||||
var ticketsTable = $('#tickets-table');
|
||||
|
||||
@ -200,4 +298,183 @@
|
||||
console.error("Table not found.");
|
||||
}
|
||||
});
|
||||
|
||||
function get_emp_master_data_for_update(input, id){
|
||||
|
||||
get_emp_master_data_for_update_ajax(id)
|
||||
|
||||
}
|
||||
|
||||
function get_emp_master_data_for_update_ajax(id){
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
$.ajax({
|
||||
url: '<?php echo base_url('util/get_emp_master_data_for_update/');?>'+id,
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
|
||||
console.log('get_emp_master_data_for_update response', res)
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
let data = res.data
|
||||
|
||||
if(res.status == true){
|
||||
|
||||
if(data.relationship == 'Self'){
|
||||
$('#gender').prop('disabled', false)
|
||||
}else{
|
||||
$('#gender').prop('disabled', true)
|
||||
}
|
||||
|
||||
$('#employee_primary_id').val(data.id);
|
||||
$('#emp_code_for_edit').val(data.emp_code);
|
||||
$('#name').val(data.name);
|
||||
$('#gender').val(data.gender);
|
||||
$('#dob').val(data.formatted_dob);
|
||||
$('#email_corporate').val(data.email_corporate);
|
||||
$('#mobile').val(data.mobile);
|
||||
|
||||
var myModal = new bootstrap.Modal(document.getElementById('emp_modal'));
|
||||
myModal.show();
|
||||
|
||||
}else{
|
||||
$('#employee_primary_id').val('');
|
||||
$('#emp_code_for_edit').val('');
|
||||
$('#name').val('');
|
||||
$('#gender').val('');
|
||||
$('#dob').val('');
|
||||
$('#email_corporate').val('');
|
||||
$('#mobile').val('');
|
||||
|
||||
toastr.warning(res.message, 'WARNING');
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function update_emp_master_data_submit_function(event, form){
|
||||
|
||||
event.preventDefault(); // Prevent the default form submission
|
||||
|
||||
var isValid = $(form).parsley().validate();
|
||||
if (!isValid) {
|
||||
console.log('Form is Empty', 'Warning');
|
||||
return ;
|
||||
}
|
||||
|
||||
const formData = new FormData(form);
|
||||
|
||||
const submitButton = form.querySelector('button[type="submit"]');
|
||||
submitButton.disabled = true;
|
||||
submitButton.innerText = 'Updating...';
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
// AJAX request to update the individual employee
|
||||
$.ajax({
|
||||
url: '<?= base_url('/util/update_emp_data') ?>',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(response) {
|
||||
|
||||
console.log(response)
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
if(response.status == true){
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
|
||||
$('.close').click();
|
||||
|
||||
$('#employee_primary_id').val('');
|
||||
$('#emp_code_for_edit').val('');
|
||||
$('#name').val('');
|
||||
$('#gender').val('');
|
||||
$('#dob').val('');
|
||||
$('#email_corporate').val('');
|
||||
$('#mobile').val('');
|
||||
|
||||
window.location.reload();
|
||||
|
||||
}else{
|
||||
toastr.error(response.message, 'ERROR');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
// Handle error
|
||||
console.error('Upload error occurred:');
|
||||
console.error('Status: ', status); // Status of the request
|
||||
console.error('Error: ', error); // Specific error message
|
||||
console.error('XHR Object: ', xhr); // Full XHR object with response details
|
||||
|
||||
// Optionally log server response, if available
|
||||
if (xhr.responseText) {
|
||||
console.error('Response Text: ', xhr.responseText);
|
||||
}
|
||||
|
||||
toastr.warning('Error uploading file', 'WARNING');
|
||||
console.error('Upload error:', error);
|
||||
},
|
||||
complete: function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
// Re-enable the submit button and reset its text
|
||||
submitButton.disabled = false;
|
||||
submitButton.innerText = 'Submit';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function send_mail_for_individual_employee_ecard(id){
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
$.ajax({
|
||||
|
||||
url: '<?php echo base_url('util/send_mail_for_individual_employee_ecard/');?>'+id,
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
|
||||
console.log('send_mail_for_individual_employee_ecard response', res)
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
if(res.status == true){
|
||||
toastr.success(res.message, 'SUCCESS');
|
||||
}else{
|
||||
toastr.error(res.message, 'ERROR');
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@ -7,6 +7,17 @@
|
||||
table.dataTable tbody td {
|
||||
padding: 4px 4px !important;
|
||||
}
|
||||
|
||||
.select2-selection__choice {
|
||||
background-color: #0a8794 !important;
|
||||
color: white !important;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.select2-selection__choice__remove {
|
||||
color: white !important;
|
||||
margin-right: 5px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="row">
|
||||
@ -48,17 +59,22 @@ table.dataTable tbody td {
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label>Status</label> <br />
|
||||
<select class="form-control" id="status2">
|
||||
<select class="form-control" name="status2[]" id="status2" multiple>
|
||||
<option value="0">Select</option>
|
||||
<?php foreach($status as $key => $value) { ?>
|
||||
<option value="<?= $key ?>"
|
||||
<?= (isset($getData) && $getData['status'] == $key) ? 'selected' : '' ?>>
|
||||
<?php
|
||||
if ((!isset($getData) || count($getData['status']) == 0) && $key == 'active') {
|
||||
echo 'selected';
|
||||
}
|
||||
?>>
|
||||
<?= $value ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label>Employee Code</label> <br />
|
||||
<input type="text" class="form-control" id="emp_code" name="emp_code" value="<?= isset($getData['emp_code']) && !empty($getData['emp_code']) ? $getData['emp_code'] : '' ?>">
|
||||
@ -106,6 +122,13 @@ $(document).ready(function() {
|
||||
$("#policies").select2();
|
||||
$("#branch_id").select2();
|
||||
|
||||
$("#status2").select2({
|
||||
placeholder : 'Select Status'
|
||||
});
|
||||
|
||||
$("textarea.select2-search__field").attr('rows', '1');
|
||||
$("textarea.select2-search__field").css('resize', 'none');
|
||||
|
||||
// if ($('.select2-selection__arrow').length > 0) {
|
||||
// $('.select2-selection__arrow').removeClass('select2-selection__arrow').addClass('fa fa-chevron-down');
|
||||
// }
|
||||
@ -119,11 +142,22 @@ var clientPoliciesWithBranch = {
|
||||
var client_id = '<?= isset($getData) ? $getData['client_id'] : '0' ?>';
|
||||
var client_branch_id = '<?= isset($getData) ? $getData['branch_id'] : '0' ?>';
|
||||
|
||||
var statusData = <?= json_encode(isset($getData['status']) ? $getData['status'] : []) ?>;
|
||||
|
||||
$(document).ready(function() {
|
||||
// Loop through each item in statusData and set the option as selected.
|
||||
statusData.forEach(function(status) {
|
||||
$('#status2 option[value="' + status + '"]').prop('selected', true);
|
||||
});
|
||||
|
||||
// Refresh the select element (necessary if you are using a plugin like Select2).
|
||||
$('#status2').trigger('change');
|
||||
});
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
console.log("document loaded");
|
||||
//fetchClientPolicies();
|
||||
|
||||
});
|
||||
|
||||
$(window).on("load", function() {
|
||||
@ -330,6 +364,11 @@ function fetchEmpolyeeList(event) {
|
||||
var emp_code = $('#emp_code').val();
|
||||
var emp_name = $('#emp_name').val();
|
||||
|
||||
var statusArray = [];
|
||||
$('#status2 option:selected').each(function() {
|
||||
statusArray.push($(this).val());
|
||||
});
|
||||
|
||||
// console.log(client_id + '-' + policy_id);
|
||||
// if (client_id == '0' || policy_id == '0') {
|
||||
// alert('Please select values in both dropdowns.');
|
||||
@ -343,7 +382,7 @@ function fetchEmpolyeeList(event) {
|
||||
branch_id: branch_id,
|
||||
emp_code : emp_code,
|
||||
emp_name : emp_name,
|
||||
status : status,
|
||||
status : statusArray,
|
||||
};
|
||||
|
||||
const queryString = objectToQueryString(queryParams);
|
||||
|
||||
@ -458,8 +458,6 @@
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
if (Array.isArray(foundPolicies) && foundPolicies.length === 0) {
|
||||
|
||||
appendPolicies2(foundPolicies);
|
||||
@ -551,15 +549,27 @@
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
$('#insurer_or_tpa').change(function(){
|
||||
|
||||
var insurer_or_tpa = $(this).val()
|
||||
var policy_value = $('#policy').val()
|
||||
var event_type_data = $('#event_type_data').val();
|
||||
var action_type = $('#action_type').val()
|
||||
|
||||
console.log('policy_value', policy_value)
|
||||
|
||||
if(insurer_or_tpa == 'tpa' || event_type_data == 0){
|
||||
// if(insurer_or_tpa == 'tpa' || event_type_data == 0){
|
||||
if(insurer_or_tpa == 'tpa'){
|
||||
|
||||
$("#event_type").removeAttr("multiple");
|
||||
$("#event_type").attr("name", "event_type");
|
||||
$("#event_type").select2('destroy');
|
||||
|
||||
}else if(insurer_or_tpa == 'insurer' && action_type == 'import'){
|
||||
|
||||
$("#event_type").removeAttr("multiple");
|
||||
$("#event_type").attr("name", "event_type");
|
||||
$("#event_type").select2('destroy');
|
||||
|
||||
}else{
|
||||
if(policy_value != 0){
|
||||
$("#event_type").attr("multiple", "multiple");
|
||||
@ -570,15 +580,26 @@
|
||||
}) ;
|
||||
|
||||
$('#action_type').change(function(){
|
||||
var insurer_or_tpa = $(this).val()
|
||||
var action_type = $(this).val()
|
||||
var policy_value = $('#policy').val()
|
||||
var insurer_or_tpa = $('#insurer_or_tpa').val()
|
||||
|
||||
var event_type_data = $('#event_type_data').val();
|
||||
|
||||
console.log('policy_value', policy_value)
|
||||
if(insurer_or_tpa == 'import' || event_type_data == 0){
|
||||
// if(insurer_or_tpa == 'import' || event_type_data == 0){
|
||||
if(action_type == 'import'){
|
||||
|
||||
$("#event_type").removeAttr("multiple");
|
||||
$("#event_type").attr("name", "event_type");
|
||||
$("#event_type").select2('destroy');
|
||||
|
||||
} else if(action_type == 'export' && insurer_or_tpa == 'tpa'){
|
||||
|
||||
$("#event_type").removeAttr("multiple");
|
||||
$("#event_type").attr("name", "event_type");
|
||||
$("#event_type").select2('destroy');
|
||||
|
||||
}else{
|
||||
if(policy_value != 0){
|
||||
$("#event_type").attr("multiple", "multiple");
|
||||
@ -588,12 +609,15 @@
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
$('#policy').change(function(){
|
||||
|
||||
var policy_value = $(this).val()
|
||||
if(policy_value == 0){
|
||||
var insurer_or_tpa = $('insurer_or_tpa').val()
|
||||
var action_type = $('action_type').val()
|
||||
|
||||
if(policy_value == 0 || insurer_or_tpa == 'tpa' || action_type == 'import'){
|
||||
$("#event_type").removeAttr("multiple");
|
||||
$("#event_type").attr("name", "event_type");
|
||||
$("#event_type").select2('destroy');
|
||||
|
||||
@ -656,12 +656,12 @@
|
||||
</li>
|
||||
|
||||
<!-- leads -->
|
||||
<!-- <li>
|
||||
<li>
|
||||
<a href="<?= base_url('/leads/list') ?>">
|
||||
<i class="mdi mdi-chart-bar"></i>
|
||||
<span> Leads </span>
|
||||
</a>
|
||||
</li> -->
|
||||
</li>
|
||||
|
||||
<?php if((get_role_id() == 1 || get_role_id() == 5) && (in_array(BUSINESS_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team()))) { ?>
|
||||
|
||||
|
||||
@ -30,32 +30,32 @@
|
||||
$account_maneger_summary_mail = 0;
|
||||
$client_hr_summary_mail = 0;
|
||||
if(isset($notification)){
|
||||
foreach($notification as $value){
|
||||
|
||||
if ($value['template_name'] == 'member_welcome_mail') {
|
||||
$member_welcome_mail = $value['enabled'];
|
||||
}
|
||||
foreach($notification as $value){
|
||||
|
||||
if ($value['template_name'] == 'member_welcome_mail') {
|
||||
$member_welcome_mail = $value['enabled'];
|
||||
}
|
||||
|
||||
if ($value['template_name'] == 'member_reminder_mail') {
|
||||
$member_reminder_mail = $value['enabled'];
|
||||
}
|
||||
if ($value['template_name'] == 'member_reminder_mail') {
|
||||
$member_reminder_mail = $value['enabled'];
|
||||
}
|
||||
|
||||
if ($value['template_name'] == 'member_ecard_mail') {
|
||||
$member_ecard_mail = $value['enabled'];
|
||||
}
|
||||
if ($value['template_name'] == 'member_ecard_mail') {
|
||||
$member_ecard_mail = $value['enabled'];
|
||||
}
|
||||
|
||||
if ($value['template_name'] == 'member_review_and_summary_mail') {
|
||||
$member_review_and_summary_mail = $value['enabled'];
|
||||
}
|
||||
if ($value['template_name'] == 'member_review_and_summary_mail') {
|
||||
$member_review_and_summary_mail = $value['enabled'];
|
||||
}
|
||||
|
||||
if ($value['template_name'] == 'account_maneger_summary_mail') {
|
||||
$account_maneger_summary_mail = $value['enabled'];
|
||||
}
|
||||
if ($value['template_name'] == 'account_maneger_summary_mail') {
|
||||
$account_maneger_summary_mail = $value['enabled'];
|
||||
}
|
||||
|
||||
if ($value['template_name'] == 'client_hr_summary_mail') {
|
||||
$client_hr_summary_mail = $value['enabled'];
|
||||
if ($value['template_name'] == 'client_hr_summary_mail') {
|
||||
$client_hr_summary_mail = $value['enabled'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?></p>
|
||||
</div>
|
||||
@ -197,7 +197,7 @@
|
||||
<div class="modal-dialog modal-full-width scrollb" >
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="myLargeModalLabel">Member welcome mail <span id="nameOfThePolicy"></span></h4>
|
||||
<h4 class="modal-title" id="myLargeModalLabel">Template Name : Member welcome mail <span id="nameOfThePolicy"></span></h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
@ -206,19 +206,13 @@
|
||||
|
||||
<form role="form" class="parsley-examples" method="post" id="member_welcome_mail_form" enctype="multipart/form-data">
|
||||
|
||||
<input type="hidden" class="form-control" id="template_name" name="template_name" value="Member Welcome Mail" readonly>
|
||||
<input type="hidden" id="member_welcome_mail_template_name" value="member_welcome_mail">
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
<div class="form-row" id="rac_rate_dropdown">
|
||||
<div class="form-group col-md-2">
|
||||
<label for="emp_code">Template Name</label>
|
||||
</div>
|
||||
<div class="form-group col-md-5">
|
||||
<input type="text" id="template_name" name="template_name" class="form-control" value="Member Welcome Mail" readonly placeholder="Template Name">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row" id="rac_rate_dropdown">
|
||||
<div class="form-group col-md-2">
|
||||
<div class="form-group col-md-1">
|
||||
<label for="emp_code">Subject</label>
|
||||
</div>
|
||||
<div class="form-group col-md-5">
|
||||
@ -229,26 +223,47 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row" id="rac_rate_dropdown">
|
||||
<div class="form-group col-md-12">
|
||||
<select id="member_welcome_mail_customButton" class="form-control" style="border:none;right: 6px;width: auto;position: absolute;z-index: 1;top: 17px;height: 32px;float: right;">
|
||||
<option value="">PlaceHolders</option>
|
||||
<?php foreach ($placeHolders as $value): ?>
|
||||
<?php if($value == 'member_name' || $value == 'nhance_logo' || $value == 'client_logo' || $value == 'app_link' || $value == 'client_name'){ ?>
|
||||
<?php $valueChange = str_replace('_', ' ', $value); $valueChange = ucwords($valueChange); ?>
|
||||
<option value="[[<?php echo $value; ?>]]"><?php echo $valueChange; ?></option>
|
||||
<?php } ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="member_welcome_mail_snow_editor" name="content" style="height: 300px;">
|
||||
|
||||
<div id="accordion_2" class="mb-0">
|
||||
<div class="card mb-0" style="border: 2px dotted;">
|
||||
<h5 class="m-1"> Editor
|
||||
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseThree" aria-expanded="true">
|
||||
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
|
||||
</a>
|
||||
</h5>
|
||||
<div id="collapseThree" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_2" style="margin-top: -10px;">
|
||||
|
||||
<div class="form-row" id="rac_rate_dropdown">
|
||||
<div class="form-group col-md-12">
|
||||
<select id="member_welcome_mail_customButton" class="form-control" style="border:none;right: 6px;width: auto;position: absolute;z-index: 1;top: 17px;height: 32px;float: right;">
|
||||
<option value="">PlaceHolders</option>
|
||||
<?php foreach ($placeHolders as $value): ?>
|
||||
<?php if($value == 'member_name' || $value == 'nhance_logo' || $value == 'client_logo' || $value == 'app_link' || $value == 'client_name'){ ?>
|
||||
<?php $valueChange = str_replace('_', ' ', $value); $valueChange = ucwords($valueChange); ?>
|
||||
<option value="[[<?php echo $value; ?>]]"><?php echo $valueChange; ?></option>
|
||||
<?php } ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="member_welcome_mail_snow_editor" name="content" style="height: 300px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="file" id="Question_title_fileInput" style="display: none;">
|
||||
|
||||
<table id="attachment_table" class="table table-sm mb-0" style="margin-top: 30px;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Attachments</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="attachment_tbody">
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group text-right m-b-0">
|
||||
@ -685,7 +700,6 @@
|
||||
</div><!-- /.modal -->
|
||||
|
||||
|
||||
|
||||
<div class="modal fade" id="preview_modal" tabindex="-1" role="dialog" aria-hidden="false" aria-modal="true" data-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
@ -722,7 +736,7 @@
|
||||
// console.log('DOMContentLoaded end');
|
||||
|
||||
// });
|
||||
|
||||
|
||||
$(document).on('hide.bs.modal', '.modal', function () {
|
||||
console.log("Modal is hidden");
|
||||
});
|
||||
@ -1204,18 +1218,27 @@
|
||||
$(`#${template_name}_form`).find('.jodit-wysiwyg').html(res.mail_content);
|
||||
|
||||
console.log(res.id)
|
||||
console.log(res.data)
|
||||
|
||||
if(res.data){
|
||||
addHTMLInput(res.data);
|
||||
}else{
|
||||
addHTMLInput();
|
||||
}
|
||||
|
||||
if(res.id){
|
||||
$('.testmail').show();
|
||||
$('#attachment_table').show();
|
||||
$('.setid').attr('data-id', res.id);
|
||||
}else{
|
||||
$('.testmail').hide();
|
||||
$('#attachment_table').hide();
|
||||
$('.setid').attr('data-id', '');
|
||||
|
||||
}
|
||||
|
||||
}else{
|
||||
$('.testmail').hide();
|
||||
$('#attachment_table').hide();
|
||||
$('.setid').attr('data-id', '');
|
||||
|
||||
}
|
||||
@ -1340,4 +1363,190 @@
|
||||
return emailPattern.test(email);
|
||||
}
|
||||
|
||||
function addHTMLInput(data = null) {
|
||||
|
||||
console.log('addHTMLInput function called');
|
||||
|
||||
const container = document.getElementById('attachment_tbody');
|
||||
|
||||
if (data) {
|
||||
|
||||
$(container).empty();
|
||||
|
||||
data.forEach(item => {
|
||||
const newRow = document.createElement('tr');
|
||||
newRow.className = 'dynamic-form-row';
|
||||
|
||||
newRow.innerHTML = `
|
||||
<td> ${item.file_name} </td>
|
||||
<td> <a class="fa fa-trash" data-id="${item.id}" onclick="removeAttachment('${item.id}')"></a></td>
|
||||
`;
|
||||
|
||||
container.appendChild(newRow);
|
||||
});
|
||||
|
||||
// Creating another row for the form with file input
|
||||
const newFormRow = document.createElement('tr');
|
||||
newFormRow.className = 'dynamic-form-row';
|
||||
|
||||
newFormRow.innerHTML = `
|
||||
<td>
|
||||
<form class="ajax" onsubmit="submitAttachmentForm(event, this)">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-3">
|
||||
<input type="file" class="file-input__input" name="file" required>
|
||||
</div>
|
||||
<div class="form-group col-2">
|
||||
<button type="submit" class="btn btn-sm btn-primary">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
`;
|
||||
|
||||
container.appendChild(newFormRow);
|
||||
|
||||
} else {
|
||||
// If no data is passed, create a new empty row
|
||||
const newRow = document.createElement('tr');
|
||||
newRow.className = 'dynamic-form-row';
|
||||
|
||||
newRow.innerHTML = `
|
||||
<td>
|
||||
<form class="ajax" onsubmit="submitAttachmentForm(event, this)">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-3">
|
||||
<input type="file" class="file-input__input" name="file" required>
|
||||
</div>
|
||||
<div class="form-group col-2">
|
||||
<button type="submit" class="btn btn-sm btn-primary">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
`;
|
||||
container.appendChild(newRow);
|
||||
}
|
||||
}
|
||||
|
||||
function removeHTMLInput(element) {
|
||||
const container = document.getElementById('attachment_tbody');
|
||||
const rows = container.querySelectorAll('.dynamic-form-row');
|
||||
|
||||
if (rows.length > 1) {
|
||||
const row = element.closest('.dynamic-form-row');
|
||||
row.remove();
|
||||
}
|
||||
}
|
||||
|
||||
function submitAttachmentForm(event, form) {
|
||||
|
||||
event.preventDefault(); // Prevent the default form submission
|
||||
|
||||
var template_name = $('#member_welcome_mail_template_name').val();
|
||||
var client_id = $('#general_PrimaryKey').val();
|
||||
|
||||
const formData = new FormData(form);
|
||||
formData.append('template_name', template_name);
|
||||
formData.append('client_id', client_id);
|
||||
|
||||
const fileInput = form.querySelector('input[type="file"]');
|
||||
|
||||
// Check if a file is selected
|
||||
if (!fileInput.files.length) {
|
||||
toastr.warning("Please select a file to upload.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Optional: Display a loading indicator
|
||||
const submitButton = form.querySelector('button[type="submit"]');
|
||||
submitButton.disabled = true;
|
||||
submitButton.innerText = 'Uploading...';
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
// AJAX request to upload the file
|
||||
$.ajax({
|
||||
url: '<?= base_url('client/notification/add_attachment') ?>', // Replace with your actual upload URL
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(response) {
|
||||
|
||||
console.log(response)
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
if(response.status == true){
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
addHTMLInput(response.data);
|
||||
}else{
|
||||
toastr.error(response.message, 'ERROR');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
// Handle error
|
||||
console.error('Upload error occurred:');
|
||||
console.error('Status: ', status); // Status of the request
|
||||
console.error('Error: ', error); // Specific error message
|
||||
console.error('XHR Object: ', xhr); // Full XHR object with response details
|
||||
|
||||
// Optionally log server response, if available
|
||||
if (xhr.responseText) {
|
||||
console.error('Response Text: ', xhr.responseText);
|
||||
}
|
||||
|
||||
toastr.warning('Error uploading file', 'WARNING');
|
||||
console.error('Upload error:', error);
|
||||
},
|
||||
complete: function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
// Re-enable the submit button and reset its text
|
||||
submitButton.disabled = false;
|
||||
submitButton.innerText = 'Submit';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function removeAttachment(id){
|
||||
|
||||
var template_name = $('#member_welcome_mail_template_name').val();
|
||||
var client_id = $('#general_PrimaryKey').val();
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
$.ajax({
|
||||
url: '<?php echo base_url('client/notification/removeAttachment/');?>'+ id + '/' + client_id + '/' + template_name,
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
|
||||
console.log('removeAttachment response', res)
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
if(res.status == true){
|
||||
toastr.success(res.message, 'SUCCESS')
|
||||
addHTMLInput(res.data);
|
||||
}else{
|
||||
toastr.warning(res.message, 'WARNING')
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
@ -216,6 +216,7 @@ body {
|
||||
<button id="submitMail"class="btn btn-primary" onclick="showModal()">Send Mail</button>
|
||||
|
||||
<input type="hidden" id="lead_id" name="lead_id" value="<?= isset($lead_id) ? $lead_id : '' ?>">
|
||||
<input type="hidden" id="qcr_count" value="<?= isset($qcr_count) ? $qcr_count : 0 ?>">
|
||||
<!-- <button id="openDialogBtn">Open Dialog</button> -->
|
||||
|
||||
<div class="table-container">
|
||||
@ -765,6 +766,7 @@ function moveAddRowButton() {
|
||||
|
||||
// Event listener to handle row removal
|
||||
rfqTable.addEventListener('click', function(e) {
|
||||
|
||||
if (e.target.classList.contains('removeRow')) {
|
||||
const row = e.target.closest('tr'); // Get the row to be removed
|
||||
const rowKey = row.getAttribute('id');
|
||||
@ -778,6 +780,7 @@ rfqTable.addEventListener('click', function(e) {
|
||||
moveAddRowButton(); // Move the add row button to the last row
|
||||
realignSpecialConditions();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Function to add new columns
|
||||
@ -1203,6 +1206,7 @@ function addInsurer(event) {
|
||||
|
||||
insurerName = result.selectedInsurer;
|
||||
version = result.insurerDetails;
|
||||
dataId = result.dataId;
|
||||
|
||||
if (version.trim() !== '') {
|
||||
insurerName = `${insurerName}-${version.trim()}`.replace(/\s+/g, '');
|
||||
@ -1281,7 +1285,8 @@ function addInsurer(event) {
|
||||
'ins_name': (insurerName.split('-')[0]),
|
||||
'qcr': 1,
|
||||
'stc': 1,
|
||||
'display_name': insurerName
|
||||
'display_name': insurerName,
|
||||
'id': dataId
|
||||
});
|
||||
}
|
||||
|
||||
@ -1294,6 +1299,7 @@ function addInsurer(event) {
|
||||
}
|
||||
|
||||
function dupInsurer(event) {
|
||||
|
||||
const thPosition = getThPosition(event);
|
||||
console.log(thPosition);
|
||||
// if(thPosition.rowIndex == 1)
|
||||
@ -1301,6 +1307,7 @@ function dupInsurer(event) {
|
||||
//return false;
|
||||
// }
|
||||
// alert('addInsurer clicked');
|
||||
|
||||
let insurerName = prompt("Enter Insurer Name:");
|
||||
if (insurerName) {
|
||||
let parentThIndex = null;
|
||||
@ -1599,6 +1606,7 @@ function changeInsurer(event) {
|
||||
|
||||
let newInsurerName = result.selectedInsurer
|
||||
let newversion = result.insurerDetails;
|
||||
let dataId = result.dataId;
|
||||
|
||||
if (newversion.trim() !== '') {
|
||||
newInsurerName = `${newInsurerName}-${newversion.trim()}`.replace(/\s+/g, '');
|
||||
@ -1651,7 +1659,8 @@ function changeInsurer(event) {
|
||||
over_all_column_data[proposal_name].insurers.forEach(item => {
|
||||
if (item.display_name === oldInsurerName) {
|
||||
item.display_name = newInsurerName; // Replace with new name
|
||||
item.ins_name = newInsurerName.split('-')[0].trim();; // Replace with new name
|
||||
item.ins_name = newInsurerName.split('-')[0].trim(); // Replace with new name
|
||||
item.id = dataId
|
||||
}
|
||||
});
|
||||
// console.log(tempInsurerList);
|
||||
@ -1670,8 +1679,16 @@ function changeInsurer(event) {
|
||||
|
||||
function changeState(event) {
|
||||
|
||||
var type = event.target.className;
|
||||
console.log(type);
|
||||
let type = event.target.className;
|
||||
console.log('1 : ', type);
|
||||
|
||||
// if (type.includes('sendClientProposal') && type.includes('fa fa-check-square')) {
|
||||
// type = 'sendClientProposal';
|
||||
// } else if (type.includes('qcrProposal') && type.includes('fa fa-check-square')) {
|
||||
// type = 'qcrProposal';
|
||||
// }
|
||||
|
||||
// console.log('2 : ',type);
|
||||
|
||||
if (['qcrProposal', 'sendClientProposal'].includes(type)) {
|
||||
|
||||
@ -2082,7 +2099,7 @@ async function selectInsurer(insurers) {
|
||||
<div class="form-group col-md-8">
|
||||
<select id="insurerSelect">
|
||||
<option></option> <!-- Placeholder for Select2 -->
|
||||
${insurers.map(insurer => `<option value="${insurer.insurer_name}-${insurer.branch_code}">${insurer.insurer_name}-${insurer.branch_code}</option>`).join('')}
|
||||
${insurers.map(insurer => `<option data-id="${insurer.id}-${insurer.insurer_id}" value="${insurer.insurer_name}-${insurer.branch_code}">${insurer.insurer_name}-${insurer.branch_code}</option>`).join('')}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@ -2099,14 +2116,19 @@ async function selectInsurer(insurers) {
|
||||
html: selectHTML,
|
||||
showCancelButton: true,
|
||||
preConfirm: () => {
|
||||
|
||||
const selectedInsurer = document.getElementById('insurerSelect').value;
|
||||
const insurerDetails = document.getElementById('insurerDetails').value;
|
||||
|
||||
const insurerSelect = document.getElementById('insurerSelect');
|
||||
const selectedOption = insurerSelect.options[insurerSelect.selectedIndex];
|
||||
const dataId = selectedOption.getAttribute('data-id');
|
||||
|
||||
if (!selectedInsurer) {
|
||||
Swal.showValidationMessage("You need to select an insurer :)");
|
||||
}
|
||||
|
||||
return { selectedInsurer, insurerDetails };
|
||||
return { selectedInsurer, insurerDetails, dataId};
|
||||
},
|
||||
didOpen: () => {
|
||||
// Initialize Select2 on the dropdown
|
||||
@ -2175,6 +2197,7 @@ function showModal(){
|
||||
}
|
||||
|
||||
function ajaxRequestForGetMailData(url){
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: "GET",
|
||||
@ -2212,7 +2235,7 @@ function appendInput(data) {
|
||||
if (!data.contact_person_email) {
|
||||
html += `
|
||||
<div class="form-group col-md-12">
|
||||
<a href="${url}">Click here to add mail</a>
|
||||
<a href="${url}">Click here to update mail ID</a>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
@ -2282,36 +2305,49 @@ function constructURL() {
|
||||
}
|
||||
|
||||
function ajaxRequest(url){
|
||||
|
||||
console.log(url);
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
url: url,
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
|
||||
console.log(res);
|
||||
if(res.status == 'success' && res.code == 200){
|
||||
toastr.success('Mail send Successfully', 'SUCCESS')
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
console.log(res);
|
||||
if(res.status == 'success' && res.code == 200){
|
||||
toastr.success('Mail send Successfully', 'SUCCESS')
|
||||
}else{
|
||||
if(res.messgae){
|
||||
toastr.error(res.messgae, 'ERROR')
|
||||
}else{
|
||||
if(res.messgae){
|
||||
toastr.error(res.messgae, 'ERROR')
|
||||
}else{
|
||||
toastr.error('Mail send failed', 'ERROR')
|
||||
}
|
||||
toastr.error('Mail send failed', 'ERROR')
|
||||
}
|
||||
}
|
||||
|
||||
$('.close').click()
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
}
|
||||
$('.close').click()
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// not in use do not remove this function
|
||||
function tableToJson() {
|
||||
|
||||
const headers = [];
|
||||
@ -2522,14 +2558,14 @@ function jsonToTable(json) {
|
||||
proposel_count++;
|
||||
|
||||
// Extract qcr and stc status for the main headers
|
||||
const dropdown_data_qcr = proposels[header.parentHeader]?.qcr === 1 ?
|
||||
const dropdown_data_qcr = proposels[header.parentHeader]?.qcr == 1 ?
|
||||
'style="background-color: rgb(221, 221, 221);"' : '';
|
||||
const dropdown_data_stc = proposels[header.parentHeader]?.stc === 1 ?
|
||||
const dropdown_data_stc = proposels[header.parentHeader]?.stc == 1 ?
|
||||
'style="background-color: rgb(221, 221, 221);"' : '';
|
||||
|
||||
const check_icon_qcr = proposels[header.parentHeader]?.qcr === 1 ?
|
||||
const check_icon_qcr = proposels[header.parentHeader]?.qcr == 1 ?
|
||||
`<i class="fa fa-check-square" style="color: green; margin-left: 8px;"></i>` : '';
|
||||
const check_icon_stc = proposels[header.parentHeader]?.stc === 1 ?
|
||||
const check_icon_stc = proposels[header.parentHeader]?.stc == 1 ?
|
||||
`<i class="fa fa-check-square" style="color: green; margin-left: 8px;"></i>` : '';
|
||||
|
||||
|
||||
@ -2539,7 +2575,7 @@ function jsonToTable(json) {
|
||||
<div class="dropdown-content">
|
||||
<a href="#" class="addInsurer">Add Insurer</a>
|
||||
<a href="#" class="qcrProposal" ${dropdown_data_qcr}>QCR${check_icon_qcr}</a>
|
||||
<a href="#" class="sendClientProposal" ${dropdown_data_stc}>Send to Client${check_icon_qcr}</a>
|
||||
<a href="#" class="sendClientProposal" ${dropdown_data_stc}>Send to Client${check_icon_stc}</a>
|
||||
<a href="#" class="removeProposal">Remove</a>
|
||||
</div>
|
||||
</span>`;
|
||||
@ -2603,15 +2639,15 @@ function jsonToTable(json) {
|
||||
|
||||
const insurerData = proposels[header.parentHeader]?.insurers[index - 1] || {};
|
||||
|
||||
dropdownDataQCRForInsurer = insurerData.qcr === 1 ?
|
||||
dropdownDataQCRForInsurer = insurerData.qcr == 1 ?
|
||||
'style="background-color: rgb(221, 221, 221);"' : '';
|
||||
dropdownDataSTCForInsurer = insurerData.stc === 1 ?
|
||||
dropdownDataSTCForInsurer = insurerData.stc == 1 ?
|
||||
'style="background-color: rgb(221, 221, 221);"' : '';
|
||||
|
||||
checkDropdownDataQCRForInsurer = insurerData.qcr === 1 ?
|
||||
checkDropdownDataQCRForInsurer = insurerData.qcr == 1 ?
|
||||
`<i class="fa fa-check-square" style="color: green; margin-left: 8px;"></i>` :
|
||||
'';
|
||||
checkDropdownDataSTCForInsurer = insurerData.stc === 1 ?
|
||||
checkDropdownDataSTCForInsurer = insurerData.stc == 1 ?
|
||||
`<i class="fa fa-check-square" style="color: green; margin-left: 8px;"></i>` :
|
||||
'';
|
||||
|
||||
@ -2814,57 +2850,72 @@ function jsonToTable(json) {
|
||||
|
||||
console.log(over_all_column_data);
|
||||
|
||||
try {
|
||||
let qcr_count = $('#qcr_count').val()
|
||||
let lead_id = $('#lead_id').val()
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
if(qcr_count != 0 && RFQ_or_QCR == 1){
|
||||
|
||||
const jsonData = await convertJsonForQCR(); // Construct the JSON data
|
||||
console.log('qcr found')
|
||||
|
||||
// Create a FormData object
|
||||
const formData = new FormData();
|
||||
url = '<?= base_url('rfq/list/') ?>' + lead_id + '/' + 2;
|
||||
window.location.href = url;
|
||||
|
||||
let lead_id = $('#lead_id').val();
|
||||
}else{
|
||||
|
||||
formData.append('json', JSON.stringify(jsonData));
|
||||
formData.append('lead_id', lead_id);
|
||||
console.log('qcr not found')
|
||||
|
||||
const postUrl = '<?= base_url('rfq/createQCR')?>';
|
||||
console.log(postUrl);
|
||||
try {
|
||||
|
||||
const response = await $.ajax({
|
||||
url: postUrl,
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false, // Important to prevent jQuery from processing the data
|
||||
contentType: false, // Important to set this to false to let jQuery set the content type correctly
|
||||
});
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
console.log('Data sent successfully:', response);
|
||||
if(response.status == true){
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
}else{
|
||||
toastr.warning(response.message, 'WARNING');
|
||||
}
|
||||
const jsonData = await convertJsonForQCR(); // Construct the JSON data
|
||||
|
||||
window.location.href = '<?= base_url('rfq/list/') ?>' + lead_id + '/' + 2;
|
||||
// Create a FormData object
|
||||
const formData = new FormData();
|
||||
|
||||
} catch (error) {
|
||||
console.error('An error occurred during the AJAX request:');
|
||||
|
||||
if (error.responseText) {
|
||||
try {
|
||||
const errorResponse = JSON.parse(error.responseText);
|
||||
console.error('Server Response:', errorResponse);
|
||||
} catch (parseError) {
|
||||
console.error('Error Message:', error.message);
|
||||
console.error('Could not parse error response:', error.responseText);
|
||||
let lead_id = $('#lead_id').val();
|
||||
|
||||
formData.append('json', JSON.stringify(jsonData));
|
||||
formData.append('lead_id', lead_id);
|
||||
|
||||
const postUrl = '<?= base_url('rfq/createQCR')?>';
|
||||
console.log(postUrl);
|
||||
|
||||
const response = await $.ajax({
|
||||
url: postUrl,
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false, // Important to prevent jQuery from processing the data
|
||||
contentType: false, // Important to set this to false to let jQuery set the content type correctly
|
||||
});
|
||||
|
||||
console.log('Data sent successfully:', response);
|
||||
if(response.status == true){
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
}else{
|
||||
toastr.warning(response.message, 'WARNING');
|
||||
}
|
||||
} else {
|
||||
console.error('Error Message:', error.message);
|
||||
}
|
||||
|
||||
console.error('Full Error Object:', error);
|
||||
window.location.href = '<?= base_url('rfq/list/') ?>' + lead_id + '/' + 2;
|
||||
|
||||
} catch (error) {
|
||||
console.error('An error occurred during the AJAX request:');
|
||||
|
||||
if (error.responseText) {
|
||||
try {
|
||||
const errorResponse = JSON.parse(error.responseText);
|
||||
console.error('Server Response:', errorResponse);
|
||||
} catch (parseError) {
|
||||
console.error('Error Message:', error.message);
|
||||
console.error('Could not parse error response:', error.responseText);
|
||||
}
|
||||
} else {
|
||||
console.error('Error Message:', error.message);
|
||||
}
|
||||
|
||||
console.error('Full Error Object:', error);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -2882,15 +2933,21 @@ function jsonToTable(json) {
|
||||
|
||||
let headerIndex = 0;
|
||||
parentHeaders.forEach((header) => {
|
||||
|
||||
console.log('header names', header);
|
||||
console.log('header header.innerText', header.innerText);
|
||||
|
||||
const colspan = header.getAttribute('colspan') || 1;
|
||||
const subHeaderArray = [];
|
||||
|
||||
for (let i = 0; i < colspan; i++) {
|
||||
subHeaderArray.push(subHeaders[headerIndex].innerText.replace('⋮', '').trim());
|
||||
const cleanedText = subHeaders[headerIndex].innerText.split('⋮')[0].trim();
|
||||
subHeaderArray.push(cleanedText);
|
||||
headerIndex++;
|
||||
}
|
||||
|
||||
headers.push({
|
||||
parentHeader: header.innerText.replace('⋮', '').trim(),
|
||||
parentHeader: header.innerText.split('⋮')[0].trim(),
|
||||
subHeaders: subHeaderArray
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user