m3 Security Fixes
This commit is contained in:
@@ -2,19 +2,13 @@
|
||||
|
||||
namespace Modules\M3\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use DB;
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Modules\M3\Services\SpreadsheetExport;
|
||||
use Str;
|
||||
|
||||
|
||||
use Storage;
|
||||
|
||||
class WHSMetricsSaveXls extends Command
|
||||
{
|
||||
/**
|
||||
@@ -48,41 +42,41 @@ class WHSMetricsSaveXls extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//$this->info('Start CallCloseAPI...');
|
||||
// $this->info('Start CallCloseAPI...');
|
||||
ini_set('max_execution_time', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('max_input_time', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOutCL'));
|
||||
ini_set('memory_limit', '1024M');
|
||||
|
||||
try {
|
||||
Log::channel('dailyCron')->info("Cron...Start Save WHS Metrics to Excel");
|
||||
Log::channel('dailyCron')->info('Cron...Start Save WHS Metrics to Excel');
|
||||
|
||||
# Get the Calling User
|
||||
$userId = $this->argument('user');
|
||||
$SHUSER = isset($userId) ? $userId : (m3_user() !== '' ? Str::upper(trim(m3_user())) : '');
|
||||
// Get the Calling User
|
||||
$userId = $this->argument('user');
|
||||
$SHUSER = isset($userId) ? $userId : (m3_user() !== '' ? Str::upper(trim(m3_user())) : '');
|
||||
|
||||
$CO = $this->argument('co');
|
||||
$CO = $this->argument('co');
|
||||
// $COMPANY = isset($CO) ? trim($CO) : '110';
|
||||
$COMPANY = '110';
|
||||
$PWHS = $this->argument('whs');
|
||||
$COMPANY = '110';
|
||||
$PWHS = $this->argument('whs');
|
||||
// $WHS = isset($PWHS) ? trim($PWHS) : '321';
|
||||
$WHS = '321';
|
||||
$PPL = $this->argument('pl');
|
||||
$WHS = '321';
|
||||
$PPL = $this->argument('pl');
|
||||
// $PLANT = isset($PPL) ? trim($PPL) : '143';
|
||||
$PLANT = '143';
|
||||
$PLANT = '143';
|
||||
|
||||
$date = new \DateTime();
|
||||
$DateToday = $date->format('Y-m-d');
|
||||
$date = new \DateTime;
|
||||
$DateToday = $date->format('Y-m-d');
|
||||
|
||||
# Define File Name
|
||||
$whsPerfFile = 'WhsPerf/'.$WHS.'/WhsPerfMetrics_'.$DateToday.'-'.$WHS.'.xlsx';
|
||||
Log::channel('dailyCron')->info(">>> File Name:");
|
||||
// Define File Name
|
||||
$whsPerfFile = 'WhsPerf/' . $WHS . '/WhsPerfMetrics_' . $DateToday . '-' . $WHS . '.xlsx';
|
||||
Log::channel('dailyCron')->info('>>> File Name:');
|
||||
Log::channel('dailyCron')->info($whsPerfFile);
|
||||
|
||||
$this->info("Generate Today WHS Performance Report...");
|
||||
$this->info('Generate Today WHS Performance Report...');
|
||||
|
||||
if( $COMPANY!='' && $WHS!='' && $PLANT!='' ){
|
||||
# Get Header Content
|
||||
if ($COMPANY != '' && $WHS != '' && $PLANT != '') {
|
||||
// Get Header Content
|
||||
$ICM700MHeadSel = DB::connection(config('m3.connection', 'pgsql'))
|
||||
->select("
|
||||
WITH TEMPFILE AS (
|
||||
@@ -100,31 +94,32 @@ class WHSMetricsSaveXls extends Command
|
||||
");
|
||||
// dd($ICM700MHeadSel);
|
||||
|
||||
$newItem = ["A4SHIPTYPE" => 'Method', "STATUS" => 'Status', "SOURCE" => 'Source', "PICKERS" => 'Pickers',
|
||||
"WEIGHT" => 'Weight', "LINES" => 'Lines', "DOLLARS" => 'Dollars'];
|
||||
$newItem = ['A4SHIPTYPE' => 'Method', 'STATUS' => 'Status', 'SOURCE' => 'Source', 'PICKERS' => 'Pickers',
|
||||
'WEIGHT' => 'Weight', 'LINES' => 'Lines', 'DOLLARS' => 'Dollars'];
|
||||
|
||||
# Trim All values
|
||||
// Trim All values
|
||||
$ICM700MHeadCol = collect($ICM700MHeadSel)->map(function ($item) {
|
||||
foreach ($item as $key => $value) {
|
||||
if (is_string($value)) {
|
||||
$item->{$key} = trim($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $item;
|
||||
});
|
||||
# Prepend Header to Collection
|
||||
// Prepend Header to Collection
|
||||
$ICM700MHeadCol->prepend($newItem);
|
||||
|
||||
// $this->info($ICM700MHeadCol);
|
||||
// Log::channel('dailyCron')->info(">>> Header Content");
|
||||
// Log::channel('dailyCron')->info($ICM700MHeadCol);
|
||||
|
||||
# Count records before exporting to excel
|
||||
$ICM700MHeadCount = $ICM700MHeadCol->count();
|
||||
// Count records before exporting to excel
|
||||
$ICM700MHeadCount = $ICM700MHeadCol->count();
|
||||
|
||||
# Get Details Content
|
||||
// Get Details Content
|
||||
$ICM700MDetailsSel = DB::connection(config('m3.connection', 'pgsql'))
|
||||
->select("
|
||||
->select("
|
||||
WITH TEMPFILE AS (
|
||||
SELECT A3CO,A3WHS,A3PLT,A3MACPKR,A4PICKCRTS,SOURCE,
|
||||
(SELECT TO_TIMESTAMP(CAST(SHDT AS TEXT) || ' ' || CAST(SHTIME AS TEXT), 'YYYY-MM-DD HH24:MI:SS') FROM ICM699M WHERE SHMACPKR=A4MACPKR AND SHTYPE='Lisnr-Hold' ORDER BY SHDT DESC, SHTIME DESC FETCH FIRST 1 ROWS ONLY) AS CARRIERASSIGNED,
|
||||
@@ -140,54 +135,51 @@ class WHSMetricsSaveXls extends Command
|
||||
SELECT * FROM TEMPFILE
|
||||
");
|
||||
|
||||
$newItem2 = ["A3CO" => 'Co', "A3WHS" => 'Whs', "A3PLT" => 'Plt', "A3MACPKR" => 'Delivery No', "A4PICKCRTS" => 'Date Time Arrived in Sentinel',
|
||||
"SOURCE" => 'Source', "CARRIERASSIGNED" => 'Date carrier Assigned', "A4ONO" => 'Order No', "A4SHSHNM" => 'Customer name',"A4SCAC" => 'Carrier',
|
||||
"A42SSVCNAM" => 'Service', "A4PICKSTS" => 'Picker Status', "STATUS" => 'Open or Closed', "A4SHIPTYPE" => 'Method',
|
||||
"A4TPCKWGHT" => 'Weight', "A4NOPICLNS" => 'Lines' , "DOLLARS" => 'Dollars' ];
|
||||
# Trim all values
|
||||
$newItem2 = ['A3CO' => 'Co', 'A3WHS' => 'Whs', 'A3PLT' => 'Plt', 'A3MACPKR' => 'Delivery No', 'A4PICKCRTS' => 'Date Time Arrived in Sentinel',
|
||||
'SOURCE' => 'Source', 'CARRIERASSIGNED' => 'Date carrier Assigned', 'A4ONO' => 'Order No', 'A4SHSHNM' => 'Customer name', 'A4SCAC' => 'Carrier',
|
||||
'A42SSVCNAM' => 'Service', 'A4PICKSTS' => 'Picker Status', 'STATUS' => 'Open or Closed', 'A4SHIPTYPE' => 'Method',
|
||||
'A4TPCKWGHT' => 'Weight', 'A4NOPICLNS' => 'Lines', 'DOLLARS' => 'Dollars'];
|
||||
// Trim all values
|
||||
$ICM700MDetailsCol = collect($ICM700MDetailsSel)->map(function ($item) {
|
||||
foreach ($item as $key => $value) {
|
||||
if (is_string($value)) {
|
||||
$item->{$key} = trim($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $item;
|
||||
});
|
||||
|
||||
# Prepend Header
|
||||
// Prepend Header
|
||||
$ICM700MDetailsCol->prepend($newItem2);
|
||||
|
||||
# Count records before exporting to excel
|
||||
$ICM700MDetailsCount = $ICM700MDetailsCol->count();
|
||||
}
|
||||
else{
|
||||
// Count records before exporting to excel
|
||||
$ICM700MDetailsCount = $ICM700MDetailsCol->count();
|
||||
} else {
|
||||
$ICM700MDetailsCol = collect();
|
||||
}
|
||||
// Log::channel('dailyCron')->info(">>> Detail Content");
|
||||
// Log::channel('dailyCron')->info($ICM700MDetailsCol);
|
||||
|
||||
# Save Head and Details to XLS file
|
||||
if ($ICM700MHeadCount>0 && $ICM700MDetailsCount>0) {
|
||||
$this->info("Saving Today WHS Performance Report to Disk...");
|
||||
Log::channel('dailyCron')->info("Saving Today WHS Performance Report to Disk...");
|
||||
// Save Head and Details to XLS file
|
||||
if ($ICM700MHeadCount > 0 && $ICM700MDetailsCount > 0) {
|
||||
$this->info('Saving Today WHS Performance Report to Disk...');
|
||||
Log::channel('dailyCron')->info('Saving Today WHS Performance Report to Disk...');
|
||||
|
||||
# Store both collections in one XLSX workbook using Core's PhpSpreadsheet dependency.
|
||||
app(\Modules\M3\Services\SpreadsheetExport::class)->storeSheets([
|
||||
// Store both collections in one XLSX workbook using Core's PhpSpreadsheet dependency.
|
||||
app(SpreadsheetExport::class)->storeSheets([
|
||||
'Summary' => $ICM700MHeadCol,
|
||||
'Details' => $ICM700MDetailsCol,
|
||||
], $whsPerfFile, 'publicLabels');
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
Log::channel('dailyCron')->info("Today WHS Performance Report, no records found: Nothing to save...");
|
||||
} else {
|
||||
Log::channel('dailyCron')->info('Today WHS Performance Report, no records found: Nothing to save...');
|
||||
}
|
||||
|
||||
Log::channel('dailyCron')->info("Cron...End Save Today WHS Performance Report to Excel");
|
||||
$this->info("Cron...End Save Today WHS Performance Report to Excel");
|
||||
Log::channel('dailyCron')->info('Cron...End Save Today WHS Performance Report to Excel');
|
||||
$this->info('Cron...End Save Today WHS Performance Report to Excel');
|
||||
|
||||
}
|
||||
catch (\Throwable $th) {
|
||||
} catch (\Throwable $th) {
|
||||
// Log::error($th);
|
||||
Log::channel('dailyCron')->error($th);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user