Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
b42245b9d8
@ -99,5 +99,5 @@ class Autoload extends AutoloadConfig
|
||||
* @var string[]
|
||||
* @phpstan-var list<string>
|
||||
*/
|
||||
public $helpers = ['uuid','session','utility', 'form', 'url', 'oauth', 'fileupload', 'excel_import_export', 'file', 'drive'];
|
||||
public $helpers = ['uuid','session','utility', 'form', 'url', 'oauth', 'fileupload', 'excel_import_export', 'file', 'drive','ExcelSanitizeHelper'];
|
||||
}
|
||||
|
||||
@ -155,6 +155,7 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get("truncate/(:any)", "EmployeeController::truncateFileData/$1");
|
||||
$routes->get("test-rack-rate", "EmployeeController::testRackRate");
|
||||
$routes->post("test-rack-rate", "EmployeeController::testRackRate");
|
||||
$routes->get('test_members_list', 'EmployeeController::test_members_list');
|
||||
});
|
||||
|
||||
$routes->group("/master", ["filter" => "authMVC"], function ($routes) {
|
||||
@ -330,6 +331,9 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get('getCoShareStatementDetails/(:any)', 'PolicyTransactionController::getCoShareStatementDetails/$1');
|
||||
$routes->get('getClientPolicyDataBasedOnClientAndInsuer', 'PolicyTransactionController::getClientPolicyDataBasedOnClientAndInsuer');
|
||||
$routes->get('checkCDAmountForBasePremium', 'PolicyTransactionController::checkCDAmountForBasePremium');
|
||||
$routes->post('map_employees', 'EmployeeController::mapEmployees');
|
||||
$routes->post('get_data_for_mapping', 'EmployeeController::getDataForMapping');
|
||||
$routes->post('unmap_employees/(:num)', 'EmployeeController::unmapEmployees/$1');
|
||||
$routes->get('transformMailContent', 'LeadsController::transformMailContent');
|
||||
});
|
||||
|
||||
@ -396,6 +400,7 @@ $routes->get("driveListFiles", "GoogleDriveController::listFiles");
|
||||
$routes->post('dmsSearch', 'PolicyTransactionController::dmsSearch', ['filter' => 'authMVC']);
|
||||
$routes->get('dmsSearch', 'PolicyTransactionController::dmsSearch', ['filter' => 'authMVC']);
|
||||
$routes->get('downloadGdriveFile', 'GoogleDriveController::downloadGdriveFile', ['filter' => 'authMVC']);
|
||||
$routes->get('cli/sendZeptoMail', 'MasterController::testZeptoSMTP');
|
||||
|
||||
$routes->cli('cli/processjob', 'JobWorker::processJob');
|
||||
$routes->cli('cli/processjobs', 'JobWorker::processJobs');
|
||||
@ -403,6 +408,7 @@ $routes->cli('cli/processjobs', 'JobWorker::processJobs');
|
||||
$routes->get("processjob", "JobWorker::processJob");
|
||||
$routes->cli('cli/new_gmail_token', 'MasterController::generateNewGmailAPIToken');
|
||||
$routes->cli('cli/send_mail_cli', 'MasterController::testGmailAPIViaCLI');
|
||||
$routes->cli('cli/sendZeptoMail', 'MasterController::testZeptoSMTP');
|
||||
$routes->cli('cli/check_bounce_mail_cli', 'MasterController::testCheckBounceMails');
|
||||
$routes->cli('cli/app_check_list', 'MasterController::appCheckList');
|
||||
$routes->cli('cli/new_gdrive_token', 'GoogleDriveController::generateNewGoogleDriveAccessToken');
|
||||
|
||||
@ -24,6 +24,7 @@ use App\Models\TPAModel;
|
||||
use App\Models\InsurerExcelExportTemplateModel;
|
||||
use App\Models\InsurerModel;
|
||||
use App\Models\ClientDepositModel;
|
||||
use App\Models\PolicyPremium2Model;
|
||||
|
||||
|
||||
use App\Controllers\Jobs;
|
||||
@ -62,6 +63,7 @@ class EmployeeController extends AdminController
|
||||
protected $excelExportTemplateModel;
|
||||
protected $insurerModel;
|
||||
protected $cashDepositModel;
|
||||
protected $PolicyPremium2Model;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@ -81,6 +83,7 @@ class EmployeeController extends AdminController
|
||||
$this->policiesModel = new PolicesModel();
|
||||
$this->insurerModel = new InsurerModel();
|
||||
$this->cashDepositModel = new ClientDepositModel();
|
||||
$this->PolicyPremium2Model = new PolicyPremium2Model();
|
||||
}
|
||||
|
||||
public function list()
|
||||
@ -1818,7 +1821,7 @@ class EmployeeController extends AdminController
|
||||
public function update_emp_data()
|
||||
{
|
||||
$data = $this->request->getPost();
|
||||
// print_rr($data);
|
||||
// print_rr($data);die();
|
||||
// $data['dob'] = date('Y-m-d', strtotime($data['dob']));
|
||||
$data['dob'] = change_date_format($data['dob'], 'd/m/Y', 'Y-m-d');
|
||||
// print_rr($data); die;
|
||||
@ -2077,6 +2080,109 @@ class EmployeeController extends AdminController
|
||||
exit;
|
||||
}
|
||||
|
||||
public function test_members_list(){
|
||||
// $model = new EmployeeModel();
|
||||
// $list = [
|
||||
// ['relationship' => 'spouse','emp_code' => 'TEST002', 'name' => 'Lakshmi','email_personal' => 'lakshmi@gmail.com','mobile'=>'6382156701','gender'=>'female','dob'=>'1996-05-19','doj'=>'2022-02-01','basic_pay'=>'100000','emp_status'=>'enrolled'],
|
||||
// ['relationship' => 'Daughter','emp_code' => 'TEST002', 'name' => 'Jayalakshmi','email_personal' => 'jayalakshmi@gmail.com','mobile'=>'6382156701','gender'=>'female','dob'=>'2018-05-19','doj'=>'2022-02-01','basic_pay'=>'100000','emp_status'=>'enrolled'],
|
||||
// ['relationship' => 'Son','emp_code' => 'TEST002', 'name' => 'Jayam Ravi','email_personal' => 'jayamravi@gmail.com','mobile'=>'6382156701','gender'=>'male','dob'=>'1994-05-19','doj'=>'2019-02-01','basic_pay'=>'100000','emp_status'=>'enrolled'],
|
||||
// // ['relationship' => 'self','emp_code' => 'TEST003', 'name' => 'Ravi Shankar','email_personal' => 'srinivassaravanan2002@gmail.com','email_corporate'=>'srinivas.saravanan@venbainfotech.com','mobile'=>'6382156701','gender'=>'male','dob'=>'1994-05-19','doj'=>'2022-02-01','basic_pay'=>'100000','emp_status'=>'enrolled']
|
||||
// ['relationship' => 'spouse','emp_code' => 'TEST001', 'name' => 'Lakshmi','email_personal' => 'lakshmi@gmail.com','mobile'=>'6382156701','gender'=>'female','dob'=>'1996-05-19','doj'=>'2022-02-01','basic_pay'=>'100000','emp_status'=>'enrolled'],
|
||||
|
||||
// ];
|
||||
// foreach($list as $listitem){
|
||||
|
||||
|
||||
// $model->insert($listitem);
|
||||
// }
|
||||
// die();
|
||||
$employee_data = $this->employeeModel->getTestEmployeeData();
|
||||
$data['employees'] = $employee_data;
|
||||
$data['clients'] = $this->clientModel->findAll();
|
||||
// dd($data);
|
||||
return $this->loadLayout('test_members_list',$data);
|
||||
}
|
||||
|
||||
public function mapEmployees(){
|
||||
$client_id = $this->request->getPost('client_id');
|
||||
$branch_id = $this->request->getPost('branch_id');
|
||||
$policy_id = $this->request->getPost('client_policy_id');
|
||||
$selected_employees = (array)$this->request->getPost('selected');
|
||||
$si_amt = $this->request->getPost('si_amt');
|
||||
$policy_start_date_unformatted = $this->request->getPost('policy_start_date');
|
||||
|
||||
$policy_start_date = change_date_format($policy_start_date_unformatted, 'd/M/Y', 'Y-m-d');
|
||||
|
||||
$data1 = [
|
||||
'client_id' => $client_id,
|
||||
'client_branch_id' => $branch_id,
|
||||
];
|
||||
$data2 = [
|
||||
'client_policy_id' => $policy_id,
|
||||
'status' => 'draft',
|
||||
'date_coverage' => $policy_start_date,
|
||||
'basic_cover_si' => $si_amt,
|
||||
|
||||
];
|
||||
|
||||
for($i = 0; $i < count($selected_employees); $i++){
|
||||
$data2['employee_id'] = $selected_employees[$i];
|
||||
$result1 = $this->employeeModel->set($data1)->where('id',$selected_employees[$i])->update();
|
||||
$result2 = $this->employeePolicyModel->insert($data2);
|
||||
}
|
||||
if ($result1 && $result2) {
|
||||
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Employees mapped successfully'], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to map employees.'], 404);
|
||||
}
|
||||
}
|
||||
|
||||
public function getDataForMapping(){
|
||||
$policy_id = $this->request->getPost('policy_id');log_message('error',$policy_id);
|
||||
$data['policy_start_date'] = $this->clientPolicyModel->select('policy_start_date')->where('id',$policy_id)->first()['policy_start_date'];
|
||||
$data['si_amt'] = $this->PolicyPremium2Model->select('si')->where('client_policy_id', $policy_id)->groupBy('si')->findAll();
|
||||
log_message('error',json_encode($data).'policy id '.$policy_id);
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $data], 200);
|
||||
}
|
||||
|
||||
public function unmapEmployees($actionType){
|
||||
$selected_employees = (array)$this->request->getPost('selected');
|
||||
if($actionType == 0){
|
||||
for($i = 0;$i<count($selected_employees);$i++){log_message('error',$selected_employees[$i]);
|
||||
$result1 = $this->employeeModel->set(['client_id' => null, 'client_branch_id' => null])->where('id',$selected_employees[$i])->update();log_message('error',$result1);
|
||||
$result2 = $this->employeePolicyModel->where('employee_id',$selected_employees[$i])->delete();log_message('error',$result2);
|
||||
}
|
||||
}
|
||||
else if ($actionType == 1){
|
||||
for($i = 0;$i<count($selected_employees);$i++){
|
||||
log_message('error','Emp id is '.$selected_employees[$i]);
|
||||
$result1 = $this->employeeModel->set(['client_id' => null, 'client_branch_id' => null])->where('id',$selected_employees[$i])->update();log_message('error','result 1 is '.$result1);
|
||||
$result2 = $this->employeePolicyModel->where('employee_id',$selected_employees[$i])->delete();log_message('error', 'result 2 is '.$result2);
|
||||
$emp_code = $this->employeeModel->select('emp_code')->where('id',$selected_employees[$i])->first()['emp_code'];log_message('error','emp_code is '.$emp_code);
|
||||
$result3 = $this->employeeModel->where('emp_code',$emp_code)->whereNotIn('relationship',['self'])->delete();log_message('error','result 3 is '.$result3);
|
||||
}
|
||||
}
|
||||
else{
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Invalid action type.'], 404);
|
||||
}
|
||||
if($actionType == 1){
|
||||
if($result1 && $result2 && $result3){
|
||||
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Employees unmapped successfully and Dependencies are Deleted'], 200);
|
||||
}
|
||||
else{
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to unmap employees.'], 404);
|
||||
}
|
||||
}else{
|
||||
if($result1 && $result2 ){
|
||||
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Employees unmapped successfully'], 200);
|
||||
}
|
||||
else{
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to unmap employees.'], 404);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function cloneWorksheet()
|
||||
|
||||
@ -29,6 +29,7 @@ use App\Models\InsurerModel;
|
||||
|
||||
use App\Helpers\MailHelper;
|
||||
use App\Helpers\ExcelMergeHelper;
|
||||
use App\Helpers\ExcelSanitizeHelper;
|
||||
use Google\Service\CloudSearch\PushItem;
|
||||
use Kint;
|
||||
|
||||
@ -863,9 +864,12 @@ class LeadsController extends BaseController
|
||||
{
|
||||
$lead_id = $params['lead_id'];
|
||||
$lead_data = $this->leadsModel->find($lead_id);
|
||||
$file_name_with_path = WRITEPATH . "/uploads/lead_files/" . $lead_data['file_name'];
|
||||
|
||||
if (!$lead_data) {
|
||||
return ['status' => 'failed', 'message' => 'Lead data not found'];
|
||||
}
|
||||
if ($lead_data['file_name']) {
|
||||
$file_name_with_path = WRITEPATH . "/uploads/lead_files/" . $lead_data['file_name'];
|
||||
// $file_name_with_path = WRITEPATH . "/uploads/lead_files/NonPrintableCharacters.xlsx";
|
||||
|
||||
//check physical file
|
||||
if (!file_exists($file_name_with_path)) {
|
||||
@ -882,9 +886,8 @@ class LeadsController extends BaseController
|
||||
$members_sheet = $spreadsheet->getSheet(0);
|
||||
$highestRowAndColumn = $members_sheet->getHighestRowAndColumn();
|
||||
// dd($highestRowAndColumn);
|
||||
$members = $members_sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
|
||||
// dd($members[6]);
|
||||
|
||||
$uncleaned_members = $members_sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
|
||||
$members = ExcelSanitizeHelper::sanitizeArrayData($uncleaned_members);
|
||||
//get age band data
|
||||
$age_band_sheet = $spreadsheet->getSheet(1);
|
||||
$highestRowAndColumn = $age_band_sheet->getHighestRowAndColumn();
|
||||
@ -916,19 +919,24 @@ class LeadsController extends BaseController
|
||||
}
|
||||
|
||||
try {
|
||||
$result = $this->generateClassifierSpreadsheet($classifiers, 'writable/uploads/lead_files');
|
||||
|
||||
$result = $this->generateClassifierSpreadsheet($classifiers, WRITEPATH . 'uploads/lead_files/');
|
||||
if ($result['success']) {
|
||||
$this->myLogger->logme('error', "Spreadsheet generated successfully!");
|
||||
|
||||
echo "Location: " . $result['fullpath'] . "\n";
|
||||
echo "Filename: " . $result['filename'] . "\n";
|
||||
$filePaths = [
|
||||
['file_path' => WRITEPATH . 'uploads/lead_files/' . $lead_data['file_name'], 'sheets' => [0, 1]],
|
||||
['file_path' => 'writable/uploads/lead_files/' . $result['filename'], 'sheets' => []],
|
||||
['file_path' => WRITEPATH.'/uploads/lead_files/' . $result['filename'], 'sheets' => []],
|
||||
];
|
||||
$outputPath = WRITEPATH . 'uploads/lead_files/Member_Data.xlsx';
|
||||
$result = ExcelMergeHelper::mergeExcelFiles($filePaths, $outputPath);
|
||||
if ($result) {
|
||||
$result_merge = ExcelMergeHelper::mergeExcelFiles($filePaths, $outputPath);
|
||||
if ($result_merge) {
|
||||
// Call the delete function after the file is successfully created
|
||||
$deleteResponse = $this->deleteGeneratedFile($result['fullpath']);
|
||||
|
||||
// Add delete message to response
|
||||
$response['deleteMessage'] = $deleteResponse['message'];
|
||||
return ['status' => 'success', 'message' => 'Member_Data Merged Suceesfully'];
|
||||
}
|
||||
} else {
|
||||
@ -1055,23 +1063,22 @@ class LeadsController extends BaseController
|
||||
|
||||
public function generateClassifierSpreadsheet($classifiers, $outputDir = 'exports')
|
||||
{
|
||||
|
||||
if (!file_exists($outputDir)) {
|
||||
if (!mkdir($outputDir, 0755, true)) {
|
||||
throw new Exception("Failed to create directory: $outputDir");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check if directory is writable
|
||||
if (!is_writable($outputDir)) {
|
||||
throw new Exception("Directory is not writable: $outputDir");
|
||||
}
|
||||
|
||||
|
||||
// Generate unique filename
|
||||
$timestamp = date('Y-m-d_His');
|
||||
$filename = "member_classification_{$timestamp}.xlsx";
|
||||
$filepath = $outputDir . DIRECTORY_SEPARATOR . $filename;
|
||||
|
||||
|
||||
// Check if file already exists (shouldn't happen with timestamp, but just in case)
|
||||
if (file_exists($filepath)) {
|
||||
$counter = 1;
|
||||
@ -1081,28 +1088,39 @@ class LeadsController extends BaseController
|
||||
$filename = "member_classification_{$timestamp}_{$counter}.xlsx";
|
||||
$filepath = $outputDir . DIRECTORY_SEPARATOR . $filename;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$sheet->setTitle('Demography_Data');
|
||||
|
||||
// Get all age bands
|
||||
$age_bands = array_keys(reset($classifiers['general']));
|
||||
array_pop($age_bands); // Remove 'Grand Total'
|
||||
$age_bands[] = 'Grand Total'; // Add it back at the end
|
||||
|
||||
|
||||
$currentRow = 5; // Start from row 5 to match the example
|
||||
|
||||
|
||||
// Function to write section data
|
||||
$writeSectionData = function ($data, $sheet, &$currentRow) use ($age_bands) {
|
||||
// Set headers
|
||||
$writeSectionData = function ($data, $sheet, &$currentRow, $si_type) use ($age_bands) {
|
||||
// Add section header for the SI type
|
||||
$sheet->setCellValue('B' . $currentRow, strtoupper($si_type));
|
||||
|
||||
// Style section header
|
||||
$sheet->getStyle('B' . $currentRow)->applyFromArray([
|
||||
'font' => ['bold' => true, 'size' => 14],
|
||||
'alignment' => ['horizontal' => Alignment::HORIZONTAL_CENTER],
|
||||
]);
|
||||
|
||||
$currentRow++; // Move to the next row after the section header
|
||||
|
||||
// Set headers for the data table
|
||||
$sheet->setCellValue('B' . $currentRow, 'Relationship');
|
||||
$col = 'C';
|
||||
foreach ($age_bands as $band) {
|
||||
$sheet->setCellValue($col . $currentRow, $band);
|
||||
$col++;
|
||||
}
|
||||
|
||||
|
||||
// Style headers
|
||||
$lastCol = chr(ord('B') + count($age_bands));
|
||||
$headerRange = 'B' . $currentRow . ':' . $lastCol . $currentRow;
|
||||
@ -1118,9 +1136,9 @@ class LeadsController extends BaseController
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
$currentRow++;
|
||||
|
||||
|
||||
// Write data rows
|
||||
foreach ($data as $relation => $values) {
|
||||
if ($relation !== 'Grand Total') {
|
||||
@ -1131,7 +1149,7 @@ class LeadsController extends BaseController
|
||||
$sheet->setCellValue($col . $currentRow, $value);
|
||||
$col++;
|
||||
}
|
||||
|
||||
|
||||
// Style data row
|
||||
$dataRange = 'B' . $currentRow . ':' . $lastCol . $currentRow;
|
||||
$sheet->getStyle($dataRange)->applyFromArray([
|
||||
@ -1145,11 +1163,11 @@ class LeadsController extends BaseController
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
$currentRow++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add Grand Total row
|
||||
$sheet->setCellValue('B' . $currentRow, 'Grand Total');
|
||||
$col = 'C';
|
||||
@ -1157,7 +1175,7 @@ class LeadsController extends BaseController
|
||||
$sheet->setCellValue($col . $currentRow, $data['Grand Total'][$band]);
|
||||
$col++;
|
||||
}
|
||||
|
||||
|
||||
// Style Grand Total row
|
||||
$totalRange = 'B' . $currentRow . ':' . $lastCol . $currentRow;
|
||||
$sheet->getStyle($totalRange)->applyFromArray([
|
||||
@ -1176,37 +1194,41 @@ class LeadsController extends BaseController
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
$currentRow += 3; // Add gap after each section
|
||||
};
|
||||
|
||||
|
||||
// Write each SI section with gaps
|
||||
foreach ($classifiers as $si_type => $data) {
|
||||
$writeSectionData($data, $sheet, $currentRow);
|
||||
$writeSectionData($data, $sheet, $currentRow, $si_type);
|
||||
}
|
||||
|
||||
|
||||
// Auto-size columns
|
||||
foreach (range('B', chr(ord('B') + count($age_bands))) as $col) {
|
||||
$sheet->getColumnDimension($col)->setAutoSize(true);
|
||||
}
|
||||
|
||||
|
||||
// Create Excel file
|
||||
try {
|
||||
// Create Excel file
|
||||
$writer = new Xlsx($spreadsheet);
|
||||
$writer->save($filepath);
|
||||
|
||||
|
||||
// Verify file was created successfully
|
||||
if (!file_exists($filepath)) {
|
||||
throw new Exception("Failed to create file: $filepath");
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
// Return the file info after creation
|
||||
$response = [
|
||||
'success' => true,
|
||||
'filepath' => $filepath,
|
||||
'filename' => $filename,
|
||||
'fullpath' => realpath($filepath)
|
||||
];
|
||||
|
||||
return $response;
|
||||
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'success' => false,
|
||||
@ -1214,7 +1236,31 @@ class LeadsController extends BaseController
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Function to delete generated file
|
||||
public function deleteGeneratedFile($filePath)
|
||||
{
|
||||
try {
|
||||
if (file_exists($filePath)) {
|
||||
unlink($filePath); // Delete the file
|
||||
return [
|
||||
'success' => true,
|
||||
'message' => "File deleted successfully"
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => "File does not exist"
|
||||
];
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'success' => false,
|
||||
'error' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function getAge($available_col, $member, $col_index)
|
||||
{
|
||||
if ($available_col == 'age') {
|
||||
|
||||
@ -1641,7 +1641,35 @@ class MasterController extends AdminController
|
||||
print_r($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function testZeptoSMTP() {
|
||||
$message = '<style>body{font-family:Arial,sans-serif;color:#333;line-height:1.6;margin:0;padding:0}.email-container{width:100%;max-width:600px;margin:0 auto;padding:20px;border:1px solid #e0e0e0;background-color:#f9f9f9}.header{background-color:#4a90e2;color:#fff;padding:15px;text-align:center}.header h1{margin:0;font-size:24px}.content{padding:20px;background-color:#fff}.content h2{color:#4a90e2;font-size:20px;margin-top:0}.content p{margin:10px 0}.details-table{width:100%;border-collapse:collapse;margin-top:20px}.details-table td,.details-table th{border:1px solid #ddd;padding:10px;text-align:left}.details-table th{background-color:#f2f2f2}.footer{margin-top:20px;font-size:12px;color:#777;text-align:center}.attachment-note{margin-top:20px;padding:10px;background-color:#f7f7f7;border-left:4px solid #4a90e2;font-style:italic}</style><div class=email-container><div class=header><h1>Request for Quotation (RFQ)</h1></div><div class=content><h2>Dear {{RECIPIENT_NAME}},</h2><p>We are reaching out to request a quotation for the following insurance coverage. Please review the details below and provide your quote at your earliest convenience.<h2>RFQ Details</h2><table class=details-table><tr><th>Client name<td>{{CLIENT_NAME}}<tr><th>Coverage Type<td>{{POLICY_LONG_NAME}}<tr><th>Policy Start Date<td>{{POLICY_START_DATE}}<tr><th>Policy Duration<td>{{DURATION}}</table><div class=attachment-note>Please note: Additional terms and details are included in the attachment for your reference.</div><p>Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.<p>Best regards,<p><strong>Nhance India Pvt Ltd</strong><br></div><div class=footer><p>© Nhance India Pvt Ltd. All rights reserved.</div></div>';
|
||||
$attachments = [
|
||||
["filePath" => ROOTPATH."public/sample_excel/sample_addition.xls","fileName" => "sample_addition.xls"],
|
||||
["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.xls"],
|
||||
["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"]
|
||||
];
|
||||
$email_id = 'srinivas.saravanan@venbainfotech.com';
|
||||
$common = ['mail_type'=>'test_mail_cli'];
|
||||
// Send email and get response
|
||||
$result = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => $message,'attachments' => $attachments,'common'=>$common]);
|
||||
|
||||
|
||||
log_message('error',json_encode($result));
|
||||
// Format the response for display/debugging
|
||||
$response = [
|
||||
'success' => $result['success'] ?? false,
|
||||
'smtp_data' => [
|
||||
'last_reply' => $result['smtp_data']['last_reply'] ?? '',
|
||||
'error_info' => $result['smtp_data']['error_info'] ?? ''
|
||||
],
|
||||
'message_id' => $result['message_id'] ?? '',
|
||||
'timestamp' => $result['timestamp'] ?? ''
|
||||
];
|
||||
|
||||
// Return JSON response
|
||||
return $this->response->setJSON($result);
|
||||
}
|
||||
public function testCheckBounceMails()
|
||||
{
|
||||
$gmailapi = \Config\Services::gmailapi();
|
||||
|
||||
@ -1,218 +1,150 @@
|
||||
<?php
|
||||
namespace App\Helpers;
|
||||
|
||||
use Exception;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use Exception;
|
||||
|
||||
class ExcelMergeHelper
|
||||
{
|
||||
|
||||
protected static $logger;
|
||||
|
||||
public static function initialize()
|
||||
{
|
||||
self::$logger = \Config\Services::mylogger();
|
||||
}
|
||||
public static function mergeExcelFiles(array $filesToMerge, string $outputPath)
|
||||
class ExcelMergeHelper {
|
||||
/**
|
||||
* Main merge function with auto-retry
|
||||
*
|
||||
* @param array $filePaths Array of file paths with optional sheets to merge.
|
||||
* @param string $outputPath Path to save the merged Excel file.
|
||||
* @return string|null Returns output path on success, null on failure.
|
||||
*/
|
||||
public static function mergeExcelFiles(array $filePaths, string $outputPath): ?string
|
||||
{
|
||||
try {
|
||||
self::initialize();
|
||||
if (empty($filesToMerge)) {
|
||||
throw new Exception("No files provided for merging.");
|
||||
}
|
||||
|
||||
// Validate files exist and are readable
|
||||
foreach ($filesToMerge as $fileData) {
|
||||
if (!file_exists($fileData['file_path'])) {
|
||||
throw new Exception("File not found: " . $fileData['file_path']);
|
||||
}
|
||||
if (!is_readable($fileData['file_path'])) {
|
||||
throw new Exception("File not readable: " . $fileData['file_path']);
|
||||
}
|
||||
}
|
||||
|
||||
self::$logger->logme('error',"Creating new spreadsheet...");
|
||||
$mergedSpreadsheet = new Spreadsheet();
|
||||
$firstSheet = true;
|
||||
|
||||
foreach ($filesToMerge as $fileIndex => $fileData) {
|
||||
$filePath = $fileData['file_path'];
|
||||
$sheetsToMerge = $fileData['sheets'];
|
||||
self::$logger->logme('error',"Processing file $fileIndex: $filePath");
|
||||
|
||||
try {
|
||||
self::$logger->logme('error',"Attempting to load file: $filePath");
|
||||
$reader = IOFactory::createReaderForFile($filePath);
|
||||
$reader->setReadDataOnly(true); // This can help with memory usage
|
||||
self::$logger->logme('error',"Reader created successfully");
|
||||
|
||||
$currentSpreadsheet = $reader->load($filePath);
|
||||
self::$logger->logme('error',"File loaded successfully");
|
||||
|
||||
$sheetCount = $currentSpreadsheet->getSheetCount();
|
||||
self::$logger->logme('error',"File $filePath has $sheetCount sheets.");
|
||||
|
||||
if (empty($sheetsToMerge)) {
|
||||
$sheetsToMerge = range(0, $sheetCount - 1);
|
||||
}
|
||||
|
||||
foreach ($sheetsToMerge as $sourceSheetIndex) {
|
||||
self::$logger->logme('error',"Processing sheet index: $sourceSheetIndex");
|
||||
|
||||
if ($sourceSheetIndex < 0 || $sourceSheetIndex >= $sheetCount) {
|
||||
self::$logger->logme('error',"Invalid sheet index $sourceSheetIndex in file $filePath");
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$sourceSheet = $currentSpreadsheet->getSheet($sourceSheetIndex);
|
||||
self::$logger->logme('error',"Source sheet loaded");
|
||||
|
||||
$baseName = $sourceSheet->getTitle();
|
||||
self::$logger->logme('error',"Processing sheet: $baseName");
|
||||
|
||||
$newSheetName = $baseName;
|
||||
$counter = 1;
|
||||
|
||||
while ($mergedSpreadsheet->sheetNameExists($newSheetName)) {
|
||||
$newSheetName = $baseName . '_' . $fileIndex . '_' . $counter;
|
||||
$counter++;
|
||||
}
|
||||
self::$logger->logme('error',"New sheet name will be: $newSheetName");
|
||||
|
||||
if ($firstSheet) {
|
||||
$targetSheet = $mergedSpreadsheet->getActiveSheet();
|
||||
$targetSheet->setTitle($newSheetName);
|
||||
$firstSheet = false;
|
||||
self::$logger->logme('error',"Using first sheet");
|
||||
} else {
|
||||
$targetSheet = new Worksheet($mergedSpreadsheet, $newSheetName);
|
||||
$mergedSpreadsheet->addSheet($targetSheet);
|
||||
self::$logger->logme('error',"Created new sheet");
|
||||
}
|
||||
|
||||
self::$logger->logme('error',"Starting content copy for sheet: $newSheetName");
|
||||
self::copyWorksheetContent($sourceSheet, $targetSheet);
|
||||
self::$logger->logme('error',"Content copied successfully for sheet: $newSheetName");
|
||||
|
||||
} catch (Exception $e) {
|
||||
self::$logger->logme('error',"Error processing sheet $sourceSheetIndex: " . $e->getMessage());
|
||||
self::$logger->logme('error',"Error trace: " . $e->getTraceAsString());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Free up memory
|
||||
$currentSpreadsheet->disconnectWorksheets();
|
||||
unset($currentSpreadsheet);
|
||||
self::$logger->logme('error',"Cleaned up spreadsheet resources");
|
||||
|
||||
} catch (Exception $e) {
|
||||
self::$logger->logme('error',"Error processing file $filePath: " . $e->getMessage());
|
||||
self::$logger->logme('error',"Error trace: " . $e->getTraceAsString());
|
||||
continue;
|
||||
}
|
||||
|
||||
self::$logger->logme('error',"Current sheet names in merged spreadsheet:");
|
||||
foreach ($mergedSpreadsheet->getSheetNames() as $name) {
|
||||
self::$logger->logme('error'," - $name");
|
||||
}
|
||||
}
|
||||
|
||||
if ($mergedSpreadsheet->getSheetCount() === 0) {
|
||||
throw new Exception("No sheets were successfully merged.");
|
||||
}
|
||||
|
||||
self::$logger->logme('error',"Setting active sheet to index 0");
|
||||
$mergedSpreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
self::$logger->logme('error',"Preparing to save merged file to: $outputPath");
|
||||
|
||||
// Ensure output directory exists
|
||||
$outputDir = dirname($outputPath);
|
||||
if (!is_dir($outputDir)) {
|
||||
mkdir($outputDir, 0777, true);
|
||||
}
|
||||
|
||||
if (!is_writable($outputDir)) {
|
||||
throw new Exception("Output directory is not writable: $outputDir");
|
||||
}
|
||||
|
||||
if (ob_get_length()) {
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
self::$logger->logme('error',"Creating Excel writer");
|
||||
$writer = new Xlsx($mergedSpreadsheet);
|
||||
|
||||
self::$logger->logme('error',"Saving file...");
|
||||
$writer->save($outputPath);
|
||||
|
||||
// Free up memory
|
||||
$mergedSpreadsheet->disconnectWorksheets();
|
||||
unset($mergedSpreadsheet);
|
||||
|
||||
self::$logger->logme('error',"Merge successful. File saved at: $outputPath");
|
||||
return $outputPath;
|
||||
|
||||
log_message('debug', 'Attempting merge with original file order');
|
||||
return self::processFiles($filePaths, $outputPath);
|
||||
} catch (Exception $e) {
|
||||
self::$logger->logme('error',"Excel Merge Error: " . $e->getMessage());
|
||||
self::$logger->logme('error',"Error trace: " . $e->getTraceAsString());
|
||||
throw $e;
|
||||
log_message('error', 'First attempt failed: ' . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine());
|
||||
log_message('debug', 'Retrying with reversed file order');
|
||||
|
||||
// Reverse the file order and try again
|
||||
$reversedFiles = array_reverse($filePaths);
|
||||
|
||||
try {
|
||||
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());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function copyWorksheetContent($sourceSheet, $targetSheet)
|
||||
/**
|
||||
* Process files to merge spreadsheets
|
||||
*
|
||||
* @param array $filePaths
|
||||
* @param string $outputPath
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
private static function processFiles(array $filePaths, string $outputPath): string
|
||||
{
|
||||
try {
|
||||
self::$logger->logme('error',"Starting copyWorksheetContent");
|
||||
|
||||
// Get the highest row and column indexes
|
||||
$highestRow = $sourceSheet->getHighestRow();
|
||||
$highestColumn = $sourceSheet->getHighestColumn();
|
||||
self::$logger->logme('error',"Copying data from range A1:{$highestColumn}{$highestRow}");
|
||||
log_message('debug', 'Starting Excel merge process');
|
||||
log_message('debug', 'Files to process: ' . json_encode($filePaths));
|
||||
|
||||
if (empty($filePaths)) {
|
||||
throw new Exception("No files provided to merge");
|
||||
}
|
||||
|
||||
// Copy cell values only first for better performance
|
||||
foreach ($sourceSheet->getRowIterator() as $row) {
|
||||
$cellIterator = $row->getCellIterator();
|
||||
$cellIterator->setIterateOnlyExistingCells(true);
|
||||
foreach ($cellIterator as $cell) {
|
||||
$column = $cell->getColumn();
|
||||
$rowIndex = $cell->getRow();
|
||||
$targetSheet->setCellValue($column . $rowIndex, $cell->getValue());
|
||||
// Initialize an empty merged spreadsheet
|
||||
$mergedSpreadsheet = new Spreadsheet();
|
||||
$mergedSpreadsheet->removeSheetByIndex(0); // Remove the default empty sheet
|
||||
|
||||
// Process the base file
|
||||
$firstFile = array_shift($filePaths);
|
||||
self::processSingleFile($firstFile, $mergedSpreadsheet);
|
||||
|
||||
// Process remaining files
|
||||
foreach ($filePaths as $index => $fileInfo) {
|
||||
self::processSingleFile($fileInfo, $mergedSpreadsheet, $index);
|
||||
}
|
||||
|
||||
// Save the merged file
|
||||
log_message('debug', "Saving merged file to: {$outputPath}");
|
||||
$writer = IOFactory::createWriter($mergedSpreadsheet, 'Xlsx');
|
||||
$writer->setPreCalculateFormulas(false);
|
||||
$writer->save($outputPath);
|
||||
|
||||
// Clean up
|
||||
$mergedSpreadsheet->disconnectWorksheets();
|
||||
unset($mergedSpreadsheet);
|
||||
gc_collect_cycles();
|
||||
|
||||
log_message('debug', 'Excel merge process completed successfully');
|
||||
return $outputPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a single file to merge its sheets into the merged spreadsheet
|
||||
*
|
||||
* @param array $fileInfo
|
||||
* @param Spreadsheet $mergedSpreadsheet
|
||||
* @param int|null $index
|
||||
* @throws Exception
|
||||
*/
|
||||
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}");
|
||||
return;
|
||||
}
|
||||
|
||||
log_message('debug', "Processing file " . ($index ?? 'base') . ": " . $fileInfo['file_path']);
|
||||
|
||||
try {
|
||||
// Load the source spreadsheet
|
||||
$sourceSpreadsheet = IOFactory::load($fileInfo['file_path']);
|
||||
|
||||
// Get all worksheets
|
||||
$worksheets = $sourceSpreadsheet->getAllSheets();
|
||||
$totalSheets = count($worksheets);
|
||||
log_message('debug', "Total sheets in file: " . $totalSheets);
|
||||
|
||||
$sheetsToMerge = $fileInfo['sheets'] ?? [];
|
||||
|
||||
// Process each worksheet
|
||||
foreach ($worksheets as $sheetIndex => $worksheet) {
|
||||
if (empty($sheetsToMerge) || in_array($sheetIndex, $sheetsToMerge)) {
|
||||
try {
|
||||
$sheetName = $worksheet->getTitle();
|
||||
log_message('debug', "Processing sheet: {$sheetName}");
|
||||
|
||||
// Generate unique sheet name before cloning
|
||||
$newName = $sheetName;
|
||||
$counter = 1;
|
||||
|
||||
while (in_array($newName, $mergedSpreadsheet->getSheetNames())) {
|
||||
$newName = $sheetName . "_" . $counter++;
|
||||
log_message('debug', "Sheet name already exists. Trying new name: {$newName}");
|
||||
}
|
||||
|
||||
// Clone the worksheet and set the new name
|
||||
$clonedSheet = clone $worksheet;
|
||||
$clonedSheet->setTitle($newName);
|
||||
|
||||
// Add as external sheet
|
||||
$mergedSpreadsheet->addExternalSheet($clonedSheet);
|
||||
|
||||
log_message('debug', "Successfully added sheet: {$newName}");
|
||||
} catch (Exception $e) {
|
||||
log_message('error', "Error processing sheet {$sheetName} as new name {$newName}: " . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
self::$logger->logme('error',"Basic cell values copied");
|
||||
|
||||
// Copy column dimensions
|
||||
foreach ($sourceSheet->getColumnDimensions() as $columnId => $sourceDim) {
|
||||
$targetSheet->getColumnDimension($columnId)
|
||||
->setWidth($sourceDim->getWidth())
|
||||
->setVisible($sourceDim->getVisible())
|
||||
->setAutoSize($sourceDim->getAutoSize());
|
||||
}
|
||||
self::$logger->logme('error',"Column dimensions copied");
|
||||
|
||||
// Copy row dimensions
|
||||
foreach ($sourceSheet->getRowDimensions() as $rowId => $sourceDim) {
|
||||
$targetSheet->getRowDimension($rowId)
|
||||
->setRowHeight($sourceDim->getRowHeight())
|
||||
->setVisible($sourceDim->getVisible());
|
||||
}
|
||||
self::$logger->logme('error',"Row dimensions copied");
|
||||
|
||||
// Copy basic worksheet properties
|
||||
$targetSheet->setShowGridlines($sourceSheet->getShowGridlines());
|
||||
$targetSheet->setShowRowColHeaders($sourceSheet->getShowRowColHeaders());
|
||||
self::$logger->logme('error',"Worksheet properties copied");
|
||||
|
||||
// Clean up source spreadsheet
|
||||
$sourceSpreadsheet->disconnectWorksheets();
|
||||
unset($sourceSpreadsheet);
|
||||
gc_collect_cycles();
|
||||
|
||||
} catch (Exception $e) {
|
||||
self::$logger->logme('error',"Error in copyWorksheetContent: " . $e->getMessage());
|
||||
self::$logger->logme('error',"Error trace: " . $e->getTraceAsString());
|
||||
throw $e;
|
||||
log_message('error', "Error processing file {$fileInfo['file_path']}: " . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
51
app/Helpers/ExcelSanitizeHelper.php
Normal file
51
app/Helpers/ExcelSanitizeHelper.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace App\Helpers;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
|
||||
|
||||
class ExcelSanitizeHelper
|
||||
{
|
||||
/**
|
||||
* Array of non-printable characters to be removed from strings.
|
||||
*
|
||||
* You can modify this array to include any characters you want to remove.
|
||||
*/
|
||||
private static $nonPrintableChars = [
|
||||
"\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\x09",
|
||||
"\x0A", "\x0B", "\x0C", "\x0D", "\x0E", "\x0F", "\x10", "\x11", "\x12", "\x13",
|
||||
"\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1A", "\x1B", "\x1C", "\x1D",
|
||||
"\x1E", "\x1F", "\x7F", "_x000D_", "_x000A_", "_x0009_", "_x0008_", "_x0007_",
|
||||
"_x0006_", "_x0005_", "_x0004_", "_x0003_", "_x0002_", "_x0001_"
|
||||
];
|
||||
|
||||
/**
|
||||
* Sanitizes array data by removing non-printable characters and trimming whitespace from strings.
|
||||
*
|
||||
* @param array $data Input array containing data to sanitize
|
||||
* @return array Sanitized array with non-printable characters removed and leading/trailing whitespace trimmed
|
||||
*/
|
||||
public static function sanitizeArrayData(array $data): array
|
||||
{
|
||||
try {
|
||||
$cleanData = [];
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
$cleanData[$key] = self::sanitizeArrayData($value); // Recursive call for nested arrays
|
||||
} elseif (is_string($value)) {
|
||||
// Remove non-printable characters and trim whitespace from strings
|
||||
$cleanData[$key] = trim(str_replace(self::$nonPrintableChars, '', $value));
|
||||
} else {
|
||||
$cleanData[$key] = $value; // Keep non-string/non-array data as is
|
||||
}
|
||||
}
|
||||
|
||||
return $cleanData;
|
||||
} catch (\Exception $e) {
|
||||
// Log the error and the problematic data for debugging
|
||||
log_message('error', 'Error sanitizing array data: ' . $e->getMessage());
|
||||
log_message('error', 'Problematic data: ' . json_encode($data));
|
||||
return $data; // Return the original data in case of error
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -77,17 +77,16 @@ class GmailResponseHandler{
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($params['gmail_api']['status']) && $params['gmail_api']['status'] == 1 ){
|
||||
$data['gmail_api_status'] = isset($params['gmail_api']['status']) ? $params['gmail_api']['status'] : null;
|
||||
$data['gmail_api_id'] = isset($params['gmail_api']['data']['id']) ? $params['gmail_api']['data']['id'] : null;
|
||||
$data['received_message'] = isset($params['gmail_api']['data']['labelIds']) ? json_encode($params['gmail_api']['data']['labelIds']) : null;
|
||||
if(isset($params['zepto_api']['data']) && $params['zepto_api']['message'] == 'OK' ){
|
||||
$data['gmail_api_status'] = isset($params['zepto_api']['data']) ? $params['zepto_api']['data'][0]['code'] : null;
|
||||
$data['gmail_api_id'] = isset($params['zepto_api']['request_id']) ? $params['zepto_api']['request_id'] : null;
|
||||
$data['received_message'] = isset($params['zepto_api']['data'][0]['message']) ? json_encode($params['zepto_api']['data'][0]['message']) : null;
|
||||
|
||||
}
|
||||
elseif(isset($params['gmail_api']['status']) && $params['gmail_api']['status'] == false ){
|
||||
$data['gmail_api_status'] = $params['gmail_api']['status'];
|
||||
if(isset($params['gmail_api']['data'])){
|
||||
$data['received_message'] = json_encode($params['gmail_api']['data']);
|
||||
}
|
||||
elseif(isset($params['zepto_api']['error'])){
|
||||
$data['gmail_api_status'] = isset($params['zepto_api']['error']['code'])?$params['zepto_api']['error']['code']:null;
|
||||
$data['received_message'] = json_encode($params['zepto_api']);
|
||||
$data['gmail_api_id'] = isset($params['zepto_api']['error']['request_id']) ? $params['zepto_api']['error']['request_id'] : null;
|
||||
}
|
||||
|
||||
$gmailModel = new GmailSentHistoryModel();
|
||||
@ -96,7 +95,9 @@ class GmailResponseHandler{
|
||||
|
||||
public function gmail_response_logger($params)
|
||||
{
|
||||
$this->myLogger->logme('error',json_encode($params));
|
||||
if(isset($params['zepto_api']['error'])){
|
||||
$this->myLogger->logme('error',json_encode($params));
|
||||
}
|
||||
}
|
||||
|
||||
public function client_id_flag_setter($params)
|
||||
@ -119,7 +120,6 @@ class GmailResponseHandler{
|
||||
$error = $e->getMessage();
|
||||
$this->myLogger->logme('error','An Error Occured - '.$error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,177 +1,422 @@
|
||||
<?php
|
||||
|
||||
// namespace App\Helpers;
|
||||
// use Psr\Log\LoggerInterface;
|
||||
|
||||
// use App\Controllers\BaseController;
|
||||
|
||||
// use PHPMailer\PHPMailer\PHPMailer;
|
||||
// use PHPMailer\PHPMailer\SMTP;
|
||||
// use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
// use App\Models\JobModel;
|
||||
|
||||
// class MailHelper
|
||||
// {
|
||||
// public static function send_email_smtp($params)
|
||||
// {
|
||||
|
||||
// // print_r($params);die;
|
||||
// $myLogger = \Config\Services::mylogger();
|
||||
// $emaill = $params['mail'];
|
||||
// $subject = $params['subject'];
|
||||
// $message = $params['message'];
|
||||
// if (isset($params['bcc'])) {
|
||||
// $bcc = $params['bcc'];
|
||||
// }else{
|
||||
// $bcc= '';
|
||||
// }
|
||||
// try {
|
||||
|
||||
// $email = \Config\Services::email();
|
||||
// $email->setMailType('html');
|
||||
// $email->setFrom('bbone@venbait.in', 'Nhance');
|
||||
|
||||
// $email->setTo($emaill);
|
||||
|
||||
// if (!empty($bcc)) {
|
||||
// // Convert the comma-separated string into an array
|
||||
// $bccList = explode(',', $bcc);
|
||||
// // Trim whitespace from each email ID
|
||||
// $bccList = array_map('trim', $bccList);
|
||||
// // Set BCC recipients
|
||||
// $email->setBCC($bccList);
|
||||
// }
|
||||
|
||||
// $email->setSubject($subject);
|
||||
|
||||
// $email->setMessage($message);
|
||||
|
||||
// if ($email->send()) {
|
||||
|
||||
// return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...','data' => $emaill,],200);
|
||||
// } else {
|
||||
// $myLogger->logme('error', "mail sent failed - $emaill");
|
||||
// return json_encode(['status' => 'failed','code' => 404,'message'=>'Email Sent Failed...','data' => $emaill ],404);
|
||||
// }
|
||||
|
||||
// } catch (Exception $e) {
|
||||
// $msg = $e->getMessage();
|
||||
// $myLogger->logme('error', "mail sent failed - $msg");
|
||||
// return json_encode(['status' => 'failed','code' => 500,'data' => $emaill],500);
|
||||
// }
|
||||
// }
|
||||
|
||||
// public static function bulk_mail_smtp(array $mails = [])
|
||||
// {
|
||||
// // print_r();die;
|
||||
// $model = new JobModel();
|
||||
// $start = microtime(true);
|
||||
// $runtime= 0;
|
||||
// try {
|
||||
// foreach ( $mails as $index=>$mail) {
|
||||
// $runtime = microtime(true) - $start;
|
||||
// $send_mail = self::send_email($mail);
|
||||
// }
|
||||
|
||||
// return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...'],200);
|
||||
|
||||
// } catch (\Throwable $th) {
|
||||
// return json_encode(['status' => 'failed','code' => 500],500);
|
||||
// }
|
||||
// }
|
||||
|
||||
// //using GmailAPI
|
||||
// public static function send_email($params)
|
||||
// {
|
||||
|
||||
// // print_r($params);die;
|
||||
// $myLogger = \Config\Services::mylogger();
|
||||
// $gmailapi = \Config\Services::gmailapi();
|
||||
|
||||
// $emaill = $params['mail'];
|
||||
// $subject = $params['subject'];
|
||||
// $message = $params['message'];
|
||||
// $attachments = isset($params['attachments']) && count($params['attachments']) ? $params['attachments'] : [];
|
||||
// $common = isset($params['common'])?$params['common']:'';
|
||||
// //check BCC mail
|
||||
// if (isset($params['bcc'])) {
|
||||
// $bcc = $params['bcc'];
|
||||
// if(!is_array($bcc)){
|
||||
// $bcc = explode(',', $bcc);
|
||||
// }
|
||||
// }else{
|
||||
// $bcc = [];
|
||||
// }
|
||||
|
||||
// //check CC mail
|
||||
// if (isset($params['cc'])) {
|
||||
// $cc = $params['cc'];
|
||||
// if(!is_array($cc)){
|
||||
// $cc = explode(',', $cc);
|
||||
// }
|
||||
// }else{
|
||||
// $cc = [];
|
||||
// }
|
||||
|
||||
// //check REPLY TO mail
|
||||
// $reply_to = "";
|
||||
// if(isset($params['reply_to']) && !empty($params['reply_to'])){
|
||||
// $reply_to = $params['reply_to'];
|
||||
// }
|
||||
// $MailDataHelper = new GmailResponseHandler();
|
||||
|
||||
// $res['params'] = $params;
|
||||
// try {
|
||||
|
||||
// $res['gmail_api'] = $gmailapi->sendMessage($emaill, $subject, $message, 'no-reply@nhanceindia.in', $reply_to, $cc, $bcc,$attachments);
|
||||
// if($res['gmail_api']['status'])
|
||||
// {
|
||||
// $response = $res;
|
||||
// $MailDataHelper->receive_and_distribute_param_to_functions($response);
|
||||
// return json_encode(['status' => 'success','code' => 200, 'message'=>('Email Sent Successfully...'.$emaill),'data' => $res,],200);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $myLogger->logme('error', "mail sent failed - $emaill");
|
||||
// $response = $res;
|
||||
// $MailDataHelper->receive_and_distribute_param_to_functions($response);
|
||||
// return json_encode(['status' => 'failed','code' => 404,'message'=>( 'Email Sent Failed...' . $emaill ),'data' => $res ],404);
|
||||
// }
|
||||
|
||||
// } catch (Exception $e) {
|
||||
// $msg['error'] = $e->getMessage();
|
||||
// $msg['params'] = $params;
|
||||
// $myLogger->logme('error', "mail sent failed - $msg");
|
||||
// $response = $msg;
|
||||
// $MailDataHelper->receive_and_distribute_param_to_functions($response);
|
||||
// return json_encode(['status' => 'failed','code' => 500,'data' => $msg],500);
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// public static function bulk_mail(array $mails = [])
|
||||
// {
|
||||
// // print_r($mails);die;
|
||||
// $model = new JobModel();
|
||||
// $start = microtime(true);
|
||||
// $runtime= 0;
|
||||
// try {
|
||||
// foreach ( $mails as $index=>$mail) {
|
||||
// $runtime = microtime(true) - $start;
|
||||
// $send_mail = self::send_email($mail);
|
||||
// }
|
||||
|
||||
// return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...'],200);
|
||||
|
||||
// } catch (\Throwable $th) {
|
||||
// $error = $th->getMessage();
|
||||
// log_message('error',$error);
|
||||
// return json_encode(['status' => 'failed','code' => 500,'error'=>$error],500);
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
|
||||
namespace App\Helpers;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\SMTP;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
use App\Models\JobModel;
|
||||
|
||||
class MailHelper
|
||||
{
|
||||
public static function send_email_smtp($params)
|
||||
{
|
||||
|
||||
// print_r($params);die;
|
||||
$myLogger = \Config\Services::mylogger();
|
||||
$emaill = $params['mail'];
|
||||
$subject = $params['subject'];
|
||||
$message = $params['message'];
|
||||
if (isset($params['bcc'])) {
|
||||
$bcc = $params['bcc'];
|
||||
}else{
|
||||
$bcc= '';
|
||||
} else {
|
||||
$bcc = '';
|
||||
}
|
||||
$from_address = getenv('email.fromEmail');
|
||||
|
||||
|
||||
try {
|
||||
|
||||
$email = \Config\Services::email();
|
||||
$email->setMailType('html');
|
||||
$email->setFrom('bbone@venbait.in', 'Nhance');
|
||||
|
||||
$email->setTo($emaill);
|
||||
$curl = curl_init();
|
||||
$postData = [
|
||||
'from' => [
|
||||
'address' => $from_address
|
||||
],
|
||||
'to' => [
|
||||
[
|
||||
'email_address' => [
|
||||
'address' => $emaill
|
||||
]
|
||||
]
|
||||
],
|
||||
'subject' => $subject,
|
||||
'htmlbody' => $message
|
||||
];
|
||||
|
||||
// Add BCC if present
|
||||
if (!empty($bcc)) {
|
||||
// Convert the comma-separated string into an array
|
||||
$bccList = explode(',', $bcc);
|
||||
// Trim whitespace from each email ID
|
||||
$bccList = array_map('trim', $bccList);
|
||||
// Set BCC recipients
|
||||
$email->setBCC($bccList);
|
||||
$postData['bcc'] = array_map(function($email) {
|
||||
return [
|
||||
'email_address' => [
|
||||
'address' => $email
|
||||
]
|
||||
];
|
||||
}, $bccList);
|
||||
}
|
||||
|
||||
$email->setSubject($subject);
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => "https://api.zeptomail.in/v1.1/email",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => json_encode($postData),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"accept: application/json",
|
||||
"authorization: Zoho-enczapikey " . getenv('ZEPTO_API_KEY'),
|
||||
"cache-control: no-cache",
|
||||
"content-type: application/json",
|
||||
],
|
||||
]);
|
||||
|
||||
$email->setMessage($message);
|
||||
$response = curl_exec($curl);
|
||||
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
$err = curl_error($curl);
|
||||
|
||||
if ($email->send()) {
|
||||
curl_close($curl);
|
||||
if ($err) {
|
||||
$myLogger->logme('error', "mail sent failed - $emaill");
|
||||
return json_encode(['status' => 'failed', 'code' => 404, 'message' => 'Email Sent Failed...', 'data' => $emaill], 404);
|
||||
}
|
||||
|
||||
return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...','data' => $emaill,],200);
|
||||
$apiResponse = json_decode($response, true);
|
||||
|
||||
if ($httpCode === 200) {
|
||||
return json_encode(['status' => 'success', 'code' => 200, 'message' => 'Email Sent Successfully...', 'data' => $emaill], 200);
|
||||
} else {
|
||||
$myLogger->logme('error', "mail sent failed - $emaill");
|
||||
return json_encode(['status' => 'failed','code' => 404,'message'=>'Email Sent Failed...','data' => $emaill ],404);
|
||||
return json_encode(['status' => 'failed', 'code' => 404, 'message' => 'Email Sent Failed...', 'data' => $emaill], 404);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$msg = $e->getMessage();
|
||||
$myLogger->logme('error', "mail sent failed - $msg");
|
||||
return json_encode(['status' => 'failed','code' => 500,'data' => $emaill],500);
|
||||
}
|
||||
return json_encode(['status' => 'failed', 'code' => 500, 'data' => $emaill], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public static function bulk_mail_smtp(array $mails = [])
|
||||
{
|
||||
// print_r();die;
|
||||
$model = new JobModel();
|
||||
$start = microtime(true);
|
||||
$runtime= 0;
|
||||
try {
|
||||
foreach ( $mails as $index=>$mail) {
|
||||
$runtime = 0;
|
||||
try {
|
||||
foreach ($mails as $index => $mail) {
|
||||
$runtime = microtime(true) - $start;
|
||||
$send_mail = self::send_email($mail);
|
||||
}
|
||||
|
||||
return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...'],200);
|
||||
}
|
||||
|
||||
return json_encode(['status' => 'success', 'code' => 200, 'message' => 'Email Sent Successfully...'], 200);
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
return json_encode(['status' => 'failed','code' => 500],500);
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
return json_encode(['status' => 'failed', 'code' => 500], 500);
|
||||
}
|
||||
}
|
||||
|
||||
//using GmailAPI
|
||||
public static function send_email($params)
|
||||
public static function send_email($params)
|
||||
{
|
||||
|
||||
// print_r($params);die;
|
||||
$myLogger = \Config\Services::mylogger();
|
||||
$gmailapi = \Config\Services::gmailapi();
|
||||
|
||||
|
||||
$emaill = $params['mail'];
|
||||
$subject = $params['subject'];
|
||||
$message = $params['message'];
|
||||
$attachments = isset($params['attachments']) && count($params['attachments']) ? $params['attachments'] : [];
|
||||
$common = isset($params['common'])?$params['common']:'';
|
||||
//check BCC mail
|
||||
if (isset($params['bcc'])) {
|
||||
$bcc = $params['bcc'];
|
||||
if(!is_array($bcc)){
|
||||
$bcc = explode(',', $bcc);
|
||||
}
|
||||
}else{
|
||||
$bcc = [];
|
||||
}
|
||||
$attachments = isset($params['attachments']) ? $params['attachments'] : [];
|
||||
$common = isset($params['common']) ? $params['common'] : '';
|
||||
|
||||
//check CC mail
|
||||
if (isset($params['cc'])) {
|
||||
$cc = $params['cc'];
|
||||
if(!is_array($cc)){
|
||||
$cc = explode(',', $cc);
|
||||
}
|
||||
}else{
|
||||
$cc = [];
|
||||
}
|
||||
|
||||
//check REPLY TO mail
|
||||
$reply_to = "";
|
||||
if(isset($params['reply_to']) && !empty($params['reply_to'])){
|
||||
$reply_to = $params['reply_to'];
|
||||
}
|
||||
$MailDataHelper = new GmailResponseHandler();
|
||||
|
||||
$res['params'] = $params;
|
||||
$from_address = getenv('email.fromEmail');
|
||||
try {
|
||||
|
||||
$res['gmail_api'] = $gmailapi->sendMessage($emaill, $subject, $message, 'no-reply@nhanceindia.in', $reply_to, $cc, $bcc,$attachments);
|
||||
if($res['gmail_api']['status'])
|
||||
{
|
||||
$response = $res;
|
||||
$MailDataHelper->receive_and_distribute_param_to_functions($response);
|
||||
return json_encode(['status' => 'success','code' => 200, 'message'=>('Email Sent Successfully...'.$emaill),'data' => $res,],200);
|
||||
}
|
||||
else
|
||||
{
|
||||
$myLogger->logme('error', "mail sent failed - $emaill");
|
||||
$response = $res;
|
||||
$MailDataHelper->receive_and_distribute_param_to_functions($response);
|
||||
return json_encode(['status' => 'failed','code' => 404,'message'=>( 'Email Sent Failed...' . $emaill ),'data' => $res ],404);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
$curl = curl_init();
|
||||
|
||||
$postData = [
|
||||
'from' => [
|
||||
'address' => $from_address
|
||||
],
|
||||
'to' => [
|
||||
[
|
||||
'email_address' => [
|
||||
'address' => $emaill
|
||||
]
|
||||
]
|
||||
],
|
||||
'subject' => $subject,
|
||||
'htmlbody' => $message
|
||||
];
|
||||
|
||||
// Handle attachments
|
||||
if (!empty($attachments)) {
|
||||
$postData['attachments'] = [];
|
||||
foreach ($attachments as $attachment) {
|
||||
if (isset($attachment['filePath']) && file_exists($attachment['filePath'])) {
|
||||
// Determine MIME type dynamically
|
||||
$fileMimeType = mime_content_type($attachment['filePath']);
|
||||
|
||||
$postData['attachments'][] = [
|
||||
'content' => base64_encode(file_get_contents($attachment['filePath'])),
|
||||
'name' => $attachment['fileName'],
|
||||
'mime_type' => $fileMimeType, // Add mime_type field
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => "https://api.zeptomail.in/v1.1/email",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => json_encode($postData),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"accept: application/json",
|
||||
"authorization: Zoho-enczapikey " . getenv('ZEPTO_API_KEY'),
|
||||
"cache-control: no-cache",
|
||||
"content-type: application/json",
|
||||
],
|
||||
]);
|
||||
|
||||
$mail_result = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
curl_close($curl);
|
||||
// log_message('error','inside mail helper');
|
||||
// log_message('error', $response.' error->'.$err);die();
|
||||
$res['params'] = $params;
|
||||
$MailDataHelper = new GmailResponseHandler();
|
||||
$apiResponse = json_decode($mail_result, true);
|
||||
$res['zepto_api'] = $apiResponse;
|
||||
if (isset($apiResponse['error'])) {
|
||||
$response = $res;
|
||||
$MailDataHelper->receive_and_distribute_param_to_functions($response);
|
||||
return json_encode([
|
||||
'status' => 'failed',
|
||||
'code' => 404,
|
||||
'message' => 'Email Sent Failed...' . $emaill,
|
||||
'data' => $res
|
||||
], 404);
|
||||
}
|
||||
|
||||
// $apiResponse = json_decode($response, true);
|
||||
|
||||
// Check if request_id exists in response (indicates success)
|
||||
if (isset($apiResponse['data'])) {
|
||||
$response = $res;
|
||||
$MailDataHelper->receive_and_distribute_param_to_functions($response);
|
||||
return json_encode([
|
||||
'status' => 'success',
|
||||
'code' => 200,
|
||||
'message' => 'Email Sent Successfully...' . $emaill,
|
||||
'data' => $res
|
||||
], 200);
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$msg['error'] = $e->getMessage();
|
||||
$msg['params'] = $params;
|
||||
$myLogger->logme('error', "mail sent failed - $msg");
|
||||
$response = $msg;
|
||||
$response = $res;
|
||||
$MailDataHelper->receive_and_distribute_param_to_functions($response);
|
||||
return json_encode(['status' => 'failed','code' => 500,'data' => $msg],500);
|
||||
return json_encode([
|
||||
'status' => 'failed',
|
||||
'code' => 500,
|
||||
'data' => $msg
|
||||
], 500);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function bulk_mail(array $mails = [])
|
||||
{
|
||||
// print_r($mails);die;
|
||||
$model = new JobModel();
|
||||
$start = microtime(true);
|
||||
$runtime= 0;
|
||||
try {
|
||||
foreach ( $mails as $index=>$mail) {
|
||||
$runtime = 0;
|
||||
try {
|
||||
foreach ($mails as $index => $mail) {
|
||||
$runtime = microtime(true) - $start;
|
||||
$send_mail = self::send_email($mail);
|
||||
}
|
||||
|
||||
return json_encode(['status' => 'success', 'code' => 200, 'message' => 'Email Sent Successfully...'], 200);
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
$error = $th->getMessage();
|
||||
log_message('error', $error);
|
||||
return json_encode(['status' => 'failed', 'code' => 500, 'error' => $error], 500);
|
||||
}
|
||||
|
||||
return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...'],200);
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
$error = $th->getMessage();
|
||||
log_message('error',$error);
|
||||
return json_encode(['status' => 'failed','code' => 500,'error'=>$error],500);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@ -210,4 +210,32 @@ class EmployeeModel extends Model
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function getTestEmployeeData(){
|
||||
$query = "
|
||||
SELECT
|
||||
e.*,
|
||||
(
|
||||
SELECT
|
||||
COUNT(ep.client_policy_id)
|
||||
FROM
|
||||
employee_polices ep
|
||||
WHERE
|
||||
ep.employee_id = e.id
|
||||
) AS policy_count
|
||||
FROM
|
||||
employees e
|
||||
WHERE
|
||||
e.emp_code LIKE 'TEST%'
|
||||
ORDER BY
|
||||
e.emp_code,
|
||||
CASE
|
||||
WHEN e.relationship = 'self' THEN 1
|
||||
WHEN e.relationship = 'spouse' THEN 2
|
||||
ELSE 3
|
||||
END;
|
||||
";
|
||||
$results = $this->db->query($query)->getResultArray();
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -581,6 +581,9 @@
|
||||
<li>
|
||||
<a href="<?= base_url('/employee/enrollment-list') ?>">View Enrolment</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/employee/test_members_list') ?>">Test Members List</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
1005
app/Views/test_members_list.php
Normal file
1005
app/Views/test_members_list.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -17,15 +17,15 @@
|
||||
"dompdf/dompdf": "^2.0",
|
||||
"firebase/php-jwt": "^6.10",
|
||||
"google/apiclient": "^2.15.0",
|
||||
"kreait/firebase-php": "^7.0",
|
||||
"laminas/laminas-escaper": "^2.9",
|
||||
"php-amqplib/php-amqplib": "^2.8",
|
||||
"phpmailer/phpmailer": "^6.9",
|
||||
"phpoffice/phpspreadsheet": "^2.1",
|
||||
"psr/http-message": "^1.0",
|
||||
"psr/log": "^1.1",
|
||||
"slim/slim": "^4.13",
|
||||
"zircote/swagger-php": "^4.8",
|
||||
"psr/http-message": "^1.0",
|
||||
"kreait/firebase-php":"^7.0"
|
||||
"zircote/swagger-php": "^4.8"
|
||||
},
|
||||
"require-dev": {
|
||||
"codeigniter/coding-standard": "^1.7",
|
||||
|
||||
Binary file not shown.
@ -9,20 +9,21 @@ class ExcelMergeHelperTest extends TestCase
|
||||
public function testMergeExcelFiles_Success()
|
||||
{
|
||||
// Use the paths you provided
|
||||
$filePaths = [
|
||||
// ['file_path' =>WRITEPATH.'uploads/lead_files/Member_Data.xlsx','sheets' => []],
|
||||
// ['file_path' =>WRITEPATH.'/tmp/RFQ_ABC_GMC_20241220140640.xlsx','sheets' => []],
|
||||
$filePaths = [
|
||||
['file_path' =>WRITEPATH.'uploads/lead_files/Member_Data.xlsx','sheets' => []],
|
||||
|
||||
['file_path' =>'/home/venba/Downloads/enrollment (1).xlsx','sheets' => []],
|
||||
['file_path' =>'/home/venba/Downloads/Financial_Sample.xlsx','sheets' => []],
|
||||
['file_path' =>WRITEPATH.'/tmp/RFQ_ABC_GMC_20241220140640.xlsx','sheets' => []],
|
||||
|
||||
// ['file_path' =>'/home/venba/Downloads/Employee_data.xlsx','sheets' => []],
|
||||
];
|
||||
$outputPath = '/home/venba/Documents/merged_file.xlsx'; // Output path for the merged file
|
||||
|
||||
// Call the mergeExcelFiles function
|
||||
$result = ExcelMergeHelper::mergeExcelFiles($filePaths, $outputPath);
|
||||
var_dump($result);
|
||||
echo('result is -> '.$result);
|
||||
// Check if the result is true (indicating success)
|
||||
$this->assertTrue($result, 'Expected true, but got false');
|
||||
$this->assertFileExists($result);
|
||||
$this->assertTrue(filesize($result) > 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user