'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; $iCM664M = Schema::connection($connection)->hasTable('icm664m') ? DB::connection($connection)->table('icm664m')->where('AVCO', $co)->where('AVPLANT', $plant)->where('AVWHS', $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(); $shipvia = Schema::connection($connection)->hasTable('icm319m') ? DB::connection($connection)->table('icm319m')->select('AXCODE', 'AXDESC')->orderBy('AXCODE')->get() : collect(); return view('m3::liberty-theme.pages.M3Delivery', ['ICM664M' => $iCM664M, 'IC670M' => $iC670M, 'power_user' => $power_user, 'shipvia' => $shipvia]); } // // 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'; } }