index.blade.php 20.7 KB
Newer Older
Aan Choesni Herlingga committed
1 2 3 4 5 6 7 8 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 40 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 86 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
@extends('webprofile.backend.layouts.master')

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

@section('assets')
<link rel="stylesheet" href="{!! asset('backend/assets/select2/select2.min.css') !!}">
<style media="screen">
  .tkh{
    color: black;
  }
</style>
@stop

@section('breadcrumbs')
<li><a href="{{URL::to('dashboard')}}">Dashboard</a></li>
<li class="active">Menu</li>
@stop

@section('content')
<!-- page start-->
<div class="row">
	<div class="col-md-4">
	    <div class="panel panel-default">
        {!! Form::open(array('url' => route('menu.store'), 'method' => 'POST', 'id' => 'menu')) !!}
        {!! csrf_field() !!}
	        <div class="panel-heading">
	            <h3 class="panel-title">Tambah Menu Baru</h3>
	        </div>
	        <div class="panel-body">
	            <div class="row">
	                <div class="col-md-12">
	                    <div class="form-group @if ($errors->has('title')) has-error @endif">
                          <div class="col-md-12">
                            <label for="parent">Parent</label>
                            {{ Form::select('parent', $parent, old('parent'), ['class' => 'form-control select2', 'style' => 'width: 100%; font-size: 14pt;', 'id' => 'parent', 'placeholder' => 'Parent']) }}
                            @if ($errors->has('parent'))
                            <label id="login-error" class="error" for="login">{{$errors->first('parent')}}</label>
                            @endif
                          </div>
                          <div class="col-md-12">
                            <label for="name">Judul</label>
	                          {{ Form::text('name', old('name'), array('class' => 'form-control', 'placeholder'=>'Judul')) }}
	                          @if ($errors->has('name'))
	                          <label id="login-error" class="error" for="login">{{$errors->first('name')}}</label>
	                          @endif
	                        </div>
                          <div class="col-md-12">
                            <label for="url">URL</label>
	                          {{ Form::text('url', old('url'), array('class' => 'form-control', 'placeholder'=>'URL')) }}
	                          @if ($errors->has('url'))
	                          <label id="login-error" class="error" for="login">{{$errors->first('url')}}</label>
	                          @endif
	                        </div>
                          <div class="col-md-12" style="padding-top: 10px;">
                            <button class="btn btn-info pull-right">Simpan</button>
                          </div>
	                    </div>
                  </div>
	            </div>
	        </div>
        {!! Form::close() !!}
	    </div>
      <div class="panel panel-default">
        {!! Form::open(array('url' => route('menu.storepage'), 'method' => 'POST', 'id' => 'menu')) !!}
        {!! csrf_field() !!}
	        <div class="panel-heading">
	            <h3 class="panel-title">Tambah Menu Dari Page</h3>
	        </div>
	        <div class="panel-body">
	            <div class="row">
	                <div class="col-md-12">
	                    <div class="form-group @if ($errors->has('title')) has-error @endif">
                          <div class="col-md-12">
                            <label for="parentpage">Parent</label>
                            {{ Form::select('parentpage', $parent, old('parentpage'), ['class' => 'form-control select2', 'style' => 'width: 100%; font-size: 14pt;', 'id' => 'parentpage', 'placeholder' => 'Parent']) }}
                            @if ($errors->has('parentpage'))
                            <label id="login-error" class="error" for="login">{{$errors->first('parentpage')}}</label>
                            @endif
                          </div>
                          <div class="col-md-12">
                            <label for="page">Page</label>
                            {{ Form::select('page', $page, old('page'), ['class' => 'form-control select2', 'style' => 'width: 100%; font-size: 14pt;', 'id' => 'page', 'placeholder' => 'Page', 'required']) }}
                            @if ($errors->has('page'))
                            <label id="login-error" class="error" for="login">{{$errors->first('page')}}</label>
                            @endif
                          </div>
                          <div class="col-md-12" style="padding-top: 10px;">
                            <button class="btn btn-info pull-right">Simpan</button>
                          </div>
	                    </div>
                  </div>
	            </div>
	        </div>
        {!! Form::close() !!}
	    </div>
	</div>
	<div class="col-md-8">
	    <div class="panel panel-default">
	        <div class="panel-heading">
	            <h3 class="panel-title">Menu</h3>
	            <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">
	            <div class="row">
                    <div class="col-md-12">
	                    <table class="table table-hover">
                        <thead>
                            <tr>
