This commit is contained in:
@@ -66,7 +66,7 @@ class FormUpCountryController extends Controller
|
||||
|
||||
$role = auth()->user()->getRoleNames()[0];
|
||||
$startDay = (int) env('STARTING_DATE', 11);
|
||||
$closingDay = (int) env('CLOSING_DATE', 10);
|
||||
$closingDay = (int) env('CLOSING_DATE', 13);
|
||||
|
||||
// Current time reference
|
||||
$now = Carbon::now();
|
||||
@@ -190,20 +190,20 @@ class FormUpCountryController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
public function create()
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.country.create']);
|
||||
$rayons = $this->getAccessibleRayonsForCurrentUser();
|
||||
|
||||
return view('backend.pages.forms.upcountry.create', [
|
||||
'rayons' => $rayons,
|
||||
return view('backend.pages.forms.upcountry.create', [
|
||||
'rayons' => $rayons,
|
||||
'attachmentCategories' => array_keys($this->attachmentCategories),
|
||||
'attachmentCategoryLabels' => $this->attachmentCategories,
|
||||
]);
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.country.create']);
|
||||
$request->validate([
|
||||
'rayon_id' => 'required|exists:rayon,id',
|
||||
@@ -221,23 +221,24 @@ class FormUpCountryController extends Controller
|
||||
]);
|
||||
|
||||
$tanggal = Carbon::parse($request->tanggal);
|
||||
|
||||
// SINKRONISASI JENDELA INPUT ATURAN BISNIS: 11 s/d 10 Bulan Berikutnya
|
||||
$startDay = (int) env('STARTING_DATE', 11);
|
||||
$closingDay = (int) env('CLOSING_DATE', 10);
|
||||
$inputMaxDay = (int) env('INPUT_MAX_DATE', 10);
|
||||
$now = Carbon::now();
|
||||
|
||||
// Tentukan periode aktif saat ini
|
||||
if ($now->day >= $startDay) {
|
||||
$startDate = Carbon::create($now->year, $now->month, $startDay);
|
||||
$closingDate = Carbon::create($now->copy()->addMonth()->year, $now->copy()->addMonth()->month, $closingDay);
|
||||
$startDate = Carbon::create($now->year, $now->month, $startDay)->startOfDay();
|
||||
$maxInputDate = Carbon::create($now->copy()->addMonth()->year, $now->copy()->addMonth()->month, $inputMaxDay)->endOfDay();
|
||||
} else {
|
||||
$startDate = Carbon::create($now->copy()->subMonth()->year, $now->copy()->subMonth()->month, $startDay);
|
||||
$closingDate = Carbon::create($now->year, $now->month, $closingDay);
|
||||
$startDate = Carbon::create($now->copy()->subMonth()->year, $now->copy()->subMonth()->month, $startDay)->startOfDay();
|
||||
$maxInputDate = Carbon::create($now->year, $now->month, $inputMaxDay)->endOfDay();
|
||||
}
|
||||
|
||||
// Validasi apakah tanggal input berada di periode aktif
|
||||
if ($tanggal->lt($startDate) || $tanggal->gt($closingDate)) {
|
||||
session()->flash('error', "Gagal, tanggal tidak berada dalam periode input: {$startDate->format('d M')} - {$closingDate->format('d M')}");
|
||||
return redirect()->back();
|
||||
// Blokade Sistem: Tolak input jika berada di luar siklus pengisian aktif
|
||||
if ($now->lt($startDate) || $now->gt($maxInputDate)) {
|
||||
session()->flash('error', "Gagal, pengajuan saat ini sudah ditutup. Periode pengisian aktif hanya diizinkan dari tanggal {$startDay} sampai tanggal {$inputMaxDay} berikutnya.");
|
||||
return redirect()->back()->withInput();
|
||||
}
|
||||
|
||||
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()?->cabang;
|
||||
@@ -247,7 +248,9 @@ class FormUpCountryController extends Controller
|
||||
}
|
||||
|
||||
$region = Region::find($cabang->region_id);
|
||||
$kategori = Kategori::where('name', 'Up Country')->first();
|
||||
|
||||
// Optimasi pencarian kategori menggunakan LIKE fleksibel untuk menjamin ID ditemukan
|
||||
$kategori = Kategori::where('name', 'LIKE', '%Up Country%')->first();
|
||||
|
||||
// Hitung periode budget dari tanggal input
|
||||
if ($tanggal->day >= $startDay) {
|
||||
@@ -301,6 +304,8 @@ class FormUpCountryController extends Controller
|
||||
$form = FormUpCountry::create([
|
||||
'expense_number' => $expense_number,
|
||||
'user_id' => auth()->user()->id,
|
||||
'cabang_id' => $cabang->id, // <--- REPARASI: Memasukkan Cabang ID milik user pengaju secara instan
|
||||
'kategori_id' => $kategori->id ?? null, // SUNTIK KATEGORI_ID OTOMATIS BERHASIL
|
||||
'rayon_id' => $request->rayon_id,
|
||||
'tanggal' => $request->tanggal,
|
||||
'tujuan' => $request->tujuan,
|
||||
@@ -315,14 +320,14 @@ class FormUpCountryController extends Controller
|
||||
'bukti_transport_ankot' => null,
|
||||
'bukti_hotel' => null,
|
||||
'uc_plan' => $ucPlanPath,
|
||||
'account_number' => $kategori->account_number,
|
||||
'account_number' => $kategori->account_number ?? null,
|
||||
'status' => 'On Progress',
|
||||
]);
|
||||
|
||||
if (!empty($attachmentsPayload)) {
|
||||
$this->attachmentService->addMultipleAttachments(
|
||||
$form->id,
|
||||
AttachmentTableName::FORM_UP_COUNTRY,
|
||||
$dynamicTable = AttachmentTableName::FORM_UP_COUNTRY,
|
||||
$attachmentsPayload
|
||||
);
|
||||
}
|
||||
@@ -359,11 +364,11 @@ class FormUpCountryController extends Controller
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id, $region_id) {
|
||||
if ($role === 'Marketing Information System') {
|
||||
return true; // Tidak ada filter cabang untuk peran ini
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!$user->cabang || !$user->cabang->cabang) {
|
||||
return false; // Pastikan user memiliki cabang
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($role === 'Admin Region' || $role === 'Marketing Operational Manager Region') {
|
||||
@@ -417,10 +422,10 @@ class FormUpCountryController extends Controller
|
||||
AuditTrailHelper::AddAuditTrail('Insert', 'Insert New Expense at Form Up Country (' . $expense_number . ')');
|
||||
session()->flash('success', 'Form has been created.');
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
public function edit($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.country.edit']);
|
||||
$role = auth()->user()->getRoleNames()[0];
|
||||
|
||||
@@ -453,14 +458,14 @@ class FormUpCountryController extends Controller
|
||||
];
|
||||
})->values();
|
||||
|
||||
return view('backend.pages.forms.upcountry.edit', [
|
||||
'rayons' => $rayonData,
|
||||
return view('backend.pages.forms.upcountry.edit', [
|
||||
'rayons' => $rayonData,
|
||||
'form' => $form,
|
||||
'attachments' => $existingAttachments,
|
||||
'attachmentCategories' => array_keys($this->attachmentCategories),
|
||||
'attachmentCategoryLabels' => $this->attachmentCategories,
|
||||
]);
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getAccessibleRayonsForCurrentUser()
|
||||
{
|
||||
@@ -494,7 +499,7 @@ class FormUpCountryController extends Controller
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.country.edit']);
|
||||
$role = auth()->user()->getRoleNames()[0];
|
||||
|
||||
@@ -525,12 +530,31 @@ class FormUpCountryController extends Controller
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
// PEMBATASAN INPUT MENGGUNAKAN STARTING_DATE & INPUT_MAX_DATE
|
||||
$startDay = (int) env('STARTING_DATE', 11);
|
||||
$inputMaxDay = (int) env('INPUT_MAX_DATE', 10);
|
||||
$now = Carbon::now();
|
||||
|
||||
if ($now->day >= $startDay) {
|
||||
$startDate = Carbon::create($now->year, $now->month, $startDay)->startOfDay();
|
||||
$maxInputDate = Carbon::create($now->copy()->addMonth()->year, $now->copy()->addMonth()->month, $inputMaxDay)->endOfDay();
|
||||
} else {
|
||||
$startDate = Carbon::create($now->copy()->subMonth()->year, $now->copy()->subMonth()->month, $startDay)->startOfDay();
|
||||
$maxInputDate = Carbon::create($now->year, $now->month, $inputMaxDay)->endOfDay();
|
||||
}
|
||||
|
||||
if ($now->lt($startDate) || $now->gt($maxInputDate)) {
|
||||
session()->flash('error', "Gagal, pengajuan saat ini sudah ditutup. Periode pengisian aktif hanya diizinkan dari tanggal {$startDay} sampai tanggal {$inputMaxDay} berikutnya.");
|
||||
return redirect()->back()->withInput();
|
||||
}
|
||||
|
||||
$region = Region::find($cabang->region_id);
|
||||
$kategori = Kategori::where('name', 'Up Country')->first();
|
||||
|
||||
// Optimasi pencarian kategori menggunakan LIKE fleksibel untuk menjamin ID ditemukan
|
||||
$kategori = Kategori::where('name', 'LIKE', '%Up Country%')->first();
|
||||
|
||||
// Hitung periode dari tanggal input
|
||||
$tanggal = Carbon::parse($request->tanggal);
|
||||
$startDay = (int) env('STARTING_DATE', 11);
|
||||
if ($tanggal->day >= $startDay) {
|
||||
$periodeDate = Carbon::create($tanggal->year, $tanggal->month, $startDay);
|
||||
} else {
|
||||
@@ -564,7 +588,7 @@ class FormUpCountryController extends Controller
|
||||
|
||||
// Validasi budget dengan periode
|
||||
$availableBudget = BudgetHelper::getAvailableBudget($cabang->id, $periodeMonth, $periodeYear);
|
||||
if(array_sum($data_nominal) > $availableBudget) {
|
||||
if($totalNominal > $availableBudget) {
|
||||
session()->flash('error', 'The total nominal exceeds the available budget.');
|
||||
return redirect()->back();
|
||||
}
|
||||
@@ -574,6 +598,8 @@ class FormUpCountryController extends Controller
|
||||
try {
|
||||
$form->update([
|
||||
'rayon_id' => $request->rayon_id,
|
||||
'cabang_id' => $cabang->id, // <--- REPARASI: Memastikan Cabang ID tersimpan akurat saat update data
|
||||
'kategori_id' => $kategori->id ?? null, // RE-SUNTIK KATEGORI_ID SAAT UPDATE
|
||||
'tanggal' => $request->tanggal,
|
||||
'tujuan' => $request->tujuan,
|
||||
'jarak' => $request->jarak,
|
||||
@@ -583,7 +609,7 @@ class FormUpCountryController extends Controller
|
||||
'hotel' => $data_nominal['hotel'],
|
||||
'total' => $totalNominal,
|
||||
'uc_plan' => $ucPlanPath ?? $form->uc_plan,
|
||||
'account_number' => $kategori->account_number,
|
||||
'account_number' => $kategori->account_number ?? $form->account_number,
|
||||
]);
|
||||
|
||||
if (!empty($attachmentsPayload)) {
|
||||
@@ -609,7 +635,7 @@ class FormUpCountryController extends Controller
|
||||
AuditTrailHelper::AddAuditTrail('Update', 'Update Record at Form Up Country (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been updated.');
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteAttachment(Request $request, $formId, $attachmentId)
|
||||
{
|
||||
@@ -717,11 +743,11 @@ class FormUpCountryController extends Controller
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id, $region_id) {
|
||||
if ($role === 'Marketing Information System') {
|
||||
return true; // Tidak ada filter cabang untuk peran ini
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!$user->cabang || !$user->cabang->cabang) {
|
||||
return false; // Pastikan user memiliki cabang
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($role === 'Admin Region' || $role === 'Marketing Operational Manager Region') {
|
||||
@@ -808,11 +834,11 @@ class FormUpCountryController extends Controller
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id, $region_id) {
|
||||
if ($role === 'Marketing Information System' || $role === 'Head of Sales Marketing') {
|
||||
return true; // Tidak ada filter cabang untuk peran ini
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!$user->cabang || !$user->cabang->cabang) {
|
||||
return false; // Pastikan user memiliki cabang
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($role === 'Admin Region' || $role === 'Marketing Operational Manager Region') {
|
||||
@@ -867,7 +893,7 @@ class FormUpCountryController extends Controller
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function finalApprove($id)
|
||||
public function finalApprove(Request $request, $id) // <--- MENAMBAHKAN OBJECT REQUEST
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['final_approval.approve']);
|
||||
$form = FormUpCountry::findOrFail($id);
|
||||
@@ -877,42 +903,61 @@ class FormUpCountryController extends Controller
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
// Ambil cabang_id dari user yang mengisi form
|
||||
// ATURAN BISNIS: Batas Akhir Approval adalah tanggal CLOSING_DATE (Bulan Depan tgl 13)
|
||||
$closingDay = (int) env('CLOSING_DATE', 13);
|
||||
$startDay = (int) env('STARTING_DATE', 11);
|
||||
$now = Carbon::now();
|
||||
$tanggalForm = Carbon::parse($form->tanggal);
|
||||
|
||||
// Hitung batas maksimal closing sesuai siklus transaksi form tersebut
|
||||
if ($tanggalForm->day >= $startDay) {
|
||||
$maxClosingDate = Carbon::create($tanggalForm->year, $tanggalForm->month, $closingDay)->addMonth()->endOfDay();
|
||||
} else {
|
||||
$maxClosingDate = Carbon::create($tanggalForm->year, $tanggalForm->month, $closingDay)->endOfDay();
|
||||
}
|
||||
|
||||
if ($now->gt($maxClosingDate)) {
|
||||
session()->flash('error', "Gagal, Batas waktu maksimal approval (Closing Date) untuk pengajuan ini telah berakhir pada {$maxClosingDate->format('d M Y H:i')} WIB.");
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()?->cabang_id;
|
||||
if (!$cabang_id) {
|
||||
session()->flash('error', 'Data cabang tidak ditemukan.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
// Hitung periode berdasarkan tanggal form
|
||||
$tanggal = Carbon::parse($form->tanggal);
|
||||
$startDay = (int) env('STARTING_DATE', 11);
|
||||
if ($tanggal->day >= $startDay) {
|
||||
$periodeDate = Carbon::create($tanggal->year, $tanggal->month, $startDay);
|
||||
if ($tanggalForm->day >= $startDay) {
|
||||
$periodeDate = Carbon::create($tanggalForm->year, $tanggalForm->month, $startDay);
|
||||
} else {
|
||||
$periodeDate = Carbon::create($tanggal->copy()->subMonth()->year, $tanggal->copy()->subMonth()->month, $startDay);
|
||||
$periodeDate = Carbon::create($tanggalForm->copy()->subMonth()->year, $tanggalForm->copy()->subMonth()->month, $startDay);
|
||||
}
|
||||
|
||||
$periodeMonth = strtolower($periodeDate->format('F'));
|
||||
$periodeYear = (int) $periodeDate->format('Y');
|
||||
|
||||
// MENGAMBIL NILAI AKUMULASI CHECKLIST DARI JAVASCRIPT JS (Fallback ke total awal jika kosong)
|
||||
$approvedTotal = $request->input('approved_total', $form->total);
|
||||
|
||||
// Ambil sisa budget sesuai periode
|
||||
$availableBudget = BudgetHelper::getAvailableBudget($cabang_id, $periodeMonth, $periodeYear);
|
||||
if($form->approved_total > $availableBudget) {
|
||||
if($approvedTotal > $availableBudget) { // <--- DISINKRONKAN DENGAN NILAI BARU HASIL CHECKLIST
|
||||
session()->flash('error', 'Budget cabang untuk periode ini tidak mencukupi, silahkan ajukan pada periode expense berikutnya');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
// UPDATE DATABASE SECARA AKURAT BERDASARKAN HASIL PILIHAN CHECKLIST FINANCE
|
||||
$form->update([
|
||||
'approved_total' => $approvedTotal, // <--- SUNTIK NOMINAL BARU HASIL CHECKLIST KE DATABASE
|
||||
'final_approved_at' => now(),
|
||||
'final_approved_by' => auth()->user()->id,
|
||||
'status' => 'Closed',
|
||||
'status' => 'Closed',
|
||||
]);
|
||||
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->tanggal;
|
||||
$total = $form->approved_total;
|
||||
$total = $form->approved_total; // <--- OTOMATIS MEMAKAI DATA UPDATE TERBARU
|
||||
|
||||
$roles = ['Head of Sales Marketing', 'Marketing Operational Manager Region'];
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
@@ -927,11 +972,11 @@ class FormUpCountryController extends Controller
|
||||
foreach ($roles as $role) {
|
||||
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id, $region_id) {
|
||||
if ($role === 'Marketing Information System' || $role === 'Head of Sales Marketing') {
|
||||
return true; // Tidak ada filter cabang untuk peran ini
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!$user->cabang || !$user->cabang->cabang) {
|
||||
return false; // Pastikan user memiliki cabang
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($role === 'Admin Region' || $role === 'Marketing Operational Manager Region') {
|
||||
@@ -985,16 +1030,21 @@ class FormUpCountryController extends Controller
|
||||
|
||||
public function reject(Request $request, $id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['approval.reject']);
|
||||
if (!auth()->user()->hasAnyPermission(['approval.reject', 'approval2.reject', 'final_approval.approve'])) {
|
||||
abort(403, 'Akses Ditolak: Anda tidak memiliki izin untuk melakukan Reject.');
|
||||
}
|
||||
|
||||
$request->validate([
|
||||
'remarks' => 'required|string|max:500',
|
||||
'remarks' => 'required|string|max:500',
|
||||
]);
|
||||
|
||||
$form = FormUpCountry::findOrfail($id);
|
||||
|
||||
$form->update([
|
||||
'status' => 'Rejected',
|
||||
'remarks' => $request->remarks,
|
||||
'status' => 'Rejected',
|
||||
'remarks' => $request->remarks,
|
||||
'rejected_by' => auth()->id(), // SUNTIK DATA AUDIT TRAIL
|
||||
'rejected_at' => now(), // SUNTIK DATA AUDIT TRAIL
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
@@ -1003,53 +1053,37 @@ class FormUpCountryController extends Controller
|
||||
$tanggal = $form->tanggal;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
$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'];
|
||||
$recipients[] = $heads['cabang_head']['email'];
|
||||
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||
}
|
||||
|
||||
if ($heads['region_head']) {
|
||||
$recipients[] = $heads['region_head']['email'];
|
||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||
$recipients[] = $heads['region_head']['email'];
|
||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||
}
|
||||
|
||||
// Remove duplicate email addresses, if any
|
||||
$recipients = array_unique($recipients);
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// send whatsapp message
|
||||
$url = route('forms.up-country.view', $form->id);
|
||||
$url = route('forms.up-country.view', $form->id);
|
||||
WhatsappHelper::rejectExpense($phoneNumbers, $expense_number, $url, $tanggal, $total, $name, $request->remarks);
|
||||
|
||||
// Send bulk email
|
||||
$brevoService = app(BrevoService::class);
|
||||
foreach ($recipients as $recipient) {
|
||||
try {
|
||||
$mail = new ExpenseRejected(
|
||||
$name,
|
||||
$expense_number,
|
||||
$tanggal,
|
||||
$total,
|
||||
$url,
|
||||
$request->remarks
|
||||
);
|
||||
|
||||
$response = $brevoService->expenseRejected($recipient, $name, $mail);
|
||||
|
||||
if (isset($response['success']) && $response['success'] === false) {
|
||||
Log::warning("Email to {$recipient} failed: " . ($response['message'] ?? 'Unknown error'));
|
||||
try {
|
||||
$mail = new ExpenseRejected($name, $expense_number, $tanggal, $total, $url, $request->remarks);
|
||||
$brevoService->expenseRejected($recipient, $name, $mail);
|
||||
} catch (\Exception $e) {
|
||||
Log::error("Failed to send email to {$recipient}: " . $e->getMessage());
|
||||
continue;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error("Failed to send email to {$recipient}: " . $e->getMessage());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Reject', 'Reject Expense at Form Up Country (' . $form->expense_number . ')');
|
||||
AuditTrailHelper::AddAuditTrail('Reject', 'Reject Expense at Form Up Country (' . $form->expense_number . ') oleh ' . auth()->user()->name);
|
||||
session()->flash('success', 'Form has been rejected.');
|
||||
return redirect()->back();
|
||||
}
|
||||
@@ -1070,12 +1104,12 @@ class FormUpCountryController extends Controller
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.country.delete']);
|
||||
$role = auth()->user()->getRoleNames()[0];
|
||||
|
||||
$form = FormUpCountry::findOrfail($id);
|
||||
$form = FormUpCountry::findOrfail($id);
|
||||
if($form->status != 'On Progress' && $role == 'Medical Representatif') {
|
||||
session()->flash('error', 'You cannot edit this form because it has been approved or rejected.');
|
||||
return redirect()->back();
|
||||
@@ -1083,9 +1117,9 @@ class FormUpCountryController extends Controller
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Delete', 'Delete Record at Form Up Country (' . $form->expense_number . ')');
|
||||
|
||||
$form->delete();
|
||||
$form->delete();
|
||||
|
||||
session()->flash('success', 'Form has been deleted.');
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
session()->flash('success', 'Form has been deleted.');
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user