suctr location filter, MH NO. search, subctr manadatory field removed, added select all for delete and also all edit at once feature added
This commit is contained in:
@@ -477,6 +477,30 @@ def report_file():
|
||||
else:
|
||||
bill.Fetch(ra_bill_no, subcontractor_id, location, mh_no)
|
||||
|
||||
|
||||
# ---------------------------------------------------------
|
||||
if (
|
||||
bill.df_tr.empty and
|
||||
bill.df_mh.empty and
|
||||
bill.df_dc.empty and
|
||||
bill.df_laying.empty
|
||||
):
|
||||
flash(
|
||||
f"No records found for RA Bill No '{ra_bill_no}'. "
|
||||
"Please check the RA Bill No and try again."
|
||||
if ra_bill_no else
|
||||
"No records found for the selected filters.",
|
||||
"warning"
|
||||
)
|
||||
return render_template(
|
||||
"subcontractor_report.html",
|
||||
subcontractors=subcontractors,
|
||||
selected_sc_id=selected_sc_id,
|
||||
selected_ra_bill=ra_bill_no,
|
||||
selected_location=location,
|
||||
selected_category=category
|
||||
)
|
||||
|
||||
# -----------------------------------------
|
||||
# Generate Abstract Report for Web
|
||||
# -----------------------------------------
|
||||
@@ -497,6 +521,32 @@ def report_file():
|
||||
bill.df_tr = bill.df_mh = bill.df_dc = pd.DataFrame()
|
||||
|
||||
|
||||
if (
|
||||
category in ("tr", "mh", "dc", "laying")
|
||||
and bill.df_tr.empty and bill.df_mh.empty
|
||||
and bill.df_dc.empty and bill.df_laying.empty
|
||||
):
|
||||
category_labels = {
|
||||
"tr": "Trench Excavation",
|
||||
"mh": "Manhole Excavation",
|
||||
"dc": "Domestic Chamber",
|
||||
"laying": "Pipe Laying",
|
||||
}
|
||||
flash(
|
||||
f"No {category_labels[category]} records found for the "
|
||||
"selected filters.",
|
||||
"warning"
|
||||
)
|
||||
return render_template(
|
||||
"subcontractor_report.html",
|
||||
subcontractors=subcontractors,
|
||||
selected_sc_id=selected_sc_id,
|
||||
selected_ra_bill=ra_bill_no,
|
||||
selected_location=location,
|
||||
selected_category=category
|
||||
)
|
||||
|
||||
|
||||
# ===================================================
|
||||
# DOWNLOAD EXCEL
|
||||
# ===================================================
|
||||
@@ -508,16 +558,46 @@ def report_file():
|
||||
abstract = AbstractReportService(subcontractor_id=subcontractor_id,ra_bill_no=ra_bill_no)
|
||||
abstract.generate(workbook)
|
||||
|
||||
bill.df_tr.to_excel(writer,sheet_name="Tr.Ex",index=False)
|
||||
bill.df_mh.to_excel(writer,sheet_name="Mh.Ex",index=False)
|
||||
bill.df_dc.to_excel(writer,sheet_name="MH & DC",index=False)
|
||||
bill.df_laying.to_excel(writer,sheet_name="Pipe Laying",index=False)
|
||||
|
||||
sheet_map = [
|
||||
(bill.df_tr, "Tr.Ex"),
|
||||
(bill.df_mh, "Mh.Ex"),
|
||||
(bill.df_dc, "MH & DC"),
|
||||
(bill.df_laying, "Pipe Laying"),
|
||||
]
|
||||
for df, sheet_name in sheet_map:
|
||||
if not df.empty:
|
||||
df.to_excel(writer, sheet_name=sheet_name, index=False)
|
||||
writer.close()
|
||||
output.seek(0)
|
||||
|
||||
|
||||
sc_obj = next(
|
||||
(s for s in subcontractors if str(s.id) == str(subcontractor_id)),
|
||||
None
|
||||
)
|
||||
sc_name = sc_obj.subcontractor_name if sc_obj else "Subcontractor"
|
||||
sc_name = re.sub(r'[^A-Za-z0-9_-]+', '_', sc_name).strip('_')
|
||||
|
||||
name_parts = [sc_name]
|
||||
|
||||
if ra_bill_no:
|
||||
name_parts.append(f"RA{re.sub(r'[^A-Za-z0-9_-]+', '_', ra_bill_no)}")
|
||||
|
||||
if location:
|
||||
name_parts.append(re.sub(r'[^A-Za-z0-9_-]+', '_', location).strip('_'))
|
||||
|
||||
if category and category != "all":
|
||||
name_parts.append(category.upper())
|
||||
|
||||
if action == "excel_all":
|
||||
name_parts.append("All")
|
||||
|
||||
filename = "_".join(name_parts) + "_Report.xlsx"
|
||||
|
||||
return send_file(
|
||||
output,
|
||||
download_name= "subcontractor_Report.xlsx",
|
||||
download_name=filename,
|
||||
as_attachment=True
|
||||
)
|
||||
|
||||
|
||||
@@ -168,51 +168,61 @@
|
||||
</div>
|
||||
|
||||
{% if tables %}
|
||||
{% set show_all = (not selected_category) or selected_category == 'all' %}
|
||||
<!-- 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 active" data-bs-toggle="tab" data-bs-target="#abstract">
|
||||
<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>
|
||||
|
||||
{% if show_all or selected_category == 'tr' %}
|
||||
<li class="nav-item">
|
||||
<button class="nav-link " data-bs-toggle="tab" data-bs-target="#tr">
|
||||
<button class="nav-link {% if selected_category == 'tr' %}active{% endif %}" data-bs-toggle="tab" data-bs-target="#tr">
|
||||
<i class="bi bi-cone-striped"></i> Trench Excavation
|
||||
</button>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if show_all or selected_category == 'mh' %}
|
||||
<li class="nav-item">
|
||||
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#mh">
|
||||
<button class="nav-link {% if selected_category == 'mh' %}active{% endif %}" data-bs-toggle="tab" data-bs-target="#mh">
|
||||
<i class="bi bi-nut"></i> Manhole Excavation
|
||||
</button>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if show_all or selected_category == 'dc' %}
|
||||
<li class="nav-item">
|
||||
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#dc">
|
||||
<button class="nav-link {% if selected_category == 'dc' %}active{% endif %}" data-bs-toggle="tab" data-bs-target="#dc">
|
||||
<i class="bi bi-grid-3x3"></i> Manhole & Domestic Chambers Construction
|
||||
</button>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if show_all or selected_category == 'laying' %}
|
||||
<li class="nav-item">
|
||||
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#laying">
|
||||
<button class="nav-link {% if selected_category == 'laying' %}active{% endif %}" data-bs-toggle="tab" data-bs-target="#laying">
|
||||
<i class="bi bi-bezier2"></i> Pipe Laying
|
||||
</button>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="tab-content">
|
||||
|
||||
<div class="tab-pane fade show active" id="abstract">
|
||||
<div class="tab-pane fade {% if show_all %}show active{% endif %}" id="abstract">
|
||||
{{ abstract_html|safe }}
|
||||
</div>
|
||||
|
||||
{% if show_all or selected_category == 'tr' %}
|
||||
<!-- Trench -->
|
||||
<div class="tab-pane fade "id="tr">
|
||||
<div class="tab-pane fade {% if selected_category == 'tr' %}show active{% endif %}" id="tr">
|
||||
{% if has_data.tr %}
|
||||
<div class="mb-3 d-flex gap-2 flex-wrap">
|
||||
<button onclick="deleteSelected('tr')" class="btn btn-danger">
|
||||
@@ -230,9 +240,11 @@
|
||||
{{ tables.tr|safe }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if show_all or selected_category == 'mh' %}
|
||||
<!-- MH -->
|
||||
<div class="tab-pane fade" id="mh">
|
||||
<div class="tab-pane fade {% if selected_category == 'mh' %}show active{% endif %}" id="mh">
|
||||
{% if has_data.mh %}
|
||||
<div class="mb-3 d-flex gap-2 flex-wrap">
|
||||
<button onclick="deleteSelected('mh')" class="btn btn-danger">
|
||||
@@ -250,9 +262,11 @@
|
||||
{{ tables.mh|safe }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if show_all or selected_category == 'dc' %}
|
||||
<!-- DC -->
|
||||
<div class="tab-pane fade" id="dc">
|
||||
<div class="tab-pane fade {% if selected_category == 'dc' %}show active{% endif %}" id="dc">
|
||||
{% if has_data.dc %}
|
||||
<div class="mb-3 d-flex gap-2 flex-wrap">
|
||||
<button onclick="deleteSelected('dc')"class="btn btn-danger">
|
||||
@@ -271,9 +285,11 @@
|
||||
{{ tables.dc|safe }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if show_all or selected_category == 'laying' %}
|
||||
<!-- Laying -->
|
||||
<div class="tab-pane fade" id="laying">
|
||||
<div class="tab-pane fade {% if selected_category == 'laying' %}show active{% endif %}" id="laying">
|
||||
{% if has_data.laying %}
|
||||
<div class="mb-3 d-flex gap-2 flex-wrap">
|
||||
<button onclick="deleteSelected('laying')"
|
||||
@@ -293,6 +309,7 @@
|
||||
{{ tables.laying|safe }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -382,7 +399,7 @@
|
||||
});
|
||||
|
||||
// SELECT ALL (per table)
|
||||
// The header checkbox is now rendered server-side with
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user