113 114 115
                                <th style="text-align: center;">Name</th>
                                <th width="10%" style="text-align: center;">Order</th>
                                <th align="center" width="15%" style="text-align: center;">Actions</th>
Aan Choesni Herlingga committed
116 117 118 119 120 121 122 123
                            </tr>
                        </thead>
                        @foreach ($arr as $key => $value)
                          <tr>
                            <td>
                              <a href="{!! url((string)$value['url']) !!}" target="_blank">{!! $value['name'] !!}</a>
                            </td>
                            <td style="text-align:center; vertical-align: middle;">
124
                              @if(count($value['r_child']) != 1)
Aan Choesni Herlingga committed
125 126 127 128 129 130
                              @if($value['urutan'] == 1)
                                <a href="{{ route('menu_down', ['data'=>Crypt::encrypt($value['id'])]) }}" class="btn btn-warning btn-xs">
                                  <i class="fa fa-arrow-down"></i>
                                </a>
                              @endif
                              @if($value['urutan'] > 1)
131
                                @if($value['urutan'] == count($arr))
Aan Choesni Herlingga committed
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
                                  <a href="{{ route('menu_up', ['data'=>Crypt::encrypt($value['id'])]) }}" class="btn btn-warning btn-xs">
                                    <i class="fa fa-arrow-up"></i>
                                  </a>
                                @else
                                  <a href="{{ route('menu_up', ['data'=>Crypt::encrypt($value['id'])]) }}" class="btn btn-warning btn-xs">
                                    <i class="fa fa-arrow-up"></i>
                                  </a>
                                  @if ($key+1 < count($arr))
                                  <a href="{{ route('menu_down', ['data'=>Crypt::encrypt($value['id'])]) }}" class="btn btn-warning btn-xs">
                                    <i class="fa fa-arrow-down"></i>
                                  </a>
                                  @endif
                                @endif
                              @endif
                              @endif
147 148
                            </td>
                            <td style="text-align:center; vertical-align: middle;">
Aan Choesni Herlingga committed
149 150 151
                              <a href="{{ route('menu.edit', ['data'=>Crypt::encrypt($value['id'])]) }}" data-toggle="tooltip" data-original-title="@lang('label.edit')" class="edit btn btn-primary btn-xs"><i class="fa fa-edit"></i></a>

                              <button class="btn btn-danger btn-xs" id="btn_delete" data-file="{{$value['id']}}" data-toggle="tooltip" data-original-title="@lang('label.delete')"><i class="fa fa-trash-o"></i></button>
Aan Choesni Herlingga committed
152 153 154 155 156
                              {{ Form::open(['url'=>route('menu.destroy', ['data'=>Crypt::encrypt($value['id'])]), 'method'=>'delete', 'id' => $value['id'], 'style' => 'display: none;']) }}
                              {{ csrf_field() }}
                              {{ Form::close() }}
                            </td>
                          </tr>
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
                          @if(!empty($value['r_child']))
                          @foreach ($value['r_child'] as $ckey => $val)
                          <tr>
                            <td>
                              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="{!! url((string)$val['url']) !!}">{!! $val['name'] !!}</a>
                            </td>
                            <td style="text-align:center; vertical-align: middle;">
                              @if(count($value['r_child']) != 1)
                              @if($val['urutan'] == 1)
                                <a href="{{ route('menu_down', ['data'=>Crypt::encrypt($val['id'])]) }}" class="btn btn-warning btn-xs">
                                  <i class="fa fa-arrow-down"></i>
                                </a>
                              @endif
                              @if($val['urutan'] > 1)
                                @if($val['urutan'] == count($value['r_child']))
                                  <a href="{{ route('menu_up', ['data'=>Crypt::encrypt($val['id'])]) }}" class="btn btn-warning btn-xs">
                                    <i class="fa fa-arrow-up"></i>
                                  </a>
                                @else
                                  <a href="{{ route('menu_up', ['data'=>Crypt::encrypt($val['id'])]) }}" class="btn btn-warning btn-xs">
                                    <i class="fa fa-arrow-up"></i>
                                  </a>
                                  @if($ckey+1 < count($value['r_child']))
