
<?php $__env->startSection('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><?php echo e(__('administrator.size')); ?></h3>
                            </div>
                            <div class="pull-right">
                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Size Create')): ?>
                                    <a class=" button_info create_size"><i class="fa fa-plus"></i> <?php echo e(__('administrator.create')); ?></a>
                                    <a type="button" data-name="Import" data-href="<?php echo e(route('size-import-excel')); ?>" data-width="800px" class="getHtmlForm button_success"><i class="fa fa-upload"></i> <span>Import</span></a>
                                <?php endif; ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="wrapper-table">
                <table id="data_table" width="100%" class="table table-striped table-hover ">
                    <thead>
                    <tr>
                        <th>#</th>
                        <th><?php echo e(__('administrator.size')); ?></th>
                        <th><?php echo e(__('administrator.code')); ?></th>
                        <th><?php echo e(__('administrator.note')); ?></th>
                        <th><?php echo e(__('administrator.created_at')); ?></th>
                        <th><?php echo e(__('administrator.action')); ?></th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php $__currentLoopData = $data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td><?php echo e($key+1); ?></td>
                            <td><?php echo e($value->size); ?></td>
                            <td><?php echo e($value->code); ?></td>
                            <td><?php echo e($value->note); ?></td>
                            <td><?php echo e(date('d-m-Y', strtotime($value->created_at))); ?></td>
                            <td>
                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Size Edit')): ?>
                                    <a data-href="<?php echo e(route('get-edit-size',$value->id)); ?>"
                                       class=" button_info btn_edit"><?php echo e(__('administrator.edit')); ?></a>
                                <?php endif; ?>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>

    <script type="text/javascript">
        var $form_content = `
                <input type="text" name="size" class="form-control border-red" required placeholder="<?php echo e(__('administrator.size')); ?>" maxlength="40">
                <input type="text" name="code" class="form-control border-red" required placeholder="<?php echo e(__('administrator.code')); ?>" maxlength="40">
                <textarea name="note" id="" rows="5" maxlength="100" class="no-resize form-control" placeholder="<?php echo e(__('administrator.note')); ?>" ></textarea>`;
        $('.create_size').on('click', function () {
            form($form_content,'<?php echo e(__('administrator.submit')); ?>','<?php echo e(__('administrator.create')); ?>','<?php echo e(route('product-size.store')); ?>');
        });
        $('.btn_edit').on('click', function () {
            var url = $(this).data('href');
            $.ajax({
                url: url,
                dataType: 'json',
                method: 'get'
            }).done(function (response) {
                form($form_content,'<?php echo e(__('administrator.update')); ?>','<?php echo e(__('administrator.edit')); ?>','<?php echo e(route('update-size')); ?>',response.size,response.note,response.id);
            }).fail(function () {
                console.log(2);
            });
        });

        function form($fcontent='',btntext='',title='',route='',size='',note='',id='',code=''){
            $.confirm({
                title:title+' <?php echo e(__('administrator.size')); ?>',
                content:$fcontent,
                theme:'modern',
                buttons:{
                    cancel:{
                        text:'<?php echo e(__('administrator.cancel')); ?>',
                        btnClass:'button_warning',
                        action:function () {

                        }
                    },
                    submit:{
                        text:btntext,
                        btnClass:'button_primary',
                        action:function () {
                            var self = this;
                            var size = self.$content.find('input[name=size]').val();
                            var code = self.$content.find('input[name=code]').val();
                            var note = self.$content.find('textarea[name=note]').val();
                            self.buttons.submit.disable();
                            $.ajax({
                                url: route,
                                dataType: 'json',
                                data:{
                                    "_token": "<?php echo e(csrf_token()); ?>",
                                    size:size,
                                    code:code,
                                    note:note,
                                    id:id,
                                },
                                method: 'post'
                            }).done(function (response) {
                                if(response=='success'){
                                    window.location.reload();
                                }
                            }).fail(function(xhr){
                                var error = xhr.responseJSON.errors;
                                var text_err = '';
                                $.each(error, function (i, val) {
                                    text_err += '' + val + '<br>';
                                });
                                if (text_err == '') {
                                    text_err = 'Data is Invalid...';
                                }
                                $.alert(text_err);
                                self.buttons.submit.enable();
                            });
                            return false;
                        }
                    },
                }
            });

            if(size){
                setTimeout(function () {
                    $(document).find('textarea[name=note]').text(note);
                    $(document).find('input[name=size]').val(size);
                    $(document).find('input[name=code]').val(code);
                    $(".focus").focus();
                },1);
            }
        }



        $('#data_table').DataTable({
            "oLanguage": {
                "sSearch": "<?php echo e(__('administrator.search')); ?>:",
                "sLengthMenu": "<?php echo e(__('administrator.display')); ?> _MENU_ <?php echo e(__('administrator.record_per_page')); ?>",
                "sZeroRecords": "<?php echo e(__('administrator.Nothing_foundsorry')); ?>",
                "sInfo": "<?php echo e(__('administrator.showing')); ?> _START_ <?php echo e(__('administrator.to')); ?> _END_ <?php echo e(__('administrator.of')); ?> _TOTAL_ <?php echo e(__('administrator.record')); ?>",
                "sInfoEmpty": "<?php echo e(__('administrator.showing')); ?> 0 <?php echo e(__('administrator.to')); ?> 0 <?php echo e(__('administrator.of')); ?> 0 <?php echo e(__('administrator.record')); ?>",
                "sInfoFiltered": "(<?php echo e(__('administrator.filter_form')); ?> _MAX_ <?php echo e(__('administrator.total_records')); ?>)",
                "oPaginate": {
                    "sFirst": "<?php echo e(__('administrator.first')); ?>",
                    "sLast": "<?php echo e(__('administrator.last')); ?>",
                    "sNext": "<?php echo e(__('administrator.next')); ?>",
                    "sPrevious": "<?php echo e(__('administrator.previous')); ?>"
                },
                lengthMenu: [[20, 30, 50, 100, 200, 500, 1000], [20, 30, 50, 100, 200, 500, 1000]],
            }

        });
    </script>
<?php $__env->stopSection(); ?>




<?php echo $__env->make(branchMenu(), \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/nsowos/public_html/shr-brand/resources/views/administrator/setup-item/product-element/size/index.blade.php ENDPATH**/ ?>