275 lines
13 KiB
PHP
275 lines
13 KiB
PHP
{{-- DHL Sendungen Block für Order Detail --}}
|
|
@if($shopping_order->dhlShipments && $shopping_order->dhlShipments->count() > 0)
|
|
<div class="card mb-4">
|
|
<div class="card-header bg-warning text-dark">
|
|
<h5 class="mb-0">
|
|
<i class="fas fa-shipping-fast"></i>
|
|
DHL Sendungen ({{ $shopping_order->dhlShipments->count() }})
|
|
</h5>
|
|
</div>
|
|
<div class="card-body p-0">
|
|
<div class="table-responsive">
|
|
<table class="table table-striped table-hover mb-0">
|
|
<thead class="thead-light">
|
|
<tr>
|
|
<th style="width: 80px;">#</th>
|
|
<th>Sendungsnummer</th>
|
|
<th>Status</th>
|
|
<th>Tracking</th>
|
|
<th>E-Mail</th>
|
|
@if (isset($isAdmin) && $isAdmin)
|
|
<th style="width: 150px;">Aktionen</th>
|
|
@endif
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach($shopping_order->dhlShipments as $shipment)
|
|
<tr class="{{ $shipment->type === 'return' ? 'bg-warning bg-opacity-10' : '' }}" style="{{ $shipment->type === 'return' ? 'background-color: rgba(255, 193, 7, 0.1);' : '' }}">
|
|
<td>
|
|
<a href="{{ route('admin.dhl.show', $shipment) }}" class="font-weight-bold {{ $shipment->type === 'return' ? 'text-warning' : 'text-primary' }}">
|
|
@if($shipment->type === 'return')<i class="fas fa-undo mr-1"></i>@endif#{{ $shipment->id }}
|
|
</a>
|
|
@if($shipment->type === 'return')
|
|
<br><span class="badge badge-warning badge-sm" style="font-weight: 600;">RETOURE</span>
|
|
@endif
|
|
</td>
|
|
<td>
|
|
@if($shipment->dhl_shipment_no)
|
|
<code class="text-success">{{ $shipment->dhl_shipment_no }}</code>
|
|
<br>
|
|
<a href="{{ $shipment->getTrackingUrl() }}" target="_blank" class="small text-muted">
|
|
<i class="fas fa-external-link-alt"></i> Bei DHL verfolgen
|
|
</a>
|
|
@else
|
|
<span class="text-muted">-</span>
|
|
@endif
|
|
</td>
|
|
<td>
|
|
<span class="badge badge-{{ $shipment->getStatusBadgeClass() }}">
|
|
{{ $shipment->status }}
|
|
</span>
|
|
@if($shipment->tracking_status)
|
|
<br><small class="text-muted">{{ $shipment->tracking_status }}</small>
|
|
@endif
|
|
</td>
|
|
<td>
|
|
@if($shipment->last_tracked_at)
|
|
<small class="text-muted">
|
|
{{ $shipment->last_tracked_at->format('d.m.Y H:i') }}
|
|
</small>
|
|
@else
|
|
<span class="text-muted">-</span>
|
|
@endif
|
|
</td>
|
|
<td>
|
|
@if($shipment->wasTrackingEmailSent())
|
|
<span class="badge badge-success" title="Gesendet am {{ $shipment->tracking_email_sent_at->format('d.m.Y H:i') }} ({{ $shipment->tracking_email_type === 'auto' ? 'automatisch' : 'manuell' }})">
|
|
<i class="fas fa-check"></i> {{ $shipment->tracking_email_sent_at->format('d.m.Y') }}
|
|
</span>
|
|
<br>
|
|
<small class="text-muted">
|
|
@if($shipment->tracking_email_type === 'auto')
|
|
<i class="fas fa-robot"></i> Automatisch
|
|
@else
|
|
<i class="fas fa-user"></i> Manuell
|
|
@endif
|
|
</small>
|
|
@else
|
|
<span class="badge badge-secondary">Nicht gesendet</span>
|
|
@endif
|
|
</td>
|
|
@if (isset($isAdmin) && $isAdmin)
|
|
<td>
|
|
<div class="btn-group btn-group-sm" role="group">
|
|
<a href="{{ route('admin.dhl.show', $shipment) }}" class="btn btn-outline-primary" title="Details">
|
|
<i class="fas fa-eye"></i>
|
|
</a>
|
|
@if($shipment->label_path)
|
|
<a href="{{ route('admin.dhl.download-label', $shipment) }}" class="btn btn-outline-success" title="Label herunterladen">
|
|
<i class="fas fa-download"></i>
|
|
</a>
|
|
@endif
|
|
@if($shipment->dhl_shipment_no)
|
|
<button type="button"
|
|
class="btn btn-outline-secondary dhl-update-tracking-btn"
|
|
data-shipment-id="{{ $shipment->id }}"
|
|
title="Tracking aktualisieren">
|
|
<i class="fas fa-sync"></i>
|
|
</button>
|
|
@if($shipment->canSendTrackingEmail())
|
|
<button type="button"
|
|
class="btn {{ $shipment->wasTrackingEmailSent() ? 'btn-success' : 'btn-outline-info' }} dhl-send-email-btn"
|
|
data-shipment-id="{{ $shipment->id }}"
|
|
title="{{ $shipment->wasTrackingEmailSent() ? 'E-Mail erneut senden' : 'Tracking-E-Mail senden' }}">
|
|
<i class="fas fa-envelope"></i>
|
|
</button>
|
|
@endif
|
|
@endif
|
|
@if($shipment->type === 'outbound' && !$shipment->returns->count())
|
|
<button type="button"
|
|
class="btn btn-outline-info dhl-create-return-btn"
|
|
data-shipment-id="{{ $shipment->id }}"
|
|
title="Retourenlabel erstellen">
|
|
<i class="fas fa-undo"></i>
|
|
</button>
|
|
@endif
|
|
@if($shipment->canCancel())
|
|
<button type="button"
|
|
class="btn btn-outline-danger dhl-cancel-shipment-btn"
|
|
data-shipment-id="{{ $shipment->id }}"
|
|
title="Sendung stornieren">
|
|
<i class="fas fa-ban"></i>
|
|
</button>
|
|
@endif
|
|
</div>
|
|
</td>
|
|
@endif
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
// Update tracking button
|
|
$('.dhl-update-tracking-btn').click(function() {
|
|
var shipmentId = $(this).data('shipment-id');
|
|
var btn = $(this);
|
|
|
|
btn.prop('disabled', true).html('<i class="fas fa-spinner fa-spin"></i>');
|
|
|
|
$.ajax({
|
|
url: `/admin/dhl/shipment/${shipmentId}/update-tracking`,
|
|
method: 'POST',
|
|
data: {
|
|
_token: '{{ csrf_token() }}'
|
|
},
|
|
success: function(response) {
|
|
if (response.success) {
|
|
location.reload();
|
|
} else {
|
|
alert('Fehler: ' + response.message);
|
|
btn.prop('disabled', false).html('<i class="fas fa-sync"></i>');
|
|
}
|
|
},
|
|
error: function() {
|
|
alert('Fehler beim Aktualisieren des Trackings.');
|
|
btn.prop('disabled', false).html('<i class="fas fa-sync"></i>');
|
|
}
|
|
});
|
|
});
|
|
|
|
// Send email button
|
|
$('.dhl-send-email-btn').click(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>');
|
|
|
|
$.ajax({
|
|
url: `/admin/dhl/shipment/${shipmentId}/send-tracking-email`,
|
|
method: 'POST',
|
|
data: {
|
|
_token: '{{ csrf_token() }}'
|
|
},
|
|
success: function(response) {
|
|
if (response.success) {
|
|
alert(response.message);
|
|
location.reload();
|
|
} else {
|
|
alert('Fehler: ' + response.message);
|
|
btn.prop('disabled', false).html('<i class="fas fa-envelope"></i>');
|
|
}
|
|
},
|
|
error: function(xhr) {
|
|
var errorMsg = xhr.responseJSON ? xhr.responseJSON.message : 'Fehler beim Senden der E-Mail.';
|
|
alert(errorMsg);
|
|
btn.prop('disabled', false).html('<i class="fas fa-envelope"></i>');
|
|
}
|
|
});
|
|
});
|
|
|
|
// Create return label button
|
|
$('.dhl-create-return-btn').click(function() {
|
|
var shipmentId = $(this).data('shipment-id');
|
|
var btn = $(this);
|
|
|
|
// Check if already processing
|
|
if (btn.prop('disabled')) {
|
|
return;
|
|
}
|
|
|
|
if (!confirm('Möchten Sie ein Retourenlabel für diese Sendung erstellen?')) {
|
|
return;
|
|
}
|
|
|
|
btn.prop('disabled', true).html('<i class="fas fa-spinner fa-spin"></i>');
|
|
|
|
$.ajax({
|
|
url: `/admin/dhl/shipment/${shipmentId}/return-label`,
|
|
method: 'POST',
|
|
data: {
|
|
_token: '{{ csrf_token() }}'
|
|
},
|
|
success: function(response) {
|
|
if (response.success) {
|
|
alert(response.message || 'Retourenlabel wurde erstellt!');
|
|
setTimeout(function() {
|
|
location.reload();
|
|
}, 1500);
|
|
} else {
|
|
alert('Fehler: ' + response.message);
|
|
btn.prop('disabled', false).html('<i class="fas fa-undo"></i>');
|
|
}
|
|
},
|
|
error: function(xhr) {
|
|
var errorMsg = xhr.responseJSON ? xhr.responseJSON.message : 'Fehler beim Erstellen des Retourenlabels.';
|
|
alert(errorMsg);
|
|
btn.prop('disabled', false).html('<i class="fas fa-undo"></i>');
|
|
}
|
|
});
|
|
});
|
|
|
|
// Cancel shipment button
|
|
$('.dhl-cancel-shipment-btn').click(function() {
|
|
var shipmentId = $(this).data('shipment-id');
|
|
var btn = $(this);
|
|
|
|
if (!confirm('Möchten Sie diese Sendung wirklich stornieren?\n\nDas Label wird bei DHL ungültig und kann nicht mehr verwendet werden.')) {
|
|
return;
|
|
}
|
|
|
|
btn.prop('disabled', true).html('<i class="fas fa-spinner fa-spin"></i>');
|
|
|
|
$.ajax({
|
|
url: `/admin/dhl/shipment/${shipmentId}/cancel`,
|
|
method: 'DELETE',
|
|
data: {
|
|
_token: '{{ csrf_token() }}'
|
|
},
|
|
success: function(response) {
|
|
if (response.success) {
|
|
alert(response.message || 'Sendung wird storniert...');
|
|
location.reload();
|
|
} else {
|
|
alert('Fehler: ' + response.message);
|
|
btn.prop('disabled', false).html('<i class="fas fa-ban"></i>');
|
|
}
|
|
},
|
|
error: function(xhr) {
|
|
var errorMsg = xhr.responseJSON ? xhr.responseJSON.message : 'Fehler beim Stornieren der Sendung.';
|
|
alert(errorMsg);
|
|
btn.prop('disabled', false).html('<i class="fas fa-ban"></i>');
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
@endif
|