@extends('layouts.master')

@section('title', 'IV Media - Increase your popularity')
@section('content')
<!-- Start content -->
<div class="content">
    <div class="container-fluid">

        <div class="row">
            <div class="col-xl-12">
                <div class="page-title-box">
                    <h4 class="page-title float-left">Dashboard</h4>

                    <ol class="breadcrumb float-right">
                        <li class="breadcrumb-item"><a href="{{ url('/') }}">{!! \App\Helper::panelName() !!}</a>
                        </li>
                        <li class="breadcrumb-item active">Server Live Views</li>
                    </ol>

                    <div class="clearfix"></div>
                </div>
            </div>
        </div>
        <!-- end row -->


        <div class="row">
            @if ($flash = session('message')) {
              <div class="col-md-12">
                <div class="alert alert-success" role="alert">
                  <ul>
                  @foreach ($flash as $key => $val)
                    <li>{{$key.'  '.$val}}</li>
                  @endforeach
                  </ul>
                </div>
              </div>
            @endif
            <div class="col-lg-6 col-md-12">

                @if($result = session('result'))
                    {!! $result !!}
                @endif
                <div class="card-box">

                    <h4 class="header-title m-t-0 m-b-30"><span class="label label-primary">{{ auth()->user()->level }}</span> {!! \App\Helper::panelName() !!} Story Views</h4>
                    
<!--{{ url('server/comment') }}-->
                    <div class="row">
                        <div class="col-12">
                            <form action="/service/submitstory" method="POST">
                                
                                {{ csrf_field() }}
                                <?php
                                    $max = 1000;
                                ?>
                                @if(\Carbon\Carbon::now() > auth()->user()->delay->like_3)
                                
                                <fieldset class="form-group">
                                    <label for="username">Username Instagram</label>
                                    <input type="text" name="username" class="form-control" placeholder="Tiktok">
                                </fieldset>
                                <fieldset class="form-group">
                                    <label for="username">Mau Berapa Viewer?</label>
                                    <input type="number" class="form-control {{ $errors->has('jumlah') ? 'parsley-error' : '' }}" id="jumlah" placeholder="{{ $max }}" name="jumlah">
                                            @if ($errors->has('jumlah'))
                                                <span class="help-block">
                                                    <ul class="parsley-errors-list filled"><li class="parsley-required">{{ $errors->first('jumlah') }}</li></ul>
                                                </span>
                                            @endif
                                </fieldset>
                                
                                <button type="submit" id="submitBtn" class="btn btn-block btn-primary">Submit</button>
                                
                                @else
                                <div class="alert alert-danger" role="alert">
                                    Please wait {{ \Carbon\Carbon::parse(auth()->user()->delay->like_3)->diffForHumans() }} to submit Story Views
                                </div>
                                
                                <div class="alert alert-success" role="alert">
                                    Success Submit Story Views ! ^_^
                                </div>
                                @php ($button = '<button type="submit" id="submitBtn" class="btn btn-block btn-danger" disabled>Please Wait</button>')
                                @endif
                                
                            </form>
                        </div>
                    </div><!-- end row -->
                </div>
            </div>
            <div class="col-lg-6 col-md-12">
                <div class="card-box">
                    <h4 class="header-title m-t-0 m-b-30"><span class="label label-primary">{{ auth()->user()->level }}</span> {!! \App\Helper::panelName() !!} Story Views</h4>
                    <ul class="list-group">
                      <li class="list-group-item">Selamat Datang Di {!! \App\Helper::panelName() !!} PANEL</li>
                      <li class="list-group-item">Isi Target Dengan Username Tanpa @</li>
                      <li class="list-group-item">Story Views Akan Terisi Pada Story Gram Terbaru</li>
                      <li class="list-group-item">Data Base Story Views Bisa Naik Turun 1000±</li>
                      <li class="list-group-item">Jeda Submit 10 Menit</li>
                      <li class="list-group-item">Instagram Jangan Di <span class="label label-danger"><i class="fa fa-lock"></i> Private</span></li>
                      {{-- <li class="list-group-item">Delay <span class="label label-success">@if($id != 9){{ constant("DELAY_".strtoupper(auth()->user()->level)) }} MENIT @else 15 Menit @endif</span></li> --}}
                    </ul>
                </div>
            </div>
        </div>
        <!-- end row -->


    </div>
    <!-- container -->

</div>
<!-- content -->
@endsection

@section('js')
<script>
$(document).ready(function(){
    $('#submitBtn').dblclick(function(){
        $('#submitBtn').attr('disabled', true);
    });
});
$(document).ready(function(){
    $('#jumlah').on('input change', function(){
        var submitBtn = $('#submitBtn');
        var value = $('#jumlah').val();
        if(value <= {{ $max }}){
            submitBtn.removeAttr("disabled");
            submitBtn.text('Submit');
            submitBtn.removeClass('btn-danger').addClass('btn-primary');
        }
        else{
            submitBtn.attr("disabled", true);
            submitBtn.text('Max {{ $max }}! Silahkan Rubah Jumlah');
            submitBtn.removeClass('btn-primary').addClass('btn-danger');
        }
    });
    $('#submitBtn').on('click',function(){
        $('#submitBtn').attr('disabled', true);
        $('#formini').submit();
    });
  });
</script>
@endsection
