CHANGE_INVOCIE_NEW_CUSTOMER_CREATE_ADDRESS_NOT_ADD_ISSUE_BILLING_AND_SHIPPING_ADDRESS_ISSUE : AADHAVAN

This commit is contained in:
aadhavan valli 2024-05-03 18:46:13 +05:30
parent 6d9e855fae
commit 0ab6b686d9
5 changed files with 149 additions and 57 deletions

View File

@ -670,9 +670,9 @@ class Invoice extends BaseController
$this->logger->info("Approve notification Email Request data = " . json_encode($records));
$email_result = $notification->sendEmail($records);
$this->logger->info("Approve notification Email Response = " . json_encode($email_result));
$this->logger->info("Approve notification Whatsapp Request data = " . json_encode($params));
$whatsapp_result = $notification->sendWhatsAppMessage(SEND_WAAI_URL, "POST", $params);
$this->logger->info("Approve notification Whatsapp Response = " . json_encode($whatsapp_result));
// $this->logger->info("Approve notification Whatsapp Request data = " . json_encode($params));
// $whatsapp_result = $notification->sendWhatsAppMessage(SEND_WAAI_URL, "POST", $params);
// $this->logger->info("Approve notification Whatsapp Response = " . json_encode($whatsapp_result));
}
## To Generate Invoice PDF based on invoice ID

View File

