133 lines
5.5 KiB
PHP
133 lines
5.5 KiB
PHP
@extends('layouts.master')
|
|
|
|
@section('content')
|
|
{{-- <div class="container"> --}}
|
|
<div class="card shadow-sm">
|
|
<div class="card-header d-flex justify-content-between align-items-center">
|
|
<h5 class="mb-0 font-weight-bold">{{ @$title }}</h5>
|
|
<button type="button" class="btn btn-sm btn-primary float-right" data-bs-toggle="modal" data-bs-target="#lockModal">
|
|
Hitung Data
|
|
</button>
|
|
</div>
|
|
|
|
<div class="card-body">
|
|
|
|
<div class="table-responsive">
|
|
<table class="table w-100"
|
|
data-search="true"
|
|
data-toggle="table"
|
|
data-pagination="true"
|
|
data-toolbar="#toolbar"
|
|
data-show-refresh="false"
|
|
data-url="{{route($route.'.grid')}}"
|
|
data-ajax-options='{"xhrFields": {"withCredentials": true}}'
|
|
data-sort-name="ids"
|
|
data-sort-order="desc"
|
|
data-page-size="10"
|
|
data-id-field="id"
|
|
id="grid-data">
|
|
<thead class="table-primary text-primary">
|
|
<tr>
|
|
<th data-field="created_at">Waktu Input</th>
|
|
<th data-field="inventory_year">Tahun Inventory</th>
|
|
<th data-field="status">Status</th>
|
|
<th data-field="executed_time">Waktu Eksekusi</th>
|
|
<th data-field="finished_time">Waktu Selesai</th>
|
|
<th data-field="duration">Durasi</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody></tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{-- </div> --}}
|
|
|
|
<!-- Lock Modal -->
|
|
<div class="modal fade" id="lockModal" tabindex="-1" aria-labelledby="lockModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="lockModalLabel">Hitung Data dari Produsen</h5>
|
|
</div>
|
|
<form action="{{ route($route.'.store') }}" method="POST" id="lockForm">
|
|
@csrf
|
|
<div class="modal-body">
|
|
<div class="form-group">
|
|
<label for="inventory_year">Tahun Inventory <span class="text-danger">*</span></label>
|
|
<select name="inventory_year" id="inventory_year" class="form-control w-100" required>
|
|
<option value=""></option>
|
|
@if (isset($availableYears) && count($availableYears) > 0)
|
|
@foreach ($availableYears as $year)
|
|
<option value="{{ $year }}">{{ $year }}</option>
|
|
@endforeach
|
|
@else
|
|
<option value="" disabled>Tidak ada tahun inventory yang terdata.</option>
|
|
@endif
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
|
|
<button type="submit" class="btn btn-primary">Hitung Data</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endsection
|
|
|
|
@section('js')
|
|
<script>
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
$(document).on('click', 'form button', function(e) {
|
|
var isCancelButton = $(this).hasClass('btn-secondary');
|
|
if (isCancelButton) {
|
|
return;
|
|
}
|
|
|
|
e.preventDefault();
|
|
var form = $(this).closest('form');
|
|
var actionText = $(this).text();
|
|
var inventoryYear = form.find('select[name="inventory_year"]').val() ?? form.find(
|
|
'input[name="inventory_year"]').val();
|
|
var isCopyActivityChecked = form.find('input[name="copy_activity"]:checked').val() ===
|
|
'yes';
|
|
|
|
// Construct the warning text
|
|
var warningText =
|
|
'Apakah Anda yakin ingin melakukan hitung data dari produsen ke data konsolidasi pada tahun inventory ' +
|
|
inventoryYear + '? Data yang sudah ada akan di-refresh/replace.';
|
|
|
|
Swal.fire({
|
|
title: 'Apakah Anda yakin?',
|
|
text: warningText,
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonColor: '#3085d6',
|
|
cancelButtonColor: '#d33',
|
|
confirmButtonText: 'Ya, ' + actionText + '!',
|
|
cancelButtonText: 'Batal'
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
form.submit();
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
@endsection
|
|
|
|
@section('js')
|
|
<script>
|
|
$(document).ready(function() {
|
|
$('#inventory_year').select2({
|
|
placeholder: 'Pilih Tahun',
|
|
width: '100%',
|
|
});
|
|
});
|
|
</script>
|
|
@endsection
|