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

<main>
    <!-- Start pg_header -->
    <?php echo $__env->make('web.pages.components.header.header', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

    <!-- Start section -->
    <section class="checkout_pg section">
        <div class="container">
            <form method="post" action="<?php echo e($action); ?>" onsubmit="formAction(this)">
                <?php echo csrf_field(); ?>
                <div class="row">
                    <div class="col-lg-12">
                        <div class=" mb-5">
                            <!-- Location -->
                            <div class="box mb-5">
                                <h2 class="sec_title bb fw-bold mb-5">    <?php echo e(__('web.addresses')); ?>      </h2>

                                <div class="row mb-4">
                                    <?php if(!auth()->user()): ?>
                                        <div class="col-lg-6">
                                            <div class="form-group mb-4">
                                                <input name="name" value="<?php echo e($account['user']->name); ?>" class="form-control" placeholder=" <?php echo e(__('web.name')); ?>  "/>
                                            </div>
                                        </div>
                                        <div class="col-lg-6">
                                            <div class="form-group mb-4">
                                                <input type="email" name="email" value="<?php echo e($account['user']->email); ?>" class="form-control" placeholder="<?php echo e(__('web.email')); ?>"/>
                                            </div>
                                        </div>
                                        <div class="col-lg-6">
                                            <div class="form-group phone_group mb-4">
                                                <input type="number" name="phone" value="<?php echo e($account['user']->phone); ?>" class="form-control" placeholder="<?php echo e(__('web.phone')); ?>"/>
                                                <select class="phoneSelect">
                                                    <option>966</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="col-lg-6"></div>
                                    <?php endif; ?>
                                    <?php $__currentLoopData = $addresses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <div class="col-lg-4">
                                        <div class="form-check mb-3">
                                            <input class="form-check-input" type="radio" name="address_id" value="<?php echo e($row->id); ?>" id="locRadio<?php echo e($row->id); ?>" >
                                            <label class="form-check-label" for="locRadio<?php echo e($row->id); ?>">
                                                <?php echo $row->address; ?>

                                            </label>
                                        </div>
                                    </div>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    <div class="col-lg-4">
                                        <div class="form-check mb-3">
                                            <input class="form-check-input" type="radio" value="" name="address_id" id="locRadio0" >
                                            <label class="form-check-label" for="locRadio0">
                                                <?php echo e(__('web.add_new_address')); ?>

                                            </label>
                                        </div>
                                    </div>



                                </div>
                                <div class="row mb-0 mt-5" id="newLocForm">
                                    <div class="col-lg-6">
                                        <div class="row">

                                            <div class="col-lg-6">
                                                <div class="mb-4">
                                                    <label class="inputLabel"> <?php echo e(__('web.country_id')); ?>  </label>
                                                    <select name="country_id" onchange="fetchCities(this)" class="form-control form-select">
                                                        <option value=""><?php echo e(__('web.select')); ?></option>
                                                        <?php $__currentLoopData = $countries; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <option value="<?php echo e($row->id); ?>"><?php echo e($row->title); ?></option>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="col-lg-6">
                                                <div class="mb-4">
                                                    <label class="inputLabel"> <?php echo e(__('web.city_id')); ?>  </label>
                                                    <select name="city_id" id="city_id" class="form-control form-select">
                                                        <option value=""><?php echo e(__('web.select')); ?></option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="col-lg-12">
                                                <div class="mb-4">
                                                    <label class="inputLabel"><?php echo e(__('web.address_details')); ?></label>
                                                    <input type="text" name="address"  class="form-control" placeholder="">
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="col-lg-6">
                                        <input type="hidden" name="latitude" id="latitude" value="<?php echo e($address->latitude ?? ''); ?>">
                                        <input type="hidden" name="longitude" id="longitude" value="<?php echo e($address->longitude ?? ''); ?>">
                                        <div id="map" style="width: 100%;height: 20pc"></div>
                                    </div>
                                </div>
                            </div>

                        </div>
                    </div>

                    <div class="butns d-flex align-items-center justify-content-center">
                        <a href="<?php echo e(route('cart.index')); ?>" class="butn primary_border_butn me-2"> <?php echo e(__('web.back')); ?>  </a>
                        <button type="submit" class="butn primary_butn">
                            <?php echo e(__('web.next')); ?>

                        </button>
                    </div>

                </div>
            </form>
        </div>
    </section>



</main>

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

<?php $__env->startSection('inject_js'); ?>
    <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCOuP7Khf-OXuiervHfHONEq9QmLUarsTA&libraries=places"></script>
    <script src="<?php echo e(url('')); ?>/assets/web/js/custom/address.js"></script>
    <script>
        let url_fetch_cities = "<?php echo e(route('web.fetch.cities')); ?>"
    </script>
    <script type="text/javascript">

        var latlng = new google.maps.LatLng(<?php echo isset($address) ? $address->latitude.', '.$address->longitude : '21.4989, 39.2509'; ?>);
        var map = new google.maps.Map(document.getElementById('map'), {
            center: latlng,
            zoom: 11,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        });
        var marker = new google.maps.Marker({
            position: latlng,
            map: map,
            title: 'Set lat/lon values for this property',
            draggable: true
        });
        google.maps.event.addListener(marker, 'dragend', function(a) {
            var div = document.createElement('div');
            document.getElementsByTagName('body')[0].appendChild(div);
            $("#latitude").val(function() {
                return  a.latLng.lat().toFixed(4);
            });
            $("#longitude").val(function() {
                return  a.latLng.lng().toFixed(4);
            });
        });

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

<?php echo $__env->make('web.layouts.layout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /Applications/MAMP/htdocs/electric/resources/views/web/pages/orders/checkout_address.blade.php ENDPATH**/ ?>