pintu2/resources/views/user/user_roles_index.blade.php

251 lines
10 KiB
PHP
Raw Normal View History

2024-02-27 22:53:57 +07:00
<!-- Extend Layout -->
@extends('layout.app')
<!-- Add Custom CSS -->
@push('css')
<link rel="stylesheet" href="{{asset('/')}}plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
<link rel="stylesheet" href="{{asset('/')}}plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
<link rel="stylesheet" href="{{asset('/')}}plugins/datatables-buttons/css/buttons.bootstrap4.min.css">
@endpush
<!-- Add Content Here -->
@section('content')
<!-- Include Sidebar -->
2024-03-02 18:06:48 +07:00
@include('layout.navbars.sidebar')
2024-02-27 22:53:57 +07:00
<div class="content-wrapper">
<!-- Main content -->
<section class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
2024-03-02 18:06:48 +07:00
<h1>Manajemen User</h1>
2024-02-27 22:53:57 +07:00
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
2024-03-02 18:06:48 +07:00
<li class="breadcrumb-item"><a href="{{ route('admin.dashboard') }}">Admin</a></li>
<li class="breadcrumb-item active">Manajemen User</li>
2024-02-27 22:53:57 +07:00
</ol>
</div>
</div>
</div><!-- /.container-fluid -->
</section>
<section class="content">
<div class="card">
<div class="card-header">
<h3 class="card-title">Title</h3>
<div class="card-tools">
<button type="button" class="btn btn-tool" data-card-widget="collapse" title="Collapse">
<i class="fas fa-minus"></i>
</button>
<button type="button" class="btn btn-tool" data-card-widget="remove" title="Remove">
<i class="fas fa-times"></i>
</button>
</div>
</div>
<div class="card-body">
2024-03-02 18:06:48 +07:00
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error )
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
@if(session('success'))
<div class="alert alert-success">
<ul>
<li>{{ session('success') }}</li>
</ul>
</div>
@endif
@if(session('error'))
<div class="alert alert-danger">
<ul>
<li>{{ session('error') }}</li>
</ul>
</div>
@endif
<button class="btn btn-primary" data-toggle="modal" data-target="#modal-default">Tambah Data</button>
2024-02-27 22:53:57 +07:00
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
2024-03-02 18:06:48 +07:00
<th>No</th>
2024-02-27 22:53:57 +07:00
<th>Nama Role User</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach ($data as $datas)
<tr>
2024-03-02 18:06:48 +07:00
<td>{{ $loop->iteration }}</td>
<td>{{ $datas->name }}</td>
<td class="text-center"><button class="btn btn-success" data-toggle="modal" data-target="#modal{{ $loop->iteration }}">Edit</button> | <button class="btn btn-primary" data-toggle="modal" data-target="#assign{{ $loop->iteration }}">Assign Roles</button>
2024-02-27 22:53:57 +07:00
</tr>
2024-03-02 18:06:48 +07:00
<div class="modal fade" id="modal{{ $loop->iteration }}">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Edit Nama Roles</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col">
<form action="#" method="post">
@csrf
<label for="role_name">Nama Role:</label>
<input type="text" name="role_name" id="role_name" class="form-control" placeholder="Masukkan nama Role" value="{{ $datas->name }}" required>
</div>
<!-- /.col -->
</div>
</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Tambah</button>
</form>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<div class="modal fade" id="assign{{ $loop->iteration }}">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Assign <b>{{ $datas->name }}</b> Ke:</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col">
<form action="{{ route('users-roles.assign')}}" method="post">
@csrf
<input type="hidden" name="roles_user" value="{{ $datas->name }}">
<label class="col-form-label">User: </label>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="checkAll">
<label for="checkAll" class="form-check-label">Check All</label>
</div>
@foreach ($user as $users)
<div class="form-check">
<input type="checkbox" class="itemCheckbox form-check-input" name="checkboxes[]" value="{{$users->id}}">
<label for="{{$users->id}}" class="form-check-label">{{ $users->nama_gelar }}</label>
</div>
@endforeach
</select>
</div>
<!-- /.col -->
</div>
</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Tambah</button>
</form>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
2024-02-27 22:53:57 +07:00
@endforeach
</tbody>
<tfoot>
<tr>
<th>ID</th>
<th>Nama Role User</th>
<th>Action</th>
</tr>
</tfoot>
</table>
</div>
<!-- /.card-body -->
<div class="card-footer">
.
</div>
<!-- /.card-footer-->
</div>
<!-- /.card -->
2024-03-02 18:06:48 +07:00
<!-- /.Modal ADD DATA -->
<div class="modal fade" id="modal-default">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Tambah Data</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col">
<form action="{{ route('users-roles.store') }}" method="post">
@csrf
<label for="role_name">Nama Role:</label>
<input type="text" name="role_name" id="role_name" class="form-control" placeholder="Masukkan nama Role" value="{{ old('role_name')}}" required>
</div>
<!-- /.col -->
</div>
</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Tambah</button>
</form>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
2024-02-27 22:53:57 +07:00
</section>
<!-- /.content -->
</div>
@endsection
<!-- Add Custom JS -->
@push('js')
<!-- DataTables & Plugins -->
<script src="{{asset('/')}}plugins/datatables/jquery.dataTables.min.js"></script>
<script src="{{asset('/')}}plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="{{asset('/')}}plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="{{asset('/')}}plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="{{asset('/')}}plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="{{asset('/')}}plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
<script src="{{asset('/')}}plugins/jszip/jszip.min.js"></script>
<script src="{{asset('/')}}plugins/pdfmake/pdfmake.min.js"></script>
<script src="{{asset('/')}}plugins/pdfmake/vfs_fonts.js"></script>
<script src="{{asset('/')}}plugins/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="{{asset('/')}}plugins/datatables-buttons/js/buttons.print.min.js"></script>
<script src="{{asset('/')}}plugins/datatables-buttons/js/buttons.colVis.min.js"></script>
<!-- Page specific script -->
<script>
$(function () {
$("#example1").DataTable({
"responsive": true, "lengthChange": false, "autoWidth": false,
2024-03-02 18:06:48 +07:00
}).container().appendTo('#example1_wrapper .col-md-6:eq(0)');
//checkAll button
});
const checkAll = document.getElementById('checkAll');
const itemCheckboxes = document.querySelectorAll('.itemCheckbox');
checkAll.addEventListener('change', function() {
for (const checkbox of itemCheckboxes) {
checkbox.checked = this.checked;
}
});
// Optionally, update the "Check All" text based on checked items:
itemCheckboxes.forEach(checkbox => {
checkbox.addEventListener('change', function() {
checkAll.checked = [...itemCheckboxes].every(box => box.checked);
});
2024-02-27 22:53:57 +07:00
});
</script>
@endpush