150 lines
5.6 KiB
PHP
150 lines
5.6 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('content')
|
|
<div class="container">
|
|
<div class="row justify-content-center">
|
|
<div class="col-md-8">
|
|
@if ($message = Session::get('success'))
|
|
<div class="alert alert-success">
|
|
<p>{{ $message }}</p>
|
|
</div>
|
|
@endif
|
|
<form action="{{ route('pengguna.store') }}" method="POST" id="formpengguna">
|
|
@csrf
|
|
<div class="form-row">
|
|
<div class="form-group col-md-6">
|
|
<label for="inputEmail4">Nama</label>
|
|
<input type="text" value="{{$user->name}}" class="form-control" name="name" id="inputText" readonly>
|
|
</div>
|
|
<div class="form-group col-md-6">
|
|
<label for="inputPassword4">Emel</label>
|
|
<input type="email" value="{{$user->email}}" class="form-control" name="emel" id="inputEmail4" readonly>
|
|
</div>
|
|
</div>
|
|
<div class="form-row">
|
|
<h4 class="col-md-3">Taraf Pengguna</h4>
|
|
<div class="form-group col-md-9">
|
|
@foreach ($allroles as $namataraf)
|
|
<div class="col-4 form-check form-check-inline">
|
|
<input class="form-check-input" name="taraf{{$namataraf}}" type="checkbox" id="taraf{{$namataraf}}" value="{{$namataraf}}" @if (in_array($namataraf,$userroles)) checked @endif>
|
|
{{-- <input type="hidden" id="alltaraf" value=""> --}}
|
|
<label class="form-check-label" for="taraf{{$namataraf}}">{{$namataraf}}</label>
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
@if($user->user_type == 1)
|
|
<div class="d-flex form-group">
|
|
<div class="d-flex col-md-6">
|
|
<div style="margin-right:2%;">
|
|
<label for="status1">Status</label>
|
|
</div>
|
|
<div class="custom-control custom-switch" >
|
|
<input type="checkbox" class="custom-control-input" name="status" id="customSwitch1" onchange="showstatus(this)">
|
|
<label class="custom-control-label" for="customSwitch1" data-status="{{ $user->status }}" id="txtstatus"></lable>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endif
|
|
<div class="text-right pt-4">
|
|
<input type="hidden" name="userid" value="{{$user->id}}">
|
|
<a href="{{url('pengguna/listpengguna')}}" class="btn btn-primary">Kembali</a>
|
|
<button type="button" class="btn btn-warning" onclick="confirm()">Simpan</button>
|
|
</div>
|
|
|
|
</form>
|
|
{{-- <button class="btn btn-primary" onclick="confirm()">Simpan</button> --}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
function confirm() {
|
|
$.confirm({
|
|
title: 'Confirmation',
|
|
content: 'Anda pasti?',
|
|
type: 'orange',
|
|
typeAnimated: true,
|
|
buttons: {
|
|
Simpan: {
|
|
btnClass: 'btn-warning',
|
|
action: function () {
|
|
$("#formpengguna").submit();
|
|
}
|
|
},
|
|
Batal: {
|
|
btnClass: 'btn-default',
|
|
action: function () {}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
var status = $('#txtstatus').data('status');
|
|
|
|
console.log(status);
|
|
if(status == 'active'){
|
|
$('#customSwitch1').prop('checked',true) ;
|
|
$('#customSwitch2').prop('checked',false) ;
|
|
$('#txtstatus').text('Active');
|
|
}
|
|
else if(status == 'banned')
|
|
{
|
|
$('#customSwitch1').prop('checked',false) ;
|
|
$('#customSwitch2').prop('checked',true) ;
|
|
$('#txtstatusban').text('Banned');
|
|
}
|
|
else{
|
|
$('#customSwitch1').prop('checked',false) ;
|
|
$('#customSwitch2').prop('checked',false) ;
|
|
$('#txtstatus').text('Inactive');
|
|
}
|
|
function kemaskini() {
|
|
// console.log($('#txtstatus').val());
|
|
$("#formkemaskini").submit();
|
|
}
|
|
|
|
function showban(e){
|
|
var value = $(e).prop('checked') ;
|
|
if( value == true){
|
|
$('#txtstatus').text('Inactive');
|
|
$('#txtstatusban').text('Banned');
|
|
$('#customSwitch1').prop('checked',false) ;
|
|
}
|
|
else{
|
|
if(status == 'active'){
|
|
$('#customSwitch1').prop('checked',true) ;
|
|
$('#txtstatus').text('Active');
|
|
$('#txtstatusban').text('');
|
|
}
|
|
else
|
|
{
|
|
$('#txtstatusban').text('');
|
|
$('#txtstatus').text('Inactive');
|
|
}
|
|
}
|
|
}
|
|
function showstatus(e){
|
|
var value = $(e).prop('checked') ;
|
|
if( value == true)
|
|
{
|
|
$('#txtstatusban').text('');
|
|
$('#txtstatus').text('Active');
|
|
$('#customSwitch2').prop('checked',false) ;
|
|
}
|
|
else{
|
|
if(status == 'banned'){
|
|
$('#customSwitch2').prop('checked',true) ;
|
|
$('#txtstatus').text('Inactive');
|
|
$('#txtstatusban').text('Banned');
|
|
}
|
|
else
|
|
{
|
|
$('#txtstatusban').text('');
|
|
$('#txtstatus').text('Inactive');
|
|
}
|
|
}
|
|
console.log(value);
|
|
}
|
|
</script>
|
|
@endsection
|