Merge branch 'dev'

This commit is contained in:
izuddin
2024-03-06 14:24:55 +00:00
4 changed files with 67 additions and 22 deletions
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin;
use App\Models\User;
use App\Models\Role;
use App\Models\Pengaturan;
use App\Models\Roless;
use App\Models\RoleUser;
use Illuminate\Http\Request;
@@ -25,7 +26,8 @@ class MstPenggunaController extends Controller
{
$data = null;
// $data = User::where('role_name', "<>", "superadmin")->latest()->paginate(10);
return view('admin.mst_pengguna.index',compact('data'))
$pengaturan = Pengaturan::where("id",1)->first();
return view('admin.mst_pengguna.index',compact('data', 'pengaturan'))
->with('i', (request()->input('page', 1) - 1) * 10);
}
@@ -171,7 +173,7 @@ class MstPenggunaController extends Controller
->with('success','Lock upload data sudah diubah!');
}
public function lockTambahData($userId="", $reset=0, Request $req)
public function lockTambahData($userId="", $reset=0, $check=0, Request $req)
{
$updateValue = [
"lock_tambah_data"=>$reset == 0 ? 1:0,
@@ -181,6 +183,15 @@ class MstPenggunaController extends Controller
if (empty($userId))
{
if ($check==2){
$updateValue = [
"lock_tambah_data"=>0,
];
Pengaturan::where("id",1)->update(["check_all_tambah"=>0]);
}else{
Pengaturan::where("id",1)->update(["check_all_tambah"=>1]);
}
User::query()->update($updateValue);
}else{
User::where(["id"=>$userId])->update($updateValue);
@@ -191,7 +202,7 @@ class MstPenggunaController extends Controller
}
public function lockUbahData($userId="", $reset=0, Request $req)
public function lockUbahData($userId="", $reset=0, $check=0, Request $req)
{
$updateValue = [
"lock_ubah_data"=>$reset == 0 ? 1:0,
@@ -200,6 +211,14 @@ class MstPenggunaController extends Controller
if (empty($userId))
{
if ($check==2){
$updateValue = [
"lock_ubah_data"=>0,
];
Pengaturan::where("id",1)->update(["check_all_ubah"=>0]);
}else{
Pengaturan::where("id",1)->update(["check_all_ubah"=>1]);
}
User::query()->update($updateValue);
}else{
User::where(["id"=>$userId])->update($updateValue);
@@ -210,7 +229,7 @@ class MstPenggunaController extends Controller
}
public function lockHapusData($userId="", $reset=0, Request $req)
public function lockHapusData($userId="", $reset=0, $check=0, Request $req)
{
$updateValue = [
"lock_hapus_data"=>$reset == 0 ? 1:0,
@@ -219,6 +238,14 @@ class MstPenggunaController extends Controller
if (empty($userId))
{
if ($check==2){
$updateValue = [
"lock_hapus_data"=>0,
];
Pengaturan::where("id",1)->update(["check_all_hapus"=>0]);
}else{
Pengaturan::where("id",1)->update(["check_all_hapus"=>1]);
}
User::query()->update($updateValue);
}else{
User::where(["id"=>$userId])->update($updateValue);
+18
View File
@@ -0,0 +1,18 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\Permission\Traits\HasPermissions;
class Pengaturan extends Model
{
use HasFactory, HasPermissions;
protected $table = 'pengaturan';
protected $fillable = [
'check_all_tambah',
'check_all_hapus',
'check_all_ubah'
];
}
@@ -22,14 +22,6 @@
<div class="card-tools">
<a class="btn btn-tool btn-dark" href="{{ route('users.create') }}"><i class="fa fa-edit"></i> Tambah Data</a>
<!-- <button id="btn_lock_all" type="button" class="btn btn-tool btn-dark"><i class="fa fa-lock"></i> Lock Upload Data</button> -->
<button id="btn_reset_lock_all" type="button" class="btn btn-tool btn-dark"><i class="fa fa-unlock"></i> unLock Upload Data</button>
<!-- <button id="btn_lock_tambah" type="button" class="btn btn-tool btn-dark"><i class="fa fa-lock"></i> Lock Tambah Data</button> -->
<button id="btn_reset_tambah" type="button" class="btn btn-tool btn-dark"><i class="fa fa-unlock"></i> unLock Tambah Data</button>
<!-- <button id="btn_lock_ubah" type="button" class="btn btn-tool btn-dark"><i class="fa fa-lock"></i> Lock Ubah Data</button> -->
<button id="btn_reset_ubah" type="button" class="btn btn-tool btn-dark"><i class="fa fa-unlock"></i> unLock Ubah Data</button>
<button id="btn_lock_hapus" type="button" class="btn btn-tool btn-dark"><i class="fa fa-lock"></i> Lock Hapus Data</button>
<button id="btn_reset_hapus" type="button" class="btn btn-tool btn-dark"><i class="fa fa-unlock"></i> unLock Hapus Data</button>
</div>
</div>
<div class="card-body">
@@ -40,10 +32,10 @@
<th>NRK</th>
<th>Nama</th>
<th>Level</th>
<th><input class="form-check-input" type="checkbox" id="btn_lock_all" >Lock Upload</th>
<th><input class="form-check-input" type="checkbox" id="btn_lock_tambah">Lock Tambah</th>
<th><input class="form-check-input" type="checkbox" id="btn_lock_ubah">Lock Ubah</th>
<th><input class="form-check-input" type="checkbox" id="btn_lock_hapus">Lock Hapus</th>
<th><input class="form-check-input" type="checkbox" id="btn_lock_all" value="1">Lock Upload</th>
<th><input class="form-check-input" type="checkbox" id="btn_lock_tambah" value="1" {{ $pengaturan->check_all_tambah=="1"?"checked":"" }}>Lock Tambah</th>
<th><input class="form-check-input" type="checkbox" id="btn_lock_ubah" value="1" {{ $pengaturan->check_all_ubah=="1"?"checked":"" }}>Lock Ubah</th>
<th><input class="form-check-input" type="checkbox" id="btn_lock_hapus" value="1" {{ $pengaturan->check_all_hapus=="1"?"checked":"" }}>Lock Hapus</th>
<th class="text-center">Action</th>
</thead>
</tr>
@@ -202,6 +194,8 @@
})
});
$("#btn_reset_lock_all").on("click", function(){
let test = Swal.fire({
title: 'Fitur upload data akan direset untuk semua user!?',
@@ -220,6 +214,7 @@
$("#btn_lock_tambah").on("click", function(){
let checkVal = $(this).prop("checked");
let test = Swal.fire({
title: 'Fitur tambah data akan dikunci untuk semua user!?',
showDenyButton: true,
@@ -230,7 +225,8 @@
}).then((result) => {
/* Read more about isConfirmed, isDenied below */
if (result.isConfirmed) {
location.href = "{{ URL::to("/admin/users") }}/lock-tambah-all/0/0";
let val = checkVal == true?1:2;
location.href = "{{ URL::to("/admin/users") }}/lock-tambah-all/0/0/"+val;
}
})
});
@@ -252,6 +248,7 @@
});
$("#btn_lock_ubah").on("click", function(){
let checkVal = $(this).prop("checked");
let test = Swal.fire({
title: 'Fitur ubah data akan dikunci untuk semua user!?',
showDenyButton: true,
@@ -262,7 +259,8 @@
}).then((result) => {
/* Read more about isConfirmed, isDenied below */
if (result.isConfirmed) {
location.href = "{{ URL::to("/admin/users") }}/lock-ubah-all/0/0";
let val = checkVal == true?1:2;
location.href = "{{ URL::to("/admin/users") }}/lock-ubah-all/0/0/"+val;
}
})
});
@@ -284,6 +282,7 @@
});
$("#btn_lock_hapus").on("click", function(){
let checkVal = $(this).prop("checked");
let test = Swal.fire({
title: 'Fitur hapus data akan dikunci untuk semua user!?',
showDenyButton: true,
@@ -294,7 +293,8 @@
}).then((result) => {
/* Read more about isConfirmed, isDenied below */
if (result.isConfirmed) {
location.href = "{{ URL::to("/admin/users") }}/lock-hapus-all/0/0";
let val = checkVal == true?1:2;
location.href = "{{ URL::to("/admin/users") }}/lock-hapus-all/0/0/"+val;
}
})
});
+3 -3
View File
@@ -38,13 +38,13 @@ Route::group(['middleware' => 'auth'], function () {
Route::get('users/{userId}/lock-ubah-data/{type}', [MstPenggunaController::class, 'lockUbahData']);
Route::get('users/{userId}/lock-hapus-data/{type}', [MstPenggunaController::class, 'lockHapusData']);
Route::get('users/lock-tambah-all/{userId}/{reset}', [MstPenggunaController::class, 'lockTambahData']);
Route::get('users/lock-tambah-all/{userId}/{reset}/{check}', [MstPenggunaController::class, 'lockTambahData']);
Route::get('users/{userId}/lock-tambah-all/{reset}', [MstPenggunaController::class, 'lockTambahData']);
Route::get('users/{userId}/lock-ubah/{reset}', [MstPenggunaController::class, 'lockUbahData']);
Route::get('users/lock-ubah-all/{userId}/{reset}', [MstPenggunaController::class, 'lockUbahData']);
Route::get('users/lock-ubah-all/{userId}/{reset}/{check}', [MstPenggunaController::class, 'lockUbahData']);
Route::get('users/lock-hapus-all/{userId}/{reset}', [MstPenggunaController::class, 'lockHapusData']);
Route::get('users/lock-hapus-all/{userId}/{reset}/{check}', [MstPenggunaController::class, 'lockHapusData']);
Route::get('users/{userId}/lock-hapus-all/{reset}', [MstPenggunaController::class, 'lockHapusData']);
Route::get('users/{user}/reset', [MstPenggunaController::class, 'resetPass']);