FIX_MINOR_ISSUES

This commit is contained in:
velz 2025-01-02 15:01:29 +05:30
parent e5ea779aee
commit 6fa957e32e
3 changed files with 65 additions and 4 deletions

View File

@ -208,6 +208,7 @@ class EmployeeController extends AdminController
// dd($failure_reason);
// }
// $this->truncateFileData(747, 5) ;
// print_rr($this->cloneWorksheet());
// die();
if ($this->request->getMethod() == 'post') {
@ -1693,14 +1694,18 @@ class EmployeeController extends AdminController
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $client_id,client_branch_id: $branch_id);
//get familiy details in inception file format array from post method
$data = calculate_premium_new(family_data: $family_details,policy_terms:$policy_details,slab_details:$slab_details,fileArr: $file,existing_units: $existing_units);
// print_rr($data);die();
foreach($data as $key => $member )
{
// ~dd($member);
if(is_array($member))
if(is_array($member) && isset($member['policy_details']['date_coverage']) && isset($member['policy_details']['policy_end_date']) )
{
$data[$key]['policy_details']['no_of_days'] = $member['policy_details']['date_coverage'] ? (calculate_days_bw_dates($member['policy_details']['date_coverage'],$member['policy_details']['policy_end_date'])->days + 1) : '';
}
else
{
$data[$key]['policy_details']['no_of_days'] = '0';
}
}
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => ['new' => $data,'old' => $existing_famility_details], 200]);
@ -2072,4 +2077,60 @@ class EmployeeController extends AdminController
exit;
}
public function cloneWorksheet()
{
// Define file paths
$inputFilePath = 'C:\Users\Venba\Downloads/merge1.xlsx'; // Path to the existing file
$outputFilePath = WRITEPATH . '/tmp/cloned_file.xlsx'; // Path to save the new file
try {
// Load the existing spreadsheet
$spreadsheet = IOFactory::load($inputFilePath);
// Get the first worksheet (or specify the index of the sheet to clone)
$originalWorksheet = $spreadsheet->getSheet(0);
// Clone the worksheet
$clonedWorksheet = clone $originalWorksheet;
// Generate a unique name for the cloned worksheet
$baseName = "Cloned Sheet";
$sheetIndex = 1;
$uniqueName = $baseName;
// Check for duplicate names and generate a unique one
while ($spreadsheet->sheetNameExists($uniqueName)) {
$uniqueName = $baseName . " " . $sheetIndex;
$sheetIndex++;
}
// Set the unique name for the cloned worksheet
$clonedWorksheet->setTitle($uniqueName);
// Add the cloned worksheet to the spreadsheet
$spreadsheet->addSheet($clonedWorksheet);
// Modify the cloned sheet (optional)
$clonedWorksheet->setCellValue('A1', 'Hello, Cloned Sheet!');
// Save the modified spreadsheet to a new file
$writer = new Xlsx($spreadsheet);
$writer->save($outputFilePath);
return $this->response->setJSON([
'status' => 'success',
'message' => 'Spreadsheet with cloned sheet created successfully!',
'file_path' => $outputFilePath,
]);
} catch (\Exception $e) {
// Handle exceptions
return $this->response->setJSON([
'status' => 'error',
'message' => $e->getMessage(),
]);
}
}
}

View File

@ -2010,7 +2010,7 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
$value['emp_code'] = $row[1];
$value['name'] = $row[2];
$value['doj'] = (!empty($row[3]) ? change_date_format($row[3],'d-M-Y','Y-m-d');
$value['doj'] = (!empty($row[3]) ? change_date_format($row[3],'d-M-Y','Y-m-d') : null );
$value['gender'] = $row[4];
$value['relationship'] = ucfirst(trim($row[5]));
$value['dob'] = change_date_format($row[6],'d-M-Y','Y-m-d');

View File

@ -21,7 +21,7 @@ class MyLogger extends Logger
$message = '{context} - {uuid} -' . $message;
// /echo $message;//die();
$context = array_merge($context,['uuid' => get_session_uuid()]);
$context = array_merge($context,['uuid' => (null !== get_session_uuid()) ? get_session_uuid() : 'CLI']);
// print_r($context);die();
// echo isset($context['context']) ? $context['context'] : $this->context;die();
$context['context'] = isset($context['context']) ? $context['context'] : get_session_context();