FIX_Invoice

This commit is contained in:
VE10-Sanjeev 2024-11-22 05:43:59 +00:00
parent 1fb5e647fe
commit 9f1c5550df
5 changed files with 112 additions and 78 deletions

View File

@ -25,18 +25,18 @@
<?php if (session()->getFlashdata('success')) : ?>
<div class="alert alert-success"><?= session()->getFlashdata('success') ?></div>
<?php endif; ?>
<form class="needs-validation" novalidate method="post" enctype="multipart/form-data" action="<?= base_url() . "insert_books"; ?>" id="myForm">
<form class="parsley-examples needs-validation" novalidate method="post" enctype="multipart/form-data" action="<?= base_url() . "insert_books"; ?>" id="myForm">
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-6">
<label for="title" class="col-form-label">Book Name<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="title" name="title" value="<?= isset($details['title']) ? $details['title'] : '' ?>" placeholder="Book Name" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-6">
<label for="author" class="col-form-label">Author<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="author" name="author" value="<?= isset($details['author']) ? $details['author'] : '' ?>" placeholder="Author" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
<div class="form-row">
@ -44,12 +44,12 @@
<div class="form-group col-md-6">
<label for="publisher" class="col-form-label">Publisher Name<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="publisher" name="publisher" placeholder="Publisher Name" value="<?= isset($details['publisher']) ? $details['publisher'] : '' ?>" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-6">
<label for="publication_date" class="col-form-label">Publication Date<span class="text-danger"> *</span></label>
<input type="date" class="form-control" id="publication_date" name="publication_date" value="<?= isset($details['publication_date']) ? $details['publication_date'] : '' ?>" max="<?= date('Y-m-d'); ?>" required placeholder="Publication Date">
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
@ -61,7 +61,7 @@
<div class="form-group col-md-6">
<label for="isbn_code" class="col-form-label">ISBN Code<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="isbn_code" name="isbn_code" value="<?= isset($details['isbn_code']) ? $details['isbn_code'] : '' ?>" placeholder="ISBN Code" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
@ -77,7 +77,7 @@
<div class="form-group col-md-4">
<label for="price" class="col-form-label">Price<span class="text-danger"> *</span></label>
<input type="number" class="form-control" id="price" name="price" placeholder="Price" required value="<?= isset($details['price']) ? $details['price'] : '' ?>" />
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
@ -183,19 +183,21 @@
});
</script>
<script>
document.getElementById('myForm').addEventListener('submit', function(event) {
var form = event.target;
document.getElementById('myForm').addEventListener('submit', function(event) {
var form = event.target;
if (form.checkValidity() === false) {
// Check if form is valid
if (!form.checkValidity()) {
form.reportValidity(); // Display validation error messages
event.preventDefault(); // Prevent form submission if it's not valid
$('#submitBtn').prop('disabled', false); // Re-enable the button
form.reportValidity(); // Display validation error messages
event.preventDefault(); // Prevent form submission if it's not valid
$('#submitBtn').prop('disabled', false);
} else {
$('#submitBtn').prop('disabled', true);
}
});
// Display custom alert message
alert('Please fill out all required fields correctly.');
} else {
$('#submitBtn').prop('disabled', true); // Disable the button to prevent duplicate submissions
}
});
</script>
<script>
const DateInput = document.getElementById("publication_date");

View File

