added url to whatsapp notif, email soon
This commit is contained in:
@@ -8,81 +8,94 @@ use Illuminate\Support\Str;
|
|||||||
|
|
||||||
class WhatsappHelper
|
class WhatsappHelper
|
||||||
{
|
{
|
||||||
public static function approveExpense($phones, $expense_number)
|
public static function approveExpense($phones, $expense_number, $url = null)
|
||||||
{
|
{
|
||||||
$client = new Client();
|
$client = new Client();
|
||||||
|
|
||||||
$data = [];
|
// Ensure the URL is formatted correctly
|
||||||
foreach ($phones as $phone) {
|
if ($url && !preg_match('/^https?:\/\//', $url)) {
|
||||||
$data[] = [
|
$url = 'https://' . $url;
|
||||||
'phone' => $phone,
|
}
|
||||||
'message' => 'Pengajuan pengeluaran anda dengan nomor *' . $expense_number . '* telah disetujui. Silahkan buka website untuk melihat detailnya.',
|
|
||||||
'source' => 'web'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
$data = [];
|
||||||
'headers' => [
|
foreach ($phones as $phone) {
|
||||||
'Authorization' => env('WABLAS_TOKEN'),
|
$data[] = [
|
||||||
'Content-Type' => 'application/json'
|
'phone' => $phone,
|
||||||
],
|
'message' => 'Pengajuan pengeluaran anda dengan nomor *' . $expense_number . '* telah disetujui. Silahkan buka link berikut untuk melihat detailnya: ' . $url,
|
||||||
'json' => [
|
'source' => 'web'
|
||||||
'data' => $data
|
];
|
||||||
]
|
}
|
||||||
]);
|
|
||||||
|
|
||||||
return $response->getBody()->getContents();
|
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
||||||
|
'headers' => [
|
||||||
|
'Authorization' => env('WABLAS_TOKEN'),
|
||||||
|
'Content-Type' => 'application/json'
|
||||||
|
],
|
||||||
|
'json' => [
|
||||||
|
'data' => $data
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $response->getBody()->getContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function rejectExpense($phones, $expense_number)
|
public static function rejectExpense($phones, $expense_number, $url = null)
|
||||||
{
|
{
|
||||||
$client = new Client();
|
$client = new Client();
|
||||||
|
|
||||||
$data = [];
|
if ($url && !preg_match('/^https?:\/\//', $url)) {
|
||||||
foreach ($phones as $phone) {
|
$url = 'https://' . $url;
|
||||||
$data[] = [
|
}
|
||||||
'phone' => $phone,
|
|
||||||
'message' => 'Pengajuan pengeluaran anda dengan nomor *' . $expense_number . '* telah ditolak. Silahkan buka website untuk melihat detailnya.',
|
|
||||||
'source' => 'web'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
$data = [];
|
||||||
'headers' => [
|
foreach ($phones as $phone) {
|
||||||
'Authorization' => env('WABLAS_TOKEN'),
|
$data[] = [
|
||||||
'Content-Type' => 'application/json'
|
'phone' => $phone,
|
||||||
],
|
'message' => 'Pengajuan pengeluaran anda dengan nomor *' . $expense_number . '* telah ditolak. Silahkan buka link berikut untuk melihat detailnya: ' . $url,
|
||||||
'json' => [
|
'source' => 'web'
|
||||||
'data' => $data
|
];
|
||||||
]
|
}
|
||||||
]);
|
|
||||||
|
|
||||||
return $response->getBody()->getContents();
|
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
||||||
}
|
'headers' => [
|
||||||
|
'Authorization' => env('WABLAS_TOKEN'),
|
||||||
|
'Content-Type' => 'application/json'
|
||||||
|
],
|
||||||
|
'json' => [
|
||||||
|
'data' => $data
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
public static function finalApprove($phones, $expense_number)
|
return $response->getBody()->getContents();
|
||||||
{
|
}
|
||||||
$client = new Client();
|
|
||||||
|
|
||||||
$data = [];
|
public static function finalApprove($phones, $expense_number, $url = null)
|
||||||
foreach ($phones as $phone) {
|
{
|
||||||
$data[] = [
|
$client = new Client();
|
||||||
'phone' => $phone,
|
|
||||||
'message' => 'Pengajuan pengeluaran anda dengan nomor *' . $expense_number . '* telah ditutup karena telah selesai diproses. Silahkan buka website untuk melihat detailnya.',
|
|
||||||
'source' => 'web'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
if ($url && !preg_match('/^https?:\/\//', $url)) {
|
||||||
'headers' => [
|
$url = 'https://' . $url;
|
||||||
'Authorization' => env('WABLAS_TOKEN'),
|
}
|
||||||
'Content-Type' => 'application/json'
|
|
||||||
],
|
|
||||||
'json' => [
|
|
||||||
'data' => $data
|
|
||||||
]
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $response->getBody()->getContents();
|
$data = [];
|
||||||
}
|
foreach ($phones as $phone) {
|
||||||
|
$data[] = [
|
||||||
|
'phone' => $phone,
|
||||||
|
'message' => 'Pengajuan pengeluaran anda dengan nomor *' . $expense_number . '* telah ditutup karena telah selesai diproses. Silahkan buka link berikut untuk melihat detailnya: ' . $url,
|
||||||
|
'source' => 'web'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
||||||
|
'headers' => [
|
||||||
|
'Authorization' => env('WABLAS_TOKEN'),
|
||||||
|
'Content-Type' => 'application/json'
|
||||||
|
],
|
||||||
|
'json' => [
|
||||||
|
'data' => $data
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $response->getBody()->getContents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -343,7 +343,8 @@ class FormMeetingSeminarController extends Controller
|
|||||||
// ));
|
// ));
|
||||||
|
|
||||||
// Send bulk WhatsApp message
|
// Send bulk WhatsApp message
|
||||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number);
|
$url = route('forms.meeting.view', $form->id);
|
||||||
|
WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url);
|
||||||
|
|
||||||
AuditTrailHelper::AddAuditTrail('Approve', 'Approve Expense at Form Meeting Seminar (' . $form->expense_number . ')');
|
AuditTrailHelper::AddAuditTrail('Approve', 'Approve Expense at Form Meeting Seminar (' . $form->expense_number . ')');
|
||||||
session()->flash('success', 'Form has been approved.');
|
session()->flash('success', 'Form has been approved.');
|
||||||
@@ -399,7 +400,8 @@ class FormMeetingSeminarController extends Controller
|
|||||||
// ));
|
// ));
|
||||||
|
|
||||||
// send whatsapp message
|
// send whatsapp message
|
||||||
WhatsappHelper::finalApprove($phoneNumbers, $expense_number);
|
$url = route('forms.meeting.view', $form->id);
|
||||||
|
WhatsappHelper::finalApprove($phoneNumbers, $expense_number, $url);
|
||||||
|
|
||||||
AuditTrailHelper::AddAuditTrail('Final Approve', 'Final Approve Expense at Form Meeting Seminar (' . $form->expense_number . ')');
|
AuditTrailHelper::AddAuditTrail('Final Approve', 'Final Approve Expense at Form Meeting Seminar (' . $form->expense_number . ')');
|
||||||
session()->flash('success', 'Form has been final approved.');
|
session()->flash('success', 'Form has been final approved.');
|
||||||
@@ -464,7 +466,8 @@ class FormMeetingSeminarController extends Controller
|
|||||||
// ));
|
// ));
|
||||||
|
|
||||||
// Send bulk WhatsApp message
|
// Send bulk WhatsApp message
|
||||||
WhatsappHelper::rejectExpense($phoneNumbers, $expense_number);
|
$url = route('forms.meeting.view', $form->id);
|
||||||
|
WhatsappHelper::rejectExpense($phoneNumbers, $expense_number, $url);
|
||||||
|
|
||||||
AuditTrailHelper::AddAuditTrail('Reject', 'Reject Expense at Form Meeting Seminar (' . $form->expense_number . ')');
|
AuditTrailHelper::AddAuditTrail('Reject', 'Reject Expense at Form Meeting Seminar (' . $form->expense_number . ')');
|
||||||
session()->flash('success', 'Form has been rejected.');
|
session()->flash('success', 'Form has been rejected.');
|
||||||
|
|||||||
@@ -401,7 +401,8 @@ class FormUpCountryController extends Controller
|
|||||||
// ));
|
// ));
|
||||||
|
|
||||||
// send whatsapp message
|
// send whatsapp message
|
||||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number);
|
$url = route('forms.up-country.view', $form->id);
|
||||||
|
WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url);
|
||||||
|
|
||||||
AuditTrailHelper::AddAuditTrail('Approve', 'Approve Expense at Form Entertainment Presentation (' . $form->expense_number . ')');
|
AuditTrailHelper::AddAuditTrail('Approve', 'Approve Expense at Form Entertainment Presentation (' . $form->expense_number . ')');
|
||||||
session()->flash('success', 'Form has been approved.');
|
session()->flash('success', 'Form has been approved.');
|
||||||
@@ -450,7 +451,8 @@ class FormUpCountryController extends Controller
|
|||||||
// ));
|
// ));
|
||||||
|
|
||||||
// send whatsapp message
|
// send whatsapp message
|
||||||
WhatsappHelper::rejectExpense($phoneNumbers, $expense_number);
|
$url = route('forms.up-country.view', $form->id);
|
||||||
|
WhatsappHelper::rejectExpense($phoneNumbers, $expense_number, $url);
|
||||||
|
|
||||||
AuditTrailHelper::AddAuditTrail('Reject', 'Reject Expense at Form Entertainment Presentation (' . $form->expense_number . ')');
|
AuditTrailHelper::AddAuditTrail('Reject', 'Reject Expense at Form Entertainment Presentation (' . $form->expense_number . ')');
|
||||||
session()->flash('success', 'Form has been rejected.');
|
session()->flash('success', 'Form has been rejected.');
|
||||||
@@ -506,7 +508,8 @@ class FormUpCountryController extends Controller
|
|||||||
// ));
|
// ));
|
||||||
|
|
||||||
// send whatsapp message
|
// send whatsapp message
|
||||||
WhatsappHelper::finalApprove($phoneNumbers, $expense_number);
|
$url = route('forms.up-country.view', $form->id);
|
||||||
|
WhatsappHelper::finalApprove($phoneNumbers, $expense_number, $url);
|
||||||
|
|
||||||
AuditTrailHelper::AddAuditTrail('Final Approve', 'Final Approve Expense at Form Entertainment Presentation (' . $form->expense_number . ')');
|
AuditTrailHelper::AddAuditTrail('Final Approve', 'Final Approve Expense at Form Entertainment Presentation (' . $form->expense_number . ')');
|
||||||
session()->flash('success', 'Form has been final approved.');
|
session()->flash('success', 'Form has been final approved.');
|
||||||
|
|||||||
Reference in New Issue
Block a user