<?php $__env->startSection('styles'); ?>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.2/jquery-confirm.min.css">
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>

    <?php if(session()->has('error')): ?>
        <div class="alert alert-danger"><?php echo e(session()->get('error')); ?></div>
    <?php endif; ?>
    <?php if(session()->has('success')): ?>
        <div class="alert alert-success"><?php echo e(session()->get('success')); ?></div>
    <?php endif; ?>
    <?php if(count($errors) > 0): ?>
        <div class="alert alert-danger">
            <ul>
                <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <li><?php echo e($error); ?></li>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </ul>
        </div>
    <?php endif; ?>
    <div class="row">
        <div class="col-md-12">
            <!-- BEGIN SAMPLE FORM PORTLET-->
            <div class="portlet light bordered">
                <div class="portlet-title">
                    <div class="caption font-red-sunglo">
                        <i class="icon-settings font-red-sunglo"></i>
                        <span class="caption-subject bold uppercase"> Thiết lập mẫu Logo (Mẫu logo này dùng để in ra trong phiếu thu, phiếu chi và hoá đơn )</span>
                    </div>
                </div>
                <div class="portlet-body form">
                    <form role="form" action="<?php echo e(url('admin2/setting/create-logo')); ?>" method="POST" enctype="multipart/form-data">
                        <?php echo csrf_field(); ?>

                        <div class="form-body">
                            <div class="form-group">

                                <div class="fileinput fileinput-new" data-provides="fileinput">
                                    <div class="fileinput-new thumbnail" style="width: 200px; height: 150px;">
                                        <?php if(empty($item->logo)): ?>
                                            <img src="http://www.placehold.it/200x150/EFEFEF/AAAAAA&amp;text=no+image"
                                                 alt=""></div>
                                    <?php else: ?>
                                        <img src="/files/<?php echo e($item->logo); ?>" alt=""></div>
                                <?php endif; ?>
                                <div class="fileinput-preview fileinput-exists thumbnail"
                                     style="max-width: 200px; max-height: 150px;"></div>
                                <div>
                                                                <span class="btn default btn-file">
                                                                    <span class="fileinput-new"> Chọn hình ảnh </span>
                                                                    <span class="fileinput-exists"> Thay đổi </span>
                                                                    <input type="file" name="image"> </span>
                                    <a href="javascript:;" class="btn red fileinput-exists" data-dismiss="fileinput">
                                        Hủy bỏ </a>
                                    <?php if(!empty($item->id)): ?>
                                    <a href="javascript:;" class="btn red delete-img-exists" data-id="<?php echo e($item->id); ?>">
                                        Xóa ảnh </a>
                                        <?php endif; ?>
                                </div>
                            </div>
                            
                            

                        </div>
                        <div class="form-actions">
                            <button type="submit" class="btn blue">Lưu</button>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>

<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.2/jquery-confirm.min.js"></script>

<script>

    $('.ckeditor').ckeditor({
        height: '500px'
    });

    $(document).on('click', '.delete-img-exists', function () {
        var id = $(this).attr('data-id');
        $.confirm({
            title: 'Bạn muốn xóa ảnh này?',

            content: 'Ảnh này sẽ xóa khi xác nhận thao tác!',
            buttons: {
                confirm: {
                    text:'Xác nhận',
                    btnClass: 'btn-blue',
                    action:function () {
                        $.ajax({
                            url: '<?php echo e(url('admin2/setting/delete-logo')); ?>',
                            type:'post',
                            data:{
                                id: id,
                            },
                            success:function () {
                                swal({
                                    title: "Thành công!",
                                    text: "Xóa ảnh thành công!",
                                    icon: "success",
                                });
                                location.reload();
                            },
                            error:function (e) {
                                console.log(e);
                            }
                        })
                    }
                },
                cancel: {
                    text:'Hủy bỏ',
                    action: function () {
                        $.alert('Canceled!');
                    },

                }

            }
        });

    })

</script>

<?php $__env->stopPush(); ?>
<?php echo $__env->make('admin2', \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>