MERGE_UAT_TPA

This commit is contained in:
Ubuntu 2026-04-08 17:59:51 +05:30
commit 806af52910
7 changed files with 95 additions and 70 deletions

View File

@ -1457,17 +1457,17 @@ class EmployeeServiceController extends AdminController
// }
}
// if ($employee_insert_count > 0) {
// $this->fileModel->where('id', $file_id)->set(['status' => 'success', 'reason' => ''])->update();
// $this->myLogger->logme("error", '{file_id} uploaded success', ['file_id' => $file_id]);
// } else {
// $reason = json_encode([
// 'error_summary' => [5 => 1],
// 'error_data' => "Rack rate configuration issue: Please check the slab rates configuration"
// ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
// $this->fileModel->where('id', $file_id)->set(['status' => 'failed', 'reason' => $reason])->update();
// $this->myLogger->logme("error", '{file_id} uploaded failed with reason: Rack rate configuration issue: Please check the slab rates configuration', ['file_id' => $file_id]);
// }
if ($employee_insert_count > 0) {
$this->fileModel->where('id', $file_id)->set(['status' => 'success', 'reason' => ''])->update();
$this->myLogger->logme("error", '{file_id} uploaded success', ['file_id' => $file_id]);
} else {
$reason = json_encode([
'error_summary' => [5 => 1],
'error_data' => "Rack rate configuration issue: Please check the slab rates configuration"
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$this->fileModel->where('id', $file_id)->set(['status' => 'failed', 'reason' => $reason])->update();
$this->myLogger->logme("error", '{file_id} uploaded failed with reason: Rack rate configuration issue: Please check the slab rates configuration', ['file_id' => $file_id]);
}
// $this->setPullNotification($this->getFileMetaDataByFileId($file_id, 'success'));
} else if (isset($params['client_policy_id'])) //handle data from enrollment to inception

View File

@ -2126,6 +2126,7 @@ class LeadsController extends BaseController
$data = $this->convertJsonForQCR($data, $type);
} // dd($data);
$lead_data = [];
if ($rfq_data['lead_type'] == 1) {
if (in_array($rfq_data['policy_type_id'], [2, 3, 4, 5])) {
@ -2152,6 +2153,12 @@ class LeadsController extends BaseController
// 'TPA' => $rfq_data['tpa_name'] ?? " - ",
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
];
}else {
$lead_data = [
'Insured' => $rfq_data['client_name'],
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? ""
];
}
} else {
@ -2239,6 +2246,11 @@ class LeadsController extends BaseController
// 'TPA' => $rfq_data['tpa_name'] ?? " - ",
// 'Total Lives at Inception' => $rfq_data['total_lives_at_incept'],
];
} else {
$lead_data = [
'Insured' => $rfq_data['client_name'],
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? ""
];
}
}
// print_r($lead_data); die;
@ -2274,39 +2286,43 @@ class LeadsController extends BaseController
$maxWidthA = 0;
$maxWidthB = 0;
foreach ($lead_data as $key => $value) {
// dd($lead_data);
// Merge A:B for key and C:D for value
$mergeRangeKey = "A{$rowNumber}:B{$rowNumber}";
// $mergeRangeValue = "C{$rowNumber}";
$sheet->mergeCells($mergeRangeKey);
// $sheet->mergeCells($mergeRangeValue);
if(! empty($lead_data)) {
foreach ($lead_data as $key => $value) {
// Set values in merged cells
$sheet->setCellValue("A{$rowNumber}", $key);
$sheet->setCellValue("C{$rowNumber}", $value);
// Merge A:B for key and C:D for value
$mergeRangeKey = "A{$rowNumber}:B{$rowNumber}";
// $mergeRangeValue = "C{$rowNumber}";
$sheet->mergeCells($mergeRangeKey);
// $sheet->mergeCells($mergeRangeValue);
// // Apply styles for alignment and bold text in A:B
// $sheet->getStyle($mergeRangeKey)->applyFromArray([
// 'font' => ['bold' => true],
// 'alignment' => [
// 'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
// 'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER,
// ],
// ]);
// Set values in merged cells
$sheet->setCellValue("A{$rowNumber}", $key);
$sheet->setCellValue("C{$rowNumber}", $value);
// Apply bold style to B column if the key is "Insured"
if ($key == "Insured") {
$sheet->getStyle("C{$rowNumber}")->applyFromArray([
'font' => ['bold' => true],
]);
// // Apply styles for alignment and bold text in A:B
// $sheet->getStyle($mergeRangeKey)->applyFromArray([
// 'font' => ['bold' => true],
// 'alignment' => [
// 'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
// 'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER,
// ],
// ]);
// Apply bold style to B column if the key is "Insured"
if ($key == "Insured") {
$sheet->getStyle("C{$rowNumber}")->applyFromArray([
'font' => ['bold' => true],
]);
}
// Track max width needed for columns
$maxWidthA = max($maxWidthA, mb_strlen($key));
$maxWidthB = max($maxWidthB, mb_strlen($value));
$rowNumber++;
}
// Track max width needed for columns
$maxWidthA = max($maxWidthA, mb_strlen($key));
$maxWidthB = max($maxWidthB, mb_strlen($value));
$rowNumber++;
}
// Set column width based on max content length (adjusted for padding)
@ -5393,31 +5409,32 @@ class LeadsController extends BaseController
$this->myLogger->logme('error', "QCR Sheet: copied from RFQ sheet | lead_id={$leadId}, rfq_sheet_id={$rfqSheetId}, new_sheet_id={$newSheetId}");
// Apply permissions: sales team as editors
$salesTeam = $this->userModel
->select('user_profiles.email')
->join('user_teams', 'user_profiles.id = user_teams.user_id')
->where('user_teams.team_id', 5)
->where('user_teams.is_active', 1)
->where('user_profiles.is_active', 1)
->findAll();
$editorEmails = array_values(array_filter(array_unique(array_column($salesTeam, 'email'))));
// $salesTeam = $this->userModel
// ->select('user_profiles.email')
// ->join('user_teams', 'user_profiles.id = user_teams.user_id')
// ->where('user_teams.team_id', 5)
// ->where('user_teams.is_active', 1)
// ->where('user_profiles.is_active', 1)
// ->findAll();
// $editorEmails = array_values(array_filter(array_unique(array_column($salesTeam, 'email'))));
// Decode rfq_qcr_viewers from lead and add as viewers
$viewerEmails = [];
$editorEmails = [];
if (! empty($lead['rfq_qcr_viewers'])) {
$decoded = json_decode($lead['rfq_qcr_viewers'], true);
if (is_array($decoded)) {
$viewerEmails = array_values(array_filter(array_unique($decoded)));
$editorEmails = array_values(array_filter(array_unique($decoded)));
}
}
if (! empty($editorEmails) || ! empty($viewerEmails)) {
// !dd($editorEmails);
if (! empty($editorEmails)) {
try {
$sheetLib->applyPermissions($newSheetId, [
'editors' => $editorEmails,
'viewers' => $viewerEmails,
// 'viewers' => $viewerEmails,
]);
$this->myLogger->logme('error', "QCR Sheet: permissions applied | sheet_id={$newSheetId}, editors=" . count($editorEmails) . ", viewers=" . count($viewerEmails));
$this->myLogger->logme('error', "QCR Sheet: permissions applied | sheet_id={$newSheetId}, editors=" . count($editorEmails));
} catch (\Throwable $e) {
$this->myLogger->logme('error', "QCR Sheet: failed to apply permissions | sheet_id={$newSheetId}, error=" . $e->getMessage());
}
@ -5634,30 +5651,30 @@ class LeadsController extends BaseController
$this->myLogger->logme('error', "Placement Sheet: copied from QCR | lead_id={$leadId}, qcr_sheet_id={$qcrSheetId}, placement_sheet_id={$placementSheetId}");
// Apply same permissions as QCR (editors: sales team, viewers: rfq_qcr_viewers)
$salesTeam = $this->userModel
->select('user_profiles.email')
->join('user_teams', 'user_profiles.id = user_teams.user_id')
->where('user_teams.team_id', 5)
->where('user_teams.is_active', 1)
->where('user_profiles.is_active', 1)
->findAll();
$editorEmails = array_values(array_filter(array_unique(array_column($salesTeam, 'email'))));
// $salesTeam = $this->userModel
// ->select('user_profiles.email')
// ->join('user_teams', 'user_profiles.id = user_teams.user_id')
// ->where('user_teams.team_id', 5)
// ->where('user_teams.is_active', 1)
// ->where('user_profiles.is_active', 1)
// ->findAll();
// $editorEmails = array_values(array_filter(array_unique(array_column($salesTeam, 'email'))));
$viewerEmails = [];
$editorEmails = [];
if (! empty($lead_data['rfq_qcr_viewers'])) {
$decoded = json_decode($lead_data['rfq_qcr_viewers'], true);
if (is_array($decoded)) {
$viewerEmails = array_values(array_filter(array_unique($decoded)));
$editorEmails = array_values(array_filter(array_unique($decoded)));
}
}
if (! empty($editorEmails) || ! empty($viewerEmails)) {
if (! empty($editorEmails) ) {
try {
$sheetLib->applyPermissions($placementSheetId, [
'editors' => $editorEmails,
'viewers' => $viewerEmails,
// 'viewers' => $viewerEmails,
]);
$this->myLogger->logme('error', "Placement Sheet: permissions applied | sheet_id={$placementSheetId}, editors=" . count($editorEmails) . ", viewers=" . count($viewerEmails));
$this->myLogger->logme('error', "Placement Sheet: permissions applied | sheet_id={$placementSheetId}, editors=" . count($editorEmails));
} catch (\Throwable $e) {
$this->myLogger->logme('error', "Placement Sheet: failed to apply permissions | sheet_id={$placementSheetId}, error=" . $e->getMessage());
}

View File

@ -537,13 +537,21 @@ class SalesController extends BaseController
$value = trim($this->request->getGet('value') ?? '');
$exclude_id = $this->request->getGet('exclude_id');
// ── Whitelist ─────────────────────────────────────────────
// ── Whitelist (table → model, pk, allowed fields) ─────────
$allowed = [
'clients' => ['model' => $this->clientModel, 'pk' => 'id'],
'clients' => [
'model' => $this->clientModel,
'pk' => 'id',
'fields' => ['short_name', 'client_name'],
],
'sales_actual_leads' => [
'model' => $this->leadModel,
'pk' => 'lead_id',
'fields' => ['company_name'],
],
];
// ── Allowed fields per table ──────────────────────────────
if (!array_key_exists($table, $allowed) || !in_array($field, ['short_name', 'client_name'])) {
if (! isset($allowed[$table]) || ! in_array($field, $allowed[$table]['fields'], true)) {
return $this->response
->setStatusCode(400)
->setContentType('application/json')

View File

@ -50,7 +50,7 @@ class SalesActualLeadModel extends Model
'company_name' => [
'required' => 'Company Name is Missing',
// 'alpha_space' => 'Company Name must contain only letters and spaces',
'regex_match' => 'Company Name can only contain letters, numbers, spaces, hyphens and underscores.',
'regex_match' => 'Company Name can only contain letters, numbers.',
'min_length' => 'Company Name must be at least 2 characters long',
'max_length' => 'Company Name must be at most 255 characters long'
],