fix form create update postcheck and precheck
This commit is contained in:
@@ -320,7 +320,7 @@ use Illuminate\Support\Facades\Auth;
|
||||
box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
|
||||
}
|
||||
|
||||
/* Claim tab specific styling */
|
||||
/* Claim tab specific styling - Enhanced and Fixed */
|
||||
#claimTransactionsTable {
|
||||
font-size: 14px;
|
||||
}
|
||||
@@ -352,6 +352,186 @@ use Illuminate\Support\Facades\Auth;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* Fixed column widths for claim table */
|
||||
#claimTransactionsTable th:nth-child(1),
|
||||
#claimTransactionsTable td:nth-child(1) {
|
||||
width: 12% !important;
|
||||
min-width: 100px !important;
|
||||
} /* Tanggal */
|
||||
#claimTransactionsTable th:nth-child(2),
|
||||
#claimTransactionsTable td:nth-child(2) {
|
||||
width: 10% !important;
|
||||
min-width: 80px !important;
|
||||
} /* SPK */
|
||||
#claimTransactionsTable th:nth-child(3),
|
||||
#claimTransactionsTable td:nth-child(3) {
|
||||
width: 12% !important;
|
||||
min-width: 100px !important;
|
||||
} /* No Polisi */
|
||||
#claimTransactionsTable th:nth-child(4),
|
||||
#claimTransactionsTable td:nth-child(4) {
|
||||
width: 20% !important;
|
||||
min-width: 150px !important;
|
||||
} /* Pekerjaan */
|
||||
#claimTransactionsTable th:nth-child(5),
|
||||
#claimTransactionsTable td:nth-child(5) {
|
||||
width: 8% !important;
|
||||
min-width: 60px !important;
|
||||
} /* Qty */
|
||||
#claimTransactionsTable th:nth-child(6),
|
||||
#claimTransactionsTable td:nth-child(6) {
|
||||
width: 15% !important;
|
||||
min-width: 120px !important;
|
||||
} /* Service Advisor */
|
||||
#claimTransactionsTable th:nth-child(7),
|
||||
#claimTransactionsTable td:nth-child(7) {
|
||||
width: 10% !important;
|
||||
min-width: 80px !important;
|
||||
} /* Status */
|
||||
#claimTransactionsTable th:nth-child(8),
|
||||
#claimTransactionsTable td:nth-child(8) {
|
||||
width: 8% !important;
|
||||
min-width: 80px !important;
|
||||
} /* Aksi */
|
||||
#claimTransactionsTable th:nth-child(9),
|
||||
#claimTransactionsTable td:nth-child(9) {
|
||||
width: 8% !important;
|
||||
min-width: 100px !important;
|
||||
} /* Pre Check */
|
||||
#claimTransactionsTable th:nth-child(10),
|
||||
#claimTransactionsTable td:nth-child(10) {
|
||||
width: 8% !important;
|
||||
min-width: 100px !important;
|
||||
} /* Post Check */
|
||||
|
||||
/* Action column specific styling - Enhanced */
|
||||
#claimTransactionsTable td:nth-child(8),
|
||||
#claimTransactionsTable td:nth-child(9),
|
||||
#claimTransactionsTable td:nth-child(10) {
|
||||
text-align: center !important;
|
||||
vertical-align: middle !important;
|
||||
padding: 8px 4px !important;
|
||||
}
|
||||
|
||||
/* Button alignment in action columns - Fixed */
|
||||
#claimTransactionsTable td:nth-child(8) .btn,
|
||||
#claimTransactionsTable td:nth-child(9) .btn,
|
||||
#claimTransactionsTable td:nth-child(10) .btn {
|
||||
margin: 1px 2px !important;
|
||||
vertical-align: middle !important;
|
||||
display: inline-block !important;
|
||||
}
|
||||
|
||||
/* Specific button styling for different types */
|
||||
#claimTransactionsTable .btn-success {
|
||||
background-color: #28a745 !important;
|
||||
border-color: #28a745 !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
#claimTransactionsTable .btn-warning {
|
||||
background-color: #ffc107 !important;
|
||||
border-color: #ffc107 !important;
|
||||
color: #212529 !important;
|
||||
}
|
||||
|
||||
#claimTransactionsTable .btn-primary {
|
||||
background-color: #007bff !important;
|
||||
border-color: #007bff !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
#claimTransactionsTable .btn-danger {
|
||||
background-color: #dc3545 !important;
|
||||
border-color: #dc3545 !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
/* Badge styling fixes */
|
||||
#claimTransactionsTable .badge-warning {
|
||||
background-color: #ffc107 !important;
|
||||
color: #212529 !important;
|
||||
}
|
||||
|
||||
#claimTransactionsTable .badge-success {
|
||||
background-color: #28a745 !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
#claimTransactionsTable .badge-info {
|
||||
background-color: #17a2b8 !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
#claimTransactionsTable .badge-danger {
|
||||
background-color: #dc3545 !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
/* DataTable specific fixes */
|
||||
#claimTransactionsTable_wrapper {
|
||||
overflow-x: auto !important;
|
||||
}
|
||||
|
||||
#claimTransactionsTable_wrapper .dataTables_scrollHead {
|
||||
overflow: hidden !important;
|
||||
}
|
||||
|
||||
#claimTransactionsTable_wrapper .dataTables_scrollBody {
|
||||
overflow-x: auto !important;
|
||||
}
|
||||
|
||||
/* Responsive adjustments for smaller screens */
|
||||
@media (max-width: 768px) {
|
||||
#claimTransactionsTable {
|
||||
font-size: 12px !important;
|
||||
}
|
||||
|
||||
#claimTransactionsTable th,
|
||||
#claimTransactionsTable td {
|
||||
padding: 8px 4px !important;
|
||||
}
|
||||
|
||||
#claimTransactionsTable .btn {
|
||||
font-size: 10px !important;
|
||||
padding: 3px 6px !important;
|
||||
min-width: 50px !important;
|
||||
}
|
||||
|
||||
#claimTransactionsTable .badge {
|
||||
font-size: 9px !important;
|
||||
padding: 3px 6px !important;
|
||||
}
|
||||
|
||||
/* Adjust column widths for mobile */
|
||||
#claimTransactionsTable th:nth-child(4),
|
||||
#claimTransactionsTable td:nth-child(4) {
|
||||
width: 25% !important;
|
||||
min-width: 120px !important;
|
||||
} /* Pekerjaan - wider on mobile */
|
||||
}
|
||||
|
||||
/* Additional fixes for DataTable rendering */
|
||||
.dataTables_wrapper .dataTables_length,
|
||||
.dataTables_wrapper .dataTables_filter,
|
||||
.dataTables_wrapper .dataTables_info,
|
||||
.dataTables_wrapper .dataTables_processing,
|
||||
.dataTables_wrapper .dataTables_paginate {
|
||||
color: #333 !important;
|
||||
}
|
||||
|
||||
.dataTables_wrapper .dataTables_paginate .paginate_button {
|
||||
padding: 0.5em 1em !important;
|
||||
margin: 0 2px !important;
|
||||
border-radius: 4px !important;
|
||||
}
|
||||
|
||||
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
|
||||
background: #007bff !important;
|
||||
color: white !important;
|
||||
border: 1px solid #007bff !important;
|
||||
}
|
||||
|
||||
/* Tab claim specific styling */
|
||||
#form-claim {
|
||||
background-color: #fff;
|
||||
@@ -737,9 +917,6 @@ use Illuminate\Support\Facades\Auth;
|
||||
<input type="hidden" name="category" value="work">
|
||||
<div class="work_multirow">
|
||||
@if (old('work_id') && old('form') == 'work')
|
||||
{{-- @php
|
||||
dd($errors->all());
|
||||
@endphp --}}
|
||||
<input type="hidden" class="work_field_counter" value="{{ count(old('work_id')) }}">
|
||||
@for ($i = 0; $i < count(old('work_id')); $i++)
|
||||
<div class="form-group row" id="work_field{{ $i+1 }}">
|
||||
@@ -957,20 +1134,21 @@ use Illuminate\Support\Facades\Auth;
|
||||
<h6 class="mb-3">Daftar Pekerjaan yang Dapat Diklaim</h6>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-hover" id="claimTransactionsTable">
|
||||
<thead class="thead-light">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="10%">Tanggal</th>
|
||||
<th width="15%">No. SPK</th>
|
||||
<th width="15%">No. Polisi</th>
|
||||
<th width="20%">Pekerjaan</th>
|
||||
<th width="10%">Qty</th>
|
||||
<th width="15%">Service Advisor</th>
|
||||
<th width="10%">Status</th>
|
||||
<th width="5%">Aksi</th>
|
||||
<th>Tanggal</th>
|
||||
<th>SPK</th>
|
||||
<th>No Polisi</th>
|
||||
<th>Pekerjaan</th>
|
||||
<th>Qty</th>
|
||||
<th>Service Advisor</th>
|
||||
<th>Status</th>
|
||||
<th>Aksi</th>
|
||||
<th>Pre Check</th>
|
||||
<th>Post Check</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- Data will be loaded via DataTables AJAX -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -1180,6 +1358,73 @@ use Illuminate\Support\Facades\Auth;
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal Edit Transaksi -->
|
||||
<div class="modal fade" id="editTransactionModal" tabindex="-1" role="dialog" aria-labelledby="editTransactionModalLabel">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="editTransactionModalLabel">Edit Transaksi</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<form id="editTransactionForm" action="" method="POST">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<input type="hidden" name="transaction_id" value="">
|
||||
<input type="hidden" name="from_transaction_page" value="1">
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label>No. SPK</label>
|
||||
<input type="text" class="form-control" name="spk" placeholder="No. SPK" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Tanggal</label>
|
||||
<input type="text" class="form-control" name="date" id="edit-transaction-date" placeholder="YYYY-MM-DD" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>No. Polisi</label>
|
||||
<input type="text" class="form-control" name="police_number" placeholder="No. Polisi" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Pekerjaan</label>
|
||||
<select class="form-control" name="work_id" required>
|
||||
<option value="" disabled>Pilih Pekerjaan</option>
|
||||
@foreach ($work_works as $work)
|
||||
<option value="{{ $work->id }}">{{ $work->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Qty</label>
|
||||
<input type="number" class="form-control" name="qty" min="1" placeholder="Qty" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Warranty</label>
|
||||
<select class="form-control" name="warranty" required>
|
||||
<option value="1">Ya</option>
|
||||
<option value="0">Tidak</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Service Advisor</label>
|
||||
<select class="form-control" name="user_sa_id" required>
|
||||
<option value="">Pilih Service Advisor</option>
|
||||
@foreach ($user_sas as $user_sa)
|
||||
<option value="{{ $user_sa->id }}">{{ $user_sa->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Tutup</button>
|
||||
<button type="submit" class="btn btn-success" id="editTransactionButton">Simpan</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal Detail Mutasi -->
|
||||
<div class="modal fade" id="mutationDetailModal" tabindex="-1" role="dialog" aria-labelledby="mutationDetailModalLabel">
|
||||
<div class="modal-dialog modal-xl" role="document">
|
||||
@@ -1866,6 +2111,11 @@ use Illuminate\Support\Facades\Auth;
|
||||
autoclose: true,
|
||||
todayHighlight: true
|
||||
});
|
||||
$("#edit-transaction-date").datepicker({
|
||||
format: 'yyyy-mm-dd',
|
||||
autoclose: true,
|
||||
todayHighlight: true
|
||||
});
|
||||
$("#date-opname").datepicker({
|
||||
format: 'yyyy-mm-dd',
|
||||
autoclose: true,
|
||||
@@ -2508,19 +2758,21 @@ use Illuminate\Support\Facades\Auth;
|
||||
}
|
||||
},
|
||||
columns: [
|
||||
{data: 'date', name: 'date'},
|
||||
{data: 'spk', name: 'spk'},
|
||||
{data: 'police_number', name: 'police_number'},
|
||||
{data: 'work_name', name: 'work_name'},
|
||||
{data: 'qty', name: 'qty'},
|
||||
{data: 'sa_name', name: 'sa_name'},
|
||||
{data: 'status', name: 'status', orderable: false},
|
||||
{data: 'action', name: 'action', orderable: false, searchable: false}
|
||||
{data: 'date', name: 'date', title: 'Tanggal'},
|
||||
{data: 'spk', name: 'spk', title: 'SPK'},
|
||||
{data: 'police_number', name: 'police_number', title: 'No Polisi'},
|
||||
{data: 'work_name', name: 'work_name', title: 'Pekerjaan'},
|
||||
{data: 'qty', name: 'qty', title: 'Qty'},
|
||||
{data: 'sa_name', name: 'sa_name', title: 'Service Advisor'},
|
||||
{data: 'status', name: 'status', title: 'Status', orderable: false},
|
||||
{data: 'action', name: 'action', title: 'Aksi', orderable: false, searchable: false},
|
||||
{data: 'action_precheck', name: 'action_precheck', title: 'Pre Check', orderable: false, searchable: false},
|
||||
{data: 'action_postcheck', name: 'action_postcheck', title: 'Post Check', orderable: false, searchable: false},
|
||||
],
|
||||
pageLength: 10,
|
||||
responsive: true,
|
||||
scrollX: true,
|
||||
order: [[0, 'desc']], // Sort by date descending
|
||||
order: [[0, 'desc']]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2934,49 +3186,71 @@ use Illuminate\Support\Facades\Auth;
|
||||
}
|
||||
|
||||
function editTransaction(transactionId) {
|
||||
// Redirect to edit page or show edit modal
|
||||
window.location.href = '{{ route("transaction.edit", ":id") }}'.replace(':id', transactionId);
|
||||
// Load transaction data and show modal with form
|
||||
$('#editTransactionModal').modal('show');
|
||||
const url = '{{ route("transaction.edit", ":id") }}'.replace(':id', transactionId);
|
||||
const action = '{{ route("transaction.update", ":id") }}'.replace(':id', transactionId);
|
||||
|
||||
// Reset form
|
||||
const form = document.getElementById('editTransactionForm');
|
||||
form.reset();
|
||||
form.action = action;
|
||||
form.querySelector('input[name="transaction_id"]').value = transactionId;
|
||||
|
||||
// Fetch data
|
||||
$.get(url, function(response) {
|
||||
if (response && response.status === 200 && response.data) {
|
||||
const trx = response.data;
|
||||
form.querySelector('input[name="spk"]').value = trx.spk || '';
|
||||
form.querySelector('input[name="date"]').value = trx.date || '';
|
||||
form.querySelector('input[name="police_number"]').value = trx.police_number || '';
|
||||
form.querySelector('select[name="work_id"]').value = trx.work_id || '';
|
||||
form.querySelector('input[name="qty"]').value = trx.qty || 1;
|
||||
form.querySelector('select[name="warranty"]').value = String(trx.warranty ?? '0');
|
||||
form.querySelector('select[name="user_sa_id"]').value = trx.user_sa_id || '';
|
||||
} else {
|
||||
Swal.fire({ icon: 'error', title: 'Error', text: 'Gagal memuat data transaksi' });
|
||||
}
|
||||
}).fail(function() {
|
||||
Swal.fire({ icon: 'error', title: 'Error', text: 'Terjadi kesalahan saat memuat data' });
|
||||
});
|
||||
}
|
||||
|
||||
function deleteTransaction(transactionId) {
|
||||
Swal.fire({
|
||||
title: 'Konfirmasi Hapus',
|
||||
text: 'Apakah Anda yakin ingin menghapus transaksi ini?',
|
||||
html: '<div class="text-left">Tindakan ini tidak dapat dibatalkan.<br>Hapus transaksi ini?</div>',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#d33',
|
||||
cancelButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ya, Hapus!',
|
||||
cancelButtonColor: '#6c757d',
|
||||
confirmButtonText: 'Ya, Hapus',
|
||||
cancelButtonText: 'Batal'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
// Send delete request
|
||||
$.ajax({
|
||||
url: '{{ route("transaction.destroy", ":id") }}'.replace(':id', transactionId),
|
||||
method: 'DELETE',
|
||||
method: 'POST',
|
||||
data: {
|
||||
_method: 'DELETE',
|
||||
_token: '{{ csrf_token() }}'
|
||||
},
|
||||
success: function(response) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Berhasil!',
|
||||
text: 'Transaksi berhasil dihapus',
|
||||
timer: 2000,
|
||||
title: 'Berhasil',
|
||||
text: response && response.message ? response.message : 'Transaksi berhasil dihapus',
|
||||
timer: 1800,
|
||||
showConfirmButton: false
|
||||
}).then(() => {
|
||||
// Refresh the table
|
||||
if (claimTransactionsTable) {
|
||||
claimTransactionsTable.ajax.reload();
|
||||
claimTransactionsTable.ajax.reload(null, false);
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function() {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Error',
|
||||
text: 'Gagal menghapus transaksi'
|
||||
});
|
||||
error: function(xhr) {
|
||||
const msg = (xhr.responseJSON && xhr.responseJSON.message) ? xhr.responseJSON.message : 'Gagal menghapus transaksi';
|
||||
Swal.fire({ icon: 'error', title: 'Error', text: msg });
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -3274,6 +3548,51 @@ use Illuminate\Support\Facades\Auth;
|
||||
initializePhysicalStock();
|
||||
handleServerSideErrors();
|
||||
initializeTabs();
|
||||
|
||||
// Handle edit transaction form submit via AJAX
|
||||
$(document).on('submit', '#editTransactionForm', function(e) {
|
||||
e.preventDefault();
|
||||
const form = this;
|
||||
const action = form.action;
|
||||
const formData = $(form).serialize();
|
||||
|
||||
// Disable button to prevent double submit
|
||||
const $btn = $('#editTransactionButton');
|
||||
$btn.prop('disabled', true).html('<i class="fa fa-spinner fa-spin"></i> Menyimpan...');
|
||||
|
||||
$.ajax({
|
||||
url: action,
|
||||
method: 'POST',
|
||||
data: formData,
|
||||
success: function(response) {
|
||||
$('#editTransactionModal').modal('hide');
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Berhasil',
|
||||
text: (response && response.message) ? response.message : 'Transaksi berhasil diperbarui',
|
||||
timer: 1800,
|
||||
showConfirmButton: false
|
||||
}).then(() => {
|
||||
if (claimTransactionsTable) {
|
||||
claimTransactionsTable.ajax.reload(null, false);
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function(xhr) {
|
||||
let msg = 'Gagal memperbarui transaksi';
|
||||
if (xhr.responseJSON && xhr.responseJSON.errors) {
|
||||
const errors = xhr.responseJSON.errors;
|
||||
msg = Object.values(errors).flat().join('\n');
|
||||
} else if (xhr.responseJSON && xhr.responseJSON.message) {
|
||||
msg = xhr.responseJSON.message;
|
||||
}
|
||||
Swal.fire({ icon: 'error', title: 'Error', text: msg });
|
||||
},
|
||||
complete: function() {
|
||||
$btn.prop('disabled', false).text('Simpan');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Handle sub-tab switching for transaksi tabs
|
||||
|
||||
Reference in New Issue
Block a user