2025-12-12 11:38:54 +05:30
|
|
|
{% extends "base.html" %}
|
|
|
|
|
{% block content %}
|
|
|
|
|
|
2026-07-30 14:38:37 +05:30
|
|
|
<div class="container-fluid py-4">
|
2025-12-12 11:38:54 +05:30
|
|
|
|
2026-07-30 14:38:37 +05:30
|
|
|
<!-- Page Header -->
|
|
|
|
|
<div class="card shadow-sm border-0 mb-4">
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<div class="d-flex justify-content-between align-items-center">
|
|
|
|
|
<div>
|
|
|
|
|
<h2 class="fw-bold text-primary mb-1">
|
|
|
|
|
<i class="bi bi-file-earmark-bar-graph"></i>
|
|
|
|
|
Subcontractor Report
|
|
|
|
|
</h2>
|
|
|
|
|
<small class="text-muted">
|
|
|
|
|
View, Filter, Edit and Delete Subcontractor Records
|
|
|
|
|
</small>
|
|
|
|
|
</div>
|
2026-01-15 14:21:36 +05:30
|
|
|
</div>
|
2026-07-30 14:38:37 +05:30
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-12-12 18:38:50 +05:30
|
|
|
|
2026-07-30 14:38:37 +05:30
|
|
|
<!-- Filter Card -->
|
|
|
|
|
<div class="card shadow-sm border-0">
|
|
|
|
|
<div class="card-header bg-primary text-white">
|
|
|
|
|
<h5 class="mb-0">
|
|
|
|
|
<i class="bi bi-funnel-fill"></i>
|
|
|
|
|
Report Filters
|
|
|
|
|
</h5>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<form method="POST" class="loading-form">
|
|
|
|
|
|
|
|
|
|
<div class="row g-3">
|
|
|
|
|
<div class="col-lg-3">
|
|
|
|
|
<label class="form-label fw-semibold">
|
|
|
|
|
Subcontractor
|
|
|
|
|
<span class="text-danger">*</span>
|
|
|
|
|
</label>
|
|
|
|
|
<select name="subcontractor_id" class="form-select" required>
|
|
|
|
|
<option value="">--- Select Contractor ---</option>
|
|
|
|
|
{% for sc in subcontractors %}
|
|
|
|
|
<option value="{{ sc.id }}"
|
|
|
|
|
{% if selected_sc_id|string == sc.id|string %}selected{% endif %}>
|
|
|
|
|
{{ sc.subcontractor_name }}
|
|
|
|
|
</option>
|
|
|
|
|
{% endfor %}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col-lg-3">
|
|
|
|
|
<label class="form-label fw-semibold"> RA Bill No</label>
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
name="ra_bill_no"
|
|
|
|
|
class="form-control"
|
|
|
|
|
placeholder="Enter RA Bill"
|
|
|
|
|
value="{{ selected_ra_bill or '' }}">
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col-lg-3">
|
|
|
|
|
<label class="form-label fw-semibold"> Location </label>
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
name="location"
|
|
|
|
|
class="form-control"
|
|
|
|
|
placeholder="Project Location"
|
|
|
|
|
value="{{ selected_location or '' }}">
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col-lg-3">
|
|
|
|
|
<label class="form-label fw-semibold">Work Category</label>
|
|
|
|
|
<select name="category" class="form-select">
|
|
|
|
|
|
|
|
|
|
<option value="all">All Categories</option>
|
|
|
|
|
|
|
|
|
|
<option value="tr"
|
|
|
|
|
{% if request.form.get('category')=='tr' %}selected{% endif %}>
|
|
|
|
|
Trench Excavation
|
|
|
|
|
</option>
|
|
|
|
|
|
|
|
|
|
<option value="mh"
|
|
|
|
|
{% if request.form.get('category')=='mh' %}selected{% endif %}>
|
|
|
|
|
Manhole Excavation
|
|
|
|
|
</option>
|
|
|
|
|
|
|
|
|
|
<option value="dc"
|
|
|
|
|
{% if request.form.get('category')=='dc' %}selected{% endif %}>
|
2026-08-06 16:00:12 +05:30
|
|
|
Domestic Chamber
|
2026-07-30 14:38:37 +05:30
|
|
|
</option>
|
|
|
|
|
|
|
|
|
|
<option value="laying"
|
|
|
|
|
{% if request.form.get('category')=='laying' %}selected{% endif %}>
|
|
|
|
|
Pipe Laying
|
|
|
|
|
</option>
|
|
|
|
|
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
2026-01-15 14:21:36 +05:30
|
|
|
</div>
|
2026-07-30 14:38:37 +05:30
|
|
|
|
|
|
|
|
<div class="mt-4 d-flex justify-content-end gap-2">
|
|
|
|
|
|
|
|
|
|
<!-- Preview -->
|
|
|
|
|
<button type="submit" name="action" value="preview"class="btn btn-primary">
|
|
|
|
|
<i class="bi bi-search"></i>
|
|
|
|
|
Preview Report
|
2026-01-15 14:21:36 +05:30
|
|
|
</button>
|
2026-07-30 14:38:37 +05:30
|
|
|
|
|
|
|
|
<!-- Download -->
|
|
|
|
|
<div class="btn-group">
|
|
|
|
|
<button type="button" class="btn btn-success dropdown-toggle"data-bs-toggle="dropdown">
|
|
|
|
|
<i class="bi bi-download"></i>
|
|
|
|
|
Download Report
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<ul class="dropdown-menu dropdown-menu-end">
|
|
|
|
|
<li>
|
|
|
|
|
<button class="dropdown-item"type="submit" name="action" value="excel">
|
|
|
|
|
<i class="bi bi-file-earmark-excel text-success"></i>
|
|
|
|
|
Download Excel
|
|
|
|
|
</button>
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
|
|
<button class="dropdown-item" type="submit" name="action"
|
|
|
|
|
value="excel_all">
|
|
|
|
|
<i class="bi bi-file-earmark-spreadsheet text-primary"></i>
|
|
|
|
|
Download All Excel
|
|
|
|
|
</button>
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
<li><hr class="dropdown-divider"></li>
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
|
|
<button class="dropdown-item"type="submit"name="action" value="pdf">
|
|
|
|
|
<i class="bi bi-file-earmark-pdf text-danger"></i>
|
|
|
|
|
PDF (Coming Soon)
|
|
|
|
|
</button>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<button type="reset" class="btn btn-secondary" id="resetBtn">
|
|
|
|
|
<i class="bi bi-arrow-clockwise"></i>
|
|
|
|
|
Reset
|
|
|
|
|
</button>
|
|
|
|
|
|
2026-01-15 14:21:36 +05:30
|
|
|
</div>
|
2026-07-30 14:38:37 +05:30
|
|
|
</form>
|
2026-01-16 13:04:59 +05:30
|
|
|
|
2026-07-30 14:38:37 +05:30
|
|
|
</div>
|
2025-12-12 18:38:50 +05:30
|
|
|
</div>
|
|
|
|
|
|
2026-01-15 14:21:36 +05:30
|
|
|
{% if tables %}
|
2026-08-06 16:00:12 +05:30
|
|
|
{% set show_all = (not selected_category) or selected_category == 'all' %}
|
2026-07-30 14:38:37 +05:30
|
|
|
<!-- Tabs -->
|
|
|
|
|
<div class="card shadow-sm border-0 mt-4">
|
|
|
|
|
<div class="card-header bg-light">
|
|
|
|
|
<ul class="nav nav-pills">
|
|
|
|
|
<li class="nav-item">
|
2026-08-06 16:00:12 +05:30
|
|
|
<button class="nav-link {% if show_all %}active{% endif %}" data-bs-toggle="tab" data-bs-target="#abstract">
|
2026-07-30 14:38:37 +05:30
|
|
|
<i class="bi bi-file-earmark-text"></i> Abstract
|
|
|
|
|
</button>
|
|
|
|
|
</li>
|
2026-01-16 13:04:59 +05:30
|
|
|
|
2026-08-06 16:00:12 +05:30
|
|
|
{% if show_all or selected_category == 'tr' %}
|
2026-07-30 14:38:37 +05:30
|
|
|
<li class="nav-item">
|
2026-08-06 16:00:12 +05:30
|
|
|
<button class="nav-link {% if selected_category == 'tr' %}active{% endif %}" data-bs-toggle="tab" data-bs-target="#tr">
|
2026-07-30 14:38:37 +05:30
|
|
|
<i class="bi bi-cone-striped"></i> Trench Excavation
|
|
|
|
|
</button>
|
|
|
|
|
</li>
|
2026-08-06 16:00:12 +05:30
|
|
|
{% endif %}
|
2026-01-15 14:21:36 +05:30
|
|
|
|
2026-08-06 16:00:12 +05:30
|
|
|
{% if show_all or selected_category == 'mh' %}
|
2026-07-30 14:38:37 +05:30
|
|
|
<li class="nav-item">
|
2026-08-06 16:00:12 +05:30
|
|
|
<button class="nav-link {% if selected_category == 'mh' %}active{% endif %}" data-bs-toggle="tab" data-bs-target="#mh">
|
2026-07-30 14:38:37 +05:30
|
|
|
<i class="bi bi-nut"></i> Manhole Excavation
|
|
|
|
|
</button>
|
|
|
|
|
</li>
|
2026-08-06 16:00:12 +05:30
|
|
|
{% endif %}
|
2026-01-16 13:04:59 +05:30
|
|
|
|
2026-08-06 16:00:12 +05:30
|
|
|
{% if show_all or selected_category == 'dc' %}
|
2026-07-30 14:38:37 +05:30
|
|
|
<li class="nav-item">
|
2026-08-06 16:00:12 +05:30
|
|
|
<button class="nav-link {% if selected_category == 'dc' %}active{% endif %}" data-bs-toggle="tab" data-bs-target="#dc">
|
2026-07-30 14:38:37 +05:30
|
|
|
<i class="bi bi-grid-3x3"></i> Manhole & Domestic Chambers Construction
|
|
|
|
|
</button>
|
|
|
|
|
</li>
|
2026-08-06 16:00:12 +05:30
|
|
|
{% endif %}
|
2026-01-16 13:04:59 +05:30
|
|
|
|
2026-08-06 16:00:12 +05:30
|
|
|
{% if show_all or selected_category == 'laying' %}
|
2026-07-30 14:38:37 +05:30
|
|
|
<li class="nav-item">
|
2026-08-06 16:00:12 +05:30
|
|
|
<button class="nav-link {% if selected_category == 'laying' %}active{% endif %}" data-bs-toggle="tab" data-bs-target="#laying">
|
2026-07-30 14:38:37 +05:30
|
|
|
<i class="bi bi-bezier2"></i> Pipe Laying
|
|
|
|
|
</button>
|
|
|
|
|
</li>
|
2026-08-06 16:00:12 +05:30
|
|
|
{% endif %}
|
2026-07-30 14:38:37 +05:30
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<div class="tab-content">
|
|
|
|
|
|
2026-08-06 16:00:12 +05:30
|
|
|
<div class="tab-pane fade {% if show_all %}show active{% endif %}" id="abstract">
|
2026-07-30 14:38:37 +05:30
|
|
|
{{ abstract_html|safe }}
|
|
|
|
|
</div>
|
2026-01-16 13:04:59 +05:30
|
|
|
|
2026-08-06 16:00:12 +05:30
|
|
|
{% if show_all or selected_category == 'tr' %}
|
2026-07-30 14:38:37 +05:30
|
|
|
<!-- Trench -->
|
2026-08-06 16:00:12 +05:30
|
|
|
<div class="tab-pane fade {% if selected_category == 'tr' %}show active{% endif %}" id="tr">
|
2026-07-30 14:38:37 +05:30
|
|
|
<div class="mb-3">
|
|
|
|
|
<button onclick="deleteSelected('tr')" class="btn btn-danger">
|
|
|
|
|
<i class="bi bi-trash"></i> Delete Selected
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="table-responsive border rounded shadow-sm">
|
|
|
|
|
{{ tables.tr|safe }}
|
2026-01-15 14:21:36 +05:30
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-08-06 16:00:12 +05:30
|
|
|
{% endif %}
|
2026-01-16 13:04:59 +05:30
|
|
|
|
2026-08-06 16:00:12 +05:30
|
|
|
{% if show_all or selected_category == 'mh' %}
|
2026-07-30 14:38:37 +05:30
|
|
|
<!-- MH -->
|
2026-08-06 16:00:12 +05:30
|
|
|
<div class="tab-pane fade {% if selected_category == 'mh' %}show active{% endif %}" id="mh">
|
2026-07-30 14:38:37 +05:30
|
|
|
<div class="mb-3">
|
|
|
|
|
<button onclick="deleteSelected('mh')" class="btn btn-danger">
|
|
|
|
|
<i class="bi bi-trash"></i>Delete Selected
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="table-responsive border rounded shadow-sm">
|
|
|
|
|
{{ tables.mh|safe }}
|
2026-01-15 14:21:36 +05:30
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-08-06 16:00:12 +05:30
|
|
|
{% endif %}
|
2026-01-16 13:04:59 +05:30
|
|
|
|
2026-08-06 16:00:12 +05:30
|
|
|
{% if show_all or selected_category == 'dc' %}
|
2026-07-30 14:38:37 +05:30
|
|
|
<!-- DC -->
|
2026-08-06 16:00:12 +05:30
|
|
|
<div class="tab-pane fade {% if selected_category == 'dc' %}show active{% endif %}" id="dc">
|
2026-07-30 14:38:37 +05:30
|
|
|
<div class="mb-3">
|
|
|
|
|
<button onclick="deleteSelected('dc')"class="btn btn-danger">
|
|
|
|
|
<i class="bi bi-trash"></i>
|
|
|
|
|
Delete Selected
|
|
|
|
|
</button>
|
2026-01-15 14:21:36 +05:30
|
|
|
</div>
|
2026-07-30 14:38:37 +05:30
|
|
|
<div class="table-responsive border rounded shadow-sm">
|
|
|
|
|
{{ tables.dc|safe }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-08-06 16:00:12 +05:30
|
|
|
{% endif %}
|
2026-01-16 11:27:26 +05:30
|
|
|
|
2026-08-06 16:00:12 +05:30
|
|
|
{% if show_all or selected_category == 'laying' %}
|
2026-07-30 14:38:37 +05:30
|
|
|
<!-- Laying -->
|
2026-08-06 16:00:12 +05:30
|
|
|
<div class="tab-pane fade {% if selected_category == 'laying' %}show active{% endif %}" id="laying">
|
2026-07-30 14:38:37 +05:30
|
|
|
<div class="mb-3">
|
|
|
|
|
<button onclick="deleteSelected('laying')"
|
|
|
|
|
class="btn btn-danger">
|
|
|
|
|
<i class="bi bi-trash"></i>
|
|
|
|
|
Delete Selected
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="table-responsive border rounded shadow-sm">
|
|
|
|
|
{{ tables.laying|safe }}
|
2026-01-16 11:27:26 +05:30
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-08-06 16:00:12 +05:30
|
|
|
{% endif %}
|
2026-01-15 14:21:36 +05:30
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-12-12 18:38:50 +05:30
|
|
|
</div>
|
2026-01-15 14:21:36 +05:30
|
|
|
{% endif %}
|
|
|
|
|
|
2026-01-16 13:04:59 +05:30
|
|
|
</div>
|
2026-01-15 14:21:36 +05:30
|
|
|
|
|
|
|
|
<script>
|
2026-08-06 16:00:12 +05:30
|
|
|
|
|
|
|
|
document.getElementById("resetBtn").addEventListener("click", function () {
|
|
|
|
|
window.location.href = window.location.pathname;
|
|
|
|
|
});
|
2026-07-30 14:38:37 +05:30
|
|
|
|
|
|
|
|
// DATATABLE
|
|
|
|
|
$(document).ready(function () {
|
2026-08-06 16:00:12 +05:30
|
|
|
|
|
|
|
|
$('.datatable').each(function () {
|
|
|
|
|
$(this).DataTable({
|
|
|
|
|
pageLength: 10,
|
|
|
|
|
dom: 'Bfrtip',
|
|
|
|
|
buttons: ['copy', 'csv', 'excel', 'print'],
|
|
|
|
|
initComplete: function () {
|
|
|
|
|
|
|
|
|
|
$(this).closest('.dataTables_wrapper')
|
|
|
|
|
.find('thead tr th:first-child')
|
|
|
|
|
.html('<input type="checkbox" class="select-all" title="Select All">');
|
|
|
|
|
}
|
|
|
|
|
});
|
2026-07-30 14:38:37 +05:30
|
|
|
});
|
2026-08-06 16:00:12 +05:30
|
|
|
});
|
2026-07-30 14:38:37 +05:30
|
|
|
|
2026-08-06 16:00:12 +05:30
|
|
|
// SELECT ALL — scoped to the checkbox's own table only
|
|
|
|
|
$(document).on("change", ".select-all", function () {
|
|
|
|
|
$(this).closest("table").find(".row-check").prop("checked", this.checked);
|
2026-07-30 14:38:37 +05:30
|
|
|
});
|
|
|
|
|
|
2026-08-06 16:00:12 +05:30
|
|
|
// If a row checkbox is unchecked manually, uncheck that table's select-all
|
|
|
|
|
$(document).on("change", ".row-check", function () {
|
|
|
|
|
if (!this.checked) {
|
|
|
|
|
$(this).closest("table").find(".select-all").prop("checked", false);
|
|
|
|
|
}
|
2026-07-30 14:38:37 +05:30
|
|
|
});
|
|
|
|
|
|
2026-08-06 16:00:12 +05:30
|
|
|
|
|
|
|
|
function getSelectedIds(model) {
|
2026-07-30 14:38:37 +05:30
|
|
|
let ids = [];
|
2026-08-06 16:00:12 +05:30
|
|
|
$("#" + model + " .row-check:checked").each(function () {
|
2026-07-30 14:38:37 +05:30
|
|
|
ids.push($(this).data("id"));
|
|
|
|
|
});
|
|
|
|
|
return ids;
|
2026-01-15 14:21:36 +05:30
|
|
|
}
|
|
|
|
|
|
2026-07-30 14:38:37 +05:30
|
|
|
// BULK DELETE
|
|
|
|
|
function deleteSelected(model) {
|
2026-08-06 16:00:12 +05:30
|
|
|
let ids = getSelectedIds(model);
|
2026-07-30 14:38:37 +05:30
|
|
|
if (ids.length === 0) return alert("Select records");
|
|
|
|
|
|
|
|
|
|
if (!confirm(`Delete ${ids.length} record(s)?`)) return;
|
|
|
|
|
|
|
|
|
|
fetch("/file/delete_records", {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: { "Content-Type": "application/json" },
|
|
|
|
|
body: JSON.stringify({ model: model, ids: ids })
|
|
|
|
|
})
|
|
|
|
|
.then(res => res.json().then(data => ({ ok: res.ok, data })))
|
|
|
|
|
.then(({ ok, data }) => {
|
|
|
|
|
if (ok && data.status === "success") {
|
|
|
|
|
alert("Deleted Successfully");
|
|
|
|
|
location.reload();
|
|
|
|
|
} else {
|
|
|
|
|
alert("Delete failed: " + (data.message || "Unknown error"));
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch(err => {
|
|
|
|
|
alert("Delete request failed: " + err);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SINGLE DELETE
|
|
|
|
|
$(document).on("click", ".delete-btn", function () {
|
|
|
|
|
let id = $(this).data("id");
|
|
|
|
|
let model = $(this).data("model");
|
|
|
|
|
|
|
|
|
|
if (!confirm("Are you sure you want to delete this record?")) return;
|
|
|
|
|
|
|
|
|
|
fetch("/file/delete_records", {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: { "Content-Type": "application/json" },
|
|
|
|
|
body: JSON.stringify({ model: model, ids: [id] })
|
|
|
|
|
})
|
|
|
|
|
.then(res => res.json().then(data => ({ ok: res.ok, data })))
|
|
|
|
|
.then(({ ok, data }) => {
|
|
|
|
|
if (ok && data.status === "success") {
|
|
|
|
|
alert("Deleted Successfully");
|
|
|
|
|
location.reload();
|
|
|
|
|
} else {
|
|
|
|
|
alert("Delete failed: " + (data.message || "Unknown error"));
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch(err => {
|
|
|
|
|
alert("Delete request failed: " + err);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
2026-01-15 14:21:36 +05:30
|
|
|
</script>
|
2026-07-30 14:38:37 +05:30
|
|
|
|
2025-12-12 11:38:54 +05:30
|
|
|
{% endblock %}
|