<?php $__env->startSection('title', translate('Add new branch')); ?>

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

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

<?php $__env->startSection('content'); ?>
    <div class="content container-fluid">
        <!-- Page Header -->
        <div class="page-header">
            <div class="row align-items-center">
                <div class="col-sm mb-2 mb-sm-0">
                    <h1 class="page-header-title"><i class="tio-add-circle-outlined"></i> <?php echo e(translate('add New Branch')); ?></h1>
                </div>
            </div>
        </div>
        <!-- End Page Header -->
        <div class="row gx-2 gx-lg-3">
            <div class="col-sm-12 col-lg-12 mb-3 mb-lg-2">
                <form action="<?php echo e(route('admin.branch.store')); ?>" method="post" enctype="multipart/form-data">
                    <?php echo csrf_field(); ?>
                    <div class="row">
                        <div class="col-6">
                            <div class="form-group">
                                <label class="input-label" for="exampleFormControlInput1"><?php echo e(translate('name')); ?></label>
                                <input type="text" name="name" class="form-control" placeholder="<?php echo e(translate('New branch')); ?>" value="<?php echo e(old('name')); ?>" maxlength="255" required>
                            </div>
                        </div>
                        <div class="col-6">
                            <div class="form-group">
                                <label class="input-label" for="exampleFormControlInput1"><?php echo e(translate('email')); ?></label>
                                <input type="email" name="email" class="form-control" value="<?php echo e(old('email')); ?>"
                                       maxlength="255" placeholder="<?php echo e(translate('EX : example@example.com')); ?>"
                                       required>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-5">
                            <div class="form-group">
                                <label class="input-label" for=""><?php echo e(translate('latitude')); ?></label>
                                <input type="number" name="latitude" class="form-control" placeholder="<?php echo e(translate('Ex : -132.44442')); ?>"
                                       maxlength="255" value="<?php echo e(old('latitude')); ?>" step="any"
                                       required>
                            </div>
                        </div>
                        <div class="col-5">
                            <div class="form-group">
                                <label class="input-label" for=""><?php echo e(translate('longitude')); ?></label>
                                <input type="number" name="longitude" class="form-control" placeholder="<?php echo e(translate('Ex : 94.233')); ?>"
                                       maxlength="255" value="<?php echo e(old('longitude')); ?>" step="any"
                                       required>
                            </div>
                        </div>
                        <div class="col-2">
                            <div class="form-group">
                                <label class="input-label" for="">
                                    <i class="tio-info-outined"
                                       data-toggle="tooltip"
                                       data-placement="top"
                                       title="<?php echo e(translate('This value is the radius from your restaurant location, and customer can order food inside  the circle calculated by this radius.')); ?>"></i>
                                    <?php echo e(translate('coverage (km)')); ?>

                                </label>
                                <input type="number" name="coverage" min="1" max="1000" class="form-control"
                                       placeholder="<?php echo e(translate('Ex : 3')); ?>" value="<?php echo e(old('coverage')); ?>"
                                       required>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-6">
                            <div class="form-group">
                                <label class="input-label" for=""><?php echo e(translate('address')); ?></label>
                                <input type="text" name="address" class="form-control" placeholder="" value="<?php echo e(old('address')); ?>" required>
                            </div>
                        </div>
                        <div class="col-6">
                            <div class="form-group">
                                <label class="input-label" for="exampleFormControlInput1"><?php echo e(translate('password')); ?></label>
                                <input type="text" name="password" class="form-control" placeholder="<?php echo e(translate('Password')); ?>" maxlength="255" value="<?php echo e(old('password')); ?>" required>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label><?php echo e(translate('Branch Image')); ?></label><small style="color: red">* ( <?php echo e(translate('ratio')); ?> 1:1 )</small>
                        <div class="custom-file">
                            <input type="file" name="image" id="customFileEg1" class="custom-file-input" value="<?php echo e(old('image')); ?>"
                                   accept=".jpg, .png, .jpeg, .gif, .bmp, .tif, .tiff|image/*" required>
                            <label class="custom-file-label" for="customFileEg1"><?php echo e(translate('Choose File')); ?></label>
                        </div>
                        <div class="text-center mt-2">
                            <img style="height: 200px;border: 1px solid; border-radius: 10px;" id="viewer"
                                 src="<?php echo e(asset('public/assets/admin/img/400x400/img2.jpg')); ?>" alt="branch image"/>
                        </div>
                    </div>

                    <button type="submit" class="btn btn-primary"><?php echo e(translate('submit')); ?></button>
                </form>
            </div>

            <div class="col-sm-12 col-lg-12 mb-3 mb-lg-2 mt-2">
                <div class="card">
                    <div class="card-header flex-between">
                        <div class="flex-start">
                            <h5 class="card-header-title"><?php echo e(translate('Branch Table')); ?></h5>
                            <h5 class="card-header-title text-primary mx-1">(<?php echo e($branches->total()); ?>)</h5>
                        </div>
                        <div>
                            <form action="<?php echo e(url()->current()); ?>" method="GET">
                                <div class="input-group">
                                    <input id="datatableSearch_" type="search" name="search"
                                           class="form-control"
                                           placeholder="<?php echo e(translate('Search')); ?>" aria-label="Search"
                                           value="<?php echo e($search); ?>" required autocomplete="off">
                                    <div class="input-group-append">
                                        <button type="submit" class="input-group-text"><i class="tio-search"></i>
                                        </button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                    <!-- Table -->
                    <div class="table-responsive datatable-custom">
                        <table id="columnSearchDatatable"
                               class="table table-borderless table-thead-bordered table-nowrap table-align-middle card-table"
                               data-hs-datatables-options='{
                                 "order": [],
                                 "orderCellsTop": true
                               }'>
                            <thead class="thead-light">
                            <tr>
                                <th style="width: 5%"><?php echo e(translate('#')); ?></th>
                                <th><?php echo e(translate('image')); ?></th>
                                <th><?php echo e(translate('name')); ?></th>
                                <th><?php echo e(translate('email')); ?></th>
                                <th style="width: 10%"><?php echo e(translate('action')); ?></th>
                            </tr>

                            </thead>

                            <tbody>
                            <?php $__currentLoopData = $branches; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$branch): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td><?php echo e($branches->firstItem()+$key); ?></td>
                                    <td>
                                        <img class="" height="60px" width="60px"
                                             onerror="this.src='<?php echo e(asset('public/assets/admin/img/160x160/img2.jpg')); ?>'"
                                             src="<?php echo e(asset('storage/app/public/branch')); ?>/<?php echo e($branch['image']); ?>">
                                    </td>
                                    <td>
                                    <span class="d-block font-size-sm text-body text-trim-50">
                                        <?php echo e($branch['name']); ?> <?php if($branch['id']==1): ?>
                                            <label class="badge badge-danger"><?php echo e(translate('main')); ?></label>
                                        <?php else: ?>
                                            <label class="badge badge-info"><?php echo e(translate('sub')); ?></label>
                                        <?php endif; ?>
                                    </span>
                                    </td>
                                    <td>
                                        <a href="mailto:<?php echo e($branch['email']); ?>?subject=<?php echo e(translate('Mail from '). \App\Model\BusinessSetting::where(['key' => 'restaurant_name'])->first()->value); ?>"><?php echo e($branch['email']); ?></a>
                                    </td>
                                    <td>
                                        <!-- Dropdown -->
                                        <div class="dropdown">
                                            <button class="btn btn-secondary dropdown-toggle" type="button"
                                                    id="dropdownMenuButton" data-toggle="dropdown"
                                                    aria-haspopup="true"
                                                    aria-expanded="false">
                                                <i class="tio-settings"></i>
                                            </button>
                                            <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                                                <a class="dropdown-item"
                                                   href="<?php echo e(route('admin.branch.edit',[$branch['id']])); ?>"><?php echo e(translate('edit')); ?></a>
                                                <?php if($branch['id']!=1): ?>
                                                    <a class="dropdown-item" href="javascript:"
                                                       onclick="form_alert('branch-<?php echo e($branch['id']); ?>','<?php echo e(translate('Want to delete this branch ?')); ?>')"><?php echo e(translate('delete')); ?></a>
                                                    <form action="<?php echo e(route('admin.branch.delete',[$branch['id']])); ?>"
                                                          method="post" id="branch-<?php echo e($branch['id']); ?>">
                                                        <?php echo csrf_field(); ?> <?php echo method_field('delete'); ?>
                                                    </form>
                                                <?php endif; ?>
                                            </div>
                                        </div>
                                        <!-- End Dropdown -->
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                        <hr>
                        <table>
                            <tfoot>
                            <?php echo $branches->links(); ?>

                            </tfoot>
                        </table>
                    </div>
                </div>
            </div>
            <!-- End Table -->
        </div>
    </div>

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

<?php $__env->startPush('script_2'); ?>
    <script>
        function readURL(input) {
            if (input.files && input.files[0]) {
                var reader = new FileReader();

                reader.onload = function (e) {
                    $('#viewer').attr('src', e.target.result);
                }

                reader.readAsDataURL(input.files[0]);
            }
        }

        $("#customFileEg1").change(function () {
            readURL(this);
        });
    </script>
    <script>
        $(document).on('ready', function () {
            // INITIALIZATION OF DATATABLES
            // =======================================================
            var datatable = $.HSCore.components.HSDatatables.init($('#columnSearchDatatable'));

            $('#column1_search').on('keyup', function () {
                datatable
                    .columns(1)
                    .search(this.value)
                    .draw();
            });


            $('#column3_search').on('change', function () {
                datatable
                    .columns(2)
                    .search(this.value)
                    .draw();
            });


            // INITIALIZATION OF SELECT2
            // =======================================================
            $('.js-select2-custom').each(function () {
                var select2 = $.HSCore.components.HSSelect2.init($(this));
            });
        });
    </script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.admin.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/penastud/public_html/pi/store/resources/views/admin-views/branch/index.blade.php ENDPATH**/ ?>