updates to M3 module
This commit is contained in:
@@ -343,36 +343,39 @@ class Helper
|
||||
}
|
||||
|
||||
public static function getUserCOWHSPLT(){
|
||||
# Get Current USER
|
||||
$loggedUser = strtoUpper(m3_user());
|
||||
// dump($loggedUser);
|
||||
$getUsers = DB::connection(config('m3.connection', 'pgsql'))->select("select R428US, R428ADMUSR, R428PWRUSR, R428CO, R428PL, R428WH, R42811A,R42821A from ICM428M where R428US='".$loggedUser."'");
|
||||
|
||||
foreach ($getUsers as $key=>$user) {
|
||||
if(trim($user->R428ADMUSR)=="Y") {
|
||||
# Different logic from Qinclude version : this not an Array
|
||||
$admin_users=trim($user->R428ADMUSR);
|
||||
}
|
||||
if(trim($user->R428PWRUSR)=="Y") {
|
||||
# Different logic from Qinclude version : this not an Array
|
||||
$power_users=trim($user->R428PWRUSR);
|
||||
}
|
||||
if(trim($user->R42811A)=="C") {
|
||||
$csr="Y";
|
||||
}
|
||||
if(trim($user->R42821A)=="Y") {
|
||||
$execUser="Y";
|
||||
}
|
||||
$UserCO = $user->R428CO;
|
||||
$UserWHS = $user->R428WH;
|
||||
$UserPL = $user->R428PL;
|
||||
$defaults = [
|
||||
'UserCO' => '',
|
||||
'UserWHS' => '',
|
||||
'UserPL' => '',
|
||||
];
|
||||
|
||||
$currentUser = [
|
||||
'UserCO' => $UserCO,
|
||||
'UserWHS' => $UserWHS,
|
||||
'UserPL' => $UserPL,
|
||||
$loggedUser = strtoupper(trim((string) m3_user()));
|
||||
if ($loggedUser === '') {
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!\Illuminate\Support\Facades\Schema::connection(config('m3.connection', 'pgsql'))->hasTable('icm428m')) {
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
$user = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US', 'R428ADMUSR', 'R428PWRUSR', 'R428CO', 'R428PL', 'R428WH', 'R42811A', 'R42821A')
|
||||
->where('R428US', $loggedUser)
|
||||
->first();
|
||||
|
||||
if (!$user) {
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
return [
|
||||
'UserCO' => trim((string) ($user->R428CO ?? '')),
|
||||
'UserWHS' => trim((string) ($user->R428WH ?? '')),
|
||||
'UserPL' => trim((string) ($user->R428PL ?? '')),
|
||||
];
|
||||
return $currentUser;
|
||||
} catch (\Throwable $e) {
|
||||
\Illuminate\Support\Facades\Log::warning('M3 user context unavailable', ['exception' => $e->getMessage()]);
|
||||
return $defaults;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user