223 lines
11 KiB
PHP
Executable File
223 lines
11 KiB
PHP
Executable File
<div class="btn-group btn-group-sm" role="group">
|
|
<!-- View Button -->
|
|
<a href="{{ route('mutations.show', $row->id) }}"
|
|
class="btn btn-sm btn-info mr-2">
|
|
Detail
|
|
</a>
|
|
|
|
@if($row->status->value === 'sent')
|
|
<!-- Receive Button (untuk dealer tujuan) -->
|
|
@if(auth()->user()->dealer_id == $row->to_dealer_id)
|
|
<button type="button"
|
|
class="btn btn-sm btn-primary btn-receive mr-2"
|
|
data-id="{{ $row->id }}"
|
|
data-bs-toggle="modal"
|
|
data-bs-target="#receiveModal{{ $row->id }}">
|
|
Terima
|
|
</button>
|
|
@endif
|
|
|
|
<!-- Cancel Button (untuk pengirim) -->
|
|
@if(auth()->user()->dealer_id == $row->from_dealer_id || auth()->user()->hasRole('admin'))
|
|
<button type="button"
|
|
class="btn btn-sm btn-warning btn-cancel mr-2"
|
|
data-id="{{ $row->id }}">
|
|
Batal
|
|
</button>
|
|
@endif
|
|
@endif
|
|
|
|
@if($row->status->value === 'received')
|
|
<!-- Approve Button (untuk pengirim atau admin) -->
|
|
@if(auth()->user()->dealer_id == $row->from_dealer_id || auth()->user()->hasRole('admin'))
|
|
<button type="button"
|
|
class="btn btn-sm btn-success btn-approve mr-2"
|
|
data-id="{{ $row->id }}"
|
|
data-bs-toggle="modal"
|
|
data-bs-target="#approveModal{{ $row->id }}">
|
|
Setujui
|
|
</button>
|
|
@endif
|
|
|
|
<!-- Reject Button (untuk pengirim atau admin) -->
|
|
@if(auth()->user()->dealer_id == $row->from_dealer_id || auth()->user()->hasRole('admin'))
|
|
<button type="button"
|
|
class="btn btn-sm btn-danger btn-reject mr-2"
|
|
data-id="{{ $row->id }}"
|
|
data-bs-toggle="modal"
|
|
data-bs-target="#rejectModal{{ $row->id }}">
|
|
Tolak
|
|
</button>
|
|
@endif
|
|
@endif
|
|
|
|
@if($row->status->value === 'approved')
|
|
<!-- Stock has already been moved automatically after approval -->
|
|
<div class="text-center">
|
|
<span class="btn btn-sm btn-success" style="cursor: default; pointer-events: none;">Selesai</span>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
|
|
<!-- Modal untuk Approve -->
|
|
<div class="modal fade" id="approveModal{{ $row->id }}" tabindex="-1" aria-labelledby="approveModalLabel{{ $row->id }}" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="approveModalLabel{{ $row->id }}">Setujui Mutasi</h5>
|
|
</div>
|
|
<form action="{{ route('mutations.approve', $row->id) }}" method="POST" class="approve-form">
|
|
@csrf
|
|
<div class="modal-body">
|
|
<div class="alert alert-info">
|
|
<strong>Konfirmasi!</strong> Anda akan menyetujui mutasi yang telah diterima oleh <strong>{{ $row->toDealer->name }}</strong>.
|
|
<br><strong>Stock akan dipindahkan secara otomatis setelah disetujui.</strong>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Catatan Persetujuan</label>
|
|
<textarea name="approval_notes" class="form-control" rows="3" placeholder="Opsional: tambahkan catatan..."></textarea>
|
|
</div>
|
|
|
|
<h6>Detail Produk yang Diterima:</h6>
|
|
<div class="table-responsive">
|
|
<table class="table table-sm table-bordered">
|
|
<thead>
|
|
<tr>
|
|
<th>Produk</th>
|
|
<th width="20%" class="text-center">Qty Diminta</th>
|
|
<th width="20%" class="text-center">Qty Diterima</th>
|
|
<th width="30%">Catatan</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach($row->mutationDetails as $detail)
|
|
<tr>
|
|
<td>{{ $detail->product->name }}</td>
|
|
<td class="text-center">{{ number_format($detail->quantity_requested, 2) }}</td>
|
|
<td class="text-center">
|
|
<span class="font-weight-bold {{ $detail->quantity_approved < $detail->quantity_requested ? 'text-warning' : 'text-success' }}">
|
|
{{ number_format($detail->quantity_approved, 2) }}
|
|
</span>
|
|
@if($detail->quantity_approved < $detail->quantity_requested)
|
|
<small class="text-muted d-block">
|
|
(Kurang {{ number_format($detail->quantity_requested - $detail->quantity_approved, 2) }})
|
|
</small>
|
|
@endif
|
|
</td>
|
|
<td>
|
|
<small class="text-muted">{{ $detail->notes ?: '-' }}</small>
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<p class="text-muted">Setelah disetujui, stock akan dipindahkan secara otomatis.</p>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
|
|
<button type="submit" class="btn btn-success">Setujui Mutasi</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Modal untuk Reject -->
|
|
<div class="modal fade" id="rejectModal{{ $row->id }}" tabindex="-1" aria-labelledby="rejectModalLabel{{ $row->id }}" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="rejectModalLabel{{ $row->id }}">Tolak Mutasi</h5>
|
|
</div>
|
|
<form action="{{ route('mutations.reject', $row->id) }}" method="POST">
|
|
@csrf
|
|
<div class="modal-body">
|
|
<div class="alert alert-warning">
|
|
<strong>Peringatan!</strong> Mutasi yang ditolak tidak dapat diubah lagi.
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Alasan Penolakan <span class="text-danger">*</span></label>
|
|
<textarea name="rejection_reason" class="form-control" rows="3" required placeholder="Masukkan alasan penolakan..."></textarea>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
|
|
<button type="submit" class="btn btn-danger">Tolak Mutasi</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Modal untuk Receive -->
|
|
<div class="modal fade" id="receiveModal{{ $row->id }}" tabindex="-1" aria-labelledby="receiveModalLabel{{ $row->id }}" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="receiveModalLabel{{ $row->id }}">Terima Mutasi</h5>
|
|
</div>
|
|
<form action="{{ route('mutations.receive', $row->id) }}" method="POST">
|
|
@csrf
|
|
<div class="modal-body">
|
|
<div class="alert alert-info">
|
|
<strong>Konfirmasi!</strong> Anda akan menerima mutasi dari <strong>{{ $row->fromDealer->name }}</strong>.
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Catatan Penerimaan</label>
|
|
<textarea name="reception_notes" class="form-control" rows="3" placeholder="Catatan kondisi barang saat diterima (opsional)"></textarea>
|
|
</div>
|
|
|
|
<h6>Detail Produk yang Diterima:</h6>
|
|
<div class="table-responsive">
|
|
<table class="table table-sm table-bordered">
|
|
<thead>
|
|
<tr>
|
|
<th>Produk</th>
|
|
<th width="15%" class="text-center">Qty Diminta</th>
|
|
<th width="15%" class="text-center">Qty Diterima</th>
|
|
<th width="35%">Catatan Produk</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach($row->mutationDetails as $index => $detail)
|
|
<tr>
|
|
<td>{{ $detail->product->name }}</td>
|
|
<td class="text-center">{{ number_format($detail->quantity_requested, 2) }}</td>
|
|
<td class="text-center">
|
|
<input type="number"
|
|
name="products[{{ $detail->id }}][quantity_approved]"
|
|
class="form-control form-control-sm text-center"
|
|
value="{{ $detail->quantity_requested }}"
|
|
min="0"
|
|
max="{{ $detail->quantity_requested }}"
|
|
step="0.01"
|
|
required>
|
|
</td>
|
|
<td>
|
|
<input type="text"
|
|
name="products[{{ $detail->id }}][notes]"
|
|
class="form-control form-control-sm"
|
|
placeholder="Catatan kondisi produk saat diterima">
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<p class="text-muted">Setelah menerima, mutasi akan menunggu persetujuan dari pengirim. Stock akan dipindahkan otomatis setelah disetujui.</p>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
|
|
<button type="submit" class="btn btn-primary">Ya, Terima Mutasi</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Complete Modal is no longer needed since stock moves automatically after approval -->
|