Compare commits
4 Commits
e98e1422a0
...
prajakta-d
| Author | SHA1 | Date | |
|---|---|---|---|
| b380ed510b | |||
| e7805b71a8 | |||
| aa759c9d96 | |||
| bc4b9c778e |
15
.env
15
.env
@@ -4,7 +4,7 @@
|
||||
FLASK_ENV=development
|
||||
FLASK_DEBUG=True
|
||||
FLASK_HOST=0.0.0.0
|
||||
FLASK_PORT=5015
|
||||
FLASK_PORT=5011
|
||||
|
||||
# -----------------------------
|
||||
# Security
|
||||
@@ -23,4 +23,17 @@ DB_USER=root
|
||||
DB_PASSWORD=root
|
||||
|
||||
# DATABASE_URL=mysql+pymysql://root:root@localhost/comparisondb
|
||||
# -----------------------------
|
||||
# LDAP Configuration
|
||||
# -----------------------------
|
||||
USE_LDAP_AUTH=true
|
||||
|
||||
LDAP_URL=ldap://192.168.0.25:389
|
||||
LDAP_BIND_DN=cn=admin,dc=lcepl,dc=org
|
||||
LDAP_BIND_PASSWORD=Lcepl1950@2026
|
||||
LDAP_BASE_DN=dc=lcepl,dc=org
|
||||
LDAP_DOMAIN=lcepl.org
|
||||
|
||||
# OpenLDAP standard username attribute
|
||||
LDAP_SEARCH_FILTER=(uid={username})
|
||||
|
||||
|
||||
@@ -5,20 +5,23 @@ WORKDIR /app
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
gcc \
|
||||
default-libmysqlclient-dev \
|
||||
pkg-config \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy requirements and install Python dependencies
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
RUN pip install --no-cache-dir -r requirements.txt gunicorn
|
||||
|
||||
# Copy application code
|
||||
COPY . .
|
||||
|
||||
# Create necessary directories
|
||||
RUN mkdir -p app/logs app/static/uploads app/static/downloads
|
||||
ENV FLASK_APP=run.py
|
||||
|
||||
# Expose port
|
||||
EXPOSE 5001
|
||||
|
||||
# Run the application
|
||||
CMD ["python", "run.py"]
|
||||
# Run the application with Gunicorn (production WSGI server)
|
||||
CMD ["gunicorn", "--bind", "0.0.0.0:5001", "run:app"]
|
||||
@@ -1,6 +1,6 @@
|
||||
from flask import Flask, redirect, url_for
|
||||
from app.config import Config
|
||||
from app.services.db_service import db
|
||||
from app.services.db_service import db, migrate
|
||||
from app.services.logger_service import LoggerService
|
||||
|
||||
def create_app():
|
||||
@@ -9,6 +9,9 @@ def create_app():
|
||||
|
||||
# Initialize extensions
|
||||
db.init_app(app)
|
||||
migrate.init_app(app, db)
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
|
||||
# Initialize Logger
|
||||
LoggerService.init_app(app)
|
||||
@@ -35,10 +38,7 @@ def register_blueprints(app):
|
||||
from app.routes.file_report import file_report_bp
|
||||
from app.routes.generate_comparison_report import generate_report_bp
|
||||
from app.routes.file_format import file_format_bp
|
||||
|
||||
# new
|
||||
from app.routes.activity_routes import activity_bp
|
||||
from app.routes.engineering import engi_bp
|
||||
|
||||
app.register_blueprint(auth_bp)
|
||||
app.register_blueprint(user_bp)
|
||||
@@ -47,11 +47,8 @@ def register_blueprints(app):
|
||||
app.register_blueprint(file_import_bp)
|
||||
app.register_blueprint(file_report_bp)
|
||||
app.register_blueprint(generate_report_bp)
|
||||
app.register_blueprint(file_format_bp)
|
||||
|
||||
# new
|
||||
app.register_blueprint(file_format_bp )
|
||||
app.register_blueprint(activity_bp)
|
||||
app.register_blueprint(engi_bp)
|
||||
|
||||
|
||||
def register_error_handlers(app):
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import os
|
||||
# project base url
|
||||
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
class Config:
|
||||
# secret key
|
||||
@@ -21,4 +23,23 @@ class Config:
|
||||
)
|
||||
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
# uploads folder path
|
||||
UPLOAD_FOLDER = os.path.join(BASE_DIR, "static", "uploads")
|
||||
# file extension
|
||||
ALLOWED_EXTENSIONS = {"xlsx", "xls", "csv"}
|
||||
|
||||
# ---------------- LDAP settings ----------------
|
||||
USE_LDAP_AUTH = os.getenv("USE_LDAP_AUTH", "false").lower() == "true"
|
||||
# e.g. "ldap://192.168.0.25:389" or "ldaps://192.168.0.25:636" (preferred, encrypted)
|
||||
LDAP_SERVER = os.getenv("LDAP_URL", "ldap://192.168.0.25:389")
|
||||
# Service/admin account used only to SEARCH for a user's real DN.
|
||||
# The user's own password is never used for this bind.
|
||||
LDAP_BIND_DN = os.getenv("LDAP_BIND_DN", "cn=admin,dc=lcepl,dc=org")
|
||||
LDAP_BIND_PASSWORD = os.getenv("LDAP_BIND_PASSWORD", "")
|
||||
# Base DN to search for user entries under
|
||||
LDAP_BASE_DN = os.getenv("LDAP_BASE_DN", "dc=lcepl,dc=org")
|
||||
# Used only as a fallback to build an email if the directory entry has none
|
||||
LDAP_DOMAIN = os.getenv("LDAP_DOMAIN", "lcepl.org")
|
||||
# Filter used to find the user's entry by their login username.
|
||||
# Standard OpenLDAP attribute is "uid". Active Directory would use sAMAccountName.
|
||||
LDAP_SEARCH_FILTER = os.getenv("LDAP_SEARCH_FILTER", "(uid={username})")
|
||||
|
||||
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}>"
|
||||
|
||||
@@ -7,10 +7,13 @@ class User(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String(200), nullable=False)
|
||||
email = db.Column(db.String(120), unique=True, nullable=False)
|
||||
password_hash = db.Column(db.String(255), nullable=False)
|
||||
password_hash = db.Column(db.String(255), nullable=True)
|
||||
auth_source = db.Column(db.String(20), nullable=False, default="local")
|
||||
|
||||
def set_password(self, password):
|
||||
self.password_hash = generate_password_hash(password)
|
||||
|
||||
def check_password(self, password):
|
||||
if not self.password_hash:
|
||||
return False
|
||||
return check_password_hash(self.password_hash, password)
|
||||
|
||||
@@ -1,97 +1,49 @@
|
||||
from flask import (Blueprint, render_template, request, redirect, url_for, flash, session, current_app)
|
||||
|
||||
from flask import Blueprint, render_template, request, redirect, url_for, flash, session
|
||||
from app.services.user_service import UserService
|
||||
from app.constants.messages import SuccessMessage, ErrorMessage
|
||||
from app.constants.http_status import HTTPStatus
|
||||
|
||||
auth_bp = Blueprint("auth", __name__)
|
||||
|
||||
|
||||
# ==========================
|
||||
# LOGIN
|
||||
# ==========================
|
||||
@auth_bp.route("/login", methods=["GET", "POST"])
|
||||
def login():
|
||||
|
||||
if session.get("user_id"):
|
||||
current_app.logger.info("User already logged in.")
|
||||
return redirect(url_for("dashboard.dashboard"))
|
||||
|
||||
if request.method == "POST":
|
||||
email = request.form.get("email")
|
||||
password = request.form.get("password")
|
||||
|
||||
try:
|
||||
email = request.form.get("email", "").strip()
|
||||
password = request.form.get("password", "")
|
||||
user = UserService.validate_login(email, password)
|
||||
if user:
|
||||
session["user_id"] = user.id
|
||||
session["user_name"] = user.name
|
||||
session["user_email"] = user.email
|
||||
flash("Login successful", "success")
|
||||
return redirect(url_for("dashboard.dashboard"))
|
||||
|
||||
if not email or not password:
|
||||
flash(ErrorMessage.INVALID_REQUEST, "danger")
|
||||
current_app.logger.warning("Login failed. Email or password missing.")
|
||||
return render_template("login.html", title="Login")
|
||||
|
||||
user = UserService.validate_login(email, password)
|
||||
|
||||
if user:
|
||||
session.clear()
|
||||
session["user_id"] = user.id
|
||||
session["user_name"] = user.name
|
||||
session.permanent = True
|
||||
|
||||
current_app.logger.info(f"Login successful. User={user.name}")
|
||||
flash(SuccessMessage.LOGIN, "success")
|
||||
return redirect(url_for("dashboard.dashboard"))
|
||||
|
||||
current_app.logger.warning(f"Invalid login attempt. Email={email}")
|
||||
flash(ErrorMessage.LOGIN_FAILED,"danger")
|
||||
|
||||
except Exception as e:
|
||||
current_app.logger.exception("Login Error" )
|
||||
flash(ErrorMessage.INTERNAL_SERVER_ERROR,"danger")
|
||||
flash("Invalid email or password", "danger")
|
||||
|
||||
return render_template("login.html", title="Login")
|
||||
|
||||
|
||||
# ==========================
|
||||
# LOGOUT
|
||||
# ==========================
|
||||
@auth_bp.route("/logout")
|
||||
def logout():
|
||||
username = session.get("user_name", "Unknown")
|
||||
session.clear()
|
||||
current_app.logger.info(f"Logout successful. User={username}")
|
||||
flash(SuccessMessage.LOGOUT,"info")
|
||||
|
||||
flash("Logged out successfully", "info")
|
||||
return redirect(url_for("auth.login"))
|
||||
|
||||
|
||||
# ==========================
|
||||
# REGISTER
|
||||
# ==========================
|
||||
@auth_bp.route("/register", methods=["GET", "POST"])
|
||||
def register():
|
||||
|
||||
if request.method == "POST":
|
||||
try:
|
||||
name = request.form.get("name", "").strip()
|
||||
email = request.form.get("email", "").strip()
|
||||
password = request.form.get("password", "")
|
||||
name = request.form.get("name")
|
||||
email = request.form.get("email")
|
||||
password = request.form.get("password")
|
||||
|
||||
if not name or not email or not password:
|
||||
flash(ErrorMessage.INVALID_REQUEST,"danger")
|
||||
return redirect(url_for("auth.register"))
|
||||
user = UserService.register_user(name, email, password)
|
||||
if not user:
|
||||
flash("Email already exists", "danger")
|
||||
return redirect(url_for("auth.register"))
|
||||
|
||||
user = UserService.register_user(name, email, password)
|
||||
flash("User registered successfully", "success")
|
||||
return redirect(url_for("auth.login"))
|
||||
|
||||
if not user:
|
||||
current_app.logger.warning(f"Duplicate Registration: {email}")
|
||||
flash(ErrorMessage.DUPLICATE_ENTRY,"danger")
|
||||
return redirect(url_for("auth.register"))
|
||||
|
||||
current_app.logger.info(f"New user registered: {email}")
|
||||
flash(SuccessMessage.CREATED,"success")
|
||||
return redirect(url_for("auth.login"))
|
||||
|
||||
except Exception:
|
||||
current_app.logger.exception("User Registration Failed" )
|
||||
flash(ErrorMessage.INTERNAL_SERVER_ERROR,"danger")
|
||||
|
||||
return render_template("register.html",title="Register")
|
||||
return render_template("register.html", title="Register")
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
72
app/services/ldap_service.py
Normal file
72
app/services/ldap_service.py
Normal file
@@ -0,0 +1,72 @@
|
||||
from flask import current_app
|
||||
from ldap3 import Server, Connection, ALL, SUBTREE
|
||||
from ldap3.core.exceptions import LDAPException
|
||||
|
||||
|
||||
class LDAPService:
|
||||
"""
|
||||
Handles authentication against an LDAP / OpenLDAP server using the
|
||||
standard "search + bind" pattern:
|
||||
1. Bind with a service/admin account just to SEARCH for the user's DN.
|
||||
2. Re-bind using that DN + the password the user typed, to verify it.
|
||||
The user's typed password is only ever used in step 2, never sent
|
||||
anywhere else.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def authenticate(username, password):
|
||||
if not username or not password:
|
||||
return None
|
||||
|
||||
server = Server(current_app.config["LDAP_SERVER"], get_info=ALL)
|
||||
|
||||
# --- Step 1: bind as the admin/service account to search the directory ---
|
||||
try:
|
||||
admin_conn = Connection(
|
||||
server,
|
||||
user=current_app.config["LDAP_BIND_DN"],
|
||||
password=current_app.config["LDAP_BIND_PASSWORD"],
|
||||
auto_bind=True,
|
||||
)
|
||||
except LDAPException as e:
|
||||
current_app.logger.error(f"LDAP service account bind failed: {e}")
|
||||
return None
|
||||
|
||||
# --- Step 2: find the user's real DN + profile attributes ---
|
||||
try:
|
||||
search_filter = current_app.config["LDAP_SEARCH_FILTER"].format(username=username)
|
||||
admin_conn.search(
|
||||
search_base=current_app.config["LDAP_BASE_DN"],
|
||||
search_filter=search_filter,
|
||||
search_scope=SUBTREE,
|
||||
attributes=["cn", "mail", "uid"],
|
||||
)
|
||||
except LDAPException as e:
|
||||
current_app.logger.error(f"LDAP search failed for '{username}': {e}")
|
||||
admin_conn.unbind()
|
||||
return None
|
||||
|
||||
if not admin_conn.entries:
|
||||
current_app.logger.warning(f"LDAP user not found: {username}")
|
||||
admin_conn.unbind()
|
||||
return None
|
||||
|
||||
entry = admin_conn.entries[0]
|
||||
user_dn = entry.entry_dn
|
||||
name = str(entry.cn) if "cn" in entry and entry.cn.value else username
|
||||
email = (
|
||||
str(entry.mail)
|
||||
if "mail" in entry and entry.mail.value
|
||||
else f"{username}@{current_app.config['LDAP_DOMAIN']}"
|
||||
)
|
||||
admin_conn.unbind()
|
||||
|
||||
# --- Step 3: the actual auth check - bind AS the user with their password ---
|
||||
try:
|
||||
user_conn = Connection(server, user=user_dn, password=password, auto_bind=True)
|
||||
user_conn.unbind()
|
||||
except LDAPException as e:
|
||||
current_app.logger.warning(f"LDAP authentication failed for '{username}': {e}")
|
||||
return None
|
||||
|
||||
return {"username": username, "name": name, "email": email}
|
||||
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()
|
||||
@@ -1,6 +1,7 @@
|
||||
from flask import current_app
|
||||
from app.models.user_model import User
|
||||
from app.services.db_service import db
|
||||
from flask import current_app
|
||||
from app.services.ldap_service import LDAPService
|
||||
|
||||
class UserService:
|
||||
|
||||
@@ -9,21 +10,57 @@ class UserService:
|
||||
if User.query.filter_by(email=email).first():
|
||||
return None
|
||||
|
||||
user = User(name=name, email=email)
|
||||
user = User(name=name, email=email, auth_source="local")
|
||||
user.set_password(password)
|
||||
|
||||
db.session.add(user)
|
||||
db.session.commit()
|
||||
current_app.logger.info("User list viewed")
|
||||
return user
|
||||
|
||||
@staticmethod
|
||||
def validate_login(email, password):
|
||||
user = User.query.filter_by(email=email).first()
|
||||
def validate_login(identifier, password):
|
||||
"""
|
||||
identifier = whatever was typed in the login form. Can be an email
|
||||
(local users) or an LDAP username, depending on USE_LDAP_AUTH.
|
||||
"""
|
||||
if current_app.config.get("USE_LDAP_AUTH"):
|
||||
ldap_user = UserService._validate_ldap_login(identifier, password)
|
||||
if ldap_user:
|
||||
return ldap_user
|
||||
return None
|
||||
user = User.query.filter_by(email=identifier).first()
|
||||
if user and user.check_password(password):
|
||||
return user
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def _validate_ldap_login(username, password):
|
||||
ldap_info = LDAPService.authenticate(username, password)
|
||||
if not ldap_info:
|
||||
return None
|
||||
return UserService._get_or_create_ldap_user(ldap_info)
|
||||
|
||||
@staticmethod
|
||||
def _get_or_create_ldap_user(ldap_info):
|
||||
"""
|
||||
LDAP is the source of truth for the password. We still keep a row in
|
||||
our local `users` table (no password) so the rest of the app - which
|
||||
expects a User with an id - keeps working unchanged.
|
||||
"""
|
||||
user = User.query.filter_by(email=ldap_info["email"]).first()
|
||||
if user is None:
|
||||
user = User(
|
||||
name=ldap_info["name"],
|
||||
email=ldap_info["email"],
|
||||
auth_source="ldap",
|
||||
)
|
||||
db.session.add(user)
|
||||
db.session.commit()
|
||||
elif user.name != ldap_info["name"]:
|
||||
user.name = ldap_info["name"]
|
||||
db.session.commit()
|
||||
return user
|
||||
|
||||
@staticmethod
|
||||
def get_all_users():
|
||||
return User.query.all()
|
||||
|
||||
@@ -124,66 +124,109 @@
|
||||
<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
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<!-- 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> -->
|
||||
</li>
|
||||
|
||||
<!-- 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 Standard Rates
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<!-- Formats -->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/file_format">
|
||||
<i class="bi bi-file-earmark-text me-1"></i> Formats
|
||||
</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
<!-- Formats -->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/file_format">
|
||||
<i class="bi bi-file-earmark-text me-1"></i> Formats
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<!-- USER DROPDOWN -->
|
||||
{% if session.get("user_id") %}
|
||||
<li class="nav-item dropdown ms-lg-3">
|
||||
<li class="nav-item dropdown">
|
||||
|
||||
<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">
|
||||
<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>
|
||||
|
||||
<!-- Dashboard -->
|
||||
<li>
|
||||
<a class="dropdown-item" href="/dashboard">
|
||||
<a class="dropdown-item text-light py-2" href="{{ url_for('dashboard.dashboard') }}">
|
||||
<i class="bi bi-speedometer2 me-2"></i> Dashboard
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<!-- Activity Log page -->
|
||||
<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('activity.activity') }}">
|
||||
<i class="bi bi-clock-history me-2"></i> Activity Log
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<!-- Manage Account -->
|
||||
<li>
|
||||
<a class="dropdown-item text-warning" href="/logout">
|
||||
<i class="bi bi-box-arrow-right me-2"></i> Logout
|
||||
<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 %}
|
||||
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>
|
||||
|
||||
<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="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">Address:</label>
|
||||
<textarea type="text" class="form-control" name="address"></textarea>
|
||||
<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>
|
||||
|
||||
<!-- 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 class="mb-3">
|
||||
<label class="form-label">Mobile No:</label>
|
||||
<input type="text" class="form-control" name="mobile_no">
|
||||
</div>
|
||||
</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 %}
|
||||
@@ -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 %}
|
||||
@@ -17,9 +17,11 @@ services:
|
||||
build: .
|
||||
container_name: comparison_app
|
||||
restart: always
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
FLASK_ENV: development
|
||||
FLASK_DEBUG: "True"
|
||||
FLASK_ENV: production
|
||||
FLASK_DEBUG: "False"
|
||||
FLASK_HOST: "0.0.0.0"
|
||||
FLASK_PORT: "5001"
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
Flask
|
||||
ldap3
|
||||
pandas
|
||||
openpyxl
|
||||
xlrd
|
||||
@@ -9,4 +10,3 @@ xlsxwriter
|
||||
matplotlib
|
||||
flask_sqlalchemy
|
||||
flask_migrate
|
||||
weasyprint
|
||||
4
run.py
4
run.py
@@ -1,15 +1,11 @@
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
from app import create_app
|
||||
from app.services.db_service import db
|
||||
import os
|
||||
|
||||
app = create_app()
|
||||
|
||||
if __name__ == "__main__":
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
|
||||
app.run(
|
||||
host=os.getenv("FLASK_HOST"),
|
||||
port=int(os.getenv("FLASK_PORT")),
|
||||
|
||||
Reference in New Issue
Block a user