added report all

This commit is contained in:
Jagad R R
2025-01-11 13:31:44 +07:00
parent 7aaa9d5370
commit 3127b3b5d7
17 changed files with 639 additions and 144 deletions
+162
View File
@@ -0,0 +1,162 @@
<?php
namespace App\Helpers;
use App\Models\FormEntertaimentPresentation;
use App\Models\FormMeetingSeminar;
use App\Models\FormOthers;
use App\Models\FormUpCountry;
use App\Models\FormVehicleRunningCost;
use Illuminate\Support\Facades\DB;
class FormHelper
{
public static function getFormsByUserIds($userIds, $month, $year) {
$formUpCountryQuery = FormUpCountry::select(
'expense_number',
'user_id',
'total',
'approved_total',
'status',
'account_number',
'created_at',
DB::raw("'Up Country' as type")
)->whereIn('user_id', $userIds)
->whereMonth('tanggal', '=', date('m', strtotime($month)))
->whereYear('tanggal', '=', $year);
$formVehicleRunningCostQuery = FormVehicleRunningCost::select(
'expense_number',
'user_id',
'total',
'approved_total',
'status',
'account_number',
'created_at',
DB::raw("'Vehicle Running Cost' as type")
)->whereIn('user_id', $userIds)
->whereMonth('tanggal', '=', date('m', strtotime($month)))
->whereYear('tanggal', '=', $year);
$formEntertaimentPresentationQuery = FormEntertaimentPresentation::select(
'expense_number',
'user_id',
'total',
'approved_total',
'status',
'account_number',
'created_at',
DB::raw("'Entertainment Presentation' as type")
)->whereIn('user_id', $userIds)
->whereMonth('tanggal', '=', date('m', strtotime($month)))
->whereYear('tanggal', '=', $year);
$formMeetingSeminarQuery = FormMeetingSeminar::select(
'expense_number',
'user_id',
'total',
'approved_total',
'status',
'account_number',
'created_at',
DB::raw("'Meeting Seminar' as type")
)->whereIn('user_id', $userIds)
->whereMonth('created_at', '=', date('m', strtotime($month)))
->whereYear('created_at', '=', $year);
$formOthersQuery = FormOthers::select(
'expense_number',
'user_id',
'total',
'approved_total',
'status',
'account_number',
'created_at',
DB::raw("'Others' as type")
)->whereIn('user_id', $userIds)
->whereMonth('tanggal', '=', date('m', strtotime($month)))
->whereYear('tanggal', '=', $year);
// Use union before fetching the data
$forms = $formUpCountryQuery
->union($formVehicleRunningCostQuery)
->union($formEntertaimentPresentationQuery)
->union($formMeetingSeminarQuery)
->union($formOthersQuery)
->get();
return $forms;
}
public static function getAllForms($month, $year) {
$formUpCountryQuery = FormUpCountry::select(
'expense_number',
'user_id',
'total',
'approved_total',
'status',
'account_number',
'created_at',
DB::raw("'Up Country' as type")
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
->whereYear('tanggal', '=', $year);
$formVehicleRunningCostQuery = FormVehicleRunningCost::select(
'expense_number',
'user_id',
'total',
'approved_total',
'status',
'account_number',
'created_at',
DB::raw("'Vehicle Running Cost' as type")
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
->whereYear('tanggal', '=', $year);
$formEntertaimentPresentationQuery = FormEntertaimentPresentation::select(
'expense_number',
'user_id',
'total',
'approved_total',
'status',
'account_number',
'created_at',
DB::raw("'Entertainment Presentation' as type")
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
->whereYear('tanggal', '=', $year);
$formMeetingSeminarQuery = FormMeetingSeminar::select(
'expense_number',
'user_id',
'total',
'approved_total',
'status',
'account_number',
'created_at',
DB::raw("'Meeting Seminar' as type")
)->whereMonth('created_at', '=', date('m', strtotime($month)))
->whereYear('created_at', '=', $year);
$formOthersQuery = FormOthers::select(
'expense_number',
'user_id',
'total',
'approved_total',
'status',
'account_number',
'created_at',
DB::raw("'Others' as type")
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
->whereYear('tanggal', '=', $year);
// Use union before fetching the data
$forms = $formUpCountryQuery
->union($formVehicleRunningCostQuery)
->union($formEntertaimentPresentationQuery)
->union($formMeetingSeminarQuery)
->union($formOthersQuery)
->get();
return $forms;
}
}