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; $ICM664M = DB::connection(config('m3.connection', 'pgsql'))->select("select * from ICM664M where AVCO='$co' and AVPLANT='$plant' and AVWHS='$whs'"); $IC670M = DB::connection(config('m3.connection', 'pgsql'))->select("select * from IC670M where WDCO='$co' and WDPL='$plant' and WDWHS='$whs'"); $shipvia = DB::connection(config('m3.connection', 'pgsql'))->select("select AXCODE, AXDESC from ICM319M order by 1"); #646 where AXCO='$co' and AXWHS='$whs' and AXPLANT='$plant' return view('m3::liberty-theme.pages.M3Delivery', compact('ICM664M','IC670M','power_user','shipvia')); // AVCO AVCO CHARACTER 3 No ' ' Division // AVWHS AVWHS CHARACTER 3 No ' ' Warehouse // AVPLANT AVPLANT CHARACTER 3 No ' ' Plant // AVDELMETH AVDELMETH CHARACTER 4 No ' ' Delivery method // AVSHPVIA AVSHPVIA CHARACTER 4 No ' ' Sentinel ship via // AVSHSRT AVSHSRT CHARACTER 6 No ' ' Sentinel route // AVSHORCL AVSHORCL CHARACTER 3 No ' ' Sentinel intl code // AVSPR1A01 AVSPR1A01 CHARACTER 1 No ' ' Spare field 1A 01 // AVSPR1A02 AVSPR1A02 CHARACTER 1 No ' ' Spare field 1A 02 // AVSPR10A01 AVSPR10A01 CHARACTER 10 No ' ' Spare field 10A 1 // AVSPR15A01 AVSPR15A01 CHARACTER 15 No ' ' Spare field 15A 1 // AVSPR30A01 AVSPR30A01 CHARACTER 30 No ' ' Spare field 30A 1 } // // Process data from Add modal // public static function saveM3DeliveryAdd(Request $request) { $icm664m=DB::connection(config('m3.connection', 'pgsql'))->select("select count(*) as COUNT1 from ICM664M where AVCO='$request->AVCO' and AVWHS='$request->AVWHS' and AVPLANT='$request->AVPLANT' and AVDELMETH='$request->AVDELMETH'"); if($icm664m[0]->COUNT1=="1") { return "exists"; } else { DB::connection(config('m3.connection', 'pgsql'))->insert("insert into ICM664M (AVCO, AVPLANT, AVWHS, AVDELMETH, AVSHPVIA, AVSHSRT, AVSHORCL) values ('$request->AVCO', '$request->AVPLANT', '$request->AVWHS', '$request->AVDELMETH', '$request->AVSHPVIA', '$request->AVSHSRT', '$request->AVSHORCL')"); return "success"; } } // // Process data from Edit modal // public static function saveM3DeliveryEdit(Request $request) { #dd($request); // Update record to ICM664M DB::connection(config('m3.connection', 'pgsql'))->update("update ICM664M set AVSHPVIA='$request->AVSHPVIA', AVSHSRT='$request->AVSHSRT', AVSHORCL='$request->AVSHORCL' where AVCO='$request->AVCO' and AVPLANT='$request->AVPLANT' and AVWHS='$request->AVWHS' and AVDELMETH='$request->AVDELMETH'"); return "success"; } }