13 Commits

Author SHA1 Message Date
80d4e82f9b Merge pull request 'pankaj-dev' (#27) from pankaj-dev into main
Reviewed-on: #27
2026-08-08 07:30:36 +00:00
2769179a5a Merge branch 'main' of http://gitea.lcepl.org/pjpatil12/Comparison_Project into pankaj-dev 2026-08-08 12:55:03 +05:30
10511c959f Merge pull request 'Changes done in client report page' (#26) from Prajakta-main into main
Reviewed-on: #26
Reviewed-by: Pankaj J Patil <pankajjpatil2001@gmail.com>
Reviewed-by: Swapnil9693 <swapnil.dahiphale005@gmail.com>
Reviewed-by: laxmibamnale <laxmibamnale2702@gmail.com>
2026-08-08 07:02:37 +00:00
272705e437 Changes done in client report page 2026-08-08 11:25:22 +05:30
4baf8378c7 Added on Client rate model 2026-08-08 10:34:07 +05:30
06fe162198 edit .gitignore file 2026-08-07 13:51:58 +05:30
d5d69a5ba5 Merge pull request 'subctr location filter, MH NO. search, subctr manadatory field removed, added select all for delete and also all edit at once feature added' (#24) from swapnil-dev into main
Reviewed-on: #24
Reviewed-by: Pankaj J Patil <pankajjpatil2001@gmail.com>
2026-08-07 07:44:07 +00:00
5b76beff8e subctr location filter, MH NO. search, subctr manadatory field removed, added select all for delete and also all edit at once feature added 2026-08-07 13:01:38 +05:30
aa9f5f0ebf log changes 2026-08-07 12:33:42 +05:30
82c57f8445 suctr location filter, MH NO. search, subctr manadatory field removed, added select all for delete and also all edit at once feature added 2026-08-07 12:30:21 +05:30
8304df6ba7 Merge pull request 'fix: category filter, action icons, download filename, reset button' (#19) from Laxmi-Devs into main
Reviewed-on: #19
Reviewed-by: Pankaj J Patil <pankajjpatil2001@gmail.com>
2026-08-07 06:25:22 +00:00
c09cb8ea3a suctr location filter, MH NO. search, subctr manadatory field removed, added select all for delete and also all edit at once feature added 2026-08-07 11:51:51 +05:30
12529800f0 fix: category filter, action icons, download filename, reset button 2026-08-07 11:49:18 +05:30
14 changed files with 1900 additions and 406 deletions

5
.gitignore vendored
View File

@@ -11,8 +11,11 @@ app/static/uploads/
# Ignore env files # Ignore env files
venv venv
# Ignore Log files ss # Ignore Log files
logs/ logs/
logs/app.log
logs/debug.log
logs/error.log
*.log *.log

View File

@@ -0,0 +1,20 @@
from app import db
from datetime import datetime
class ClientRate(db.Model):
__tablename__ = "client_rates"
id = db.Column(db.Integer, primary_key=True)
category = db.Column(db.String(50), nullable=False)
item_code = db.Column(db.String(50), nullable=False)
item_name = db.Column(db.String(200), nullable=False)
unit = db.Column(db.String(20))
rate = db.Column(db.Numeric(12,2), nullable=False)
effective_from = db.Column(db.Date, nullable=False)
effective_to = db.Column(db.Date)
status = db.Column(db.String(20), default="Active")
created_at = db.Column(db.DateTime, default=datetime.now)
def __repr__(self):
return f"< Client Rate {self.item_name}>"

View File

@@ -6,10 +6,11 @@ from flask import (
url_for, url_for,
flash, jsonify flash, jsonify
) )
from app.constants.messages import SuccessMessage, ErrorMessage
from app.models.subcontractor_model import Subcontractor from app.models.subcontractor_model import Subcontractor
from app.services.subcontractor_rate_service import SubcontractorRateService from app.services.subcontractor_rate_service import SubcontractorRateService
from app.constants.messages import SuccessMessage, ErrorMessage from app.services.client_rate_service import ClientRateService
engi_bp = Blueprint( engi_bp = Blueprint(
"engineering", "engineering",
@@ -27,17 +28,60 @@ def engineering_master():
title="Engineering Masters" title="Engineering Masters"
) )
# Client rate model #---------------------- Client rate model -------------------------------
@engi_bp.route("/client-rate") @engi_bp.route("/client-rate", methods=["GET", "POST"])
def client_rates(): def client_rate_master():
if request.method == "POST":
result = ClientRateService.save_or_update(request.form)
if result["success"]:
flash(result["message"], "success")
return redirect(url_for("engineering.client_rate_master"))
else:
flash(result["message"], "danger")
rates = ClientRateService.get_all_rates()
return render_template( return render_template(
"engineering/client_rate.html", "engineering/client_rate.html",
title="Client Rate Master" title="Client Rate Master",
rates=rates
) )
@engi_bp.route("/client-rate/edit/<int:rate_id>", methods=["GET", "POST"])
def client_edit_rate(rate_id):
if request.method == "POST":
result = ClientRateService.save_or_update(request.form)
if result["success"]:
flash(result["message"], "success")
return redirect(url_for("engineering.client-rate"))
flash(result["message"], "danger")
rate = ClientRateService.get_rate(rate_id)
rates = ClientRateService.get_all_rates()
return render_template(
"engineering/client_rate.html",
rate=rate,
rates=rates
)
@engi_bp.route("/client-rate/delete/<int:rate_id>")
def client_delete_rate(rate_id):
ClientRateService.delete_rate(rate_id)
flash("Rate deleted successfully.", "success")
return redirect(url_for("engineering.client-rate"))
# -------------------- Sub-Contractor -------------------------------------
@engi_bp.route("/subcontractor-rate", methods=["GET", "POST"]) @engi_bp.route("/subcontractor-rate", methods=["GET", "POST"])
def add_subcontractor_rates(): def subcontractor_rate_master():
subcontractors = Subcontractor.query.filter_by(status="Active").all() subcontractors = Subcontractor.query.filter_by(status="Active").all()
@@ -45,7 +89,7 @@ def add_subcontractor_rates():
result = SubcontractorRateService.save_or_update(request.form) result = SubcontractorRateService.save_or_update(request.form)
if result["success"]: if result["success"]:
flash(result["message"], "success") flash(result["message"], "success")
return redirect(url_for("engineering.add_subcontractor_rates")) return redirect(url_for("engineering.subcontractor_rate_master"))
else: else:
flash(result["message"], "danger") flash(result["message"], "danger")
@@ -59,7 +103,7 @@ def add_subcontractor_rates():
) )
@engi_bp.route("/subcontractor-rate/edit/<int:rate_id>", methods=["GET", "POST"]) @engi_bp.route("/subcontractor-rate/edit/<int:rate_id>", methods=["GET", "POST"])
def edit_rate(rate_id): def subcontractor_edit_rate(rate_id):
subcontractors = Subcontractor.query.filter_by(status="Active").all() subcontractors = Subcontractor.query.filter_by(status="Active").all()
@@ -69,7 +113,7 @@ def edit_rate(rate_id):
if result["success"]: if result["success"]:
flash(result["message"], "success") flash(result["message"], "success")
return redirect(url_for("engineering.add_subcontractor_rates")) return redirect(url_for("engineering.subcontractor_rate_master"))
flash(result["message"], "danger") flash(result["message"], "danger")
@@ -85,10 +129,10 @@ def edit_rate(rate_id):
) )
@engi_bp.route("/subcontractor-rate/delete/<int:rate_id>") @engi_bp.route("/subcontractor-rate/delete/<int:rate_id>")
def delete_rate(rate_id): def subcontractor_delete_rate(rate_id):
SubcontractorRateService.delete_rate(rate_id) SubcontractorRateService.delete_rate(rate_id)
flash("Rate deleted successfully.", "success") flash("Rate deleted successfully.", "success")
return redirect(url_for("engineering.add_subcontractor_rates")) return redirect(url_for("engineering.subcontractor_rate_master"))
@engi_bp.route("/check-rate") @engi_bp.route("/check-rate")

View File

