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')) : ?> <?php if (session()->getFlashdata('success')) : ?>
<div class="alert alert-success"><?= session()->getFlashdata('success') ?></div> <div class="alert alert-success"><?= session()->getFlashdata('success') ?></div>
<?php endif; ?> <?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-group">
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="title" class="col-form-label">Book Name<span class="text-danger"> *</span></label> <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 /> <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>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="author" class="col-form-label">Author<span class="text-danger"> *</span></label> <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 /> <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> </div>
<div class="form-row"> <div class="form-row">
@ -44,12 +44,12 @@
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="publisher" class="col-form-label">Publisher Name<span class="text-danger"> *</span></label> <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 /> <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>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="publication_date" class="col-form-label">Publication Date<span class="text-danger"> *</span></label> <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"> <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>
</div> </div>
@ -61,7 +61,7 @@
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="isbn_code" class="col-form-label">ISBN Code<span class="text-danger"> *</span></label> <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 /> <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>
</div> </div>
@ -77,7 +77,7 @@
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="price" class="col-form-label">Price<span class="text-danger"> *</span></label> <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'] : '' ?>" /> <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>
</div> </div>
@ -183,19 +183,21 @@
}); });
</script> </script>
<script> <script>
document.getElementById('myForm').addEventListener('submit', function(event) { document.getElementById('myForm').addEventListener('submit', function(event) {
var form = event.target; 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 // Display custom alert message
event.preventDefault(); // Prevent form submission if it's not valid alert('Please fill out all required fields correctly.');
$('#submitBtn').prop('disabled', false); } else {
} else { $('#submitBtn').prop('disabled', true); // Disable the button to prevent duplicate submissions
}
$('#submitBtn').prop('disabled', true); });
}
});
</script> </script>
<script> <script>
const DateInput = document.getElementById("publication_date"); const DateInput = document.getElementById("publication_date");

View File

