CODE_MERGE : AADHAVAN
This commit is contained in:
commit
fd16bc2d01
@ -99,5 +99,5 @@ class Autoload extends AutoloadConfig
|
||||
* @var string[]
|
||||
* @phpstan-var list<string>
|
||||
*/
|
||||
public $helpers = ['uuid','session','utility', 'form', 'url', 'oauth', 'fileupload'];
|
||||
public $helpers = ['uuid','session','utility', 'form', 'url', 'oauth', 'fileupload', 'excel_import_export', 'file'];
|
||||
}
|
||||
|
||||
@ -187,6 +187,8 @@ $routes->group("/util", ["filter" => "authMVC"], function($routes){
|
||||
$routes->get("kyc-other-docs-delete/(:any)", "ClientController::deleteClientKycOtherDocs/$1");
|
||||
$routes->get("policy-premium", "ClientController::getpolicyGridData/$1");
|
||||
$routes->get("update-policy-status", "ClientController::updateClientPolicyStatus/$1");
|
||||
$routes->get("download-excel/(:any)", "EmployeeController::downloadSampleExcelFile/$1");
|
||||
$routes->post("import-export", "EmployeeController::importExport");
|
||||
});
|
||||
|
||||
$routes->cli('processjob', 'JobWorker::processJob');
|
||||
|
||||
@ -90,20 +90,11 @@ class ClientController extends AdminController
|
||||
public function index()
|
||||
{
|
||||
|
||||
// $token = $_SESSION;
|
||||
// $token = $request->getHeaderLine('Authorization');
|
||||
|
||||
|
||||
// print_r(JWTToken::getIdFromToken($token));
|
||||
|
||||
// die();
|
||||
|
||||
$this->myLogger->logme('error','Client list function called');
|
||||
$headerData['page_name'] = 'Client List';
|
||||
$data['clientList'] = $this->clientModel->getCreatedByUserName();
|
||||
$data['client_rm'] = $this->clientRMModel->getAllClientRM();
|
||||
// echo '<pre>';
|
||||
// print_r($data); die;
|
||||
|
||||
echo view('layout/header', $headerData);
|
||||
echo view('client_list', $data);
|
||||
echo view('layout/footer');
|
||||
@ -138,18 +129,18 @@ class ClientController extends AdminController
|
||||
// In your controller
|
||||
public function deposit($id = null)
|
||||
{
|
||||
$headerData['page_name'] = 'Client Deposit';
|
||||
$headerData['page_name'] = 'Client Deposit';
|
||||
|
||||
$data['clientData'] = $this->clientPolicyModel->getinsurerswithclientid($id);
|
||||
$data['depositsummary'] = $this->clientPolicyModel->getDepositlistsummary($id);
|
||||
$data['clientData'] = $this->clientPolicyModel->getinsurerswithclientid($id);
|
||||
$data['depositsummary'] = $this->clientPolicyModel->getDepositlistsummary($id);
|
||||
|
||||
// Fetch associated insurer names and balances
|
||||
$balances = $this->clientPolicyModel->getBalances($id);
|
||||
$data['balances'] = $balances;
|
||||
// Fetch associated insurer names and balances
|
||||
$balances = $this->clientPolicyModel->getBalances($id);
|
||||
$data['balances'] = $balances;
|
||||
|
||||
echo view('layout/header', $headerData);
|
||||
echo view('client_deposit_list', $data);
|
||||
echo view('layout/footer');
|
||||
echo view('layout/header', $headerData);
|
||||
echo view('client_deposit_list', $data);
|
||||
echo view('layout/footer');
|
||||
}
|
||||
|
||||
public function view_Deposit($insurerId)
|
||||
|
||||
166
app/Controllers/EmpDataServiceController.php
Normal file
166
app/Controllers/EmpDataServiceController.php
Normal file
@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
|
||||
use App\Models\EmployeeModel;
|
||||
use App\Models\EmployeePolicyModel;
|
||||
use App\Models\ClientModel;
|
||||
use App\Models\ClientPolicyModel;
|
||||
use App\Models\FileModel;
|
||||
use App\Models\BatchListModel;
|
||||
use App\Models\BatchFileModel;
|
||||
use App\Models\EmpEndorsementModel;
|
||||
|
||||
use App\Controllers\Jobs ;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
|
||||
class EmpDataServiceController extends BaseController
|
||||
{
|
||||
protected $myLogger;
|
||||
protected $employeeModel;
|
||||
protected $employeePolicyModel;
|
||||
protected $clientModel;
|
||||
protected $fileModel;
|
||||
protected $clientPolicyModel;
|
||||
protected $batchListModel;
|
||||
protected $batchFileModel;
|
||||
protected $empEndorsementModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// helper('utility');
|
||||
set_session_context('EmployeeDataService Second Service');
|
||||
$this->myLogger = \Config\Services::mylogger();
|
||||
$this->employeeModel = new EmployeeModel();
|
||||
$this->employeePolicyModel = new EmployeePolicyModel();
|
||||
$this->clientModel = new ClientModel();
|
||||
$this->fileModel = new FileModel();
|
||||
$this->clientPolicyModel = new ClientPolicyModel();
|
||||
$this->batchListModel = new BatchListModel();
|
||||
$this->batchFileModel = new BatchFileModel();
|
||||
$this->empEndorsementModel = new EmpEndorsementModel();
|
||||
}
|
||||
|
||||
|
||||
public function batchFilesAndBatchListEntry($data, $filename, $objects){
|
||||
$random_number_count = 4;
|
||||
$data['batch_code'] = generate_random_string($random_number_count);
|
||||
$data['created_by'] = get_session_userid();
|
||||
$data['file_name'] = $filename;
|
||||
$insert = $this->batchFileModel->insert($data);
|
||||
$batch_file_batch_code = $this->batchFileModel->where('id', $insert)->first();
|
||||
|
||||
if($insert){
|
||||
foreach($objects as $value){
|
||||
$batch_list_data['batch_code'] = $batch_file_batch_code['batch_code'];
|
||||
$batch_list_data['emp_policy_id'] = $value->employee_policy_id ?? $value->emp_id;
|
||||
$batch_list_data['created_by'] = get_session_userid();
|
||||
$this->batchListModel->insert($batch_list_data);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function generateExcelForAdditionandInception($batch_files_data, $export_data, $file_name)
|
||||
{
|
||||
|
||||
$data = transform_objects_to_array_for_inception($export_data);
|
||||
$headers = [
|
||||
'S.No', 'NAME OF EMP/DEP', 'EMP ID', 'EMP/DEP TYPE', 'RELATION', 'DOB', 'GENDER', 'PRE EXISTING AILMENTS',
|
||||
'BASIC COVER SI', 'DATE OF COVERAGE', 'AGE', 'RELATIONSHIP', 'REMARKS', 'POLICY END DATE', 'NO OF DAYS', 'TPA ID', 'UHID',
|
||||
'PREMIUM', 'PR0 RATA PREMIUM', 'GST', 'TOTAL'
|
||||
];
|
||||
|
||||
// Create a temporary file in memory
|
||||
$tempFile = tmpfile();
|
||||
|
||||
// Generate Excel file with the temporary file
|
||||
$value = generate_excel($headers, $data, $tempFile, 1);
|
||||
|
||||
// Generate a random filename
|
||||
$randomFilename = $file_name;
|
||||
|
||||
if($value){
|
||||
$return = $this->batchFilesAndBatchListEntry($batch_files_data, $randomFilename, $export_data);
|
||||
if($return){
|
||||
|
||||
// Set the appropriate headers for Excel file download
|
||||
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||
header('Content-Disposition: attachment;filename="' . $randomFilename . '"');
|
||||
header('Cache-Control: max-age=0');
|
||||
|
||||
// Rewind the temporary file pointer
|
||||
rewind($tempFile);
|
||||
|
||||
// Output the contents of the temporary file to the browser
|
||||
fpassthru($tempFile);
|
||||
|
||||
// Close and remove the temporary file
|
||||
fclose($tempFile);
|
||||
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function generateExcelForCorrection($file_name, $objects, $batch_files_data)
|
||||
{
|
||||
|
||||
$correction_data = transform_objects_to_array_for_correction($objects);
|
||||
|
||||
$headers = [
|
||||
'Emp Code', 'RISK ID', 'NAME OF EMP/DEP', 'EMP/DEP TYPE', 'RELATION', 'DOB', 'GENDER', 'Wrong Data', 'Correct Data', 'Remarks', 'Endorsement_Id'
|
||||
];
|
||||
|
||||
|
||||
// Create a temporary file in memory
|
||||
$tempFile = tmpfile();
|
||||
|
||||
// Generate Excel file with the temporary file
|
||||
$value = generate_excel($headers, $correction_data, $tempFile);
|
||||
|
||||
// Generate a random filename
|
||||
$randomFilename = $file_name;
|
||||
|
||||
if($value){
|
||||
$return = $this->batchFilesAndBatchListEntry($batch_files_data, $randomFilename, $objects);
|
||||
if($return){
|
||||
|
||||
// Set the appropriate headers for Excel file download
|
||||
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||
header('Content-Disposition: attachment;filename="' . $randomFilename . '"');
|
||||
header('Cache-Control: max-age=0');
|
||||
|
||||
// Rewind the temporary file pointer
|
||||
rewind($tempFile);
|
||||
|
||||
// Output the contents of the temporary file to the browser
|
||||
fpassthru($tempFile);
|
||||
|
||||
// Close and remove the temporary file
|
||||
fclose($tempFile);
|
||||
|
||||
return true;
|
||||
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -12,11 +12,16 @@ use App\Models\EmployeeModel;
|
||||
use App\Models\EmployeePolicyModel;
|
||||
use App\Models\ClientModel;
|
||||
use App\Models\FileModel;
|
||||
use App\Models\BatchListModel;
|
||||
use App\Models\BatchFileModel;
|
||||
use App\Models\EmpEndorsementModel;
|
||||
use App\Models\ClientPolicyModel;
|
||||
|
||||
use App\Controllers\Jobs ;
|
||||
use App\Controllers\JobWorker ;
|
||||
use App\Controllers\Jobs\SubJob;
|
||||
use App\Controllers\EmployeeServiceController;
|
||||
use App\Controllers\EmpDataServiceController;
|
||||
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
|
||||
@ -32,6 +37,11 @@ class EmployeeController extends AdminController
|
||||
protected $employeePolicyModel;
|
||||
protected $clientModel;
|
||||
protected $fileModel;
|
||||
protected $batchListModel;
|
||||
protected $batchFileModel;
|
||||
protected $empEndorsementModel;
|
||||
protected $clientPolicyModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// helper('utility');
|
||||
@ -41,6 +51,10 @@ class EmployeeController extends AdminController
|
||||
$this->employeePolicyModel = new EmployeePolicyModel();
|
||||
$this->clientModel = new ClientModel();
|
||||
$this->fileModel = new FileModel();
|
||||
$this->batchListModel = new BatchListModel();
|
||||
$this->batchFileModel = new BatchFileModel();
|
||||
$this->empEndorsementModel = new EmpEndorsementModel();
|
||||
$this->clientPolicyModel = new ClientPolicyModel();
|
||||
}
|
||||
|
||||
public function list()
|
||||
@ -177,6 +191,9 @@ class EmployeeController extends AdminController
|
||||
}
|
||||
|
||||
$data['actions'] = ['inception' => 'Inception + Addition + Deletion','correction' =>'Correction','si_enhancement' =>'SI Enhancement'];
|
||||
$data['events'] = ['inception' => 'Inception + Addition','correction' =>'Correction', 'deletion'=>'Deletion' ,'si_enhancement' =>'SI Enhancement'];
|
||||
$data['import_or_export'] = ['import' => 'Import','export' =>'Export'];
|
||||
$data['insurer_or_tpa'] = ['insurer' => 'Insurer','tpa' =>'TPA'];
|
||||
$data['fileList'] = $this->fileModel
|
||||
->select(['files.*','up.emp_code','up.first_name','pm.name as policy_name','c.short_name'])
|
||||
->join('user_profiles up','files.created_by = up.id')
|
||||
@ -186,77 +203,251 @@ class EmployeeController extends AdminController
|
||||
// dd($data['fileList']);die();
|
||||
if($this->request->getMethod() == "get")
|
||||
{
|
||||
$this->loadLayout('employee_upload',$data);
|
||||
$this->loadLayout('import_export',$data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getExcelFileErrors()
|
||||
{
|
||||
$file_id = $this->request->uri->getSegment(3);
|
||||
$empServiceController = new EmployeeServiceController();
|
||||
|
||||
$file_id = $this->request->uri->getSegment(3);
|
||||
$file = $this->fileModel->find($file_id);
|
||||
$error_data = json_decode($file['reason']);
|
||||
$file_name_with_path = WRITEPATH."/uploads/excel/".$file['file_name'];
|
||||
// Render views and capture output
|
||||
$result = $empServiceController->getExcelErrorData($file_id);
|
||||
|
||||
//check the file exist or not
|
||||
if(!file_exists($file_name_with_path))
|
||||
{
|
||||
$error_message = "File not found";
|
||||
$this->myLogger->logme('error',($error_message . ' for file id ' . $file_id));
|
||||
}
|
||||
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
// echo '<pre>';
|
||||
// print_r($result); die;
|
||||
echo view('excel_errors', $result);
|
||||
|
||||
$highestRowAndColumn = $sheet->getHighestRowAndColumn();
|
||||
$excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
|
||||
$data['excel_header'] = $excel_data[0];
|
||||
unset($excel_data[0]);
|
||||
$data['excel_data'] = $excel_data;
|
||||
|
||||
}
|
||||
|
||||
echo '<pre>';
|
||||
/**This downloadSampleExcelFile() function facilitates downloading various sample Excel files
|
||||
** based on user-selected actions, handling file retrieval and download processes. **/
|
||||
public function downloadSampleExcelFile($actionType = null)
|
||||
{
|
||||
// $actionType = $this->request->getGet();
|
||||
$filePath = '';
|
||||
// Path to your file
|
||||
if($actionType == 'inception'){
|
||||
$filePath = ROOTPATH . 'public/sample_excel/inception.xls';
|
||||
|
||||
// foreach ($error_data->error_data as $key => $value) {
|
||||
// print_r($excel_data[$key]);
|
||||
// foreach($value as $key2 => $value2){
|
||||
// // echo '<pre>';
|
||||
// // print_r($excel_data[$key][$value2->col_idx]);
|
||||
// }
|
||||
|
||||
// }
|
||||
$finalArray = [];
|
||||
foreach ($error_data->error_data as $key => $value) {
|
||||
foreach($value as $key2 => $value2){
|
||||
$error_data = $value2->error;
|
||||
}else if($actionType == 'correction'){
|
||||
$filePath = ROOTPATH . 'public/sample_excel/inception_1.xls';
|
||||
|
||||
echo '<pre>';
|
||||
// print_r([$value2->col_idx]);
|
||||
$excel_data[$key][$value2->col_idx] = $error_data;
|
||||
// print_r($excel_data[$key]);
|
||||
|
||||
}
|
||||
// print_r($excel_data[$key]);
|
||||
// array_push($finalArray, $excel_data);
|
||||
}
|
||||
}else if($actionType == 'si_enhancement'){
|
||||
$filePath = ROOTPATH . 'public/sample_excel/inception_2.xls';
|
||||
}
|
||||
|
||||
// Check if the file exists
|
||||
if (file_exists($filePath)) {
|
||||
|
||||
// Set the appropriate MIME type
|
||||
$mimeType = mime_content_type($filePath);
|
||||
|
||||
print_r($excel_data);
|
||||
|
||||
die;
|
||||
|
||||
|
||||
// echo '###################################################################### <br>';
|
||||
// print_r($excel_data);
|
||||
// echo '###################################################################### <br>';
|
||||
// print_r($error_data->error_data); die;
|
||||
|
||||
$headerData['page_name'] = 'Excel Error';
|
||||
echo view('layout/header', $headerData);
|
||||
echo view('excel_errors', $data);
|
||||
echo view('layout/footer');
|
||||
// Send the file to the client for download
|
||||
return $this->response->download($filePath, null, $mimeType);
|
||||
} else {
|
||||
// File not found, show an error message or redirect
|
||||
return redirect()->back()->with('error', 'File not found.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function importExport()
|
||||
{
|
||||
|
||||
$this->myLogger->logme('error','importExport function called');
|
||||
$empDataServiceController = new EmpDataServiceController();
|
||||
$client_id = $this->request->getPost('client_id');
|
||||
$client_policy_id = $this->request->getPost('client_policy_id');
|
||||
$insurer_or_tpa = $this->request->getPost('insurer_or_tpa');
|
||||
$event_type = $this->request->getPost('event_type');
|
||||
$actions = $this->request->getPost('action_type');
|
||||
|
||||
$batch_data = [
|
||||
'client_id' => $client_id,
|
||||
'client_policy_id' => $client_policy_id,
|
||||
'insurer_or_tpa' => $insurer_or_tpa,
|
||||
'event_type' => $event_type,
|
||||
'actions' => $actions,
|
||||
];
|
||||
|
||||
$client_data = $this->clientModel->where('id', $client_id)->first();
|
||||
$policy_name = $this->clientPolicyModel->select('policies.name')
|
||||
->join('policies', 'policies.id = client_policy.policy_id')
|
||||
->where('client_policy.id', $client_policy_id)->first();
|
||||
$file_name = generate_filename($client_data['short_name'], $event_type, $actions, $insurer_or_tpa, $policy_name['name']);
|
||||
|
||||
if($actions == 'export'){
|
||||
|
||||
if($event_type == 'inception'){
|
||||
|
||||
$objects = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($client_policy_id, $insurer_or_tpa, $event_type, $actions);
|
||||
$count = count($objects);
|
||||
$this->myLogger->logme('error','Inception export data count : {data}', ['data'=> $count ]);
|
||||
$batch_data['count'] = $count;
|
||||
|
||||
}
|
||||
if($count == 0){
|
||||
|
||||
session()->setFlashdata('error', 'No data found');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
}
|
||||
|
||||
$this->myLogger->logme('error','Inception export file name : {data}', ['data'=> $file_name ]);
|
||||
$empDataServiceController->generateExcelForAdditionandInception($batch_data, $objects, $file_name);
|
||||
|
||||
} else if($event_type == 'correction'){
|
||||
|
||||
$objects = $this->employeePolicyModel->getCorrectionEmployeesDataForExportExcel($client_id, $client_policy_id, $insurer_or_tpa);
|
||||
$count = count($objects);
|
||||
$this->myLogger->logme('error','Correction export data count : {data}', ['data'=> $count ]);
|
||||
$batch_data['count'] = $count;
|
||||
if($count == 0){
|
||||
session()->setFlashdata('error', 'No data found');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
}
|
||||
$this->myLogger->logme('error','Correction export file name : {data}', ['data'=> $file_name ]);
|
||||
$empDataServiceController->generateExcelForCorrection($file_name, $objects, $batch_data);
|
||||
}
|
||||
|
||||
}else if($actions == 'import'){
|
||||
|
||||
if($event_type == 'inception'){
|
||||
|
||||
$file = $this->request->getFile('import_file_data');
|
||||
$is_moved = $file->move(WRITEPATH . 'uploads/import_excel');
|
||||
$filename = $file->getName();
|
||||
|
||||
$this->myLogger->logme('error','Inception Import file name : {data}', ['data'=> $filename ]);
|
||||
$random_number_count = 4;
|
||||
$batch_code = generate_random_string($random_number_count);
|
||||
|
||||
$this->myLogger->logme('error','Inception Import BATCH CODE : {data}', ['data'=> $batch_code ]);
|
||||
|
||||
$batch_data['batch_code'] = $batch_code;
|
||||
$batch_data['created_by'] = get_session_userid();
|
||||
$batch_data['file_name'] = $filename;
|
||||
$insert = $this->batchFileModel->insert($batch_data);
|
||||
$batch_file_batch_code = $this->batchFileModel->where('id', $insert)->first();
|
||||
|
||||
$file_name_with_path = WRITEPATH."/uploads/import_excel/".$batch_file_batch_code['file_name'];
|
||||
|
||||
//check the file exist or not
|
||||
if(!file_exists($file_name_with_path))
|
||||
{
|
||||
session()->setFlashdata('error', 'File not found');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
}
|
||||
|
||||
$data = read_excel_file_to_array($file_name_with_path);
|
||||
unset($data[0]);
|
||||
array_pop($data);
|
||||
// dd($data );
|
||||
foreach ($data as $key => $value) {
|
||||
// Check if the array is not empty and has the necessary data
|
||||
if (!empty($value) && (isset($value[15]) || isset($value[16]))) {
|
||||
|
||||
// Extract the client_policy_id and tpa_id from the array
|
||||
$tpa_id = $value[15] != null ? $value[15] : '';
|
||||
$uhid = $value[16] != null ? $value[16] : '';
|
||||
$emp_code = $value[2];
|
||||
$name = $value[1];
|
||||
|
||||
// echo $tpa_id, $uhid, $emp_code, $name; die;
|
||||
$this->employeePolicyModel->updateTPAIDorUHID( $client_policy_id, $client_id, $name, $emp_code, $uhid, $tpa_id);
|
||||
$query = $this->employeePolicyModel->getLastQuery();
|
||||
echo $query . "<br>";
|
||||
|
||||
}else{
|
||||
|
||||
session()->setFlashdata('error', 'Something went wrong');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
session()->setFlashdata('success', 'Data updated successfully');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
|
||||
}else if($event_type == 'correction'){
|
||||
|
||||
$file = $this->request->getFile('import_file_data');
|
||||
$is_moved = $file->move(WRITEPATH . 'uploads/import_excel');
|
||||
$filename = $file->getName();
|
||||
|
||||
$this->myLogger->logme('error','Correction Import file name : {data}', ['data'=> $filename ]);
|
||||
$random_number_count = 4;
|
||||
$batch_code = generate_random_string($random_number_count);
|
||||
$this->myLogger->logme('error','Correction Import BATCH CODE : {data}', ['data'=> $batch_code ]);
|
||||
|
||||
|
||||
$batch_data['batch_code'] = $batch_code;
|
||||
$batch_data['created_by'] = get_session_userid();
|
||||
$batch_data['file_name'] = $filename;
|
||||
$insert = $this->batchFileModel->insert($batch_data);
|
||||
$batch_file_batch_code = $this->batchFileModel->where('id', $insert)->first();
|
||||
|
||||
$file_name_with_path = WRITEPATH."/uploads/import_excel/".$batch_file_batch_code['file_name'];
|
||||
|
||||
if(!file_exists($file_name_with_path))
|
||||
{
|
||||
session()->setFlashdata('error', 'File not found');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
}
|
||||
|
||||
$data = read_excel_file_to_array($file_name_with_path);
|
||||
unset($data[0]);
|
||||
// dd($data);
|
||||
foreach ($data as $key => $value) {
|
||||
|
||||
if (!empty($value) && isset($value[10])) {
|
||||
|
||||
$emp_code = $value[0];
|
||||
$uhid = $value[1];
|
||||
$endorsement_id = $value[10] != null ? $value[10] : '';
|
||||
// $this->employeePolicyModel->updateCorrectionData($emp_code, $uhid, $endorsement_id);
|
||||
|
||||
$queryData = $this->empEndorsementModel->select('emp_endorsement.*')
|
||||
->join('employees', 'employees.id = emp_endorsement.emp_id')
|
||||
->join('employee_polices', 'employee_polices.employee_id = employees.id')
|
||||
->where('employees.emp_code', $emp_code)
|
||||
->where('employees.client_id', $client_id)
|
||||
->where('employee_polices.client_policy_id', $client_policy_id)
|
||||
->where('employee_polices.uhid', $uhid)
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
// dd($queryData);
|
||||
|
||||
foreach ($queryData as $endorsementData) {
|
||||
|
||||
$emp_endoresment_id = $endorsementData['id'];
|
||||
$emp_id = $endorsementData['emp_id'];
|
||||
$field_name = $endorsementData['field_name'];
|
||||
$new_value = $endorsementData['new_value'];
|
||||
$this->empEndorsementModel->where('id', $emp_endoresment_id)->set('endorsement_id', $endorsement_id)->update();
|
||||
$this->employeeModel->where('id', $emp_id)->set($field_name, $new_value)->update();
|
||||
}
|
||||
|
||||
$query = $this->employeePolicyModel->getLastQuery();
|
||||
echo $query . "<br>";
|
||||
}else{
|
||||
session()->setFlashdata('error', 'Something went wrong');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
session()->setFlashdata('success', 'Data updated successfully');
|
||||
return redirect()->to(base_url('employee/upload'));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -378,6 +378,103 @@ class EmployeeServiceController extends AdminController
|
||||
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
public function getExcelErrorData($file_id){
|
||||
|
||||
$file = $this->fileModel->find($file_id);
|
||||
$error_data = json_decode($file['reason']);
|
||||
|
||||
// return $error_data;
|
||||
|
||||
$file_name_with_path = WRITEPATH."/uploads/excel/".$file['file_name'];
|
||||
|
||||
//check the file exist or not
|
||||
if(!file_exists($file_name_with_path))
|
||||
{
|
||||
$error_message = "File not found";
|
||||
$this->myLogger->logme('error',($error_message . ' for file id ' . $file_id));
|
||||
}
|
||||
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$highestRowAndColumn = $sheet->getHighestRowAndColumn();
|
||||
$excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
|
||||
$excelErrorData['excel_header'] = $excel_data[0];
|
||||
unset($excel_data[0]);
|
||||
// echo '<pre>';
|
||||
|
||||
if($error_data->error_type == 1){
|
||||
|
||||
$finalArray = [];
|
||||
foreach ($error_data->error_data as $key => $value) {
|
||||
|
||||
foreach ($value as $key2 => $value2) {
|
||||
$error_data = $value2->error;
|
||||
$data = ['value' => $excel_data[$key][$value2->col_idx], 'error'=>$error_data,];
|
||||
$excel_data[$key][$value2->col_idx] = $data;
|
||||
|
||||
}
|
||||
array_push($finalArray, $excel_data[$key]);
|
||||
}
|
||||
|
||||
foreach ($finalArray as $fkey => $value){
|
||||
foreach ($value as $vkey => $arrayData){
|
||||
if(!is_array($arrayData)){
|
||||
$data = ['value' => $arrayData];
|
||||
$finalArray[$fkey][$vkey] = $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$excelErrorData['excel_data'] = $finalArray;
|
||||
return $excelErrorData;
|
||||
|
||||
}else if($error_data->error_type == 2){
|
||||
|
||||
|
||||
$allErrors = [];
|
||||
$typeTowArray = [];
|
||||
|
||||
foreach ($error_data->error_data as $index => $item) {
|
||||
|
||||
foreach ($item as $field) {
|
||||
if (!isset($allErrors[$index])) {
|
||||
$allErrors[$index] = [];
|
||||
}
|
||||
$allErrors[$index] = array_merge($allErrors[$index], $field->error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach ($allErrors as $key => $value){
|
||||
$data = ['value' => $excel_data[$key][1], 'error'=>$value,];
|
||||
$excel_data[$key][1] = $data;
|
||||
array_push($typeTowArray, $excel_data[$key]);
|
||||
}
|
||||
|
||||
foreach ($typeTowArray as $fkey => $value){
|
||||
foreach ($value as $vkey => $arrayData){
|
||||
if(!is_array($arrayData)){
|
||||
$data = ['value' => $arrayData];
|
||||
$typeTowArray[$fkey][$vkey] = $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$excelErrorData['excel_data'] = $typeTowArray;
|
||||
return $excelErrorData;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -48,6 +48,7 @@ class LoginController extends BaseController
|
||||
log_message('error', 'Is User Login Sucessfully');
|
||||
|
||||
// $this->getUserDeviceInfo($user->id);
|
||||
$this->getUserDeviceInfo($user->id, 'NhanceUser');
|
||||
return redirect()->to(base_url('/dashboard/view'));
|
||||
|
||||
}else{
|
||||
|
||||
260
app/Helpers/excel_import_export_helper.php
Normal file
260
app/Helpers/excel_import_export_helper.php
Normal file
@ -0,0 +1,260 @@
|
||||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
|
||||
|
||||
if (!function_exists('generate_random_string')) {
|
||||
/**
|
||||
* Generate a random string of specified length and type.
|
||||
*
|
||||
* @param int $length The length of the random string.
|
||||
* @param string $type (optional) The type of characters to include in the random string.
|
||||
* Possible values: 'numeric', 'alphabetic', 'alphanumeric'.
|
||||
* Default is 'numeric'.
|
||||
*
|
||||
* @return string The generated random string.
|
||||
*/
|
||||
function generate_random_string($length, $type = 'numeric') {
|
||||
$characters = '';
|
||||
|
||||
// Define character sets based on the type
|
||||
switch ($type) {
|
||||
case 'numeric':
|
||||
$characters = '0123456789';
|
||||
break;
|
||||
case 'alphabetic':
|
||||
$characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
break;
|
||||
case 'alphanumeric':
|
||||
default:
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
break;
|
||||
}
|
||||
|
||||
$charactersLength = strlen($characters);
|
||||
$randomString = '';
|
||||
|
||||
// Generate random string
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
|
||||
return $randomString;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('generate_excel')) {
|
||||
function generate_excel($headers, $data, $filename, $totals = null)
|
||||
{
|
||||
// Create new Spreadsheet object
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set worksheet title
|
||||
$spreadsheet->getActiveSheet()->setTitle('Sheet 1');
|
||||
|
||||
// Set headers into the spreadsheet
|
||||
$spreadsheet->getActiveSheet()->fromArray([$headers], null, 'A1');
|
||||
|
||||
// Set data into the spreadsheet
|
||||
$spreadsheet->getActiveSheet()->fromArray($data, null, 'A2');
|
||||
|
||||
if($totals){
|
||||
// Call the helper function for Calculate GST, Pro Rata Premium, and Total sums for inception
|
||||
add_totals_row($spreadsheet, $data);
|
||||
}
|
||||
|
||||
// Create Excel writer
|
||||
$writer = new Xlsx($spreadsheet);
|
||||
|
||||
try {
|
||||
// Save Excel file to the specified path
|
||||
$writer->save($filename);
|
||||
return true; // Return true if file was successfully saved
|
||||
} catch (\Exception $e) {
|
||||
// Log or handle the exception
|
||||
return false; // Return false if there was an error saving the file
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (! function_exists('transform_objects_to_array_for_inception')) {
|
||||
function transform_objects_to_array_for_inception($objects) {
|
||||
|
||||
// Define an array to store the transformed data
|
||||
$data = [];
|
||||
$TPAID = "";
|
||||
$UHID = "";
|
||||
|
||||
// Initialize serial number
|
||||
$serialNumber = 1;
|
||||
|
||||
// Iterate through each object
|
||||
foreach ($objects as $obj) {
|
||||
// Extract all values for the object
|
||||
$rowData = [
|
||||
$serialNumber++, // Serial Number
|
||||
$obj->emp_name, // Employee Name
|
||||
$obj->emp_code, // Employee Code
|
||||
$obj->emp_type, // Employee Type
|
||||
$obj->emp_relationship_code, // Relationship Code
|
||||
$obj->emp_dob, // Date of Birth
|
||||
$obj->emp_gender, // Employee Gender
|
||||
$obj->pre_existing_alignments, // Pre-existing Alignments
|
||||
$obj->basic_cover_si, // Basic Cover SI
|
||||
$obj->date_coverage, // Date Coverage
|
||||
$obj->emp_age, // Employee Age
|
||||
$obj->emp_relationship, // Employee Relationship
|
||||
$obj->change_event, // Change Event
|
||||
$obj->policy_end_date, // Policy End Date
|
||||
$obj->days, // Days
|
||||
$TPAID, //EMPTY FIELD FOR TPA ID
|
||||
$UHID, //EMPTY FIELD FOR UHID
|
||||
$obj->premium, // Premium
|
||||
$obj->rata_premimum, // Rata Premium
|
||||
$obj->gst, // GST
|
||||
$obj->total // Total
|
||||
];
|
||||
|
||||
// Append the row data to the main data array
|
||||
$data[] = $rowData;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (! function_exists('transform_objects_to_array_for_correction')) {
|
||||
function transform_objects_to_array_for_correction($objects) {
|
||||
|
||||
// Define an array to store the transformed data
|
||||
$data = [];
|
||||
$endorsement_id = "";
|
||||
|
||||
// Iterate through each object
|
||||
foreach ($objects as $obj) {
|
||||
// Extract all values for the object
|
||||
$rowData = [
|
||||
$obj->emp_code,
|
||||
$obj->uhid,
|
||||
$obj->emp_name,
|
||||
$obj->emp_type,
|
||||
$obj->relationship_code,
|
||||
$obj->emp_dob,
|
||||
$obj->emp_gender,
|
||||
$obj->old_value,
|
||||
$obj->new_value,
|
||||
$obj->remarks,
|
||||
$endorsement_id,
|
||||
];
|
||||
|
||||
// Append the row data to the main data array
|
||||
$data[] = $rowData;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('add_totals_row')) {
|
||||
function add_totals_row(Spreadsheet $spreadsheet, array $data)
|
||||
{
|
||||
// Calculate GST, Pro Rata Premium, and Total sums
|
||||
$gstSum = 0;
|
||||
$proRataPremiumSum = 0;
|
||||
$totalSum = 0;
|
||||
|
||||
foreach ($data as $row) {
|
||||
$gstSum += $row[18];
|
||||
$proRataPremiumSum += $row[19];
|
||||
$totalSum += $row[20];
|
||||
}
|
||||
|
||||
// Add a new row with sums
|
||||
$lastRow = count($data) + 1; // To get the last row number
|
||||
$spreadsheet->getActiveSheet()->setCellValue('R' . ($lastRow + 1), 'TOTALS');
|
||||
$spreadsheet->getActiveSheet()->setCellValue('S' . ($lastRow + 1), $gstSum);
|
||||
$spreadsheet->getActiveSheet()->setCellValue('T' . ($lastRow + 1), $proRataPremiumSum);
|
||||
$spreadsheet->getActiveSheet()->setCellValue('U' . ($lastRow + 1), $totalSum);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('read_excel_file_to_array')) {
|
||||
function read_excel_file_to_array($file)
|
||||
{
|
||||
// Load the Excel file
|
||||
$spreadsheet = IOFactory::load($file);
|
||||
|
||||
// Get the active sheet
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Get the highest row and column numbers
|
||||
$highestRow = $sheet->getHighestRow();
|
||||
$highestColumn = $sheet->getHighestColumn();
|
||||
|
||||
$data = [];
|
||||
|
||||
// Iterate through each row
|
||||
for ($row = 1; $row <= $highestRow; $row++) {
|
||||
// Initialize the row data array
|
||||
$rowData = [];
|
||||
|
||||
// Iterate through each column in the row
|
||||
for ($col = 'A'; $col <= $highestColumn; $col++) {
|
||||
// Get the cell value
|
||||
$value = $sheet->getCell($col . $row)->getValue();
|
||||
|
||||
// Add the cell value to the row data array
|
||||
$rowData[] = $value;
|
||||
}
|
||||
|
||||
// Add the row data to the main data array
|
||||
$data[] = $rowData;
|
||||
}
|
||||
|
||||
// Return the array containing data from the Excel file
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// app/Helpers/filename_helper.php
|
||||
|
||||
if (! function_exists('generate_filename')) {
|
||||
function generate_filename($client_short_name, $event_type, $actions, $insurer_or_tpa, $policy_name) {
|
||||
|
||||
$evenTypeLabel = '';
|
||||
if($event_type == 'inception'){
|
||||
$evenTypeLabel = 'I';
|
||||
}else if($event_type == 'deletion'){
|
||||
$evenTypeLabel = 'D';
|
||||
}else if($event_type == 'correction'){
|
||||
$evenTypeLabel = 'C';
|
||||
}else if($event_type == 'si_enhancement'){
|
||||
$evenTypeLabel = 'SI';
|
||||
}
|
||||
|
||||
$insurer_or_tpa_lable = "";
|
||||
if($insurer_or_tpa == 'insurer'){
|
||||
$insurer_or_tpa_lable = 'I';
|
||||
}else if($insurer_or_tpa == 'tpa'){
|
||||
$insurer_or_tpa_lable = 'T';
|
||||
}
|
||||
|
||||
$actions = 'E';
|
||||
$currentDateTime = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
|
||||
$formattedDateTime = $currentDateTime->format('d-m-Y_H-i-s');
|
||||
$policy_name = str_replace(' ', '_', $policy_name);
|
||||
|
||||
// Generate file name
|
||||
$file_name = $client_short_name. '_' . $policy_name . '_' . $insurer_or_tpa_lable . $actions . $evenTypeLabel . '_' . $formattedDateTime . '.xlsx';
|
||||
return $file_name;
|
||||
}
|
||||
}
|
||||
25
app/Models/BatchFileModel.php
Normal file
25
app/Models/BatchFileModel.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class BatchFileModel extends Model
|
||||
{
|
||||
protected $table = 'batch_files';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
'id',
|
||||
'client_id',
|
||||
'client_policy_id',
|
||||
'batch_code',
|
||||
'file_name',
|
||||
'insurer_or_tpa',
|
||||
'event_type',
|
||||
'actions',
|
||||
'count',
|
||||
"created_by",
|
||||
"updated_by",
|
||||
"is_active",
|
||||
];
|
||||
}
|
||||
20
app/Models/BatchListModel.php
Normal file
20
app/Models/BatchListModel.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class BatchListModel extends Model
|
||||
{
|
||||
protected $table = 'batch_list';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
'id',
|
||||
'emp_policy_id',
|
||||
'batch_code',
|
||||
"created_by",
|
||||
"updated_by",
|
||||
"is_active",
|
||||
];
|
||||
|
||||
}
|
||||
28
app/Models/EmpEndorsementModel.php
Normal file
28
app/Models/EmpEndorsementModel.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class EmpEndorsementModel extends Model
|
||||
{
|
||||
protected $table = 'emp_endorsement';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
'id',
|
||||
'emp_id',
|
||||
'endorsement_id',
|
||||
'emp_code',
|
||||
'table_name',
|
||||
'actions',
|
||||
'name',
|
||||
'field_name',
|
||||
'old_value',
|
||||
'new_value',
|
||||
'status',
|
||||
"created_by",
|
||||
"updated_by",
|
||||
"is_active",
|
||||
];
|
||||
|
||||
}
|
||||
@ -32,6 +32,7 @@ class EmployeeModel extends Model
|
||||
|
||||
|
||||
|
||||
|
||||
public function getEmployeePolicy($id)
|
||||
{
|
||||
|
||||
@ -43,4 +44,5 @@ class EmployeeModel extends Model
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ class EmployeePolicyModel extends Model
|
||||
"client_policy_id",
|
||||
"tpa_id",
|
||||
"uhid",
|
||||
"batch_id",
|
||||
"status",
|
||||
"pre_existing_alignments",
|
||||
"basic_cover_si",
|
||||
@ -45,4 +46,139 @@ class EmployeePolicyModel extends Model
|
||||
->findAll();
|
||||
return ($result);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
||||
public function getInceptionEmployeeDataForExportExcel($client_policy_id, $insurer_or_tpa, $event_type)
|
||||
{
|
||||
return $this->db->table('employee_polices')
|
||||
->select('employees.name AS emp_name,
|
||||
employees.emp_code AS emp_code,
|
||||
employees.dob AS emp_dob,
|
||||
employees.gender AS emp_gender,
|
||||
employees.change_event AS change_event,
|
||||
employees.relationship AS emp_relationship,
|
||||
employees.relationship_code AS emp_relationship_code,
|
||||
TIMESTAMPDIFF(YEAR, employees.dob, CURDATE()) AS emp_age,
|
||||
"Has Define" as emp_type,
|
||||
|
||||
employee_polices.id as employee_policy_id,
|
||||
employee_polices.pre_existing_alignments,
|
||||
employee_polices.basic_cover_si,
|
||||
employee_polices.date_coverage,
|
||||
employee_polices.policy_end_date,
|
||||
employee_polices.days,
|
||||
employee_polices.premium,
|
||||
employee_polices.rata_premimum,
|
||||
employee_polices.gst,
|
||||
(employee_polices.rata_premimum + employee_polices.gst) AS total,
|
||||
batch_data.emp_policy_id,
|
||||
batch_data.bl AS batch_list_batch_code,
|
||||
batch_data.bf AS batch_files_batch_code')
|
||||
|
||||
->join('employees', 'employees.id = employee_polices.employee_id', 'left')
|
||||
->join("(
|
||||
SELECT
|
||||
batch_list.emp_policy_id,
|
||||
batch_list.batch_code as bl,
|
||||
batch_files.batch_code as bf
|
||||
FROM batch_files
|
||||
LEFT JOIN batch_list ON batch_files.batch_code = batch_list.batch_code
|
||||
WHERE batch_files.event_type = 'inception'
|
||||
AND batch_files.actions = 'export'
|
||||
AND batch_files.insurer_or_tpa = '{$insurer_or_tpa}') as batch_data", 'employee_polices.id = batch_data.emp_policy_id', 'left')
|
||||
->where('batch_data.bf', null)
|
||||
->where('batch_data.bl', null)
|
||||
->where('employee_polices.client_policy_id', $client_policy_id)
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
|
||||
public function getCorrectionEmployeesDataForExportExcel($client_id, $client_policy_id, $insurer_or_tpa)
|
||||
{
|
||||
|
||||
return $this->db->table('emp_endorsement')
|
||||
->select('emp_endorsement.id,
|
||||
emp_endorsement.emp_id,
|
||||
emp_endorsement.emp_code,
|
||||
emp_endorsement.endorsement_id,
|
||||
emp_endorsement.old_value,
|
||||
emp_endorsement.new_value,
|
||||
emp_endorsement.field_name,
|
||||
emp_endorsement.remarks,
|
||||
employees.name AS emp_name,
|
||||
employees.dob AS emp_dob,
|
||||
employees.gender AS emp_gender,
|
||||
employees.client_id AS emp_client_id,
|
||||
"Has Define" as emp_type,
|
||||
employee_polices.uhid,
|
||||
employees.relationship_code,
|
||||
batch_data.emp_policy_id,
|
||||
batch_data.bl AS batch_list_batch_code,
|
||||
batch_data.bf AS batch_files_batch_code')
|
||||
->join('employees', 'employees.id = emp_endorsement.emp_id', 'left')
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id', 'left')
|
||||
->join("(SELECT batch_list.emp_policy_id,
|
||||
batch_list.batch_code as bl,
|
||||
batch_files.batch_code as bf
|
||||
FROM batch_files
|
||||
LEFT JOIN batch_list ON batch_files.batch_code = batch_list.batch_code
|
||||
WHERE batch_files.event_type = 'correction'
|
||||
AND batch_files.actions = 'export'
|
||||
AND batch_files.insurer_or_tpa = '{$insurer_or_tpa}') as batch_data", 'emp_endorsement.emp_id = batch_data.emp_policy_id', 'left', false)
|
||||
->where('batch_data.bf IS NULL')
|
||||
->where('batch_data.bl IS NULL')
|
||||
->where('emp_endorsement.endorsement_id', '')
|
||||
->where('employees.client_id', $client_id)
|
||||
->where('employee_polices.client_policy_id', $client_policy_id)
|
||||
->get()
|
||||
->getResult();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function updateTPAIDorUHID( $client_policy_id, $client_id, $name, $emp_code, $uhid, $tpa_id)
|
||||
{
|
||||
|
||||
// $this->table('employee_polices')
|
||||
// ->join('employees', 'employees.id = employee_polices.employee_id')
|
||||
// ->set('employee_polices.tpa_id', $tpa_id)
|
||||
// ->set('employee_polices.uhid', $uhid)
|
||||
// ->where('employees.emp_code', $emp_code)
|
||||
// ->where('employees.name', $name)
|
||||
// ->where('employees.client_id', $client_id)
|
||||
// ->where('employee_polices.client_policy_id', $client_policy_id)
|
||||
// ->update();
|
||||
|
||||
$query = "UPDATE employee_polices
|
||||
JOIN employees ON employees.id = employee_polices.employee_id
|
||||
SET employee_polices.tpa_id = '{$tpa_id}',
|
||||
employee_polices.uhid = '{$uhid}'
|
||||
WHERE employees.emp_code = '{$emp_code}'
|
||||
AND employees.name = '{$name}'
|
||||
AND employees.client_id = '{$client_id}'
|
||||
AND employee_polices.client_policy_id = '{$client_policy_id}'";
|
||||
|
||||
$this->query($query);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function updateCorrectionData($emp_code, $uhid, $endorsement_id){
|
||||
|
||||
$sql = "
|
||||
UPDATE emp_endorsement
|
||||
JOIN employees ON employees.id = emp_endorsement.emp_id
|
||||
JOIN employee_polices ON employees.id = employee_polices.employee_id
|
||||
SET emp_endorsement.endorsement_id = '$endorsement_id'
|
||||
WHERE employees.emp_code = '$emp_code'
|
||||
AND employee_polices.uhid = '$uhid'
|
||||
";
|
||||
$query = $this->query($sql);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@ -291,5 +291,13 @@ function onlyNumbers(event){
|
||||
return false;
|
||||
}
|
||||
|
||||
var form = document.getElementById("UserForm");
|
||||
|
||||
// Add submit event listener to the form
|
||||
form.addEventListener("submit", function(event) {
|
||||
// Disable the submit button to avoid multiple submissions
|
||||
document.getElementById("btnSubmit").disabled = true;
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@ -127,8 +127,13 @@ $(document).ready(function () {
|
||||
$("#general_form").submit(function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
var $submitButton = $('#general_form').find('button[type="submit"]');
|
||||
$submitButton.prop('disabled', true); // Disable the submit button
|
||||
|
||||
var isValid = $('#general_form').parsley().validate();
|
||||
if (!isValid) {
|
||||
$submitButton.prop('disabled', false);
|
||||
console.log('Form is Empty', 'Warning');
|
||||
return ;
|
||||
}
|
||||
@ -162,7 +167,7 @@ $(document).ready(function () {
|
||||
$('#kyc_tab').click();
|
||||
var message = (PrimaryKey === '') ? 'Client General Info Created successfully' : 'Client General Info Updated successfully';
|
||||
toastr.success(message, 'Success');
|
||||
|
||||
$submitButton.prop('disabled', false);
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
@ -177,42 +182,57 @@ $(document).ready(function () {
|
||||
$('#kyc_PrimaryKey').val(res.data.id);
|
||||
$('#entity_type').val(res.data.entity_type_id);
|
||||
|
||||
$.ajax({
|
||||
url: '<?= base_url("client/kyc/list/"); ?>' + res.data.entity_type_id,
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function (res) {
|
||||
|
||||
console.log(res);
|
||||
var tbody = $('#tbody');
|
||||
tbody.empty();
|
||||
console.log()
|
||||
|
||||
$.each(res.data, function (index, item) {
|
||||
var row = `<tr>
|
||||
<td> ${item.file_name}</td>
|
||||
<td id="form_${item.id}" style=""><form class="ajax" ><input class="file-input__input" type="file" name="file_name">
|
||||
<input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
|
||||
<input type="hidden" class="form-control" value="${item.id}" name="kyc_doc_type_id" />
|
||||
<input type="hidden" name="client_id" value="<?= isset($client['id']) ? $client['id'] : '' ?>"/>
|
||||
<button class="btn btn-sm btn-primary submit" style="position: relative;right: 80px;">Submit</button></form></td>
|
||||
<td id="name_${item.id}" style="display:none;"></td>
|
||||
<td><i data-id="${item.id}" class="mdi mdi-delete btnKycDelete" style="font-size:18px;"></i></td>
|
||||
</tr>`;
|
||||
tbody.append(row);
|
||||
});
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
}
|
||||
});
|
||||
if(PrimaryKey === ''){
|
||||
$.ajax({
|
||||
url: '<?= base_url("client/kyc/list/"); ?>' + res.data.entity_type_id,
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function (res) {
|
||||
|
||||
console.log('kyc docs', res);
|
||||
var tbody = $('#tbody');
|
||||
tbody.empty();
|
||||
|
||||
$.each(res.data, function (index, item) {
|
||||
var row = `<tr>
|
||||
<td> ${item.file_name}</td>
|
||||
<td id="form_${item.id}" style=""><form class="ajax" ><input class="file-input__input" type="file" name="file_name">
|
||||
<input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
|
||||
<input type="hidden" class="form-control" value="${item.id}" name="kyc_doc_type_id" />
|
||||
<input type="hidden" name="client_id" value="<?= isset($client['id']) ? $client['id'] : '' ?>"/>
|
||||
<button class="btn btn-sm btn-primary submit" style="position: relative;right: 80px;">Submit</button></form></td>
|
||||
<td id="name_${item.id}" style="display:none;"></td>
|
||||
<td><i data-id="${item.id}" class="mdi mdi-delete btnKycDelete" style="font-size:18px;"></i></td>
|
||||
</tr>`;
|
||||
tbody.append(row);
|
||||
});
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
$submitButton.prop('disabled', false);
|
||||
if (xhr.status === 404) {
|
||||
toastr.warning('Resource not found', 'Warning');
|
||||
} else if (xhr.status === 500) {
|
||||
toastr.warning('Internal server error', 'Warning');
|
||||
} else {
|
||||
toastr.warning('Unknown error occurred', 'Warning');
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -94,7 +94,7 @@
|
||||
|
||||
<script>
|
||||
|
||||
var kycPrimaryKey = $('#kyc_PrimaryKey').val();
|
||||
var kycPrimaryKey = $('#client_id_kyc').val();
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
@ -144,6 +144,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
@ -160,6 +161,15 @@
|
||||
}, 1000);
|
||||
// res = JSON.parse(res)
|
||||
// console.log(res);
|
||||
|
||||
if(res){
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
toastr.success('File Uloaded successfully', 'Success');
|
||||
}, 500);
|
||||
}
|
||||
|
||||
form.trigger('reset')
|
||||
$.each(res.data, function (index, item) {
|
||||
|
||||
@ -179,6 +189,7 @@
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
toastr.warning('Something Wrong!', 'warning');
|
||||
}, 1000);
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -198,7 +209,7 @@
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}, 1000);
|
||||
console.log(res);
|
||||
|
||||
var tbody = $('#tbody');
|
||||
tbody.empty();
|
||||
|
||||
@ -254,9 +265,9 @@
|
||||
// console.log('name_' + item.kyc_doc_type_id);
|
||||
// console.log(document.getElementById('name_' + item.kyc_doc_type_id));
|
||||
setTimeout(function() {
|
||||
$('#name_'+item.id).show();
|
||||
$('#name_'+item.id).html(item.file_name);
|
||||
$('#form_'+item.id).hide();
|
||||
$('#name_'+item.kyc_doc_type_id).show();
|
||||
$('#name_'+item.kyc_doc_type_id).html(item.file_name);
|
||||
$('#form_'+item.kyc_doc_type_id).hide();
|
||||
}, 1000);
|
||||
|
||||
});
|
||||
@ -273,6 +284,7 @@
|
||||
});
|
||||
|
||||
|
||||
/*** for Others documents form submit ***/
|
||||
$("#kyc_form").submit(function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
@ -305,9 +317,15 @@
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}, 1000);
|
||||
console.log(res);
|
||||
$('#kyc_form').trigger('reset')
|
||||
var message = (kycPrimaryKey === '') ? 'KYC Docs Uploaded successfully' : 'KYC Docs Uploaded successfully';
|
||||
toastr.success(message, 'Success');
|
||||
$('#kyc_form').trigger('reset');
|
||||
if(res){
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
var message = (kycPrimaryKey === '') ? 'KYC Other Docs Uploaded successfully' : 'KYC Other Docs Uploaded successfully';
|
||||
toastr.success(message, 'Success');
|
||||
}, 500);
|
||||
}
|
||||
|
||||
$('#other_docs tr').remove();
|
||||
$.each(res.data, function(index, item) {
|
||||
@ -334,6 +352,7 @@
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
toastr.warning('Something Wrong!', 'warning');
|
||||
}, 1000);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -1,13 +1,3 @@
|
||||
<style>
|
||||
th {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
td{
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="tab-pane fade" id="police-tab">
|
||||
|
||||
|
||||
|
||||
@ -69,6 +69,8 @@ $(document).ready(function(){
|
||||
|
||||
relation_PrimaryKey = $('#relation_PrimaryKey').val()
|
||||
|
||||
$('#client_rm_edit').hide()
|
||||
|
||||
$('#account_manager').multiselect({
|
||||
nonSelectedText: 'Select Account Manager',
|
||||
enableFiltering: false,
|
||||
@ -80,6 +82,7 @@ $(document).ready(function(){
|
||||
|
||||
var data = <?= isset($client_relation) ? json_encode($client_relation) : '[]' ?>;
|
||||
if (relation_PrimaryKey !== '') {
|
||||
$('#client_rm_edit').show()
|
||||
$('#client_rm_btnSubmit').hide();
|
||||
$.each(data, function(index, item) {
|
||||
$('#head option[value="' + item.user_id + '"]').prop('selected', true);
|
||||
|
||||
@ -4,144 +4,150 @@
|
||||
<!-- <?php echo fancy_date_time_format('2024-02-13 14:40:32');echo '<br>';?> -->
|
||||
<!-- <?php echo fancy_date_time_format('2024-02-13 14:58:00');echo '<br>';?> -->
|
||||
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<!-- <div class="text-center"> -->
|
||||
<form id="emp-upload-form" action="<?php echo base_url().'employee/upload'?>" method="post">
|
||||
<input type="hidden" name="<?= csrf_token() ?>" value="<?= csrf_hash() ?>" id="csrf_token">
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-xl-3">
|
||||
<div class="form-group mb-3">
|
||||
<label>Client</label> <br/>
|
||||
<select name="client_id" class="form-control" id="client_id" required>
|
||||
<option value="">Select</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-xl-3">
|
||||
<div class="form-group mb-3">
|
||||
<label>Policy</label> <br/>
|
||||
<select name="policy_id" class="form-control" id="policy_id">
|
||||
<option value="">Select</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 col-xl-3">
|
||||
<div class="form-group mb-3">
|
||||
<label>Action</label> <br/>
|
||||
<select name="upload-action-type" class="form-control" id="upload-action-type" required>
|
||||
<option value="">Select</option>
|
||||
<?php
|
||||
if(isset($actions) && count($actions))
|
||||
|
||||
<div class="tab-pane fade active show" id="general-q-tab">
|
||||
<div class="row" >
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<!-- <div class="text-center"> -->
|
||||
<form id="emp-upload-form" action="<?php echo base_url().'employee/upload'?>" method="post">
|
||||
<input type="hidden" name="<?= csrf_token() ?>" value="<?= csrf_hash() ?>" id="csrf_token">
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label>Client</label> <br />
|
||||
<select name="client_id" class="form-control" id="client_id" required>
|
||||
<option value="">Select</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label>Policy</label> <br/>
|
||||
<select name="policy_id" class="form-control" id="policy_id">
|
||||
<option value="">Select</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label>Event</label> <br />
|
||||
<select name="upload-action-type" class="form-control" id="upload-action-type" required>
|
||||
<option value="">Select</option>
|
||||
<?php
|
||||
if(isset($actions) && count($actions))
|
||||
{
|
||||
foreach($actions as $key => $action)
|
||||
{
|
||||
foreach($actions as $key => $action)
|
||||
{
|
||||
echo "<option value=".$key.">".$action."</option>";
|
||||
}
|
||||
echo "<option value=".$key.">".$action."</option>";
|
||||
}
|
||||
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-xl-3">
|
||||
<div class="form-group mb-3">
|
||||
<label>Choose file</label> <br/>
|
||||
<input type="file" name="emplist" id="emplist" accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet" required>
|
||||
</div></div>
|
||||
|
||||
<div class="col-8" style="text-align: right;">
|
||||
<button id="emp_form_submit_button" type="submit" class="btn btn-primary waves-effect waves-light">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<!-- </div> -->
|
||||
<hr>
|
||||
|
||||
<div class="form-row" id="file_upload">
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label>Upload file</label> [ <a id="excel_download" data-toggle="tooltip" data-placement="top" title="Download Sample Excel">Sample Excel</a> ]
|
||||
<input type="file" name="emplist" id="emplist" accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet"
|
||||
required>
|
||||
</div>
|
||||
|
||||
<div class="d-flex align-items-center justify-content-start" style="margin-top: 18px;">
|
||||
<div class="form-group col-md-11"> <!-- Adjusted the width to 11 columns -->
|
||||
<div class="col-md-3">
|
||||
<button id="emp_form_submit_button" type="submit" class="btn btn-primary waves-effect waves-light justify-content-end">Upload</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box page-title-box-alt">
|
||||
<h4 class="page-title"></h4>
|
||||
<div class="page-title-right">
|
||||
</form>
|
||||
<!-- </div> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
<div class="row" id="file_list">
|
||||
<?php include('file_list.php');?>
|
||||
|
||||
<!-- end page title -->
|
||||
<div class="row" id="file_list">
|
||||
<?php include('file_list.php');?>
|
||||
</div>
|
||||
<!-- end row -->
|
||||
|
||||
</div>
|
||||
<!-- end row -->
|
||||
<!-- Center modal content -->
|
||||
<div class="modal fade" id="file-err-modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="myCenterModalLabel">File Rejected Reason</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
|
||||
|
||||
<!-- <div id="loader" class="loader" style="display:none;">SPINNER</div> -->
|
||||
|
||||
<!-- Center modal content -->
|
||||
<div class="modal fade" id="file-err-modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="myCenterModalLabel">File Rejected Reason</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
// Declare a global variable to store API response data
|
||||
var clientPolicies = [];
|
||||
|
||||
$( document ).ready(function() {
|
||||
console.log( "document loaded" );
|
||||
//fetchClientPolicies();
|
||||
//for modal pop up
|
||||
$('#file-err-modal').on('show.bs.modal', function (event) {
|
||||
// console.log(event.relatedTarget);
|
||||
var myVal = $(event.relatedTarget).data('err');
|
||||
console.log(myVal);
|
||||
var loader = '<div style="text-align: center;"><img src="<?php echo base_url()?>public/assets/images/simple_loader.gif" height="50px" width="50px" ></div>';
|
||||
$('#file-err-modal').find(".modal-body").html(loader);
|
||||
var model_data = fetchFileError(myVal);
|
||||
// console.log('data received.');
|
||||
// console.log(model_data);
|
||||
|
||||
});
|
||||
$('#file_upload').hide();
|
||||
|
||||
|
||||
//for form submit
|
||||
$("#emp-upload-form").submit(function(event) {
|
||||
// Declare a global variable to store API response data
|
||||
var clientPolicies = [];
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
console.log("document loaded");
|
||||
//fetchClientPolicies();
|
||||
//for modal pop up
|
||||
$('#file-err-modal').on('show.bs.modal', function(event) {
|
||||
// console.log(event.relatedTarget);
|
||||
var myVal = $(event.relatedTarget).data('err');
|
||||
console.log(myVal);
|
||||
var loader =
|
||||
'<div style="text-align: center;"><img src="<?php echo base_url()?>public/assets/images/simple_loader.gif" height="50px" width="50px" ></div>';
|
||||
$('#file-err-modal').find(".modal-body").html(loader);
|
||||
var model_data = fetchFileError(myVal);
|
||||
// console.log('data received.');
|
||||
// console.log(model_data);
|
||||
|
||||
});
|
||||
|
||||
//for form submit
|
||||
$("#emp-upload-form").submit(function(event) {
|
||||
event.preventDefault(); // Prevent default form submission
|
||||
console.log('submit called');
|
||||
|
||||
|
||||
var action_item = $('#upload-action-type').val();
|
||||
var policy_id = $('#policy_id').val();
|
||||
console.log('action_item - '+ action_item);
|
||||
if(action_item != 'correction' && policy_id == "")
|
||||
{
|
||||
console.log('action_item - ' + action_item);
|
||||
if (action_item != 'correction' && policy_id == "") {
|
||||
// $('#policy_id').attr('required', true);
|
||||
// $('#policy_id').prop('title', 'plz choose policy');
|
||||
// $('#policy_id').mouseover();
|
||||
console.log('required');
|
||||
alert('please choose policy for this uploaing event ');
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
|
||||
$('#policy_id').attr('required', false);
|
||||
console.log('not required');
|
||||
@ -150,11 +156,14 @@
|
||||
// Create FormData object
|
||||
var formData = new FormData($(this)[0]);
|
||||
for (var pair of formData.entries()) {
|
||||
console.log(pair[0]+ ', ' + pair[1]); }
|
||||
|
||||
console.log(pair[0] + ', ' + pair[1]);
|
||||
}
|
||||
|
||||
console.log(formData);
|
||||
$('#emp_form_submit_button').prop('disabled',true);
|
||||
$('#emp_form_submit_button').html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Loading...');
|
||||
$('#emp_form_submit_button').prop('disabled', true);
|
||||
$('#emp_form_submit_button').html(
|
||||
'<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Loading...'
|
||||
);
|
||||
// return false;
|
||||
$.ajax({
|
||||
url: $(this).attr("action"),
|
||||
@ -164,29 +173,29 @@
|
||||
contentType: false, // Let jQuery handle the content type
|
||||
headers: {
|
||||
// "Content-Type":"multipart/form-data",
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
},
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
},
|
||||
success: function(response) {
|
||||
// Request successful, handle response
|
||||
$('#policy_id').attr('required', false);
|
||||
$('#policy_id').attr('required', false);
|
||||
console.log(response);
|
||||
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||||
toastr.success('File upload successs, Data validation is in-progress', 'success');
|
||||
window.location.reload(true);
|
||||
} 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);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (response.code === 200 && response.dataStatus === true && response
|
||||
.data !== "") {
|
||||
toastr.success('File upload successs, Data validation is in-progress',
|
||||
'success');
|
||||
window.location.reload(true);
|
||||
} 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);
|
||||
} else {
|
||||
console.error('Something went wrong!');
|
||||
// alert('Something went wrong! Try later');
|
||||
toastr.error('Something went wrong! Try later', 'Error');
|
||||
window.location.reload(true);
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Request failed, handle error
|
||||
@ -195,158 +204,167 @@
|
||||
window.location.reload(true);
|
||||
}
|
||||
});
|
||||
});//end
|
||||
}); //end
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
$( window ).on( "load", function() {
|
||||
console.log( "window loaded" );
|
||||
fetchClientPolicies();
|
||||
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
$(window).on("load", function() {
|
||||
console.log("window loaded");
|
||||
fetchClientPolicies();
|
||||
|
||||
|
||||
function fetchClientPolicies() {
|
||||
|
||||
});
|
||||
|
||||
|
||||
function fetchClientPolicies() {
|
||||
$('#loader').show();
|
||||
var apiURL = '<?php echo base_url();?>' + 'util/clients-with-policies';
|
||||
console.log('fetchClientPolicies');
|
||||
console.log(apiURL);
|
||||
$.ajax({
|
||||
url: apiURL,
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
},
|
||||
success: function(response) {
|
||||
// console.log(response.code);
|
||||
// console.log(response.dataStatus);
|
||||
// console.log(response.data);
|
||||
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||||
try {
|
||||
clientPolicies = (response.data);
|
||||
// console.log(clientPolicies);
|
||||
appendClients(clientPolicies);
|
||||
} catch (error)
|
||||
{
|
||||
console.error('Error parsing API response data:', error);
|
||||
}
|
||||
} else if(response.code === 404 && response.dataStatus === false){
|
||||
console.error('no data found', response);
|
||||
url: apiURL,
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
},
|
||||
success: function(response) {
|
||||
// console.log(response.code);
|
||||
// console.log(response.dataStatus);
|
||||
// console.log(response.data);
|
||||
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||||
try {
|
||||
clientPolicies = (response.data);
|
||||
// console.log(clientPolicies);
|
||||
appendClients(clientPolicies);
|
||||
} catch (error) {
|
||||
console.error('Error parsing API response data:', error);
|
||||
}
|
||||
} else if (response.code === 404 && response.dataStatus === false) {
|
||||
console.error('no data found', response);
|
||||
} else {
|
||||
console.error('Something went wrong!');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error fetching data from API:', error);
|
||||
}
|
||||
else
|
||||
{
|
||||
console.error('Something went wrong!');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error fetching data from API:', error);
|
||||
}
|
||||
});
|
||||
|
||||
$('#loader').hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function fetchFileError(file_id) {
|
||||
function fetchFileError(file_id) {
|
||||
$('#loader').show();
|
||||
var apiURL = '<?php echo base_url();?>' + 'util/get-file-error/' + file_id;
|
||||
console.log('fetchFileError');
|
||||
console.log(apiURL);
|
||||
$.ajax({
|
||||
url: apiURL,
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
},
|
||||
success: function(response) {
|
||||
// console.log(response.code);
|
||||
// console.log(response.dataStatus);
|
||||
// console.log(response.data);
|
||||
$(this).find(".modal-body").html("");
|
||||
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||||
try {
|
||||
console.log((JSON.parse(response.data)));
|
||||
var file_error_data = (JSON.parse(response.data));
|
||||
var file_error_html = "";
|
||||
|
||||
for (var key in file_error_data['error_summary']) {
|
||||
console.log(key);
|
||||
var err_id = key;
|
||||
var err_count = file_error_data['error_summary'][key];
|
||||
// for (var ckey in col)
|
||||
// {
|
||||
|
||||
file_error_html += (err_id == 1 ? "<strong>Mandatory values missing</strong> <span class='badge badge-danger float-right'>"+err_count+"</span>" : (err_id == 2 ? "<strong>Values not in expected format</strong> <span class='badge badge-danger float-right'>"+err_count+"</span>" : (err_id == 3 ? "<strong>Field contains not allowed values</strong> <span class='badge badge-danger float-right'>"+err_count+"</span>" : (err_id == 4 ? "<strong>Rule Conflict</strong> <span class='badge badge-danger float-right'>"+err_count+"</span>" : (err_id == 5 ? "<strong>"+file_error_data['error_data']+"</strong>" : (err_id == 6 ? "<strong>"+file_error_data['error_data']+"</strong>" : ""))))));
|
||||
file_error_html += '<br/>';
|
||||
// }
|
||||
|
||||
}
|
||||
if(err_id != 5 && err_id != 6)
|
||||
{
|
||||
file_error_html += (file_error_html != "" ? "<a href ='<?php echo base_url()?>"+ "employee/excel_error/" + file_id + "' target=_blank>click here to more details...</a>":"");
|
||||
url: apiURL,
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
},
|
||||
success: function(response) {
|
||||
// console.log(response.code);
|
||||
// console.log(response.dataStatus);
|
||||
// console.log(response.data);
|
||||
$(this).find(".modal-body").html("");
|
||||
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||||
try {
|
||||
console.log((JSON.parse(response.data)));
|
||||
var file_error_data = (JSON.parse(response.data));
|
||||
var file_error_html = "";
|
||||
|
||||
for (var key in file_error_data['error_summary']) {
|
||||
console.log(key);
|
||||
var err_id = key;
|
||||
var err_count = file_error_data['error_summary'][key];
|
||||
// for (var ckey in col)
|
||||
// {
|
||||
|
||||
file_error_html += (err_id == 1 ?
|
||||
"<strong>Mandatory values missing</strong> <span class='badge badge-danger float-right'>" +
|
||||
err_count + "</span>" : (err_id == 2 ?
|
||||
"<strong>Values not in expected format</strong> <span class='badge badge-danger float-right'>" +
|
||||
err_count + "</span>" : (err_id == 3 ?
|
||||
"<strong>Field contains not allowed values</strong> <span class='badge badge-danger float-right'>" +
|
||||
err_count + "</span>" : (err_id == 4 ?
|
||||
"<strong>Rule Conflict</strong> <span class='badge badge-danger float-right'>" +
|
||||
err_count + "</span>" : (err_id == 5 ? "<strong>" +
|
||||
file_error_data['error_data'] + "</strong>" : (err_id == 6 ?
|
||||
"<strong>" + file_error_data['error_data'] +
|
||||
"</strong>" : ""))))));
|
||||
file_error_html += '<br/>';
|
||||
// }
|
||||
|
||||
}
|
||||
console.log(file_error_html);
|
||||
$('#file-err-modal').find(".modal-body").html(file_error_html);
|
||||
return file_error_html;
|
||||
} catch (error)
|
||||
{
|
||||
console.error('Error parsing API response data:', error);
|
||||
}
|
||||
} else if(response.code === 404 && response.dataStatus === false){
|
||||
console.error('no data found', response);
|
||||
if (err_id != 5 && err_id != 6) {
|
||||
file_error_html += (file_error_html != "" ? "<a href ='<?php echo base_url()?>" +
|
||||
"employee/excel_error/" + file_id +
|
||||
"' target=_blank>click here to more details...</a>" : "");
|
||||
}
|
||||
console.log(file_error_html);
|
||||
$('#file-err-modal').find(".modal-body").html(file_error_html);
|
||||
return file_error_html;
|
||||
} catch (error) {
|
||||
console.error('Error parsing API response data:', error);
|
||||
}
|
||||
} else if (response.code === 404 && response.dataStatus === false) {
|
||||
console.error('no data found', response);
|
||||
} else {
|
||||
console.error('Something went wrong!');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error fetching data from API:', error);
|
||||
}
|
||||
else
|
||||
{
|
||||
console.error('Something went wrong!');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error fetching data from API:', error);
|
||||
}
|
||||
});
|
||||
|
||||
$('#loader').hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function appendClients(data) {
|
||||
function appendClients(data) {
|
||||
$.each(data, function(index, item) {
|
||||
$('#client_id').append($('<option>', {
|
||||
value: item.id,
|
||||
text: item.client_name
|
||||
}));
|
||||
$('#client_id').append($('<option>', {
|
||||
value: item.id,
|
||||
text: item.client_name
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function appendPolicies(data) {
|
||||
function appendPolicies(data) {
|
||||
$('#policy_id').empty();
|
||||
$('#policy_id').append($('<option>', { value: '',text: 'Select'}));
|
||||
$('#policy_id').append($('<option>', {
|
||||
value: '',
|
||||
text: 'Select'
|
||||
}));
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
$('#policy_id').append($('<option>', {
|
||||
value: item.id,
|
||||
text: item.name
|
||||
}));
|
||||
$('#policy_id').append($('<option>', {
|
||||
value: item.id,
|
||||
text: item.name
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$('#client_id').on('change', function() {
|
||||
var selectedClient = $(this).val();
|
||||
console.log(selectedClient);
|
||||
// $('#selectedOptionInfo').text('Selected option: ' + selectedOption);
|
||||
|
||||
|
||||
// Check if the selected option exists in apiData
|
||||
var foundPolicies = clientPolicies.find(function(item) {
|
||||
return item.id === selectedClient;
|
||||
return item.id === selectedClient;
|
||||
});
|
||||
console.log(foundPolicies.policies);
|
||||
appendPolicies(foundPolicies.policies);
|
||||
});
|
||||
console.log(foundPolicies.policies);
|
||||
appendPolicies(foundPolicies.policies);
|
||||
});
|
||||
|
||||
// Function to convert object to query parameters
|
||||
function objectToQueryString(obj) {
|
||||
@ -355,25 +373,25 @@ function objectToQueryString(obj) {
|
||||
|
||||
function fetchEmpolyeeList(event) {
|
||||
event.preventDefault(); // Prevent default action
|
||||
|
||||
|
||||
var client_id = $('#client_id').val();
|
||||
var policy_id = $('#policy_id').val();
|
||||
console.log(client_id+'-'+policy_id);
|
||||
if (client_id == '0' || policy_id == '0' ) {
|
||||
console.log(client_id + '-' + policy_id);
|
||||
if (client_id == '0' || policy_id == '0') {
|
||||
alert('Please select values in both dropdowns.');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var queryParams = {
|
||||
client_id: client_id,
|
||||
policy_id: policy_id
|
||||
};
|
||||
|
||||
|
||||
const queryString = objectToQueryString(queryParams);
|
||||
const apiURL = $('#get-emp-list').attr('href')+"?" + queryString;
|
||||
const apiURL = $('#get-emp-list').attr('href') + "?" + queryString;
|
||||
console.log(apiURL);
|
||||
window.location.href = apiURL;
|
||||
|
||||
|
||||
|
||||
// var apiURL2 = $('#get-emp-list').attr('href'); // Get href attribute value
|
||||
// console.log(apiURL);
|
||||
@ -392,5 +410,37 @@ function fetchEmpolyeeList(event) {
|
||||
// });
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
/**This function updates the download link based on the selected option in the dropdown menu. **/
|
||||
$('#upload-action-type').change(function() {
|
||||
|
||||
var selectedValue = $(this).val();
|
||||
if(selectedValue !== ''){
|
||||
$('#file_upload').show();
|
||||
var fullURL = '<?= base_url("util/download-excel/"); ?>' + selectedValue;
|
||||
$('#excel_download').attr('href', fullURL);
|
||||
}else{
|
||||
$('#file_upload').hide();
|
||||
$('#excel_download').removeAttr('href');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/** This function verifies if the download link (#excel_download) has its href attribute set,
|
||||
** ensuring proper link configuration. **/
|
||||
|
||||
$('#excel_download').click(function() {
|
||||
|
||||
// Check if the element with ID "excel_download" has the href attribute set
|
||||
if (!$(this).attr('href')) {
|
||||
// If href attribute is not set, show an error message
|
||||
toastr.warning('Please select an Action to download a sample Excel.', 'Warning');
|
||||
} else {
|
||||
console.log('Download action triggered.');
|
||||
}
|
||||
});
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
</script>
|
||||
@ -1,34 +1,125 @@
|
||||
<div class="row" id="List-page">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row" style="margin-bottom:1rem;">
|
||||
<div class="col-6" style="align-self: center;">
|
||||
<h4 class="header-title" style="position: relative;">Excel Error List</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="0" id="tickets-table">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<?php foreach ($excel_header as $header): ?>
|
||||
<th><?php echo $header; ?></th>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php for ($i = 1; $i < count($excel_data); $i++): ?>
|
||||
<tr>
|
||||
<?php foreach ($excel_data[$i] as $data): ?>
|
||||
<td><?php echo $data; ?></td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php endfor; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end col -->
|
||||
</div>
|
||||
<!-- Include DataTables CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.min.css">
|
||||
<!-- Include DataTables Buttons CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/2.3.0/css/buttons.dataTables.min.css">
|
||||
<!-- Include Font Awesome CSS -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
|
||||
|
||||
<style>
|
||||
/* Table styles */
|
||||
.table {
|
||||
width: 100%;
|
||||
border: 2px solid #ddd;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.table th, .table td {
|
||||
padding: 8px;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.table th {
|
||||
background-color: #f2f2f2;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.table tr:nth-child(even) {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
.error-tooltip {
|
||||
display: none;
|
||||
/* Hide error message by default */
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
background-color: #000;
|
||||
color: #fff;
|
||||
padding: 5px;
|
||||
border-radius: 5px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.error-icon {
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.error-icon:hover+.error-tooltip {
|
||||
display: block;
|
||||
/* Show error message when hovering over the icon */
|
||||
}
|
||||
|
||||
/* .error-cell {
|
||||
border: 2px solid red !important;
|
||||
} */
|
||||
|
||||
/* .container{
|
||||
position: relative;
|
||||
bottom: 150px;
|
||||
} */
|
||||
|
||||
table.dataTable tbody td {
|
||||
padding: 4px 4px !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div class="container">
|
||||
<table class="table table-sm table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="0" id="tickets-table">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<?php foreach ($excel_header as $header): ?>
|
||||
<th><?php echo $header; ?></th>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php for ($i = 0; $i < count($excel_data); $i++): ?>
|
||||
<tr>
|
||||
<?php foreach ($excel_data[$i] as $data): ?>
|
||||
<td <?php if (isset($data['error'])) echo 'class="error-cell"'; ?>>
|
||||
<?php
|
||||
if (isset($data['value'])) {
|
||||
echo $data['value'];
|
||||
}
|
||||
if (isset($data['error'])) {
|
||||
echo '<span class="error-icon"> <i class="fas fa-exclamation-circle" style="color: red;"></i></span>';
|
||||
echo '<span class="error-tooltip">' . implode("<br>", $data['error']) . '</span>';
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php endfor; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Include jQuery -->
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<!-- Include DataTables JavaScript -->
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
|
||||
<!-- Include DataTables Buttons JavaScript -->
|
||||
<script src="https://cdn.datatables.net/buttons/2.3.0/js/dataTables.buttons.min.js"></script>
|
||||
<!-- Include DataTables JSZip library -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
||||
<!-- Include DataTables Buttons HTML5 export extension -->
|
||||
<script src="https://cdn.datatables.net/buttons/2.3.0/js/buttons.html5.min.js"></script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#tickets-table').DataTable({
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
{
|
||||
extend: 'excel',
|
||||
text: 'Excel', // Set the title for the Excel button
|
||||
title: 'ExcelErrorData', // Set your custom title here
|
||||
}
|
||||
],
|
||||
paging: false, // Disable pagination
|
||||
lengthMenu: [[-1], ["All"]] // Display all rows
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
32
app/Views/import_export.php
Normal file
32
app/Views/import_export.php
Normal file
@ -0,0 +1,32 @@
|
||||
|
||||
|
||||
<div class="row" id="client_add" style="position: relative; bottom: 25px;">
|
||||
<div class="col-12">
|
||||
<div class="card-body">
|
||||
<ul class="nav nav-pills navtab-bg">
|
||||
<li class="nav-item">
|
||||
<a href="#general-q-tab" data-toggle="tab" aria-expanded="false"
|
||||
class="nav-link px-3 py-2 active" id="general_tab">
|
||||
<span class="mr-1"><i class="mdi mdi-contacts"></i></span>
|
||||
<span class="d-none d-sm-inline-block">Data From Client</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="#KYC-DOC-tab" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2" id="kyc_tab">
|
||||
<span class="mr-1"><i class="fa fa-file"></i></span>
|
||||
<span class="d-none d-sm-inline-block">Insurer or TPA Data</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<?php include('employee_upload.php'); ?>
|
||||
<?php include('insurer_or_tpa_data.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
334
app/Views/insurer_or_tpa_data.php
Normal file
334
app/Views/insurer_or_tpa_data.php
Normal file
@ -0,0 +1,334 @@
|
||||
<div class="tab-pane fade active show" id="KYC-DOC-tab">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<!-- <div class="text-center"> -->
|
||||
<form class="parsley-examples" id="import_export_excel_form" action = "<?php echo base_url().'util/import-export'?>" method="post"
|
||||
enctype="multipart/form-data">
|
||||
<input type="hidden" name="<?= csrf_token() ?>" value="<?= csrf_hash() ?>" id="csrf_token">
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label>Client</label> <br />
|
||||
<select name="client_id" class="form-control" id="client" required>
|
||||
<option value="">Select</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label>Policy</label> <br />
|
||||
<select name="client_policy_id" class="form-control" id="policy" required>
|
||||
<option value="">Select</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label>Insurer/TPA Data</label> <br />
|
||||
<select name="insurer_or_tpa" class="form-control" id="insurer_or_tpa" required>
|
||||
<option value="">Select</option>
|
||||
<?php
|
||||
if(isset($insurer_or_tpa) && count($insurer_or_tpa))
|
||||
{
|
||||
foreach($insurer_or_tpa as $key => $action)
|
||||
{
|
||||
echo "<option value=".$key.">".$action."</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label>Action</label> <br />
|
||||
<select name="action_type" class="form-control" id="action_type" required>
|
||||
<option value="">Select</option>
|
||||
<?php
|
||||
if(isset($import_or_export) && count($import_or_export))
|
||||
{
|
||||
foreach($import_or_export as $key => $action)
|
||||
{
|
||||
echo "<option value=".$key.">".$action."</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label>Event</label> <br />
|
||||
<select name="event_type" class="form-control" id="upload-action-type" required>
|
||||
<option value="">Select</option>
|
||||
<?php
|
||||
if(isset($events) && count($events))
|
||||
{
|
||||
foreach($events as $key => $action)
|
||||
{
|
||||
echo "<option value=".$key.">".$action."</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<div class="form-row" id="import_excel_btn">
|
||||
<div class="form-group col-md-3">
|
||||
<label>Upload file</label>
|
||||
<input type="file" name="import_file_data" id="import_file" accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet" required>
|
||||
</div>
|
||||
<div class="d-flex align-items-center justify-content-start" style="margin-top: 18px;">
|
||||
<div class="form-group col-md-3">
|
||||
<button id="emp_form_submit_button" type="submit"
|
||||
class="btn btn-primary waves-effect waves-light justify-content-end">Upload</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row" id="export_excel_btn">
|
||||
<div class="d-flex align-items-center justify-content-start" style="margin-top: 18px;">
|
||||
<div class="form-group col-md-3">
|
||||
<button id="emp_form_submit_button_2" type="submit"
|
||||
class="btn btn-primary waves-effect waves-light justify-content-end">Download</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
// Declare a global variable to store API response data
|
||||
var clientPolicies = [];
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
<?php if (session()->has('error')): ?>
|
||||
toastr.error('<?= session()->getFlashdata('error') ?>', 'Failed');
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (session()->has('success')): ?>
|
||||
toastr.success('<?= session()->getFlashdata('success') ?>', 'success');
|
||||
<?php endif; ?>
|
||||
|
||||
$('#import_excel_btn').hide();
|
||||
$('#export_excel_btn').hide();
|
||||
|
||||
// for form submit
|
||||
$("#import_export_excel_forms").submit(function(event) {
|
||||
|
||||
var action = "<?php echo base_url().'util/import-export'?>"
|
||||
// var action = $(this).attr("action");
|
||||
event.preventDefault(); // Prevent default form submission
|
||||
console.log('submit called');
|
||||
|
||||
var isValid = $('#import_export_excel_form').parsley().validate();
|
||||
|
||||
if (!isValid) {
|
||||
console.log('Form is Empty', 'Warning');
|
||||
return;
|
||||
}
|
||||
|
||||
// Create FormData object
|
||||
var formData = new FormData($(this)[0]);
|
||||
for (var pair of formData.entries()) {
|
||||
console.log(pair[0] + ', ' + pair[1]);
|
||||
}
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
$.ajax({
|
||||
url: action,
|
||||
type: "POST",
|
||||
data: formData,
|
||||
processData: false, // Prevent jQuery from automatically processing the data
|
||||
contentType: false, // Let jQuery handle the content type
|
||||
success: function(response) {
|
||||
|
||||
console.log(response);
|
||||
if (response.code === 200 && response.status === true) {
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
$$("#import_export_excel_form")[0].reset()
|
||||
toastr.success('File Download successs', 'success');
|
||||
|
||||
} else if (response.code === 404 && response.status === false) {
|
||||
|
||||
console.error('no data found', response);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
$("#import_export_excel_form")[0].reset()
|
||||
toastr.error(response.message, 'Failed');
|
||||
|
||||
} else {
|
||||
console.error('Something went wrong!');
|
||||
toastr.error('Something went wrong! Try later', 'Error');
|
||||
// window.location.reload(true);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Request failed, handle error
|
||||
console.error("Request failed:", status, error);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
$("#import_export_excel_form")[0].reset()
|
||||
toastr.error('Something went wrong! Try later', 'Error');
|
||||
// window.location.reload(true);
|
||||
}
|
||||
});
|
||||
}); //end
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
$(window).on("load", function() {
|
||||
fetchClientPolicies2();
|
||||
});
|
||||
|
||||
|
||||
function fetchClientPolicies2() {
|
||||
|
||||
$('#loader').show();
|
||||
|
||||
var apiURL = '<?php echo base_url();?>' + 'util/clients-with-policies';
|
||||
$.ajax({
|
||||
url: apiURL,
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
},
|
||||
success: function(response) {
|
||||
// console.log(response.code);
|
||||
// console.log(response.dataStatus);
|
||||
// console.log(response.data);
|
||||
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||||
try {
|
||||
clientPolicies = (response.data);
|
||||
console.log(clientPolicies);
|
||||
appendClients2(clientPolicies);
|
||||
} catch (error) {
|
||||
console.error('Error parsing API response data:', error);
|
||||
}
|
||||
} else if (response.code === 404 && response.dataStatus === false) {
|
||||
console.error('no data found', response);
|
||||
} else {
|
||||
console.error('Something went wrong!');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error fetching data from API:', error);
|
||||
}
|
||||
});
|
||||
|
||||
$('#loader').hide();
|
||||
}
|
||||
|
||||
|
||||
function appendClients2(data) {
|
||||
$.each(data, function(index, item) {
|
||||
$('#client').append($('<option>', {
|
||||
value: item.id,
|
||||
text: item.client_name
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
function appendPolicies2(data) {
|
||||
$('#policy').empty();
|
||||
$('#policy').append($('<option>', {
|
||||
value: '',
|
||||
text: 'Select'
|
||||
}));
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
$('#policy').append($('<option>', {
|
||||
value: item.id,
|
||||
text: item.name
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
$('#client').on('change', function() {
|
||||
var selectedClient = $(this).val();
|
||||
console.log(selectedClient);
|
||||
// $('#selectedOptionInfo').text('Selected option: ' + selectedOption);
|
||||
|
||||
// Check if the selected option exists in apiData
|
||||
var foundPolicies = clientPolicies.find(function(item) {
|
||||
return item.id === selectedClient;
|
||||
});
|
||||
console.log(foundPolicies.policies);
|
||||
appendPolicies2(foundPolicies.policies);
|
||||
});
|
||||
|
||||
// Function to convert object to query parameters
|
||||
function objectToQueryString2(obj) {
|
||||
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
|
||||
}
|
||||
|
||||
function fetchEmpolyeeList2(event) {
|
||||
event.preventDefault(); // Prevent default action
|
||||
|
||||
var client_id = $('#client').val();
|
||||
var policy_id = $('#policy').val();
|
||||
console.log(client_id + '-' + policy_id);
|
||||
if (client_id == '0' || policy_id == '0') {
|
||||
alert('Please select values in both dropdowns.');
|
||||
return;
|
||||
}
|
||||
|
||||
var queryParams = {
|
||||
client_id: client_id,
|
||||
policy_id: policy_id
|
||||
};
|
||||
|
||||
const queryString = objectToQueryString2(queryParams);
|
||||
const apiURL = $('#get-emp-list').attr('href') + "?" + queryString;
|
||||
console.log(apiURL);
|
||||
window.location.href = apiURL;
|
||||
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
$('#action_type').change(function() {
|
||||
|
||||
var selectedValue = $(this).val();
|
||||
console.log(selectedValue);
|
||||
|
||||
if (selectedValue == '') {
|
||||
$('#import_excel_btn').hide();
|
||||
$('#export_excel_btn').hide();
|
||||
} else if (selectedValue == 'import') {
|
||||
$('#import_file').prop('required', true);
|
||||
$('#import_file').attr('name', 'import_file_data');
|
||||
$('#import_excel_btn').show();
|
||||
$('#export_excel_btn').hide();
|
||||
} else if (selectedValue == 'export') {
|
||||
$('#import_file').removeAttr('name');
|
||||
$('#import_file').prop('required', false);
|
||||
$('#import_excel_btn').hide();
|
||||
$('#export_excel_btn').show();
|
||||
}
|
||||
});
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
</script>
|
||||
@ -43,10 +43,6 @@
|
||||
<link href="<?= base_url()."public"; ?>/assets/css/jodit.css" rel="stylesheet" type="text/css" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- JQuery CDN -->
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
|
||||
|
||||
BIN
public/sample_excel/inception.xls
Normal file
BIN
public/sample_excel/inception.xls
Normal file
Binary file not shown.
BIN
public/sample_excel/inception_1.xls
Normal file
BIN
public/sample_excel/inception_1.xls
Normal file
Binary file not shown.
BIN
public/sample_excel/inception_2.xls
Normal file
BIN
public/sample_excel/inception_2.xls
Normal file
Binary file not shown.
BIN
public/sample_excel/inception_3.xls
Normal file
BIN
public/sample_excel/inception_3.xls
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user