date) ? date('Y-m-d', strtotime($request->date)) : date('Y-m-d'); $for = isset($request->for) ? $request->for : 'a'; $all = "tempfile4 as ( select a5macpkr, a4shshnm, a4shipvia1, interco, a4shiptype, sum(dollarvalue) as dollarvalue, sum(weight) as weight, max(source) as source from tempfile3 where not (a4shipvia1='OCEAN' or interco='interco') and source<>'A2' group by a5macpkr, a4shshnm, a4shipvia1, interco, a4shiptype ) select * from tempfile4 order by source"; $ltl = "tempfile4 as ( select a5macpkr, a4shshnm, a4shipvia1, interco, a4shiptype, sum(dollarvalue) as dollarvalue, sum(weight) as weight, max(source) as source from tempfile3 where not (a4shipvia1='OCEAN' or interco='interco') and source<>'A2' and a4shiptype='LTL' group by a5macpkr, a4shshnm, a4shipvia1, interco, a4shiptype ) select * from tempfile4 order by source"; $parcel = "tempfile4 as ( select a5macpkr, a4shshnm, a4shipvia1, interco, a4shiptype, sum(dollarvalue) as dollarvalue, sum(weight) as weight, max(source) as source from tempfile3 where not (a4shipvia1='OCEAN' or interco='interco') and source<>'A2' and a4shiptype='SmallPack' group by a5macpkr, a4shshnm, a4shipvia1, interco, a4shiptype ) select * from tempfile4 order by source"; $io = "tempfile4 as ( select a5macpkr, a4shshnm, a4shipvia1, interco, a4shiptype, sum(dollarvalue) as dollarvalue, sum(weight) as weight, max(source) as source from tempfile3 where (a4shipvia1='OCEAN' or interco='interco') and source<>'A2' group by a5macpkr, a4shshnm, a4shipvia1, interco, a4shiptype ) select * from tempfile4 order by source"; switch ($for) { case 'a': $stmt2 = $all; break; case 'l': $stmt2 = $ltl; break; case 'p': $stmt2 = $parcel; break; case 'i': $stmt2 = $io; break; default: $stmt2 = $all; break; } include $_SERVER['DOCUMENT_ROOT'] . '/../../KPI2_update711M_SQL_main.inc.php'; $perfDetails = DB::connection(config('m3.connection', 'pgsql'))->select($sqlstmt1 . $stmt2); return view('m3::liberty-theme.pages.whsePerfDetails', compact('perfDetails', 'date_in', 'for')); } }