Files
2026-09-21 10:14:57 +01:00

317 lines
13 KiB
PHP
Executable File

@extends('m3::liberty-theme.layout.main')
@section('title')
Solon Sentinel Portal - ERP/TMS Part Data
@endsection
@section('content')
<!-- /.row -->
<div class="container-fluid px-4">
<h1 class="mt-4">ERP/TMS Part Data</h1>
<div class="card mb-4">
<div class="card-header">
@if($power_user->R428PWRUSR=="Y")
<button name="qtyAdd" type="button" class="btn btn-sm btn-info qtyAdd_click" id="qtyAdd_click"
data-AT9DPW="{{$power_user->R428CO.$power_user->R428PL.$power_user->R428WH}}">Add Record</button>
@endif
<!-- data-AT9DPW="$co.$plant.$whs">Add Record</button> -->
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover" id="datatablesSimple5" style="width:100%">
<thead>
<tr>
<th></th>
<th></th>
<th>Div-Plt-Whs</th>
<th>Part</th>
<th>Pallet Qty</th>
<th>Hazardous Material</th>
</tr>
</thead>
<tbody>
@foreach($ICM709M as $key=>$val)
<tr>
<td></td>
<td>
@if($power_user->R428PWRUSR=="Y")
<button name="qtyEdit{{trim($val->AT9PART)}}" type="submit" class="btn btn-sm btn-info qtyEdit_click" id="qtyEdit_click"
data-AT9CO="{{$val->AT9CO}}" data-AT9PLT="{{trim($val->AT9PLT)}}" data-AT9WHS="{{trim($val->AT9WHS)}}"
data-AT9PART="{{trim($val->AT9PART)}}" data-AT9QTY="{{$val->AT9QTY}}" data-AT9WRN="{{trim($val->AT9WRN)}}"
data-AT9DPW="{{$val->AT9CO.$val->AT9PLT.$val->AT9WHS}}"
>Edit</button>
@endif
</td>
<td> {{ $val->AT9CO }} {{ $val->AT9PLT }} {{ $val->AT9WHS }} </td>
<td> {{ $val->AT9PART }} </td>
<td> {{ $val->AT9QTY }} </td>
<td> {{ trim($val->AT9WRN) }} </td>
</tr>
@endforeach
<!-- endif-->
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- /.row -->
<!-- @include('m3::liberty-theme.partials.modals.blank') -->
@include('m3::liberty-theme.partials.modals.qtyAdd')
@include('m3::liberty-theme.partials.modals.qtyEdit')
@endsection
@section('scripts')
<script>
$(document).ready(function() {
// DataTable init
var myTable = $('#datatablesSimple5').DataTable({
"aaSorting": [],
"lengthMenu": [ [15,35,50,-1], [15,35,50,"All"] ],
"sPaginationType": "full_numbers",
"dom": 'Bfrtip', // Needs button container
"responsive": true,
"orderCellsTop": true,
"order": [ [1, 'desc'] ],
"pageLength": 15,
"columnDefs": [
{
orderable: true,
searchable: true,
targets: -1
}
],
});
//
// Open Modal Qty Edit
//
$(document).on('click', '#qtyEdit_click', function() {
//console.log($(this));
$("#AT9CO").val($(this).data("at9co"));
$("#AT9PLT").val($(this).data("at9plt"));
$("#AT9WHS").val($(this).data("at9whs"));
$("#AT9DPW").val($(this).data("at9dpw"));
$("#AT9PART").val($(this).data("at9part"));
$("#AT9QTY").val($(this).data("at9qty"));
$("#AT9WRN").val($(this).data("at9wrn"));
$("#OLD_AT9CO").val($(this).data("at9co"));
$("#OLD_AT9PLT").val($(this).data("at9plt"));
$("#OLD_AT9WHS").val($(this).data("at9whs"));
$("#OLD_AT9PART").val($(this).data("at9part"));
$("#OLD_AT9QTY").val($(this).data("at9qty"));
$("#OLD_AT9WRN").val($(this).data("at9wrn"));
$("#AT9QTY").focus();
$('#qtyEdit').modal('show');
});
//
// Open Modal Qty Add
//
$(document).on('click', '#qtyAdd_click', function() {
console.log($(this));
//$("#addAT9DPW").val("");
$("#addAT9QTY").val(1);
// $("#AT9DPW").val($(this).data("at9dpw"));
$("#addAT9QTY").focus();
$('#qtyAdd').modal('show');
});
// Clear values on Edit form when Close is clicked
$(document).on('click', '#closeEdit', function() {
document.getElementById("frmEdit").reset();
});
// Clear values on Add form when Close is clicked
$(document).on('click', '#closeAdd', function() {
document.getElementById("frmAdd").reset();
});
//
// Save Qty Edit
//
$(document).on('click', '#submitQtyEdit', function() {
var changes_detected = 0;
// Retrieve the values we need to pass on
//var NEW_AT9CO = $("#AT9CO").val();
//var NEW_AT9PLT = $("#AT9PLT").val();
//var NEW_AT9WHS = $("#AT9WHS").val();
var NEW_AT9CO = $("#AT9DPW").val().substring(0,3);
var NEW_AT9PLT = $("#AT9DPW").val().substring(3,6);
var NEW_AT9WHS = $("#AT9DPW").val().substring(6,9);
var NEW_AT9PART = $("#AT9PART").val();
var NEW_AT9QTY = $("#AT9QTY").val();
var NEW_AT9WRN = $("#AT9WRN").val();
// Retrieve old values
var OLD_AT9CO = $("#OLD_AT9CO").val();
var OLD_AT9PLT = $("#OLD_AT9PLT").val();
var OLD_AT9WHS = $("#OLD_AT9WHS").val();
var OLD_AT9DPW = $("#OLD_AT9DPW").val();
var OLD_AT9PART = $("#OLD_AT9PART").val();
var OLD_AT9QTY = $("#OLD_AT9QTY").val();
var OLD_AT9WRN = $("#OLD_AT9WRN").val();
// test fields that are not supposed to be blank/empty
if (NEW_AT9QTY.trim()=="") {
$('#qtyEdit').modal('show');
$('#AT9QTY').focus();
alert("There are fields that are blank that must be populated.");
} else {
// Compare the new and the old value before submitting
if(NEW_AT9QTY!=OLD_AT9QTY) {
changes_detected = 1;
}
if(NEW_AT9WRN!=OLD_AT9WRN) {
changes_detected = 1;
}
// If we have no changes we let the user know in a blank modal
//alert(changes_detected);
if (changes_detected==0) {
$('#qtyEdit').modal('show');
alert("No changes have been detected. Please try again");
// Send ajax request
} else {
var csrf = document.querySelector('meta[name="csrf-token"]').content;
$.ajax({
type:'POST',
url:'/palletQty/saveQtyEdit',
data: {
'AT9CO': NEW_AT9CO,
'AT9PLT': NEW_AT9PLT,
'AT9WHS': NEW_AT9WHS,
'AT9PART': NEW_AT9PART,
'AT9QTY': NEW_AT9QTY,
'AT9WRN': NEW_AT9WRN,
'_token': csrf
},
success:function(data) {
if (data=="success") {
//$('#blank-modal').modal('hide');
$('#qtyEdit').modal('hide');
// alert("should reload here");
location.reload();
} else {
$("#AT9CO").val(NEW_AT9CO);
$("#AT9PLT").val(NEW_AT9PLT);
$("#AT9WHS").val(NEW_AT9WHS);
$("#AT9DPW").val(NEW_AT9DPWH);
$("#AT9PART").val(NEW_AT9PART);
$("#AT9QTY").val(NEW_AT9QTY);
$("#AT9WRN").val(NEW_AT9WRN);
$("#OLD_AT9CO").val(OLD_AT9CO);
$("#OLD_AT9PLT").val(OLD_AT9PLT);
$("#OLD_AT9WHS").val(OLD_AT9WHS);
$("#OLD_AT9PART").val(OLD_AT9PART);
$("#OLD_AT9QTY").val(OLD_AT9QTY);
$("#OLD_AT9WRN").val(OLD_AT9WRN);
}
}
});
}
}
});
//
// Save Qty Add
//
$(document).on('click', '#submitQtyAdd', function() {
// Retrieve the values we need to pass on
//if($("#addAT9DPW").val()!=null) {
var NEW_AT9CO = ($("#addAT9DPW").val()).substring(0,3);
var NEW_AT9PLT = ($("#addAT9DPW").val()).substring(3,6);
var NEW_AT9WHS = ($("#addAT9DPW").val()).substring(6,9);
var NEW_AT9DPW = $("#addAT9DPW").val();
//}
//var NEW_AT9CO = $("input[name=addAT9CO]").val();
//var NEW_AT9PLT = $("input[name=addAT9PLT]").val();
//var NEW_AT9WHS = $("input[name=addAT9WHS]").val();
//var NEW_AT9DPW = $("input[name=addAT9DPW]").val();
var NEW_AT9PART = $("input[name=addAT9PART]").val();
var NEW_AT9QTY = $("input[name=addAT9QTY]").val();
var NEW_AT9WRN = $("input[name=addAT9WRN]").val();
var csrf = document.querySelector('meta[name="csrf-token"]').content;
var form_post = {
'AT9CO': NEW_AT9CO,
'AT9PLT': NEW_AT9PLT,
'AT9WHS': NEW_AT9WHS,
'AT9PART': NEW_AT9PART,
'AT9QTY': NEW_AT9QTY,
'AT9WRN': NEW_AT9WRN,
'_token': csrf
};
if (NEW_AT9PART.trim()=="" || NEW_AT9QTY.trim()=="") {
$('#qtyAdd').modal('show');
if (NEW_AT9QTY=="") {
$('#AT9QTY').focus();
}
alert("There are fields that are blank that must be populated.");
} else {
$.ajax({
type:'POST',
url:'/palletQty/saveQtyAdd',
data: form_post,
success:function(data) {
if (data=="success") {
$('#qtyAdd').modal('hide');
location.reload();
} else {
$("#addAT9CO").val(NEW_AT9CO);
$("#addAT9PLT").val(NEW_AT9PLT);
$("#addAT9WHS").val(NEW_AT9WHS);
$("#addAT9DPW").val(NEW_AT9DPW);
$("#addAT9PART").val(NEW_AT9PART);
$("#addAT9QTY").val(NEW_AT9QTY);
$("#addAT9WRN").val(NEW_AT9WRN);
if (data=="exists") {
$("#addAT9PART").val("");
alert("Record already exists in this file.");
$('#qtyAdd').modal('show');
}
if (data=="not exist") {
if (confirm("Part number "+NEW_AT9PART+" does not yet exist in Sentinel. Are you sure it exists in the ERP system?")) {
//console.log(form_post);
$.ajax({
type:'POST',
url:'/palletQty/saveQtyAdd2',
data: form_post,
success:function(data) {
if (data=="success") {
$('#qtyAdd').modal('hide');
location.reload();
}
}
});
}
}
}
}
});
}
});
});
//});
</script>
@endsection