Aan Choesni Herlingga committed
180 181 182 183
                                    <a href="{{ route('menu_down', ['data'=>Crypt::encrypt($val['id'])]) }}" class="btn btn-warning btn-xs">
                                      <i class="fa fa-arrow-down"></i>
                                    </a>
                                  @endif
184 185 186
                                @endif
                              @endif
                              @endif
187 188
                            </td>
                            <td style="text-align:center; vertical-align: middle;">
Aan Choesni Herlingga committed
189 190 191
                              <a href="{{ route('menu.edit', ['data'=>Crypt::encrypt($val['id'])]) }}" data-toggle="tooltip" data-original-title="@lang('label.edit')" class="edit btn btn-primary btn-xs"><i class="fa fa-edit"></i></a>
                              
                              <button class="btn btn-danger btn-xs" id="btn_delete" data-file="{{$val['id']}}" data-toggle="tooltip" data-original-title="@lang('label.delete')"><i class="fa fa-trash-o"></i></button>
192 193 194 195 196
                              {{ Form::open(['url'=>route('menu.destroy', ['data'=>Crypt::encrypt($val['id'])]), 'method'=>'delete', 'id' => $val['id'], 'style' => 'display: none;']) }}
                              {{ csrf_field() }}
                              {{ Form::close() }}
                            </td>
                          </tr>
197 198 199 200 201 202 203 204 205
                            @if (!empty($val['r_child']))
                              @foreach ($val['r_child'] as $ckey2 => $val2)
                                <tr>
                                  <td>
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="{!! url((string)$val2['url']) !!}">{!! $val2['name'] !!}</a>
                                  </td>
                                  <td style="text-align:center; vertical-align: middle;">
                                    @if(count($val['r_child']) != 1)
                                    @if($val2['urutan'] == 1)
206 207
                                      <a href="{{ route('menu_down', ['data'=>Crypt::encrypt($val2['id'])]) }}" class="btn btn-warning btn-xs">
                                        <i class="fa fa-arrow-down"></i>
Aan Choesni Herlingga committed
208 209
                                      </a>
                                    @endif
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
                                    @if($val2['urutan'] > 1)
                                      @if($val2['urutan'] == count($val['r_child']))
                                        <a href="{{ route('menu_up', ['data'=>Crypt::encrypt($val2['id'])]) }}" class="btn btn-warning btn-xs">
                                          <i class="fa fa-arrow-up"></i>
                                        </a>
                                      @else
                                        <a href="{{ route('menu_up', ['data'=>Crypt::encrypt($val2['id'])]) }}" class="btn btn-warning btn-xs">
                                          <i class="fa fa-arrow-up"></i>
                                        </a>
                                        @if($ckey2+1 < count($val['r_child']))
                                          <a href="{{ route('menu_down', ['data'=>Crypt::encrypt($val2['id'])]) }}" class="btn btn-warning btn-xs">
                                            <i class="fa fa-arrow-down"></i>
                                          </a>
                                        @endif
                                      @endif
                                    @endif
                                    @endif
                                  </td>
                                  <td style="text-align:center; vertical-align: middle;">
                                    <a href="{{ route('menu.edit', ['data'=>Crypt::encrypt($val2['id'])]) }}" data-toggle="tooltip" data-original-title="@lang('label.edit')" class="edit btn btn-primary btn-xs"><i class="fa fa-edit"></i></a>
