Village module delete issue resolved and also message shown in alert #8
3
.gitignore
vendored
3
.gitignore
vendored
@@ -3,4 +3,5 @@ venv/
|
||||
__pycache__/
|
||||
|
||||
static/downloads/
|
||||
static/uploads/
|
||||
static/uploads/
|
||||
|
||||
|
||||
@@ -1,362 +1,4 @@
|
||||
# from flask_login import current_user
|
||||
# from model.Utilities import RegEx, ResponseHandler, HtmlHelper, ItemCRUDType
|
||||
# from model.Log import LogHelper
|
||||
|
||||
# import config
|
||||
# import re
|
||||
# import mysql.connector
|
||||
|
||||
|
||||
# # ----------------------------------------------------------
|
||||
# # Mapping Class
|
||||
# # ----------------------------------------------------------
|
||||
# class itemCRUDMapping:
|
||||
|
||||
# def __init__(self, itemType):
|
||||
# if itemType is ItemCRUDType.Village:
|
||||
# self.name = "Village"
|
||||
# elif itemType is ItemCRUDType.Block:
|
||||
# self.name = "Block"
|
||||
# elif itemType is ItemCRUDType.State:
|
||||
# self.name = "State"
|
||||
# elif itemType is ItemCRUDType.HoldType:
|
||||
# self.name = "Hold Type"
|
||||
# elif itemType is ItemCRUDType.Subcontractor:
|
||||
# self.name = "Subcontractor"
|
||||
# else:
|
||||
# self.name = "Item"
|
||||
|
||||
|
||||
# # ----------------------------------------------------------
|
||||
# # Generic CRUD Class
|
||||
# # ----------------------------------------------------------
|
||||
# class ItemCRUD:
|
||||
|
||||
# def __init__(self, itemType):
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = ""
|
||||
# self.itemCRUDType = itemType
|
||||
# self.itemCRUDMapping = itemCRUDMapping(itemType)
|
||||
|
||||
# # ----------------------------------------------------------
|
||||
# # DELETE
|
||||
# # ----------------------------------------------------------
|
||||
# def DeleteItem(self, request, itemID, storedprocDelete):
|
||||
|
||||
# connection = config.get_db_connection()
|
||||
# cursor = connection.cursor()
|
||||
|
||||
# LogHelper.log_action(
|
||||
# f"Delete {self.itemCRUDMapping.name}",
|
||||
# f"User {current_user.id} deleted {self.itemCRUDMapping.name} '{itemID}'"
|
||||
# )
|
||||
|
||||
# try:
|
||||
# cursor.callproc(storedprocDelete, (itemID,))
|
||||
# connection.commit()
|
||||
|
||||
# self.isSuccess = True
|
||||
# self.resultMessage = HtmlHelper.json_response(
|
||||
# ResponseHandler.delete_success(self.itemCRUDMapping.name), 200
|
||||
# )
|
||||
|
||||
# except mysql.connector.Error as e:
|
||||
# print(f"Error deleting {self.itemCRUDMapping.name}: {e}")
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = HtmlHelper.json_response(
|
||||
# ResponseHandler.delete_failure(self.itemCRUDMapping.name), 500
|
||||
# )
|
||||
|
||||
# finally:
|
||||
# cursor.close()
|
||||
# connection.close()
|
||||
|
||||
# # ----------------------------------------------------------
|
||||
# # ADD
|
||||
# # ----------------------------------------------------------
|
||||
# def AddItem(self, request, parentid=None, childname=None, storedprocfetch=None, storedprocadd=None, data=None):
|
||||
|
||||
# connection = config.get_db_connection()
|
||||
# if not connection:
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = HtmlHelper.json_response(
|
||||
# ResponseHandler.db_connection_failure(), 500
|
||||
# )
|
||||
# return
|
||||
|
||||
# cursor = connection.cursor()
|
||||
|
||||
# LogHelper.log_action(
|
||||
# f"Add {self.itemCRUDMapping.name}",
|
||||
# f"User {current_user.id} adding '{childname if childname else (data.get('Contractor_Name') if data else '')}'"
|
||||
# )
|
||||
|
||||
# try:
|
||||
# # ======================================================
|
||||
# # SUBCONTRACTOR (MULTI-FIELD)
|
||||
# # ======================================================
|
||||
# if data:
|
||||
|
||||
# # Duplicate check
|
||||
# cursor.callproc(storedprocfetch, (data['Contractor_Name'],))
|
||||
|
||||
# existing_item = None
|
||||
# for rs in cursor.stored_results():
|
||||
# existing_item = rs.fetchone()
|
||||
|
||||
# if existing_item:
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = HtmlHelper.json_response(
|
||||
# ResponseHandler.already_exists(self.itemCRUDMapping.name), 409
|
||||
# )
|
||||
# return
|
||||
|
||||
# # Insert
|
||||
# cursor.callproc(storedprocadd, (
|
||||
# data['Contractor_Name'],
|
||||
# data['Address'],
|
||||
# data['Mobile_No'],
|
||||
# data['PAN_No'],
|
||||
# data['Email'],
|
||||
# data['Gender'],
|
||||
# data['GST_Registration_Type'],
|
||||
# data['GST_No'],
|
||||
# data['Contractor_password']
|
||||
# ))
|
||||
|
||||
# connection.commit()
|
||||
|
||||
# self.isSuccess = True
|
||||
# self.resultMessage = HtmlHelper.json_response(
|
||||
# ResponseHandler.add_success(self.itemCRUDMapping.name), 200
|
||||
# )
|
||||
# return
|
||||
|
||||
# # ======================================================
|
||||
# # NORMAL (Village / Block / State)
|
||||
# # ======================================================
|
||||
# if not re.match(RegEx.patternAlphabetOnly, childname):
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = HtmlHelper.json_response(
|
||||
# ResponseHandler.invalid_name(self.itemCRUDMapping.name), 400
|
||||
# )
|
||||
# return
|
||||
|
||||
# # Duplicate check
|
||||
# if parentid is None:
|
||||
# cursor.callproc(storedprocfetch, (childname,))
|
||||
# else:
|
||||
# cursor.callproc(storedprocfetch, (childname, parentid))
|
||||
|
||||
# existing_item = None
|
||||
# for rs in cursor.stored_results():
|
||||
# existing_item = rs.fetchone()
|
||||
|
||||
# if existing_item:
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = HtmlHelper.json_response(
|
||||
# ResponseHandler.already_exists(self.itemCRUDMapping.name), 409
|
||||
# )
|
||||
# return
|
||||
|
||||
# # Insert
|
||||
# if parentid is None:
|
||||
# cursor.callproc(storedprocadd, (childname,))
|
||||
# else:
|
||||
# cursor.callproc(storedprocadd, (childname, parentid))
|
||||
|
||||
# connection.commit()
|
||||
|
||||
# self.isSuccess = True
|
||||
# self.resultMessage = HtmlHelper.json_response(
|
||||
|
||||
# ResponseHandler.add_success(self.itemCRUDMapping.name), 200
|
||||
# )
|
||||
|
||||
# except mysql.connector.Error as e:
|
||||
# print(f"Database Error: {e}")
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = HtmlHelper.json_response(
|
||||
# ResponseHandler.add_failure(self.itemCRUDMapping.name), 500
|
||||
# )
|
||||
|
||||
# finally:
|
||||
# cursor.close()
|
||||
# connection.close()
|
||||
|
||||
# # ----------------------------------------------------------
|
||||
# # EDIT
|
||||
# # ----------------------------------------------------------
|
||||
# def EditItem(self, request, childid, parentid=None, childname=None, storedprocupdate=None, data=None):
|
||||
|
||||
# connection = config.get_db_connection()
|
||||
# cursor = connection.cursor()
|
||||
|
||||
# LogHelper.log_action(
|
||||
# f"Edit {self.itemCRUDMapping.name}",
|
||||
# f"User {current_user.id} edited '{childid}'"
|
||||
# )
|
||||
|
||||
# try:
|
||||
# # ======================================================
|
||||
# # SUBCONTRACTOR (MULTI-FIELD)
|
||||
# # ======================================================
|
||||
# if data:
|
||||
# cursor.callproc(storedprocupdate, (
|
||||
# childid,
|
||||
# data['Contractor_Name'],
|
||||
# data['Address'],
|
||||
# data['Mobile_No'],
|
||||
# data['PAN_No'],
|
||||
# data['Email'],
|
||||
# data['Gender'],
|
||||
# data['GST_Registration_Type'],
|
||||
# data['GST_No'],
|
||||
# data['Contractor_password']
|
||||
# ))
|
||||
|
||||
# connection.commit()
|
||||
|
||||
# self.isSuccess = True
|
||||
# self.resultMessage = HtmlHelper.json_response(
|
||||
# ResponseHandler.update_success(self.itemCRUDMapping.name), 200
|
||||
# )
|
||||
# return
|
||||
|
||||
# # ======================================================
|
||||
# # NORMAL
|
||||
# # ======================================================
|
||||
# if not re.match(RegEx.patternAlphabetOnly, childname):
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = ResponseHandler.update_failure(self.itemCRUDMapping.name)['message']
|
||||
# return
|
||||
|
||||
# if parentid is None:
|
||||
# cursor.callproc(storedprocupdate, (childid, childname))
|
||||
# else:
|
||||
# cursor.callproc(storedprocupdate, (childid, parentid, childname))
|
||||
|
||||
# connection.commit()
|
||||
|
||||
# self.isSuccess = True
|
||||
# self.resultMessage = ResponseHandler.update_success(self.itemCRUDMapping.name)['message']
|
||||
|
||||
# except mysql.connector.Error as e:
|
||||
# print(f"Error updating {self.itemCRUDMapping.name}: {e}")
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = HtmlHelper.json_response(
|
||||
# ResponseHandler.update_failure(self.itemCRUDMapping.name), 500
|
||||
# )
|
||||
|
||||
# finally:
|
||||
# cursor.close()
|
||||
# connection.close()
|
||||
|
||||
# # ----------------------------------------------------------
|
||||
# # GET ALL
|
||||
# # ----------------------------------------------------------
|
||||
# def GetAllData(self, request, storedproc):
|
||||
|
||||
# data = []
|
||||
# connection = config.get_db_connection()
|
||||
|
||||
# if not connection:
|
||||
# return []
|
||||
|
||||
# cursor = connection.cursor()
|
||||
|
||||
# try:
|
||||
# cursor.callproc(storedproc)
|
||||
|
||||
# for result in cursor.stored_results():
|
||||
# data = result.fetchall()
|
||||
|
||||
# self.isSuccess = True
|
||||
|
||||
# except mysql.connector.Error as e:
|
||||
# print(f"Error fetching {self.itemCRUDMapping.name}: {e}")
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = HtmlHelper.json_response(
|
||||
# ResponseHandler.fetch_failure(self.itemCRUDMapping.name), 500
|
||||
# )
|
||||
# return []
|
||||
|
||||
# finally:
|
||||
# cursor.close()
|
||||
# connection.close()
|
||||
|
||||
# return data
|
||||
|
||||
# # ----------------------------------------------------------
|
||||
# # GET BY ID
|
||||
# # ----------------------------------------------------------
|
||||
# def GetDataByID(self, id, storedproc):
|
||||
|
||||
# data = None
|
||||
# connection = config.get_db_connection()
|
||||
# cursor = connection.cursor()
|
||||
|
||||
# try:
|
||||
# cursor.callproc(storedproc, (id,))
|
||||
|
||||
# for rs in cursor.stored_results():
|
||||
# data = rs.fetchone()
|
||||
|
||||
# except mysql.connector.Error as e:
|
||||
# print(f"Error fetching {self.itemCRUDMapping.name}: {e}")
|
||||
|
||||
# finally:
|
||||
# cursor.close()
|
||||
# connection.close()
|
||||
|
||||
# return data
|
||||
|
||||
# # ----------------------------------------------------------
|
||||
# # CHECK ITEM
|
||||
# # ----------------------------------------------------------
|
||||
# def CheckItem(self, request, parentid, childname, storedprocfetch):
|
||||
|
||||
# connection = config.get_db_connection()
|
||||
# cursor = connection.cursor()
|
||||
|
||||
# LogHelper.log_action(
|
||||
# f"Check {self.itemCRUDMapping.name}",
|
||||
# f"User {current_user.id} checked '{childname}'"
|
||||
# )
|
||||
|
||||
# if not re.match(RegEx.patternAlphabetOnly, childname):
|
||||
# return HtmlHelper.json_response(
|
||||
# ResponseHandler.invalid_name(self.itemCRUDMapping.name), 400
|
||||
# )
|
||||
|
||||
# try:
|
||||
# if parentid is None:
|
||||
# cursor.callproc(storedprocfetch, (childname,))
|
||||
# else:
|
||||
# cursor.callproc(storedprocfetch, (childname, parentid))
|
||||
|
||||
# existing_item = None
|
||||
# for rs in cursor.stored_results():
|
||||
# existing_item = rs.fetchone()
|
||||
|
||||
# if existing_item:
|
||||
# return HtmlHelper.json_response(
|
||||
# ResponseHandler.already_exists(self.itemCRUDMapping.name), 409
|
||||
# )
|
||||
|
||||
# return HtmlHelper.json_response(
|
||||
# ResponseHandler.is_available(self.itemCRUDMapping.name), 200
|
||||
# )
|
||||
|
||||
# except mysql.connector.Error as e:
|
||||
# print(f"Error checking {self.itemCRUDMapping.name}: {e}")
|
||||
# return HtmlHelper.json_response(
|
||||
# ResponseHandler.fetch_failure(self.itemCRUDMapping.name), 500
|
||||
# )
|
||||
|
||||
# finally:
|
||||
# cursor.close()
|
||||
# connection.close()
|
||||
|
||||
|
||||
from flask_login import current_user
|
||||
|
||||
171
model/Village.py
171
model/Village.py
@@ -1,175 +1,4 @@
|
||||
# from model.Utilities import ResponseHandler, HtmlHelper, ItemCRUDType
|
||||
# import config
|
||||
# import mysql.connector
|
||||
# from model.ItemCRUD import ItemCRUD
|
||||
|
||||
|
||||
# class Village:
|
||||
# isSuccess = False
|
||||
# resultMessage = ""
|
||||
|
||||
# def __init__(self):
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = ""
|
||||
# self.village = ItemCRUD(itemType=ItemCRUDType.Village)
|
||||
|
||||
# # 🔹 Helper: sync status
|
||||
# def _set_status(self, village):
|
||||
# self.isSuccess = village.isSuccess
|
||||
# self.resultMessage = village.resultMessage
|
||||
|
||||
# # 🔹 Helper: get request data
|
||||
# def _get_form_data(self, request):
|
||||
# block_id = request.form.get('block_Id')
|
||||
# village_name = request.form.get('Village_Name', '').strip()
|
||||
# return block_id, village_name
|
||||
|
||||
# def AddVillage(self, request):
|
||||
# block_id, village_name = self._get_form_data(request)
|
||||
|
||||
# if not village_name:
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = "Village name cannot be empty"
|
||||
# return
|
||||
|
||||
# try:
|
||||
# self.village.AddItem(
|
||||
# request=request,
|
||||
# parentid=block_id,
|
||||
# childname=village_name,
|
||||
# storedprocfetch="GetVillageByNameAndBlock",
|
||||
# storedprocadd="SaveVillage"
|
||||
# )
|
||||
# self._set_status(self.village)
|
||||
|
||||
# except Exception as e:
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = str(e)
|
||||
|
||||
# def GetAllVillages(self, request):
|
||||
|
||||
# try:
|
||||
# villagesdata = self.village.GetAllData(
|
||||
# request=request,
|
||||
# storedproc="GetAllVillages"
|
||||
# )
|
||||
# self._set_status(self.village)
|
||||
# return villagesdata
|
||||
|
||||
# except Exception as e:
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = str(e)
|
||||
# return []
|
||||
|
||||
# def CheckVillage(self, request):
|
||||
# block_id, village_name = self._get_form_data(request)
|
||||
|
||||
# if not village_name:
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = "Village name cannot be empty"
|
||||
# return None
|
||||
|
||||
# try:
|
||||
# result = self.village.CheckItem(
|
||||
# request=request,
|
||||
# parentid=block_id,
|
||||
# childname=village_name,
|
||||
# storedprocfetch="GetVillageByNameAndBlocks"
|
||||
# )
|
||||
# self._set_status(self.village)
|
||||
# return result
|
||||
|
||||
# except Exception as e:
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = str(e)
|
||||
# return None
|
||||
|
||||
# def DeleteVillage(self, request, village_id):
|
||||
|
||||
# try:
|
||||
# self.village.DeleteItem(
|
||||
# request=request,
|
||||
# itemID=village_id,
|
||||
# storedprocDelete="DeleteVillage"
|
||||
# )
|
||||
# self._set_status(self.village)
|
||||
|
||||
# except Exception as e:
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = str(e)
|
||||
|
||||
# def EditVillage(self, request, village_id):
|
||||
# block_id, village_name = self._get_form_data(request)
|
||||
|
||||
# if not village_name:
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = "Village name cannot be empty"
|
||||
# return
|
||||
|
||||
# try:
|
||||
# self.village.EditItem(
|
||||
# request=request,
|
||||
# childid=village_id,
|
||||
# parentid=block_id,
|
||||
# childname=village_name,
|
||||
# storedprocupdate="UpdateVillage"
|
||||
# )
|
||||
# self._set_status(self.village)
|
||||
|
||||
# except Exception as e:
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = str(e)
|
||||
|
||||
# def GetVillageByID(self, id):
|
||||
|
||||
# try:
|
||||
# villagedetailsdata = self.village.GetDataByID(
|
||||
# id=id,
|
||||
# storedproc="GetVillageDetailsById"
|
||||
# )
|
||||
|
||||
# if villagedetailsdata:
|
||||
# self.isSuccess = True
|
||||
# else:
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = "Village not found"
|
||||
|
||||
# return villagedetailsdata
|
||||
|
||||
# except Exception as e:
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = str(e)
|
||||
# return None
|
||||
|
||||
# def GetAllBlocks(self):
|
||||
# blocks = []
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = ""
|
||||
|
||||
# connection = config.get_db_connection()
|
||||
# if not connection:
|
||||
# return []
|
||||
|
||||
# try:
|
||||
# with connection.cursor() as cursor:
|
||||
# cursor.callproc('GetAllBlocks')
|
||||
|
||||
# for result in cursor.stored_results():
|
||||
# blocks.extend(result.fetchall())
|
||||
|
||||
# self.isSuccess = True
|
||||
# return blocks
|
||||
|
||||
# except mysql.connector.Error as e:
|
||||
# print(f"Error fetching blocks: {e}")
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = HtmlHelper.json_response(
|
||||
# ResponseHandler.fetch_failure("block"), 500
|
||||
# )
|
||||
# return []
|
||||
|
||||
# finally:
|
||||
# connection.close()
|
||||
|
||||
from model.Utilities import ResponseHandler, HtmlHelper, ItemCRUDType
|
||||
import config
|
||||
|
||||
@@ -1,201 +1,4 @@
|
||||
// window.onload = function () {
|
||||
// document.getElementById('Village_Name').focus();
|
||||
// };
|
||||
|
||||
// $(document).ready(function () {
|
||||
|
||||
// // STATE → DISTRICT
|
||||
// $('#state_Id').change(function () {
|
||||
|
||||
// var stateId = $(this).val();
|
||||
|
||||
// if (stateId) {
|
||||
|
||||
// $.ajax({
|
||||
// url: '/get_districts/' + stateId,
|
||||
// type: 'GET',
|
||||
|
||||
// success: function (data) {
|
||||
|
||||
// var districtDropdown = $('#district_Id');
|
||||
|
||||
// districtDropdown.empty();
|
||||
// districtDropdown.append('<option value="" disabled selected>Select District</option>');
|
||||
|
||||
// data.forEach(function (district) {
|
||||
|
||||
// districtDropdown.append(
|
||||
// '<option value="' + district.id + '">' + district.name + '</option>'
|
||||
// );
|
||||
|
||||
// });
|
||||
|
||||
// districtDropdown.prop('disabled', false);
|
||||
|
||||
// }
|
||||
|
||||
// });
|
||||
|
||||
// }
|
||||
|
||||
// });
|
||||
|
||||
|
||||
// // DISTRICT → BLOCK
|
||||
// $('#district_Id').change(function () {
|
||||
|
||||
// var districtId = $(this).val();
|
||||
|
||||
// if (districtId) {
|
||||
|
||||
// $.ajax({
|
||||
// url: '/get_blocks/' + districtId,
|
||||
// type: 'GET',
|
||||
|
||||
// success: function (data) {
|
||||
|
||||
// var blockDropdown = $('#block_Id');
|
||||
|
||||
// blockDropdown.empty();
|
||||
// blockDropdown.append('<option value="" disabled selected>Select Block</option>');
|
||||
|
||||
// data.forEach(function (block) {
|
||||
|
||||
// blockDropdown.append(
|
||||
// '<option value="' + block.id + '">' + block.name + '</option>'
|
||||
// );
|
||||
|
||||
// });
|
||||
|
||||
// blockDropdown.prop('disabled', false);
|
||||
|
||||
// }
|
||||
|
||||
// });
|
||||
|
||||
// }
|
||||
|
||||
// });
|
||||
|
||||
|
||||
// // VILLAGE NAME VALIDATION
|
||||
// $('#Village_Name').on('input', function () {
|
||||
|
||||
// var villageName = $(this).val();
|
||||
// var validPattern = /^[A-Za-z ]*$/;
|
||||
|
||||
// if (!validPattern.test(villageName)) {
|
||||
|
||||
// $('#villageMessage')
|
||||
// .text('Only letters and spaces are allowed!')
|
||||
// .css('color', 'red');
|
||||
|
||||
// $('#submitVillage').prop('disabled', true);
|
||||
|
||||
// } else {
|
||||
|
||||
// $('#villageMessage').text('');
|
||||
// $('#submitVillage').prop('disabled', false);
|
||||
|
||||
// }
|
||||
|
||||
// });
|
||||
|
||||
|
||||
// // CHECK DUPLICATE VILLAGE
|
||||
// $('#Village_Name, #block_Id').on('change keyup', function () {
|
||||
|
||||
// var blockId = $('#block_Id').val();
|
||||
// var villageName = $('#Village_Name').val().trim();
|
||||
|
||||
// if (blockId && villageName) {
|
||||
|
||||
// $.ajax({
|
||||
|
||||
// url: '/check_village',
|
||||
// type: 'POST',
|
||||
|
||||
// data: {
|
||||
// block_Id: blockId,
|
||||
// Village_Name: villageName
|
||||
// },
|
||||
|
||||
// success: function (response) {
|
||||
|
||||
// if (response.status === 'exists') {
|
||||
|
||||
// $('#villageMessage')
|
||||
// .text(response.message)
|
||||
// .css('color', 'red');
|
||||
|
||||
// $('#submitVillage').prop('disabled', true);
|
||||
|
||||
// } else {
|
||||
|
||||
// $('#villageMessage')
|
||||
// .text(response.message)
|
||||
// .css('color', 'green');
|
||||
|
||||
// $('#submitVillage').prop('disabled', false);
|
||||
|
||||
// }
|
||||
|
||||
// },
|
||||
|
||||
// error: function () {
|
||||
|
||||
// $('#villageMessage')
|
||||
// .text('Error checking village name')
|
||||
// .css('color', 'red');
|
||||
|
||||
// $('#submitVillage').prop('disabled', true);
|
||||
|
||||
// }
|
||||
|
||||
// });
|
||||
|
||||
// }
|
||||
|
||||
// });
|
||||
|
||||
|
||||
// // ADD VILLAGE
|
||||
// $('#villageForm').submit(function (event) {
|
||||
|
||||
// event.preventDefault();
|
||||
|
||||
// $.ajax({
|
||||
|
||||
// url: '/add_village',
|
||||
// type: 'POST',
|
||||
// data: $(this).serialize(),
|
||||
|
||||
// success: function (response) {
|
||||
|
||||
// if (response.status === 'success') {
|
||||
|
||||
// alert('Village added successfully!');
|
||||
// location.reload();
|
||||
|
||||
// } else {
|
||||
|
||||
// alert('Error adding village. Please try again.');
|
||||
|
||||
// }
|
||||
|
||||
// },
|
||||
|
||||
// error: function () {
|
||||
|
||||
// alert('An error occurred. Please try again.');
|
||||
|
||||
// }
|
||||
|
||||
// });
|
||||
|
||||
// });
|
||||
|
||||
// });
|
||||
|
||||
window.onload = function () {
|
||||
document.getElementById('Village_Name').focus();
|
||||
|
||||
Reference in New Issue
Block a user