renames of report html files

This commit is contained in:
2026-01-17 14:01:15 +05:30
parent dd4b494435
commit a07c1ddf8a
8 changed files with 21 additions and 21 deletions

View File

@@ -5,7 +5,8 @@ from app.utils.helpers import login_required
file_import_bp = Blueprint("file_import", __name__, url_prefix="/file")
@file_import_bp.route("/import", methods=["GET", "POST"])
# this is contractractor immport routes
@file_import_bp.route("/import_Subcontractor", methods=["GET", "POST"])
@login_required
def import_file():
subcontractors = Subcontractor.query.all()
@@ -21,13 +22,13 @@ def import_file():
flash(msg, "success" if success else "danger")
return render_template(
"file_import.html",
"file_import_subcontractor.html",
title="Sub-cont. File Import",
subcontractors=subcontractors
)
# this route import client files
# this is client import routes
@file_import_bp.route("/import_client", methods=["GET", "POST"])
@login_required
def client_import_file():

View File

@@ -74,7 +74,7 @@ class SubcontractorBill:
df.drop(columns=drop_cols, errors="ignore", inplace=True)
# --- subcontractor report only ---
@file_report_bp.route("/report", methods=["GET", "POST"])
@file_report_bp.route("/Subcontractor_report", methods=["GET", "POST"])
@login_required
def report_file():
subcontractors = Subcontractor.query.all()
@@ -122,7 +122,6 @@ def report_file():
return send_file(output, download_name=file_name, as_attachment=True)
# We add bootstrap classes directly to the pandas output
# table_classes = "table table-hover table-bordered table-striped"
table_classes = "table table-bordered table-striped table-hover table-sm mb-0"
tables = {
"tr": bill_gen.df_tr.to_html(classes=table_classes, index=False),
@@ -133,7 +132,7 @@ def report_file():
selected_sc_id = subcontractor_id
return render_template(
"report.html",
"subcontractor_report.html",
subcontractors=subcontractors,
tables=tables,
selected_sc_id=selected_sc_id,
@@ -141,8 +140,8 @@ def report_file():
download_all=download_all
)
# --- client comparison ---
@file_report_bp.route("/client_vs_subcont", methods=["GET", "POST"])
# --- client report only ---
@file_report_bp.route("/client_report", methods=["GET", "POST"])
@login_required
def client_vs_all_subcontractor():
tables = {"tr": None, "mh": None, "dc": None}
@@ -183,7 +182,7 @@ def client_vs_all_subcontractor():
# Aggregate data
df_sub_tr_grp = aggregate_df(contractorBill.df_tr, ["Location", "MH_NO"], qty_cols)
df_sub_mh_grp = aggregate_df(contractorBill.df_mh, ["Location", "MH_NO"], qty_cols)
df_sub_dc_grp = aggregate_df(contractorBill.df_dc, ["Location", "Node_No"], mh_dc_qty_cols)
df_sub_dc_grp = aggregate_df(contractorBill.df_dc, ["Location", "MH_NO"], mh_dc_qty_cols)
# --- FINAL MERGE LOGIC ---
# We check if "Location" exists in the client data. If not, we add it to prevent the KeyError.
@@ -194,17 +193,17 @@ def client_vs_all_subcontractor():
try:
df_tr_cmp = clientBill.df_tr.merge(df_sub_tr_grp, on=["Location", "MH_NO"], how="left", suffixes=("_Client", "_Sub"))
df_mh_cmp = clientBill.df_mh.merge(df_sub_mh_grp, on=["Location", "MH_NO"], how="left", suffixes=("_Client", "_Sub"))
df_dc_cmp = clientBill.df_dc.merge(df_sub_dc_grp, on=["Location", "Node_No"], how="left", suffixes=("_Client", "_Sub"))
df_dc_cmp = clientBill.df_dc.merge(df_sub_dc_grp, on=["Location", "MH_NO"], how="left", suffixes=("_Client", "_Sub"))
except KeyError as e:
flash(f"Merge Error: Missing column {str(e)}. Check if 'Location' is defined in your database models.", "danger")
return render_template("generate_comparison_client_vs_subcont.html", tables=tables, ra_val=ra_val)
# ... (Rest of your calculation and download logic) ...
# Convert to HTML for preview
tables["tr"] = df_tr_cmp.to_html(classes='table table-striped table-hover table-sm', index=False)
tables["mh"] = df_mh_cmp.to_html(classes='table table-striped table-hover table-sm', index=False)
tables["dc"] = df_dc_cmp.to_html(classes='table table-striped table-hover table-sm', index=False)
return render_template("generate_comparison_client_vs_subcont.html", tables=tables, ra_val=ra_val)
return render_template("client_report.html", tables=tables, ra_val=ra_val)

View File

@@ -68,12 +68,12 @@
</a>
<ul class="dropdown-menu dropdown-menu-dark">
<li>
<a class="dropdown-item" href="/file/import">
<a class="dropdown-item" href="/file/import_Subcontractor">
<i class="bi bi-upload me-2"></i> Import File
</a>
</li>
<li>
<a class="dropdown-item" href="/file/report">
<a class="dropdown-item" href="/file/Subcontractor_report">
<i class="bi bi-download me-2"></i> Show Reports
</a>
</li>
@@ -93,7 +93,7 @@
</li>
<li>
<a class="dropdown-item" href="/file/client_vs_subcont">
<a class="dropdown-item" href="/file/client_report">
<i class="bi bi-arrow-left-right me-2"></i> Show Report
</a>
</li>

View File

@@ -13,8 +13,8 @@
<div class="col-12 col-md-4">
<div class="card text-white bg-primary shadow h-100">
<div class="card-body text-center text-md-start">
<h6>Total Work</h6>
<h3 class="fw-bold">410</h3>
<h6>Test Total Work</h6>
<h3 class="fw-bold">30%</h3>
</div>
</div>
</div>
@@ -23,8 +23,8 @@
<div class="col-12 col-md-4">
<div class="card text-white bg-success shadow h-100">
<div class="card-body text-center text-md-start">
<h6>Completed</h6>
<h3 class="fw-bold">265</h3>
<h6>test Completed</h6>
<h3 class="fw-bold">35%</h3>
</div>
</div>
</div>
@@ -34,7 +34,7 @@
<div class="card text-dark bg-warning shadow h-100">
<div class="card-body text-center text-md-start">
<h6>Pending</h6>
<h3 class="fw-bold">145</h3>
<h3 class="fw-bold">35%</h3>
</div>
</div>
</div>