Rapport-Laravel/resources/views/horizonreport/pob.blade.php

87 lines
4.0 KiB
PHP

@extends('layouts.vertical', ['page_title' => $title])
@section('content')
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card mt-3">
<div class="card-body">
<h4 class="page-title mb-0">{{ $title }}</h4>
@if ($access === false)
<div class="alert alert-danger mb-0 mt-3" role="alert">You do not have access to this report.</div>
@else
@if (!empty($error))
<div class="alert alert-danger mt-3" role="alert">{{ $error }}</div>
@endif
@if (!empty($message))
<div class="alert alert-success mt-3" role="alert">{{ $message }}</div>
@endif
<form method="get" action="/horizonreport/pob" class="row g-2 align-items-end mt-2" id="horizon-pob-form">
<div class="col-md-3">
<label for="horizon-pob-from" class="form-label">From</label>
<input
type="date"
class="form-control"
name="from"
id="horizon-pob-from"
value="{{ $from }}"
>
</div>
<div class="col-md-3">
<label for="horizon-pob-to" class="form-label">To</label>
<input
type="date"
class="form-control"
name="to"
id="horizon-pob-to"
value="{{ $to }}"
>
</div>
<div class="col-auto" id="horizon-pob-action">
@if (!empty($filePath))
<a href="{{ $filePath }}" class="btn btn-primary" download="pob-report.xlsx" target="_blank" rel="noopener">Download</a>
@else
<button type="submit" class="btn btn-primary" id="horizon-pob-fetch">Fetch</button>
@endif
</div>
</form>
@endif
</div>
</div>
</div>
</div>
</div>
@endsection
@section('script')
<script>
(function () {
var form = document.getElementById('horizon-pob-form');
if (!form) return;
var fromInput = document.getElementById('horizon-pob-from');
var toInput = document.getElementById('horizon-pob-to');
var action = document.getElementById('horizon-pob-action');
function showFetchButton() {
if (!action || action.querySelector('#horizon-pob-fetch')) return;
action.innerHTML = '<button type="submit" class="btn btn-primary" id="horizon-pob-fetch">Fetch</button>';
bindFetchButton();
}
function bindFetchButton() {
var fetchBtn = document.getElementById('horizon-pob-fetch');
if (!fetchBtn) return;
form.addEventListener('submit', function () {
fetchBtn.disabled = true;
fetchBtn.textContent = 'Fetching...';
}, { once: true });
}
if (fromInput) fromInput.addEventListener('change', showFetchButton);
if (toInput) toInput.addEventListener('change', showFetchButton);
bindFetchButton();
})();
</script>
@endsection