FIX_INVOICE MODULE TEST

This commit is contained in:
venba-Inspriron-3558 2025-10-30 11:12:28 +05:30
parent b6c809adc9
commit c41b1b2f14
3 changed files with 134 additions and 37 deletions

View File

@ -407,8 +407,9 @@
<select class="form-control cleint-select SelExample" id="clientName" required>
<option value="">Select a Client</option>
<?php foreach ($client as $value) : ?>
<option value="<?= $value["client_id"] ?>">
<?= $value["mobile_no"] .' - '. $value["client_name"]; ?>
<option data-id="<?= $value["mobile_no"] .' - '. $value["client_name"]; ?>"
value="<?= $value["client_id"] ?>">
<?= $value["client_name"]; ?>
</option>
<?php endforeach; ?>
</select>
@ -669,6 +670,8 @@ $(document).ready(function() {
$('.vehicle-select').change(function() {
var vehicleId = $(this).val();
console.log(":)",vehicleId);
$('input[id="makeAndModel"],input[name="client_id"], input[name="client_name"], textarea[name="billing_address"], input[name="city"], input[name="state"], input[name="country"], input[name="mobile_no"], input[name="email"], input[name="postalcode"]').val('');
if (vehicleId !== '') {
// Find the selected vehicle
@ -1460,36 +1463,41 @@ $(document).on('click', '#selectClient', function() {
$(window).on('load', function() {
// This code will execute after the page has been reloaded
vehicle_id = localStorage.getItem('vehicle_id');
localStorage.removeItem('vehicle_id');
if(vehicle_id) {
var vehicleId = vehicle_id;
if (vehicleId !== '') {
// Find the selected client in the client data
var selectedClient = vehicles.find(function(vehicle) {
return vehicle.vehicle_id == vehicleId;
});
var makeId = selectedClient.make;
var modelId = selectedClient.model;
var vehicle_id = localStorage.getItem('vehicle_id');
if (vehicle_id) {
$('#vehicle_id').val(vehicle_id).trigger('change');
localStorage.removeItem('vehicle_id');
$('input[id="makeAndModel"], input[name="client_id"], input[name="client_name"], textarea[name="billing_address"], input[name="city"], input[name="state"], input[name="country"], input[name="mobile_no"], input[name="email"], input[name="postalcode"]').val('');
// Find the selected vehicle details
var selectedVehicle = vehicles.find(function(vehicle) {
return vehicle.vehicle_id == vehicle_id;
});
if (selectedVehicle) {
var makeId = selectedVehicle.make;
var modelId = selectedVehicle.model;
fetchMakeAndModel(makeId, modelId);
console.log("nmnmn",selectedClient);
$('input[name="client_id"]').val(selectedClient.client_id);
$('input[name="client_name"]').val(selectedClient.client_name);
$('textarea[name="billing_address"]').val(selectedClient.address);
// Fill client & vehicle info fields
$('input[name="client_id"]').val(selectedVehicle.client_id);
$('input[name="client_name"]').val(selectedVehicle.client_name);
$('textarea[name="billing_address"]').val(selectedVehicle.address);
// $('input[name="billing_address"]').val(selectedClient.address);
$('input[name="city"]').val(selectedClient.city);
$('input[name="state"]').val(selectedClient.state);
$('input[name="country"]').val(selectedClient.country);
$('input[name="mobile_no"]').val(selectedClient.mobile_no);
$('input[name="email"]').val(selectedClient.email);
$('input[name="postalcode"]').val(selectedClient.postal_code);
$('input[name="city"]').val(selectedVehicle.city);
$('input[name="state"]').val(selectedVehicle.state);
$('input[name="country"]').val(selectedVehicle.country);
$('input[name="mobile_no"]').val(selectedVehicle.mobile_no);
$('input[name="email"]').val(selectedVehicle.email);
$('input[name="postalcode"]').val(selectedVehicle.postal_code);
} else {
console.warn("⚠️ Vehicle not found in 'vehicles' list for ID:", vehicle_id);
}
$('#vehicle_name').val(vehicle_id).trigger('change');
}
});
@ -1509,7 +1517,7 @@ $(document).on('click', '#selectClient', function() {
success: function(response) {
// console.log(response);
// Populate make and model in the input field
var makeAndModel = response.makeName + ' ' + response.modelName;
var makeAndModel = response.makeName + ' - ' + response.modelName;
$('#makeAndModel').val(makeAndModel);
if(response.product.length){
@ -1533,14 +1541,19 @@ $(document).on('click', '#selectClient', function() {
<!-- script for set the product name id -->
<script>
function addProductNamesId(selectElement) {
if (!selectElement) return; // safety
if (selectElement.value === "add_new_product") {
$('#addProductModal').modal('show');
var rowIndex = $(this).closest('tr').index(); // get row index
// $('#addProductModal').modal('show');
// var rowIndex = $(this).closest('tr').index(); // get row index
// localStorage.setItem('add_product_index', rowIndex);
// $(selectElement).val(''); // reset dropdown to empty
$(selectElement).select2('close');
$(selectElement).val('').trigger('change.select2');
var rowIndex = $(selectElement).closest('tr').index();
localStorage.setItem('add_product_index', rowIndex);
$(selectElement).val(''); // reset dropdown to empty
$('#addProductModal').modal('show');
$('.select2-container--open').removeClass('select2-container--open');
}
}

View File

@ -36,7 +36,23 @@
<tr>
<td style="width: 33.3333%;">&nbsp;</td>
<td style="width: 4.98683%;">&nbsp;</td>
<td style="width: 61.6798%; text-align: right; font-size: small;"><?= $invoice[0]->company_city; ?>,<?= $invoice[0]->company_state; ?>-<?= $invoice[0]->company_postal_code; ?></td>
<td style="width: 61.6798%; text-align: right; font-size: small;">
<?php
$c = trim($invoice[0]->company_city ?? '');
$s = trim($invoice[0]->company_state ?? '');
$p = trim($invoice[0]->company_postal_code ?? '');
if ($p === '0' || $p === 0) { $p = ''; }
$output = '';
if ($c && $s && $p) { $output = "$c, $s - $p.";
} elseif ($c && $s) { $output = "$c, $s.";
} elseif ($c && $p) { $output = "$c - $p.";
} elseif ($s && $p) { $output = "$s - $p.";
} elseif ($c) { $output = "$c.";
} elseif ($s) { $output = "$s.";
} elseif ($p) { $output = "$p."; }
echo $output;
?>
</td>
</tr>
<tr>
<td style="width: 33.3333%;">&nbsp;</td>
@ -65,7 +81,33 @@
<td style="width: 18.5039%; height: 18px; text-align: right; font-size: small;"><?= date("d-m-Y", strtotime($invoice[0]->created_at)); ?></td>
</tr>
<tr style="height: 18px;">
<td style="width: 49.4096%; height: 18px; font-size: small;"><?= $invoice[0]->billing_address; ?>,<?= $invoice[0]->billing_city; ?>,<?= $invoice[0]->billing_state; ?>-<?= $invoice[0]->billing_postal_code; ?>,</td>
<td style="width: 49.4096%; height: 18px; font-size: small;">
<?php
$ba = trim($invoice[0]->billing_address ?? '');
$bc = trim($invoice[0]->billing_city ?? '');
$bs = trim($invoice[0]->billing_state ?? '');
$bp = trim($invoice[0]->billing_postal_code ?? '');
if ($bp === '0' || $bp === 0) {$bp = '';}
$address = '';
if ($ba && $bc && $bs && $bp) { $address = "$ba, $bc, $bs - $bp.";
} elseif ($ba && $bc && $bs) { $address = "$ba, $bc, $bs.";
} elseif ($ba && $bc && $bp) { $address = "$ba, $bc - $bp.";
} elseif ($ba && $bs && $bp) { $address = "$ba, $bs - $bp.";
} elseif ($ba && $bc) { $address = "$ba, $bc.";
} elseif ($ba && $bs) { $address = "$ba, $bs.";
} elseif ($ba && $bp) { $address = "$ba - $bp.";
} elseif ($bc && $bs && $bp) { $address = "$bc, $bs - $bp.";
} elseif ($bc && $bs) { $address = "$bc, $bs.";
} elseif ($bc && $bp) { $address = "$bc - $bp.";
} elseif ($bs && $bp) { $address = "$bs - $bp.";
} elseif ($ba) { $address = "$ba.";
} elseif ($bc) { $address = "$bc.";
} elseif ($bs) { $address = "$bs.";
} elseif ($bp) { $address = "$bp.";
} else { $address = '-';}
echo $address;
?>
</td>
<td style="width: 1.9685%; height: 18px;">&nbsp;</td>
<td style="width: 30.3148%; height: 18px; text-align: right; font-size: small;">Payment Mode:</td>
<td style="width: 18.5039%; height: 18px; text-align: right; font-size: small;"><?= $invoice[0]->mode_of_payment; ?></td>

View File

@ -26,7 +26,23 @@
<tr>
<td style="width: 33.3333%;">&nbsp;</td>
<td style="width: 4.98683%;">&nbsp;</td>
<td style="width: 61.6798%; text-align: right; font-size: small;"><?= $sales[0]->company_city; ?>,<?= $sales[0]->company_state; ?>-<?= $sales[0]->company_postal_code; ?></td>
<td style="width: 61.6798%; text-align: right; font-size: small;">
<?php
$c = trim($sales[0]->company_city ?? '');
$s = trim($sales[0]->company_state ?? '');
$p = trim($sales[0]->company_postal_code ?? '');
if ($p === '0' || $p === 0) { $p = ''; }
$output = '';
if ($c && $s && $p) { $output = "$c, $s - $p.";
} elseif ($c && $s) { $output = "$c, $s.";
} elseif ($c && $p) { $output = "$c - $p.";
} elseif ($s && $p) { $output = "$s - $p.";
} elseif ($c) { $output = "$c.";
} elseif ($s) { $output = "$s.";
} elseif ($p) { $output = "$p."; }
echo $output;
?>
</td>
</tr>
<tr>
<td style="width: 33.3333%;">&nbsp;</td>
@ -55,7 +71,33 @@
<td style="width: 18.5039%; height: 18px; text-align: right; font-size: small;"><?= date("d-m-Y", strtotime($sales[0]->created_at)); ?></td>
</tr>
<tr style="height: 18px;">
<td style="width: 49.4096%; height: 18px; font-size: small;"><?= $sales[0]->billing_address; ?>,<?= $sales[0]->billing_city; ?>,<?= $sales[0]->billing_state; ?>-<?= $sales[0]->billing_postal_code; ?>,</td>
<td style="width: 49.4096%; height: 18px; font-size: small;">
<?php
$ba = trim($sales[0]->billing_address ?? '');
$bc = trim($sales[0]->billing_city ?? '');
$bs = trim($sales[0]->billing_state ?? '');
$bp = trim($sales[0]->billing_postal_code ?? '');
if ($bp === '0' || $bp === 0) {$bp = '';}
$address = '';
if ($ba && $bc && $bs && $bp) { $address = "$ba, $bc, $bs - $bp.";
} elseif ($ba && $bc && $bs) { $address = "$ba, $bc, $bs.";
} elseif ($ba && $bc && $bp) { $address = "$ba, $bc - $bp.";
} elseif ($ba && $bs && $bp) { $address = "$ba, $bs - $bp.";
} elseif ($ba && $bc) { $address = "$ba, $bc.";
} elseif ($ba && $bs) { $address = "$ba, $bs.";
} elseif ($ba && $bp) { $address = "$ba - $bp.";
} elseif ($bc && $bs && $bp) { $address = "$bc, $bs - $bp.";
} elseif ($bc && $bs) { $address = "$bc, $bs.";
} elseif ($bc && $bp) { $address = "$bc - $bp.";
} elseif ($bs && $bp) { $address = "$bs - $bp.";
} elseif ($ba) { $address = "$ba.";
} elseif ($bc) { $address = "$bc.";
} elseif ($bs) { $address = "$bs.";
} elseif ($bp) { $address = "$bp.";
} else { $address = '';}
echo $address;
?>
</td>
<td style="width: 1.9685%; height: 18px;">&nbsp;</td>
<td style="width: 30.3148%; height: 18px; text-align: right; font-size: small;">Payment Mode:</td>
<td style="width: 18.5039%; height: 18px; text-align: right; font-size: small;"><?= $sales[0]->mode_of_payment; ?></td>