static Menubar apply boostrap css
This commit is contained in:
@@ -1,42 +1,49 @@
|
||||
import pandas as pd
|
||||
import io
|
||||
from flask import Blueprint, render_template, request, send_file, flash
|
||||
from app.utils.helpers import login_required
|
||||
|
||||
from app.models.subcontractor_model import Subcontractor
|
||||
|
||||
from app.models.manhole_excavation_model import ManholeExcavation
|
||||
from app.models.trench_excavation_model import TrenchExcavation
|
||||
from app.models.manhole_domestic_chamber_model import ManholeDomesticChamber
|
||||
from app.models.laying_model import Laying
|
||||
|
||||
from app.models.mh_ex_client_model import ManholeExcavationClient
|
||||
from app.models.tr_ex_client_model import TrenchExcavationClient
|
||||
from app.models.mh_dc_client_model import ManholeDomesticChamberClient
|
||||
from app.utils.helpers import login_required
|
||||
from app.models.laying_client_model import LayingClient
|
||||
|
||||
|
||||
# --- BLUEPRINT DEFINITION ---
|
||||
file_report_bp = Blueprint("file_report", __name__, url_prefix="/file")
|
||||
|
||||
# --- DATA WRAPPERS ---
|
||||
# --- Client class ---
|
||||
class ClientBill:
|
||||
def __init__(self):
|
||||
self.df_tr = pd.DataFrame()
|
||||
self.df_mh = pd.DataFrame()
|
||||
self.df_dc = pd.DataFrame()
|
||||
self.df_laying = pd.DataFrame()
|
||||
|
||||
def Fetch(self, RA_Bill_No):
|
||||
trench = TrenchExcavationClient.query.filter_by(RA_Bill_No=RA_Bill_No).all()
|
||||
mh = ManholeExcavationClient.query.filter_by(RA_Bill_No=RA_Bill_No).all()
|
||||
dc = ManholeDomesticChamberClient.query.filter_by(RA_Bill_No=RA_Bill_No).all()
|
||||
lay = LayingClient.query.filter_by(RA_Bill_No=RA_Bill_No).all()
|
||||
|
||||
self.df_tr = pd.DataFrame([c.serialize() for c in trench])
|
||||
self.df_mh = pd.DataFrame([c.serialize() for c in mh])
|
||||
self.df_dc = pd.DataFrame([c.serialize() for c in dc])
|
||||
|
||||
if not self.df_dc.empty and "MH_NO" in self.df_dc.columns:
|
||||
self.df_dc.rename(columns={"MH_NO": "Node_No"}, inplace=True)
|
||||
|
||||
self.df_laying = pd.DataFrame([c.serialize() for c in lay])
|
||||
|
||||
drop_cols = ["id", "created_at", "_sa_instance_state"]
|
||||
for df in [self.df_tr, self.df_mh, self.df_dc]:
|
||||
for df in [self.df_tr, self.df_mh, self.df_dc, self.df_laying]:
|
||||
if not df.empty:
|
||||
df.drop(columns=drop_cols, errors="ignore", inplace=True)
|
||||
|
||||
# --- Subcontractor class ---
|
||||
class SubcontractorBill:
|
||||
def __init__(self):
|
||||
self.df_tr = pd.DataFrame()
|
||||
@@ -54,22 +61,19 @@ class SubcontractorBill:
|
||||
trench = TrenchExcavation.query.filter_by(**filters).all()
|
||||
mh = ManholeExcavation.query.filter_by(**filters).all()
|
||||
dc = ManholeDomesticChamber.query.filter_by(**filters).all()
|
||||
lay = ManholeDomesticChamber.query.filter_by(**filters).all()
|
||||
lay = Laying.query.filter_by(**filters).all()
|
||||
|
||||
self.df_tr = pd.DataFrame([c.serialize() for c in trench])
|
||||
self.df_mh = pd.DataFrame([c.serialize() for c in mh])
|
||||
self.df_dc = pd.DataFrame([c.serialize() for c in dc])
|
||||
self.df_laying = pd.DataFrame([c.serialize() for c in lay])
|
||||
|
||||
# if not self.df_dc.empty and "MH_NO" in self.df_dc.columns:
|
||||
# self.df_dc.rename(columns={"MH_NO": "Node_No"}, inplace=True)
|
||||
|
||||
|
||||
drop_cols = ["id", "created_at", "_sa_instance_state"]
|
||||
for df in [self.df_tr, self.df_mh, self.df_dc, self.df_laying]:
|
||||
if not df.empty:
|
||||
df.drop(columns=drop_cols, errors="ignore", inplace=True)
|
||||
|
||||
|
||||
# --- subcontractor report only ---
|
||||
@file_report_bp.route("/report", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def report_file():
|
||||
@@ -118,7 +122,8 @@ 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-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),
|
||||
"mh": bill_gen.df_mh.to_html(classes=table_classes, index=False),
|
||||
@@ -136,6 +141,7 @@ def report_file():
|
||||
download_all=download_all
|
||||
)
|
||||
|
||||
# --- client comparison ---
|
||||
@file_report_bp.route("/client_vs_subcont", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def client_vs_all_subcontractor():
|
||||
|
||||
Reference in New Issue
Block a user