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

 <section class="inner_header">
        <img src="<?php echo e(url('')); ?>/assets/web/images/icons/inner.svg" alt="" class="inner_shap">
        <div class="container">
            <ul class="links">
                <li>
                    <a href="<?php echo e(url(getCurrentLocale().'/')); ?>"><i class="bi bi-house"></i></a>
                </li>
                <li>
                    <a href="<?php echo e(url(getCurrentLocale().'/stores')); ?>"> <?php echo e(__('web.stores')); ?> </a>
                </li>
            </ul>
            <h4><?php echo e(__('web.stores')); ?></h4>
        </div>
    </section>
    <!--End-inner_header-->
    <!--Contents-->
    <main>
        <!-- -------------- about --------------- -->
        <section class="shops section_padding bg_gray">
            <div class="container">
                <div class="row align-items-center">
                    <div class="col-lg-6">
                        <h3><?php echo e(__('web.stores')); ?> <small class="text-secondary" id="countStore">( <?php echo e(count($stores)); ?>  )</small></h3>
                    </div>
                    <div class="col-lg-6 text-right" style="display:none" id="showmap">
                        <a href="#"  class="butn main_color" data-toggle="modal" data-target="#modal_map">
                            <span><?php echo e(__('web.on_map')); ?></span>
                        </a>
                    </div>
                </div>
                <div class="shops_filter mb-4">
                    <form id="filter" action="<?php echo e(url(getCurrentLocale().'/filter')); ?>" class="form">
                        <?php echo csrf_field(); ?>
                        <div class="row">
                            <div class="col-lg-3">
                                <div class="form-group">
                                    <label for=""><?php echo e(__('web.category_store')); ?></label>
                                    <select name="category_id" id="category_id" onchange="filter()" class="custom-select form-control">
                                        <option value=""><?php echo e(__('web.all')); ?></option>
                                        <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($row->id); ?>"><?php echo e(categorydescription($row->id,'name')); ?></option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                </div>
                            </div>
                            <div class="col-lg-3">
                                <div class="form-group">
                                    <label for=""><?php echo e(__('web.city')); ?></label>
                                    <select name="city_id" id="city" onchange="citySelect(this)" class="custom-select form-control">
                                        <option value=""><?php echo e(__('web.all')); ?></option>
                                         <?php $__currentLoopData = $cities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($row->id); ?>"><?php echo e(citydescription($row->id,'name')); ?></option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                </div>
                            </div>
                            <div class="col-lg-3">
                                <div class="form-group">
                                    <label for=""><?php echo e(__('web.area')); ?></label>
                                    <select name="area_id" id="areas" onchange="filter()" class="custom-select form-control">
                                        <option selected disabled><?php echo e(__('web.select_city')); ?></option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-lg-3">
                                <div class="form-group">
                                    <label for="">التقييم</label>
                                    <select name="rate" id="rate" onchange="filter()" class="custom-select form-control">
                                        <option selected value=""><?php echo e(__('web.all')); ?></option>
                                        <option value="5">5 <?php echo e(__('web.star')); ?></option>
                                        <option value="4">4 <?php echo e(__('web.star')); ?></option>
                                        <option value="3">3 <?php echo e(__('web.star')); ?></option>
                                        <option value="2">2 <?php echo e(__('web.star')); ?></option>
                                        <option value="1">1 <?php echo e(__('web.star')); ?></option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>

                <div class="shops_contt">
                    <div class="row" id="stores">
                        <?php $__currentLoopData = $stores; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <div class="col-lg-4">
                            <a href="<?php echo e(url(getCurrentLocale().'/stores/'.$row->id)); ?>">
                            <div class="product_card my-3">
                                <div class="img">
                                    <img class="ob_cover" src="<?php echo e(asset($row->banner)); ?>" alt="">
                                </div>
                                <div class="info">
                                    <img src="<?php echo e(asset($row->image)); ?>" alt="" class="prod_logo">
                                    <h5><?php echo e(storedescription($row->id,'name')); ?></h5>
                                    <small><?php echo e(categorydescription($row->category_id,'name')); ?> </small>
                                    <div class="text">
                                        <?php echo storedescription($row->id,'description'); ?>

                                    </div>
                                </div>
                            </div>
                            </a>
                        </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>
                    <!--<nav aria-label="Page navigation example">-->
                    <!--    <ul class="pagination">-->
                    <!--        <li class="page-item">-->
                    <!--            <a class="page-link" href="#">-->
                    <!--                <i class="bi bi-arrow-right"></i>-->
                    <!--            </a>-->
                    <!--        </li>-->
                    <!--        <li class="page-item"><a class="page-link" href="#">1</a></li>-->
                    <!--        <li class="page-item"><a class="page-link" href="#">2</a></li>-->
                    <!--        <li class="page-item"><a class="page-link" href="#">3</a></li>-->
                    <!--        <li class="page-item">-->
                    <!--            <a class="page-link" href="#">-->
                    <!--                <i class="bi bi-arrow-left"></i>-->
                    <!--            </a>-->
                    <!--        </li>-->
                    <!--    </ul>-->
                    <!--    </nav>-->
                </div>
            </div>
        </section>
    </main>


