98 lines
4.4 KiB
PHP
Executable File
98 lines
4.4 KiB
PHP
Executable File
<?php
|
|
|
|
namespace Modules\M3\Http\Controllers;
|
|
|
|
use Config;
|
|
use DB;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Modules\M3\Models\ICM709M;
|
|
|
|
class PalletQtyController extends Controller
|
|
{
|
|
public static function index(Request $request)
|
|
{
|
|
$connection = config('m3.connection', 'pgsql');
|
|
$power_user = (object) ['R428PWRUSR' => 'N', 'R428US' => strtoupper(m3_user()), 'R428CO' => '', 'R428PL' => '', 'R428WH' => ''];
|
|
if (Schema::connection($connection)->hasTable('icm428m')) {
|
|
$power_user = DB::connection($connection)->table('icm428m')
|
|
->select('R428PWRUSR', 'R428US', 'R428CO', 'R428PL', 'R428WH')
|
|
->where('R428US', '=', strtoupper(m3_user()))->first() ?? $power_user;
|
|
}
|
|
$co = $power_user->R428CO;
|
|
$plant = $power_user->R428PL;
|
|
$whs = $power_user->R428WH;
|
|
$iCM709M = Schema::connection($connection)->hasTable('icm709m')
|
|
? DB::connection($connection)->table('icm709m')->where('AT9CO', $co)->where('AT9PLT', $plant)->where('AT9WHS', $whs)->get() : collect();
|
|
$iC670M = Schema::connection($connection)->hasTable('ic670m')
|
|
? DB::connection($connection)->table('ic670m')->where('WDCO', $co)->where('WDPL', $plant)->where('WDWHS', $whs)->get() : collect();
|
|
|
|
return view('m3::liberty-theme.pages.palletQty', ['ICM709M' => $iCM709M, 'IC670M' => $iC670M, 'power_user' => $power_user]);
|
|
}
|
|
|
|
//
|
|
// Process data from Add modal
|
|
//
|
|
public static function saveQtyAdd(Request $request)
|
|
{
|
|
|
|
// Insert record to ICM709M
|
|
// var_dump($request);
|
|
// Verify record does not already exist in ICM709M
|
|
$icm709m = DB::connection(config('m3.connection', 'pgsql'))->select("select count(*) as COUNT1 from ICM709M
|
|
where AT9CO='$request->AT9CO' and AT9PLT='$request->AT9PLT' and AT9WHS='$request->AT9WHS' and AT9PART='$request->AT9PART'");
|
|
if ($icm709m[0]->COUNT1 >= '1') {
|
|
return 'exists';
|
|
} else {
|
|
// Verify Part# already exists in ICM630M
|
|
$ic630m = DB::connection(config('m3.connection', 'pgsql'))->select("select count(*) as COUNT1 from IC630M
|
|
where LLCO='$request->AT9CO' and LLWHNO='$request->AT9WHS' and LLPPN='$request->AT9PART'");
|
|
if ($ic630m[0]->COUNT1 == '0') {
|
|
return 'not exist';
|
|
} else {
|
|
DB::connection(config('m3.connection', 'pgsql'))->insert("insert into ICM709M (AT9CO, AT9PLT, AT9WHS, AT9PART, AT9QTY, AT9WRN)
|
|
values ('$request->AT9CO', '$request->AT9PLT', '$request->AT9WHS', '$request->AT9PART', '$request->AT9QTY', '$request->AT9WRN')");
|
|
|
|
return 'success';
|
|
}
|
|
}
|
|
}
|
|
|
|
public static function saveQtyAdd2(Request $request)
|
|
{
|
|
|
|
// Insert record to ICM709M
|
|
// var_dump($request);
|
|
// Verify record does not already exist in ICM709M
|
|
// DB::connection(config('m3.connection', 'pgsql'))->insert("insert into ICM709M (AT9CO, AT9PLT, AT9WHS, AT9PART, AT9QTY)
|
|
// values ('$request->AT9CO', '$request->AT9PLT', '$request->AT9WHS', '$request->AT9PART', '$request->AT9QTY')");
|
|
// $data=['AT9CO'=>$request->AT9CO, 'AT9PLT'=>$request->AT9PLT, 'AT9WHS'=>$request->AT9WHS, 'AT9PART'=>$request->AT9PART,
|
|
// 'AT9QTY'=>$request->AT9QTY, 'AT9WRN'=>$request->AT9WRN];
|
|
// $insertSQL = DB::connection(config('m3.connection', 'pgsql'))->table('icm709m')->insert($data);
|
|
DB::connection(config('m3.connection', 'pgsql'))->insert("insert into ICM709M (AT9CO, AT9PLT, AT9WHS, AT9PART, AT9QTY, AT9WRN)
|
|
values ('$request->AT9CO', '$request->AT9PLT', '$request->AT9WHS', '$request->AT9PART', '$request->AT9QTY', '$request->AT9WRN')");
|
|
|
|
// if($insertSQL) {
|
|
return 'success';
|
|
// }
|
|
|
|
}
|
|
|
|
//
|
|
// Process data from Edit modal
|
|
//
|
|
public static function saveQtyEdit(Request $request)
|
|
{
|
|
|
|
// where AT9CO='$request->AT9CO' and AT9PLT='$request->AT9PLT' and AT9WHS='$request->AT9WHS' and AT9PART='$request->AT9PART'");
|
|
// var_dump($icm709m);
|
|
|
|
DB::connection(config('m3.connection', 'pgsql'))->update("update ICM709M
|
|
set AT9QTY='$request->AT9QTY', AT9WRN='$request->AT9WRN'
|
|
where AT9CO='$request->AT9CO' and AT9PLT='$request->AT9PLT' and AT9WHS='$request->AT9WHS' and AT9PART='$request->AT9PART'");
|
|
|
|
return 'success';
|
|
|
|
}
|
|
}
|