@extends(branchMenu())
@section('content')
    <?php Fun::lang()?>
    <style>
        .jconfirm-content-pane input{
            margin-bottom: 10px;
        }
    </style>
    <div class="page">
        <div class=container-fluid>
            <div class="top-content">
                <div class="row">
                    <div class="col-sm-12 col-xs-12">
                        <div class="title-add">
                            <div class="pull-left">
                                <h3>{{__('administrator.color')}}</h3>
                            </div>
                            <div class="pull-right">
                                @can('Color Create')
                                    <a class=" button_info create_color"><i class="fa fa-plus"></i> {{__('administrator.create')}}</a>
                                    <a type="button" data-name="Import" data-href="{{route('color-import-excel')}}" data-width="800px" class="getHtmlForm button_success"> <i class="fa fa-upload"></i><span>Import</span></a>
                                </a>
                                @endcan
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="wrapper-table">
                <table id="data_table" class="table table-striped table-hover ">
                    <thead>
                    <tr>
                        <th>#</th>
                        <th>{{__('administrator.code')}}</th>
                        <th>{{__('administrator.name')}}</th>
                        <th>{{__('administrator.color')}}</th>
                        <th>{{__('administrator.created_at')}}</th>
                        <th>{{__('administrator.action')}}</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($data as $key => $value)
                        <tr>
                            <td>{{$key+1}}</td>
                            <td>{{$value->code }}</td>
                            <td>{{$value->name}}</td>
                            <td><button type="button" style="background: {{$value->color}};border:1px solid black" class="btn">&nbsp;&nbsp;&nbsp;</button></td>
                            <td>{{date('d-m-Y', strtotime($value->created_at)) }}</td>
                            @can('Color Edit')
                            <td>
                                <a data-href="{{route('product-color.edit',$value->id)}}"
                                   class=" button_warning btn_edit">{{__('administrator.edit')}}</a>

                            </td>
                            @endcan
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
@endsection
@section('script')

    <script type="text/javascript">
        $('.create_color').on('click', function () {
            getHtmlForm('{{route('product-color.create')}}','{{__('administrator.create')}} {{__('administrator.color')}}');
        });
        $('.btn_edit').on('click', function () {
            getHtmlForm($(this).data('href'),'{{__('administrator.edit')}} {{__('administrator.color')}}');
        });

        $('#data_table').DataTable({
            "oLanguage": {
                "sSearch": "{{__('administrator.search')}}:",
                "sLengthMenu": "{{__('administrator.display')}} _MENU_ {{__('administrator.record_per_page')}}",
                "sZeroRecords": "{{__('administrator.Nothing_foundsorry')}}",
                "sInfo": "{{__('administrator.showing')}} _START_ {{__('administrator.to')}} _END_ {{__('administrator.of')}} _TOTAL_ {{__('administrator.record')}}",
                "sInfoEmpty": "{{__('administrator.showing')}} 0 {{__('administrator.to')}} 0 {{__('administrator.of')}} 0 {{__('administrator.record')}}",
                "sInfoFiltered": "({{__('administrator.filter_form')}} _MAX_ {{__('administrator.total_records')}})",
                "oPaginate": {
                    "sFirst": "{{__('administrator.first')}}",
                    "sLast": "{{__('administrator.last')}}",
                    "sNext": "{{__('administrator.next')}}",
                    "sPrevious": "{{__('administrator.previous')}}"
                },
            }

        });
    </script>
@stop



