FEAT_DMS_GDRIVE,PAYMENT_DELETE

This commit is contained in:
velz 2024-09-24 14:06:43 +05:30
parent 66332dd590
commit 7f7c6f6384
14 changed files with 1124 additions and 86 deletions

View File

@ -322,16 +322,26 @@ $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
$routes->post("upload", "PolicyTransactionController::uploadInsurerStatement");
$routes->get("getPaymentDetails/(:any)", "PolicyTransactionController::getInvoicePaymentDetails/$1");
$routes->post("saveInvoicePaymentDetails", "PolicyTransactionController::saveInvoicePaymentDetails");
$routes->get("deletePaymentEntry/(:any)", "PolicyTransactionController::deletePaymentEntry/$1");
$routes->get("downloadSampleInsurerStatement", "PolicyTransactionController::downloadSampleInsurerStatement");
$routes->get("getFileErr/(:any)", "PolicyTransactionController::getFileErr/$1");
});
});
$routes->get("driveListFiles", "GoogleDriveController::listFiles");
$routes->post('dmsSearch', 'PolicyTransactionController::dmsSearch', ['filter' => 'authMVC']);
$routes->get('dmsSearch', 'PolicyTransactionController::dmsSearch', ['filter' => 'authMVC']);
$routes->get('downloadGdriveFile', 'GoogleDriveController::downloadGdriveFile', ['filter' => 'authMVC']);
$routes->cli('cli/processjob', 'JobWorker::processJob');
$routes->cli('cli/processjobs', 'JobWorker::processJobs');
$routes->cli('cli/enrollment_status', 'JobWorker::enrollment_status');
$routes->get("processjob", "JobWorker::processJob");
$routes->cli('cli/new_gmail_token', 'MasterController::generateNewGmailAPIToken');
$routes->cli('cli/send_mail_cli', 'MasterController::testGmailAPIViaCLI');
$routes->cli('cli/send_mail_cli(/:any)?', 'MasterController::testGmailAPIViaCLI$1');
$routes->cli('cli/app_check_list', 'MasterController::appCheckList');
$routes->cli('cli/new_gdrive_token', 'GoogleDriveController::generateNewGoogleDriveAccessToken');

View File

@ -6,6 +6,7 @@ use CodeIgniter\Config\BaseService;
use App\Libraries\Slug;
use App\Libraries\MyLogger;
use App\Libraries\GmailAPI;
use App\Libraries\MyGoogleDrive;
use App\Libraries\DataServiceSqlite;
use App\Controllers\Home;
@ -70,5 +71,14 @@ class Services extends BaseService
return new GmailAPI();
}
public static function myGoogleDrive($getShared = true)
{
if ($getShared) {
return static::getSharedInstance('myGoogleDrive');
}
return new MyGoogleDrive();
}
}

View File