@@ -4,6 +4,7 @@ from flask import Blueprint, render_template, request, send_file, flash, jsonify
from app.utils.helpers import login_required from app.utils.helpers import login_required
from app.utils.regex_utils import RegularExpression from app.utils.regex_utils import RegularExpression
from app import db from app import db
from sqlalchemy import func
import re import re
from app.models.subcontractor_model import Subcontractor from app.models.subcontractor_model import Subcontractor
@@ -17,42 +18,174 @@ from app.models.tr_ex_client_model import TrenchExcavationClient
from app.models.mh_dc_client_model import ManholeDomesticChamberClient from app.models.mh_dc_client_model import ManholeDomesticChamberClient
from app.models.laying_client_model import LayingClient from app.models.laying_client_model import LayingClient
from app.services.abstract_service import AbstractReportService from app.services.abstract_service import AbstractReportService, ClientAbstractReportService
# --- BLUEPRINT DEFINITION --- # --- BLUEPRINT DEFINITION ---
file_report_bp = Blueprint("file_report", __name__, url_prefix="/file") file_report_bp = Blueprint("file_report", __name__, url_prefix="/file")
# ---------------- LOCATION HELPERS ----------------
WORK_MODELS = [TrenchExcavation, ManholeExcavation, ManholeDomesticChamber, Laying]
def get_distinct_locations():
"""Union of distinct, non-empty Location values across all 4 work tables."""
locations = set()
for Model in WORK_MODELS:
rows = db.session.query(Model.Location).distinct().all()
for (loc,) in rows:
if loc and loc.strip():
locations.add(loc.strip())
return sorted(locations)
def get_subcontractors_for_location(location):
"""Return Subcontractor objects that have at least one work record
(in any of the 4 category tables) at the given location. If no
location is given, returns every subcontractor. Shared by the AJAX
endpoint below and by the server-rendered dropdown so the list is
correct even before/without JS running (e.g. on page reload or a
validation-error re-render).
Matching is case- and whitespace-insensitive, since Location is a
free-text field and stored values can drift ("Pune" vs "PUNE " etc.)
even though the dropdown options themselves come from a distinct
query and look identical."""
location = (location or "").strip()
if not location:
return Subcontractor.query.order_by(Subcontractor.subcontractor_name).all()
target = location.upper()
sc_ids = set()
for Model in WORK_MODELS:
rows = (
db.session.query(Model.subcontractor_id)
.filter(func.upper(func.trim(Model.Location)) == target)
.distinct()
.all()
)
for (sid,) in rows:
if sid:
sc_ids.add(sid)
if not sc_ids:
return []
return (
Subcontractor.query.filter(Subcontractor.id.in_(sc_ids))
.order_by(Subcontractor.subcontractor_name)
.all()
)
@file_report_bp.route("/get_subcontractors_by_location")
@login_required
def get_subcontractors_by_location():
"""AJAX endpoint: return subcontractors that have at least one work
record (in any of the 4 category tables) at the given location."""
location = request.args.get("location", "").strip()
subs = get_subcontractors_for_location(location)
return jsonify([{"id": s.id, "name": s.subcontractor_name} for s in subs])
# ---------------- ACTION COLUMN ---------------- # ---------------- ACTION COLUMN ----------------
def add_action_columns(df, model_key): def add_action_columns(df, model_key):
if df.empty: if df.empty:
return df return df
# Edit + Delete side by side in one "Action" column, both as icon buttons. df.insert(0, "Select", df["Id"].apply(
df.insert(0, "Action", df["Id"].apply( lambda x: f'<input type="checkbox" class="row-check" data-model="{model_key}" data-id="{x}">'
lambda x: ( ))
f'<div class="d-flex gap-1">'
f'<a href="/file/edit/{model_key}/{x}" class="btn btn-sm btn-warning edit-btn" title="Edit">' df["Update"] = df["Id"].apply(
f'<i class="bi bi-pencil-square"></i></a>' lambda x: f'<a href="/file/edit/{model_key}/{x}" class="btn btn-sm btn-warning edit-btn"><i class="bi bi-pencil-square"></i> Edit</a>'
f'<button class="btn btn-sm btn-danger delete-btn" data-id="{x}" data-model="{model_key}" title="Delete">'
f'<i class="bi bi-trash"></i></button>'
f'</div>'
) )
))
df.insert(1, "Select", df["Id"].apply( df["Delete"] = df["Id"].apply(
lambda x: f'<input type="checkbox" class="row-check" data-id="{x}">' lambda x: f'<button class="btn btn-sm btn-danger delete-btn" data-id="{x}" data-model="{model_key}">Delete</button>'
)) )
df["Id"] = range(1, len(df) + 1)
df = df.rename(columns={"Id": "Sr No"})
return df return df
# ---------------- SELECT-ALL HEADER ----------------
def add_select_all_header(table_html, model_key):
return table_html.replace(
"<th>Select</th>",
f'<th><input type="checkbox" class="select-all-checkbox" '
f'data-model="{model_key}" title="Select All"></th>',
1
)
# ---------------- TABLE OR EMPTY-STATE ----------------
def add_data_field_attrs(table_html, raw_fields):
"""Tag each editable data <td> with a data-field attribute naming its
underlying database column, so bulk-edit mode on the frontend knows
exactly which field to submit for each input it creates. The 'id'
column is deliberately skipped - it's the primary key and must never
be editable.
Uses match spans (not string search-and-replace) to rebuild each row,
because a naive .replace() on duplicate cell text (e.g. two cells
that both just say "0.00") would edit the wrong cell.
NOTE: only used for Subcontractor tables (which have Bulk Edit).
Client tables do not use this."""
total_cols = 1 + len(raw_fields) + 2 # Select + data columns + Update + Delete
def process_row(m):
row_html = m.group(0)
matches = list(re.finditer(r"<td>.*?</td>", row_html, flags=re.S))
if len(matches) != total_cols:
return row_html # shape mismatch - leave untouched rather than guess
pieces = []
last_end = 0
for i, mt in enumerate(matches):
pieces.append(row_html[last_end:mt.start()])
cell = mt.group(0)
if 1 <= i <= len(raw_fields):
field = raw_fields[i - 1]
if field.lower() != "id":
cell = f'<td data-field="{field}">' + cell[len("<td>"):]
pieces.append(cell)
last_end = mt.end()
pieces.append(row_html[last_end:])
return "".join(pieces)
return re.sub(r"<tr>.*?</tr>", process_row, table_html, flags=re.S)
def render_table_or_empty(df, model_key, table_class, raw_fields=None):
"""Render a table, or a friendly placeholder if there's no data.
IMPORTANT: pandas' to_html() on a fully empty DataFrame (0 rows AND
0 columns, which is what we get when a category has no matching
records) still emits a <table class="datatable"> - just with a
header row that has zero <th> cells. jQuery DataTables then tries to
initialize on a table with no columns and throws, which (since the
init code runs as one synchronous block) silently kills every bit of
JS registered after it - including the select-all checkbox handler
for the OTHER tables on the page. Returning a plain message instead
of an empty <table class="datatable"> avoids ever handing DataTables
something it can't initialize.
raw_fields is only needed for Subcontractor tables (Bulk Edit);
leave it as None for Client tables and this just skips the
data-field tagging step."""
if df.empty:
return '<div class="alert alert-info mb-0">No records found.</div>'
html = df.to_html(classes=table_class, index=False, escape=False)
html = add_select_all_header(html, model_key)
if raw_fields:
html = add_data_field_attrs(html, raw_fields)
return html
# ---------------- FETCH ---------------- # ---------------- FETCH ----------------
class SubcontractorBill: class SubcontractorBill:
@@ -63,7 +196,7 @@ class SubcontractorBill:
self.df_laying = pd.DataFrame() self.df_laying = pd.DataFrame()
# self.df_abstract = pd.DataFrame() # NEW # self.df_abstract = pd.DataFrame() # NEW
def Fetch(self, RA_Bill_No=None, subcontractor_id=None, location=None): def Fetch(self, RA_Bill_No=None, subcontractor_id=None, location=None, mh_no=None):
filters = {} filters = {}
if subcontractor_id: if subcontractor_id:
@@ -80,7 +213,6 @@ class SubcontractorBill:
# LOCATION FILTER # LOCATION FILTER
if location: if location:
search = location.strip().lower() search = location.strip().lower()
print("location::",search)
trench = [ trench = [
t for t in trench t for t in trench
if search in (t.Location or "").strip().lower() if search in (t.Location or "").strip().lower()
@@ -101,6 +233,29 @@ class SubcontractorBill:
if search in (t.Location or "").strip().lower() if search in (t.Location or "").strip().lower()
] ]
# MH NO FILTER
if mh_no:
mh_search = mh_no.strip().lower()
trench = [
t for t in trench
if mh_search in (t.MH_NO or "").strip().lower()
]
mh = [
t for t in mh
if mh_search in (t.MH_NO or "").strip().lower()
]
dc = [
t for t in dc
if mh_search in (t.MH_NO or "").strip().lower()
]
lay = [
t for t in lay
if mh_search in (t.MH_NO or "").strip().lower()
]
# Set dataframe # Set dataframe
self.df_tr = pd.DataFrame([c.serialize() for c in trench]) self.df_tr = pd.DataFrame([c.serialize() for c in trench])
self.df_mh = pd.DataFrame([c.serialize() for c in mh]) self.df_mh = pd.DataFrame([c.serialize() for c in mh])
@@ -109,9 +264,24 @@ class SubcontractorBill:
drop_cols = ["11", "_sa_instance_state", "subcontractor_id" , "created_at"] drop_cols = ["11", "_sa_instance_state", "subcontractor_id" , "created_at"]
for df in [self.df_tr, self.df_mh, self.df_dc, self.df_laying]: # Raw (pre-format_column_names) column names for each table, e.g.
# "MH_NO" rather than the display label "MH No". Bulk-edit mode
# needs these to know which real database column each input maps
# to, since the table only shows the prettified header text.
self.tr_fields = []
self.mh_fields = []
self.dc_fields = []
self.laying_fields = []
for df, attr in [
(self.df_tr, "tr_fields"),
(self.df_mh, "mh_fields"),
(self.df_dc, "dc_fields"),
(self.df_laying, "laying_fields"),
]:
if not df.empty: if not df.empty:
df.drop(columns=drop_cols, errors="ignore", inplace=True) df.drop(columns=drop_cols, errors="ignore", inplace=True)
setattr(self, attr, list(df.columns))
format_column_names(df) format_column_names(df)
name = "" name = ""
@@ -134,7 +304,11 @@ def delete_records():
"tr": TrenchExcavation, "tr": TrenchExcavation,
"mh": ManholeExcavation, "mh": ManholeExcavation,
"dc": ManholeDomesticChamber, "dc": ManholeDomesticChamber,
"laying": Laying "laying": Laying,
"tr_client": TrenchExcavationClient,
"mh_client": ManholeExcavationClient,
"dc_client": ManholeDomesticChamberClient,
"laying_client": LayingClient
} }
ModelClass = model_map.get(model) ModelClass = model_map.get(model)
@@ -159,6 +333,61 @@ def delete_records():
return jsonify({"status": "error", "message": str(e)}), 500 return jsonify({"status": "error", "message": str(e)}), 500
@file_report_bp.route("/bulk_update", methods=["POST"])
@login_required
def bulk_update():
"""Bulk-edit save endpoint. Subcontractor tables only - Client
report does not have Bulk Edit. Expects JSON shaped like:
{ "tr": { "5": {"MH_NO": "12A", "Location": "Pune"}, ... }, "mh": {...}, ... }
Field names are validated against each model's real table columns
server-side - the frontend sending a field name is not enough on its
own to permit writing it; id/subcontractor_id/created_at are always
refused regardless of what's submitted.
"""
data = request.json or {}
model_map = {
"tr": TrenchExcavation,
"mh": ManholeExcavation,
"dc": ManholeDomesticChamber,
"laying": Laying
}
PROTECTED_FIELDS = {"id", "subcontractor_id", "created_at"}
updated = 0
errors = []
try:
for model_key, records in data.items():
ModelClass = model_map.get(model_key)
if not ModelClass:
errors.append(f"Unknown table '{model_key}'")
continue
valid_columns = {c.name for c in ModelClass.__table__.columns} - PROTECTED_FIELDS
for record_id, fields in (records or {}).items():
obj = ModelClass.query.get(record_id)
if not obj:
errors.append(f"{model_key} #{record_id}: record not found")
continue
for field, value in (fields or {}).items():
if field not in valid_columns:
errors.append(f"{model_key} #{record_id}: '{field}' is not editable")
continue
setattr(obj, field, value)
updated += 1
db.session.commit()
except Exception as e:
db.session.rollback()
return jsonify({"status": "error", "message": str(e)}), 500
return jsonify({"status": "success", "updated": updated, "errors": errors})
@file_report_bp.route("/edit/<string:model>/<int:record_id>", methods=["GET", "POST"]) @file_report_bp.route("/edit/<string:model>/<int:record_id>", methods=["GET", "POST"])
@login_required @login_required
def edit_record(model, record_id): def edit_record(model, record_id):
@@ -167,7 +396,11 @@ def edit_record(model, record_id):
"tr": TrenchExcavation, "tr": TrenchExcavation,
"mh": ManholeExcavation, "mh": ManholeExcavation,
"dc": ManholeDomesticChamber, "dc": ManholeDomesticChamber,
"laying": Laying "laying": Laying,
"tr_client": TrenchExcavationClient,
"mh_client": ManholeExcavationClient,
"dc_client": ManholeDomesticChamberClient,
"laying_client": LayingClient
} }
ModelClass = model_map.get(model) ModelClass = model_map.get(model)
@@ -192,7 +425,10 @@ def edit_record(model, record_id):
try: try:
db.session.commit() db.session.commit()
flash("Record updated successfully.", "success") flash("Record updated successfully.", "success")
# ✅ fixed: correct blueprint name
if model.endswith("_client"):
return redirect(url_for("file_report.client_report"))
return redirect(url_for("file_report.report_file")) return redirect(url_for("file_report.report_file"))
except Exception as e: except Exception as e:
@@ -211,28 +447,40 @@ def edit_record(model, record_id):
def report_file(): def report_file():
# get all subcontractor data # get all subcontractor data
subcontractors = Subcontractor.query.all() subcontractors = Subcontractor.query.all()
locations = get_distinct_locations()
tables = None tables = None
abstract_html = "" abstract_html = ""
selected_sc_id = None selected_sc_id = None
has_data = {"tr": False, "mh": False, "dc": False, "laying": False}
ra_bill_no = "" ra_bill_no = ""
location = "" location = ""
mh_no = ""
category = "" category = ""
# Search or load data # Search or load data
if request.method == "POST": if request.method == "POST":
# get from data # get from data
subcontractor_id = request.form.get("subcontractor_id") subcontractor_id = request.form.get("subcontractor_id") or None
ra_bill_no = request.form.get("ra_bill_no", "").strip() ra_bill_no = request.form.get("ra_bill_no", "").strip()
location = request.form.get("location", "").strip() location = request.form.get("location", "").strip()
mh_no = request.form.get("mh_no", "").strip()
category = request.form.get("category", "") category = request.form.get("category", "")
action = request.form.get("action", "preview") action = request.form.get("action", "preview")
if not subcontractor_id: # Keep the subcontractor dropdown scoped to the chosen location
flash("Select Subcontractor", "danger") # even on a plain (non-JS) page render.
subcontractors = get_subcontractors_for_location(location)
# Subcontractor is now optional - at least one other filter must
# be given so the search isn't a "return everything" query.
if not subcontractor_id and not location and not ra_bill_no and not mh_no:
flash("Enter at least a Location, RA Bill No, MH No, or Subcontractor to search", "danger")
return render_template( return render_template(
"subcontractor_report.html", "subcontractor_report.html",
subcontractors=subcontractors subcontractors=subcontractors,
locations=locations,
has_data=has_data
) )
selected_sc_id = subcontractor_id selected_sc_id = subcontractor_id
@@ -241,7 +489,7 @@ def report_file():
if action == "excel_all": if action == "excel_all":
bill.Fetch(subcontractor_id=subcontractor_id) bill.Fetch(subcontractor_id=subcontractor_id)
else: else:
bill.Fetch(ra_bill_no,subcontractor_id,location) bill.Fetch(ra_bill_no, subcontractor_id, location, mh_no)
# --------------------------------------------------------- # ---------------------------------------------------------
@@ -384,8 +632,16 @@ def report_file():
bill.df_dc = add_action_columns(bill.df_dc, "dc") bill.df_dc = add_action_columns(bill.df_dc, "dc")
bill.df_laying = add_action_columns(bill.df_laying, "laying") bill.df_laying = add_action_columns(bill.df_laying, "laying")
# Used by the template to hide Delete Selected / Bulk Edit for a
# category that has no rows to act on.
has_data = {
"tr": not bill.df_tr.empty,
"mh": not bill.df_mh.empty,
"dc": not bill.df_dc.empty,
"laying": not bill.df_laying.empty,
}
# this are html classes # this are html classes
# table_class = ( "table " "table-bordered" "table-hover " "table-striped " "table-sm " "align-middle " "datatable " "mb-0")
table_class = ( table_class = (
"table " "table "
"table-bordered " "table-bordered "
@@ -400,21 +656,24 @@ def report_file():
# This are showing on web tables # This are showing on web tables
tables = { tables = {
"tr": bill.df_tr.to_html(classes=table_class, index=False, escape=False), "tr": render_table_or_empty(bill.df_tr, "tr", table_class, bill.tr_fields),
"mh": bill.df_mh.to_html(classes=table_class, index=False, escape=False), "mh": render_table_or_empty(bill.df_mh, "mh", table_class, bill.mh_fields),
"dc": bill.df_dc.to_html(classes=table_class, index=False, escape=False ), "dc": render_table_or_empty(bill.df_dc, "dc", table_class, bill.dc_fields),
"laying": bill.df_laying.to_html(classes=table_class, index=False, escape=False) "laying": render_table_or_empty(bill.df_laying, "laying", table_class, bill.laying_fields)
} }
return render_template( return render_template(
"subcontractor_report.html", "subcontractor_report.html",
subcontractors=subcontractors, subcontractors=subcontractors,
locations=locations,
selected_sc_id=selected_sc_id, selected_sc_id=selected_sc_id,
selected_ra_bill=ra_bill_no, selected_ra_bill=ra_bill_no,
selected_location=location, selected_location=location,
selected_mh_no=mh_no,
selected_category=category, selected_category=category,
tables=tables, tables=tables,
abstract_html=abstract_html abstract_html=abstract_html,
has_data=has_data
) )
@@ -426,22 +685,65 @@ class ClientBill:
self.df_dc = pd.DataFrame() self.df_dc = pd.DataFrame()
self.df_laying = pd.DataFrame() self.df_laying = pd.DataFrame()
def Fetch(self, RA_Bill_No): def Fetch(self, RA_Bill_No=None, location=None, mh_no=None):
trench = TrenchExcavationClient.query.filter_by(RA_Bill_No=RA_Bill_No).all() filters = {}
mh = ManholeExcavationClient.query.filter_by(RA_Bill_No=RA_Bill_No).all() if RA_Bill_No:
dc = ManholeDomesticChamberClient.query.filter_by(RA_Bill_No=RA_Bill_No).all() filters["RA_Bill_No"] = RA_Bill_No
lay = LayingClient.query.filter_by(RA_Bill_No=RA_Bill_No).all()
trench = TrenchExcavationClient.query.filter_by(**filters).all()
mh = ManholeExcavationClient.query.filter_by(**filters).all()
dc = ManholeDomesticChamberClient.query.filter_by(**filters).all()
lay = LayingClient.query.filter_by(**filters).all()
# LOCATION FILTER
if location:
search = location.strip().lower()
trench = [
t for t in trench
if search in (t.Location or "").strip().lower()
]
mh = [
t for t in mh
if search in (t.Location or "").strip().lower()
]
dc = [
t for t in dc
if search in (t.Location or "").strip().lower()
]
lay = [
t for t in lay
if search in (t.Location or "").strip().lower()
]
# MH NO FILTER
if mh_no:
search_mh = mh_no.strip().lower()
trench = [
t for t in trench
if search_mh in (t.MH_NO or "").strip().lower()
]
mh = [
t for t in mh
if search_mh in (t.MH_NO or "").strip().lower()
]
dc = [
t for t in dc
if search_mh in (t.MH_NO or "").strip().lower()
]
lay = [
t for t in lay
if search_mh in (t.MH_NO or "").strip().lower()
]
self.df_tr = pd.DataFrame([c.serialize() for c in trench]) self.df_tr = pd.DataFrame([c.serialize() for c in trench])
self.df_mh = pd.DataFrame([c.serialize() for c in mh]) self.df_mh = pd.DataFrame([c.serialize() for c in mh])
self.df_dc = pd.DataFrame([c.serialize() for c in dc]) self.df_dc = pd.DataFrame([c.serialize() for c in dc])
self.df_laying = pd.DataFrame([c.serialize() for c in lay]) self.df_laying = pd.DataFrame([c.serialize() for c in lay])
drop_cols = ["created_at", "_sa_instance_state"]
drop_cols = ["id", "created_at", "_sa_instance_state"]
for df in [self.df_tr, self.df_mh, self.df_dc, self.df_laying]: for df in [self.df_tr, self.df_mh, self.df_dc, self.df_laying]:
if not df.empty: if not df.empty:
df.drop(columns=drop_cols, errors="ignore", inplace=True) df.drop(columns=drop_cols, errors="ignore", inplace=True)
format_column_names(df)
# --- CLIENT REPORT (PREVIEW + DOWNLOAD) --- # --- CLIENT REPORT (PREVIEW + DOWNLOAD) ---
@@ -449,23 +751,41 @@ class ClientBill:
@login_required @login_required
def client_report(): def client_report():
tables = {"tr": None, "mh": None, "dc": None, "laying": None} tables = None
ra_val = "" ra_val = ""
location_val = ""
mh_no_val = ""
category_val = ""
abstract_html = ""
has_data = {"tr": False, "mh": False, "dc": False, "laying": False}
if request.method == "POST": if request.method == "POST":
# ⚠ MUST match HTML name RA_Bill_No = request.form.get("RA_Bill_No", "").strip()
RA_Bill_No = request.form.get("RA_Bill_No") location = request.form.get("location", "").strip()
action = request.form.get("action") mh_no = request.form.get("mh_no", "").strip()
category = request.form.get("category", "")
action = request.form.get("action", "preview")
ra_val = RA_Bill_No ra_val = RA_Bill_No
location_val = location
mh_no_val = mh_no
category_val = category
if not RA_Bill_No: if not RA_Bill_No:
flash("Please enter RA Bill No.", "danger") flash("Please enter RA Bill No.", "danger")
return render_template("client_report.html", tables=tables, ra_val=ra_val) return render_template(
"client_report.html",
tables=tables, ra_val=ra_val,
location_val=location_val, mh_no_val=mh_no_val,
category_val=category_val,
abstract_html=abstract_html,
has_data=has_data
)
# -------- FETCH CLIENT DATA -------- # -------- FETCH CLIENT DATA --------
bill_gen = ClientBill() bill_gen = ClientBill()
bill_gen.Fetch(RA_Bill_No) bill_gen.Fetch(RA_Bill_No, location, mh_no)
# If no data # If no data
if ( if (
@@ -475,7 +795,27 @@ def client_report():
bill_gen.df_laying.empty bill_gen.df_laying.empty
): ):
flash(f"No Client records found for RA Bill {RA_Bill_No}", "warning") flash(f"No Client records found for RA Bill {RA_Bill_No}", "warning")
return render_template("client_report.html", tables=tables, ra_val=ra_val) return render_template(
"client_report.html",
tables=tables, ra_val=ra_val,
location_val=location_val, mh_no_val=mh_no_val,
category_val=category_val,
abstract_html=abstract_html,
has_data=has_data
)
abstract_service = ClientAbstractReportService(ra_bill_no=RA_Bill_No)
abstract_html = abstract_service.generate_html()
# ---------------- CATEGORY FILTER ----------------
if category == "tr":
bill_gen.df_mh = bill_gen.df_dc = bill_gen.df_laying = pd.DataFrame()
elif category == "mh":
bill_gen.df_tr = bill_gen.df_dc = bill_gen.df_laying = pd.DataFrame()
elif category == "dc":
bill_gen.df_tr = bill_gen.df_mh = bill_gen.df_laying = pd.DataFrame()
elif category == "laying":
bill_gen.df_tr = bill_gen.df_mh = bill_gen.df_dc = pd.DataFrame()
# -------- DOWNLOAD -------- # -------- DOWNLOAD --------
if action == "download": if action == "download":
@@ -483,10 +823,13 @@ def client_report():
output = io.BytesIO() output = io.BytesIO()
with pd.ExcelWriter(output, engine="xlsxwriter") as writer: with pd.ExcelWriter(output, engine="xlsxwriter") as writer:
bill_gen.df_tr.to_excel(writer, index=False, sheet_name="Trench") workbook = writer.book
bill_gen.df_mh.to_excel(writer, index=False, sheet_name="MH") abstract_service.generate(workbook)
bill_gen.df_tr.to_excel(writer, index=False, sheet_name="Tr.Ex")
bill_gen.df_mh.to_excel(writer, index=False, sheet_name="Mh.Ex")
bill_gen.df_dc.to_excel(writer, index=False, sheet_name="MH & DC") bill_gen.df_dc.to_excel(writer, index=False, sheet_name="MH & DC")
bill_gen.df_laying.to_excel(writer, index=False, sheet_name="Laying") bill_gen.df_laying.to_excel(writer, index=False, sheet_name="Pipe Laying")
output.seek(0) output.seek(0)
@@ -496,15 +839,47 @@ def client_report():
as_attachment=True as_attachment=True
) )
# -------- PREVIEW -------- # ===================================================
table_class = "table table-bordered table-striped table-hover table-sm" # ADD ACTIONS (same helpers as Subcontractor report)
# ===================================================
bill_gen.df_tr = add_action_columns(bill_gen.df_tr, "tr_client")
bill_gen.df_mh = add_action_columns(bill_gen.df_mh, "mh_client")
bill_gen.df_dc = add_action_columns(bill_gen.df_dc, "dc_client")
bill_gen.df_laying = add_action_columns(bill_gen.df_laying, "laying_client")
tables["tr"] = bill_gen.df_tr.to_html(classes=table_class, index=False) has_data = {
tables["mh"] = bill_gen.df_mh.to_html(classes=table_class, index=False) "tr": not bill_gen.df_tr.empty,
tables["dc"] = bill_gen.df_dc.to_html(classes=table_class, index=False) "mh": not bill_gen.df_mh.empty,
tables["laying"] = bill_gen.df_laying.to_html(classes=table_class, index=False) "dc": not bill_gen.df_dc.empty,
"laying": not bill_gen.df_laying.empty,
}
return render_template("client_report.html", tables=tables, ra_val=ra_val) table_class = (
"table "
"table-bordered "
"table-hover "
"table-striped "
"table-sm "
"align-middle "
"datatable "
"text-nowrap "
"mb-0"
)
tables = {
"tr": render_table_or_empty(bill_gen.df_tr, "tr_client", table_class),
"mh": render_table_or_empty(bill_gen.df_mh, "mh_client", table_class),
"dc": render_table_or_empty(bill_gen.df_dc, "dc_client", table_class),
"laying": render_table_or_empty(bill_gen.df_laying, "laying_client", table_class)
}
return render_template(
"client_report.html",
tables=tables, ra_val=ra_val,
location_val=location_val, mh_no_val=mh_no_val,
category_val=category_val,
abstract_html=abstract_html,
has_data=has_data
)
def format_column_names(df): def format_column_names(df):

