added crud data master region & cabang

This commit is contained in:
Jagad R R
2025-01-08 14:12:45 +07:00
parent 1027b0dfb4
commit 314fefd52d
27 changed files with 983 additions and 15 deletions
@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Backend;
use App\Http\Controllers\Controller;
use App\Models\AuditTrail;
use App\Models\FormUpCountry;
use App\Models\FormEntertaimentPresentation;
use App\Models\FormMeetingSeminar;
use App\Models\FormVehicleRunningCost;
use App\Models\FormOthers;
class ReportController extends Controller
{
public function index()
{
return view('backend.pages.report.index', [
]);
}
}
@@ -0,0 +1,104 @@
<?php
namespace App\Http\Controllers\Master;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Cabang;
use App\Helpers\AuditTrailHelper;
use App\Models\Admin;
use App\Models\CostCentre;
use App\Models\Region;
class CabangController extends Controller
{
public function index()
{
$this->checkAuthorization(auth()->user(), ['cabang.view']);
session()->put('redirect_url', route('admin.cabang.index'));
return view('backend.pages.master.cabang.index', [
'cabang' => Cabang::all()
]);
}
public function create()
{
$this->checkAuthorization(auth()->user(), ['cabang.create']);
return view('backend.pages.master.cabang.create', [
'users' => Admin::getUserWhereRoleIsNot('Medical Representatif'),
'cost_centres' => CostCentre::all(),
'regions' => Region::all()
]);
}
public function store(Request $request)
{
$this->checkAuthorization(auth()->user(), ['cabang.create']);
$request->validate([
'head_id' => 'required|exists:admins,id',
'region_id' => 'required|exists:region,id',
'cost_id' => 'required|exists:cost_centre,id',
'code' => 'required|unique:cabang',
'name' => 'required|unique:cabang'
]);
Cabang::create([
'head_id' => $request->head_id,
'region_id' => $request->region_id,
'cost_id' => $request->cost_id,
'code' => $request->code,
'name' => $request->name
]);
AuditTrailHelper::AddAuditTrail('Insert', 'Insert New Record at Cabang Table (' . $request->name . ')');
session()->flash('success', 'Cabang has been added successfully.');
return redirect()->back();
}
public function edit($id)
{
$this->checkAuthorization(auth()->user(), ['cabang.edit']);
return view('backend.pages.master.cabang.edit', [
'cabang' => Cabang::findOrfail($id),
'users' => Admin::getUserWhereRoleIsNot('Medical Representatif'),
'cost_centres' => CostCentre::all(),
'regions' => Region::all()
]);
}
public function update(Request $request, $id)
{
$this->checkAuthorization(auth()->user(), ['cabang.edit']);
$request->validate([
'head_id' => 'required|exists:admins,id',
'region_id' => 'required|exists:region,id',
'cost_id' => 'required|exists:cost_centre,id',
'code' => 'required|unique:cabang,code,' . $id,
'name' => 'required|unique:cabang,name,' . $id
]);
Cabang::findOrfail($id)->update([
'head_id' => $request->head_id,
'region_id' => $request->region_id,
'cost_id' => $request->cost_id,
'code' => $request->code,
'name' => $request->name
]);
AuditTrailHelper::AddAuditTrail('Update', 'Update New Record at Cabang Table (' . $request->name . ')');
session()->flash('success', 'Cabang has been updated successfully.');
return redirect()->back();
}
public function destroy($id)
{
$this->checkAuthorization(auth()->user(), ['cabang.delete']);
$cabang = Cabang::findOrfail($id);
AuditTrailHelper::AddAuditTrail('Delete', 'Delete Record at Cabang Table (' . $cabang->name . ')');
$cabang->delete();
session()->flash('success', 'Cabang has been deleted successfully.');
return redirect()->back();
}
}
@@ -0,0 +1,90 @@
<?php
namespace App\Http\Controllers\Master;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Region;
use App\Helpers\AuditTrailHelper;
use App\Models\Admin;
class RegionController extends Controller
{
public function index()
{
$this->checkAuthorization(auth()->user(), ['region.view']);
session()->put('redirect_url', route('admin.region.index'));
return view('backend.pages.master.region.index', [
'region' => Region::all()
]);
}
public function create()
{
$this->checkAuthorization(auth()->user(), ['region.create']);
return view('backend.pages.master.region.create', [
'users' => Admin::getUserWhereRoleIsNot('Medical Representatif')
]);
}
public function store(Request $request)
{
$this->checkAuthorization(auth()->user(), ['region.create']);
$request->validate([
'head_id' => 'required|exists:admins,id',
'code' => 'required|unique:region',
'name' => 'required|unique:region'
]);
Region::create([
'head_id' => $request->head_id,
'code' => $request->code,
'name' => $request->name
]);
AuditTrailHelper::AddAuditTrail('Insert', 'Insert New Record at Region Table (' . $request->name . ')');
session()->flash('success', 'Region has been added successfully.');
return redirect()->back();
}
public function edit($id)
{
$this->checkAuthorization(auth()->user(), ['region.edit']);
return view('backend.pages.master.region.edit', [
'region' => Region::findOrfail($id),
'users' => Admin::getUserWhereRoleIsNot('Medical Representatif')
]);
}
public function update(Request $request, $id)
{
$this->checkAuthorization(auth()->user(), ['region.edit']);
$request->validate([
'head_id' => 'required|exists:admins,id',
'code' => 'required|unique:region,code,' . $id,
'name' => 'required|unique:region,name,' . $id
]);
Region::findOrfail($id)->update([
'head_id' => $request->head_id,
'code' => $request->code,
'name' => $request->name
]);
AuditTrailHelper::AddAuditTrail('Update', 'Update New Record at Region Table (' . $request->name . ')');
session()->flash('success', 'Region has been updated successfully.');
return redirect()->back();
}
public function destroy($id)
{
$this->checkAuthorization(auth()->user(), ['region.delete']);
$region = Region::findOrfail($id);
AuditTrailHelper::AddAuditTrail('Delete', 'Delete Record at Region Table (' . $region->name . ')');
$region->delete();
session()->flash('success', 'Region has been deleted successfully.');
return redirect()->back();
}
}
+7
View File
@@ -167,4 +167,11 @@ class Admin extends Authenticatable
return []; return [];
} }
public static function getUserWhereRoleIsNot($roleName)
{
return self::whereDoesntHave('roles', function ($query) use ($roleName) {
$query->where('name', $roleName);
})->get();
}
} }
+5
View File
@@ -27,4 +27,9 @@ class Cabang extends Model
{ {
return $this->belongsTo(Region::class, 'region_id'); return $this->belongsTo(Region::class, 'region_id');
} }
public function cost()
{
return $this->belongsTo(CostCentre::class, 'cost_id');
}
} }
+3 -1
View File
@@ -11,6 +11,7 @@ use Database\Seeds\RolePermissionSeeder3;
use Database\Seeds\RolePermissionSeeder4; use Database\Seeds\RolePermissionSeeder4;
use Database\Seeds\RolePermissionSeeder5; use Database\Seeds\RolePermissionSeeder5;
use Database\Seeds\RolePermissionSeeder6; use Database\Seeds\RolePermissionSeeder6;
use Database\Seeds\RolePermissionSeeder7;
class DatabaseSeeder extends Seeder class DatabaseSeeder extends Seeder
{ {
@@ -30,6 +31,7 @@ class DatabaseSeeder extends Seeder
// $this->call(RolePermissionSeeder3::class); // $this->call(RolePermissionSeeder3::class);
// $this->call(RolePermissionSeeder4::class); // $this->call(RolePermissionSeeder4::class);
// $this->call(RolePermissionSeeder5::class); // $this->call(RolePermissionSeeder5::class);
$this->call(RolePermissionSeeder6::class); // $this->call(RolePermissionSeeder6::class);
$this->call(RolePermissionSeeder7::class);
} }
} }
+94
View File
@@ -0,0 +1,94 @@
<?php
namespace Database\Seeds;
use App\Models\Admin;
use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Role;
use Spatie\Permission\Models\Permission;
/**
* Class RolePermissionSeeder.
*
* @see https://spatie.be/docs/laravel-permission/v5/basic-usage/multiple-guards
*
* @package App\Database\Seeds
*/
class RolePermissionSeeder7 extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
/**
* Enable these options if you need same role and other permission for User Model
* Else, please follow the below steps for admin guard
*/
$permissions = [
[
'group_name' => 'region',
'permissions' => [
'region.view',
'region.edit',
'region.create',
'region.delete',
]
],
[
'group_name' => 'cabang',
'permissions' => [
'cabang.view',
'cabang.edit',
'cabang.create',
'cabang.delete',
]
],
];
// Do same for the admin guard for tutorial purposes.
$admin = Admin::where('username', 'superadmin')->first();
$roleSuperAdmin = $this->maybeCreateSuperAdminRole($admin);
// Create and Assign Permissions
for ($i = 0; $i < count($permissions); $i++) {
$permissionGroup = $permissions[$i]['group_name'];
for ($j = 0; $j < count($permissions[$i]['permissions']); $j++) {
$permissionExist = Permission::where('name', $permissions[$i]['permissions'][$j])->first();
if (is_null($permissionExist)) {
$permission = Permission::create(
[
'name' => $permissions[$i]['permissions'][$j],
'group_name' => $permissionGroup,
'guard_name' => 'admin'
]
);
$roleSuperAdmin->givePermissionTo($permission);
$permission->assignRole($roleSuperAdmin);
}
}
}
// Assign super admin role permission to superadmin user
if ($admin) {
$admin->assignRole($roleSuperAdmin);
}
}
private function maybeCreateSuperAdminRole($admin): Role
{
if (is_null($admin)) {
$roleSuperAdmin = Role::create(['name' => 'superadmin', 'guard_name' => 'admin']);
} else {
$roleSuperAdmin = Role::where('name', 'superadmin')->where('guard_name', 'admin')->first();
}
if (is_null($roleSuperAdmin)) {
$roleSuperAdmin = Role::create(['name' => 'superadmin', 'guard_name' => 'admin']);
}
return $roleSuperAdmin;
}
}
@@ -85,6 +85,7 @@
<tr> <tr>
<th>#</th> <th>#</th>
<th>User</th> <th>User</th>
<th>Cabang</th>
<th>Nama Penerima</th> <th>Nama Penerima</th>
<th>Tanggal</th> <th>Tanggal</th>
<th>Jenis</th> <th>Jenis</th>
@@ -112,6 +113,7 @@
<tr> <tr>
<td>{{ $loop->iteration }}</td> <td>{{ $loop->iteration }}</td>
<td>{{ $item->user->name }}</td> <td>{{ $item->user->name }}</td>
<td>{{ $item->user->cabang->cabang->name }}</td>
<td>{{ $item->name }}</td> <td>{{ $item->name }}</td>
<td>{{ \Carbon\Carbon::parse($item->tanggal)->locale('id')->isoFormat('D MMMM Y') }}</td> <td>{{ \Carbon\Carbon::parse($item->tanggal)->locale('id')->isoFormat('D MMMM Y') }}</td>
<td>{{ $item->jenis }}</td> <td>{{ $item->jenis }}</td>
@@ -322,7 +324,7 @@
$('#dataTable').DataTable({ $('#dataTable').DataTable({
responsive: false, responsive: false,
dom: 'Bfrtip', dom: 'Bfrtip',
buttons: ['excel', 'pdf', 'print'] buttons: ['excel', 'pdf', 'print', 'colvis'],
}); });
} }
@@ -86,6 +86,7 @@
<th>#</th> <th>#</th>
<th>No Expense</th> <th>No Expense</th>
<th>Nama</th> <th>Nama</th>
<th>Cabang</th>
<th>Tanggal</th> <th>Tanggal</th>
<th>Allowance</th> <th>Allowance</th>
<th>Transport Ankot</th> <th>Transport Ankot</th>
@@ -113,6 +114,7 @@
<td>{{ $loop->iteration }}</td> <td>{{ $loop->iteration }}</td>
<td>{{ $item->expense_number }}</td> <td>{{ $item->expense_number }}</td>
<td>{{ $item->user->name }}</td> <td>{{ $item->user->name }}</td>
<td>{{ $item->user->cabang->cabang->name }}</td>
<td>{{ \Carbon\Carbon::parse($item->created_at)->locale('id')->isoFormat('D MMMM Y') }}</td> <td>{{ \Carbon\Carbon::parse($item->created_at)->locale('id')->isoFormat('D MMMM Y') }}</td>
<td>{{ number_format($item->allowance, 0, ',', '.') }}</td> <td>{{ number_format($item->allowance, 0, ',', '.') }}</td>
<td>{{ number_format($item->transport_ankot, 0, ',', '.') }}</td> <td>{{ number_format($item->transport_ankot, 0, ',', '.') }}</td>
@@ -324,7 +326,7 @@
$('#dataTable').DataTable({ $('#dataTable').DataTable({
responsive: false, responsive: false,
dom: 'Bfrtip', dom: 'Bfrtip',
buttons: ['excel', 'pdf', 'print'] buttons: ['excel', 'pdf', 'print', 'colvis'],
}); });
} }
@@ -85,6 +85,7 @@
<tr> <tr>
<th>#</th> <th>#</th>
<th>Nama</th> <th>Nama</th>
<th>Cabang</th>
<th>Tanggal</th> <th>Tanggal</th>
<th>Jenis</th> <th>Jenis</th>
<th>Keterangan</th> <th>Keterangan</th>
@@ -110,6 +111,7 @@
<tr> <tr>
<td>{{ $loop->iteration }}</td> <td>{{ $loop->iteration }}</td>
<td>{{ $item->user->name }}</td> <td>{{ $item->user->name }}</td>
<td>{{ $item->user->cabang->cabang->name }}</td>
<td>{{ \Carbon\Carbon::parse($item->tanggal)->locale('id')->isoFormat('D MMMM Y') }}</td> <td>{{ \Carbon\Carbon::parse($item->tanggal)->locale('id')->isoFormat('D MMMM Y') }}</td>
<td>{{ $item->kategori->name }}</td> <td>{{ $item->kategori->name }}</td>
<td>{{ $item->keterangan }}</td> <td>{{ $item->keterangan }}</td>
@@ -309,7 +311,7 @@
$('#dataTable').DataTable({ $('#dataTable').DataTable({
responsive: false, responsive: false,
dom: 'Bfrtip', dom: 'Bfrtip',
buttons: ['excel', 'pdf', 'print'] buttons: ['excel', 'pdf', 'print', 'colvis'],
}); });
} }
@@ -86,6 +86,7 @@
<th>#</th> <th>#</th>
<th>No Expense</th> <th>No Expense</th>
<th>Nama</th> <th>Nama</th>
<th>Cabang</th>
<th>Rayon</th> <th>Rayon</th>
<th>Tanggal</th> <th>Tanggal</th>
<th>Tujuan</th> <th>Tujuan</th>
@@ -113,6 +114,7 @@
<td>{{ $loop->iteration }}</td> <td>{{ $loop->iteration }}</td>
<td>{{ $item->expense_number }}</td> <td>{{ $item->expense_number }}</td>
<td>{{ $item->user->name }}</td> <td>{{ $item->user->name }}</td>
<td>{{ $item->user->cabang->cabang->name }}</td>
<td>{{ $item->rayon->code }}</td> <td>{{ $item->rayon->code }}</td>
<td>{{ \Carbon\Carbon::parse($item->tanggal)->locale('id')->isoFormat('D MMMM Y') }}</td> <td>{{ \Carbon\Carbon::parse($item->tanggal)->locale('id')->isoFormat('D MMMM Y') }}</td>
<td>{{ $item->tujuan }}</td> <td>{{ $item->tujuan }}</td>
@@ -350,7 +352,7 @@
$('#dataTable').DataTable({ $('#dataTable').DataTable({
responsive: false, responsive: false,
dom: 'Bfrtip', dom: 'Bfrtip',
buttons: ['excel', 'pdf', 'print'] buttons: ['excel', 'pdf', 'print', 'colvis'],
}); });
} }
@@ -85,6 +85,7 @@
<tr> <tr>
<th>#</th> <th>#</th>
<th>Nama</th> <th>Nama</th>
<th>Cabang</th>
<th>Tanggal</th> <th>Tanggal</th>
<th>Liter</th> <th>Liter</th>
<th>Total</th> <th>Total</th>
@@ -113,6 +114,7 @@
<tr> <tr>
<td>{{ $loop->iteration }}</td> <td>{{ $loop->iteration }}</td>
<td>{{ $item->user->name }}</td> <td>{{ $item->user->name }}</td>
<td>{{ $item->user->cabang->cabang->name }}</td>
<td>{{ \Carbon\Carbon::parse($item->tanggal)->locale('id')->isoFormat('dddd, D MMMM Y HH:mm:ss') }}</td> <td>{{ \Carbon\Carbon::parse($item->tanggal)->locale('id')->isoFormat('dddd, D MMMM Y HH:mm:ss') }}</td>
<td>{{ $item->liter }}</td> <td>{{ $item->liter }}</td>
<td>{{ number_format($item->total, 0, ',', '.') }}</td> <td>{{ number_format($item->total, 0, ',', '.') }}</td>
@@ -327,7 +329,7 @@
$('#dataTable').DataTable({ $('#dataTable').DataTable({
responsive: false, responsive: false,
dom: 'Bfrtip', dom: 'Bfrtip',
buttons: ['excel', 'pdf', 'print'] buttons: ['excel', 'pdf', 'print', 'colvis'],
}); });
} }
@@ -0,0 +1,71 @@
@extends('layouts.app')
@section('title')
Dashboard
@endsection
@section('admin-content')
<section class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1>Tambahkan Cabang Baru</h1>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="{{ route('dashboard.index') }}">Dashboard</a></li>
</li>
</ol>
</div>
</div>
</div>
</section>
<section class="content">
<div class="container-fluid">
<div class="card card-primary card-outline">
<div class="card-body">
<form method="POST" action="{{ route('admin.cabang.store') }}">
@csrf
@include('backend.layouts.partials.messages')
<div class="mb-3">
<label class="form-label">Pilih Kepala Cabang</label>
<select class="form-control" name="head_id">
<option value="">Pilih Kepala Cabang</option>
@foreach ($users as $user)
<option value="{{ $user->id }}">{{ $user->name }} | {{ $user->email }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label class="form-label">Pilih Induk Region</label>
<select class="form-control" name="region_id">
<option value="">Pilih Region</option>
@foreach ($regions as $item)
<option value="{{ $item->id }}">{{ $item->code }} | {{ $item->name }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label class="form-label">Pilih Cost Centre</label>
<select class="form-control" name="cost_id">
<option value="">Pilih Cost Centre</option>
@foreach ($cost_centres as $item)
<option value="{{ $item->id }}">{{ $item->code }} | {{ $item->name }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label class="form-label">Code Cabang</label>
<input type="text" class="form-control" name="code">
</div>
<div class="mb-3">
<label class="form-label">Nama Cabang</label>
<input type="text" class="form-control" name="name">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
</div>
</section>
@endsection
@@ -0,0 +1,72 @@
@extends('layouts.app')
@section('title')
Dashboard
@endsection
@section('admin-content')
<section class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1>Edit Cabang</h1>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="{{ route('dashboard.index') }}">Dashboard</a></li>
</li>
</ol>
</div>
</div>
</div>
</section>
<section class="content">
<div class="container-fluid">
<div class="card card-primary card-outline">
<div class="card-body">
<form method="POST" action="{{ route('admin.cabang.update', $cabang->id) }}">
@csrf
@method('PUT')
@include('backend.layouts.partials.messages')
<div class="mb-3">
<label class="form-label">Pilih Kepala Cabang</label>
<select class="form-control" name="head_id">
<option value="">Pilih Kepala Cabang</option>
@foreach ($users as $user)
<option value="{{ $user->id }}" {{ $cabang->head_id == $user->id ? 'selected' : '' }}>{{ $user->name }} | {{ $user->email }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label class="form-label">Pilih Induk Region</label>
<select class="form-control" name="region_id">
<option value="">Pilih Region</option>
@foreach ($regions as $item)
<option value="{{ $item->id }}" {{ $cabang->region_id == $item->id ? 'selected' : '' }}>{{ $item->code }} | {{ $item->name }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label class="form-label">Pilih Cost Centre</label>
<select class="form-control" name="cost_id">
<option value="">Pilih Cost Centre</option>
@foreach ($cost_centres as $item)
<option value="{{ $item->id }}" {{ $cabang->cost_id == $item->id ? 'selected' : '' }}>{{ $item->code }} | {{ $item->name }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label class="form-label">Code Cabang</label>
<input type="text" class="form-control" name="code" value="{{ $cabang->code }}">
</div>
<div class="mb-3">
<label class="form-label">Nama Cabang</label>
<input type="text" class="form-control" name="name" value="{{ $cabang->name }}">
</div>
<button type="submit" class="btn btn-primary">Save</button>
</form>
</div>
</div>
</div>
</section>
@endsection
@@ -0,0 +1,108 @@
@extends('layouts.app')
@section('title')
Dashboard
@endsection
@section('admin-content')
<section class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1>Data Master Cabang</h1>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="{{ route('dashboard.index') }}">Dashboard</a></li>
</li>
</ol>
</div>
</div>
</div>
</section>
<section class="content">
<div class="container-fluid">
<div class="card card-primary card-outline">
<div class="card-body">
<h4 class="header-title float-left">List Data Cabang</h4>
<p class="float-right mb-2">
@if (Auth::user()->can('cabang.create'))
<a class="btn btn-primary text-white" href="{{ route('admin.cabang.create') }}">
Add New Cabang
</a>
@endif
</p>
<div class="clearfix"></div>
<div class="dataTables_wrapper dt-bootstrap4 mt-2">
@include('backend.layouts.partials.messages')
<div class="table-responsive">
<table id="dataTable"
class="table table-bordered table-striped table-head-fixed dataTable dtr-inline"
style="width:100%">
<thead class="bg-light text-capitalize">
<tr>
<th>#</th>
<th>Nama Kepala Cabang</th>
<th>Email Kepala Cabang</th>
<th>Region</th>
<th>Code</th>
<th>Nama</th>
<th>Cost Centre</th>
<th>Aksi</th>
</tr>
</thead>
<tbody>
@foreach ($cabang as $item)
<tr>
<td>{{ $loop->index + 1 }}</td>
<td>{{ $item->head->name }}</td>
<td>{{ $item->head->email }}</td>
<td>{{ $item->region->name }}</td>
<td>{{ $item->code }}</td>
<td>{{ $item->name }}</td>
<td>{{ $item->cost->name }} ({{ $item->cost->code }})</td>
<td>
@if (auth()->user()->can('cabang.edit'))
<a class="btn btn-success btn-sm text-white" href="{{ route('admin.cabang.edit', $item->id) }}">Edit</a>
@endif
@if (auth()->user()->can('cabang.delete'))
<a class="btn btn-danger text-white btn-sm" href="javascript:void(0);"
onclick="event.preventDefault(); if(confirm('Are you sure you want to delete?')) { document.getElementById('delete-form-{{ $item->id }}').submit(); }">
{{ __('Delete') }}
</a>
<form id="delete-form-{{ $item->id }}"
action="{{ route('admin.cabang.destroy', $item->id) }}"
method="POST" style="display: none;">
@method('DELETE')
@csrf
</form>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</section>
@endsection
@section('scripts')
<script>
$(document).ready(function () {
if ($('#dataTable').length) {
$('#dataTable').DataTable({
responsive: true,
dom: 'Bfrtip',
buttons: [
'excel', 'pdf', 'print'
]
});
}
});
</script>
@endsection
@@ -37,7 +37,7 @@
<label class="form-label">Account Number</label> <label class="form-label">Account Number</label>
<input type="text" class="form-control" name="account_number" value="{{ $category->account_number }}"> <input type="text" class="form-control" name="account_number" value="{{ $category->account_number }}">
</div> </div>
<button type="submit" class="btn btn-primary">Submit</button> <button type="submit" class="btn btn-primary">Save</button>
</form> </form>
</div> </div>
</div> </div>
@@ -54,10 +54,10 @@
<td>{{ $category->name }}</td> <td>{{ $category->name }}</td>
<td>{{ $category->account_number }}</td> <td>{{ $category->account_number }}</td>
<td> <td>
@if (auth()->user()->can('admin.edit')) @if (auth()->user()->can('category.edit'))
<a class="btn btn-success btn-sm text-white" href="{{ route('admin.category.edit', $category->id) }}">Edit</a> <a class="btn btn-success btn-sm text-white" href="{{ route('admin.category.edit', $category->id) }}">Edit</a>
@endif @endif
@if (auth()->user()->can('admin.delete')) @if (auth()->user()->can('category.delete'))
<a class="btn btn-danger text-white btn-sm" href="javascript:void(0);" <a class="btn btn-danger text-white btn-sm" href="javascript:void(0);"
onclick="event.preventDefault(); if(confirm('Are you sure you want to delete?')) { document.getElementById('delete-form-{{ $category->id }}').submit(); }"> onclick="event.preventDefault(); if(confirm('Are you sure you want to delete?')) { document.getElementById('delete-form-{{ $category->id }}').submit(); }">
{{ __('Delete') }} {{ __('Delete') }}
@@ -37,7 +37,7 @@
<label class="form-label">Nama Cost Centre</label> <label class="form-label">Nama Cost Centre</label>
<input type="text" class="form-control" name="name" value="{{ $cost->name }}"> <input type="text" class="form-control" name="name" value="{{ $cost->name }}">
</div> </div>
<button type="submit" class="btn btn-primary">Submit</button> <button type="submit" class="btn btn-primary">Save</button>
</form> </form>
</div> </div>
</div> </div>
@@ -54,10 +54,10 @@
<td>{{ $cost->code }}</td> <td>{{ $cost->code }}</td>
<td>{{ $cost->name }}</td> <td>{{ $cost->name }}</td>
<td> <td>
@if (auth()->user()->can('admin.edit')) @if (auth()->user()->can('cost.edit'))
<a class="btn btn-success btn-sm text-white" href="{{ route('admin.cost.edit', $cost->id) }}">Edit</a> <a class="btn btn-success btn-sm text-white" href="{{ route('admin.cost.edit', $cost->id) }}">Edit</a>
@endif @endif
@if (auth()->user()->can('admin.delete')) @if (auth()->user()->can('cost.delete'))
<a class="btn btn-danger text-white btn-sm" href="javascript:void(0);" <a class="btn btn-danger text-white btn-sm" href="javascript:void(0);"
onclick="event.preventDefault(); if(confirm('Are you sure you want to delete?')) { document.getElementById('delete-form-{{ $cost->id }}').submit(); }"> onclick="event.preventDefault(); if(confirm('Are you sure you want to delete?')) { document.getElementById('delete-form-{{ $cost->id }}').submit(); }">
{{ __('Delete') }} {{ __('Delete') }}
@@ -36,7 +36,7 @@
<label class="form-label">Nama Rayon</label> <label class="form-label">Nama Rayon</label>
<input type="text" class="form-control" name="name" value="{{ $rayon->name }}"> <input type="text" class="form-control" name="name" value="{{ $rayon->name }}">
</div> </div>
<button type="submit" class="btn btn-primary">Submit</button> <button type="submit" class="btn btn-primary">Save</button>
</form> </form>
</div> </div>
</div> </div>
@@ -54,10 +54,10 @@
<td>{{ $rayon->code }}</td> <td>{{ $rayon->code }}</td>
<td>{{ $rayon->name }}</td> <td>{{ $rayon->name }}</td>
<td> <td>
@if (auth()->user()->can('admin.edit')) @if (auth()->user()->can('rayon.edit'))
<a class="btn btn-success btn-sm text-white" href="{{ route('admin.rayon.edit', $rayon->id) }}">Edit</a> <a class="btn btn-success btn-sm text-white" href="{{ route('admin.rayon.edit', $rayon->id) }}">Edit</a>
@endif @endif
@if (auth()->user()->can('admin.delete')) @if (auth()->user()->can('rayon.delete'))
<a class="btn btn-danger text-white btn-sm" href="javascript:void(0);" <a class="btn btn-danger text-white btn-sm" href="javascript:void(0);"
onclick="event.preventDefault(); if(confirm('Are you sure you want to delete?')) { document.getElementById('delete-form-{{ $rayon->id }}').submit(); }"> onclick="event.preventDefault(); if(confirm('Are you sure you want to delete?')) { document.getElementById('delete-form-{{ $rayon->id }}').submit(); }">
{{ __('Delete') }} {{ __('Delete') }}
@@ -0,0 +1,53 @@
@extends('layouts.app')
@section('title')
Dashboard
@endsection
@section('admin-content')
<section class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1>Tambahkan Region Baru</h1>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="{{ route('dashboard.index') }}">Dashboard</a></li>
</li>
</ol>
</div>
</div>
</div>
</section>
<section class="content">
<div class="container-fluid">
<div class="card card-primary card-outline">
<div class="card-body">
<form method="POST" action="{{ route('admin.region.store') }}">
@csrf
@include('backend.layouts.partials.messages')
<div class="mb-3">
<label class="form-label">Pilih Kepala Region</label>
<select class="form-control" name="head_id">
<option value="">Pilih Kepala Region</option>
@foreach ($users as $user)
<option value="{{ $user->id }}">{{ $user->name }} | {{ $user->email }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label class="form-label">Code Region</label>
<input type="text" class="form-control" name="code">
</div>
<div class="mb-3">
<label class="form-label">Nama Region</label>
<input type="text" class="form-control" name="name">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
</div>
</section>
@endsection
@@ -0,0 +1,54 @@
@extends('layouts.app')
@section('title')
Dashboard
@endsection
@section('admin-content')
<section class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1>Edit Region</h1>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="{{ route('dashboard.index') }}">Dashboard</a></li>
</li>
</ol>
</div>
</div>
</div>
</section>
<section class="content">
<div class="container-fluid">
<div class="card card-primary card-outline">
<div class="card-body">
<form method="POST" action="{{ route('admin.region.update', $region->id) }}">
@csrf
@method('PUT')
@include('backend.layouts.partials.messages')
<div class="mb-3">
<label class="form-label">Pilih Kepala Region</label>
<select class="form-control" name="head_id">
<option value="">Pilih Kepala Region</option>
@foreach ($users as $user)
<option value="{{ $user->id }}" {{ $region->head_id == $user->id ? 'selected' : '' }}>{{ $user->name }} | {{ $user->email }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label class="form-label">Code Region</label>
<input type="text" class="form-control" name="code" value="{{ $region->code }}">
</div>
<div class="mb-3">
<label class="form-label">Nama Region</label>
<input type="text" class="form-control" name="name" value="{{ $region->name }}">
</div>
<button type="submit" class="btn btn-primary">Save</button>
</form>
</div>
</div>
</div>
</section>
@endsection
@@ -0,0 +1,104 @@
@extends('layouts.app')
@section('title')
Dashboard
@endsection
@section('admin-content')
<section class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1>Data Master Region</h1>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="{{ route('dashboard.index') }}">Dashboard</a></li>
</li>
</ol>
</div>
</div>
</div>
</section>
<section class="content">
<div class="container-fluid">
<div class="card card-primary card-outline">
<div class="card-body">
<h4 class="header-title float-left">List Data Region</h4>
<p class="float-right mb-2">
@if (Auth::user()->can('region.create'))
<a class="btn btn-primary text-white" href="{{ route('admin.region.create') }}">
Add New Region
</a>
@endif
</p>
<div class="clearfix"></div>
<div class="dataTables_wrapper dt-bootstrap4 mt-2">
@include('backend.layouts.partials.messages')
<div class="table-responsive">
<table id="dataTable"
class="table table-bordered table-striped table-head-fixed dataTable dtr-inline"
style="width:100%">
<thead class="bg-light text-capitalize">
<tr>
<th>#</th>
<th>Nama Kepala Region</th>
<th>Email Kepala Region</th>
<th>Code</th>
<th>Nama</th>
<th>Aksi</th>
</tr>
</thead>
<tbody>
@foreach ($region as $item)
<tr>
<td>{{ $loop->index + 1 }}</td>
<td>{{ $item->head->name }}</td>
<td>{{ $item->head->email }}</td>
<td>{{ $item->code }}</td>
<td>{{ $item->name }}</td>
<td>
@if (auth()->user()->can('region.edit'))
<a class="btn btn-success btn-sm text-white" href="{{ route('admin.region.edit', $item->id) }}">Edit</a>
@endif
@if (auth()->user()->can('region.delete'))
<a class="btn btn-danger text-white btn-sm" href="javascript:void(0);"
onclick="event.preventDefault(); if(confirm('Are you sure you want to delete?')) { document.getElementById('delete-form-{{ $item->id }}').submit(); }">
{{ __('Delete') }}
</a>
<form id="delete-form-{{ $item->id }}"
action="{{ route('admin.region.destroy', $item->id) }}"
method="POST" style="display: none;">
@method('DELETE')
@csrf
</form>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</section>
@endsection
@section('scripts')
<script>
$(document).ready(function () {
if ($('#dataTable').length) {
$('#dataTable').DataTable({
responsive: true,
dom: 'Bfrtip',
buttons: [
'excel', 'pdf', 'print'
]
});
}
});
</script>
@endsection
@@ -0,0 +1,143 @@
@extends('layouts.app')
@section('title')
Dashboard
@endsection
@section('admin-content')
<section class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1>Active Budgets</h1>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="{{ route('dashboard.index') }}">Dashboard</a></li>
</li>
</ol>
</div>
</div>
</div>
</section>
<section class="content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-4 col-6">
<div class="small-box bg-info">
<div class="inner">
<h3>Rp {{ number_format(2000000, 0, ',', '.') }}</h3>
<p>Total Budget Bulan Ini</p>
</div>
<div class="icon">
<i class="fas fa-wallet"></i>
</div>
</div>
</div>
<div class="col-lg-4 col-6">
<div class="small-box bg-success">
<div class="inner">
<h3>Rp {{ number_format(2000000, 0, ',', '.') }}</h3>
<p>Total Budget Tersedia</p>
</div>
<div class="icon">
<i class="fas fa-check-circle"></i>
</div>
</div>
</div>
<div class="col-lg-4 col-6">
<div class="small-box bg-danger">
<div class="inner">
<h3 class="text-white">Rp {{ number_format(2000000, 0, ',', '.') }}</h3>
<p class="text-white">Total Budget Terpakai</p>
</div>
<div class="icon">
<i class="fas fa-times"></i>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="content">
<div class="container-fluid">
<div class="card card-primary card-outline">
<div class="card-body">
<h4 class="header-title float-left">Current Active Budget</h4>
<div class="clearfix"></div>
<div class="dataTables_wrapper dt-bootstrap4 mt-2">
@include('backend.layouts.partials.messages')
<div class="table-responsive">
<table id="dataTable"
class="table table-bordered table-striped table-head-fixed dataTable dtr-inline"
style="width:100%">
<thead class="bg-light text-capitalize">
<tr>
<th>#</th>
<th>Penerima</th>
<th>Cabang</th>
<th>Pengirim</th>
<th>Total</th>
<th>Keterangan</th>
<th>Periode</th>
<th>Tanggal Closing</th>
<th>Status</th>
<th>Aksi</th>
</tr>
</thead>
<tbody>
@foreach ($data as $item)
<tr>
<td>{{ $loop->iteration }}</td>
<td>{{ $item->receiver->name }}</td>
<td>{{ $item->cabang->name }}</td>
<td>{{ $item->sender->name }}</td>
<td>{{ number_format($item->amount, 0, ',', '.') }}</td>
<td>{{ $item->remarks }}</td>
<td>{{ strtoupper($item->periode_month) }} {{ $item->periode_year }}</td>
<td>{{ \Carbon\Carbon::parse($item->closing_at)->locale('id')->isoFormat('D MMMM Y H:mm') }}</td>
<td>
@if ($item->status == 'Unassigned')
<span class="badge badge-warning text-white">{{ $item->status }}</span>
@elseif ($item->status == 'Assigned')
<span class="badge badge-success text-white">{{ $item->status }}</span>
@else
<span class="badge badge-danger text-white">{{ $item->status }}</span>
@endif
</td>
<td>
@if (auth()->user()->can('budget_control.delete'))
<form action="{{ route('budget_control.destroy', $item->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to delete this item?');">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger btn-sm">
<i class="fas fa-trash"></i>
</button>
</form>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</section>
@endsection
@section('scripts')
<script>
$(document).ready(function () {
if ($('#dataTable').length) {
$('#dataTable').DataTable({
responsive: false,
dom: 'Bfrtip',
buttons: ['excel', 'pdf', 'print']
});
}
});
</script>
@endsection
@@ -89,4 +89,9 @@
margin-bottom: 15px; /* Adjust the value as needed */ margin-bottom: 15px; /* Adjust the value as needed */
margin-right: 20px; margin-right: 20px;
} }
.dt-search {
float: right;
text-align: right;
}
</style> </style>
+23
View File
@@ -18,6 +18,9 @@ use App\Http\Controllers\Forms\FormMeetingSeminarController;
use App\Http\Controllers\Forms\FormOtherController; use App\Http\Controllers\Forms\FormOtherController;
use App\Http\Controllers\Backend\AuditTrailController; use App\Http\Controllers\Backend\AuditTrailController;
use App\Http\Controllers\Backend\BudgetControlController; use App\Http\Controllers\Backend\BudgetControlController;
use App\Http\Controllers\Backend\ReportController;
use App\Http\Controllers\Master\RegionController;
use App\Http\Controllers\Master\CabangController;
Auth::routes(); Auth::routes();
@@ -63,6 +66,22 @@ Route::group(['prefix' => 'admin', 'as' => 'admin.', 'middleware' => ['auth:admi
Route::put('/category/update/{id}', [CategoryController::class, 'update'])->name('category.update'); Route::put('/category/update/{id}', [CategoryController::class, 'update'])->name('category.update');
Route::delete('/category/destroy/{id}', [CategoryController::class, 'destroy'])->name('category.destroy'); Route::delete('/category/destroy/{id}', [CategoryController::class, 'destroy'])->name('category.destroy');
// Region
Route::get('/region', [RegionController::class, 'index'])->name('region.index');
Route::get('/region/create', [RegionController::class, 'create'])->name('region.create');
Route::post('/region/store', [RegionController::class, 'store'])->name('region.store');
Route::get('/region/edit/{id}', [RegionController::class, 'edit'])->name('region.edit');
Route::put('/region/update/{id}', [RegionController::class, 'update'])->name('region.update');
Route::delete('/region/destroy/{id}', [RegionController::class, 'destroy'])->name('region.destroy');
// Cabang
Route::get('/cabang', [CabangController::class, 'index'])->name('cabang.index');
Route::get('/cabang/create', [CabangController::class, 'create'])->name('cabang.create');
Route::post('/cabang/store', [CabangController::class, 'store'])->name('cabang.store');
Route::get('/cabang/edit/{id}', [CabangController::class, 'edit'])->name('cabang.edit');
Route::put('/cabang/update/{id}', [CabangController::class, 'update'])->name('cabang.update');
Route::delete('/cabang/destroy/{id}', [CabangController::class, 'destroy'])->name('cabang.destroy');
// Audit Trail // Audit Trail
Route::get('/audit-trails', [AuditTrailController::class, 'index'])->name('audit-trail.index'); Route::get('/audit-trails', [AuditTrailController::class, 'index'])->name('audit-trail.index');
@@ -83,6 +102,10 @@ Route::middleware(['auth:admin', 'menu'])->group(function () {
Route::delete('/destroy/{id}', [BudgetControlController::class, 'destroy'])->name('budget_control.destroy'); Route::delete('/destroy/{id}', [BudgetControlController::class, 'destroy'])->name('budget_control.destroy');
}); });
Route::prefix('reports')->group(function () {
Route::get('/', [ReportController::class, 'index'])->name('reports');
});
// Forms // Forms
Route::prefix('forms')->group(function () { Route::prefix('forms')->group(function () {
// Up Country // Up Country