@ -0,0 +1,355 @@
<?php
namespace App\Controllers;
use App\Models\ClientModel;
use App\Models\ClientPolicyModel;
use Google_Service_Drive_DriveFile;
use Kint;
class GoogleDriveController extends BaseController
{
protected $clientModel;
protected $clientPolicyModel;
protected $googleDrive;
protected $driveService;
protected $cache;
public function __construct()
{
$this->clientModel = new ClientModel();
$this->clientPolicyModel = new ClientPolicyModel();
$this->googleDrive = \Config\Services::myGoogleDrive();
$this->driveService = $this->googleDrive->getDriveService();
$this->cache = \Config\Services::cache(); // Load the cache service
}
public function listFiles()
{
// dd($this->getClientFolderIds(client_id : 18));
$file_path = WRITEPATH.'uploads/client_kyc_documents/nhance_bpf.pdf';
// dd($file_path);
// dd($this->uploadFiletoGdrive(client_id : 18,doc_type:'KYC',file_path:$file_path,file_name:"dummy.pdf"));
dd( $this->uploadFiletoGdrive(client_id: 12, doc_type: 'KYC', file_path: $file_path, file_name: "dummy.pdf"));
$session = \Config\Services::session();
$fileName = $request->getVar('filename');
$fileType = $request->getVar('filetype');
$userAccess = $session->get('userEmail');
$parentFolderID = '1M0GH3GbNUOYZLNeHXA5U7C_P2NSx7F7O';
$searchQuery = '';//"'your-folder-id' in parents"
try {
// $driveService = $this->googleDrive->getDriveService();
$searchQuery = "name contains 'test' and 'vitvelz@gmail.com' in readers";
// Query to list files
$response = $this->driveService->files->listFiles([
'q' => $searchQuery,
'supportsAllDrives' => true,
'includeItemsFromAllDrives' => true,
'fields' => 'nextPageToken, files(id, name, mimeType, size, createdTime, modifiedTime, owners, shared, permissions, webViewLink, thumbnailLink)',
'pageSize' => 20,
]);
$files = $response->getFiles();
if (empty($files)) {
echo "No files found.";
} else {
foreach ($files as $file) {
echo "File Name: " . $file->getName() . " | File ID: " . $file->getId() . "<br>";
}
}
} catch (\Exception $e) {
return $this->response->setStatusCode(500)->setBody($e->getMessage());
}
}
//by file id
public function downloadFile(string $fileId = '',string $fileName = '',string $mimeType = '',string $fileSize = '')
{
// dd($fileName);
try {
if($fileName == '' && $mimeType == '')
{
// Get file metadata
$file = $this->driveService->files->get($fileId, ['fields' => 'name, mimeType,size']);
$fileName = $file->getName();
$mimeType = $file->getMimeType();
$fileSize = $file->getSize();
}
// Download the file content from Google Drive
$response = $this->driveService->files->get($fileId, ['alt' => 'media']);
$fileContent = $response->getBody()->getContents();
// dd($fileContent);
$temp_file_name = WRITEPATH.'/tmp/'.date('YmdHis');
$this->cache->save('temp_gdrive_file', $temp_file_name, 300);
file_put_contents( $temp_file_name, $fileContent );
// Use CodeIgniter helper for downloading the file
return $this->response->download($temp_file_name, null)->setFileName($fileName);
} catch (\Exception $e) {
return $this->response->setStatusCode(500)->setBody($e->getMessage());
}
}
public function generateNewGoogleDriveAccessToken()
{
$this->driveService->generateNewToken();
}
public function getClientFolderIds(int $client_id = 0,int $client_policy_id = 0)
{
// Fetch client short name from the database
if($client_id)
{
//check folder ids in cahce,
$cacheKey = "client_gdrive_folderids_{$client_id}";
$folderIds = $this->cache->get($cacheKey);
// dd($folderIds);
if($folderIds !== NULL)//if available retrun from cache
{
return $folderIds;
}
//if not in cache then get it from grdrive
$client = $this->clientModel->find($client_id);
$clientShortName = $client['short_name']; // Assuming short_name is the column for client's short name
}
else if($client_policy_id)
{
$cacheKey = "client_policy_gdrive_folderids_{$client_policy_id}";
$folderIds = $this->cache->get($cacheKey);
// dd($folderIds);
if($folderIds !== NULL)//if available retrun from cache
{
return $folderIds;
}
$client = $this->clientPolicyModel->select('c.short_name,pt.policy_type,client_policy.policy_no')
->join('clients c','client_policy.client_id = c.id')
->join('policy_type pt','client_policy.policy_type_id = pt.id')
->where('client_policy.id',$client_policy_id)
->get()->getResultarray();
// dd($client);
$clientShortName = $client[0]['short_name'];
$policyFolderName = $client[0]['policy_type'].'-'.$client[0]['policy_no'];
}
else
{
return [];
}
// dd($policyFolderName);
// Define parent folder ID where client folders are stored
$parentFolderId = getenv('GDRIVE_ROOT_FOLDER_ID');; // Replace with your specific folder ID
// Check if the client folder exists in GDrive, if not create one
$clientFolderId = $this->checkOrCreateFolder($clientShortName, $parentFolderId);
// Check or create KYC_DOCS folder inside the client folder
$kycFolderId = $this->checkOrCreateFolder('KYC_DOCS', $clientFolderId);
// Check or create POLICY_DOCS folder inside the client folder
$policyFolderId = $this->checkOrCreateFolder('POLICY_DOCS', $clientFolderId);
if($client_policy_id && (isset($policyFolderName)))
{
$clientPolicyFolderId = $this->checkOrCreateFolder($policyFolderName, $policyFolderId);
$clientPolicyUploadFolderId = $this->checkOrCreateFolder('UPLOADS', $clientPolicyFolderId);
}
// Return folder IDs in the specified format
$folderIds = [
'client_folder_id' => $clientFolderId, // example HCL,TCS
'kyc_doc_folder_id' => $kycFolderId, // KYC_DOCS inside HCL,TCS
'policy_doc_folder_id' => $policyFolderId, //POLICY_DOCS inside HCL,TCS
'client_policy_doc_folder_id' => isset($clientPolicyFolderId) ? $clientPolicyFolderId : null, //GMC-POLICY_NO inside POLICY_DOCS folder
'client_policy_uoload_doc_folder_id' => isset($clientPolicyUploadFolderId) ? $clientPolicyUploadFolderId : null, //UPLOADS folder in side GMC-POLICY_NO folder
];
// Save the folder IDs in cache for future requests
$this->cache->save($cacheKey, $folderIds, 604800); // Cache for 7 Days (3600 seconds * 24 * 7 )
return $folderIds;
}
// Method to check if a folder exists or create one if it doesn't
public function checkOrCreateFolder($folderName, $parentFolderId)
{
// Step 1: Check if the folder exists
$folderId = $this->getFolderId($folderName, $parentFolderId);
if ($folderId === null) {
// Step 2: If folder does not exist, create it
$folderId = $this->createFolder($folderName, $parentFolderId);
}
// Step 3: Return the folder ID
return $folderId;
}
// Method to get the folder ID by searching in Google Drive
private function getFolderId($folderName, $parentFolderId)
{
$query = "name = '$folderName' and mimeType = 'application/vnd.google-apps.folder' and '$parentFolderId' in parents and trashed = false";
$response = $this->driveService->files->listFiles([
'q' => $query,
'spaces' => 'drive',
'fields' => 'files(id, name)',
'pageSize' => 1,
]);
if (count($response->files) > 0) {
return $response->files[0]->id; // Return folder ID if found
}
return null; // Return null if folder doesn't exist
}
// Method to create a folder in Google Drive
private function createFolder($folderName, $parentFolderId)
{
$fileMetadata = new \Google_Service_Drive_DriveFile([
'name' => $folderName,
'mimeType' => 'application/vnd.google-apps.folder',
'parents' => [$parentFolderId]
]);
$folder = $this->driveService->files->create($fileMetadata, [
'fields' => 'id',
]);
return $folder->id; // Return the newly created folder's ID
}
// public function uploadFiletoGdrive(int $client_id = 0,int $client_policy_id = 0,string $doc_type,string
// $file_path,string $file_name)
public function uploadFiletoGdrive(int $client_id = 0, int $client_policy_id = 0, string $doc_type = '', string $file_path = '', string $file_name = '')
{
$gdriveFolderIds = $this->getClientFolderIds(client_id: $client_id,client_policy_id: $client_policy_id);
// Kint::dump($gdriveFolderIds);//die();
$parentFolderId = '';
if($client_id && $doc_type == 'KYC')
{
$parentFolderId = $gdriveFolderIds['kyc_doc_folder_id'];
}
else if($client_policy_id && $doc_type == 'POLICY')
{
$parentFolderId = $gdriveFolderIds['client_policy_doc_folder_id'];
}
else if($client_policy_id && $doc_type == 'UPLOADS')
{
$parentFolderId = $gdriveFolderIds['client_policy_uoload_doc_folder_id'];
}
if($parentFolderId == '')
{
return null;
}
// dd($parentFolderId);
$file = new \Google_Service_Drive_DriveFile([
'name' => $file_name,
'parents' => [$parentFolderId] // Specify the folder ID here
]);
$file_blob_data = file_get_contents($file_path);
$createdFile = $this->driveService->files->create($file, [
'data' => $file_blob_data,
'mimeType' => 'application/octet-stream',
'uploadType' => 'multipart',
'fields' => 'id' // Specify fields to return
]);
if($createdFile->id)
{
unlink($file_path);
}
return $createdFile->id;
}
public function downloadGdriveFile()
{
$client_id = $this->request->getGet('client_id');
$client_policy_id = $this->request->getGet('client_policy_id');
$file_type = $this->request->getGet('file_type');
$file_name = $this->request->getGet('file_name');
if(!is_numeric($client_policy_id))
$client_policy_id = 0;
else
$client_id = 0;
$gdriveFolderIds = $this->getClientFolderIds(client_id: $client_id,client_policy_id: $client_policy_id);
// dd($gdriveFolderIds);
$parentFolderId = '';
if($file_type == 'kyc')
{
$parentFolderId = $gdriveFolderIds['kyc_doc_folder_id'];
}
else if($file_type == 'policy')
{
$parentFolderId = $gdriveFolderIds['client_policy_doc_folder_id'];
}
else if($file_type == 'uploads')
{
$parentFolderId = $gdriveFolderIds['client_policy_uoload_doc_folder_id'];
}
if($parentFolderId == '')
{
return $this->response->setStatusCode(500)
->setHeader('Content-Type', 'text/html')
->setBody('<script>alert("File not found");</script>');
}
return $this->searchGdriveFileByName(parentFolderID: $parentFolderId, fileName: $file_name);
}
//search files in gdrive by parent folder id and name of the file
public function searchGdriveFileByName(string $parentFolderID,string $fileName)
{
//check exisitng temp file from cache and delete it
if($this->cache->get('temp_gdrive_file') && is_file($this->cache->get('temp_gdrive_file')))
{
unlink($this->cache->get('temp_gdrive_file'));
}
try {
$searchQuery = "'$parentFolderID' in parents and (name contains '$fileName')";
// Query to list files
$response = $this->driveService->files->listFiles([
'q' => $searchQuery,
'supportsAllDrives' => true,
'includeItemsFromAllDrives' => true,
'fields' => 'nextPageToken, files(id, name, mimeType, size)',
'pageSize' => 1,
]);
$files = $response->getFiles();
if (empty($files)) {
return $this->response->setStatusCode(500)
->setHeader('Content-Type', 'text/html')
->setBody('<script>alert("File not found");window.close();</script>');
}
else
{
//echo "File Name: " . $files[0]->getName() . " | File ID: " . $file[0]->getId() . "<br>";
// echo($files[0]->getId());
// echo 'working';
return $this->downloadFile(fileId:$files[0]->getId(),fileName:$files[0]->getName(),mimeType:$files[0]->getMimeType(),fileSize:$files[0]->getSize());
}
} catch (\Exception $e) {
return $this->response->setStatusCode(500)->setBody($e->getMessage());
}
}
}