View File

@@ -1,3 +1,4 @@
import re
from sqlalchemy import func from sqlalchemy import func
from app import db from app import db
@@ -7,6 +8,13 @@ from app.models.manhole_excavation_model import ManholeExcavation
from app.models.manhole_domestic_chamber_model import ManholeDomesticChamber from app.models.manhole_domestic_chamber_model import ManholeDomesticChamber
from app.models.laying_model import Laying from app.models.laying_model import Laying
from app.models.tr_ex_client_model import TrenchExcavationClient
from app.models.mh_ex_client_model import ManholeExcavationClient
from app.models.mh_dc_client_model import ManholeDomesticChamberClient
from app.models.laying_client_model import LayingClient
from app.utils.regex_utils import RegularExpression
class AbstractReportService: class AbstractReportService:
@@ -357,3 +365,214 @@ class AbstractReportService:
""" """
return html return html
# ================================================================
# CLIENT ABSTRACT REPORT
def _format_range_text(raw):
"""'6_0_to_7_5' -> '6.0-7.5' '0_to_1_5' -> '0-1.5'"""
raw = re.sub(r'(\d+)_(\d+)', lambda m: f"{m.group(1)}.{m.group(2)}", raw)
return raw.replace("_to_", "-")
def _label_for_total_column(col_name):
"""'Soft_Murum_0_to_1_5_total' -> 'Soft Murum 0-1.5 mm'"""
value = col_name[:-6] if col_name.endswith("_total") else col_name
m = re.search(r'(\d[\d_]*_to_[\d_]+)$', value)
if m:
prefix = value[:m.start()].rstrip("_").replace("_", " ")
range_text = _format_range_text(m.group(1))
return f"{prefix} {range_text} mm".strip()
return value.replace("_", " ").title()
def _label_for_d_range_column(col_name):
"""'d_6_0_to_6_5' -> '6.0-6.5 mm'"""
raw = col_name[2:] # strip leading "d_"
return f"{_format_range_text(raw)} mm"
def _label_for_pipe_column(col_name):
"""'pipe_150_mm' -> '150 mm Dia'"""
m = re.match(r"pipe_(\d+)_mm", col_name)
if m:
return f"{m.group(1)} mm Dia"
return col_name.replace("_", " ").title()
class ClientAbstractReportService:
def __init__(self, ra_bill_no=None):
self.ra_bill_no = ra_bill_no
def filters(self):
f = {}
if self.ra_bill_no:
f["RA_Bill_No"] = self.ra_bill_no
return f
def _summary(self, model, matcher, uom, label_fn):
f = self.filters()
summary = []
for column in model.__table__.columns:
if matcher(column.name):
qty = (
db.session.query(func.sum(getattr(model, column.name)))
.filter_by(**f)
.scalar()
)
summary.append({
"Description": label_fn(column.name),
"UOM": uom,
"Qty": float(qty or 0)
})
return summary
# ------------------------------------------------------------
def trench_summary(self):
return self._summary(
TrenchExcavationClient,
RegularExpression.STR_TOTAL_PATTERN.match,
"Cum",
_label_for_total_column
)
def manhole_summary(self):
return self._summary(
ManholeExcavationClient,
RegularExpression.STR_TOTAL_PATTERN.match,
"Cum",
_label_for_total_column
)
def domestic_summary(self):
return self._summary(
ManholeDomesticChamberClient,
RegularExpression.D_RANGE_PATTERN.match,
"Nos",
_label_for_d_range_column
)
def laying_summary(self):
return self._summary(
LayingClient,
RegularExpression.PIPE_MM_PATTERN.match,
"RM",
_label_for_pipe_column
)
# ------------------------------------------------------------
# EXCEL SHEET
# ------------------------------------------------------------
def generate(self, workbook):
worksheet = workbook.add_worksheet("Abstract")
title = workbook.add_format({
"bold": True, "font_size": 16, "align": "center",
"valign": "vcenter", "border": 1
})
heading = workbook.add_format({
"bold": True, "bg_color": "#D9EAD3", "border": 1, "align": "center"
})
cell = workbook.add_format({"border": 1})
number = workbook.add_format({"border": 1, "num_format": "#,##0.00"})
worksheet.merge_range("A1:D1", "ABSTRACT OF QUANTITY (CLIENT)", title)
worksheet.write("A3", "RA Bill No", heading)
worksheet.write("B3", self.ra_bill_no or "", cell)
worksheet.write_row("A5", ["Sr", "Description", "UOM", "Qty"], heading)
row = 5
sr = 1
sections = [
("TRENCH EXCAVATION", self.trench_summary()),
("MANHOLE EXCAVATION", self.manhole_summary()),
("DOMESTIC CHAMBER", self.domestic_summary()),
("PIPE LAYING", self.laying_summary()),
]
for title_text, rows in sections:
worksheet.write(row, 1, title_text, heading)
row += 1
for item in rows:
worksheet.write(row, 0, sr, cell)
worksheet.write(row, 1, item["Description"], cell)
worksheet.write(row, 2, item["UOM"], cell)
worksheet.write(row, 3, item["Qty"], number)
sr += 1
row += 1
worksheet.set_column("A:A", 8)
worksheet.set_column("B:B", 55)
worksheet.set_column("C:C", 10)
worksheet.set_column("D:D", 18)
# ------------------------------------------------------------
# HTML (for web preview)
# ------------------------------------------------------------
def generate_html(self):
html = """
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped">
<thead class="table-success">
<tr>
<th colspan="4" class="text-center fs-4">
ABSTRACT OF QUANTITY
</th>
</tr>
<tr>
<th>RA Bill NO</th>
<td colspan="3">{}</td>
</tr>
<tr>
<th width="8%">Sr</th>
<th>Description</th>
<th width="10%">UOM</th>
<th width="15%">Qty</th>
</tr>
</thead>
<tbody>
""".format(self.ra_bill_no or "")
sr = 1
sections = [
("TRENCH EXCAVATION", self.trench_summary()),
("MANHOLE EXCAVATION", self.manhole_summary()),
("DOMESTIC CHAMBER", self.domestic_summary()),
("PIPE LAYING", self.laying_summary()),
]
for title_text, rows in sections:
html += f"""
<tr class="table-secondary fw-bold">
<td colspan="4">{title_text}</td>
</tr>
"""
for item in rows:
html += f"""
<tr>
<td>{sr}</td>
<td>{item['Description']}</td>
<td>{item['UOM']}</td>
<td class="text-end">{item['Qty']:.2f}</td>
</tr>
"""
sr += 1
html += """
</tbody>
</table>
</div>
"""
return html

