242 lines
9.9 KiB
PHP
242 lines
9.9 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" required>
|
|
</div>
|
|
<div class="form-group col-md-6">
|
|
<label for="inputEmail4">Username</label>
|
|
<input type="text" value="{{$user->username}}" class="form-control" name="username" id="inputText" required>
|
|
</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" required>
|
|
</div>
|
|
<div class="form-group col-md-6">
|
|
<label for="name">Cawangan</label>
|
|
<select class="custom-select" name="caw" id="caw" required>
|
|
<option disabled>Pilih Cawangan</option>
|
|
<option selected value="">-</option>
|
|
@if($user->cawangan != NULL)
|
|
<option selected value="{{$user->kodcaw}}">
|
|
{{$user->cawangan->caw_name}}
|
|
</option> @endif
|
|
@foreach ($caw as $item)
|
|
<option value="{{$item->caw_code}}">{{$item->caw_name}}</option>
|
|
@endforeach
|
|
|
|
<!-- <option value="all">Select All</option> -->
|
|
</select>
|
|
</div>
|
|
@if($user->user_type == 3)
|
|
<div class="form-group col-md-6">
|
|
<label for="inputPassword4">No.Telefon</label>
|
|
<input type="text" value="{{$user->notelbimbit}}" class="form-control" name="notelbimbit" id="notelbimbit" required>
|
|
</div>
|
|
@endif
|
|
</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 checkbox get-roles" name="taraf{{$namataraf}}" type="checkbox" onclick="checkboxRoles(this)" 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 | $user->user_type == 3)
|
|
<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>
|
|
window.onload = function(){
|
|
var x = document.getElementsByClassName("get-roles");
|
|
var y = [];
|
|
for (z of x) {
|
|
if(z.checked)
|
|
{
|
|
y.push(z);
|
|
}
|
|
}
|
|
checkboxRoles(y[0]);
|
|
};
|
|
|
|
var allRoles = JSON.parse('<?php echo json_encode($allroles) ?>');
|
|
var allRolesWithTaraf = [];
|
|
for (item of allRoles) {
|
|
var itemToAdded = "";
|
|
itemToAdded = itemToAdded.concat("taraf", item);
|
|
allRolesWithTaraf.push(itemToAdded);
|
|
}
|
|
|
|
function checkboxRoles(taraf) {
|
|
for (const item of allRolesWithTaraf) {
|
|
if (taraf.id == item) {
|
|
if (taraf.checked == true) {
|
|
if (taraf.id == "tarafadmin") {
|
|
$(".checkbox").each(function() {
|
|
$(this).not('#tarafadmin').prop("disabled", true);
|
|
});
|
|
} else if (taraf.id == "tarafaccount") {
|
|
$(".checkbox").each(function() {
|
|
$(this).not('#tarafaccount').prop("disabled", true);
|
|
});
|
|
}else if (taraf.id == "tarafajk") {
|
|
$(".checkbox").each(function() {
|
|
$(this).not('#tarafajk').prop("disabled", true);
|
|
});
|
|
}
|
|
else if (taraf.id == "tarafcallcenter") {
|
|
$(".checkbox").each(function() {
|
|
$(this).not('#tarafcallcenter').prop("disabled", true);
|
|
});
|
|
} else if (taraf.id == "tarafpembida") {
|
|
$(".checkbox").each(function() {
|
|
$(this).not('#tarafpembida').prop("disabled", true);
|
|
});
|
|
} else if (taraf.id == "tarafpenilai" || taraf.id == "tarafkhazanah" || taraf.id == "tarafpengurus-cawangan") {
|
|
$(".checkbox").each(function() {
|
|
$(this).not('#tarafpenilai, #tarafkhazanah, #tarafpengurus-cawangan').prop("disabled", true);
|
|
});
|
|
} else if (taraf.id == "tarafoperasi" || taraf.id == "tarafpengurus-operasi") {
|
|
$(".checkbox").each(function() {
|
|
$(this).not('#tarafoperasi, #tarafpengurus-operasi').prop("disabled", true);
|
|
});
|
|
}
|
|
} else {
|
|
$(".checkbox").each(function() {
|
|
if ($('.checkbox:checked').length == 0) {
|
|
$(this).prop("disabled", false);
|
|
}
|
|
});
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function confirm() {
|
|
$.confirm({
|
|
title: 'Pengesahan',
|
|
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
|