View File

@ -31,6 +31,7 @@ use App\Models\PolicyTypeModel;
use App\Models\CDMasterModel;
use App\Models\ClientDepositModel;
use App\Models\InsurerExcelExportTemplateModel;
use App\Models\SettingsModel;
class MasterController extends AdminController
{
@ -1527,11 +1528,106 @@ class MasterController extends AdminController
//testing a sample mail from cli
public function testGmailAPIViaCLI()
public function testGmailAPIViaCLI(string $email_id = 'velmurugan.s@venbainfotech.com')
{
// print_r($email_id);die();
$gmailapi = \Config\Services::gmailapi();
$res = MailHelper::send_email(['mail' => 'velmurugan.s@venbainfotech.com', 'subject' => 'Mail Via CLI', 'message' => 'This is sample mail sent via CLI mode']);
$res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => 'This is sample mail sent via CLI mode']);
print_r($res);
}
public function appCheckList()
{
//check temprory folders in writeable and public/uploads folder
$this->checkAndCreateDirectories();
$this->checkGoogleOAuthCredentialsinDB();
$this->getCronJobsList();
}
public function checkAndCreateDirectories()
{
echo "#################### CHECKING TEMP DIRECTORIES ############################\n";
// Array of folder names and their respective paths
$folders = [
'e_card_template' => WRITEPATH . 'e_card_template/',
'uploads' => WRITEPATH . 'uploads/',
'excel' => WRITEPATH . 'uploads/excel/',
'statements' => WRITEPATH . 'uploads/statements/',
'import_excel' => WRITEPATH . 'uploads/import_excel/',
'logs' => WRITEPATH . 'uploads/logs/',
'client_kyc_documents' => WRITEPATH . 'uploads/client_kyc_documents/',
'tmp' => WRITEPATH . 'tmp/',
'e_card_imgs' => ROOTPATH . 'public/e_card_imgs',
'uploads' => ROOTPATH . 'public/uploads',
'add_image_upload' => ROOTPATH . 'public/uploads/add_image_upload/',//adverdisement images for enrollment app
'logo' => ROOTPATH . 'public/uploads/logo/',
'template_bg' => ROOTPATH . 'public/uploads/template_bg/'
];
foreach ($folders as $folderName => $folderPath) {
// Check if the folder exists
if (!is_dir($folderPath)) {
// Try to create the folder
if (mkdir($folderPath, 0777, true)) {
// Set permissions to 0777
chmod($folderPath, 0777);
echo "\nDirectory '$folderPath' created successfully with 0777 permissions.\n";
} else {
// Handle error in directory creation
echo "Failed to create directory '$folderPath'.\n";
}
} else {
echo "Directory '$folderPath' already exists.\n";
}
}
echo "################################################################\n\n";
}
public function checkGoogleOAuthCredentialsinDB()
{
$settingsModel = new SettingsModel();
$token = $settingsModel->where('id', 1)->first();
echo "################ CHECKING GMAIL OAUTH FOR EMAIL ###################\n";
if (is_array($token) && !is_null($token['gmail_api_oauth_credentials'])) {
echo "Email OAuth credentials not found in database.\n";
echo "Check the following..!\n";
echo "1. Update Gmail Oauth credentials in 'gmail_api_oauth_credentials' field in 'settings' table in JSON format.\n";
echo "2. Call this cli route to generate new access token: 'php public/index.php cli/new_gmail_token' from root of the project.\n";
echo "3. Call this cli route : 'php public/index.php cli/send_mail_cli someone@gmail.com' to send test mail to testGmailAPIViaCLI ( replace someone@gmail.com with real time mail).\n";
}
else
{
echo "Gmail OAuth for sending email is set in DB\n";
}
echo "################################################################\n\n";
}
function getCronJobsList()
{
// Execute the shell command to get cron jobs
$output = null;
$resultCode = null;
echo "#################### CHECKING CRONJOBS ############################\n";
// Use shell_exec to get cron jobs from the current user's crontab
$output = shell_exec('crontab -l 2>&1');
// Check if the command was successful
if (strpos($output, 'no crontab') !== false) {
echo "No cron jobs are set for this user.\n";
} elseif ($output) {
// Return the cron job list
echo nl2br($output);
echo "\n" ;// Convert newlines to <br> for easier HTML rendering
} else {
echo "Error retrieving cron jobs or no cron jobs set.\n";
}
echo "################################################################\n\n";
}
}

View File

