/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
var validatedGSTIN=false;
var validatedMobile=false;
var validatedName=false;
var validatedAmount=false;
document.addEventListener('DOMContentLoaded', function() {
const inputFields = document.querySelectorAll('input[type="text"]');
inputFields.forEach(function(input) {
input.addEventListener('input', function() {
this.value = this.value.toUpperCase();
});
});
});
function getTradeName(){
//document.getElementById("tradeName").value="";
// document.getElementById("tradeName").disabled=false;
$("#loading").show();
document.getElementById("gstin").style.borderColor = "initial";
var gstin=encodeURIComponent(String(document.getElementById("gstin").value).trim());
if (gstin == ""){
$("#loading").hide();
document.getElementById("gstin").focus();
document.getElementById("gstin").style.borderColor = "red";
validatedGSTIN=false;
return false;}
// var gstOrTemp=$("input[name='optradio']:checked").val();
//alert(gstOrTemp);
//new code check 22032024
$.ajax({
type:"POST",
url: "checkDuplicateEntry",
data: `gstin=${gstin.trim()}`,
processData: false,
contenttype:false,
cache: false,
success: function(results){
//alert(results);
if(results.trim()==""){
$("#loading").hide();
$("#errorMsg").empty();
$("#errorMsg").append("CONECTION ERROR TRY AGAIN");
}else if(results.trim()=="PASS_GENERATED"){
$("#loading").hide();
$("#errorMsg").empty();
$("#errorMsg").append("CANNOT RESUBMIT FORM WITH THIS GSTIN, AS AUCTION PASS ALREADY GENERATED. PLEASE CONTACT PROPER OFFICER FOR MORE INFORMATION");
}else if(results.trim()=="NO_DUPLICATE"){
$.ajax({
type:"POST",
url: "getTradeName",
data: 'gstin='+ gstin,
processData: false,
contenttype:false,
cache: false,
success: function(results){
if(results.trim()=="NULL"){
$("#loading").hide();
//alert(results);
//$('gstin').popover();
//document.getElementById("tradeName").readOnly=false;
$("#errorMsg").empty();
$("#errorMsg").append("GSTIN NOT FOUND OR CANCELLED");
// document.getElementById("gstin").style.borderColor = "red";
// document.getElementById("gstinNotFound").style.display = "block";
// document.getElementById("tradeName").placeholder="Enter TRADE NAME"
validatedGSTIN=false;
return false;
}
else{
$("#loading").hide();
$("#errorMsg").empty();
$tradeName = results.split("#")[0];
$legalName = results.split("#")[1];
// document.getElementById("gstinNotFound").style.display = "none";
document.getElementById("tradeName").value=$tradeName;
document.getElementById("tradeName").disabled=true;
document.getElementById("legalName").value=$legalName;
document.getElementById("legalName").disabled=true;
validatedGSTIN=true;
return true;
}
}
});
}else if(results.trim()=="NO_PASS"){
$("#loading").hide();
if (window.confirm("ALERT:::You have already applied once against this GSTIN! IF YOU RESUBMIT THIS FORM THE EARLIER ENTRY WITH THIS GSTIN WILL BE DELETED. DO YOU WANT TO PROCEED?")) {
$.ajax({
type:"POST",
url: "getTradeName",
data: 'gstin='+ gstin,
processData: false,
contenttype:false,
cache: false,
success: function(results){
if(results.trim()=="NULL"){
alert(results);
//$('gstin').popover();
//document.getElementById("tradeName").readOnly=false;
$("#errorMsg").empty();
$("#errorMsg").append("GSTIN NOT FOUND");
// document.getElementById("gstin").style.borderColor = "red";
// document.getElementById("gstinNotFound").style.display = "block";
// document.getElementById("tradeName").placeholder="Enter TRADE NAME"
validatedGSTIN=false;
return false;
}
else{
$("#errorMsg").empty();
// $("#errorMsg").append("GSTIN NOT FOUND");
$tradeName = results.split("#")[0];
$legalName = results.split("#")[1];
// document.getElementById("gstinNotFound").style.display = "none";
document.getElementById("tradeName").value=$tradeName;
document.getElementById("tradeName").disabled=true;
document.getElementById("legalName").value=$legalName;
document.getElementById("legalName").disabled=true;
validatedGSTIN=true;
return true;
}
}
});
//alert("delete the data and update the table with new entry");
} else {
alert("Request Cancelled");
}
}
},
error:function(a,b){
alert(b);
}
});
//end 22032024
// $.ajax({
// type:"POST",
// url: "getTradeName",
// data: 'gstin='+ gstin,
// processData: false,
// contenttype:false,
// cache: false,
// success: function(results){
//
//
// if(results.trim()=="NULL"){
// alert(results);
//
// //$('gstin').popover();
// //document.getElementById("tradeName").readOnly=false;
// document.getElementById("gstin").style.borderColor = "red";
// document.getElementById("gstinNotFound").style.display = "block";
//// document.getElementById("tradeName").placeholder="Enter TRADE NAME"
// validatedGSTIN=false;
// return false;
// }
// else{
// $tradeName = results.split("#")[0];
// $legalName = results.split("#")[1];
// document.getElementById("gstinNotFound").style.display = "none";
// document.getElementById("tradeName").value=$tradeName;
// document.getElementById("tradeName").disabled=true;
//
// document.getElementById("legalName").value=$legalName;
// document.getElementById("legalName").disabled=true;
// validatedGSTIN=true;
// return true;
// }
//
//
//
// }
// });
}
function validateMobile() {
var mobileInput = String(document.getElementById('mobile').value).trim();
//const errorElement = document.getElementById('mobileError');
//alert(mobileInput);
const mobilePattern = /^\d{10}$/; // Regular expression for 10-digit mobile number
if (mobilePattern.test(mobileInput)) {
// Valid mobile number
document.getElementById('mobileError').textContent = ''; // Clear error message
document.getElementById('mobileError').style.display = 'none'; // Hide error message
document.getElementById('mobile').style.borderColor = "initial";
validatedMobile=true;
return true;
} else {
// Invalid mobile number
document.getElementById('mobileError').textContent = 'Please enter a 10-digit mobile number'; // Set error message
document.getElementById('mobileError').style.display = 'block'; // Show error message
//document.getElementById('mobile').focus();
document.getElementById('mobile').style.borderColor = "red";
validatedMobile=false;
return false;
}
}
function validateName() {
var appliName = String(document.getElementById('applicant-name').value).trim();
//const errorElement = document.getElementById('mobileError');
//alert(mobileInput);
validatedName=true;
// const namePattern = /^[a-zA-Z\s]*$/; // Regular expression for NAME with space
//
// if (namePattern.test(appliName)) {
// // Valid mobile number
// document.getElementById('nameError').textContent = ''; // Clear error message
// document.getElementById('nameError').style.display = 'none'; // Hide error message
// document.getElementById('applicant-name').style.borderColor = "initial";
// validatedName=true;
// return true;
//
// } else {
// // Invalid mobile number
// document.getElementById('nameError').textContent = 'Please enter proper Name'; // Set error message
// document.getElementById('nameError').style.display = 'block'; // Show error message
// //document.getElementById('mobile').focus();
// document.getElementById('applicant-name').style.borderColor = "red";
// validatedName=false;
// return false;
//
// }
}
function validateAmount() {
var amnt = String(document.getElementById('amount').value).trim();
//const errorElement = document.getElementById('mobileError');
//alert(mobileInput);
const amountPattern = /^\d*\.?\d*$/; // Regular expression for amount
if (amountPattern.test(amnt)) {
// Valid mobile number
document.getElementById('amount-error').textContent = ''; // Clear error message
document.getElementById('amount-error').style.display = 'none'; // Hide error message
document.getElementById('amount').style.borderColor = "initial";
validatedAmount=true;
return true;
} else {
// Invalid mobile number
document.getElementById('amount-error').textContent = 'Please enter proper Name'; // Set error message
document.getElementById('amount-error').style.display = 'block'; // Show error message
//document.getElementById('mobile').focus();
document.getElementById('amount').style.borderColor = "red";
validatedAmount=false;
return false;
}
}
function createAckPage(){
// const urlParams = new URLSearchParams(window.location.search);
// const gstin = urlParams.get('gstin');
// //alert(gstin);
$.ajax({
type:"POST",
url: "createAckPage",
// data: `gstin=${encodeURIComponent(gstin.trim())}`,
processData: false,
contenttype:false,
cache: false,
success: function(results){
//alert(results);
if(results.trim()==""){
$("#errorMsg").empty();
$("#errorMsg").append("CONECTION ERROR TRY AGAIN");
}else if(results.trim()=="ERROR"){
$("#errorMsg").empty();
$("#errorMsg").append("CONECTION ERROR TRY AGAIN");
}else{
//
$("#bodyData").empty();
$("#bodyData").append(results.trim());
}
},
error:function(a,b){
alert(b);
}
});
}
function checkGSTINforPrint(){
var gstin=encodeURIComponent(String(document.getElementById("gstin").value).trim());
$("#errorMsg").empty();
if (gstin == ""){
document.getElementById("gstin").focus();
document.getElementById("gstin").style.borderColor = "red";
validatedGSTIN=false;
return false;
}
$.ajax({
type:"POST",
url: "checkDuplicateEntry",
data: `gstin=${gstin.trim()}`,
processData: false,
contenttype:false,
cache: false,
success: function(results){
//alert(results);
if(results.trim()==""){
$("#errorMsg").empty();
$("#errorMsg").append("CONECTION ERROR TRY AGAIN");
}else if(results.trim()=="NO_DUPLICATE"){
$("#errorMsg").append("NO APPLICATION FOUND WITH THIS GSTIN");
}else {
var url='ackPage.jsp';
window.open(url, '_blank');
}
}
});
}
document.addEventListener('DOMContentLoaded', function() {
const form = document.getElementById('aucForm');
form.addEventListener('submit', function(event) {
event.preventDefault(); // Prevent the form from submitting
const gstin = encodeURIComponent(document.getElementById('gstin').value);
const tradeName = encodeURIComponent(document.getElementById('tradeName').value);
const legalName = encodeURIComponent(document.getElementById('legalName').value);
const applicantName = encodeURIComponent(document.getElementById('applicant-name').value);
const mobile = encodeURIComponent(document.getElementById('mobile').value);
const relationship = encodeURIComponent(document.getElementById('relationship').value);
const proof = encodeURIComponent(document.querySelector('input[name="proof"]:checked').value);
const idNumber = encodeURIComponent(document.getElementById('id-number').value);
const ddNumber = encodeURIComponent(document.getElementById('dd-number').value);
const ddDate = encodeURIComponent(document.getElementById('dd-date').value);
//alert(ddDate);
const ddAmount = encodeURIComponent(document.getElementById('amount').value);
//const message = `Please recheck the data before submitting:\nGSTIN: ${gstin}\nTrade Name: ${tradeName}\nLegal Name: ${legalName}\nApplicant Name: ${applicantName}\nMobile: ${mobile}\nRelationship: ${relationship}\nProof of Identity: ${proof}\nID Number: ${idNumber}\nDD Number: ${ddNumber}\nDD Date: ${ddDate}\nDD Amount: ${ddAmount}`;
//alert(message);
$("#errorMsg").empty()
if(validatedGSTIN&&validatedMobile&&validatedName&&validatedAmount){
$.ajax({
type:"POST",
url: "checkDuplicateEntry",
data: `gstin=${gstin.trim()}`,
processData: false,
contenttype:false,
cache: false,
success: function(results){
//alert(results);
if(results.trim()==""){
$("#errorMsg").empty();
$("#errorMsg").append("CONECTION ERROR TRY AGAIN");
}else if(results.trim()=="PASS_GENERATED"){
$("#errorMsg").empty();
$("#errorMsg").append("CANNOT RESUBMIT FORM WITH THIS GSTIN, AS AUCTION PASS ALREADY GENERATED. PLEASE CONTACT PROPER OFFICER FOR MORE INFORMATION");
}else if(results.trim()=="NO_DUPLICATE"){
$.ajax({
type:"POST",
url: "genAcknowleg",
data: `gstin=${gstin.trim()}&trade_name=${tradeName.trim()}&legal_name=${legalName.trim()}&applicantName=${applicantName.trim()}&mobile=${mobile.trim()}&relation=${relationship.trim()}&proof_of_id=${proof.trim()}&id_num=${idNumber.trim()}&dd_num=${ddNumber.trim()}&dd_date=${ddDate.trim()}&dd_amount=${ddAmount.trim()}`,
processData: false,
contenttype:false,
cache: false,
success: function(results){
//alert(results);
if(results.trim()==""){
$("#errorMsg").empty();
$("#errorMsg").append("CONECTION ERROR TRY AGAIN");
}else if(results.trim()=="ERROR"){
$("#errorMsg").empty();
$("#errorMsg").append("CONECTION ERROR TRY AGAIN");
}else{
$("#errorMsg").empty();
$("#errorMsg").append("
Form Submitted.
");
$("#ackNoDiv").empty();
$("#ackNoDiv").append("ACK No.: "+results.trim()+"
");
//TODO04042024
var button = document.getElementById('formSubmit');
// Hide the button by setting its display style to 'none'
button.style.display = 'none';
$("#aucForm").find(":input:not(:disabled)").prop("disabled", true);
var url='ackPage.jsp';
window.open(url, '_blank');
//
}
},
error:function(a,b){
alert(b);
}
});
//Create a new page to be printed
//createAckPage(gstin);
//var url='ackPage.jsp?gstin=' + encodeURIComponent(gstin);
}else if(results.trim()=="NO_PASS"){
if (window.confirm("ALERT:::ARE YOU SURE YOU WANT TO DELETE THE EARLIER ENTRY AND MAKE A FRESH ENTRY WITH THIS NEW DATA?")) {
//alert("delete the data and update the table with new entry");
$.ajax({
type:"POST",
url: "userUpdateData",
data: `gstin=${gstin.trim()}&trade_name=${tradeName.trim()}&legal_name=${legalName.trim()}&applicantName=${applicantName.trim()}&mobile=${mobile.trim()}&relation=${relationship.trim()}&proof_of_id=${proof.trim()}&id_num=${idNumber.trim()}&dd_num=${ddNumber.trim()}&dd_date=${ddDate.trim()}&dd_amount=${ddAmount.trim()}`,
processData: false,
contenttype:false,
cache: false,
success: function(results){
//alert(results);
if(results.trim()==""){
$("#errorMsg").empty();
$("#errorMsg").append("CONECTION ERROR TRY AGAIN");
}else if(results.trim()=="ERROR"){
$("#errorMsg").empty();
$("#errorMsg").append("CONECTION ERROR TRY AGAIN");
}else{
$("#errorMsg").empty();
$("#errorMsg").append("Form Re-Submitted.
");
//
$("#ackNoDiv").empty();
$("#ackNoDiv").append("ACK No.: "+results.trim()+"
");
//hide the submit button
// Get the button element by id
var button = document.getElementById('formSubmit');
// Hide the button by setting its display style to 'none'
button.style.display = 'none';
var url='ackPage.jsp?gstin=' + encodeURIComponent(gstin);
window.open(url, '_blank');
}
},
error:function(a,b){
alert(b);
}
});
} else {
alert("Request Cancelled");
}
}
},
error:function(a,b){
alert(b);
}
});
}else{
alert("FORM NOT SUBMITTED. PLEAE CHECK THE FIELDS AND RESUBMIT");
return false;
}
});
});
//---------------------------------