@ -16,6 +16,8 @@
<h4 class="header-title"><?= $page_name; ?></h4>
<br>
<form method="POST" enctype="multipart/form-data" action="<?= base_url() . "save_invoice"; ?>" id="myForm">
<input type="hidden" id="customer_id_set" >
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-6">
@ -126,7 +128,6 @@
<thead>
<tr>
<th>Item Details</th>
<th>Description</th>
<th>Qty</th>
<th>Rate</th>
<th style="display:none;">Tax</th>
@ -141,7 +142,8 @@
<?php if (!empty($invoice_item_details)) {
foreach ($invoice_item_details as $inx => $ii_details) : ?>
<tr>
<td style="width:20%"><select class="form-control book-select" id="<?= "book" . $inx; ?>bookSelect" name="item_details[]" onchange="displayBookTag(this,<?= $inx; ?>)" required data-toggle="select2" style="width: 249px !important;">
<td style="width:20%">
<select class="form-control book-select" id="<?= "book" . $inx; ?>bookSelect" name="item_details[]" onchange="displayBookTag(this,<?= $inx; ?>)" required data-toggle="select2" style="width: 249px !important;">
<option value="">Select a <?= $flag_name; ?></option>
<?php if ($invoice_type === '1') { ?>
@ -157,8 +159,9 @@
echo $book->title;
} ?></option>
<?php endforeach; ?>
</select></td>
<td style="width:25%"><textarea name="description[]" id="<?= "description" . $inx; ?>" cols="30" rows="2" style="height: 37px;"><?= isset($ii_details['description']) ? $ii_details['description'] : '' ?></textarea></td>
</select>
<textarea name="description[]" id="<?= "description" . $inx; ?>" cols="30" rows="2" style="height: 37px;"><?= isset($ii_details['description']) ? $ii_details['description'] : '' ?></textarea>
</td>
<td style="width:7%;"><input type="number" class="form-control item-quantity" id="<?= "quantity" . $inx; ?>" name="quantity[]" oninput="calculateInvoice(this,<?= $inx; ?>)" value="<?= isset($ii_details['quantity']) ? $ii_details['quantity'] : '' ?>" min="1" />
</td>
<td style="width:9%;"><input type="text" class="form-control item-rate" id="<?= "rate" . $inx; ?>" name="rate[]" oninput="calculateInvoice(this,<?= $inx; ?>)" value="<?= isset($ii_details['unit_price']) ? $ii_details['unit_price'] : '' ?>" readonly />
@ -201,8 +204,9 @@
<?php endif;
endforeach; ?>
</select>
<textarea name="description[]" id="" cols="34" rows="2" style="margin-top: 16px;border-color: lightgray;"></textarea>
</td>
<td style="width:25%"><textarea name="description[]" id="" cols="30" rows="2" style="height: 37px;"></textarea></td>
<td style="width:10%;"><input type="number" class="form-control item-quantity" id="quantity0" name="quantity[]" oninput="calculateInvoice(this,0)" min="1" />
</td>
<td style="width:10%;"><input type="text" class="form-control item-rate" id="rate0" name="rate[]" oninput="calculateInvoice(this,0)" /></td>
@ -616,8 +620,12 @@ Account No : 89900787655</textarea>
<div class="modal-dialog modal-dialog-centered modal-lg">
<div class="modal-content">
<div class="modal-body">
<div class="text-center mt-2 mb-4">
<h4 id="form_add_edit">Billing & Shipping Address</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close" onclick="hideBillingShippingModel(this)">
<span aria-hidden="true">&times;</span>
</button>
</div>
<h5 >Billing Address</h5>
<div class="row">
@ -744,14 +752,14 @@ Account No : 89900787655</textarea>
cell1.innerHTML = html;
// cell1.innerHTML = '<input type="text" class="form-control" name="item_details[]">';
cell2.innerHTML = '<textarea name="description[]" id="description'+counter+'" cols="30" rows="2" style="height: 37px;"></textarea>';
cell3.innerHTML = '<input type="number" class="form-control item-quantity" id="quantity' + counter + '" name="quantity[]" oninput="calculateInvoice(this,' + counter + ')" min="1">';
cell4.innerHTML = '<input type="number" class="form-control item-rate" id="rate' + counter + '" name="rate[]" oninput="calculateInvoice(this,' + counter + ')" min="0" step="0.01">';
cell5.innerHTML = '<input type="number" class="form-control item-tax" id="tax' + counter + '" name="tax[]" min="0" step="0.01">';
cell6.innerHTML = '<input type="number" class="form-control item-amount" id="amount' + counter + '" name="amount[]" min="0" step="0.01">';
cell7.innerHTML = '<input type="number" class="form-control item-discount-amount" id="item_discount_amount' + counter + '" name="discount_amount[]" oninput="calculateInvoice(this,' + counter + ')" min="0" step="0.01">';
cell8.innerHTML = '<select class="form-control item-discount-type" style=""width:12%;" id="item_discount_type' + counter + '" name="discount_type[]" oninput="calculateInvoice(this,' + counter + ')"><option value="₹">₹</option><option value="%">%</option></select>';
cell9.innerHTML = '<input type="hidden" class="form-control" id="hiddenInvoiceChildId' + counter + '" placeholder="hidden for invoice child/item id" name="invoice_child_id[]" value=""><center><i class="fa fa-trash remove-item "></center>';
cell1.innerHTML += '<textarea name="description[]" id="description'+counter+'" cols="34" rows="2" style="margin-top: 16px;border-color: lightgray;"></textarea>';
cell2.innerHTML = '<input type="number" class="form-control item-quantity" id="quantity' + counter + '" name="quantity[]" oninput="calculateInvoice(this,' + counter + ')" min="1">';
cell3.innerHTML = '<input type="number" class="form-control item-rate" id="rate' + counter + '" name="rate[]" oninput="calculateInvoice(this,' + counter + ')" min="0" step="0.01">';
// cell4.innerHTML = '<input type="number" class="form-control item-tax" id="tax' + counter + '" name="tax[]" min="0" step="0.01">';
cell4.innerHTML = '<input type="number" class="form-control item-amount" id="amount' + counter + '" name="amount[]" min="0" step="0.01">';
cell5.innerHTML = '<input type="number" class="form-control item-discount-amount" id="item_discount_amount' + counter + '" name="discount_amount[]" oninput="calculateInvoice(this,' + counter + ')" min="0" step="0.01">';
cell6.innerHTML = '<select class="form-control item-discount-type" style=""width:12%;" id="item_discount_type' + counter + '" name="discount_type[]" oninput="calculateInvoice(this,' + counter + ')"><option value="₹">₹</option><option value="%">%</option></select>';
cell7.innerHTML = '<input type="hidden" class="form-control" id="hiddenInvoiceChildId' + counter + '" placeholder="hidden for invoice child/item id" name="invoice_child_id[]" value=""><center><i class="fa fa-trash remove-item "></center>';
$(newRow.querySelector('.book-select')).select2();
localStorage.setItem('add_book_index', counter);
@ -971,7 +979,10 @@ Account No : 89900787655</textarea>
}
if ((bill_addrid === "" || parseInt(bill_addrid) === 0)) {
$('#editAddressesCheckbox').prop('checked', true);
$("#storeBillingAddress").prop("readonly", false);
// $("#storeBillingAddress").prop("readonly", false);
$("#storeBillingAddress").prop("readonly", true);
$("#storeShippingAddress").prop("readonly", true);
}
$('#hiddenBillingAddressId').val(bill_addrid);
get_customer_membership_details(custid)
@ -995,28 +1006,34 @@ Account No : 89900787655</textarea>
$("#editAddressesCheckbox").on("change", function() {
if ($(this).is(":checked")) {
$("#storeBillingAddress").prop("readonly", false);
$('#hiddenBillingAddressId').val(0);
// $("#storeBillingAddress").prop("readonly", false);
$("#storeBillingAddress").prop("readonly", true);
$("#storeShippingAddress").prop("readonly", true);
$('#hiddenBillingAddressId').val(0);
$('#billing_shipping_addresses_modal').modal('show');
$.ajax({
type: "GET",
url: "<?= base_url() . 'get_country' ?>",
success: function(response) {
var countries = JSON.parse(response);
// Loop through the countries array
$.each(countries, function(index, country) {
// Append an <option> element for each country
$('#billing_country').append('<option value="' + country.country_short_name + '">' + country.country_name + '</option>');
$('#shipping_country').append('<option value="' + country.country_short_name + '">' + country.country_name + '</option>');
}); },
error: function() {
alert("Error fetching address.");
}
});
$('#billing_shipping_addresses_modal').modal('show');
$.ajax({
type: "GET",
url: "<?= base_url() . 'get_country' ?>",
success: function(response) {
var countries = JSON.parse(response);
// Loop through the countries array
$.each(countries, function(index, country) {
// Append an <option> element for each country
$('#billing_country').append('<option value="' + country.country_short_name + '">' + country.country_name + '</option>');
$('#shipping_country').append('<option value="' + country.country_short_name + '">' + country.country_name + '</option>');
}); },
error: function() {
alert("Error fetching address.");
}
});
} else {
$("#storeBillingAddress").prop("readonly", true);
$("#storeShippingAddress").prop("readonly", true);
if (global_billarr !== "") {
$("#storeBillingAddress").val(global_billarr);
$('#hiddenBillingAddressId').val(global_billid);
@ -1047,7 +1064,8 @@ Account No : 89900787655</textarea>
if (custid != '' && (ship_addrid == undefined || ship_addrid == null || ship_addrid == '0' || ship_addrid == '')) {
$("#storeShippingAddress").prop("readonly", false);
// $("#storeShippingAddress").prop("readonly", false);
$("#storeShippingAddress").prop("readonly", true);
console.log('ship addrid is undefined, null, 0, or empty');
}
@ -1060,8 +1078,10 @@ Account No : 89900787655</textarea>
$('#customerModal').modal('show');
}else if(cust_id != ''){
$('#editAddressesCheckbox').prop('checked', false);
$("#storeBillingAddress").prop("readonly", false);
$("#storeShippingAddress").prop("readonly", false);
// $("#storeBillingAddress").prop("readonly", false);
$("#storeBillingAddress").prop("readonly", true);
// $("#storeShippingAddress").prop("readonly", false);
$("#storeShippingAddress").prop("readonly", true);
$('#customerModal').modal('hide');
$('#cus_mobile_no').val("");
$('#cus_first_name').val("");
@ -1088,6 +1108,7 @@ Account No : 89900787655</textarea>
global_billid = "";
var customer_billing_addressDetails = [];
if (cb.length > 0) {
console.log("cbbbbbbbbb",cb);
$.each(cb, function(k, v) {
var state = v.state_name ? v.state_name : v.state;
state = v.postal_code ? state + "-" + v.postal_code : state;
@ -1097,6 +1118,8 @@ Account No : 89900787655</textarea>
v.country_name ? customer_billing_addressDetails.push(v.country_name) : "";
customer_billing_id = v.customer_address_id;
});
}else{
}
global_billarr = customer_billing_addressDetails.join(', \n') + ".";
global_billid = customer_billing_id;
@ -1116,14 +1139,23 @@ Account No : 89900787655</textarea>
});
$("#storeShippingAddress").val('');
} else {
$("#editAddressesCheckbox").prop("checked", true);
$("#storeBillingAddress").prop("readonly", false);
$('#loadShippingDropdown').empty();
$('#loadShippingDropdown').append($('<option>', {
value: "",
text: "Select an address"
}));
$("#editAddressesCheckbox").prop("checked", false);
// $("#storeBillingAddress").prop("readonly", false);
$("#storeBillingAddress").prop("readonly", true);
$("#storeShippingAddress").prop("readonly", true);
}
},
error: function() {
alert("Error fetching address.");
$("#editAddressesCheckbox").prop("checked", true);
$("#storeBillingAddress").prop("readonly", false);
$("#editAddressesCheckbox").prop("checked", false);
// $("#storeBillingAddress").prop("readonly", false);
$("#storeBillingAddress").prop("readonly", true);
$("#storeShippingAddress").prop("readonly", true);
}
});
}
@ -1447,7 +1479,10 @@ function saveInvoiceCustomer() {
szip: szip.value
},
success: function(response) {
console.log(response['data']);
if (response['data']['status']) {
$('#customer_id_set').val(response['data']['cus_id']);
console.log($('#customer_id_set'));
// Handle success response
alert(response['data']['message']);
@ -1469,8 +1504,10 @@ function saveInvoiceCustomer() {
$('#hiddenBillingAddressId').val(bAddressId);
}else{
console.log("editAddress checkbox valid - true");
$("#editAddressesCheckbox").prop("checked", true);
$("#storeBillingAddress").val("").prop("readonly", false);
$("#editAddressesCheckbox").prop("checked", false);
// $("#storeBillingAddress").val("").prop("readonly", false);
$("#storeBillingAddress").val("").prop("readonly", true);
$("#storeShippingAddress").prop("readonly", true);
$('#loadShippingDropdown').empty().append($('<option>', {value: "",text: "Select an address"}));
}
if(sAddressId !== null ){
@ -1490,7 +1527,8 @@ function saveInvoiceCustomer() {
$("#storeShippingAddress").val(ajax_shiparr).prop("readonly", true);
$('#loadShippingDropdown').empty().append(newShippingAddrOption);
}else{
$("#storeShippingAddress").val("").prop("readonly", false);
// $("#storeShippingAddress").val("").prop("readonly", false);
$("#storeShippingAddress").val("").prop("readonly", true);
$('#loadShippingDropdown').empty().append($('<option>', {value: "",text: "Select an address"}));
}
// Create a new option element
@ -1807,6 +1845,8 @@ function saveInvoiceCustomer() {
});
function submitAddress(params) {
$('#storeBillingAddress').val("").prop('readonly',false);
$('#storeShippingAddress').val("").prop('readonly',false);
var last_name = $("#last_name").val();
var first_name = $("#first_name").val();
var bAddress = $("#billing_address").val();
@ -1820,8 +1860,16 @@ function saveInvoiceCustomer() {
var sCity = $("#shipping_city").val();
var sPostalCode = $("#shipping_postal_code").val();
var cus_id = 0 ;
if ($('#customer_name').val()) {
cus_id = $('#customer_name').val();
}else{
cus_id = $('#customer_id_set').val();
}
console.log("customer_name",cus_id);
var formData = {
customer_id :$('#customer_name').val(),
customer_id :cus_id,
last_name: last_name,
first_name: first_name,
billing: {
@ -1846,18 +1894,24 @@ function saveInvoiceCustomer() {
data: formData,
success: function(response) {
// Handle success response
// console.log(response);
console.log("11111111111111111");
console.log(response);
$('#billing_shipping_addresses_modal').modal('hide');
var billing_Address = bAddress + ','+bCity + ',' + bCountry + '-' +bPostalCode + ',' + bState + '.' ;
var shipping_Address = sAddress + ','+sCity + ',' + sCountry + '-' +sPostalCode + ',' + sState + '.' ;
$('#storeBillingAddress').empty();
$('#storeBillingAddress').html(billing_Address);
$('#storeShippingAddress').empty();
$('#storeShippingAddress').html(shipping_Address);
console.log(billing_Address);
$('#editAddressesCheckbox').prop('checked', false).trigger('change');
$('#storeBillingAddress').empty();
$('#storeBillingAddress').html(billing_Address);
$('#storeBillingAddress').val(billing_Address);
$('#storeShippingAddress').empty();
$('#storeShippingAddress').html(shipping_Address);
$('#storeShippingAddress').val(shipping_Address);
// $('#editAddressesCheckbox').prop('checked', false).trigger('change');
},
error: function() {
@ -1865,6 +1919,16 @@ function saveInvoiceCustomer() {
alert("Error saving address.");
}
});
$('#storeBillingAddress').val("").prop('readonly',true);
$('#storeShippingAddress').val("").prop('readonly',true);
$('#editAddressesCheckbox').click();
}
function hideBillingShippingModel(params) {
$('#editAddressesCheckbox').click();
}

View File

@ -298,10 +298,7 @@
</table>
<br> <br>
<table class="invoice-related-table">
<thead style="
border-top: 1px solid grey;
border-bottom: 1px solid grey;
">
<thead style="border-top: 1px solid grey; border-bottom: 1px solid grey;">
<tr>
<th>S.no</th>
<th style="text-align: left;">Item Name</th>

View File

@ -272,6 +272,7 @@
printWindow.document.write(modifiedContent);
printWindow.document.close();
// Wait for content to load before printing
printWindow.onload = function() {
printWindow.focus(); // Focus the new window

View File

@ -39,6 +39,36 @@
<link href="<?= base_url()."public/assets/css/icons.min.css" ?>" rel="stylesheet" type="text/css" />
<link href="<?= base_url()."public/assets/libs/summernote/summernote-bs4.min.css" ?>" rel="stylesheet" type="text/css" />
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<!-- toster alert -->
<script src="https://cdn.jsdelivr.net/npm/toastr@2.1.4/toastr.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/toastr@2.1.4/build/toastr.min.css" rel="stylesheet">
<style>
/* Override toastr font color */
.toast-warning {
color: black !important;
background-color: #edd179 !important; /* Set background color to a solid color */
opacity: 1 !important; /* Set opacity to 1 to remove transparency */
}
.toast-success {
color: black !important;
background-color: #2aa762 !important; /* Set background color to a solid color */
opacity: 1 !important; /* Set opacity to 1 to remove transparency */
}
.icon-large {
font-size: 1.5em; /* Adjust the font size as needed */
}
</style>
<script>
toastr.options = {
"timeOut": 5000,
"closeButton": true,
};
</script>
</head>
<body class="loading">