@ -990,14 +990,29 @@ class PolicyTransactionController extends BaseController
// dd( $data['insurers']);
$data['insurer_statement_list'] = $this->insurerStatements
->select('insurer_statements.*,
insurers.name AS insurer_name,insurers.short_name,user_profiles.first_name,insurer_branch.branch_code
')
->join('insurers', 'insurer_statements.insurer_id = insurers.id')
->join('insurer_branch', 'insurer_statements.branch_id = insurer_branch.id')
->join('user_profiles', 'insurer_statements.created_by = user_profiles.id')
->orderBy('insurer_statements.id', 'desc')
->findAll();
->select('insurer_statements.*,
insurers.name AS insurer_name,
insurers.short_name,
user_profiles.first_name,
insurer_branch.branch_code,
(SELECT SUM(pt_co_share_details.exp_amt)
FROM pt_co_share_details
WHERE pt_co_share_details.is_active = 1
AND pt_co_share_details.statement_id = insurer_statements.id
) AS exp_inv_amt,
(SELECT SUM(inv_payment_details.inv_amt)
FROM inv_payment_details
WHERE inv_payment_details.is_active = 1
AND inv_payment_details.statement_id = insurer_statements.id
) AS received_inv_amt'
)
->join('insurers', 'insurer_statements.insurer_id = insurers.id')
->join('insurer_branch', 'insurer_statements.branch_id = insurer_branch.id')
->join('user_profiles', 'insurer_statements.created_by = user_profiles.id')
->where('insurer_statements.is_active', 1)
->orderBy('insurer_statements.id', 'DESC')
->findAll();
// dd( $data['insurer_statement_list']);
$this->loadLayout('insurer_statement_list', $data);
}
@ -1144,7 +1159,7 @@ class PolicyTransactionController extends BaseController
$line_items = count($excel_data);
// get uploaded month transactions data
$source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(month:$month,year:$year,insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']);
// Kint::dump($source_data);
// var_dump($source_data);die();
// Kint::dump($excel_data);
// check policy no,insurer and etc in DB for this month
@ -1332,7 +1347,7 @@ class PolicyTransactionController extends BaseController
// $ret_status = false;
// }
//update in DB
//$this->insurerStatements->where('id', $file_id)->set(['file_status' => $status,'reason' => json_encode($error_data)])->update();
$this->insurerStatements->where('id', $file_id)->set(['file_status' => $status,'reason' => json_encode($error_data),'invoice_status' =>'pending'])->update();
return array('status' => $ret_status, 'error_code' => $error_data['error_code'],'error_data' => $error_data['error_data']);
}
@ -1378,7 +1393,7 @@ class PolicyTransactionController extends BaseController
// $this->insurerStatements->update($hiddenStatementId, $parentData);
$this->insurerStatements->update($hiddenStatementId, $parentData);
// Process child data
$invoiceAmounts = $jsonData['invoice_amount'];
@ -1396,21 +1411,99 @@ class PolicyTransactionController extends BaseController
'inv_amt' => $invoiceAmount,
'utr_no' => $utrNo,
'received_date' => $paymentDate,
'statement_id' => $hiddenStatementId,
'id' => is_numeric($pk) ? (int)$pk : '',
'statement_id' => $hiddenStatementId
];
if($pk){ $childData['updated_by'] = get_session_userid(); }
if($pk){
$childData['updated_by'] = get_session_userid();
$childData['id'] = (int)$pk;
}
else { $childData['created_by'] = get_session_userid(); }
// print_r($childData);
// Insert or update
$this->invPaymentDetailsModel->save($childData);
print_r($this->invPaymentDetailsModel->errors());
// print_r($this->invPaymentDetailsModel->errors());
}
return $this->respond(['dataStatus' => true, 'code' => 200], 200);
//return $this->response->setJSON(['dataStatus' => 'true']);
}
public function deletePaymentEntry()
{
$payment_id = $this->request->getUri()->getSegment(4);
//echo $payment_id;
$this->invPaymentDetailsModel->update($payment_id, ['is_active' => 0]);
return $this->respond(['dataStatus' => true, 'code' => 200], 200);
}
public function downloadSampleInsurerStatement()
{
$filePath = ROOTPATH . 'public/sample_excel/insurer_stament_sample.xlsx';
// Check if the file exists
if (file_exists($filePath)) {
// Set the appropriate MIME type
$mimeType = mime_content_type($filePath);
// 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
echo view('errors/html/production');
}
}
public function getFileErr()
{
$file_id = $this->request->getUri()->getSegment(4);
$file = $this->insurerStatements->find($file_id);
return $this->respond(['dataStatus' => true, 'code' => 200,'data' => $file['reason']], 200);
}
public function dmsSearch()
{
// echo 'scbsc';die();
if ($this->request->getMethod() == 'post')
{
// $jsonData = (array)$this->request->getJSON();
$customer_id = $this->request->getPost('customer_id');
$policy_id = $this->request->getPost('policy_id');
$cus_doc_name = $this->request->getPost('cus_doc_name');
$policy_doc_name = $this->request->getPost('policy_doc_name');
$pt_files = [];
$kyc_files = [];
// print_r($jsonData);die();
if($policy_id != "")
{
//get policy docs from policy transation related tables
$pt_files = $this->PTFileModel->getPolicyDriveFilesIndex($policy_id,$policy_doc_name);
// ~dd($this->PTFileModel->getLastQuery());
// ~dd($d);
}
if($customer_id != "")
{
$kyc_files = $this->clientKYCDocsModel->getClientKYCDriveFilesIndex($customer_id,$cus_doc_name);
// dd($this->clientKYCDocsModel->getLastQuery());
// !dd($kyc_files);
}
$data['files'] = array_merge($pt_files,$kyc_files);
// dd($data['files']);
}
$data['customers'] = $this->clientModel->select('id,client_name,short_name as display_value')->where('is_active',1)->get()->getResultarray();
$data['policies'] = $this->clientPolicyModel->select("client_policy.id,client_policy.policy_no,policy_type.policy_type,concat(policy_type.policy_type,' - ',client_policy.policy_no) as display_value")
->join('policy_type','client_policy.policy_type_id = policy_type.id')
->where('client_policy.is_active',1)->get()->getResultarray();
// dd($data);
$this->loadLayout('dms_search', $data);
}
}

View File

@ -175,6 +175,6 @@ class GmailAPI
$this->storeTokenToDB($accessToken);
$this->myLogger->logme('error', 'New token generated and stored in the database.');
print 'New token generated and stored in the database.';
print 'New token generated and stored in the database.';
}
}

View File

