changed tgl cut off to 20
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Models\FormOthers;
|
|||||||
use App\Models\FormUpCountry;
|
use App\Models\FormUpCountry;
|
||||||
use App\Models\FormVehicleRunningCost;
|
use App\Models\FormVehicleRunningCost;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use App\Models\UserHasCabang;
|
||||||
|
|
||||||
class FormHelper
|
class FormHelper
|
||||||
{
|
{
|
||||||
@@ -159,4 +160,25 @@ class FormHelper
|
|||||||
|
|
||||||
return $forms;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ class FormEntertainmentPresentationController extends Controller
|
|||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$forms = FormEntertaimentPresentation::whereMonth('tanggal', date('m'))
|
$forms = FormEntertaimentPresentation::whereMonth('tanggal', date('m'))
|
||||||
->whereYear('tanggal', date('Y'))
|
->whereYear('tanggal', date('Y'))
|
||||||
->where('tanggal', '<=', date('Y-m-10'))
|
->where('tanggal', '<=', date('Y-m-20'))
|
||||||
->whereRaw('DAY(CURDATE()) <= 10')
|
->whereRaw('DAY(CURDATE()) <= 20')
|
||||||
->orderBy('tanggal', 'desc')
|
->orderBy('tanggal', 'desc')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ class FormMeetingSeminarController extends Controller
|
|||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$forms = FormMeetingSeminar::whereMonth('created_at', date('m'))
|
$forms = FormMeetingSeminar::whereMonth('created_at', date('m'))
|
||||||
->whereYear('created_at', date('Y'))
|
->whereYear('created_at', date('Y'))
|
||||||
->where('created_at', '<=', date('Y-m-10'))
|
->where('created_at', '<=', date('Y-m-20'))
|
||||||
->whereRaw('DAY(CURDATE()) <= 10')
|
->whereRaw('DAY(CURDATE()) <= 20')
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ class FormOtherController extends Controller
|
|||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$forms = FormOthers::whereMonth('tanggal', date('m'))
|
$forms = FormOthers::whereMonth('tanggal', date('m'))
|
||||||
->whereYear('tanggal', date('Y'))
|
->whereYear('tanggal', date('Y'))
|
||||||
->where('tanggal', '<=', date('Y-m-10'))
|
->where('tanggal', '<=', date('Y-m-20'))
|
||||||
->whereRaw('DAY(CURDATE()) <= 10')
|
->whereRaw('DAY(CURDATE()) <= 20')
|
||||||
->orderBy('tanggal', 'desc')
|
->orderBy('tanggal', 'desc')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ class FormUpCountryController extends Controller
|
|||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$forms = FormUpCountry::whereMonth('tanggal', date('m'))
|
$forms = FormUpCountry::whereMonth('tanggal', date('m'))
|
||||||
->whereYear('tanggal', date('Y'))
|
->whereYear('tanggal', date('Y'))
|
||||||
->where('tanggal', '<=', date('Y-m-10'))
|
->where('tanggal', '<=', date('Y-m-20'))
|
||||||
->whereRaw('DAY(CURDATE()) <= 10')
|
->whereRaw('DAY(CURDATE()) <= 20')
|
||||||
->orderBy('tanggal', 'desc')
|
->orderBy('tanggal', 'desc')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ class FormVehicleController extends Controller
|
|||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$forms = FormVehicleRunningCost::whereMonth('tanggal', date('m'))
|
$forms = FormVehicleRunningCost::whereMonth('tanggal', date('m'))
|
||||||
->whereYear('tanggal', date('Y'))
|
->whereYear('tanggal', date('Y'))
|
||||||
->where('tanggal', '<=', date('Y-m-10'))
|
->where('tanggal', '<=', date('Y-m-20'))
|
||||||
->whereRaw('DAY(CURDATE()) <= 10')
|
->whereRaw('DAY(CURDATE()) <= 20')
|
||||||
->orderBy('tanggal', 'desc')
|
->orderBy('tanggal', 'desc')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user