tambah function untuk stok audit semasa

This commit is contained in:
Nur Izzati
2026-02-23 15:24:47 +08:00
parent 9f37340bea
commit a92ddca1f5
2 changed files with 113 additions and 56 deletions
@@ -15,10 +15,7 @@
<div class="container">
@if ($errors->any())
<div id="error-alert" class="flex justify-center">
<div id="alert-border-2" class="flex items-center p-4 text-red-800 border-t-4 border-red-300 bg-red-50 dark:text-red-400 dark:bg-gray-800 dark:border-red-800 px-10" role="alert">
<svg class="flex-shrink-0 w-4 h-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/>
</svg>
<div class="flex items-center p-4 text-red-800 border-t-4 border-red-300 bg-red-50 px-10" role="alert">
<div class="ms-3 text-sm font-medium ml-2 ">
@foreach ($errors->all() as $error)
{{ $error }}
@@ -29,58 +26,75 @@
@endif
<div class="flex w-full">
<div class="xl:w-2/3 2xl:w-1/2 p-8 mx-auto">
<div class="bg-yellow-600 text-gray-200 text-lg px-6 py-4 rounded-t-lg"><a href="/reports"
class="router-link-active"><i class="fas fa-backspace text-white"></i></a> <span
class="text-center mx-auto text-white font-bold">Laporan Stok Audit</span></div>
<div class="bg-yellow-600 text-gray-200 text-lg px-6 py-4 rounded-t-lg">
<a href="/reports">
<i class="fas fa-backspace text-white"></i>
</a>
<span class="text-center mx-auto text-white font-bold">
Laporan Stok Audit
</span>
</div>
<form method="get" id="formStokAudit" action="{{ route('reports.stok-audit.show') }}">
<div class="rounded bg-white shadow p-6">
<div class="pb-6"><label for="username"
class="font-semibold text-gray-700 block pb-1">Tarikh</label>
{{-- PILIHAN TARIKH --}}
<div class="pb-4">
<label class="font-semibold text-gray-700 block pb-1">
Pilihan Tarikh
</label>
<div class="flex items-center space-x-6 mb-3">
<label class="flex items-center">
<input type="radio" name="dateOption" value="manual" checked class="mr-2">
Pilih Tarikh
</label>
<label class="flex items-center">
<input type="radio" name="dateOption" value="current" class="mr-2">
Tarikh Semasa (Hari Ini)
</label>
</div>
<label class="font-semibold text-gray-700 block pb-1">
Tarikh
</label>
<div class="flex">
<span
class="text-gray-600 border border-2 rounded-l px-4 py-2 whitespace-no-wrap"
style="background-color: rgb(249, 250, 251);">Mula</span>
<input id="stock_audit_monthYear" name="monthYear" value=""
class="border border-2 border-l-0 rounded-r px-4 py-2 w-80r mr-2">
class="text-gray-600 border border-2 rounded-l px-4 py-2"
style="background-color: rgb(249, 250, 251);">
Pilih
</span>
<input type="date"
id="stock_audit_monthYear"
name="monthYear"
value=""
class="border border-2 border-l-0 rounded-r px-4 py-2 w-80 mr-2">
<div class="hidden">
<input type="radio" name="generateType" id="generateTypePdf"
value="pdf">
<input type="radio" name="generateType" id="generateTypeExcel"
value="excel">
<input type="radio" name="generateType" id="generateTypePdf" value="pdf">
<input type="radio" name="generateType" id="generateTypeExcel" value="excel">
</div>
<button id="generateExcel"
class="border border-yellow-600 text-yellow-600 font-montserrat py-2 px-8 font-medium rounded-xl hover:bg-yellow-600 hover:text-white transition-all duration-300 ml-5"
class="border border-yellow-600 text-yellow-600 py-2 px-8 rounded-xl hover:bg-yellow-600 hover:text-white transition-all duration-300 ml-5"
type="button">
<i class="fas fa-file-excel mr-2"></i>Excel
</button>
<button id="generatePdf"
class="border border-yellow-600 text-yellow-600 font-montserrat py-2 px-8 font-medium rounded-xl hover:bg-yellow-600 hover:text-white transition-all duration-300 ml-5"
class="border border-yellow-600 text-yellow-600 py-2 px-8 rounded-xl hover:bg-yellow-600 hover:text-white transition-all duration-300 ml-5"
type="button">
<i class="fas fa-eye mr-2"></i>View
</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<div kodcaw="operasi">
<div>
<!---->
<!---->
</div>
<div>
<!---->
<!---->
</div>
<div class="flex justify-between mb-2">
</div>
</div>
</div>
</main>
@include('layouts.footer')
@@ -90,30 +104,58 @@
@push('additional_scripts')
<script>
document.addEventListener("DOMContentLoaded", function(event) {
document.addEventListener("DOMContentLoaded", function() {
let form = document.querySelector('#formStokAudit')
let form = document.querySelector('#formStokAudit');
document.querySelector('button#generatePdf').addEventListener("click", function(event) {
// ===== BUTTON PDF =====
document.querySelector('#generatePdf').addEventListener("click", function() {
document.querySelector('#generateTypePdf').checked = true;
form.submit();
})
});
document.querySelector('button#generateExcel').addEventListener("click", function(event) {
// ===== BUTTON EXCEL =====
document.querySelector('#generateExcel').addEventListener("click", function() {
document.querySelector('#generateTypeExcel').checked = true;
form.submit();
})
});
// ===== TARIKH OPTION =====
const dateInput = document.getElementById('stock_audit_monthYear');
const dateOptions = document.querySelectorAll('input[name="dateOption"]');
dateOptions.forEach(option => {
option.addEventListener('change', function () {
if (this.value === 'current') {
let today = new Date();
let day = String(today.getDate()).padStart(2, '0');
let month = String(today.getMonth() + 1).padStart(2, '0');
let year = today.getFullYear();
dateInput.value = year + '-' + month + '-' + day;
// Ganti readOnly dengan disable
dateInput.disabled = true;
} else {
dateInput.disabled = false;
dateInput.value = '';
}
});
});
// ===== AUTO HIDE ERROR =====
const errorAlert = document.getElementById("error-alert");
if (errorAlert) {
setTimeout(function() {
errorAlert.classList.add = "opacity-0";
errorAlert.classList.add("opacity-0");
setTimeout(function() {
errorAlert.style.display = "none";
}, 500)
}, 5000); // 5000 milliseconds = 5 seconds
}, 500);
}, 5000);
}
});
</script>