M3 Integration fixes
This commit is contained in:
+79
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\M3\Models\ICM428M;
|
||||
|
||||
class UserProfileController extends Controller
|
||||
{
|
||||
public static function index(Request $request)
|
||||
{
|
||||
|
||||
// Get Current USER
|
||||
$loggedUser = strtoupper(m3_user());
|
||||
|
||||
$iCM428M = DB::connection(config('m3.connection', 'pgsql'))->table('icm428m')
|
||||
->select('R428US', 'R428CO', 'R428WH', 'R428PL', 'R428FIRST', 'R428FAMILY')
|
||||
->where('R428US', '=', $loggedUser)
|
||||
->where('R42821A', '=', 'Y')
|
||||
->first();
|
||||
|
||||
$iC670M = DB::connection(config('m3.connection', 'pgsql'))->table('ic670m')->get();
|
||||
|
||||
// Check if user is eligible for Profile update
|
||||
if (isset($iCM428M->R428US)) {
|
||||
return view('m3::liberty-theme.pages.userProfile', ['ICM428M' => $iCM428M, 'IC670M' => $iC670M]);
|
||||
} else {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function updateUserProfile(Request $request)
|
||||
{
|
||||
|
||||
$r428US = isset($request->R428US) ? trim($request->R428US) : '';
|
||||
$r428DPW = isset($request->R428DPW) ? trim($request->R428DPW) : '';
|
||||
|
||||
$r428CO = substr($r428DPW, 0, 3);
|
||||
$r428PL = substr($r428DPW, 3, 3);
|
||||
$r428WH = substr($r428DPW, 6, 3);
|
||||
|
||||
if ($r428US != '') {
|
||||
// Update record to ICM428M
|
||||
DB::connection(config('m3.connection', 'pgsql'))->update("update ICM428M
|
||||
set R428CO='$r428CO', R428PL='$r428PL', R428WH='$r428WH'
|
||||
where R428US='$r428US'");
|
||||
|
||||
return redirect('/userprofile')->with('success', 'Profile updated successfully!');
|
||||
} else {
|
||||
return redirect('/userprofile')->with('success', 'Profile updated successfully!');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function updateUserProfileAjax(Request $request)
|
||||
{
|
||||
|
||||
$r428US = isset($request->R428US) ? trim($request->R428US) : '';
|
||||
$r428DPW = isset($request->R428DPW) ? trim($request->R428DPW) : '';
|
||||
|
||||
$r428CO = substr($r428DPW, 0, 3);
|
||||
$r428PL = substr($r428DPW, 3, 3);
|
||||
$r428WH = substr($r428DPW, 6, 3);
|
||||
|
||||
if ($r428US != '') {
|
||||
// Update record to ICM428M
|
||||
DB::connection(config('m3.connection', 'pgsql'))->update("update ICM428M
|
||||
set R428CO='$r428CO', R428PL='$r428PL', R428WH='$r428WH'
|
||||
where R428US='$r428US'");
|
||||
|
||||
return response()->json(['success' => true]);
|
||||
} else {
|
||||
return response()->json(['success' => false]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user