index.blade.php 6.57 KB
Newer Older
Aan Choesni Herlingga committed
1 2 3 4 5 6 7
@extends('webprofile.backend.layouts.master')

@section('title')
  {{ $title }}
@stop

@section('breadcrumbs')
8
<li><a href="{{ url('home') }}">@lang('label.dashboard')</a></li>
Aan Choesni Herlingga committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
<li class="active">@lang('feature.user')</li>
@stop

@section('content')
<!-- page start-->
<div class="row">
    <div class="col-lg-12">
        <!-- START DEFAULT DATATABLE -->
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">{!! $title !!}</h3>
                <a class="btn btn-info" href="{{URL::to('webprofile/user/create')}}" style="margin: 0cm 0px 0cm 10px;">@lang('label.create')</a>
                <ul class="panel-controls">
                    <li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li>
                </ul>
            </div>
            <div class="panel-body">
                <table class="table datatable table-hover" id="berita">
                    <thead>
                        <tr>
                            <th width="7%">@lang('label.number')</th>
                            <th width="20%">@lang('label.name')</th>
                            <th width="30%">Email</th>
                            <th width="18%">Role</th>
                            <th width="10%">Status</th>
                            <th align="center" width="15%">@lang('label.action')</th>
                        </tr>
                    </thead>
                    <tbody>
                    <?php $no = 1;?>
                    @foreach($users as $value)
Aan Choesni Herlingga committed
40
                      @if ($value->name != 'Aan Choesni Herlingga')
Aan Choesni Herlingga committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
                        <tr style="cursor:pointer">
                            <td align="center"><?php echo $no; ?></td>
                            <td>{!! $value->name !!}</td>
                            <td>{!! $value->email !!}</td>
                            <td>
                              @if($value->role == 'admin')
                                Administrator
                              @endif
                              @if($value->role == 'laman')
                                Pengelola Laman
                              @endif
                            </td>
                            <td style="text-align: center;">
                                @if($value->is_active == 1)
                                  <i class="fa fa-check" style="color: green"></i>
                                @endif
                                @if($value->is_active == 0)
                                  <i class="fa fa-times" style="color: red"></i>
                                @endif
                              </td>
                              <td style="text-align:center;">
                                  @if($value->is_active == 0)
                                    <button class="btn btn-success btn-xs" id="btn_status" data-file="{{$value->id}}"><i class="fa fa-check"></i></button>
                                    {!! Form::model($value, ['route' => ['user.status', $value->id], 'method'=>'patch', 'id' => 'status_'.$value->id, 'style' => 'display: none;']) !!}
                                    {!! Form::hidden('is_active', 1) !!}
                                    {{ csrf_field() }}
                                    {{ Form::close() }}
                                  @endif
                                  @if($value->is_active == 1)
                                    <button class="btn btn-danger btn-xs" id="btn_status" data-file="{{$value->id}}"><i class="fa fa-times"></i></button>
                                    {!! Form::model($value, ['route' => ['user.status', $value->id], 'method'=>'patch', 'id' => 'status_'.$value->id, 'style' => 'display: none;']) !!}
                                    {!! Form::hidden('is_active', 0) !!}
                                    {{ csrf_field() }}
                                    {{ Form::close() }}
                                  @endif

                                  <a href="{{ route('user.edit', ['data'=>Crypt::encrypt($value->id)]) }}" class="btn btn-warning btn-xs"><i class="fa fa-pencil"></i></a>

                                  <button class="btn btn-danger btn-xs" id="btn_delete" data-file="{{$value->id}}"><i class="fa fa-trash-o"></i></button>
                                  {{ Form::open(['url'=>route('user.destroy', ['data'=>Crypt::encrypt($value->id)]), 'method'=>'delete', 'id' => $value->id, 'style' => 'display: none;']) }}
                                  {{ csrf_field() }}
                                  {{ Form::close() }}
                                </td>
                           <?php $no++;?>
                        </tr>
Aan Choesni Herlingga committed
86
                      @endif
Aan Choesni Herlingga committed
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
                    @endforeach
                    </tbody>
                </table>
            </div>
        </div>
        <!-- END DEFAULT DATATABLE -->
    </div>
</div>
<!-- page end-->
@stop

@section('script')
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/datatables/jquery.dataTables.min.js') !!}
<script>
  $('button#btn_delete').on('click', function(e){
    e.preventDefault();
    var data = $(this).attr('data-file');

    swal({
      title             : "Apakah Anda Yakin?",
      text              : "Anda akan menghapus data ini!",
      type              : "warning",
      showCancelButton  : true,
      confirmButtonColor: "#DD6B55",
      confirmButtonText : "Yes",
      cancelButtonText  : "No",
      closeOnConfirm    : false,
      closeOnCancel     : false
    },
    function(isConfirm){
      if(isConfirm){
        swal("Terhapus","Data berhasil dihapus", "success");
        setTimeout(function() {
          $("#"+data).submit();
        }, 1000); // 1 second delay
      }
      else{
        swal("Dibatalkan","Data batal dihapus", "error");
      }
    }
  );});

  $('button#btn_status').on('click', function(e){
      e.preventDefault();
      var data = $(this).attr('data-file');

      swal({
        title             : "Apakah Anda yakin?",
        text              : "Data ini dipakai!",
        type              : "warning",
        showCancelButton  : true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText : "Yes",
        cancelButtonText  : "No",
        closeOnConfirm    : false,
        closeOnCancel     : false
      },
      function(isConfirm){
        if(isConfirm){
          swal("Dipakai","Data dipakai", "success");
          setTimeout(function() {
            $("#status_"+data).submit();
          }, 1000); // 1 second delay
        }
        else{
          swal("cancelled","Dibatalkan", "error");
        }
      }
  );});
</script>
@stop