partial update create mutations workflow
This commit is contained in:
@@ -102,38 +102,43 @@
|
||||
</div>
|
||||
<div class="kt-portlet__body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-hover">
|
||||
<table class="table table-bordered table-hover mutation-detail-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No.</th>
|
||||
<th>Nama Produk</th>
|
||||
<th>Jumlah Diminta</th>
|
||||
<th>Jumlah Disetujui</th>
|
||||
<th>Status Approval</th>
|
||||
<th>Catatan</th>
|
||||
<th width="5%">No.</th>
|
||||
<th width="25%">Nama Produk</th>
|
||||
<th width="15%" class="text-center">Jumlah Diminta</th>
|
||||
<th width="15%" class="text-center">Jumlah Disetujui</th>
|
||||
<th width="15%" class="text-center">Status Approval</th>
|
||||
<th width="25%">Catatan</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($mutation->mutationDetails as $index => $detail)
|
||||
<tr>
|
||||
<td>{{ $index + 1 }}</td>
|
||||
<td class="text-center">{{ $index + 1 }}</td>
|
||||
<td>{{ $detail->product->name }}</td>
|
||||
<td>{{ number_format($detail->quantity_requested, 2) }}</td>
|
||||
<td>
|
||||
<td class="text-center">{{ number_format($detail->quantity_requested, 2) }}</td>
|
||||
<td class="text-center">
|
||||
@if($mutation->status->value === 'received' || $mutation->status->value === 'approved' || $mutation->status->value === 'completed')
|
||||
{{ number_format($detail->quantity_approved ?? 0, 2) }}
|
||||
@else
|
||||
<span class="text-muted">Belum ditentukan</span>
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
@if($mutation->status->value === 'received' || $mutation->status->value === 'approved' || $mutation->status->value === 'completed')
|
||||
<span class="kt-badge kt-badge--{{ $detail->approval_status_color }} kt-badge--pill">
|
||||
{{ $detail->approval_status }}
|
||||
</span>
|
||||
@else
|
||||
<span class="kt-badge kt-badge--secondary kt-badge--pill">Menunggu</span>
|
||||
@endif
|
||||
<td class="text-center">
|
||||
@php
|
||||
$textColorClass = match($detail->approval_status_color) {
|
||||
'success' => 'text-success',
|
||||
'warning' => 'text-warning',
|
||||
'danger' => 'text-danger',
|
||||
'info' => 'text-info',
|
||||
default => 'text-muted'
|
||||
};
|
||||
@endphp
|
||||
<span class="font-weight-bold {{ $textColorClass }}">
|
||||
{{ $detail->approval_status }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ $detail->notes ?? '-' }}</td>
|
||||
</tr>
|
||||
@@ -141,9 +146,9 @@
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="kt-font-bold">
|
||||
<td colspan="2">Total</td>
|
||||
<td>{{ number_format($mutation->mutationDetails->sum('quantity_requested'), 2) }}</td>
|
||||
<td>
|
||||
<td colspan="2" class="text-right">Total</td>
|
||||
<td class="text-center">{{ number_format($mutation->mutationDetails->sum('quantity_requested'), 2) }}</td>
|
||||
<td class="text-center">
|
||||
@if($mutation->status->value === 'received' || $mutation->status->value === 'approved' || $mutation->status->value === 'completed')
|
||||
{{ number_format($mutation->mutationDetails->sum('quantity_approved'), 2) }}
|
||||
@else
|
||||
@@ -165,8 +170,7 @@
|
||||
<div class="col-lg-12">
|
||||
@if($mutation->status->value === 'sent' && auth()->user()->dealer_id == $mutation->to_dealer_id)
|
||||
<!-- Receive Button for destination dealer -->
|
||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#receiveModal">
|
||||
<i class="la la-download"></i>
|
||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#receiveModal{{ $mutation->id }}">
|
||||
Terima Mutasi
|
||||
</button>
|
||||
@endif
|
||||
@@ -174,12 +178,10 @@
|
||||
@if($mutation->status->value === 'received' && (auth()->user()->dealer_id == $mutation->from_dealer_id || auth()->user()->hasRole('admin')))
|
||||
<!-- Approve Button for sender or admin -->
|
||||
<button type="button" class="btn btn-success btn-approve" data-id="{{ $mutation->id }}">
|
||||
<i class="la la-check"></i>
|
||||
Setujui Mutasi
|
||||
</button>
|
||||
<!-- Reject Button for sender or admin -->
|
||||
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#rejectModal">
|
||||
<i class="la la-times"></i>
|
||||
Tolak Mutasi
|
||||
</button>
|
||||
@endif
|
||||
@@ -187,7 +189,6 @@
|
||||
@if($mutation->status->value === 'approved')
|
||||
<!-- Complete Button -->
|
||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#completeModal">
|
||||
<i class="la la-check-circle"></i>
|
||||
Selesaikan Mutasi
|
||||
</button>
|
||||
@endif
|
||||
@@ -195,18 +196,11 @@
|
||||
@if($mutation->canBeCancelled() && (auth()->user()->dealer_id == $mutation->from_dealer_id || auth()->user()->hasRole('admin')))
|
||||
<!-- Cancel Button -->
|
||||
<button type="button" class="btn btn-warning" data-toggle="modal" data-target="#cancelModal">
|
||||
<i class="la la-ban"></i>
|
||||
Batalkan Mutasi
|
||||
</button>
|
||||
@endif
|
||||
|
||||
@if($mutation->status->value === 'completed')
|
||||
<!-- Print Button -->
|
||||
<a href="{{ route('mutations.print', $mutation->id) }}" class="btn btn-info" target="_blank">
|
||||
<i class="la la-print"></i>
|
||||
Cetak Laporan
|
||||
</a>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -217,8 +211,8 @@
|
||||
<!-- Modals -->
|
||||
@if($mutation->status->value === 'sent' && auth()->user()->dealer_id == $mutation->to_dealer_id)
|
||||
<!-- Receive Modal -->
|
||||
<div class="modal fade" id="receiveModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal fade" id="receiveModal{{ $mutation->id }}" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Terima Mutasi</h5>
|
||||
@@ -232,11 +226,55 @@
|
||||
<div class="alert alert-info">
|
||||
<strong>Konfirmasi!</strong> Anda akan menerima mutasi dari <strong>{{ $mutation->fromDealer->name }}</strong>.
|
||||
</div>
|
||||
<p>Setelah menerima, mutasi akan menunggu persetujuan dari pengirim sebelum stock dipindahkan.</p>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Catatan Penerimaan</label>
|
||||
<textarea name="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($mutation->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 sebelum stock dipindahkan.</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Batal</button>
|
||||
<button type="submit" class="btn btn-primary">Ya, Terima</button>
|
||||
<button type="submit" class="btn btn-primary">Ya, Terima Mutasi</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@@ -258,20 +296,51 @@
|
||||
<form action="{{ route('mutations.approve', $mutation->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>{{ $mutation->toDealer->name }}</strong>.
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Catatan Persetujuan</label>
|
||||
<textarea name="notes" class="form-control" rows="3" placeholder="Opsional: tambahkan catatan..."></textarea>
|
||||
</div>
|
||||
|
||||
<!-- Detail produk akan dimuat via AJAX -->
|
||||
<div id="mutation-details{{ $mutation->id }}">
|
||||
<div class="text-center">
|
||||
<div class="spinner-border" role="status">
|
||||
<span class="sr-only">Loading...</span>
|
||||
</div>
|
||||
<p>Memuat detail produk...</p>
|
||||
</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($mutation->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 siap untuk dipindahkan.</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Batal</button>
|
||||
@@ -372,71 +441,41 @@
|
||||
@endif
|
||||
@endsection
|
||||
|
||||
@section('styles')
|
||||
<style>
|
||||
/* Custom CSS for mutation detail table alignment */
|
||||
.mutation-detail-table {
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
.mutation-detail-table th,
|
||||
.mutation-detail-table td {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.mutation-detail-table .text-center {
|
||||
text-align: center !important;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Ensure proper alignment in approval modal */
|
||||
.approve-form .form-control.text-center {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
@endsection
|
||||
|
||||
@section('javascripts')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Handle Approve Button Click
|
||||
$(document).on('click', '.btn-approve', function() {
|
||||
var mutationId = $(this).data('id');
|
||||
|
||||
// Load mutation details via AJAX
|
||||
$.ajax({
|
||||
url: '/warehouse/mutations/' + mutationId + '/details',
|
||||
type: 'GET',
|
||||
beforeSend: function() {
|
||||
$('#mutation-details' + mutationId).html(
|
||||
'<div class="text-center">' +
|
||||
'<div class="spinner-border" role="status">' +
|
||||
'<span class="sr-only">Loading...</span>' +
|
||||
'</div>' +
|
||||
'<p>Memuat detail produk...</p>' +
|
||||
'</div>'
|
||||
);
|
||||
},
|
||||
success: function(response) {
|
||||
var detailsHtml = '<h6>Detail Produk:</h6>';
|
||||
detailsHtml += '<div class="table-responsive">';
|
||||
detailsHtml += '<table class="table table-sm">';
|
||||
detailsHtml += '<thead>';
|
||||
detailsHtml += '<tr>';
|
||||
detailsHtml += '<th>Produk</th>';
|
||||
detailsHtml += '<th>Diminta</th>';
|
||||
detailsHtml += '<th>Disetujui</th>';
|
||||
detailsHtml += '<th>Stock Tersedia</th>';
|
||||
detailsHtml += '</tr>';
|
||||
detailsHtml += '</thead>';
|
||||
detailsHtml += '<tbody>';
|
||||
|
||||
response.details.forEach(function(detail, index) {
|
||||
detailsHtml += '<tr>';
|
||||
detailsHtml += '<td>' + detail.product.name + '</td>';
|
||||
detailsHtml += '<td>' + parseFloat(detail.quantity_requested).toLocaleString() + '</td>';
|
||||
detailsHtml += '<td>';
|
||||
detailsHtml += '<input type="number" name="details[' + detail.id + '][quantity_approved]" ';
|
||||
detailsHtml += 'class="form-control form-control-sm" ';
|
||||
detailsHtml += 'value="' + detail.quantity_requested + '" ';
|
||||
detailsHtml += 'min="0" max="' + Math.min(detail.quantity_requested, detail.available_stock) + '" ';
|
||||
detailsHtml += 'step="0.01" required>';
|
||||
detailsHtml += '</td>';
|
||||
detailsHtml += '<td>' + parseFloat(detail.available_stock).toLocaleString() + '</td>';
|
||||
detailsHtml += '</tr>';
|
||||
});
|
||||
|
||||
detailsHtml += '</tbody>';
|
||||
detailsHtml += '</table>';
|
||||
detailsHtml += '</div>';
|
||||
|
||||
$('#mutation-details' + mutationId).html(detailsHtml);
|
||||
},
|
||||
error: function() {
|
||||
$('#mutation-details' + mutationId).html('<div class="alert alert-danger">Gagal memuat detail produk</div>');
|
||||
}
|
||||
});
|
||||
|
||||
$('#approveModal' + mutationId).modal('show');
|
||||
});
|
||||
|
||||
// Auto-calculate approved quantity based on available stock
|
||||
// Validate quantity approved in receive modal
|
||||
$(document).on('input', 'input[name*="quantity_approved"]', function() {
|
||||
var maxValue = parseFloat($(this).attr('max'));
|
||||
var currentValue = parseFloat($(this).val());
|
||||
@@ -445,7 +484,7 @@ $(document).ready(function() {
|
||||
$(this).val(maxValue);
|
||||
$(this).addClass('is-invalid');
|
||||
if (!$(this).siblings('.invalid-feedback').length) {
|
||||
$(this).after('<div class="invalid-feedback">Jumlah melebihi stock yang tersedia</div>');
|
||||
$(this).after('<div class="invalid-feedback">Quantity tidak boleh melebihi yang diminta</div>');
|
||||
}
|
||||
} else {
|
||||
$(this).removeClass('is-invalid');
|
||||
|
||||
Reference in New Issue
Block a user