@ -26,18 +26,18 @@
<!-- Customer Details Tab --> <!-- Customer Details Tab -->
<div class="tab-pane fade show active" id="customerDetails" role="tabpanel" aria-labelledby="customerDetails-tab"> <div class="tab-pane fade show active" id="customerDetails" role="tabpanel" aria-labelledby="customerDetails-tab">
<!-- Customer details form fields --> <!-- 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"> --> <!-- <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-row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="cfname" class="col-form-label">First Name<span class="text-danger"> *</span></label> <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 /> <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>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="csname" class="col-form-label">Last Name<span class="text-danger"> *</span></label> <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" /> <input type="text" class="form-control" name="csname" value="<?= isset($customer['last_name']) ? $customer['last_name'] : '' ?>" placeholder="Last Name" required />
<div class="invalid-feedback"> Please provide. </div>
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="cmail" class="col-form-label">Email<span class="text-danger"> *</span></label> <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-row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="cmobile" class="col-form-label">Mobile/Landline<span class="text-danger"> *</span></label> <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')" /> <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> <span id="mobileValidationMessage"></span>
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
@ -111,12 +107,12 @@
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="baddress1" class="col-form-label">Address 1<span class="text-danger"> *</span></label> <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 /> <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>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="baddress2" class="col-form-label">Address 2<span class="text-danger"> *</span></label> <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 /> <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> </div>
<div class="form-row"> <div class="form-row">
@ -130,13 +126,13 @@
</option> </option>
<?php } ?> <?php } ?>
</select> </select>
<div class="invalid-feedback"> Please provide. </div>
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<div id="billinput" style="display: block"> <div id="billinput" style="display: block">
<label for="bistate" class="col-form-label">State</label> <label for="bistate" class="col-form-label">State</label>
<input type="text" class="form-control" id="bistate" name="bistate[]" placeholder="State" /> <input type="text" class="form-control" id="bistate" name="bistate[]" placeholder="State" />
<!-- <div class="invalid-feedback"> Please provide. </div> -->
</div> </div>
<div id="billdropdown" style="display: none"> <div id="billdropdown" style="display: none">
<label for="bdstate" class="col-form-label">State</label> <label for="bdstate" class="col-form-label">State</label>
@ -155,12 +151,12 @@
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="bcity" class="col-form-label">City<span class="text-danger"> *</span></label> <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 /> <input type="text" class="form-control" id="bcity" name="bcity[]" placeholder="City" required />
<div class="invalid-feedback"> Please provide. </div>
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="bzip" class="col-form-label">Postal Code<span class="text-danger"> *</span></label> <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" /> <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>
</div> </div>
<input type="hidden" id="bcustomer_address_id" name="bcustomer_address_id[]" placeholder="hidden for billing customer address id" /> <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"> <div class="form-group col-md-6">
<label for="saddress1" class="col-form-label">Address 1<span class="text-danger"> *</span></label> <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 /> <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>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="saddress2" class="col-form-label">Address 2<span class="text-danger"> *</span></label> <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 /> <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> </div>
<div class="form-row"> <div class="form-row">
@ -203,7 +199,7 @@
</option> </option>
<?php } ?> <?php } ?>
</select> </select>
<div class="invalid-feedback"> Please provide. </div>
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="" class="col-form-label">State</label> <label for="" class="col-form-label">State</label>
@ -221,12 +217,12 @@
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="scity" class="col-form-label">City<span class="text-danger"> *</span></label> <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 /> <input type="text" class="form-control" id="scity" name="scity[]" placeholder="City" required />
<div class="invalid-feedback"> Please provide. </div>
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="szip" class="col-form-label">Postal Code<span class="text-danger"> *</span></label> <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" /> <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>
</div> </div>
@ -555,14 +551,28 @@
} }
</script> </script>
<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; var form = event.target;
// Check if form is valid // Check if form is valid
if (!form.checkValidity()) { if (!form.checkValidity()) {
event.preventDefault(); // Prevent form submission event.preventDefault(); // Prevent form submission
form.reportValidity(); // Display validation error messages
$('#submitBtn').prop('disabled', false); // Re-enable the button $('#submitBtn').prop('disabled', false); // Re-enable the button
// Display custom alert message
alert('Please fill out all required fields correctly.');
} else { } else {
$('#submitBtn').prop('disabled', true); // Disable the button to prevent duplicate submissions $('#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 */ 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> </style>
<?php $flag_name = $invoice_type === '1' ? " Books" : " Scheme"; <?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"> <div class="card-body">
<br> <br>
<form method="POST" enctype="multipart/form-data" action="<?= base_url() . "save_invoice"; ?>" id="myForm"> <form method="POST" enctype="multipart/form-data" action="<?= base_url() . "save_invoice"; ?>" id="myForm">
<!-- class="parsley-examples" -->
<div class="form-group"> <div class="form-group">
<div class="form-row"> <div class="form-row">
@ -147,7 +162,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
<?php } else { ?> <?php } else { ?>
<label for="customerName">Customer Name<span class="text-danger"> *</span></label> <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> <option value="">Select a customer</option>
<?php if ($invoice_type === '1') { // invoice means Add new costomers; <?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>
<div class="form-group col-md-5"> <div class="form-group col-md-5">
<label for="loadShippingDropdown">Shipping Address</label> <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)"> <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> <option value="">Select an address</option>
</select> </select>
</div> </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> <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> --> <!-- <input type="date" class="form-control" id="tosubcription" name="to_subscription" value="<?= $formattedtosubdate; ?>" required> -->
<div class="input-group"> <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;"> <div class="input-group-append" style="margin-left: -11px;">
<span class="input-group-text" style="background-color: #37cde6;color:#fff;"> <span class="input-group-text" style="background-color: #37cde6;color:#fff;">
<i class="ri-calendar-event-fill" style="position: relative;left: 4px;"></i> <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 class="input-group-text">+91</div>
</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')" /> <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> </div>
<span id="mobileValidationMessage"></span> <span id="mobileValidationMessage"></span>
</div> </div>
@ -723,7 +737,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="bookName">Book Name<span class="text-danger"> *</span></label> <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>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="bookPrice">Price<span class="text-danger"> *</span></label> <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"> <div class="form-group col-md-6">
<label for="publication_date" class="col-form-label">Publication Date<span class="text-danger"> *</span></label> <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"> <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>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="isbn_code" class="col-form-label">ISBN Code</label> <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" /> <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> </div>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="publisher" class="col-form-label">Publisher Name</label> <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'] : '' ?>" /> <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>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="publishers_code" class="col-form-label">Publisher Code<span class="text-danger"> *</span></label> <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 $(".subscribedetails").show(); // Change this line to use the class selector
let message = "No Earlier Membership found"; let message = "No Earlier Membership found";
//$("#schemeName").text(message); //$("#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() { error: function() {
@ -1697,13 +1708,18 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
</script> </script>
<script> <script>
document.getElementById('myForm').addEventListener('submit', function(event) { document.getElementById('myForm').addEventListener('submit', function(event) {
console.log("submit event");
var form = event.target; var form = event.target;
var status = document.getElementById('status').value; var status = document.getElementById('status').value;
var invoice_type = document.getElementById('invoice_type').value; var invoice_type = document.getElementById('invoice_type').value;
if (form.checkValidity() === false) { if (!form.checkValidity()) {
form.reportValidity(); // Display validation error messages form.reportValidity(); // Display validation error messages
event.preventDefault(); // Prevent form submission if it's not valid event.preventDefault(); // Prevent form submission if it's not valid
this.classList.add('was-validated');
if (status == "Draft") { if (status == "Draft") {
alert('Please fill out all required fields correctly.');
$('#saveDraftButton').prop('disabled', false); $('#saveDraftButton').prop('disabled', false);
$('#saveApprovedButton').prop('disabled', false); $('#saveApprovedButton').prop('disabled', false);
$('#saveapproved').prop('disabled', false); $('#saveapproved').prop('disabled', false);

View File

@ -4,7 +4,7 @@
<div class="card-body"> <div class="card-body">
<h4 class="header-title"><?= $page_name; ?></h4> <h4 class="header-title"><?= $page_name; ?></h4>
<p class="sub-header"> </p> <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-group">
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
@ -21,7 +21,7 @@
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="sduration" class="col-form-label">Duration<span class="text-danger">*</span></label> <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 /> <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>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="sku" class="col-form-label">SKU ID</label> <label for="sku" class="col-form-label">SKU ID</label>
@ -73,16 +73,18 @@
<!-- end row --> <!-- end row -->
<script> <script>
document.getElementById('myForm').addEventListener('submit', function(event) { document.getElementById('myForm').addEventListener('submit', function(event) {
var form = event.target; 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 // Display custom alert message
event.preventDefault(); // Prevent form submission if it's not valid alert('Please fill out all required fields correctly.');
$('#submitBtn').prop('disabled', false); } else {
} else { $('#submitBtn').prop('disabled', true); // Disable the button to prevent duplicate submissions
}
$('#submitBtn').prop('disabled', true); });
}
});
</script> </script>

View File

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