View File

@@ -0,0 +1,97 @@
from app.services.db_service import db
from app.models.client_rate_model import ClientRate
from sqlalchemy import func
class ClientRateService:
@staticmethod
def save_or_update(form):
rate_id = form.get("id")
category = form.get("category")
item_name = form.get("item_name").strip()
# -----------------------------
# Duplicate Validation
# -----------------------------
duplicate = (
ClientRate.query
.filter(
ClientRate.category == category,
func.lower(ClientRate.item_name) == item_name.lower()
)
.first()
)
# Ignore current record while editing
if duplicate and (not rate_id or duplicate.id != int(rate_id)):
return {
"success": False,
"message": "Category and Rate already exists for this Client."
}
# -----------------------------
# Insert / Update
# -----------------------------
if rate_id:
rate = ClientRate.query.get_or_404(rate_id)
else:
rate = ClientRate()
rate.category = category
rate.item_code = form.get("item_code")
rate.item_name = item_name
rate.unit = form.get("unit")
rate.rate = form.get("rate")
rate.effective_from = form.get("effective_from")
rate.effective_to = form.get("effective_to") or None
rate.status = form.get("status")
if not rate_id:
db.session.add(rate)
db.session.commit()
return {
"success": True,
"message": "Saved Successfully."
}
@staticmethod
def get_all_rates():
return (
ClientRate.query
.order_by(ClientRate.created_at.desc())
.all()
)
@staticmethod
def get_rate(rate_id):
return ClientRate.query.get_or_404(rate_id)
def delete_rate(rate_id):
rate = ClientRate.query.get_or_404(rate_id)
db.session.delete(rate)
db.session.commit()
@staticmethod
def check_duplicate(subcontractor_id, category, item_name, rate_id=None):
query = ClientRate.query.filter(
ClientRate.category == category,
func.lower(ClientRate.item_name) == item_name.strip().lower()
)
if rate_id:
query = query.filter(ClientRate.id != int(rate_id))
return query.first() is not None

View File

@@ -155,75 +155,79 @@
<!-- Client Standard Rates --> <!-- Client Standard Rates -->
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="/engi/client-rate"> <a class="nav-link" href="/engi/client-rate">
<i class="bi bi-file-earmark-text me-1"></i> Client Standard Rates <i class="bi bi-file-earmark-text me-1"></i> Client Rates
</a> </a>
</li> </li>
<!-- Formats -->
<li class="nav-item">
<a class="nav-link" href="/file_format">
<i class="bi bi-file-earmark-text me-1"></i> Formats
</a>
</li>
</ul> </ul>
</li> </li>
<!-- USER DROPDOWN --> <!-- USER DROPDOWN -->
{% if session.get("user_id") %} <li class="nav-item dropdown">
<li class="nav-item dropdown ms-lg-3">
<a class="nav-link dropdown-toggle d-flex align-items-center gap-2" href="#" <a class="nav-link dropdown-toggle d-flex align-items-center text-white"
data-bs-toggle="dropdown"> href="#" id="profileDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<i class="bi bi-person-circle fs-5"></i>
<span class="d-none d-lg-inline"> <i class="bi bi-person-circle fs-4"></i>
<span class="ms-2 fw-semibold">
{{ session.get("user_name") }} {{ session.get("user_name") }}
</span> </span>
</a> </a>
<ul class="dropdown-menu dropdown-menu-end dropdown-menu-dark shadow"> <ul class="dropdown-menu dropdown-menu-end dropdown-menu-dark border-0 shadow-lg bg-dark p-0"
style="width:320px;">
<!-- User card --> <!-- Profile Header -->
<li class="px-3 py-3 text-center border-bottom"> <li class="text-center py-4 border-bottom border-secondary">
<i class="bi bi-person-circle fs-1"></i> <i class="bi bi-person-circle text-light" style="font-size:60px;"></i>
<div class="fw-semibold mt-1"> <h5 class="mt-2 mb-0 fw-bold">
{{ session.get("user_name") }} {{ session.get("user_name") }}
</div> </h5>
<small class="text-muted">Logged in user</small> <small class="text-secondary">
{{ session.get("email") }}
</small>
</li> </li>
<!-- Dashboard --> <!-- Masters -->
<li> <li>
<a class="dropdown-item text-light py-2" href="{{ url_for('dashboard.dashboard') }}"> <a class="dropdown-item text-light py-2" href="{{ url_for('engineering.engineering_master') }}">
<i class="bi bi-speedometer2 me-2"></i> Dashboard <i class="bi bi-gear me-2"></i> Masters
</a> </a>
</li> </li>
<!-- Activity Log page -->
<li> <li>
<a class="dropdown-item text-light py-2" href="{{ url_for('activity.activity') }}"> <a class="dropdown-item text-light py-2" href="{{ url_for('activity.activity') }}">
<i class="bi bi-clock-history me-2"></i> Activity Log <i class="bi bi-clock-history me-2"></i> Activity Log
</a> </a>
</li> </li>
<!-- Manage Account --> <!-- Manage Account
<li> <li>
<a class="dropdown-item py-2" href="#"> <a class="dropdown-item py-2" href="#">
<i class="bi bi-gear me-2"></i> Manage Account <i class="bi bi-gear me-2"></i> Manage Account
</a> </a>
</li> </li>
-->
<li><hr class="dropdown-divider border-secondary m-0"></li> <li><hr class="dropdown-divider border-secondary m-0"></li>
<!-- Logout Account --> <!-- Logout Account -->
<li> <li>
<a class="dropdown-item text-warning" href="/logout"> <a class="dropdown-item text-warning py-2" href="{{ url_for('auth.logout') }}">
<i class="bi bi-box-arrow-right me-2"></i> Logout <i class="bi bi-box-arrow-right me-2"></i>
Logout
</a> </a>
</li> </li>
<!-- Footer -->
<li class="text-center py-3 bg-secondary bg-opacity-10 border-top border-secondary">
<small class="text-light">
<i class="bi bi-shield-check text-success"></i>
Secured by <strong>LCEPL</strong>
</small>
</li>
</ul> </ul>
</li> </li>
{% endif %}
</ul> </ul>
</div> </div>

View File

