fix style transaction page
This commit is contained in:
@@ -1321,7 +1321,7 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setup form fields without stock checking
|
// Setup form fields without stock checking
|
||||||
$(document).ready(function() {
|
function setupFormFields() {
|
||||||
// Ensure transaksi tab is active by default if no tab is active
|
// Ensure transaksi tab is active by default if no tab is active
|
||||||
if (!$('.nav-tabs-line-primary .nav-link.active').length) {
|
if (!$('.nav-tabs-line-primary .nav-link.active').length) {
|
||||||
$('.nav-link[href="#transaksi"]').addClass('active');
|
$('.nav-link[href="#transaksi"]').addClass('active');
|
||||||
@@ -1373,7 +1373,7 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
console.log('Old work_id values:', @json(old('work_id')));
|
console.log('Old work_id values:', @json(old('work_id')));
|
||||||
@endif
|
@endif
|
||||||
@endif
|
@endif
|
||||||
});
|
}
|
||||||
|
|
||||||
// Function to add form fields (stock checking removed)
|
// Function to add form fields (stock checking removed)
|
||||||
function addFormFieldWithStockCheck(form) {
|
function addFormFieldWithStockCheck(form) {
|
||||||
@@ -1604,9 +1604,6 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
|
|
||||||
$("#opnameForm").submit(function(e) {
|
$("#opnameForm").submit(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Set default values for empty fields and validate
|
// Set default values for empty fields and validate
|
||||||
var hasValidStock = false;
|
var hasValidStock = false;
|
||||||
|
|
||||||
@@ -1709,8 +1706,6 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
$(document).on('submit', '#mutasiForm', function(e) {
|
$(document).on('submit', '#mutasiForm', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Validate form
|
// Validate form
|
||||||
var isValid = true;
|
var isValid = true;
|
||||||
var errorMessages = [];
|
var errorMessages = [];
|
||||||
@@ -1794,8 +1789,6 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
isValid = false;
|
isValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
// Highlight invalid fields
|
// Highlight invalid fields
|
||||||
if (!$('#to_dealer_id').val()) {
|
if (!$('#to_dealer_id').val()) {
|
||||||
@@ -1861,8 +1854,8 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Initialize datepickers when document is ready
|
// Initialize datepickers
|
||||||
$(document).ready(function() {
|
function initializeDatepickers() {
|
||||||
$("#date-work").datepicker({
|
$("#date-work").datepicker({
|
||||||
format: 'yyyy-mm-dd',
|
format: 'yyyy-mm-dd',
|
||||||
autoclose: true,
|
autoclose: true,
|
||||||
@@ -1885,7 +1878,7 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
autoclose: true,
|
autoclose: true,
|
||||||
todayHighlight: true
|
todayHighlight: true
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
// Calculate difference for opname
|
// Calculate difference for opname
|
||||||
$(document).on('input change keyup', '.physical-stock', function() {
|
$(document).on('input change keyup', '.physical-stock', function() {
|
||||||
@@ -1930,16 +1923,14 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize default values for physical stock inputs
|
// Initialize default values for physical stock inputs
|
||||||
$(document).ready(function() {
|
function initializePhysicalStock() {
|
||||||
$('.physical-stock').each(function() {
|
$('.physical-stock').each(function() {
|
||||||
var value = $(this).val();
|
var value = $(this).val();
|
||||||
if (value === '' || value === null || value === undefined) {
|
if (value === '' || value === null || value === undefined) {
|
||||||
$(this).val('0.00');
|
$(this).val('0.00');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
// Handle when input loses focus - set default if empty
|
// Handle when input loses focus - set default if empty
|
||||||
$(document).on('blur', '.physical-stock', function() {
|
$(document).on('blur', '.physical-stock', function() {
|
||||||
@@ -1989,7 +1980,7 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Handle server-side errors - scroll to first error and highlight
|
// Handle server-side errors - scroll to first error and highlight
|
||||||
$(document).ready(function() {
|
function handleServerSideErrors() {
|
||||||
// Set default date for opname if empty
|
// Set default date for opname if empty
|
||||||
if ($('#date-opname').val() === '') {
|
if ($('#date-opname').val() === '') {
|
||||||
var today = new Date().toISOString().split('T')[0];
|
var today = new Date().toISOString().split('T')[0];
|
||||||
@@ -2014,8 +2005,6 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Check if we should show specific tab (after form submission)
|
// Check if we should show specific tab (after form submission)
|
||||||
@if(session('success') || session('error') || $errors->any())
|
@if(session('success') || session('error') || $errors->any())
|
||||||
@if(session('active_tab') == 'opname')
|
@if(session('active_tab') == 'opname')
|
||||||
@@ -2083,8 +2072,6 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
@endif
|
@endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Handle success/error messages for both opname and mutasi
|
// Handle success/error messages for both opname and mutasi
|
||||||
@if(session('success'))
|
@if(session('success'))
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
@@ -2236,7 +2223,7 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
confirmButtonText: 'OK'
|
confirmButtonText: 'OK'
|
||||||
});
|
});
|
||||||
@endif
|
@endif
|
||||||
});
|
}
|
||||||
|
|
||||||
// Handle opname date field - set default if becomes empty
|
// Handle opname date field - set default if becomes empty
|
||||||
$('#date-opname').on('blur', function() {
|
$('#date-opname').on('blur', function() {
|
||||||
@@ -2249,8 +2236,6 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
// Handle mutasi form - similar to create mutation
|
// Handle mutasi form - similar to create mutation
|
||||||
var productIndexMutasi = 0;
|
var productIndexMutasi = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Function to submit mutasi form directly
|
// Function to submit mutasi form directly
|
||||||
function submitMutasiFormDirect() {
|
function submitMutasiFormDirect() {
|
||||||
console.log('=== SUBMITTING FORM ===');
|
console.log('=== SUBMITTING FORM ===');
|
||||||
@@ -2301,10 +2286,6 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Add product row for mutasi
|
// Add product row for mutasi
|
||||||
$('#add-product-mutasi').click(function() {
|
$('#add-product-mutasi').click(function() {
|
||||||
productIndexMutasi++;
|
productIndexMutasi++;
|
||||||
@@ -2536,7 +2517,7 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
{data: 'status', name: 'status', orderable: false},
|
{data: 'status', name: 'status', orderable: false},
|
||||||
{data: 'action', name: 'action', orderable: false, searchable: false}
|
{data: 'action', name: 'action', orderable: false, searchable: false}
|
||||||
],
|
],
|
||||||
pageLength: 15,
|
pageLength: 10,
|
||||||
responsive: true,
|
responsive: true,
|
||||||
scrollX: true,
|
scrollX: true,
|
||||||
order: [[0, 'desc']], // Sort by date descending
|
order: [[0, 'desc']], // Sort by date descending
|
||||||
@@ -2892,11 +2873,6 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Functions for claim transactions
|
// Functions for claim transactions
|
||||||
function viewTransaction(transactionId) {
|
function viewTransaction(transactionId) {
|
||||||
// Show transaction detail modal
|
// Show transaction detail modal
|
||||||
@@ -3149,8 +3125,6 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function createTransaction(form) {
|
function createTransaction(form) {
|
||||||
let work_ids;
|
let work_ids;
|
||||||
if(form == 'work') {
|
if(form == 'work') {
|
||||||
@@ -3198,15 +3172,8 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Ensure transaksi tab is shown by default
|
// Ensure transaksi tab is shown by default
|
||||||
$(document).ready(function() {
|
function initializeTabs() {
|
||||||
// First, ensure all tabs are properly hidden
|
// First, ensure all tabs are properly hidden
|
||||||
$('#transaksi, #stock').removeClass('active');
|
$('#transaksi, #stock').removeClass('active');
|
||||||
$('.nav-tabs-line-primary .nav-link').removeClass('active');
|
$('.nav-tabs-line-primary .nav-link').removeClass('active');
|
||||||
@@ -3300,14 +3267,18 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
initClaimTransactionsTable();
|
initClaimTransactionsTable();
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main document ready function - consolidate all initialization
|
||||||
|
$(document).ready(function() {
|
||||||
|
// Initialize all components
|
||||||
|
setupFormFields();
|
||||||
|
initializeDatepickers();
|
||||||
|
initializePhysicalStock();
|
||||||
|
handleServerSideErrors();
|
||||||
|
initializeTabs();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Handle sub-tab switching for transaksi tabs
|
// Handle sub-tab switching for transaksi tabs
|
||||||
$('#transaksi .nav-tabs-line-success .nav-link').on('click', function(e) {
|
$('#transaksi .nav-tabs-line-success .nav-link').on('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user