updates to M3 module

This commit is contained in:
Mark Gregory
2026-09-16 16:51:59 +01:00
parent ce06aa9fac
commit 0237b1dc2a
6 changed files with 99 additions and 69 deletions
@@ -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) {