@@ -1,92 +1,347 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block content %} {% block content %}
<div class="container-fluid mt-4">
<h2 class="mb-4">Client RA Bills Reports</h2>
<div class="card p-4 shadow-sm mb-5"> <div class="container-fluid py-4">
<!-- Page Header -->
<div class="card shadow-sm border-0 mb-4">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center">
<div>
<h2 class="fw-bold text-primary mb-1">
<i class="bi bi-file-earmark-bar-graph"></i>
Client Report
</h2>
<small class="text-muted">
View, Filter, Edit and Delete Client Records
</small>
</div>
</div>
</div>
</div>
<!-- Filter Card -->
<div class="card shadow-sm border-0">
<div class="card-header bg-primary text-white">
<h5 class="mb-0">
<i class="bi bi-funnel-fill"></i>
Report Filters
</h5>
</div>
<div class="card-body">
<form method="POST" class="loading-form"> <form method="POST" class="loading-form">
<label class="form-label fw-bold">RA Bill No</label>
<input type="text" name="RA_Bill_No" class="form-control mb-3" value="{{ ra_val }}" required>
<div class="row"> <div class="row g-3">
<div class="col-md-6"> <div class="col-lg-3">
<button type="submit" name="action" value="preview" class="btn btn-secondary w-100">Preview <label class="form-label fw-semibold">
Data</button> RA Bill No
<span class="text-danger">*</span>
</label>
<input type="text" name="RA_Bill_No" class="form-control" placeholder="Enter RA Bill"
value="{{ ra_val or '' }}" required>
</div> </div>
<div class="col-md-6">
<button type="submit" name="action" value="download" class="btn btn-primary w-100">Download Excel Report</button> <div class="col-lg-3">
<label class="form-label fw-semibold"> MH No </label>
<input type="text" name="mh_no" class="form-control" placeholder="Enter MH No"
value="{{ mh_no_val or '' }}">
</div> </div>
<div class="col-lg-3">
<label class="form-label fw-semibold"> Location </label>
<input type="text" name="location" class="form-control" placeholder="Project Location"
value="{{ location_val or '' }}">
</div>
<div class="col-lg-3">
<label class="form-label fw-semibold">Work Category</label>
<select name="category" class="form-select">
<option value="all">All Categories</option>
<option value="tr" {% if category_val=='tr' %}selected{% endif %}>
Trench Excavation
</option>
<option value="mh" {% if category_val=='mh' %}selected{% endif %}>
Manhole Excavation
</option>
<option value="dc" {% if category_val=='dc' %}selected{% endif %}>
Manhole Domestic Chamber
</option>
<option value="laying" {% if category_val=='laying' %}selected{% endif %}>
Pipe Laying
</option>
</select>
</div>
</div>
<div class="mt-4 d-flex justify-content-end gap-2">
<!-- Preview -->
<button type="submit" name="action" value="preview" class="btn btn-primary">
<i class="bi bi-search"></i>
Preview Report
</button>
<!-- Download -->
<button type="submit" name="action" value="download" class="btn btn-success">
<i class="bi bi-download"></i>
Download Excel Report
</button>
<button type="reset" class="btn btn-secondary" id="resetBtn">
<i class="bi bi-arrow-clockwise"></i>
Reset
</button>
</div> </div>
</form> </form>
</div>
</div> </div>
{% if tables.tr or tables.mh or tables.dc or tables.laying %} {% if tables %}
<div class="card shadow-sm p-4"> {% set show_all = (not category_val) or category_val == 'all' %}
<h4 class="mb-3">Table Preview</h4> <!-- Tabs -->
<div class="card shadow-sm border-0 mt-4">
<div class="card-header bg-light">
<ul class="nav nav-pills">
<li class="nav-item">
<button class="nav-link {% if show_all %}active{% endif %}" data-bs-toggle="tab"
data-bs-target="#abstract">
<i class="bi bi-file-earmark-text"></i> Abstract
</button>
</li>
<ul class="nav nav-tabs" id="reportTabs" role="tablist"> {% if show_all or category_val == 'tr' %}
<li class="nav-item"> <li class="nav-item">
<button class="nav-link active" id="tr-tab" data-bs-toggle="tab" data-bs-target="#tr" <button class="nav-link {% if category_val == 'tr' %}active{% endif %}" data-bs-toggle="tab"
type="button">Tr.Ex </button> data-bs-target="#tr">
</li> <i class="bi bi-cone-striped"></i> Trench Excavation
<li class="nav-item">
<<<<<<< HEAD
<button class="nav-link" id="mh-tab" data-bs-toggle="tab" data-bs-target="#mh" type="button">Mh.Ex
</button> </button>
</li> </li>
{% endif %}
{% if show_all or category_val == 'mh' %}
<li class="nav-item"> <li class="nav-item">
<button class="nav-link" id="dc-tab" data-bs-toggle="tab" data-bs-target="#dc" type="button">MH & DC <button class="nav-link {% if category_val == 'mh' %}active{% endif %}" data-bs-toggle="tab"
data-bs-target="#mh">
<i class="bi bi-nut"></i> Manhole Excavation
</button> </button>
</li> </li>
{% endif %}
{% if show_all or category_val == 'dc' %}
<li class="nav-item"> <li class="nav-item">
<<<<<<< HEAD <button class="nav-link {% if category_val == 'dc' %}active{% endif %}" data-bs-toggle="tab"
<button class="nav-link" id="laying-tab" data-bs-toggle="tab" data-bs-target="#laying" data-bs-target="#dc">
type="button">Laying <i class="bi bi-grid-3x3"></i> Manhole & Domestic Chambers Construction
& Bedding Comparison</button> </button>
=======
<button class="nav-link" id="laying-tab" data-bs-toggle="tab" data-bs-target="#laying" type="button">Laying
& Bedding </button>
>>>>>>> 1dceb640bd930c37888799f10f02fe90b219be67
=======
<button class="nav-link" id="mh-tab" data-bs-toggle="tab" data-bs-target="#mh" type="button">
Mh.Ex</button>
</li> </li>
{% endif %}
{% if show_all or category_val == 'laying' %}
<li class="nav-item"> <li class="nav-item">
<button class="nav-link" id="dc-tab" data-bs-toggle="tab" data-bs-target="#dc" type="button"> <button class="nav-link {% if category_val == 'laying' %}active{% endif %}" data-bs-toggle="tab"
MH & DC</button> data-bs-target="#laying">
<i class="bi bi-bezier2"></i> Pipe Laying
</button>
</li> </li>
<li class="nav-item"> {% endif %}
<button class="nav-link" id="laying-tab" data-bs-toggle="tab" data-bs-target="#laying"type="button">
Laying & Bedding </button>
>>>>>>> pankaj-dev
</ul> </ul>
</div>
<div class="tab-content mt-3" id="reportTabsContent"> <div class="card-body">
<div class="tab-pane fade show active" id="tr" role="tabpanel"> <div class="tab-content">
<div class="table-responsive" style="max-height: 500px;">
<div class="tab-pane fade {% if show_all %}show active{% endif %}" id="abstract">
{{ abstract_html|safe }}
</div>
{% if show_all or category_val == 'tr' %}
<!-- Trench -->
<div class="tab-pane fade {% if category_val == 'tr' %}show active{% endif %}" id="tr">
{% if has_data.tr %}
<div class="mb-3">
<button onclick="deleteSelected('tr_client')" class="btn btn-danger">
<i class="bi bi-trash"></i> Delete Selected
</button>
</div>
{% endif %}
<div class="table-responsive border rounded shadow-sm">
{{ tables.tr|safe }} {{ tables.tr|safe }}
</div> </div>
</div> </div>
<div class="tab-pane fade" id="mh" role="tabpanel"> {% endif %}
<div class="table-responsive" style="max-height: 500px;">
{% if show_all or category_val == 'mh' %}
<!-- MH -->
<div class="tab-pane fade {% if category_val == 'mh' %}show active{% endif %}" id="mh">
{% if has_data.mh %}
<div class="mb-3">
<button onclick="deleteSelected('mh_client')" class="btn btn-danger">
<i class="bi bi-trash"></i> Delete Selected
</button>
</div>
{% endif %}
<div class="table-responsive border rounded shadow-sm">
{{ tables.mh|safe }} {{ tables.mh|safe }}
</div> </div>
</div> </div>
<div class="tab-pane fade" id="dc" role="tabpanel"> {% endif %}
<div class="table-responsive" style="max-height: 500px;">
{% if show_all or category_val == 'dc' %}
<!-- DC -->
<div class="tab-pane fade {% if category_val == 'dc' %}show active{% endif %}" id="dc">
{% if has_data.dc %}
<div class="mb-3">
<button onclick="deleteSelected('dc_client')" class="btn btn-danger">
<i class="bi bi-trash"></i> Delete Selected
</button>
</div>
{% endif %}
<div class="table-responsive border rounded shadow-sm">
{{ tables.dc|safe }} {{ tables.dc|safe }}
</div> </div>
</div> </div>
<div class="tab-pane fade" id="laying" role="tabpanel"> {% endif %}
<div class="table-responsive" style="max-height: 500px;">
{% if show_all or category_val == 'laying' %}
<!-- Laying -->
<div class="tab-pane fade {% if category_val == 'laying' %}show active{% endif %}" id="laying">
{% if has_data.laying %}
<div class="mb-3">
<button onclick="deleteSelected('laying_client')" class="btn btn-danger">
<i class="bi bi-trash"></i> Delete Selected
</button>
</div>
{% endif %}
<div class="table-responsive border rounded shadow-sm">
{{ tables.laying|safe }} {{ tables.laying|safe }}
</div> </div>
</div>
{% endif %}
</div>
</div> </div>
</div> </div>
{% endif %} {% endif %}
</div> </div>
</div>
<script>
document.addEventListener("DOMContentLoaded", function () {
const TAB_STORAGE_KEY = "clientReportActiveTab";
$(document).on("shown.bs.tab", '[data-bs-toggle="tab"]', function (e) {
let target = $(e.target).attr("data-bs-target");
if (target) sessionStorage.setItem(TAB_STORAGE_KEY, target);
});
(function restoreActiveTab() {
let target = sessionStorage.getItem(TAB_STORAGE_KEY);
if (!target) return;
let btn = document.querySelector(`[data-bs-toggle="tab"][data-bs-target="${target}"]`);
if (btn) {
bootstrap.Tab.getOrCreateInstance(btn).show();
}
})();
// Reset
document.getElementById("resetBtn").addEventListener("click", function () {
sessionStorage.removeItem(TAB_STORAGE_KEY);
window.location.href = window.location.pathname;
});
$('.datatable').each(function () {
try {
$(this).DataTable({
pageLength: 10,
dom: 'Bfrtip',
buttons: ['copy', 'csv', 'excel', 'print'],
columnDefs: [
{ orderable: false, targets: [0, -1, -2] } // Select, Update, Delete columns
]
});
} catch (err) {
console.error("DataTable init failed for a table:", err);
}
});
$(document).on("change", ".select-all-checkbox", function () {
let model = $(this).data("model");
$(`.row-check[data-model="${model}"]`).prop("checked", this.checked);
});
$(document).on("change", ".row-check", function () {
let model = $(this).data("model");
let $rows = $(`.row-check[data-model="${model}"]`);
let allChecked = $rows.length > 0 && $rows.length === $rows.filter(":checked").length;
$(`.select-all-checkbox[data-model="${model}"]`).prop("checked", allChecked);
});
// SINGLE DELETE
$(document).on("click", ".delete-btn", function () {
let id = $(this).data("id");
let model = $(this).data("model");
if (!confirm("Are you sure you want to delete this record?")) return;
fetch("/file/delete_records", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ model: model, ids: [id] })
})
.then(res => res.json().then(data => ({ ok: res.ok, data })))
.then(({ ok, data }) => {
if (ok && data.status === "success") {
alert("Deleted Successfully");
location.reload();
} else {
alert("Delete failed: " + (data.message || "Unknown error"));
}
})
.catch(err => {
alert("Delete request failed: " + err);
});
});
});
// GET IDS - scoped to a single table via data-model.
function getSelectedIds(model) {
let ids = [];
$(`.row-check[data-model="${model}"]:checked`).each(function () {
ids.push($(this).data("id"));
});
return ids;
}
window.deleteSelected = function (model) {
let ids = getSelectedIds(model);
if (ids.length === 0) return alert("Select records");
if (!confirm(`Delete ${ids.length} record(s)?`)) return;
fetch("/file/delete_records", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ model: model, ids: ids })
})
.then(res => res.json().then(data => ({ ok: res.ok, data })))
.then(({ ok, data }) => {
if (ok && data.status === "success") {
alert("Deleted Successfully");
location.reload();
} else {
alert("Delete failed: " + (data.message || "Unknown error"));
}
})
.catch(err => {
alert("Delete request failed: " + err);
});
}
</script>
{% endblock %} {% endblock %}

View File

@@ -14,7 +14,353 @@
</div> </div>
<div class="card-body">
<form method="POST" id="rateForm">
<!-- Hidden ID -->
<input type="hidden" id="rate_id" name="id" value="{{ rate.id if rate else '' }}">
<div class="row">
<!-- Category -->
<div class="col-md-4 mb-3">
<label class="form-label fw-bold"> Category </label>
<select id="category" name="category" class="form-select" required>
<option value="">-- Select Category --</option>
<option value="trench_excavation"
{% if rate and rate.category=="trench_excavation" %}selected{% endif %}>
Trench Excavation
</option>
<option value="manhole_excavation"
{% if rate and rate.category=="manhole_excavation" %}selected{% endif %}>
Manhole Excavation
</option>
<option value="Manhole_Domestic_Chamber"
{% if rate and rate.category=="Manhole_Domestic_Chamber" %}selected{% endif %}>
MH & Domestic Chamber
</option>
<option value="Laying"
{% if rate and rate.category=="Laying" %}selected{% endif %}>
Pipe Laying
</option>
</select>
</div>
<!-- Status -->
<div class="col-md-4 mb-3">
<label class="form-label fw-bold"> Status </label>
<select name="status" class="form-select">
<option value="Active"
{% if not rate or rate.status=="Active" %}selected{% endif %}>
Active
</option>
<option value="Inactive"
{% if rate and rate.status=="Inactive" %}selected{% endif %}>
Inactive
</option>
</select>
</div>
</div>
<div class="row">
<!-- Item Code -->
<div class="col-md-3 mb-3">
<label class="form-label fw-bold"> Item Code </label>
<input type="text" name="item_code" class="form-control" value="{{ rate.item_code if rate else '' }}" required>
</div>
<!-- Item Name -->
<div class="col-md-5 mb-3">
<label class="form-label fw-bold"> Item Name </label>
<input type="text"
id="item_name"
name="item_name"
class="form-control"
autocomplete="off"
value="{{ rate.item_name if rate else '' }}"
required>
<small id="duplicateMessage"
class="text-danger"
style="display:none;">
</small>
</div> </div>
<!-- Unit -->
<div class="col-md-2 mb-3">
<label class="form-label fw-bold">Unit</label>
<select name="unit" class="form-select">
<option value="Cum"
{% if not rate or rate.unit=="Cum" %}selected{% endif %}>
Cum
</option>
<option value="Nos"
{% if rate and rate.unit=="Nos" %}selected{% endif %}>
Nos
</option>
<option value="Rmt"
{% if rate and rate.unit=="Rmt" %}selected{% endif %}>
Rmt
</option>
<option value="Sqm"
{% if rate and rate.unit=="Sqm" %}selected{% endif %}>
Sqm
</option>
</select>
</div>
<!-- Rate -->
<div class="col-md-2 mb-3">
<label class="form-label fw-bold">Rate</label>
<input type="number" step="0.01" name="rate" class="form-control" value="{{ rate.rate if rate else '' }}" required>
</div>
</div>
<div class="row">
<div class="col-md-3 mb-3">
<label class="form-label fw-bold"> Effective From </label>
<input type="date" name="effective_from" class="form-control" value="{{ rate.effective_from if rate else '' }}" required>
</div>
<div class="col-md-3 mb-3">
<label class="form-label fw-bold"> Effective To </label>
<input type="date" name="effective_to" class="form-control" value="{{ rate.effective_to if rate else '' }}">
</div>
</div>
<hr>
<div class="text-end">
<a href="{{ url_for('engineering.client_rate_master') }}" class="btn btn-secondary">
<i class="bi bi-arrow-clockwise"></i> Reset
</a>
<button type="submit" id="saveBtn" class="btn btn-success">
{% if rate %}
<i class="bi bi-pencil-square"></i>
Update Rate
{% else %}
<i class="bi bi-check-circle"></i>
Save Rate
{% endif %}
</button>
</div>
</form>
</div>
</div>
<!-- Table -->
<div class="card shadow mt-4">
<div class="card-header bg-dark text-white">
<h5 class="mb-0">
<i class="bi bi-table"></i>Rate List
</h5>
</div>
<div class="card-body">
<table class="table table-bordered table-hover table-striped" id="rateTable">
<thead class="table-primary">
<tr>
<th>#</th>
<th>Category</th>
<th>Item Code</th>
<th>Item Name</th>
<th>Unit</th>
<th>Rate</th>
<th>Status</th>
<th width="130">Action</th>
</tr>
</thead>
<tbody>
{% for row in rates %}
<tr>
<td>{{ loop.index }}</td>
<td>{{ row.category }}</td>
<td>{{ row.item_code }}</td>
<td>{{ row.item_name }}</td>
<td>{{ row.unit }}</td>
<td>{{ row.rate }}</td>
<td>
{% if row.status=="Active" %}
<span class="badge bg-success">
Active
</span>
{% else %}
<span class="badge bg-danger">
Inactive
</span>
{% endif %}
</td>
<td>
<a href="{{ url_for('engineering.client_edit_rate', rate_id=row.id) }}" class="btn btn-warning btn-sm">
<i class="bi bi-pencil-square"></i>
</a>
<a href="{{ url_for('engineering.client_delete_rate', rate_id=row.id) }}"
class="btn btn-danger btn-sm" onclick="return confirm('Delete this Item:{{row.item_name}} & Rate:{{row.rate}} ?')">
<i class="bi bi-trash"></i>
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
<script>
$(document).ready(function () {
// ----------------------------
// DataTable
// ----------------------------
$("#rateTable").DataTable({
responsive: true,
pageLength: 10,
destroy: true
});
// ----------------------------
// Validate on field change
// ----------------------------
$("#subcontractor_id, #category").on("change", function () {
clearValidation();
checkDuplicateRate();
});
// ----------------------------
// Validate while typing
// ----------------------------
let timer;
$("#item_name").on("keyup input", function () {
clearTimeout(timer);
timer = setTimeout(function () {
checkDuplicateRate();
}, 300);
});
// Edit Mode
checkDuplicateRate();
// ----------------------------
// Prevent Submit
// ----------------------------
$("#rateForm").submit(function (e) {
if ($("#saveBtn").prop("disabled")) {
e.preventDefault();
$("#item_name").focus();
return false;
}
});
});
//=========================================
// Reset Validation
//=========================================
function clearValidation() {
$("#duplicateMessage")
.hide()
.text("")
.removeClass("text-success text-danger");
$("#item_name")
.removeClass("is-valid is-invalid");
$("#saveBtn").prop("disabled", false);
}
//=========================================
// Duplicate Validation
//=========================================
function checkDuplicateRate() {
let subcontractor = $("#subcontractor_id").val();
let category = $("#category").val();
let item_name = $("#item_name").val().trim();
let rate_id = $("#rate_id").val();
// Mandatory fields
if (
subcontractor == "" ||
category == "" ||
item_name.length < 2
) {
clearValidation();
return;
}
$.ajax({
url: "{{ url_for('engineering.check_rate') }}",
type: "GET",
dataType: "json",
data: {
subcontractor_id: subcontractor,
category: category,
item_name: item_name,
rate_id: rate_id
},
success: function (response) {
if (response.exists) {
$("#duplicateMessage")
.text("This Item Name already exists for the selected Subcontractor and Category.")
.removeClass("text-success")
.addClass("text-danger")
.show();
$("#item_name")
.removeClass("is-valid")
.addClass("is-invalid");
$("#saveBtn").prop("disabled", true);
}
else {
$("#duplicateMessage")
.text("Item Name is available.")
.removeClass("text-danger")
.addClass("text-success")
.show();
$("#item_name")
.removeClass("is-invalid")
.addClass("is-valid");
$("#saveBtn").prop("disabled", false);
}
},
error: function () {
clearValidation();
}
});
}
</script>
{% endblock %} {% endblock %}

