changed tgl cut off to 20

This commit is contained in:
Jagad R R
2025-01-14 12:01:54 +07:00
parent deeb8c7a68
commit 9f2260c611
6 changed files with 32 additions and 10 deletions
+22
View File
@@ -8,6 +8,7 @@ use App\Models\FormOthers;
use App\Models\FormUpCountry;
use App\Models\FormVehicleRunningCost;
use Illuminate\Support\Facades\DB;
use App\Models\UserHasCabang;
class FormHelper
{
@@ -159,4 +160,25 @@ class FormHelper
return $forms;
}
public static function getNominalByFormType($cabang_id, $type, $type_id, $month, $year) {
$users = UserHasCabang::where('cabang_id', $cabang_id)->get();
$userIds = $users->pluck('user_id')->toArray();
if($type == 'Up Country') {
$form = FormUpCountry::select('approved_total')->whereIn('user_id', $userIds)->whereMonth('tanggal', '=', date('m', strtotime($month)))->whereYear('tanggal', '=', $year);
} else if($type == 'Vehicle Running Cost') {
$form = FormVehicleRunningCost::select('approved_total')->whereIn('user_id', $userIds)->whereMonth('tanggal', '=', date('m', strtotime($month)))->whereYear('tanggal', '=', $year);
} else if($type == 'Entertainment') {
$form = FormEntertaimentPresentation::select('approved_total')->whereIn('user_id', $userIds)->whereMonth('tanggal', '=', date('m', strtotime($month)))->whereYear('tanggal', '=', $year);
} else if($type == 'Meeting / Seminar') {
$form = FormMeetingSeminar::select('approved_total')->whereIn('user_id', $userIds)->whereMonth('created_at', '=', date('m', strtotime($month)))->whereYear('created_at', '=', $year);
} else {
$form = FormOthers::select('approved_total')->whereIn('user_id', $userIds)->whereMonth('tanggal', '=', date('m', strtotime($month)))->whereYear('tanggal', '=', $year)->where('kategori_id', $type_id);
}
$nominal = $form->sum('approved_total');
return $nominal;
}
}