date_in)); $date_in = isset($request->date)?date('Y-m-d',strtotime($request->date)):date('Y-m-d'); $date_in_minus_4_months = date('Y-m-d', strtotime($date_in .' -4 months')); $for = isset($request->for)?$request->for:'a'; $username = m3_user() !== '' ? Str::upper(trim(m3_user())) : ''; # Get Logged User CO & WH & PL $ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m') ->select('R428US','R428CO', 'R428WH', 'R428PL') ->where('R428US','=',$username) ->first(); $co = isset($ICM428M->R428CO) ? $ICM428M->R428CO : ''; $whseno = isset($ICM428M->R428WH) ? $ICM428M->R428WH : ''; $plantno = isset($ICM428M->R428PL) ? $ICM428M->R428PL : ''; $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; } #phpinfo(); include($_SERVER['DOCUMENT_ROOT'].'/../../KPI2_update711M_SQL_main.inc.php'); #var_dump($sqlstmt1.$stmt2); $perfDetails = DB::connection(config('m3.connection', 'pgsql'))->select($sqlstmt1.$stmt2); #var_dump($perfDetails); return view('m3::liberty-theme.pages.whsePerfDetails', compact('perfDetails','date_in','for')); } }