@ -0,0 +1,131 @@
<?php
namespace App\Libraries;
use CodeIgniter\CLI\CLI;
use Google_Client;
use Google_Service_Drive;
class MyGoogleDrive
{
private $client;
private $myLogger;
public function __construct()
{
$this->myLogger = \Config\Services::mylogger();
$this->client = new Google_Client();
$this->client->setAuthConfig(ROOTPATH . 'nhance-app-google-drive.json'); // App credentials
// putenv('GOOGLE_APPLICATION_CREDENTIALS=' . ROOTPATH . 'nhance-app-google-drive.json');
$this->client->useApplicationDefaultCredentials();
$this->client->addScope(Google_Service_Drive::DRIVE); // Full access to Google Drive
}
public function getDriveService()
{
return new Google_Service_Drive($this->client);
}
// this function serve no purpose on anywhere, just for test purpose
public function listFiles(string $searchQuery = '')
{
$service = $this->getDriveService();
// $searchQuery = "name contains 'test' and 'vitvelz@gmail.com' in readers";
$searchQuery = "name contains 'test' or name contains 'new'";
// $searchQuery = "name contains 'test' and mimeType = 'application/vnd.google-apps.folder' or name contains 'new' and mimeType = 'application/vnd.ms-excel'";
// List the files
$files = $service->files->listFiles([
'q' => $searchQuery,
// 'supportsAllDrives' => true,
// 'includeItemsFromAllDrives' => true,
'fields' => 'nextPageToken, files(id, name, mimeType, size, createdTime, modifiedTime, owners, shared, permissions, webViewLink, thumbnailLink)',
'pageSize' => 20,
]);
// print_r($files);
echo "\n**************\n";
foreach ($files->getFiles() as $file) {
echo 'File ID: ' . $file->getID() . "\n";
echo 'File Name: ' . $file->getName() . "\n";
// echo 'MIME Type: ' . $file->getMimeType() . "\n";
// echo 'Size: ' . $file->getSize() . " bytes\n";
// echo 'Created Time: ' . $file->getCreatedTime() . "\n";
// echo 'Modified Time: ' . $file->getModifiedTime() . "\n";
// echo 'Owner: ' . $file->getOwners()[0]->getEmailAddress() . "\n";
// echo 'Shared: ' . ($file->getShared() ? 'Yes' : 'No') . "\n";
// echo 'Permissions: ' . json_encode($file->getPermissions()) . "\n";
// echo 'Web View Link: ' . $file->getWebViewLink() . "\n";
// echo 'Thumbnail Link: ' . $file->getThumbnailLink() . "\n";
echo 'parents: ' .$file->getParents()."\n";
echo "-----\n";
}
}
// this fucntion is not generating any new token, just for testing purpose
public function generateNewToken()
{
// $this->uploadFile();die();
$this->listFiles();die();
// dd('called');
if (!is_cli()) {
throw new \RuntimeException('This method can only be accessed via the command line.');
}
if (php_sapi_name() != 'cli') {
throw new Exception('This application must be run on the command line.');
}
$authUrl = $this->client->createAuthUrl();
CLI::write('Open the following link in your browser');
CLI::write("\n");
CLI::write($authUrl);
// printf ("Open the following link in your browser:\n%s\n", $authUrl);
CLI::write('Enter verification code: ');
// print 'Enter verification code: ';
$authCode = trim(fgets(STDIN));
$accessToken = $this->client->fetchAccessTokenWithAuthCode($authCode);
if (array_key_exists('error', $accessToken)) {
$this->myLogger->logme('error', 'Error in getting access token from authCode' . join(', ', $accessToken));
throw new \Exception(join(', ', $accessToken));
}
$this->storeToken($accessToken);
$this->myLogger->logme('error', 'New token generated and stored in the writepath for google drive.');
print 'New token generated and stored in the writepath for google drive.';
}
/**
* Upload a file to Google Drive
* this function not used in anywhere
*/
public function uploadFile($filePath = '', $fileName= '')
{
$service = $this->getDriveService();
// $file = new \Google_Service_Drive_DriveFile();
// $file->setName('tata.xlsx');
// $file->setParents('TEST');
// Create a new file metadata object
$file = new \Google_Service_Drive_DriveFile([
'name' => 'mypdf.pdf',
'parents' => ['1M0GH3GbNUOYZLNeHXA5U7C_P2NSx7F7O'] // Specify the folder ID here
]);
$data = file_get_contents('C:\Users\Venba\Desktop\nhance_bpf.pdf');
$createdFile = $service->files->create($file, [
'data' => $data,
'mimeType' => 'application/octet-stream',
'uploadType' => 'multipart',
'fields' => 'id' // Specify fields to return
]);
echo $createdFile->id;
}
}

View File

@ -27,4 +27,17 @@ class ClientKYCDocsModel extends Model
return $query;
}
public function getClientKYCDriveFilesIndex($client_id,$client_doc_name = '')
{
$query = $this->select('client_kyc_documents.client_id,client_kyc_documents.file_name, kyc_docs.file_name as doc_name,"url","client_policy_id","kyc" as file_type')
->join('kyc_docs', 'kyc_docs.id = client_kyc_documents.kyc_doc_type_id')
->where(['client_kyc_documents.client_id' => $client_id, 'client_kyc_documents.is_active' => 1])
->when($client_doc_name, function($query) use ($client_doc_name){
return $query->where("kyc_docs.file_name like '%$client_doc_name%'");
})
->get()
->getResultArray();
return $query;
}
}

View File

@ -96,6 +96,7 @@ class PTCOShareDetailsModel extends Model
->where('YEAR(pt.created_at)', $year)
->where('pt_co.insurer_id', $insurer_id)
->where('pt_co.insurer_branch_id', $insurer_branch_id)
->where('pt_co.statement_id is null')
// ->where('pt_co.exp_amt', 0.00)
// ->orWhere('pt_co.exp_amt is null')
->get()

View File

@ -25,5 +25,18 @@ class PTFileModel extends Model
];
public function getPolicyDriveFilesIndex($policy_id,$policy_doc_name)
{
$clients = $this->select('pt_files.doc_name,pt_files.file_name,pt_files.url,pt.client_id,pt.client_policy_id,"policy" as file_type')
->join('policy_transaction pt', 'pt_files.pt_id = pt.id')
->where('pt.client_policy_id', $policy_id)
->where('pt.is_active',1)
->when($policy_doc_name, function($query) use ($policy_doc_name){
return $query->where("pt_files.doc_name like '%$policy_doc_name%'");
})
->get()
->getResultArray();
return $clients;
}
}

225
app/Views/dms_search.php Normal file
View File

