Commit df864293 by Farendi Giotivano R.P

menu reviewer

parent 2b583998
......@@ -3,7 +3,7 @@
namespace App\Http\Controllers\Operator;
use App\Http\Controllers\Controller;
use App\Models\Admin\Role;
use App\Models\Role;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
......@@ -18,13 +18,14 @@ class UserController extends Controller
*/
public function index()
{
$data['users'] = User::with(['biodata','rolesCustom'])->whereHas('rolesCustom',function ($q){
$q->whereIn('name', ['satuan','verifikator']);
$data['title'] = 'Daftar User';
$data['users'] = User::with(['rBiodata','rolesCustom'])->whereHas('rolesCustom',function ($q){
$q->whereIn('name', ['dosen','reviewer']);
})->get();
$data['roles'] = Role::query()->orderBy('name')->get();
$data['roles'] = Role::whereIn('name', ['reviewer', 'operator'])->orderBy('name')->get();
return view('admin.user.index', $data);
return view('backend.operator.user.index', $data);
}
public function removeRole(Request $request)
......@@ -42,7 +43,7 @@ class UserController extends Controller
$data['user'] = User::query()->find(decrypt($request->user_id));
$data['user']->assignRole($data['role']);
return view('admin.user.row_role', $data);
return view('backend.operator.user.row_role', $data);
}
/**
......
@extends('layouts.master')
@section('title')
Dashboard
@endsection
@section('header')
<div class="page-title">
<h3>Dashboard</h3>
</div>
@endsection
@section('contents')
<!-- start page title -->
<div class="page-title-box">
<div class="row align-items-center">
<div class="col-md-8">
<h6 class="page-title">{!! $title !!}</h6>
<ol class="breadcrumb m-0">
<li class="breadcrumb-item">Dosen</li>
<li class="breadcrumb-item">{!! $title !!}</li>
</ol>
</div>
<div class="col-md-4">
<div class="float-end d-none d-md-block">
</div>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<table id="datatable" class="table table-bordered dt-responsive" style="border-collapse: collapse; border-spacing: 0; width: 100%;">
<thead>
<tr>
<th>No.</th>
<th>Nama</th>
<th>Email</th>
<th>Roles</th>
</tr>
</thead>
<tbody>
@foreach ($users as $item)
@php
$userToken = Str::random(30);
@endphp
<tr>
<td>{{ $loop->iteration }}</td>
<td>
{{ $item->name }} <br>
{{ $item->rBiodata->noidentitas }}
</td>
<td>
{{ $item->email }}
</td>
<td>
@foreach ($item->rolesCustom as $role)
<div id="{{ $userToken }}">
<div class="row mb-2">
<div class="col-md-4">
{{ $role->name }}
</div>
<div class="col-md-6">
<button type="button" onclick="removeRole('{{ encrypt($item->id) }}', '{{ encrypt($role->id) }}', this)" style="padding: 8px" class="btn btn-sm btn-danger"><i class="fa fa-times"></i></button>
</div>
</div>
</div>
@endforeach
<div class="row">
<div class="col-md-7">
<div class="input-group mb-3">
<select class="form-select" name="" id="select_{{ $userToken }}">
@foreach ($roles as $role)
<option value="{{ encrypt($role->id) }}">{{ $role->name }}</option>
@endforeach
</select>
<div class="input-group-append">
<button style="padding: 8px" onclick="addRole('{{ $userToken }}', '{{ encrypt($item->id) }}')" class="btn btn-sm btn-success" type="button">Tambah</button>
</div>
</div>
</div>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div> <!-- end col -->
</div> <!-- end row -->
@endsection
@section('js')
<script src="{{ asset('theme/js/pages/datatables.init.js') }}"></script>
<script>
$("body").on("click", ".delete", function (e) {
e.preventDefault();
var id = $(this).data('id');
Swal.fire({
title: "Apakah Anda Yakin?",
text: "Anda akan menghapus data ini!",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes",
cancelButtonText: "No"
}).then((result) => {
if (result.value) {
Swal.close();
$("#"+id).submit();
} else if (result.dismiss === Swal.DismissReason.cancel) {
Swal.fire('Dibatalkan', 'Data batal dihapus', 'error');
}
});
});
function removeRole(user_id, role_id, element){
var token = "{{ csrf_token() }}";
var request = $.ajax({
url:"{{ route('operator.remove-role') }}",
type:"POST",
dataType:"html",
data:{
user_id:user_id,
role_id:role_id,
_token:token
},
success: function(result){
$(element).parent().parent().remove();
}
})
}
function addRole(user_token, user_id){
var token = "{{ csrf_token() }}";
var role_id = $('#select_'+user_token).val();
var request = $.ajax({
url:"{{ route('operator.add-role') }}",
type:"POST",
dataType:"html",
data:{
user_id:user_id,
role_id:role_id,
_token:token
},
success: function(result){
$('#'+user_token).append(result);
}
})
}
</script>
@endsection
<div class="row mb-2">
<div class="col-md-4">
{{ $role->name }}
</div>
<div class="col-md-6">
<button type="button" onclick="removeRole('{{ encrypt($user->id) }}', '{{ encrypt($role->id) }}', this)" style="padding: 8px" class="btn btn-sm btn-danger"><i class="fa fa-times"></i></button>
</div>
</div>
......@@ -41,11 +41,10 @@
<div class="dropdown d-inline-block">
<button type="button" class="btn header-item waves-effect" id="page-header-user-dropdown" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@if (Auth::user()->roles->first()->name != 'mahasiswa')
<img src="https://siakadu.unesa.ac.id/photo/fotomhs/{{ Auth::user()->rBiodata->noidentitas }}.jpg" alt="Header Avatar" class="rounded-circle header-profile-user" >
<img src="https://siakadu.unesa.ac.id/photo/fotomhs/{{ is_null(Auth::user()->rBiodata) ? '01' : Auth::user()->rBiodata->noidentitas }}.jpg" alt="Header Avatar" class="rounded-circle header-profile-user" >
@else
<img src="https://siakadu.unesa.ac.id/photo/{{ Auth::user()->rBiodata->noidentitas }}.jpg" alt="Header Avatar" class="rounded-circle header-profile-user" >
<img src="https://siakadu.unesa.ac.id/photo/{{ is_null(Auth::user()->rBiodata) ? '01' : Auth::user()->rBiodata->noidentitas }}.jpg" alt="Header Avatar" class="rounded-circle header-profile-user" >
@endif
</button>
......
......@@ -155,6 +155,24 @@
</li>
@endif
@if (Auth::user()->hasrole(['reviewer']))
<li class="menu-title">Menu Reviewer</li>
<li>
<a href="{{ URL::to('/reviewer/seleksi-internal') }}" class="waves-effect"><i class="ti-check"></i><span>Seleksi Internal</span></a>
</li>
<li>
<a href="javascript: void(0);" class="has-arrow waves-effect">
<i class="ti-layers-alt"></i>
<span>Monev Internal</span>
</a>
<ul class="sub-menu" aria-expanded="false">
<li><a href="{{ URL::to('/reviewer/monev/I') }}">Monev Internal I</a></li>
<li><a href="{{ URL::to('/reviewer/monev/II') }}">Monev Internal II</a></li>
<li><a href="{{ URL::to('/reviewer/monev/III') }}">Monev Internal III</a></li>
</ul>
</li>
@endif
</ul>
</div>
<!-- Sidebar -->
......
......@@ -5,7 +5,7 @@ use Illuminate\Support\Facades\Route;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\Operator\JenisController;
use App\Http\Controllers\Operator\UserController;
use App\Http\Controllers\Operator\SelectController;
use App\Http\Controllers\Mahasiswa\AnggotaController;
use App\Http\Controllers\Operator\ReviewerController;
......@@ -167,6 +167,10 @@ Route::group(['middleware' => ['auth:sanctum', 'verified']], function () {
Route::resource('monev-internal-proposal', MonevProposalController::class)->except(['index']);
Route::get('/monev-internal-reviewer-approval/{id}/{status}', [MonevProposalController::class, 'approval'])->name('monev-internal.approval');
Route::get('getMonevProposal', [MonevProposalController::class, 'getData'])->name('getMonevProposal');
Route::resource('user', UserController::class);
Route::post('/user/remove-role', [UserController::class, 'removeRole'])->name('remove-role');
Route::post('/user/add-role', [UserController::class, 'addRole'])->name('add-role');
});
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment