FEAT_MULTI_FILE_UPLOAD_IN_LEAD_AND_SEND_ATTACHMENTS_RFQ : RV
This commit is contained in:
parent
28eda66847
commit
12e74fc877
@ -348,6 +348,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
|||||||
$routes->get('getTheEmpDataForClaimSearchByMobile/(:any)', 'ClientController::getTheEmpDataForClaimSearchByMobile/$1');
|
$routes->get('getTheEmpDataForClaimSearchByMobile/(:any)', 'ClientController::getTheEmpDataForClaimSearchByMobile/$1');
|
||||||
$routes->get('getLeadNonEB/(:any)', 'LeadsController::getLeadNonEB/$1');
|
$routes->get('getLeadNonEB/(:any)', 'LeadsController::getLeadNonEB/$1');
|
||||||
$routes->get('getPolicyTypeFields', 'LeadsController::getPolicyTypeFields');
|
$routes->get('getPolicyTypeFields', 'LeadsController::getPolicyTypeFields');
|
||||||
|
$routes->get('removeMultiFile', 'LeadsController::removeMultiFile');
|
||||||
});
|
});
|
||||||
|
|
||||||
$routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
|
$routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
|
||||||
|
|||||||
@ -29,6 +29,7 @@ use App\Models\TPABranchModel;
|
|||||||
use App\Models\RFQModel;
|
use App\Models\RFQModel;
|
||||||
use App\Models\InsurerModel;
|
use App\Models\InsurerModel;
|
||||||
use App\Models\OccupancyMasterModel;
|
use App\Models\OccupancyMasterModel;
|
||||||
|
use App\Models\LeadFilesModel;
|
||||||
|
|
||||||
use App\Helpers\MailHelper;
|
use App\Helpers\MailHelper;
|
||||||
use App\Helpers\ExcelMergeHelper;
|
use App\Helpers\ExcelMergeHelper;
|
||||||
@ -62,6 +63,7 @@ class LeadsController extends BaseController
|
|||||||
protected $RFQModel;
|
protected $RFQModel;
|
||||||
protected $insurerModel;
|
protected $insurerModel;
|
||||||
protected $occupancyModel;
|
protected $occupancyModel;
|
||||||
|
protected $leadFilesModel;
|
||||||
|
|
||||||
//variables for storing array
|
//variables for storing array
|
||||||
protected $issuer;
|
protected $issuer;
|
||||||
@ -92,6 +94,7 @@ class LeadsController extends BaseController
|
|||||||
$this->RFQModel = new RFQModel();
|
$this->RFQModel = new RFQModel();
|
||||||
$this->insurerModel = new InsurerModel();
|
$this->insurerModel = new InsurerModel();
|
||||||
$this->occupancyModel = new OccupancyMasterModel();
|
$this->occupancyModel = new OccupancyMasterModel();
|
||||||
|
$this->leadFilesModel = new LeadFilesModel();
|
||||||
|
|
||||||
$this->issuer = [1 => 'JIBS', 2 => 'Nhance'];
|
$this->issuer = [1 => 'JIBS', 2 => 'Nhance'];
|
||||||
$this->clientType = [1 => 'Group', 2 => 'Individual'];
|
$this->clientType = [1 => 'Group', 2 => 'Individual'];
|
||||||
@ -206,13 +209,12 @@ class LeadsController extends BaseController
|
|||||||
private function prepareSingleLeadData($data)
|
private function prepareSingleLeadData($data)
|
||||||
{
|
{
|
||||||
// print_r($data); die;
|
// print_r($data); die;
|
||||||
$uploadFilePath = WRITEPATH . 'uploads/lead_files/';
|
$index_plus_one = 1;
|
||||||
|
$form_file_name = "file_name_".$index_plus_one;
|
||||||
// Get all uploaded files for 'file_name[]'
|
$form_docs_name = "docs_name_".$index_plus_one;
|
||||||
$files = $this->request->getFileMultiple('file_name');
|
$leads_file_primary_key = $data['leads_file_id'] ?? [];
|
||||||
|
$files = $this->request->getFileMultiple($form_file_name);
|
||||||
// print_r($files); die;
|
$multi_file_data = $this->uploadMultiFiles($files, $data[$form_docs_name], $leads_file_primary_key);
|
||||||
|
|
||||||
|
|
||||||
// Separate the insurer and insurer branch, handle missing or invalid data
|
// Separate the insurer and insurer branch, handle missing or invalid data
|
||||||
if (isset($data['insurer']) && strpos($data['insurer'], '-') !== false) {
|
if (isset($data['insurer']) && strpos($data['insurer'], '-') !== false) {
|
||||||
@ -249,7 +251,9 @@ class LeadsController extends BaseController
|
|||||||
$data['policy_end_date'] = null;
|
$data['policy_end_date'] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['file_name'] = file_Upload($files, $uploadFilePath);
|
// $data['file_name'] = file_Upload($files, $uploadFilePath);
|
||||||
|
$data['multi_file_data']= $multi_file_data ?? null;
|
||||||
|
|
||||||
$processcedData[] = $data;
|
$processcedData[] = $data;
|
||||||
|
|
||||||
// print_r($data);die();
|
// print_r($data);die();
|
||||||
@ -260,15 +264,16 @@ class LeadsController extends BaseController
|
|||||||
{
|
{
|
||||||
// print_r($data); die;
|
// print_r($data); die;
|
||||||
$processedData = [];
|
$processedData = [];
|
||||||
$uploadFilePath = WRITEPATH . 'uploads/lead_files/';
|
|
||||||
|
|
||||||
// Get all uploaded files for 'file_name[]'
|
|
||||||
$files = $this->request->getFileMultiple('file_name');
|
|
||||||
|
|
||||||
// print_r($files); die;
|
|
||||||
|
|
||||||
foreach ($data['policy_type_id'] as $index => $value) {
|
foreach ($data['policy_type_id'] as $index => $value) {
|
||||||
|
|
||||||
|
$index_plus_one = $index + 1;
|
||||||
|
$form_file_name = "file_name_".$index_plus_one;
|
||||||
|
$form_docs_name = "docs_name_".$index_plus_one;
|
||||||
|
$leads_file_primary_key = $data['leads_file_id'] ?? [];
|
||||||
|
$files = $this->request->getFileMultiple($form_file_name);
|
||||||
|
$multi_file_data = $this->uploadMultiFiles($files, $data[$form_docs_name], $leads_file_primary_key);
|
||||||
|
|
||||||
// Separate the insurer and insurer branch, handle missing or invalid data
|
// Separate the insurer and insurer branch, handle missing or invalid data
|
||||||
if (isset($data['insurer'][$index]) && strpos($data['insurer'][$index], '-') !== false) {
|
if (isset($data['insurer'][$index]) && strpos($data['insurer'][$index], '-') !== false) {
|
||||||
list($insurer_branch_id, $insurer_id) = explode('-', $data['insurer'][$index]);
|
list($insurer_branch_id, $insurer_id) = explode('-', $data['insurer'][$index]);
|
||||||
@ -324,7 +329,7 @@ class LeadsController extends BaseController
|
|||||||
$premium_date = null;
|
$premium_date = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$file_name = file_Upload($files[$index], $uploadFilePath);
|
// $file_name = file_Upload($files[$index], $uploadFilePath);
|
||||||
|
|
||||||
$last_3_years_claims = $data['finyear'];
|
$last_3_years_claims = $data['finyear'];
|
||||||
|
|
||||||
@ -387,7 +392,8 @@ class LeadsController extends BaseController
|
|||||||
'total_si_at_renewal' => $data['total_si_at_renewal'][$index] ?? 0,
|
'total_si_at_renewal' => $data['total_si_at_renewal'][$index] ?? 0,
|
||||||
'fin_years_claims' => $last_3_years_claims,
|
'fin_years_claims' => $last_3_years_claims,
|
||||||
|
|
||||||
'file_name' => $file_name,
|
// 'file_name' => $file_name,
|
||||||
|
'multi_file_data' => $multi_file_data ?? null,
|
||||||
|
|
||||||
'status' => $data['status'] ?? null,
|
'status' => $data['status'] ?? null,
|
||||||
'notes' => $data['notes'] ?? null,
|
'notes' => $data['notes'] ?? null,
|
||||||
@ -405,6 +411,11 @@ class LeadsController extends BaseController
|
|||||||
$insertCount = [];
|
$insertCount = [];
|
||||||
foreach ($data as $value) {
|
foreach ($data as $value) {
|
||||||
$insert = $this->leadsModel->insert($value);
|
$insert = $this->leadsModel->insert($value);
|
||||||
|
|
||||||
|
if ($insert) {
|
||||||
|
$this->insertMultiFilesData($value['multi_file_data'], $insert);
|
||||||
|
}
|
||||||
|
|
||||||
$insertCount[] = $insert;
|
$insertCount[] = $insert;
|
||||||
$this->insertLeadStatus($insert, $value['status'], 3);
|
$this->insertLeadStatus($insert, $value['status'], 3);
|
||||||
|
|
||||||
@ -427,13 +438,15 @@ class LeadsController extends BaseController
|
|||||||
private function updateOldLead($id, $data)
|
private function updateOldLead($id, $data)
|
||||||
{
|
{
|
||||||
if ($this->leadsModel->where('id', $id)->set($data[0])->update()) {
|
if ($this->leadsModel->where('id', $id)->set($data[0])->update()) {
|
||||||
|
|
||||||
|
$this->insertMultiFilesData($data[0]['multi_file_data'], $id);
|
||||||
$this->insertLeadStatus($id, $data[0]['status'], 3);
|
$this->insertLeadStatus($id, $data[0]['status'], 3);
|
||||||
return $this->respond(['status' => true, 'lead_id' => $id, 'message' => "Lead updated successfully", 'data' => $data], 200);
|
return $this->respond(['status' => true, 'lead_id' => $id, 'message' => "Lead updated successfully", 'data' => $data], 200);
|
||||||
}
|
}
|
||||||
return $this->respond(['status' => false, 'lead_id' => $id, 'message' => "Failed to update Lead", 'data' => $data], 200);
|
return $this->respond(['status' => false, 'lead_id' => $id, 'message' => "Failed to update Lead", 'data' => $data], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the Single Lead data for edit
|
// Get the Single Lead data for edit uisng ajax ( do not delete)
|
||||||
public function getLeadDataForEdit($id)
|
public function getLeadDataForEdit($id)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -472,6 +485,8 @@ class LeadsController extends BaseController
|
|||||||
$data['premium_date'] = null;
|
$data['premium_date'] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$data['multi_file_data'] = $this->leadFilesModel->where('lead_id', $id)->first() ?? null;
|
||||||
|
|
||||||
$data['lastFiveYears'] = $this->getLastFiveFinancialYears();
|
$data['lastFiveYears'] = $this->getLastFiveFinancialYears();
|
||||||
$data['gpaClaimType'] = $this->claim_type_for_gpa;
|
$data['gpaClaimType'] = $this->claim_type_for_gpa;
|
||||||
$data['causeOfDeath'] = $this->cause_of_death;
|
$data['causeOfDeath'] = $this->cause_of_death;
|
||||||
@ -485,6 +500,8 @@ class LeadsController extends BaseController
|
|||||||
|
|
||||||
$data['html'] = $this->generateViewPageHtml($data['policy_type_id'], $data) ?? "";
|
$data['html'] = $this->generateViewPageHtml($data['policy_type_id'], $data) ?? "";
|
||||||
|
|
||||||
|
// print_r($data); die;
|
||||||
|
|
||||||
if ($data) {
|
if ($data) {
|
||||||
return $this->respond(['status' => true, 'data' => $data], 200);
|
return $this->respond(['status' => true, 'data' => $data], 200);
|
||||||
} else {
|
} else {
|
||||||
@ -503,6 +520,77 @@ class LeadsController extends BaseController
|
|||||||
$this->policyTransactionStatusModel->insert($statusData);
|
$this->policyTransactionStatusModel->insert($statusData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function uploadMultiFiles($files, $docs_names, $primaryKey)
|
||||||
|
{
|
||||||
|
$uploadFilePath = WRITEPATH . 'uploads/lead_files/';
|
||||||
|
|
||||||
|
$multi_file_data = [];
|
||||||
|
foreach ($files as $index => $value) {
|
||||||
|
$file_name = file_Upload($value, $uploadFilePath);
|
||||||
|
$multi_file_data[] = [
|
||||||
|
'file_name' => $file_name,
|
||||||
|
'docs_name' => $docs_names[$index],
|
||||||
|
'id' => $primaryKey[$index] ?? "",
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $multi_file_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function insertMultiFilesData($data, $lead_id)
|
||||||
|
{
|
||||||
|
// print_r($data); die;
|
||||||
|
|
||||||
|
if(!empty($data)){
|
||||||
|
foreach ($data as $key => $value) {
|
||||||
|
|
||||||
|
if(!empty($value['id'])){
|
||||||
|
|
||||||
|
$lead_file_data = [
|
||||||
|
'lead_id' => $lead_id,
|
||||||
|
'docs_name' => $value['docs_name'],
|
||||||
|
];
|
||||||
|
|
||||||
|
if(!empty($value['file_name'])) {
|
||||||
|
$lead_file_data['file_name'] = $value['file_name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->leadFilesModel->where('id', $value['id'])->set($lead_file_data)->update();
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$lead_file_data = [
|
||||||
|
'lead_id' => $lead_id,
|
||||||
|
'docs_name' => $value['docs_name'],
|
||||||
|
'file_name' => $value['file_name'],
|
||||||
|
];
|
||||||
|
$this->leadFilesModel->insert($lead_file_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($key == 0 && !empty($value['file_name'])) {
|
||||||
|
$this->leadsModel->where('id', $lead_id)->set('file_name', $value['file_name'])->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeMultiFile()
|
||||||
|
{
|
||||||
|
$id = $this->request->getGet('lead_file_id');
|
||||||
|
if(!empty($id)){
|
||||||
|
$this->leadFilesModel->where('id', $id)->set(['is_active' => 0])->update();
|
||||||
|
return $this->respond(['status' => true, 'message' => 'File removed successfully'], 200);
|
||||||
|
}else{
|
||||||
|
return $this->respond(['status' => false, 'message' => 'File could not be removed.'], 200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateLeadTableFields()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//--------RFQ-----------------------------------------------------------------------------------------------
|
//--------RFQ-----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -575,7 +663,10 @@ class LeadsController extends BaseController
|
|||||||
$data['mail_content'] = $this->transformMailContent($lead_data, $mail_content, $data['page_name']);
|
$data['mail_content'] = $this->transformMailContent($lead_data, $mail_content, $data['page_name']);
|
||||||
$data['subject'] = $this->transformMailContent($lead_data, $subject, $data['page_name']);
|
$data['subject'] = $this->transformMailContent($lead_data, $subject, $data['page_name']);
|
||||||
|
|
||||||
|
$data['multi_file_data'] = $this->leadFilesModel->where('lead_id', $id)->where('is_active', 1)->findAll() ?? null;
|
||||||
|
$data['attachment_html'] = view('rfq/attachment_files', $data) ?? "";
|
||||||
|
|
||||||
|
// dd($data);
|
||||||
|
|
||||||
if ($data['lead_data']['lead_form_type'] == 1) {
|
if ($data['lead_data']['lead_form_type'] == 1) {
|
||||||
|
|
||||||
@ -635,7 +726,6 @@ class LeadsController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function createRFQ()
|
public function createRFQ()
|
||||||
{
|
{
|
||||||
$data = $this->request->getPost();
|
$data = $this->request->getPost();
|
||||||
@ -691,7 +781,6 @@ class LeadsController extends BaseController
|
|||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function createQCR()
|
public function createQCR()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1693,6 +1782,7 @@ class LeadsController extends BaseController
|
|||||||
$propsal_and_insurer = isset($params['proposal_insurer']) ? $params['proposal_insurer'] : null;
|
$propsal_and_insurer = isset($params['proposal_insurer']) ? $params['proposal_insurer'] : null;
|
||||||
$mail_content = $params['mail_content'];
|
$mail_content = $params['mail_content'];
|
||||||
$mail_subject = $params['subject'];
|
$mail_subject = $params['subject'];
|
||||||
|
$attachment_file_ids = $params['selected_attachment_files'];
|
||||||
|
|
||||||
$result_data = [];
|
$result_data = [];
|
||||||
// dd($recipient_mail);
|
// dd($recipient_mail);
|
||||||
@ -1817,7 +1907,12 @@ class LeadsController extends BaseController
|
|||||||
|
|
||||||
$file_path = $result;
|
$file_path = $result;
|
||||||
$file_name = basename($result);
|
$file_name = basename($result);
|
||||||
|
|
||||||
|
// Attacments part
|
||||||
$attachments = [['fileName' => $file_name, 'filePath' => $file_path]];
|
$attachments = [['fileName' => $file_name, 'filePath' => $file_path]];
|
||||||
|
$other_attachments = $this->handleMultiFileAttachments($attachment_file_ids, $lead_id);
|
||||||
|
$attachments = array_merge($attachments, $other_attachments);
|
||||||
|
// print_r($attachments); die;
|
||||||
|
|
||||||
//get recipient address
|
//get recipient address
|
||||||
if ($recipient_type == 'insurer' || $recipient_type == 'placement') {
|
if ($recipient_type == 'insurer' || $recipient_type == 'placement') {
|
||||||
@ -2579,6 +2674,7 @@ class LeadsController extends BaseController
|
|||||||
$this->loadLayout('view_rfq_non_eb');
|
$this->loadLayout('view_rfq_non_eb');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get lead data for edit bot EB and NON-EB
|
||||||
public function getLeadNonEB($type, $id = null)
|
public function getLeadNonEB($type, $id = null)
|
||||||
{
|
{
|
||||||
// Set basic data
|
// Set basic data
|
||||||
@ -2606,9 +2702,15 @@ class LeadsController extends BaseController
|
|||||||
->where('user_profiles.is_active', 1)
|
->where('user_profiles.is_active', 1)
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!empty($id)) {
|
if (!empty($id)) {
|
||||||
|
|
||||||
$data['lead_edit_data'] = $this->leadsModel->where('id', $id)->first() ?? [];
|
$data['lead_edit_data'] = $this->leadsModel->where('id', $id)->first() ?? [];
|
||||||
|
|
||||||
|
$data['lead_edit_data']['multi_file_data'] = $this->leadFilesModel->where('lead_id', $id)->where('is_active', 1)->findAll() ?? null;
|
||||||
|
$data['lead_edit_data']['lead_file_count'] = count($data['lead_edit_data']['multi_file_data']);
|
||||||
|
|
||||||
// Decode and merge custom fields if present
|
// Decode and merge custom fields if present
|
||||||
$custom_fields_data = !empty($data['lead_edit_data']['custom_fields'])
|
$custom_fields_data = !empty($data['lead_edit_data']['custom_fields'])
|
||||||
? json_decode($data['lead_edit_data']['custom_fields'], true)
|
? json_decode($data['lead_edit_data']['custom_fields'], true)
|
||||||
@ -2633,6 +2735,8 @@ class LeadsController extends BaseController
|
|||||||
$data['lead_edit_data']['policy_type_id'] ?? null,
|
$data['lead_edit_data']['policy_type_id'] ?? null,
|
||||||
$data
|
$data
|
||||||
) ?? "";
|
) ?? "";
|
||||||
|
|
||||||
|
$data['lead_edit_data']['multi_file_html'] = view('rfq/multi_files', $data) ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($data['lead_edit_data']['lead_type'] != 1 && $data['lead_edit_data']['lead_form_type'] == 2) {
|
if ($data['lead_edit_data']['lead_type'] != 1 && $data['lead_edit_data']['lead_form_type'] == 2) {
|
||||||
@ -3477,19 +3581,34 @@ class LeadsController extends BaseController
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// function getPreviousColumn($columnLetter)
|
public function getPreviousColumn($columnLetter, $decrement = 1)
|
||||||
// {
|
{
|
||||||
// $colIndex = Coordinate::columnIndexFromString($columnLetter);
|
|
||||||
// if ($colIndex > 1) {
|
|
||||||
// $colIndex--;
|
|
||||||
// }
|
|
||||||
// return Coordinate::stringFromColumnIndex($colIndex);
|
|
||||||
// }
|
|
||||||
|
|
||||||
function getPreviousColumn($columnLetter, $decrement = 1) {
|
|
||||||
$colIndex = Coordinate::columnIndexFromString($columnLetter);
|
$colIndex = Coordinate::columnIndexFromString($columnLetter);
|
||||||
$colIndex = max(1, $colIndex - $decrement); // ensure column index doesn't go below 1
|
$colIndex = max(1, $colIndex - $decrement); // ensure column index doesn't go below 1
|
||||||
return Coordinate::stringFromColumnIndex($colIndex);
|
return Coordinate::stringFromColumnIndex($colIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function handleMultiFileAttachments($json_string, $lead_id)
|
||||||
|
{
|
||||||
|
$attachments = [];
|
||||||
|
|
||||||
|
if (!empty($json_string)) {
|
||||||
|
$fileIds = json_decode($json_string, true);
|
||||||
|
$lead_file_path = WRITEPATH . 'uploads/lead_files/';
|
||||||
|
|
||||||
|
foreach ($fileIds as $id) {
|
||||||
|
$lead_file = $this->leadFilesModel->where('lead_id', $lead_id)->where('id', $id)->where('is_active', 1)->first();
|
||||||
|
|
||||||
|
if ($lead_file) {
|
||||||
|
$attachments[] = [
|
||||||
|
'fileName' => $lead_file['file_name'],
|
||||||
|
'filePath' => $lead_file_path . $lead_file['file_name']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $attachments;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
55
app/Models/LeadFilesModel.php
Normal file
55
app/Models/LeadFilesModel.php
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use CodeIgniter\Model;
|
||||||
|
|
||||||
|
class LeadFilesModel extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'lead_files';
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
protected $allowedFields = [
|
||||||
|
'id',
|
||||||
|
'lead_id',
|
||||||
|
'docs_name',
|
||||||
|
'file_name',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -917,11 +917,7 @@
|
|||||||
|
|
||||||
<div id="appendArea_${increment}" class = "form-group col-md-12 appendArea"></div>
|
<div id="appendArea_${increment}" class = "form-group col-md-12 appendArea"></div>
|
||||||
|
|
||||||
<div class="form-group col-md-3">
|
<div id="multiFileAppendArea_${increment}"></div>
|
||||||
<label for="file_upload">File Upload<span class="text-danger"></span></label>
|
|
||||||
<input type="file" class="form-control" id="file_name_${increment}" name="file_name[]" accept=".xls,.xlsx">
|
|
||||||
<span class="text-danger" id="file_name_display"></span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group col-md-12 btnDiv" style="position: relative;top: 28px;float: right;text-align: end;">
|
<div class="form-group col-md-12 btnDiv" style="position: relative;top: 28px;float: right;text-align: end;">
|
||||||
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this)">x</a>
|
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this)">x</a>
|
||||||
@ -931,6 +927,8 @@
|
|||||||
|
|
||||||
container.appendChild(newRow);
|
container.appendChild(newRow);
|
||||||
|
|
||||||
|
//append mutli file html
|
||||||
|
addFileField(increment);
|
||||||
|
|
||||||
var lead_type = $('#lead_type').val();
|
var lead_type = $('#lead_type').val();
|
||||||
leadTypeBsedHideAndShow(lead_type)
|
leadTypeBsedHideAndShow(lead_type)
|
||||||
@ -1540,4 +1538,8 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@ -86,6 +86,8 @@ if (isset($selected_lead_type)) {
|
|||||||
var temp_client_id = 0;
|
var temp_client_id = 0;
|
||||||
var temp_branch_id = 0;
|
var temp_branch_id = 0;
|
||||||
var selected_lead_form_type = <?= isset($selected_lead_type) ? $selected_lead_type : 0 ?>;
|
var selected_lead_form_type = <?= isset($selected_lead_type) ? $selected_lead_type : 0 ?>;
|
||||||
|
var fileIndex = 1; // Initialize index
|
||||||
|
|
||||||
|
|
||||||
// select2 document ready
|
// select2 document ready
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
@ -327,6 +329,122 @@ if (isset($selected_lead_type)) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function addFileField(increment) {
|
||||||
|
|
||||||
|
console.log('addFileField function called');
|
||||||
|
|
||||||
|
const container = document.getElementById(`multiFileAppendArea_${increment}`);
|
||||||
|
if (!container) return;
|
||||||
|
|
||||||
|
const div = document.createElement("div");
|
||||||
|
div.className = "form-row d-flex align-items-end";
|
||||||
|
div.setAttribute("id", `fileField_${fileIndex}`);
|
||||||
|
|
||||||
|
let isFirstField = container.childElementCount === 0; // Check if it's the first field
|
||||||
|
let placeholder = isFirstField ? 'First file must be Demography.' : '';
|
||||||
|
let accept = isFirstField ? '.xls,.xlsx' : '';
|
||||||
|
|
||||||
|
div.innerHTML = `
|
||||||
|
<div class="form-group col-md-5">
|
||||||
|
<label>Document Name<span class="text-danger"></span></label>
|
||||||
|
<input type="text" class="form-control" name="docs_name_${increment}[]" placeholder="${placeholder}">
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-5">
|
||||||
|
<label>File Upload<span class="text-danger"></span></label>
|
||||||
|
<input type="file" class="form-control" id="file_name_${fileIndex}" name="file_name_${increment}[]" accept="${accept}">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-2" style="position: relative; bottom: 16px;">
|
||||||
|
<button type="button" class="btn btn-danger" onclick="removeFileField(${fileIndex})">x</button>
|
||||||
|
<button type="button" class="btn btn-primary" onclick="addFileField(${increment})">+</button>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
container.appendChild(div);
|
||||||
|
fileIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeFileField(index, lead_file_id = null) {
|
||||||
|
|
||||||
|
if(index == 1){
|
||||||
|
toastr.warning("You can't remove the first file field", 'WARNING');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(lead_file_id != null) {
|
||||||
|
|
||||||
|
Swal.fire({
|
||||||
|
title: "Do you want to remove this file?",
|
||||||
|
// text: "Do you want Save this!",
|
||||||
|
icon: "warning",
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonColor: "#3085d6",
|
||||||
|
cancelButtonColor: "#d33",
|
||||||
|
confirmButtonText: "Yes, Procced!"
|
||||||
|
}).then((result) => {
|
||||||
|
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
|
||||||
|
let url = '<?= base_url('util/removeMultiFile') ?>';
|
||||||
|
|
||||||
|
let requestData = {
|
||||||
|
lead_file_id: lead_file_id
|
||||||
|
};
|
||||||
|
|
||||||
|
$('.loader').fadeIn();
|
||||||
|
$('.loader-mask').fadeIn();
|
||||||
|
|
||||||
|
// Send AJAX request
|
||||||
|
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
|
||||||
|
console.log('Data fetched successfully:', response);
|
||||||
|
|
||||||
|
if (response.status == true) {
|
||||||
|
toastr.success(response.message, 'SUCCESS');
|
||||||
|
|
||||||
|
//remove the file field
|
||||||
|
const field = document.getElementById(`fileField_${index}`);
|
||||||
|
if(index != 1){
|
||||||
|
if (field) field.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
toastr.error(response.message, 'WARNING');
|
||||||
|
}
|
||||||
|
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
|
|
||||||
|
}, function(xhr, status, error) {
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
|
console.error('Error fetching data:', error);
|
||||||
|
console.error(xhr.responseText);
|
||||||
|
toastr.error('An error occurred while checking the CD amount.', 'ERROR');
|
||||||
|
});
|
||||||
|
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}else{
|
||||||
|
const field = document.getElementById(`fileField_${index}`);
|
||||||
|
if(index != 1){
|
||||||
|
if (field) field.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function showFileName(input, index) {
|
||||||
|
if (input.files.length > 0) {
|
||||||
|
document.getElementById(`file_name_display_${index}`).textContent = input.files[0].name;
|
||||||
|
} else {
|
||||||
|
document.getElementById(`file_name_display_${index}`).textContent = "No file chosen";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -337,7 +455,7 @@ if (isset($selected_lead_type)) {
|
|||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
handleEbAndNonEbEdit(
|
handleEbAndNonEbEdit(
|
||||||
<?= json_encode($lead_edit_data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP) ?>);
|
<?= json_encode($lead_edit_data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP) ?>);
|
||||||
}, 1000)
|
}, 2000)
|
||||||
|
|
||||||
function handleEbAndNonEbEdit(data){
|
function handleEbAndNonEbEdit(data){
|
||||||
if(data.lead_form_type == 1){
|
if(data.lead_form_type == 1){
|
||||||
@ -353,6 +471,7 @@ if (isset($selected_lead_type)) {
|
|||||||
|
|
||||||
console.log('Received data:', data);
|
console.log('Received data:', data);
|
||||||
let dataIncrement = 1;
|
let dataIncrement = 1;
|
||||||
|
fileIndex = data.lead_file_count + 1;
|
||||||
|
|
||||||
if (!data || typeof data !== 'object') {
|
if (!data || typeof data !== 'object') {
|
||||||
console.error('Invalid data received for editing.');
|
console.error('Invalid data received for editing.');
|
||||||
@ -361,6 +480,7 @@ if (isset($selected_lead_type)) {
|
|||||||
|
|
||||||
$('.btnDiv').hide();
|
$('.btnDiv').hide();
|
||||||
$('#appendArea_' + dataIncrement).empty();
|
$('#appendArea_' + dataIncrement).empty();
|
||||||
|
$('#multiFileAppendArea_' + dataIncrement).empty();
|
||||||
|
|
||||||
if (data.html) {
|
if (data.html) {
|
||||||
$('#appendArea_' + dataIncrement).append(data.html);
|
$('#appendArea_' + dataIncrement).append(data.html);
|
||||||
@ -368,6 +488,15 @@ if (isset($selected_lead_type)) {
|
|||||||
console.warn('HTML content missing in data.');
|
console.warn('HTML content missing in data.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.multi_file_html) {
|
||||||
|
console.log(data.multi_file_html);
|
||||||
|
setTimeout(function(){
|
||||||
|
$('#multiFileAppendArea_' + dataIncrement).append(data.multi_file_html);
|
||||||
|
}, 2000)
|
||||||
|
} else {
|
||||||
|
console.warn('MULTI FILE HTML content missing in data.');
|
||||||
|
}
|
||||||
|
|
||||||
let policy_type_id = data.policy_type_id || null;
|
let policy_type_id = data.policy_type_id || null;
|
||||||
let lead_type = data.lead_type || null;
|
let lead_type = data.lead_type || null;
|
||||||
|
|
||||||
@ -498,6 +627,7 @@ if (isset($selected_lead_type)) {
|
|||||||
console.log('########### THIS IS NON EB LEAD ###############')
|
console.log('########### THIS IS NON EB LEAD ###############')
|
||||||
console.log('Received data:', data);
|
console.log('Received data:', data);
|
||||||
let dataIncrement = 1;
|
let dataIncrement = 1;
|
||||||
|
fileIndex = data.lead_file_count + 1;
|
||||||
|
|
||||||
if (!data || typeof data !== 'object') {
|
if (!data || typeof data !== 'object') {
|
||||||
console.error('Invalid data received for editing.');
|
console.error('Invalid data received for editing.');
|
||||||
@ -505,6 +635,8 @@ if (isset($selected_lead_type)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$('#appendArea').empty();
|
$('#appendArea').empty();
|
||||||
|
$('#multiFileAppendArea_' + dataIncrement).empty();
|
||||||
|
|
||||||
|
|
||||||
if (data.html) {
|
if (data.html) {
|
||||||
$('#appendArea').append(data.html);
|
$('#appendArea').append(data.html);
|
||||||
@ -512,6 +644,15 @@ if (isset($selected_lead_type)) {
|
|||||||
console.warn('HTML content missing in data.');
|
console.warn('HTML content missing in data.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.multi_file_html) {
|
||||||
|
console.log(data.multi_file_html);
|
||||||
|
setTimeout(function(){
|
||||||
|
$('#multiFileAppendArea_' + dataIncrement).append(data.multi_file_html);
|
||||||
|
}, 2000)
|
||||||
|
} else {
|
||||||
|
console.warn('MULTI FILE HTML content missing in data.');
|
||||||
|
}
|
||||||
|
|
||||||
let policy_type_id = data.policy_type_id || null;
|
let policy_type_id = data.policy_type_id || null;
|
||||||
let lead_type = data.lead_type || null;
|
let lead_type = data.lead_type || null;
|
||||||
|
|
||||||
|
|||||||
@ -290,14 +290,18 @@ hr.solid {
|
|||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
<div id="multiFileAppendArea_1"></div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
<!-- other row -->
|
<!-- other row -->
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
|
|
||||||
<div class="form-group col-md-3">
|
<!-- <div class="form-group col-md-3">
|
||||||
<label for="file_upload">File Upload<span class="text-danger"></span></label>
|
<label for="file_upload">File Upload<span class="text-danger"></span></label>
|
||||||
<input type="file" class="form-control" id="file_name" name="file_name" accept=".xls,.xlsx">
|
<input type="file" class="form-control" id="file_name" name="file_name" accept=".xls,.xlsx">
|
||||||
<span class="text-danger" id="file_name_display"></span>
|
<span class="text-danger" id="file_name_display"></span>
|
||||||
</div>
|
</div> -->
|
||||||
|
|
||||||
<div class="form-group col-md-3">
|
<div class="form-group col-md-3">
|
||||||
<label for="salse_person_id">Sales Person<span class="text-danger">*</span></label>
|
<label for="salse_person_id">Sales Person<span class="text-danger">*</span></label>
|
||||||
@ -370,6 +374,8 @@ $(document).ready(function(){
|
|||||||
dateFormat: "d/m/Y",
|
dateFormat: "d/m/Y",
|
||||||
allowInput: false
|
allowInput: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
addFileField(1);
|
||||||
})
|
})
|
||||||
|
|
||||||
function getPolicyTypeFields(input) {
|
function getPolicyTypeFields(input) {
|
||||||
|
|||||||
14
app/Views/rfq/attachment_files.php
Normal file
14
app/Views/rfq/attachment_files.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php if (!empty($multi_file_data)) : ?>
|
||||||
|
<div class="form-group col-md-12">
|
||||||
|
<label>Select Files:</label>
|
||||||
|
<?php foreach ($multi_file_data as $file) : ?>
|
||||||
|
<div class="form-check">
|
||||||
|
|
||||||
|
<input type="checkbox" class="form-check-input multi_file_attachment" id="file_<?= $file['id'] ?>" name="selected_attachment_files[]" value="<?= $file['id'] ?>" checked>
|
||||||
|
<label class="form-check-label" for="file_<?= $file['id'] ?>">
|
||||||
|
<?= htmlspecialchars($file['docs_name']) ?> - <?= htmlspecialchars($file['file_name']) ?>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
50
app/Views/rfq/multi_files.php
Normal file
50
app/Views/rfq/multi_files.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
$fileIndex = 1; // Initialize index
|
||||||
|
$increment = 1; // Example increment value
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php if (isset($lead_edit_data) && isset($lead_edit_data["multi_file_data"]) && !empty($lead_edit_data["multi_file_data"])) {
|
||||||
|
foreach ($lead_edit_data["multi_file_data"] as $index => $value) {
|
||||||
|
$isFirstField = ($index === 0); // First file must be Demography
|
||||||
|
$placeholder = $isFirstField ? 'First file must be Demography.' : '';
|
||||||
|
$accept = $isFirstField ? '.xls,.xlsx' : '';
|
||||||
|
$index = $index + 1;
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="form-row d-flex align-items-end" id="fileField_<?= $index ?>">
|
||||||
|
|
||||||
|
<input type="hidden" name="leads_file_id[]"
|
||||||
|
value="<?= htmlspecialchars($value['id']) ?>" id="file_id_<?= $index ?>">
|
||||||
|
|
||||||
|
<!-- Document Name Input -->
|
||||||
|
<div class="form-group col-md-5">
|
||||||
|
<label>Document Name<span class="text-danger"></span></label>
|
||||||
|
<input type="text" class="form-control" name="docs_name_<?= $increment ?>[]"
|
||||||
|
placeholder="<?= $placeholder ?>"
|
||||||
|
value="<?= htmlspecialchars($value['docs_name']) ?>" id="docs_name_<?= $index ?>">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- File Upload Input -->
|
||||||
|
<div class="form-group col-md-5">
|
||||||
|
<label>
|
||||||
|
File Upload
|
||||||
|
<span class="text-danger"></span><br>
|
||||||
|
<small id="file_name_display_<?= $index ?>" class="text-muted">
|
||||||
|
<?= !empty($value['file_name']) ? htmlspecialchars($value['file_name']) : 'No file chosen' ?>
|
||||||
|
</small>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<input type="file" class="form-control" id="file_name_<?= $index ?>"
|
||||||
|
name="file_name_<?= $increment ?>[]" accept="<?= $accept ?>"
|
||||||
|
onchange="showFileName(this, <?= $index ?>)">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Add/Remove Buttons -->
|
||||||
|
<div class="col-md-2" style="position: relative; bottom: 16px;">
|
||||||
|
<button type="button" class="btn btn-danger" onclick="removeFileField(<?= $index ?>, <?= htmlspecialchars($value['id']) ?>)">x</button>
|
||||||
|
<button type="button" class="btn btn-primary" onclick="addFileField(<?= $increment ?>)">+</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php } } ?>
|
||||||
@ -374,6 +374,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<h4>Attachments Files</h4>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div class="form-group" id="insurer_or_clinet_mail_attachment">
|
||||||
|
<div class="form-row" >
|
||||||
|
<?php echo isset($attachment_html) && !empty($attachment_html) ? $attachment_html : ''; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||||||
<button type="submit" class="btn btn-primary" onclick="constructURL(1)">Send Mail</button>
|
<button type="submit" class="btn btn-primary" onclick="constructURL(1)">Send Mail</button>
|
||||||
</div>
|
</div>
|
||||||
@ -394,47 +404,58 @@
|
|||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="to">To </label>
|
<label for="to">To </label>
|
||||||
<select class="form-control" id="to" name="to" required>
|
<select class="form-control" id="to" name="to" required>
|
||||||
<?php if (isset($userList)) { ?>
|
<?php if (isset($userList)) { ?>
|
||||||
<?php foreach ($userList as $user) { ?>
|
<?php foreach ($userList as $user) { ?>
|
||||||
<option value="<?= $user['email'];?>">
|
<option value="<?= $user['email'];?>">
|
||||||
<?= $user['first_name'].' - '.$user['email'];?>
|
<?= $user['first_name'].' - '.$user['email'];?>
|
||||||
</option>
|
</option>
|
||||||
<?php } ?>
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</select>
|
<?php } ?>
|
||||||
</div>
|
</select>
|
||||||
|
|
||||||
<div class="form-group col-md-4">
|
|
||||||
<label for="cc">CC </label>
|
|
||||||
<select class="form-control" id="cc" name="cc" required multiple>
|
|
||||||
<?php if (isset($userList)) { ?>
|
|
||||||
<?php foreach ($userList as $user) { ?>
|
|
||||||
<option value="<?= $user['id'];?>">
|
|
||||||
<?= $user['first_name'].' - '.$user['email'];?>
|
|
||||||
</option>
|
|
||||||
<?php } ?>
|
|
||||||
<?php } ?>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group col-md-12">
|
|
||||||
<label for="subject">Subject</label>
|
|
||||||
<input id="subject" type="text" class="form-control" name="subject" value="<?= isset($subject) ? $subject : " " ?>">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group col-md-12">
|
|
||||||
<label for="internal_mail_content">Mail Content</label>
|
|
||||||
<textarea id="internal_mail_content" class="form-control" name="internal_mail_content" rows="3"><?= isset($mail_content) ? $mail_content : " " ?></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
<label for="cc">CC </label>
|
||||||
|
<select class="form-control" id="cc" name="cc" required multiple>
|
||||||
|
<?php if (isset($userList)) { ?>
|
||||||
|
<?php foreach ($userList as $user) { ?>
|
||||||
|
<option value="<?= $user['id'];?>">
|
||||||
|
<?= $user['first_name'].' - '.$user['email'];?>
|
||||||
|
</option>
|
||||||
|
<?php } ?>
|
||||||
|
<?php } ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-12">
|
||||||
|
<label for="subject">Subject</label>
|
||||||
|
<input id="subject" type="text" class="form-control" name="subject" value="<?= isset($subject) ? $subject : " " ?>">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-12">
|
||||||
|
<label for="internal_mail_content">Mail Content</label>
|
||||||
|
<textarea id="internal_mail_content" class="form-control" name="internal_mail_content" rows="3"><?= isset($mail_content) ? $mail_content : " " ?></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
|
||||||
|
<br>
|
||||||
|
<h4>Attachments Files</h4>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div class="form-group" id="internal_mail_attachment">
|
||||||
|
<div class="form-row" >
|
||||||
|
<?php echo isset($attachment_html) && !empty($attachment_html) ? $attachment_html : ''; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||||||
<button type="submit" class="btn btn-primary" onclick="constructURL(2)">Send Mail</button>
|
<button type="submit" class="btn btn-primary" onclick="constructURL(2)">Send Mail</button>
|
||||||
</div>
|
</div>
|
||||||
@ -535,6 +556,16 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<h4>Attachments Files</h4>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div class="form-group" id="placement_mail_attachment">
|
||||||
|
<div class="form-row" >
|
||||||
|
<?php echo isset($attachment_html) && !empty($attachment_html) ? $attachment_html : ''; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||||||
<button type="submit" class="btn btn-primary" onclick="constructURL(3)">Send Mail</button>
|
<button type="submit" class="btn btn-primary" onclick="constructURL(3)">Send Mail</button>
|
||||||
</div>
|
</div>
|
||||||
@ -557,6 +588,7 @@
|
|||||||
var premium_data_check = false;
|
var premium_data_check = false;
|
||||||
var user_role_id = <?= get_role_id(); ?>;
|
var user_role_id = <?= get_role_id(); ?>;
|
||||||
var jsonDataForHide = null;
|
var jsonDataForHide = null;
|
||||||
|
var multi_file_data = [];
|
||||||
|
|
||||||
const editorConfig = {
|
const editorConfig = {
|
||||||
buttons: [
|
buttons: [
|
||||||
@ -595,7 +627,8 @@
|
|||||||
console.log('Type:', type);
|
console.log('Type:', type);
|
||||||
|
|
||||||
let titile_client_name = "<?= isset($lead_data) ? $lead_data['client_name'] : '' ?>";
|
let titile_client_name = "<?= isset($lead_data) ? $lead_data['client_name'] : '' ?>";
|
||||||
|
multi_file_data = <?= isset($multi_file_data) ? json_encode($multi_file_data) : '[]' ?>;
|
||||||
|
appendMultiFileData(multi_file_data)
|
||||||
RFQ_or_QCR = type;
|
RFQ_or_QCR = type;
|
||||||
|
|
||||||
var type_for_url = 1;
|
var type_for_url = 1;
|
||||||
@ -3452,6 +3485,11 @@ function constructURL_ForInsurerAndClientMailSend() {
|
|||||||
bcc = bcc.map(Number);
|
bcc = bcc.map(Number);
|
||||||
bcc = JSON.stringify(bcc);
|
bcc = JSON.stringify(bcc);
|
||||||
|
|
||||||
|
var selectedFiles = [];
|
||||||
|
$('#insurer_or_clinet_mail_attachment .multi_file_attachment:checked').each(function () {
|
||||||
|
selectedFiles.push($(this).val());
|
||||||
|
});
|
||||||
|
|
||||||
// Prepare FormData object
|
// Prepare FormData object
|
||||||
var formData = new FormData();
|
var formData = new FormData();
|
||||||
formData.append('lead_id', lead_id);
|
formData.append('lead_id', lead_id);
|
||||||
@ -3459,6 +3497,8 @@ function constructURL_ForInsurerAndClientMailSend() {
|
|||||||
formData.append('subject', subject);
|
formData.append('subject', subject);
|
||||||
formData.append('cc', cc);
|
formData.append('cc', cc);
|
||||||
formData.append('bcc', bcc);
|
formData.append('bcc', bcc);
|
||||||
|
formData.append('selected_attachment_files', JSON.stringify(selectedFiles));
|
||||||
|
|
||||||
|
|
||||||
if (RFQ_or_QCR == 2) {
|
if (RFQ_or_QCR == 2) {
|
||||||
formData.append('file_type', 'qcr');
|
formData.append('file_type', 'qcr');
|
||||||
@ -3493,6 +3533,11 @@ function constructURL_ForInternalMailSend() {
|
|||||||
// Determine file type
|
// Determine file type
|
||||||
var file_type = RFQ_or_QCR == 2 ? 'qcr' : 'rfq';
|
var file_type = RFQ_or_QCR == 2 ? 'qcr' : 'rfq';
|
||||||
|
|
||||||
|
var selectedFiles = [];
|
||||||
|
$('#internal_mail_attachment .multi_file_attachment:checked').each(function () {
|
||||||
|
selectedFiles.push($(this).val());
|
||||||
|
});
|
||||||
|
|
||||||
// Create FormData
|
// Create FormData
|
||||||
var formData = new FormData();
|
var formData = new FormData();
|
||||||
formData.append('lead_id', lead_id);
|
formData.append('lead_id', lead_id);
|
||||||
@ -3503,6 +3548,7 @@ function constructURL_ForInternalMailSend() {
|
|||||||
formData.append('subject', subject);
|
formData.append('subject', subject);
|
||||||
formData.append('mail_content', mail_content);
|
formData.append('mail_content', mail_content);
|
||||||
formData.append('recipient_mail', ''); // Empty value as per logic
|
formData.append('recipient_mail', ''); // Empty value as per logic
|
||||||
|
formData.append('selected_attachment_files', JSON.stringify(selectedFiles));
|
||||||
|
|
||||||
ajaxRequest(formData)
|
ajaxRequest(formData)
|
||||||
|
|
||||||
@ -3528,6 +3574,11 @@ function constructURL_ForPlacementMailSend() {
|
|||||||
to = to.split(',').map(email => email.trim());
|
to = to.split(',').map(email => email.trim());
|
||||||
cc = cc.map(Number); // or split if it's a string: `cc.split(',').map(email => email.trim())`
|
cc = cc.map(Number); // or split if it's a string: `cc.split(',').map(email => email.trim())`
|
||||||
|
|
||||||
|
var selectedFiles = [];
|
||||||
|
$('#placement_mail_attachment .multi_file_attachment:checked').each(function () {
|
||||||
|
selectedFiles.push($(this).val());
|
||||||
|
});
|
||||||
|
|
||||||
// Prepare FormData
|
// Prepare FormData
|
||||||
var formData = new FormData();
|
var formData = new FormData();
|
||||||
formData.append('lead_id', lead_id);
|
formData.append('lead_id', lead_id);
|
||||||
@ -3544,6 +3595,8 @@ function constructURL_ForPlacementMailSend() {
|
|||||||
formData.append('total_amount', total_amount);
|
formData.append('total_amount', total_amount);
|
||||||
formData.append('cd_amount', cd_amount);
|
formData.append('cd_amount', cd_amount);
|
||||||
formData.append('mail_content', mail_content);
|
formData.append('mail_content', mail_content);
|
||||||
|
formData.append('selected_attachment_files', JSON.stringify(selectedFiles));
|
||||||
|
|
||||||
|
|
||||||
ajaxRequest(formData);
|
ajaxRequest(formData);
|
||||||
|
|
||||||
@ -5157,6 +5210,11 @@ function autoCaluculationForPremiumChildTable(input) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function appendMultiFileData(data) {
|
||||||
|
|
||||||
|
console.log('appendMultiFileData function called');
|
||||||
|
console.log(data)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -309,11 +309,22 @@
|
|||||||
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="form-row" id="input_for_row">
|
<div class="form-row" id="input_for_row">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<h4>Attachments Files</h4>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div class="form-group" id="insurer_or_clinet_mail_attachment">
|
||||||
|
<div class="form-row" >
|
||||||
|
<?php echo isset($attachment_html) && !empty($attachment_html) ? $attachment_html : ''; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||||||
<button type="submit" class="btn btn-primary" onclick="constructURL(1)">Send Mail</button>
|
<button type="submit" class="btn btn-primary" onclick="constructURL(1)">Send Mail</button>
|
||||||
</div>
|
</div>
|
||||||
@ -374,7 +385,17 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
<h4>Attachments Files</h4>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div class="form-group" id="internal_mail_attachment">
|
||||||
|
<div class="form-row" >
|
||||||
|
<?php echo isset($attachment_html) && !empty($attachment_html) ? $attachment_html : ''; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||||||
<button type="submit" class="btn btn-primary" onclick="constructURL(2)">Send Mail</button>
|
<button type="submit" class="btn btn-primary" onclick="constructURL(2)">Send Mail</button>
|
||||||
</div>
|
</div>
|
||||||
@ -475,6 +496,16 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<h4>Attachments Files</h4>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div class="form-group" id="placement_mail_attachment">
|
||||||
|
<div class="form-row" >
|
||||||
|
<?php echo isset($attachment_html) && !empty($attachment_html) ? $attachment_html : ''; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||||||
<button type="submit" class="btn btn-primary" onclick="constructURL(3)">Send Mail</button>
|
<button type="submit" class="btn btn-primary" onclick="constructURL(3)">Send Mail</button>
|
||||||
</div>
|
</div>
|
||||||
@ -4550,6 +4581,11 @@
|
|||||||
bcc = bcc.map(Number);
|
bcc = bcc.map(Number);
|
||||||
bcc = JSON.stringify(bcc);
|
bcc = JSON.stringify(bcc);
|
||||||
|
|
||||||
|
var selectedFiles = [];
|
||||||
|
$('#insurer_or_clinet_mail_attachment .multi_file_attachment:checked').each(function () {
|
||||||
|
selectedFiles.push($(this).val());
|
||||||
|
});
|
||||||
|
|
||||||
// Prepare FormData object
|
// Prepare FormData object
|
||||||
var formData = new FormData();
|
var formData = new FormData();
|
||||||
formData.append('lead_id', lead_id);
|
formData.append('lead_id', lead_id);
|
||||||
@ -4557,6 +4593,8 @@
|
|||||||
formData.append('subject', subject);
|
formData.append('subject', subject);
|
||||||
formData.append('cc', cc);
|
formData.append('cc', cc);
|
||||||
formData.append('bcc', bcc);
|
formData.append('bcc', bcc);
|
||||||
|
formData.append('selected_attachment_files', JSON.stringify(selectedFiles));
|
||||||
|
|
||||||
|
|
||||||
if (rfq_or_qcr == 2) {
|
if (rfq_or_qcr == 2) {
|
||||||
formData.append('file_type', 'qcr');
|
formData.append('file_type', 'qcr');
|
||||||
@ -4591,6 +4629,12 @@
|
|||||||
// Determine file type
|
// Determine file type
|
||||||
var file_type = rfq_or_qcr == 2 ? 'qcr' : 'rfq';
|
var file_type = rfq_or_qcr == 2 ? 'qcr' : 'rfq';
|
||||||
|
|
||||||
|
var selectedFiles = [];
|
||||||
|
$('#internal_mail_attachment .multi_file_attachment:checked').each(function () {
|
||||||
|
selectedFiles.push($(this).val());
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Create FormData
|
// Create FormData
|
||||||
var formData = new FormData();
|
var formData = new FormData();
|
||||||
formData.append('lead_id', lead_id);
|
formData.append('lead_id', lead_id);
|
||||||
@ -4601,6 +4645,8 @@
|
|||||||
formData.append('subject', subject);
|
formData.append('subject', subject);
|
||||||
formData.append('mail_content', mail_content);
|
formData.append('mail_content', mail_content);
|
||||||
formData.append('recipient_mail', ''); // Empty value as per logic
|
formData.append('recipient_mail', ''); // Empty value as per logic
|
||||||
|
formData.append('selected_attachment_files', JSON.stringify(selectedFiles));
|
||||||
|
|
||||||
|
|
||||||
ajaxRequest(formData)
|
ajaxRequest(formData)
|
||||||
|
|
||||||
@ -4626,6 +4672,13 @@
|
|||||||
to = to.split(',').map(email => email.trim());
|
to = to.split(',').map(email => email.trim());
|
||||||
cc = cc.map(Number); // or split if it's a string: `cc.split(',').map(email => email.trim())`
|
cc = cc.map(Number); // or split if it's a string: `cc.split(',').map(email => email.trim())`
|
||||||
|
|
||||||
|
|
||||||
|
var selectedFiles = [];
|
||||||
|
$('#placement_mail_attachment .multi_file_attachment:checked').each(function () {
|
||||||
|
selectedFiles.push($(this).val());
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Prepare FormData
|
// Prepare FormData
|
||||||
var formData = new FormData();
|
var formData = new FormData();
|
||||||
formData.append('lead_id', lead_id);
|
formData.append('lead_id', lead_id);
|
||||||
@ -4642,11 +4695,14 @@
|
|||||||
formData.append('total_amount', total_amount);
|
formData.append('total_amount', total_amount);
|
||||||
formData.append('cd_amount', cd_amount);
|
formData.append('cd_amount', cd_amount);
|
||||||
formData.append('mail_content', mail_content);
|
formData.append('mail_content', mail_content);
|
||||||
|
formData.append('selected_attachment_files', JSON.stringify(selectedFiles));
|
||||||
|
|
||||||
|
|
||||||
ajaxRequest(formData);
|
ajaxRequest(formData);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function ajaxRequest(formData) {
|
function ajaxRequest(formData) {
|
||||||
|
|
||||||
var apiURL = '<?= base_url('leads/sendMail') ?>';
|
var apiURL = '<?= base_url('leads/sendMail') ?>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user