update
parent
7b3c107f7f
commit
dbffa627de
|
|
@ -4,6 +4,7 @@ use Illuminate\Support\Str;
|
|||
use App\Models\Master\Menu;
|
||||
use App\Models\Master\AccessMenu;
|
||||
use App\Models\User;
|
||||
use App\Models\Master\Group;
|
||||
use App\Models\UnitKonversi;
|
||||
use App\Models\GWP;
|
||||
|
||||
|
|
@ -30,6 +31,37 @@ if (!function_exists('taskLabel')) {
|
|||
return $task;
|
||||
}
|
||||
}
|
||||
if (!function_exists('getNameRole')) {
|
||||
/**
|
||||
* @param $request
|
||||
* @param $note
|
||||
*/
|
||||
function getNameRole($id)
|
||||
{
|
||||
$role = Group::find($id);
|
||||
|
||||
return $role->name;
|
||||
}
|
||||
}
|
||||
if (!function_exists('getRoles')) {
|
||||
/**
|
||||
* @param $request
|
||||
* @param $note
|
||||
*/
|
||||
function getRoles()
|
||||
{
|
||||
$user = User::find(auth()->user()->id);
|
||||
if($user->ms_group_id == 1){
|
||||
$role = [];
|
||||
}else{
|
||||
$roleDefault = array($user->ms_group_id);
|
||||
$rolesId = json_decode($user->roles_id);
|
||||
$role = Group::whereIn('MsGroupId',array_unique(array_merge($rolesId,$roleDefault)))->get();
|
||||
}
|
||||
|
||||
return $role;
|
||||
}
|
||||
}
|
||||
if (!function_exists('logActivity')) {
|
||||
/**
|
||||
* @param $request
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Master\AccessMenu;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
|
|
@ -24,6 +25,16 @@ class HomeController extends Controller
|
|||
public function index()
|
||||
{
|
||||
$data['title'] = 'Dashboard';
|
||||
if(session('group_id') == 1){
|
||||
$data['dashboard'] = AccessMenu::with(['parentMenu'])->whereHas('parentMenu',function($query){
|
||||
$query->where('parent_id','!=','0');
|
||||
})->where('module','like','%dashboard%')->get();
|
||||
}else{
|
||||
$data['dashboard'] = AccessMenu::with(['parentMenu'])->whereHas('parentMenu',function($query){
|
||||
$query->where('parent_id','!=','0');
|
||||
})->where('ms_group_id',session('group_id'))->where('module','like','%dashboard%')->get();
|
||||
}
|
||||
|
||||
return view('home',$data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ class UserController extends Controller
|
|||
$user->password = Hash::make($request->password);
|
||||
}
|
||||
$user->name = $request->name;
|
||||
$user->roles_id = json_encode($request->roles_id);
|
||||
$user->save();
|
||||
}else{
|
||||
Validator::make($request->all(), [
|
||||
|
|
@ -133,6 +134,7 @@ class UserController extends Controller
|
|||
$user->password = Hash::make($request->password);
|
||||
}
|
||||
$user->name = $request->name;
|
||||
$user->roles_id = json_encode($request->roles_id);
|
||||
$user->save();
|
||||
}
|
||||
|
||||
|
|
@ -242,4 +244,21 @@ class UserController extends Controller
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function role(Request $request)
|
||||
{
|
||||
if($request->all()){
|
||||
$group = Group::find(decode_id($request->input('id')));
|
||||
$session = [
|
||||
'group_id' => @$group->MsGroupId,
|
||||
'group_alias' => @$group->alias,
|
||||
'group_name' => @$group->name,
|
||||
];
|
||||
//dd($session);
|
||||
session($session);
|
||||
return response()->json(['status' => 1]);
|
||||
} else {
|
||||
return response()->json(['status' => 0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,4 +11,8 @@ class AccessMenu extends Model
|
|||
protected $table = 'ms_access_menu';
|
||||
protected $primaryKey = 'MsAccessMenuId';
|
||||
protected $guarded = [];
|
||||
|
||||
function parentMenu() {
|
||||
return $this->belongsTo(\App\Models\Master\Menu::class,'ms_menu_id','MsMenuId');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->json('roles_id')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -20,49 +20,36 @@
|
|||
<p class="text-muted">di Portal Sistem Informasi Gas Rumah Kaca Provinsi DKI Jakarta.</p>
|
||||
</div>
|
||||
<div class="row mt-5">
|
||||
<div class="col-md-12 col-lg-4 col-xl-4">
|
||||
<a href="{{ url('dashboard/inventory') }}">
|
||||
<div class="card">
|
||||
<img class="card-img img-fluid" src="{{ asset('assets/images/small/img-6.jpg') }}" alt="Card image">
|
||||
<div class="card-img-overlay d-flex flex-column justify-content-center">
|
||||
<h4 class="card-title text-dark">Dashboard Inventory</h4>
|
||||
<p class="card-text text-dark">
|
||||
Dashboard Inventory adalah tampilan ringkas dan interaktif yang menampilkan status inventaris (stok, lokasi, kondisi, alokasi anggaran) secara real-time.
|
||||
</p>
|
||||
@foreach ($dashboard as $datas)
|
||||
<?php
|
||||
$image = '';
|
||||
$text = '';
|
||||
if($datas->parentMenu->title == 'Adaptasi'){
|
||||
$image = 'assets/images/small/img-9.jpg';
|
||||
$text = 'This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.';
|
||||
}elseif($datas->parentMenu->title == 'Mitigasi'){
|
||||
$image = 'assets/images/small/img-8.jpg';
|
||||
$text = 'This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.';
|
||||
}elseif($datas->parentMenu->title == 'Inventory'){
|
||||
$image = 'assets/images/small/img-6.jpg';
|
||||
$text = 'Dashboard Inventory adalah tampilan ringkas dan interaktif yang menampilkan status inventaris (stok, lokasi, kondisi, alokasi anggaran) secara real-time..';
|
||||
}
|
||||
?>
|
||||
<div class="col-md-12 col-lg-4 col-xl-4 mx-auto text-center">
|
||||
<a href="{{ url($datas->parentMenu->url) }}">
|
||||
<div class="card">
|
||||
<img class="card-img img-fluid" src="{{ asset($image) }}" alt="Card image">
|
||||
<div class="card-img-overlay d-flex flex-column justify-content-center">
|
||||
<h4 class="card-title text-dark">Dashboard {{ $datas->parentMenu->title }}</h4>
|
||||
<p class="card-text text-dark">
|
||||
{{ $text }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-4 col-xl-4">
|
||||
<a href="{{ url('dashboard/mitigasi') }}">
|
||||
<div class="card">
|
||||
<img class="card-img img-fluid" src="{{ asset('assets/images/small/img-8.jpg') }}" alt="Card image">
|
||||
<div class="card-img-overlay d-flex flex-column justify-content-center">
|
||||
<h4 class="card-title text-dark">Dashboard Mitigasi</h4>
|
||||
<p class="card-text text-dark">
|
||||
This is a wider card with supporting text below as a
|
||||
natural lead-in to additional content. This content is a little bit
|
||||
longer.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-4 col-xl-4">
|
||||
<a href="{{ url('dashboard/adaptasi') }}">
|
||||
<div class="card">
|
||||
<img class="card-img img-fluid" src="{{ asset('assets/images/small/img-9.jpg') }}" alt="Card image">
|
||||
<div class="card-img-overlay d-flex flex-column justify-content-center">
|
||||
<h4 class="card-title text-dark">Dashboard Adaptasi</h4>
|
||||
<p class="card-text text-dark">
|
||||
This is a wider card with supporting text below as a
|
||||
natural lead-in to additional content. This content is a little bit
|
||||
longer.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<header id="page-topbar" class="isvertical-topbar">
|
||||
<div class="navbar-header">
|
||||
<header id="page-topbar" class="isvertical-topbar bg-white">
|
||||
<div class="navbar-header bg-white">
|
||||
<div class="d-flex">
|
||||
<!-- LOGO -->
|
||||
<div class="navbar-brand-box">
|
||||
<a href="index.php" class="logo logo-dark">
|
||||
<a href="{{ url('/') }}" class="logo logo-dark">
|
||||
<span class="logo-sm">
|
||||
<img src="{{asset('assets/logo-dinas.ico')}}" alt="" height="26">
|
||||
</span>
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
</span>
|
||||
</a>
|
||||
|
||||
<a href="index.php" class="logo logo-light">
|
||||
<a href="{{ url('/') }}" class="logo logo-light">
|
||||
<span class="logo-lg">
|
||||
<img src="{{asset('assets/logo-dinas.ico')}}" alt="" height="30">
|
||||
</span>
|
||||
|
|
@ -27,9 +27,25 @@
|
|||
</button>
|
||||
|
||||
<!-- start page title -->
|
||||
<?php $role = getRoles(); ?>
|
||||
@if(@$role)
|
||||
<div class="page-title-box align-self-center d-none d-md-block">
|
||||
<h4 class="page-title mb-0">{{@$title}}</h4>
|
||||
<div class="d-flex justify-content-center align-items-center gap-3 px-2">
|
||||
<div class="d-flex justify-content-center align-items-center gap-1">
|
||||
<i class="bx bx-user icon nav-icon" style="font-size:16px;"></i>
|
||||
<span>Akses Saat Ini :</span>
|
||||
</div>
|
||||
<div>
|
||||
<select name="role" id="changeRole" class="form-control bg-info border-0 text-white px-2 py-1">
|
||||
@foreach($role as $dataRole)
|
||||
<option {{ $dataRole->MsGroupId == session('group_id') ? 'selected' : '' }} value="{{ encode_id($dataRole->MsGroupId) }}">{{getNameRole($dataRole->MsGroupId)}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{{-- <h4 class="page-title mb-0">{{@$title}}</h4> --}}
|
||||
</div>
|
||||
@endif
|
||||
<!-- end page title -->
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
@include('include.topbar')
|
||||
@include('include.sidebar')
|
||||
<div class="main-content">
|
||||
<div class="page-content">
|
||||
<div class="page-content mt-5">
|
||||
<div class="container-fluid">
|
||||
@yield('content')
|
||||
</div>
|
||||
|
|
@ -87,6 +87,30 @@
|
|||
|
||||
@yield('js')
|
||||
<script>
|
||||
|
||||
$('#changeRole').on('change',function(){
|
||||
var id = $(this).find(':selected').val();
|
||||
request = $.ajax({
|
||||
xhrFields: {
|
||||
withCredentials: true
|
||||
},
|
||||
url: "{!! route('modules.management.user.role') !!}",
|
||||
data: {'id' : id},
|
||||
type: "GET",
|
||||
});
|
||||
|
||||
// Callback handler that will be called on success
|
||||
request.done(function(response, textStatus, jqXHR){
|
||||
alertify.success("Berhasil Menhapus Data");
|
||||
window.location.replace("{{url('dashboard')}}");
|
||||
});
|
||||
|
||||
// Callback handler that will be called on failure
|
||||
request.fail(function (jqXHR, textStatus, errorThrown){
|
||||
alertify.error("Gagal " + textStatus, errorThrown);
|
||||
});
|
||||
|
||||
});
|
||||
$('.select2').select2();
|
||||
@if (Session::get('error'))
|
||||
alertify.error("{{ Session::get('error') }}");
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
<div class="form-group">
|
||||
<label class="col-xl-12 form-label" for="fname">Username</label>
|
||||
<div class="col-12 ">
|
||||
<input type="text" readonly value="{{@$item->username ? @$item->username : old('username')}}" name="username" class="form-control bg-secondary @error('username') is-invalid @enderror" placeholder="Masukan username" required>
|
||||
<input type="text" value="{{@$item->username ? @$item->username : old('username')}}" name="username" class="form-control @error('username') is-invalid @enderror" placeholder="Masukan username" required>
|
||||
@error('username')
|
||||
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
|
||||
@enderror
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
<div class="form-group">
|
||||
<label class="col-xl-12 form-label" for="emailverify">Email</label>
|
||||
<div class="col-12 ">
|
||||
<input type="email" name="email" readonly value="{{@$item->email ? @$item->email : old('email')}}" id="emailverify" class="form-control bg-secondary @error('email') is-invalid @enderror" placeholder="Masukan Email Aktif" required>
|
||||
<input type="email" name="email" value="{{@$item->email ? @$item->email : old('email')}}" id="emailverify" class="form-control @error('email') is-invalid @enderror" placeholder="Masukan Email Aktif" required>
|
||||
@error('email')
|
||||
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
|
||||
@enderror
|
||||
|
|
@ -53,7 +53,7 @@
|
|||
|
||||
<div class="col-12 mb-3">
|
||||
<div class="form-group">
|
||||
<label class="col-xl-12 form-label" for="fname">Role User</label>
|
||||
<label class="col-xl-12 form-label" for="fname">Role User ( Default )</label>
|
||||
<div class="col-12 ">
|
||||
<select name="group" class="form-control @error('group') is-invalid @enderror" required>
|
||||
<option value="">-Pilih Role User-</option>
|
||||
|
|
@ -67,6 +67,27 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 mb-3">
|
||||
<div class="form-group">
|
||||
<label class="col-xl-12 form-label" for="fname">Role User ( Tambahan )</label>
|
||||
<div class="col-12 ">
|
||||
<?php
|
||||
$selected = json_decode(@$item->roles_id);
|
||||
?>
|
||||
<select name="roles_id[]" class="form-control @error('roles_id') is-invalid @enderror select2" multiple required>
|
||||
<option value="">-Pilih Role User-</option>
|
||||
@foreach($group as $data_group)
|
||||
<option {{@$selected ? in_array($data_group->MsGroupId,@$selected) ? 'selected' : '' : ''}} value="{{$data_group->MsGroupId}}">{{$data_group->name}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@error('roles_id')
|
||||
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 mb-3">
|
||||
<div class="form-group">
|
||||
<label class="col-xl-12 form-label">Password Baru</label>
|
||||
|
|
|
|||
|
|
@ -53,53 +53,56 @@ $("#grid-data").on("click", ".forcelogin", function() {
|
|||
var base_url = $(this).attr('data-href');
|
||||
var id = $(this).attr('data-id');
|
||||
Swal.fire({
|
||||
title: "Force Login!",
|
||||
text: "Apa anda yakin ingin login sebagai akun ini ?",
|
||||
type: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#3F7D58",
|
||||
confirmButtonText: "Ya Masuk Sekarang",
|
||||
cancelButtonText: "Tidak",
|
||||
closeOnConfirm: true,
|
||||
closeOnCancel: true
|
||||
},
|
||||
function(isConfirm) {
|
||||
if(isConfirm){
|
||||
title: "Force Login!",
|
||||
text: "Apa anda yakin ingin login sebagai akun ini ?",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#3F7D58",
|
||||
confirmButtonText: "Ya Masuk Sekarang",
|
||||
cancelButtonText: "Tidak",
|
||||
closeOnConfirm: true,
|
||||
closeOnCancel: true
|
||||
}).then((result) => {
|
||||
|
||||
request = $.ajax({
|
||||
url: base_url,
|
||||
type: "GET",
|
||||
xhrFields: {
|
||||
withCredentials: true
|
||||
}
|
||||
});
|
||||
if (result.isConfirmed) {
|
||||
|
||||
// Callback handler that will be called on success
|
||||
request.done(function(response, textStatus, jqXHR){
|
||||
console.log(response);
|
||||
if(response.status == true){
|
||||
toastr.success("Berhasil Login", 'Berhasil!', {positionClass: 'toast-bottom-right', containerId: 'toast-bottom-right'});
|
||||
console.log(response);
|
||||
window.location.href = '{{url("/dashboard")}}';
|
||||
history.pushState(null, null, location.href);
|
||||
window.onpopstate = function () {
|
||||
history.go(1);
|
||||
};
|
||||
}else{
|
||||
toastr.error("Maaf Terjadi Kesalahan", 'Gagal!', {positionClass: 'toast-bottom-right', containerId: 'toast-bottom-right'});
|
||||
console.log(response);
|
||||
}
|
||||
request = $.ajax({
|
||||
url: base_url,
|
||||
type: "GET",
|
||||
xhrFields: {
|
||||
withCredentials: true
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
// Callback handler that will be called on success
|
||||
request.done(function(response, textStatus, jqXHR){
|
||||
console.log(response);
|
||||
if(response.status == true){
|
||||
alertify.success("Berhasil Login", 'Berhasil!', {positionClass: 'toast-bottom-right', containerId: 'toast-bottom-right'});
|
||||
console.log(response);
|
||||
window.location.href = '{{url("/dashboard")}}';
|
||||
history.pushState(null, null, location.href);
|
||||
window.onpopstate = function () {
|
||||
history.go(1);
|
||||
};
|
||||
}else{
|
||||
alertify.error("Maaf Terjadi Kesalahan", 'Gagal!', {positionClass: 'toast-bottom-right', containerId: 'toast-bottom-right'});
|
||||
console.log(response);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Callback handler that will be called on failure
|
||||
request.fail(function (jqXHR, textStatus, errorThrown){
|
||||
alertify.error(
|
||||
"Gagal "+textStatus, errorThrown
|
||||
);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Callback handler that will be called on failure
|
||||
request.fail(function (jqXHR, textStatus, errorThrown){
|
||||
toastr.error(
|
||||
"Gagal "+textStatus, errorThrown
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
$("#grid-data").on("click", ".remove_data", function() {
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ Route::name('management.')->prefix('management')->group(function () {
|
|||
Route::get('update/{id?}',[UserController::class,'update'])->name('update');
|
||||
Route::get('delete/{id?}',[UserController::class,'delete'])->name('delete');
|
||||
Route::get('forcelogin/{id?}',[UserController::class,'forcelogin'])->name('forcelogin');
|
||||
Route::get('role/',[UserController::class,'role'])->name('role');
|
||||
});
|
||||
|
||||
Route::name('role.')->prefix('role')->group(function () {
|
||||
|
|
|
|||
Loading…
Reference in New Issue