View File

@@ -4,14 +4,12 @@
<div class="container-fluid mt-4"> <div class="container-fluid mt-4">
<div class="card shadow"> <div class="card shadow">
<!-- Heading -->
<div class="card-header bg-primary text-white d-flex justify-content-between align-items-center"> <div class="card-header bg-primary text-white d-flex justify-content-between align-items-center">
<h4 class="mb-0"> <h4 class="mb-0">
<i class="bi bi-currency-rupee"></i> <i class="bi bi-currency-rupee"></i>
Subcontractor Rate Master Subcontractor Rate Master
</h4> </h4>
</div> </div>
<div class="card-body"> <div class="card-body">
@@ -67,23 +65,6 @@
</select> </select>
</div> </div>
<!-- Status -->
<div class="col-md-4 mb-3">
<label class="form-label fw-bold"> Status </label>
<select name="status" class="form-select">
<option value="Active"
{% if not rate or rate.status=="Active" %}selected{% endif %}>
Active
</option>
<option value="Inactive"
{% if rate and rate.status=="Inactive" %}selected{% endif %}>
Inactive
</option>
</select>
</div>
</div> </div>
<div class="row"> <div class="row">
@@ -95,7 +76,7 @@
</div> </div>
<!-- Item Name --> <!-- Item Name -->
<div class="col-md-5 mb-3"> <div class="col-md-4 mb-3">
<label class="form-label fw-bold"> Item Name </label> <label class="form-label fw-bold"> Item Name </label>
<input type="text" <input type="text"
id="item_name" id="item_name"
@@ -116,6 +97,7 @@
<div class="col-md-2 mb-3"> <div class="col-md-2 mb-3">
<label class="form-label fw-bold">Unit</label> <label class="form-label fw-bold">Unit</label>
<select name="unit" class="form-select"> <select name="unit" class="form-select">
<option value=""> -- Select Unit -- </option>
<option value="Cum" <option value="Cum"
{% if not rate or rate.unit=="Cum" %}selected{% endif %}> {% if not rate or rate.unit=="Cum" %}selected{% endif %}>
Cum Cum
@@ -136,28 +118,46 @@
</div> </div>
<!-- Rate --> <!-- Rate -->
<div class="col-md-2 mb-3"> <div class="col-md-3 mb-3">
<label class="form-label fw-bold">Rate</label> <label class="form-label fw-bold">Rate</label>
<input type="number" step="0.01" name="rate" class="form-control" value="{{ rate.rate if rate else '' }}" required> <input type="number" step="0.01" name="rate" class="form-control" value="{{ rate.rate if rate else '' }}" required>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<!-- Effective From -->
<div class="col-md-3 mb-3"> <div class="col-md-3 mb-3">
<label class="form-label fw-bold"> Effective From </label> <label class="form-label fw-bold"> Effective From </label>
<input type="date" name="effective_from" class="form-control" value="{{ rate.effective_from if rate else '' }}" required> <input type="date" name="effective_from" class="form-control" value="{{ rate.effective_from if rate else '' }}" required>
</div> </div>
<!-- Effective To -->
<div class="col-md-3 mb-3"> <div class="col-md-3 mb-3">
<label class="form-label fw-bold"> Effective To </label> <label class="form-label fw-bold"> Effective To </label>
<input type="date" name="effective_to" class="form-control" value="{{ rate.effective_to if rate else '' }}"> <input type="date" name="effective_to" class="form-control" value="{{ rate.effective_to if rate else '' }}">
</div> </div>
<!-- Status -->
<div class="col-md-3 mb-3">
<label class="form-label fw-bold"> Status </label>
<select name="status" class="form-select">
<option value="Active"
{% if not rate or rate.status=="Active" %}selected{% endif %}>
Active
</option>
<option value="Inactive"
{% if rate and rate.status=="Inactive" %}selected{% endif %}>
Inactive
</option>
</select>
</div>
</div> </div>
<hr> <hr>
<div class="text-end"> <div class="text-end">
<a href="{{ url_for('engineering.add_subcontractor_rates') }}" class="btn btn-secondary"> <a href="{{ url_for('engineering.subcontractor_rate_master') }}" class="btn btn-secondary">
<i class="bi bi-arrow-clockwise"></i> Reset <i class="bi bi-arrow-clockwise"></i> Reset
</a> </a>
@@ -222,11 +222,11 @@
</td> </td>
<td> <td>
<a href="{{ url_for('engineering.edit_rate', rate_id=row.id) }}" class="btn btn-warning btn-sm"> <a href="{{ url_for('engineering.subcontractor_edit_rate', rate_id=row.id) }}" class="btn btn-warning btn-sm">
<i class="bi bi-pencil-square"></i> <i class="bi bi-pencil-square"></i>
</a> </a>
<a href="{{ url_for('engineering.delete_rate', rate_id=row.id) }}" <a href="{{ url_for('engineering.subcontractor_delete_rate', rate_id=row.id) }}"
class="btn btn-danger btn-sm" onclick="return confirm('Delete this Item:{{row.item_name}} & Rate:{{row.rate}} ?')"> class="btn btn-danger btn-sm" onclick="return confirm('Delete this Item:{{row.item_name}} & Rate:{{row.rate}} ?')">
<i class="bi bi-trash"></i> <i class="bi bi-trash"></i>
</a> </a>

View File

@@ -32,7 +32,7 @@
Manage subcontractor-wise rates. Manage subcontractor-wise rates.
</p> </p>
<a href="{{ url_for('engineering.add_subcontractor_rates') }}" <a href="{{ url_for('engineering.subcontractor_rate_master') }}"
class="btn btn-success"> class="btn btn-success">
<i class="bi bi-arrow-right-circle"></i> <i class="bi bi-arrow-right-circle"></i>
@@ -62,7 +62,7 @@
Manage client standard rates. Manage client standard rates.
</p> </p>
<a href="{{ url_for('engineering.client_rates') }}" <a href="{{ url_for('engineering.client_rate_master') }}"
class="btn btn-primary"> class="btn btn-primary">
<i class="bi bi-arrow-right-circle"></i> <i class="bi bi-arrow-right-circle"></i>

View File