Aan Choesni Herlingga committed
230

231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
                                    <button class="btn btn-danger btn-xs" id="btn_delete" data-file="{{$val2['id']}}" data-toggle="tooltip" data-original-title="@lang('label.delete')"><i class="fa fa-trash-o"></i></button>
                                    {{ Form::open(['url'=>route('menu.destroy', ['data'=>Crypt::encrypt($val2['id'])]), 'method'=>'delete', 'id' => $val2['id'], 'style' => 'display: none;']) }}
                                    {{ csrf_field() }}
                                    {{ Form::close() }}
                                  </td>
                                </tr>
                                    @if (!empty($val2['r_child']))
                                      @foreach ($val2['r_child'] as $ckey3 => $val3)
                                        <tr>
                                          <td>
                                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="{!! url((string)$val3['url']) !!}">{!! $val3['name'] !!}</a>
                                          </td>
                                          <td style="text-align:center; vertical-align: middle;">
                                            @if(count($val2['r_child']) != 1)
                                            @if($val3['urutan'] == 1)
                                              <a href="{{ route('menu_down', ['data'=>Crypt::encrypt($val3['id'])]) }}" class="btn btn-warning btn-xs">
                                                <i class="fa fa-arrow-down"></i>
                                              </a>
                                            @endif
                                            @if($val3['urutan'] > 1)
                                              @if($val3['urutan'] == count($val2['r_child']))
                                                <a href="{{ route('menu_up', ['data'=>Crypt::encrypt($val3['id'])]) }}" class="btn btn-warning btn-xs">
                                                  <i class="fa fa-arrow-up"></i>
                                                </a>
                                              @else
                                                <a href="{{ route('menu_up', ['data'=>Crypt::encrypt($val3['id'])]) }}" class="btn btn-warning btn-xs">
                                                  <i class="fa fa-arrow-up"></i>
                                                </a>
                                                @if($ckey3+1 < count($val2['r_child']))
                                                  <a href="{{ route('menu_down', ['data'=>Crypt::encrypt($val3['id'])]) }}" class="btn btn-warning btn-xs">
                                                    <i class="fa fa-arrow-down"></i>
                                                  </a>
                                                @endif
                                              @endif
                                            @endif
                                            @endif
                                          </td>
                                          <td style="text-align:center; vertical-align: middle;">
                                            <a href="{{ route('menu.edit', ['data'=>Crypt::encrypt($val3['id'])]) }}" data-toggle="tooltip" data-original-title="@lang('label.edit')" class="edit btn btn-primary btn-xs"><i class="fa fa-edit"></i></a>

                                            <button class="btn btn-danger btn-xs" id="btn_delete" data-file="{{$val3['id']}}" data-toggle="tooltip" data-original-title="@lang('label.delete')"><i class="fa fa-trash-o"></i></button>
                                            {{ Form::open(['url'=>route('menu.destroy', ['data'=>Crypt::encrypt($val3['id'])]), 'method'=>'delete', 'id' => $val3['id'], 'style' => 'display: none;']) }}
                                            {{ csrf_field() }}
                                            {{ Form::close() }}
                                          </td>
                                        </tr>
                                      @endforeach
                                    @endif
                              @endforeach
                            @endif
                            @endforeach
Aan Choesni Herlingga committed
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
                          @endif
                        @endforeach
	                    </table>
	                </div>
	            </div>
	        </div>
	        <div class="panel-footer">
	        </div>
	    </div>
	</div>
</div>
<!-- page end-->
@stop

@section('script')
<script src="{!!asset('backend/js/datatables.net/js/jquery.dataTables.min.js') !!}"></script>
{!! Html::script('backend/assets/select2/select2.full.min.js') !!}
<script type="text/javascript">
  $('#parent').select2();
  $('#parentpage').select2();
  $('#page').select2();

  $('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_aktif').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() {
            $("#aktif_"+data).submit();
          }, 1000); // 1 second delay
        }
        else{
          swal("cancelled","Dibatalkan", "error");
        }
      }
  );});

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

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