66 lines
2.8 KiB
PHP
Executable File
66 lines
2.8 KiB
PHP
Executable File
<?php
|
|
|
|
namespace Modules\M3\Http\Controllers;
|
|
|
|
use DB;
|
|
use Illuminate\Http\Request;
|
|
|
|
class SentinelController extends Controller
|
|
{
|
|
public static function packSyst5Func(Request $request)
|
|
{
|
|
|
|
$aYINTBOX = isset($request->AYINTBOX) ? trim($request->AYINTBOX) : '';
|
|
$aYCO = isset($request->AYCO) ? trim($request->AYCO) : '';
|
|
$aYWHS = isset($request->AYWHS) ? trim($request->AYWHS) : '';
|
|
$aYUSER = isset($request->AYUSER) ? trim($request->AYUSER) : '';
|
|
|
|
if ($aYINTBOX != '') {
|
|
// Get the record from ICM695M1
|
|
$iCM695M1Sel = DB::connection(config('m3.connection', 'pgsql'))->table('icm695m1')
|
|
->select()
|
|
->where('AYINTBOX', $aYINTBOX)
|
|
->where('AYCO', $aYCO)
|
|
->where('AYWHS', $aYWHS)
|
|
->where('AYSTATUS', '')
|
|
->first();
|
|
|
|
$allowDeletion = ! empty($iCM695M1Sel->AYSENTPKR);
|
|
|
|
if ($allowDeletion) {
|
|
$timestamp = date('Y-m-d H:i:s.u');
|
|
$date1 = date('Ymd');
|
|
$time1 = date('His');
|
|
|
|
// Delete Records from ICM695M1 And ICM695M2
|
|
DB::connection(config('m3.connection', 'pgsql'))->table('icm695m1')
|
|
->where('AYINTBOX', $aYINTBOX)
|
|
->where('AYCO', $aYCO)
|
|
->where('AYWHS', $aYWHS)
|
|
->delete();
|
|
|
|
DB::connection(config('m3.connection', 'pgsql'))->table('icm695m2')
|
|
->where('AZINTBOX', $aYINTBOX)
|
|
->where('AZCO', $aYCO)
|
|
->where('AZWHS', $aYWHS)
|
|
->delete();
|
|
|
|
// Log the event as an unusual transaction to appear on SPD bottom right:
|
|
$insertValues = "'$iCM695M1Sel->AYCO', '$iCM695M1Sel->AYWHS', '$iCM695M1Sel->AYSENTPKR', '$iCM695M1Sel->AYMACPKR', '$iCM695M1Sel->AYONO', '$iCM695M1Sel->AYRLNO', '$iCM695M1Sel->AYSHNO', '', 'Box $aYINTBOX emptied and repacked',
|
|
'$timestamp', '$date1', '$time1', '$aYUSER','$timestamp', '$date1', '$time1', '$aYUSER','$aYINTBOX'";
|
|
|
|
DB::connection(config('m3.connection', 'pgsql'))->insert("INSERT INTO ICM689M
|
|
(A7CO, A7WHS, A7SENTPKR, A7MACPKR, A7ONO, A7RLNO, A7SHNO, A7SOURCE, A7ERRMSG, A7DISRAITS, A7DISRAID, A7DISRAIT, A7DISRAIU, A7DISRESTS ,A7DISRESD ,A7DISREST ,A7DISRESU , A7SPR15A01)
|
|
values ($insertValues)");
|
|
|
|
return response()->json(['success' => true, 'message' => 'Line Deleted']);
|
|
} else {
|
|
return response()->json(['success' => false, 'message' => 'Line already packed']);
|
|
}
|
|
} else {
|
|
return response()->json(['success' => false, 'message' => 'Line missing']);
|
|
}
|
|
|
|
}
|
|
}
|