year check valid or not All form commit

This commit is contained in:
2025-12-08 13:40:33 +05:30
parent bd24fa5f4e
commit 425f213606
13 changed files with 175 additions and 193 deletions

18
main.py
View File

@@ -6,7 +6,6 @@ import io
import mysql.connector
from werkzeug.utils import secure_filename
from config import db_config
from AppCode.Config import DBConfig
from AppCode.FileHandler import FileHandler
from AppCode.DocumentHandler import DocumentHandler
@@ -133,6 +132,23 @@ def update_itr(id):
return render_template('update_itr.html', record=record)
# new new -- check year in table existe or not by using ajax calling.
@app.route('/check_year', methods=['POST'])
def check_year():
table_name = request.json.get("table")
year = request.json.get("year")
conn = DBConfig.get_db_connection()
cursor = conn.cursor()
query = f"SELECT COUNT(*) FROM {table_name} WHERE year = %s"
cursor.execute(query, (year,))
result = cursor.fetchone()[0]
cursor.close()
conn.close()
return {"exists": result > 0}
## ===============================================