Files
Kent-logistics-Laravel/resources/views/admin/shipments.blade.php
2025-12-01 10:38:52 +05:30

2105 lines
71 KiB
PHP

@extends('admin.layouts.app')
@section('page-title', 'Shipment Management')
@section('content')
<style>
/*Remove horizontal scroll bar*/
html, body {
overflow-x: hidden !important;
font-family: 'Inter', sans-serif;
}
.table thead th,
.table tbody td {
white-space: nowrap !important;
padding: 14px 8px !important;
font-size: 14px;
font-family: 'Inter', sans-serif;
}
.table th:nth-child(10),
.table td:nth-child(10) {
max-width: 110px !important;
width: 110px !important;
overflow: hidden;
text-overflow: ellipsis;
}
.table {
table-layout: fixed !important;
font-family: 'Inter', sans-serif;
}
.table, .custom-table-modal, .shipment-details-table {
min-width: unset !important;
width: 100% !important;
table-layout: auto !important;
font-family: 'Inter', sans-serif;
}
.table thead th,
.table tbody td,
.custom-table-modal th,
.custom-table-modal td,
.shipment-details-table th,
.shipment-details-table td {
white-space: normal !important;
word-break: break-word;
font-family: 'Inter', sans-serif;
font-size: 14px;
}
.table-responsive, .modal .table-responsive {
overflow-x: auto !important;
}
:root {
--primary: #4361ee;
--primary-dark: #3a56d4;
--secondary: #f72585;
--success: #4cc9f0;
--warning: #f8961e;
--danger: #e63946;
--light: #f8f9fa;
--dark: #212529;
--gray: #6c757d;
--border: #e2e8f0;
--card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
--hover-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
/* Search Bar Styles */
.search-shipment-bar {
display: flex;
align-items: center;
gap: 15px;
padding: 20px;
background: white;
border-radius: 16px;
box-shadow: var(--card-shadow);
flex-wrap: wrap;
margin-bottom: 30px;
color: #333;
position: relative;
overflow: hidden;
font-family: 'Inter', sans-serif;
border: 1px solid #e2e8f0;
}
.search-input-container {
display: flex;
flex: 1;
min-width: 300px;
background: white;
border-radius: 10px;
overflow: hidden;
border: 1px solid #d1d5db;
transition: all 0.3s ease;
}
.search-input-container:focus-within {
border-color: #4361ee;
box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}
.search-shipment-bar input {
padding: 12px 16px;
border: none;
flex: 1;
background: transparent;
font-weight: 500;
transition: all 0.3s ease;
font-family: 'Inter', sans-serif;
font-size: 14px;
outline: none;
color: #333;
}
.search-shipment-bar input::placeholder {
color: #6b7280;
}
.search-button {
background: white;
color: #4361ee;
border: none;
padding: 12px 20px;
cursor: pointer;
transition: all 0.3s ease;
font-weight: 600;
font-family: 'Inter', sans-serif;
font-size: 14px;
display: flex;
align-items: center;
gap: 8px;
border-radius: 0 10px 10px 0;
min-width: 100px;
justify-content: center;
border-left: 1px solid #d1d5db;
}
.search-input-group {
border: 1px solid #d1d5db !important;
border-radius: 8px !important;
padding: 4px !important;
background: #ffffff !important;
}
.search-button:hover {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}
.search-icon {
font-size: 16px;
color: #4361ee;
transition: all 0.3s ease;
}
.search-button:hover .search-icon {
color: white;
}
.search-shipment-bar select {
padding: 20px 16px;
border: 1px solid #d1d5db;
border-radius: 10px;
min-width: 150px;
background: white;
font-weight: 500;
transition: all 0.3s ease;
font-family: 'Inter', sans-serif;
font-size: 14px;
color: #333;
}
.search-shipment-bar select:focus {
background: white;
box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
outline: none;
border-color: #4361ee;
}
.btn-add-shipment {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
padding: 17px 24px;
border-radius: 10px;
cursor: pointer;
display: flex;
align-items: center;
gap: 8px;
transition: all 0.3s ease;
white-space: nowrap;
font-weight: 600;
font-family: 'Inter', sans-serif;
font-size: 14px;
}
.btn-add-shipment:hover {
transform: translateY(-2px);
box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}
.truck-icon {
font-size: 18px;
}
@media (max-width: 768px) {
.search-shipment-bar {
flex-direction: column;
align-items: stretch;
}
.search-input-container,
.search-shipment-bar select {
width: 100%;
}
}
/* Card Styles */
.card {
border: none;
border-radius: 16px;
box-shadow: var(--card-shadow);
transition: all 0.3s ease;
overflow: hidden;
font-family: 'Inter', sans-serif;
}
.card:hover {
transform: translateY(-5px);
box-shadow: var(--hover-shadow);
}
.card-header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
padding: 20px 25px;
border-radius: 16px 16px 0 0 !important;
font-family: 'Inter', sans-serif;
}
.card-header h5 {
margin: 0;
font-weight: 700;
display: flex;
align-items: center;
gap: 10px;
font-family: 'Inter', sans-serif;
font-size: 18px;
}
/* Table Styles */
.table-responsive {
border-radius: 0 0 16px 16px;
overflow-x: auto;
}
.table {
margin: 0;
border-collapse: separate;
border-spacing: 0;
width: 100%;
min-width: 1200px;
padding: 0;
font-family: 'Inter', sans-serif;
}
.table thead th {
background: #f8f9fa;
border: none;
padding: 16px 12px;
font-weight: 700;
color: var(--dark);
text-align: center;
vertical-align: middle;
border-bottom: 2px solid var(--border);
position: relative;
white-space: nowrap;
font-family: 'Inter', sans-serif;
font-size: 14px;
}
.table thead th:first-child {
border-radius: 0;
}
.table thead th:last-child {
border-radius: 0;
}
.table tbody tr {
transition: all 0.3s ease;
border-radius: 10px;
}
.table tbody tr:hover {
background-color: #f8f9ff;
transform: scale(1.01);
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.table tbody td {
padding: 14px 12px;
text-align: center;
vertical-align: middle;
border-bottom: 1px solid var(--border);
font-weight: 500;
white-space: nowrap;
font-family: 'Inter', sans-serif;
font-size: 14px;
}
.table tbody tr:last-child td {
border-bottom: none;
}
/* Status Badge Styles */
.badge {
padding: 7px 17px !important;
border-radius: 20px !important;
font-weight: 600 !important;
font-size: 13px !important;
border: 2px solid transparent !important;
min-width: 40px !important;
text-align: center !important;
display: inline-flex !important;
align-items: center;
justify-content: center;
line-height: 1.2 !important;
font-family: 'Inter', sans-serif;
gap: 6px;
width: 110px;
}
/* Status icons */
.status-icon {
font-size: 13px;
display: flex;
align-items: center;
justify-content: center;
}
/* Pending Status */
.badge-pending {
background: linear-gradient(135deg, #fef3c7, #fde68a) !important;
color: #d97706 !important;
border-color: #f59e0b !important;
}
/* In Transit Status */
.badge-in_transit {
background: linear-gradient(135deg, #dbeafe, #93c5fd) !important;
color: #1e40af !important;
border-color: #3b82f6 !important;
}
/* Dispatched Status */
.badge-dispatched {
background: linear-gradient(135deg, #e9d5ff, #c4b5fd) !important;
color: #6b21a8 !important;
border-color: #8b5cf6 !important;
}
/* Delivered Status */
.badge-delivered {
background: linear-gradient(135deg, #d1fae5, #a7f3d0) !important;
color: #065f46 !important;
border-color: #10b981 !important;
}
/* Light badges for quantity, kg, cbm */
.badge.bg-light {
background: #f8f9fa !important;
color: #212529 !important;
border: 1px solid #dee2e6 !important;
min-width: 80px !important;
padding: 6px 12px !important;
font-family: 'Inter', sans-serif;
font-size: 13px;
width: auto;
}
/* Action Button Styles */
.action-container {
position: relative;
display: inline-block;
}
.btn-edit-status {
background: linear-gradient(135deg, #667eea, #764ba2);
color: white;
border: none;
border-radius: 8px;
padding: 8px 10px;
cursor: pointer;
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
width: 36px;
height: 36px;
font-family: 'Inter', sans-serif;
}
.btn-edit-status:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
background: linear-gradient(135deg, #5a6fd8, #6a42a0);
}
.status-dropdown {
position: absolute;
top: 100%;
right: 50px;
background: white;
border-radius: 10px;
box-shadow: 0 10px 25px rgba(0,0,0,0.2);
padding: 8px;
min-width: 150px;
display: none;
flex-direction: column;
gap: 5px;
margin-top: -50px;
border: 1px solid var(--border);
z-index: 1050;
font-family: 'Inter', sans-serif;
}
.status-dropdown.show {
display: flex;
}
.status-option {
padding: 10px 12px;
border: none;
border-radius: 6px;
cursor: pointer;
font-size: 0.8rem;
font-weight: 600;
transition: all 0.2s ease;
text-align: left;
display: flex;
align-items: center;
gap: 8px;
background: transparent;
width: 100%;
font-family: 'Inter', sans-serif;
}
.status-option:hover {
transform: translateX(5px);
}
.status-option.pending {
background: rgba(248, 150, 30, 0.1);
color: #f8961e;
}
.status-option.pending:hover {
background: rgba(248, 150, 30, 0.2);
}
.status-option.in_transit {
background: rgba(67, 97, 238, 0.1);
color: #4361ee;
}
.status-option.in_transit:hover {
background: rgba(67, 97, 238, 0.2);
}
.status-option.dispatched {
background: rgba(139, 92, 246, 0.1);
color: #8b5cf6;
}
.status-option.dispatched:hover {
background: rgba(139, 92, 246, 0.2);
}
.status-option.delivered {
background: rgba(16, 185, 129, 0.1);
color: #10b981;
}
.status-option.delivered:hover {
background: rgba(16, 185, 129, 0.2);
}
.status-indicator {
width: 8px;
height: 8px;
border-radius: 50%;
display: inline-block;
}
.status-indicator.pending {
background: #f8961e;
}
.status-indicator.in_transit {
background: #4361ee;
}
.status-indicator.dispatched {
background: #8b5cf6;
}
.status-indicator.delivered {
background: #10b981;
}
/* View Button Styles */
.btn-view {
background: #4361ee;
color: white;
border: none;
border-radius: 8px;
padding: 8px;
cursor: pointer;
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
width: 36px;
height: 36px;
font-weight: 600;
font-size: 16px;
font-family: 'Inter', sans-serif;
position: relative;
overflow: hidden;
}
.btn-view::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
transition: all 0.3s ease;
z-index: 1;
}
.btn-view:hover::before {
left: 0;
}
.btn-view i {
position: relative;
z-index: 2;
transition: all 0.3s ease;
}
.btn-view:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}
.btn-view:hover i {
transform: scale(1.1);
}
/* Action buttons container */
.action-buttons {
display: flex;
gap: 8px;
align-items: center;
justify-content: center;
}
/* Modal Styles */
.modal-content {
border-radius: 20px;
border: none;
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
overflow: hidden;
font-family: 'Inter', sans-serif;
}
.modal-header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
padding: 25px 30px 15px;
border-radius: 20px 20px 0 0;
position: relative;
font-family: 'Inter', sans-serif;
}
.modal-header::after {
content: '';
position: absolute;
bottom: 0;
left: 5%;
width: 90%;
height: 1px;
background: rgba(255,255,255,0.2);
}
.modal-title {
font-weight: 700;
font-size: 1.5rem;
font-family: 'Inter', sans-serif;
}
.btn-close {
filter: invert(1);
opacity: 0.8;
}
.btn-close:hover {
opacity: 1;
}
.modal-body {
padding: 25px 30px;
font-family: 'Inter', sans-serif;
}
/* Form Styles */
.form-label {
font-weight: 600;
color: #5a6c7d;
margin-bottom: 8px;
font-size: 0.9rem;
font-family: 'Inter', sans-serif;
}
.form-control {
border-radius: 10px;
border: 1px solid #e2e8f0;
padding: 12px 16px;
font-size: 14px;
transition: all 0.3s ease;
background: #fafbfc;
color: #4a5568;
font-family: 'Inter', sans-serif;
}
.form-control:focus {
border-color: #a3bffa;
box-shadow: 0 0 0 3px rgba(163, 191, 250, 0.2);
background: white;
}
.form-control::placeholder {
color: #a0aec0;
}
/* Button Styles */
.btn-cancel {
background: #f7fafc;
color: #718096;
border: 1px solid #cbd5e0;
border-radius: 10px;
font-weight: 600;
padding: 12px 30px;
transition: all 0.3s ease;
font-family: 'Inter', sans-serif;
font-size: 14px;
}
.btn-cancel:hover {
background: #edf2f7;
color: #4a5568;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.btn-create {
background: linear-gradient(135deg, #48bb78, #38a169);
color: white;
font-weight: 600;
font-size: 14px;
border-radius: 10px;
padding: 12px 35px;
border: none;
transition: all 0.3s ease;
font-family: 'Inter', sans-serif;
}
.btn-create:hover {
transform: translateY(-2px);
box-shadow: 0 10px 20px rgba(72, 187, 120, 0.3);
background: linear-gradient(135deg, #38a169, #2f855a);
}
/* Custom Table in Modal */
.custom-table-modal {
width: 100%;
border-collapse: separate;
border-spacing: 0 8px;
margin: 0;
min-width: 1300px;
font-family: 'Inter', sans-serif;
}
.custom-table-modal thead th {
background: linear-gradient(135deg, #ebf8ff, #f0fff4);
color: #2b6cb0;
font-weight: 600;
padding: 16px 10px;
border: 1px solid #e2e8f0;
text-align: center;
position: relative;
font-size: 14px;
letter-spacing: 0.3px;
white-space: nowrap;
font-family: 'Inter', sans-serif;
}
.custom-table-modal thead th:first-child {
border-top-left-radius: 12px;
border-bottom-left-radius: 12px;
}
.custom-table-modal thead th:last-child {
border-top-right-radius: 12px;
border-bottom-right-radius: 12px;
}
.custom-table-modal tbody tr {
background: #fdfdfe;
border-radius: 10px;
box-shadow: 0 1px 3px rgba(0,0,0,0.04);
transition: all 0.3s ease;
border: 1px solid #f1f5f9;
}
.custom-table-modal tbody tr:hover {
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(0,0,0,0.08);
border-color: #e2e8f0;
background: white;
}
.custom-table-modal tbody td {
padding: 14px 10px;
text-align: center;
vertical-align: middle;
border: none;
font-weight: 500;
position: relative;
color: #4a5568;
white-space: nowrap;
font-family: 'Inter', sans-serif;
font-size: 14px;
}
.custom-table-modal tbody tr td:first-child {
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
}
.custom-table-modal tbody tr td:last-child {
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
}
/* Shipment Details Modal */
.shipment-details-header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
padding: 25px 30px 15px;
border-radius: 20px 20px 0 0;
font-family: 'Inter', sans-serif;
}
.shipment-details-body {
padding: 40px 45px;
font-family: 'Inter', sans-serif;
}
.shipment-info-row {
display: flex;
justify-content: space-between;
margin-bottom: 25px;
padding: 20px;
background: #f8fafc;
border-radius: 12px;
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
font-family: 'Inter', sans-serif;
}
.shipment-info-item {
flex: 1;
text-align: center;
padding: 0 15px;
}
.shipment-info-label {
font-weight: 600;
color: #64748b;
font-size: 14px;
margin-bottom: 5px;
font-family: 'Inter', sans-serif;
}
.shipment-info-value {
font-weight: 700;
font-size: 18px;
color: var(--dark);
font-family: 'Inter', sans-serif;
}
.shipment-details-table {
width: 100%;
border-collapse: separate;
border-spacing: 0 8px;
margin-top: 20px;
min-width: 1400px;
font-family: 'Inter', sans-serif;
}
.shipment-details-table th {
background: #f1f5f9;
padding: 16px 12px;
text-align: center;
font-weight: 700;
color: var(--dark);
border: none;
position: relative;
white-space: nowrap;
font-family: 'Inter', sans-serif;
font-size: 14px;
}
.shipment-details-table th:first-child {
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
}
.shipment-details-table th:last-child {
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
}
.shipment-details-table td {
padding: 14px 12px;
text-align: center;
border: none;
background: white;
box-shadow: 0 2px 5px rgba(0,0,0,0.05);
white-space: nowrap;
font-family: 'Inter', sans-serif;
font-size: 14px;
}
.shipment-details-table tr td:first-child {
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
}
.shipment-details-table tr td:last-child {
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
}
/* Delete Button for Orders */
.btn-delete-order {
background: linear-gradient(135deg, #f87171, #ef4444);
color: white;
border: none;
border-radius: 6px;
padding: 6px 12px;
cursor: pointer;
transition: all 0.3s ease;
font-size: 12px;
font-weight: 600;
font-family: 'Inter', sans-serif;
display: flex;
align-items: center;
gap: 4px;
min-width: 80px;
justify-content: center;
}
.btn-delete-order:hover {
background: linear-gradient(135deg, #ef4444, #dc2626);
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}
/* Shipment Totals Section */
.shipment-totals {
margin-top: 25px;
padding: 25px;
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;
font-family: 'Inter', sans-serif;
}
.shipment-totals-row {
display: flex;
flex-wrap: wrap;
gap: 20px;
justify-content: space-between;
}
.shipment-total-item {
flex: 1;
min-width: 150px;
text-align: center;
padding: 15px;
background: white;
border-radius: 10px;
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.shipment-total-label {
font-weight: 600;
color: #64748b;
font-size: 12px;
margin-bottom: 8px;
text-transform: uppercase;
letter-spacing: 0.5px;
font-family: 'Inter', sans-serif;
}
.shipment-total-value {
font-weight: 800;
font-size: 20px;
color: #1e293b;
line-height: 1.2;
font-family: 'Inter', sans-serif;
}
.total-amount {
color: #059669 !important;
background: linear-gradient(135deg, #d1fae5, #a7f3d0);
padding: 10px;
border-radius: 8px;
border: 2px solid #10b981;
}
.total-quantity {
color: #0369a1 !important;
background: linear-gradient(135deg, #e0f2fe, #bae6fd);
padding: 10px;
border-radius: 8px;
border: 2px solid #0ea5e9;
}
.total-weight {
color: #7c3aed !important;
background: linear-gradient(135deg, #f3e8ff, #e9d5ff);
padding: 10px;
border-radius: 8px;
border: 2px solid #8b5cf6;
}
.total-cbm {
color: #dc2626 !important;
background: linear-gradient(135deg, #fecaca, #fca5a5);
padding: 10px;
border-radius: 8px;
border: 2px solid #ef4444;
}
.total-ctn {
color: #d97706 !important;
background: linear-gradient(135deg, #fef3c7, #fde68a);
padding: 10px;
border-radius: 8px;
border: 2px solid #f59e0b;
}
.total-ttl-cbm {
color: #7c3aed !important;
background: linear-gradient(135deg, #e9d5ff, #c4b5fd);
padding: 10px;
border-radius: 8px;
border: 2px solid #8b5cf6;
}
.total-ttl-kg {
color: #0d9488 !important;
background: linear-gradient(135deg, #ccfbf1, #99f6e4);
padding: 10px;
border-radius: 8px;
border: 2px solid #14b8a6;
}
/* Animation for loading */
@keyframes pulse {
0% { opacity: 1; }
50% { opacity: 0.5; }
100% { opacity: 1; }
}
.loading {
animation: pulse 1.5s infinite;
}
/* Status Filter Styles */
.status-filter-container {
position: relative;
margin-left:350px;
}
.status-filter-select {
cursor: pointer;
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
background-repeat: no-repeat;
background-position: right 12px center;
background-size: 16px;
padding-right: 40px !important;
}
/* Pagination Styles */
.pagination-container {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 15px;
padding: 12px 25px;
border-top: 1px solid #eef3fb;
font-family: 'Inter', sans-serif;
}
.pagination-info {
font-size: 13px;
color: #9ba5bb;
font-weight: 600;
font-family: 'Inter', sans-serif;
}
.pagination-controls {
display: flex;
align-items: center;
gap: 8px;
}
.pagination-btn {
background: #fff;
border: 1px solid #e3eaf6;
color: #1a2951;
padding: 8px 12px;
border-radius: 6px;
font-size: 13px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
min-width: 40px;
height: 32px;
font-family: 'Inter', sans-serif;
}
.pagination-btn:hover:not(:disabled) {
background: #1a2951;
color: white;
border-color: #1a2951;
}
.pagination-btn:disabled {
background: #f8fafc;
color: #cbd5e0;
border-color: #e2e8f0;
cursor: not-allowed;
opacity: 0.6;
}
.pagination-page-btn {
background: #fff;
border: 1px solid #e3eaf6;
color: #1a2951;
padding: 6px 12px;
border-radius: 6px;
font-size: 13px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
min-width: 36px;
text-align: center;
font-family: 'Inter', sans-serif;
}
.pagination-page-btn:hover {
background: #1a2951;
color: white;
border-color: #1a2951;
}
.pagination-page-btn.active {
background: #1a2951;
color: white;
border-color: #1a2951;
}
.pagination-pages {
display: flex;
gap: 4px;
align-items: center;
}
.pagination-ellipsis {
color: #9ba5bb;
font-size: 13px;
padding: 0 4px;
font-family: 'Inter', sans-serif;
}
.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%);
}
@media (max-width: 768px) {
.pagination-container {
flex-direction: column;
gap: 10px;
align-items: stretch;
}
.pagination-controls {
justify-content: center;
}
}
/* Delete Confirmation Modal */
.delete-confirmation-modal .modal-header {
background: linear-gradient(135deg, #ef4444, #dc2626);
}
.delete-confirmation-modal .btn-confirm-delete {
background: linear-gradient(135deg, #ef4444, #dc2626);
color: white;
border: none;
border-radius: 8px;
padding: 10px 20px;
font-weight: 600;
transition: all 0.3s ease;
}
.delete-confirmation-modal .btn-confirm-delete:hover {
background: linear-gradient(135deg, #dc2626, #b91c1c);
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}
.delete-confirmation-modal .btn-cancel-delete {
background: #f7fafc;
color: #718096;
border: 1px solid #cbd5e0;
border-radius: 8px;
padding: 10px 20px;
font-weight: 600;
transition: all 0.3s ease;
}
.delete-confirmation-modal .btn-cancel-delete:hover {
background: #edf2f7;
color: #4a5568;
}
</style>
<div class="container-fluid py-4">
{{-- SUCCESS / ERROR MESSAGES --}}
@if(session('success'))
<div class="alert alert-success alert-dismissible fade show" role="alert">
<i class="bi bi-check-circle-fill me-2"></i>
{{ session('success') }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
@endif
@if(session('error'))
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<i class="bi bi-exclamation-triangle-fill me-2"></i>
{{ session('error') }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
@endif
<!-- SEARCH BAR AND ADD BUTTON -->
<div class="search-shipment-bar">
<form method="GET" action="">
<div class="input-group mb-2 search-input-group">
<input
type="text"
name="search"
id="searchInput"
value="{{ request('search') }}"
class="form-control"
placeholder="Search Shipments..."
>
<button
class="btn btn-outline-primary search-button"
type="submit"
>
<i class="bi bi-search search-icon"></i>
</button>
</div>
</form>
<div class="status-filter-container">
<select id="statusFilter" class="status-filter-select">
<option value="all">All Status</option>
<option value="pending">Pending</option>
<option value="in_transit">In Transit</option>
<option value="dispatched">Dispatched</option>
<option value="delivered">Delivered</option>
</select>
</div>
<button type="button" class="btn-add-shipment" data-bs-toggle="modal" data-bs-target="#createShipmentModal">
<span class="truck-icon">🚚</span>
Add Shipments
</button>
</div>
<!-- CREATE SHIPMENT MODAL -->
<div class="modal fade" id="createShipmentModal" tabindex="-1" aria-labelledby="createShipmentModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="createShipmentModalLabel">
<i class="bi bi-plus-circle me-2"></i>Create New Shipment
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form action="{{ route('admin.shipments.store') }}" method="POST">
@csrf
<div class="row g-3 pb-2">
<div class="col-md-4">
<label class="form-label">Origin *</label>
<input type="text" class="form-control" name="origin" placeholder="Enter origin city" required>
</div>
<div class="col-md-4">
<label class="form-label">Destination *</label>
<input type="text" class="form-control" name="destination" placeholder="Enter destination city" required>
</div>
<div class="col-md-4">
<label class="form-label">Shipment Date *</label>
<input type="date"
name="shipment_date"
class="form-control"
value="{{ date('Y-m-d') }}"
min="{{ date('Y-m-d') }}"
required>
</div>
</div>
<div class="table-responsive mt-4" style="max-height:400px; border-radius:12px;">
<table class="custom-table-modal">
<thead>
<tr>
<th></th>
<th>Order ID</th>
<th>Origin</th>
<th>Destination</th>
<th>CTN</th>
<th>QTY</th>
<th>TTL/QTY</th>
<th>CBM</th>
<th>TTL CBM</th>
<th>KG</th>
<th>TTL KG</th>
<th>Amount ()</th>
</tr>
</thead>
<tbody>
@forelse($availableOrders as $order)
<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">{{ number_format($order->ttl_amount, 2) }}</td>
</tr>
@empty
<tr>
<td colspan="12" class="text-muted text-center py-4">No available orders to add to shipment</td>
</tr>
@endforelse
</tbody>
</table>
</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">
<i class="bi bi-check-lg me-2"></i>Create Shipment
</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- SHIPMENT LIST TABLE -->
<div class="card">
<div class="card-header">
<h5 class="mb-0"><i class="bi bi-truck me-2"></i> Shipments List</h5>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead>
<tr>
<th>#</th>
<th>Shipment ID</th>
<th>Origin</th>
<th>Destination</th>
<th>Total QTY</th>
<th>Total KG</th>
<th>Total CBM</th>
<th>Total Amount</th>
<th>Status</th>
<th>Date</th>
<th>Actions</th>
<th>View</th>
</tr>
</thead>
<tbody id="shipmentsTableBody">
@php
$totalShipments = count($shipments);
@endphp
@forelse($shipments as $ship)
<tr class="shipment-row" data-status="{{ $ship->status }}" data-shipment-id="{{ $ship->shipment_id }}">
{{-- REVERSE INDEX --}}
<td class="fw-bold">{{ $totalShipments - $loop->index }}</td>
<td>
<span class="fw-bold text-primary">
{{ $ship->shipment_id }}
</span>
</td>
<td>{{ $ship->origin }}</td>
<td>{{ $ship->destination }}</td>
<td><span class="badge bg-light text-dark">{{ $ship->total_qty }}</span></td>
<td><span class="badge bg-light text-dark">{{ $ship->total_kg }} kg</span></td>
<td><span class="badge bg-light text-dark">{{ $ship->total_cbm }} CBM</span></td>
<td class="fw-bold text-success">{{ number_format($ship->total_amount, 2) }}</td>
<td>
<span class="badge badge-{{ $ship->status }}">
@if($ship->status == 'pending')
<i class="bi bi-clock-fill status-icon"></i>
@elseif($ship->status == 'in_transit')
<i class="bi bi-truck status-icon"></i>
@elseif($ship->status == 'dispatched')
<i class="bi bi-box-seam status-icon"></i>
@elseif($ship->status == 'delivered')
<i class="bi bi-check-circle-fill status-icon"></i>
@endif
{{ ucfirst(str_replace('_', ' ', $ship->status)) }}
</span>
</td>
<td>{{ \Carbon\Carbon::parse($ship->shipment_date)->format('d M Y') }}</td>
<td>
<div class="action-buttons">
<div class="action-container">
<button type="button" class="btn-edit-status" onclick="toggleStatusDropdown(this, {{ $ship->id }})" title="Edit Status">
<i class="bi bi-pencil"></i>
</button>
<div class="status-dropdown" id="statusDropdown-{{ $ship->id }}">
<form action="{{ route('admin.shipments.updateStatus') }}" method="POST" class="status-form">
@csrf
<input type="hidden" name="shipment_id" value="{{ $ship->id }}">
<button type="submit" name="status" value="pending" class="status-option pending">
<span class="status-indicator pending"></span>
Pending
</button>
<button type="submit" name="status" value="in_transit" class="status-option in_transit">
<span class="status-indicator in_transit"></span>
In Transit
</button>
<button type="submit" name="status" value="dispatched" class="status-option dispatched">
<span class="status-indicator dispatched"></span>
Dispatched
</button>
<button type="submit" name="status" value="delivered" class="status-option delivered">
<span class="status-indicator delivered"></span>
Delivered
</button>
</form>
</div>
</div>
</div>
</td>
<td>
<button type="button" class="btn-view" onclick="viewShipmentOrders({{ $ship->id }})" title="View Orders">
<i class="bi bi-eye"></i>
</button>
</td>
</tr>
@empty
<tr>
<td colspan="12" class="text-center py-5 text-muted">
<i class="bi bi-inbox display-4 d-block mb-3"></i>
No shipments found
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<!-- Pagination Controls -->
<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-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">
<!-- Page numbers will be inserted here -->
</div>
<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>
</button>
</div>
</div>
</div>
</div>
<!-- VIEW SHIPMENT ORDERS MODAL -->
<div class="modal fade" id="viewShipmentOrdersModal" tabindex="-1">
<div class="modal-dialog modal-xl modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header shipment-details-header d-flex justify-content-between align-items-center">
<h5 class="modal-title fw-bold">
<i class="bi bi-list-ul me-2"></i>
Shipment Details <span id="shipmentOrdersHeader"></span>
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body shipment-details-body" id="shipmentOrdersContent">
<div class="text-center py-4 loading">
<div class="spinner-border text-primary" role="status">
<span class="visually-hidden">Loading...</span>
</div>
<p class="mt-2 text-muted">Loading orders...</p>
</div>
</div>
</div>
</div>
</div>
<!-- DELETE CONFIRMATION MODAL -->
<div class="modal fade delete-confirmation-modal" id="deleteOrderModal" tabindex="-1">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title fw-bold">
<i class="bi bi-exclamation-triangle-fill me-2"></i>
Confirm Delete
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body text-center">
<i class="bi bi-trash-fill display-1 text-danger mb-3"></i>
<h4 class="mb-3">Are you sure?</h4>
<p class="text-muted mb-4">You are about to delete this order from the shipment. This action cannot be undone.</p>
<input type="hidden" id="orderToDeleteId">
<input type="hidden" id="shipmentToDeleteFromId">
<div class="d-flex justify-content-center gap-3">
<button type="button" class="btn-cancel-delete" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn-confirm-delete" onclick="confirmDeleteOrder()">
<i class="bi bi-trash me-2"></i>Delete Order
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
// Global variables
let currentShipmentId = null;
let currentPage = 1;
const itemsPerPage = 10;
let allShipments = @json($shipments);
let filteredShipments = [...allShipments];
// Initialize on page load
document.addEventListener('DOMContentLoaded', function() {
renderTable();
updatePaginationControls();
// Bind pagination events
document.getElementById('prevPageBtn').addEventListener('click', goToPreviousPage);
document.getElementById('nextPageBtn').addEventListener('click', goToNextPage);
// Status Filter Functionality
const statusFilter = document.getElementById('statusFilter');
const searchInput = document.getElementById('searchInput');
// Function to filter shipments
function filterShipments() {
const selectedStatus = statusFilter.value;
const searchTerm = searchInput.value.toLowerCase();
filteredShipments = allShipments.filter(shipment => {
let include = true;
// Status filter
if (selectedStatus !== 'all' && shipment.status !== selectedStatus) {
include = false;
}
// Search filter
if (searchTerm) {
const matchesSearch =
(shipment.shipment_id && shipment.shipment_id.toLowerCase().includes(searchTerm)) ||
(shipment.origin && shipment.origin.toLowerCase().includes(searchTerm)) ||
(shipment.destination && shipment.destination.toLowerCase().includes(searchTerm));
if (!matchesSearch) include = false;
}
return include;
});
currentPage = 1;
renderTable();
updatePaginationControls();
}
// Event listeners for filters
statusFilter.addEventListener('change', filterShipments);
searchInput.addEventListener('input', filterShipments);
searchInput.addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
filterShipments();
}
});
// Initialize filter on page load
filterShipments();
});
// Pagination Functions
function goToPreviousPage() {
if (currentPage > 1) {
currentPage--;
renderTable();
updatePaginationControls();
}
}
function goToNextPage() {
const totalPages = Math.ceil(filteredShipments.length / itemsPerPage);
if (currentPage < totalPages) {
currentPage++;
renderTable();
updatePaginationControls();
}
}
function updatePaginationControls() {
const totalPages = Math.ceil(filteredShipments.length / itemsPerPage);
const prevBtn = document.getElementById('prevPageBtn');
const nextBtn = document.getElementById('nextPageBtn');
const pageInfo = document.getElementById('pageInfo');
const paginationPages = document.getElementById('paginationPages');
prevBtn.disabled = currentPage === 1;
nextBtn.disabled = currentPage === totalPages || totalPages === 0;
// Update page info text
const startIndex = (currentPage - 1) * itemsPerPage + 1;
const endIndex = Math.min(currentPage * itemsPerPage, filteredShipments.length);
pageInfo.textContent = `Showing ${startIndex} to ${endIndex} of ${filteredShipments.length} entries`;
// Generate page numbers
paginationPages.innerHTML = '';
if (totalPages <= 7) {
// Show all pages
for (let i = 1; i <= totalPages; i++) {
addPageButton(i, paginationPages);
}
} else {
// Show first page, current page range, and last page
addPageButton(1, paginationPages);
if (currentPage > 3) {
paginationPages.innerHTML += '<span class="pagination-ellipsis">...</span>';
}
const start = Math.max(2, currentPage - 1);
const end = Math.min(totalPages - 1, currentPage + 1);
for (let i = start; i <= end; i++) {
addPageButton(i, paginationPages);
}
if (currentPage < totalPages - 2) {
paginationPages.innerHTML += '<span class="pagination-ellipsis">...</span>';
}
addPageButton(totalPages, paginationPages);
}
}
function addPageButton(pageNumber, container) {
const button = document.createElement('button');
button.className = 'pagination-page-btn';
if (pageNumber === currentPage) {
button.classList.add('active');
}
button.textContent = pageNumber;
button.addEventListener('click', () => {
currentPage = pageNumber;
renderTable();
updatePaginationControls();
});
container.appendChild(button);
}
// Render Table Function
function renderTable() {
const tbody = document.getElementById('shipmentsTableBody');
if (filteredShipments.length === 0) {
tbody.innerHTML = `
<tr>
<td colspan="12" class="text-center py-5 text-muted">
<i class="bi bi-search display-4 d-block mb-3"></i>
No shipments found matching your criteria
</td>
</tr>
`;
return;
}
// Calculate pagination
const startIndex = (currentPage - 1) * itemsPerPage;
const endIndex = startIndex + itemsPerPage;
const paginatedItems = filteredShipments.slice(startIndex, endIndex);
// 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 = '';
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);
row.setAttribute('data-shipment-id', shipment.shipment_id);
row.innerHTML = `
<td class="fw-bold">${displayIndex}</td>
<td>
<span class="fw-bold text-primary">
${shipment.shipment_id}
</span>
</td>
<td>${shipment.origin}</td>
<td>${shipment.destination}</td>
<td>${shipment.total_qty}</td>
<td>${shipment.total_kg} kg</td>
<td>${shipment.total_cbm} CBM</td>
<td class="fw-bold text-success">₹${parseFloat(shipment.total_amount).toLocaleString('en-IN', {minimumFractionDigits: 2, maximumFractionDigits: 2})}</td>
<td>
<span class="badge badge-${shipment.status}">
${shipment.status === 'pending' ? '<i class="bi bi-clock-fill status-icon"></i>' : ''}
${shipment.status === 'in_transit' ? '<i class="bi bi-truck status-icon"></i>' : ''}
${shipment.status === 'dispatched' ? '<i class="bi bi-box-seam status-icon"></i>' : ''}
${shipment.status === 'delivered' ? '<i class="bi bi-check-circle-fill status-icon"></i>' : ''}
${shipment.status.charAt(0).toUpperCase() + shipment.status.slice(1).replace('_', ' ')}
</span>
</td>
<td>${new Date(shipment.shipment_date).toLocaleDateString('en-GB', { day: '2-digit', month: 'short', year: 'numeric' })}</td>
<td>
<div class="action-buttons">
<div class="action-container">
<button type="button" class="btn-edit-status" onclick="toggleStatusDropdown(this, ${shipment.id})" title="Edit Status">
<i class="bi bi-pencil"></i>
</button>
<div class="status-dropdown" id="statusDropdown-${shipment.id}">
<form action="/admin/shipments/update-status" method="POST" class="status-form">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="hidden" name="shipment_id" value="${shipment.id}">
<button type="submit" name="status" value="pending" class="status-option pending">
<span class="status-indicator pending"></span>
Pending
</button>
<button type="submit" name="status" value="in_transit" class="status-option in_transit">
<span class="status-indicator in_transit"></span>
In Transit
</button>
<button type="submit" name="status" value="dispatched" class="status-option dispatched">
<span class="status-indicator dispatched"></span>
Dispatched
</button>
<button type="submit" name="status" value="delivered" class="status-option delivered">
<span class="status-indicator delivered"></span>
Delivered
</button>
</form>
</div>
</div>
</div>
</td>
<td>
<button type="button" class="btn-view" onclick="viewShipmentOrders(${shipment.id})" title="View Orders">
<i class="bi bi-eye"></i>
</button>
</td>
`;
tbody.appendChild(row);
});
}
// Function to view shipment orders
function viewShipmentOrders(shipmentId) {
currentShipmentId = shipmentId;
const modal = new bootstrap.Modal(document.getElementById('viewShipmentOrdersModal'));
const content = document.getElementById('shipmentOrdersContent');
const header = document.getElementById('shipmentOrdersHeader');
content.innerHTML = `
<div class="text-center py-4 loading">
<div class="spinner-border text-primary" role="status">
<span class="visually-hidden">Loading...</span>
</div>
<p class="mt-2 text-muted">Loading orders...</p>
</div>
`;
fetch(`/admin/shipments/${shipmentId}/orders`)
.then(res => {
if (!res.ok) throw new Error('Network response was not ok');
return res.json();
})
.then(data => {
// Update header with shipment ID
header.textContent = data.shipment.shipment_id;
let html = `
<!-- Shipment Basic Info -->
<div class="shipment-info-row">
<div class="shipment-info-item">
<div class="shipment-info-label">Shipment ID</div>
<div class="shipment-info-value">${data.shipment.shipment_id}</div>
</div>
<div class="shipment-info-item">
<div class="shipment-info-label">Total Orders</div>
<div class="shipment-info-value">${data.orders.length}</div>
</div>
<div class="shipment-info-item">
<div class="shipment-info-label">Status</div>
<div class="shipment-info-value">
<span class="badge badge-${data.shipment.status}">
${data.shipment.status.charAt(0).toUpperCase() + data.shipment.status.slice(1).replace('_', ' ')}
</span>
</div>
</div>
<div class="shipment-info-item">
<div class="shipment-info-label">Date</div>
<div class="shipment-info-value">${new Date(data.shipment.shipment_date).toLocaleDateString('en-GB', { day: '2-digit', month: 'short', year: 'numeric' })}</div>
</div>
</div>
<h6 class="fw-bold mt-4 mb-3">Detailed view of all orders in this shipment</h6>
<div class="table-responsive">
<table class="shipment-details-table">
<thead>
<tr>
<th>Order ID</th>
<th>Origin</th>
<th>Destination</th>
<th>CTN</th>
<th>QTY</th>
<th>TTL/QTY</th>
<th>CBM</th>
<th>TTL CBM</th>
<th>KG</th>
<th>TTL KG</th>
<th>Amount (₹)</th>
<th>Action</th>
</tr>
</thead>
<tbody>
`;
data.orders.forEach(order => {
html += `
<tr id="order-row-${order.id}">
<td class="fw-bold text-primary">${order.order_id}</td>
<td>${order.origin || 'N/A'}</td>
<td>${order.destination || 'N/A'}</td>
<td>${order.ctn}</td>
<td>${order.qty}</td>
<td>${order.ttl_qty}</td>
<td>${order.cbm || '0.00'}</td>
<td>${order.ttl_cbm || '0.00'}</td>
<td>${order.kg || '0.00'}</td>
<td>${order.ttl_kg || '0.00'}</td>
<td class="fw-bold text-success">₹${parseFloat(order.ttl_amount).toLocaleString('en-IN', {minimumFractionDigits: 2, maximumFractionDigits: 2})}</td>
<td>
<button type="button" class="btn-delete-order" onclick="deleteOrderFromShipment(${order.id}, ${data.shipment.id})">
<i class="bi bi-trash"></i> Remove
</button>
</td>
</tr>
`;
});
html += `
</tbody>
</table>
</div>
<!-- Totals Section -->
<div class="shipment-totals">
<div class="shipment-totals-row">
<div class="shipment-total-item">
<div class="shipment-total-label">Total CTN</div>
<div class="shipment-total-value total-ctn">${data.shipment.total_ctn}</div>
</div>
<div class="shipment-total-item">
<div class="shipment-total-label">Total QTY</div>
<div class="shipment-total-value total-quantity">${data.shipment.total_qty}</div>
</div>
<div class="shipment-total-item">
<div class="shipment-total-label">Total CBM</div>
<div class="shipment-total-value total-cbm">${data.shipment.total_cbm}</div>
</div>
<div class="shipment-total-item">
<div class="shipment-total-label">Total KG</div>
<div class="shipment-total-value total-weight">${data.shipment.total_kg}</div>
</div>
<div class="shipment-total-item">
<div class="shipment-total-label">Total TTL/QTY</div>
<div class="shipment-total-value total-quantity">${data.shipment.total_ttl_qty}</div>
</div>
<div class="shipment-total-item">
<div class="shipment-total-label">Total TTL/CBM</div>
<div class="shipment-total-value total-ttl-cbm">${data.shipment.total_ttl_cbm}</div>
</div>
<div class="shipment-total-item">
<div class="shipment-total-label">Total TTL/KG</div>
<div class="shipment-total-value total-ttl-kg">${data.shipment.total_ttl_kg}</div>
</div>
<div class="shipment-total-item">
<div class="shipment-total-label">Total Amount</div>
<div class="shipment-total-value total-amount">₹${parseFloat(data.shipment.total_amount).toLocaleString('en-IN', {minimumFractionDigits: 2, maximumFractionDigits: 2})}</div>
</div>
</div>
</div>
`;
content.innerHTML = html;
})
.catch(error => {
console.error('Error loading shipment orders:', error);
content.innerHTML = `
<div class="text-center py-5">
<i class="bi bi-exclamation-triangle display-1 text-danger"></i>
<h4 class="mt-3 text-danger">Error Loading Orders</h4>
<p class="text-muted">Please try again later</p>
<button class="btn btn-primary mt-2" onclick="viewShipmentOrders(${shipmentId})">Retry</button>
</div>
`;
});
modal.show();
}
// Function to show delete confirmation modal
function deleteOrderFromShipment(orderId, shipmentId) {
document.getElementById('orderToDeleteId').value = orderId;
document.getElementById('shipmentToDeleteFromId').value = shipmentId;
const deleteModal = new bootstrap.Modal(document.getElementById('deleteOrderModal'));
deleteModal.show();
}
// Function to confirm and delete order from shipment
function confirmDeleteOrder() {
const orderId = document.getElementById('orderToDeleteId').value;
const shipmentId = document.getElementById('shipmentToDeleteFromId').value;
// Create form data for DELETE request
const formData = new FormData();
formData.append('_method', 'DELETE');
formData.append('_token', '{{ csrf_token() }}');
fetch(`/admin/shipments/${shipmentId}/orders/${orderId}`, {
method: 'POST',
body: formData,
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
if (data.success) {
// Close delete modal
const deleteModal = bootstrap.Modal.getInstance(document.getElementById('deleteOrderModal'));
deleteModal.hide();
// Remove the order row from the table
const orderRow = document.getElementById(`order-row-${orderId}`);
if (orderRow) {
orderRow.remove();
}
// Show success message
showAlert('Order removed successfully from shipment', 'success');
// If there are no orders left, close the modal and refresh the page
if (data.orders_remaining === 0) {
const viewModal = bootstrap.Modal.getInstance(document.getElementById('viewShipmentOrdersModal'));
viewModal.hide();
location.reload();
} else {
// Update totals in the modal
updateShipmentTotals(data.shipment);
}
} else {
showAlert('Error removing order: ' + (data.message || 'Unknown error'), 'error');
}
})
.catch(error => {
console.error('Error deleting order:', error);
showAlert('Error removing order. Please try again.', 'error');
});
}
// Function to update shipment totals in the modal
function updateShipmentTotals(shipment) {
// Update totals section
const totalsRow = document.querySelector('.shipment-totals-row');
if (totalsRow) {
totalsRow.innerHTML = `
<div class="shipment-total-item">
<div class="shipment-total-label">Total CTN</div>
<div class="shipment-total-value total-ctn">${shipment.total_ctn}</div>
</div>
<div class="shipment-total-item">
<div class="shipment-total-label">Total QTY</div>
<div class="shipment-total-value total-quantity">${shipment.total_qty}</div>
</div>
<div class="shipment-total-item">
<div class="shipment-total-label">Total CBM</div>
<div class="shipment-total-value total-cbm">${shipment.total_cbm}</div>
</div>
<div class="shipment-total-item">
<div class="shipment-total-label">Total KG</div>
<div class="shipment-total-value total-weight">${shipment.total_kg}</div>
</div>
<div class="shipment-total-item">
<div class="shipment-total-label">Total TTL/QTY</div>
<div class="shipment-total-value total-quantity">${shipment.total_ttl_qty}</div>
</div>
<div class="shipment-total-item">
<div class="shipment-total-label">Total TTL/CBM</div>
<div class="shipment-total-value total-ttl-cbm">${shipment.total_ttl_cbm}</div>
</div>
<div class="shipment-total-item">
<div class="shipment-total-label">Total TTL/KG</div>
<div class="shipment-total-value total-ttl-kg">${shipment.total_ttl_kg}</div>
</div>
<div class="shipment-total-item">
<div class="shipment-total-label">Total Amount</div>
<div class="shipment-total-value total-amount">₹${parseFloat(shipment.total_amount).toLocaleString('en-IN', {minimumFractionDigits: 2, maximumFractionDigits: 2})}</div>
</div>
`;
}
}
// Function to show alert messages
function showAlert(message, type) {
const alertDiv = document.createElement('div');
alertDiv.className = `alert alert-${type === 'success' ? 'success' : 'danger'} alert-dismissible fade show position-fixed`;
alertDiv.style.cssText = 'top: 20px; right: 20px; z-index: 9999; min-width: 300px;';
alertDiv.innerHTML = `
<i class="bi ${type === 'success' ? 'bi-check-circle-fill' : 'bi-exclamation-triangle-fill'} me-2"></i>
${message}
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
`;
document.body.appendChild(alertDiv);
// Auto remove after 5 seconds
setTimeout(() => {
if (alertDiv.parentNode) {
alertDiv.parentNode.removeChild(alertDiv);
}
}, 5000);
}
// Toggle status dropdown
function toggleStatusDropdown(button, shipmentId) {
const dropdown = document.getElementById(`statusDropdown-${shipmentId}`);
const isShowing = dropdown.classList.contains('show');
// Close all other dropdowns
document.querySelectorAll('.status-dropdown.show').forEach(dropdown => {
dropdown.classList.remove('show');
});
// Toggle current dropdown
if (!isShowing) {
dropdown.classList.add('show');
}
// Close dropdown when clicking outside
document.addEventListener('click', function closeDropdown(e) {
if (!button.contains(e.target) && !dropdown.contains(e.target)) {
dropdown.classList.remove('show');
document.removeEventListener('click', closeDropdown);
}
});
}
// Auto-close dropdown after form submission
document.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('.status-form').forEach(form => {
form.addEventListener('submit', function() {
const dropdown = this.closest('.status-dropdown');
if (dropdown) {
dropdown.classList.remove('show');
}
});
});
});
</script>
@endsection