fix some revisi

This commit is contained in:
Jagad R R
2025-01-19 14:57:01 +07:00
parent 430700bc59
commit 1610d83bc6
17 changed files with 562 additions and 477 deletions
+76
View File
@@ -181,6 +181,82 @@ class FormHelper
}); });
} }
public static function getAllForms2() {
// Get all users with eager loading for 'region' and 'cabang'
$users = Admin::with(['region', 'cabang'])
->get();
$formUpCountryQuery = FormUpCountry::select(
'expense_number',
'user_id',
'total',
'approved_total',
'status',
'account_number',
'created_at',
DB::raw("'Up Country' as type")
);
$formVehicleRunningCostQuery = FormVehicleRunningCost::select(
'expense_number',
'user_id',
'total',
'approved_total',
'status',
'account_number',
'created_at',
DB::raw("'Vehicle Running Cost' as type")
);
$formEntertaimentPresentationQuery = FormEntertaimentPresentation::select(
'expense_number',
'user_id',
'total',
'approved_total',
'status',
'account_number',
'created_at',
DB::raw("'Entertainment Presentation' as type")
);
$formMeetingSeminarQuery = FormMeetingSeminar::select(
'expense_number',
'user_id',
'total',
'approved_total',
'status',
'account_number',
'created_at',
DB::raw("'Meeting Seminar' as type")
);
$formOthersQuery = FormOthers::select(
'expense_number',
'user_id',
'total',
'approved_total',
'status',
'account_number',
'created_at',
DB::raw("'Others' as type")
);
// Combine queries using union
$forms = $formUpCountryQuery
->union($formVehicleRunningCostQuery)
->union($formEntertaimentPresentationQuery)
->union($formMeetingSeminarQuery)
->union($formOthersQuery)
->get();
// Map users to the forms with eager loaded data
return $forms->map(function ($form) use ($users) {
$user = $users->firstWhere('id', $form->user_id);
$form->user = $user;
return $form;
});
}
public static function getNominalByFormType($cabang_id, $type, $type_id, $month, $year) { public static function getNominalByFormType($cabang_id, $type, $type_id, $month, $year) {
$users = UserHasCabang::where('cabang_id', $cabang_id)->get(); $users = UserHasCabang::where('cabang_id', $cabang_id)->get();
$userIds = $users->pluck('user_id')->toArray(); $userIds = $users->pluck('user_id')->toArray();
@@ -104,27 +104,12 @@ class DashboardController extends Controller
public function notifications() public function notifications()
{ {
$this->checkAuthorization(auth()->user(), ['notification.view']); $this->checkAuthorization(auth()->user(), ['notification.view']);
$role = auth()->user()->getRoleNames()[0];
// Mulai dengan query dasar // Mulai dengan query dasar
$notifications = Notifications::orderBy('created_at', 'desc') $notifications = Notifications::orderBy('created_at', 'desc')
->where('receiver_id', auth()->user()->id) ->where('receiver_id', auth()->user()->id)
->where('is_read', 0); ->where('is_read', 0);
// Tambahkan filter berdasarkan role
if ($role == 'Admin Region') {
$notifications->where('type', 'new_expense');
} elseif ($role == 'Marketing Operational Manager Region') {
$notifications->where('type', 'approve2_expense');
} elseif ($role == 'Area Manager Cabang' || $role == 'Marketing Information System') {
$notifications->where('type', 'approve_expense');
} elseif ($role == 'Head of Sales Marketing') {
$notifications->where('type', 'approve2_expense');
} else {
// Jika tidak ada role yang sesuai, kembalikan koleksi kosong
return response()->json([]);
}
// Ambil data dan kembalikan sebagai JSON // Ambil data dan kembalikan sebagai JSON
return response()->json($notifications->limit(6)->get()); return response()->json($notifications->limit(6)->get());
} }
@@ -498,7 +498,7 @@ class ReportController extends Controller
} else { } else {
$cabangs = Cabang::all(); $cabangs = Cabang::all();
$regions = Region::all(); $regions = Region::all();
$forms = FormHelper::getAllForms($month, $year)->sortByDesc('created_at'); $forms = FormHelper::getAllForms2()->sortByDesc('created_at');
} }
// get all params in url // get all params in url
@@ -114,30 +114,32 @@ class FormEntertainmentPresentationController extends Controller
public function store(Request $request) public function store(Request $request)
{ {
$this->checkAuthorization(auth()->user(), ['forms.entertainment.create']); $this->checkAuthorization(auth()->user(), ['forms.entertainment.create']);
$cabang_id = UserHasCabang::where('user_id', auth()->user()->id)->first()->cabang_id;
$request->validate([ $request->validate([
'tanggal' => 'required', 'tanggal' => 'required',
'jenis' => 'required|in:entertainment,presentation,sponsorship', 'jenis' => 'required|in:entertainment,presentation,sponsorship',
'keterangan' => 'required', 'keterangan' => 'required',
'total' => 'required|numeric|min:1|max:' . BudgetHelper::getAvailableBudget($cabang_id), 'total' => 'required|numeric|min:1',
'name' => 'required', 'name' => 'required',
'alamat' => 'required', 'alamat' => 'required',
'nik_or_npwp' => 'required', 'nik_or_npwp' => 'required',
'bukti_total' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], 'bukti_total' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
]); ]);
$currentDate = date('Y-m-d');
$startDate = date('Y-m-' . env('STARTING_DATE')); $startDate = date('Y-m-' . env('STARTING_DATE'));
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE'); $closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE');
if ($currentDate < $startDate || $currentDate > $closingDateNextMonth) { if ($request->tanggal < $startDate || $request->tanggal > $closingDateNextMonth) {
return response()->json([ session()->flash('error', 'Gagal, Input expense sudah melewati periode input 12-10');
'error' => 'Current date is not within the valid range.' return redirect()->back();
], 400);
} }
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang; $cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
if($request->total > BudgetHelper::getAvailableBudget($cabang->id)) {
session()->flash('error', 'Alokasi budget bulanan cabang tidak mencukupi,silahkan ajukan pada periode expense berikutnya');
return redirect()->back();
}
$region = Region::where('id', $cabang->region_id)->first(); $region = Region::where('id', $cabang->region_id)->first();
$kategori = Kategori::where('name', 'Entertainment')->first(); $kategori = Kategori::where('name', 'Entertainment')->first();
@@ -133,9 +133,8 @@ class FormMeetingSeminarController extends Controller
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE'); $closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE');
if ($currentDate < $startDate || $currentDate > $closingDateNextMonth) { if ($currentDate < $startDate || $currentDate > $closingDateNextMonth) {
return response()->json([ session()->flash('error', 'Gagal, Input expense sudah melewati periode input 12-10');
'error' => 'Current date is not within the valid range.' return redirect()->back();
], 400);
} }
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang; $cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
@@ -195,9 +194,8 @@ class FormMeetingSeminarController extends Controller
]; ];
// Check if the total nominal exceeds the available budget // Check if the total nominal exceeds the available budget
$cabang_id = UserHasCabang::where('user_id', auth()->user()->id)->first()->cabang_id; if(array_sum($data_nominal) > BudgetHelper::getAvailableBudget($cabang->id)) {
if(array_sum($data_nominal) > BudgetHelper::getAvailableBudget($cabang_id)) { session()->flash('error', 'Alokasi budget bulanan cabang tidak mencukupi,silahkan ajukan pada periode expense berikutnya');
session()->flash('error', 'The total nominal exceeds the available budget.');
return redirect()->back(); return redirect()->back();
} }
@@ -114,27 +114,29 @@ class FormOtherController extends Controller
public function store(Request $request) public function store(Request $request)
{ {
$this->checkAuthorization(auth()->user(), ['forms.other.create']); $this->checkAuthorization(auth()->user(), ['forms.other.create']);
$cabang_id = UserHasCabang::where('user_id', auth()->user()->id)->first()->cabang_id;
$request->validate([ $request->validate([
'kategori_id' => 'required', 'kategori_id' => 'required',
'tanggal' => 'required|date', 'tanggal' => 'required|date',
'keterangan' => 'required', 'keterangan' => 'required',
'total' => 'required|numeric|min:1|max:' . BudgetHelper::getAvailableBudget($cabang_id), 'total' => 'required|numeric|min:1',
'bukti_total' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], 'bukti_total' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
]); ]);
$currentDate = date('Y-m-d');
$startDate = date('Y-m-' . env('STARTING_DATE')); $startDate = date('Y-m-' . env('STARTING_DATE'));
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE'); $closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE');
if ($currentDate < $startDate || $currentDate > $closingDateNextMonth) { if ($request->tanggal < $startDate || $request->tanggal > $closingDateNextMonth) {
return response()->json([ session()->flash('error', 'Gagal, Input expense sudah melewati periode input 12-10');
'error' => 'Current date is not within the valid range.' return redirect()->back();
], 400);
} }
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang; $cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
if($request->total > BudgetHelper::getAvailableBudget($cabang->id)) {
session()->flash('error', 'Alokasi budget bulanan cabang tidak mencukupi,silahkan ajukan pada periode expense berikutnya');
return redirect()->back();
}
$region = Region::where('id', $cabang->region_id)->first(); $region = Region::where('id', $cabang->region_id)->first();
$kategori = Kategori::where('id', $request->kategori_id)->first(); $kategori = Kategori::where('id', $request->kategori_id)->first();
@@ -115,9 +115,10 @@ class FormUpCountryController extends Controller
public function create() public function create()
{ {
$this->checkAuthorization(auth()->user(), ['forms.country.create']); $this->checkAuthorization(auth()->user(), ['forms.country.create']);
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
return view('backend.pages.forms.upcountry.create', [ return view('backend.pages.forms.upcountry.create', [
'rayons' => Rayon::all() 'rayons' => Rayon::where('cabang_id', $cabang->id)->get()
]); ]);
} }
@@ -140,14 +141,12 @@ class FormUpCountryController extends Controller
'bukti_hotel' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], 'bukti_hotel' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
]); ]);
$currentDate = date('Y-m-d');
$startDate = date('Y-m-' . env('STARTING_DATE')); $startDate = date('Y-m-' . env('STARTING_DATE'));
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE'); $closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE');
if ($currentDate < $startDate || $currentDate > $closingDateNextMonth) { if ($request->tanggal < $startDate || $request->tanggal > $closingDateNextMonth) {
return response()->json([ session()->flash('error', 'Gagal, Input expense sudah melewati periode input 12-10');
'error' => 'Current date is not within the valid range.' return redirect()->back();
], 400);
} }
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang; $cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
@@ -220,9 +219,8 @@ class FormUpCountryController extends Controller
]; ];
// Check if the total nominal exceeds the available budget // Check if the total nominal exceeds the available budget
$cabang_id = UserHasCabang::where('user_id', auth()->user()->id)->first()->cabang_id; if(array_sum($data_nominal) > BudgetHelper::getAvailableBudget($cabang->id)) {
if(array_sum($data_nominal) > BudgetHelper::getAvailableBudget($cabang_id)) { session()->flash('error', 'Alokasi budget bulanan cabang tidak mencukupi,silahkan ajukan pada periode expense berikutnya');
session()->flash('error', 'The total nominal exceeds the available budget.');
return redirect()->back(); return redirect()->back();
} }
@@ -307,6 +305,8 @@ class FormUpCountryController extends Controller
$this->checkAuthorization(auth()->user(), ['forms.country.edit']); $this->checkAuthorization(auth()->user(), ['forms.country.edit']);
$role = auth()->user()->getRoleNames()[0]; $role = auth()->user()->getRoleNames()[0];
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
$form = FormUpCountry::with('rayon')->findOrfail($id); $form = FormUpCountry::with('rayon')->findOrfail($id);
if (($form->status != 'On Progress' && $form->status != 'Rejected') && $role == 'Medical Representatif') { if (($form->status != 'On Progress' && $form->status != 'Rejected') && $role == 'Medical Representatif') {
session()->flash('error', 'You cannot edit this form because it has been approved or closed.'); session()->flash('error', 'You cannot edit this form because it has been approved or closed.');
@@ -314,7 +314,7 @@ class FormUpCountryController extends Controller
} }
return view('backend.pages.forms.upcountry.edit', [ return view('backend.pages.forms.upcountry.edit', [
'rayons' => Rayon::all(), 'rayons' => Rayon::where('cabang_id', $cabang->id)->get(),
'form' => $form 'form' => $form
]); ]);
} }
@@ -115,12 +115,11 @@ class FormVehicleController extends Controller
public function store(Request $request) public function store(Request $request)
{ {
$this->checkAuthorization(auth()->user(), ['forms.vehicle.create']); $this->checkAuthorization(auth()->user(), ['forms.vehicle.create']);
$cabang_id = UserHasCabang::where('user_id', auth()->user()->id)->first()->cabang_id;
$request->validate([ $request->validate([
'tanggal' => 'required', 'tanggal' => 'required',
'liter' => 'required', 'liter' => 'required',
'total' => 'required|numeric|min:1|max:' . BudgetHelper::getAvailableBudget($cabang_id), 'total' => 'required|numeric|min:1',
'jarak' => 'required', 'jarak' => 'required',
'tipe_bensin' => 'required|in:pertalite,pertamax', 'tipe_bensin' => 'required|in:pertalite,pertamax',
'nopol' => 'required', 'nopol' => 'required',
@@ -128,17 +127,20 @@ class FormVehicleController extends Controller
'bukti_total' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], 'bukti_total' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
]); ]);
$currentDate = date('Y-m-d');
$startDate = date('Y-m-' . env('STARTING_DATE')); $startDate = date('Y-m-' . env('STARTING_DATE'));
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE'); $closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE');
if ($currentDate < $startDate || $currentDate > $closingDateNextMonth) { if ($request->tanggal < $startDate || $request->tanggal > $closingDateNextMonth) {
return response()->json([ session()->flash('error', 'Gagal, Input expense sudah melewati periode input 12-10');
'error' => 'Current date is not within the valid range.' return redirect()->back();
], 400);
} }
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang; $cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
if($request->total > BudgetHelper::getAvailableBudget($cabang->id)) {
session()->flash('error', 'Alokasi budget bulanan cabang tidak mencukupi,silahkan ajukan pada periode expense berikutnya');
return redirect()->back();
}
$region = Region::where('id', $cabang->region_id)->first(); $region = Region::where('id', $cabang->region_id)->first();
$kategori = Kategori::where('name', 'Vehicle Running Cost')->first(); $kategori = Kategori::where('name', 'Vehicle Running Cost')->first();
+1 -1
View File
@@ -10,5 +10,5 @@ class Rayon extends Model
use SoftDeletes; use SoftDeletes;
protected $table = 'rayon'; protected $table = 'rayon';
protected $fillable = ['code', 'name']; protected $fillable = ['code', 'name', 'cabang_id'];
} }
@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('rayon', function (Blueprint $table) {
$table->foreignId('cabang_id')->nullable()->constrained('cabang')->cascadeOnDelete()->after('id')->default(1);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('rayon', function (Blueprint $table) {
$table->dropForeign(['cabang_id']);
$table->dropColumn('cabang_id');
});
}
};
@@ -109,13 +109,13 @@
<th>Bukti</th> <th>Bukti</th>
<th>Account Number</th> <th>Account Number</th>
<th>Status</th> <th>Status</th>
@if (auth()->user()->can('approval.approve')) @if (auth()->user()->can('approval.view'))
<th>Approval 1</th> <th>Approval 1</th>
@endif @endif
@if (auth()->user()->can('approval2.approve')) @if (auth()->user()->can('approval2.view'))
<th>Approval 2</th> <th>Approval 2</th>
@endif @endif
@if (auth()->user()->can('final_approval.approve')) @if (auth()->user()->can('final_approval.view'))
<th>Final Approval</th> <th>Final Approval</th>
@endif @endif
<th>Aksi</th> <th>Aksi</th>
@@ -157,10 +157,11 @@
<span class="badge badge-danger text-white">{{ $item->status }}</span> <span class="badge badge-danger text-white">{{ $item->status }}</span>
@endif @endif
</td> </td>
@if (auth()->user()->can('approval.approve')) @if (auth()->user()->can('approval.view'))
<td> <td>
{{-- approve / reject button --}} {{-- approve / reject button --}}
@if ($item->status == 'On Progress' || $item->status == 'Rejected') @if (auth()->user()->can('approval.approve'))
@if ($item->status == 'On Progress')
<form action="javascript:void(0);" class="d-inline"> <form action="javascript:void(0);" class="d-inline">
<button type="button" <button type="button"
class="btn btn-success btn-sm open-approve-modal" class="btn btn-success btn-sm open-approve-modal"
@@ -176,20 +177,17 @@
Reject Reject
</button> </button>
</form> </form>
@else @endif
@endif
@if ($item->approved_at) @if ($item->approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }} {{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@elseif($item->rejected_at)
{{ \Carbon\Carbon::parse($item->rejected_at)->locale('id')->isoFormat('D MMMM Y') }}
@else
-
@endif
@endif @endif
</td> </td>
@endif @endif
@if (auth()->user()->can('approval2.approve')) @if (auth()->user()->can('approval2.view'))
<td> <td>
{{-- approve / reject button --}} {{-- approve / reject button --}}
@if (auth()->user()->can('approval2.approve'))
@if ($item->status == 'Approved 1' && $item->approved_at) @if ($item->status == 'Approved 1' && $item->approved_at)
<form action="javascript:void(0);" class="d-inline"> <form action="javascript:void(0);" class="d-inline">
<button type="button" <button type="button"
@@ -206,20 +204,17 @@
Reject Reject
</button> </button>
</form> </form>
@else @endif
@endif
@if ($item->approved2_at) @if ($item->approved2_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }} {{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@elseif($item->rejected_at)
{{ \Carbon\Carbon::parse($item->rejected_at)->locale('id')->isoFormat('D MMMM Y') }}
@else
-
@endif
@endif @endif
</td> </td>
@endif @endif
@if(auth()->user()->can('final_approval.approve')) @if(auth()->user()->can('final_approval.view'))
<td> <td>
{{-- approve / reject button --}} {{-- approve / reject button --}}
@if(auth()->user()->can('final_approval.approve'))
@if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at) @if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at)
<form action="javascript:void(0);" class="d-inline"> <form action="javascript:void(0);" class="d-inline">
<button type="button" <button type="button"
@@ -237,12 +232,12 @@
Open Open
</button> </button>
</form> </form>
@elseif ($item->final_approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@else
-
@endif @endif
@endif @endif
@endif
@if ($item->final_approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@endif
</td> </td>
@endif @endif
<td> <td>
@@ -108,13 +108,13 @@
<th>Total Approved</th> <th>Total Approved</th>
<th>Account Number</th> <th>Account Number</th>
<th>Status</th> <th>Status</th>
@if (auth()->user()->can('approval.approve')) @if (auth()->user()->can('approval.view'))
<th>Approval 1</th> <th>Approval 1</th>
@endif @endif
@if (auth()->user()->can('approval2.approve')) @if (auth()->user()->can('approval2.view'))
<th>Approval 2</th> <th>Approval 2</th>
@endif @endif
@if (auth()->user()->can('final_approval.approve')) @if (auth()->user()->can('final_approval.view'))
<th>Final Approval</th> <th>Final Approval</th>
@endif @endif
<th>Aksi</th> <th>Aksi</th>
@@ -147,10 +147,11 @@
<span class="badge badge-danger text-white">{{ $item->status }}</span> <span class="badge badge-danger text-white">{{ $item->status }}</span>
@endif @endif
</td> </td>
@if (auth()->user()->can('approval.approve')) @if (auth()->user()->can('approval.view'))
<td> <td>
{{-- approve / reject button --}} {{-- approve / reject button --}}
@if ($item->status == 'On Progress' || $item->status == 'Rejected') @if (auth()->user()->can('approval.approve'))
@if ($item->status == 'On Progress')
<form action="javascript:void(0);" class="d-inline"> <form action="javascript:void(0);" class="d-inline">
<button type="button" <button type="button"
class="btn btn-success btn-sm open-approve-modal" class="btn btn-success btn-sm open-approve-modal"
@@ -166,20 +167,17 @@
Reject Reject
</button> </button>
</form> </form>
@else @endif
@endif
@if ($item->approved_at) @if ($item->approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }} {{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@elseif($item->rejected_at)
{{ \Carbon\Carbon::parse($item->rejected_at)->locale('id')->isoFormat('D MMMM Y') }}
@else
-
@endif
@endif @endif
</td> </td>
@endif @endif
@if (auth()->user()->can('approval2.approve')) @if (auth()->user()->can('approval2.view'))
<td> <td>
{{-- approve / reject button --}} {{-- approve / reject button --}}
@if (auth()->user()->can('approval2.approve'))
@if ($item->status == 'Approved 1' && $item->approved_at) @if ($item->status == 'Approved 1' && $item->approved_at)
<form action="javascript:void(0);" class="d-inline"> <form action="javascript:void(0);" class="d-inline">
<button type="button" <button type="button"
@@ -196,20 +194,17 @@
Reject Reject
</button> </button>
</form> </form>
@else @endif
@endif
@if ($item->approved2_at) @if ($item->approved2_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }} {{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@elseif($item->rejected_at)
{{ \Carbon\Carbon::parse($item->rejected_at)->locale('id')->isoFormat('D MMMM Y') }}
@else
-
@endif
@endif @endif
</td> </td>
@endif @endif
@if(auth()->user()->can('final_approval.approve')) @if(auth()->user()->can('final_approval.view'))
<td> <td>
{{-- approve / reject button --}} {{-- approve / reject button --}}
@if(auth()->user()->can('final_approval.approve'))
@if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at) @if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at)
<form action="javascript:void(0);" class="d-inline"> <form action="javascript:void(0);" class="d-inline">
<button type="button" <button type="button"
@@ -227,12 +222,12 @@
Open Open
</button> </button>
</form> </form>
@elseif ($item->final_approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@else
-
@endif @endif
@endif @endif
@endif
@if ($item->final_approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@endif
</td> </td>
@endif @endif
<td> <td>
@@ -108,13 +108,13 @@
<th>Bukti Total</th> <th>Bukti Total</th>
<th>Account Number</th> <th>Account Number</th>
<th>Status</th> <th>Status</th>
@if (auth()->user()->can('approval.approve')) @if (auth()->user()->can('approval.view'))
<th>Approval 1</th> <th>Approval 1</th>
@endif @endif
@if (auth()->user()->can('approval2.approve')) @if (auth()->user()->can('approval2.view'))
<th>Approval 2</th> <th>Approval 2</th>
@endif @endif
@if (auth()->user()->can('final_approval.approve')) @if (auth()->user()->can('final_approval.view'))
<th>Final Approval</th> <th>Final Approval</th>
@endif @endif
<th>Aksi</th> <th>Aksi</th>
@@ -155,10 +155,11 @@
<span class="badge badge-danger text-white">{{ $item->status }}</span> <span class="badge badge-danger text-white">{{ $item->status }}</span>
@endif @endif
</td> </td>
@if (auth()->user()->can('approval.approve')) @if (auth()->user()->can('approval.view'))
<td> <td>
{{-- approve / reject button --}} {{-- approve / reject button --}}
@if ($item->status == 'On Progress' || $item->status == 'Rejected') @if (auth()->user()->can('approval.approve'))
@if ($item->status == 'On Progress')
<form action="javascript:void(0);" class="d-inline"> <form action="javascript:void(0);" class="d-inline">
<button type="button" <button type="button"
class="btn btn-success btn-sm open-approve-modal" class="btn btn-success btn-sm open-approve-modal"
@@ -174,20 +175,17 @@
Reject Reject
</button> </button>
</form> </form>
@else @endif
@endif
@if ($item->approved_at) @if ($item->approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }} {{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@elseif($item->rejected_at)
{{ \Carbon\Carbon::parse($item->rejected_at)->locale('id')->isoFormat('D MMMM Y') }}
@else
-
@endif
@endif @endif
</td> </td>
@endif @endif
@if (auth()->user()->can('approval2.approve')) @if (auth()->user()->can('approval2.view'))
<td> <td>
{{-- approve / reject button --}} {{-- approve / reject button --}}
@if (auth()->user()->can('approval2.approve'))
@if ($item->status == 'Approved 1' && $item->approved_at) @if ($item->status == 'Approved 1' && $item->approved_at)
<form action="javascript:void(0);" class="d-inline"> <form action="javascript:void(0);" class="d-inline">
<button type="button" <button type="button"
@@ -204,20 +202,17 @@
Reject Reject
</button> </button>
</form> </form>
@else @endif
@endif
@if ($item->approved2_at) @if ($item->approved2_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }} {{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@elseif($item->rejected_at)
{{ \Carbon\Carbon::parse($item->rejected_at)->locale('id')->isoFormat('D MMMM Y') }}
@else
-
@endif
@endif @endif
</td> </td>
@endif @endif
@if(auth()->user()->can('final_approval.approve')) @if(auth()->user()->can('final_approval.view'))
<td> <td>
{{-- approve / reject button --}} {{-- approve / reject button --}}
@if(auth()->user()->can('final_approval.approve'))
@if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at) @if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at)
<form action="javascript:void(0);" class="d-inline"> <form action="javascript:void(0);" class="d-inline">
<button type="button" <button type="button"
@@ -235,12 +230,12 @@
Open Open
</button> </button>
</form> </form>
@elseif ($item->final_approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@else
-
@endif @endif
@endif @endif
@endif
@if ($item->final_approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@endif
</td> </td>
@endif @endif
<td> <td>
@@ -108,13 +108,13 @@
<th>Total Approved</th> <th>Total Approved</th>
<th>Account Number</th> <th>Account Number</th>
<th>Status</th> <th>Status</th>
@if (auth()->user()->can('approval.approve')) @if (auth()->user()->can('approval.view'))
<th>Approval 1</th> <th>Approval 1</th>
@endif @endif
@if (auth()->user()->can('approval2.approve')) @if (auth()->user()->can('approval2.view'))
<th>Approval 2</th> <th>Approval 2</th>
@endif @endif
@if (auth()->user()->can('final_approval.approve')) @if (auth()->user()->can('final_approval.view'))
<th>Final Approval</th> <th>Final Approval</th>
@endif @endif
<th>Aksi</th> <th>Aksi</th>
@@ -153,10 +153,11 @@
<span class="badge badge-danger text-white">{{ $item->status }}</span> <span class="badge badge-danger text-white">{{ $item->status }}</span>
@endif @endif
</td> </td>
@if (auth()->user()->can('approval.approve')) @if (auth()->user()->can('approval.view'))
<td> <td>
{{-- approve / reject button --}} {{-- approve / reject button --}}
@if ($item->status == 'On Progress' || $item->status == 'Rejected') @if (auth()->user()->can('approval.approve'))
@if ($item->status == 'On Progress')
<form action="javascript:void(0);" class="d-inline"> <form action="javascript:void(0);" class="d-inline">
<button type="button" <button type="button"
class="btn btn-success btn-sm open-approve-modal" class="btn btn-success btn-sm open-approve-modal"
@@ -172,20 +173,17 @@
Reject Reject
</button> </button>
</form> </form>
@else @endif
@endif
@if ($item->approved_at) @if ($item->approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }} {{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@elseif($item->rejected_at)
{{ \Carbon\Carbon::parse($item->rejected_at)->locale('id')->isoFormat('D MMMM Y') }}
@else
-
@endif
@endif @endif
</td> </td>
@endif @endif
@if (auth()->user()->can('approval2.approve')) @if (auth()->user()->can('approval2.view'))
<td> <td>
{{-- approve / reject button --}} {{-- approve / reject button --}}
@if (auth()->user()->can('approval2.approve'))
@if ($item->status == 'Approved 1' && $item->approved_at) @if ($item->status == 'Approved 1' && $item->approved_at)
<form action="javascript:void(0);" class="d-inline"> <form action="javascript:void(0);" class="d-inline">
<button type="button" <button type="button"
@@ -202,20 +200,17 @@
Reject Reject
</button> </button>
</form> </form>
@else @endif
@endif
@if ($item->approved2_at) @if ($item->approved2_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }} {{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@elseif($item->rejected_at)
{{ \Carbon\Carbon::parse($item->rejected_at)->locale('id')->isoFormat('D MMMM Y') }}
@else
-
@endif
@endif @endif
</td> </td>
@endif @endif
@if(auth()->user()->can('final_approval.approve')) @if(auth()->user()->can('final_approval.view'))
<td> <td>
{{-- approve / reject button --}} {{-- approve / reject button --}}
@if(auth()->user()->can('final_approval.approve'))
@if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at) @if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at)
<form action="javascript:void(0);" class="d-inline"> <form action="javascript:void(0);" class="d-inline">
<button type="button" <button type="button"
@@ -233,12 +228,12 @@
Open Open
</button> </button>
</form> </form>
@elseif ($item->final_approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@else
-
@endif @endif
@endif @endif
@endif
@if ($item->final_approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@endif
</td> </td>
@endif @endif
<td> <td>
@@ -110,13 +110,13 @@
<th>Bukti</th> <th>Bukti</th>
<th>Account Number</th> <th>Account Number</th>
<th>Status</th> <th>Status</th>
@if (auth()->user()->can('approval.approve')) @if (auth()->user()->can('approval.view'))
<th>Approval 1</th> <th>Approval 1</th>
@endif @endif
@if (auth()->user()->can('approval2.approve')) @if (auth()->user()->can('approval2.view'))
<th>Approval 2</th> <th>Approval 2</th>
@endif @endif
@if (auth()->user()->can('final_approval.approve')) @if (auth()->user()->can('final_approval.view'))
<th>Final Approval</th> <th>Final Approval</th>
@endif @endif
<th>Aksi</th> <th>Aksi</th>
@@ -159,10 +159,11 @@
<span class="badge badge-danger text-white">{{ $item->status }}</span> <span class="badge badge-danger text-white">{{ $item->status }}</span>
@endif @endif
</td> </td>
@if (auth()->user()->can('approval.approve')) @if (auth()->user()->can('approval.view'))
<td> <td>
{{-- approve / reject button --}} {{-- approve / reject button --}}
@if ($item->status == 'On Progress' || $item->status == 'Rejected') @if (auth()->user()->can('approval.approve'))
@if ($item->status == 'On Progress')
<form action="javascript:void(0);" class="d-inline"> <form action="javascript:void(0);" class="d-inline">
<button type="button" <button type="button"
class="btn btn-success btn-sm open-approve-modal" class="btn btn-success btn-sm open-approve-modal"
@@ -178,20 +179,17 @@
Reject Reject
</button> </button>
</form> </form>
@else @endif
@endif
@if ($item->approved_at) @if ($item->approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }} {{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@elseif($item->rejected_at)
{{ \Carbon\Carbon::parse($item->rejected_at)->locale('id')->isoFormat('D MMMM Y') }}
@else
-
@endif
@endif @endif
</td> </td>
@endif @endif
@if (auth()->user()->can('approval2.approve')) @if (auth()->user()->can('approval2.view'))
<td> <td>
{{-- approve / reject button --}} {{-- approve / reject button --}}
@if (auth()->user()->can('approval2.approve'))
@if ($item->status == 'Approved 1' && $item->approved_at) @if ($item->status == 'Approved 1' && $item->approved_at)
<form action="javascript:void(0);" class="d-inline"> <form action="javascript:void(0);" class="d-inline">
<button type="button" <button type="button"
@@ -208,20 +206,17 @@
Reject Reject
</button> </button>
</form> </form>
@else @endif
@endif
@if ($item->approved2_at) @if ($item->approved2_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }} {{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@elseif($item->rejected_at)
{{ \Carbon\Carbon::parse($item->rejected_at)->locale('id')->isoFormat('D MMMM Y') }}
@else
-
@endif
@endif @endif
</td> </td>
@endif @endif
@if(auth()->user()->can('final_approval.approve')) @if(auth()->user()->can('final_approval.view'))
<td> <td>
{{-- approve / reject button --}} {{-- approve / reject button --}}
@if(auth()->user()->can('final_approval.approve'))
@if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at) @if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at)
<form action="javascript:void(0);" class="d-inline"> <form action="javascript:void(0);" class="d-inline">
<button type="button" <button type="button"
@@ -239,12 +234,12 @@
Open Open
</button> </button>
</form> </form>
@elseif ($item->final_approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@else
-
@endif @endif
@endif @endif
@endif
@if ($item->final_approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@endif
</td> </td>
@endif @endif
<td> <td>
@@ -149,7 +149,21 @@
{ {
extend: 'excel', extend: 'excel',
text: 'Export Excel', text: 'Export Excel',
buttons: ['excel', 'csv', 'pdf', 'print', 'colvis'], customize: function (xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
// Add additional information to the Excel sheet
var additionalInfo = `
Cabang: {{ $cabang->name }}
Periode: {{ ucfirst($month) }} {{ $year }}
Cost Centre: {{ $cabang->cost->code }}
`;
var rows = additionalInfo.split('\n').map(function (text) {
return `<row><c t="inlineStr"><is><t>${text.trim()}</t></is></c></row>`;
}).join('');
// Inject the additional information at the top of the sheet
var data = $(sheet).find('sheetData').prepend(rows);
}
}, },
{ {
extend: 'csv', extend: 'csv',
@@ -160,7 +174,6 @@
Cabang: {{ $cabang->name }} Cabang: {{ $cabang->name }}
Periode: {{ ucfirst($month) }} {{ $year }} Periode: {{ ucfirst($month) }} {{ $year }}
Cost Centre: {{ $cabang->cost->code }} Cost Centre: {{ $cabang->cost->code }}
`; `;
return additionalInfo + csv; return additionalInfo + csv;
} }
+4 -1
View File
@@ -101,7 +101,10 @@
<a class="d-block font-weight-bold" style="font-size: 11px;"> <a class="d-block font-weight-bold" style="font-size: 11px;">
{{ Auth::guard('admin')->user()->getRoleNames()[0] }} {{ Auth::guard('admin')->user()->getRoleNames()[0] }}
</a> </a>
@if(auth()->user()->getMyCabangAndRegion()['cabang'] != '-' && Auth::guard('admin')->user()->getRoleNames()[0] == 'Medical Representatif') @if(
auth()->user()->getMyCabangAndRegion()['cabang'] != '-' &&
in_array(Auth::guard('admin')->user()->getRoleNames()[0], ['Medical Representatif', 'Area Manager Cabang'])
)
<a class="d-block" style="font-size: 14px;"> <a class="d-block" style="font-size: 14px;">
<span class="badge badge-primary"> <span class="badge badge-primary">
{{ auth()->user()->getMyCabangAndRegion()['cabang'] }} {{ auth()->user()->getMyCabangAndRegion()['cabang'] }}