@@ -33,13 +33,26 @@
<form method="POST" class="loading-form"> <form method="POST" class="loading-form">
<div class="row g-3"> <div class="row g-3">
<div class="col-lg-3">
<label class="form-label fw-semibold"> Location </label>
<select name="location" id="location" class="form-select">
<option value="">--- Select Location ---</option>
{% for loc in locations %}
<option value="{{ loc }}"
{% if selected_location == loc %}selected{% endif %}>
{{ loc }}
</option>
{% endfor %}
</select>
</div>
<div class="col-lg-3"> <div class="col-lg-3">
<label class="form-label fw-semibold"> <label class="form-label fw-semibold">
Subcontractor Subcontractor
<span class="text-danger">*</span> <span class="text-muted fw-normal"></span>
</label> </label>
<select name="subcontractor_id" class="form-select" required> <select name="subcontractor_id" id="subcontractor_id" class="form-select">
<option value="">--- Select Contractor ---</option> <option value="">--- All Subcontractors ---</option>
{% for sc in subcontractors %} {% for sc in subcontractors %}
<option value="{{ sc.id }}" <option value="{{ sc.id }}"
{% if selected_sc_id|string == sc.id|string %}selected{% endif %}> {% if selected_sc_id|string == sc.id|string %}selected{% endif %}>
@@ -61,13 +74,13 @@
</div> </div>
<div class="col-lg-3"> <div class="col-lg-3">
<label class="form-label fw-semibold"> Location </label> <label class="form-label fw-semibold"> MH No </label>
<input <input
type="text" type="text"
name="location" name="mh_no"
class="form-control" class="form-control"
placeholder="Project Location" placeholder="Enter MH No"
value="{{ selected_location or '' }}"> value="{{ selected_mh_no or '' }}">
</div> </div>
<div class="col-lg-3"> <div class="col-lg-3">
@@ -88,7 +101,7 @@
<option value="dc" <option value="dc"
{% if request.form.get('category')=='dc' %}selected{% endif %}> {% if request.form.get('category')=='dc' %}selected{% endif %}>
Domestic Chamber Manhole Domestic Chamber
</option> </option>
<option value="laying" <option value="laying"
@@ -210,11 +223,19 @@
{% if show_all or selected_category == 'tr' %} {% if show_all or selected_category == 'tr' %}
<!-- Trench --> <!-- Trench -->
<div class="tab-pane fade {% if selected_category == 'tr' %}show active{% endif %}" id="tr"> <div class="tab-pane fade {% if selected_category == 'tr' %}show active{% endif %}" id="tr">
<div class="mb-3"> {% if has_data.tr %}
<div class="mb-3 d-flex gap-2 flex-wrap">
<button onclick="deleteSelected('tr')" class="btn btn-danger"> <button onclick="deleteSelected('tr')" class="btn btn-danger">
<i class="bi bi-trash"></i> Delete Selected <i class="bi bi-trash"></i> Delete Selected
</button> </button>
<button type="button" class="btn btn-outline-primary bulk-edit-toggle-btn" data-model="tr">
<i class="bi bi-pencil-square"></i> Bulk Edit
</button>
<button type="button" class="btn btn-outline-secondary bulk-edit-cancel-btn d-none" data-model="tr">
Cancel
</button>
</div> </div>
{% endif %}
<div class="table-responsive border rounded shadow-sm"> <div class="table-responsive border rounded shadow-sm">
{{ tables.tr|safe }} {{ tables.tr|safe }}
</div> </div>
@@ -224,11 +245,19 @@
{% if show_all or selected_category == 'mh' %} {% if show_all or selected_category == 'mh' %}
<!-- MH --> <!-- MH -->
<div class="tab-pane fade {% if selected_category == 'mh' %}show active{% endif %}" id="mh"> <div class="tab-pane fade {% if selected_category == 'mh' %}show active{% endif %}" id="mh">
<div class="mb-3"> {% if has_data.mh %}
<div class="mb-3 d-flex gap-2 flex-wrap">
<button onclick="deleteSelected('mh')" class="btn btn-danger"> <button onclick="deleteSelected('mh')" class="btn btn-danger">
<i class="bi bi-trash"></i>Delete Selected <i class="bi bi-trash"></i>Delete Selected
</button> </button>
<button type="button" class="btn btn-outline-primary bulk-edit-toggle-btn" data-model="mh">
<i class="bi bi-pencil-square"></i> Bulk Edit
</button>
<button type="button" class="btn btn-outline-secondary bulk-edit-cancel-btn d-none" data-model="mh">
Cancel
</button>
</div> </div>
{% endif %}
<div class="table-responsive border rounded shadow-sm"> <div class="table-responsive border rounded shadow-sm">
{{ tables.mh|safe }} {{ tables.mh|safe }}
</div> </div>
@@ -238,12 +267,20 @@
{% if show_all or selected_category == 'dc' %} {% if show_all or selected_category == 'dc' %}
<!-- DC --> <!-- DC -->
<div class="tab-pane fade {% if selected_category == 'dc' %}show active{% endif %}" id="dc"> <div class="tab-pane fade {% if selected_category == 'dc' %}show active{% endif %}" id="dc">
<div class="mb-3"> {% if has_data.dc %}
<div class="mb-3 d-flex gap-2 flex-wrap">
<button onclick="deleteSelected('dc')"class="btn btn-danger"> <button onclick="deleteSelected('dc')"class="btn btn-danger">
<i class="bi bi-trash"></i> <i class="bi bi-trash"></i>
Delete Selected Delete Selected
</button> </button>
<button type="button" class="btn btn-outline-primary bulk-edit-toggle-btn" data-model="dc">
<i class="bi bi-pencil-square"></i> Bulk Edit
</button>
<button type="button" class="btn btn-outline-secondary bulk-edit-cancel-btn d-none" data-model="dc">
Cancel
</button>
</div> </div>
{% endif %}
<div class="table-responsive border rounded shadow-sm"> <div class="table-responsive border rounded shadow-sm">
{{ tables.dc|safe }} {{ tables.dc|safe }}
</div> </div>
@@ -253,13 +290,21 @@
{% if show_all or selected_category == 'laying' %} {% if show_all or selected_category == 'laying' %}
<!-- Laying --> <!-- Laying -->
<div class="tab-pane fade {% if selected_category == 'laying' %}show active{% endif %}" id="laying"> <div class="tab-pane fade {% if selected_category == 'laying' %}show active{% endif %}" id="laying">
<div class="mb-3"> {% if has_data.laying %}
<div class="mb-3 d-flex gap-2 flex-wrap">
<button onclick="deleteSelected('laying')" <button onclick="deleteSelected('laying')"
class="btn btn-danger"> class="btn btn-danger">
<i class="bi bi-trash"></i> <i class="bi bi-trash"></i>
Delete Selected Delete Selected
</button> </button>
<button type="button" class="btn btn-outline-primary bulk-edit-toggle-btn" data-model="laying">
<i class="bi bi-pencil-square"></i> Bulk Edit
</button>
<button type="button" class="btn btn-outline-secondary bulk-edit-cancel-btn d-none" data-model="laying">
Cancel
</button>
</div> </div>
{% endif %}
<div class="table-responsive border rounded shadow-sm"> <div class="table-responsive border rounded shadow-sm">
{{ tables.laying|safe }} {{ tables.laying|safe }}
</div> </div>
@@ -273,76 +318,246 @@
</div> </div>
<script> <script>
// NOTE: this content block renders before base.html's bottom-of-body
// <script src="jquery..."> tag, so $ is not defined yet if this runs
// immediately - that was silently breaking the location cascade
// (and DataTable init) below. Deferring to DOMContentLoaded (native
// JS, no jQuery needed to register it) guarantees jQuery has loaded
// by the time this code actually runs.
document.addEventListener("DOMContentLoaded", function () {
// Remember which tab is active so that actions which reload the
// page (Delete Selected, bulk delete, bulk-edit Save) bring you
// back to the tab you were working on instead of resetting to
// the Abstract tab (the default "active" one in the markup).
const TAB_STORAGE_KEY = "subReportActiveTab";
$(document).on("shown.bs.tab", '[data-bs-toggle="tab"]', function (e) {
let target = $(e.target).attr("data-bs-target"); // e.g. "#tr"
if (target) sessionStorage.setItem(TAB_STORAGE_KEY, target);
});
(function restoreActiveTab() {
let target = sessionStorage.getItem(TAB_STORAGE_KEY);
if (!target) return;
let btn = document.querySelector(`[data-bs-toggle="tab"][data-bs-target="${target}"]`);
if (btn) {
bootstrap.Tab.getOrCreateInstance(btn).show();
}
})();
// Reset
document.getElementById("resetBtn").addEventListener("click", function () { document.getElementById("resetBtn").addEventListener("click", function () {
sessionStorage.removeItem(TAB_STORAGE_KEY);
window.location.href = window.location.pathname; window.location.href = window.location.pathname;
}); });
// DATATABLE // LOCATION -> SUBCONTRACTOR CASCADE
$(document).ready(function () { $(document).on("change", "#location", function () {
let location = $(this).val();
let $sc = $("#subcontractor_id");
let currentVal = $sc.val();
$.getJSON("/file/get_subcontractors_by_location", { location: location }, function (data) {
$sc.empty().append('<option value="">--- All Subcontractors ---</option>');
data.forEach(function (sc) {
$sc.append(`<option value="${sc.id}">${sc.name}</option>`);
});
if (data.some(sc => String(sc.id) === String(currentVal))) {
$sc.val(currentVal);
}
}).fail(function () {
alert("Failed to load subcontractors for this location.");
});
});
// DATATABLE
// Initialize each table independently and wrap in try/catch: if
// one table is malformed for any reason, it logs an error but
// does NOT stop the rest of this script (select-all handlers,
// delete handlers, etc.) from registering for the other tables.
// Instances are kept in dtInstances (keyed by model) so bulk-edit
// mode can force "show all rows" and disable search on demand.
const dtInstances = {};
$('.datatable').each(function () { $('.datatable').each(function () {
$(this).DataTable({ try {
let model = $(this).find('.select-all-checkbox').data('model');
let dt = $(this).DataTable({
pageLength: 10, pageLength: 10,
dom: 'Bfrtip', dom: 'Bfrtip',
buttons: ['copy', 'csv', 'excel', 'print'], buttons: ['copy', 'csv', 'excel', 'print'],
initComplete: function () { columnDefs: [
{ orderable: false, targets: [0, -1, -2] } // Select, Update, Delete columns
$(this).closest('.dataTables_wrapper') ]
.find('thead tr th:first-child') });
.html('<input type="checkbox" class="select-all" title="Select All">'); if (model) dtInstances[model] = dt;
} catch (err) {
console.error("DataTable init failed for a table:", err);
} }
}); });
});
// SELECT ALL (per table)
// The header checkbox is rendered server-side with
// class="select-all-checkbox" and data-model="tr|mh|dc|laying"
// (see add_select_all_header in file_report.py), and each row
// checkbox carries the same data-model. Scoping by data-model
// means checking "select all" on the Trench Excavation tab only
// toggles Trench Excavation rows, not the other 3 tables.
$(document).on("change", ".select-all-checkbox", function () {
let model = $(this).data("model");
$(`.row-check[data-model="${model}"]`).prop("checked", this.checked);
}); });
// SELECT ALL — scoped to the checkbox's own table only // Keep a table's select-all checkbox in sync if a row is
$(document).on("change", ".select-all", function () { // unchecked/checked individually.
$(this).closest("table").find(".row-check").prop("checked", this.checked);
});
// If a row checkbox is unchecked manually, uncheck that table's select-all
$(document).on("change", ".row-check", function () { $(document).on("change", ".row-check", function () {
if (!this.checked) { let model = $(this).data("model");
$(this).closest("table").find(".select-all").prop("checked", false); let $rows = $(`.row-check[data-model="${model}"]`);
let allChecked = $rows.length > 0 && $rows.length === $rows.filter(":checked").length;
$(`.select-all-checkbox[data-model="${model}"]`).prop("checked", allChecked);
});
// ============== BULK EDIT (per table) ==============
// Each of the 4 tables has its own Bulk Edit / Cancel button
// (data-model="tr|mh|dc|laying"). Editing one table never
// touches the others - each is entered, tracked, saved, and
// cancelled independently, and multiple tables can be in edit
// mode at the same time if you click more than one toggle.
//
// Every <td data-field="..."> (see add_data_field_attrs in
// file_report.py) is an editable data cell whose data-field
// names the real database column. Tab-pane ids ("tr", "mh",
// "dc", "laying") match the model keys 1:1, so `#${model}` scopes
// every selector below to just that one table.
let bulkEditActiveModels = {};
let pendingBulkChanges = {};
function bulkEditButtons(model) {
return {
$toggle: $(`.bulk-edit-toggle-btn[data-model="${model}"]`),
$cancel: $(`.bulk-edit-cancel-btn[data-model="${model}"]`)
};
}
function enterBulkEditMode(model) {
bulkEditActiveModels[model] = true;
pendingBulkChanges[model] = {};
// Show every row and disable search for THIS table only -
// otherwise DataTables pagination/filtering could redraw
// this table using its own stored (unedited) data and
// silently wipe out edits on a row that's since scrolled
// off-page.
let dt = dtInstances[model];
if (dt) {
dt.page.len(-1).draw(false);
$(dt.table().container()).find('.dataTables_filter input').prop('disabled', true);
}
$(`#${model} td[data-field]`).each(function () {
let original = $(this).text().trim();
$(this).data('original', original);
$(this).empty().append(
$('<input>', {
type: 'text',
class: 'form-control form-control-sm bulk-edit-input',
value: original
})
);
});
let { $toggle, $cancel } = bulkEditButtons(model);
$toggle.html('<i class="bi bi-save"></i> Save All Changes')
.removeClass('btn-outline-primary').addClass('btn-success');
$cancel.removeClass('d-none');
}
function exitBulkEditMode(model, { revert }) {
bulkEditActiveModels[model] = false;
pendingBulkChanges[model] = {};
$(`#${model} td[data-field]`).each(function () {
let $td = $(this);
let $input = $td.find('.bulk-edit-input');
if ($input.length) {
let value = revert ? ($td.data('original') ?? '') : $input.val();
$td.empty().text(value);
} }
}); });
let dt = dtInstances[model];
function getSelectedIds(model) { if (dt) {
let ids = []; dt.page.len(10).draw(false);
$("#" + model + " .row-check:checked").each(function () { $(dt.table().container()).find('.dataTables_filter input').prop('disabled', false);
ids.push($(this).data("id"));
});
return ids;
} }
// BULK DELETE let { $toggle, $cancel } = bulkEditButtons(model);
function deleteSelected(model) { $toggle.html('<i class="bi bi-pencil-square"></i> Bulk Edit')
let ids = getSelectedIds(model); .removeClass('btn-success').addClass('btn-outline-primary');
if (ids.length === 0) return alert("Select records"); $cancel.addClass('d-none');
}
if (!confirm(`Delete ${ids.length} record(s)?`)) return; $(document).on('input', '.bulk-edit-input', function () {
let $td = $(this).closest('td');
let $tr = $(this).closest('tr');
let field = $td.data('field');
let model = $tr.find('.delete-btn').data('model');
let id = $tr.find('.delete-btn').data('id');
if (!model || id === undefined) return;
fetch("/file/delete_records", { if (!pendingBulkChanges[model]) pendingBulkChanges[model] = {};
if (!pendingBulkChanges[model][id]) pendingBulkChanges[model][id] = {};
pendingBulkChanges[model][id][field] = $(this).val();
});
function saveBulkChanges(model) {
let changes = pendingBulkChanges[model] || {};
if (Object.keys(changes).length === 0) {
alert("No changes to save.");
return;
}
if (!confirm("Save all changes?")) return;
let payload = {};
payload[model] = changes;
fetch("/file/bulk_update", {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ model: model, ids: ids }) body: JSON.stringify(payload)
}) })
.then(res => res.json().then(data => ({ ok: res.ok, data }))) .then(res => res.json().then(data => ({ ok: res.ok, data })))
.then(({ ok, data }) => { .then(({ ok, data }) => {
if (ok && data.status === "success") { if (ok && data.status === "success") {
alert("Deleted Successfully"); let msg = `Updated ${data.updated} field(s).`;
if (data.errors && data.errors.length) {
msg += "\n\nSome entries were skipped:\n" + data.errors.join("\n");
}
alert(msg);
location.reload(); location.reload();
} else { } else {
alert("Delete failed: " + (data.message || "Unknown error")); alert("Update failed: " + (data.message || "Unknown error"));
} }
}) })
.catch(err => { .catch(err => alert("Update request failed: " + err));
alert("Delete request failed: " + err);
});
} }
$(document).on('click', '.bulk-edit-toggle-btn', function () {
let model = $(this).data('model');
if (!bulkEditActiveModels[model]) {
enterBulkEditMode(model);
} else {
saveBulkChanges(model);
}
});
$(document).on('click', '.bulk-edit-cancel-btn', function () {
let model = $(this).data('model');
exitBulkEditMode(model, { revert: true });
});
// SINGLE DELETE // SINGLE DELETE
$(document).on("click", ".delete-btn", function () { $(document).on("click", ".delete-btn", function () {
let id = $(this).data("id"); let id = $(this).data("id");
@@ -369,6 +584,46 @@
}); });
}); });
});
// GET IDS - scoped to a single table via data-model, so "Delete
// Selected" on one tab never picks up checked rows from another tab.
// (kept global - called from deleteSelected below)
function getSelectedIds(model) {
let ids = [];
$(`.row-check[data-model="${model}"]:checked`).each(function () {
ids.push($(this).data("id"));
});
return ids;
}
// BULK DELETE
// Exposed on window because it's invoked from inline onclick="" attributes
// in the markup above, which always resolve names in the global scope.
window.deleteSelected = function (model) {
let ids = getSelectedIds(model);
if (ids.length === 0) return alert("Select records");
if (!confirm(`Delete ${ids.length} record(s)?`)) return;
fetch("/file/delete_records", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ model: model, ids: ids })
})
.then(res => res.json().then(data => ({ ok: res.ok, data })))
.then(({ ok, data }) => {
if (ok && data.status === "success") {
alert("Deleted Successfully");
location.reload();
} else {
alert("Delete failed: " + (data.message || "Unknown error"));
}
})
.catch(err => {
alert("Delete request failed: " + err);
});
}
</script> </script>

View File

