diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 8ad5366a..e6aca562 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -1028,6 +1028,7 @@ class EmployeeRestController extends AdminController $self['data']['basic_cover_si'] = $employee_policy->basic_cover_si; $array->mapped_family_floaters = $self; + $array->type = 'GPA'; @@ -1155,7 +1156,7 @@ class EmployeeRestController extends AdminController } $array->mapped_family_floaters = $data; - $array->type = "Group Medical Coverage"; + $array->type = "GMC"; $checkGmcParentsPolicyExist = $this->clientPolicyModel->select('client_policy.id as ClientPolicyId , client_policy.client_id as ClientId, client_policy.policy_type_id as policy_type_id, policy_type.long_name as Policy_Name , client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type , client_policy.policy_terms as Policy_Terms') ->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left') @@ -1344,7 +1345,7 @@ class EmployeeRestController extends AdminController } $array->mapped_family_floaters = $data; - $array->type = "Group Medical Coverage - Parents"; + $array->type = "GMC - Parents"; return $array; @@ -1791,7 +1792,7 @@ class EmployeeRestController extends AdminController $responce['family_floaters_of_only_si_value'] = $only_si_value; $responce['family_floaters_of_only_si_premium_value'] = $only_si_premium_value; $responce['family_floaters_of_only_si_gst_value'] = $only_si_gst_value; - $responce['type'] = "Group Medical Coverage - Top Up"; + if($this->request->getGet('policy') == 'GMC-SI-TOPUP'){ return $this->respond(['status' => 'success','code' => 200,'data' => ['gmc_si_topup'=>$responce]], 200); @@ -1840,7 +1841,7 @@ class EmployeeRestController extends AdminController $responce['family_floaters_of_only_si_value'] = $only_si_value; $responce['family_floaters_of_only_si_premium_value'] = $only_si_premium_value; $responce['family_floaters_of_only_si_gst_value'] = $only_si_gst_value; - $responce['type'] = "Group Medical Coverage - Parents Top Up"; + if($this->request->getGet('policy') == 'GMC-SI-PARENT-TOPUP'){ return $this->respond(['status' => 'success','code' => 200,'data' => ['gmc_si_parent_topup'=>$responce]], 200); diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index 0d5e76e3..68ce024d 100755 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -56,6 +56,7 @@ class MasterController extends AdminController protected $clientModel; protected $clientDepositModel; protected $insurerTemplateModel; + protected $cli_colors; @@ -84,6 +85,13 @@ class MasterController extends AdminController $this->clientModel = new ClientModel(); $this->clientDepositModel = new ClientDepositModel(); $this->insurerTemplateModel = new InsurerExcelExportTemplateModel(); + $this->cli_colors = [ + 'red' => "\033[31m", + 'green' => "\033[32m", + 'yellow' => "\033[33m", + 'blue' => "\033[34m", + 'reset' => "\033[0m" + ]; } @@ -1546,6 +1554,7 @@ class MasterController extends AdminController $this->checkAndCreateDirectories(); $this->checkGoogleOAuthCredentialsinDB(); $this->getCronJobsList(); + $this->checkGdriveRootFolderID(); } @@ -1594,7 +1603,7 @@ class MasterController extends AdminController $token = $settingsModel->where('id', 1)->first(); echo "################ CHECKING GMAIL OAUTH FOR EMAIL ###################\n"; - if (is_array($token) && !is_null($token['gmail_api_oauth_credentials'])) { + 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"; @@ -1632,4 +1641,20 @@ class MasterController extends AdminController echo "################################################################\n\n"; } + //check gdrive root folder id in env file + function checkGdriveRootFolderID() + { + echo "#################### CHECKING GDRIVE FOLDER ID IN ENV FILE ############################\n"; + $id = getenv('GDRIVE_ROOT_FOLDER_ID'); + if($id) + { + echo $this->cli_colors['green'] . "ID is :". $id . $this->cli_colors['reset']. "\n"; + } + else + { + echo $this->cli_colors['red'] ."Gdrive Folder id not set in env file. set it under 'GDRIVE_ROOT_FOLDER_ID' in env file.". $this->cli_colors['reset'] ."\n"; + } + echo "################################################################\n\n"; + } + } \ No newline at end of file diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 2607f41c..b73c9daf 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -1268,8 +1268,11 @@ class PolicyTransactionController extends BaseController //insurer statement list page public function statementList() { - // dd($this->updateInsurerStatement(['file_id' => 13])); + // dd($this->validateInsurerStatement(['file_id' => 30])); // $data['insurers'] = $this->insurerModel->where('is_active',1)->findAll(); + $today = date('Y-m-d'); + $fromday = $from_date = date('Y-m-d', strtotime('-60 days', strtotime($today))); + // echo $fromday;die(); $data['invoice_status_array'] = $this->invoiceStatus; $data['insurers'] = $this->insurerBranchModel ->getInsurerBranchesWithInsurerNames(); @@ -1285,7 +1288,7 @@ class PolicyTransactionController extends BaseController 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) + (SELECT SUM(inv_payment_details.inv_amt) + SUM(inv_payment_details.tds) FROM inv_payment_details WHERE inv_payment_details.is_active = 1 AND inv_payment_details.statement_id = insurer_statements.id @@ -1295,10 +1298,12 @@ class PolicyTransactionController extends BaseController ->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) + ->where('date(insurer_statements.created_at) >= ', $from_date) + ->where('date(insurer_statements.created_at) <= ', $today) ->orderBy('insurer_statements.id', 'DESC') ->findAll(); - // dd( $data['insurer_statement_list']); + // dd( $this->insurerStatements->getLastQuery()); $this->loadLayout('insurer_statement_list', $data); } @@ -1314,7 +1319,7 @@ class PolicyTransactionController extends BaseController 'max_size[statement,16384]', ], ]); - $this->createStatementFolder(); + // $this->createStatementFolder(); if ($validated) { $avatar = $this->request->getFile('statement'); @@ -1351,6 +1356,8 @@ class PolicyTransactionController extends BaseController // print_r($branch_id); // die(); $month = $this->request->getPost('statement_month'); + $month = $month.'-01'; + // print_r($month);die; $month = change_date_format($month,'Y-M-d','Y-m-d'); // print_r($month);die; @@ -1439,27 +1446,28 @@ class PolicyTransactionController extends BaseController // dd($highestRowAndColumn); $excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']); unset($excel_data[0]); - // dd($excel_data); + // Kint::dump($excel_data); //get no of line items and update in DB $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']); // var_dump($source_data);die(); - // Kint::dump($excel_data); + // Kint::dump($source_data);//die(); // check policy no,insurer and etc in DB for this month // if all good return true, otherwise return false with messssage foreach ($excel_data as $excel_key => $excel_row) { $is_source_found = 0; - $excel_row[4] = trim($excel_row[4]); - $excel_row[5] = trim($excel_row[5]); - // Kint::dump(change_date_format($excel_row[4],'d-m-Y','Y-m-d')); - // echo $excel_row[1].'#'.$excel_row[2] .'#'.$excel_row[3].'#'.change_date_format($excel_row[4],'d-m-Y','Y-m-d').'#'.change_date_format($excel_row[5],'d-m-Y','Y-m-d').'
'; + $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]);//policy_start_date from excel + $policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]);//policy_end_date from excel + $policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]);//policy_end_date from excel + $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]);//clientname from excel + $endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]);//policy_end_date from excel + foreach ($source_data as $source_key => $source_row) { - // Kint::dump(change_date_format($excel_row[3],'d-m-Y','Y-m-d')); - if( (trim($excel_row[1]) == $source_row['policy_no']) && trim($excel_row[2]) == $source_row['endorsement_no'] && trim($excel_row[3]) == $source_row['client_name'] && change_date_format($excel_row[4],'d-m-Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($excel_row[5],'d-m-Y','Y-m-d') == $source_row['policy_end_date']) + if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_row['endorsement_no'] && change_date_format($policy_start_date,'d-m-Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date,'d-m-Y','Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) { $is_source_found = 1; unset($source_data[$source_key]); @@ -1475,7 +1483,6 @@ class PolicyTransactionController extends BaseController $error_data['error_data'] = array_merge($error_data['error_data'],[$excel_row[0]]);//match not found } } - if($error_data['error_code']) { $status = 'failed'; @@ -1543,13 +1550,16 @@ class PolicyTransactionController extends BaseController foreach ($excel_data as $excel_key => $excel_row) { $is_source_found = 0; - $excel_row[4] = trim($excel_row[4]); - $excel_row[5] = trim($excel_row[5]); + $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]);//policy_start_date from excel + $policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]);//policy_end_date from excel + $policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]);//policy_end_date from excel + $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]);//clientname from excel + $endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]);//policy_end_date from excel foreach ($source_data as $source_key => $source_row) { // Kint::dump(change_date_format($excel_row[3],'d-m-Y','Y-m-d')); - if( (trim($excel_row[1]) == $source_row['policy_no']) && trim($excel_row[2]) == $source_row['endorsement_no'] && trim($excel_row[3]) == $source_row['client_name'] && change_date_format($excel_row[4],'d-m-Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($excel_row[5],'d-m-Y','Y-m-d') == $source_row['policy_end_date']) + if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_row['endorsement_no'] && change_date_format($policy_start_date,'d-m-Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date,'d-m-Y','Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) { $is_source_found = 1; @@ -1646,10 +1656,11 @@ class PolicyTransactionController extends BaseController ->where('is_active',1) ->get() ->getResultArray(); - // print_r($inv_details); + // ~dd($inv_details); $data = [ 'invoice_status' => $inv_details['invoice_status'], 'invoice_no' => $inv_details['invoice_no'], - 'invoice_date' => $inv_details['invoice_date'] ]; + 'invoice_amount' => $inv_details['invoice_amount'], + 'invoice_date' => isset($inv_details['invoice_date']) ? change_date_format($inv_details['invoice_date'],'Y-m-d','d-m-Y') : null ]; $data['payments'] = $inv_payment_details; return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $data], 200); @@ -1666,13 +1677,15 @@ class PolicyTransactionController extends BaseController $invoiceStatus = $jsonData['invoice_status']; $hiddenStatementId = $jsonData['hidden_statement_id']; $invoiceNo = $jsonData['invoice_no']; - $invoiceDate = $jsonData['invoice_date']; + $invoiceDate = change_date_format($jsonData['invoice_date'],'d-m-Y','Y-m-d'); + $invoice_amount = $jsonData['invoice_amount']; //Update statement table $parentData = [ 'invoice_status' => $invoiceStatus, 'invoice_no' => $invoiceNo, 'invoice_date' => $invoiceDate, + 'invoice_amount' => $invoice_amount, 'updated_by' => get_session_userid() ]; @@ -1681,21 +1694,24 @@ class PolicyTransactionController extends BaseController $this->insurerStatements->update($hiddenStatementId, $parentData); // Process child data - $invoiceAmounts = $jsonData['invoice_amount']; + $receivedAmounts = $jsonData['received_amount']; $utrNos = $jsonData['utr_no']; + $tdsTotal = $jsonData['tds']; $paymentDates = $jsonData['payment_date']; $pks = $jsonData['pk']; - foreach ($invoiceAmounts as $index => $invoiceAmount) { + foreach ($receivedAmounts as $index => $receivedAmount) { $pk = $pks[$index]; // Get the pk for the current record $utrNo = $utrNos[$index]; + $tds = $tdsTotal[$index]; $paymentDate = $paymentDates[$index]; // Prepare data for insert/update $childData = [ - 'inv_amt' => $invoiceAmount, + 'inv_amt' => $receivedAmount, 'utr_no' => $utrNo, - 'received_date' => $paymentDate, + 'tds' => $tds, + 'received_date' => change_date_format($paymentDate,'d-m-Y','Y-m-d'), 'statement_id' => $hiddenStatementId ]; if($pk){ diff --git a/app/Models/InsurerStatements.php b/app/Models/InsurerStatements.php index 6b85ed0f..0e2dc2ec 100644 --- a/app/Models/InsurerStatements.php +++ b/app/Models/InsurerStatements.php @@ -21,6 +21,7 @@ class InsurerStatements extends Model "reason", "invoice_status", "invoice_no", + "invoice_amount", "invoice_date", "updated_by" diff --git a/app/Models/InvPaymentDetailsModel.php b/app/Models/InvPaymentDetailsModel.php index 6b2d9dac..262f76d6 100644 --- a/app/Models/InvPaymentDetailsModel.php +++ b/app/Models/InvPaymentDetailsModel.php @@ -15,6 +15,7 @@ class InvPaymentDetailsModel extends Model 'statement_id', 'inv_amt', 'utr_no', + 'tds', 'received_date', 'created_by', 'is_active', diff --git a/app/Models/PTCOShareDetailsModel.php b/app/Models/PTCOShareDetailsModel.php index 274b572b..385645ed 100644 --- a/app/Models/PTCOShareDetailsModel.php +++ b/app/Models/PTCOShareDetailsModel.php @@ -87,16 +87,18 @@ class PTCOShareDetailsModel extends Model pt_co.bp_amt, pt_co.tp_amt, pt_co.tep_amt, - pt_co.exp_amt + pt_co.exp_amt, + pt_co.statement_id ') ->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.created_at)', $month) - ->where('YEAR(pt.created_at)', $year) + ->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.status','completed') // ->where('pt_co.exp_amt', 0.00) // ->orWhere('pt_co.exp_amt is null') ->get() diff --git a/app/Views/insurer_statement_list.php b/app/Views/insurer_statement_list.php index cf14f29d..4407c302 100644 --- a/app/Views/insurer_statement_list.php +++ b/app/Views/insurer_statement_list.php @@ -113,13 +113,10 @@ table.dataTable tbody td {

Insurer Statement List

- - - - - + +
- +
@@ -155,18 +152,20 @@ table.dataTable tbody td { @@ -203,7 +203,7 @@ table.dataTable tbody td {
-
+
-
+
- +
-
+ @@ -254,7 +254,7 @@ table.dataTable tbody td {
-
- + + @@ -324,9 +329,10 @@ table.dataTable tbody td { - + + - + @@ -354,19 +360,24 @@ table.dataTable tbody td { const invoiceNoDiv = document.getElementById('invoice_no_div_modal'); // 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'; // invoiceDateDiv.style.display = 'none'; paymentTableDiv.style.display = 'none'; + totalReceivedAmtDiv.style.display = 'none'; // Show fields based on selected status if (invoiceStatus === 'generated' || invoiceStatus === 'sent') { invoiceNoDiv.style.display = 'flex'; + totalReceivedAmtDiv.style.display = 'none'; switchRequired('invoice_no_modal',true); switchRequired('invoice_date_modal',true); + switchRequired('invoice_amount_no_modal',true); - switchRequired('invoice_amount',false,'name'); + switchRequired('received_amount',false,'name'); + switchRequired('tds',false,'name'); switchRequired('utr_no',false,'name'); switchRequired('payment_date',false,'name'); switchRequired('pk',false,'name'); @@ -374,24 +385,32 @@ table.dataTable tbody td { } else if (invoiceStatus === 'payment_received') { invoiceNoDiv.style.display = 'flex'; paymentTableDiv.style.display = 'block'; + totalReceivedAmtDiv.style.display = 'block'; switchRequired('invoice_no_modal',true); switchRequired('invoice_date_modal',true); - - switchRequired('invoice_amount',true,'name'); + switchRequired('invoice_amount_no_modal',true); + + + switchRequired('received_amount',true,'name'); switchRequired('utr_no',true,'name'); + switchRequired('tds',true,'name'); switchRequired('payment_date',true,'name'); switchRequired('pk',true,'name'); }else if(invoiceStatus === 'pending') { invoiceNoDiv.style.display = 'none'; paymentTableDiv.style.display = 'none'; + totalReceivedAmtDiv.style.display = 'none'; + // switchRequired('modal_received_amt_div',false); switchRequired('invoice_no_modal',false); switchRequired('invoice_date_modal',false); + switchRequired('invoice_amount_no_modal',false); - switchRequired('invoice_amount',false,'name'); + switchRequired('received_amount',false,'name'); switchRequired('utr_no',false,'name'); switchRequired('payment_date',false,'name'); switchRequired('pk',false,'name'); + switchRequired('tds',false,'name'); } }); @@ -417,12 +436,21 @@ table.dataTable tbody td { $('#invoiceForm').on('submit', function (e) { e.preventDefault(); // Prevent default form submission var form = document.getElementById('invoiceForm'); - if(!form.checkValidity()) + // alert(form.checkValidity()); + // alert($('#invoice_date_modal').val()); + if((!form.checkValidity())) { + // console.log('error2'); return false; } - - + + if($('#invoice_date_modal').val().trim() === '' && $('#invoice_status').val() != 'pending') + { + // console.log('error1'); + return false; + } + // console.log('final'); + // return false; // Serialize form data to array and then convert to JSON var formData = new FormData(form); var formDataJSON = {}; @@ -456,14 +484,13 @@ table.dataTable tbody td { success: function (response) { console.log(response); // Close the modal - var myModal = new bootstrap.Modal(document.getElementById('invoice_modal')); - myModal.hide(); - + + $('.close').click() // Reset the form data $('#invoiceForm')[0].reset(); - - // Optionally display success message or perform further actions + alert('Invoice updated successfully!'); + location.reload(); }, error: function (xhr, status, error) { // Handle any errors @@ -471,6 +498,7 @@ table.dataTable tbody td { alert('An error occurred while updating the invoice.'); } }); + // location.reload(); $('.loader').fadeOut(); $('.loader-mask').delay(10).fadeOut('slow'); }); @@ -484,13 +512,18 @@ table.dataTable tbody td { newRow.innerHTML = ` - + + - + `; tableBody.appendChild(newRow); + $('.payment_date').datepicker({ + format: 'dd-mm-yyyy', + autoclose: true + }); }); // Remove row @@ -529,33 +562,7 @@ table.dataTable tbody td { }); - function switchRequired(elementId, isRequired, type = 'id') { - - if(type == 'id')//id attribute - { - let element = document.getElementById(elementId); - if (isRequired) { - element.setAttribute('required', 'required'); - } else { - element.removeAttribute('required'); - } - } - else //name attribute - { - var name_attribute = elementId+'[]'; - // Select all elements with the name 'invoice_amt[]' - var elements = document.getElementsByName(name_attribute); - - // Loop through the elements and set or remove the 'required' attribute - elements.forEach(function(element) { - if (isRequired) { - element.setAttribute('required', 'required'); // Make required - } else { - element.removeAttribute('required'); // Remove required - } - }); - } -} + @@ -568,16 +575,31 @@ function showFileUploadModal(input) // $(input).val(''); } +function formatDate(date) { + var day = ("0" + date.getDate()).slice(-2); + var month = ("0" + (date.getMonth() + 1)).slice(-2); + var year = date.getFullYear(); + return day + "-" + month + "-" + year; +} +function formatDateToDMY(dateStr) { + // Split the date string by the hyphen + var parts = dateStr.split('-'); + return parts[2] + '-' + parts[1] + '-' + parts[0]; // Rearrange to DD-MM-YYYY +} function showInvoiceStatusModal(event) { + var modal_received_amt_div = document.getElementById('modal_received_amt_div'); + modal_received_amt_div.style.display = 'none'; + // alert(); // 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_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,8 +624,14 @@ function showInvoiceStatusModal(event) } document.getElementById('invoice_no_modal').value = response.data.invoice_no; - document.getElementById('invoice_date_modal').value = response.data.invoice_date; + document.getElementById('invoice_date_modal').value = response.data.invoice_date === '' ? : response.data.invoice_date; + document.getElementById('invoice_amount_no_modal').value = response.data.invoice_amount; + if (!$('#invoice_date_modal').val()) { + // alert('nope'); + // Set today's date as the default date + $('#invoice_date_modal').datepicker('setDate', new Date()); + } // Clear existing rows in the payment table var paymentTableBody = document.querySelector('#payment_table_modal tbody'); @@ -616,14 +644,15 @@ function showInvoiceStatusModal(event) var row = paymentTableBody.insertRow(); row.innerHTML = ` - + + - + `; }); } - + $('.payment_date').datepicker({ format: 'dd-mm-yyyy',autoclose: true}); // Show the modal var myModal = new bootstrap.Modal(document.getElementById('invoice_modal')); myModal.show(); @@ -641,17 +670,51 @@ function showInvoiceStatusModal(event) }); $('.loader').fadeOut(); $('.loader-mask').delay(10).fadeOut('slow'); - var myModal = new bootstrap.Modal(document.getElementById('invoice_modal')); - myModal.show(); + // var myModal = new bootstrap.Modal(document.getElementById('invoice_modal')); + // myModal.show(); // $(input).val(''); } $(document).ready(function(){ - var rollover_date = flatpickr("#statement_month", { - dateFormat: "Y-M-d", - allowInput: true + // var rollover_date = flatpickr("#statement_month", { + // dateFormat: "Y-M", + // allowInput: true + // }); + $('#statement_month').datepicker({ + format: 'yyyy-M', + viewMode: 'months', + minViewMode: 'months', + autoclose: true }); + + + $('.payment_date').datepicker({ + format: 'dd-mm-yyyy', + autoclose: true + }); + + // Get today's date +var today = new Date(); + +// Calculate the minimum date (60 days before today) +var minDate = new Date(); +minDate.setDate(today.getDate() - 180); + +// Calculate the maximum date (60 days after today) +var maxDate = new Date(); +maxDate.setDate(today.getDate() + 180); + $('#invoice_date_modal').datepicker({ + format: 'dd-mm-yyyy', + autoclose: true, + startDate: minDate, + endDate: maxDate + }); + + // var invoice_date_modal = flatpickr("#invoice_date_modal", { + // dateFormat: "d-m-Y", + // allowInput: true + // }); }); @@ -692,7 +755,7 @@ $(document).ready(function(){ toastr.success( 'File upload successs', 'success'); - $('.close').click() + $('.close').click(); window.location.reload(true); } else if (response.code === 404 && response.dataStatus === false) { console.error('no data found', response); @@ -765,19 +828,59 @@ $(document).ready(function(){ } -function checkInvAmont(event) -{ +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 = ''; + var receivedAmounts = document.querySelectorAll('input[name="received_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 tdsVal = parseFloat(tdsAmounts[index].value) || 0; + // Add received amount and tds amount + // console.log(); + total += (receivedVal + tdsVal); + }); + // console.log(total); + // Get the expected invoice amount + var exp_amt = parseFloat(document.getElementById('invoice_amount_no_modal').value) || 0; + + // 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 } } + +function switchRequired(elementId, isRequired, type = 'id') { + // console.log('switchRequired: ' + elementId+' - '+' - '+ type); + if(type == 'id')//id attribute + { + let element = document.getElementById(elementId); + if (isRequired) { + element.setAttribute('required', 'required'); + } else { + element.removeAttribute('required'); + } + } + else //name attribute + { + var name_attribute = elementId+'[]'; + // Select all elements with the name 'invoice_amt[]' + var elements = document.getElementsByName(name_attribute); + + // Loop through the elements and set or remove the 'required' attribute + elements.forEach(function(element) { + if (isRequired) { + element.setAttribute('required', 'required'); // Make required + } else { + element.removeAttribute('required'); // Remove required + } + }); + } +} + + \ No newline at end of file
+ + '.$row['first_name'] ?> - + +
pkInvoice AmountReceived AmountTDS UTR Number Date Action