diff --git a/app/Http/Controllers/Forms/FormEntertainmentPresentationController.php b/app/Http/Controllers/Forms/FormEntertainmentPresentationController.php index 6356a48..4da4b7d 100644 --- a/app/Http/Controllers/Forms/FormEntertainmentPresentationController.php +++ b/app/Http/Controllers/Forms/FormEntertainmentPresentationController.php @@ -31,7 +31,7 @@ class FormEntertainmentPresentationController extends Controller $role = auth()->user()->getRoleNames()[0]; $forms = FormEntertaimentPresentation::get(); - if ($role == 'Admin Region') { + if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') { $region_id = auth()->user()->getMyCabangAndRegionId()['region']; if ($region_id) { @@ -43,8 +43,20 @@ class FormEntertainmentPresentationController extends Controller $forms = $forms->whereIn('user_id', $userIds); } } - else { + else if ($role == 'Area Manager Cabang') { + $cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang']; + + if ($cabang_id) { + $users = UserHasCabang::where('cabang_id', $cabang_id)->get(); + $userIds = $users->pluck('user_id')->toArray(); + $forms = $forms->whereIn('user_id', $userIds); + } + } + else if ($role == 'Medical Representatif') { $forms = $forms->where('user_id', auth()->user()->id); + } + else { + $forms = $forms; } session()->put('redirect_url', route('forms.entertainment')); diff --git a/app/Http/Controllers/Forms/FormMeetingSeminarController.php b/app/Http/Controllers/Forms/FormMeetingSeminarController.php index 0af0ff7..4454739 100644 --- a/app/Http/Controllers/Forms/FormMeetingSeminarController.php +++ b/app/Http/Controllers/Forms/FormMeetingSeminarController.php @@ -31,7 +31,7 @@ class FormMeetingSeminarController extends Controller $role = auth()->user()->getRoleNames()[0]; $forms = FormMeetingSeminar::get(); - if ($role == 'Admin Region') { + if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') { $region_id = auth()->user()->getMyCabangAndRegionId()['region']; if ($region_id) { @@ -43,8 +43,20 @@ class FormMeetingSeminarController extends Controller $forms = $forms->whereIn('user_id', $userIds); } } - else { + else if ($role == 'Area Manager Cabang') { + $cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang']; + + if ($cabang_id) { + $users = UserHasCabang::where('cabang_id', $cabang_id)->get(); + $userIds = $users->pluck('user_id')->toArray(); + $forms = $forms->whereIn('user_id', $userIds); + } + } + else if ($role == 'Medical Representatif') { $forms = $forms->where('user_id', auth()->user()->id); + } + else { + $forms = $forms; } session()->put('redirect_url', route('forms.meeting')); diff --git a/app/Http/Controllers/Forms/FormOtherController.php b/app/Http/Controllers/Forms/FormOtherController.php index 71bfc8e..b4c305d 100644 --- a/app/Http/Controllers/Forms/FormOtherController.php +++ b/app/Http/Controllers/Forms/FormOtherController.php @@ -34,7 +34,7 @@ class FormOtherController extends Controller $role = auth()->user()->getRoleNames()[0]; $forms = FormOthers::get(); - if ($role == 'Admin Region') { + if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') { $region_id = auth()->user()->getMyCabangAndRegionId()['region']; if ($region_id) { @@ -46,8 +46,20 @@ class FormOtherController extends Controller $forms = $forms->whereIn('user_id', $userIds); } } - else { + else if ($role == 'Area Manager Cabang') { + $cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang']; + + if ($cabang_id) { + $users = UserHasCabang::where('cabang_id', $cabang_id)->get(); + $userIds = $users->pluck('user_id')->toArray(); + $forms = $forms->whereIn('user_id', $userIds); + } + } + else if ($role == 'Medical Representatif') { $forms = $forms->where('user_id', auth()->user()->id); + } + else { + $forms = $forms; } session()->put('redirect_url', route('forms.other')); diff --git a/app/Http/Controllers/Forms/FormUpCountryController.php b/app/Http/Controllers/Forms/FormUpCountryController.php index 4ad9549..62e1497 100644 --- a/app/Http/Controllers/Forms/FormUpCountryController.php +++ b/app/Http/Controllers/Forms/FormUpCountryController.php @@ -30,7 +30,7 @@ class FormUpCountryController extends Controller $role = auth()->user()->getRoleNames()[0]; $forms = FormUpCountry::get(); - if ($role == 'Admin Region') { + if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') { $region_id = auth()->user()->getMyCabangAndRegionId()['region']; if ($region_id) { @@ -42,8 +42,20 @@ class FormUpCountryController extends Controller $forms = $forms->whereIn('user_id', $userIds); } } - else { + else if ($role == 'Area Manager Cabang') { + $cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang']; + + if ($cabang_id) { + $users = UserHasCabang::where('cabang_id', $cabang_id)->get(); + $userIds = $users->pluck('user_id')->toArray(); + $forms = $forms->whereIn('user_id', $userIds); + } + } + else if ($role == 'Medical Representatif') { $forms = $forms->where('user_id', auth()->user()->id); + } + else { + $forms = $forms; } session()->put('redirect_url', route('forms.up-country')); diff --git a/app/Http/Controllers/Forms/FormVehicleController.php b/app/Http/Controllers/Forms/FormVehicleController.php index 30ccd09..9a9963e 100644 --- a/app/Http/Controllers/Forms/FormVehicleController.php +++ b/app/Http/Controllers/Forms/FormVehicleController.php @@ -30,7 +30,7 @@ class FormVehicleController extends Controller $role = auth()->user()->getRoleNames()[0]; $forms = FormVehicleRunningCost::get(); - if ($role == 'Admin Region') { + if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') { $region_id = auth()->user()->getMyCabangAndRegionId()['region']; if ($region_id) { @@ -42,8 +42,20 @@ class FormVehicleController extends Controller $forms = $forms->whereIn('user_id', $userIds); } } - else { + else if ($role == 'Area Manager Cabang') { + $cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang']; + + if ($cabang_id) { + $users = UserHasCabang::where('cabang_id', $cabang_id)->get(); + $userIds = $users->pluck('user_id')->toArray(); + $forms = $forms->whereIn('user_id', $userIds); + } + } + else if ($role == 'Medical Representatif') { $forms = $forms->where('user_id', auth()->user()->id); + } + else { + $forms = $forms; } session()->put('redirect_url', route('forms.vehicle'));