MERGE_UAT_RFQ_MUL_FILE_UPOAD&DEMOGRAPHY_ISSUE
This commit is contained in:
commit
b025898bea
@ -352,6 +352,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get('getTheEmpDataForClaimSearchByMobile/(:any)', 'ClientController::getTheEmpDataForClaimSearchByMobile/$1');
|
||||
$routes->get('getLeadNonEB/(:any)', 'LeadsController::getLeadNonEB/$1');
|
||||
$routes->get('getPolicyTypeFields', 'LeadsController::getPolicyTypeFields');
|
||||
$routes->get('removeMultiFile', 'LeadsController::removeMultiFile');
|
||||
});
|
||||
|
||||
$routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
|
||||
|
||||
@ -17,6 +17,8 @@ class EcardDownloadConversation extends Conversation
|
||||
|
||||
protected function showEcardMenu()
|
||||
{
|
||||
log_message('error', ('showEcardMenu function called'));
|
||||
|
||||
$chat_session_info = get_chatbot_session_info();
|
||||
$policy_list = ChatbotHelper::getListOfPolicies($chat_session_info);
|
||||
$buttons = [];
|
||||
|
||||
@ -46,9 +46,14 @@ class MainMenuConversation extends Conversation
|
||||
$this->bot->reply($message);
|
||||
}
|
||||
|
||||
log_message('error', ('user_reponse before: ' . $user_reponse));
|
||||
|
||||
|
||||
if (!$answer->isInteractiveMessageReply()) {
|
||||
$user_reponse = null;
|
||||
}
|
||||
|
||||
|
||||
// Get just the existing path array
|
||||
$path = $this->bot->userStorage()->get('path') ?? [];
|
||||
|
||||
@ -60,6 +65,9 @@ class MainMenuConversation extends Conversation
|
||||
'path' => $path
|
||||
]);
|
||||
|
||||
log_message('error', ('user_reponse : ' . $user_reponse));
|
||||
|
||||
|
||||
switch ($user_reponse) {
|
||||
|
||||
case "ecard_download":
|
||||
|
||||
@ -59,7 +59,10 @@ class NetworkHospitalConversation extends Conversation
|
||||
$this->bot->userStorage()->save([
|
||||
'path' => $path
|
||||
]);
|
||||
log_message('error', ('user_reponse : ' . $answer->getValue()));
|
||||
|
||||
switch ($answer->getValue()) {
|
||||
|
||||
case is_string($answer->getValue()) && is_array(explode('#',$answer->getValue())) && count((explode('#',$answer->getValue()))) == 2:
|
||||
|
||||
$client_poilicy_id = explode('#',$answer->getValue())[1];
|
||||
|
||||
@ -46,6 +46,9 @@ class policyConversation extends Conversation
|
||||
if (!$answer->isInteractiveMessageReply()) {
|
||||
$user_reponse = null;
|
||||
}
|
||||
|
||||
log_message('error', ('user_reponse : ' . $answer->getValue()));
|
||||
|
||||
$path = $this->bot->userStorage()->get('path');
|
||||
array_push($path,
|
||||
$answer->getValue()
|
||||
|
||||
@ -89,7 +89,7 @@ class ChatbotControllerNew extends BaseController
|
||||
|
||||
$user = $this->botman->getUser();
|
||||
$id = $user->getId();
|
||||
// $this->myLogger->logme('error', ('TEST' . $id));
|
||||
$this->myLogger->logme('error', ('TEST' . $id));
|
||||
$this->session->set('CHATBOT_RANDOM_USER_ID', $id);
|
||||
}
|
||||
|
||||
@ -128,14 +128,14 @@ class ChatbotControllerNew extends BaseController
|
||||
$this->botman->listen();
|
||||
}
|
||||
|
||||
private function registerHandlers()
|
||||
{
|
||||
// Handling Policy and Claims
|
||||
$this->botman->hears('group:policy:{option}', [\App\Controllers\Chatbot\PolicyHandler::class, 'handle']);
|
||||
$this->botman->hears('group:claim:{option}', [\App\Libraries\Chatbot\ClaimHandler::class, 'handle']);
|
||||
// private function registerHandlers()
|
||||
// {
|
||||
// // Handling Policy and Claims
|
||||
// $this->botman->hears('group:policy:{option}', [\App\Controllers\Chatbot\PolicyHandler::class, 'handle']);
|
||||
// $this->botman->hears('group:claim:{option}', [\App\Libraries\Chatbot\ClaimHandler::class, 'handle']);
|
||||
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
public function chatbot()
|
||||
{
|
||||
|
||||
@ -29,6 +29,7 @@ use App\Models\TPABranchModel;
|
||||
use App\Models\RFQModel;
|
||||
use App\Models\InsurerModel;
|
||||
use App\Models\OccupancyMasterModel;
|
||||
use App\Models\LeadFilesModel;
|
||||
|
||||
use App\Helpers\MailHelper;
|
||||
use App\Helpers\ExcelMergeHelper;
|
||||
@ -62,6 +63,7 @@ class LeadsController extends BaseController
|
||||
protected $RFQModel;
|
||||
protected $insurerModel;
|
||||
protected $occupancyModel;
|
||||
protected $leadFilesModel;
|
||||
|
||||
//variables for storing array
|
||||
protected $issuer;
|
||||
@ -92,6 +94,7 @@ class LeadsController extends BaseController
|
||||
$this->RFQModel = new RFQModel();
|
||||
$this->insurerModel = new InsurerModel();
|
||||
$this->occupancyModel = new OccupancyMasterModel();
|
||||
$this->leadFilesModel = new LeadFilesModel();
|
||||
|
||||
$this->issuer = [1 => 'JIBS', 2 => 'Nhance'];
|
||||
$this->clientType = [1 => 'Group', 2 => 'Individual'];
|
||||
@ -206,13 +209,12 @@ class LeadsController extends BaseController
|
||||
private function prepareSingleLeadData($data)
|
||||
{
|
||||
// print_r($data); die;
|
||||
$uploadFilePath = WRITEPATH . 'uploads/lead_files/';
|
||||
|
||||
// Get all uploaded files for 'file_name[]'
|
||||
$files = $this->request->getFileMultiple('file_name');
|
||||
|
||||
// print_r($files); die;
|
||||
|
||||
$index_plus_one = 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
|
||||
if (isset($data['insurer']) && strpos($data['insurer'], '-') !== false) {
|
||||
@ -249,7 +251,9 @@ class LeadsController extends BaseController
|
||||
$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;
|
||||
|
||||
// print_r($data);die();
|
||||
@ -260,15 +264,16 @@ class LeadsController extends BaseController
|
||||
{
|
||||
// print_r($data); die;
|
||||
$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) {
|
||||
|
||||
$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
|
||||
if (isset($data['insurer'][$index]) && strpos($data['insurer'][$index], '-') !== false) {
|
||||
list($insurer_branch_id, $insurer_id) = explode('-', $data['insurer'][$index]);
|
||||
@ -324,7 +329,7 @@ class LeadsController extends BaseController
|
||||
$premium_date = null;
|
||||
}
|
||||
|
||||
$file_name = file_Upload($files[$index], $uploadFilePath);
|
||||
// $file_name = file_Upload($files[$index], $uploadFilePath);
|
||||
|
||||
$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,
|
||||
'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,
|
||||
'notes' => $data['notes'] ?? null,
|
||||
@ -405,6 +411,11 @@ class LeadsController extends BaseController
|
||||
$insertCount = [];
|
||||
foreach ($data as $value) {
|
||||
$insert = $this->leadsModel->insert($value);
|
||||
|
||||
if ($insert) {
|
||||
$this->insertMultiFilesData($value['multi_file_data'], $insert);
|
||||
}
|
||||
|
||||
$insertCount[] = $insert;
|
||||
$this->insertLeadStatus($insert, $value['status'], 3);
|
||||
|
||||
@ -427,13 +438,15 @@ class LeadsController extends BaseController
|
||||
private function updateOldLead($id, $data)
|
||||
{
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
// Get the Single Lead data for edit
|
||||
// Get the Single Lead data for edit uisng ajax ( do not delete)
|
||||
public function getLeadDataForEdit($id)
|
||||
{
|
||||
|
||||
@ -472,6 +485,8 @@ class LeadsController extends BaseController
|
||||
$data['premium_date'] = null;
|
||||
}
|
||||
|
||||
$data['multi_file_data'] = $this->leadFilesModel->where('lead_id', $id)->first() ?? null;
|
||||
|
||||
$data['lastFiveYears'] = $this->getLastFiveFinancialYears();
|
||||
$data['gpaClaimType'] = $this->claim_type_for_gpa;
|
||||
$data['causeOfDeath'] = $this->cause_of_death;
|
||||
@ -485,6 +500,8 @@ class LeadsController extends BaseController
|
||||
|
||||
$data['html'] = $this->generateViewPageHtml($data['policy_type_id'], $data) ?? "";
|
||||
|
||||
// print_r($data); die;
|
||||
|
||||
if ($data) {
|
||||
return $this->respond(['status' => true, 'data' => $data], 200);
|
||||
} else {
|
||||
@ -503,6 +520,77 @@ class LeadsController extends BaseController
|
||||
$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-----------------------------------------------------------------------------------------------
|
||||
|
||||
@ -575,8 +663,11 @@ class LeadsController extends BaseController
|
||||
$data['mail_content'] = $this->transformMailContent($lead_data, $mail_content, $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) {
|
||||
|
||||
$this->loadLayout('view_rfq.php', $data);
|
||||
@ -635,7 +726,6 @@ class LeadsController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function createRFQ()
|
||||
{
|
||||
$data = $this->request->getPost();
|
||||
@ -691,7 +781,6 @@ class LeadsController extends BaseController
|
||||
], 200);
|
||||
}
|
||||
|
||||
|
||||
public function createQCR()
|
||||
{
|
||||
|
||||
@ -1693,6 +1782,7 @@ class LeadsController extends BaseController
|
||||
$propsal_and_insurer = isset($params['proposal_insurer']) ? $params['proposal_insurer'] : null;
|
||||
$mail_content = $params['mail_content'];
|
||||
$mail_subject = $params['subject'];
|
||||
$attachment_file_ids = $params['selected_attachment_files'];
|
||||
|
||||
$result_data = [];
|
||||
// dd($recipient_mail);
|
||||
@ -1801,7 +1891,7 @@ class LeadsController extends BaseController
|
||||
['file_path' => $temp_file_path, 'sheets' => []],
|
||||
['file_path' => $lead_file_path, 'sheets' => []]
|
||||
];
|
||||
$outputPath = dirname($temp_file_path) . '/' . 'merged_' . $temp_file_name;
|
||||
$outputPath = dirname($temp_file_path) . '/' . $temp_file_name;
|
||||
$result = ExcelMergeHelper::mergeExcelFiles($filePaths, $outputPath);
|
||||
// print_rr($result);
|
||||
}
|
||||
@ -1817,7 +1907,12 @@ class LeadsController extends BaseController
|
||||
|
||||
$file_path = $result;
|
||||
$file_name = basename($result);
|
||||
|
||||
// Attacments part
|
||||
$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
|
||||
if ($recipient_type == 'insurer' || $recipient_type == 'placement') {
|
||||
@ -2579,6 +2674,7 @@ class LeadsController extends BaseController
|
||||
$this->loadLayout('view_rfq_non_eb');
|
||||
}
|
||||
|
||||
// get lead data for edit bot EB and NON-EB
|
||||
public function getLeadNonEB($type, $id = null)
|
||||
{
|
||||
// Set basic data
|
||||
@ -2606,9 +2702,15 @@ class LeadsController extends BaseController
|
||||
->where('user_profiles.is_active', 1)
|
||||
->findAll();
|
||||
|
||||
|
||||
|
||||
if (!empty($id)) {
|
||||
|
||||
$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
|
||||
$custom_fields_data = !empty($data['lead_edit_data']['custom_fields'])
|
||||
? 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
|
||||
) ?? "";
|
||||
|
||||
$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) {
|
||||
@ -3477,19 +3581,34 @@ class LeadsController extends BaseController
|
||||
return $data;
|
||||
}
|
||||
|
||||
// function getPreviousColumn($columnLetter)
|
||||
// {
|
||||
// $colIndex = Coordinate::columnIndexFromString($columnLetter);
|
||||
// if ($colIndex > 1) {
|
||||
// $colIndex--;
|
||||
// }
|
||||
// return Coordinate::stringFromColumnIndex($colIndex);
|
||||
// }
|
||||
|
||||
function getPreviousColumn($columnLetter, $decrement = 1) {
|
||||
public function getPreviousColumn($columnLetter, $decrement = 1)
|
||||
{
|
||||
$colIndex = Coordinate::columnIndexFromString($columnLetter);
|
||||
$colIndex = max(1, $colIndex - $decrement); // ensure column index doesn't go below 1
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -17,10 +17,13 @@ class ExcelMergeHelper {
|
||||
{
|
||||
try {
|
||||
log_message('debug', 'Attempting merge with original file order');
|
||||
// echo "Attempting merge with original file order\n";
|
||||
return self::processFiles($filePaths, $outputPath);
|
||||
} catch (Exception $e) {
|
||||
log_message('error', 'First attempt failed: ' . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine());
|
||||
// echo "First attempt failed: " . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine() . "\n";
|
||||
log_message('debug', 'Retrying with reversed file order');
|
||||
// echo "Retrying with reversed file order\n";
|
||||
|
||||
// Reverse the file order and try again
|
||||
$reversedFiles = array_reverse($filePaths);
|
||||
@ -29,6 +32,7 @@ class ExcelMergeHelper {
|
||||
return self::processFiles($reversedFiles, $outputPath);
|
||||
} catch (Exception $e2) {
|
||||
log_message('error', 'Both attempts failed. Last error: ' . $e2->getMessage() . ' in ' . $e2->getFile() . ' on line ' . $e2->getLine());
|
||||
// echo "Both attempts failed. Last error: " . $e2->getMessage() . ' in ' . $e2->getFile() . ' on line ' . $e2->getLine() . "\n";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -45,7 +49,9 @@ class ExcelMergeHelper {
|
||||
private static function processFiles(array $filePaths, string $outputPath): string
|
||||
{
|
||||
log_message('debug', 'Starting Excel merge process');
|
||||
// echo "Starting Excel merge process\n";
|
||||
log_message('debug', 'Files to process: ' . json_encode($filePaths));
|
||||
// echo "Files to process: " . json_encode($filePaths) . "\n";
|
||||
|
||||
if (empty($filePaths)) {
|
||||
throw new Exception("No files provided to merge");
|
||||
@ -66,6 +72,7 @@ class ExcelMergeHelper {
|
||||
|
||||
// Save the merged file
|
||||
log_message('debug', "Saving merged file to: {$outputPath}");
|
||||
// echo "Saving merged file to: {$outputPath}\n";
|
||||
$writer = IOFactory::createWriter($mergedSpreadsheet, 'Xlsx');
|
||||
$writer->setPreCalculateFormulas(false);
|
||||
$writer->save($outputPath);
|
||||
@ -76,6 +83,7 @@ class ExcelMergeHelper {
|
||||
gc_collect_cycles();
|
||||
|
||||
log_message('debug', 'Excel merge process completed successfully');
|
||||
// echo "Excel merge process completed successfully\n";
|
||||
return $outputPath;
|
||||
}
|
||||
|
||||
@ -87,15 +95,17 @@ class ExcelMergeHelper {
|
||||
* @param int|null $index
|
||||
* @throws Exception
|
||||
*/
|
||||
private static function processSingleFile(array $fileInfo, Spreadsheet $mergedSpreadsheet, int $index = null)
|
||||
private static function processSingleFile(array $fileInfo, Spreadsheet $mergedSpreadsheet, ?int $index = null)
|
||||
{
|
||||
if (!isset($fileInfo['file_path']) || !file_exists($fileInfo['file_path'])) {
|
||||
$path = $fileInfo['file_path'] ?? 'undefined';
|
||||
log_message('error', "File " . ($index ?? 'base') . ": Invalid or missing file path: {$path}");
|
||||
// echo "File " . ($index ?? 'base') . ": Invalid or missing file path: {$path}\n";
|
||||
return;
|
||||
}
|
||||
|
||||
log_message('debug', "Processing file " . ($index ?? 'base') . ": " . $fileInfo['file_path']);
|
||||
// echo "Processing file " . ($index ?? 'base') . ": " . $fileInfo['file_path'] . "\n";
|
||||
|
||||
try {
|
||||
// Load the source spreadsheet
|
||||
@ -105,6 +115,7 @@ class ExcelMergeHelper {
|
||||
$worksheets = $sourceSpreadsheet->getAllSheets();
|
||||
$totalSheets = count($worksheets);
|
||||
log_message('debug', "Total sheets in file: " . $totalSheets);
|
||||
// echo "Total sheets in file: " . $totalSheets . "\n";
|
||||
|
||||
$sheetsToMerge = $fileInfo['sheets'] ?? [];
|
||||
|
||||
@ -114,26 +125,30 @@ class ExcelMergeHelper {
|
||||
try {
|
||||
$sheetName = $worksheet->getTitle();
|
||||
log_message('debug', "Processing sheet: {$sheetName}");
|
||||
// echo "Processing sheet: {$sheetName}\n";
|
||||
|
||||
// Generate unique sheet name before cloning
|
||||
$newName = $sheetName;
|
||||
$counter = 1;
|
||||
|
||||
while (in_array($newName, $mergedSpreadsheet->getSheetNames())) {
|
||||
$newName = $sheetName . "_" . $counter++;
|
||||
// $newName = $sheetName . "_" . $counter++;
|
||||
log_message('debug', "Sheet name already exists. Trying new name: {$newName}");
|
||||
// echo "Sheet name already exists. Trying new name: {$newName}\n";
|
||||
}
|
||||
|
||||
// Clone the worksheet and set the new name
|
||||
$clonedSheet = clone $worksheet;
|
||||
$clonedSheet->setTitle($newName);
|
||||
// $clonedSheet = clone $worksheet;
|
||||
// $clonedSheet->setTitle($newName);
|
||||
|
||||
// Add as external sheet
|
||||
$mergedSpreadsheet->addExternalSheet($clonedSheet);
|
||||
$mergedSpreadsheet->addExternalSheet($worksheet);
|
||||
|
||||
log_message('debug', "Successfully added sheet: {$newName}");
|
||||
// echo "Successfully added sheet: {$newName}\n";
|
||||
} catch (Exception $e) {
|
||||
log_message('error', "Error processing sheet {$sheetName} as new name {$newName}: " . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine());
|
||||
// echo "Error processing sheet {$sheetName} as new name {$newName}: " . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine() . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -145,6 +160,7 @@ class ExcelMergeHelper {
|
||||
|
||||
} catch (Exception $e) {
|
||||
log_message('error', "Error processing file {$fileInfo['file_path']}: " . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine());
|
||||
// echo "Error processing file {$fileInfo['file_path']}: " . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine() . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
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,12 +917,8 @@
|
||||
|
||||
<div id="appendArea_${increment}" class = "form-group col-md-12 appendArea"></div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<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 id="multiFileAppendArea_${increment}"></div>
|
||||
|
||||
<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-primary waves-effect waves-light mr-1" onclick="addHTMLInput(1)">+</a>
|
||||
@ -931,6 +927,8 @@
|
||||
|
||||
container.appendChild(newRow);
|
||||
|
||||
//append mutli file html
|
||||
addFileField(increment);
|
||||
|
||||
var lead_type = $('#lead_type').val();
|
||||
leadTypeBsedHideAndShow(lead_type)
|
||||
@ -1064,7 +1062,7 @@
|
||||
console.log('incurredClaimDate', incurredClaimDate)
|
||||
|
||||
if (policyStartDate && incurredClaimDate) {
|
||||
var timeDiff = incurredClaimDate - policyStartDate; // Time difference in milliseconds
|
||||
var timeDiff = (policyStartDate - incurredClaimDate) + 1; // Time difference in milliseconds
|
||||
console.log('timeDiff', timeDiff);
|
||||
var daysDiff = Math.ceil(timeDiff / (1000 * 60 * 60 * 24)); // Convert to days and add 1
|
||||
console.log('daysDiff', daysDiff);
|
||||
@ -1145,6 +1143,69 @@
|
||||
$('#earned_premium_' + increment).val(earned_premium_roundoff);
|
||||
}
|
||||
|
||||
$(document).on("input", "#incept_emp_count, #incept_dept_count, #renewal_emp_count, #renewal_dept_count, #exp_emp_count, #exp_dept_count", function() {
|
||||
calculateTotalLives(this);
|
||||
});
|
||||
|
||||
function calculateTotalLives(input) {
|
||||
|
||||
var lead_type = $('#lead_type').val();
|
||||
|
||||
if (lead_type == 1) {
|
||||
|
||||
let formRow = input.closest('.form-row');
|
||||
|
||||
if (formRow) {
|
||||
// Get the employee count and dependent count within the same row
|
||||
let empCountInput = formRow.querySelector('[name="incept_emp_count[]"]');
|
||||
let depCountInput = formRow.querySelector('[name="incept_dept_count[]"]');
|
||||
let totalLivesInput = formRow.querySelector('[name="incept_no_of_lives[]"]');
|
||||
|
||||
// Parse the input values as integers, defaulting to 0 if empty
|
||||
let empCount = empCountInput ? parseInt(empCountInput.value) || 0 : 0;
|
||||
let depCount = depCountInput ? parseInt(depCountInput.value) || 0 : 0;
|
||||
|
||||
// Calculate total lives
|
||||
let totalLives = empCount + depCount;
|
||||
|
||||
// Set the total lives input value
|
||||
if (totalLivesInput) {
|
||||
totalLivesInput.value = totalLives;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
console.log("Function Called");
|
||||
|
||||
if (input.id === "incept_emp_count" || input.id === "incept_dept_count") {
|
||||
var incept_emp_count = parseInt($("#incept_emp_count").val()) || 0;
|
||||
var incept_dept_count = parseInt($("#incept_dept_count").val()) || 0;
|
||||
|
||||
var totalCount = incept_emp_count + incept_dept_count;
|
||||
$("#incept_no_of_lives").val(totalCount);
|
||||
|
||||
} else if (input.id === "renewal_emp_count" || input.id === "renewal_dept_count") {
|
||||
var renewal_emp_count = parseInt($("#renewal_emp_count").val()) || 0;
|
||||
var renewal_dept_count = parseInt($("#renewal_dept_count").val()) || 0;
|
||||
|
||||
var totalCount = renewal_emp_count + renewal_dept_count;
|
||||
$("#renewal_no_of_lives").val(totalCount);
|
||||
|
||||
} else {
|
||||
var exp_emp_count = parseInt($("#exp_emp_count").val()) || 0;
|
||||
var exp_dept_count = parseInt($("#exp_dept_count").val()) || 0;
|
||||
|
||||
var totalCount = exp_emp_count + exp_dept_count;
|
||||
$("#exp_no_of_lives").val(totalCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------ FORM SUBMIT ---------------------------------------------------------------------------------
|
||||
|
||||
$("#leads_form_id").submit(function(event) {
|
||||
@ -1540,4 +1601,8 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
</script>
|
||||
@ -86,6 +86,8 @@ if (isset($selected_lead_type)) {
|
||||
var temp_client_id = 0;
|
||||
var temp_branch_id = 0;
|
||||
var selected_lead_form_type = <?= isset($selected_lead_type) ? $selected_lead_type : 0 ?>;
|
||||
var fileIndex = 1; // Initialize index
|
||||
|
||||
|
||||
// select2 document ready
|
||||
$(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>
|
||||
|
||||
@ -337,7 +455,7 @@ if (isset($selected_lead_type)) {
|
||||
setTimeout(function(){
|
||||
handleEbAndNonEbEdit(
|
||||
<?= json_encode($lead_edit_data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP) ?>);
|
||||
}, 1000)
|
||||
}, 2000)
|
||||
|
||||
function handleEbAndNonEbEdit(data){
|
||||
if(data.lead_form_type == 1){
|
||||
@ -353,6 +471,7 @@ if (isset($selected_lead_type)) {
|
||||
|
||||
console.log('Received data:', data);
|
||||
let dataIncrement = 1;
|
||||
fileIndex = data.lead_file_count + 1;
|
||||
|
||||
if (!data || typeof data !== 'object') {
|
||||
console.error('Invalid data received for editing.');
|
||||
@ -361,6 +480,7 @@ if (isset($selected_lead_type)) {
|
||||
|
||||
$('.btnDiv').hide();
|
||||
$('#appendArea_' + dataIncrement).empty();
|
||||
$('#multiFileAppendArea_' + dataIncrement).empty();
|
||||
|
||||
if (data.html) {
|
||||
$('#appendArea_' + dataIncrement).append(data.html);
|
||||
@ -368,6 +488,15 @@ if (isset($selected_lead_type)) {
|
||||
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 lead_type = data.lead_type || null;
|
||||
|
||||
@ -498,6 +627,7 @@ if (isset($selected_lead_type)) {
|
||||
console.log('########### THIS IS NON EB LEAD ###############')
|
||||
console.log('Received data:', data);
|
||||
let dataIncrement = 1;
|
||||
fileIndex = data.lead_file_count + 1;
|
||||
|
||||
if (!data || typeof data !== 'object') {
|
||||
console.error('Invalid data received for editing.');
|
||||
@ -505,6 +635,8 @@ if (isset($selected_lead_type)) {
|
||||
}
|
||||
|
||||
$('#appendArea').empty();
|
||||
$('#multiFileAppendArea_' + dataIncrement).empty();
|
||||
|
||||
|
||||
if (data.html) {
|
||||
$('#appendArea').append(data.html);
|
||||
@ -512,6 +644,15 @@ if (isset($selected_lead_type)) {
|
||||
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 lead_type = data.lead_type || null;
|
||||
|
||||
|
||||
@ -290,14 +290,18 @@ hr.solid {
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="multiFileAppendArea_1"></div>
|
||||
|
||||
<hr>
|
||||
|
||||
<!-- other 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>
|
||||
<input type="file" class="form-control" id="file_name" name="file_name" accept=".xls,.xlsx">
|
||||
<span class="text-danger" id="file_name_display"></span>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="salse_person_id">Sales Person<span class="text-danger">*</span></label>
|
||||
@ -370,6 +374,8 @@ $(document).ready(function(){
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false
|
||||
});
|
||||
|
||||
addFileField(1);
|
||||
})
|
||||
|
||||
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; ?>
|
||||
@ -116,14 +116,14 @@
|
||||
<label for="incept_emp_count" class="emp_title"> No of Employees at Inception <span
|
||||
class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['incept_emp_count']) ? $lead_edit_data['incept_emp_count'] : '' ?>" type="text" class="form-control" id="incept_emp_count" name="incept_emp_count[]"
|
||||
placeholder="Enter Lives" required>
|
||||
placeholder="Enter Lives" required oninput="calculateTotalLives(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="incept_dept_count" class="depnd_title"> No of Dependents at Inception <span
|
||||
class="text-danger">*</span></label>
|
||||
<input value="<?= isset($lead_edit_data['incept_dept_count']) ? $lead_edit_data['incept_dept_count'] : '' ?>" type="text" class="form-control" id="incept_dept_count" name="incept_dept_count[]"
|
||||
placeholder="Enter Lives" required>
|
||||
placeholder="Enter Lives" required oninput="calculateTotalLives(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
|
||||
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 } } ?>
|
||||
@ -373,6 +373,16 @@
|
||||
<div class="form-row" id="input_for_row">
|
||||
</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">
|
||||
<button type="submit" class="btn btn-primary" onclick="constructURL(1)">Send Mail</button>
|
||||
@ -394,47 +404,58 @@
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="to">To </label>
|
||||
<select class="form-control" id="to" name="to" required>
|
||||
<?php if (isset($userList)) { ?>
|
||||
<?php foreach ($userList as $user) { ?>
|
||||
<option value="<?= $user['email'];?>">
|
||||
<?= $user['first_name'].' - '.$user['email'];?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="to">To </label>
|
||||
<select class="form-control" id="to" name="to" required>
|
||||
<?php if (isset($userList)) { ?>
|
||||
<?php foreach ($userList as $user) { ?>
|
||||
<option value="<?= $user['email'];?>">
|
||||
<?= $user['first_name'].' - '.$user['email'];?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</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>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</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>
|
||||
<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">
|
||||
<button type="submit" class="btn btn-primary" onclick="constructURL(2)">Send Mail</button>
|
||||
</div>
|
||||
@ -535,6 +556,16 @@
|
||||
|
||||
</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">
|
||||
<button type="submit" class="btn btn-primary" onclick="constructURL(3)">Send Mail</button>
|
||||
</div>
|
||||
@ -557,6 +588,7 @@
|
||||
var premium_data_check = false;
|
||||
var user_role_id = <?= get_role_id(); ?>;
|
||||
var jsonDataForHide = null;
|
||||
var multi_file_data = [];
|
||||
|
||||
const editorConfig = {
|
||||
buttons: [
|
||||
@ -595,7 +627,8 @@
|
||||
console.log('Type:', type);
|
||||
|
||||
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;
|
||||
|
||||
var type_for_url = 1;
|
||||
@ -3452,6 +3485,11 @@ function constructURL_ForInsurerAndClientMailSend() {
|
||||
bcc = bcc.map(Number);
|
||||
bcc = JSON.stringify(bcc);
|
||||
|
||||
var selectedFiles = [];
|
||||
$('#insurer_or_clinet_mail_attachment .multi_file_attachment:checked').each(function () {
|
||||
selectedFiles.push($(this).val());
|
||||
});
|
||||
|
||||
// Prepare FormData object
|
||||
var formData = new FormData();
|
||||
formData.append('lead_id', lead_id);
|
||||
@ -3459,6 +3497,8 @@ function constructURL_ForInsurerAndClientMailSend() {
|
||||
formData.append('subject', subject);
|
||||
formData.append('cc', cc);
|
||||
formData.append('bcc', bcc);
|
||||
formData.append('selected_attachment_files', JSON.stringify(selectedFiles));
|
||||
|
||||
|
||||
if (RFQ_or_QCR == 2) {
|
||||
formData.append('file_type', 'qcr');
|
||||
@ -3493,6 +3533,11 @@ function constructURL_ForInternalMailSend() {
|
||||
// Determine file type
|
||||
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
|
||||
var formData = new FormData();
|
||||
formData.append('lead_id', lead_id);
|
||||
@ -3503,6 +3548,7 @@ function constructURL_ForInternalMailSend() {
|
||||
formData.append('subject', subject);
|
||||
formData.append('mail_content', mail_content);
|
||||
formData.append('recipient_mail', ''); // Empty value as per logic
|
||||
formData.append('selected_attachment_files', JSON.stringify(selectedFiles));
|
||||
|
||||
ajaxRequest(formData)
|
||||
|
||||
@ -3528,6 +3574,11 @@ function constructURL_ForPlacementMailSend() {
|
||||
to = to.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
|
||||
var formData = new FormData();
|
||||
formData.append('lead_id', lead_id);
|
||||
@ -3544,6 +3595,8 @@ function constructURL_ForPlacementMailSend() {
|
||||
formData.append('total_amount', total_amount);
|
||||
formData.append('cd_amount', cd_amount);
|
||||
formData.append('mail_content', mail_content);
|
||||
formData.append('selected_attachment_files', JSON.stringify(selectedFiles));
|
||||
|
||||
|
||||
ajaxRequest(formData);
|
||||
|
||||
@ -5157,6 +5210,11 @@ function autoCaluculationForPremiumChildTable(input) {
|
||||
}
|
||||
|
||||
|
||||
function appendMultiFileData(data) {
|
||||
|
||||
console.log('appendMultiFileData function called');
|
||||
console.log(data)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@ -309,11 +309,22 @@
|
||||
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="form-group">
|
||||
<div class="form-row" id="input_for_row">
|
||||
</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">
|
||||
<button type="submit" class="btn btn-primary" onclick="constructURL(1)">Send Mail</button>
|
||||
</div>
|
||||
@ -374,7 +385,17 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<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">
|
||||
<button type="submit" class="btn btn-primary" onclick="constructURL(2)">Send Mail</button>
|
||||
</div>
|
||||
@ -475,6 +496,16 @@
|
||||
|
||||
</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">
|
||||
<button type="submit" class="btn btn-primary" onclick="constructURL(3)">Send Mail</button>
|
||||
</div>
|
||||
@ -4550,6 +4581,11 @@
|
||||
bcc = bcc.map(Number);
|
||||
bcc = JSON.stringify(bcc);
|
||||
|
||||
var selectedFiles = [];
|
||||
$('#insurer_or_clinet_mail_attachment .multi_file_attachment:checked').each(function () {
|
||||
selectedFiles.push($(this).val());
|
||||
});
|
||||
|
||||
// Prepare FormData object
|
||||
var formData = new FormData();
|
||||
formData.append('lead_id', lead_id);
|
||||
@ -4557,6 +4593,8 @@
|
||||
formData.append('subject', subject);
|
||||
formData.append('cc', cc);
|
||||
formData.append('bcc', bcc);
|
||||
formData.append('selected_attachment_files', JSON.stringify(selectedFiles));
|
||||
|
||||
|
||||
if (rfq_or_qcr == 2) {
|
||||
formData.append('file_type', 'qcr');
|
||||
@ -4591,6 +4629,12 @@
|
||||
// Determine file type
|
||||
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
|
||||
var formData = new FormData();
|
||||
formData.append('lead_id', lead_id);
|
||||
@ -4601,6 +4645,8 @@
|
||||
formData.append('subject', subject);
|
||||
formData.append('mail_content', mail_content);
|
||||
formData.append('recipient_mail', ''); // Empty value as per logic
|
||||
formData.append('selected_attachment_files', JSON.stringify(selectedFiles));
|
||||
|
||||
|
||||
ajaxRequest(formData)
|
||||
|
||||
@ -4626,6 +4672,13 @@
|
||||
to = to.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
|
||||
var formData = new FormData();
|
||||
formData.append('lead_id', lead_id);
|
||||
@ -4642,11 +4695,14 @@
|
||||
formData.append('total_amount', total_amount);
|
||||
formData.append('cd_amount', cd_amount);
|
||||
formData.append('mail_content', mail_content);
|
||||
formData.append('selected_attachment_files', JSON.stringify(selectedFiles));
|
||||
|
||||
|
||||
ajaxRequest(formData);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function ajaxRequest(formData) {
|
||||
|
||||
var apiURL = '<?= base_url('leads/sendMail') ?>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user