@ -0,0 +1,225 @@
<style>
.col-12 {
max-width: 98% !important;
}
.autocomplete-suggestions {
border: 1px solid #d4d4d4;
max-height: 150px;
overflow-y: auto;
position: absolute;
background-color: white;
width: inherit;
z-index: 1;
}
.autocomplete-suggestion {
padding: 8px;
cursor: pointer;
}
.autocomplete-suggestion:hover {
background-color: #e9e9e9;
}
</style>
<div class="row">
<div class="col-12" style="margin-top: -12px;">
<div id="accordion" class="mb-3">
<div class="card mb-1">
<h5 class="m-1">
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne"
aria-expanded="true">
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
</a>
</h5>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
<div class="form-group">
<form method="post" action="<?= base_url("/dmsSearch");?>" id='dms_search_form'>
<div class="form-row">
<div class="form-group col-md-2">
<label for="customer">Customer</label>
<!-- <div style="position:relative;"> -->
<input type="text" class="form-control" id="customer" placeholder="Enter customer name">
<input type="hidden" name="customer_id" class="form-control" id="customer_id" placeholder="Enter customer name">
<div id="customer_suggestions" class="autocomplete-suggestions" style="display:none;"></div>
<!-- </div> -->
</div>
<div class="form-group col-md-2">
<label for="customer">Customer document name</label>
<!-- <div style="position:relative;"> -->
<input type="text" name="cus_doc_name" class="form-control" id="cus_doc_name" placeholder="Enter customer doc name ">
<!-- </div> -->
</div>
<div class="form-group col-md-1" style="text-align: center;">
OR
</div>
<div class="form-group col-md-3">
<label for="customer">Policy</label>
<!-- <div style="position:relative;"> -->
<input type="text" class="form-control" id="policy" placeholder="Enter policy no">
<input type="hidden" name="policy_id" class="form-control" id="policy_id" placeholder="Enter policy no">
<div id="policy_suggestions" class="autocomplete-suggestions" style="display:none;"></div>
<!-- </div> -->
</div>
<div class="form-group col-md-3">
<label for="customer">Policy document name</label>
<!-- <div style="position:relative;"> -->
<input type="text" name="policy_doc_name" class="form-control" id="policy_doc_name" placeholder="Enter policy doc name ">
<!-- </div> -->
</div>
</div>
<div class="form-group text-right m-b-0">
<button type="button" class="btn btn-secondary" id="clear-filters">Clear</button>
<input type="submit" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="fetchFileList(event);" value="submit">
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- end page title -->
<div class="col-12" id="second_page">
<div class="card">
<div class="card-body">
<div class="row" style="padding-bottom: 10px;">
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">File search result</h4>
</div>
</div>
<div class="table-responsive" style="overflow-x: auto;">
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="bg-light">
<tr>
<th>S.No</th>
<th>Doc name</th>
<th>File name</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php if (isset($files)) { ?>
<?php foreach($files as $index => $row){ ?>
<tr>
<td><?= $index + 1 ?></td>
<td><?php echo $row['doc_name']; ?></td>
<td><?php echo $row['file_name']; ?></td>
<td>
<a id="download_1"
data-id="1"
class="fa fa-download"
style="font-size: 18px;"
target="_blank"
href="<?= base_url("/downloadGdriveFile?client_id=" . $row['client_id'] . "&file_type=" . $row['file_type'] . "&file_name=" . $row['file_name']."&client_policy_id=".$row['client_policy_id']); ?>">
</a>
</td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
<div>
</div>
</div>
</div><!-- end col -->
</div>
</div>
<script>
$(document).ready(function() {
// $('#client_id').select2();
// $('#insurer_id').select2();
// $('#policy_type_id').select2();
const customer_suggestions = <?php echo json_encode($customers); ?>;
const policy_suggestions = <?php echo json_encode($policies); ?>;
showSuggestions('customer','customer_suggestions','customer_id',customer_suggestions);
showSuggestions('policy','policy_suggestions','policy_id',policy_suggestions);
})
function showSuggestions(inputID, suggestionBoxID,hiddenInputID,suggestions) {
// console.log('showSuggestions');
// console.log(suggestions);return;
const input = document.getElementById(inputID);
const suggestionBox = document.getElementById(suggestionBoxID);
const hiddenInput = document.getElementById(hiddenInputID);
input.addEventListener('input', function() {
const value = this.value.toLowerCase();
suggestionBox.innerHTML = ''; // Clear previous suggestions
if (value) {
const filteredSuggestions = suggestions.filter(item =>
item.display_value.toLowerCase().includes(value)
);
// console.log(filteredSuggestions);
filteredSuggestions.forEach(suggestion => {
const suggestionItem = document.createElement('div');
suggestionItem.textContent = suggestion.display_value;
suggestionItem.classList.add('autocomplete-suggestion');
suggestionItem.addEventListener('click', function() {
input.value = suggestion.display_value; // Display value in input
hiddenInput.value = suggestion.id; // Store id in hidden input
suggestionBox.innerHTML = ''; // Clear suggestions after selecting
suggestionBox.style.display = 'none';
});
suggestionBox.appendChild(suggestionItem);
suggestionBox.style.display = 'block';
});
}
});
}
function fetchFileList(event)
{
event.preventDefault();
var customer = document.getElementById('customer').value;
var customer_id = document.getElementById('customer_id').value;
var policy = document.getElementById('policy').value;
var policy_id = document.getElementById('policy_id').value;
var cus_doc_name = document.getElementById('cus_doc_name').value;
var policy_doc_name = document.getElementById('policy_doc_name').value;
if(customer == '' && cus_doc_name != '')
{
alert('choose customer');return false;
}
if(policy == '' && policy_doc_name != '')
{
alert('choose policy');return false;
}
if(policy == '' && customer == '')
{
alert('choose customer or policy');return false;
}
console.log('called');
let customEvent = new CustomEvent('fetchFileListCustomEvent');
$('#dms_search_form').submit();
}
</script>

View File

@ -128,8 +128,10 @@ table.dataTable tbody td {
<th></th>
<th><div class="column-header">Insurer</div></th>
<th><div class="column-header">Month</div></th>
<th><div class="column-header">Statement</div></th>
<th><div class="column-header">Line Items</div></th>
<th><div class="column-header">Filename</div></th>
<th><div class="column-header">Line<br>items</div></th>
<th><div class="column-header">File<br>status</div></th>
<th><div class="column-header">Invoice<br>status</div></th>
<th><div class="column-header">User/Time</div></th>
<th><div class="column-header">Action</div></th>
</tr>
@ -143,13 +145,32 @@ table.dataTable tbody td {
<td><?php echo change_date_format($row['month'],'Y-m-d','M-Y'); ?></td>
<td><?php echo $row['file_name'] ?> </td>
<td><?php echo $row['line_items'] ?></td>
<td><?php echo $row['file_status'];
if($row['file_status'] == 'failed')
{
echo " <span class='col-xl-3 col-lg-4 col-sm-6'> <i class='fe-alert-circle' data-toggle='modal' data-target='#file-err-modal' data-err=" . $row['id'] . "></i></span>";
}
?>
</td>
<td><?php echo (isset($invoice_status_array[ $row['invoice_status'] ]) ? $invoice_status_array[ $row['invoice_status'] ] : ' - ') ?>
<span class="col-xl-3 col-lg-4 col-sm-6">
<i class="fe-alert-circle"
data-toggle="tooltip"
data-placement="right"
title="<?php echo 'Exp Invoice Amt: ' . (isset($row['exp_inv_amt']) ? $row['exp_inv_amt'] : '0.00' ) . ' Received Invoice Amt: ' . (isset($row['received_inv_amt']) ? $row['received_inv_amt'] : '0.00') ; ?>"
data-original-title="Tooltip on right">
</i>
</span>
</td>
<td><?php echo change_date_format($row['created_at'],'Y-m-d H:i:s','d M Y h:i a').' by <br>'.$row['first_name'] ?></td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" onclick="showInvoiceStatusModal(event)">
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" data-exp-amt="<?= $row['exp_inv_amt'];?>" data-received-amt="<?= $row['received_inv_amt'];?>" onclick="showInvoiceStatusModal(event)">
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Invoice status
</a>
</div>
@ -167,57 +188,6 @@ table.dataTable tbody td {
</div>
<!-- end table row -->
<!-- CD No form content modal-->
<div class="modal fade" id="cd_form_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="title">Add CD Account Number</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body p-4">
<div class="">
<form role="form" class="parsley-examples" method="post" id="CDMasterForm" enctype="multipart/form-data">
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-12">
<label for="email">Opening Date<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="opening_date" id="opening_date" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="mobile">CD Account Number<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="cd_ac_no_data" name="cd_ac_no" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="mobile">Opening Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="opening_bal" name="opening_bal" onkeypress="return onlyNumbers(event)" required>
</div>
</div>
</div>
<div class="form-group text-right m-b-0">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
id="btnSubmit">Submit</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="file_upload" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
@ -251,7 +221,7 @@ table.dataTable tbody td {
<input type="date" class="form-control" id="statement_month" name="statement_month" placeholder="Enter Invoice Number" required>
</div>
<div class="form-group col-md-12" >
<label for="statment">Statement </label>
<label for="statment">Statement </label> <span><a href="downloadSampleInsurerStatement" id="download_sample_file" style="font-size: small;">Download sample file</a></span>
<input type="file" class="form-control" name="statement" required accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet">
</div>
@ -268,6 +238,21 @@ table.dataTable tbody td {
</div>
</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 -->
<!-- Invoice status content modal-->
<div class="modal fade" id="invoice_modal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
@ -283,7 +268,7 @@ table.dataTable tbody td {
<div class="form-group">
<div class="row">
<div class="form-group col-md-6">
<div class="form-group col-md-4">
<label for="addon_policy">Invoice Status <span class="text-danger">*</span></label>
<select class="form-control" id="invoice_status" name="invoice_status" required>
<option value="" selected>Select Invoice Status</option>
@ -296,6 +281,14 @@ table.dataTable tbody td {
?>
</select>
<input type="hidden" id="hidden_statement_id" name="hidden_statement_id">
</div>
<div class="form-group col-md-4">
<label for="addon_policy">Exp Amount</label>
<input type="text" class="form-control" id="modal_exp_amt" placeholder="Enter Invoice Number" disabled>
</div>
<div class="form-group col-md-4">
<label for="addon_policy">Received Amount</label>
<input type="text" class="form-control" id="modal_received_amt" placeholder="Enter Invoice Number" disabled>
</div>
</div>
@ -331,7 +324,7 @@ table.dataTable tbody td {
<tbody>
<tr>
<td style="display: none;"><input type="hidden" class="form-control" name="pk[]" placeholder="Enter Amount"></td>
<td><input type="number" class="form-control" name="invoice_amount[]" placeholder="Enter Amount" required></td>
<td><input type="number" class="form-control" name="invoice_amount[]" placeholder="Enter Amount" required onchange="checkInvAmont(event)"></td>
<td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" required></td>
<td><input type="date" class="form-control" name="payment_date[]" value="<?php echo date('Y-m-d'); ?>" required></td>
<td><i class="fa fa-trash mr-2 font-18 vertical-middle text-danger remove-row" style="text-align: center;"></i></td>
@ -344,7 +337,7 @@ table.dataTable tbody td {
<div class="form-group text-right m-b-0">
<!-- <button type="button" id="add_row_btn" class="btn btn-primary waves-effect waves-light mr-1">Add payment</button> -->
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnSubmit">Submit</button>
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnSubmit">Save</button>
</div>
</form>
</div>
@ -406,6 +399,21 @@ table.dataTable tbody td {
$(document).ready(function () {
$('#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);
});
$('#invoiceForm').on('submit', function (e) {
e.preventDefault(); // Prevent default form submission
var form = document.getElementById('invoiceForm');
@ -448,8 +456,8 @@ table.dataTable tbody td {
success: function (response) {
console.log(response);
// Close the modal
// var myModal = new bootstrap.Modal(document.getElementById('invoice_modal'));
// myModal.hide();
var myModal = new bootstrap.Modal(document.getElementById('invoice_modal'));
myModal.hide();
// Reset the form data
$('#invoiceForm')[0].reset();
@ -476,7 +484,7 @@ table.dataTable tbody td {
newRow.innerHTML = `
<td style="display: none;"><input type="hidden" class="form-control" name="pk[]" placeholder="Enter Amount"></td>
<td><input type="number" class="form-control" name="invoice_amount[]" placeholder="Enter Amount" required></td>
<td><input type="number" class="form-control" name="invoice_amount[]" placeholder="Enter Amount" onchange="checkInvAmont(event)" required></td>
<td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" required></td>
<td><input type="date" class="form-control" value="<?php echo date('Y-m-d'); ?>" name="payment_date[]" placeholder="Enter UTR No" required></td>
<td><i class="fa fa-trash mr-2 font-18 vertical-middle text-danger remove-row" style="text-align: center;"></i></td>
@ -498,13 +506,15 @@ table.dataTable tbody td {
} else {
// If pk is non-empty, send AJAX request to remove it from the backend
$.ajax({
url: '/delete-entry', // Your backend URL here
type: 'POST',
data: { pk: pk }, // Send the pk value to delete on server-side
url: 'deletePaymentEntry/'+pk, // Your backend URL here
type: 'GET',
// data: { pk: pk }, // Send the pk value to delete on server-side
success: function (response) {
// On success, remove the row
if (response.success) {
console.log(response);
if (response.dataStatus) {
row.remove();
alert('Payment deleted successfully.');
} else {
alert('Failed to delete the entry.');
}
@ -562,8 +572,12 @@ function showInvoiceStatusModal(event)
{
// console.log(event.target.data)
var dataId = event.target.getAttribute('data-id');
var dataExpAmt = event.target.getAttribute('data-exp-amt');
var dataReceivedAmt = event.target.getAttribute('data-received-amt');
// Set the value to a hidden input field in the modal
document.getElementById('hidden_statement_id').value = dataId;
document.getElementById('modal_exp_amt').value = dataExpAmt;
document.getElementById('modal_received_amt').value = dataReceivedAmt;
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
// AJAX call to get the invoice details based on data-id
@ -602,7 +616,7 @@ function showInvoiceStatusModal(event)
var row = paymentTableBody.insertRow();
row.innerHTML = `
<td style="display: none;"><input type="hidden" class="form-control" name="pk[]" value="${payment.id}"></td>
<td><input type="number" class="form-control" name="invoice_amount[]" placeholder="Enter Amount" value="${payment.inv_amt}" required></td>
<td><input type="number" class="form-control" name="invoice_amount[]" placeholder="Enter Amount" value="${payment.inv_amt}" onchange="checkInvAmont(event)" required></td>
<td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" value="${payment.utr_no}" required></td>
<td><input type="date" class="form-control" name="payment_date[]" value="${payment.received_date}" required></td>
<td><i class="fa fa-trash mr-2 font-18 vertical-middle text-danger remove-row" style="text-align: center;"></i></td>
@ -705,4 +719,65 @@ $(document).ready(function(){
$('.loader-mask').delay(10).fadeOut('slow');
});
function fetchFileError(file_id) {
$('#loader').show();
var apiURL = 'getFileErr/' + file_id;
// console.log('fetchFileError');
// console.log(apiURL);
$.ajax({
url: apiURL,
method: 'GET',
headers: {
"X-Requested-With": "XMLHttpRequest"
},
success: function(response) {
console.log(response);
$(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 = "";
if (file_error_data['error_code'] == 1) {
file_error_html += 'The following row no(s) from excel are <span style="font-weight:bold">either already mapped / not found with policy transactions / duplicates.</span>';
file_error_html += ' : ' + '<span style="font-weight:bolder">' + file_error_data['error_data'].join(',') + '</span>';
}
// 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);
}
});
$('#loader').hide();
}
function checkInvAmont(event)
{
var total = 0;
document.querySelectorAll('input[name="invoice_amount[]"]').forEach(function(el) {
let val = parseFloat(el.value) || 0;
total += val;
});
var exp_amt = document.getElementById('modal_exp_amt').value;
if(exp_amt < total)
{
alert('Exceeds expected amt');
event.target.value = '';
}
}
</script>

View File

@ -673,6 +673,9 @@
<li>
<a href="<?= base_url('/policy_tranction/statement/list') ?>">Statement upload</a>
</li>
<li>
<a href="<?= base_url('/dmsSearch') ?>">DMS Search</a>
</li>
</ul>
</div>
</li>

View File

@ -0,0 +1,13 @@
{
"type": "service_account",
"project_id": "nhance-app-4fedb",
"private_key_id": "e764472bb4a0c9226d172f7aebdd2eb785c5fca8",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCzyKk6yQqLZHnL\n8+qRwMHtIhV3kR6bYuCol7LTU/aRyTZpFafewJ/6y5bMvvHaRSaohuuTjDhp5H+w\nf7DAiWO06C/YdgZ/tv3dPM8FnkOEnwxUXVgJskK+srJ4g6zsYkT+0DNI0qMJRW5m\n0jv+HKPJ0axCAPcUZUVtraV/HFHF7pJp4oWMFD5X7Jhv7kbW3TetJofSN3SvRvr8\nyfCiVGzqgF0Gx0Tgd25GTMOuRXTGoTlQeDHFMm19g8YY1de0Ol9WqFey6E8e6a/h\nw8KHGdywgsI+q5yF0EIUdxKc6U9Bea25k0YnKHSCsJjJTVlKW+xlxR6wA1yuBb66\n2dAhEzldAgMBAAECggEACEssKpb5dadVPdt+PJ2r58CueD1JfRL8i/p98hhjY9bo\niJEXSFDfI6aYFp22ZYKfWNK3wMimr5SuPIB5F6C4gn3b+y95ERPQtg/AkyDgB39M\nBjZNW4EnabAWFWlc2FJknjnd+JcmLnhoy+h/gpnKoOkbYISDFKQWJfJtRvLE/1on\nhKvnhEkO++93HZp6KPYA21BQIWt6q6gYjjjwxQIHE0Vg30bZC8ciNVaVlmOnpoKW\nlsQ3+TL+b6vDsSxez4hSqWlua7wWL6JgKvyGw6FGiDLGjvTEvVQ0cvfykCDmO5td\nWvVihTMOMXEMx+iVAUOXJLrSPOFGXxSHL9jilqCn0QKBgQDu4P64sE5T15rA+83B\neRMyQUfLru/oxyQ7pAbgRk4nwQj1mXcdD3/RpHF6jg0rt0msRjkzkqyWiJN0qsZ9\nlQY7h0I8pu8dxFhbd7LLcPaNV+OpNAokG06dBK8qhuMcZBlRfvJ3ye5L/Dk0Z7A4\nPw6/OxySns+kzfxtPdpJTNeqFQKBgQDAq2BXm+MsjqjZm2Z1LFMgZcjRLUu4ylMC\n9W3jqd35dBypcafAJ3TqhPLsx+HyWuC+GLMWohx3XGU7oZabGg1zuWAS8A4hnogZ\nk47OT3OYHDaT65HFmSAGJy1UFVvESUdiVzPqO3Xn9dYvRIw6By2b09w+kD1oxmE0\nvAh5UFAMKQKBgHg06plfxxqzzWE9lS290qYgaZOaxYla5OXKRdeIKX4hynNktab/\nDLAfUyd74i7UfhNeBxznu0fJFILKCTZazpcYGoHQ81UEX/4vPt7XSoqX5q1XzZ6b\nyzSCje8Vj6XSzVbQTg1vpSXBl7vCTdAQE0ix40/48L6bFWKXlIf8Ti59AoGAd8UR\nKuT5H6W/SSbVVlmrgyRC5eWmgMUlPV2cZj4egwevGZZRlZ3xjCgBazgGOUZNF177\nVUKJN5n0RFF68ggL/LhsBNm9ryCBsoSL7axuS0yekO2LvK4nvit0fiSY2zhCa9uR\npjY4YW3tK40NLrVvoMLe0vWPdyZ7HvEUw3UtjaECgYAMoonkNACD7EyWesAQzjpD\ntAL5ByXtFkMqMMr8ELLoDU2D5+qzb6gu0+GuYzGvxtYQHz2L+cP7yonn8IRBrAO1\njZCi2Mn1qOYecSGBnv6rotcagMALXwExkymjjVxPLiOae7A01sxSFDpqtRBww2JA\ngFsHNMpkQ1KmZu7LW0q1fg==\n-----END PRIVATE KEY-----\n",
"client_email": "only-drive-access@nhance-app-4fedb.iam.gserviceaccount.com",
"client_id": "116214376249781337850",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/only-drive-access%40nhance-app-4fedb.iam.gserviceaccount.com",
"universe_domain": "googleapis.com"
}