table('icm428m')->get(); $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; $ICM428M = DB::connection(config('m3.connection', 'pgsql'))->select("SELECT * FROM ICM428M where R428CO='$co' and R428WH='$whs'"); #765 add DATE_PASSWORD_EXPIRES as DATE_EXPIRED, SET_PASSWORD_TO_EXPIRE as EXPIRED $USER_INFO = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')->selectRaw('R428US as USERPRF, R428STS as STATUS, NULL as DATE_EXPIRED, NULL as EXPIRED')->get()->all(); #echo "
"; var_dump($USER_INFO); echo ""; $power_user = DB::connection(config('m3.connection', 'pgsql'))->select("select R428PWRUSR, R428CO, R428PL, R428WH from ICM428M where R428US='".strtoUpper(m3_user())."'"); #765 # $expired_users = DB::connection(config('m3.connection', 'pgsql'))->select("SELECT USER_PROFILE FROM TABLE (SYSTOOLS.AUDIT_JOURNAL_CP () ) WHERE PASSWORD_EXPIRED = '*YES'"); # echo "
"; print_r($expired_users); echo ""; $IC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get(); return view('m3::liberty-theme.pages.userControl', compact('ICM428M','IC670M','power_user','USER_INFO')); } // // Process data from Add modal // public static function saveUserAdd(Request $request) { if($request->R428EMPCDE=="") { $request->R428EMPCDE=0; } // Insert record to ICM428M #dump($request); // Validate user profile exists on the system $usrprf = [(object) ['COUNT' => 0]]; // PostgreSQL/Core owns M3 profiles; no QSYS2 lookup. // Validate employee code exists in LBPF file #if($request->R428EMPCDE>0) { # $empcde=DB::connection(config('m3.connection', 'pgsql'))->select("select count(*) as COUNT2 from LBPF where EMPNO='$request->R428EMPCDE'"); # if($empcde[0]->COUNT2=="0") { # #echo ""; # return "error empcd"; # } #} $icm428m=DB::connection(config('m3.connection', 'pgsql'))->select("select count(*) as COUNT1 from ICM428M where R428US='$request->R428US'"); if($icm428m[0]->COUNT1=="1") { return "error exists"; } else { if($usrprf[0]->COUNT=="1") { DB::connection(config('m3.connection', 'pgsql'))->insert("insert into ICM428M (R428CO, R428PL, R428WH, R428STS, R428US, R428FIRST, R428FAMILY, R428EMAIL, R428EMPCDE, R428ADMUSR, R428PWRUSR, MENU2OPT, MENU3OPT, MENU4OPT, MENU5OPT, MENU6OPT, R42811A) values ('$request->R428CO', '$request->R428PL', '$request->R428WH', '$request->R428STS', '$request->R428US', '$request->R428FIRST', '$request->R428FAMILY', '$request->R428EMAIL', $request->R428EMPCDE, '$request->R428ADMUSR', '$request->R428PWRUSR', 'NN".$request->MENU2OPT3."NNN".$request->MENU2OPT7.$request->MENU2OPT8."N', '".$request->MENU3OPT1.$request->MENU3OPT2."NNNNNNN', '".$request->MENU4OPT1.$request->MENU4OPT2.$request->MENU4OPT3."NNNNNN', '".$request->MENU5OPT1.$request->MENU5OPT2.$request->MENU5OPT3."N".$request->MENU5OPT5."NNNN','".$request->MENU6OPT1.$request->MENU6OPT2.$request->MENU6OPT3."','".$request->R42811A."')"); return "success"; } else { #echo ""; # CL program call here (ewobjtst.)ICMUSRPRF parms(R428US, R428FIRST, R428FAMILY) // connect to toolkit using DB2 credentials (can also leave blank for default authority) try { $conn = app(\Modules\M3\Services\PostgresProgramBridge::class); } catch (Exception $e) { // Determine reason for failure. // Probably database authentication error or invalid or unreachable database. $code = $e->getCode(); $msg = $e->getMessage(); switch ($code) { case 8001: // "Authorization failure on distributed database connection attempt" // Usually means a wrong DB2 user or password $PGMERRORS = 'Could not connect due to wrong user or password.'; return "error profile3"; break; case 42705: $PGMERRORS = 'Database not found. Try WRKRDBDIRE to check.'; return "error profile4"; break; default: $PGMERRORS = 'Could not connect. Error: ' . $code . ' ' . $msg; return "error profile5"; break; } } $conn->setOptions(array('persistent' => false, 'stateless' => true, 'debug' => true,'debugLogFile' => '/www/sentm3test/htdocs/M3/storage/logs/toolkit_debug.log')); // Add LIB // $result = $conn->CLCommand('ADDLIBLE LIB(MPDAT10)'); // define several input/output params $params = []; $params[] = $conn->AddParameterChar('in',10,'User profile','E#iUsrPrf',$request->R428US); $params[] = $conn->AddParameterChar('in',20,'First name','FIRST',$request->R428FIRST); $params[] = $conn->AddParameterChar('in',30,'Family name','FAMILY',$request->R428FAMILY); ## $result = $conn->PgmCall(Config::get('eproconf.misc.PGM1'), Config::get('eproconf.misc.libname4'), $params, array(), array()); $result = $conn->PgmCall('ICMUSRPRF', 'EWOBJ', $params, array(), array()); if (!$result) { $PGMERRORS = 'Error calling program. Code: ' . $conn->getErrorCode() . ' Msg: ' . $conn->getErrorMsg(); //echo ""; return "error profile2"; } else { // Successful Call : User profile created with default password //dd($result); //echo ""; DB::connection(config('m3.connection', 'pgsql'))->insert("insert into ICM428M (R428CO, R428PL, R428WH, R428STS, R428US, R428FIRST, R428FAMILY, R428EMAIL, R428EMPCDE, R428ADMUSR, R428PWRUSR, MENU2OPT, MENU3OPT, MENU4OPT, MENU5OPT, MENU6OPT, R42811A,R42821A) values ('$request->R428CO', '$request->R428PL', '$request->R428WH', '$request->R428STS', '$request->R428US', '$request->R428FIRST', '$request->R428FAMILY', '$request->R428EMAIL', $request->R428EMPCDE, '$request->R428ADMUSR', '$request->R428PWRUSR', 'NN".$request->MENU2OPT3."NNN".$request->MENU2OPT7.$request->MENU2OPT8."N', '".$request->MENU3OPT1.$request->MENU3OPT2."NNNNNNN', '".$request->MENU4OPT1.$request->MENU4OPT2.$request->MENU4OPT3."NNNNNN', '".$request->MENU5OPT1.$request->MENU5OPT2.$request->MENU5OPT3."N".$request->MENU5OPT5."NNNN','".$request->MENU6OPT1.$request->MENU6OPT2.$request->MENU6OPT3."','".$request->R42811A."','".$request->R42821A."')"); return "success2"; } ##kd return "error profile"; } } } // // Process data from Edit modal // public static function saveUserEdit(Request $request) { #dump($request); if($request->R428EMPCDE=="") { $request->R428EMPCDE=0; } // Validate employee code exists in LBPF file //dump($request->R428EMPCDE); #if($request->R428EMPCDE>0) { # $sqlstmt="select count(*) as COUNT from LBPF where EMPNO='$request->R428EMPCDE'"; # #echo "$sqlstmt