293 lines
14 KiB
PHP
Executable File
293 lines
14 KiB
PHP
Executable File
<!-- #732 -->
|
||
@extends('m3::liberty-theme.layout.main')
|
||
@section('title')
|
||
Solon Sentinel Portal - Trucks pending closure with M3
|
||
@endsection
|
||
@section('content')
|
||
<!-- /.row -->
|
||
<div class="container-fluid px-4">
|
||
<h1 class="mt-4">Trucks pending closure with M3</h1>
|
||
|
||
<div class="card mb-4">
|
||
<div class="card-header">
|
||
<i class="fas fa-table me-1"></i>
|
||
The trucks will be closed automatically at 6pm daily. But you can initiate the close earlier by clicking on the manifest number
|
||
@if($ICM699M[0]->COUNT1>0)
|
||
<b><p style="background-color:tomato;">There are <a href="./M3ErrorsDisplay?showerrors=Y&skipdates=Y&shsource=CloseShipmentCoChargeAPI">
|
||
{{$ICM699M[0]->COUNT1}}</a> closing delivery order errors pending review</p></b>
|
||
@endif
|
||
@if(count($unprocessedArr)>0)
|
||
@php $unprocessedMan = implode(', ', $unprocessedArr); @endphp
|
||
<b><p style="background-color:tomato;">Manifests: {!! $unprocessedMan !!} have some orders that still have a header picking status of B, and may not have closed in M3. Please investigate</b>
|
||
@endif
|
||
|
||
</div>
|
||
<div class="card-body">
|
||
<table class="table table-striped table-bordered table-hover" id="datatablesSimple5">
|
||
<thead>
|
||
<tr>
|
||
<th> </th>
|
||
<th>Manifest</th>
|
||
<th>Status</th>
|
||
<th>Dock door</th>
|
||
<th>Carrier</th>
|
||
<th>Truck ID</th>
|
||
<th>Type</th>
|
||
<th>User open</th>
|
||
<th>Date open</th>
|
||
<th>Time open</th>
|
||
<th>TMS<br>User close</th>
|
||
<th>TMS<br>Date close</th>
|
||
<th>TMS<br>Time close</th>
|
||
<th>Sentinel<br>User close</th>
|
||
<th>Sentinel<br>Date close</th>
|
||
<th>Sentinel<br>Time close</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
@foreach($ICM705M1 as $key=>$val)
|
||
@php
|
||
$closeinRed = false;
|
||
$APLDCLOD = trim($val->APLDCLOD)!="0" ? date('Y-m-d', strtotime($val->APLDCLOD)) : "";
|
||
$APLDCLOT = trim($val->APLDCLOT)!="0"?(strlen($val->APLDCLOT)==6?date('H:i:s', strtotime($val->APLDCLOT)):date('H:i:s', strtotime('0'.$val->APLDCLOT))):"";
|
||
# Get current time as a timestamp
|
||
$currentTime = time();
|
||
$APLDCLOZ = trim($val->APLDCLOZ)!="0" ? strtotime($val->APLDCLOZ) : "";
|
||
# Calculate the difference in minutes
|
||
if ($APLDCLOZ!='') {
|
||
$minutesDiff = round(abs($currentTime - $APLDCLOZ) / 60);
|
||
$closeinRed = $minutesDiff <15 ? true : false;
|
||
}
|
||
$closeInRedClass = $closeinRed ? ' class=text-danger ' : '' ;
|
||
|
||
# Get In process Manifests with delay > 3 hours
|
||
$ManifestDelayed = false;
|
||
if ($val->APSPARE2=="P") {
|
||
$SHDT = isset($ICM699Ma[$val->APMANIFEST]['SHDT']) ? $ICM699Ma[$val->APMANIFEST]['SHDT'] : '';
|
||
$SHTIME = isset($ICM699Ma[$val->APMANIFEST]['SHTIME']) ? $ICM699Ma[$val->APMANIFEST]['SHTIME'] : '';
|
||
// dump($val->APMANIFEST."-".$SHDT."-".$SHTIME);
|
||
if ($SHDT!='' && $SHTIME!='') {
|
||
$specifiedDateTime = new \DateTime($SHDT . " " . $SHTIME);
|
||
$currentDateTime = new \DateTime();
|
||
# Calculate total hours
|
||
$totalHours = $specifiedDateTime->diff($currentDateTime)->days * 24 + $specifiedDateTime->diff($currentDateTime)->h;
|
||
// dump("Total Hours: " . $totalHours);
|
||
if ($totalHours > 3) {
|
||
$ManifestDelayed = true;
|
||
}
|
||
}
|
||
}
|
||
@endphp
|
||
<tr>
|
||
<td></td>
|
||
<td>
|
||
{{-- Link to Manifest Orders --}}
|
||
@if( $val->APMANIFEST!="0" )
|
||
<a class="btn btn-link" target="_blank" href="{{ url('MFOrders', ['id' => trim($val->APMANIFEST)]) }}">
|
||
{{ trim($val->APMANIFEST)!="0"?$val->APMANIFEST:"" }}
|
||
</a>
|
||
@endif
|
||
{{-- Close Button --}}
|
||
@if( ($val->APMANIFEST!="0" && $val->APSPARE2!="P" && trim($val->APLDCLOD)!="") && !$closeinRed)
|
||
<button class="btn btn-sm btn-warning" id="submitManifest" data-shuser="{{trim($user)}}" data-manifest="{{trim($val->APMANIFEST)}}" data-apco="{{trim($val->APCO)}}" data-apwhs="{{trim($val->APWHS)}}">
|
||
Close
|
||
</button>
|
||
@elseif($val->APSPARE2=="P")
|
||
{{ trim($val->APMANIFEST)!="0" ?$val->APMANIFEST : "" }}
|
||
@endif
|
||
</td>
|
||
{{-- MAK Show Retry Message instead of Contact MPBA --}}
|
||
<td> {!! $val->APSPARE2=="P" && !$ManifestDelayed ? "In Process" :
|
||
( $val->APSPARE2=="P" && $ManifestDelayed ?
|
||
'<button class="btn btn-sm btn-danger" id="allowRetry"
|
||
data-shuser="' . trim($user) . '"
|
||
data-manifest="' . trim($val->APMANIFEST) . '"
|
||
data-apco="' . trim($val->APCO) . '"
|
||
data-apwhs="' . trim($val->APWHS) . '">
|
||
Failed – please reset
|
||
</button>'
|
||
: '')
|
||
!!}
|
||
</td>
|
||
<td> {{ $val->APDOCKDOOR }} </td>
|
||
<td> {{ $val->APCARRIER }} </td>
|
||
<td> {{ $val->APTRUCKIDT }} </td>
|
||
<td> {{ $val->APSPARE1 }} </td>
|
||
<td> {{ $val->APLDSTRU }} </td>
|
||
<td> {{ date('Y-m-d', strtotime($val->APLDSTRD)) }} </td>
|
||
<td> {{ strlen($val->APLDSTRT)==6 ? date('H:i:s', strtotime($val->APLDSTRT)):date('H:i:s', strtotime('0'.$val->APLDSTRT)) }} </td>
|
||
<td> {{ isset($ICM698Ma[$val->APMANIFEST])?$ICM698Ma[$val->APMANIFEST]['TMSUSER']:"" }} </td>
|
||
<td> {{ trim($ICM698Ma[$val->APMANIFEST]['TMSDATE'])!=""?date('Y-m-d', strtotime($ICM698Ma[$val->APMANIFEST]['TMSDATE'])):"" }} </td>
|
||
<td> {{ trim($ICM698Ma[$val->APMANIFEST]['TMSTIME'])!=""?(strlen($ICM698Ma[$val->APMANIFEST]['TMSTIME'])==6?date('H:i:s', strtotime($ICM698Ma[$val->APMANIFEST]['TMSTIME'])):date('H:i:s', strtotime('0'.$ICM698Ma[$val->APMANIFEST]['TMSTIME']))):"" }} </td>
|
||
<td> {{ $val->APLDCLOU }} </td>
|
||
<td> {{ $APLDCLOD }} </td>
|
||
<td {{ $closeInRedClass }}> {{ $APLDCLOT }} </td>
|
||
</tr>
|
||
@endforeach
|
||
</tbody>
|
||
</table>
|
||
|
||
<div class="row">
|
||
<div class="col-12">
|
||
<form id="manifestForm" class="row row-cols-lg-auto g-3 align-items-center">
|
||
<div class="col-12">
|
||
<label class="visually-hidden" for="inlineFormInputGroupManifest #">Manifest #</label>
|
||
<div class="input-group">
|
||
<div class="input-group-text">View closed manifest</div>
|
||
<label for="MFInput" class="visually-hidden">Manifest #</label>
|
||
<input type="text" class="form-control" id="MFInput" placeholder="Manifest #">
|
||
</div>
|
||
</div>
|
||
<div class="col-12">
|
||
<button type="button" id="viewMF" class="btn btn-primary" >Submit</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
<!-- /.row -->
|
||
|
||
@endsection
|
||
|
||
@section('scripts')
|
||
<script>
|
||
|
||
$(document).ready(function() {
|
||
|
||
// DataTable init
|
||
$('#datatablesSimple5').DataTable({
|
||
"aaSorting": [],
|
||
"lengthMenu": [ [100,200,500,-1], [100,200,500,"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>>",
|
||
"responsive": true,
|
||
"orderCellsTop": true,
|
||
"order": [ [2, 'asc'] ],
|
||
pageLength: 25,
|
||
"lengthMenu": [ [10,25,50,100,500], [10,25,50,100,500] ],
|
||
"columnDefs": [
|
||
{
|
||
orderable: true,
|
||
searchable: true,
|
||
targets: -1
|
||
}
|
||
],
|
||
});
|
||
|
||
|
||
// Submit Manifet
|
||
$(document).on('click','#submitManifest', function () {
|
||
if (confirm("Do you want to close this manifest in M3 immediately?")) {
|
||
SHUSER = $(this).data('shuser');
|
||
MANIFEST = $(this).data('manifest');
|
||
APCO = $(this).data('apco');
|
||
APWHS = $(this).data('apwhs');
|
||
|
||
var form_post2 = {
|
||
SHUSER : SHUSER,
|
||
MANIFEST :MANIFEST,
|
||
APCO :APCO,
|
||
APWHS :APWHS,
|
||
_token : '{{ csrf_token() }}'
|
||
};
|
||
|
||
$.ajax({
|
||
url: "{{ route('m3.M3ManifestCloseAPI') }}",
|
||
type: "POST",
|
||
data: form_post2,
|
||
async:true,
|
||
success: function(response) {
|
||
},
|
||
error: function(error) {
|
||
// console.log(error);
|
||
// alert(error);
|
||
}
|
||
});
|
||
|
||
Swal.fire({
|
||
title: "Manifest Submitted for Closing",
|
||
text: "",
|
||
icon: "success",
|
||
confirmButtonColor: "#3085d6"
|
||
});
|
||
// alert("Manifest Submitted for Closing");
|
||
setTimeout(function(){
|
||
window.location.reload();
|
||
}, 3000);
|
||
|
||
}
|
||
|
||
});
|
||
|
||
// Allow Retry
|
||
$(document).on('click','#allowRetry', function () {
|
||
if (confirm("Do you want to allow manifest Closing?")) {
|
||
SHUSER = $(this).data('shuser');
|
||
MANIFEST = $(this).data('manifest');
|
||
APCO = $(this).data('apco');
|
||
APWHS = $(this).data('apwhs');
|
||
|
||
var form_post2 = {
|
||
SHUSER : SHUSER,
|
||
MANIFEST :MANIFEST,
|
||
APCO :APCO,
|
||
APWHS :APWHS,
|
||
_token : '{{ csrf_token() }}'
|
||
};
|
||
// console.log(form_post2); return false;
|
||
|
||
$.ajax({
|
||
url: "{{ route('m3.allowRetry') }}",
|
||
type: "POST",
|
||
data: form_post2,
|
||
async:true,
|
||
success: function(response) {
|
||
},
|
||
error: function(error) {
|
||
// console.log(error);
|
||
// alert(error);
|
||
}
|
||
});
|
||
|
||
// alert("Manifest Can now Submitted for retry");
|
||
Swal.fire({
|
||
title: "Manifest Can now Submitted for retry",
|
||
text: "",
|
||
icon: "success",
|
||
confirmButtonColor: "#3085d6"
|
||
});
|
||
setTimeout(function(){
|
||
window.location.reload();
|
||
}, 3000);
|
||
|
||
}
|
||
|
||
});
|
||
|
||
$('#viewMF').on('click', function () {
|
||
var MFInput = $('#MFInput').val().trim();
|
||
if (MFInput!='') {
|
||
var url = "{{ url('MFOrders')}}"+"/"+MFInput;
|
||
// window.location.href = url;
|
||
window.open(url, '_blank');
|
||
}
|
||
else{
|
||
alert("Manifest # is empty.");
|
||
}
|
||
});
|
||
|
||
$("#manifestForm").on('submit', function(e) {
|
||
e.preventDefault();
|
||
$('#viewMF').trigger('click');
|
||
});
|
||
|
||
});
|
||
|
||
</script>
|
||
@endsection
|