MERGE_CODE_MERGE : RV
This commit is contained in:
commit
8bedc1ea9c
@ -365,6 +365,8 @@ $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
|
|||||||
$routes->get("deletePaymentEntry/(:any)", "PolicyTransactionController::deletePaymentEntry/$1");
|
$routes->get("deletePaymentEntry/(:any)", "PolicyTransactionController::deletePaymentEntry/$1");
|
||||||
$routes->get("downloadSampleInsurerStatement", "PolicyTransactionController::downloadSampleInsurerStatement");
|
$routes->get("downloadSampleInsurerStatement", "PolicyTransactionController::downloadSampleInsurerStatement");
|
||||||
$routes->get("getFileErr/(:any)", "PolicyTransactionController::getFileErr/$1");
|
$routes->get("getFileErr/(:any)", "PolicyTransactionController::getFileErr/$1");
|
||||||
|
$routes->get("getInsurerStatementMonth", "PolicyTransactionController::getInsurerStatementMonth");
|
||||||
|
$routes->get("deleteStatement/(:any)", "PolicyTransactionController::deleteStatement/$1");
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -378,6 +380,7 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) {
|
|||||||
$routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1");
|
$routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1");
|
||||||
$routes->get("featchLeadDataAndInsertClient/(:any)", "LeadsController::featchLeadDataAndInsertClient/$1");
|
$routes->get("featchLeadDataAndInsertClient/(:any)", "LeadsController::featchLeadDataAndInsertClient/$1");
|
||||||
$routes->get("featchClientPolicyFromLead/(:any)", "LeadsController::featchClientPolicyFromLead/$1");
|
$routes->get("featchClientPolicyFromLead/(:any)", "LeadsController::featchClientPolicyFromLead/$1");
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$routes->group("rfq", ["filter" => "authMVC"], function ($routes) {
|
$routes->group("rfq", ["filter" => "authMVC"], function ($routes) {
|
||||||
|
|||||||
@ -1328,7 +1328,7 @@ class EmployeeServiceController extends AdminController
|
|||||||
// }
|
// }
|
||||||
// dd($row[4]);
|
// dd($row[4]);
|
||||||
//for emp table
|
//for emp table
|
||||||
$this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'emp_status','old_value' => $data['emp_status'],'new_value' => 'deactivate','created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']);
|
// $this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'emp_status','old_value' => $data['emp_status'],'new_value' => 'deactivate','created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']);
|
||||||
// dd( $this->empEndorsementModel->getLastQuery());
|
// dd( $this->empEndorsementModel->getLastQuery());
|
||||||
// $this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'change_event','old_value' => $data['change_event'],'new_value' => 'deletion','created_by' => $file['created_by'],'remarks' => 'general deletion']);
|
// $this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'change_event','old_value' => $data['change_event'],'new_value' => 'deletion','created_by' => $file['created_by'],'remarks' => 'general deletion']);
|
||||||
|
|
||||||
|
|||||||
@ -126,6 +126,10 @@ class JobWorker extends AdminController
|
|||||||
'employeesEnrollmentInsert' => [
|
'employeesEnrollmentInsert' => [
|
||||||
'type' => 'CC', // Handler Category
|
'type' => 'CC', // Handler Category
|
||||||
'handler' => 'App\Controllers\EmployeeServiceController',
|
'handler' => 'App\Controllers\EmployeeServiceController',
|
||||||
|
],
|
||||||
|
'calculateMembersDemography' => [
|
||||||
|
'type' => 'CC', // Handler Category
|
||||||
|
'handler' => 'App\Controllers\LeadsController',
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@ -4,10 +4,14 @@ namespace App\Controllers;
|
|||||||
|
|
||||||
use CodeIgniter\API\ResponseTrait;
|
use CodeIgniter\API\ResponseTrait;
|
||||||
|
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\Fill;
|
||||||
|
|
||||||
use App\Models\UserModel;
|
use App\Models\UserModel;
|
||||||
use App\Models\ClientModel;
|
use App\Models\ClientModel;
|
||||||
@ -24,6 +28,8 @@ use App\Models\RFQModel;
|
|||||||
use App\Models\InsurerModel;
|
use App\Models\InsurerModel;
|
||||||
|
|
||||||
use App\Helpers\MailHelper;
|
use App\Helpers\MailHelper;
|
||||||
|
use App\Helpers\ExcelMergeHelper;
|
||||||
|
use Google\Service\CloudSearch\PushItem;
|
||||||
use Kint;
|
use Kint;
|
||||||
|
|
||||||
|
|
||||||
@ -92,7 +98,9 @@ class LeadsController extends BaseController
|
|||||||
{
|
{
|
||||||
|
|
||||||
// $d = $this->constructExcelToSaveTemp(24, 1, $propsal_and_insurer = null);
|
// $d = $this->constructExcelToSaveTemp(24, 1, $propsal_and_insurer = null);
|
||||||
// $d = $this->calculateMembersDemography(['lead_id' => 34]);
|
$job_details = new Jobs();
|
||||||
|
// $r = Jobs::addJob(['job_name' => 'calculateMembersDemography', 'payload' => ['lead_id' => 24]]);
|
||||||
|
// $d = $this->calculateMembersDemography(['lead_id' => 24]);
|
||||||
//$this->mergeQuoteExcelFileWithMembersListExcelFile(24, 1, $propsal_and_insurer = null);
|
//$this->mergeQuoteExcelFileWithMembersListExcelFile(24, 1, $propsal_and_insurer = null);
|
||||||
// dd($d);
|
// dd($d);
|
||||||
$data['page_name'] = 'Leads';
|
$data['page_name'] = 'Leads';
|
||||||
@ -148,20 +156,20 @@ class LeadsController extends BaseController
|
|||||||
{
|
{
|
||||||
$data = $this->request->getPost();
|
$data = $this->request->getPost();
|
||||||
|
|
||||||
if($data['lead_type'] == 2){
|
if ($data['lead_type'] == 2) {
|
||||||
$client_data = $this->clientModel->where('id', $data['client_id'])->where('is_active', 1)->first();
|
$client_data = $this->clientModel->where('id', $data['client_id'])->where('is_active', 1)->first();
|
||||||
$data['client_name'] = $client_data['client_name'];
|
$data['client_name'] = $client_data['client_name'];
|
||||||
$data['client_short_name'] = $client_data['short_name'];
|
$data['client_short_name'] = $client_data['short_name'];
|
||||||
$data['entity_type_id'] = $client_data['entity_type_id'];
|
$data['entity_type_id'] = $client_data['entity_type_id'];
|
||||||
$data['client_type'] = $client_data['client_type'];
|
$data['client_type'] = $client_data['client_type'];
|
||||||
}else{
|
} else {
|
||||||
$data['client_id'] = 0;
|
$data['client_id'] = 0;
|
||||||
$data['client_branch_id'] = 0;
|
$data['client_branch_id'] = 0;
|
||||||
$data['source_policy_id'] = 0;
|
$data['source_policy_id'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['client_code'] = generate_client_code();
|
$data['client_code'] = generate_client_code();
|
||||||
if($data['client_code'] == 2){
|
if ($data['client_code'] == 2) {
|
||||||
$data['client_code'] = generate_client_code('IC');
|
$data['client_code'] = generate_client_code('IC');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,15 +224,15 @@ class LeadsController extends BaseController
|
|||||||
$proposed_tpa_id = 0;
|
$proposed_tpa_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($data['policy_start_date'][$index])){
|
if (!empty($data['policy_start_date'][$index])) {
|
||||||
$policy_start_date = change_date_format($data['policy_start_date'][$index], 'd/m/Y', 'Y-m-d');
|
$policy_start_date = change_date_format($data['policy_start_date'][$index], 'd/m/Y', 'Y-m-d');
|
||||||
}else{
|
} else {
|
||||||
$policy_start_date = null;
|
$policy_start_date = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($data['policy_end_date'][$index])){
|
if (!empty($data['policy_end_date'][$index])) {
|
||||||
$policy_end_date = change_date_format($data['policy_end_date'][$index], 'd/m/Y', 'Y-m-d');
|
$policy_end_date = change_date_format($data['policy_end_date'][$index], 'd/m/Y', 'Y-m-d');
|
||||||
}else{
|
} else {
|
||||||
$policy_end_date = null;
|
$policy_end_date = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,26 +319,26 @@ class LeadsController extends BaseController
|
|||||||
private function insertNewLead($data)
|
private function insertNewLead($data)
|
||||||
{
|
{
|
||||||
$insertCount = [];
|
$insertCount = [];
|
||||||
foreach($data as $value){
|
foreach ($data as $value) {
|
||||||
$insert = $this->leadsModel->insert($value);
|
$insert = $this->leadsModel->insert($value);
|
||||||
$insertCount[] = $insert;
|
$insertCount[] = $insert;
|
||||||
$this->insertLeadStatus($insert, $value['status'], 3);
|
$this->insertLeadStatus($insert, $value['status'], 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($insertCount) > 0) {
|
if (count($insertCount) > 0) {
|
||||||
return $this->respond(['status' => true, 'lead_id' => $insert, 'message' => 'New Lead created successfully', 'data' =>$data], 200);
|
return $this->respond(['status' => true, 'lead_id' => $insert, 'message' => 'New Lead created successfully', 'data' => $data], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond(['status' => false, 'lead_id' => $insert, 'message' => "Failed to create Lead", 'data' =>$data], 200);
|
return $this->respond(['status' => false, 'lead_id' => $insert, 'message' => "Failed to create Lead", 'data' => $data], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateOldLead($id, $data)
|
private function updateOldLead($id, $data)
|
||||||
{
|
{
|
||||||
if ($this->leadsModel->where('id', $id)->set($data[0])->update()) {
|
if ($this->leadsModel->where('id', $id)->set($data[0])->update()) {
|
||||||
$this->insertLeadStatus($id, $data[0]['status'], 3);
|
$this->insertLeadStatus($id, $data[0]['status'], 3);
|
||||||
return $this->respond(['status' => true, 'lead_id' => $id, 'message' => "Lead updated successfully", 'data' =>$data], 200);
|
return $this->respond(['status' => true, 'lead_id' => $id, 'message' => "Lead updated successfully", 'data' => $data], 200);
|
||||||
}
|
}
|
||||||
return $this->respond(['status' => false, 'lead_id' => $id, 'message' => "Failed to update Lead", 'data' =>$data], 200);
|
return $this->respond(['status' => false, 'lead_id' => $id, 'message' => "Failed to update Lead", 'data' => $data], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the Single Lead data for edit
|
// Get the Single Lead data for edit
|
||||||
@ -338,28 +346,27 @@ class LeadsController extends BaseController
|
|||||||
{
|
{
|
||||||
|
|
||||||
$data = $this->leadsModel
|
$data = $this->leadsModel
|
||||||
->where('leads.id', $id)
|
->where('leads.id', $id)
|
||||||
->where('leads.is_active', 1)
|
->where('leads.is_active', 1)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if(!empty($data['policy_start_date'])){
|
if (!empty($data['policy_start_date'])) {
|
||||||
$data['policy_start_date'] = change_date_format($data['policy_start_date'], 'Y-m-d', 'd/m/Y');
|
$data['policy_start_date'] = change_date_format($data['policy_start_date'], 'Y-m-d', 'd/m/Y');
|
||||||
}else{
|
} else {
|
||||||
$data['policy_start_date'] = null;
|
$data['policy_start_date'] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($data['policy_end_date'])){
|
if (!empty($data['policy_end_date'])) {
|
||||||
$data['policy_end_date'] = change_date_format($data['policy_end_date'], 'Y-m-d', 'd/m/Y');
|
$data['policy_end_date'] = change_date_format($data['policy_end_date'], 'Y-m-d', 'd/m/Y');
|
||||||
}else{
|
} else {
|
||||||
$data['policy_end_date'] = null;
|
$data['policy_end_date'] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($data){
|
if ($data) {
|
||||||
return $this->respond(['status' => true, 'data' => $data], 200);
|
return $this->respond(['status' => true, 'data' => $data], 200);
|
||||||
}else{
|
} else {
|
||||||
return $this->respond(['status' => false], 200);
|
return $this->respond(['status' => false], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function insertLeadStatus($primaryKey, $status, $statusType)
|
private function insertLeadStatus($primaryKey, $status, $statusType)
|
||||||
@ -377,7 +384,8 @@ class LeadsController extends BaseController
|
|||||||
//--------RFQ-----------------------------------------------------------------------------------------------
|
//--------RFQ-----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
public function viewRFQ($id, $type = 1){
|
public function viewRFQ($id, $type = 1)
|
||||||
|
{
|
||||||
|
|
||||||
$data['rfq_data'] = $this->RFQModel
|
$data['rfq_data'] = $this->RFQModel
|
||||||
->where('lead_id', $id)
|
->where('lead_id', $id)
|
||||||
@ -392,10 +400,10 @@ class LeadsController extends BaseController
|
|||||||
->countAllResults();
|
->countAllResults();
|
||||||
|
|
||||||
$data['qcr_count'] = $this->RFQModel
|
$data['qcr_count'] = $this->RFQModel
|
||||||
->where('lead_id', $id)
|
->where('lead_id', $id)
|
||||||
->where('type', 2)
|
->where('type', 2)
|
||||||
->where('is_active', 1)
|
->where('is_active', 1)
|
||||||
->countAllResults();
|
->countAllResults();
|
||||||
|
|
||||||
// dd(count($data['rfq_data']));
|
// dd(count($data['rfq_data']));
|
||||||
|
|
||||||
@ -409,7 +417,7 @@ class LeadsController extends BaseController
|
|||||||
|
|
||||||
// dd($lead_data);
|
// dd($lead_data);
|
||||||
|
|
||||||
if($lead_data['lead_type'] == 2){
|
if ($lead_data['lead_type'] == 2) {
|
||||||
$client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first();
|
$client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first();
|
||||||
$data['policy_terms'] = $client_policy_data['policy_terms'];
|
$data['policy_terms'] = $client_policy_data['policy_terms'];
|
||||||
}
|
}
|
||||||
@ -441,14 +449,14 @@ class LeadsController extends BaseController
|
|||||||
$result = $this->RFQModel->insert($data);
|
$result = $this->RFQModel->insert($data);
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
return $this->respond(['status' => true, 'id' => $result, 'message' => 'RFQ created successfully', 'data' =>$data], 200);
|
return $this->respond(['status' => true, 'id' => $result, 'message' => 'RFQ created successfully', 'data' => $data], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond(['status' => false, 'id' => $result, 'message' => "Failed to create RFQ", 'data' =>$data], 200);
|
return $this->respond(['status' => false, 'id' => $result, 'message' => "Failed to create RFQ", 'data' => $data], 200);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createQCR(){
|
public function createQCR()
|
||||||
|
{
|
||||||
|
|
||||||
$data = $this->request->getPost();
|
$data = $this->request->getPost();
|
||||||
$lead_id = $data['lead_id'];
|
$lead_id = $data['lead_id'];
|
||||||
@ -464,10 +472,10 @@ class LeadsController extends BaseController
|
|||||||
$result = $this->RFQModel->insert($data);
|
$result = $this->RFQModel->insert($data);
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
return $this->respond(['status' => true, 'id' => $result, 'message' => 'QCR created successfully', 'data' =>$data], 200);
|
return $this->respond(['status' => true, 'id' => $result, 'message' => 'QCR created successfully', 'data' => $data], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond(['status' => false, 'id' => $result, 'message' => "Failed to create QCR", 'data' =>$data], 200);
|
return $this->respond(['status' => false, 'id' => $result, 'message' => "Failed to create QCR", 'data' => $data], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -475,8 +483,9 @@ class LeadsController extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
//export main route function
|
//export main route function
|
||||||
public function exportQCRandRFQ($lead_id, $type, $export_type){
|
public function exportQCRandRFQ($lead_id, $type, $export_type)
|
||||||
$this-> exportExcelForQCRandRFQ($lead_id, $type);
|
{
|
||||||
|
$this->exportExcelForQCRandRFQ($lead_id, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
//FOR EXCEL
|
//FOR EXCEL
|
||||||
@ -655,7 +664,7 @@ class LeadsController extends BaseController
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
if($type == 2){
|
if ($type == 2) {
|
||||||
|
|
||||||
$rowNumber += 2;
|
$rowNumber += 2;
|
||||||
|
|
||||||
@ -694,7 +703,6 @@ class LeadsController extends BaseController
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto-size columns
|
// Auto-size columns
|
||||||
@ -722,9 +730,7 @@ class LeadsController extends BaseController
|
|||||||
{
|
{
|
||||||
$rfq_data = $this->RFQModel->getRFQTableDataWithLeadIDAndType($lead_id, $type);
|
$rfq_data = $this->RFQModel->getRFQTableDataWithLeadIDAndType($lead_id, $type);
|
||||||
|
|
||||||
if($source_file_path && $rfq_data['file_name'])
|
if ($source_file_path && $rfq_data['file_name']) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -734,46 +740,42 @@ class LeadsController extends BaseController
|
|||||||
{
|
{
|
||||||
$lead_id = $params['lead_id'];
|
$lead_id = $params['lead_id'];
|
||||||
$lead_data = $this->leadsModel->find($lead_id);
|
$lead_data = $this->leadsModel->find($lead_id);
|
||||||
$file_name_with_path = WRITEPATH."/uploads/lead_files/".$lead_data['file_name'];
|
$file_name_with_path = WRITEPATH . "/uploads/lead_files/" . $lead_data['file_name'];
|
||||||
|
|
||||||
// print_rr($lead_data);
|
if ($lead_data['file_name']) {
|
||||||
if($lead_data['file_name'])
|
|
||||||
{
|
|
||||||
|
|
||||||
//check physical file
|
//check physical file
|
||||||
if(!file_exists($file_name_with_path))
|
if (!file_exists($file_name_with_path)) {
|
||||||
{
|
|
||||||
//file not found update status and reason
|
//file not found update status and reason
|
||||||
$message = "Lead Physcial file not found";
|
$message = "Lead Physcial file not found";
|
||||||
// echo $message;
|
// echo $message;
|
||||||
$this->myLogger->logme('error',($message . ' for file ' . $file_name_with_path));
|
$this->myLogger->logme('error', ($message . ' for file ' . $file_name_with_path));
|
||||||
return ['status' => 'failed','message' => 'no physcial file'];
|
return ['status' => 'failed', 'message' => 'no physical file'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
|
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
|
||||||
|
|
||||||
//get members data
|
//get members data
|
||||||
$members_sheet = $spreadsheet->getSheet(0);
|
$members_sheet = $spreadsheet->getSheet(0);
|
||||||
$highestRowAndColumn = $members_sheet->getHighestRowAndColumn();
|
$highestRowAndColumn = $members_sheet->getHighestRowAndColumn();
|
||||||
// dd($highestRowAndColumn);
|
// dd($highestRowAndColumn);
|
||||||
$members = $members_sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
|
$members = $members_sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
|
||||||
// dd($members);
|
// dd($members[6]);
|
||||||
|
|
||||||
//get age band data
|
//get age band data
|
||||||
$age_band_sheet = $spreadsheet->getSheet(1);
|
$age_band_sheet = $spreadsheet->getSheet(1);
|
||||||
$highestRowAndColumn = $age_band_sheet->getHighestRowAndColumn();
|
$highestRowAndColumn = $age_band_sheet->getHighestRowAndColumn();
|
||||||
$age_band_data = $age_band_sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
|
$age_band_data = $age_band_sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
|
||||||
print_r($age_band_data);
|
|
||||||
|
|
||||||
//check age or dob column
|
|
||||||
$members_heading = $members[0];
|
//check age or dob column
|
||||||
// Kint::dump($members_heading);
|
$members_heading = $members[0];
|
||||||
$available_col = null;
|
$available_col = null;
|
||||||
$col_index = null;
|
$col_index = null;
|
||||||
|
|
||||||
if (in_array('age', array_map('strtolower',$members_heading))) {
|
if (in_array('age', array_map('strtolower', $members_heading))) {
|
||||||
$available_col = 'age';
|
$available_col = 'age';
|
||||||
$col_index = array_search('age',array_map('strtolower',$members_heading));
|
$col_index = array_search('age', array_map('strtolower', $members_heading));
|
||||||
} elseif (in_array('dob', array_map('strtolower', $members_heading))) {
|
} elseif (in_array('dob', array_map('strtolower', $members_heading))) {
|
||||||
$available_col = 'dob';
|
$available_col = 'dob';
|
||||||
$col_index = array_search('dob', array_map('strtolower', $members_heading));
|
$col_index = array_search('dob', array_map('strtolower', $members_heading));
|
||||||
@ -781,19 +783,349 @@ class LeadsController extends BaseController
|
|||||||
|
|
||||||
if ($available_col == null) {
|
if ($available_col == null) {
|
||||||
$message = 'No DOB or Age column ';
|
$message = 'No DOB or Age column ';
|
||||||
$this->myLogger->logme('error',($message . $file_name_with_path));
|
$this->myLogger->logme('error', ($message . $file_name_with_path));
|
||||||
return ['status' => 'failed','message' => $message];
|
return ['status' => 'failed', 'message' => $message];
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$classifiers = $this->getDemographyData($members, $age_band_data, $members_heading, $available_col, $col_index);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return ['status' => 'fail', 'message' => $e->getMessage()];
|
||||||
}
|
}
|
||||||
|
|
||||||
//convert age slab data into array
|
try {
|
||||||
|
$result = $this->generateClassifierSpreadsheet($classifiers, 'writable/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' => []],
|
||||||
|
];
|
||||||
|
$outputPath = WRITEPATH . 'uploads/lead_files/Member_Data.xlsx';
|
||||||
|
$result = ExcelMergeHelper::mergeExcelFiles($filePaths, $outputPath);
|
||||||
|
if ($result) {
|
||||||
|
return ['status' => 'success', 'message' => 'Member_Data Merged Suceesfully'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "Error generating spreadsheet: " . $result['error'];
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo "Error: " . $e->getMessage();
|
||||||
|
return ['status' => 'fail', 'message' => $e->getMessage()];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->myLogger->logme('error', (' no file found ' . $file_name_with_path));
|
||||||
|
return ['status' => 'failed', 'message' => 'no file found'];
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
|
||||||
$this->myLogger->logme('error',(' no file found ' . $file_name_with_path));
|
public function getDemographyData($members, $age_band_data, $members_heading, $available_col, $col_index)
|
||||||
return ['status' => 'failed','message' => 'no file found'];
|
{
|
||||||
|
$first_loop = 0;
|
||||||
|
$col_index_si = array_search('si enhancement', array_map('strtolower', $members_heading));
|
||||||
|
$col_index_relationship = array_search('relationship', array_map('strtolower', $members_heading));
|
||||||
|
$relations = [];
|
||||||
|
$si_amt = ['general']; // Initialize with 'general' as per first loop condition
|
||||||
|
|
||||||
|
// First pass - collect unique relations and SI amounts
|
||||||
|
foreach ($members as $member) {
|
||||||
|
if ($first_loop == 0) {
|
||||||
|
$first_loop++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($member == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!in_array($member[$col_index_relationship], $relations) && $member[$col_index_relationship] != null) {
|
||||||
|
$relations[] = $member[$col_index_relationship];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!in_array($member[$col_index_si], $si_amt) && $member[$col_index_si] != null) {
|
||||||
|
$si_amt[] = $member[$col_index_si];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Initialize classifier array
|
||||||
|
$classifiers = [];
|
||||||
|
foreach ($si_amt as $si) {
|
||||||
|
$classifiers[$si] = [];
|
||||||
|
// Initialize relation counts including Grand Total row
|
||||||
|
foreach ($relations as $relation) {
|
||||||
|
$classifiers[$si][$relation] = [];
|
||||||
|
foreach ($age_band_data as $age_bands) {
|
||||||
|
foreach ($age_bands as $age_interval) {
|
||||||
|
$classifiers[$si][$relation][$age_interval] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Add Grand Total column for each relation echo('test passed 3.5');
|
||||||
|
|
||||||
|
$classifiers[$si][$relation]['Grand Total'] = 0;
|
||||||
|
}
|
||||||
|
// Initialize Grand Total row
|
||||||
|
$classifiers[$si]['Grand Total'] = [];
|
||||||
|
foreach ($age_band_data as $age_bands) {
|
||||||
|
foreach ($age_bands as $age_interval) {
|
||||||
|
$classifiers[$si]['Grand Total'][$age_interval] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Add grand total of grand totals
|
||||||
|
$classifiers[$si]['Grand Total']['Grand Total'] = 0;
|
||||||
|
}
|
||||||
|
// Process members and count them
|
||||||
|
foreach ($members as $member) {
|
||||||
|
if ($first_loop == 0) {
|
||||||
|
$first_loop++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Get age
|
||||||
|
$age = $this->getAge($available_col, $member, $col_index);
|
||||||
|
|
||||||
|
|
||||||
|
$relation = $member[$col_index_relationship];
|
||||||
|
$member_si = $member[$col_index_si];
|
||||||
|
|
||||||
|
// Find the correct age band (only once per member)
|
||||||
|
$found_band = false;
|
||||||
|
foreach ($age_band_data as $age_bands) {
|
||||||
|
if ($found_band) break;
|
||||||
|
|
||||||
|
foreach ($age_bands as $age_band) {
|
||||||
|
//get Min and Max Age
|
||||||
|
list($min_age, $max_age) = $this->getAgeRange($age_band);
|
||||||
|
|
||||||
|
// If age fits in this band
|
||||||
|
if ($age >= $min_age && $age <= $max_age) {
|
||||||
|
// Update counts for general category
|
||||||
|
if (isset($classifiers['general'][$relation][$age_band])) {
|
||||||
|
// Increment count for specific relation and age band
|
||||||
|
$classifiers['general'][$relation][$age_band]++;
|
||||||
|
// Update row total (Grand Total column)
|
||||||
|
$classifiers['general'][$relation]['Grand Total']++;
|
||||||
|
// Update column total (Grand Total row)
|
||||||
|
$classifiers['general']['Grand Total'][$age_band]++;
|
||||||
|
// Update grand total of grand totals
|
||||||
|
$classifiers['general']['Grand Total']['Grand Total']++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update counts for specific SI category
|
||||||
|
if (isset($classifiers[$member_si][$relation][$age_band])) {
|
||||||
|
// Increment count for specific relation and age band
|
||||||
|
$classifiers[$member_si][$relation][$age_band]++;
|
||||||
|
// Update row total (Grand Total column)
|
||||||
|
$classifiers[$member_si][$relation]['Grand Total']++;
|
||||||
|
// Update column total (Grand Total row)
|
||||||
|
$classifiers[$member_si]['Grand Total'][$age_band]++;
|
||||||
|
// Update grand total of grand totals
|
||||||
|
$classifiers[$member_si]['Grand Total']['Grand Total']++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$found_band = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $classifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
while (file_exists($outputDir . DIRECTORY_SEPARATOR . "member_classification_{$timestamp}_{$counter}.xlsx")) {
|
||||||
|
$counter++;
|
||||||
|
}
|
||||||
|
$filename = "member_classification_{$timestamp}_{$counter}.xlsx";
|
||||||
|
$filepath = $outputDir . DIRECTORY_SEPARATOR . $filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$sheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// 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
|
||||||
|
$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;
|
||||||
|
$sheet->getStyle($headerRange)->applyFromArray([
|
||||||
|
'font' => ['bold' => true],
|
||||||
|
'borders' => [
|
||||||
|
'allBorders' => [
|
||||||
|
'borderStyle' => Border::BORDER_THIN,
|
||||||
|
'color' => ['rgb' => '000000'],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'alignment' => [
|
||||||
|
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$currentRow++;
|
||||||
|
|
||||||
|
// Write data rows
|
||||||
|
foreach ($data as $relation => $values) {
|
||||||
|
if ($relation !== 'Grand Total') {
|
||||||
|
$sheet->setCellValue('B' . $currentRow, $relation);
|
||||||
|
$col = 'C';
|
||||||
|
foreach ($age_bands as $band) {
|
||||||
|
$value = $values[$band] ?: ''; // Convert 0 to empty string
|
||||||
|
$sheet->setCellValue($col . $currentRow, $value);
|
||||||
|
$col++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Style data row
|
||||||
|
$dataRange = 'B' . $currentRow . ':' . $lastCol . $currentRow;
|
||||||
|
$sheet->getStyle($dataRange)->applyFromArray([
|
||||||
|
'borders' => [
|
||||||
|
'allBorders' => [
|
||||||
|
'borderStyle' => Border::BORDER_THIN,
|
||||||
|
'color' => ['rgb' => '000000'],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'alignment' => [
|
||||||
|
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$currentRow++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add Grand Total row
|
||||||
|
$sheet->setCellValue('B' . $currentRow, 'Grand Total');
|
||||||
|
$col = 'C';
|
||||||
|
foreach ($age_bands as $band) {
|
||||||
|
$sheet->setCellValue($col . $currentRow, $data['Grand Total'][$band]);
|
||||||
|
$col++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Style Grand Total row
|
||||||
|
$totalRange = 'B' . $currentRow . ':' . $lastCol . $currentRow;
|
||||||
|
$sheet->getStyle($totalRange)->applyFromArray([
|
||||||
|
'font' => ['bold' => true],
|
||||||
|
'borders' => [
|
||||||
|
'allBorders' => [
|
||||||
|
'borderStyle' => Border::BORDER_THIN,
|
||||||
|
'color' => ['rgb' => '000000'],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'fill' => [
|
||||||
|
'fillType' => Fill::FILL_SOLID,
|
||||||
|
'startColor' => ['rgb' => 'F2F2F2'],
|
||||||
|
],
|
||||||
|
'alignment' => [
|
||||||
|
'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);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 [
|
||||||
|
'success' => true,
|
||||||
|
'filepath' => $filepath,
|
||||||
|
'filename' => $filename,
|
||||||
|
'fullpath' => realpath($filepath)
|
||||||
|
];
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return [
|
||||||
|
'success' => false,
|
||||||
|
'error' => $e->getMessage()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAge($available_col, $member, $col_index)
|
||||||
|
{
|
||||||
|
if ($available_col == 'age') {
|
||||||
|
$age = $member[$col_index];
|
||||||
|
} else {
|
||||||
|
$dob = $member[$col_index];
|
||||||
|
if ($dob == 'DOB') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$dobDate = \DateTime::createFromFormat('d-M-Y', $dob);
|
||||||
|
$currentDate = new \DateTime();
|
||||||
|
if ($dobDate == false) {
|
||||||
|
$this->myLogger->logme('error', $dob . 'is not valid');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$age = $currentDate->diff($dobDate)->y;
|
||||||
|
}
|
||||||
|
return $age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAgeRange($age_band)
|
||||||
|
{
|
||||||
|
$age_band = trim($age_band);
|
||||||
|
// Parse age range
|
||||||
|
if (strpos($age_band, '-') === false) {
|
||||||
|
$min_age = (int)filter_var($age_band, FILTER_SANITIZE_NUMBER_INT);
|
||||||
|
$max_age = PHP_INT_MAX;
|
||||||
|
} else {
|
||||||
|
$parts = explode("-", $age_band);
|
||||||
|
$min_age = (int)$parts[0];
|
||||||
|
$max_age = (int)$parts[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
return array($min_age, $max_age);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -802,7 +1134,7 @@ class LeadsController extends BaseController
|
|||||||
{
|
{
|
||||||
helper('excel_util_helper');
|
helper('excel_util_helper');
|
||||||
helper('MailHelper');
|
helper('MailHelper');
|
||||||
|
helper('ExcelMergeHelper');
|
||||||
$params = $this->request->getGet();
|
$params = $this->request->getGet();
|
||||||
// print_r($params); die;
|
// print_r($params); die;
|
||||||
$lead_id = $params['lead_id'];
|
$lead_id = $params['lead_id'];
|
||||||
@ -831,7 +1163,7 @@ class LeadsController extends BaseController
|
|||||||
$cc_mails = [];
|
$cc_mails = [];
|
||||||
|
|
||||||
//get CC Mails
|
//get CC Mails
|
||||||
if($recipient_type == 'internal' || $recipient_type == 'placement'){
|
if ($recipient_type == 'internal' || $recipient_type == 'placement') {
|
||||||
|
|
||||||
$cc_data = isset($params['cc']) ? $params['cc'] : "";
|
$cc_data = isset($params['cc']) ? $params['cc'] : "";
|
||||||
$param_cc_mail = json_decode($cc_data, true);
|
$param_cc_mail = json_decode($cc_data, true);
|
||||||
@ -870,12 +1202,28 @@ class LeadsController extends BaseController
|
|||||||
|
|
||||||
//get file path to attach
|
//get file path to attach
|
||||||
$file_info = $this->constructExcelToSaveTemp($lead_id, ($file_type == 'rfq' ? 1 : 2), $propsal_and_insurer);
|
$file_info = $this->constructExcelToSaveTemp($lead_id, ($file_type == 'rfq' ? 1 : 2), $propsal_and_insurer);
|
||||||
|
if ($lead_data['file_name'] != null && $lead_data['file_name'] != '') {
|
||||||
|
$temp_file_path = $file_info['filePath'];
|
||||||
|
$temp_file_name = $file_info['fileName'];
|
||||||
|
$lead_file_path = WRITEPATH . 'uploads/lead_files/' . $lead_data['file_name'];
|
||||||
|
if ($lead_file_path) {
|
||||||
|
$filePaths = [
|
||||||
|
['file_path' => $temp_file_path, 'sheets' => []],
|
||||||
|
['file_path' => $lead_file_path, 'sheets' => []]
|
||||||
|
];
|
||||||
|
$outputPath = dirname($temp_file_path) . '/' . 'merged_' . $temp_file_name;
|
||||||
|
$result = ExcelMergeHelper::mergeExcelFiles($filePaths, $outputPath);
|
||||||
|
// print_rr($result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// print_rr($lead_data);
|
||||||
|
// print_rr($file_info);
|
||||||
// $file_path = WRITEPATH."uploads/excel/sample/correction.xls";
|
// $file_path = WRITEPATH."uploads/excel/sample/correction.xls";
|
||||||
// $file_name = $file_type.'.xlsx';
|
// $file_name = $file_type.'.xlsx';
|
||||||
// !dd($file_info);
|
// !dd($file_info);
|
||||||
|
|
||||||
$file_path = $file_info['filePath'];
|
$file_path = $result;
|
||||||
$file_name = $file_info['fileName'];
|
$file_name = basename($result);
|
||||||
$attachments = [['fileName' => $file_name, 'filePath' => $file_path]];
|
$attachments = [['fileName' => $file_name, 'filePath' => $file_path]];
|
||||||
|
|
||||||
//get recipient address
|
//get recipient address
|
||||||
@ -890,9 +1238,9 @@ class LeadsController extends BaseController
|
|||||||
|
|
||||||
// print_r($recipient_data); die;
|
// print_r($recipient_data); die;
|
||||||
|
|
||||||
} else if($recipient_type == 'client') {
|
} else if ($recipient_type == 'client') {
|
||||||
$recipient_data = [['name' => $lead_data['contact_person_name'], 'email' => $lead_data['contact_person_email']]];
|
$recipient_data = [['name' => $lead_data['contact_person_name'], 'email' => $lead_data['contact_person_email']]];
|
||||||
}else{
|
} else {
|
||||||
$recipient_data = [['name' => "Team", 'email' => $params['to']]];
|
$recipient_data = [['name' => "Team", 'email' => $params['to']]];
|
||||||
}
|
}
|
||||||
// print_r($recipient_data); die;
|
// print_r($recipient_data); die;
|
||||||
@ -900,7 +1248,7 @@ class LeadsController extends BaseController
|
|||||||
$subject = $file_type == 'rfq' ? 'Request for Quotation from ' . $lead_data['client_name'] . ' for ' . $lead_data['policy_type'] : 'Quotation Comparison Report for ' . $lead_data['policy_type'];
|
$subject = $file_type == 'rfq' ? 'Request for Quotation from ' . $lead_data['client_name'] . ' for ' . $lead_data['policy_type'] : 'Quotation Comparison Report for ' . $lead_data['policy_type'];
|
||||||
$original_message = '<div style="width:100%;max-width:600px;margin:0 auto;padding:20px;border:1px solid #e0e0e0;background-color:#f9f9f9;font-family:Arial,sans-serif;color:#333;line-height:1.6"><div style=background-color:#4a90e2;color:#fff;padding:15px;text-align:center><h1 style=margin:0;font-size:24px>Request for Quotation (RFQ)</h1></div><div style=padding:20px;background-color:#fff><h2 style=color:#4a90e2;font-size:20px;margin-top:0>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 style=color:#4a90e2;font-size:20px;margin-top:20px>RFQ Details</h2><table style=width:100%;border-collapse:collapse;margin-top:20px><tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Client name<td style="border:1px solid #ddd;padding:10px;text-align:left">{{CLIENT_NAME}}<tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Coverage Type<td style="border:1px solid #ddd;padding:10px;text-align:left">{{POLICY_LONG_NAME}}<tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Policy Start Date<td style="border:1px solid #ddd;padding:10px;text-align:left">{{POLICY_START_DATE}}<tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Policy Duration<td style="border:1px solid #ddd;padding:10px;text-align:left">{{DURATION}}</table><div style="margin-top:20px;padding:10px;background-color:#f7f7f7;border-left:4px solid #4a90e2;font-style:italic">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 style=margin-top:20px;font-size:12px;color:#777;text-align:center><p>© Nhance India Pvt Ltd. All rights reserved.</div></div>';
|
$original_message = '<div style="width:100%;max-width:600px;margin:0 auto;padding:20px;border:1px solid #e0e0e0;background-color:#f9f9f9;font-family:Arial,sans-serif;color:#333;line-height:1.6"><div style=background-color:#4a90e2;color:#fff;padding:15px;text-align:center><h1 style=margin:0;font-size:24px>Request for Quotation (RFQ)</h1></div><div style=padding:20px;background-color:#fff><h2 style=color:#4a90e2;font-size:20px;margin-top:0>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 style=color:#4a90e2;font-size:20px;margin-top:20px>RFQ Details</h2><table style=width:100%;border-collapse:collapse;margin-top:20px><tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Client name<td style="border:1px solid #ddd;padding:10px;text-align:left">{{CLIENT_NAME}}<tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Coverage Type<td style="border:1px solid #ddd;padding:10px;text-align:left">{{POLICY_LONG_NAME}}<tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Policy Start Date<td style="border:1px solid #ddd;padding:10px;text-align:left">{{POLICY_START_DATE}}<tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Policy Duration<td style="border:1px solid #ddd;padding:10px;text-align:left">{{DURATION}}</table><div style="margin-top:20px;padding:10px;background-color:#f7f7f7;border-left:4px solid #4a90e2;font-style:italic">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 style=margin-top:20px;font-size:12px;color:#777;text-align:center><p>© Nhance India Pvt Ltd. All rights reserved.</div></div>';
|
||||||
|
|
||||||
if($recipient_data){
|
if ($recipient_data) {
|
||||||
foreach ($recipient_data as $recipient) {
|
foreach ($recipient_data as $recipient) {
|
||||||
|
|
||||||
$message = $original_message;
|
$message = $original_message;
|
||||||
@ -912,13 +1260,13 @@ class LeadsController extends BaseController
|
|||||||
|
|
||||||
// print_rr($message);calculate_days_bw_dates
|
// print_rr($message);calculate_days_bw_dates
|
||||||
|
|
||||||
$res = MailHelper::send_email(['mail' => $recipient['email'], 'cc'=> $cc_mails, 'subject' => $subject, 'message' => $message, 'attachments' => $attachments, 'reply_to' => $reply_to]);
|
$res = MailHelper::send_email(['mail' => $recipient['email'], 'cc' => $cc_mails, 'subject' => $subject, 'message' => $message, 'attachments' => $attachments, 'reply_to' => $reply_to]);
|
||||||
// !dd($res);
|
// !dd($res);
|
||||||
$result_data[] = ['mail' => $recipient['email'], 'status' => $res];
|
$result_data[] = ['mail' => $recipient['email'], 'status' => $res];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($recipient_type == 'placement'){
|
if ($recipient_type == 'placement') {
|
||||||
|
|
||||||
list($proposal_key, $insurer_key) = explode('-', $propsal_and_insurer, 2);
|
list($proposal_key, $insurer_key) = explode('-', $propsal_and_insurer, 2);
|
||||||
|
|
||||||
@ -926,7 +1274,7 @@ class LeadsController extends BaseController
|
|||||||
'proposel_name' => $proposal_key,
|
'proposel_name' => $proposal_key,
|
||||||
'insurer_name' => $insurer_key,
|
'insurer_name' => $insurer_key,
|
||||||
'insurer' => $params['insurer_and_branch'],
|
'insurer' => $params['insurer_and_branch'],
|
||||||
] ;
|
];
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'proposel_data' => json_encode($lead_update_data),
|
'proposel_data' => json_encode($lead_update_data),
|
||||||
@ -951,12 +1299,11 @@ class LeadsController extends BaseController
|
|||||||
|
|
||||||
$data = $this->levelContactModel->getContactForRFQ();
|
$data = $this->levelContactModel->getContactForRFQ();
|
||||||
|
|
||||||
if($data){
|
if ($data) {
|
||||||
return $this->respond(['status' => true, 'data' => $data], 200);
|
return $this->respond(['status' => true, 'data' => $data], 200);
|
||||||
}else{
|
} else {
|
||||||
return $this->respond(['status' => false], 200);
|
return $this->respond(['status' => false], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInsurerBranchContacts($insurer_and_branch_id)
|
public function getInsurerBranchContacts($insurer_and_branch_id)
|
||||||
@ -1082,7 +1429,6 @@ class LeadsController extends BaseController
|
|||||||
$data['premium_data']['data'] = $premiumData;
|
$data['premium_data']['data'] = $premiumData;
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function convertJsonForQCR($json, $type)
|
public function convertJsonForQCR($json, $type)
|
||||||
@ -1265,7 +1611,7 @@ class LeadsController extends BaseController
|
|||||||
$client_policy_id = $this->clientPolicyModel->insert($client_policy_data);
|
$client_policy_id = $this->clientPolicyModel->insert($client_policy_data);
|
||||||
|
|
||||||
|
|
||||||
if($client_policy_id){
|
if ($client_policy_id) {
|
||||||
$this->leadsModel->where('id', $data['id'])->set('is_client_created', $client_id)->update();
|
$this->leadsModel->where('id', $data['id'])->set('is_client_created', $client_id)->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1302,7 +1648,7 @@ class LeadsController extends BaseController
|
|||||||
// if ($base_policy) {
|
// if ($base_policy) {
|
||||||
// $data['is_addon'] = 3; // Dependent Addon
|
// $data['is_addon'] = 3; // Dependent Addon
|
||||||
// } else {
|
// } else {
|
||||||
$data['is_addon'] = 1;
|
$data['is_addon'] = 1;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1329,29 +1675,82 @@ class LeadsController extends BaseController
|
|||||||
private function convertQCRJsonToPolicyTerms($data, $policy_type, $proposel_name, $insurer_name)
|
private function convertQCRJsonToPolicyTerms($data, $policy_type, $proposel_name, $insurer_name)
|
||||||
{
|
{
|
||||||
$GMC_Keys = [
|
$GMC_Keys = [
|
||||||
"sum_insured", "family_floater", "family_floaters", "age_ratio", "waiverofpreexistingdiseases",
|
"sum_insured",
|
||||||
"maternitycoverage", "twindelivery", "preandpostnatal", "babyday1cover", "9monthwaitingperiodwaived",
|
"family_floater",
|
||||||
"coverfromthedateofjoining", "waiverof1,2,3&4thyearexclusions", "waiverof30dayswaitingperiod",
|
"family_floaters",
|
||||||
"prehospitalizationcover", "congenitaldiseasesinternal", "copayzonewisecopay",
|
"age_ratio",
|
||||||
"bioabsorbablestenttoriclensmultifocallens", "roomrentlimit", "proportionatedeductionclause",
|
"waiverofpreexistingdiseases",
|
||||||
"ailmentcapping", "ambulancecharges", "airambulance", "familytransportationbenefit",
|
"maternitycoverage",
|
||||||
"reasonableandcustomarycharges", "ayudhtreatmentcover", "congenitaldiseasesexternal",
|
"twindelivery",
|
||||||
"optionalparentalcopay", "posthospitalizationcover", "corporatebuffer", "sublimitofcorporatebuffer",
|
"preandpostnatal",
|
||||||
"ayushTreatmentCoverData", "armdcovered", "suminsuredenhancement", "automaticsuminsuredreinstatement",
|
"babyday1cover",
|
||||||
"additionalsicknessbenefit", "lasiksurgery", "midterminclusion", "capd", "organdonorexpenses",
|
"9monthwaitingperiodwaived",
|
||||||
"moderntreatmentsasperirdai", "Wellness", "days_of_discharge", "days_from_dod",
|
"coverfromthedateofjoining",
|
||||||
"special_condition_label", "special_condition_input", "multiple_sum_insured",
|
"waiverof1,2,3&4thyearexclusions",
|
||||||
"cataract", "cataractData"
|
"waiverof30dayswaitingperiod",
|
||||||
|
"prehospitalizationcover",
|
||||||
|
"congenitaldiseasesinternal",
|
||||||
|
"copayzonewisecopay",
|
||||||
|
"bioabsorbablestenttoriclensmultifocallens",
|
||||||
|
"roomrentlimit",
|
||||||
|
"proportionatedeductionclause",
|
||||||
|
"ailmentcapping",
|
||||||
|
"ambulancecharges",
|
||||||
|
"airambulance",
|
||||||
|
"familytransportationbenefit",
|
||||||
|
"reasonableandcustomarycharges",
|
||||||
|
"ayudhtreatmentcover",
|
||||||
|
"congenitaldiseasesexternal",
|
||||||
|
"optionalparentalcopay",
|
||||||
|
"posthospitalizationcover",
|
||||||
|
"corporatebuffer",
|
||||||
|
"sublimitofcorporatebuffer",
|
||||||
|
"ayushTreatmentCoverData",
|
||||||
|
"armdcovered",
|
||||||
|
"suminsuredenhancement",
|
||||||
|
"automaticsuminsuredreinstatement",
|
||||||
|
"additionalsicknessbenefit",
|
||||||
|
"lasiksurgery",
|
||||||
|
"midterminclusion",
|
||||||
|
"capd",
|
||||||
|
"organdonorexpenses",
|
||||||
|
"moderntreatmentsasperirdai",
|
||||||
|
"Wellness",
|
||||||
|
"days_of_discharge",
|
||||||
|
"days_from_dod",
|
||||||
|
"special_condition_label",
|
||||||
|
"special_condition_input",
|
||||||
|
"multiple_sum_insured",
|
||||||
|
"cataract",
|
||||||
|
"cataractData"
|
||||||
];
|
];
|
||||||
|
|
||||||
$GPA_Keys = [
|
$GPA_Keys = [
|
||||||
"sumInsured2", "totalSumInsured", "age_ratio", "accidentalDeathBenefit", "permanentTotalDisablement",
|
"sumInsured2",
|
||||||
"permanentPartialDisablement", "temporaryTotalDisablementBenefit", "accidentalHospitalizationExpenses",
|
"totalSumInsured",
|
||||||
"childrenEducationWelfareFund", "compassionateVisitExpenses", "compassionateVisitExpensesData",
|
"age_ratio",
|
||||||
"brokenBoneExpenses", "brokenBoneExpensesData", "ambulanceCharges", "ambulanceChargesData",
|
"accidentalDeathBenefit",
|
||||||
"burnExpenses", "burnExpensesData", "carriageOfDeadBody", "carriageOfDeadBodyData",
|
"permanentTotalDisablement",
|
||||||
"animalSnakeInsectBite", "terrorism", "worldwideCover", "gpa_special_condition_label",
|
"permanentPartialDisablement",
|
||||||
"gpa_special_condition_input", "multiple_sum_insured"
|
"temporaryTotalDisablementBenefit",
|
||||||
|
"accidentalHospitalizationExpenses",
|
||||||
|
"childrenEducationWelfareFund",
|
||||||
|
"compassionateVisitExpenses",
|
||||||
|
"compassionateVisitExpensesData",
|
||||||
|
"brokenBoneExpenses",
|
||||||
|
"brokenBoneExpensesData",
|
||||||
|
"ambulanceCharges",
|
||||||
|
"ambulanceChargesData",
|
||||||
|
"burnExpenses",
|
||||||
|
"burnExpensesData",
|
||||||
|
"carriageOfDeadBody",
|
||||||
|
"carriageOfDeadBodyData",
|
||||||
|
"animalSnakeInsectBite",
|
||||||
|
"terrorism",
|
||||||
|
"worldwideCover",
|
||||||
|
"gpa_special_condition_label",
|
||||||
|
"gpa_special_condition_input",
|
||||||
|
"multiple_sum_insured"
|
||||||
];
|
];
|
||||||
|
|
||||||
// Select keys based on policy type
|
// Select keys based on policy type
|
||||||
@ -1383,8 +1782,10 @@ class LeadsController extends BaseController
|
|||||||
$value = $cellData['value'] ?? '';
|
$value = $cellData['value'] ?? '';
|
||||||
|
|
||||||
// Skip unwanted keys
|
// Skip unwanted keys
|
||||||
if (in_array($parentth, ['Sno', 'Item Key', 'Particulars', 'Action']) ||
|
if (
|
||||||
in_array($subth, ['Quote Asked'])) {
|
in_array($parentth, ['Sno', 'Item Key', 'Particulars', 'Action']) ||
|
||||||
|
in_array($subth, ['Quote Asked'])
|
||||||
|
) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1444,7 +1845,6 @@ class LeadsController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond(['status' => false, 'message' => 'Failed to create policy', 'data' => $data], 200);
|
return $this->respond(['status' => false, 'message' => 'Failed to create policy', 'data' => $data], 200);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -4,90 +4,215 @@ namespace App\Helpers;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||||
|
|
||||||
class ExcelMergeHelper
|
class ExcelMergeHelper
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Merge multiple Excel files into a single spreadsheet.
|
protected static $logger;
|
||||||
*
|
|
||||||
* @param array $filesToMerge Array of files to merge.
|
public static function initialize()
|
||||||
* @param string $outputPath Path to save the merged file.
|
{
|
||||||
* @return bool True if merge successful, false otherwise.
|
self::$logger = \Config\Services::mylogger();
|
||||||
*/
|
}
|
||||||
public static function mergeExcelFiles(array $filesToMerge, string $outputPath): bool
|
public static function mergeExcelFiles(array $filesToMerge, string $outputPath)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// Validate input: If no files are provided, throw an error.
|
self::initialize();
|
||||||
if (empty($filesToMerge)) {
|
if (empty($filesToMerge)) {
|
||||||
throw new Exception("No files provided for merging");
|
throw new Exception("No files provided for merging.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the base spreadsheet (starting with null, will be created with the first file)
|
// Validate files exist and are readable
|
||||||
$spreadsheet = null;
|
foreach ($filesToMerge as $fileData) {
|
||||||
|
if (!file_exists($fileData['file_path'])) {
|
||||||
// Loop through the files to merge
|
throw new Exception("File not found: " . $fileData['file_path']);
|
||||||
foreach ($filesToMerge as $filePath => $sheetsToMerge) {
|
}
|
||||||
// Load the current file
|
if (!is_readable($fileData['file_path'])) {
|
||||||
$currentSpreadsheet = IOFactory::load($filePath);
|
throw new Exception("File not readable: " . $fileData['file_path']);
|
||||||
|
|
||||||
// Debugging: Log the number of sheets in the current file
|
|
||||||
error_log("File: $filePath has " . $currentSpreadsheet->getSheetCount() . " sheets.");
|
|
||||||
|
|
||||||
// If this is the first file, initialize the base spreadsheet
|
|
||||||
if ($spreadsheet === null) {
|
|
||||||
$spreadsheet = $currentSpreadsheet;
|
|
||||||
|
|
||||||
// If specific sheets are provided for the first file, remove the others
|
|
||||||
if (!is_null($sheetsToMerge) && !empty($sheetsToMerge)) {
|
|
||||||
$sheetCount = $spreadsheet->getSheetCount();
|
|
||||||
for ($i = $sheetCount - 1; $i >= 0; $i--) {
|
|
||||||
if (!in_array($i, $sheetsToMerge)) {
|
|
||||||
$spreadsheet->removeSheetByIndex($i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// If we are not working with the first file, we need to merge specified sheets
|
|
||||||
if (is_null($sheetsToMerge) || empty($sheetsToMerge)) {
|
|
||||||
// If no specific sheets, merge all sheets
|
|
||||||
$sheetsToMerge = range(0, $currentSpreadsheet->getSheetCount() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Merge the specified sheets from the current file
|
|
||||||
foreach ($sheetsToMerge as $sheetIndex) {
|
|
||||||
// Check if sheet index is within bounds
|
|
||||||
if ($sheetIndex < 0 || $sheetIndex >= $currentSpreadsheet->getSheetCount()) {
|
|
||||||
throw new Exception("Invalid sheet index $sheetIndex in file $filePath");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retrieve the sheet to copy
|
|
||||||
$sheetToCopy = $currentSpreadsheet->getSheet($sheetIndex);
|
|
||||||
|
|
||||||
// Handle sheet name collision by renaming the sheet with a counter
|
|
||||||
$baseName = $sheetToCopy->getTitle();
|
|
||||||
$sheetName = $baseName;
|
|
||||||
$counter = 1;
|
|
||||||
while ($spreadsheet->sheetNameExists($sheetName)) {
|
|
||||||
$sheetName = $baseName . '_merged_' . $counter;
|
|
||||||
$counter++;
|
|
||||||
}
|
|
||||||
$sheetToCopy->setTitle($sheetName);
|
|
||||||
|
|
||||||
// Clone and add the sheet to the base spreadsheet
|
|
||||||
$spreadsheet->addSheet(clone $sheetToCopy);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the merged file
|
self::$logger->logme('error',"Creating new spreadsheet...");
|
||||||
$writer = new Xlsx($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);
|
$writer->save($outputPath);
|
||||||
|
|
||||||
return true; // Return true if merge was successful
|
// Free up memory
|
||||||
|
$mergedSpreadsheet->disconnectWorksheets();
|
||||||
|
unset($mergedSpreadsheet);
|
||||||
|
|
||||||
|
self::$logger->logme('error',"Merge successful. File saved at: $outputPath");
|
||||||
|
return $outputPath;
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// Log the error (optional) and return false on failure
|
self::$logger->logme('error',"Excel Merge Error: " . $e->getMessage());
|
||||||
error_log("Excel Merge Error: " . $e->getMessage());
|
self::$logger->logme('error',"Error trace: " . $e->getTraceAsString());
|
||||||
return false;
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function copyWorksheetContent($sourceSheet, $targetSheet)
|
||||||
|
{
|
||||||
|
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}");
|
||||||
|
|
||||||
|
// 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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");
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
self::$logger->logme('error',"Error in copyWorksheetContent: " . $e->getMessage());
|
||||||
|
self::$logger->logme('error',"Error trace: " . $e->getTraceAsString());
|
||||||
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
38
app/Models/COShareStmtDetailsModel.php
Normal file
38
app/Models/COShareStmtDetailsModel.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use CodeIgniter\Model;
|
||||||
|
|
||||||
|
class COShareStmtDetailsModel extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'co_share_stmt_details';
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
protected $useAutoIncrement = true;
|
||||||
|
protected $returnType = 'array';
|
||||||
|
protected $useSoftDeletes = false;
|
||||||
|
protected $protectFields = true;
|
||||||
|
protected $allowedFields = [
|
||||||
|
'id',
|
||||||
|
'co_share_id',
|
||||||
|
'statement_id',
|
||||||
|
'actual_bp_amt',
|
||||||
|
'actual_tp_amt',
|
||||||
|
'actual_tep_amt',
|
||||||
|
'actual_bp_per',
|
||||||
|
'actual_tp_per',
|
||||||
|
'actual_tep_per',
|
||||||
|
'actual_bp_brokerage_amt',
|
||||||
|
'actual_tp_brokerage_amt',
|
||||||
|
'actual_tep_brokerage_amt',
|
||||||
|
'reward',
|
||||||
|
'exp_amt',
|
||||||
|
'variance',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
|
'is_active'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -23,7 +23,11 @@ class InsurerStatements extends Model
|
|||||||
"invoice_no",
|
"invoice_no",
|
||||||
"invoice_amount",
|
"invoice_amount",
|
||||||
"invoice_date",
|
"invoice_date",
|
||||||
"updated_by"
|
"updated_by",
|
||||||
|
"stmt_sno",
|
||||||
|
"gst_per",
|
||||||
|
"gst_value",
|
||||||
|
"invoice_value"
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@ -16,6 +16,7 @@ class InvPaymentDetailsModel extends Model
|
|||||||
'inv_amt',
|
'inv_amt',
|
||||||
'utr_no',
|
'utr_no',
|
||||||
'tds',
|
'tds',
|
||||||
|
'gst',
|
||||||
'received_date',
|
'received_date',
|
||||||
'created_by',
|
'created_by',
|
||||||
'is_active',
|
'is_active',
|
||||||
|
|||||||
@ -67,8 +67,11 @@ class PTCOShareDetailsModel extends Model
|
|||||||
'follower_policy_no',
|
'follower_policy_no',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getNonReconcileredPolicyTransactions(string $month,string $year,string $insurer_id,string $insurer_branch_id)
|
public function getNonReconcileredPolicyTransactions(string $insurer_id,string $insurer_branch_id)
|
||||||
{
|
{
|
||||||
|
$currentDate = date('Y-m-d');
|
||||||
|
$sixMonthsAgo = date('Y-m-01', strtotime('-6 months'));
|
||||||
|
|
||||||
return $this->db->table('pt_co_share_details pt_co')
|
return $this->db->table('pt_co_share_details pt_co')
|
||||||
->select('
|
->select('
|
||||||
pt_co.id,
|
pt_co.id,
|
||||||
@ -94,12 +97,15 @@ class PTCOShareDetailsModel extends Model
|
|||||||
->join('policy_transaction pt', 'pt_co.pt_id = pt.id')
|
->join('policy_transaction pt', 'pt_co.pt_id = pt.id')
|
||||||
->join('clients c', 'pt.client_id = c.id')
|
->join('clients c', 'pt.client_id = c.id')
|
||||||
->where('pt_co.is_active', 1)
|
->where('pt_co.is_active', 1)
|
||||||
->where('MONTH(pt.month)', $month)
|
->where('pt.is_active', 1)
|
||||||
->where('YEAR(pt.month)', $year)
|
// ->where('MONTH(pt.month)', $month)
|
||||||
|
// ->where('YEAR(pt.month)', $year)
|
||||||
->where('pt_co.insurer_id', $insurer_id)
|
->where('pt_co.insurer_id', $insurer_id)
|
||||||
->where('pt_co.insurer_branch_id', $insurer_branch_id)
|
->where('pt_co.insurer_branch_id', $insurer_branch_id)
|
||||||
->where('pt_co.statement_id is null')
|
// ->where('pt_co.statement_id is null')
|
||||||
->where('pt.status','completed')
|
->where('pt.status','completed')
|
||||||
|
->where('DATE(pt.created_at) >=', $sixMonthsAgo)
|
||||||
|
->where('DATE(pt.created_at) <=', $currentDate)
|
||||||
// ->where('pt_co.exp_amt', 0.00)
|
// ->where('pt_co.exp_amt', 0.00)
|
||||||
// ->orWhere('pt_co.exp_amt is null')
|
// ->orWhere('pt_co.exp_amt is null')
|
||||||
->get()
|
->get()
|
||||||
|
|||||||
@ -978,7 +978,7 @@ class PolicyTransactionModel extends Model
|
|||||||
return $builder->get()->getResultArray();
|
return $builder->get()->getResultArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOutstandingReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
|
public function getOutstandingReportList_OLD($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
|
||||||
{
|
{
|
||||||
$builder = $this->db->table('policy_transaction')
|
$builder = $this->db->table('policy_transaction')
|
||||||
->select("
|
->select("
|
||||||
@ -1076,4 +1076,52 @@ class PolicyTransactionModel extends Model
|
|||||||
return $builder->get()->getResultArray();
|
return $builder->get()->getResultArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getOutstandingReportList($start_date = 0, $end_date = 0, $insurer_id = 0,$insurer_branch_id = 0)
|
||||||
|
{
|
||||||
|
$builder = $this->db->table('insurer_statements s')
|
||||||
|
->select('
|
||||||
|
s.id,
|
||||||
|
s.insurer_id,
|
||||||
|
s.branch_id,
|
||||||
|
ins.short_name,
|
||||||
|
ib.branch_name,
|
||||||
|
s.month,
|
||||||
|
s.line_items,
|
||||||
|
s.stmt_sno,
|
||||||
|
s.invoice_status,
|
||||||
|
s.invoice_date,
|
||||||
|
s.invoice_no,
|
||||||
|
s.invoice_amount,
|
||||||
|
COALESCE(SUM(p.inv_amt) + SUM(p.tds) + SUM(p.gst), 0) AS total_paid,
|
||||||
|
(s.invoice_amount - COALESCE(SUM(p.inv_amt) + SUM(p.tds) + SUM(p.gst), 0)) AS outstanding_amount
|
||||||
|
')
|
||||||
|
->join('inv_payment_details p', 's.id = p.statement_id', 'left')
|
||||||
|
->join('insurers ins', 's.insurer_id = ins.id')
|
||||||
|
->join('insurer_branch ib', 's.branch_id = ib.id')
|
||||||
|
->where('s.is_active', 1)
|
||||||
|
->where('p.is_active', 1)
|
||||||
|
->groupBy('s.id, s.invoice_no, s.invoice_date, s.invoice_amount')
|
||||||
|
->having('outstanding_amount >', 0);
|
||||||
|
// ->get();
|
||||||
|
|
||||||
|
|
||||||
|
// Date range filtering
|
||||||
|
if ($start_date != 0 && $end_date != 0) {
|
||||||
|
|
||||||
|
$builder->where('s.month >=', $start_date)
|
||||||
|
->where('s.month <=', $end_date);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($insurer_id != 0) {
|
||||||
|
$builder->where('s.insurer_id', $insurer_id);
|
||||||
|
}
|
||||||
|
if ($insurer_branch_id != 0) {
|
||||||
|
$builder->where('s.branch_id', $insurer_branch_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$builder->orderBy('s.id', 'desc');
|
||||||
|
|
||||||
|
return $builder->get()->getResultArray();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,6 +103,10 @@ table.dataTable tbody td {
|
|||||||
.slider.round:before {
|
.slider.round:before {
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.disabled-option {
|
||||||
|
color: gray;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class="row" id="inception_list">
|
<div class="row" id="inception_list">
|
||||||
@ -125,6 +129,7 @@ table.dataTable tbody td {
|
|||||||
<th></th>
|
<th></th>
|
||||||
<th><div class="column-header">Insurer</div></th>
|
<th><div class="column-header">Insurer</div></th>
|
||||||
<th><div class="column-header">Month</div></th>
|
<th><div class="column-header">Month</div></th>
|
||||||
|
<th><div class="column-header">Statement<br>sno</div></th>
|
||||||
<th><div class="column-header">Filename</div></th>
|
<th><div class="column-header">Filename</div></th>
|
||||||
<th><div class="column-header">Line<br>items</div></th>
|
<th><div class="column-header">Line<br>items</div></th>
|
||||||
<th><div class="column-header">File<br>status</div></th>
|
<th><div class="column-header">File<br>status</div></th>
|
||||||
@ -140,6 +145,7 @@ table.dataTable tbody td {
|
|||||||
<td><input type="hidden" class="row-select" data-id="<?= $row['id']; ?>"></td>
|
<td><input type="hidden" class="row-select" data-id="<?= $row['id']; ?>"></td>
|
||||||
<td><?php echo $row['short_name'].'-'.$row['branch_code']; ?></td>
|
<td><?php echo $row['short_name'].'-'.$row['branch_code']; ?></td>
|
||||||
<td><?php echo change_date_format($row['month'],'Y-m-d','M-Y'); ?></td>
|
<td><?php echo change_date_format($row['month'],'Y-m-d','M-Y'); ?></td>
|
||||||
|
<td><?php echo $row['stmt_sno'] ?> </td>
|
||||||
<td><?php echo $row['file_name'] ?> </td>
|
<td><?php echo $row['file_name'] ?> </td>
|
||||||
<td><?php echo $row['line_items'] ?></td>
|
<td><?php echo $row['line_items'] ?></td>
|
||||||
<td><?php echo $row['file_status'];
|
<td><?php echo $row['file_status'];
|
||||||
@ -172,6 +178,9 @@ table.dataTable tbody td {
|
|||||||
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" data-exp-amt="<?= $row['exp_inv_amt'];?>" data-received-amt="<?= $row['received_inv_amt'];?>" onclick="showInvoiceStatusModal(event)">
|
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" data-exp-amt="<?= $row['exp_inv_amt'];?>" data-received-amt="<?= $row['received_inv_amt'];?>" onclick="showInvoiceStatusModal(event)">
|
||||||
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Invoice status
|
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Invoice status
|
||||||
</a>
|
</a>
|
||||||
|
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>"onclick="deleteStatement(<?= $row['id'];?>)">
|
||||||
|
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
@ -218,8 +227,24 @@ table.dataTable tbody td {
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-10">
|
<div class="form-group col-md-10">
|
||||||
<label for="statement_month">Statement month</label>
|
<label for="statement_month">Statement month</label>
|
||||||
<input type="text" class="form-control" id="statement_month" name="statement_month" placeholder="" required readonly>
|
<input type="text" class="form-control" id="statement_month" name="statement_month" placeholder="" required readonly onchange="getStatementNo()">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-10">
|
||||||
|
<label for="statement_no">Statement no</label>
|
||||||
|
<select class="form-control" id="statement_no" name="statement_no" required >
|
||||||
|
<option value="" selected>Select statement no</option>
|
||||||
|
<?php
|
||||||
|
$stmt_no = [1,2,3,4,5,6,7];
|
||||||
|
if (isset($stmt_no) && count($stmt_no)) {
|
||||||
|
foreach ($stmt_no as $key => $value) {
|
||||||
|
echo "<option value=" . $value . ">" . $value . "</option>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-md-10" >
|
<div class="form-group col-md-10" >
|
||||||
<label for="statment">Statement </label> <span><a href="downloadSampleInsurerStatement" id="download_sample_file" style="font-size: small;">Download sample file</a></span>
|
<label for="statment">Statement </label> <span><a href="downloadSampleInsurerStatement" id="download_sample_file" style="font-size: small;">Download sample file</a></span>
|
||||||
<input type="file" class="form-control" name="statement" required accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet">
|
<input type="file" class="form-control" name="statement" required accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet">
|
||||||
@ -255,7 +280,7 @@ table.dataTable tbody td {
|
|||||||
|
|
||||||
<!-- Invoice status content modal-->
|
<!-- Invoice status content modal-->
|
||||||
<div class="modal fade" id="invoice_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
<div class="modal fade" id="invoice_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||||
<div class="modal-dialog modal-lg">
|
<div class="modal-dialog modal-lg" style="max-width:1000px;">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h4 class="modal-title" id="title">Update Invoice Status</h4>
|
<h4 class="modal-title" id="title">Update Invoice Status</h4>
|
||||||
@ -286,32 +311,65 @@ table.dataTable tbody td {
|
|||||||
<label for="addon_policy">Exp Amount</label>
|
<label for="addon_policy">Exp Amount</label>
|
||||||
<input type="text" class="form-control" id="modal_exp_amt" placeholder="" disabled>
|
<input type="text" class="form-control" id="modal_exp_amt" placeholder="" disabled>
|
||||||
</div> -->
|
</div> -->
|
||||||
<div class="form-group col-md-4" id="modal_received_amt_div">
|
|
||||||
<label for="addon_policy">Total Received Amount</label>
|
|
||||||
<input type="text" class="form-control" id="modal_received_amt" placeholder="" disabled>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Invoice Number and Invoice Date in same row -->
|
<!-- Invoice Number and Invoice Date in same row -->
|
||||||
<div class="row" id="invoice_no_div_modal" style="display: none;">
|
<!-- <div id="invoice_no_div_modal" style="display: none;"> -->
|
||||||
<div class="form-group col-md-4">
|
<div class="row" id="invoice_no_div_modal" style="display: none;">
|
||||||
<label for="invoice_no">Invoice Number<span id="base_danger" class="text-danger"></span></label>
|
<div class="form-group col-md-4">
|
||||||
<input type="text" class="form-control" id="invoice_no_modal" name="invoice_no" placeholder="Enter Invoice Number" required>
|
<label for="invoice_no">Invoice Number<span id="base_danger" class="text-danger"></span></label>
|
||||||
|
<input type="text" class="form-control" id="invoice_no_modal" name="invoice_no" placeholder="Enter Invoice Number" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
<label for="invoice_date">Invoice Date</label>
|
||||||
|
<input type="text" class="form-control" id="invoice_date_modal" name="invoice_date" value="<?php echo date('Y-m-d'); ?>" readonly required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
<label for="invoice_value_modal">Invoice value<span id="base_danger" class="text-danger"></span></label>
|
||||||
|
<input type="number" class="form-control" id="invoice_value_modal" name="invoice_value" placeholder="Enter Invoice Value" readonly>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-4">
|
<div class="row" id="invoice_no_div_modal2" style="display: none;">
|
||||||
<label for="invoice_no">Invoice Amount<span id="base_danger" class="text-danger"></span></label>
|
|
||||||
<input type="number" class="form-control" id="invoice_amount_no_modal" name="invoice_amount" placeholder="Enter Invoice Amt" required>
|
<div class="form-group col-md-4">
|
||||||
|
<label for="gst_value_modal">GST %<span id="base_danger" class="text-danger"></span></label>
|
||||||
|
<input type="number" class="form-control" id="gst_per_modal" name="invoice_gst_per" placeholder="Enter GST %" required onchange="calcGSTValue()">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
<label for="gst_value_modal">GST Value<span id="base_danger" class="text-danger"></span></label>
|
||||||
|
<input type="number" class="form-control" id="gst_value_modal" name="invoice_gst" placeholder="Enter Invoice Value" required readonly step="0.01">
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
<label for="invoice_no">Invoice Amount<span id="base_danger" class="text-danger"></span></label>
|
||||||
|
<input type="number" class="form-control" id="invoice_amount_no_modal" name="invoice_amount" placeholder="Enter Invoice Amt" required readonly step="0.01">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- <div class="form-group col-md-3" id="modal_received_amt_div">
|
||||||
|
<label for="addon_policy">Total Received Amount</label>
|
||||||
|
<input type="text" class="form-control" id="modal_received_amt" placeholder="" disabled>
|
||||||
|
</div> -->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-4">
|
|
||||||
<label for="invoice_date">Invoice Date</label>
|
<div class="row" id="modal_received_amt_div">
|
||||||
<input type="text" class="form-control" id="invoice_date_modal" name="invoice_date" value="<?php echo date('Y-m-d'); ?>" readonly required>
|
<div class="form-group col-md-4" >
|
||||||
|
<label for="addon_policy">Total Received Amount</label>
|
||||||
|
<input type="number" class="form-control" id="modal_received_amt" placeholder="" disabled>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<!-- </div> -->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Payment Received Table -->
|
<!-- Payment Received Table -->
|
||||||
<div class="form-group col-md-12" style="display: none;" id="payment_table_div_modal">
|
<div class="form-group col-md-12" style="display: none;" id="payment_table_div_modal" style="max-width: 800px;">
|
||||||
<button type="button" id="add_row_btn" class="btn btn-secondary float-right"><i class="fa fa-plus"></i></button>
|
<button type="button" id="add_row_btn" class="btn btn-secondary float-right"><i class="fa fa-plus"></i></button>
|
||||||
|
|
||||||
|
|
||||||
@ -319,7 +377,8 @@ table.dataTable tbody td {
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th style="display: none;">pk</th>
|
<th style="display: none;">pk</th>
|
||||||
<th>Received Amount</th>
|
<th>Invoice value</th>
|
||||||
|
<th>GST</th>
|
||||||
<th>TDS</th>
|
<th>TDS</th>
|
||||||
<th>UTR Number</th>
|
<th>UTR Number</th>
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
@ -330,6 +389,7 @@ table.dataTable tbody td {
|
|||||||
<tr>
|
<tr>
|
||||||
<td style="display: none;"><input type="hidden" class="form-control" name="pk[]" placeholder="Enter Amount"></td>
|
<td style="display: none;"><input type="hidden" class="form-control" name="pk[]" placeholder="Enter Amount"></td>
|
||||||
<td><input type="number" class="form-control" name="received_amount[]" placeholder="Enter Amount" required onchange="checkInvAmont(event)"></td>
|
<td><input type="number" class="form-control" name="received_amount[]" placeholder="Enter Amount" required onchange="checkInvAmont(event)"></td>
|
||||||
|
<td><input type="number" class="form-control" name="gst_amount[]" placeholder="Enter GST" required step="0.01" onchange="checkInvAmont(event)"></td>
|
||||||
<td><input type="number" class="form-control" name="tds[]" placeholder="Enter TDS" onchange="checkInvAmont(event)" required></td>
|
<td><input type="number" class="form-control" name="tds[]" placeholder="Enter TDS" onchange="checkInvAmont(event)" required></td>
|
||||||
<td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" required></td>
|
<td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" required></td>
|
||||||
<td><input type="text" class="form-control payment_date" name="payment_date[]" value="<?php echo date('d/m/Y'); ?>" placeholder="dd/mm/yyyy" required readonly></td>
|
<td><input type="text" class="form-control payment_date" name="payment_date[]" value="<?php echo date('d/m/Y'); ?>" placeholder="dd/mm/yyyy" required readonly></td>
|
||||||
@ -358,12 +418,14 @@ table.dataTable tbody td {
|
|||||||
const invoiceStatus = this.value;
|
const invoiceStatus = this.value;
|
||||||
console.log(invoiceStatus);
|
console.log(invoiceStatus);
|
||||||
const invoiceNoDiv = document.getElementById('invoice_no_div_modal');
|
const invoiceNoDiv = document.getElementById('invoice_no_div_modal');
|
||||||
|
const invoiceNoDiv2 = document.getElementById('invoice_no_div_modal2');
|
||||||
// const invoiceDateDiv = document.getElementById('invoice_date_div_modal');
|
// const invoiceDateDiv = document.getElementById('invoice_date_div_modal');
|
||||||
const paymentTableDiv = document.getElementById('payment_table_div_modal');
|
const paymentTableDiv = document.getElementById('payment_table_div_modal');
|
||||||
const totalReceivedAmtDiv = document.getElementById('modal_received_amt_div');
|
const totalReceivedAmtDiv = document.getElementById('modal_received_amt_div');
|
||||||
|
|
||||||
// Hide everything initially
|
// Hide everything initially
|
||||||
invoiceNoDiv.style.display = 'none';
|
invoiceNoDiv.style.display = 'none';
|
||||||
|
invoiceNoDiv2.style.display = 'none';
|
||||||
// invoiceDateDiv.style.display = 'none';
|
// invoiceDateDiv.style.display = 'none';
|
||||||
paymentTableDiv.style.display = 'none';
|
paymentTableDiv.style.display = 'none';
|
||||||
totalReceivedAmtDiv.style.display = 'none';
|
totalReceivedAmtDiv.style.display = 'none';
|
||||||
@ -371,6 +433,7 @@ table.dataTable tbody td {
|
|||||||
// Show fields based on selected status
|
// Show fields based on selected status
|
||||||
if (invoiceStatus === 'generated' || invoiceStatus === 'sent') {
|
if (invoiceStatus === 'generated' || invoiceStatus === 'sent') {
|
||||||
invoiceNoDiv.style.display = 'flex';
|
invoiceNoDiv.style.display = 'flex';
|
||||||
|
invoiceNoDiv2.style.display = 'flex';
|
||||||
totalReceivedAmtDiv.style.display = 'none';
|
totalReceivedAmtDiv.style.display = 'none';
|
||||||
switchRequired('invoice_no_modal',true);
|
switchRequired('invoice_no_modal',true);
|
||||||
switchRequired('invoice_date_modal',true);
|
switchRequired('invoice_date_modal',true);
|
||||||
@ -384,6 +447,7 @@ table.dataTable tbody td {
|
|||||||
// invoiceDateDiv.style.display = 'block';
|
// invoiceDateDiv.style.display = 'block';
|
||||||
} else if (invoiceStatus === 'payment_received') {
|
} else if (invoiceStatus === 'payment_received') {
|
||||||
invoiceNoDiv.style.display = 'flex';
|
invoiceNoDiv.style.display = 'flex';
|
||||||
|
invoiceNoDiv2.style.display = 'flex';
|
||||||
paymentTableDiv.style.display = 'block';
|
paymentTableDiv.style.display = 'block';
|
||||||
totalReceivedAmtDiv.style.display = 'block';
|
totalReceivedAmtDiv.style.display = 'block';
|
||||||
switchRequired('invoice_no_modal',true);
|
switchRequired('invoice_no_modal',true);
|
||||||
@ -399,6 +463,7 @@ table.dataTable tbody td {
|
|||||||
}else if(invoiceStatus === 'pending')
|
}else if(invoiceStatus === 'pending')
|
||||||
{
|
{
|
||||||
invoiceNoDiv.style.display = 'none';
|
invoiceNoDiv.style.display = 'none';
|
||||||
|
invoiceNoDiv2.style.display = 'none';
|
||||||
paymentTableDiv.style.display = 'none';
|
paymentTableDiv.style.display = 'none';
|
||||||
totalReceivedAmtDiv.style.display = 'none';
|
totalReceivedAmtDiv.style.display = 'none';
|
||||||
// switchRequired('modal_received_amt_div',false);
|
// switchRequired('modal_received_amt_div',false);
|
||||||
@ -435,6 +500,13 @@ table.dataTable tbody td {
|
|||||||
|
|
||||||
$('#invoiceForm').on('submit', function (e) {
|
$('#invoiceForm').on('submit', function (e) {
|
||||||
e.preventDefault(); // Prevent default form submission
|
e.preventDefault(); // Prevent default form submission
|
||||||
|
|
||||||
|
var res = checkInvAmont();
|
||||||
|
if(!res)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var form = document.getElementById('invoiceForm');
|
var form = document.getElementById('invoiceForm');
|
||||||
// alert(form.checkValidity());
|
// alert(form.checkValidity());
|
||||||
// alert($('#invoice_date_modal').val());
|
// alert($('#invoice_date_modal').val());
|
||||||
@ -487,7 +559,7 @@ table.dataTable tbody td {
|
|||||||
|
|
||||||
$('.close').click()
|
$('.close').click()
|
||||||
// Reset the form data
|
// Reset the form data
|
||||||
$('#invoiceForm')[0].reset();
|
// $('#invoiceForm')[0].reset();
|
||||||
|
|
||||||
alert('Invoice updated successfully!');
|
alert('Invoice updated successfully!');
|
||||||
location.reload();
|
location.reload();
|
||||||
@ -513,6 +585,7 @@ table.dataTable tbody td {
|
|||||||
newRow.innerHTML = `
|
newRow.innerHTML = `
|
||||||
<td style="display: none;"><input type="hidden" class="form-control" name="pk[]" placeholder="Enter Amount"></td>
|
<td style="display: none;"><input type="hidden" class="form-control" name="pk[]" placeholder="Enter Amount"></td>
|
||||||
<td><input type="number" class="form-control" name="received_amount[]" placeholder="Enter Amount" onchange="checkInvAmont(event)" required></td>
|
<td><input type="number" class="form-control" name="received_amount[]" placeholder="Enter Amount" onchange="checkInvAmont(event)" required></td>
|
||||||
|
<td><input type="number" class="form-control" name="gst_amount[]" placeholder="Enter GST" onchange="checkInvAmont(event)" required step="0.01"></td>
|
||||||
<td><input type="number" class="form-control" name="tds[]" placeholder="Enter TDS" onchange="checkInvAmont(event)" required></td>
|
<td><input type="number" class="form-control" name="tds[]" placeholder="Enter TDS" onchange="checkInvAmont(event)" required></td>
|
||||||
<td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" required></td>
|
<td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" required></td>
|
||||||
<td><input type="text" class="form-control payment_date" value="<?php echo date('d/m/Y'); ?>" name="payment_date[]" placeholder="dd/mm/yyyy" required readonly></td>
|
<td><input type="text" class="form-control payment_date" value="<?php echo date('d/m/Y'); ?>" name="payment_date[]" placeholder="dd/mm/yyyy" required readonly></td>
|
||||||
@ -628,6 +701,10 @@ function showInvoiceStatusModal(event)
|
|||||||
document.getElementById('invoice_date_modal').value = response.data.invoice_date === '' ? <?php echo date('d-m-Y')?> : response.data.invoice_date;
|
document.getElementById('invoice_date_modal').value = response.data.invoice_date === '' ? <?php echo date('d-m-Y')?> : response.data.invoice_date;
|
||||||
document.getElementById('invoice_amount_no_modal').value = response.data.invoice_amount;
|
document.getElementById('invoice_amount_no_modal').value = response.data.invoice_amount;
|
||||||
|
|
||||||
|
document.getElementById('invoice_value_modal').value = response.data.invoice_value;
|
||||||
|
document.getElementById('gst_per_modal').value = response.data.gst_per;
|
||||||
|
document.getElementById('gst_value_modal').value = response.data.gst_value;
|
||||||
|
|
||||||
if (!$('#invoice_date_modal').val()) {
|
if (!$('#invoice_date_modal').val()) {
|
||||||
// alert('nope');
|
// alert('nope');
|
||||||
// Set today's date as the default date
|
// Set today's date as the default date
|
||||||
@ -646,6 +723,7 @@ function showInvoiceStatusModal(event)
|
|||||||
row.innerHTML = `
|
row.innerHTML = `
|
||||||
<td style="display: none;"><input type="hidden" class="form-control" name="pk[]" value="${payment.id}"></td>
|
<td style="display: none;"><input type="hidden" class="form-control" name="pk[]" value="${payment.id}"></td>
|
||||||
<td><input type="number" class="form-control" name="received_amount[]" placeholder="Enter Amount" value="${payment.inv_amt}" onchange="checkInvAmont(event)" required></td>
|
<td><input type="number" class="form-control" name="received_amount[]" placeholder="Enter Amount" value="${payment.inv_amt}" onchange="checkInvAmont(event)" required></td>
|
||||||
|
<td><input type="number" class="form-control" name="gst_amount[]" placeholder="Enter Amount" value="${payment.gst}" onchange="checkInvAmont(event)" required step="0.01"></td>
|
||||||
<td><input type="number" class="form-control" name="tds[]" placeholder="Enter Amount" value="${payment.tds}" onchange="checkInvAmont(event)" required></td>
|
<td><input type="number" class="form-control" name="tds[]" placeholder="Enter Amount" value="${payment.tds}" onchange="checkInvAmont(event)" required></td>
|
||||||
<td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" value="${payment.utr_no}" required></td>
|
<td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" value="${payment.utr_no}" required></td>
|
||||||
<td><input type="text" class="form-control payment_date" name="payment_date[]" value="${formatDateToDMY(payment.received_date)}" required readonly></td>
|
<td><input type="text" class="form-control payment_date" name="payment_date[]" value="${formatDateToDMY(payment.received_date)}" required readonly></td>
|
||||||
@ -730,8 +808,6 @@ maxDate.setDate(today.getDate() + 180);
|
|||||||
}
|
}
|
||||||
|
|
||||||
$('#btnSubmit').prop('disabled', true).text('Submitting...');
|
$('#btnSubmit').prop('disabled', true).text('Submitting...');
|
||||||
|
|
||||||
|
|
||||||
// Create FormData object
|
// Create FormData object
|
||||||
var formData = new FormData($(this)[0]);
|
var formData = new FormData($(this)[0]);
|
||||||
for (var pair of formData.entries()) {
|
for (var pair of formData.entries()) {
|
||||||
@ -773,6 +849,9 @@ maxDate.setDate(today.getDate() + 180);
|
|||||||
toastr.error('Something went wrong! Try later', 'Error');
|
toastr.error('Something went wrong! Try later', 'Error');
|
||||||
window.location.reload(true);
|
window.location.reload(true);
|
||||||
}
|
}
|
||||||
|
$('.close').click()
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(10).fadeOut('slow');
|
||||||
|
|
||||||
$('#btnSubmit').prop('disabled', false).text('Submit');
|
$('#btnSubmit').prop('disabled', false).text('Submit');
|
||||||
|
|
||||||
@ -782,11 +861,13 @@ maxDate.setDate(today.getDate() + 180);
|
|||||||
console.error("Request failed:", status, error);
|
console.error("Request failed:", status, error);
|
||||||
toastr.error('Something went wrong! Try later', 'Error');
|
toastr.error('Something went wrong! Try later', 'Error');
|
||||||
$('#uploadForm')[0].reset();
|
$('#uploadForm')[0].reset();
|
||||||
|
$('.close').click()
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(10).fadeOut('slow');
|
||||||
window.location.reload(true);
|
window.location.reload(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('.loader').fadeOut();
|
|
||||||
$('.loader-mask').delay(10).fadeOut('slow');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function fetchFileError(file_id) {
|
function fetchFileError(file_id) {
|
||||||
@ -810,7 +891,7 @@ maxDate.setDate(today.getDate() + 180);
|
|||||||
var file_error_html = "";
|
var file_error_html = "";
|
||||||
|
|
||||||
if (file_error_data['error_code'] == 1) {
|
if (file_error_data['error_code'] == 1) {
|
||||||
file_error_html += 'The following row no(s) from excel are <span style="font-weight:bold">either already mapped / not found with policy transactions / duplicates.</span>';
|
file_error_html += 'The following row no(s) from excel are <span style="font-weight:bold">not found with policy transactions / duplicates.</span>';
|
||||||
file_error_html += ' : ' + '<span style="font-weight:bolder">' + file_error_data['error_data'].join(',') + '</span>';
|
file_error_html += ' : ' + '<span style="font-weight:bolder">' + file_error_data['error_data'].join(',') + '</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -835,19 +916,21 @@ maxDate.setDate(today.getDate() + 180);
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function checkInvAmont(event) {
|
function checkInvAmont(event = null) {
|
||||||
var total = 0;
|
var total = 0;
|
||||||
var receivedAmounts = document.querySelectorAll('input[name="received_amount[]"]');
|
var receivedAmounts = document.querySelectorAll('input[name="received_amount[]"]');
|
||||||
|
var receivedGST = document.querySelectorAll('input[name="gst_amount[]"]');
|
||||||
var tdsAmounts = document.querySelectorAll('input[name="tds[]"]');
|
var tdsAmounts = document.querySelectorAll('input[name="tds[]"]');
|
||||||
// console.log();
|
// console.log();
|
||||||
receivedAmounts.forEach(function(el, index) {
|
receivedAmounts.forEach(function(el, index) {
|
||||||
// Get the received amount
|
// Get the received amount
|
||||||
let receivedVal = parseFloat(el.value) || 0;
|
let receivedVal = parseFloat(el.value) || 0;
|
||||||
// Get the corresponding tds amount (paired with the received amount)
|
// Get the corresponding tds amount (paired with the received amount)
|
||||||
|
let gstVal = parseFloat(receivedGST[index].value) || 0;
|
||||||
let tdsVal = parseFloat(tdsAmounts[index].value) || 0;
|
let tdsVal = parseFloat(tdsAmounts[index].value) || 0;
|
||||||
// Add received amount and tds amount
|
// Add received amount and tds amount
|
||||||
// console.log();
|
// console.log();
|
||||||
total += (receivedVal + tdsVal);
|
total += (receivedVal + tdsVal + gstVal);
|
||||||
});
|
});
|
||||||
// console.log(total);
|
// console.log(total);
|
||||||
// Get the expected invoice amount
|
// Get the expected invoice amount
|
||||||
@ -855,9 +938,16 @@ function checkInvAmont(event) {
|
|||||||
|
|
||||||
// Check if the total exceeds the expected amount
|
// Check if the total exceeds the expected amount
|
||||||
if (exp_amt < total) {
|
if (exp_amt < total) {
|
||||||
alert('Exceeds Invoice amount');
|
alert('Exceeds Invoice amount...Plz adjust numbers');
|
||||||
event.target.value = ''; // Reset the value of the element that triggered the event
|
if(event != null)
|
||||||
|
{
|
||||||
|
event.target.value = '';
|
||||||
|
|
||||||
|
}
|
||||||
|
return false; // Reset the value of the element that triggered the event
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -889,5 +979,186 @@ function switchRequired(elementId, isRequired, type = 'id') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getStatementNo()
|
||||||
|
{
|
||||||
|
var insurer_id = $('#insurer').val();
|
||||||
|
var statement_month = $('#statement_month').val();
|
||||||
|
|
||||||
|
console.log(insurer_id+' / '+statement_month);
|
||||||
|
if(insurer_id == "")
|
||||||
|
{
|
||||||
|
alert('Choose insurer...!');
|
||||||
|
$('#statement_month').val('');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$('.loader').fadeIn();
|
||||||
|
$('.loader-mask').fadeIn();
|
||||||
|
var apiURL = 'getInsurerStatementMonth?insurer_id=' +insurer_id+'&month='+statement_month ;
|
||||||
|
$.ajax({
|
||||||
|
url: apiURL,
|
||||||
|
type: "GET",
|
||||||
|
headers: {
|
||||||
|
// "Content-Type":"multipart/form-data",
|
||||||
|
"X-Requested-With": "XMLHttpRequest"
|
||||||
|
},
|
||||||
|
success: function(response) {
|
||||||
|
|
||||||
|
console.log(response);
|
||||||
|
// $('#insurer_statement_upload_form')[0].reset();
|
||||||
|
|
||||||
|
if (response.code === 200 && response.dataStatus === true && response
|
||||||
|
.data !== "") {
|
||||||
|
|
||||||
|
disableStatementNo(response.data)
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(10).fadeOut('slow');
|
||||||
|
} else if (response.code === 404 && response.dataStatus === false) {
|
||||||
|
console.error('no data found', response);
|
||||||
|
// alert(response.message);
|
||||||
|
// toastr.error(response.message, 'Failed');
|
||||||
|
// window.location.reload(true);
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(10).fadeOut('slow');
|
||||||
|
} else {
|
||||||
|
console.error('Something went wrong!');
|
||||||
|
// alert('Something went wrong! Try later');
|
||||||
|
toastr.error('Something went wrong! Try later', 'Error');
|
||||||
|
// window.location.reload(true);
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(10).fadeOut('slow');
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
// Request failed, handle error
|
||||||
|
console.error("Request failed:", status, error);
|
||||||
|
toastr.error('Something went wrong! Try later', 'Error');
|
||||||
|
// $('#uploadForm')[0].reset();
|
||||||
|
// window.location.reload(true);
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(10).fadeOut('slow');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// $('.loader').fadeOut();
|
||||||
|
// $('.loader-mask').delay(10).fadeOut('slow');
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function calcGSTValue()
|
||||||
|
{
|
||||||
|
// alert('calcGSTValue');
|
||||||
|
var gst_per = document.getElementById('gst_per_modal').value;
|
||||||
|
|
||||||
|
var invoice_value_dom_obj = document.getElementById('invoice_value_modal');
|
||||||
|
var invoice_value = invoice_value_dom_obj.value;
|
||||||
|
|
||||||
|
var gst_value_dom_obj = document.getElementById('gst_value_modal');
|
||||||
|
var gst_value = gst_value_dom_obj.value;
|
||||||
|
|
||||||
|
var invoice_amount_dom_obj = document.getElementById('invoice_amount_no_modal');
|
||||||
|
// var invoice_amount = invoice_amount_dom_obj.value();
|
||||||
|
|
||||||
|
gst_value_dom_obj.value = (parseFloat(gst_per) / 100 ) * invoice_value;
|
||||||
|
invoice_amount_dom_obj.value = parseFloat(invoice_value_dom_obj.value) + parseFloat(gst_value_dom_obj.value);
|
||||||
|
checkInvAmont();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function disableStatementNo(arr)
|
||||||
|
{
|
||||||
|
// JavaScript array with values to disable
|
||||||
|
// const disableValues = arr;
|
||||||
|
const disableIds = arr.map(item => item.stmt_sno);
|
||||||
|
console.log(disableIds);
|
||||||
|
|
||||||
|
// Get the select element
|
||||||
|
const selectElement = document.getElementById("statement_no");
|
||||||
|
// Variable to track if the first enabled option is selected
|
||||||
|
let firstEnabledOptionSelected = false;
|
||||||
|
// Iterate over the options in the select element
|
||||||
|
Array.from(selectElement.options).forEach(option => {
|
||||||
|
// If the option value is in the disableIds array, disable it
|
||||||
|
console.log(option.value);
|
||||||
|
option.disabled = false;
|
||||||
|
option.style.backgroundColor = "";
|
||||||
|
if (disableIds.includes((option.value))) {
|
||||||
|
option.disabled = true;
|
||||||
|
option.style.backgroundColor = "lightgray";
|
||||||
|
}
|
||||||
|
else if (!firstEnabledOptionSelected && option.value !== "") {
|
||||||
|
// Automatically select the first enabled option
|
||||||
|
option.selected = true;
|
||||||
|
firstEnabledOptionSelected = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteStatement(id)
|
||||||
|
{
|
||||||
|
//alert(id);
|
||||||
|
Swal.fire({
|
||||||
|
title: "Do you want to delete statement & it's invoice data if any?",
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: "Delete",
|
||||||
|
confirmButtonColor: "#ff3333",
|
||||||
|
}).then((result) => {
|
||||||
|
|
||||||
|
console.log(result);
|
||||||
|
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
|
||||||
|
$('.loader').fadeIn();
|
||||||
|
$('.loader-mask').fadeIn();
|
||||||
|
var apiURL = 'deleteStatement/' + id;
|
||||||
|
// console.log('Truncate API URL : ', apiURL);
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: apiURL,
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
"X-Requested-With": "XMLHttpRequest"
|
||||||
|
},
|
||||||
|
success: function(response) {
|
||||||
|
// console.log('Truncate Response', response)
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(10).fadeOut('slow');
|
||||||
|
if (response.code === 200 && response.dataStatus === true) {
|
||||||
|
Swal.fire({
|
||||||
|
title: "Deleted!",
|
||||||
|
icon: "success"
|
||||||
|
});
|
||||||
|
window.location.reload(true);
|
||||||
|
} else {
|
||||||
|
Swal.fire({
|
||||||
|
title: "Failed!",
|
||||||
|
text: 'Something went wrong! Try later',
|
||||||
|
icon: "error"
|
||||||
|
});
|
||||||
|
|
||||||
|
window.location.reload(true);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
|
||||||
|
console.error(xhr.responseText);
|
||||||
|
console.error(status, error);
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(10).fadeOut('slow');
|
||||||
|
console.error('Error fetching data from API:', error);
|
||||||
|
toastr.error('Something went wrong! Try later', 'Error');
|
||||||
|
window.location.reload(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@ -41,7 +41,7 @@ table.dataTable tbody td {
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
|
|
||||||
<div class="form-group col-md-3">
|
<!-- <div class="form-group col-md-3">
|
||||||
<label for="client_branch">Client<span class="text-danger"></span></label>
|
<label for="client_branch">Client<span class="text-danger"></span></label>
|
||||||
<select class="form-control" id="client_id" name="client_id">
|
<select class="form-control" id="client_id" name="client_id">
|
||||||
<option value="0">Select Client</option>
|
<option value="0">Select Client</option>
|
||||||
@ -53,7 +53,7 @@ table.dataTable tbody td {
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div> -->
|
||||||
|
|
||||||
<div class="form-group col-md-3">
|
<div class="form-group col-md-3">
|
||||||
<label for="addon_policy"> Insurer <span id="base_danger"
|
<label for="addon_policy"> Insurer <span id="base_danger"
|
||||||
@ -69,6 +69,19 @@ table.dataTable tbody td {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-md-3">
|
<div class="form-group col-md-3">
|
||||||
|
<label for="addon_policy"> Insurer Branch<span id="base_danger"
|
||||||
|
class="text-danger"></span></label>
|
||||||
|
<select class="form-control" id="insurer_id" name="insurer_id">
|
||||||
|
<option value="0" selected>Select Insurer</option>
|
||||||
|
<?php if(isset($insurer) && count($insurer)){ ?>
|
||||||
|
<?php foreach ($insurer as $value) { ?>
|
||||||
|
<option value="<?= $value['id']?>"><?= $value['name']?></option>
|
||||||
|
<?php } ?>
|
||||||
|
<?php } ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- <div class="form-group col-md-3">
|
||||||
<label for="email"> Policy Type <span class="text-danger"></span></label>
|
<label for="email"> Policy Type <span class="text-danger"></span></label>
|
||||||
<select class="form-control" id="policy_type_id" name="policy_type_id">
|
<select class="form-control" id="policy_type_id" name="policy_type_id">
|
||||||
<option value="0">Select Policy Type</option>
|
<option value="0">Select Policy Type</option>
|
||||||
@ -80,9 +93,9 @@ table.dataTable tbody td {
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div> -->
|
||||||
|
|
||||||
<div class="form-group col-md-3">
|
<!-- <div class="form-group col-md-3">
|
||||||
<label for="client_branch">Issuer<span class="text-danger">*</span></label>
|
<label for="client_branch">Issuer<span class="text-danger">*</span></label>
|
||||||
<select class="form-control" id="issuer" name="issuer" required>
|
<select class="form-control" id="issuer" name="issuer" required>
|
||||||
<option value="0">Select Issure</option>
|
<option value="0">Select Issure</option>
|
||||||
@ -94,13 +107,13 @@ table.dataTable tbody td {
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div> -->
|
||||||
|
|
||||||
</div>
|
<!-- </div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row"> -->
|
||||||
|
|
||||||
<div class="form-group col-md-3">
|
<!-- <div class="form-group col-md-3">
|
||||||
<label>Date Type<span class="text-danger"></span></label>
|
<label>Date Type<span class="text-danger"></span></label>
|
||||||
<select class="form-control" id="date_type" name="date_type"
|
<select class="form-control" id="date_type" name="date_type"
|
||||||
onchange="hideDateField()">
|
onchange="hideDateField()">
|
||||||
@ -113,10 +126,10 @@ table.dataTable tbody td {
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div> -->
|
||||||
|
|
||||||
<div class="form-group col-md-3" style="display: none;" id="date_div">
|
<div class="form-group col-md-3" style="display: true;" id="date_div">
|
||||||
<label>Date<span class="text-danger"></span></label>
|
<label>Statement Month<span class="text-danger"></span></label>
|
||||||
<div id="reportrange" class="form-control"
|
<div id="reportrange" class="form-control"
|
||||||
style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc; width: 100%">
|
style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc; width: 100%">
|
||||||
<i class="fa fa-calendar"></i>
|
<i class="fa fa-calendar"></i>
|
||||||
@ -158,28 +171,36 @@ table.dataTable tbody td {
|
|||||||
<thead class="bg-light">
|
<thead class="bg-light">
|
||||||
<tr>
|
<tr>
|
||||||
<th>S.No</th>
|
<th>S.No</th>
|
||||||
<th>Client Name</th>
|
<!-- <th>Client Name</th> -->
|
||||||
<th>Insurer</th>
|
<th>Insurer</th>
|
||||||
<th>Policy</th>
|
<th>Insurer<br> Branch</th>
|
||||||
<th>Endorsement No</th>
|
<th>Statement<br> Month</th>
|
||||||
|
<th>Statement<br> No</th>
|
||||||
|
<th>Invoice No</th>
|
||||||
<th>Invoice Status</th>
|
<th>Invoice Status</th>
|
||||||
|
<th>Invoice Date</th>
|
||||||
<th>Invoice Amount</th>
|
<th>Invoice Amount</th>
|
||||||
<th>Realization Amount</th>
|
<th>Realization <br>Amount</th>
|
||||||
<th>Outstanding Amount</th>
|
<th>Outstanding <br>Amount</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php if (isset($outstanding_list)) { ?>
|
<?php
|
||||||
<?php foreach($outstanding_list as $index => $row){ ?>
|
|
||||||
|
// dd($outstanting_list);
|
||||||
|
if (isset($outstanting_list)) { ?>
|
||||||
|
<?php foreach($outstanting_list as $index => $row){ ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?= $index + 1 ?></td>
|
<td><?= $index + 1 ?></td>
|
||||||
<td><?php echo $row['client_name']; ?></td>
|
<td><?php echo $row['short_name']; ?></td>
|
||||||
<td><?php echo $row['insurer_name']; ?></td>
|
<td><?php echo $row['branch_name']; ?></td>
|
||||||
<td><?php echo $row['policy_type'] .' - '. $row['policy_no']; ?></td>
|
<td><?php echo change_date_format($row['month'],'Y-m-d','Y-m') ?></td>
|
||||||
<td><?php echo $row['endorsement_no']; ?></td>
|
<td><?php echo $row['stmt_sno']; ?></td>
|
||||||
|
<td><?php echo $row['invoice_no']; ?></td>
|
||||||
<td class="center-align-input"><?php echo isset($row['invoice_status']) ? $row['invoice_status'] : ' - '; ?></td>
|
<td class="center-align-input"><?php echo isset($row['invoice_status']) ? $row['invoice_status'] : ' - '; ?></td>
|
||||||
|
<td><?php echo change_date_format($row['invoice_date'],'Y-m-d','d-M-Y'); ?></td>
|
||||||
<td class="right-align-input"><?php echo isset($row['invoice_amount']) ? $row['invoice_amount'] : '0.00'; ?></td>
|
<td class="right-align-input"><?php echo isset($row['invoice_amount']) ? $row['invoice_amount'] : '0.00'; ?></td>
|
||||||
<td class="right-align-input"><?php echo isset($row['realization_amount']) ? $row['realization_amount'] : '0.00'; ?></td>
|
<td class="right-align-input"><?php echo isset($row['total_paid']) ? $row['total_paid'] : '0.00'; ?></td>
|
||||||
<td class="right-align-input"><?php echo isset($row['outstanding_amount']) ? $row['outstanding_amount'] : '0.00'; ?></td>
|
<td class="right-align-input"><?php echo isset($row['outstanding_amount']) ? $row['outstanding_amount'] : '0.00'; ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
@ -364,10 +385,6 @@ $(function() {
|
|||||||
startDate: start,
|
startDate: start,
|
||||||
endDate: end,
|
endDate: end,
|
||||||
ranges: {
|
ranges: {
|
||||||
'Today': [moment(), moment()],
|
|
||||||
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
|
||||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
|
||||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
|
||||||
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
||||||
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month')
|
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month')
|
||||||
.endOf('month')
|
.endOf('month')
|
||||||
|
|||||||
@ -10,8 +10,11 @@ class ExcelMergeHelperTest extends TestCase
|
|||||||
{
|
{
|
||||||
// Use the paths you provided
|
// Use the paths you provided
|
||||||
$filePaths = [
|
$filePaths = [
|
||||||
'/home/venba/Downloads/Financial_Sample.xlsx' => [1,3,2],
|
// ['file_path' =>WRITEPATH.'uploads/lead_files/Member_Data.xlsx','sheets' => []],
|
||||||
'/home/venba/Downloads/enrollment.xlsx' => []
|
// ['file_path' =>WRITEPATH.'/tmp/RFQ_ABC_GMC_20241220140640.xlsx','sheets' => []],
|
||||||
|
|
||||||
|
['file_path' =>'/home/venba/Downloads/enrollment (1).xlsx','sheets' => []],
|
||||||
|
['file_path' =>'/home/venba/Downloads/Financial_Sample.xlsx','sheets' => []],
|
||||||
];
|
];
|
||||||
$outputPath = '/home/venba/Documents/merged_file.xlsx'; // Output path for the merged file
|
$outputPath = '/home/venba/Documents/merged_file.xlsx'; // Output path for the merged file
|
||||||
|
|
||||||
@ -23,3 +26,12 @@ class ExcelMergeHelperTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// $temp_file_path = WRITEPATH.'tmp/RFQ_ABC_GMC_20241219172307.xlsx';
|
||||||
|
// $temp_file_name = 'RFQ_ABC_GMC_20241219172307.xlsx';
|
||||||
|
// $lead_file_path = WRITEPATH.'uploads/lead_files/Member_Data.xlsx';
|
||||||
|
|
||||||
|
// $filePaths = [
|
||||||
|
// ['file_path' => $temp_file_path,'sheets' =>[]],
|
||||||
|
// ['file_path' =>$lead_file_path ,'sheets' =>[]]
|
||||||
|
// ];
|
||||||
|
// $outputPath = dirname($temp_file_path).'/'.$temp_file_name.'_merged';
|
||||||
|
|||||||
183
tests/unit/LeadsControllerTest.php
Normal file
183
tests/unit/LeadsControllerTest.php
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\unit;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use CodeIgniter\Test\CIUnitTestCase;
|
||||||
|
use App\Controllers\LeadsController;
|
||||||
|
|
||||||
|
class LeadsControllerTest extends CIUnitTestCase
|
||||||
|
{
|
||||||
|
protected $leadsController;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$this->leadsController = new LeadsController();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetDemographyDataBasicScenario()
|
||||||
|
{
|
||||||
|
echo('passed 0');
|
||||||
|
// Arrange
|
||||||
|
$members = [
|
||||||
|
// Header row
|
||||||
|
['Name', 'Age', 'Relationship', 'SI Enhancement'],
|
||||||
|
// Data rows
|
||||||
|
['John', '25', 'Self', '100000'],
|
||||||
|
['Jane', '23', 'Spouse', '100000'],
|
||||||
|
['Kid', '5', 'Child', '50000']
|
||||||
|
];
|
||||||
|
echo('passed 1');
|
||||||
|
$age_band_data = [
|
||||||
|
['0-17', '18-35', '36-45', 'Above 46']
|
||||||
|
];
|
||||||
|
echo('passed 2');
|
||||||
|
$members_heading = ['Name', 'Age', 'Relationship', 'SI Enhancement'];
|
||||||
|
$available_col = 'age';print_rr($available_col);
|
||||||
|
$col_index = 1;
|
||||||
|
echo('passed 3');
|
||||||
|
try{
|
||||||
|
echo('Inside try');
|
||||||
|
// Act
|
||||||
|
echo('passed 3.5');
|
||||||
|
$result = $this->leadsController->getDemographyData($members,$age_band_data,$members_heading,$available_col,$col_index);
|
||||||
|
|
||||||
|
echo('passed 4');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo "Message: " . $e->getMessage() . "\n";
|
||||||
|
echo "File: " . $e->getFile() . "\n";
|
||||||
|
echo "Line: " . $e->getLine() . "\n";
|
||||||
|
// Optionally, print the full stack trace
|
||||||
|
echo "Stack trace: " . $e->getTraceAsString() . "\n";
|
||||||
|
}
|
||||||
|
var_dump($result);
|
||||||
|
// Assert
|
||||||
|
$this->assertIsArray($result);
|
||||||
|
$this->assertArrayHasKey('general', $result);
|
||||||
|
$this->assertArrayHasKey('100000', $result);
|
||||||
|
$this->assertArrayHasKey('50000', $result);
|
||||||
|
|
||||||
|
// Check counts for general category
|
||||||
|
$this->assertEquals(1, $result['general']['Self']['18-35']);
|
||||||
|
$this->assertEquals(1, $result['general']['Spouse']['18-35']);
|
||||||
|
$this->assertEquals(1, $result['general']['Child']['0-17']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetDemographyDataWithDOB()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$members = [
|
||||||
|
// Header row
|
||||||
|
['Name', 'DOB', 'Relationship', 'SI Enhancement'],
|
||||||
|
// Data rows
|
||||||
|
['John', '01-Jan-1995', 'Self', '100000'],
|
||||||
|
['Jane', '01-Jan-1998', 'Spouse', '100000']
|
||||||
|
];
|
||||||
|
|
||||||
|
$age_band_data = [
|
||||||
|
['18-35', '36-45', '46+']
|
||||||
|
];
|
||||||
|
|
||||||
|
$members_heading = ['Name', 'DOB', 'Relationship', 'SI Enhancement'];
|
||||||
|
$available_col = 'dob';
|
||||||
|
$col_index = 1;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$result = $this->leadsController->getDemographyData(
|
||||||
|
$members,
|
||||||
|
$age_band_data,
|
||||||
|
$members_heading,
|
||||||
|
$available_col,
|
||||||
|
$col_index
|
||||||
|
);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$this->assertIsArray($result);
|
||||||
|
$this->assertArrayHasKey('general', $result);
|
||||||
|
$this->assertArrayHasKey('100000', $result);
|
||||||
|
|
||||||
|
// Both members should be in 18-35 age band
|
||||||
|
$this->assertEquals(1, $result['general']['Self']['18-35']);
|
||||||
|
$this->assertEquals(1, $result['general']['Spouse']['18-35']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetDemographyDataWithEmptyMembers()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$members = [
|
||||||
|
// Only header row
|
||||||
|
['Name', 'Age', 'Relationship', 'SI Enhancement']
|
||||||
|
];
|
||||||
|
|
||||||
|
$age_band_data = [
|
||||||
|
['0-17', '18-35', '36-45', '46+']
|
||||||
|
];
|
||||||
|
|
||||||
|
$members_heading = ['Name', 'Age', 'Relationship', 'SI Enhancement'];
|
||||||
|
$available_col = 'age';
|
||||||
|
$col_index = 1;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$result = $this->leadsController->getDemographyData(
|
||||||
|
$members,
|
||||||
|
$age_band_data,
|
||||||
|
$members_heading,
|
||||||
|
$available_col,
|
||||||
|
$col_index
|
||||||
|
);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$this->assertIsArray($result);
|
||||||
|
$this->assertArrayHasKey('general', $result);
|
||||||
|
|
||||||
|
// Check that all totals are zero
|
||||||
|
$this->assertEquals(0, $result['general']['Grand Total']['Grand Total']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetDemographyDataWithMultipleSIBands()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$members = [
|
||||||
|
// Header row
|
||||||
|
['Name', 'Age', 'Relationship', 'SI Enhancement'],
|
||||||
|
// Data rows with different SI amounts
|
||||||
|
['John', '25', 'Self', '100000'],
|
||||||
|
['Jane', '23', 'Spouse', '200000'],
|
||||||
|
['Kid1', '5', 'Child', '100000'],
|
||||||
|
['Kid2', '7', 'Child', '200000']
|
||||||
|
];
|
||||||
|
|
||||||
|
$age_band_data = [
|
||||||
|
['0-17', '18-35', '36-45', '46+']
|
||||||
|
];
|
||||||
|
|
||||||
|
$members_heading = ['Name', 'Age', 'Relationship', 'SI Enhancement'];
|
||||||
|
$available_col = 'age';
|
||||||
|
$col_index = 1;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$result = $this->leadsController->getDemographyData(
|
||||||
|
$members,
|
||||||
|
$age_band_data,
|
||||||
|
$members_heading,
|
||||||
|
$available_col,
|
||||||
|
$col_index
|
||||||
|
);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$this->assertIsArray($result);
|
||||||
|
$this->assertArrayHasKey('100000', $result);
|
||||||
|
$this->assertArrayHasKey('200000', $result);
|
||||||
|
|
||||||
|
// Check counts for different SI bands
|
||||||
|
$this->assertEquals(1, $result['100000']['Self']['18-35']);
|
||||||
|
$this->assertEquals(1, $result['200000']['Spouse']['18-35']);
|
||||||
|
$this->assertEquals(1, $result['100000']['Child']['0-17']);
|
||||||
|
$this->assertEquals(1, $result['200000']['Child']['0-17']);
|
||||||
|
|
||||||
|
// Check general category totals
|
||||||
|
$this->assertEquals(2, $result['general']['Child']['0-17']);
|
||||||
|
$this->assertEquals(2, $result['general']['Child']['Grand Total']);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user