Compare commits
16 Commits
e98e1422a0
...
Laxmi-Devs
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ea2f24151 | |||
| b80717ffde | |||
| 12529800f0 | |||
| de7b85034d | |||
| 2f99c290df | |||
| e7805b71a8 | |||
| aa759c9d96 | |||
| bc4b9c778e | |||
| 5577576112 | |||
| ce0e4f90cf | |||
| 446778a50c | |||
| 310ab40bf9 | |||
| bb56f00a6c | |||
| 8353bb6426 | |||
| 1dceb640bd | |||
| 359847958d |
26
.env
26
.env
@@ -1,26 +0,0 @@
|
|||||||
# -----------------------------
|
|
||||||
# Flask App Configuration
|
|
||||||
# -----------------------------
|
|
||||||
FLASK_ENV=development
|
|
||||||
FLASK_DEBUG=True
|
|
||||||
FLASK_HOST=0.0.0.0
|
|
||||||
FLASK_PORT=5015
|
|
||||||
|
|
||||||
# -----------------------------
|
|
||||||
# Security
|
|
||||||
# -----------------------------
|
|
||||||
SECRET_KEY=change-this-to-strong-secret-key
|
|
||||||
|
|
||||||
# -----------------------------
|
|
||||||
# Database Configuration
|
|
||||||
# -----------------------------
|
|
||||||
DB_DIALECT=mysql
|
|
||||||
DB_DRIVER=pymysql
|
|
||||||
DB_HOST=127.0.0.1
|
|
||||||
DB_PORT=3306
|
|
||||||
DB_NAME=comparisondb
|
|
||||||
DB_USER=root
|
|
||||||
DB_PASSWORD=root
|
|
||||||
|
|
||||||
# DATABASE_URL=mysql+pymysql://root:root@localhost/comparisondb
|
|
||||||
|
|
||||||
19
.gitignore
vendored
19
.gitignore
vendored
@@ -1,19 +1,22 @@
|
|||||||
# Python
|
# Python
|
||||||
app/__pycache__/
|
app/__pycache__/
|
||||||
|
__pycache__/
|
||||||
*.pyc
|
*.pyc
|
||||||
*.pyo
|
*.pyo
|
||||||
*.pyd
|
*.pyd
|
||||||
*.__pycache__
|
|
||||||
|
|
||||||
# Ingnor upload files
|
# Ignore upload files
|
||||||
app/static/uploads/
|
app/static/uploads/
|
||||||
|
|
||||||
# Ignore env files
|
# Virtual environment
|
||||||
venv
|
venv/
|
||||||
|
.venv/
|
||||||
|
|
||||||
# Ignore Log files ss
|
# Environment / secrets
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
|
||||||
|
# Log files
|
||||||
logs/
|
logs/
|
||||||
*.log
|
*.log
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ The Comparison Project is designed to:
|
|||||||
|
|
||||||
## Tech Stack
|
## Tech Stack
|
||||||
|
|
||||||
**Backend Framework**: Flask
|
**Frontend Framework**: HTML, CSS, Js, Bootstrap
|
||||||
|
**Backend Framework**: Python Flask
|
||||||
**Database**: SQL Database (MySQL/PostgreSQL/SQLite configured via environment variables)
|
**Database**: SQL Database (MySQL/PostgreSQL/SQLite configured via environment variables)
|
||||||
**ORM**: SQLAlchemy
|
**ORM**: SQLAlchemy
|
||||||
**File Processing**: Pandas, OpenPyXL, XlsxWriter
|
**File Processing**: Pandas, OpenPyXL, XlsxWriter
|
||||||
@@ -580,4 +581,4 @@ Open browser: `http://127.0.0.1:5000/`
|
|||||||
|
|
||||||
For issues, feature requests, or contributions, please contact the development team.
|
For issues, feature requests, or contributions, please contact the development team.
|
||||||
|
|
||||||
**Last Updated:** January 2026
|
**Last Updated:** April 2026
|
||||||
@@ -38,7 +38,7 @@ def register_blueprints(app):
|
|||||||
|
|
||||||
# new
|
# new
|
||||||
from app.routes.activity_routes import activity_bp
|
from app.routes.activity_routes import activity_bp
|
||||||
from app.routes.engineering import engi_bp
|
from app.routes.engineering_master_routes import engi_bp
|
||||||
|
|
||||||
app.register_blueprint(auth_bp)
|
app.register_blueprint(auth_bp)
|
||||||
app.register_blueprint(user_bp)
|
app.register_blueprint(user_bp)
|
||||||
|
|||||||
@@ -22,3 +22,13 @@ class Config:
|
|||||||
|
|
||||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||||
|
|
||||||
|
|
||||||
|
# LDAP Configuration New
|
||||||
|
LDAP_SERVER = os.getenv("LDAP_SERVER")
|
||||||
|
LDAP_PORT = int(os.getenv("LDAP_PORT", 389))
|
||||||
|
LDAP_USE_SSL = os.getenv("LDAP_USE_SSL", "False").lower() == "true"
|
||||||
|
|
||||||
|
LDAP_BASE_DN = os.getenv("LDAP_BASE_DN")
|
||||||
|
LDAP_DOMAIN = os.getenv("LDAP_DOMAIN")
|
||||||
|
|
||||||
|
LDAP_SEARCH_BASE = os.getenv("LDAP_SEARCH_BASE")
|
||||||
23
app/models/subcontractor_rate_model.py
Normal file
23
app/models/subcontractor_rate_model.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
from app import db
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
class SubcontractorRate(db.Model):
|
||||||
|
__tablename__ = "subcontractor_rates"
|
||||||
|
|
||||||
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
subcontractor_id = db.Column(db.Integer, db.ForeignKey("subcontractors.id"), nullable=False)
|
||||||
|
subcontractor = db.relationship("Subcontractor", backref="rate_master")
|
||||||
|
|
||||||
|
category = db.Column(db.String(50), nullable=False)
|
||||||
|
item_code = db.Column(db.String(50), nullable=False)
|
||||||
|
item_name = db.Column(db.String(200), nullable=False)
|
||||||
|
unit = db.Column(db.String(20))
|
||||||
|
rate = db.Column(db.Numeric(12,2), nullable=False)
|
||||||
|
effective_from = db.Column(db.Date, nullable=False)
|
||||||
|
effective_to = db.Column(db.Date)
|
||||||
|
status = db.Column(db.String(20), default="Active")
|
||||||
|
created_at = db.Column(db.DateTime, default=datetime.now)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return f"<subcontractor Rate {self.item_name}>"
|
||||||
|
|
||||||
@@ -34,6 +34,7 @@ def login():
|
|||||||
session.clear()
|
session.clear()
|
||||||
session["user_id"] = user.id
|
session["user_id"] = user.id
|
||||||
session["user_name"] = user.name
|
session["user_name"] = user.name
|
||||||
|
session["email"] = user.email
|
||||||
session.permanent = True
|
session.permanent = True
|
||||||
|
|
||||||
current_app.logger.info(f"Login successful. User={user.name}")
|
current_app.logger.info(f"Login successful. User={user.name}")
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
from flask import Blueprint
|
|
||||||
from app.models.width_model import Width
|
|
||||||
|
|
||||||
engi_bp = Blueprint("engineering",__name__, url_prefix="/engi")
|
|
||||||
|
|
||||||
|
|
||||||
@engi_bp.route("/add")
|
|
||||||
def add_width_md():
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
@engi_bp.route("/list")
|
|
||||||
def display_list():
|
|
||||||
|
|
||||||
return True
|
|
||||||
56
app/routes/engineering_master_routes.py
Normal file
56
app/routes/engineering_master_routes.py
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
from flask import (
|
||||||
|
Blueprint,
|
||||||
|
render_template,
|
||||||
|
request,
|
||||||
|
redirect,
|
||||||
|
url_for,
|
||||||
|
flash
|
||||||
|
)
|
||||||
|
|
||||||
|
from app.models.subcontractor_model import Subcontractor
|
||||||
|
from app.services.subcontractor_rate_service import SubcontractorRateService
|
||||||
|
from app.constants.messages import SuccessMessage, ErrorMessage
|
||||||
|
|
||||||
|
engi_bp = Blueprint(
|
||||||
|
"engineering",
|
||||||
|
__name__,
|
||||||
|
url_prefix="/engi"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@engi_bp.route("/")
|
||||||
|
def engineering_master():
|
||||||
|
|
||||||
|
return render_template(
|
||||||
|
"engineering/index.html",
|
||||||
|
title="Engineering Masters"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@engi_bp.route("/subcontractor-rate")
|
||||||
|
def add_subcontractor_rates():
|
||||||
|
subcontractors = Subcontractor.query.filter_by(status="Active").all()
|
||||||
|
|
||||||
|
if request.method == "POST":
|
||||||
|
try:
|
||||||
|
SubcontractorRateService.save_rate(request.form)
|
||||||
|
flash(SuccessMessage.SAVE, "success")
|
||||||
|
return redirect(url_for("engineering.add_subcontractor_rates"))
|
||||||
|
except Exception as e:
|
||||||
|
flash(ErrorMessage.INTERNAL_SERVER_ERROR, "danger")
|
||||||
|
|
||||||
|
return render_template(
|
||||||
|
"engineering/add_rate.html",
|
||||||
|
title="Subcontractor Rate Master",
|
||||||
|
subcontractors=subcontractors
|
||||||
|
)
|
||||||
|
|
||||||
|
@engi_bp.route("/client-rate")
|
||||||
|
def client_rates():
|
||||||
|
|
||||||
|
return render_template(
|
||||||
|
"engineering/client_rate.html",
|
||||||
|
title="Client Rate Master"
|
||||||
|
)
|
||||||
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
import io
|
import io
|
||||||
|
from datetime import datetime
|
||||||
from flask import Blueprint, render_template, request, send_file, flash, jsonify,redirect, url_for
|
from flask import Blueprint, render_template, request, send_file, flash, jsonify,redirect, url_for
|
||||||
from app.utils.helpers import login_required
|
from app.utils.helpers import login_required
|
||||||
from app.utils.regex_utils import RegularExpression
|
from app.utils.regex_utils import RegularExpression
|
||||||
@@ -29,17 +30,24 @@ def add_action_columns(df, model_key):
|
|||||||
if df.empty:
|
if df.empty:
|
||||||
return df
|
return df
|
||||||
|
|
||||||
df.insert(0, "Select", df["Id"].apply(
|
# Edit + Delete side by side in one "Action" column, both as icon buttons.
|
||||||
|
df.insert(0, "Action", df["Id"].apply(
|
||||||
|
lambda x: (
|
||||||
|
f'<div class="d-flex gap-1">'
|
||||||
|
f'<a href="/file/edit/{model_key}/{x}" class="btn btn-sm btn-warning edit-btn" title="Edit">'
|
||||||
|
f'<i class="bi bi-pencil-square"></i></a>'
|
||||||
|
f'<button class="btn btn-sm btn-danger delete-btn" data-id="{x}" data-model="{model_key}" title="Delete">'
|
||||||
|
f'<i class="bi bi-trash"></i></button>'
|
||||||
|
f'</div>'
|
||||||
|
)
|
||||||
|
))
|
||||||
|
|
||||||
|
df.insert(1, "Select", df["Id"].apply(
|
||||||
lambda x: f'<input type="checkbox" class="row-check" data-id="{x}">'
|
lambda x: f'<input type="checkbox" class="row-check" data-id="{x}">'
|
||||||
))
|
))
|
||||||
|
|
||||||
df["Update"] = df["Id"].apply(
|
df["Id"] = range(1, len(df) + 1)
|
||||||
lambda x: f'<a href="/file/edit/{model_key}/{x}" class="btn btn-sm btn-warning edit-btn"><i class="bi bi-pencil-square"></i> Edit</a>'
|
df = df.rename(columns={"Id": "Sr No"})
|
||||||
)
|
|
||||||
|
|
||||||
df["Delete"] = df["Id"].apply(
|
|
||||||
lambda x: f'<button class="btn btn-sm btn-danger delete-btn" data-id="{x}" data-model="{model_key}">Delete</button>'
|
|
||||||
)
|
|
||||||
|
|
||||||
return df
|
return df
|
||||||
|
|
||||||
@@ -47,6 +55,115 @@ def add_action_columns(df, model_key):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------- EXCEL SHEET FORMATTING (Tr.Ex / Mh.Ex / MH & DC / Pipe Laying) ----------------
|
||||||
|
|
||||||
|
SHEET_TITLES = {
|
||||||
|
"Tr.Ex": "TRENCH EXCAVATION",
|
||||||
|
"Mh.Ex": "MANHOLE EXCAVATION",
|
||||||
|
"MH & DC": "MANHOLE DOMESTIC CHAMBER",
|
||||||
|
"Pipe Laying": "PIPE LAYING",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def format_detail_sheet(workbook, worksheet, df, sheet_name, contractor_name="", ra_bill_no="", report_date=""):
|
||||||
|
"""
|
||||||
|
Writes an info line (Category / Contractor / RA Bill No / Date) at the
|
||||||
|
top, followed by a bold/bordered table with sensible column widths
|
||||||
|
and a frozen header row.
|
||||||
|
|
||||||
|
Assumes df.to_excel(..., startrow=1) already wrote the header at row 1
|
||||||
|
and the data starting at row 2 - this function overwrites those rows
|
||||||
|
with formatting and fills in row 0 with the info line.
|
||||||
|
"""
|
||||||
|
if df.empty:
|
||||||
|
return
|
||||||
|
|
||||||
|
header_format = workbook.add_format({
|
||||||
|
"bold": True,
|
||||||
|
"bg_color": "#D9EAD3",
|
||||||
|
"border": 1,
|
||||||
|
"align": "center",
|
||||||
|
"valign": "vcenter",
|
||||||
|
"text_wrap": True
|
||||||
|
})
|
||||||
|
|
||||||
|
text_format = workbook.add_format({
|
||||||
|
"border": 1,
|
||||||
|
"valign": "vcenter"
|
||||||
|
})
|
||||||
|
|
||||||
|
number_format = workbook.add_format({
|
||||||
|
"border": 1,
|
||||||
|
"valign": "vcenter",
|
||||||
|
"num_format": "#,##0.00"
|
||||||
|
})
|
||||||
|
|
||||||
|
n_rows, n_cols = df.shape
|
||||||
|
header_row = 1 # matches startrow=1 used in df.to_excel()
|
||||||
|
|
||||||
|
# -----------------------------------------------------
|
||||||
|
# INFO LINE (row 0) - separate cells, not one merged block,
|
||||||
|
# so each field (RA Bill No, Date, etc.) can be clicked/copied
|
||||||
|
# on its own. Always starts at column 0, so position is
|
||||||
|
# consistent regardless of how many table columns exist.
|
||||||
|
# -----------------------------------------------------
|
||||||
|
last_col = max(n_cols - 1, 0)
|
||||||
|
report_title = SHEET_TITLES.get(sheet_name, sheet_name.upper())
|
||||||
|
|
||||||
|
label_format = workbook.add_format({"bold": True})
|
||||||
|
value_format = workbook.add_format({})
|
||||||
|
|
||||||
|
info_fields = [
|
||||||
|
("Category:", report_title),
|
||||||
|
("Contractor:", contractor_name or "-"),
|
||||||
|
("RA Bill No:", ra_bill_no or "All"),
|
||||||
|
("Date:", report_date),
|
||||||
|
]
|
||||||
|
|
||||||
|
col = 0
|
||||||
|
for label, value in info_fields:
|
||||||
|
worksheet.write(0, col, label, label_format)
|
||||||
|
worksheet.write(0, col + 1, value, value_format)
|
||||||
|
col += 3 # leave one blank column as a visual gap before next field
|
||||||
|
|
||||||
|
# Fill any remaining columns on row 0 with a blank bordered cell so
|
||||||
|
# the row reads cleanly if the sheet is wider than the info fields.
|
||||||
|
if last_col > col:
|
||||||
|
worksheet.write_blank(0, col, None)
|
||||||
|
|
||||||
|
# -----------------------------------------------------
|
||||||
|
# TABLE HEADER (row 1) - re-write with formatting
|
||||||
|
# -----------------------------------------------------
|
||||||
|
for col_idx, col_name in enumerate(df.columns):
|
||||||
|
worksheet.write(header_row, col_idx, col_name, header_format)
|
||||||
|
|
||||||
|
# -----------------------------------------------------
|
||||||
|
# TABLE BODY (rows 2+) - borders / number formatting
|
||||||
|
# -----------------------------------------------------
|
||||||
|
for row_idx in range(n_rows):
|
||||||
|
for col_idx, col_name in enumerate(df.columns):
|
||||||
|
value = df.iat[row_idx, col_idx]
|
||||||
|
|
||||||
|
if pd.isna(value):
|
||||||
|
worksheet.write(header_row + 1 + row_idx, col_idx, "", text_format)
|
||||||
|
elif isinstance(value, (int, float)):
|
||||||
|
worksheet.write_number(header_row + 1 + row_idx, col_idx, float(value), number_format)
|
||||||
|
else:
|
||||||
|
worksheet.write(header_row + 1 + row_idx, col_idx, str(value), text_format)
|
||||||
|
|
||||||
|
# Auto width columns based on header + content length
|
||||||
|
for col_idx, col_name in enumerate(df.columns):
|
||||||
|
max_len = len(str(col_name))
|
||||||
|
if n_rows:
|
||||||
|
col_values = df.iloc[:, col_idx].astype(str)
|
||||||
|
content_max = col_values.map(len).max()
|
||||||
|
max_len = max(max_len, content_max)
|
||||||
|
worksheet.set_column(col_idx, col_idx, min(max_len + 4, 30))
|
||||||
|
|
||||||
|
worksheet.freeze_panes(header_row + 1, 1)
|
||||||
|
worksheet.set_row(header_row, 30)
|
||||||
|
|
||||||
|
|
||||||
# ---------------- FETCH ----------------
|
# ---------------- FETCH ----------------
|
||||||
class SubcontractorBill:
|
class SubcontractorBill:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -236,6 +353,30 @@ def report_file():
|
|||||||
else:
|
else:
|
||||||
bill.Fetch(ra_bill_no,subcontractor_id,location)
|
bill.Fetch(ra_bill_no,subcontractor_id,location)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------
|
||||||
|
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
|
# Generate Abstract Report for Web
|
||||||
# -----------------------------------------
|
# -----------------------------------------
|
||||||
@@ -256,10 +397,46 @@ def report_file():
|
|||||||
bill.df_tr = bill.df_mh = bill.df_dc = pd.DataFrame()
|
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
|
# DOWNLOAD EXCEL
|
||||||
# ===================================================
|
# ===================================================
|
||||||
if action in ["excel", "excel_all"]:
|
if action in ["excel", "excel_all"]:
|
||||||
|
|
||||||
|
# Look up the contractor's real name once, up front, so it can
|
||||||
|
# be shown in the title block of every sheet.
|
||||||
|
sc_obj = next(
|
||||||
|
(s for s in subcontractors if str(s.id) == str(subcontractor_id)),
|
||||||
|
None
|
||||||
|
)
|
||||||
|
contractor_display_name = sc_obj.subcontractor_name if sc_obj else ""
|
||||||
|
report_date = datetime.now().strftime("%d-%b-%Y")
|
||||||
|
|
||||||
output = io.BytesIO()
|
output = io.BytesIO()
|
||||||
|
|
||||||
with pd.ExcelWriter(output,engine="xlsxwriter") as writer:
|
with pd.ExcelWriter(output,engine="xlsxwriter") as writer:
|
||||||
@@ -267,16 +444,52 @@ def report_file():
|
|||||||
abstract = AbstractReportService(subcontractor_id=subcontractor_id,ra_bill_no=ra_bill_no)
|
abstract = AbstractReportService(subcontractor_id=subcontractor_id,ra_bill_no=ra_bill_no)
|
||||||
abstract.generate(workbook)
|
abstract.generate(workbook)
|
||||||
|
|
||||||
bill.df_tr.to_excel(writer,sheet_name="Tr.Ex",index=False)
|
sheet_map = [
|
||||||
bill.df_mh.to_excel(writer,sheet_name="Mh.Ex",index=False)
|
(bill.df_tr, "Tr.Ex"),
|
||||||
bill.df_dc.to_excel(writer,sheet_name="MH & DC",index=False)
|
(bill.df_mh, "Mh.Ex"),
|
||||||
bill.df_laying.to_excel(writer,sheet_name="Pipe Laying",index=False)
|
(bill.df_dc, "MH & DC"),
|
||||||
|
(bill.df_laying, "Pipe Laying"),
|
||||||
|
]
|
||||||
|
for df, sheet_name in sheet_map:
|
||||||
|
if not df.empty:
|
||||||
|
# Use a copy for the export only - bill.df_tr etc. still
|
||||||
|
# need the real "Id" column later for the Edit/Delete
|
||||||
|
# buttons on the web preview table.
|
||||||
|
export_df = df.drop(columns=["Id"], errors="ignore").copy()
|
||||||
|
export_df.insert(0, "Sr No", range(1, len(export_df) + 1))
|
||||||
|
|
||||||
|
export_df.to_excel(writer, sheet_name=sheet_name, index=False, startrow=1)
|
||||||
|
worksheet = writer.sheets[sheet_name]
|
||||||
|
format_detail_sheet(
|
||||||
|
workbook, worksheet, export_df, sheet_name,
|
||||||
|
contractor_name=contractor_display_name,
|
||||||
|
ra_bill_no=ra_bill_no,
|
||||||
|
report_date=report_date
|
||||||
|
)
|
||||||
writer.close()
|
writer.close()
|
||||||
output.seek(0)
|
output.seek(0)
|
||||||
|
|
||||||
|
sc_name = re.sub(r'[^A-Za-z0-9_-]+', '_', contractor_display_name or "Subcontractor").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(
|
return send_file(
|
||||||
output,
|
output,
|
||||||
download_name= "subcontractor_Report.xlsx",
|
download_name=filename,
|
||||||
as_attachment=True
|
as_attachment=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -257,18 +257,18 @@ class AbstractReportService:
|
|||||||
def laying_summary(self):
|
def laying_summary(self):
|
||||||
f = self.filters()
|
f = self.filters()
|
||||||
data = [
|
data = [
|
||||||
("150 mm Pipe","RM",Laying.pipe_150_mm),
|
("150 mm Dia","RM",Laying.pipe_150_mm),
|
||||||
("200 mm Pipe","RM",Laying.pipe_200_mm),
|
("200 mm Dia","RM",Laying.pipe_200_mm),
|
||||||
("250 mm Pipe","RM",Laying.pipe_250_mm),
|
("250 mm Dia","RM",Laying.pipe_250_mm),
|
||||||
("300 mm Pipe","RM",Laying.pipe_300_mm),
|
("300 mm Dia","RM",Laying.pipe_300_mm),
|
||||||
("350 mm Pipe","RM",Laying.pipe_350_mm),
|
("350 mm Dia","RM",Laying.pipe_350_mm),
|
||||||
("400 mm Pipe","RM",Laying.pipe_400_mm),
|
("400 mm Dia","RM",Laying.pipe_400_mm),
|
||||||
("450 mm Pipe","RM",Laying.pipe_450_mm),
|
("450 mm Dia","RM",Laying.pipe_450_mm),
|
||||||
("500 mm Pipe","RM",Laying.pipe_500_mm),
|
("500 mm Dia","RM",Laying.pipe_500_mm),
|
||||||
("600 mm Pipe","RM",Laying.pipe_600_mm),
|
("600 mm Dia","RM",Laying.pipe_600_mm),
|
||||||
("700 mm Pipe","RM",Laying.pipe_700_mm),
|
("700 mm Dia","RM",Laying.pipe_700_mm),
|
||||||
("900 mm Pipe","RM",Laying.pipe_900_mm),
|
("900 mm Dia","RM",Laying.pipe_900_mm),
|
||||||
("1200 mm Pipe","RM",Laying.pipe_1200_mm),
|
("1200 mm Dia","RM",Laying.pipe_1200_mm),
|
||||||
]
|
]
|
||||||
return self.make_summary(data, Laying, f)
|
return self.make_summary(data, Laying, f)
|
||||||
|
|
||||||
|
|||||||
130
app/services/ldap_service.py
Normal file
130
app/services/ldap_service.py
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
from ldap3 import (
|
||||||
|
Server,
|
||||||
|
Connection,
|
||||||
|
ALL,
|
||||||
|
NTLM,
|
||||||
|
SIMPLE,
|
||||||
|
SUBTREE
|
||||||
|
)
|
||||||
|
|
||||||
|
from flask import current_app
|
||||||
|
from app.config import Config
|
||||||
|
|
||||||
|
|
||||||
|
class LDAPService:
|
||||||
|
"""
|
||||||
|
LDAP / Active Directory Authentication Service
|
||||||
|
"""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def authenticate(username, password):
|
||||||
|
"""
|
||||||
|
Authenticate LDAP User
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
{
|
||||||
|
"success": True,
|
||||||
|
"user": {
|
||||||
|
"username": "...",
|
||||||
|
"name": "...",
|
||||||
|
"email": "..."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OR
|
||||||
|
|
||||||
|
{
|
||||||
|
"success": False,
|
||||||
|
"message": "Invalid username or password"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
if not username or not password:
|
||||||
|
return {
|
||||||
|
"success": False,
|
||||||
|
"message": "Username and Password are required."
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
|
# -----------------------------------
|
||||||
|
# LDAP SERVER
|
||||||
|
# -----------------------------------
|
||||||
|
server = Server(
|
||||||
|
Config.LDAP_SERVER,
|
||||||
|
port=Config.LDAP_PORT,
|
||||||
|
use_ssl=Config.LDAP_USE_SSL,
|
||||||
|
get_info=ALL
|
||||||
|
)
|
||||||
|
|
||||||
|
# -----------------------------------
|
||||||
|
# Login Format
|
||||||
|
#
|
||||||
|
# username@domain.com
|
||||||
|
# -----------------------------------
|
||||||
|
user_dn = f"{username}@{Config.LDAP_DOMAIN}"
|
||||||
|
|
||||||
|
conn = Connection(
|
||||||
|
server,
|
||||||
|
user=user_dn,
|
||||||
|
password=password,
|
||||||
|
authentication=SIMPLE,
|
||||||
|
auto_bind=True
|
||||||
|
)
|
||||||
|
|
||||||
|
# -----------------------------------
|
||||||
|
# Search User
|
||||||
|
# -----------------------------------
|
||||||
|
search_filter = f"(sAMAccountName={username})"
|
||||||
|
|
||||||
|
conn.search(
|
||||||
|
search_base=Config.LDAP_SEARCH_BASE,
|
||||||
|
search_filter=search_filter,
|
||||||
|
search_scope=SUBTREE,
|
||||||
|
attributes=[
|
||||||
|
"displayName",
|
||||||
|
"mail",
|
||||||
|
"givenName",
|
||||||
|
"sn",
|
||||||
|
"cn"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
display_name = username
|
||||||
|
email = ""
|
||||||
|
|
||||||
|
if conn.entries:
|
||||||
|
|
||||||
|
entry = conn.entries[0]
|
||||||
|
|
||||||
|
if "displayName" in entry:
|
||||||
|
display_name = str(entry.displayName)
|
||||||
|
|
||||||
|
if "mail" in entry:
|
||||||
|
email = str(entry.mail)
|
||||||
|
|
||||||
|
conn.unbind()
|
||||||
|
|
||||||
|
current_app.logger.info(
|
||||||
|
f"LDAP Login Success : {username}"
|
||||||
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
|
"success": True,
|
||||||
|
"user": {
|
||||||
|
"username": username,
|
||||||
|
"name": display_name,
|
||||||
|
"email": email
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
except Exception as ex:
|
||||||
|
|
||||||
|
current_app.logger.warning(
|
||||||
|
f"LDAP Login Failed : {username} : {str(ex)}"
|
||||||
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
|
"success": False,
|
||||||
|
"message": "Invalid Username or Password."
|
||||||
|
}
|
||||||
65
app/services/subcontractor_rate_service.py
Normal file
65
app/services/subcontractor_rate_service.py
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
from app.services.db_service import db
|
||||||
|
from app.models.subcontractor_rate_model import SubcontractorRate
|
||||||
|
|
||||||
|
|
||||||
|
class SubcontractorRateService:
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def save_rate(form):
|
||||||
|
|
||||||
|
rate = SubcontractorRate(
|
||||||
|
subcontractor_id=form.get("subcontractor_id"),
|
||||||
|
category=form.get("category"),
|
||||||
|
item_code=form.get("item_code"),
|
||||||
|
item_name=form.get("item_name"),
|
||||||
|
unit=form.get("unit"),
|
||||||
|
rate=form.get("rate"),
|
||||||
|
effective_from=form.get("effective_from"),
|
||||||
|
effective_to=form.get("effective_to") or None,
|
||||||
|
status=form.get("status")
|
||||||
|
)
|
||||||
|
|
||||||
|
db.session.add(rate)
|
||||||
|
db.session.commit()
|
||||||
|
return rate
|
||||||
|
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_all_rates():
|
||||||
|
|
||||||
|
return (
|
||||||
|
SubcontractorRate.query
|
||||||
|
.order_by(SubcontractorRate.created_at.desc())
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
@staticmethod
|
||||||
|
def get_rate(rate_id):
|
||||||
|
|
||||||
|
return SubcontractorRate.query.get_or_404(rate_id)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def update_rate(rate_id, form):
|
||||||
|
|
||||||
|
rate = SubcontractorRate.query.get_or_404(rate_id)
|
||||||
|
|
||||||
|
rate.subcontractor_id = form.get("subcontractor_id")
|
||||||
|
rate.category = form.get("category")
|
||||||
|
rate.item_code = form.get("item_code")
|
||||||
|
rate.item_name = form.get("item_name")
|
||||||
|
rate.unit = form.get("unit")
|
||||||
|
rate.rate = form.get("rate")
|
||||||
|
rate.effective_from = form.get("effective_from")
|
||||||
|
rate.effective_to = form.get("effective_to") or None
|
||||||
|
rate.status = form.get("status")
|
||||||
|
|
||||||
|
db.session.commit()
|
||||||
|
return rate
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def delete_rate(rate_id):
|
||||||
|
|
||||||
|
rate = SubcontractorRate.query.get_or_404(rate_id)
|
||||||
|
|
||||||
|
db.session.delete(rate)
|
||||||
|
|
||||||
|
db.session.commit()
|
||||||
@@ -336,6 +336,7 @@
|
|||||||
|
|
||||||
showLoader();
|
showLoader();
|
||||||
const btn = this.querySelector("button[type='submit']");
|
const btn = this.querySelector("button[type='submit']");
|
||||||
|
const originalBtnHtml = btn ? btn.innerHTML : null;
|
||||||
|
|
||||||
if(btn){
|
if(btn){
|
||||||
btn.disabled = true;
|
btn.disabled = true;
|
||||||
@@ -345,10 +346,24 @@
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
setTimeout(function () {
|
||||||
|
hideLoader();
|
||||||
|
if (btn) {
|
||||||
|
btn.disabled = false;
|
||||||
|
btn.innerHTML = originalBtnHtml;
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
window.addEventListener("pageshow", function () {
|
||||||
|
hideLoader();
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,24 @@
|
|||||||
type="button">Tr.Ex </button>
|
type="button">Tr.Ex </button>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<button class="nav-link" id="mh-tab" data-bs-toggle="tab" data-bs-target="#mh" 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">
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<button class="nav-link" id="laying-tab" data-bs-toggle="tab" data-bs-target="#laying"
|
||||||
|
type="button">Laying
|
||||||
|
& Bedding Comparison</button>
|
||||||
|
=======
|
||||||
|
<button class="nav-link" id="laying-tab" data-bs-toggle="tab" data-bs-target="#laying" type="button">Laying
|
||||||
|
& Bedding </button>
|
||||||
|
>>>>>>> 1dceb640bd930c37888799f10f02fe90b219be67
|
||||||
|
=======
|
||||||
<button class="nav-link" id="mh-tab" data-bs-toggle="tab" data-bs-target="#mh" type="button">
|
<button class="nav-link" id="mh-tab" data-bs-toggle="tab" data-bs-target="#mh" type="button">
|
||||||
Mh.Ex</button>
|
Mh.Ex</button>
|
||||||
</li>
|
</li>
|
||||||
@@ -41,6 +59,7 @@
|
|||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<button class="nav-link" id="laying-tab" data-bs-toggle="tab" data-bs-target="#laying"type="button">
|
<button class="nav-link" id="laying-tab" data-bs-toggle="tab" data-bs-target="#laying"type="button">
|
||||||
Laying & Bedding </button>
|
Laying & Bedding </button>
|
||||||
|
>>>>>>> pankaj-dev
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div class="tab-content mt-3" id="reportTabsContent">
|
<div class="tab-content mt-3" id="reportTabsContent">
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
{% extends "base.html" %}
|
|
||||||
{% block content %}
|
|
||||||
|
|
||||||
<div class="card shadow-sm p-4">
|
|
||||||
<h4 class="mb-3">Add New Subcontractor</h4>
|
|
||||||
|
|
||||||
<form action="{{ url_for('subcontractor.save_subcontractor') }}" method="POST">
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="form-label">Subcontractor Name:</label>
|
|
||||||
<input type="text" class="form-control" name="subcontractor_name" required>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="form-label">Contact Person Name:</label>
|
|
||||||
<input type="text" class="form-control" name="contact_person">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="form-label">Address:</label>
|
|
||||||
<textarea type="text" class="form-control" name="address"></textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="form-label">Mobile No:</label>
|
|
||||||
<input type="text" class="form-control" name="mobile_no">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="form-label">Email:</label>
|
|
||||||
<input type="email" class="form-control" name="email_id">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="form-label">GST No:</label>
|
|
||||||
<input type="text" class="form-control" name="gst_no">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="form-label">PAN No:</label>
|
|
||||||
<input type="text" class="form-control" name="pan_no">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button class="btn btn-success">Save</button>
|
|
||||||
<a href="{{ url_for('subcontractor.subcontractor_list') }}" class="btn btn-secondary">Back</a>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
236
app/templates/engineering/add_rate.html
Normal file
236
app/templates/engineering/add_rate.html
Normal file
@@ -0,0 +1,236 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% block content %}
|
||||||
|
<div class="container-fluid mt-4">
|
||||||
|
|
||||||
|
<div class="card shadow">
|
||||||
|
|
||||||
|
<div class="card-header bg-primary text-white">
|
||||||
|
<h4 class="mb-0">
|
||||||
|
<i class="bi bi-currency-rupee"></i>
|
||||||
|
Subcontractor Rate Master
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-body">
|
||||||
|
|
||||||
|
<form method="POST">
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<!-- Subcontractor -->
|
||||||
|
<div class="col-md-4 mb-3">
|
||||||
|
<label class="form-label fw-bold">
|
||||||
|
Subcontractor
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<select name="subcontractor_id"
|
||||||
|
class="form-select"
|
||||||
|
required>
|
||||||
|
|
||||||
|
<option value="">
|
||||||
|
Select Subcontractor
|
||||||
|
</option>
|
||||||
|
|
||||||
|
{% for sub in subcontractors %}
|
||||||
|
<option value="{{ sub.id }}">
|
||||||
|
{{ sub.subcontractor_name }}
|
||||||
|
</option>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Category -->
|
||||||
|
<div class="col-md-4 mb-3">
|
||||||
|
|
||||||
|
<label class="form-label fw-bold">
|
||||||
|
Category
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<select name="category"
|
||||||
|
class="form-select"
|
||||||
|
required>
|
||||||
|
|
||||||
|
<option value="">
|
||||||
|
Select Category
|
||||||
|
</option>
|
||||||
|
|
||||||
|
<option value="TR_EX">
|
||||||
|
Trench Excavation
|
||||||
|
</option>
|
||||||
|
|
||||||
|
<option value="MH_EX">
|
||||||
|
Manhole Excavation
|
||||||
|
</option>
|
||||||
|
|
||||||
|
<option value="MH_DC">
|
||||||
|
Manhole & Domestic Chamber
|
||||||
|
</option>
|
||||||
|
|
||||||
|
<option value="LAYING">
|
||||||
|
Pipe Laying
|
||||||
|
</option>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Status -->
|
||||||
|
<div class="col-md-4 mb-3">
|
||||||
|
|
||||||
|
<label class="form-label fw-bold">
|
||||||
|
Status
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<select name="status"
|
||||||
|
class="form-select">
|
||||||
|
|
||||||
|
<option value="Active">
|
||||||
|
Active
|
||||||
|
</option>
|
||||||
|
|
||||||
|
<option value="Inactive">
|
||||||
|
Inactive
|
||||||
|
</option>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<!-- Item Code -->
|
||||||
|
<div class="col-md-3 mb-3">
|
||||||
|
|
||||||
|
<label class="form-label fw-bold">
|
||||||
|
Item Code
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<input type="text"
|
||||||
|
name="item_code"
|
||||||
|
class="form-control"
|
||||||
|
placeholder="SM01"
|
||||||
|
required>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Item Name -->
|
||||||
|
<div class="col-md-5 mb-3">
|
||||||
|
|
||||||
|
<label class="form-label fw-bold">
|
||||||
|
Item Name
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<input type="text"
|
||||||
|
name="item_name"
|
||||||
|
class="form-control"
|
||||||
|
placeholder="Soft Murum 0-1.5"
|
||||||
|
required>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Unit -->
|
||||||
|
<div class="col-md-2 mb-3">
|
||||||
|
|
||||||
|
<label class="form-label fw-bold">
|
||||||
|
Unit
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<select name="unit"
|
||||||
|
class="form-select">
|
||||||
|
|
||||||
|
<option value="Cum">Cum</option>
|
||||||
|
<option value="Nos">Nos</option>
|
||||||
|
<option value="Rmt">Rmt</option>
|
||||||
|
<option value="Sqm">Sqm</option>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Rate -->
|
||||||
|
<div class="col-md-2 mb-3">
|
||||||
|
|
||||||
|
<label class="form-label fw-bold">
|
||||||
|
Rate (₹)
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<input type="number"
|
||||||
|
step="0.01"
|
||||||
|
min="0"
|
||||||
|
name="rate"
|
||||||
|
class="form-control"
|
||||||
|
placeholder="0.00"
|
||||||
|
required>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<!-- Effective From -->
|
||||||
|
<div class="col-md-3 mb-3">
|
||||||
|
|
||||||
|
<label class="form-label fw-bold">
|
||||||
|
Effective From
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<input type="date"
|
||||||
|
name="effective_from"
|
||||||
|
class="form-control"
|
||||||
|
required>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Effective To -->
|
||||||
|
<div class="col-md-3 mb-3">
|
||||||
|
|
||||||
|
<label class="form-label fw-bold">
|
||||||
|
Effective To
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<input type="date"
|
||||||
|
name="effective_to"
|
||||||
|
class="form-control">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div class="text-end">
|
||||||
|
|
||||||
|
<button type="reset"
|
||||||
|
class="btn btn-secondary">
|
||||||
|
|
||||||
|
<i class="bi bi-arrow-clockwise"></i>
|
||||||
|
|
||||||
|
Reset
|
||||||
|
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button type="submit"
|
||||||
|
class="btn btn-success">
|
||||||
|
|
||||||
|
<i class="bi bi-check-circle"></i>
|
||||||
|
|
||||||
|
Save Rate
|
||||||
|
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
83
app/templates/engineering/index.html
Normal file
83
app/templates/engineering/index.html
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="container-fluid mt-4">
|
||||||
|
|
||||||
|
<div class="row mb-4">
|
||||||
|
<div class="col-12">
|
||||||
|
<h3 class="fw-bold">
|
||||||
|
<i class="bi bi-gear-fill text-primary"></i>
|
||||||
|
Engineering Masters
|
||||||
|
</h3>
|
||||||
|
<hr>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row g-4">
|
||||||
|
|
||||||
|
<!-- Subcontractor Rate Master -->
|
||||||
|
<div class="col-lg-4 col-md-6">
|
||||||
|
<div class="card shadow h-100">
|
||||||
|
|
||||||
|
<div class="card-body text-center">
|
||||||
|
|
||||||
|
<i class="bi bi-cash-stack text-success"
|
||||||
|
style="font-size:55px;"></i>
|
||||||
|
|
||||||
|
<h5 class="mt-3">
|
||||||
|
Subcontractor Rate Master
|
||||||
|
</h5>
|
||||||
|
|
||||||
|
<p class="text-muted">
|
||||||
|
Manage subcontractor-wise rates.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<a href="{{ url_for('engineering.add_subcontractor_rates') }}"
|
||||||
|
class="btn btn-success">
|
||||||
|
|
||||||
|
<i class="bi bi-arrow-right-circle"></i>
|
||||||
|
Open Module
|
||||||
|
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Client Rate Master -->
|
||||||
|
<div class="col-lg-4 col-md-6">
|
||||||
|
<div class="card shadow h-100">
|
||||||
|
|
||||||
|
<div class="card-body text-center">
|
||||||
|
|
||||||
|
<i class="bi bi-building text-primary"
|
||||||
|
style="font-size:55px;"></i>
|
||||||
|
|
||||||
|
<h5 class="mt-3">
|
||||||
|
Client Standard Rate Master
|
||||||
|
</h5>
|
||||||
|
|
||||||
|
<p class="text-muted">
|
||||||
|
Manage client standard rates.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<a href="{{ url_for('engineering.client_rates') }}"
|
||||||
|
class="btn btn-primary">
|
||||||
|
|
||||||
|
<i class="bi bi-arrow-right-circle"></i>
|
||||||
|
Open Module
|
||||||
|
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -84,10 +84,11 @@
|
|||||||
</span>
|
</span>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
type="email"
|
type="text"
|
||||||
name="email"
|
name="email"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
placeholder="Enter Email"
|
placeholder="Enter Domain Username"
|
||||||
|
autocomplete="username"
|
||||||
required>
|
required>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,50 +1,170 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<div class="card shadow-sm p-4">
|
<div class="container-fluid">
|
||||||
<h4 class="mb-3">Add New Subcontractor</h4>
|
|
||||||
|
|
||||||
<form action="{{ url_for('subcontractor.save_subcontractor') }}" method="POST">
|
<!-- Page Header -->
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
<div class="mb-3">
|
<div>
|
||||||
<label class="form-label">Subcontractor Name:</label>
|
<h3 class="fw-bold mb-1">
|
||||||
<input type="text" class="form-control" name="subcontractor_name" required>
|
<i class="bi bi-person-plus-fill text-success me-2"></i>
|
||||||
|
Add New Subcontractor
|
||||||
|
</h3>
|
||||||
|
<p class="text-muted mb-0">
|
||||||
|
Enter the subcontractor details below.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<a href="{{ url_for('subcontractor.subcontractor_list') }}"
|
||||||
<label class="form-label">Contact Person Name:</label>
|
class="btn btn-outline-secondary">
|
||||||
<input type="text" class="form-control" name="contact_person">
|
<i class="bi bi-arrow-left me-2"></i>
|
||||||
|
Back to List
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card shadow border-0">
|
||||||
|
|
||||||
|
<div class="card-header bg-success text-white">
|
||||||
|
<h5 class="mb-0">
|
||||||
|
<i class="bi bi-building-fill-add me-2"></i>
|
||||||
|
Subcontractor Information
|
||||||
|
</h5>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="card-body">
|
||||||
<label class="form-label">Address:</label>
|
|
||||||
<textarea type="text" class="form-control" name="address"></textarea>
|
<form action="{{ url_for('subcontractor.save_subcontractor') }}"
|
||||||
|
method="POST"
|
||||||
|
class="loading-form">
|
||||||
|
|
||||||
|
<div class="row g-4">
|
||||||
|
|
||||||
|
<!-- Subcontractor Name -->
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label fw-semibold">
|
||||||
|
<i class="bi bi-building me-1"></i>
|
||||||
|
Subcontractor Name
|
||||||
|
<span class="text-danger">*</span>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<input type="text"
|
||||||
|
class="form-control"
|
||||||
|
name="subcontractor_name"
|
||||||
|
placeholder="Enter Subcontractor Name"
|
||||||
|
required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Contact Person -->
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label fw-semibold">
|
||||||
|
<i class="bi bi-person-fill me-1"></i>
|
||||||
|
Contact Person
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<input type="text"
|
||||||
|
class="form-control"
|
||||||
|
name="contact_person"
|
||||||
|
placeholder="Enter Contact Person">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Mobile -->
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label fw-semibold">
|
||||||
|
<i class="bi bi-telephone-fill me-1"></i>
|
||||||
|
Mobile Number
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<input type="text"
|
||||||
|
class="form-control"
|
||||||
|
name="mobile_no"
|
||||||
|
maxlength="10"
|
||||||
|
placeholder="Enter Mobile Number">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Email -->
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label fw-semibold">
|
||||||
|
<i class="bi bi-envelope-fill me-1"></i>
|
||||||
|
Email Address
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<input type="email"
|
||||||
|
class="form-control"
|
||||||
|
name="email_id"
|
||||||
|
placeholder="Enter Email Address">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- GST -->
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label fw-semibold">
|
||||||
|
<i class="bi bi-receipt-cutoff me-1"></i>
|
||||||
|
GST Number
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<input type="text"
|
||||||
|
class="form-control"
|
||||||
|
name="gst_no"
|
||||||
|
placeholder="Enter GST Number">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- PAN -->
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label fw-semibold">
|
||||||
|
<i class="bi bi-credit-card-2-front-fill me-1"></i>
|
||||||
|
PAN Number
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<input type="text"
|
||||||
|
class="form-control"
|
||||||
|
name="pan_no"
|
||||||
|
placeholder="Enter PAN Number">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Address -->
|
||||||
|
<div class="col-12">
|
||||||
|
<label class="form-label fw-semibold">
|
||||||
|
<i class="bi bi-geo-alt-fill me-1"></i>
|
||||||
|
Address
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<textarea class="form-control"
|
||||||
|
rows="4"
|
||||||
|
name="address"
|
||||||
|
placeholder="Enter Complete Address"></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr class="my-4">
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-end gap-2">
|
||||||
|
|
||||||
|
<button type="reset"
|
||||||
|
class="btn btn-outline-warning">
|
||||||
|
<i class="bi bi-arrow-clockwise me-2"></i>
|
||||||
|
Reset
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<a href="{{ url_for('subcontractor.subcontractor_list') }}"
|
||||||
|
class="btn btn-outline-secondary">
|
||||||
|
<i class="bi bi-x-circle me-2"></i>
|
||||||
|
Cancel
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<button type="submit"
|
||||||
|
class="btn btn-success">
|
||||||
|
<i class="bi bi-check-circle-fill me-2"></i>
|
||||||
|
Save Subcontractor
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
</div>
|
||||||
<label class="form-label">Mobile No:</label>
|
|
||||||
<input type="text" class="form-control" name="mobile_no">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="form-label">Email:</label>
|
|
||||||
<input type="email" class="form-control" name="email_id">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="form-label">GST No:</label>
|
|
||||||
<input type="text" class="form-control" name="gst_no">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="form-label">PAN No:</label>
|
|
||||||
<input type="text" class="form-control" name="pan_no">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button class="btn btn-success">Save</button>
|
|
||||||
<a href="{{ url_for('subcontractor.subcontractor_list') }}" class="btn btn-secondary">Back</a>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -155,51 +155,61 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if tables %}
|
{% if tables %}
|
||||||
|
{% set show_all = (not selected_category) or selected_category == 'all' %}
|
||||||
<!-- Tabs -->
|
<!-- Tabs -->
|
||||||
<div class="card shadow-sm border-0 mt-4">
|
<div class="card shadow-sm border-0 mt-4">
|
||||||
<div class="card-header bg-light">
|
<div class="card-header bg-light">
|
||||||
<ul class="nav nav-pills">
|
<ul class="nav nav-pills">
|
||||||
<li class="nav-item">
|
<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
|
<i class="bi bi-file-earmark-text"></i> Abstract
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
{% if show_all or selected_category == 'tr' %}
|
||||||
<li class="nav-item">
|
<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
|
<i class="bi bi-cone-striped"></i> Trench Excavation
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if show_all or selected_category == 'mh' %}
|
||||||
<li class="nav-item">
|
<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
|
<i class="bi bi-nut"></i> Manhole Excavation
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if show_all or selected_category == 'dc' %}
|
||||||
<li class="nav-item">
|
<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
|
<i class="bi bi-grid-3x3"></i> Manhole & Domestic Chambers Construction
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if show_all or selected_category == 'laying' %}
|
||||||
<li class="nav-item">
|
<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
|
<i class="bi bi-bezier2"></i> Pipe Laying
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="tab-content">
|
<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 }}
|
{{ abstract_html|safe }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if show_all or selected_category == 'tr' %}
|
||||||
<!-- Trench -->
|
<!-- Trench -->
|
||||||
<div class="tab-pane fade "id="tr">
|
<div class="tab-pane fade {% if selected_category == 'tr' %}show active{% endif %}" id="tr">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<button onclick="deleteSelected('tr')" class="btn btn-danger">
|
<button onclick="deleteSelected('tr')" class="btn btn-danger">
|
||||||
<i class="bi bi-trash"></i> Delete Selected
|
<i class="bi bi-trash"></i> Delete Selected
|
||||||
@@ -209,9 +219,11 @@
|
|||||||
{{ tables.tr|safe }}
|
{{ tables.tr|safe }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if show_all or selected_category == 'mh' %}
|
||||||
<!-- MH -->
|
<!-- MH -->
|
||||||
<div class="tab-pane fade" id="mh">
|
<div class="tab-pane fade {% if selected_category == 'mh' %}show active{% endif %}" id="mh">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<button onclick="deleteSelected('mh')" class="btn btn-danger">
|
<button onclick="deleteSelected('mh')" class="btn btn-danger">
|
||||||
<i class="bi bi-trash"></i>Delete Selected
|
<i class="bi bi-trash"></i>Delete Selected
|
||||||
@@ -221,9 +233,11 @@
|
|||||||
{{ tables.mh|safe }}
|
{{ tables.mh|safe }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if show_all or selected_category == 'dc' %}
|
||||||
<!-- DC -->
|
<!-- DC -->
|
||||||
<div class="tab-pane fade" id="dc">
|
<div class="tab-pane fade {% if selected_category == 'dc' %}show active{% endif %}" id="dc">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<button onclick="deleteSelected('dc')"class="btn btn-danger">
|
<button onclick="deleteSelected('dc')"class="btn btn-danger">
|
||||||
<i class="bi bi-trash"></i>
|
<i class="bi bi-trash"></i>
|
||||||
@@ -234,9 +248,11 @@
|
|||||||
{{ tables.dc|safe }}
|
{{ tables.dc|safe }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if show_all or selected_category == 'laying' %}
|
||||||
<!-- Laying -->
|
<!-- Laying -->
|
||||||
<div class="tab-pane fade" id="laying">
|
<div class="tab-pane fade {% if selected_category == 'laying' %}show active{% endif %}" id="laying">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<button onclick="deleteSelected('laying')"
|
<button onclick="deleteSelected('laying')"
|
||||||
class="btn btn-danger">
|
class="btn btn-danger">
|
||||||
@@ -248,6 +264,7 @@
|
|||||||
{{ tables.laying|safe }}
|
{{ tables.laying|safe }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -256,31 +273,45 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Reset
|
|
||||||
document.getElementById("resetBtn").addEventListener("click", function () {location.reload();});
|
document.getElementById("resetBtn").addEventListener("click", function () {
|
||||||
|
window.location.href = window.location.pathname;
|
||||||
|
});
|
||||||
|
|
||||||
// DATATABLE
|
// DATATABLE
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$('.datatable').DataTable({
|
|
||||||
pageLength: 10,
|
$('.datatable').each(function () {
|
||||||
dom: 'Bfrtip',
|
$(this).DataTable({
|
||||||
buttons: ['copy', 'csv', 'excel', 'print']
|
pageLength: 10,
|
||||||
|
dom: 'Bfrtip',
|
||||||
|
buttons: ['copy', 'csv', 'excel', 'print'],
|
||||||
|
initComplete: function () {
|
||||||
|
|
||||||
|
$(this).closest('.dataTables_wrapper')
|
||||||
|
.find('thead tr th:first-child')
|
||||||
|
.html('<input type="checkbox" class="select-all" title="Select All">');
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
$("table thead tr th:first-child").html('<input type="checkbox" id="select-all">');
|
|
||||||
}, 500);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// SELECT ALL
|
// SELECT ALL — scoped to the checkbox's own table only
|
||||||
$(document).on("change", "#select-all", function () {
|
$(document).on("change", ".select-all", function () {
|
||||||
$(".row-check").prop("checked", this.checked);
|
$(this).closest("table").find(".row-check").prop("checked", this.checked);
|
||||||
});
|
});
|
||||||
|
|
||||||
// GET IDS
|
// If a row checkbox is unchecked manually, uncheck that table's select-all
|
||||||
function getSelectedIds() {
|
$(document).on("change", ".row-check", function () {
|
||||||
|
if (!this.checked) {
|
||||||
|
$(this).closest("table").find(".select-all").prop("checked", false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function getSelectedIds(model) {
|
||||||
let ids = [];
|
let ids = [];
|
||||||
$(".row-check:checked").each(function () {
|
$("#" + model + " .row-check:checked").each(function () {
|
||||||
ids.push($(this).data("id"));
|
ids.push($(this).data("id"));
|
||||||
});
|
});
|
||||||
return ids;
|
return ids;
|
||||||
@@ -288,7 +319,7 @@
|
|||||||
|
|
||||||
// BULK DELETE
|
// BULK DELETE
|
||||||
function deleteSelected(model) {
|
function deleteSelected(model) {
|
||||||
let ids = getSelectedIds();
|
let ids = getSelectedIds(model);
|
||||||
if (ids.length === 0) return alert("Select records");
|
if (ids.length === 0) return alert("Select records");
|
||||||
|
|
||||||
if (!confirm(`Delete ${ids.length} record(s)?`)) return;
|
if (!confirm(`Delete ${ids.length} record(s)?`)) return;
|
||||||
|
|||||||
@@ -1,119 +0,0 @@
|
|||||||
{% extends "base.html" %}
|
|
||||||
{% block content %}
|
|
||||||
|
|
||||||
<div class="container mt-3">
|
|
||||||
|
|
||||||
<h4>RA Bill Dashboard</h4>
|
|
||||||
|
|
||||||
<div class="row mb-3">
|
|
||||||
|
|
||||||
<!-- Contractor -->
|
|
||||||
<div class="col-md-4">
|
|
||||||
<select id="subcontractor" class="form-control">
|
|
||||||
<option value="">Select Contractor</option>
|
|
||||||
{% for s in subcontractors %}
|
|
||||||
<option value="{{s.id}}">{{s.subcontractor_name}}</option>
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Category -->
|
|
||||||
<div class="col-md-4">
|
|
||||||
<select id="category" class="form-control">
|
|
||||||
<option value="">Select Category</option>
|
|
||||||
<option value="trench_excavation">Trench Excavation</option>
|
|
||||||
<option value="manhole_excavation">Manhole Excavation</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- RA Bill -->
|
|
||||||
<div class="col-md-4">
|
|
||||||
<select id="ra_bill" class="form-control">
|
|
||||||
<option value="">RA Bill</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body">
|
|
||||||
<canvas id="comparisonChart"></canvas>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
|
|
||||||
let chart;
|
|
||||||
|
|
||||||
// ✅ Load RA Bills
|
|
||||||
function loadRABills() {
|
|
||||||
|
|
||||||
let subcontractor = document.getElementById("subcontractor").value
|
|
||||||
let category = document.getElementById("category").value
|
|
||||||
|
|
||||||
if (!subcontractor || !category) return
|
|
||||||
|
|
||||||
fetch(`/dashboard/api/get-ra-bills?subcontractor=${subcontractor}&category=${category}`)
|
|
||||||
.then(res => res.json())
|
|
||||||
.then(data => {
|
|
||||||
|
|
||||||
let ra = document.getElementById("ra_bill")
|
|
||||||
ra.innerHTML = '<option value="">RA Bill</option>'
|
|
||||||
|
|
||||||
data.ra_bills.forEach(bill => {
|
|
||||||
ra.innerHTML += `<option value="${bill}">${bill}</option>`
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// ✅ Load Chart
|
|
||||||
function loadChart() {
|
|
||||||
|
|
||||||
let subcontractor = document.getElementById("subcontractor").value
|
|
||||||
let ra_bill = document.getElementById("ra_bill").value
|
|
||||||
|
|
||||||
fetch(`/dashboard/api/trench-analysis?subcontractor=${subcontractor}&ra_bill=${ra_bill}`)
|
|
||||||
.then(res => res.json())
|
|
||||||
.then(data => {
|
|
||||||
|
|
||||||
if (chart) chart.destroy()
|
|
||||||
|
|
||||||
chart = new Chart(document.getElementById("comparisonChart"), {
|
|
||||||
type: "bar",
|
|
||||||
data: {
|
|
||||||
labels: data.labels,
|
|
||||||
datasets: [
|
|
||||||
{
|
|
||||||
label: "Depth",
|
|
||||||
data: data.depth,
|
|
||||||
backgroundColor: "green"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Excavation Qty (cum)",
|
|
||||||
data: data.qty,
|
|
||||||
backgroundColor: "blue"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Events
|
|
||||||
document.getElementById("subcontractor").addEventListener("change", () => {
|
|
||||||
loadRABills()
|
|
||||||
})
|
|
||||||
|
|
||||||
document.getElementById("category").addEventListener("change", () => {
|
|
||||||
loadRABills()
|
|
||||||
})
|
|
||||||
|
|
||||||
document.getElementById("ra_bill").addEventListener("change", loadChart)
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
Reference in New Issue
Block a user