revised notification for new approval system
This commit is contained in:
@@ -167,18 +167,28 @@ class FormEntertainmentPresentationController extends Controller
|
||||
'status' => 'On Progress',
|
||||
]);
|
||||
|
||||
// Send notification to MIS and Admin Region
|
||||
$roles = ['Marketing Information System', 'Admin Region'];
|
||||
$recipients = [];
|
||||
$phoneNumbers = [];
|
||||
|
||||
$name = auth()->user()->name;
|
||||
$tanggal = $form->tanggal;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->total;
|
||||
|
||||
// Send notification to MIS and Admin Region and Area Manager Cabang
|
||||
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang', 'Marketing Operational Manager Region'];
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||
|
||||
// Collect all recipients (emails and phone numbers) for the specified roles
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role);
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang) {
|
||||
// Include 'Marketing Information System' without cabang filtering
|
||||
if ($role === 'Marketing Information System') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ensure user has a cabang and matches the current cabang ID
|
||||
return $user->cabang && $user->cabang->cabang->id === $cabang->id;
|
||||
});
|
||||
|
||||
// Extract emails and phone numbers
|
||||
foreach ($users as $user) {
|
||||
$recipients[] = $user->email;
|
||||
$phoneNumbers[] = $user->phone;
|
||||
@@ -187,6 +197,7 @@ class FormEntertainmentPresentationController extends Controller
|
||||
|
||||
// Remove duplicate email addresses, if any
|
||||
$recipients = array_unique($recipients);
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// Generate URL and send WhatsApp notification
|
||||
$url = route('forms.entertainment.view', $form->id);
|
||||
@@ -294,24 +305,33 @@ class FormEntertainmentPresentationController extends Controller
|
||||
'status' => 'Approved 1',
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang'];
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||
|
||||
if ($heads['cabang_head']) {
|
||||
$recipients[] = $heads['cabang_head']['email'];
|
||||
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||
}
|
||||
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||
// Include 'Marketing Information System' without cabang filtering
|
||||
if ($role === 'Marketing Information System') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($heads['region_head']) {
|
||||
$recipients[] = $heads['region_head']['email'];
|
||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||
// Ensure user has a cabang and matches the current cabang ID
|
||||
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||
});
|
||||
|
||||
// Extract emails and phone numbers
|
||||
foreach ($users as $user) {
|
||||
$recipients[] = $user->email;
|
||||
$phoneNumbers[] = $user->phone;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicate data, if any
|
||||
@@ -353,18 +373,28 @@ class FormEntertainmentPresentationController extends Controller
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang', 'Marketing Operational Manager Region'];
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||
|
||||
if ($heads['cabang_head']) {
|
||||
$recipients[] = $heads['cabang_head']['email'];
|
||||
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||
}
|
||||
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||
|
||||
if ($heads['region_head']) {
|
||||
$recipients[] = $heads['region_head']['email'];
|
||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||
// Include 'Marketing Information System' without cabang filtering
|
||||
if ($role === 'Marketing Information System') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ensure user has a cabang and matches the current cabang ID
|
||||
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||
});
|
||||
|
||||
// Extract emails and phone numbers
|
||||
foreach ($users as $user) {
|
||||
$recipients[] = $user->email;
|
||||
$phoneNumbers[] = $user->phone;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicate data, if any
|
||||
@@ -413,24 +443,31 @@ class FormEntertainmentPresentationController extends Controller
|
||||
'approved_total' => $form->total,
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->approved_total;
|
||||
|
||||
// Collect all recipients
|
||||
$roles = ['Head of Sales Marketing', 'Marketing Operational Manager Region'];
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||
|
||||
if ($heads['cabang_head']) {
|
||||
$recipients[] = $heads['cabang_head']['email'];
|
||||
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||
}
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||
// Include 'Marketing Information System' without cabang filtering
|
||||
if ($role === 'Marketing Information System') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($heads['region_head']) {
|
||||
$recipients[] = $heads['region_head']['email'];
|
||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||
// Ensure user has a cabang and matches the current cabang ID
|
||||
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||
});
|
||||
|
||||
// Extract emails and phone numbers
|
||||
foreach ($users as $user) {
|
||||
$recipients[] = $user->email;
|
||||
$phoneNumbers[] = $user->phone;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicate email addresses, if any
|
||||
|
||||
@@ -205,18 +205,28 @@ class FormMeetingSeminarController extends Controller
|
||||
'status' => 'On Progress',
|
||||
]);
|
||||
|
||||
// Send notification to MIS and Admin Region
|
||||
$roles = ['Marketing Information System', 'Admin Region'];
|
||||
$recipients = [];
|
||||
$phoneNumbers = [];
|
||||
|
||||
$name = auth()->user()->name;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->total;
|
||||
|
||||
// Send notification to MIS and Admin Region and Area Manager Cabang
|
||||
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang', 'Marketing Operational Manager Region'];
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||
|
||||
// Collect all recipients (emails and phone numbers) for the specified roles
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role);
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang) {
|
||||
// Include 'Marketing Information System' without cabang filtering
|
||||
if ($role === 'Marketing Information System') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ensure user has a cabang and matches the current cabang ID
|
||||
return $user->cabang && $user->cabang->cabang->id === $cabang->id;
|
||||
});
|
||||
|
||||
// Extract emails and phone numbers
|
||||
foreach ($users as $user) {
|
||||
$recipients[] = $user->email;
|
||||
$phoneNumbers[] = $user->phone;
|
||||
@@ -366,24 +376,33 @@ class FormMeetingSeminarController extends Controller
|
||||
'status' => 'Approved 1',
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang'];
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||
|
||||
if ($heads['cabang_head']) {
|
||||
$recipients[] = $heads['cabang_head']['email'];
|
||||
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||
}
|
||||
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||
// Include 'Marketing Information System' without cabang filtering
|
||||
if ($role === 'Marketing Information System') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($heads['region_head']) {
|
||||
$recipients[] = $heads['region_head']['email'];
|
||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||
// Ensure user has a cabang and matches the current cabang ID
|
||||
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||
});
|
||||
|
||||
// Extract emails and phone numbers
|
||||
foreach ($users as $user) {
|
||||
$recipients[] = $user->email;
|
||||
$phoneNumbers[] = $user->phone;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicate data, if any
|
||||
@@ -419,24 +438,33 @@ class FormMeetingSeminarController extends Controller
|
||||
'status' => 'Approved 2',
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang', 'Marketing Operational Manager Region'];
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||
|
||||
if ($heads['cabang_head']) {
|
||||
$recipients[] = $heads['cabang_head']['email'];
|
||||
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||
}
|
||||
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||
|
||||
if ($heads['region_head']) {
|
||||
$recipients[] = $heads['region_head']['email'];
|
||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||
// Include 'Marketing Information System' without cabang filtering
|
||||
if ($role === 'Marketing Information System') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ensure user has a cabang and matches the current cabang ID
|
||||
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||
});
|
||||
|
||||
// Extract emails and phone numbers
|
||||
foreach ($users as $user) {
|
||||
$recipients[] = $user->email;
|
||||
$phoneNumbers[] = $user->phone;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicate data, if any
|
||||
@@ -494,24 +522,31 @@ class FormMeetingSeminarController extends Controller
|
||||
'approved_total' => array_sum($approved_data),
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->approved_total;
|
||||
|
||||
// Collect all recipients
|
||||
$roles = ['Head of Sales Marketing', 'Marketing Operational Manager Region'];
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||
|
||||
if ($heads['cabang_head']) {
|
||||
$recipients[] = $heads['cabang_head']['email'];
|
||||
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||
}
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||
// Include 'Marketing Information System' without cabang filtering
|
||||
if ($role === 'Marketing Information System') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($heads['region_head']) {
|
||||
$recipients[] = $heads['region_head']['email'];
|
||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||
// Ensure user has a cabang and matches the current cabang ID
|
||||
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||
});
|
||||
|
||||
// Extract emails and phone numbers
|
||||
foreach ($users as $user) {
|
||||
$recipients[] = $user->email;
|
||||
$phoneNumbers[] = $user->phone;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicate email addresses, if any
|
||||
|
||||
@@ -165,18 +165,28 @@ class FormOtherController extends Controller
|
||||
'status' => 'On Progress',
|
||||
]);
|
||||
|
||||
// Send notification to MIS and Admin Region
|
||||
$roles = ['Marketing Information System', 'Admin Region'];
|
||||
$recipients = [];
|
||||
$phoneNumbers = [];
|
||||
|
||||
$name = auth()->user()->name;
|
||||
$tanggal = $request->tanggal;
|
||||
$total = $request->total;
|
||||
|
||||
// Send notification to MIS and Admin Region and Area Manager Cabang
|
||||
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang', 'Marketing Operational Manager Region'];
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||
|
||||
// Collect all recipients (emails and phone numbers) for the specified roles
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role);
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang) {
|
||||
// Include 'Marketing Information System' without cabang filtering
|
||||
if ($role === 'Marketing Information System') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ensure user has a cabang and matches the current cabang ID
|
||||
return $user->cabang && $user->cabang->cabang->id === $cabang->id;
|
||||
});
|
||||
|
||||
// Extract emails and phone numbers
|
||||
foreach ($users as $user) {
|
||||
$recipients[] = $user->email;
|
||||
$phoneNumbers[] = $user->phone;
|
||||
@@ -185,6 +195,7 @@ class FormOtherController extends Controller
|
||||
|
||||
// Remove duplicate email addresses, if any
|
||||
$recipients = array_unique($recipients);
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// Generate URL and send WhatsApp notification
|
||||
$url = route('forms.other.view', $form->id);
|
||||
@@ -294,17 +305,27 @@ class FormOtherController extends Controller
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang'];
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||
|
||||
if ($heads['cabang_head']) {
|
||||
$recipients[] = $heads['cabang_head']['email'];
|
||||
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||
}
|
||||
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||
// Include 'Marketing Information System' without cabang filtering
|
||||
if ($role === 'Marketing Information System') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($heads['region_head']) {
|
||||
$recipients[] = $heads['region_head']['email'];
|
||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||
// Ensure user has a cabang and matches the current cabang ID
|
||||
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||
});
|
||||
|
||||
// Extract emails and phone numbers
|
||||
foreach ($users as $user) {
|
||||
$recipients[] = $user->email;
|
||||
$phoneNumbers[] = $user->phone;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicate data, if any
|
||||
@@ -340,24 +361,33 @@ class FormOtherController extends Controller
|
||||
'status' => 'Approved 2',
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang', 'Marketing Operational Manager Region'];
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||
|
||||
if ($heads['cabang_head']) {
|
||||
$recipients[] = $heads['cabang_head']['email'];
|
||||
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||
}
|
||||
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||
|
||||
if ($heads['region_head']) {
|
||||
$recipients[] = $heads['region_head']['email'];
|
||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||
// Include 'Marketing Information System' without cabang filtering
|
||||
if ($role === 'Marketing Information System') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ensure user has a cabang and matches the current cabang ID
|
||||
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||
});
|
||||
|
||||
// Extract emails and phone numbers
|
||||
foreach ($users as $user) {
|
||||
$recipients[] = $user->email;
|
||||
$phoneNumbers[] = $user->phone;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicate data, if any
|
||||
@@ -406,24 +436,31 @@ class FormOtherController extends Controller
|
||||
'approved_total' => $form->total,
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->approved_total;
|
||||
|
||||
// Collect all recipients
|
||||
$roles = ['Head of Sales Marketing', 'Marketing Operational Manager Region'];
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||
|
||||
if ($heads['cabang_head']) {
|
||||
$recipients[] = $heads['cabang_head']['email'];
|
||||
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||
}
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||
// Include 'Marketing Information System' without cabang filtering
|
||||
if ($role === 'Marketing Information System') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($heads['region_head']) {
|
||||
$recipients[] = $heads['region_head']['email'];
|
||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||
// Ensure user has a cabang and matches the current cabang ID
|
||||
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||
});
|
||||
|
||||
// Extract emails and phone numbers
|
||||
foreach ($users as $user) {
|
||||
$recipients[] = $user->email;
|
||||
$phoneNumbers[] = $user->phone;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicate email addresses, if any
|
||||
|
||||
@@ -236,10 +236,10 @@ class FormUpCountryController extends Controller
|
||||
'status' => 'On Progress',
|
||||
]);
|
||||
|
||||
// Send notification to MIS and Admin Region
|
||||
$roles = ['Marketing Information System', 'Admin Region'];
|
||||
$recipients = [];
|
||||
$phoneNumbers = [];
|
||||
// Send notification to MIS and Admin Region and Area Manager Cabang
|
||||
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang', 'Marketing Operational Manager Region'];
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||
|
||||
$name = auth()->user()->name;
|
||||
$tanggal = $form->tanggal;
|
||||
@@ -247,7 +247,17 @@ class FormUpCountryController extends Controller
|
||||
|
||||
// Collect all recipients (emails and phone numbers) for the specified roles
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role);
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang) {
|
||||
// Include 'Marketing Information System' without cabang filtering
|
||||
if ($role === 'Marketing Information System') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ensure user has a cabang and matches the current cabang ID
|
||||
return $user->cabang && $user->cabang->cabang->id === $cabang->id;
|
||||
});
|
||||
|
||||
// Extract emails and phone numbers
|
||||
foreach ($users as $user) {
|
||||
$recipients[] = $user->email;
|
||||
$phoneNumbers[] = $user->phone;
|
||||
@@ -256,6 +266,7 @@ class FormUpCountryController extends Controller
|
||||
|
||||
// Remove duplicate email addresses, if any
|
||||
$recipients = array_unique($recipients);
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// Generate URL and send WhatsApp notification
|
||||
$url = route('forms.up-country.view', $form->id);
|
||||
@@ -423,24 +434,33 @@ class FormUpCountryController extends Controller
|
||||
'status' => 'Approved 1',
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->tanggal;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang'];
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||
|
||||
if ($heads['cabang_head']) {
|
||||
$recipients[] = $heads['cabang_head']['email'];
|
||||
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||
}
|
||||
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||
// Include 'Marketing Information System' without cabang filtering
|
||||
if ($role === 'Marketing Information System') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($heads['region_head']) {
|
||||
$recipients[] = $heads['region_head']['email'];
|
||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||
// Ensure user has a cabang and matches the current cabang ID
|
||||
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||
});
|
||||
|
||||
// Extract emails and phone numbers
|
||||
foreach ($users as $user) {
|
||||
$recipients[] = $user->email;
|
||||
$phoneNumbers[] = $user->phone;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicate data, if any
|
||||
@@ -476,24 +496,33 @@ class FormUpCountryController extends Controller
|
||||
'status' => 'Approved 2',
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->tanggal;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang', 'Marketing Operational Manager Region'];
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||
|
||||
if ($heads['cabang_head']) {
|
||||
$recipients[] = $heads['cabang_head']['email'];
|
||||
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||
}
|
||||
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||
|
||||
if ($heads['region_head']) {
|
||||
$recipients[] = $heads['region_head']['email'];
|
||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||
// Include 'Marketing Information System' without cabang filtering
|
||||
if ($role === 'Marketing Information System') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ensure user has a cabang and matches the current cabang ID
|
||||
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||
});
|
||||
|
||||
// Extract emails and phone numbers
|
||||
foreach ($users as $user) {
|
||||
$recipients[] = $user->email;
|
||||
$phoneNumbers[] = $user->phone;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicate data, if any
|
||||
@@ -553,24 +582,31 @@ class FormUpCountryController extends Controller
|
||||
'approved_total' => array_sum($approved_data),
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->tanggal;
|
||||
$total = $form->approved_total;
|
||||
|
||||
// Collect all recipients
|
||||
$roles = ['Head of Sales Marketing', 'Marketing Operational Manager Region'];
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||
|
||||
if ($heads['cabang_head']) {
|
||||
$recipients[] = $heads['cabang_head']['email'];
|
||||
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||
}
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||
// Include 'Marketing Information System' without cabang filtering
|
||||
if ($role === 'Marketing Information System') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($heads['region_head']) {
|
||||
$recipients[] = $heads['region_head']['email'];
|
||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||
// Ensure user has a cabang and matches the current cabang ID
|
||||
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||
});
|
||||
|
||||
// Extract emails and phone numbers
|
||||
foreach ($users as $user) {
|
||||
$recipients[] = $user->email;
|
||||
$phoneNumbers[] = $user->phone;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicate email addresses, if any
|
||||
|
||||
@@ -169,18 +169,28 @@ class FormVehicleController extends Controller
|
||||
'status' => 'On Progress',
|
||||
]);
|
||||
|
||||
// Send notification to MIS and Admin Region
|
||||
$roles = ['Marketing Information System', 'Admin Region'];
|
||||
$recipients = [];
|
||||
$phoneNumbers = [];
|
||||
|
||||
$name = auth()->user()->name;
|
||||
$tanggal = $form->tanggal;
|
||||
$total = $form->total;
|
||||
|
||||
// Send notification to MIS and Admin Region and Area Manager Cabang
|
||||
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang', 'Marketing Operational Manager Region'];
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||
|
||||
// Collect all recipients (emails and phone numbers) for the specified roles
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role);
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang) {
|
||||
// Include 'Marketing Information System' without cabang filtering
|
||||
if ($role === 'Marketing Information System') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ensure user has a cabang and matches the current cabang ID
|
||||
return $user->cabang && $user->cabang->cabang->id === $cabang->id;
|
||||
});
|
||||
|
||||
// Extract emails and phone numbers
|
||||
foreach ($users as $user) {
|
||||
$recipients[] = $user->email;
|
||||
$phoneNumbers[] = $user->phone;
|
||||
@@ -189,6 +199,7 @@ class FormVehicleController extends Controller
|
||||
|
||||
// Remove duplicate email addresses, if any
|
||||
$recipients = array_unique($recipients);
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// Generate URL and send WhatsApp notification
|
||||
$url = route('forms.vehicle.view', $form->id);
|
||||
@@ -297,24 +308,33 @@ class FormVehicleController extends Controller
|
||||
'status' => 'Approved 1',
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang'];
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||
|
||||
if ($heads['cabang_head']) {
|
||||
$recipients[] = $heads['cabang_head']['email'];
|
||||
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||
}
|
||||
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||
// Include 'Marketing Information System' without cabang filtering
|
||||
if ($role === 'Marketing Information System') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($heads['region_head']) {
|
||||
$recipients[] = $heads['region_head']['email'];
|
||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||
// Ensure user has a cabang and matches the current cabang ID
|
||||
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||
});
|
||||
|
||||
// Extract emails and phone numbers
|
||||
foreach ($users as $user) {
|
||||
$recipients[] = $user->email;
|
||||
$phoneNumbers[] = $user->phone;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicate data, if any
|
||||
@@ -350,24 +370,33 @@ class FormVehicleController extends Controller
|
||||
'status' => 'Approved 2',
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang', 'Marketing Operational Manager Region'];
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||
|
||||
if ($heads['cabang_head']) {
|
||||
$recipients[] = $heads['cabang_head']['email'];
|
||||
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||
}
|
||||
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||
|
||||
if ($heads['region_head']) {
|
||||
$recipients[] = $heads['region_head']['email'];
|
||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||
// Include 'Marketing Information System' without cabang filtering
|
||||
if ($role === 'Marketing Information System') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ensure user has a cabang and matches the current cabang ID
|
||||
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||
});
|
||||
|
||||
// Extract emails and phone numbers
|
||||
foreach ($users as $user) {
|
||||
$recipients[] = $user->email;
|
||||
$phoneNumbers[] = $user->phone;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicate data, if any
|
||||
@@ -416,24 +445,31 @@ class FormVehicleController extends Controller
|
||||
'approved_total' => $form->total,
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->approved_total;
|
||||
|
||||
// Collect all recipients
|
||||
$roles = ['Head of Sales Marketing', 'Marketing Operational Manager Region'];
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||
|
||||
if ($heads['cabang_head']) {
|
||||
$recipients[] = $heads['cabang_head']['email'];
|
||||
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||
}
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||
// Include 'Marketing Information System' without cabang filtering
|
||||
if ($role === 'Marketing Information System') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($heads['region_head']) {
|
||||
$recipients[] = $heads['region_head']['email'];
|
||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||
// Ensure user has a cabang and matches the current cabang ID
|
||||
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||
});
|
||||
|
||||
// Extract emails and phone numbers
|
||||
foreach ($users as $user) {
|
||||
$recipients[] = $user->email;
|
||||
$phoneNumbers[] = $user->phone;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicate email addresses, if any
|
||||
|
||||
Reference in New Issue
Block a user