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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,10 +17,19 @@ class carrierMaintController extends Controller
|
||||
public static function index(Request $request) {
|
||||
$currentUser = Helper::getUserCOWHSPLT();
|
||||
$UserCO = $currentUser['UserCO'] ?? '';
|
||||
$ICM160M = DB::connection(config('m3.connection', 'pgsql'))->select("
|
||||
select canum, canam, substr(CATPID,1,3) as TwoshipCarrierCode, substr(CATPID,4,1) as ParcelCarrierCode, caspr10A01, caspr1A01
|
||||
from icm160m WHERE CACO='$UserCO'");
|
||||
$power_user = DB::connection(config('m3.connection', 'pgsql'))->select("select R428PWRUSR, R428CO, R428PL, R428WH from ICM428M where R428US='".strtoUpper(m3_user())."'");
|
||||
$ICM160M = [];
|
||||
$power_user = [];
|
||||
$schema = \Illuminate\Support\Facades\Schema::connection(config('m3.connection', 'pgsql'));
|
||||
if ($schema->hasTable('icm160m')) {
|
||||
$ICM160M = DB::connection(config('m3.connection', 'pgsql'))->select("
|
||||
select canum, canam, substr(CATPID,1,3) as TwoshipCarrierCode, substr(CATPID,4,1) as ParcelCarrierCode, caspr10A01, caspr1A01
|
||||
from icm160m WHERE CACO=?", [$UserCO]);
|
||||
}
|
||||
if ($schema->hasTable('icm428m')) {
|
||||
$power_user = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428PWRUSR', 'R428CO', 'R428PL', 'R428WH')
|
||||
->where('R428US', strtoUpper(m3_user()))->get()->all();
|
||||
}
|
||||
return view('m3::liberty-theme.pages.carrierMaint', compact('ICM160M','power_user'));
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,12 @@ use Log;
|
||||
class execSummaryController extends Controller
|
||||
{
|
||||
public static function index(Request $request){
|
||||
$IC670M = collect();
|
||||
$WHDDA = '';
|
||||
$COMPANY = '110';
|
||||
$PLANT = '144';
|
||||
$WHS = '322';
|
||||
|
||||
try {
|
||||
# Ajax Call
|
||||
if ($request->ajax()) {
|
||||
|
||||
@@ -32,21 +32,25 @@ class userPickingStats4 extends Controller
|
||||
#618
|
||||
# Get Logged User CO & WH
|
||||
# Get Users from ICM428M
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US','R428CO', 'R428WH')
|
||||
->where('R428US','=',strtoUpper(m3_user()))
|
||||
->first();
|
||||
$co = $ICM428M->R428CO;
|
||||
$whs = $ICM428M->R428WH;
|
||||
$co = '';
|
||||
$whs = '';
|
||||
$ICM428M = [];
|
||||
$schema = \Illuminate\Support\Facades\Schema::connection(config('m3.connection', 'pgsql'));
|
||||
if ($schema->hasTable('icm428m')) {
|
||||
$profile = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US','R428CO', 'R428WH')
|
||||
->where('R428US','=',strtoUpper(m3_user()))
|
||||
->first();
|
||||
$co = $profile->R428CO ?? '';
|
||||
$whs = $profile->R428WH ?? '';
|
||||
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->selectRaw("R428US as userprf, (trim(R428FIRST) || ' ' || trim(R428FAMILY)) as name, R428EMPCDE as empno")
|
||||
->where('R428STS', 'A')->where('R428EMPCDE', '!=', 0)
|
||||
->where('R428CO', $co)->where('R428WH', $whs)->get()->all();
|
||||
}
|
||||
|
||||
$user_array=array();
|
||||
#$sqlstmt="SELECT R428US as userprf, R428FIRST, R428FAMILY, R428EMPCDE as empno FROM ICM428M where R428EMPCDE!=0";
|
||||
$sqlstmt="SELECT R428US as userprf, (trim(R428FIRST) || ' ' || trim(R428FAMILY)) as name, R428EMPCDE as empno FROM ICM428M
|
||||
where R428STS='A' and R428EMPCDE!=0 and R428CO='$co' and R428WH='$whs'";
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->select($sqlstmt);
|
||||
// ->selectRaw("R428US, (trim(R428FIRST) || ' ' || trim(R428FAMILY)), R428EMPCDE ")
|
||||
// ->where("R428EMPCDE!=0")
|
||||
// ->get();
|
||||
#while($row = odbc_fetch_object($result)) {
|
||||
$x=0;
|
||||
foreach($ICM428M as $key=>$row) {
|
||||
|
||||
@@ -17,31 +17,40 @@ class userPickingStats5 extends Controller
|
||||
public static function index(Request $request){
|
||||
|
||||
#618
|
||||
# Get Logged User CO & WH
|
||||
# Get Users from ICM428M
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US','R428CO', 'R428WH')
|
||||
->where('R428US','=',strtoUpper(m3_user()))
|
||||
->first();
|
||||
$co = $ICM428M->R428CO;
|
||||
$whs = $ICM428M->R428WH;
|
||||
# Get Logged User CO & WH. Legacy M3 profile data may not yet exist in PostgreSQL.
|
||||
$co = '';
|
||||
$whs = '';
|
||||
$user_array = [];
|
||||
try {
|
||||
if (\Illuminate\Support\Facades\Schema::connection(config('m3.connection', 'pgsql'))->hasTable('icm428m')) {
|
||||
$profile = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US','R428CO', 'R428WH')
|
||||
->where('R428US', strtoupper((string) m3_user()))
|
||||
->first();
|
||||
$co = trim((string) ($profile->R428CO ?? ''));
|
||||
$whs = trim((string) ($profile->R428WH ?? ''));
|
||||
|
||||
#@dd($request);
|
||||
#$user_array=Config::get('arrays.user_array');
|
||||
$user_array=array();
|
||||
$sqlstmt="SELECT R428US as userprf, (trim(R428FIRST) || ' ' || trim(R428FAMILY)) as name, R428EMPCDE as empno FROM ICM428M
|
||||
where R428EMPCDE!=0 and R428CO='$co' and R428WH='$whs'";
|
||||
$ICM428M = DB::connection(config('m3.connection', 'pgsql'))->select($sqlstmt);
|
||||
$x=0;
|
||||
foreach($ICM428M as $key=>$row) {
|
||||
// print_r($row);
|
||||
$user_array[$x]['userprf']=trim($row->USERPRF);
|
||||
#$user_array[$x]['name']=trim($row->R428FIRST)+' '+trim($row->R428FAMILY);
|
||||
$user_array[$x]['name']=trim($row->NAME);
|
||||
$user_array[$x]['empno']=$row->EMPNO;
|
||||
$x++;
|
||||
if ($co !== '' && $whs !== '') {
|
||||
$rows = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->selectRaw("R428US as userprf, (trim(R428FIRST) || ' ' || trim(R428FAMILY)) as name, R428EMPCDE as empno")
|
||||
->where('R428EMPCDE', '!=', 0)
|
||||
->where('R428CO', $co)
|
||||
->where('R428WH', $whs)
|
||||
->get();
|
||||
foreach ($rows as $row) {
|
||||
$user_array[] = [
|
||||
'userprf' => trim((string) $row->userprf),
|
||||
'name' => trim((string) $row->name),
|
||||
'empno' => $row->empno,
|
||||
];
|
||||
}
|
||||
array_multisort(array_column($user_array, 'name'), SORT_ASC, $user_array);
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
\Illuminate\Support\Facades\Log::warning('M3 picking user list unavailable', ['exception' => $e->getMessage()]);
|
||||
$user_array = [];
|
||||
}
|
||||
array_multisort(array_column($user_array, 'name'), SORT_ASC, $user_array);
|
||||
|
||||
// Filter by date
|
||||
if (isset($request->dates)) {
|
||||
|
||||
@@ -263,7 +263,6 @@
|
||||
@if (Route::has('m3.userPickingStats4'))<a href="{{ route('m3.userPickingStats4') }}" class="wms-sidebar-link wms-m3-submenu-link @if (request()->routeIs('m3.userPickingStats4')) is-active @endif"><i class="fa-solid fa-chart-column wms-sidebar-icon" aria-hidden="true"></i><span>{{ __('KPI1 Bar') }}</span></a>@endif
|
||||
@if (Route::has('m3.userPickingStats5'))<a href="{{ route('m3.userPickingStats5') }}" class="wms-sidebar-link wms-m3-submenu-link @if (request()->routeIs('m3.userPickingStats5')) is-active @endif"><i class="fa-solid fa-chart-line wms-sidebar-icon" aria-hidden="true"></i><span>{{ __('KPI1 Line') }}</span></a>@endif
|
||||
@if (Route::has('m3.execsummary'))<a href="{{ route('m3.execsummary') }}" class="wms-sidebar-link wms-m3-submenu-link @if (request()->routeIs('m3.execsummary*')) is-active @endif"><i class="fa-solid fa-chart-simple wms-sidebar-icon" aria-hidden="true"></i><span>{{ __('OTTC') }}</span></a>@endif
|
||||
@if (Route::has('sentinel-integration.index'))<a href="{{ route('sentinel-integration.index') }}" class="wms-sidebar-link wms-m3-submenu-link"><i class="fa-solid fa-satellite-dish wms-sidebar-icon" aria-hidden="true"></i><span>{{ __('Sentinel Home') }}</span></a>@endif
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
|
||||
Reference in New Issue
Block a user