Files
2026-09-21 13:25:44 +01:00

321 lines
18 KiB
PHP
Executable File

@extends('m3::liberty-theme.layout.main')
@section('title')
Closed order lines report
@endsection
@section('content')
<div class="container-fluid px-4">
<h1 class="mt-4">Closed order lines report</h1>
<ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="pills-home-tab" data-bs-toggle="pill" data-bs-target="#pills-home" type="button" role="tab" aria-controls="pills-home" aria-selected="true">Daily report</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-profile-tab" data-bs-toggle="pill" data-bs-target="#pills-profile" type="button" role="tab" aria-controls="pills-profile" aria-selected="false">Download Reports</button>
</li>
</ul>
<div class="tab-content" id="pills-tabContent">
<div class="tab-pane fade show active" id="pills-home" role="tabpanel" aria-labelledby="pills-home-tab">
<div class="card mb-4">
<div class="card-header">
<form class="needs-validation" enctype="multipart/form-data" method="GET" action="{{ route("m3.OrderLinesOfClosedOrder") }}">
<div class="row d-flex flex-row align-items-center">
@php
$REPORTDATEDisp = old('REPORTDATEDisp') ?? \DateTime::createFromFormat('Ymd',$REPORTDATEDisp)->format('Y-m-d');
@endphp
<div class="col">
<label for="REPORTDATEDisp">Date</label>
<input type="date" class="form-control" id="REPORTDATEDisp" name="REPORTDATEDisp" value="{{ $REPORTDATEDisp }}" max={{ date('Y-m-d') }} required>
</div>
<div class="col">
<label for="WHDDA" >Warehouse:</label>
<select class="form-select" id="WHDDA" tabindex="-1" disabled>
@foreach ($IC670M as $key => $IC670MR)
@php $currentWHDDA = trim($IC670MR->WDCO).trim($IC670MR->WDPL).trim($IC670MR->WDWHS); @endphp
<option value="{{ $currentWHDDA }}"
data-comp="{{ trim($IC670MR->WDCO) }}" data-pl="{{ trim($IC670MR->WDPL) }}" data-wh="{{ trim($IC670MR->WDWHS) }}"
{{ ($WHDDA!='' && $WHDDA==$currentWHDDA) ? "selected" : "" }}>
{{ trim(Str::upper($IC670MR->WDWNAM)) }}
</option>
@endforeach
</select>
</div>
<div class="col">
<label for="recipient-name">Division:</label>
<label for="COMPANY" class="visually-hidden">COMPANY</label>
<input type="text" class="form-control" id="COMPANY" required readonly>
</div>
<div class="col">
<label for="recipient-name">Plant:</label>
<label for="PLANT" class="visually-hidden">PLANT</label>
<input type="text" class="form-control" id="PLANT" required readonly>
</div>
<div class="col">
<label for="recipient-name">Warehouse:</label>
<label for="WHS" class="visually-hidden">WHS</label>
<input type="text" class="form-control" id="WHS" required readonly>
</div>
<div class="col">
<button type="submit" class="btn btn-primary mt-4" id="filterTop">Submit</button>
</div>
</div>
</form>
</div>
<div class="card-body">
<div class="container-fluid table-responsive">
<table class="table table-striped table-bordered table-hover" id="datatableslinesCLosed" style="width:100%">
<th scope="col"ead>
<tr>
<th scope="col"></th>
<th scope="col">Close Date</th>
<th scope="col">Delivery #</th>
<th scope="col">Order #</th>
<th scope="col">Terms</th>
<th scope="col">Weight</th>
<th scope="col">Carrier</th>
<th scope="col">Mode</th>
<th scope="col">Order Type</th>
<th scope="col">Part #</th>
<th scope="col">Reserved</th>
<th scope="col">Packed</th>
<th scope="col">Back Order Qty</th>
<th scope="col">Value Packed $</th>
<th scope="col">Customer name</th>
{{-- <th scope="col">Date</th>
<th scope="col">Time</th> --}}
<th scope="col">Failure Reason</th>
<th scope="col">Currency Code</th>
<th scope="col">Freight</th>
</tr>
</thead>
<tbody>
@foreach($ICM688M2 as $key=>$ICM688M2R)
<tr>
<td></td>
<td>{{ $ICM688M2R->SHDT }} {{ $ICM688M2R->SHTIME }} </td>
<td class="text-end"><a type="button" class="btn btn-link" target="_blank" href="/php/AllSentPkr.php?macpkr_input={{ $ICM688M2R->A5MACPKR }}">{{ $ICM688M2R->A5MACPKR }}</a></td>
<td class="text-end"> {{ $ICM688M2R->A5ONO }} </td>
<td class="text-end"> {{ $ICM688M2R->A4OFSTRM }} </td>
<td class="text-end"> {{ number_format($ICM688M2R->WEIGHT, 2, '.', ',') }} </td>
<td class="text-end"> {{ $ICM688M2R->A4SCAC }} </td>
<td class="text-end"> {{ $ICM688M2R->A4SHIPTYPE }} </td>
<td class="text-end"> {{ $ICM688M2R->A4REFORD }} </td>
<td> {{ $ICM688M2R->A5PART }} </td>
<td class="text-end"> {{ number_format($ICM688M2R->A5RSVQTY, 0, '.', ',') }} </td>
<td class="text-end"> {{ number_format($ICM688M2R->A5PACKED, 0, '.', ',') }} </td>
<td class="text-end"> {{ number_format($ICM688M2R->CALCULATED_COLUMN, 0, '.', ',') }} </td>
<td class="text-end">{{ number_format($ICM688M2R->ANOTHER_CALCULATED_COLUMN, 2, '.', ',') }}</td>
<td>{{ $ICM688M2R->A4SHSHNM }} </td>
{{-- <td>{{ $ICM688M2R->SHDT }} </td>
<td>{{ $ICM688M2R->SHTIME }} </td> --}}
<td>{{ substr($ICM688M2R->REASON,0,150) }} </td>
<td>{{ $ICM688M2R->A1SHCURR }} </td>
<td>{{ $ICM688M2R->FREIGHT }} </td>
</tr>
@endforeach
</tbody>
<tfoot>
<tr>
<th scope="col" colspan="12"></th>
<th scope="col">Total:</th>
<th scope="col" class="text-end"></th>
<th scope="col"></th><th scope="col"></th><th scope="col"></th>
{{-- <th scope="col"></th><th scope="col"></th> --}}
<th scope="col"></th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab">
<div class="card mb-4">
<div class="card-header">
<form class="needs-validation" enctype="multipart/form-data" method="GET" action="{{ route("m3.OrderLinesOfClosedOrder") }}">
<div class="row d-flex flex-row align-items-center">
@php
$todayDate = today()->format('Ymd');
$reportDate = old('REPORTDATE') ?? \DateTime::createFromFormat('Ymd',$todayDate)->format('Y-m-d');
$toreportDate = old('TOREPORTDATE') ?? \DateTime::createFromFormat('Ymd', $todayDate)->format('Y-m-d');
@endphp
<div class="col">
<label for="REPORTDATE">From Date</label>
<input type="date" class="form-control" id="REPORTDATE" name="REPORTDATE" value="{{ $reportDate }}" max={{ date('Y-m-d') }} required>
</div>
<div class="col">
<label for="REPORTDATE">To Date</label>
<label for="TOREPORTDATE" class="visually-hidden">TOREPORTDATE</label>
<input type="date" class="form-control" id="TOREPORTDATE" name="TOREPORTDATE" value="{{ $toreportDate }}" max={{ date('Y-m-d') }} required>
</div>
<div class="col">
<button type="button" class="btn btn-primary mt-4" id="exportExcel">Download Excel</button>
{{-- MAK Used temporarly to generate report on AS400 --}}
{{-- <button type="button" class="btn btn-primary mt-4" id="saveExcel">Save Excel</button> --}}
</div>
</div>
</form>
{{-- Form for Export --}}
<form enctype="multipart/form-data" method="POST" action="{{ route("m3.exporttoExcel") }}" id="exporttoExcelForm">
@csrf
<input type="hidden" name="REPORTDATE" id="REPORTDATE1" value="">
<input type="hidden" name="TOREPORTDATE" id="TOREPORTDATE1" value="">
</form>
{{-- Form for Saving Excel --}}
<form enctype="multipart/form-data" method="POST" action="{{ route("m3.StoreExcelToDisk") }}" id="StoreExcelToDiskForm">
@csrf
<input type="hidden" name="REPORTDATE" id="REPORTDATE2" value="">
<input type="hidden" name="TOREPORTDATE" id="TOREPORTDATE2" value="">
</form>
</div>
<div class="card-body">
@foreach ($allReportsUrls as $fileName=>$reportsUrl)
@php
$fileNameOnly = strpos($fileName, '/')!= false ? substr($fileName, strpos($fileName, '/') + 1) : $fileName;
@endphp
<a href='{{ route('m3.downloadFiles', ['filename' => $fileName]) }}' >{{ $fileNameOnly }}</a><br>
@endforeach
</div>
</div>
{{-- @foreach ($allReportsUrls as $fileName=>$reportsUrl)
@php
$fileNameOnly = strpos($fileName, '/')!= false ? substr($fileName, strpos($fileName, '/') + 1) : $fileName;
@endphp
<a href='{{ route('m3.downloadFiles', ['filename' => $fileName]) }}' >{{ $fileNameOnly }}</a><br>
@endforeach --}}
</div>
</div>
</div>
@endsection
@section('scripts')
<script>
$(document).ready(function() {
// DataTable init
var myTable = $('#datatableslinesCLosed').DataTable({
"aaSorting": [],
"lengthMenu": [ [25,50,100,-1], [25,50,100,"All"] ],
"sPaginationType": "full_numbers",
dom: "<'row mt-2'<'col-sm-12 col-md-2'l><'col-sm-12 col-md-6'B><'col-sm-12 col-md-3'f>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row mt-2'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
// "dom": 'lBfrtip',
"responsive": true,
"orderCellsTop": true,
"order": [ [1, 'asc'] ],
"pageLength": 100,
"select": true,
"columnDefs": [
{
orderable: false,
className: 'select-checkbox',
targets: 0
}
],
buttons: [
{
extend: 'selectAll',
className: 'btn-primary mr-1'
},
{
extend: 'selectNone',
className: 'btn-primary mr-1'
},
{
extend: 'copy',
className: 'btn-secondary mr-1'
},
{
extend: 'csv',
className: 'btn-secondary mr-1'
},
{
extend: 'excelHtml5',
className: 'btn-secondary mr-1',
filename: function(){
var date = new Date();
// Format the date as desired, for example: 'YYYY-MM-DD'
var formattedDate = date.toISOString().split('T')[0];
return 'Closed_order_lines_report_' + formattedDate;
},
title: 'Closed order lines report',
footer: true
},
{
extend: 'pdfHtml5',
className: 'btn-secondary mr-1',
footer: true
},
{
extend: 'colvis',
className: 'btn-secondary mr-1'
}
],
footerCallback: function (row, data, start, end, display) {
let api = this.api();
// Remove the formatting to get integer data for summation
let intVal = function (i) {
return typeof i === 'string'
? i.replace(/[\$,]/g, '') * 1
: typeof i === 'number'
? i
: 0;
};
// Total over all pages
total = api
.column(13)
.data()
.reduce((a, b) => intVal(a) + intVal(b), 0);
// Update footer
api.column(13).footer().innerHTML = total.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 });;
}
});
// Update Division/WH/Plant on Warehouse change
$(document).on('change select','#WHDDA',function(){
$("#COMPANY").val($(this).find("option:selected").data("comp"));
$("#PLANT").val($(this).find("option:selected").data("pl"));
$("#WHS").val($(this).find("option:selected").data("wh"));
});
$('#WHDDA').trigger('change');
// $('#filterTop').trigger('click');
// Export To Excel exportExcel
$(document).on('click','#exportExcel', function () {
REPORTDATE = $("#REPORTDATE").val();
TOREPORTDATE = $("#TOREPORTDATE").val();
$("#REPORTDATE1").val(REPORTDATE);
$("#TOREPORTDATE1").val(TOREPORTDATE);
$("#exporttoExcelForm").submit();
});
// Export To Excel exportExcel
$(document).on('click','#saveExcel', function () {
REPORTDATE = $("#REPORTDATE").val();
TOREPORTDATE = $("#TOREPORTDATE").val();
$("#REPORTDATE2").val(REPORTDATE);
$("#TOREPORTDATE2").val(TOREPORTDATE);
$("#StoreExcelToDiskForm").submit();
});
@if (session('message')!='')
alert("{{ session('message') }}");
@endif
});
</script>
@endsection