Merge pull request 'dataase field updateds and model updateds' (#12) from pankaj-dev into main

Reviewed-on: #12
This commit was merged in pull request #12.
This commit is contained in:
2026-03-11 08:04:07 +00:00
17 changed files with 391 additions and 440 deletions

View File

@@ -36,6 +36,11 @@
<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>

View File

@@ -37,6 +37,23 @@
<input type="text" class="form-control" name="gst_no" value="{{ subcontractor.gst_no }}">
</div>
<div class="mb-3">
<label class="form-label">PAN No:</label>
<input type="text" class="form-control" name="pan_no" value="{{ subcontractor.pan_no }}">
</div>
<div class="mb-3">
<label class="form-label">Status:</label>
<select name="status" class="form-control">
<option value="Active" {% if subcontractor.status=="Active" %}selected{% endif %}>
Active
</option>
<option value="Inactive" {% if subcontractor.status=="Inactive" %}selected{% endif %}>
Inactive
</option>
</select>
</div>
<button class="btn btn-success">Update</button>
<a href="{{ url_for('subcontractor.subcontractor_list') }}" class="btn btn-secondary">Back</a>

View File

@@ -19,9 +19,9 @@
<table class="table table-bordered table-hover align-middle">
<thead class="table-dark">
<tr>
<th>ID</th>
<th>Name</th>
<th>Contact</th>
<th>Sr. No</th>
<th>Subcontractor Name</th>
<th>GST No</th>
<th>Mobile</th>
<th>Email</th>
<th>Status</th>
@@ -33,7 +33,7 @@
<tr>
<td>{{ s.id }}</td>
<td>{{ s.subcontractor_name }}</td>
<td>{{ s.contact_person }}</td>
<td>{{ s.gst_no }}</td>
<td>{{ s.mobile_no }}</td>
<td>{{ s.email_id }}</td>
<td>
@@ -65,9 +65,9 @@
{% for s in subcontractors %}
<div class="card mb-3 shadow-sm">
<div class="card-body p-3">
<h6 class="fw-bold mb-2">{{ s.subcontractor_name }}</h6>
<h5 class="fw-bold mb-2">{{ s.subcontractor_name }}</h5>
<p class="mb-1"><strong>Contact Person Name:</strong> {{ s.contact_person }}</p>
<p class="mb-1"><strong>GST No:</strong> {{ s.gst_no }}</p>
<p class="mb-1"><strong>Mobile:</strong> {{ s.mobile_no }}</p>
<p class="mb-1"><strong>Email:</strong> {{ s.email_id }}</p>

View File

@@ -1,55 +1,47 @@
{% extends "base.html" %}
{% block content %}
<div class="container-fluid px-2 px-md-4">
<div class="container-fluid mt-3">
<h4 class="mb-3 text-center text-md-start">Subcontractor Dashboard </h4>
<h4 class="mb-4">Subcontractor Dashboard</h4>
<div class="row g-3 mb-4">
<div class="col-12 col-md-4">
<div class="card text-white bg-primary shadow h-100">
<div class="card-body text-center text-md-start">
<h6>Trenching Units</h6>
<h3 class="fw-bold" id="card-trench">0</h3>
</div>
</div>
<div class="row mb-3">
<div class="col-md-4">
<select id="subcontractor" class="form-control">
<option value="">Select Subcontractor</option>
{% for s in subcontractors %}
<option value="{{s.id}}">{{s.subcontractor_name}}</option>
{% endfor %}
</select>
</div>
<div class="col-12 col-md-4">
<div class="card text-white bg-success shadow h-100">
<div class="card-body text-center text-md-start">
<h6>Manhole Units</h6>
<h3 class="fw-bold" id="card-manhole">0</h3>
</div>
</div>
<div class="col-md-4">
<select id="category" class="form-control">
<option value="">Select Category</option>
<option value="Soft Murum">Soft Murum</option>
<option value="Hard Murum">Hard Murum</option>
<option value="Soft Rock">Soft Rock</option>
<option value="Hard Rock">Hard Rock</option>
</select>
</div>
<div class="col-12 col-md-4">
<div class="card text-dark bg-warning shadow h-100">
<div class="card-body text-center text-md-start">
<h6>Laying Units</h6>
<h3 class="fw-bold" id="card-laying">0</h3>
</div>
</div>
<div class="col-md-4">
<select id="ra_bill" class="form-control">
<option value="">RA Bill</option>
</select>
</div>
</div>
<div class="row g-3">
<div class="col-12 col-md-6">
<div class="card shadow-sm h-100">
<div class="card-header bg-dark text-white">Live Category Bar Chart</div>
<div class="card-body">
<canvas id="liveBarChart" style="max-height:300px;"></canvas>
</div>
</div>
</div>
<div class="col-12 col-md-6">
<div class="card shadow-sm h-100">
<div class="card-header bg-dark text-white">Location Distribution Pie Chart</div>
<div class="card-body">
<canvas id="livePieChart" style="max-height:300px;"></canvas>
</div>
</div>
<div class="card shadow">
<div class="card-body">
<canvas id="comparisonChart" height="120"></canvas>
</div>
</div>
@@ -59,64 +51,55 @@
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
// 2. Initialize the Bar Chart
const barCtx = document.getElementById('liveBarChart').getContext('2d');
let liveBarChart = new Chart(barCtx, {
type: 'bar',
data: {
labels: ['Trenching', 'Manholes', 'Laying'],
datasets: [{
label: 'Units Completed',
data: [0, 0, 0],
backgroundColor: ['#0d6efd', '#198754', '#ffc107']
}]
},
options: { responsive: true, maintainAspectRatio: false }
});
// 3. Initialize the Pie Chart
const pieCtx = document.getElementById('livePieChart').getContext('2d');
let livePieChart = new Chart(pieCtx, {
type: 'pie',
data: {
labels: [], // Will be filled from SQL
datasets: [{
data: [],
backgroundColor: ['#0d6efd', '#198754', '#ffc107', '#6f42c1', '#fd7e14']
}]
},
options: { responsive: true, maintainAspectRatio: false }
});
let chart;
// 4. Function to Fetch Live Data from your Python API
function fetchLiveData() {
fetch('/dashboard/api/live-stats') // This matches the route we created in the "Kitchen"
.then(response => response.json())
function loadChart() {
let subcontractor = document.getElementById("subcontractor").value
let category = document.getElementById("category").value
let ra_bill = document.getElementById("ra_bill").value
fetch(`/dashboard/api/subcontractor-chart?subcontractor=${subcontractor}&category=${category}&ra_bill=${ra_bill}`)
.then(res => res.json())
.then(data => {
// Update the Summary Cards
document.getElementById('card-trench').innerText = data.summary.trench;
document.getElementById('card-manhole').innerText = data.summary.manhole;
document.getElementById('card-laying').innerText = data.summary.laying;
// Update Bar Chart
liveBarChart.data.datasets[0].data = [
data.summary.trench,
data.summary.manhole,
data.summary.laying
];
liveBarChart.update();
if (chart) {
chart.destroy()
}
const ctx = document.getElementById("comparisonChart")
chart = new Chart(ctx, {
type: "bar",
data: {
labels: data.labels,
datasets: [{
label: "Subcontractor Quantity",
data: data.values,
backgroundColor: "#0d6efd"
}]
},
options: {
responsive: true,
plugins: {
legend: { display: true }
}
}
})
// Update Pie Chart (Location stats)
livePieChart.data.labels = Object.keys(data.locations);
livePieChart.data.datasets[0].data = Object.values(data.locations);
livePieChart.update();
})
.catch(err => console.error("Error fetching live data:", err));
}
// 5. Check for updates every 10 seconds (Real-time effect)
setInterval(fetchLiveData, 10000);
fetchLiveData(); // Load immediately on page open
document.getElementById("subcontractor").addEventListener("change", loadChart)
document.getElementById("category").addEventListener("change", loadChart)
document.getElementById("ra_bill").addEventListener("change", loadChart)
loadChart()
</script>
{% endblock %}