<?php $__env->startSection('content'); ?>
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-body">
                    <div class="row">
                        <div class="col-sm-12 col-xs-12 ">
                            <form id="StorageSetting" class="ajax-form" method="POST">
                                <?php echo csrf_field(); ?>
                                <div class="form-body">
                                    <div class="row">
    
                                        <div class="col-xs-12">
                                            <div class="form-group">
                                                <label class="control-label"><?php echo app('translator')->get('menu.selectStorage'); ?></label>
                                                <select class="select2 form-control" id="storage"
                                                    name="storage">
                                                    <option value="local" <?php if(isset($local) &&
                                                        $local->status == 'enabled'): ?> selected
                                                        <?php endif; ?>><?php echo app('translator')->get('menu.local'); ?></option>
                                                    <option value="aws" <?php if(isset($S3data) &&
                                                        $S3data->status == 'enabled'): ?> selected
                                                        <?php endif; ?>><?php echo app('translator')->get('menu.aws'); ?></option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="col-md-12 aws-form">
                                            <div class="form-group">
                                                <label>AWS Key</label>
                                                <input type="text" class="form-control" name="aws_key"
                                                    <?php if(isset($S3data->key)): ?>
                                                value="<?php echo e($S3data->key); ?>" <?php endif; ?> >
                                            </div>
                                            <div class="form-group">
                                                <label>AWS Secret</label>
                                                <input type="password" class="form-control" name="aws_secret"
                                                    <?php if(isset($S3data->secret)): ?>
                                                value="<?php echo e($S3data->secret); ?>" <?php endif; ?>>
                                            </div>
                                            <div class="form-group">
                                                <label>AWS Region</label>
                                                <select class="select2 form-control" name="aws_region">
                                                    <?php $__currentLoopData = \App\StorageSetting::$awsRegions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key =>
                                                    $region): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
    
                                                    <option <?php if(isset($S3data) && $S3data->
                                                        region == $key): ?> selected <?php endif; ?>
                                                        value="<?php echo e($key); ?>"><?php echo e($region); ?></option>
    
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    
                                                </select>
                                            </div>
                                            <div class="form-group">
                                                <label>AWS Bucket</label>
                                                <input type="text" class="form-control" name="aws_bucket"
                                                    <?php if(isset($S3data->bucket)): ?>
                                                value="<?php echo e($S3data->bucket); ?>" <?php endif; ?>>
                                            </div>
                                        </div>
    
                                    </div>
    
                                    <!--/row-->
    
                                </div>
                                <div class="form-actions">
                                    <button type="button" id="save-form" class="btn btn-success"><i
                                            class="fa fa-check"></i>
                                        <?php echo app('translator')->get('app.save'); ?>
                                    </button>
    
                                    <button type="button" id="test-aws" class="aws-form btn btn-primary">Test
                                        AWS S3</button>
    
    
                                </div>
                            </form>
                    </div>
                </div>



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

<?php $__env->startPush('footer-script'); ?>
<?php $__env->startPush('footer-script'); ?>


<script>
    
            $(function () {
                <?php if($local->status == "disabled"): ?>
                    $('.aws-form').show();
                <?php else: ?>  
                     $('.aws-form').hide();
                <?php endif; ?>
            $('#storage').on('change', function(event) {
                event.preventDefault();
                var type = $(this).val();
                if (type == 'aws') {
                    $('.aws-form').show();
                } else if(type == 'local') {
                    $('.aws-form').hide();
                }
            });
            });
            
            $('#save-form').click(function () {
                // alert('wffe');
            $.easyAjax({
                url: '<?php echo e(route('admin.storage-settings.store')); ?>',
                container: '#StorageSetting',
                type: "POST",
                redirect: true,
                data: $('#StorageSetting').serialize(),
                success: function(response){
                    if(response.status == 'success' && response.storage =='aws') {
                        // $('.aws-form').show();
                    }
                    
                 }
            })
        });

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

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/hoseadevimcon/hr.hosea.dev-imcon.com/resources/views/admin/storage-setting/index.blade.php ENDPATH**/ ?>