Compare commits
3 Commits
8f817c94fd
...
ff5da926f3
| Author | SHA1 | Date | |
|---|---|---|---|
| ff5da926f3 | |||
| 1022923509 | |||
| c9a27b098b |
@@ -1,34 +1,3 @@
|
||||
# from flask import Flask
|
||||
# from app.config import Config
|
||||
# from app.services.db_service import db
|
||||
|
||||
# def create_app():
|
||||
# app = Flask(__name__)
|
||||
# app.config.from_object(Config)
|
||||
|
||||
# db.init_app(app)
|
||||
|
||||
# from app.routes.auth import auth_bp
|
||||
# from app.routes.user import user_bp
|
||||
# from app.routes.dashboard import dashboard_bp
|
||||
# from app.routes.subcontractor_routes import subcontractor_bp
|
||||
# from app.routes.file_import import file_import_bp
|
||||
# from app.routes.file_report import file_report_bp
|
||||
# from app.routes.generate_comparison_report import generate_report_bp
|
||||
# from app.routes.file_format import file_format
|
||||
|
||||
# app.register_blueprint(auth_bp)
|
||||
# app.register_blueprint(user_bp)
|
||||
# app.register_blueprint(dashboard_bp)
|
||||
# app.register_blueprint(subcontractor_bp)
|
||||
# app.register_blueprint(file_import_bp)
|
||||
# app.register_blueprint(file_report_bp)
|
||||
# app.register_blueprint(generate_report_bp)
|
||||
# app.register_blueprint(file_format)
|
||||
|
||||
# return app
|
||||
|
||||
|
||||
from flask import Flask, redirect, url_for
|
||||
from app.config import Config
|
||||
from app.services.db_service import db
|
||||
|
||||
47
app/models/laying_client_model.py
Normal file
47
app/models/laying_client_model.py
Normal file
@@ -0,0 +1,47 @@
|
||||
from app import db
|
||||
from datetime import datetime
|
||||
|
||||
class LayingClient(db.Model):
|
||||
__tablename__ = "laying_client"
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
# Foreign Key to Subcontractor tables
|
||||
# subcontractor_id = db.Column(db.Integer, db.ForeignKey("subcontractors.id"), nullable=False)
|
||||
# Relationship for easy access (subcontractor.subcontractor_name)
|
||||
# subcontractor = db.relationship("Subcontractor", backref="laying_records")
|
||||
|
||||
# Basic Fields
|
||||
Location = db.Column(db.String(500))
|
||||
MH_NO = db.Column(db.String(100))
|
||||
CC_length = db.Column(db.Float)
|
||||
|
||||
Pipe_Dia_mm = db.Column(db.Float)
|
||||
ID_of_MH_m = db.Column(db.Float)
|
||||
Laying_Length = db.Column(db.Float)
|
||||
|
||||
pipe_150_mm = db.Column(db.Float)
|
||||
pipe_200_mm = db.Column(db.Float)
|
||||
pipe_250_mm = db.Column(db.Float)
|
||||
pipe_300_mm = db.Column(db.Float)
|
||||
pipe_350_mm = db.Column(db.Float)
|
||||
pipe_400_mm = db.Column(db.Float)
|
||||
pipe_450_mm = db.Column(db.Float)
|
||||
pipe_500_mm = db.Column(db.Float)
|
||||
pipe_600_mm = db.Column(db.Float)
|
||||
pipe_700_mm = db.Column(db.Float)
|
||||
pipe_900_mm = db.Column(db.Float)
|
||||
pipe_1200_mm = db.Column(db.Float)
|
||||
|
||||
|
||||
Total = db.Column(db.Float)
|
||||
Remarks = db.Column(db.String(500))
|
||||
RA_Bill_No=db.Column(db.String(500))
|
||||
|
||||
created_at = db.Column(db.DateTime, default=datetime.today)
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
return f"<LayingModel {self.Location}>"
|
||||
|
||||
def serialize(self):
|
||||
return {c.name: getattr(self, c.name) for c in self.__table__.columns}
|
||||
@@ -5,7 +5,7 @@ class Laying(db.Model):
|
||||
__tablename__ = "laying"
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
# Foreign Key to Subcontractor table
|
||||
# Foreign Key to Subcontractor tables
|
||||
subcontractor_id = db.Column(db.Integer, db.ForeignKey("subcontractors.id"), nullable=False)
|
||||
# Relationship for easy access (subcontractor.subcontractor_name)
|
||||
subcontractor = db.relationship("Subcontractor", backref="laying_records")
|
||||
|
||||
@@ -55,7 +55,6 @@ class SubcontractorBill:
|
||||
file_report_bp = Blueprint("file_report", __name__, url_prefix="/file")
|
||||
|
||||
# --- DATA WRAPPERS ---
|
||||
|
||||
class ClientBill:
|
||||
def __init__(self):
|
||||
self.df_tr = pd.DataFrame()
|
||||
@@ -84,6 +83,7 @@ class SubcontractorBill:
|
||||
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=None, subcontractor_id=None):
|
||||
filters = {}
|
||||
@@ -95,19 +95,22 @@ 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()
|
||||
|
||||
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)
|
||||
# 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]:
|
||||
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)
|
||||
|
||||
<<<<<<< HEAD
|
||||
# --- ROUTES ---
|
||||
|
||||
# @file_report_bp.route("/report", methods=["GET", "POST"])
|
||||
@@ -149,11 +152,15 @@ class SubcontractorBill:
|
||||
# return send_file(output, download_name=file_name, as_attachment=True, mimetype="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
|
||||
# return render_template("report.html", subcontractors=subcontractors)
|
||||
>>>>>>> pankaj-dev
|
||||
=======
|
||||
|
||||
>>>>>>> pankaj-dev
|
||||
@file_report_bp.route("/report", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def report_file():
|
||||
subcontractors = Subcontractor.query.all()
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
|
||||
if request.method == "POST":
|
||||
@@ -199,6 +206,9 @@ def report_file():
|
||||
|
||||
=======
|
||||
tables = None # Match the variable name used in HTML
|
||||
=======
|
||||
tables = None
|
||||
>>>>>>> pankaj-dev
|
||||
selected_sc_id = None
|
||||
ra_bill_no = None
|
||||
download_all = False
|
||||
@@ -237,23 +247,24 @@ def report_file():
|
||||
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_laying.to_excel(writer, index=False, sheet_name="Laying")
|
||||
output.seek(0)
|
||||
return send_file(output, download_name=file_name, as_attachment=True)
|
||||
|
||||
# PREVIEW LOGIC: Convert DataFrames to HTML for the 'tables' variable
|
||||
# We add bootstrap classes directly to the pandas output
|
||||
table_classes = "table table-hover table-bordered table-striped"
|
||||
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),
|
||||
"dc": bill_gen.df_dc.to_html(classes=table_classes, index=False)
|
||||
"dc": bill_gen.df_dc.to_html(classes=table_classes, index=False),
|
||||
"laying": bill_gen.df_laying.to_html(classes=table_classes, index=False)
|
||||
}
|
||||
selected_sc_id = subcontractor_id
|
||||
|
||||
return render_template(
|
||||
"report.html",
|
||||
subcontractors=subcontractors,
|
||||
tables=tables, # This now matches your HTML
|
||||
tables=tables,
|
||||
selected_sc_id=selected_sc_id,
|
||||
ra_bill_no=ra_bill_no,
|
||||
download_all=download_all
|
||||
|
||||
@@ -16,6 +16,7 @@ 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
|
||||
|
||||
|
||||
|
||||
@@ -335,10 +336,12 @@ class FileService:
|
||||
df_tr_ex = pd.read_excel(filepath, sheet_name="Tr.Ex.", header=4)
|
||||
df_mh_ex = pd.read_excel(filepath, sheet_name="MH Ex.", header=4)
|
||||
df_mh_dc = pd.read_excel(filepath, sheet_name="MH & DC", header=3)
|
||||
df_lay = pd.read_excel(filepath, sheet_name="Laying & Bedding", header=3)
|
||||
|
||||
self.save_client_data(df_tr_ex, TrenchExcavationClient, RA_Bill_No)
|
||||
self.save_client_data(df_mh_ex, ManholeExcavationClient, RA_Bill_No)
|
||||
self.save_client_data(df_mh_dc, ManholeDomesticChamberClient, RA_Bill_No)
|
||||
self.save_client_data(df_lay, LayingClient, RA_Bill_No)
|
||||
|
||||
db.session.commit()
|
||||
return True, "Client file uploaded successfully."
|
||||
@@ -369,3 +372,4 @@ class FileService:
|
||||
|
||||
record = model(RA_Bill_No=RA_Bill_No, **record_data)
|
||||
db.session.add(record)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="container-fluid mt-4">
|
||||
<h2 class="mb-4">File Comparison</h2>
|
||||
<h2 class="mb-4">Client File Reports</h2>
|
||||
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
|
||||
@@ -93,16 +93,22 @@
|
||||
<ul class="nav nav-tabs card-header-tabs" id="reportTabs" role="tablist">
|
||||
<li class="nav-item">
|
||||
<button class="nav-link active" id="tr-tab" data-bs-toggle="tab" data-bs-target="#tr"
|
||||
type="button">Transport (Tr.Ex.)</button>
|
||||
type="button">Tr.Ex.</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button class="nav-link" id="mh-tab" data-bs-toggle="tab" data-bs-target="#mh"
|
||||
type="button">Manpower (MH.Ex.)</button>
|
||||
type="button">MH.Ex. </button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button class="nav-link" id="dc-tab" data-bs-toggle="tab" data-bs-target="#dc" type="button">MH
|
||||
& DC</button>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<button class="nav-link" id="dc-tab" data-bs-toggle="tab" data-bs-target="#dc"
|
||||
type="button">Laying</button>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
<div class="card-body tab-content" id="reportTabsContent">
|
||||
@@ -121,6 +127,12 @@
|
||||
{{ tables.dc | safe }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="laying" role="tabpanel">
|
||||
<div class="table-responsive">
|
||||
{{ tables.laying | safe }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user