@@ -1,124 +0,0 @@
2026-08-06 12:44:45 | INFO | User=System | IP=- | - | - | ======================================================================
2026-08-06 12:44:45 | INFO | User=System | IP=- | - | - | Application Started Successfully
2026-08-06 12:44:45 | INFO | User=System | IP=- | - | - | ======================================================================
<<<<<<< HEAD
=======
2026-08-07 11:46:57 | INFO | User=System | IP=- | - | - | ======================================================================
2026-08-07 11:46:57 | INFO | User=System | IP=- | - | - | Application Started Successfully
2026-08-07 11:46:57 | INFO | User=System | IP=- | - | - | ======================================================================
2026-08-07 11:47:12 | INFO | User=System | IP=- | - | - | ======================================================================
2026-08-07 11:47:12 | INFO | User=System | IP=- | - | - | Application Started Successfully
2026-08-07 11:47:12 | INFO | User=System | IP=- | - | - | ======================================================================
2026-08-07 11:47:14 | INFO | User=System | IP=- | - | - | ======================================================================
2026-08-07 11:47:14 | INFO | User=System | IP=- | - | - | Application Started Successfully
2026-08-07 11:47:14 | INFO | User=System | IP=- | - | - | ======================================================================
2026-08-07 11:47:18 | INFO | User=Laxmi | IP=192.168.0.142 | POST | http://192.168.0.142:5015/file/Subcontractor_report | Request Started
2026-08-07 11:47:18 | INFO | User=Laxmi | IP=192.168.0.142 | POST | http://192.168.0.142:5015/file/Subcontractor_report | Request Completed | Status=200
2026-08-07 11:47:19 | INFO | User=Laxmi | IP=192.168.0.142 | GET | http://192.168.0.142:5015/static/images/lcepl.png | Request Started
2026-08-07 11:47:19 | INFO | User=Laxmi | IP=192.168.0.142 | GET | http://192.168.0.142:5015/static/images/lcepl.png | Request Completed | Status=200
2026-08-07 11:47:22 | INFO | User=Laxmi | IP=192.168.0.142 | GET | http://192.168.0.142:5015/logout | Request Started
2026-08-07 11:47:22 | INFO | User=Anonymous | IP=192.168.0.142 | GET | http://192.168.0.142:5015/logout | Logout successful. User=Laxmi
2026-08-07 11:47:22 | INFO | User=Anonymous | IP=192.168.0.142 | GET | http://192.168.0.142:5015/logout | Request Completed | Status=302
2026-08-07 11:47:22 | INFO | User=Anonymous | IP=192.168.0.142 | GET | http://192.168.0.142:5015/login | Request Started
2026-08-07 11:47:22 | INFO | User=Anonymous | IP=192.168.0.142 | GET | http://192.168.0.142:5015/login | Request Completed | Status=200
2026-08-07 11:47:22 | INFO | User=Anonymous | IP=192.168.0.142 | GET | http://192.168.0.142:5015/static/images/lcepl.png | Request Started
2026-08-07 11:47:22 | INFO | User=Anonymous | IP=192.168.0.142 | GET | http://192.168.0.142:5015/static/images/lcepl.png | Request Completed | Status=304
2026-08-07 11:47:30 | INFO | User=Anonymous | IP=192.168.0.142 | POST | http://192.168.0.142:5015/login | Request Started
2026-08-07 11:47:30 | INFO | User=Laxmi | IP=192.168.0.142 | POST | http://192.168.0.142:5015/login | Login successful. User=Laxmi
2026-08-07 11:47:30 | INFO | User=Laxmi | IP=192.168.0.142 | POST | http://192.168.0.142:5015/login | Request Completed | Status=302
2026-08-07 11:47:30 | INFO | User=Laxmi | IP=192.168.0.142 | GET | http://192.168.0.142:5015/dashboard/ | Request Started
2026-08-07 11:47:30 | INFO | User=Laxmi | IP=192.168.0.142 | GET | http://192.168.0.142:5015/dashboard/ | Request Completed | Status=200
2026-08-07 11:47:30 | INFO | User=Laxmi | IP=192.168.0.142 | GET | http://192.168.0.142:5015/dashboard/api/live-stats | Request Started
2026-08-07 11:47:30 | INFO | User=Laxmi | IP=192.168.0.142 | GET | http://192.168.0.142:5015/dashboard/api/live-stats | Request Completed | Status=200
2026-08-07 11:47:35 | INFO | User=Laxmi | IP=192.168.0.142 | GET | http://192.168.0.142:5015/file/Subcontractor_report | Request Started
2026-08-07 11:47:35 | INFO | User=Laxmi | IP=192.168.0.142 | GET | http://192.168.0.142:5015/file/Subcontractor_report | Request Completed | Status=200
2026-08-07 11:47:40 | INFO | User=Laxmi | IP=192.168.0.142 | POST | http://192.168.0.142:5015/file/Subcontractor_report | Request Started
2026-08-07 11:47:40 | INFO | User=Laxmi | IP=192.168.0.142 | POST | http://192.168.0.142:5015/file/Subcontractor_report | Request Completed | Status=200
2026-08-07 11:47:41 | INFO | User=Laxmi | IP=192.168.0.142 | POST | http://192.168.0.142:5015/file/Subcontractor_report | Request Started
2026-08-07 11:47:42 | INFO | User=Laxmi | IP=192.168.0.142 | POST | http://192.168.0.142:5015/file/Subcontractor_report | Request Completed | Status=200
2026-08-07 11:47:44 | INFO | User=Laxmi | IP=192.168.0.142 | POST | http://192.168.0.142:5015/file/Subcontractor_report | Request Started
2026-08-07 11:47:44 | INFO | User=Laxmi | IP=192.168.0.142 | POST | http://192.168.0.142:5015/file/Subcontractor_report | Request Completed | Status=200
2026-08-07 11:47:46 | INFO | User=Laxmi | IP=192.168.0.142 | POST | http://192.168.0.142:5015/file/Subcontractor_report | Request Started
2026-08-07 11:47:46 | INFO | User=Laxmi | IP=192.168.0.142 | POST | http://192.168.0.142:5015/file/Subcontractor_report | Request Completed | Status=200
2026-08-07 11:47:49 | INFO | User=Laxmi | IP=192.168.0.142 | GET | http://192.168.0.142:5015/file/Subcontractor_report | Request Started
2026-08-07 11:47:49 | INFO | User=Laxmi | IP=192.168.0.142 | GET | http://192.168.0.142:5015/file/Subcontractor_report | Request Completed | Status=200
2026-08-07 11:47:54 | INFO | User=Laxmi | IP=192.168.0.142 | POST | http://192.168.0.142:5015/file/Subcontractor_report | Request Started
2026-08-07 11:47:54 | INFO | User=Laxmi | IP=192.168.0.142 | POST | http://192.168.0.142:5015/file/Subcontractor_report | Request Completed | Status=200
2026-08-07 11:47:57 | INFO | User=Laxmi | IP=192.168.0.142 | POST | http://192.168.0.142:5015/file/Subcontractor_report | Request Started
2026-08-07 11:47:57 | INFO | User=Laxmi | IP=192.168.0.142 | POST | http://192.168.0.142:5015/file/Subcontractor_report | Request Completed | Status=200
2026-08-07 11:48:07 | INFO | User=Laxmi | IP=192.168.0.142 | POST | http://192.168.0.142:5015/file/Subcontractor_report | Request Started
2026-08-07 11:48:07 | INFO | User=Laxmi | IP=192.168.0.142 | POST | http://192.168.0.142:5015/file/Subcontractor_report | Request Completed | Status=200
2026-08-07 11:48:11 | INFO | User=Laxmi | IP=192.168.0.142 | POST | http://192.168.0.142:5015/file/Subcontractor_report | Request Started
2026-08-07 11:48:11 | INFO | User=Laxmi | IP=192.168.0.142 | POST | http://192.168.0.142:5015/file/Subcontractor_report | Request Completed | Status=200
2026-08-07 12:02:57 | INFO | User=System | IP=- | - | - | ======================================================================
2026-08-07 12:02:57 | INFO | User=System | IP=- | - | - | Application Started Successfully
2026-08-07 12:02:57 | INFO | User=System | IP=- | - | - | ======================================================================
2026-08-07 12:03:04 | INFO | User=System | IP=- | - | - | ======================================================================
2026-08-07 12:03:04 | INFO | User=System | IP=- | - | - | Application Started Successfully
2026-08-07 12:03:04 | INFO | User=System | IP=- | - | - | ======================================================================
2026-08-07 12:04:23 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/ | Request Started
2026-08-07 12:04:23 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/ | Request Completed | Status=302
2026-08-07 12:04:23 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/login | Request Started
2026-08-07 12:04:23 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/login | User already logged in.
2026-08-07 12:04:23 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/login | Request Completed | Status=302
2026-08-07 12:04:23 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/dashboard/ | Request Started
2026-08-07 12:04:23 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/dashboard/ | Request Completed | Status=200
2026-08-07 12:04:23 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/dashboard/api/live-stats | Request Started
2026-08-07 12:04:23 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/dashboard/api/live-stats | Request Completed | Status=200
2026-08-07 12:04:33 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/dashboard/api/live-stats | Request Started
2026-08-07 12:04:33 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/dashboard/api/live-stats | Request Completed | Status=200
2026-08-07 12:04:37 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/engi/client-rate | Request Started
2026-08-07 12:04:37 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/engi/client-rate | Request Completed | Status=200
2026-08-07 12:04:39 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/file_format | Request Started
2026-08-07 12:04:39 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/file_format | Request Completed | Status=200
2026-08-07 12:04:40 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/file_format | Request Started
2026-08-07 12:04:40 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/file_format | Request Completed | Status=200
2026-08-07 12:04:41 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/file_format | Request Started
2026-08-07 12:04:41 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/file_format | Request Completed | Status=200
2026-08-07 12:04:42 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/file_format | Request Started
2026-08-07 12:04:42 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/file_format | Request Completed | Status=200
2026-08-07 12:04:42 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/file_format | Request Started
2026-08-07 12:04:42 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/file_format | Request Completed | Status=200
2026-08-07 12:04:44 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/file/import_client | Request Started
2026-08-07 12:04:44 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/file/import_client | Request Completed | Status=200
2026-08-07 12:04:46 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/file/Subcontractor_report | Request Started
2026-08-07 12:04:46 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/file/Subcontractor_report | Request Completed | Status=200
2026-08-07 12:04:49 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/file/Subcontractor_report | Request Started
2026-08-07 12:04:49 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/file/Subcontractor_report | Request Completed | Status=200
2026-08-07 12:04:52 | INFO | User=Admin | IP=192.168.0.118 | POST | http://192.168.0.118:5015/file/Subcontractor_report | Request Started
2026-08-07 12:04:52 | INFO | User=Admin | IP=192.168.0.118 | POST | http://192.168.0.118:5015/file/Subcontractor_report | Request Completed | Status=200
2026-08-07 12:04:54 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/file/Subcontractor_report | Request Started
2026-08-07 12:04:54 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/file/Subcontractor_report | Request Completed | Status=200
2026-08-07 12:05:01 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/dashboard/ | Request Started
2026-08-07 12:05:01 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/dashboard/ | Request Completed | Status=200
2026-08-07 12:05:01 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/dashboard/api/live-stats | Request Started
2026-08-07 12:05:01 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/dashboard/api/live-stats | Request Completed | Status=200
2026-08-07 12:05:02 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/activity/ | Request Started
2026-08-07 12:05:02 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/activity/ | Request Completed | Status=200
2026-08-07 12:07:06 | INFO | User=System | IP=- | - | - | ======================================================================
2026-08-07 12:07:06 | INFO | User=System | IP=- | - | - | Application Started Successfully
2026-08-07 12:07:06 | INFO | User=System | IP=- | - | - | ======================================================================
2026-08-07 12:07:07 | INFO | User=System | IP=- | - | - | ======================================================================
2026-08-07 12:07:07 | INFO | User=System | IP=- | - | - | Application Started Successfully
2026-08-07 12:07:07 | INFO | User=System | IP=- | - | - | ======================================================================
2026-08-07 12:07:09 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/activity/ | Request Started
2026-08-07 12:07:09 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/activity/ | Request Completed | Status=200
2026-08-07 12:07:10 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/engi/subcontractor-rate | Request Started
2026-08-07 12:07:11 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/engi/subcontractor-rate | Request Completed | Status=200
2026-08-07 12:07:11 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/static/images/lcepl.png | Request Started
2026-08-07 12:07:11 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/static/images/lcepl.png | Request Completed | Status=304
2026-08-07 12:07:14 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/engi/client-rate | Request Started
2026-08-07 12:07:14 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/engi/client-rate | Request Completed | Status=200
2026-08-07 12:07:16 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/file_format | Request Started
2026-08-07 12:07:16 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/file_format | Request Completed | Status=200
2026-08-07 12:07:16 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/engi/subcontractor-rate | Request Started
2026-08-07 12:07:16 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/engi/subcontractor-rate | Request Completed | Status=200
2026-08-07 12:07:18 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/engi/subcontractor-rate | Request Started
2026-08-07 12:07:18 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/engi/subcontractor-rate | Request Completed | Status=200
2026-08-07 12:07:23 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/dashboard/ | Request Started
2026-08-07 12:07:23 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/dashboard/ | Request Completed | Status=200
2026-08-07 12:07:23 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/dashboard/api/live-stats | Request Started
2026-08-07 12:07:23 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/dashboard/api/live-stats | Request Completed | Status=200
2026-08-07 12:07:24 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/engi/subcontractor-rate | Request Started
2026-08-07 12:07:24 | INFO | User=Admin | IP=192.168.0.118 | GET | http://192.168.0.118:5015/engi/subcontractor-rate | Request Completed | Status=200
>>>>>>> pankaj-dev