Compare commits
4 Commits
e98e1422a0
...
pankaj-dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 18874cc84e | |||
| e7805b71a8 | |||
| aa759c9d96 | |||
| bc4b9c778e |
11
.env
11
.env
@@ -24,3 +24,14 @@ DB_PASSWORD=root
|
||||
|
||||
# DATABASE_URL=mysql+pymysql://root:root@localhost/comparisondb
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# LDAP Configuration new
|
||||
# -----------------------------
|
||||
LDAP_SERVER=ldap://host.docker.internal
|
||||
LDAP_PORT=389
|
||||
LDAP_USE_SSL=False
|
||||
|
||||
LDAP_DOMAIN=lcepl.org
|
||||
LDAP_BASE_DN=DC=lcepl,DC=org
|
||||
LDAP_SEARCH_BASE=OU=Users,DC=lcepl,DC=org
|
||||
|
||||
@@ -38,7 +38,7 @@ def register_blueprints(app):
|
||||
|
||||
# new
|
||||
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(user_bp)
|
||||
|
||||
@@ -22,3 +22,13 @@ class Config:
|
||||
|
||||
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["user_id"] = user.id
|
||||
session["user_name"] = user.name
|
||||
session["email"] = user.email
|
||||
session.permanent = True
|
||||
|
||||
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
|
||||
107
app/routes/engineering_master_routes.py
Normal file
107
app/routes/engineering_master_routes.py
Normal file
@@ -0,0 +1,107 @@
|
||||
from flask import (
|
||||
Blueprint,
|
||||
render_template,
|
||||
request,
|
||||
redirect,
|
||||
url_for,
|
||||
flash, jsonify
|
||||
)
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
# Client rate model
|
||||
@engi_bp.route("/client-rate")
|
||||
def client_rates():
|
||||
|
||||
return render_template(
|
||||
"engineering/client_rate.html",
|
||||
title="Client Rate Master"
|
||||
)
|
||||
|
||||
@engi_bp.route("/subcontractor-rate", methods=["GET", "POST"])
|
||||
def add_subcontractor_rates():
|
||||
|
||||
subcontractors = Subcontractor.query.filter_by(status="Active").all()
|
||||
|
||||
if request.method == "POST":
|
||||
result = SubcontractorRateService.save_or_update(request.form)
|
||||
if result["success"]:
|
||||
flash(result["message"], "success")
|
||||
return redirect(url_for("engineering.add_subcontractor_rates"))
|
||||
else:
|
||||
flash(result["message"], "danger")
|
||||
|
||||
rates = SubcontractorRateService.get_all_rates()
|
||||
|
||||
return render_template(
|
||||
"engineering/contractor_rate.html",
|
||||
title="Subcontractor Rate Master",
|
||||
subcontractors=subcontractors,
|
||||
rates=rates
|
||||
)
|
||||
|
||||
@engi_bp.route("/subcontractor-rate/edit/<int:rate_id>", methods=["GET", "POST"])
|
||||
def edit_rate(rate_id):
|
||||
|
||||
subcontractors = Subcontractor.query.filter_by(status="Active").all()
|
||||
|
||||
if request.method == "POST":
|
||||
|
||||
result = SubcontractorRateService.save_or_update(request.form)
|
||||
|
||||
if result["success"]:
|
||||
flash(result["message"], "success")
|
||||
return redirect(url_for("engineering.add_subcontractor_rates"))
|
||||
|
||||
flash(result["message"], "danger")
|
||||
|
||||
rate = SubcontractorRateService.get_rate(rate_id)
|
||||
|
||||
rates = SubcontractorRateService.get_all_rates()
|
||||
|
||||
return render_template(
|
||||
"engineering/contractor_rate.html",
|
||||
subcontractors=subcontractors,
|
||||
rate=rate,
|
||||
rates=rates
|
||||
)
|
||||
|
||||
@engi_bp.route("/subcontractor-rate/delete/<int:rate_id>")
|
||||
def delete_rate(rate_id):
|
||||
SubcontractorRateService.delete_rate(rate_id)
|
||||
flash("Rate deleted successfully.", "success")
|
||||
return redirect(url_for("engineering.add_subcontractor_rates"))
|
||||
|
||||
|
||||
@engi_bp.route("/check-rate")
|
||||
def check_rate():
|
||||
|
||||
exists = SubcontractorRateService.check_duplicate(
|
||||
subcontractor_id=request.args.get("subcontractor_id"),
|
||||
category=request.args.get("category"),
|
||||
item_name=request.args.get("item_name"),
|
||||
rate_id=request.args.get("rate_id")
|
||||
)
|
||||
|
||||
return jsonify({
|
||||
"exists": exists
|
||||
})
|
||||
|
||||
@@ -257,18 +257,18 @@ class AbstractReportService:
|
||||
def laying_summary(self):
|
||||
f = self.filters()
|
||||
data = [
|
||||
("150 mm Pipe","RM",Laying.pipe_150_mm),
|
||||
("200 mm Pipe","RM",Laying.pipe_200_mm),
|
||||
("250 mm Pipe","RM",Laying.pipe_250_mm),
|
||||
("300 mm Pipe","RM",Laying.pipe_300_mm),
|
||||
("350 mm Pipe","RM",Laying.pipe_350_mm),
|
||||
("400 mm Pipe","RM",Laying.pipe_400_mm),
|
||||
("450 mm Pipe","RM",Laying.pipe_450_mm),
|
||||
("500 mm Pipe","RM",Laying.pipe_500_mm),
|
||||
("600 mm Pipe","RM",Laying.pipe_600_mm),
|
||||
("700 mm Pipe","RM",Laying.pipe_700_mm),
|
||||
("900 mm Pipe","RM",Laying.pipe_900_mm),
|
||||
("1200 mm Pipe","RM",Laying.pipe_1200_mm),
|
||||
("150 mm Dia","RM",Laying.pipe_150_mm),
|
||||
("200 mm Dia","RM",Laying.pipe_200_mm),
|
||||
("250 mm Dia","RM",Laying.pipe_250_mm),
|
||||
("300 mm Dia","RM",Laying.pipe_300_mm),
|
||||
("350 mm Dia","RM",Laying.pipe_350_mm),
|
||||
("400 mm Dia","RM",Laying.pipe_400_mm),
|
||||
("450 mm Dia","RM",Laying.pipe_450_mm),
|
||||
("500 mm Dia","RM",Laying.pipe_500_mm),
|
||||
("600 mm Dia","RM",Laying.pipe_600_mm),
|
||||
("700 mm Dia","RM",Laying.pipe_700_mm),
|
||||
("900 mm Dia","RM",Laying.pipe_900_mm),
|
||||
("1200 mm Dia","RM",Laying.pipe_1200_mm),
|
||||
]
|
||||
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."
|
||||
}
|
||||
102
app/services/subcontractor_rate_service.py
Normal file
102
app/services/subcontractor_rate_service.py
Normal file
@@ -0,0 +1,102 @@
|
||||
from app.services.db_service import db
|
||||
from app.models.subcontractor_rate_model import SubcontractorRate
|
||||
from sqlalchemy import func
|
||||
|
||||
|
||||
class SubcontractorRateService:
|
||||
|
||||
@staticmethod
|
||||
def save_or_update(form):
|
||||
|
||||
rate_id = form.get("id")
|
||||
|
||||
subcontractor_id = form.get("subcontractor_id")
|
||||
category = form.get("category")
|
||||
item_name = form.get("item_name").strip()
|
||||
|
||||
# -----------------------------
|
||||
# Duplicate Validation
|
||||
# -----------------------------
|
||||
duplicate = (
|
||||
SubcontractorRate.query
|
||||
.filter(
|
||||
SubcontractorRate.subcontractor_id == subcontractor_id,
|
||||
SubcontractorRate.category == category,
|
||||
func.lower(SubcontractorRate.item_name) == item_name.lower()
|
||||
)
|
||||
.first()
|
||||
)
|
||||
|
||||
# Ignore current record while editing
|
||||
if duplicate and (not rate_id or duplicate.id != int(rate_id)):
|
||||
return {
|
||||
"success": False,
|
||||
"message": "Category and Rate already exists for this Subcontractor."
|
||||
}
|
||||
|
||||
# -----------------------------
|
||||
# Insert / Update
|
||||
# -----------------------------
|
||||
if rate_id:
|
||||
rate = SubcontractorRate.query.get_or_404(rate_id)
|
||||
else:
|
||||
rate = SubcontractorRate()
|
||||
|
||||
rate.subcontractor_id = subcontractor_id
|
||||
rate.category = category
|
||||
rate.item_code = form.get("item_code")
|
||||
rate.item_name = 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")
|
||||
|
||||
if not rate_id:
|
||||
db.session.add(rate)
|
||||
|
||||
db.session.commit()
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"message": "Saved Successfully."
|
||||
}
|
||||
|
||||
@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)
|
||||
|
||||
def delete_rate(rate_id):
|
||||
rate = SubcontractorRate.query.get_or_404(rate_id)
|
||||
db.session.delete(rate)
|
||||
db.session.commit()
|
||||
|
||||
|
||||
@staticmethod
|
||||
def check_duplicate(subcontractor_id, category, item_name, rate_id=None):
|
||||
|
||||
query = SubcontractorRate.query.filter(
|
||||
SubcontractorRate.subcontractor_id == subcontractor_id,
|
||||
SubcontractorRate.category == category,
|
||||
func.lower(SubcontractorRate.item_name) == item_name.strip().lower()
|
||||
)
|
||||
|
||||
if rate_id:
|
||||
query = query.filter(SubcontractorRate.id != int(rate_id))
|
||||
|
||||
return query.first() is not None
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -124,15 +124,10 @@
|
||||
<i class="bi bi-arrow-left-right me-2"></i> Client vs Subcontractor
|
||||
</a>
|
||||
</li>
|
||||
<!-- <li>
|
||||
<a class="dropdown-item" href="/file/client_vs_subcont">
|
||||
<i class="bi bi-arrow-left-right me-2"></i> Comparison Report
|
||||
</a>
|
||||
</li> -->
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
<!-- Formats -->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/file_format">
|
||||
@@ -140,50 +135,98 @@
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<!-- USER DROPDOWN -->
|
||||
{% if session.get("user_id") %}
|
||||
<li class="nav-item dropdown ms-lg-3">
|
||||
<!-- Masters -->
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="/engi">
|
||||
<i class="bi bi-gear me-2"></i> Masters
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-dark">
|
||||
<!-- Client Standard Rates -->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/engi/subcontractor-rate">
|
||||
<i class="bi bi-file-earmark-text me-1"></i> Rate Master
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<a class="nav-link dropdown-toggle d-flex align-items-center gap-2" href="#"
|
||||
data-bs-toggle="dropdown">
|
||||
<i class="bi bi-person-circle fs-5"></i>
|
||||
<span class="d-none d-lg-inline">
|
||||
<!-- Client Standard Rates -->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/engi/client-rate">
|
||||
<i class="bi bi-file-earmark-text me-1"></i> Client Rates
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
<!-- USER DROPDOWN -->
|
||||
<li class="nav-item dropdown">
|
||||
|
||||
<a class="nav-link dropdown-toggle d-flex align-items-center text-white"
|
||||
href="#" id="profileDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
|
||||
<i class="bi bi-person-circle fs-4"></i>
|
||||
<span class="ms-2 fw-semibold">
|
||||
{{ session.get("user_name") }}
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<ul class="dropdown-menu dropdown-menu-end dropdown-menu-dark shadow">
|
||||
<ul class="dropdown-menu dropdown-menu-end dropdown-menu-dark border-0 shadow-lg bg-dark p-0"
|
||||
style="width:320px;">
|
||||
|
||||
<!-- User card -->
|
||||
<li class="px-3 py-3 text-center border-bottom">
|
||||
<i class="bi bi-person-circle fs-1"></i>
|
||||
<div class="fw-semibold mt-1">
|
||||
<!-- Profile Header -->
|
||||
<li class="text-center py-4 border-bottom border-secondary">
|
||||
<i class="bi bi-person-circle text-light" style="font-size:60px;"></i>
|
||||
<h5 class="mt-2 mb-0 fw-bold">
|
||||
{{ session.get("user_name") }}
|
||||
</div>
|
||||
<small class="text-muted">Logged in user</small>
|
||||
</h5>
|
||||
<small class="text-secondary">
|
||||
{{ session.get("email") }}
|
||||
</small>
|
||||
</li>
|
||||
|
||||
<!-- Masters -->
|
||||
<li>
|
||||
<a class="dropdown-item" href="/dashboard">
|
||||
<i class="bi bi-speedometer2 me-2"></i> Dashboard
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item" href="{{ url_for('activity.activity') }}">
|
||||
<i class="bi bi-clock-history me-2"></i>
|
||||
Activity Log
|
||||
<a class="dropdown-item text-light py-2" href="{{ url_for('engineering.engineering_master') }}">
|
||||
<i class="bi bi-gear me-2"></i> Masters
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<!-- Activity Log page -->
|
||||
<li>
|
||||
<a class="dropdown-item text-warning" href="/logout">
|
||||
<i class="bi bi-box-arrow-right me-2"></i> Logout
|
||||
<a class="dropdown-item text-light py-2" href="{{ url_for('activity.activity') }}">
|
||||
<i class="bi bi-clock-history me-2"></i> Activity Log
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<!-- Manage Account
|
||||
<li>
|
||||
<a class="dropdown-item py-2" href="#">
|
||||
<i class="bi bi-gear me-2"></i> Manage Account
|
||||
</a>
|
||||
</li>
|
||||
-->
|
||||
|
||||
<li><hr class="dropdown-divider border-secondary m-0"></li>
|
||||
|
||||
<!-- Logout Account -->
|
||||
<li>
|
||||
<a class="dropdown-item text-warning py-2" href="{{ url_for('auth.logout') }}">
|
||||
<i class="bi bi-box-arrow-right me-2"></i>
|
||||
Logout
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<!-- Footer -->
|
||||
<li class="text-center py-3 bg-secondary bg-opacity-10 border-top border-secondary">
|
||||
<small class="text-light">
|
||||
<i class="bi bi-shield-check text-success"></i>
|
||||
Secured by <strong>LCEPL</strong>
|
||||
</small>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -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 %}
|
||||
20
app/templates/engineering/client_rate.html
Normal file
20
app/templates/engineering/client_rate.html
Normal file
@@ -0,0 +1,20 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
|
||||
<div class="container-fluid mt-4">
|
||||
|
||||
<div class="card shadow">
|
||||
|
||||
<div class="card-header bg-primary text-white d-flex justify-content-between align-items-center">
|
||||
|
||||
<h4 class="mb-0">
|
||||
<i class="bi bi-currency-rupee"></i>
|
||||
Client Rate Master
|
||||
</h4>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
384
app/templates/engineering/contractor_rate.html
Normal file
384
app/templates/engineering/contractor_rate.html
Normal file
@@ -0,0 +1,384 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
|
||||
<div class="container-fluid mt-4">
|
||||
|
||||
<div class="card shadow">
|
||||
|
||||
<div class="card-header bg-primary text-white d-flex justify-content-between align-items-center">
|
||||
|
||||
<h4 class="mb-0">
|
||||
<i class="bi bi-currency-rupee"></i>
|
||||
Subcontractor Rate Master
|
||||
</h4>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
|
||||
<form method="POST" id="rateForm">
|
||||
|
||||
<!-- Hidden ID -->
|
||||
<input type="hidden" id="rate_id" name="id" value="{{ rate.id if rate else '' }}">
|
||||
|
||||
<div class="row">
|
||||
|
||||
<!-- Subcontractor -->
|
||||
<div class="col-md-4 mb-3">
|
||||
<label class="form-label fw-bold"> Subcontractor </label>
|
||||
<select id="subcontractor_id" name="subcontractor_id" class="form-select" required>
|
||||
<option value="">-- Select Subcontractor --</option>
|
||||
{% for sub in subcontractors %}
|
||||
<option value="{{ sub.id }}"
|
||||
{% if rate and rate.subcontractor_id==sub.id %}
|
||||
selected
|
||||
{% endif %}>
|
||||
{{ sub.subcontractor_name }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Category -->
|
||||
<div class="col-md-4 mb-3">
|
||||
<label class="form-label fw-bold"> Category </label>
|
||||
<select id="category" name="category" class="form-select" required>
|
||||
<option value="">-- Select Category --</option>
|
||||
|
||||
<option value="trench_excavation"
|
||||
{% if rate and rate.category=="trench_excavation" %}selected{% endif %}>
|
||||
Trench Excavation
|
||||
</option>
|
||||
<option value="manhole_excavation"
|
||||
{% if rate and rate.category=="manhole_excavation" %}selected{% endif %}>
|
||||
Manhole Excavation
|
||||
</option>
|
||||
|
||||
<option value="Manhole_Domestic_Chamber"
|
||||
{% if rate and rate.category=="Manhole_Domestic_Chamber" %}selected{% endif %}>
|
||||
MH & Domestic Chamber
|
||||
</option>
|
||||
|
||||
<option value="Laying"
|
||||
{% if rate and rate.category=="Laying" %}selected{% endif %}>
|
||||
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"
|
||||
{% if not rate or rate.status=="Active" %}selected{% endif %}>
|
||||
Active
|
||||
</option>
|
||||
|
||||
<option value="Inactive"
|
||||
{% if rate and rate.status=="Inactive" %}selected{% endif %}>
|
||||
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" value="{{ rate.item_code if rate else '' }}" required>
|
||||
</div>
|
||||
|
||||
<!-- Item Name -->
|
||||
<div class="col-md-5 mb-3">
|
||||
<label class="form-label fw-bold"> Item Name </label>
|
||||
<input type="text"
|
||||
id="item_name"
|
||||
name="item_name"
|
||||
class="form-control"
|
||||
autocomplete="off"
|
||||
value="{{ rate.item_name if rate else '' }}"
|
||||
required>
|
||||
|
||||
<small id="duplicateMessage"
|
||||
class="text-danger"
|
||||
style="display:none;">
|
||||
</small>
|
||||
</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"
|
||||
{% if not rate or rate.unit=="Cum" %}selected{% endif %}>
|
||||
Cum
|
||||
</option>
|
||||
<option value="Nos"
|
||||
{% if rate and rate.unit=="Nos" %}selected{% endif %}>
|
||||
Nos
|
||||
</option>
|
||||
<option value="Rmt"
|
||||
{% if rate and rate.unit=="Rmt" %}selected{% endif %}>
|
||||
Rmt
|
||||
</option>
|
||||
<option value="Sqm"
|
||||
{% if rate and rate.unit=="Sqm" %}selected{% endif %}>
|
||||
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" name="rate" class="form-control" value="{{ rate.rate if rate else '' }}" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<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" value="{{ rate.effective_from if rate else '' }}" required>
|
||||
</div>
|
||||
|
||||
<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" value="{{ rate.effective_to if rate else '' }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="text-end">
|
||||
<a href="{{ url_for('engineering.add_subcontractor_rates') }}" class="btn btn-secondary">
|
||||
<i class="bi bi-arrow-clockwise"></i> Reset
|
||||
</a>
|
||||
|
||||
<button type="submit" id="saveBtn" class="btn btn-success">
|
||||
{% if rate %}
|
||||
<i class="bi bi-pencil-square"></i>
|
||||
Update Rate
|
||||
{% else %}
|
||||
<i class="bi bi-check-circle"></i>
|
||||
Save Rate
|
||||
{% endif %}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Table -->
|
||||
<div class="card shadow mt-4">
|
||||
<div class="card-header bg-dark text-white">
|
||||
<h5 class="mb-0">
|
||||
<i class="bi bi-table"></i>Rate List
|
||||
</h5>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<table class="table table-bordered table-hover table-striped" id="rateTable">
|
||||
<thead class="table-primary">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Subcontractor</th>
|
||||
<th>Category</th>
|
||||
<th>Item Code</th>
|
||||
<th>Item Name</th>
|
||||
<th>Unit</th>
|
||||
<th>Rate</th>
|
||||
<th>Status</th>
|
||||
<th width="130">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{% for row in rates %}
|
||||
<tr>
|
||||
<td>{{ loop.index }}</td>
|
||||
<td>{{ row.subcontractor.subcontractor_name }}</td>
|
||||
<td>{{ row.category }}</td>
|
||||
<td>{{ row.item_code }}</td>
|
||||
<td>{{ row.item_name }}</td>
|
||||
<td>{{ row.unit }}</td>
|
||||
<td>{{ row.rate }}</td>
|
||||
<td>
|
||||
{% if row.status=="Active" %}
|
||||
<span class="badge bg-success">
|
||||
Active
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="badge bg-danger">
|
||||
Inactive
|
||||
</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<a href="{{ url_for('engineering.edit_rate', rate_id=row.id) }}" class="btn btn-warning btn-sm">
|
||||
<i class="bi bi-pencil-square"></i>
|
||||
</a>
|
||||
|
||||
<a href="{{ url_for('engineering.delete_rate', rate_id=row.id) }}"
|
||||
class="btn btn-danger btn-sm" onclick="return confirm('Delete this Item:{{row.item_name}} & Rate:{{row.rate}} ?')">
|
||||
<i class="bi bi-trash"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
// ----------------------------
|
||||
// DataTable
|
||||
// ----------------------------
|
||||
$("#rateTable").DataTable({
|
||||
responsive: true,
|
||||
pageLength: 10,
|
||||
destroy: true
|
||||
});
|
||||
|
||||
// ----------------------------
|
||||
// Validate on field change
|
||||
// ----------------------------
|
||||
$("#subcontractor_id, #category").on("change", function () {
|
||||
clearValidation();
|
||||
checkDuplicateRate();
|
||||
|
||||
});
|
||||
|
||||
// ----------------------------
|
||||
// Validate while typing
|
||||
// ----------------------------
|
||||
let timer;
|
||||
|
||||
$("#item_name").on("keyup input", function () {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(function () {
|
||||
checkDuplicateRate();
|
||||
}, 300);
|
||||
|
||||
});
|
||||
|
||||
// Edit Mode
|
||||
checkDuplicateRate();
|
||||
|
||||
// ----------------------------
|
||||
// Prevent Submit
|
||||
// ----------------------------
|
||||
$("#rateForm").submit(function (e) {
|
||||
|
||||
if ($("#saveBtn").prop("disabled")) {
|
||||
e.preventDefault();
|
||||
$("#item_name").focus();
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
//=========================================
|
||||
// Reset Validation
|
||||
//=========================================
|
||||
function clearValidation() {
|
||||
$("#duplicateMessage")
|
||||
.hide()
|
||||
.text("")
|
||||
.removeClass("text-success text-danger");
|
||||
|
||||
$("#item_name")
|
||||
.removeClass("is-valid is-invalid");
|
||||
$("#saveBtn").prop("disabled", false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=========================================
|
||||
// Duplicate Validation
|
||||
//=========================================
|
||||
function checkDuplicateRate() {
|
||||
let subcontractor = $("#subcontractor_id").val();
|
||||
let category = $("#category").val();
|
||||
let item_name = $("#item_name").val().trim();
|
||||
let rate_id = $("#rate_id").val();
|
||||
|
||||
// Mandatory fields
|
||||
if (
|
||||
subcontractor == "" ||
|
||||
category == "" ||
|
||||
item_name.length < 2
|
||||
) {
|
||||
clearValidation();
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
|
||||
url: "{{ url_for('engineering.check_rate') }}",
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
data: {
|
||||
subcontractor_id: subcontractor,
|
||||
category: category,
|
||||
item_name: item_name,
|
||||
rate_id: rate_id
|
||||
},
|
||||
|
||||
success: function (response) {
|
||||
if (response.exists) {
|
||||
$("#duplicateMessage")
|
||||
.text("This Item Name already exists for the selected Subcontractor and Category.")
|
||||
.removeClass("text-success")
|
||||
.addClass("text-danger")
|
||||
.show();
|
||||
|
||||
$("#item_name")
|
||||
.removeClass("is-valid")
|
||||
.addClass("is-invalid");
|
||||
|
||||
$("#saveBtn").prop("disabled", true);
|
||||
|
||||
}
|
||||
else {
|
||||
$("#duplicateMessage")
|
||||
.text("Item Name is available.")
|
||||
.removeClass("text-danger")
|
||||
.addClass("text-success")
|
||||
.show();
|
||||
|
||||
$("#item_name")
|
||||
.removeClass("is-invalid")
|
||||
.addClass("is-valid");
|
||||
|
||||
$("#saveBtn").prop("disabled", false);
|
||||
}
|
||||
},
|
||||
|
||||
error: function () {
|
||||
clearValidation();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
{% 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>
|
||||
|
||||
<input
|
||||
type="email"
|
||||
type="text"
|
||||
name="email"
|
||||
class="form-control"
|
||||
placeholder="Enter Email"
|
||||
placeholder="Enter Domain Username"
|
||||
autocomplete="username"
|
||||
required>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,50 +1,170 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
|
||||
<div class="card shadow-sm p-4">
|
||||
<h4 class="mb-3">Add New Subcontractor</h4>
|
||||
<div class="container-fluid">
|
||||
|
||||
<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>
|
||||
<!-- Page Header -->
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h3 class="fw-bold mb-1">
|
||||
<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 class="mb-3">
|
||||
<label class="form-label">Contact Person Name:</label>
|
||||
<input type="text" class="form-control" name="contact_person">
|
||||
<a href="{{ url_for('subcontractor.subcontractor_list') }}"
|
||||
class="btn btn-outline-secondary">
|
||||
<i class="bi bi-arrow-left me-2"></i>
|
||||
Back to List
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Address:</label>
|
||||
<textarea type="text" class="form-control" name="address"></textarea>
|
||||
<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 class="mb-3">
|
||||
<label class="form-label">Mobile No:</label>
|
||||
<input type="text" class="form-control" name="mobile_no">
|
||||
<div class="card-body">
|
||||
|
||||
<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>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Email:</label>
|
||||
<input type="email" class="form-control" name="email_id">
|
||||
<!-- 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>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">GST No:</label>
|
||||
<input type="text" class="form-control" name="gst_no">
|
||||
<!-- 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>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">PAN No:</label>
|
||||
<input type="text" class="form-control" name="pan_no">
|
||||
<!-- 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>
|
||||
|
||||
<button class="btn btn-success">Save</button>
|
||||
<a href="{{ url_for('subcontractor.subcontractor_list') }}" class="btn btn-secondary">Back</a>
|
||||
<!-- 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>
|
||||
|
||||
{% endblock %}
|
||||
@@ -88,7 +88,7 @@
|
||||
|
||||
<option value="dc"
|
||||
{% if request.form.get('category')=='dc' %}selected{% endif %}>
|
||||
Domestic Chamber
|
||||
Manhole Domestic Chamber
|
||||
</option>
|
||||
|
||||
<option value="laying"
|
||||
|
||||
@@ -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