Merge branch 'branch-jagad' into 'main'
Branch jagad See merge request fiqhpratama1/xpendify!35
This commit is contained in:
+91
-21
@@ -14,7 +14,9 @@ use App\Models\UserHasCabang;
|
|||||||
class FormHelper
|
class FormHelper
|
||||||
{
|
{
|
||||||
public static function getFormsByUserIds($userIds, $month, $year) {
|
public static function getFormsByUserIds($userIds, $month, $year) {
|
||||||
// Eager load 'user.region' and 'user.cabang'
|
$startDate = date('Y-m-' . env('STARTING_DATE'));
|
||||||
|
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE');
|
||||||
|
|
||||||
$users = Admin::with(['region', 'cabang'])
|
$users = Admin::with(['region', 'cabang'])
|
||||||
->whereIn('id', $userIds)
|
->whereIn('id', $userIds)
|
||||||
->get();
|
->get();
|
||||||
@@ -29,8 +31,7 @@ class FormHelper
|
|||||||
'created_at',
|
'created_at',
|
||||||
DB::raw("'Up Country' as type")
|
DB::raw("'Up Country' as type")
|
||||||
)->whereIn('user_id', $userIds)
|
)->whereIn('user_id', $userIds)
|
||||||
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
|
||||||
->whereYear('tanggal', '=', $year);
|
|
||||||
|
|
||||||
$formVehicleRunningCostQuery = FormVehicleRunningCost::select(
|
$formVehicleRunningCostQuery = FormVehicleRunningCost::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
@@ -42,8 +43,7 @@ class FormHelper
|
|||||||
'created_at',
|
'created_at',
|
||||||
DB::raw("'Vehicle Running Cost' as type")
|
DB::raw("'Vehicle Running Cost' as type")
|
||||||
)->whereIn('user_id', $userIds)
|
)->whereIn('user_id', $userIds)
|
||||||
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
|
||||||
->whereYear('tanggal', '=', $year);
|
|
||||||
|
|
||||||
$formEntertaimentPresentationQuery = FormEntertaimentPresentation::select(
|
$formEntertaimentPresentationQuery = FormEntertaimentPresentation::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
@@ -55,8 +55,7 @@ class FormHelper
|
|||||||
'created_at',
|
'created_at',
|
||||||
DB::raw("'Entertainment Presentation' as type")
|
DB::raw("'Entertainment Presentation' as type")
|
||||||
)->whereIn('user_id', $userIds)
|
)->whereIn('user_id', $userIds)
|
||||||
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
|
||||||
->whereYear('tanggal', '=', $year);
|
|
||||||
|
|
||||||
$formMeetingSeminarQuery = FormMeetingSeminar::select(
|
$formMeetingSeminarQuery = FormMeetingSeminar::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
@@ -68,8 +67,7 @@ class FormHelper
|
|||||||
'created_at',
|
'created_at',
|
||||||
DB::raw("'Meeting Seminar' as type")
|
DB::raw("'Meeting Seminar' as type")
|
||||||
)->whereIn('user_id', $userIds)
|
)->whereIn('user_id', $userIds)
|
||||||
->whereMonth('created_at', '=', date('m', strtotime($month)))
|
->whereBetween('created_at', [$startDate, $closingDateNextMonth]);
|
||||||
->whereYear('created_at', '=', $year);
|
|
||||||
|
|
||||||
$formOthersQuery = FormOthers::select(
|
$formOthersQuery = FormOthers::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
@@ -81,8 +79,7 @@ class FormHelper
|
|||||||
'created_at',
|
'created_at',
|
||||||
DB::raw("'Others' as type")
|
DB::raw("'Others' as type")
|
||||||
)->whereIn('user_id', $userIds)
|
)->whereIn('user_id', $userIds)
|
||||||
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
|
||||||
->whereYear('tanggal', '=', $year);
|
|
||||||
|
|
||||||
// Use union to combine queries
|
// Use union to combine queries
|
||||||
$forms = $formUpCountryQuery
|
$forms = $formUpCountryQuery
|
||||||
@@ -101,6 +98,84 @@ class FormHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function getAllForms($month, $year) {
|
public static function getAllForms($month, $year) {
|
||||||
|
$startDate = date('Y-m-' . env('STARTING_DATE'));
|
||||||
|
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE');
|
||||||
|
|
||||||
|
$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")
|
||||||
|
)->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
|
||||||
|
|
||||||
|
$formVehicleRunningCostQuery = FormVehicleRunningCost::select(
|
||||||
|
'expense_number',
|
||||||
|
'user_id',
|
||||||
|
'total',
|
||||||
|
'approved_total',
|
||||||
|
'status',
|
||||||
|
'account_number',
|
||||||
|
'created_at',
|
||||||
|
DB::raw("'Vehicle Running Cost' as type")
|
||||||
|
)->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
|
||||||
|
|
||||||
|
$formEntertaimentPresentationQuery = FormEntertaimentPresentation::select(
|
||||||
|
'expense_number',
|
||||||
|
'user_id',
|
||||||
|
'total',
|
||||||
|
'approved_total',
|
||||||
|
'status',
|
||||||
|
'account_number',
|
||||||
|
'created_at',
|
||||||
|
DB::raw("'Entertainment Presentation' as type")
|
||||||
|
)->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
|
||||||
|
|
||||||
|
$formMeetingSeminarQuery = FormMeetingSeminar::select(
|
||||||
|
'expense_number',
|
||||||
|
'user_id',
|
||||||
|
'total',
|
||||||
|
'approved_total',
|
||||||
|
'status',
|
||||||
|
'account_number',
|
||||||
|
'created_at',
|
||||||
|
DB::raw("'Meeting Seminar' as type")
|
||||||
|
)->whereBetween('created_at', [$startDate, $closingDateNextMonth]);
|
||||||
|
|
||||||
|
$formOthersQuery = FormOthers::select(
|
||||||
|
'expense_number',
|
||||||
|
'user_id',
|
||||||
|
'total',
|
||||||
|
'approved_total',
|
||||||
|
'status',
|
||||||
|
'account_number',
|
||||||
|
'created_at',
|
||||||
|
DB::raw("'Others' as type")
|
||||||
|
)->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
|
||||||
|
|
||||||
|
// 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 getAllForms2() {
|
||||||
// Get all users with eager loading for 'region' and 'cabang'
|
// Get all users with eager loading for 'region' and 'cabang'
|
||||||
$users = Admin::with(['region', 'cabang'])
|
$users = Admin::with(['region', 'cabang'])
|
||||||
->get();
|
->get();
|
||||||
@@ -114,8 +189,7 @@ class FormHelper
|
|||||||
'account_number',
|
'account_number',
|
||||||
'created_at',
|
'created_at',
|
||||||
DB::raw("'Up Country' as type")
|
DB::raw("'Up Country' as type")
|
||||||
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
);
|
||||||
->whereYear('tanggal', '=', $year);
|
|
||||||
|
|
||||||
$formVehicleRunningCostQuery = FormVehicleRunningCost::select(
|
$formVehicleRunningCostQuery = FormVehicleRunningCost::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
@@ -126,8 +200,7 @@ class FormHelper
|
|||||||
'account_number',
|
'account_number',
|
||||||
'created_at',
|
'created_at',
|
||||||
DB::raw("'Vehicle Running Cost' as type")
|
DB::raw("'Vehicle Running Cost' as type")
|
||||||
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
);
|
||||||
->whereYear('tanggal', '=', $year);
|
|
||||||
|
|
||||||
$formEntertaimentPresentationQuery = FormEntertaimentPresentation::select(
|
$formEntertaimentPresentationQuery = FormEntertaimentPresentation::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
@@ -138,8 +211,7 @@ class FormHelper
|
|||||||
'account_number',
|
'account_number',
|
||||||
'created_at',
|
'created_at',
|
||||||
DB::raw("'Entertainment Presentation' as type")
|
DB::raw("'Entertainment Presentation' as type")
|
||||||
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
);
|
||||||
->whereYear('tanggal', '=', $year);
|
|
||||||
|
|
||||||
$formMeetingSeminarQuery = FormMeetingSeminar::select(
|
$formMeetingSeminarQuery = FormMeetingSeminar::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
@@ -150,8 +222,7 @@ class FormHelper
|
|||||||
'account_number',
|
'account_number',
|
||||||
'created_at',
|
'created_at',
|
||||||
DB::raw("'Meeting Seminar' as type")
|
DB::raw("'Meeting Seminar' as type")
|
||||||
)->whereMonth('created_at', '=', date('m', strtotime($month)))
|
);
|
||||||
->whereYear('created_at', '=', $year);
|
|
||||||
|
|
||||||
$formOthersQuery = FormOthers::select(
|
$formOthersQuery = FormOthers::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
@@ -162,8 +233,7 @@ class FormHelper
|
|||||||
'account_number',
|
'account_number',
|
||||||
'created_at',
|
'created_at',
|
||||||
DB::raw("'Others' as type")
|
DB::raw("'Others' as type")
|
||||||
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
);
|
||||||
->whereYear('tanggal', '=', $year);
|
|
||||||
|
|
||||||
// Combine queries using union
|
// Combine queries using union
|
||||||
$forms = $formUpCountryQuery
|
$forms = $formUpCountryQuery
|
||||||
|
|||||||
@@ -104,29 +104,17 @@ 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([
|
||||||
|
'count' => $notifications->count(),
|
||||||
|
'data' => $notifications->take(7)->get(),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mark_read()
|
public function mark_read()
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|
||||||
|
|||||||
@@ -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,45 @@
|
|||||||
{
|
{
|
||||||
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 a blank row for spacing
|
||||||
|
var blankRow = `<row><c t="inlineStr"><is><t></t></is></c></row>`;
|
||||||
|
|
||||||
|
// Bold text using Excel XML structure
|
||||||
|
var additionalInfo = `
|
||||||
|
<row>
|
||||||
|
<c t="inlineStr" s="2"><is><t>Cabang: {{ $cabang->name }}</t></is></c>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<c t="inlineStr" s="2"><is><t>Periode: {{ ucfirst($month) }} {{ $year }}</t></is></c>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<c t="inlineStr" s="2"><is><t>Cost Centre: {{ $cabang->cost->code }}</t></is></c>
|
||||||
|
</row>
|
||||||
|
`;
|
||||||
|
|
||||||
|
// Locate the sheet data and append the blank row and additional information
|
||||||
|
var sheetData = $(sheet).find('sheetData');
|
||||||
|
var existingRows = sheetData.children();
|
||||||
|
existingRows.last().after(blankRow + additionalInfo);
|
||||||
|
|
||||||
|
// Add bold style to the sheet
|
||||||
|
var styles = xlsx.xl['styles.xml'];
|
||||||
|
var cellXfs = $(styles).find('cellXfs');
|
||||||
|
cellXfs.append(`
|
||||||
|
<xf xfId="0" applyFont="1">
|
||||||
|
<alignment horizontal="left"/>
|
||||||
|
<font>
|
||||||
|
<b/>
|
||||||
|
<sz val="11"/>
|
||||||
|
<name val="Calibri"/>
|
||||||
|
<family val="2"/>
|
||||||
|
</font>
|
||||||
|
</xf>
|
||||||
|
`);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
extend: 'csv',
|
extend: 'csv',
|
||||||
@@ -160,7 +198,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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,12 @@
|
|||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
|
<a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
{{-- periode --}}
|
||||||
|
<a class="nav-link" href="{{ route('dashboard.index') }}" role="button">
|
||||||
|
<span class="ml-2 font-weight-bold text-white">Periode: <span id="periode"></span></span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div class="navbar-center text-white m-auto">
|
<div class="navbar-center text-white m-auto">
|
||||||
@@ -36,6 +42,7 @@
|
|||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a class="nav-link" data-toggle="dropdown" href="#" role="button" data-widget="notification">
|
<a class="nav-link" data-toggle="dropdown" href="#" role="button" data-widget="notification">
|
||||||
<i class="fas fa-bell"></i>
|
<i class="fas fa-bell"></i>
|
||||||
|
<span id="notification-dot" class="badge badge-danger" style="display: none; position: absolute; top: 8px; right: 10px; font-size: 0.6rem;"></span>
|
||||||
</a>
|
</a>
|
||||||
<div class="dropdown-menu dropdown-menu-xl dropdown-menu-right">
|
<div class="dropdown-menu dropdown-menu-xl dropdown-menu-right">
|
||||||
<div id="notification">
|
<div id="notification">
|
||||||
@@ -101,7 +108,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'] }}
|
||||||
@@ -162,7 +172,7 @@
|
|||||||
hour12: false // Use 24-hour format
|
hour12: false // Use 24-hour format
|
||||||
};
|
};
|
||||||
|
|
||||||
dateTimeElement.textContent = new Intl.DateTimeFormat('id-ID', options).format(now);
|
dateTimeElement.textContent = new Intl.DateTimeFormat('id-ID', options).format(now) + ' WIB';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the clock every second
|
// Update the clock every second
|
||||||
@@ -186,7 +196,7 @@
|
|||||||
.then(data => {
|
.then(data => {
|
||||||
notificationList.innerHTML = ''; // Clear existing notifications
|
notificationList.innerHTML = ''; // Clear existing notifications
|
||||||
|
|
||||||
data.forEach(notification => {
|
data.data.forEach(notification => {
|
||||||
const item = document.createElement('a');
|
const item = document.createElement('a');
|
||||||
item.href = notification.link || '#';
|
item.href = notification.link || '#';
|
||||||
item.classList.add('dropdown-item');
|
item.classList.add('dropdown-item');
|
||||||
@@ -223,4 +233,32 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fetch('/api/notifications')
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
const notificationDot = document.getElementById('notification-dot');
|
||||||
|
|
||||||
|
if (data.count > 0) {
|
||||||
|
// Show red dot if there are notifications
|
||||||
|
// show the number of notifications
|
||||||
|
notificationDot.textContent = data.count;
|
||||||
|
notificationDot.style.display = 'block';
|
||||||
|
} else {
|
||||||
|
// Hide red dot if there are no notifications
|
||||||
|
notificationDot.style.display = 'none';
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error checking notifications:', error);
|
||||||
|
});
|
||||||
|
|
||||||
|
const periode = document.getElementById('periode');
|
||||||
|
const date = new Date();
|
||||||
|
|
||||||
|
const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
||||||
|
const month = months[date.getMonth()]; // Get the current month's short name
|
||||||
|
const nextMonth = months[(date.getMonth() + 1) % 12]; // Get the next month's short name, wrapping around if necessary
|
||||||
|
const year = date.getFullYear();
|
||||||
|
|
||||||
|
periode.textContent = `${month} (12 ${month} - 10 ${nextMonth} ${year})`;
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user