Compare commits

...

2 Commits

4 changed files with 64 additions and 2 deletions

View File

@@ -66,3 +66,17 @@ def dashboard():
pie_chart=pie_chart(), pie_chart=pie_chart(),
histogram=histogram_chart() histogram=histogram_chart()
) )
# subcontractor dashboard
@dashboard_bp.route("/subcontractor_dashboard")
def subcontractor_dashboard():
if not session.get("user_id"):
return redirect(url_for("auth.login"))
return render_template(
"subcontractor_dashboard.html",
title="Dashboard",
bar_chart=bar_chart(),
pie_chart=pie_chart(),
histogram=histogram_chart()
)

View File

@@ -4,11 +4,15 @@ import io
from app.models.subcontractor_model import Subcontractor from app.models.subcontractor_model import Subcontractor
from app.models.trench_excavation_model import TrenchExcavation from app.models.trench_excavation_model import TrenchExcavation
from app.models.tr_ex_client_model import TrenchExcavationClient
from app.models.manhole_excavation_model import ManholeExcavation from app.models.manhole_excavation_model import ManholeExcavation
from app.models.mh_ex_client_model import ManholeExcavationClient
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.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.mh_dc_client_model import ManholeDomesticChamberClient
from app.models.laying_client_model import LayingClient
from app.utils.helpers import login_required from app.utils.helpers import login_required
generate_report_bp = Blueprint("generate_report", __name__, url_prefix="/report") generate_report_bp = Blueprint("generate_report", __name__, url_prefix="/report")
@@ -191,6 +195,13 @@ def comparison_report():
).all()] ).all()]
df_dc = build_comparison(dc_client, dc_sub, "MH_NO") df_dc = build_comparison(dc_client, dc_sub, "MH_NO")
lay_client = [r.serialize() for r in LayingClient.query.all()]
lay_sub = [r.serialize() for r in Laying.query.filter_by(
subcontractor_id=subcontractor_id
).all()]
df_lay = build_comparison(lay_client, lay_sub, "MH_NO")
# -------- EXCEL -------- # -------- EXCEL --------
output = io.BytesIO() output = io.BytesIO()
filename = f"{subcontractor.subcontractor_name}_Comparison_Report.xlsx" filename = f"{subcontractor.subcontractor_name}_Comparison_Report.xlsx"
@@ -199,6 +210,7 @@ def comparison_report():
write_sheet(writer, df_tr, "Tr.Ex", subcontractor.subcontractor_name) write_sheet(writer, df_tr, "Tr.Ex", subcontractor.subcontractor_name)
write_sheet(writer, df_mh, "Mh.Ex", subcontractor.subcontractor_name) write_sheet(writer, df_mh, "Mh.Ex", subcontractor.subcontractor_name)
write_sheet(writer, df_dc, "MH & DC", subcontractor.subcontractor_name) write_sheet(writer, df_dc, "MH & DC", subcontractor.subcontractor_name)
write_sheet(writer, df_lay, "Laying", subcontractor.subcontractor_name)
output.seek(0) output.seek(0)
return send_file( return send_file(

View File

@@ -77,6 +77,13 @@
<i class="bi bi-download me-2"></i> Show Reports <i class="bi bi-download me-2"></i> Show Reports
</a> </a>
</li> </li>
<li>
<a class="dropdown-item" href="/dashboard/subcontractor_dashboard">
<i class="bi bi-speedometer2 me-2"></i> Subcontractor Dashboard
</a>
</li>
</ul> </ul>
</li> </li>

View File

@@ -0,0 +1,29 @@
{% extends "base.html" %}
{% block content %}
<div class="container-fluid px-2 px-md-4">
<h4 class="mb-3 text-center text-md-start">Subcontractor Dashboard </h4>
<!-- Charts -->
<div class="row g-3">
<!-- Bar Chart -->
<div class="col-12 col-md-6">
<div class="card shadow-sm h-100">
<div class="card-header bg-dark text-white text-center text-md-start">
Work Category Bar Chart
</div>
<div class="card-body text-center">
<img src="data:image/png;base64,{{ bar_chart }}" class="img-fluid" style="max-height:300px;">
</div>
</div>
</div>
</div>
</div>
{% endblock %}