fix some revisi
This commit is contained in:
+16
-22
@@ -14,7 +14,9 @@ use App\Models\UserHasCabang;
|
||||
class FormHelper
|
||||
{
|
||||
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'])
|
||||
->whereIn('id', $userIds)
|
||||
->get();
|
||||
@@ -29,8 +31,7 @@ class FormHelper
|
||||
'created_at',
|
||||
DB::raw("'Up Country' as type")
|
||||
)->whereIn('user_id', $userIds)
|
||||
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||
->whereYear('tanggal', '=', $year);
|
||||
->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
|
||||
|
||||
$formVehicleRunningCostQuery = FormVehicleRunningCost::select(
|
||||
'expense_number',
|
||||
@@ -42,8 +43,7 @@ class FormHelper
|
||||
'created_at',
|
||||
DB::raw("'Vehicle Running Cost' as type")
|
||||
)->whereIn('user_id', $userIds)
|
||||
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||
->whereYear('tanggal', '=', $year);
|
||||
->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
|
||||
|
||||
$formEntertaimentPresentationQuery = FormEntertaimentPresentation::select(
|
||||
'expense_number',
|
||||
@@ -55,8 +55,7 @@ class FormHelper
|
||||
'created_at',
|
||||
DB::raw("'Entertainment Presentation' as type")
|
||||
)->whereIn('user_id', $userIds)
|
||||
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||
->whereYear('tanggal', '=', $year);
|
||||
->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
|
||||
|
||||
$formMeetingSeminarQuery = FormMeetingSeminar::select(
|
||||
'expense_number',
|
||||
@@ -68,8 +67,7 @@ class FormHelper
|
||||
'created_at',
|
||||
DB::raw("'Meeting Seminar' as type")
|
||||
)->whereIn('user_id', $userIds)
|
||||
->whereMonth('created_at', '=', date('m', strtotime($month)))
|
||||
->whereYear('created_at', '=', $year);
|
||||
->whereBetween('created_at', [$startDate, $closingDateNextMonth]);
|
||||
|
||||
$formOthersQuery = FormOthers::select(
|
||||
'expense_number',
|
||||
@@ -81,8 +79,7 @@ class FormHelper
|
||||
'created_at',
|
||||
DB::raw("'Others' as type")
|
||||
)->whereIn('user_id', $userIds)
|
||||
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||
->whereYear('tanggal', '=', $year);
|
||||
->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
|
||||
|
||||
// Use union to combine queries
|
||||
$forms = $formUpCountryQuery
|
||||
@@ -101,7 +98,9 @@ class FormHelper
|
||||
}
|
||||
|
||||
public static function getAllForms($month, $year) {
|
||||
// Get all users with eager loading for 'region' and 'cabang'
|
||||
$startDate = date('Y-m-' . env('STARTING_DATE'));
|
||||
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE');
|
||||
|
||||
$users = Admin::with(['region', 'cabang'])
|
||||
->get();
|
||||
|
||||
@@ -114,8 +113,7 @@ class FormHelper
|
||||
'account_number',
|
||||
'created_at',
|
||||
DB::raw("'Up Country' as type")
|
||||
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||
->whereYear('tanggal', '=', $year);
|
||||
)->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
|
||||
|
||||
$formVehicleRunningCostQuery = FormVehicleRunningCost::select(
|
||||
'expense_number',
|
||||
@@ -126,8 +124,7 @@ class FormHelper
|
||||
'account_number',
|
||||
'created_at',
|
||||
DB::raw("'Vehicle Running Cost' as type")
|
||||
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||
->whereYear('tanggal', '=', $year);
|
||||
)->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
|
||||
|
||||
$formEntertaimentPresentationQuery = FormEntertaimentPresentation::select(
|
||||
'expense_number',
|
||||
@@ -138,8 +135,7 @@ class FormHelper
|
||||
'account_number',
|
||||
'created_at',
|
||||
DB::raw("'Entertainment Presentation' as type")
|
||||
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||
->whereYear('tanggal', '=', $year);
|
||||
)->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
|
||||
|
||||
$formMeetingSeminarQuery = FormMeetingSeminar::select(
|
||||
'expense_number',
|
||||
@@ -150,8 +146,7 @@ class FormHelper
|
||||
'account_number',
|
||||
'created_at',
|
||||
DB::raw("'Meeting Seminar' as type")
|
||||
)->whereMonth('created_at', '=', date('m', strtotime($month)))
|
||||
->whereYear('created_at', '=', $year);
|
||||
)->whereBetween('created_at', [$startDate, $closingDateNextMonth]);
|
||||
|
||||
$formOthersQuery = FormOthers::select(
|
||||
'expense_number',
|
||||
@@ -162,8 +157,7 @@ class FormHelper
|
||||
'account_number',
|
||||
'created_at',
|
||||
DB::raw("'Others' as type")
|
||||
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||
->whereYear('tanggal', '=', $year);
|
||||
)->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
|
||||
|
||||
// Combine queries using union
|
||||
$forms = $formUpCountryQuery
|
||||
|
||||
@@ -26,6 +26,12 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
|
||||
</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>
|
||||
|
||||
<div class="navbar-center text-white m-auto">
|
||||
@@ -165,7 +171,7 @@
|
||||
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
|
||||
@@ -226,4 +232,14 @@
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user