MERGE_CODE_MERGE : RV
This commit is contained in:
commit
8bedc1ea9c
@ -365,6 +365,8 @@ $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get("deletePaymentEntry/(:any)", "PolicyTransactionController::deletePaymentEntry/$1");
|
||||
$routes->get("downloadSampleInsurerStatement", "PolicyTransactionController::downloadSampleInsurerStatement");
|
||||
$routes->get("getFileErr/(:any)", "PolicyTransactionController::getFileErr/$1");
|
||||
$routes->get("getInsurerStatementMonth", "PolicyTransactionController::getInsurerStatementMonth");
|
||||
$routes->get("deleteStatement/(:any)", "PolicyTransactionController::deleteStatement/$1");
|
||||
});
|
||||
|
||||
});
|
||||
@ -378,6 +380,7 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1");
|
||||
$routes->get("featchLeadDataAndInsertClient/(:any)", "LeadsController::featchLeadDataAndInsertClient/$1");
|
||||
$routes->get("featchClientPolicyFromLead/(:any)", "LeadsController::featchClientPolicyFromLead/$1");
|
||||
|
||||
});
|
||||
|
||||
$routes->group("rfq", ["filter" => "authMVC"], function ($routes) {
|
||||
|
||||
@ -1328,7 +1328,7 @@ class EmployeeServiceController extends AdminController
|
||||
// }
|
||||
// dd($row[4]);
|
||||
//for emp table
|
||||
$this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'emp_status','old_value' => $data['emp_status'],'new_value' => 'deactivate','created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']);
|
||||
// $this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'emp_status','old_value' => $data['emp_status'],'new_value' => 'deactivate','created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']);
|
||||
// dd( $this->empEndorsementModel->getLastQuery());
|
||||
// $this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'change_event','old_value' => $data['change_event'],'new_value' => 'deletion','created_by' => $file['created_by'],'remarks' => 'general deletion']);
|
||||
|
||||
|
||||
@ -126,6 +126,10 @@ class JobWorker extends AdminController
|
||||
'employeesEnrollmentInsert' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmployeeServiceController',
|
||||
],
|
||||
'calculateMembersDemography' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\LeadsController',
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -4,90 +4,215 @@ namespace App\Helpers;
|
||||
use Exception;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class ExcelMergeHelper
|
||||
{
|
||||
/**
|
||||
* Merge multiple Excel files into a single spreadsheet.
|
||||
*
|
||||
* @param array $filesToMerge Array of files to merge.
|
||||
* @param string $outputPath Path to save the merged file.
|
||||
* @return bool True if merge successful, false otherwise.
|
||||
*/
|
||||
public static function mergeExcelFiles(array $filesToMerge, string $outputPath): bool
|
||||
|
||||
protected static $logger;
|
||||
|
||||
public static function initialize()
|
||||
{
|
||||
self::$logger = \Config\Services::mylogger();
|
||||
}
|
||||
public static function mergeExcelFiles(array $filesToMerge, string $outputPath)
|
||||
{
|
||||
try {
|
||||
// Validate input: If no files are provided, throw an error.
|
||||
self::initialize();
|
||||
if (empty($filesToMerge)) {
|
||||
throw new Exception("No files provided for merging");
|
||||
throw new Exception("No files provided for merging.");
|
||||
}
|
||||
|
||||
// Initialize the base spreadsheet (starting with null, will be created with the first file)
|
||||
$spreadsheet = null;
|
||||
|
||||
// Loop through the files to merge
|
||||
foreach ($filesToMerge as $filePath => $sheetsToMerge) {
|
||||
// Load the current file
|
||||
$currentSpreadsheet = IOFactory::load($filePath);
|
||||
|
||||
// Debugging: Log the number of sheets in the current file
|
||||
error_log("File: $filePath has " . $currentSpreadsheet->getSheetCount() . " sheets.");
|
||||
|
||||
// If this is the first file, initialize the base spreadsheet
|
||||
if ($spreadsheet === null) {
|
||||
$spreadsheet = $currentSpreadsheet;
|
||||
|
||||
// If specific sheets are provided for the first file, remove the others
|
||||
if (!is_null($sheetsToMerge) && !empty($sheetsToMerge)) {
|
||||
$sheetCount = $spreadsheet->getSheetCount();
|
||||
for ($i = $sheetCount - 1; $i >= 0; $i--) {
|
||||
if (!in_array($i, $sheetsToMerge)) {
|
||||
$spreadsheet->removeSheetByIndex($i);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If we are not working with the first file, we need to merge specified sheets
|
||||
if (is_null($sheetsToMerge) || empty($sheetsToMerge)) {
|
||||
// If no specific sheets, merge all sheets
|
||||
$sheetsToMerge = range(0, $currentSpreadsheet->getSheetCount() - 1);
|
||||
}
|
||||
|
||||
// Merge the specified sheets from the current file
|
||||
foreach ($sheetsToMerge as $sheetIndex) {
|
||||
// Check if sheet index is within bounds
|
||||
if ($sheetIndex < 0 || $sheetIndex >= $currentSpreadsheet->getSheetCount()) {
|
||||
throw new Exception("Invalid sheet index $sheetIndex in file $filePath");
|
||||
}
|
||||
|
||||
// Retrieve the sheet to copy
|
||||
$sheetToCopy = $currentSpreadsheet->getSheet($sheetIndex);
|
||||
|
||||
// Handle sheet name collision by renaming the sheet with a counter
|
||||
$baseName = $sheetToCopy->getTitle();
|
||||
$sheetName = $baseName;
|
||||
$counter = 1;
|
||||
while ($spreadsheet->sheetNameExists($sheetName)) {
|
||||
$sheetName = $baseName . '_merged_' . $counter;
|
||||
$counter++;
|
||||
}
|
||||
$sheetToCopy->setTitle($sheetName);
|
||||
|
||||
// Clone and add the sheet to the base spreadsheet
|
||||
$spreadsheet->addSheet(clone $sheetToCopy);
|
||||
}
|
||||
// Validate files exist and are readable
|
||||
foreach ($filesToMerge as $fileData) {
|
||||
if (!file_exists($fileData['file_path'])) {
|
||||
throw new Exception("File not found: " . $fileData['file_path']);
|
||||
}
|
||||
if (!is_readable($fileData['file_path'])) {
|
||||
throw new Exception("File not readable: " . $fileData['file_path']);
|
||||
}
|
||||
}
|
||||
|
||||
// Save the merged file
|
||||
$writer = new Xlsx($spreadsheet);
|
||||
$writer->save($outputPath);
|
||||
self::$logger->logme('error',"Creating new spreadsheet...");
|
||||
$mergedSpreadsheet = new Spreadsheet();
|
||||
$firstSheet = true;
|
||||
|
||||
foreach ($filesToMerge as $fileIndex => $fileData) {
|
||||
$filePath = $fileData['file_path'];
|
||||
$sheetsToMerge = $fileData['sheets'];
|
||||
self::$logger->logme('error',"Processing file $fileIndex: $filePath");
|
||||
|
||||
try {
|
||||
self::$logger->logme('error',"Attempting to load file: $filePath");
|
||||
$reader = IOFactory::createReaderForFile($filePath);
|
||||
$reader->setReadDataOnly(true); // This can help with memory usage
|
||||
self::$logger->logme('error',"Reader created successfully");
|
||||
|
||||
$currentSpreadsheet = $reader->load($filePath);
|
||||
self::$logger->logme('error',"File loaded successfully");
|
||||
|
||||
$sheetCount = $currentSpreadsheet->getSheetCount();
|
||||
self::$logger->logme('error',"File $filePath has $sheetCount sheets.");
|
||||
|
||||
if (empty($sheetsToMerge)) {
|
||||
$sheetsToMerge = range(0, $sheetCount - 1);
|
||||
}
|
||||
|
||||
foreach ($sheetsToMerge as $sourceSheetIndex) {
|
||||
self::$logger->logme('error',"Processing sheet index: $sourceSheetIndex");
|
||||
|
||||
if ($sourceSheetIndex < 0 || $sourceSheetIndex >= $sheetCount) {
|
||||
self::$logger->logme('error',"Invalid sheet index $sourceSheetIndex in file $filePath");
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$sourceSheet = $currentSpreadsheet->getSheet($sourceSheetIndex);
|
||||
self::$logger->logme('error',"Source sheet loaded");
|
||||
|
||||
$baseName = $sourceSheet->getTitle();
|
||||
self::$logger->logme('error',"Processing sheet: $baseName");
|
||||
|
||||
$newSheetName = $baseName;
|
||||
$counter = 1;
|
||||
|
||||
while ($mergedSpreadsheet->sheetNameExists($newSheetName)) {
|
||||
$newSheetName = $baseName . '_' . $fileIndex . '_' . $counter;
|
||||
$counter++;
|
||||
}
|
||||
self::$logger->logme('error',"New sheet name will be: $newSheetName");
|
||||
|
||||
if ($firstSheet) {
|
||||
$targetSheet = $mergedSpreadsheet->getActiveSheet();
|
||||
$targetSheet->setTitle($newSheetName);
|
||||
$firstSheet = false;
|
||||
self::$logger->logme('error',"Using first sheet");
|
||||
} else {
|
||||
$targetSheet = new Worksheet($mergedSpreadsheet, $newSheetName);
|
||||
$mergedSpreadsheet->addSheet($targetSheet);
|
||||
self::$logger->logme('error',"Created new sheet");
|
||||
}
|
||||
|
||||
self::$logger->logme('error',"Starting content copy for sheet: $newSheetName");
|
||||
self::copyWorksheetContent($sourceSheet, $targetSheet);
|
||||
self::$logger->logme('error',"Content copied successfully for sheet: $newSheetName");
|
||||
|
||||
} catch (Exception $e) {
|
||||
self::$logger->logme('error',"Error processing sheet $sourceSheetIndex: " . $e->getMessage());
|
||||
self::$logger->logme('error',"Error trace: " . $e->getTraceAsString());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Free up memory
|
||||
$currentSpreadsheet->disconnectWorksheets();
|
||||
unset($currentSpreadsheet);
|
||||
self::$logger->logme('error',"Cleaned up spreadsheet resources");
|
||||
|
||||
} catch (Exception $e) {
|
||||
self::$logger->logme('error',"Error processing file $filePath: " . $e->getMessage());
|
||||
self::$logger->logme('error',"Error trace: " . $e->getTraceAsString());
|
||||
continue;
|
||||
}
|
||||
|
||||
self::$logger->logme('error',"Current sheet names in merged spreadsheet:");
|
||||
foreach ($mergedSpreadsheet->getSheetNames() as $name) {
|
||||
self::$logger->logme('error'," - $name");
|
||||
}
|
||||
}
|
||||
|
||||
if ($mergedSpreadsheet->getSheetCount() === 0) {
|
||||
throw new Exception("No sheets were successfully merged.");
|
||||
}
|
||||
|
||||
self::$logger->logme('error',"Setting active sheet to index 0");
|
||||
$mergedSpreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
self::$logger->logme('error',"Preparing to save merged file to: $outputPath");
|
||||
|
||||
// Ensure output directory exists
|
||||
$outputDir = dirname($outputPath);
|
||||
if (!is_dir($outputDir)) {
|
||||
mkdir($outputDir, 0777, true);
|
||||
}
|
||||
|
||||
if (!is_writable($outputDir)) {
|
||||
throw new Exception("Output directory is not writable: $outputDir");
|
||||
}
|
||||
|
||||
if (ob_get_length()) {
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
self::$logger->logme('error',"Creating Excel writer");
|
||||
$writer = new Xlsx($mergedSpreadsheet);
|
||||
|
||||
self::$logger->logme('error',"Saving file...");
|
||||
$writer->save($outputPath);
|
||||
|
||||
// Free up memory
|
||||
$mergedSpreadsheet->disconnectWorksheets();
|
||||
unset($mergedSpreadsheet);
|
||||
|
||||
self::$logger->logme('error',"Merge successful. File saved at: $outputPath");
|
||||
return $outputPath;
|
||||
|
||||
return true; // Return true if merge was successful
|
||||
} catch (Exception $e) {
|
||||
// Log the error (optional) and return false on failure
|
||||
error_log("Excel Merge Error: " . $e->getMessage());
|
||||
return false;
|
||||
self::$logger->logme('error',"Excel Merge Error: " . $e->getMessage());
|
||||
self::$logger->logme('error',"Error trace: " . $e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function copyWorksheetContent($sourceSheet, $targetSheet)
|
||||
{
|
||||
try {
|
||||
self::$logger->logme('error',"Starting copyWorksheetContent");
|
||||
|
||||
// Get the highest row and column indexes
|
||||
$highestRow = $sourceSheet->getHighestRow();
|
||||
$highestColumn = $sourceSheet->getHighestColumn();
|
||||
self::$logger->logme('error',"Copying data from range A1:{$highestColumn}{$highestRow}");
|
||||
|
||||
// Copy cell values only first for better performance
|
||||
foreach ($sourceSheet->getRowIterator() as $row) {
|
||||
$cellIterator = $row->getCellIterator();
|
||||
$cellIterator->setIterateOnlyExistingCells(true);
|
||||
foreach ($cellIterator as $cell) {
|
||||
$column = $cell->getColumn();
|
||||
$rowIndex = $cell->getRow();
|
||||
$targetSheet->setCellValue($column . $rowIndex, $cell->getValue());
|
||||
}
|
||||
}
|
||||
self::$logger->logme('error',"Basic cell values copied");
|
||||
|
||||
// Copy column dimensions
|
||||
foreach ($sourceSheet->getColumnDimensions() as $columnId => $sourceDim) {
|
||||
$targetSheet->getColumnDimension($columnId)
|
||||
->setWidth($sourceDim->getWidth())
|
||||
->setVisible($sourceDim->getVisible())
|
||||
->setAutoSize($sourceDim->getAutoSize());
|
||||
}
|
||||
self::$logger->logme('error',"Column dimensions copied");
|
||||
|
||||
// Copy row dimensions
|
||||
foreach ($sourceSheet->getRowDimensions() as $rowId => $sourceDim) {
|
||||
$targetSheet->getRowDimension($rowId)
|
||||
->setRowHeight($sourceDim->getRowHeight())
|
||||
->setVisible($sourceDim->getVisible());
|
||||
}
|
||||
self::$logger->logme('error',"Row dimensions copied");
|
||||
|
||||
// Copy basic worksheet properties
|
||||
$targetSheet->setShowGridlines($sourceSheet->getShowGridlines());
|
||||
$targetSheet->setShowRowColHeaders($sourceSheet->getShowRowColHeaders());
|
||||
self::$logger->logme('error',"Worksheet properties copied");
|
||||
|
||||
} catch (Exception $e) {
|
||||
self::$logger->logme('error',"Error in copyWorksheetContent: " . $e->getMessage());
|
||||
self::$logger->logme('error',"Error trace: " . $e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
38
app/Models/COShareStmtDetailsModel.php
Normal file
38
app/Models/COShareStmtDetailsModel.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class COShareStmtDetailsModel extends Model
|
||||
{
|
||||
protected $table = 'co_share_stmt_details';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
'id',
|
||||
'co_share_id',
|
||||
'statement_id',
|
||||
'actual_bp_amt',
|
||||
'actual_tp_amt',
|
||||
'actual_tep_amt',
|
||||
'actual_bp_per',
|
||||
'actual_tp_per',
|
||||
'actual_tep_per',
|
||||
'actual_bp_brokerage_amt',
|
||||
'actual_tp_brokerage_amt',
|
||||
'actual_tep_brokerage_amt',
|
||||
'reward',
|
||||
'exp_amt',
|
||||
'variance',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'is_active'
|
||||
];
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -23,7 +23,11 @@ class InsurerStatements extends Model
|
||||
"invoice_no",
|
||||
"invoice_amount",
|
||||
"invoice_date",
|
||||
"updated_by"
|
||||
"updated_by",
|
||||
"stmt_sno",
|
||||
"gst_per",
|
||||
"gst_value",
|
||||
"invoice_value"
|
||||
|
||||
];
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@ class InvPaymentDetailsModel extends Model
|
||||
'inv_amt',
|
||||
'utr_no',
|
||||
'tds',
|
||||
'gst',
|
||||
'received_date',
|
||||
'created_by',
|
||||
'is_active',
|
||||
|
||||
@ -67,8 +67,11 @@ class PTCOShareDetailsModel extends Model
|
||||
'follower_policy_no',
|
||||
];
|
||||
|
||||
public function getNonReconcileredPolicyTransactions(string $month,string $year,string $insurer_id,string $insurer_branch_id)
|
||||
public function getNonReconcileredPolicyTransactions(string $insurer_id,string $insurer_branch_id)
|
||||
{
|
||||
$currentDate = date('Y-m-d');
|
||||
$sixMonthsAgo = date('Y-m-01', strtotime('-6 months'));
|
||||
|
||||
return $this->db->table('pt_co_share_details pt_co')
|
||||
->select('
|
||||
pt_co.id,
|
||||
@ -94,12 +97,15 @@ class PTCOShareDetailsModel extends Model
|
||||
->join('policy_transaction pt', 'pt_co.pt_id = pt.id')
|
||||
->join('clients c', 'pt.client_id = c.id')
|
||||
->where('pt_co.is_active', 1)
|
||||
->where('MONTH(pt.month)', $month)
|
||||
->where('YEAR(pt.month)', $year)
|
||||
->where('pt.is_active', 1)
|
||||
// ->where('MONTH(pt.month)', $month)
|
||||
// ->where('YEAR(pt.month)', $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.statement_id is null')
|
||||
->where('pt.status','completed')
|
||||
->where('DATE(pt.created_at) >=', $sixMonthsAgo)
|
||||
->where('DATE(pt.created_at) <=', $currentDate)
|
||||
// ->where('pt_co.exp_amt', 0.00)
|
||||
// ->orWhere('pt_co.exp_amt is null')
|
||||
->get()
|
||||
|
||||
@ -978,7 +978,7 @@ class PolicyTransactionModel extends Model
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
|
||||
public function getOutstandingReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
|
||||
public function getOutstandingReportList_OLD($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
|
||||
{
|
||||
$builder = $this->db->table('policy_transaction')
|
||||
->select("
|
||||
@ -1075,5 +1075,53 @@ class PolicyTransactionModel extends Model
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
|
||||
public function getOutstandingReportList($start_date = 0, $end_date = 0, $insurer_id = 0,$insurer_branch_id = 0)
|
||||
{
|
||||
$builder = $this->db->table('insurer_statements s')
|
||||
->select('
|
||||
s.id,
|
||||
s.insurer_id,
|
||||
s.branch_id,
|
||||
ins.short_name,
|
||||
ib.branch_name,
|
||||
s.month,
|
||||
s.line_items,
|
||||
s.stmt_sno,
|
||||
s.invoice_status,
|
||||
s.invoice_date,
|
||||
s.invoice_no,
|
||||
s.invoice_amount,
|
||||
COALESCE(SUM(p.inv_amt) + SUM(p.tds) + SUM(p.gst), 0) AS total_paid,
|
||||
(s.invoice_amount - COALESCE(SUM(p.inv_amt) + SUM(p.tds) + SUM(p.gst), 0)) AS outstanding_amount
|
||||
')
|
||||
->join('inv_payment_details p', 's.id = p.statement_id', 'left')
|
||||
->join('insurers ins', 's.insurer_id = ins.id')
|
||||
->join('insurer_branch ib', 's.branch_id = ib.id')
|
||||
->where('s.is_active', 1)
|
||||
->where('p.is_active', 1)
|
||||
->groupBy('s.id, s.invoice_no, s.invoice_date, s.invoice_amount')
|
||||
->having('outstanding_amount >', 0);
|
||||
// ->get();
|
||||
|
||||
|
||||
// Date range filtering
|
||||
if ($start_date != 0 && $end_date != 0) {
|
||||
|
||||
$builder->where('s.month >=', $start_date)
|
||||
->where('s.month <=', $end_date);
|
||||
}
|
||||
|
||||
if ($insurer_id != 0) {
|
||||
$builder->where('s.insurer_id', $insurer_id);
|
||||
}
|
||||
if ($insurer_branch_id != 0) {
|
||||
$builder->where('s.branch_id', $insurer_branch_id);
|
||||
}
|
||||
|
||||
$builder->orderBy('s.id', 'desc');
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -103,6 +103,10 @@ table.dataTable tbody td {
|
||||
.slider.round:before {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.disabled-option {
|
||||
color: gray;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="row" id="inception_list">
|
||||
@ -125,6 +129,7 @@ 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<br>sno</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>
|
||||
@ -140,6 +145,7 @@ table.dataTable tbody td {
|
||||
<td><input type="hidden" class="row-select" data-id="<?= $row['id']; ?>"></td>
|
||||
<td><?php echo $row['short_name'].'-'.$row['branch_code']; ?></td>
|
||||
<td><?php echo change_date_format($row['month'],'Y-m-d','M-Y'); ?></td>
|
||||
<td><?php echo $row['stmt_sno'] ?> </td>
|
||||
<td><?php echo $row['file_name'] ?> </td>
|
||||
<td><?php echo $row['line_items'] ?></td>
|
||||
<td><?php echo $row['file_status'];
|
||||
@ -172,6 +178,9 @@ table.dataTable tbody td {
|
||||
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" data-exp-amt="<?= $row['exp_inv_amt'];?>" data-received-amt="<?= $row['received_inv_amt'];?>" onclick="showInvoiceStatusModal(event)">
|
||||
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Invoice status
|
||||
</a>
|
||||
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>"onclick="deleteStatement(<?= $row['id'];?>)">
|
||||
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
@ -218,8 +227,24 @@ table.dataTable tbody td {
|
||||
</div>
|
||||
<div class="form-group col-md-10">
|
||||
<label for="statement_month">Statement month</label>
|
||||
<input type="text" class="form-control" id="statement_month" name="statement_month" placeholder="" required readonly>
|
||||
<input type="text" class="form-control" id="statement_month" name="statement_month" placeholder="" required readonly onchange="getStatementNo()">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-10">
|
||||
<label for="statement_no">Statement no</label>
|
||||
<select class="form-control" id="statement_no" name="statement_no" required >
|
||||
<option value="" selected>Select statement no</option>
|
||||
<?php
|
||||
$stmt_no = [1,2,3,4,5,6,7];
|
||||
if (isset($stmt_no) && count($stmt_no)) {
|
||||
foreach ($stmt_no as $key => $value) {
|
||||
echo "<option value=" . $value . ">" . $value . "</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-10" >
|
||||
<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">
|
||||
@ -255,7 +280,7 @@ table.dataTable tbody td {
|
||||
|
||||
<!-- Invoice status content modal-->
|
||||
<div class="modal fade" id="invoice_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-dialog modal-lg" style="max-width:1000px;">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="title">Update Invoice Status</h4>
|
||||
@ -286,32 +311,65 @@ table.dataTable tbody td {
|
||||
<label for="addon_policy">Exp Amount</label>
|
||||
<input type="text" class="form-control" id="modal_exp_amt" placeholder="" disabled>
|
||||
</div> -->
|
||||
<div class="form-group col-md-4" id="modal_received_amt_div">
|
||||
<label for="addon_policy">Total Received Amount</label>
|
||||
<input type="text" class="form-control" id="modal_received_amt" placeholder="" disabled>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Invoice Number and Invoice Date in same row -->
|
||||
<div class="row" id="invoice_no_div_modal" style="display: none;">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="invoice_no">Invoice Number<span id="base_danger" class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" id="invoice_no_modal" name="invoice_no" placeholder="Enter Invoice Number" required>
|
||||
<!-- <div id="invoice_no_div_modal" style="display: none;"> -->
|
||||
<div class="row" id="invoice_no_div_modal" style="display: none;">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="invoice_no">Invoice Number<span id="base_danger" class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" id="invoice_no_modal" name="invoice_no" placeholder="Enter Invoice Number" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="invoice_date">Invoice Date</label>
|
||||
<input type="text" class="form-control" id="invoice_date_modal" name="invoice_date" value="<?php echo date('Y-m-d'); ?>" readonly required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="invoice_value_modal">Invoice value<span id="base_danger" class="text-danger"></span></label>
|
||||
<input type="number" class="form-control" id="invoice_value_modal" name="invoice_value" placeholder="Enter Invoice Value" readonly>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="invoice_no">Invoice Amount<span id="base_danger" class="text-danger"></span></label>
|
||||
<input type="number" class="form-control" id="invoice_amount_no_modal" name="invoice_amount" placeholder="Enter Invoice Amt" required>
|
||||
<div class="row" id="invoice_no_div_modal2" style="display: none;">
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="gst_value_modal">GST %<span id="base_danger" class="text-danger"></span></label>
|
||||
<input type="number" class="form-control" id="gst_per_modal" name="invoice_gst_per" placeholder="Enter GST %" required onchange="calcGSTValue()">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="gst_value_modal">GST Value<span id="base_danger" class="text-danger"></span></label>
|
||||
<input type="number" class="form-control" id="gst_value_modal" name="invoice_gst" placeholder="Enter Invoice Value" required readonly step="0.01">
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="invoice_no">Invoice Amount<span id="base_danger" class="text-danger"></span></label>
|
||||
<input type="number" class="form-control" id="invoice_amount_no_modal" name="invoice_amount" placeholder="Enter Invoice Amt" required readonly step="0.01">
|
||||
</div>
|
||||
|
||||
<!-- <div class="form-group col-md-3" id="modal_received_amt_div">
|
||||
<label for="addon_policy">Total Received Amount</label>
|
||||
<input type="text" class="form-control" id="modal_received_amt" placeholder="" disabled>
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="invoice_date">Invoice Date</label>
|
||||
<input type="text" class="form-control" id="invoice_date_modal" name="invoice_date" value="<?php echo date('Y-m-d'); ?>" readonly required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" id="modal_received_amt_div">
|
||||
<div class="form-group col-md-4" >
|
||||
<label for="addon_policy">Total Received Amount</label>
|
||||
<input type="number" class="form-control" id="modal_received_amt" placeholder="" disabled>
|
||||
</div>
|
||||
</div>
|
||||
<!-- </div> -->
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Payment Received Table -->
|
||||
<div class="form-group col-md-12" style="display: none;" id="payment_table_div_modal">
|
||||
<div class="form-group col-md-12" style="display: none;" id="payment_table_div_modal" style="max-width: 800px;">
|
||||
<button type="button" id="add_row_btn" class="btn btn-secondary float-right"><i class="fa fa-plus"></i></button>
|
||||
|
||||
|
||||
@ -319,7 +377,8 @@ table.dataTable tbody td {
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="display: none;">pk</th>
|
||||
<th>Received Amount</th>
|
||||
<th>Invoice value</th>
|
||||
<th>GST</th>
|
||||
<th>TDS</th>
|
||||
<th>UTR Number</th>
|
||||
<th>Date</th>
|
||||
@ -330,6 +389,7 @@ table.dataTable tbody td {
|
||||
<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="received_amount[]" placeholder="Enter Amount" required onchange="checkInvAmont(event)"></td>
|
||||
<td><input type="number" class="form-control" name="gst_amount[]" placeholder="Enter GST" required step="0.01" onchange="checkInvAmont(event)"></td>
|
||||
<td><input type="number" class="form-control" name="tds[]" placeholder="Enter TDS" onchange="checkInvAmont(event)" required></td>
|
||||
<td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" required></td>
|
||||
<td><input type="text" class="form-control payment_date" name="payment_date[]" value="<?php echo date('d/m/Y'); ?>" placeholder="dd/mm/yyyy" required readonly></td>
|
||||
@ -358,12 +418,14 @@ table.dataTable tbody td {
|
||||
const invoiceStatus = this.value;
|
||||
console.log(invoiceStatus);
|
||||
const invoiceNoDiv = document.getElementById('invoice_no_div_modal');
|
||||
const invoiceNoDiv2 = document.getElementById('invoice_no_div_modal2');
|
||||
// const invoiceDateDiv = document.getElementById('invoice_date_div_modal');
|
||||
const paymentTableDiv = document.getElementById('payment_table_div_modal');
|
||||
const totalReceivedAmtDiv = document.getElementById('modal_received_amt_div');
|
||||
|
||||
// Hide everything initially
|
||||
invoiceNoDiv.style.display = 'none';
|
||||
invoiceNoDiv2.style.display = 'none';
|
||||
// invoiceDateDiv.style.display = 'none';
|
||||
paymentTableDiv.style.display = 'none';
|
||||
totalReceivedAmtDiv.style.display = 'none';
|
||||
@ -371,6 +433,7 @@ table.dataTable tbody td {
|
||||
// Show fields based on selected status
|
||||
if (invoiceStatus === 'generated' || invoiceStatus === 'sent') {
|
||||
invoiceNoDiv.style.display = 'flex';
|
||||
invoiceNoDiv2.style.display = 'flex';
|
||||
totalReceivedAmtDiv.style.display = 'none';
|
||||
switchRequired('invoice_no_modal',true);
|
||||
switchRequired('invoice_date_modal',true);
|
||||
@ -384,6 +447,7 @@ table.dataTable tbody td {
|
||||
// invoiceDateDiv.style.display = 'block';
|
||||
} else if (invoiceStatus === 'payment_received') {
|
||||
invoiceNoDiv.style.display = 'flex';
|
||||
invoiceNoDiv2.style.display = 'flex';
|
||||
paymentTableDiv.style.display = 'block';
|
||||
totalReceivedAmtDiv.style.display = 'block';
|
||||
switchRequired('invoice_no_modal',true);
|
||||
@ -399,6 +463,7 @@ table.dataTable tbody td {
|
||||
}else if(invoiceStatus === 'pending')
|
||||
{
|
||||
invoiceNoDiv.style.display = 'none';
|
||||
invoiceNoDiv2.style.display = 'none';
|
||||
paymentTableDiv.style.display = 'none';
|
||||
totalReceivedAmtDiv.style.display = 'none';
|
||||
// switchRequired('modal_received_amt_div',false);
|
||||
@ -435,6 +500,13 @@ table.dataTable tbody td {
|
||||
|
||||
$('#invoiceForm').on('submit', function (e) {
|
||||
e.preventDefault(); // Prevent default form submission
|
||||
|
||||
var res = checkInvAmont();
|
||||
if(!res)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var form = document.getElementById('invoiceForm');
|
||||
// alert(form.checkValidity());
|
||||
// alert($('#invoice_date_modal').val());
|
||||
@ -487,7 +559,7 @@ table.dataTable tbody td {
|
||||
|
||||
$('.close').click()
|
||||
// Reset the form data
|
||||
$('#invoiceForm')[0].reset();
|
||||
// $('#invoiceForm')[0].reset();
|
||||
|
||||
alert('Invoice updated successfully!');
|
||||
location.reload();
|
||||
@ -513,6 +585,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="received_amount[]" placeholder="Enter Amount" onchange="checkInvAmont(event)" required></td>
|
||||
<td><input type="number" class="form-control" name="gst_amount[]" placeholder="Enter GST" onchange="checkInvAmont(event)" required step="0.01"></td>
|
||||
<td><input type="number" class="form-control" name="tds[]" placeholder="Enter TDS" onchange="checkInvAmont(event)" required></td>
|
||||
<td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" required></td>
|
||||
<td><input type="text" class="form-control payment_date" value="<?php echo date('d/m/Y'); ?>" name="payment_date[]" placeholder="dd/mm/yyyy" required readonly></td>
|
||||
@ -627,6 +700,10 @@ function showInvoiceStatusModal(event)
|
||||
document.getElementById('invoice_no_modal').value = response.data.invoice_no;
|
||||
document.getElementById('invoice_date_modal').value = response.data.invoice_date === '' ? <?php echo date('d-m-Y')?> : response.data.invoice_date;
|
||||
document.getElementById('invoice_amount_no_modal').value = response.data.invoice_amount;
|
||||
|
||||
document.getElementById('invoice_value_modal').value = response.data.invoice_value;
|
||||
document.getElementById('gst_per_modal').value = response.data.gst_per;
|
||||
document.getElementById('gst_value_modal').value = response.data.gst_value;
|
||||
|
||||
if (!$('#invoice_date_modal').val()) {
|
||||
// alert('nope');
|
||||
@ -646,6 +723,7 @@ function showInvoiceStatusModal(event)
|
||||
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="received_amount[]" placeholder="Enter Amount" value="${payment.inv_amt}" onchange="checkInvAmont(event)" required></td>
|
||||
<td><input type="number" class="form-control" name="gst_amount[]" placeholder="Enter Amount" value="${payment.gst}" onchange="checkInvAmont(event)" required step="0.01"></td>
|
||||
<td><input type="number" class="form-control" name="tds[]" placeholder="Enter Amount" value="${payment.tds}" onchange="checkInvAmont(event)" required></td>
|
||||
<td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" value="${payment.utr_no}" required></td>
|
||||
<td><input type="text" class="form-control payment_date" name="payment_date[]" value="${formatDateToDMY(payment.received_date)}" required readonly></td>
|
||||
@ -730,8 +808,6 @@ maxDate.setDate(today.getDate() + 180);
|
||||
}
|
||||
|
||||
$('#btnSubmit').prop('disabled', true).text('Submitting...');
|
||||
|
||||
|
||||
// Create FormData object
|
||||
var formData = new FormData($(this)[0]);
|
||||
for (var pair of formData.entries()) {
|
||||
@ -773,6 +849,9 @@ maxDate.setDate(today.getDate() + 180);
|
||||
toastr.error('Something went wrong! Try later', 'Error');
|
||||
window.location.reload(true);
|
||||
}
|
||||
$('.close').click()
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(10).fadeOut('slow');
|
||||
|
||||
$('#btnSubmit').prop('disabled', false).text('Submit');
|
||||
|
||||
@ -782,11 +861,13 @@ maxDate.setDate(today.getDate() + 180);
|
||||
console.error("Request failed:", status, error);
|
||||
toastr.error('Something went wrong! Try later', 'Error');
|
||||
$('#uploadForm')[0].reset();
|
||||
$('.close').click()
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(10).fadeOut('slow');
|
||||
window.location.reload(true);
|
||||
}
|
||||
});
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(10).fadeOut('slow');
|
||||
|
||||
});
|
||||
|
||||
function fetchFileError(file_id) {
|
||||
@ -810,7 +891,7 @@ maxDate.setDate(today.getDate() + 180);
|
||||
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 += 'The following row no(s) from excel are <span style="font-weight:bold">not found with policy transactions / duplicates.</span>';
|
||||
file_error_html += ' : ' + '<span style="font-weight:bolder">' + file_error_data['error_data'].join(',') + '</span>';
|
||||
}
|
||||
|
||||
@ -835,19 +916,21 @@ maxDate.setDate(today.getDate() + 180);
|
||||
}
|
||||
|
||||
|
||||
function checkInvAmont(event) {
|
||||
function checkInvAmont(event = null) {
|
||||
var total = 0;
|
||||
var receivedAmounts = document.querySelectorAll('input[name="received_amount[]"]');
|
||||
var receivedGST = document.querySelectorAll('input[name="gst_amount[]"]');
|
||||
var tdsAmounts = document.querySelectorAll('input[name="tds[]"]');
|
||||
// console.log();
|
||||
receivedAmounts.forEach(function(el, index) {
|
||||
// Get the received amount
|
||||
let receivedVal = parseFloat(el.value) || 0;
|
||||
// Get the corresponding tds amount (paired with the received amount)
|
||||
let gstVal = parseFloat(receivedGST[index].value) || 0;
|
||||
let tdsVal = parseFloat(tdsAmounts[index].value) || 0;
|
||||
// Add received amount and tds amount
|
||||
// console.log();
|
||||
total += (receivedVal + tdsVal);
|
||||
total += (receivedVal + tdsVal + gstVal);
|
||||
});
|
||||
// console.log(total);
|
||||
// Get the expected invoice amount
|
||||
@ -855,9 +938,16 @@ function checkInvAmont(event) {
|
||||
|
||||
// Check if the total exceeds the expected amount
|
||||
if (exp_amt < total) {
|
||||
alert('Exceeds Invoice amount');
|
||||
event.target.value = ''; // Reset the value of the element that triggered the event
|
||||
alert('Exceeds Invoice amount...Plz adjust numbers');
|
||||
if(event != null)
|
||||
{
|
||||
event.target.value = '';
|
||||
|
||||
}
|
||||
return false; // Reset the value of the element that triggered the event
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -889,5 +979,186 @@ function switchRequired(elementId, isRequired, type = 'id') {
|
||||
}
|
||||
}
|
||||
|
||||
function getStatementNo()
|
||||
{
|
||||
var insurer_id = $('#insurer').val();
|
||||
var statement_month = $('#statement_month').val();
|
||||
|
||||
console.log(insurer_id+' / '+statement_month);
|
||||
if(insurer_id == "")
|
||||
{
|
||||
alert('Choose insurer...!');
|
||||
$('#statement_month').val('');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
var apiURL = 'getInsurerStatementMonth?insurer_id=' +insurer_id+'&month='+statement_month ;
|
||||
$.ajax({
|
||||
url: apiURL,
|
||||
type: "GET",
|
||||
headers: {
|
||||
// "Content-Type":"multipart/form-data",
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
},
|
||||
success: function(response) {
|
||||
|
||||
console.log(response);
|
||||
// $('#insurer_statement_upload_form')[0].reset();
|
||||
|
||||
if (response.code === 200 && response.dataStatus === true && response
|
||||
.data !== "") {
|
||||
|
||||
disableStatementNo(response.data)
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(10).fadeOut('slow');
|
||||
} else if (response.code === 404 && response.dataStatus === false) {
|
||||
console.error('no data found', response);
|
||||
// alert(response.message);
|
||||
// toastr.error(response.message, 'Failed');
|
||||
// window.location.reload(true);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(10).fadeOut('slow');
|
||||
} else {
|
||||
console.error('Something went wrong!');
|
||||
// alert('Something went wrong! Try later');
|
||||
toastr.error('Something went wrong! Try later', 'Error');
|
||||
// window.location.reload(true);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(10).fadeOut('slow');
|
||||
}
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Request failed, handle error
|
||||
console.error("Request failed:", status, error);
|
||||
toastr.error('Something went wrong! Try later', 'Error');
|
||||
// $('#uploadForm')[0].reset();
|
||||
// window.location.reload(true);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(10).fadeOut('slow');
|
||||
}
|
||||
});
|
||||
// $('.loader').fadeOut();
|
||||
// $('.loader-mask').delay(10).fadeOut('slow');
|
||||
|
||||
|
||||
}
|
||||
|
||||
function calcGSTValue()
|
||||
{
|
||||
// alert('calcGSTValue');
|
||||
var gst_per = document.getElementById('gst_per_modal').value;
|
||||
|
||||
var invoice_value_dom_obj = document.getElementById('invoice_value_modal');
|
||||
var invoice_value = invoice_value_dom_obj.value;
|
||||
|
||||
var gst_value_dom_obj = document.getElementById('gst_value_modal');
|
||||
var gst_value = gst_value_dom_obj.value;
|
||||
|
||||
var invoice_amount_dom_obj = document.getElementById('invoice_amount_no_modal');
|
||||
// var invoice_amount = invoice_amount_dom_obj.value();
|
||||
|
||||
gst_value_dom_obj.value = (parseFloat(gst_per) / 100 ) * invoice_value;
|
||||
invoice_amount_dom_obj.value = parseFloat(invoice_value_dom_obj.value) + parseFloat(gst_value_dom_obj.value);
|
||||
checkInvAmont();
|
||||
|
||||
|
||||
}
|
||||
|
||||
function disableStatementNo(arr)
|
||||
{
|
||||
// JavaScript array with values to disable
|
||||
// const disableValues = arr;
|
||||
const disableIds = arr.map(item => item.stmt_sno);
|
||||
console.log(disableIds);
|
||||
|
||||
// Get the select element
|
||||
const selectElement = document.getElementById("statement_no");
|
||||
// Variable to track if the first enabled option is selected
|
||||
let firstEnabledOptionSelected = false;
|
||||
// Iterate over the options in the select element
|
||||
Array.from(selectElement.options).forEach(option => {
|
||||
// If the option value is in the disableIds array, disable it
|
||||
console.log(option.value);
|
||||
option.disabled = false;
|
||||
option.style.backgroundColor = "";
|
||||
if (disableIds.includes((option.value))) {
|
||||
option.disabled = true;
|
||||
option.style.backgroundColor = "lightgray";
|
||||
}
|
||||
else if (!firstEnabledOptionSelected && option.value !== "") {
|
||||
// Automatically select the first enabled option
|
||||
option.selected = true;
|
||||
firstEnabledOptionSelected = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deleteStatement(id)
|
||||
{
|
||||
//alert(id);
|
||||
Swal.fire({
|
||||
title: "Do you want to delete statement & it's invoice data if any?",
|
||||
showCancelButton: true,
|
||||
confirmButtonText: "Delete",
|
||||
confirmButtonColor: "#ff3333",
|
||||
}).then((result) => {
|
||||
|
||||
console.log(result);
|
||||
|
||||
if (result.isConfirmed) {
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
var apiURL = 'deleteStatement/' + id;
|
||||
// console.log('Truncate API URL : ', apiURL);
|
||||
|
||||
$.ajax({
|
||||
url: apiURL,
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
},
|
||||
success: function(response) {
|
||||
// console.log('Truncate Response', response)
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(10).fadeOut('slow');
|
||||
if (response.code === 200 && response.dataStatus === true) {
|
||||
Swal.fire({
|
||||
title: "Deleted!",
|
||||
icon: "success"
|
||||
});
|
||||
window.location.reload(true);
|
||||
} else {
|
||||
Swal.fire({
|
||||
title: "Failed!",
|
||||
text: 'Something went wrong! Try later',
|
||||
icon: "error"
|
||||
});
|
||||
|
||||
window.location.reload(true);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(10).fadeOut('slow');
|
||||
console.error('Error fetching data from API:', error);
|
||||
toastr.error('Something went wrong! Try later', 'Error');
|
||||
window.location.reload(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
@ -41,7 +41,7 @@ table.dataTable tbody td {
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<!-- <div class="form-group col-md-3">
|
||||
<label for="client_branch">Client<span class="text-danger"></span></label>
|
||||
<select class="form-control" id="client_id" name="client_id">
|
||||
<option value="0">Select Client</option>
|
||||
@ -53,7 +53,7 @@ table.dataTable tbody td {
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="addon_policy"> Insurer <span id="base_danger"
|
||||
@ -69,6 +69,19 @@ table.dataTable tbody td {
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="addon_policy"> Insurer Branch<span id="base_danger"
|
||||
class="text-danger"></span></label>
|
||||
<select class="form-control" id="insurer_id" name="insurer_id">
|
||||
<option value="0" selected>Select Insurer</option>
|
||||
<?php if(isset($insurer) && count($insurer)){ ?>
|
||||
<?php foreach ($insurer as $value) { ?>
|
||||
<option value="<?= $value['id']?>"><?= $value['name']?></option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- <div class="form-group col-md-3">
|
||||
<label for="email"> Policy Type <span class="text-danger"></span></label>
|
||||
<select class="form-control" id="policy_type_id" name="policy_type_id">
|
||||
<option value="0">Select Policy Type</option>
|
||||
@ -80,9 +93,9 @@ table.dataTable tbody td {
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<!-- <div class="form-group col-md-3">
|
||||
<label for="client_branch">Issuer<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="issuer" name="issuer" required>
|
||||
<option value="0">Select Issure</option>
|
||||
@ -94,13 +107,13 @@ table.dataTable tbody td {
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
<!-- </div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-row"> -->
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<!-- <div class="form-group col-md-3">
|
||||
<label>Date Type<span class="text-danger"></span></label>
|
||||
<select class="form-control" id="date_type" name="date_type"
|
||||
onchange="hideDateField()">
|
||||
@ -113,10 +126,10 @@ table.dataTable tbody td {
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="form-group col-md-3" style="display: none;" id="date_div">
|
||||
<label>Date<span class="text-danger"></span></label>
|
||||
<div class="form-group col-md-3" style="display: true;" id="date_div">
|
||||
<label>Statement Month<span class="text-danger"></span></label>
|
||||
<div id="reportrange" class="form-control"
|
||||
style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc; width: 100%">
|
||||
<i class="fa fa-calendar"></i>
|
||||
@ -158,28 +171,36 @@ table.dataTable tbody td {
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th>S.No</th>
|
||||
<th>Client Name</th>
|
||||
<!-- <th>Client Name</th> -->
|
||||
<th>Insurer</th>
|
||||
<th>Policy</th>
|
||||
<th>Endorsement No</th>
|
||||
<th>Insurer<br> Branch</th>
|
||||
<th>Statement<br> Month</th>
|
||||
<th>Statement<br> No</th>
|
||||
<th>Invoice No</th>
|
||||
<th>Invoice Status</th>
|
||||
<th>Invoice Date</th>
|
||||
<th>Invoice Amount</th>
|
||||
<th>Realization Amount</th>
|
||||
<th>Outstanding Amount</th>
|
||||
<th>Realization <br>Amount</th>
|
||||
<th>Outstanding <br>Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (isset($outstanding_list)) { ?>
|
||||
<?php foreach($outstanding_list as $index => $row){ ?>
|
||||
<?php
|
||||
|
||||
// dd($outstanting_list);
|
||||
if (isset($outstanting_list)) { ?>
|
||||
<?php foreach($outstanting_list as $index => $row){ ?>
|
||||
<tr>
|
||||
<td><?= $index + 1 ?></td>
|
||||
<td><?php echo $row['client_name']; ?></td>
|
||||
<td><?php echo $row['insurer_name']; ?></td>
|
||||
<td><?php echo $row['policy_type'] .' - '. $row['policy_no']; ?></td>
|
||||
<td><?php echo $row['endorsement_no']; ?></td>
|
||||
<td><?php echo $row['short_name']; ?></td>
|
||||
<td><?php echo $row['branch_name']; ?></td>
|
||||
<td><?php echo change_date_format($row['month'],'Y-m-d','Y-m') ?></td>
|
||||
<td><?php echo $row['stmt_sno']; ?></td>
|
||||
<td><?php echo $row['invoice_no']; ?></td>
|
||||
<td class="center-align-input"><?php echo isset($row['invoice_status']) ? $row['invoice_status'] : ' - '; ?></td>
|
||||
<td><?php echo change_date_format($row['invoice_date'],'Y-m-d','d-M-Y'); ?></td>
|
||||
<td class="right-align-input"><?php echo isset($row['invoice_amount']) ? $row['invoice_amount'] : '0.00'; ?></td>
|
||||
<td class="right-align-input"><?php echo isset($row['realization_amount']) ? $row['realization_amount'] : '0.00'; ?></td>
|
||||
<td class="right-align-input"><?php echo isset($row['total_paid']) ? $row['total_paid'] : '0.00'; ?></td>
|
||||
<td class="right-align-input"><?php echo isset($row['outstanding_amount']) ? $row['outstanding_amount'] : '0.00'; ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
@ -364,10 +385,6 @@ $(function() {
|
||||
startDate: start,
|
||||
endDate: end,
|
||||
ranges: {
|
||||
'Today': [moment(), moment()],
|
||||
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
||||
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
||||
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month')
|
||||
.endOf('month')
|
||||
|
||||
@ -10,16 +10,28 @@ class ExcelMergeHelperTest extends TestCase
|
||||
{
|
||||
// Use the paths you provided
|
||||
$filePaths = [
|
||||
'/home/venba/Downloads/Financial_Sample.xlsx' => [1,3,2],
|
||||
'/home/venba/Downloads/enrollment.xlsx' => []
|
||||
// ['file_path' =>WRITEPATH.'uploads/lead_files/Member_Data.xlsx','sheets' => []],
|
||||
// ['file_path' =>WRITEPATH.'/tmp/RFQ_ABC_GMC_20241220140640.xlsx','sheets' => []],
|
||||
|
||||
['file_path' =>'/home/venba/Downloads/enrollment (1).xlsx','sheets' => []],
|
||||
['file_path' =>'/home/venba/Downloads/Financial_Sample.xlsx','sheets' => []],
|
||||
];
|
||||
$outputPath = '/home/venba/Documents/merged_file.xlsx'; // Output path for the merged file
|
||||
|
||||
// Call the mergeExcelFiles function
|
||||
$result = ExcelMergeHelper::mergeExcelFiles($filePaths, $outputPath);
|
||||
var_dump($result);
|
||||
var_dump($result);
|
||||
// Check if the result is true (indicating success)
|
||||
$this->assertTrue($result, 'Expected true, but got false');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// $temp_file_path = WRITEPATH.'tmp/RFQ_ABC_GMC_20241219172307.xlsx';
|
||||
// $temp_file_name = 'RFQ_ABC_GMC_20241219172307.xlsx';
|
||||
// $lead_file_path = WRITEPATH.'uploads/lead_files/Member_Data.xlsx';
|
||||
|
||||
// $filePaths = [
|
||||
// ['file_path' => $temp_file_path,'sheets' =>[]],
|
||||
// ['file_path' =>$lead_file_path ,'sheets' =>[]]
|
||||
// ];
|
||||
// $outputPath = dirname($temp_file_path).'/'.$temp_file_name.'_merged';
|
||||
|
||||
183
tests/unit/LeadsControllerTest.php
Normal file
183
tests/unit/LeadsControllerTest.php
Normal file
@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit;
|
||||
|
||||
use Exception;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use App\Controllers\LeadsController;
|
||||
|
||||
class LeadsControllerTest extends CIUnitTestCase
|
||||
{
|
||||
protected $leadsController;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->leadsController = new LeadsController();
|
||||
}
|
||||
|
||||
public function testGetDemographyDataBasicScenario()
|
||||
{
|
||||
echo('passed 0');
|
||||
// Arrange
|
||||
$members = [
|
||||
// Header row
|
||||
['Name', 'Age', 'Relationship', 'SI Enhancement'],
|
||||
// Data rows
|
||||
['John', '25', 'Self', '100000'],
|
||||
['Jane', '23', 'Spouse', '100000'],
|
||||
['Kid', '5', 'Child', '50000']
|
||||
];
|
||||
echo('passed 1');
|
||||
$age_band_data = [
|
||||
['0-17', '18-35', '36-45', 'Above 46']
|
||||
];
|
||||
echo('passed 2');
|
||||
$members_heading = ['Name', 'Age', 'Relationship', 'SI Enhancement'];
|
||||
$available_col = 'age';print_rr($available_col);
|
||||
$col_index = 1;
|
||||
echo('passed 3');
|
||||
try{
|
||||
echo('Inside try');
|
||||
// Act
|
||||
echo('passed 3.5');
|
||||
$result = $this->leadsController->getDemographyData($members,$age_band_data,$members_heading,$available_col,$col_index);
|
||||
|
||||
echo('passed 4');
|
||||
} catch (Exception $e) {
|
||||
echo "Message: " . $e->getMessage() . "\n";
|
||||
echo "File: " . $e->getFile() . "\n";
|
||||
echo "Line: " . $e->getLine() . "\n";
|
||||
// Optionally, print the full stack trace
|
||||
echo "Stack trace: " . $e->getTraceAsString() . "\n";
|
||||
}
|
||||
var_dump($result);
|
||||
// Assert
|
||||
$this->assertIsArray($result);
|
||||
$this->assertArrayHasKey('general', $result);
|
||||
$this->assertArrayHasKey('100000', $result);
|
||||
$this->assertArrayHasKey('50000', $result);
|
||||
|
||||
// Check counts for general category
|
||||
$this->assertEquals(1, $result['general']['Self']['18-35']);
|
||||
$this->assertEquals(1, $result['general']['Spouse']['18-35']);
|
||||
$this->assertEquals(1, $result['general']['Child']['0-17']);
|
||||
}
|
||||
|
||||
public function testGetDemographyDataWithDOB()
|
||||
{
|
||||
// Arrange
|
||||
$members = [
|
||||
// Header row
|
||||
['Name', 'DOB', 'Relationship', 'SI Enhancement'],
|
||||
// Data rows
|
||||
['John', '01-Jan-1995', 'Self', '100000'],
|
||||
['Jane', '01-Jan-1998', 'Spouse', '100000']
|
||||
];
|
||||
|
||||
$age_band_data = [
|
||||
['18-35', '36-45', '46+']
|
||||
];
|
||||
|
||||
$members_heading = ['Name', 'DOB', 'Relationship', 'SI Enhancement'];
|
||||
$available_col = 'dob';
|
||||
$col_index = 1;
|
||||
|
||||
// Act
|
||||
$result = $this->leadsController->getDemographyData(
|
||||
$members,
|
||||
$age_band_data,
|
||||
$members_heading,
|
||||
$available_col,
|
||||
$col_index
|
||||
);
|
||||
|
||||
// Assert
|
||||
$this->assertIsArray($result);
|
||||
$this->assertArrayHasKey('general', $result);
|
||||
$this->assertArrayHasKey('100000', $result);
|
||||
|
||||
// Both members should be in 18-35 age band
|
||||
$this->assertEquals(1, $result['general']['Self']['18-35']);
|
||||
$this->assertEquals(1, $result['general']['Spouse']['18-35']);
|
||||
}
|
||||
|
||||
public function testGetDemographyDataWithEmptyMembers()
|
||||
{
|
||||
// Arrange
|
||||
$members = [
|
||||
// Only header row
|
||||
['Name', 'Age', 'Relationship', 'SI Enhancement']
|
||||
];
|
||||
|
||||
$age_band_data = [
|
||||
['0-17', '18-35', '36-45', '46+']
|
||||
];
|
||||
|
||||
$members_heading = ['Name', 'Age', 'Relationship', 'SI Enhancement'];
|
||||
$available_col = 'age';
|
||||
$col_index = 1;
|
||||
|
||||
// Act
|
||||
$result = $this->leadsController->getDemographyData(
|
||||
$members,
|
||||
$age_band_data,
|
||||
$members_heading,
|
||||
$available_col,
|
||||
$col_index
|
||||
);
|
||||
|
||||
// Assert
|
||||
$this->assertIsArray($result);
|
||||
$this->assertArrayHasKey('general', $result);
|
||||
|
||||
// Check that all totals are zero
|
||||
$this->assertEquals(0, $result['general']['Grand Total']['Grand Total']);
|
||||
}
|
||||
|
||||
public function testGetDemographyDataWithMultipleSIBands()
|
||||
{
|
||||
// Arrange
|
||||
$members = [
|
||||
// Header row
|
||||
['Name', 'Age', 'Relationship', 'SI Enhancement'],
|
||||
// Data rows with different SI amounts
|
||||
['John', '25', 'Self', '100000'],
|
||||
['Jane', '23', 'Spouse', '200000'],
|
||||
['Kid1', '5', 'Child', '100000'],
|
||||
['Kid2', '7', 'Child', '200000']
|
||||
];
|
||||
|
||||
$age_band_data = [
|
||||
['0-17', '18-35', '36-45', '46+']
|
||||
];
|
||||
|
||||
$members_heading = ['Name', 'Age', 'Relationship', 'SI Enhancement'];
|
||||
$available_col = 'age';
|
||||
$col_index = 1;
|
||||
|
||||
// Act
|
||||
$result = $this->leadsController->getDemographyData(
|
||||
$members,
|
||||
$age_band_data,
|
||||
$members_heading,
|
||||
$available_col,
|
||||
$col_index
|
||||
);
|
||||
|
||||
// Assert
|
||||
$this->assertIsArray($result);
|
||||
$this->assertArrayHasKey('100000', $result);
|
||||
$this->assertArrayHasKey('200000', $result);
|
||||
|
||||
// Check counts for different SI bands
|
||||
$this->assertEquals(1, $result['100000']['Self']['18-35']);
|
||||
$this->assertEquals(1, $result['200000']['Spouse']['18-35']);
|
||||
$this->assertEquals(1, $result['100000']['Child']['0-17']);
|
||||
$this->assertEquals(1, $result['200000']['Child']['0-17']);
|
||||
|
||||
// Check general category totals
|
||||
$this->assertEquals(2, $result['general']['Child']['0-17']);
|
||||
$this->assertEquals(2, $result['general']['Child']['Grand Total']);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user