<div class="modal fade modal_map" id="modal_map" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
        aria-hidden="true">
        <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
            <div class="modal-content rounded-0">
                <div class="modal-body" id="maping">
                     <div class="map" >
                        <div id="map"  style="width: 100%; height: 400px;"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>

<?php $__env->startPush('js'); ?>
<?php $__env->startPush('js'); ?>
<script type="text/javascript">
    var locations = [
      
    ];
    <?php $__currentLoopData = $stores; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
    <?php 
    $arr = explode(',',$row->latlng);
    $lat = $arr[0];
    $lng = $arr[1];
    ?>
    var array = [<?php echo json_encode(storedescription($row->id,'name')); ?> , <?php echo $lat; ?> , <?php echo $lng; ?>];
    locations.push( array );
    <?php $__currentLoopData = branchestore($row->id); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $branch): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
    <?php 
    $arr = explode(',',$branch->latlng);
    $lat = $arr[0];
    $lng = $arr[1];
    ?>
    var array = [<?php echo json_encode(branchdescription($row->id,'name')); ?> , <?php echo $lat; ?> , <?php echo $lng; ?>];
    locations.push( array );
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    <?php if(count($stores)>0): ?>
    <?php
    $latlng  = $stores[0]['latlng'];
    ?>
    <?php else: ?>
    <?php
    $latlng = '21.6062, 39.4068';
    ?>
    <?php endif; ?>
    
    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 10,
      center: new google.maps.LatLng(<?php echo $latlng; ?>),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });
    
    var infowindow = new google.maps.InfoWindow();

    var marker, i;
    
    for (i = 0; i < locations.length; i++) {  
      marker = new google.maps.Marker({
        position: new google.maps.LatLng(locations[i][1], locations[i][2]),
        map: map
      });
      
      google.maps.event.addListener(marker, 'click', (function(marker, i) {
        return function() {
          infowindow.setContent(locations[i][0]);
          infowindow.open(map, marker);
        }
      })(marker, i));
    }
  </script>
<?php $__env->stopPush(); ?>
<script>
    
    function citySelect(elem)
    {
        let data = $(elem).val();
        if(data != ''){
      $.ajax
        ({
          url : <?php echo json_encode(url(getCurrentLocale().'/citySelect')); ?>+'/'+data,
          type: 'GET',              
          data: 'dataform',
          success:function(data)
          {
            $('#areas').html(data);
            filter();
          }
          
        })
        }
        else{
            $('#areas').html("<option selected disabled>"+<?php echo json_encode(__('web.select_city')); ?>+"</option>");
            filter();
        }
    }
    function filter()
    {
        event.preventDefault(); 
        let action = $('#filter').attr('action');
        let category = $('#category_id').val();
        let city = $('#city').val();
        let area = $('#areas').val();
        let rate = $('#rate').val();
       
       
        let urls = action;
        let url_count = <?php echo json_encode(url(getCurrentLocale().'/filtercount')); ?>;
        let url_map = <?php echo json_encode(url(getCurrentLocale().'/filtermap')); ?>;
        let dataform = $('#filter').serialize();
        if(category == '' && city == '' && area == null && rate == ''){
            $('#showmap').css('display','none');
        }
        else{
            
            $('#showmap').css('display','block');
        }
        $.ajax
        ({
          url : urls,
          type: 'POST',              
          data: dataform,
          success:function(data)
          {
                $('#stores').html(data);
      
          }
        })
        $.ajax
        ({
          url : url_count,
          type: 'POST',              
          data: dataform,         
          dataType: 'json',
          success:function(data)
          {
                $('#countStore').html('( '+data.count+' )');
                $('#url').attr('src',data.url);
      
          }
        })
        $.ajax
        ({
          url : url_map,
          type: 'POST',              
          data: dataform,     
          success:function(data)
          {
                $('#maping').html(data);
      
          }
        })
    }
</script>
<?php $__env->stopPush(); ?>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('web.layouts.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/omaralyomhost/public_html/4u/resources/views/web/pages/store/stores.blade.php ENDPATH**/ ?>