added statistic cards
This commit is contained in:
@@ -8,18 +8,68 @@ use App\Http\Controllers\Controller;
|
|||||||
use App\Models\Admin;
|
use App\Models\Admin;
|
||||||
use Spatie\Permission\Models\Permission;
|
use Spatie\Permission\Models\Permission;
|
||||||
use Spatie\Permission\Models\Role;
|
use Spatie\Permission\Models\Role;
|
||||||
|
use App\Models\FormUpCountry;
|
||||||
|
use App\Models\FormEntertaimentPresentation;
|
||||||
|
use App\Models\FormVehicleRunningCost;
|
||||||
|
use App\Models\FormMeetingSeminar;
|
||||||
|
use App\Models\FormOthers;
|
||||||
|
use App\Models\UserHasCabang;
|
||||||
|
|
||||||
|
|
||||||
class DashboardController extends Controller
|
class DashboardController extends Controller
|
||||||
{
|
{
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
|
$forms = [
|
||||||
|
'vehicle' => FormVehicleRunningCost::query(),
|
||||||
|
'upcountry' => FormUpCountry::query(),
|
||||||
|
'entertainment' => FormEntertaimentPresentation::query(),
|
||||||
|
'meeting' => FormMeetingSeminar::query(),
|
||||||
|
'others' => FormOthers::query(),
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||||
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
|
|
||||||
|
if ($region_id) {
|
||||||
|
$users = UserHasCabang::whereHas('cabang', function ($query) use ($region_id) {
|
||||||
|
$query->where('region_id', $region_id);
|
||||||
|
})->pluck('user_id');
|
||||||
|
|
||||||
|
foreach ($forms as $key => $query) {
|
||||||
|
$forms[$key] = $query->whereIn('user_id', $users)->whereIn('status', ['Approved', 'Closed']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} elseif ($role == 'Area Manager Cabang') {
|
||||||
|
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
||||||
|
|
||||||
|
if ($cabang_id) {
|
||||||
|
$users = UserHasCabang::where('cabang_id', $cabang_id)->pluck('user_id');
|
||||||
|
|
||||||
|
foreach ($forms as $key => $query) {
|
||||||
|
$forms[$key] = $query->whereIn('user_id', $users)->whereIn('status', ['Approved', 'Closed']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} elseif ($role == 'Medical Representatif') {
|
||||||
|
foreach ($forms as $key => $query) {
|
||||||
|
$forms[$key] = $query->where('user_id', auth()->user()->id)->whereIn('status', ['Approved', 'Closed']);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
foreach ($forms as $key => $query) {
|
||||||
|
$forms[$key] = $query->whereIn('status', ['Approved', 'Closed']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sum the filtered queries
|
||||||
|
foreach ($forms as $key => $query) {
|
||||||
|
$forms[$key] = $query->sum('total');
|
||||||
|
}
|
||||||
|
|
||||||
return view(
|
return view(
|
||||||
'backend.pages.dashboard.index',
|
'backend.pages.dashboard.index',
|
||||||
[
|
[
|
||||||
'total_admins' => Admin::count(),
|
'forms' => $forms,
|
||||||
'total_roles' => Role::count(),
|
|
||||||
'total_permissions' => Permission::count(),
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ class FormEntertainmentPresentationController extends Controller
|
|||||||
{
|
{
|
||||||
$this->checkAuthorization(auth()->user(), ['forms.entertainment.view']);
|
$this->checkAuthorization(auth()->user(), ['forms.entertainment.view']);
|
||||||
|
|
||||||
// get user role
|
|
||||||
// get user role
|
|
||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$forms = FormEntertaimentPresentation::get();
|
$forms = FormEntertaimentPresentation::get();
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ class FormMeetingSeminarController extends Controller
|
|||||||
{
|
{
|
||||||
$this->checkAuthorization(auth()->user(), ['forms.meeting.view']);
|
$this->checkAuthorization(auth()->user(), ['forms.meeting.view']);
|
||||||
|
|
||||||
// get user role
|
|
||||||
// get user role
|
|
||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$forms = FormMeetingSeminar::get();
|
$forms = FormMeetingSeminar::get();
|
||||||
|
|
||||||
|
|||||||
@@ -27,11 +27,6 @@ class FormOtherController extends Controller
|
|||||||
{
|
{
|
||||||
$this->checkAuthorization(auth()->user(), ['forms.other.view']);
|
$this->checkAuthorization(auth()->user(), ['forms.other.view']);
|
||||||
|
|
||||||
// get user role
|
|
||||||
$role = auth()->user()->getRoleNames()[0];
|
|
||||||
$forms = null;
|
|
||||||
|
|
||||||
// get user role
|
|
||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$forms = FormOthers::get();
|
$forms = FormOthers::get();
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ class FormUpCountryController extends Controller
|
|||||||
{
|
{
|
||||||
$this->checkAuthorization(auth()->user(), ['forms.country.view']);
|
$this->checkAuthorization(auth()->user(), ['forms.country.view']);
|
||||||
|
|
||||||
// get user role
|
|
||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$forms = FormUpCountry::get();
|
$forms = FormUpCountry::get();
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ class FormVehicleController extends Controller
|
|||||||
{
|
{
|
||||||
$this->checkAuthorization(auth()->user(), ['forms.vehicle.view']);
|
$this->checkAuthorization(auth()->user(), ['forms.vehicle.view']);
|
||||||
|
|
||||||
// get user role
|
|
||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$forms = FormVehicleRunningCost::get();
|
$forms = FormVehicleRunningCost::get();
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
<section class="content">
|
<section class="content">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 mt-5">
|
<div class="col-12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h4 class="header-title float-left">{{ $pageInfo['title'] }}</h4>
|
<h4 class="header-title float-left">{{ $pageInfo['title'] }}</h4>
|
||||||
@@ -42,6 +42,7 @@
|
|||||||
<th width="15%">{{ __('Activity') }}</th>
|
<th width="15%">{{ __('Activity') }}</th>
|
||||||
<th width="5%">Browser</th>
|
<th width="5%">Browser</th>
|
||||||
<th width="15%">User Agent</th>
|
<th width="15%">User Agent</th>
|
||||||
|
<th width="5%">Time</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -69,6 +70,7 @@
|
|||||||
<td>{{ $item->activity }}</td>
|
<td>{{ $item->activity }}</td>
|
||||||
<td>{{ $item->browser }}</td>
|
<td>{{ $item->browser }}</td>
|
||||||
<td>{{ $item->user_agent }}</td>
|
<td>{{ $item->user_agent }}</td>
|
||||||
|
<td>{{ $item->created_at->diffForHumans() }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<ol class="breadcrumb float-sm-right">
|
<ol class="breadcrumb float-sm-right">
|
||||||
<li class="breadcrumb-item"><a href="{{ route('dashboard.index') }}">Dashboard</a></li>
|
<li class="breadcrumb-item"><a href="{{ route('dashboard.index') }}">Dashboard</a></li>
|
||||||
</li>
|
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -22,6 +21,97 @@
|
|||||||
</section>
|
</section>
|
||||||
<section class="content">
|
<section class="content">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<!-- Statistic Card 1 -->
|
||||||
|
<div class="col-lg-4 col-6">
|
||||||
|
<div class="small-box bg-info">
|
||||||
|
<div class="inner">
|
||||||
|
<h3>Rp {{ number_format($forms['vehicle'] + $forms['entertainment'] + $forms['meeting'] + $forms['upcountry'] + $forms['others'], 0, ',', '.') }}</h3>
|
||||||
|
<p>All Approved Expenses</p>
|
||||||
|
</div>
|
||||||
|
<div class="icon">
|
||||||
|
<i class="fas fa-check-circle"></i>
|
||||||
|
</div>
|
||||||
|
<a href="#" class="small-box-footer">
|
||||||
|
More info <i class="fas fa-arrow-circle-right"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Statistic Card 2 -->
|
||||||
|
<div class="col-lg-4 col-6">
|
||||||
|
<div class="small-box bg-success">
|
||||||
|
<div class="inner">
|
||||||
|
<h3>Rp {{ number_format($forms['upcountry'], 0, ',', '.') }}</h3>
|
||||||
|
<p>Approved Up Country Expenses</p>
|
||||||
|
</div>
|
||||||
|
<div class="icon">
|
||||||
|
<i class="fa fa-flag" aria-hidden="true"></i>
|
||||||
|
</div>
|
||||||
|
<a href="{{ route('forms.up-country') }}" class="small-box-footer">
|
||||||
|
More info <i class="fas fa-arrow-circle-right"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Statistic Card 3 -->
|
||||||
|
<div class="col-lg-4 col-6">
|
||||||
|
<div class="small-box bg-warning">
|
||||||
|
<div class="inner text-white">
|
||||||
|
<h3>Rp {{ number_format($forms['vehicle'], 0, ',', '.') }}</h3>
|
||||||
|
<p>Approved Vehicle Running Cost Expenses</p>
|
||||||
|
</div>
|
||||||
|
<div class="icon">
|
||||||
|
<i class="fa fa-car" aria-hidden="true"></i>
|
||||||
|
</div>
|
||||||
|
<a href="{{ route('forms.vehicle') }}" class="small-box-footer text-white">
|
||||||
|
<span class="text-white">More info</span> <i class="fas fa-arrow-circle-right text-white"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-4 col-6">
|
||||||
|
<div class="small-box bg-purple">
|
||||||
|
<div class="inner">
|
||||||
|
<h3>Rp {{ number_format($forms['entertainment'], 0, ',', '.') }}</h3>
|
||||||
|
<p>Approved Entertainment Presentation Expenses</p>
|
||||||
|
</div>
|
||||||
|
<div class="icon">
|
||||||
|
<i class="fa fa-desktop" aria-hidden="true"></i>
|
||||||
|
</div>
|
||||||
|
<a href="{{ route('forms.entertainment') }}" class="small-box-footer">
|
||||||
|
More info <i class="fas fa-arrow-circle-right"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-4 col-6">
|
||||||
|
<div class="small-box bg-danger">
|
||||||
|
<div class="inner">
|
||||||
|
<h3>Rp {{ number_format($forms['meeting'], 0, ',', '.') }}</h3>
|
||||||
|
<p>Approved Meeting Seminar Expenses</p>
|
||||||
|
</div>
|
||||||
|
<div class="icon">
|
||||||
|
<i class="fa fa-desktop" aria-hidden="true"></i>
|
||||||
|
</div>
|
||||||
|
<a href="{{ route('forms.meeting') }}" class="small-box-footer">
|
||||||
|
More info <i class="fas fa-arrow-circle-right"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-4 col-6">
|
||||||
|
<div class="small-box bg-pink">
|
||||||
|
<div class="inner">
|
||||||
|
<h3>Rp {{ number_format($forms['others'], 0, ',', '.') }}</h3>
|
||||||
|
<p>Approved Other Expenses</p>
|
||||||
|
</div>
|
||||||
|
<div class="icon">
|
||||||
|
<i class="fa fa-bars" aria-hidden="true"></i>
|
||||||
|
</div>
|
||||||
|
<a href="{{ route('forms.other') }}" class="small-box-footer">
|
||||||
|
More info <i class="fas fa-arrow-circle-right"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="card card-primary card-outline">
|
<div class="card card-primary card-outline">
|
||||||
<div class="card-body text-center">
|
<div class="card-body text-center">
|
||||||
<p class="lead">Welcome to {{ config('app.name') }} (development version).</p>
|
<p class="lead">Welcome to {{ config('app.name') }} (development version).</p>
|
||||||
|
|||||||
@@ -139,12 +139,3 @@ Route::middleware(['auth:admin', 'menu'])->group(function () {
|
|||||||
Route::get('/auth/menu-tree/{id}', [MenuRoleController::class, 'index'])->name('auth.menurole.index');
|
Route::get('/auth/menu-tree/{id}', [MenuRoleController::class, 'index'])->name('auth.menurole.index');
|
||||||
Route::post('/auth/menu-tree/submit', [MenuRoleController::class, 'saveMenu'])->name('auth.menurole.submit');
|
Route::post('/auth/menu-tree/submit', [MenuRoleController::class, 'saveMenu'])->name('auth.menurole.submit');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get('/test-nextcloud', function () {
|
|
||||||
$baseUrl = env('NEXT_CLOUD_URL');
|
|
||||||
$adminUsername = env('NEXT_CLOUD_USERNAME');
|
|
||||||
$adminPassword = env('NEXT_CLOUD_PASSWORD');
|
|
||||||
|
|
||||||
$response = NextCloudHelper::createFolder($baseUrl, $adminUsername, $adminPassword, 'test-folder');
|
|
||||||
dd($response);
|
|
||||||
});
|
|
||||||
|
|||||||
Reference in New Issue
Block a user