@ -26,18 +26,18 @@
<!-- Customer Details Tab -->
<div class="tab-pane fade show active" id="customerDetails" role="tabpanel" aria-labelledby="customerDetails-tab">
<!-- Customer details form fields -->
<form class="needs-validation" novalidate method="POST" enctype="multipart/form-data" action="<?= base_url() . "insert_customer"; ?>" id="myForm" name="myForm" onsubmit="myFunction(event)">
<form class="needs-validation parsley-examples" novalidate method="POST" enctype="multipart/form-data" action="<?= base_url() . "insert_customer"; ?>" id="myForm" name="myForm" onsubmit="myFunction(event)">
<!-- <img src="<?= base_url() . "public/assets/images/plugins/loading.gif" ?>" alt="loader1" style="display:none; height:30px; width:auto;" id="loaderImg"> -->
<div class="form-row">
<div class="form-group col-md-4">
<label for="cfname" class="col-form-label">First Name<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="cfname" name="cfname" value="<?= isset($customer['first_name']) ? $customer['first_name'] : '' ?>" placeholder="First Name" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-4">
<label for="csname" class="col-form-label">Last Name<span class="text-danger"> *</span></label>
<input type="text" class="form-control" name="csname" value="<?= isset($customer['last_name']) ? $customer['last_name'] : '' ?>" placeholder="Last Name" />
<div class="invalid-feedback"> Please provide. </div>
<input type="text" class="form-control" name="csname" value="<?= isset($customer['last_name']) ? $customer['last_name'] : '' ?>" placeholder="Last Name" required />
</div>
<div class="form-group col-md-4">
<label for="cmail" class="col-form-label">Email<span class="text-danger"> *</span></label>
@ -48,13 +48,9 @@
<div class="form-row">
<div class="form-group col-md-4">
<label for="cmobile" class="col-form-label">Mobile/Landline<span class="text-danger"> *</span></label>
<div class="input-group mb-2">
<div class="input-group-prepend">
</div>
<input type="text" class="form-control" id="cmobile" name="cmobile" value="<?= isset($customer['mobile_no']) ? $customer['mobile_no'] : '' ?>" placeholder="Mobile Number (Enter only numbers)" required minlength="10" onkeypress="return restriction(event)" onchange="checkExisting(this.value,'mobile_no','cmobile')" />
<div class="invalid-feedback"> Please provide. </div>
</div>
<span id="mobileValidationMessage"></span>
</div>
<div class="form-group col-md-4">
@ -111,12 +107,12 @@
<div class="form-group col-md-6">
<label for="baddress1" class="col-form-label">Address 1<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="baddress1" name="baddress1[]" placeholder="Address (eg : 1234 Main St)" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-6">
<label for="baddress2" class="col-form-label">Address 2<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="baddress2" name="baddress2[]" placeholder="Address (eg : 1234 Main St)" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
<div class="form-row">
@ -130,13 +126,13 @@
</option>
<?php } ?>
</select>
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-3">
<div id="billinput" style="display: block">
<label for="bistate" class="col-form-label">State</label>
<input type="text" class="form-control" id="bistate" name="bistate[]" placeholder="State" />
<!-- <div class="invalid-feedback"> Please provide. </div> -->
</div>
<div id="billdropdown" style="display: none">
<label for="bdstate" class="col-form-label">State</label>
@ -155,12 +151,12 @@
<div class="form-group col-md-3">
<label for="bcity" class="col-form-label">City<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="bcity" name="bcity[]" placeholder="City" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-3">
<label for="bzip" class="col-form-label">Postal Code<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="bzip" name="bzip[]" placeholder="Postal Code" required pattern="\d*" maxlength="10" />
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
<input type="hidden" id="bcustomer_address_id" name="bcustomer_address_id[]" placeholder="hidden for billing customer address id" />
@ -183,12 +179,12 @@
<div class="form-group col-md-6">
<label for="saddress1" class="col-form-label">Address 1<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="saddress1" name="saddress1[]" placeholder="Address (eg : 1234 Main St)" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-6">
<label for="saddress2" class="col-form-label">Address 2<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="saddress2" name="saddress2[]" placeholder="Address (eg : 1234 Main St)" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
<div class="form-row">
@ -203,7 +199,7 @@
</option>
<?php } ?>
</select>
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-3">
<label for="" class="col-form-label">State</label>
@ -221,12 +217,12 @@
<div class="form-group col-md-3">
<label for="scity" class="col-form-label">City<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="scity" name="scity[]" placeholder="City" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-3">
<label for="szip" class="col-form-label">Postal Code<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="szip" name="szip[]" placeholder="Postal Code" required pattern="\d*" maxlength="10" />
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
@ -555,14 +551,28 @@
}
</script>
<script>
document.getElementById('myForm').addEventListener('submit', function(event) {
// document.getElementById('myForm').addEventListener('submit', function(event) {
// var form = event.target;
// // Check if form is valid
// if (!form.checkValidity()) {
// event.preventDefault(); // Prevent form submission
// form.reportValidity(); // Display validation error messages
// $('#submitBtn').prop('disabled', false); // Re-enable the button
// } else {
// $('#submitBtn').prop('disabled', true); // Disable the button to prevent duplicate submissions
// }
// });
document.getElementById('myForm').addEventListener('submit', function(event) {
var form = event.target;
// Check if form is valid
if (!form.checkValidity()) {
event.preventDefault(); // Prevent form submission
form.reportValidity(); // Display validation error messages
$('#submitBtn').prop('disabled', false); // Re-enable the button
// Display custom alert message
alert('Please fill out all required fields correctly.');
} else {
$('#submitBtn').prop('disabled', true); // Disable the button to prevent duplicate submissions
}

View File

@ -91,6 +91,21 @@ input[type=number] {
z-index: 1050; /* Ensure it appears above other content */
}
#invoiceDate~.parsley-errors-list{
position: absolute;
top:35px;
}
#customerName~.parsley-errors-list{
position: relative;
top: 70px !important;
z-index: 0;
}
#loadShippingDropdown~.parsley-errors-list{
position: relative;
top: 70px !important;
z-index: 0;
}
</style>
<?php $flag_name = $invoice_type === '1' ? " Books" : " Scheme";
@ -124,7 +139,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
<div class="card-body">
<br>
<form method="POST" enctype="multipart/form-data" action="<?= base_url() . "save_invoice"; ?>" id="myForm">
<!-- class="parsley-examples" -->
<div class="form-group">
<div class="form-row">
@ -147,7 +162,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
<?php } else { ?>
<label for="customerName">Customer Name<span class="text-danger"> *</span></label>
<select class="form-control" id="customerName" name="customer_name" required data-toggle="select2" onchange="get_customer_billing_details(this.value); get_customer_membership_details(this.value)">
<select class="form-control" id="customerName" name="customer_name" required data-toggle="select2" onchange="get_customer_billing_details(this.value); get_customer_membership_details(this.value)" >
<option value="">Select a customer</option>
<?php if ($invoice_type === '1') { // invoice means Add new costomers;
?>
@ -171,8 +186,8 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
</div>
<div class="form-group col-md-5">
<label for="loadShippingDropdown">Shipping Address</label>
<select class="form-control" id="loadShippingDropdown" name="shipping_address_id" data-toggle="select2" onchange="get_customer_shipping_details(this.value)">
<label for="loadShippingDropdown">Shipping Address<span class="text-danger"> *</span></label>
<select class="form-control" id="loadShippingDropdown" name="shipping_address_id" data-toggle="select2" onchange="get_customer_shipping_details(this.value)" required>
<option value="">Select an address</option>
</select>
</div>
@ -245,7 +260,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
<label for="tosubcription">To Subscription<span class="text-danger"> *</span></label>
<!-- <input type="date" class="form-control" id="tosubcription" name="to_subscription" value="<?= $formattedtosubdate; ?>" required> -->
<div class="input-group">
<input type="text" class="form-control" id="tosubcription" name="to_subscription" value="<?= $formattedtosubdate; ?>" data-provide="datepicker" data-date-format="dd/mm/yyyy" data-date-autoclose="true">
<input type="text" class="form-control" id="tosubcription" name="to_subscription" value="<?= $formattedtosubdate; ?>" data-provide="datepicker" data-date-format="dd/mm/yyyy" data-date-autoclose="true" required>
<div class="input-group-append" style="margin-left: -11px;">
<span class="input-group-text" style="background-color: #37cde6;color:#fff;">
<i class="ri-calendar-event-fill" style="position: relative;left: 4px;"></i>
@ -551,7 +566,6 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
<div class="input-group-text">+91</div>
</div>
<input type="text" class="form-control" id="cus_mobile_no" placeholder="Mobile Number (Enter only numbers)" maxlength="10" onkeypress="return restriction(event)" onchange="checkExisting(this.value,'mobile_no','cus_mobile_no')" />
<div class="invalid-feedback"> Please provide. </div>
</div>
<span id="mobileValidationMessage"></span>
</div>
@ -723,7 +737,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
<div class="form-row">
<div class="form-group col-md-6">
<label for="bookName">Book Name<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="bookName" name="bookName" required>
<input type="text" class="form-control" id="bookName" name="bookName" required />
</div>
<div class="form-group col-md-6">
<label for="bookPrice">Price<span class="text-danger"> *</span></label>
@ -735,19 +749,16 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
<div class="form-group col-md-6">
<label for="publication_date" class="col-form-label">Publication Date<span class="text-danger"> *</span></label>
<input type="date" class="form-control" id="publication_date" name="publication_date" value="<?= isset($details['publication_date']) ? $details['publication_date'] : '' ?>" max="<?= date('Y-m-d'); ?>" required placeholder="Publication Date">
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-6">
<label for="isbn_code" class="col-form-label">ISBN Code</label>
<input type="text" class="form-control" id="isbn_code" name="isbn_code" placeholder="ISBN Code" />
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="publisher" class="col-form-label">Publisher Name</label>
<input type="text" class="form-control" id="publisher" name="publisher" placeholder="Publisher Name" value="<?= isset($details['publisher']) ? $details['publisher'] : '' ?>" />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-6">
<label for="publishers_code" class="col-form-label">Publisher Code<span class="text-danger"> *</span></label>
@ -1559,7 +1570,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
$(".subscribedetails").show(); // Change this line to use the class selector
let message = "No Earlier Membership found";
//$("#schemeName").text(message);
showAlert(message)
// showAlert(message); // kannan sir tolded no membership founded means don't show the alert dated on 21/nov/2024 evening
}
},
error: function() {
@ -1697,13 +1708,18 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
</script>
<script>
document.getElementById('myForm').addEventListener('submit', function(event) {
console.log("submit event");
var form = event.target;
var status = document.getElementById('status').value;
var invoice_type = document.getElementById('invoice_type').value;
if (form.checkValidity() === false) {
if (!form.checkValidity()) {
form.reportValidity(); // Display validation error messages
event.preventDefault(); // Prevent form submission if it's not valid
this.classList.add('was-validated');
if (status == "Draft") {
alert('Please fill out all required fields correctly.');
$('#saveDraftButton').prop('disabled', false);
$('#saveApprovedButton').prop('disabled', false);
$('#saveapproved').prop('disabled', false);

View File

@ -4,7 +4,7 @@
<div class="card-body">
<h4 class="header-title"><?= $page_name; ?></h4>
<p class="sub-header"> </p>
<form class="needs-validation" novalidate method="POST" enctype="multipart/form-data" action="<?= base_url() . "insert_scheme"; ?>" id="myForm">
<form class="parsley-examples needs-validation" novalidate method="POST" enctype="multipart/form-data" action="<?= base_url() . "insert_scheme"; ?>" id="myForm">
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-6">
@ -21,7 +21,7 @@
<div class="form-group col-md-6">
<label for="sduration" class="col-form-label">Duration<span class="text-danger">*</span></label>
<input type="number" class="form-control" name="sduration" value="<?= isset($scheme['duration']) ? $scheme['duration'] : '' ?>" placeholder="Duration In Months(ex 1)" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-6">
<label for="sku" class="col-form-label">SKU ID</label>
@ -73,16 +73,18 @@
<!-- end row -->
<script>
document.getElementById('myForm').addEventListener('submit', function(event) {
var form = event.target;
if (form.checkValidity() === false) {
form.reportValidity(); // Display validation error messages
event.preventDefault(); // Prevent form submission if it's not valid
$('#submitBtn').prop('disabled', false);
} else {
$('#submitBtn').prop('disabled', true);
}
});
var form = event.target;
// Check if form is valid
if (!form.checkValidity()) {
form.reportValidity(); // Display validation error messages
event.preventDefault(); // Prevent form submission if it's not valid
$('#submitBtn').prop('disabled', false); // Re-enable the button
// Display custom alert message
alert('Please fill out all required fields correctly.');
} else {
$('#submitBtn').prop('disabled', true); // Disable the button to prevent duplicate submissions
}
});
</script>

View File

@ -237,17 +237,21 @@
}
</script>
<script>
document.getElementById('myForm').addEventListener('submit', function(event) {
var form = event.target;
if (form.checkValidity() === false) {
form.reportValidity(); // Display validation error messages
event.preventDefault(); // Prevent form submission if it's not valid
$('#submitBtn').prop('disabled', false);
} else {
$('#submitBtn').prop('disabled', true);
}
});
document.getElementById('myForm').addEventListener('submit', function(event) {
var form = event.target;
// Check if form is valid
if (!form.checkValidity()) {
form.reportValidity(); // Display validation error messages
event.preventDefault(); // Prevent form submission if it's not valid
$('#submitBtn').prop('disabled', false); // Re-enable the button
// Display custom alert message
alert('Please fill out all required fields correctly.');
} else {
$('#submitBtn').prop('disabled', true); // Disable the button to prevent duplicate submissions
}
});
</script>
<!-- Modify the existing JavaScript code -->
<script>