351 lines
16 KiB
PHP
351 lines
16 KiB
PHP
{{-- Shipment Information Display when shipments already exist --}}
|
|
<div class="modal-body">
|
|
<div class="row">
|
|
{{-- Left Column: Order Info --}}
|
|
<div class="col-md-6">
|
|
<h6 class="text-primary mb-3">
|
|
<i class="fas fa-info-circle"></i>
|
|
Bestellinformationen
|
|
</h6>
|
|
|
|
<div class="card bg-light">
|
|
<div class="card-body">
|
|
<h6 class="card-title">Bestellung #{{ $order->id }}</h6>
|
|
<div class="row">
|
|
<div class="col-6">
|
|
<small class="text-muted d-block">Kunde:</small>
|
|
<strong>{{ $order->shopping_user->billing_firstname ?? '' }}
|
|
{{ $order->shopping_user->billing_lastname ?? '' }}</strong>
|
|
</div>
|
|
<div class="col-6">
|
|
<small class="text-muted d-block">Datum:</small>
|
|
<strong>{{ $order->created_at->format('d.m.Y') }}</strong>
|
|
</div>
|
|
<div class="col-6 mt-2">
|
|
<small class="text-muted d-block">Wert:</small>
|
|
<strong>{{ number_format($order->total, 2, ',', '.') }} €</strong>
|
|
</div>
|
|
<div class="col-6 mt-2">
|
|
<small class="text-muted d-block">Artikel:</small>
|
|
<strong>{{ $order->shopping_order_items->count() }} Stück</strong>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{{-- Right Column: Shipment Summary --}}
|
|
<div class="col-md-6">
|
|
<h6 class="text-primary mb-3">
|
|
<i class="fas fa-shipping-fast"></i>
|
|
Sendungsübersicht
|
|
</h6>
|
|
|
|
<div class="card bg-light">
|
|
<div class="card-body">
|
|
<div class="text-center mb-3">
|
|
<i class="fas fa-box fa-2x text-success"></i>
|
|
<h5 class="mt-2">{{ count($existingShipments) }} Sendung(en) erstellt</h5>
|
|
</div>
|
|
|
|
<div class="row text-center">
|
|
<div class="col-6">
|
|
<small class="text-muted d-block">Letzte Sendung:</small>
|
|
<strong>{{ date('d.m.Y H:i', strtotime($existingShipments[0]['created_at'])) }}</strong>
|
|
</div>
|
|
<div class="col-6">
|
|
<small class="text-muted d-block">Status:</small>
|
|
<span class="badge badge-{{ $existingShipments[0]['status'] == 'created' ? 'success' : 'warning' }}">
|
|
{{ $existingShipments[0]['status_translated'] }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<hr>
|
|
|
|
{{-- Shipment Details --}}
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<h6 class="text-primary mb-3">
|
|
<i class="fas fa-list"></i>
|
|
Sendungsdetails
|
|
</h6>
|
|
|
|
@foreach($existingShipments as $index => $shipment)
|
|
<div class="card mb-3 {{ $shipment['type'] == 'outbound' ? 'border-primary' : 'border-info' }}">
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-8">
|
|
<div class="d-flex justify-content-between align-items-start mb-2">
|
|
<h6 class="mb-0">
|
|
@if($shipment['type'] == 'outbound')
|
|
<i class="fas fa-arrow-right text-primary"></i>
|
|
Ausgehende Sendung
|
|
@else
|
|
<i class="fas fa-undo text-info"></i>
|
|
Retoure
|
|
@endif
|
|
@if($index === 0)
|
|
<span class="badge badge-primary ml-2">Neueste</span>
|
|
@endif
|
|
</h6>
|
|
<span class="badge badge-{{ $shipment['status'] == 'created' ? 'success' : 'warning' }}">
|
|
{{ $shipment['status_translated'] }}
|
|
</span>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-sm-6">
|
|
<small class="text-muted d-block">Sendungsnummer:</small>
|
|
@if($shipment['shipment_number'])
|
|
<code class="text-success">{{ $shipment['shipment_number'] }}</code>
|
|
@else
|
|
<span class="text-muted">Nicht verfügbar</span>
|
|
@endif
|
|
</div>
|
|
{{--
|
|
<div class="col-sm-6">
|
|
<small class="text-muted d-block">Tracking-Nummer:</small>
|
|
@if($shipment['tracking_number'])
|
|
<code class="text-info">{{ $shipment['tracking_number'] }}</code>
|
|
@else
|
|
<span class="text-muted">Nicht verfügbar</span>
|
|
@endif
|
|
</div>
|
|
--}}
|
|
<div class="col-sm-6 mt-2">
|
|
<small class="text-muted d-block">Produktcode:</small>
|
|
<code>{{ $shipment['product_code'] }}</code>
|
|
</div>
|
|
<div class="col-sm-6 mt-2">
|
|
<small class="text-muted d-block">Gewicht:</small>
|
|
<strong>{{ number_format($shipment['weight'], 2) }} kg</strong>
|
|
</div>
|
|
<div class="col-sm-6 mt-2">
|
|
<small class="text-muted d-block">Erstellt:</small>
|
|
<strong>{{ date('d.m.Y H:i', strtotime($shipment['created_at'])) }}</strong>
|
|
</div>
|
|
@if($shipment['tracking_status'])
|
|
<div class="col-sm-6 mt-2">
|
|
<small class="text-muted d-block">Tracking-Status:</small>
|
|
<span class="badge badge-info">{{ $shipment['tracking_status_translated'] }}</span>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-4 text-right">
|
|
<div class="btn-group-vertical w-100">
|
|
@if($shipment['label_path'])
|
|
<a href="{{ route('admin.dhl.download-label', $shipment['id']) }}"
|
|
class="btn btn-success btn-sm mb-2">
|
|
<i class="fas fa-download"></i> Label herunterladen
|
|
</a>
|
|
@endif
|
|
|
|
@if($shipment['can_send_email'] ?? false)
|
|
<button type="button"
|
|
class="btn btn-info btn-sm mb-2 send-tracking-email-modal-btn"
|
|
data-shipment-id="{{ $shipment['id'] }}">
|
|
<i class="fas fa-envelope"></i> Tracking-E-Mail senden
|
|
</button>
|
|
@endif
|
|
|
|
<a href="{{ route('admin.dhl.show', $shipment['id']) }}"
|
|
class="btn btn-outline-primary btn-sm mb-2" target="_blank">
|
|
<i class="fas fa-eye"></i> Details anzeigen
|
|
</a>
|
|
{{-- Todo: Add tracking button
|
|
@if($shipment['can_cancel'])
|
|
<button type="button"
|
|
class="btn btn-outline-warning btn-sm mb-2"
|
|
onclick="cancelShipment({{ $shipment['id'] }})">
|
|
<i class="fas fa-ban"></i> Stornieren
|
|
</button>
|
|
@endif
|
|
|
|
@if($shipment['type'] == 'outbound' && !$shipment['is_delivered'])
|
|
<button type="button"
|
|
class="btn btn-outline-info btn-sm"
|
|
onclick="createReturnLabel({{ $shipment['id'] }})">
|
|
<i class="fas fa-undo"></i> Retoure erstellen
|
|
</button>
|
|
@endif
|
|
--}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
|
|
{{-- Action Buttons --}}
|
|
<div class="row mt-4">
|
|
<div class="col-12 text-center">
|
|
<div class="alert alert-info">
|
|
<i class="fas fa-info-circle"></i>
|
|
<strong>Hinweis:</strong> Für diese Bestellung wurden bereits DHL-Sendungen erstellt.
|
|
Sie können weitere Sendungen erstellen oder bestehende verwalten.
|
|
</div>
|
|
|
|
<button type="button"
|
|
class="btn btn-primary mr-2"
|
|
onclick="createAdditionalShipment()">
|
|
<i class="fas fa-plus"></i> Weitere Sendung erstellen
|
|
</button>
|
|
|
|
<a href="{{ route('admin.dhl.cockpit') }}"
|
|
class="btn btn-outline-secondary">
|
|
<i class="fas fa-list"></i> Zum DHL-Cockpit
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">
|
|
<i class="fas fa-times"></i> Schließen
|
|
</button>
|
|
</div>
|
|
|
|
<script>
|
|
function cancelShipment(shipmentId) {
|
|
if (!confirm('Möchten Sie diese Sendung wirklich stornieren?\n\nDieser Vorgang kann nicht rückgängig gemacht werden.')) {
|
|
return;
|
|
}
|
|
|
|
$.ajax({
|
|
url: `/admin/dhl/shipment/${shipmentId}/cancel`,
|
|
method: 'DELETE',
|
|
data: {
|
|
_token: '{{ csrf_token() }}'
|
|
},
|
|
success: function(response) {
|
|
if (response.success) {
|
|
showAlert('success', response.message);
|
|
setTimeout(function() {
|
|
location.reload();
|
|
}, 2000);
|
|
} else {
|
|
showAlert('error', response.message);
|
|
}
|
|
},
|
|
error: function(xhr) {
|
|
showAlert('error', 'Fehler beim Stornieren der Sendung.');
|
|
}
|
|
});
|
|
}
|
|
|
|
function createReturnLabel(shipmentId) {
|
|
if (!confirm('Möchten Sie ein Retourenlabel für diese Sendung erstellen?')) {
|
|
return;
|
|
}
|
|
|
|
$.ajax({
|
|
url: `/admin/dhl/shipment/${shipmentId}/return-label`,
|
|
method: 'POST',
|
|
data: {
|
|
_token: '{{ csrf_token() }}'
|
|
},
|
|
success: function(response) {
|
|
if (response.success) {
|
|
showAlert('success', response.message);
|
|
setTimeout(function() {
|
|
location.reload();
|
|
}, 2000);
|
|
} else {
|
|
showAlert('error', response.message);
|
|
}
|
|
},
|
|
error: function(xhr) {
|
|
showAlert('error', 'Fehler beim Erstellen des Retourenlabels.');
|
|
}
|
|
});
|
|
}
|
|
|
|
function createAdditionalShipment() {
|
|
// Reload modal in create mode
|
|
$.post('{{ route('modal_load') }}', {
|
|
action: 'create-dhl-shipment',
|
|
id: {{ $order->id }},
|
|
force_create: true,
|
|
_token: '{{ csrf_token() }}'
|
|
}).done(function(response) {
|
|
$('#modals-load-content .modal-dialog').html(response.html);
|
|
}).fail(function() {
|
|
alert('Fehler beim Laden des Erstellungsformulars.');
|
|
});
|
|
}
|
|
|
|
window.showAlert = function(type, message) {
|
|
var alertClass = type === 'success' ? 'alert-success' : 'alert-danger';
|
|
var iconClass = type === 'success' ? 'fas fa-check-circle' : 'fas fa-exclamation-circle';
|
|
|
|
var alertHtml = `
|
|
<div class="alert ${alertClass} alert-dismissible fade show" role="alert">
|
|
<i class="${iconClass}"></i>
|
|
${message}
|
|
<button type="button" class="close" data-dismiss="alert">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
`;
|
|
|
|
$('.modal-body').prepend(alertHtml);
|
|
|
|
// Auto-hide success alerts after 5 seconds
|
|
if (type === 'success') {
|
|
setTimeout(function() {
|
|
$('.alert-success').alert('close');
|
|
}, 5000);
|
|
}
|
|
}
|
|
|
|
// Initialize modal
|
|
$(document).ready(function() {
|
|
// Modal is ready for interaction
|
|
|
|
// Tracking E-Mail senden Button
|
|
$(document).on('click', '.send-tracking-email-modal-btn', function() {
|
|
var shipmentId = $(this).data('shipment-id');
|
|
var btn = $(this);
|
|
|
|
if (!confirm('Tracking-E-Mail an den Kunden senden?')) {
|
|
return;
|
|
}
|
|
|
|
btn.prop('disabled', true).html('<i class="fas fa-spinner fa-spin"></i> Wird gesendet...');
|
|
|
|
$.ajax({
|
|
url: `/admin/dhl/shipment/${shipmentId}/send-tracking-email`,
|
|
method: 'POST',
|
|
data: {
|
|
_token: '{{ csrf_token() }}'
|
|
},
|
|
success: function(response) {
|
|
if (response.success) {
|
|
showAlert('success', response.message);
|
|
btn.removeClass('btn-info').addClass('btn-success')
|
|
.html('<i class="fas fa-check"></i> E-Mail gesendet');
|
|
|
|
|
|
} else {
|
|
showAlert('error', response.message);
|
|
btn.prop('disabled', false).html('<i class="fas fa-envelope"></i> Tracking-E-Mail senden');
|
|
}
|
|
},
|
|
error: function(xhr) {
|
|
var errorMsg = xhr.responseJSON ? xhr.responseJSON.message : 'Fehler beim Senden der E-Mail.';
|
|
showAlert('error', errorMsg);
|
|
btn.prop('disabled', false).html('<i class="fas fa-envelope"></i> Tracking-E-Mail senden');
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|