improved some query
This commit is contained in:
@@ -19,7 +19,7 @@ class BudgetHelper
|
|||||||
public static function getAvailableBudget($cabang_id)
|
public static function getAvailableBudget($cabang_id)
|
||||||
{
|
{
|
||||||
// Get the budget control data
|
// Get the budget control data
|
||||||
$budget = BudgetControl::where('cabang_id', $cabang_id)->orderBy('created_at', 'desc')->with(['user', 'cabang'])->get();
|
$budget = BudgetControl::where('cabang_id', $cabang_id)->orderBy('created_at', 'desc')->with(['user.cabang'])->get();
|
||||||
|
|
||||||
// Initialize an empty array to hold the used budget sums
|
// Initialize an empty array to hold the used budget sums
|
||||||
$usedBudget = 0;
|
$usedBudget = 0;
|
||||||
@@ -41,6 +41,49 @@ class BudgetHelper
|
|||||||
return $availableBudget;
|
return $availableBudget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getNominalByFormType($userIds, $type, $type_id, $month, $year)
|
||||||
|
{
|
||||||
|
if ($type == 'Up Country') {
|
||||||
|
$form = FormUpCountry::select('approved_total')
|
||||||
|
->whereIn('user_id', $userIds)
|
||||||
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
|
->whereYear('tanggal', '=', $year)
|
||||||
|
->whereIn('status', ['Approved', 'Closed'])
|
||||||
|
->get();
|
||||||
|
} elseif ($type == 'Vehicle Running Cost') {
|
||||||
|
$form = FormVehicleRunningCost::select('approved_total')
|
||||||
|
->whereIn('user_id', $userIds)
|
||||||
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
|
->whereYear('tanggal', '=', $year)
|
||||||
|
->whereIn('status', ['Approved', 'Closed'])
|
||||||
|
->get();
|
||||||
|
} elseif ($type == 'Entertainment') {
|
||||||
|
$form = FormEntertaimentPresentation::select('approved_total')
|
||||||
|
->whereIn('user_id', $userIds)
|
||||||
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
|
->whereYear('tanggal', '=', $year)
|
||||||
|
->whereIn('status', ['Approved', 'Closed'])
|
||||||
|
->get();
|
||||||
|
} elseif ($type == 'Meeting / Seminar') {
|
||||||
|
$form = FormMeetingSeminar::select('approved_total')
|
||||||
|
->whereIn('user_id', $userIds)
|
||||||
|
->whereMonth('created_at', '=', date('m', strtotime($month)))
|
||||||
|
->whereYear('created_at', '=', $year)
|
||||||
|
->whereIn('status', ['Approved', 'Closed'])
|
||||||
|
->get();
|
||||||
|
} else {
|
||||||
|
$form = FormOthers::select('approved_total')
|
||||||
|
->whereIn('user_id', $userIds)
|
||||||
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
|
->whereYear('tanggal', '=', $year)
|
||||||
|
->where('kategori_id', $type_id)
|
||||||
|
->whereIn('status', ['Approved', 'Closed'])
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $form->sum('approved_total');
|
||||||
|
}
|
||||||
|
|
||||||
public static function getClosingDate($cabang_id)
|
public static function getClosingDate($cabang_id)
|
||||||
{
|
{
|
||||||
$budget = BudgetControl::where('cabang_id', $cabang_id)->orderBy('created_at', 'desc')->first();
|
$budget = BudgetControl::where('cabang_id', $cabang_id)->orderBy('created_at', 'desc')->first();
|
||||||
|
|||||||
+129
-109
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Helpers;
|
namespace App\Helpers;
|
||||||
|
|
||||||
|
use App\Models\Admin;
|
||||||
use App\Models\FormEntertaimentPresentation;
|
use App\Models\FormEntertaimentPresentation;
|
||||||
use App\Models\FormMeetingSeminar;
|
use App\Models\FormMeetingSeminar;
|
||||||
use App\Models\FormOthers;
|
use App\Models\FormOthers;
|
||||||
@@ -13,72 +14,77 @@ 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'
|
||||||
|
$users = Admin::with(['region', 'cabang'])
|
||||||
|
->whereIn('id', $userIds)
|
||||||
|
->get();
|
||||||
|
|
||||||
$formUpCountryQuery = FormUpCountry::select(
|
$formUpCountryQuery = FormUpCountry::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
'user_id',
|
'user_id',
|
||||||
'total',
|
'total',
|
||||||
'approved_total',
|
'approved_total',
|
||||||
'status',
|
'status',
|
||||||
'account_number',
|
'account_number',
|
||||||
'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)))
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
->whereYear('tanggal', '=', $year);
|
->whereYear('tanggal', '=', $year);
|
||||||
|
|
||||||
$formVehicleRunningCostQuery = FormVehicleRunningCost::select(
|
$formVehicleRunningCostQuery = FormVehicleRunningCost::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
'user_id',
|
'user_id',
|
||||||
'total',
|
'total',
|
||||||
'approved_total',
|
'approved_total',
|
||||||
'status',
|
'status',
|
||||||
'account_number',
|
'account_number',
|
||||||
'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)))
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
->whereYear('tanggal', '=', $year);
|
->whereYear('tanggal', '=', $year);
|
||||||
|
|
||||||
$formEntertaimentPresentationQuery = FormEntertaimentPresentation::select(
|
$formEntertaimentPresentationQuery = FormEntertaimentPresentation::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
'user_id',
|
'user_id',
|
||||||
'total',
|
'total',
|
||||||
'approved_total',
|
'approved_total',
|
||||||
'status',
|
'status',
|
||||||
'account_number',
|
'account_number',
|
||||||
'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)))
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
->whereYear('tanggal', '=', $year);
|
->whereYear('tanggal', '=', $year);
|
||||||
|
|
||||||
$formMeetingSeminarQuery = FormMeetingSeminar::select(
|
$formMeetingSeminarQuery = FormMeetingSeminar::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
'user_id',
|
'user_id',
|
||||||
'total',
|
'total',
|
||||||
'approved_total',
|
'approved_total',
|
||||||
'status',
|
'status',
|
||||||
'account_number',
|
'account_number',
|
||||||
'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)))
|
->whereMonth('created_at', '=', date('m', strtotime($month)))
|
||||||
->whereYear('created_at', '=', $year);
|
->whereYear('created_at', '=', $year);
|
||||||
|
|
||||||
$formOthersQuery = FormOthers::select(
|
$formOthersQuery = FormOthers::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
'user_id',
|
'user_id',
|
||||||
'total',
|
'total',
|
||||||
'approved_total',
|
'approved_total',
|
||||||
'status',
|
'status',
|
||||||
'account_number',
|
'account_number',
|
||||||
'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)))
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
->whereYear('tanggal', '=', $year);
|
->whereYear('tanggal', '=', $year);
|
||||||
|
|
||||||
// Use union before fetching the data
|
// Use union to combine queries
|
||||||
$forms = $formUpCountryQuery
|
$forms = $formUpCountryQuery
|
||||||
->union($formVehicleRunningCostQuery)
|
->union($formVehicleRunningCostQuery)
|
||||||
->union($formEntertaimentPresentationQuery)
|
->union($formEntertaimentPresentationQuery)
|
||||||
@@ -86,71 +92,80 @@ class FormHelper
|
|||||||
->union($formOthersQuery)
|
->union($formOthersQuery)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
return $forms;
|
// Return forms with eager loaded user details
|
||||||
|
return $forms->map(function ($form) use ($users) {
|
||||||
|
$user = $users->firstWhere('id', $form->user_id);
|
||||||
|
$form->user = $user;
|
||||||
|
return $form;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAllForms($month, $year) {
|
public static function getAllForms($month, $year) {
|
||||||
|
// Get all users with eager loading for 'region' and 'cabang'
|
||||||
|
$users = Admin::with(['region', 'cabang'])
|
||||||
|
->get();
|
||||||
|
|
||||||
$formUpCountryQuery = FormUpCountry::select(
|
$formUpCountryQuery = FormUpCountry::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
'user_id',
|
'user_id',
|
||||||
'total',
|
'total',
|
||||||
'approved_total',
|
'approved_total',
|
||||||
'status',
|
'status',
|
||||||
'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)))
|
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
->whereYear('tanggal', '=', $year);
|
->whereYear('tanggal', '=', $year);
|
||||||
|
|
||||||
$formVehicleRunningCostQuery = FormVehicleRunningCost::select(
|
$formVehicleRunningCostQuery = FormVehicleRunningCost::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
'user_id',
|
'user_id',
|
||||||
'total',
|
'total',
|
||||||
'approved_total',
|
'approved_total',
|
||||||
'status',
|
'status',
|
||||||
'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)))
|
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
->whereYear('tanggal', '=', $year);
|
->whereYear('tanggal', '=', $year);
|
||||||
|
|
||||||
$formEntertaimentPresentationQuery = FormEntertaimentPresentation::select(
|
$formEntertaimentPresentationQuery = FormEntertaimentPresentation::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
'user_id',
|
'user_id',
|
||||||
'total',
|
'total',
|
||||||
'approved_total',
|
'approved_total',
|
||||||
'status',
|
'status',
|
||||||
'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)))
|
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
->whereYear('tanggal', '=', $year);
|
->whereYear('tanggal', '=', $year);
|
||||||
|
|
||||||
$formMeetingSeminarQuery = FormMeetingSeminar::select(
|
$formMeetingSeminarQuery = FormMeetingSeminar::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
'user_id',
|
'user_id',
|
||||||
'total',
|
'total',
|
||||||
'approved_total',
|
'approved_total',
|
||||||
'status',
|
'status',
|
||||||
'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)))
|
)->whereMonth('created_at', '=', date('m', strtotime($month)))
|
||||||
->whereYear('created_at', '=', $year);
|
->whereYear('created_at', '=', $year);
|
||||||
|
|
||||||
$formOthersQuery = FormOthers::select(
|
$formOthersQuery = FormOthers::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
'user_id',
|
'user_id',
|
||||||
'total',
|
'total',
|
||||||
'approved_total',
|
'approved_total',
|
||||||
'status',
|
'status',
|
||||||
'account_number',
|
'account_number',
|
||||||
'created_at',
|
'created_at',
|
||||||
DB::raw("'Others' as type")
|
DB::raw("'Others' as type")
|
||||||
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
->whereYear('tanggal', '=', $year);
|
->whereYear('tanggal', '=', $year);
|
||||||
|
|
||||||
// Use union before fetching the data
|
// Combine queries using union
|
||||||
$forms = $formUpCountryQuery
|
$forms = $formUpCountryQuery
|
||||||
->union($formVehicleRunningCostQuery)
|
->union($formVehicleRunningCostQuery)
|
||||||
->union($formEntertaimentPresentationQuery)
|
->union($formEntertaimentPresentationQuery)
|
||||||
@@ -158,7 +173,12 @@ class FormHelper
|
|||||||
->union($formOthersQuery)
|
->union($formOthersQuery)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
return $forms;
|
// 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 getNominalByFormType($cabang_id, $type, $type_id, $month, $year) {
|
public static function getNominalByFormType($cabang_id, $type, $type_id, $month, $year) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Backend;
|
namespace App\Http\Controllers\Backend;
|
||||||
|
|
||||||
|
use App\Helpers\BudgetHelper;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\BudgetControl;
|
use App\Models\BudgetControl;
|
||||||
use App\Models\BudgetControlLog;
|
use App\Models\BudgetControlLog;
|
||||||
@@ -23,8 +24,6 @@ class BudgetControlController extends Controller
|
|||||||
$this->checkAuthorization(auth()->user(), ['budget_control.view']);
|
$this->checkAuthorization(auth()->user(), ['budget_control.view']);
|
||||||
session()->put('redirect_url', route('budget_control'));
|
session()->put('redirect_url', route('budget_control'));
|
||||||
|
|
||||||
// Get the budget control data
|
|
||||||
// $budget = BudgetControl::orderBy('created_at', 'desc')->with(['user', 'cabang'])->get();
|
|
||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$budget = null;
|
$budget = null;
|
||||||
|
|
||||||
@@ -32,72 +31,32 @@ class BudgetControlController extends Controller
|
|||||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
|
|
||||||
if ($region_id) {
|
if ($region_id) {
|
||||||
// Get budget controls where the region matches
|
|
||||||
$budget = BudgetControl::whereHas('cabang', function ($query) use ($region_id) {
|
$budget = BudgetControl::whereHas('cabang', function ($query) use ($region_id) {
|
||||||
$query->where('region_id', $region_id);
|
$query->where('region_id', $region_id);
|
||||||
})->get();
|
})->with(['receiver', 'sender', 'cabang'])->get();
|
||||||
}
|
}
|
||||||
} elseif ($role == 'Area Manager Cabang') {
|
} elseif ($role == 'Area Manager Cabang') {
|
||||||
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
||||||
|
|
||||||
if ($cabang_id) {
|
if ($cabang_id) {
|
||||||
// Get budget controls where the cabang matches
|
$budget = BudgetControl::where('cabang_id', $cabang_id)
|
||||||
$budget = BudgetControl::where('cabang_id', $cabang_id)->get();
|
->with(['receiver', 'sender', 'cabang'])
|
||||||
|
->get();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Get all budget controls for other roles
|
$budget = BudgetControl::with(['receiver', 'sender', 'cabang'])->get();
|
||||||
$budget = BudgetControl::all();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize an empty array to hold the used budget sums
|
// Calculate usedBudget and availableBudget for each cabang
|
||||||
$usedBudget = [];
|
$budget->map(function ($b) {
|
||||||
|
$b->availableBudget = BudgetHelper::getAvailableBudget($b->cabang_id);
|
||||||
|
|
||||||
foreach ($budget as $b) {
|
return $b;
|
||||||
// Get the month and year from the budget
|
});
|
||||||
$month = $b->periode_month;
|
|
||||||
$year = $b->periode_year;
|
|
||||||
|
|
||||||
// Add the used budget per model for the specified month and year to the usedBudget array
|
return view('backend.pages.budget_control.index', [
|
||||||
$usedBudget[] = [
|
'data' => $budget,
|
||||||
'FormUpCountry' => FormUpCountry::whereIn('status', ['Approved', 'Closed'])
|
]);
|
||||||
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
|
||||||
->whereYear('tanggal', '=', $year)
|
|
||||||
->sum('approved_total'),
|
|
||||||
|
|
||||||
'FormMeetingSeminar' => FormMeetingSeminar::whereIn('status', ['Approved', 'Closed'])
|
|
||||||
->whereMonth('created_at', '=', date('m', strtotime($month)))
|
|
||||||
->whereYear('created_at', '=', $year)
|
|
||||||
->sum('approved_total'),
|
|
||||||
|
|
||||||
'FormOthers' => FormOthers::whereIn('status', ['Approved', 'Closed'])
|
|
||||||
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
|
||||||
->whereYear('tanggal', '=', $year)
|
|
||||||
->sum('approved_total'),
|
|
||||||
|
|
||||||
'FormEntertaimentPresentation' => FormEntertaimentPresentation::whereIn('status', ['Approved', 'Closed'])
|
|
||||||
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
|
||||||
->whereYear('tanggal', '=', $year)
|
|
||||||
->sum('approved_total'),
|
|
||||||
|
|
||||||
'FormVehicleRunningCost' => FormVehicleRunningCost::whereIn('status', ['Approved', 'Closed'])
|
|
||||||
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
|
||||||
->whereYear('tanggal', '=', $year)
|
|
||||||
->sum('approved_total')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$usedBudget = array_sum(array_map(function ($b) {
|
|
||||||
return array_sum($b);
|
|
||||||
}, $usedBudget));
|
|
||||||
|
|
||||||
return view(
|
|
||||||
'backend.pages.budget_control.index',
|
|
||||||
[
|
|
||||||
'data' => $budget,
|
|
||||||
'usedBudget' => $usedBudget,
|
|
||||||
'availableBudget' => $budget->sum('amount') - $usedBudget,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function log()
|
public function log()
|
||||||
@@ -108,7 +67,7 @@ class BudgetControlController extends Controller
|
|||||||
return view(
|
return view(
|
||||||
'backend.pages.budget_control.log',
|
'backend.pages.budget_control.log',
|
||||||
[
|
[
|
||||||
'data' => BudgetControlLog::orderBy('created_at', 'desc')->with(['user', 'cabang'])->get(),
|
'data' => BudgetControlLog::orderBy('created_at', 'desc')->with(['receiver', 'sender', 'cabang'])->get(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,88 +27,75 @@ class ReportController extends Controller
|
|||||||
public function upcountry()
|
public function upcountry()
|
||||||
{
|
{
|
||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$cabangs = [];
|
$cabangs = collect(); // Default empty collection
|
||||||
$regions = [];
|
$regions = collect(); // Default empty collection
|
||||||
$forms = null;
|
$formsQuery = FormUpCountry::with([
|
||||||
|
'user.region',
|
||||||
|
'user.cabang',
|
||||||
|
'rayon'
|
||||||
|
]);
|
||||||
|
|
||||||
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
|
|
||||||
if ($region_id) {
|
if ($region_id) {
|
||||||
$users = UserHasCabang::whereHas('cabang', function ($query) use ($region_id) {
|
|
||||||
$query->where('region_id', $region_id);
|
|
||||||
})->get();
|
|
||||||
|
|
||||||
$userIds = $users->pluck('user_id')->toArray();
|
|
||||||
|
|
||||||
$cabangs = Cabang::where('region_id', $region_id)->get();
|
$cabangs = Cabang::where('region_id', $region_id)->get();
|
||||||
$regions = Region::where('id', $region_id)->get();
|
$regions = Region::where('id', $region_id)->get();
|
||||||
$forms = FormUpCountry::whereIn('user_id', $userIds)->get();
|
$userIds = UserHasCabang::whereIn('cabang_id', $cabangs->pluck('id'))->pluck('user_id');
|
||||||
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
} else if ($role == 'Area Manager Cabang') {
|
} elseif ($role == 'Area Manager Cabang') {
|
||||||
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
||||||
|
|
||||||
if ($cabang_id) {
|
if ($cabang_id) {
|
||||||
$users = UserHasCabang::where('cabang_id', $cabang_id)->get();
|
|
||||||
$userIds = $users->pluck('user_id')->toArray();
|
|
||||||
|
|
||||||
$cabangs = Cabang::where('id', $cabang_id)->get();
|
$cabangs = Cabang::where('id', $cabang_id)->get();
|
||||||
$regions = Region::where('id', $cabangs[0]->region_id)->get();
|
$regions = Region::where('id', $cabangs->first()->region_id)->get();
|
||||||
$forms = FormUpCountry::whereIn('user_id', $userIds)->get();
|
$userIds = UserHasCabang::where('cabang_id', $cabang_id)->pluck('user_id');
|
||||||
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
} else if ($role == 'Medical Representatif') {
|
|
||||||
$userId = auth()->user()->id;
|
|
||||||
|
|
||||||
$cabangs = null;
|
|
||||||
$regions = null;
|
|
||||||
$forms = FormUpCountry::where('user_id', $userId)->get();
|
|
||||||
} else {
|
} else {
|
||||||
$cabangs = Cabang::all();
|
$cabangs = Cabang::all();
|
||||||
$regions = Region::all();
|
$regions = Region::all();
|
||||||
$forms = FormUpCountry::all();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get all params in url
|
// Apply filters from URL params
|
||||||
$params = request()->all();
|
$params = request()->all();
|
||||||
if ($params) {
|
|
||||||
// Filter by region
|
|
||||||
if (isset($params['region'])) {
|
|
||||||
$region = Region::where('code', $params['region'])->first();
|
|
||||||
if ($region) {
|
|
||||||
$userIds = UserHasCabang::whereIn('cabang_id', Cabang::where('region_id', $region->id)->pluck('id'))->pluck('user_id')->toArray();
|
|
||||||
$forms = $forms->whereIn('user_id', $userIds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter by cabang
|
if (isset($params['region'])) {
|
||||||
if (isset($params['cabang'])) {
|
$region = Region::where('code', $params['region'])->first();
|
||||||
$cabang = Cabang::where('code', $params['cabang'])->first();
|
if ($region) {
|
||||||
if ($cabang) {
|
$userIds = UserHasCabang::whereIn('cabang_id', Cabang::where('region_id', $region->id)->pluck('id'))->pluck('user_id');
|
||||||
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id')->toArray();
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
$forms = $forms->whereIn('user_id', $userIds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter by date range
|
|
||||||
if (isset($params['start_date']) || isset($params['end_date'])) {
|
|
||||||
$startDate = $params['start_date'] ?? null;
|
|
||||||
$endDate = $params['end_date'] ?? null;
|
|
||||||
|
|
||||||
if ($startDate && $endDate) {
|
|
||||||
$forms = $forms->whereBetween('tanggal', [$startDate, $endDate]);
|
|
||||||
} elseif ($startDate) {
|
|
||||||
$forms = $forms->where('tanggal', '>=', $startDate);
|
|
||||||
} elseif ($endDate) {
|
|
||||||
$forms = $forms->where('tanggal', '<=', $endDate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter by status
|
|
||||||
if (isset($params['status'])) {
|
|
||||||
$forms = $forms->where('status', $params['status']);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($params['cabang'])) {
|
||||||
|
$cabang = Cabang::where('code', $params['cabang'])->first();
|
||||||
|
if ($cabang) {
|
||||||
|
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id');
|
||||||
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['start_date']) || isset($params['end_date'])) {
|
||||||
|
$startDate = $params['start_date'] ?? null;
|
||||||
|
$endDate = $params['end_date'] ?? null;
|
||||||
|
|
||||||
|
if ($startDate && $endDate) {
|
||||||
|
$formsQuery->whereBetween('tanggal', [$startDate, $endDate]);
|
||||||
|
} elseif ($startDate) {
|
||||||
|
$formsQuery->where('tanggal', '>=', $startDate);
|
||||||
|
} elseif ($endDate) {
|
||||||
|
$formsQuery->where('tanggal', '<=', $endDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['status'])) {
|
||||||
|
$formsQuery->where('status', $params['status']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch forms after applying all filters
|
||||||
|
$forms = $formsQuery->get();
|
||||||
|
|
||||||
return view('backend.pages.report.upcountry', [
|
return view('backend.pages.report.upcountry', [
|
||||||
'pageInfo' => [
|
'pageInfo' => [
|
||||||
@@ -120,51 +107,43 @@ class ReportController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function vehicle()
|
public function vehicle()
|
||||||
{
|
{
|
||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$cabangs = [];
|
$cabangs = collect(); // Default empty collection
|
||||||
$regions = [];
|
$regions = collect(); // Default empty collection
|
||||||
$forms = null;
|
$formsQuery = FormVehicleRunningCost::with([
|
||||||
|
'user.region', // Eager load 'region' within 'user'
|
||||||
|
'user.cabang', // Eager load 'cabang' within 'user'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Apply role-based query logic
|
||||||
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
|
|
||||||
if ($region_id) {
|
if ($region_id) {
|
||||||
$users = UserHasCabang::whereHas('cabang', function ($query) use ($region_id) {
|
|
||||||
$query->where('region_id', $region_id);
|
|
||||||
})->get();
|
|
||||||
|
|
||||||
$userIds = $users->pluck('user_id')->toArray();
|
|
||||||
|
|
||||||
$cabangs = Cabang::where('region_id', $region_id)->get();
|
$cabangs = Cabang::where('region_id', $region_id)->get();
|
||||||
$regions = Region::where('id', $region_id)->get();
|
$regions = Region::where('id', $region_id)->get();
|
||||||
$forms = FormVehicleRunningCost::whereIn('user_id', $userIds)->get();
|
$userIds = UserHasCabang::whereIn('cabang_id', $cabangs->pluck('id'))->pluck('user_id');
|
||||||
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
} else if ($role == 'Area Manager Cabang') {
|
} elseif ($role == 'Area Manager Cabang') {
|
||||||
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
||||||
|
|
||||||
if ($cabang_id) {
|
if ($cabang_id) {
|
||||||
$users = UserHasCabang::where('cabang_id', $cabang_id)->get();
|
|
||||||
$userIds = $users->pluck('user_id')->toArray();
|
|
||||||
|
|
||||||
$cabangs = Cabang::where('id', $cabang_id)->get();
|
$cabangs = Cabang::where('id', $cabang_id)->get();
|
||||||
$regions = Region::where('id', $cabangs[0]->region_id)->get();
|
$regions = Region::where('id', $cabangs->first()->region_id)->get();
|
||||||
$forms = FormVehicleRunningCost::whereIn('user_id', $userIds)->get();
|
$userIds = UserHasCabang::where('cabang_id', $cabang_id)->pluck('user_id');
|
||||||
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
} else if ($role == 'Medical Representatif') {
|
|
||||||
$userId = auth()->user()->id;
|
|
||||||
|
|
||||||
$cabangs = null;
|
|
||||||
$regions = null;
|
|
||||||
$forms = FormVehicleRunningCost::where('user_id', $userId)->get();
|
|
||||||
} else {
|
} else {
|
||||||
|
// Default behavior for other roles (if no specific role is matched)
|
||||||
$cabangs = Cabang::all();
|
$cabangs = Cabang::all();
|
||||||
$regions = Region::all();
|
$regions = Region::all();
|
||||||
$forms = FormVehicleRunningCost::all();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get all params in url
|
// Get all params in URL for filtering
|
||||||
$params = request()->all();
|
$params = request()->all();
|
||||||
|
|
||||||
if ($params) {
|
if ($params) {
|
||||||
@@ -172,8 +151,8 @@ class ReportController extends Controller
|
|||||||
if (isset($params['region'])) {
|
if (isset($params['region'])) {
|
||||||
$region = Region::where('code', $params['region'])->first();
|
$region = Region::where('code', $params['region'])->first();
|
||||||
if ($region) {
|
if ($region) {
|
||||||
$userIds = UserHasCabang::whereIn('cabang_id', Cabang::where('region_id', $region->id)->pluck('id'))->pluck('user_id')->toArray();
|
$userIds = UserHasCabang::whereIn('cabang_id', Cabang::where('region_id', $region->id)->pluck('id'))->pluck('user_id');
|
||||||
$forms = $forms->whereIn('user_id', $userIds);
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,8 +160,8 @@ class ReportController extends Controller
|
|||||||
if (isset($params['cabang'])) {
|
if (isset($params['cabang'])) {
|
||||||
$cabang = Cabang::where('code', $params['cabang'])->first();
|
$cabang = Cabang::where('code', $params['cabang'])->first();
|
||||||
if ($cabang) {
|
if ($cabang) {
|
||||||
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id')->toArray();
|
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id');
|
||||||
$forms = $forms->whereIn('user_id', $userIds);
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,20 +171,23 @@ class ReportController extends Controller
|
|||||||
$endDate = $params['end_date'] ?? null;
|
$endDate = $params['end_date'] ?? null;
|
||||||
|
|
||||||
if ($startDate && $endDate) {
|
if ($startDate && $endDate) {
|
||||||
$forms = $forms->whereBetween('tanggal', [$startDate, $endDate]);
|
$formsQuery->whereBetween('tanggal', [$startDate, $endDate]);
|
||||||
} elseif ($startDate) {
|
} elseif ($startDate) {
|
||||||
$forms = $forms->where('tanggal', '>=', $startDate);
|
$formsQuery->where('tanggal', '>=', $startDate);
|
||||||
} elseif ($endDate) {
|
} elseif ($endDate) {
|
||||||
$forms = $forms->where('tanggal', '<=', $endDate);
|
$formsQuery->where('tanggal', '<=', $endDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter by status
|
// Filter by status
|
||||||
if (isset($params['status'])) {
|
if (isset($params['status'])) {
|
||||||
$forms = $forms->where('status', $params['status']);
|
$formsQuery->where('status', $params['status']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch forms after applying all filters
|
||||||
|
$forms = $formsQuery->get();
|
||||||
|
|
||||||
return view('backend.pages.report.vehicle', [
|
return view('backend.pages.report.vehicle', [
|
||||||
'pageInfo' => [
|
'pageInfo' => [
|
||||||
'title' => 'Generate Reports For Form Vehicle Running Cost',
|
'title' => 'Generate Reports For Form Vehicle Running Cost',
|
||||||
@@ -219,48 +201,35 @@ class ReportController extends Controller
|
|||||||
public function entertainment()
|
public function entertainment()
|
||||||
{
|
{
|
||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$cabangs = [];
|
$cabangs = Cabang::all();
|
||||||
$regions = [];
|
$regions = Region::all();
|
||||||
$forms = null;
|
$formsQuery = FormEntertaimentPresentation::with([
|
||||||
|
'user.region', // Eager load 'region' within 'user'
|
||||||
|
'user.cabang', // Eager load 'cabang' within 'user'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Apply role-based query logic
|
||||||
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
|
|
||||||
if ($region_id) {
|
if ($region_id) {
|
||||||
$users = UserHasCabang::whereHas('cabang', function ($query) use ($region_id) {
|
|
||||||
$query->where('region_id', $region_id);
|
|
||||||
})->get();
|
|
||||||
|
|
||||||
$userIds = $users->pluck('user_id')->toArray();
|
|
||||||
|
|
||||||
$cabangs = Cabang::where('region_id', $region_id)->get();
|
$cabangs = Cabang::where('region_id', $region_id)->get();
|
||||||
$regions = Region::where('id', $region_id)->get();
|
$regions = Region::where('id', $region_id)->get();
|
||||||
$forms = FormEntertaimentPresentation::whereIn('user_id', $userIds)->get();
|
$userIds = UserHasCabang::whereIn('cabang_id', $cabangs->pluck('id'))->pluck('user_id');
|
||||||
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
} else if ($role == 'Area Manager Cabang') {
|
} elseif ($role == 'Area Manager Cabang') {
|
||||||
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
||||||
|
|
||||||
if ($cabang_id) {
|
if ($cabang_id) {
|
||||||
$users = UserHasCabang::where('cabang_id', $cabang_id)->get();
|
|
||||||
$userIds = $users->pluck('user_id')->toArray();
|
|
||||||
|
|
||||||
$cabangs = Cabang::where('id', $cabang_id)->get();
|
$cabangs = Cabang::where('id', $cabang_id)->get();
|
||||||
$regions = Region::where('id', $cabangs[0]->region_id)->get();
|
$regions = Region::where('id', $cabangs->first()->region_id)->get();
|
||||||
$forms = FormEntertaimentPresentation::whereIn('user_id', $userIds)->get();
|
$userIds = UserHasCabang::where('cabang_id', $cabang_id)->pluck('user_id');
|
||||||
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
} else if ($role == 'Medical Representatif') {
|
|
||||||
$userId = auth()->user()->id;
|
|
||||||
|
|
||||||
$cabangs = null;
|
|
||||||
$regions = null;
|
|
||||||
$forms = FormEntertaimentPresentation::where('user_id', $userId)->get();
|
|
||||||
} else {
|
|
||||||
$cabangs = Cabang::all();
|
|
||||||
$regions = Region::all();
|
|
||||||
$forms = FormEntertaimentPresentation::all();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get all params in url
|
// Get all params in URL for filtering
|
||||||
$params = request()->all();
|
$params = request()->all();
|
||||||
|
|
||||||
if ($params) {
|
if ($params) {
|
||||||
@@ -268,8 +237,8 @@ class ReportController extends Controller
|
|||||||
if (isset($params['region'])) {
|
if (isset($params['region'])) {
|
||||||
$region = Region::where('code', $params['region'])->first();
|
$region = Region::where('code', $params['region'])->first();
|
||||||
if ($region) {
|
if ($region) {
|
||||||
$userIds = UserHasCabang::whereIn('cabang_id', Cabang::where('region_id', $region->id)->pluck('id'))->pluck('user_id')->toArray();
|
$userIds = UserHasCabang::whereIn('cabang_id', Cabang::where('region_id', $region->id)->pluck('id'))->pluck('user_id');
|
||||||
$forms = $forms->whereIn('user_id', $userIds);
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,8 +246,8 @@ class ReportController extends Controller
|
|||||||
if (isset($params['cabang'])) {
|
if (isset($params['cabang'])) {
|
||||||
$cabang = Cabang::where('code', $params['cabang'])->first();
|
$cabang = Cabang::where('code', $params['cabang'])->first();
|
||||||
if ($cabang) {
|
if ($cabang) {
|
||||||
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id')->toArray();
|
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id');
|
||||||
$forms = $forms->whereIn('user_id', $userIds);
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,20 +257,23 @@ class ReportController extends Controller
|
|||||||
$endDate = $params['end_date'] ?? null;
|
$endDate = $params['end_date'] ?? null;
|
||||||
|
|
||||||
if ($startDate && $endDate) {
|
if ($startDate && $endDate) {
|
||||||
$forms = $forms->whereBetween('tanggal', [$startDate, $endDate]);
|
$formsQuery->whereBetween('tanggal', [$startDate, $endDate]);
|
||||||
} elseif ($startDate) {
|
} elseif ($startDate) {
|
||||||
$forms = $forms->where('tanggal', '>=', $startDate);
|
$formsQuery->where('tanggal', '>=', $startDate);
|
||||||
} elseif ($endDate) {
|
} elseif ($endDate) {
|
||||||
$forms = $forms->where('tanggal', '<=', $endDate);
|
$formsQuery->where('tanggal', '<=', $endDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter by status
|
// Filter by status
|
||||||
if (isset($params['status'])) {
|
if (isset($params['status'])) {
|
||||||
$forms = $forms->where('status', $params['status']);
|
$formsQuery->where('status', $params['status']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch forms after applying all filters
|
||||||
|
$forms = $formsQuery->get();
|
||||||
|
|
||||||
return view('backend.pages.report.entertainment', [
|
return view('backend.pages.report.entertainment', [
|
||||||
'pageInfo' => [
|
'pageInfo' => [
|
||||||
'title' => 'Generate Reports For Form Entertainment & Presentation',
|
'title' => 'Generate Reports For Form Entertainment & Presentation',
|
||||||
@@ -315,48 +287,37 @@ class ReportController extends Controller
|
|||||||
public function meeting()
|
public function meeting()
|
||||||
{
|
{
|
||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$cabangs = [];
|
$cabangs = Cabang::all();
|
||||||
$regions = [];
|
$regions = Region::all();
|
||||||
$forms = null;
|
|
||||||
|
// Initialize the query for FormMeetingSeminar with eager loading
|
||||||
|
$formsQuery = FormMeetingSeminar::with([
|
||||||
|
'user.region', // Eager load 'region' within 'user'
|
||||||
|
'user.cabang', // Eager load 'cabang' within 'user'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Apply role-based query logic
|
||||||
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
|
|
||||||
if ($region_id) {
|
if ($region_id) {
|
||||||
$users = UserHasCabang::whereHas('cabang', function ($query) use ($region_id) {
|
|
||||||
$query->where('region_id', $region_id);
|
|
||||||
})->get();
|
|
||||||
|
|
||||||
$userIds = $users->pluck('user_id')->toArray();
|
|
||||||
|
|
||||||
$cabangs = Cabang::where('region_id', $region_id)->get();
|
$cabangs = Cabang::where('region_id', $region_id)->get();
|
||||||
$regions = Region::where('id', $region_id)->get();
|
$regions = Region::where('id', $region_id)->get();
|
||||||
$forms = FormMeetingSeminar::whereIn('user_id', $userIds)->get();
|
$userIds = UserHasCabang::whereIn('cabang_id', $cabangs->pluck('id'))->pluck('user_id');
|
||||||
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
} else if ($role == 'Area Manager Cabang') {
|
} elseif ($role == 'Area Manager Cabang') {
|
||||||
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
||||||
|
|
||||||
if ($cabang_id) {
|
if ($cabang_id) {
|
||||||
$users = UserHasCabang::where('cabang_id', $cabang_id)->get();
|
|
||||||
$userIds = $users->pluck('user_id')->toArray();
|
|
||||||
|
|
||||||
$cabangs = Cabang::where('id', $cabang_id)->get();
|
$cabangs = Cabang::where('id', $cabang_id)->get();
|
||||||
$regions = Region::where('id', $cabangs[0]->region_id)->get();
|
$regions = Region::where('id', $cabangs->first()->region_id)->get();
|
||||||
$forms = FormMeetingSeminar::whereIn('user_id', $userIds)->get();
|
$userIds = UserHasCabang::where('cabang_id', $cabang_id)->pluck('user_id');
|
||||||
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
} else if ($role == 'Medical Representatif') {
|
|
||||||
$userId = auth()->user()->id;
|
|
||||||
|
|
||||||
$cabangs = null;
|
|
||||||
$regions = null;
|
|
||||||
$forms = FormMeetingSeminar::where('user_id', $userId)->get();
|
|
||||||
} else {
|
|
||||||
$cabangs = Cabang::all();
|
|
||||||
$regions = Region::all();
|
|
||||||
$forms = FormMeetingSeminar::all();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get all params in url
|
// Get all params in URL for filtering
|
||||||
$params = request()->all();
|
$params = request()->all();
|
||||||
|
|
||||||
if ($params) {
|
if ($params) {
|
||||||
@@ -364,8 +325,8 @@ class ReportController extends Controller
|
|||||||
if (isset($params['region'])) {
|
if (isset($params['region'])) {
|
||||||
$region = Region::where('code', $params['region'])->first();
|
$region = Region::where('code', $params['region'])->first();
|
||||||
if ($region) {
|
if ($region) {
|
||||||
$userIds = UserHasCabang::whereIn('cabang_id', Cabang::where('region_id', $region->id)->pluck('id'))->pluck('user_id')->toArray();
|
$userIds = UserHasCabang::whereIn('cabang_id', Cabang::where('region_id', $region->id)->pluck('id'))->pluck('user_id');
|
||||||
$forms = $forms->whereIn('user_id', $userIds);
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,8 +334,8 @@ class ReportController extends Controller
|
|||||||
if (isset($params['cabang'])) {
|
if (isset($params['cabang'])) {
|
||||||
$cabang = Cabang::where('code', $params['cabang'])->first();
|
$cabang = Cabang::where('code', $params['cabang'])->first();
|
||||||
if ($cabang) {
|
if ($cabang) {
|
||||||
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id')->toArray();
|
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id');
|
||||||
$forms = $forms->whereIn('user_id', $userIds);
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,20 +345,23 @@ class ReportController extends Controller
|
|||||||
$endDate = $params['end_date'] ?? null;
|
$endDate = $params['end_date'] ?? null;
|
||||||
|
|
||||||
if ($startDate && $endDate) {
|
if ($startDate && $endDate) {
|
||||||
$forms = $forms->whereBetween('tanggal', [$startDate, $endDate]);
|
$formsQuery->whereBetween('tanggal', [$startDate, $endDate]);
|
||||||
} elseif ($startDate) {
|
} elseif ($startDate) {
|
||||||
$forms = $forms->where('tanggal', '>=', $startDate);
|
$formsQuery->where('tanggal', '>=', $startDate);
|
||||||
} elseif ($endDate) {
|
} elseif ($endDate) {
|
||||||
$forms = $forms->where('tanggal', '<=', $endDate);
|
$formsQuery->where('tanggal', '<=', $endDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter by status
|
// Filter by status
|
||||||
if (isset($params['status'])) {
|
if (isset($params['status'])) {
|
||||||
$forms = $forms->where('status', $params['status']);
|
$formsQuery->where('status', $params['status']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch forms after applying all filters
|
||||||
|
$forms = $formsQuery->get();
|
||||||
|
|
||||||
return view('backend.pages.report.meeting', [
|
return view('backend.pages.report.meeting', [
|
||||||
'pageInfo' => [
|
'pageInfo' => [
|
||||||
'title' => 'Generate Reports For Form Meeting & Seminar',
|
'title' => 'Generate Reports For Form Meeting & Seminar',
|
||||||
@@ -411,48 +375,38 @@ class ReportController extends Controller
|
|||||||
public function others()
|
public function others()
|
||||||
{
|
{
|
||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$cabangs = [];
|
$cabangs = Cabang::all();
|
||||||
$regions = [];
|
$regions = Region::all();
|
||||||
$forms = null;
|
|
||||||
|
// Initialize the query for FormOthers with eager loading
|
||||||
|
$formsQuery = FormOthers::with([
|
||||||
|
'user.region', // Eager load 'region' within 'user'
|
||||||
|
'user.cabang', // Eager load 'cabang' within 'user'
|
||||||
|
'kategori'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Apply role-based query logic
|
||||||
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
|
|
||||||
if ($region_id) {
|
if ($region_id) {
|
||||||
$users = UserHasCabang::whereHas('cabang', function ($query) use ($region_id) {
|
|
||||||
$query->where('region_id', $region_id);
|
|
||||||
})->get();
|
|
||||||
|
|
||||||
$userIds = $users->pluck('user_id')->toArray();
|
|
||||||
|
|
||||||
$cabangs = Cabang::where('region_id', $region_id)->get();
|
$cabangs = Cabang::where('region_id', $region_id)->get();
|
||||||
$regions = Region::where('id', $region_id)->get();
|
$regions = Region::where('id', $region_id)->get();
|
||||||
$forms = FormOthers::whereIn('user_id', $userIds)->get();
|
$userIds = UserHasCabang::whereIn('cabang_id', $cabangs->pluck('id'))->pluck('user_id');
|
||||||
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
} else if ($role == 'Area Manager Cabang') {
|
} elseif ($role == 'Area Manager Cabang') {
|
||||||
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
||||||
|
|
||||||
if ($cabang_id) {
|
if ($cabang_id) {
|
||||||
$users = UserHasCabang::where('cabang_id', $cabang_id)->get();
|
|
||||||
$userIds = $users->pluck('user_id')->toArray();
|
|
||||||
|
|
||||||
$cabangs = Cabang::where('id', $cabang_id)->get();
|
$cabangs = Cabang::where('id', $cabang_id)->get();
|
||||||
$regions = Region::where('id', $cabangs[0]->region_id)->get();
|
$regions = Region::where('id', $cabangs->first()->region_id)->get();
|
||||||
$forms = FormOthers::whereIn('user_id', $userIds)->get();
|
$userIds = UserHasCabang::where('cabang_id', $cabang_id)->pluck('user_id');
|
||||||
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
} else if ($role == 'Medical Representatif') {
|
|
||||||
$userId = auth()->user()->id;
|
|
||||||
|
|
||||||
$cabangs = null;
|
|
||||||
$regions = null;
|
|
||||||
$forms = FormOthers::where('user_id', $userId)->get();
|
|
||||||
} else {
|
|
||||||
$cabangs = Cabang::all();
|
|
||||||
$regions = Region::all();
|
|
||||||
$forms = FormOthers::all();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get all params in url
|
// Get all params in URL for filtering
|
||||||
$params = request()->all();
|
$params = request()->all();
|
||||||
|
|
||||||
if ($params) {
|
if ($params) {
|
||||||
@@ -460,8 +414,8 @@ class ReportController extends Controller
|
|||||||
if (isset($params['region'])) {
|
if (isset($params['region'])) {
|
||||||
$region = Region::where('code', $params['region'])->first();
|
$region = Region::where('code', $params['region'])->first();
|
||||||
if ($region) {
|
if ($region) {
|
||||||
$userIds = UserHasCabang::whereIn('cabang_id', Cabang::where('region_id', $region->id)->pluck('id'))->pluck('user_id')->toArray();
|
$userIds = UserHasCabang::whereIn('cabang_id', Cabang::where('region_id', $region->id)->pluck('id'))->pluck('user_id');
|
||||||
$forms = $forms->whereIn('user_id', $userIds);
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,8 +423,8 @@ class ReportController extends Controller
|
|||||||
if (isset($params['cabang'])) {
|
if (isset($params['cabang'])) {
|
||||||
$cabang = Cabang::where('code', $params['cabang'])->first();
|
$cabang = Cabang::where('code', $params['cabang'])->first();
|
||||||
if ($cabang) {
|
if ($cabang) {
|
||||||
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id')->toArray();
|
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id');
|
||||||
$forms = $forms->whereIn('user_id', $userIds);
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,20 +434,23 @@ class ReportController extends Controller
|
|||||||
$endDate = $params['end_date'] ?? null;
|
$endDate = $params['end_date'] ?? null;
|
||||||
|
|
||||||
if ($startDate && $endDate) {
|
if ($startDate && $endDate) {
|
||||||
$forms = $forms->whereBetween('tanggal', [$startDate, $endDate]);
|
$formsQuery->whereBetween('tanggal', [$startDate, $endDate]);
|
||||||
} elseif ($startDate) {
|
} elseif ($startDate) {
|
||||||
$forms = $forms->where('tanggal', '>=', $startDate);
|
$formsQuery->where('tanggal', '>=', $startDate);
|
||||||
} elseif ($endDate) {
|
} elseif ($endDate) {
|
||||||
$forms = $forms->where('tanggal', '<=', $endDate);
|
$formsQuery->where('tanggal', '<=', $endDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter by status
|
// Filter by status
|
||||||
if (isset($params['status'])) {
|
if (isset($params['status'])) {
|
||||||
$forms = $forms->where('status', $params['status']);
|
$formsQuery->where('status', $params['status']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch forms after applying all filters
|
||||||
|
$forms = $formsQuery->get();
|
||||||
|
|
||||||
return view('backend.pages.report.others', [
|
return view('backend.pages.report.others', [
|
||||||
'pageInfo' => [
|
'pageInfo' => [
|
||||||
'title' => 'Generate Reports For Form Others',
|
'title' => 'Generate Reports For Form Others',
|
||||||
@@ -538,10 +495,6 @@ class ReportController extends Controller
|
|||||||
$regions = Region::where('id', $cabangs[0]->region_id)->get();
|
$regions = Region::where('id', $cabangs[0]->region_id)->get();
|
||||||
$forms = FormHelper::getFormsByUserIds($userIds, $month, $year)->sortByDesc('created_at');
|
$forms = FormHelper::getFormsByUserIds($userIds, $month, $year)->sortByDesc('created_at');
|
||||||
}
|
}
|
||||||
} elseif ($role == 'Medical Representatif') {
|
|
||||||
$cabangs = null;
|
|
||||||
$regions = null;
|
|
||||||
$forms = FormHelper::getFormsByUserIds([$userId], $month, $year)->sortByDesc('created_at');
|
|
||||||
} else {
|
} else {
|
||||||
$cabangs = Cabang::all();
|
$cabangs = Cabang::all();
|
||||||
$regions = Region::all();
|
$regions = Region::all();
|
||||||
@@ -674,11 +627,53 @@ class ReportController extends Controller
|
|||||||
$kategoris = Kategori::all();
|
$kategoris = Kategori::all();
|
||||||
$kategori_bca = Kategori::where('name', 'Cash in Bank BCA')->first();
|
$kategori_bca = Kategori::where('name', 'Cash in Bank BCA')->first();
|
||||||
$cabang = Cabang::with('cost')->where('code', $params['cabang'])->first();
|
$cabang = Cabang::with('cost')->where('code', $params['cabang'])->first();
|
||||||
|
|
||||||
$year = $params['year'];
|
$year = $params['year'];
|
||||||
$month = $params['month'];
|
$month = $params['month'];
|
||||||
|
|
||||||
$budget = BudgetControlLog::where('cabang_id', $cabang->id)->where('periode_year', $year)->where('periode_month', $month)->orderBy('created_at', 'desc')->first();
|
$budget = BudgetControlLog::where('cabang_id', $cabang->id)->where('periode_year', $year)->where('periode_month', $month)->orderBy('created_at', 'desc')->first();
|
||||||
|
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id');
|
||||||
|
|
||||||
|
// Fetch all relevant forms in one batch
|
||||||
|
$forms = [
|
||||||
|
'Up Country' => FormUpCountry::whereIn('user_id', $userIds)
|
||||||
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
|
->whereYear('tanggal', '=', $year)
|
||||||
|
->whereIn('status', ['Approved', 'Closed'])
|
||||||
|
->get(),
|
||||||
|
'Vehicle Running Cost' => FormVehicleRunningCost::whereIn('user_id', $userIds)
|
||||||
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
|
->whereYear('tanggal', '=', $year)
|
||||||
|
->whereIn('status', ['Approved', 'Closed'])
|
||||||
|
->get(),
|
||||||
|
'Entertainment' => FormEntertaimentPresentation::whereIn('user_id', $userIds)
|
||||||
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
|
->whereYear('tanggal', '=', $year)
|
||||||
|
->whereIn('status', ['Approved', 'Closed'])
|
||||||
|
->get(),
|
||||||
|
'Meeting / Seminar' => FormMeetingSeminar::whereIn('user_id', $userIds)
|
||||||
|
->whereMonth('created_at', '=', date('m', strtotime($month)))
|
||||||
|
->whereYear('created_at', '=', $year)
|
||||||
|
->whereIn('status', ['Approved', 'Closed'])
|
||||||
|
->get(),
|
||||||
|
];
|
||||||
|
|
||||||
|
// Fetch 'Others' forms by kategori
|
||||||
|
$otherForms = FormOthers::whereIn('user_id', $userIds)
|
||||||
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
|
->whereYear('tanggal', '=', $year)
|
||||||
|
->whereIn('status', ['Approved', 'Closed'])
|
||||||
|
->get();
|
||||||
|
|
||||||
|
// Precompute totals for each category
|
||||||
|
$nominals = [];
|
||||||
|
foreach ($kategoris as $item) {
|
||||||
|
if (isset($forms[$item->name])) {
|
||||||
|
$nominals[$item->id] = $forms[$item->name]->sum('approved_total');
|
||||||
|
} else {
|
||||||
|
$nominals[$item->id] = $otherForms->where('kategori_id', $item->id)->sum('approved_total');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return view('backend.pages.report.generate_jurnal', [
|
return view('backend.pages.report.generate_jurnal', [
|
||||||
'pageInfo' => [
|
'pageInfo' => [
|
||||||
@@ -688,8 +683,9 @@ class ReportController extends Controller
|
|||||||
'cabang' => $cabang,
|
'cabang' => $cabang,
|
||||||
'year' => $year,
|
'year' => $year,
|
||||||
'month' => $month,
|
'month' => $month,
|
||||||
'budget' => $budget,
|
'kategori_bca' => $kategori_bca,
|
||||||
'kategori_bca' => $kategori_bca
|
'nominals' => $nominals,
|
||||||
|
'budget' => $budget
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class FormEntertainmentPresentationController extends Controller
|
|||||||
->where('tanggal', '<=', date('Y-m-' . env('CLOSING_DATE')))
|
->where('tanggal', '<=', date('Y-m-' . env('CLOSING_DATE')))
|
||||||
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE'))
|
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE'))
|
||||||
->orderBy('tanggal', 'desc')
|
->orderBy('tanggal', 'desc')
|
||||||
|
->with('user')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$availableBudget = null;
|
$availableBudget = null;
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class FormMeetingSeminarController extends Controller
|
|||||||
->where('created_at', '<=', date('Y-m-' . env('CLOSING_DATE')))
|
->where('created_at', '<=', date('Y-m-' . env('CLOSING_DATE')))
|
||||||
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE'))
|
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE'))
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
|
->with('user')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$availableBudget = null;
|
$availableBudget = null;
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class FormOtherController extends Controller
|
|||||||
->where('tanggal', '<=', date('Y-m-' . env('CLOSING_DATE')))
|
->where('tanggal', '<=', date('Y-m-' . env('CLOSING_DATE')))
|
||||||
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE'))
|
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE'))
|
||||||
->orderBy('tanggal', 'desc')
|
->orderBy('tanggal', 'desc')
|
||||||
|
->with(['user', 'kategori'])
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$availableBudget = null;
|
$availableBudget = null;
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class FormUpCountryController extends Controller
|
|||||||
->where('tanggal', '<=', date('Y-m-' . env('CLOSING_DATE')))
|
->where('tanggal', '<=', date('Y-m-' . env('CLOSING_DATE')))
|
||||||
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE'))
|
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE'))
|
||||||
->orderBy('tanggal', 'desc')
|
->orderBy('tanggal', 'desc')
|
||||||
|
->with(['rayon', 'user'])
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$availableBudget = null;
|
$availableBudget = null;
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class FormVehicleController extends Controller
|
|||||||
->where('tanggal', '<=', date('Y-m-' . env('CLOSING_DATE')))
|
->where('tanggal', '<=', date('Y-m-' . env('CLOSING_DATE')))
|
||||||
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE'))
|
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE'))
|
||||||
->orderBy('tanggal', 'desc')
|
->orderBy('tanggal', 'desc')
|
||||||
|
->with('user')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$availableBudget = null;
|
$availableBudget = null;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
"yajra/laravel-datatables-oracle": "11.0"
|
"yajra/laravel-datatables-oracle": "11.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
"barryvdh/laravel-debugbar": "^3.14",
|
||||||
"fakerphp/faker": "^1.23",
|
"fakerphp/faker": "^1.23",
|
||||||
"laravel/pail": "^1.1",
|
"laravel/pail": "^1.1",
|
||||||
"laravel/pint": "^1.13",
|
"laravel/pint": "^1.13",
|
||||||
|
|||||||
Generated
+153
-1
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "868009e8371e3394bb5e17f99038a6b8",
|
"content-hash": "5ba74d8866276fa9daa9d6c52fd9f690",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "barryvdh/laravel-dompdf",
|
"name": "barryvdh/laravel-dompdf",
|
||||||
@@ -8044,6 +8044,90 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
|
{
|
||||||
|
"name": "barryvdh/laravel-debugbar",
|
||||||
|
"version": "v3.14.10",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/barryvdh/laravel-debugbar.git",
|
||||||
|
"reference": "56b9bd235e3fe62e250124804009ce5bab97cc63"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/56b9bd235e3fe62e250124804009ce5bab97cc63",
|
||||||
|
"reference": "56b9bd235e3fe62e250124804009ce5bab97cc63",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"illuminate/routing": "^9|^10|^11",
|
||||||
|
"illuminate/session": "^9|^10|^11",
|
||||||
|
"illuminate/support": "^9|^10|^11",
|
||||||
|
"maximebf/debugbar": "~1.23.0",
|
||||||
|
"php": "^8.0",
|
||||||
|
"symfony/finder": "^6|^7"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"mockery/mockery": "^1.3.3",
|
||||||
|
"orchestra/testbench-dusk": "^5|^6|^7|^8|^9",
|
||||||
|
"phpunit/phpunit": "^9.6|^10.5",
|
||||||
|
"squizlabs/php_codesniffer": "^3.5"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"aliases": {
|
||||||
|
"Debugbar": "Barryvdh\\Debugbar\\Facades\\Debugbar"
|
||||||
|
},
|
||||||
|
"providers": [
|
||||||
|
"Barryvdh\\Debugbar\\ServiceProvider"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "3.14-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"src/helpers.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Barryvdh\\Debugbar\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Barry vd. Heuvel",
|
||||||
|
"email": "barryvdh@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PHP Debugbar integration for Laravel",
|
||||||
|
"keywords": [
|
||||||
|
"debug",
|
||||||
|
"debugbar",
|
||||||
|
"laravel",
|
||||||
|
"profiler",
|
||||||
|
"webprofiler"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/barryvdh/laravel-debugbar/issues",
|
||||||
|
"source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.14.10"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://fruitcake.nl",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/barryvdh",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-12-23T10:10:42+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "fakerphp/faker",
|
"name": "fakerphp/faker",
|
||||||
"version": "v1.24.1",
|
"version": "v1.24.1",
|
||||||
@@ -8436,6 +8520,74 @@
|
|||||||
},
|
},
|
||||||
"time": "2024-11-27T15:42:28+00:00"
|
"time": "2024-11-27T15:42:28+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "maximebf/debugbar",
|
||||||
|
"version": "v1.23.5",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/php-debugbar/php-debugbar.git",
|
||||||
|
"reference": "eeabd61a1f19ba5dcd5ac4585a477130ee03ce25"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/php-debugbar/php-debugbar/zipball/eeabd61a1f19ba5dcd5ac4585a477130ee03ce25",
|
||||||
|
"reference": "eeabd61a1f19ba5dcd5ac4585a477130ee03ce25",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.2|^8",
|
||||||
|
"psr/log": "^1|^2|^3",
|
||||||
|
"symfony/var-dumper": "^4|^5|^6|^7"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"dbrekelmans/bdi": "^1",
|
||||||
|
"phpunit/phpunit": "^8|^9",
|
||||||
|
"symfony/panther": "^1|^2.1",
|
||||||
|
"twig/twig": "^1.38|^2.7|^3.0"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"kriswallsmith/assetic": "The best way to manage assets",
|
||||||
|
"monolog/monolog": "Log using Monolog",
|
||||||
|
"predis/predis": "Redis storage"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.23-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"DebugBar\\": "src/DebugBar/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Maxime Bouroumeau-Fuseau",
|
||||||
|
"email": "maxime.bouroumeau@gmail.com",
|
||||||
|
"homepage": "http://maximebf.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Barry vd. Heuvel",
|
||||||
|
"email": "barryvdh@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Debug bar in the browser for php application",
|
||||||
|
"homepage": "https://github.com/maximebf/php-debugbar",
|
||||||
|
"keywords": [
|
||||||
|
"debug",
|
||||||
|
"debugbar"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/php-debugbar/php-debugbar/issues",
|
||||||
|
"source": "https://github.com/php-debugbar/php-debugbar/tree/v1.23.5"
|
||||||
|
},
|
||||||
|
"time": "2024-12-15T19:20:42+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "mockery/mockery",
|
"name": "mockery/mockery",
|
||||||
"version": "1.6.12",
|
"version": "1.6.12",
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
<td>{{ $item->cabang->name }}</td>
|
<td>{{ $item->cabang->name }}</td>
|
||||||
<td>{{ $item->sender->name }}</td>
|
<td>{{ $item->sender->name }}</td>
|
||||||
<td>{{ number_format($item->amount, 0, ',', '.') }}</td>
|
<td>{{ number_format($item->amount, 0, ',', '.') }}</td>
|
||||||
<td>{{ number_format(BudgetHelper::getAvailableBudget($item->cabang->id), 0, ',', '.') }}</td>
|
<td>{{ number_format($item->availableBudget, 0, ',', '.') }}</td>
|
||||||
<td>{{ $item->remarks }}</td>
|
<td>{{ $item->remarks }}</td>
|
||||||
<td>{{ strtoupper($item->periode_month) }} {{ $item->periode_year }}</td>
|
<td>{{ strtoupper($item->periode_month) }} {{ $item->periode_year }}</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
@endphp
|
@endphp
|
||||||
@foreach ($kategori as $item)
|
@foreach ($kategori as $item)
|
||||||
@php
|
@php
|
||||||
$drValue = FormHelper::getNominalByFormType($cabang->id, $item->name, $item->id, $month, $year);
|
$drValue = $nominals[$item->id] ?? 0;
|
||||||
$drFormatted = $drValue == 0 ? '' : number_format($drValue, 0, ',', '.');
|
$drFormatted = $drValue == 0 ? '' : number_format($drValue, 0, ',', '.');
|
||||||
$totalDr += $drValue;
|
$totalDr += $drValue;
|
||||||
@endphp
|
@endphp
|
||||||
@@ -79,6 +79,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ $kategori->count() + 1 }}</td>
|
<td>{{ $kategori->count() + 1 }}</td>
|
||||||
<td>Petty Cash</td>
|
<td>Petty Cash</td>
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
||||||
Reference in New Issue
Block a user