@extends('template')
@section('main-content')

    <div class="row">
        <div class="col-xs-12">
            <div class="page-title-box">
                <h4 class="page-title">{{$model->getTitle()}} </h4>
                <ol class="breadcrumb p-0 m-0">
                    <li>
                        <a href="#">{{config('app.name')}}</a>
                    </li>
                    <li class="active">
                        {{$model->getTitle()}}
                    </li>
                </ol>
                <div class="clearfix"></div>
            </div>
        </div>
    </div>


    @if(in_array('add',$model->getActions()))
        <div class="row">
            <div class="col-md-12">
                <a href="{{url(Request::path().'/add')}}"  class="btn btn-primary btn-sm waves-effect waves-light m-r-5 m-b-10 pull-right" >
                    <i class="fa fa-plus"></i> Nouveau
                </a>
            </div>
        </div>
    @endif



    <div class="row">
        <div class="col-sm-12">
            <div class="card-box table-responsive">
                {{--<h4 class="m-t-0 header-title"><b>{{$model->getTitle()}}</b></h4>--}}
                @include('inc.cruds.simple_table_non_modal')
            </div>
        </div>
    </div>

    @if($model->getTable()=='users')
        <span id="opener-g-point" data-toggle="modal" data-target="#form-g-point"></span>
        <div class="modal fade none-border" id="form-g-point">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="modal-title-g-point">Ajout/Retrait de point</h4>
                    </div>
                    <form method="POST" action="{{url('gpoint')}}" enctype="multipart/form-data" class="form-horizontal form-label-left input_mask">
                        <div class="modal-body">

                            <input type="hidden" value="" id="t_id" name="t_id">
                            <input type="hidden" value="" id="t_type" name="t_type">
                            {{csrf_field()}}

                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label  class="control-label">Client</label>
                                        <div style="height: 55px" class="form-control" id="client_info">

                                        </div>
                                    </div>
                                </div>

                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label for="f_point" class="control-label">Nb. point</label>
                                        <input name="f_point"  id="f_point" type="text" class="form-control" value="" placeholder="">
                                    </div>
                                </div>

                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label for="f_motif" class="control-label">Motif</label>
                                        <textarea required name="f_motif" id="f_motif" class="form-control"></textarea>
                                    </div>
                                </div>
                            </div>

                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default waves-effect" data-dismiss="modal">Fermer</button>
                            <button type="submit" class="btn btn-success save-evt waves-effect waves-light">Enregistrer</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    @endif
@endsection



@section('my-scripts-2')
    @if($model->getTable()=='users')
        <script>
        $(document).ready(function () {
            $(document).on('click','.btn-g-point',function (e) {

                e.preventDefault();
                client_info = $(this).attr('d-client');
                _id = $(this).attr('d-fid');
                type = $(this).attr('d-type');

                title = '';
                if(type=='de')
                    title = 'Retrait de point';
                if(type=='in')
                    title = 'Ajout de point';


                $('#client_info').html(client_info);
                $('#t_id').val(_id);
                $('#t_type').val(type);

                $('#modal-title-g-point').html(title);

                $('#opener-g-point').click();
            });


        });
    </script>
    @endif
@endsection
