updates to M3 module
This commit is contained in:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user