Merge branch 'dev' of http://103.248.30.24:3000/kent-logistics/Kent-logistics-Laravel into dev
This commit is contained in:
@@ -734,17 +734,31 @@
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* Shipment Details Modal */
|
||||
/* Shipment Details Modal - EDGE-TO-EDGE STYLING */
|
||||
.modal-xl.edge-to-edge {
|
||||
max-width: 95vw !important;
|
||||
width: 95vw !important;
|
||||
margin: 1vh auto !important;
|
||||
}
|
||||
|
||||
/* UPDATED: Shipment Order Details Modal - ALSO EDGE-TO-EDGE */
|
||||
.modal-xl.edge-to-edge.order-details-modal {
|
||||
max-width: 95vw !important;
|
||||
width: 95vw !important;
|
||||
margin: 1vh auto !important;
|
||||
}
|
||||
|
||||
.shipment-details-header {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 25px 30px 15px;
|
||||
padding: 25px 35px 15px;
|
||||
border-radius: 20px 20px 0 0;
|
||||
}
|
||||
|
||||
.shipment-details-body {
|
||||
padding: 40px 45px;
|
||||
padding: 30px 35px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.shipment-info-row {
|
||||
@@ -824,47 +838,63 @@
|
||||
border-bottom-right-radius: 10px;
|
||||
}
|
||||
|
||||
/* Shipment Totals Section */
|
||||
/* Shipment Totals Section - SINGLE ROW ON DESKTOP */
|
||||
.shipment-totals {
|
||||
margin-top: 25px;
|
||||
padding: 25px;
|
||||
padding: 25px 20px;
|
||||
background: linear-gradient(135deg, #f8fafc, #e2e8f0);
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 4px 6px rgba(0,0,0,0.05);
|
||||
border-left: 4px solid #4361ee;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.shipment-totals-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 20px;
|
||||
justify-content: space-between;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(8, 1fr);
|
||||
gap: 12px;
|
||||
justify-content: center;
|
||||
align-items: stretch;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.shipment-total-item {
|
||||
flex: 1;
|
||||
min-width: 150px;
|
||||
text-align: center;
|
||||
padding: 15px;
|
||||
padding: 15px 10px;
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-shrink: 1;
|
||||
}
|
||||
|
||||
.shipment-total-label {
|
||||
font-weight: 600;
|
||||
color: #64748b;
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
margin-bottom: 8px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
line-height: 1.2;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.shipment-total-value {
|
||||
font-weight: 800;
|
||||
font-size: 20px;
|
||||
font-size: 18px;
|
||||
color: #1e293b;
|
||||
line-height: 1.2;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.total-amount {
|
||||
@@ -873,6 +903,7 @@
|
||||
padding: 10px;
|
||||
border-radius: 8px;
|
||||
border: 2px solid #10b981;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.total-quantity {
|
||||
@@ -881,6 +912,7 @@
|
||||
padding: 10px;
|
||||
border-radius: 8px;
|
||||
border: 2px solid #0ea5e9;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.total-weight {
|
||||
@@ -889,6 +921,7 @@
|
||||
padding: 10px;
|
||||
border-radius: 8px;
|
||||
border: 2px solid #8b5cf6;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.total-cbm {
|
||||
@@ -897,6 +930,7 @@
|
||||
padding: 10px;
|
||||
border-radius: 8px;
|
||||
border: 2px solid #ef4444;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.total-ctn {
|
||||
@@ -905,6 +939,7 @@
|
||||
padding: 10px;
|
||||
border-radius: 8px;
|
||||
border: 2px solid #f59e0b;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.total-ttl-cbm {
|
||||
@@ -913,6 +948,7 @@
|
||||
padding: 10px;
|
||||
border-radius: 8px;
|
||||
border: 2px solid #8b5cf6;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.total-ttl-kg {
|
||||
@@ -921,6 +957,7 @@
|
||||
padding: 10px;
|
||||
border-radius: 8px;
|
||||
border: 2px solid #14b8a6;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Animation for loading */
|
||||
@@ -964,8 +1001,8 @@
|
||||
display: table-row;
|
||||
}
|
||||
|
||||
/* ---------- Pagination Styles ---------- */
|
||||
.pagination-container, .modal-pagination-container {
|
||||
/* ---------- Pagination Styles (Same as Account Dashboard) ---------- */
|
||||
.pagination-container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
@@ -974,19 +1011,19 @@
|
||||
border-top: 1px solid #eef3fb;
|
||||
}
|
||||
|
||||
.pagination-info, .modal-pagination-info {
|
||||
.pagination-info {
|
||||
font-size: 13px;
|
||||
color: #9ba5bb;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.pagination-controls, .modal-pagination-controls {
|
||||
.pagination-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.pagination-btn, .modal-pagination-btn {
|
||||
.pagination-btn {
|
||||
background: #fff;
|
||||
border: 1px solid #e3eaf6;
|
||||
color: #1a2951;
|
||||
@@ -1003,13 +1040,13 @@
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.pagination-btn:hover:not(:disabled), .modal-pagination-btn:hover:not(:disabled) {
|
||||
.pagination-btn:hover:not(:disabled) {
|
||||
background: #1a2951;
|
||||
color: white;
|
||||
border-color: #1a2951;
|
||||
}
|
||||
|
||||
.pagination-btn:disabled, .modal-pagination-btn:disabled {
|
||||
.pagination-btn:disabled {
|
||||
background: #f8fafc;
|
||||
color: #cbd5e0;
|
||||
border-color: #e2e8f0;
|
||||
@@ -1017,7 +1054,7 @@
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.pagination-page-btn, .modal-pagination-page-btn {
|
||||
.pagination-page-btn {
|
||||
background: #fff;
|
||||
border: 1px solid #e3eaf6;
|
||||
color: #1a2951;
|
||||
@@ -1031,13 +1068,13 @@
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.pagination-page-btn:hover, .modal-pagination-page-btn:hover {
|
||||
.pagination-page-btn:hover {
|
||||
background: #1a2951;
|
||||
color: white;
|
||||
border-color: #1a2951;
|
||||
}
|
||||
|
||||
.pagination-page-btn.active, .modal-pagination-page-btn.active {
|
||||
.pagination-page-btn.active {
|
||||
background: #1a2951;
|
||||
color: white;
|
||||
border-color: #1a2951;
|
||||
@@ -1055,16 +1092,210 @@
|
||||
padding: 0 4px;
|
||||
}
|
||||
|
||||
/* Image-based pagination buttons */
|
||||
.pagination-img-btn {
|
||||
background: #fff;
|
||||
border: 1px solid #e3eaf6;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 40px;
|
||||
height: 32px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.pagination-img-btn:hover:not(:disabled) {
|
||||
background: #1a2951;
|
||||
border-color: #1a2951;
|
||||
}
|
||||
|
||||
.pagination-img-btn:disabled {
|
||||
background: #f8fafc;
|
||||
border-color: #e2e8f0;
|
||||
cursor: not-allowed;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.pagination-img-btn img {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
filter: brightness(0) saturate(100%) invert(26%) sepia(89%) saturate(748%) hue-rotate(201deg) brightness(93%) contrast(89%);
|
||||
transition: filter 0.3s ease;
|
||||
}
|
||||
|
||||
.pagination-img-btn:hover:not(:disabled) img {
|
||||
filter: brightness(0) saturate(100%) invert(100%) sepia(100%) saturate(0%) hue-rotate(288deg) brightness(106%) contrast(101%);
|
||||
}
|
||||
|
||||
.pagination-img-btn:disabled img {
|
||||
filter: brightness(0) saturate(100%) invert(84%) sepia(8%) saturate(165%) hue-rotate(179deg) brightness(89%) contrast(86%);
|
||||
}
|
||||
|
||||
/* RESPONSIVE DESIGN FOR TABLET/MOBILE */
|
||||
@media (max-width: 1200px) {
|
||||
.modal-xl.edge-to-edge {
|
||||
max-width: 96vw !important;
|
||||
width: 96vw !important;
|
||||
margin: 2vh auto !important;
|
||||
}
|
||||
|
||||
.modal-xl.edge-to-edge.order-details-modal {
|
||||
max-width: 96vw !important;
|
||||
width: 96vw !important;
|
||||
margin: 2vh auto !important;
|
||||
}
|
||||
|
||||
.shipment-totals-row {
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 992px) {
|
||||
.modal-xl.edge-to-edge {
|
||||
max-width: 95vw !important;
|
||||
width: 95vw !important;
|
||||
margin: 2.5vh auto !important;
|
||||
}
|
||||
|
||||
.modal-xl.edge-to-edge.order-details-modal {
|
||||
max-width: 95vw !important;
|
||||
width: 95vw !important;
|
||||
margin: 2.5vh auto !important;
|
||||
}
|
||||
|
||||
.shipment-details-body {
|
||||
padding: 20px 25px;
|
||||
}
|
||||
|
||||
.shipment-totals-row {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.pagination-container, .modal-pagination-container {
|
||||
.pagination-container {
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.pagination-controls, .modal-pagination-controls {
|
||||
.pagination-controls {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.modal-xl.edge-to-edge {
|
||||
max-width: 100vw !important;
|
||||
width: 100vw !important;
|
||||
margin: 0 !important;
|
||||
height: 100vh !important;
|
||||
max-height: 100vh !important;
|
||||
}
|
||||
|
||||
.modal-xl.edge-to-edge.order-details-modal {
|
||||
max-width: 100vw !important;
|
||||
width: 100vw !important;
|
||||
margin: 0 !important;
|
||||
height: 100vh !important;
|
||||
max-height: 100vh !important;
|
||||
}
|
||||
|
||||
.shipment-details-body {
|
||||
padding: 15px 20px;
|
||||
}
|
||||
|
||||
.shipment-info-row {
|
||||
flex-direction: column;
|
||||
gap: 15px;
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.shipment-info-item {
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.shipment-totals {
|
||||
padding: 20px 15px;
|
||||
}
|
||||
|
||||
.shipment-totals-row {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.shipment-total-item {
|
||||
padding: 12px 8px;
|
||||
}
|
||||
|
||||
.shipment-total-label {
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.shipment-total-value {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
/* Order details modal specific responsive styles */
|
||||
.order-details-content {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.order-details-table {
|
||||
min-width: 1000px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 576px) {
|
||||
.shipment-totals-row {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.modal-xl.edge-to-edge .modal-content {
|
||||
border-radius: 0;
|
||||
height: 100vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.modal-xl.edge-to-edge.order-details-modal .modal-content {
|
||||
border-radius: 0;
|
||||
height: 100vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.shipment-details-header {
|
||||
padding: 20px 25px 15px;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.order-details-header {
|
||||
padding: 20px 15px 10px;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.order-details-body {
|
||||
padding: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.modal-xl.edge-to-edge,
|
||||
.modal-xl.edge-to-edge.order-details-modal {
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
border-radius: 0 !important;
|
||||
}
|
||||
|
||||
.shipment-details-body,
|
||||
.order-details-body {
|
||||
padding: 10px 15px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1168,7 +1399,7 @@
|
||||
<th>Amount (₹)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="modalOrdersTableBody">
|
||||
<tbody>
|
||||
@forelse($availableOrders as $order)
|
||||
<tr>
|
||||
<td>
|
||||
@@ -1196,29 +1427,6 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Modal Pagination -->
|
||||
<div class="modal-pagination-container" id="modalPaginationContainer">
|
||||
<div class="modal-pagination-info" id="modalPageInfo">
|
||||
Showing 1 to {{ min(10, count($availableOrders)) }} of {{ count($availableOrders) }} entries
|
||||
</div>
|
||||
<div class="modal-pagination-controls">
|
||||
<button class="modal-pagination-btn" id="modalPrevPageBtn" title="Previous page" disabled>
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M10 12L6 8L10 4" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</button>
|
||||
<div class="pagination-pages" id="modalPaginationPages">
|
||||
<!-- Pages will be generated here by JavaScript -->
|
||||
</div>
|
||||
<button class="modal-pagination-btn" id="modalNextPageBtn" title="Next page" {{ count($availableOrders) <= 10 ? 'disabled' : '' }}>
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M6 4L10 8L6 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end mt-4 mb-2">
|
||||
<button type="button" class="btn-cancel me-3" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn-create">
|
||||
@@ -1354,14 +1562,14 @@
|
||||
<div class="pagination-container">
|
||||
<div class="pagination-info" id="pageInfo">Showing 1 to {{ $shipments->count() }} of {{ $shipments->count() }} entries</div>
|
||||
<div class="pagination-controls">
|
||||
<button class="pagination-btn" id="prevPageBtn" title="Previous page" disabled>
|
||||
<button class="pagination-img-btn" id="prevPageBtn" title="Previous page" disabled>
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M10 12L6 8L10 4" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</button>
|
||||
<div class="pagination-pages" id="paginationPages">
|
||||
</div>
|
||||
<button class="pagination-btn" id="nextPageBtn" title="Next page" disabled>
|
||||
<button class="pagination-img-btn" id="nextPageBtn" title="Next page" disabled>
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M6 4L10 8L6 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
@@ -1373,7 +1581,7 @@
|
||||
|
||||
{{-- SHIPMENT DETAILS MODAL --}}
|
||||
<div class="modal fade" id="shipmentDetailsModal" tabindex="-1">
|
||||
<div class="modal-dialog modal-xl modal-dialog-scrollable">
|
||||
<div class="modal-dialog modal-xl edge-to-edge modal-dialog-scrollable">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header shipment-details-header">
|
||||
<h5 class="modal-title fw-bold"><i class="bi bi-box-seam me-2"></i>Consolidated Shipment Details</h5>
|
||||
@@ -1395,34 +1603,20 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Main Pagination state
|
||||
// Pagination state
|
||||
let currentPage = 1;
|
||||
const itemsPerPage = 10;
|
||||
let allShipments = @json($shipments);
|
||||
let filteredShipments = [...allShipments];
|
||||
|
||||
// Modal Pagination state
|
||||
let modalCurrentPage = 1;
|
||||
const modalItemsPerPage = 10;
|
||||
let modalAllOrders = @json($availableOrders);
|
||||
|
||||
// Initialize both paginations on page load
|
||||
// Initialize pagination on page load
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Initialize main table pagination
|
||||
renderTable();
|
||||
updatePaginationControls();
|
||||
|
||||
// Initialize modal pagination
|
||||
renderModalTable();
|
||||
updateModalPaginationControls();
|
||||
|
||||
// Bind main pagination events
|
||||
// Bind pagination events
|
||||
document.getElementById('prevPageBtn').addEventListener('click', goToPreviousPage);
|
||||
document.getElementById('nextPageBtn').addEventListener('click', goToNextPage);
|
||||
|
||||
// Bind modal pagination events
|
||||
document.getElementById('modalPrevPageBtn').addEventListener('click', goToModalPreviousPage);
|
||||
document.getElementById('modalNextPageBtn').addEventListener('click', goToModalNextPage);
|
||||
|
||||
// Status Filter Functionality
|
||||
const statusFilter = document.getElementById('statusFilter');
|
||||
@@ -1452,7 +1646,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
if (!matchesSearch) include = false;
|
||||
}
|
||||
|
||||
// Carrier filter
|
||||
// Carrier filter (you can add carrier data attribute if needed)
|
||||
if (selectedCarrier !== 'all') {
|
||||
// Add carrier filtering logic here if you have carrier data
|
||||
}
|
||||
@@ -1474,26 +1668,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
filterShipments();
|
||||
});
|
||||
|
||||
// Helper function to extract numeric part from order ID
|
||||
function extractOrderNumber(orderId) {
|
||||
if (!orderId) return 0;
|
||||
|
||||
// Try to find numbers in the order ID
|
||||
const matches = orderId.match(/\d+/g);
|
||||
if (matches && matches.length > 0) {
|
||||
// Take the last sequence of numbers (often the actual order number)
|
||||
return parseInt(matches[matches.length - 1]);
|
||||
}
|
||||
|
||||
// Fallback: try to convert the whole string
|
||||
const num = parseInt(orderId.replace(/\D/g, ''));
|
||||
return isNaN(num) ? 0 : num;
|
||||
}
|
||||
|
||||
// ====================================
|
||||
// MAIN PAGINATION FUNCTIONS
|
||||
// ====================================
|
||||
|
||||
// Pagination Functions
|
||||
function goToPreviousPage() {
|
||||
if (currentPage > 1) {
|
||||
currentPage--;
|
||||
@@ -1532,11 +1707,11 @@ function updatePaginationControls() {
|
||||
if (totalPages <= 7) {
|
||||
// Show all pages
|
||||
for (let i = 1; i <= totalPages; i++) {
|
||||
addPageButton(i, paginationPages, currentPage);
|
||||
addPageButton(i, paginationPages);
|
||||
}
|
||||
} else {
|
||||
// Show first page, current page range, and last page
|
||||
addPageButton(1, paginationPages, currentPage);
|
||||
addPageButton(1, paginationPages);
|
||||
|
||||
if (currentPage > 3) {
|
||||
paginationPages.innerHTML += '<span class="pagination-ellipsis">...</span>';
|
||||
@@ -1546,18 +1721,18 @@ function updatePaginationControls() {
|
||||
const end = Math.min(totalPages - 1, currentPage + 1);
|
||||
|
||||
for (let i = start; i <= end; i++) {
|
||||
addPageButton(i, paginationPages, currentPage);
|
||||
addPageButton(i, paginationPages);
|
||||
}
|
||||
|
||||
if (currentPage < totalPages - 2) {
|
||||
paginationPages.innerHTML += '<span class="pagination-ellipsis">...</span>';
|
||||
}
|
||||
|
||||
addPageButton(totalPages, paginationPages, currentPage);
|
||||
addPageButton(totalPages, paginationPages);
|
||||
}
|
||||
}
|
||||
|
||||
function addPageButton(pageNumber, container, currentPage) {
|
||||
function addPageButton(pageNumber, container) {
|
||||
const button = document.createElement('button');
|
||||
button.className = 'pagination-page-btn';
|
||||
if (pageNumber === currentPage) {
|
||||
@@ -1572,93 +1747,7 @@ function addPageButton(pageNumber, container, currentPage) {
|
||||
container.appendChild(button);
|
||||
}
|
||||
|
||||
// ====================================
|
||||
// MODAL PAGINATION FUNCTIONS
|
||||
// ====================================
|
||||
|
||||
function goToModalPreviousPage() {
|
||||
if (modalCurrentPage > 1) {
|
||||
modalCurrentPage--;
|
||||
renderModalTable();
|
||||
updateModalPaginationControls();
|
||||
}
|
||||
}
|
||||
|
||||
function goToModalNextPage() {
|
||||
const totalPages = Math.ceil(modalAllOrders.length / modalItemsPerPage);
|
||||
if (modalCurrentPage < totalPages) {
|
||||
modalCurrentPage++;
|
||||
renderModalTable();
|
||||
updateModalPaginationControls();
|
||||
}
|
||||
}
|
||||
|
||||
function updateModalPaginationControls() {
|
||||
const totalPages = Math.ceil(modalAllOrders.length / modalItemsPerPage);
|
||||
const prevBtn = document.getElementById('modalPrevPageBtn');
|
||||
const nextBtn = document.getElementById('modalNextPageBtn');
|
||||
const pageInfo = document.getElementById('modalPageInfo');
|
||||
const paginationPages = document.getElementById('modalPaginationPages');
|
||||
|
||||
prevBtn.disabled = modalCurrentPage === 1;
|
||||
nextBtn.disabled = modalCurrentPage === totalPages || totalPages === 0;
|
||||
|
||||
// Update page info text - Order count correctly
|
||||
const startIndex = (modalCurrentPage - 1) * modalItemsPerPage + 1;
|
||||
const endIndex = Math.min(modalCurrentPage * modalItemsPerPage, modalAllOrders.length);
|
||||
pageInfo.textContent = `Showing ${startIndex} to ${endIndex} of ${modalAllOrders.length} entries`;
|
||||
|
||||
// Generate page numbers
|
||||
paginationPages.innerHTML = '';
|
||||
|
||||
if (totalPages <= 7) {
|
||||
// Show all pages
|
||||
for (let i = 1; i <= totalPages; i++) {
|
||||
addModalPageButton(i, paginationPages);
|
||||
}
|
||||
} else {
|
||||
// Show first page, current page range, and last page
|
||||
addModalPageButton(1, paginationPages);
|
||||
|
||||
if (modalCurrentPage > 3) {
|
||||
paginationPages.innerHTML += '<span class="pagination-ellipsis">...</span>';
|
||||
}
|
||||
|
||||
const start = Math.max(2, modalCurrentPage - 1);
|
||||
const end = Math.min(totalPages - 1, modalCurrentPage + 1);
|
||||
|
||||
for (let i = start; i <= end; i++) {
|
||||
addModalPageButton(i, paginationPages);
|
||||
}
|
||||
|
||||
if (modalCurrentPage < totalPages - 2) {
|
||||
paginationPages.innerHTML += '<span class="pagination-ellipsis">...</span>';
|
||||
}
|
||||
|
||||
addModalPageButton(totalPages, paginationPages);
|
||||
}
|
||||
}
|
||||
|
||||
function addModalPageButton(pageNumber, container) {
|
||||
const button = document.createElement('button');
|
||||
button.className = 'modal-pagination-page-btn';
|
||||
if (pageNumber === modalCurrentPage) {
|
||||
button.classList.add('active');
|
||||
}
|
||||
button.textContent = pageNumber;
|
||||
button.addEventListener('click', () => {
|
||||
modalCurrentPage = pageNumber;
|
||||
renderModalTable();
|
||||
updateModalPaginationControls();
|
||||
});
|
||||
container.appendChild(button);
|
||||
}
|
||||
|
||||
// ====================================
|
||||
// RENDER FUNCTIONS
|
||||
// ====================================
|
||||
|
||||
// Render Main Table Function
|
||||
// Render Table Function
|
||||
function renderTable() {
|
||||
const tbody = document.getElementById('shipmentsTableBody');
|
||||
|
||||
@@ -1677,27 +1766,15 @@ function renderTable() {
|
||||
// Calculate pagination
|
||||
const startIndex = (currentPage - 1) * itemsPerPage;
|
||||
const endIndex = startIndex + itemsPerPage;
|
||||
const paginatedItems = filteredShipments.slice(startIndex, endIndex);
|
||||
|
||||
// Sort by order_id in DESCENDING order (largest number first)
|
||||
const sortedItems = [...filteredShipments].sort((a, b) => {
|
||||
// Extract numeric part from order_id for comparison
|
||||
const numA = extractOrderNumber(a.shipment_id);
|
||||
const numB = extractOrderNumber(b.shipment_id);
|
||||
return numB - numA; // DESCENDING order
|
||||
});
|
||||
|
||||
const paginatedItems = sortedItems.slice(startIndex, endIndex);
|
||||
|
||||
// Calculate reverse index starting from total count
|
||||
const totalCount = filteredShipments.length;
|
||||
const reverseStartIndex = totalCount - (currentPage - 1) * itemsPerPage;
|
||||
// Sort by creation date (newest first)
|
||||
const sortedItems = [...paginatedItems].sort((a, b) => new Date(b.created_at) - new Date(a.created_at));
|
||||
|
||||
// Render table rows
|
||||
tbody.innerHTML = '';
|
||||
paginatedItems.forEach((shipment, index) => {
|
||||
// Calculate display number in reverse order
|
||||
const displayNumber = reverseStartIndex - index;
|
||||
|
||||
sortedItems.forEach((shipment, index) => {
|
||||
const displayIndex = filteredShipments.length - (startIndex + index);
|
||||
const row = document.createElement('tr');
|
||||
row.className = 'shipment-row';
|
||||
row.setAttribute('data-status', shipment.status);
|
||||
@@ -1710,7 +1787,7 @@ function renderTable() {
|
||||
};
|
||||
|
||||
row.innerHTML = `
|
||||
<td class="fw-bold">${displayNumber}</td>
|
||||
<td class="fw-bold">${displayIndex}</td>
|
||||
<td>
|
||||
<a href="#" class="text-primary fw-bold" onclick="openShipmentDetails(${shipment.id})">
|
||||
${shipment.shipment_id}
|
||||
@@ -1736,6 +1813,7 @@ function renderTable() {
|
||||
</a>
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<div class="action-container">
|
||||
<button type="button"
|
||||
@@ -1804,71 +1882,9 @@ function renderTable() {
|
||||
});
|
||||
}
|
||||
|
||||
// Render Modal Table Function
|
||||
function renderModalTable() {
|
||||
const tbody = document.getElementById('modalOrdersTableBody');
|
||||
|
||||
if (modalAllOrders.length === 0) {
|
||||
tbody.innerHTML = `
|
||||
<tr>
|
||||
<td colspan="12" class="text-muted text-center py-4">No available orders to add to shipment</td>
|
||||
</tr>
|
||||
`;
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate pagination
|
||||
const startIndex = (modalCurrentPage - 1) * modalItemsPerPage;
|
||||
const endIndex = startIndex + modalItemsPerPage;
|
||||
|
||||
// Sort by order_id in DESCENDING order (largest number first)
|
||||
const sortedItems = [...modalAllOrders].sort((a, b) => {
|
||||
// Extract numeric part from order_id for comparison
|
||||
const numA = extractOrderNumber(a.order_id);
|
||||
const numB = extractOrderNumber(b.order_id);
|
||||
return numB - numA; // DESCENDING order
|
||||
});
|
||||
|
||||
const paginatedItems = sortedItems.slice(startIndex, endIndex);
|
||||
|
||||
// Calculate reverse index starting from total count
|
||||
const totalCount = modalAllOrders.length;
|
||||
const reverseStartIndex = totalCount - (modalCurrentPage - 1) * modalItemsPerPage;
|
||||
|
||||
// Render table rows
|
||||
tbody.innerHTML = '';
|
||||
paginatedItems.forEach((order, index) => {
|
||||
// Calculate display number in reverse order
|
||||
const displayNumber = reverseStartIndex - index;
|
||||
|
||||
tbody.innerHTML += `
|
||||
<tr>
|
||||
<td>
|
||||
<input type="checkbox" name="order_ids[]" value="${order.id}">
|
||||
</td>
|
||||
<td>
|
||||
<a href="#" class="text-primary fw-bold">${order.order_id}</a>
|
||||
</td>
|
||||
<td>${order.origin}</td>
|
||||
<td>${order.destination}</td>
|
||||
<td>${order.ctn}</td>
|
||||
<td>${order.qty}</td>
|
||||
<td>${order.ttl_qty}</td>
|
||||
<td>${order.cbm}</td>
|
||||
<td>${order.ttl_cbm}</td>
|
||||
<td>${order.kg}</td>
|
||||
<td>${order.ttl_kg}</td>
|
||||
<td class="fw-bold text-success">₹${parseFloat(order.ttl_amount).toLocaleString('en-IN', {minimumFractionDigits: 2, maximumFractionDigits: 2})}</td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
}
|
||||
|
||||
// ====================================
|
||||
// OTHER FUNCTIONS
|
||||
// ====================================
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Function: Open Consolidated Shipment Details Modal
|
||||
// --------------------------------------------------------------------
|
||||
function openShipmentDetails(id) {
|
||||
let modal = new bootstrap.Modal(document.getElementById('shipmentDetailsModal'));
|
||||
let content = document.getElementById('shipmentDetailsContent');
|
||||
@@ -1952,7 +1968,11 @@ function openShipmentDetails(id) {
|
||||
html += `
|
||||
<tr>
|
||||
<td class="fw-bold">
|
||||
${order.order_id}
|
||||
<a href="javascript:void(0)"
|
||||
class="text-primary fw-bold"
|
||||
onclick="openShipmentOrderDetails(${order.id})">
|
||||
${order.order_id}
|
||||
</a>
|
||||
</td>
|
||||
<td>${order.origin || 'N/A'}</td>
|
||||
<td>${order.destination || 'N/A'}</td>
|
||||
@@ -2065,6 +2085,46 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
function openShipmentOrderDetails(orderId) {
|
||||
const modal = new bootstrap.Modal(
|
||||
document.getElementById('shipmentOrderDetailsModal')
|
||||
);
|
||||
|
||||
const body = document.getElementById('shipmentOrderDetailsBody');
|
||||
body.innerHTML = "<p class='text-center text-muted'>Loading...</p>";
|
||||
|
||||
modal.show();
|
||||
|
||||
fetch(`/admin/orders/view/${orderId}`)
|
||||
.then(res => res.text())
|
||||
.then(html => {
|
||||
body.innerHTML = html;
|
||||
})
|
||||
.catch(() => {
|
||||
body.innerHTML =
|
||||
"<p class='text-danger text-center'>Failed to load order details.</p>";
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<!-- SHIPMENT ORDER DETAILS MODAL - UPDATED TO EDGE-TO-EDGE -->
|
||||
<div class="modal fade" id="shipmentOrderDetailsModal" tabindex="-1">
|
||||
<div class="modal-dialog modal-xl edge-to-edge order-details-modal modal-dialog-scrollable">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header shipment-details-header order-details-header">
|
||||
<h5 class="modal-title fw-bold"><i class="bi bi-file-text me-2"></i>Order Details</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body shipment-details-body order-details-body" id="shipmentOrderDetailsBody">
|
||||
<p class="text-center text-muted">Loading order details...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
Reference in New Issue
Block a user