103 lines
4.6 KiB
PHP
103 lines
4.6 KiB
PHP
<?php
|
|
|
|
namespace Modules\M3\Http\Controllers;
|
|
|
|
use Modules\M3\Http\Controllers\Controller;
|
|
use DB;
|
|
use Config;
|
|
use Illuminate\Http\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Modules\M3\Models\ICM709M;
|
|
|
|
|
|
class palletQtyController extends Controller
|
|
{
|
|
|
|
public static function index(Request $request) {
|
|
|
|
#$IC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
|
|
#$power_user = DB::connection(config('m3.connection', 'pgsql'))->select("select R428PWRUSR, R428CO, R428PL, R428WH from ICM428M where R428US='".strtoUpper(m3_user())."'");
|
|
$power_user = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
|
->select('R428PWRUSR','R428US','R428CO','R428PL','R428WH')
|
|
->where('R428US','=',strtoUpper(m3_user()))
|
|
->first();
|
|
$co = $power_user->R428CO;
|
|
$plant = $power_user->R428PL;
|
|
$whs = $power_user->R428WH;
|
|
$ICM709M = DB::connection(config('m3.connection', 'pgsql'))->table('icm709m')
|
|
->where('AT9CO','=',$co)
|
|
->where('AT9PLT','=',$plant)
|
|
->where('AT9WHS','=',$whs)
|
|
->get();
|
|
$IC670M = DB::connection(config('m3.connection', 'pgsql'))->select("select * from IC670M where WDCO='$co' and WDPL='$plant' and WDWHS='$whs'");
|
|
return view('m3::liberty-theme.pages.palletQty', compact('ICM709M','IC670M','power_user'));
|
|
|
|
}
|
|
|
|
//
|
|
// Process data from Add modal
|
|
//
|
|
public static function saveQtyAdd(Request $request) {
|
|
|
|
// Insert record to ICM709M
|
|
#var_dump($request);
|
|
#console.log($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);
|
|
#console.log($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) {
|
|
|
|
#dump($request);
|
|
#console.log($request);
|
|
|
|
//$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'");
|
|
//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";
|
|
|
|
}
|
|
|
|
}
|