
<?php $__env->startSection('title'); ?>
    <title><?php echo e($websiteLang->where('lang_key','my_property')->first()->custom_text); ?></title>
<?php $__env->stopSection(); ?>


<?php $__env->startSection('user-dashboard'); ?>
<div class="row">
    <div class="col-xl-9 ms-auto">
        <div class="wsus__dashboard_main_content">
          <div class="wsus__my_property">
            <h4 class="heading"><?php echo e($websiteLang->where('lang_key','my_property')->first()->custom_text); ?> <a href="<?php echo e(route('user.create.property')); ?>" class="common_btn"><i class="fal fa-plus-octagon"></i> <?php echo e($websiteLang->where('lang_key','create')->first()->custom_text); ?></a></h4>
            <div class="row">
              <div class="col-12">
                <div class="table-responsive">
                    <table class="table">
                      <tr>
                          <th class="image">
                            <?php echo e($websiteLang->where('lang_key','img')->first()->custom_text); ?>

                          </th>
                          <th class="title">
                            <?php echo e($websiteLang->where('lang_key','property')->first()->custom_text); ?>

                          </th>
                          <th class="purpose">
                            <?php echo e($websiteLang->where('lang_key','purpose')->first()->custom_text); ?>

                          </th>
                          <th class="status">
                            <?php echo e($websiteLang->where('lang_key','status')->first()->custom_text); ?>

                          </th>
                          <th class="actions">
                            <?php echo e($websiteLang->where('lang_key','action')->first()->custom_text); ?>

                          </th>
                      </tr>
                      <?php $__currentLoopData = $properties; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                      <tr>
                          <td class="image">
                              <a href="<?php echo e(route('property.details',$item->slug)); ?>">
                                  <img src="<?php echo e(url($item->thumbnail_image)); ?>" alt="img" class="img-fluid w-100">
                              </a>
                          </td>
                          <td class="title">
                              <h5><a href="<?php echo e(route('property.details',$item->slug)); ?>"><?php echo e($item->title); ?></a></h5>
                              <p class="address"><?php echo e($item->address.', '.$item->city->name); ?></p>

                                <?php
                                    $total_review=$item->reviews->where('status',1)->count();
                                    if($total_review > 0){
                                        $avg_sum=$item->reviews->where('status',1)->sum('avarage_rating');


                                        $avg=$avg_sum/$total_review;
                                        $intAvg=intval($avg);
                                        $nextVal=$intAvg+1;
                                        $reviewPoint=$intAvg;
                                        $halfReview=false;
                                        if($intAvg < $avg && $avg < $nextVal){
                                            $reviewPoint= $intAvg + 0.5;
                                            $halfReview=true;
                                        }

                                    }
                                ?>

                              <?php if($total_review > 0): ?>
                                <p class="rating">
                                    <span><?php echo e(sprintf("%.1f", $reviewPoint)); ?></span>
                                    <?php for($i = 1; $i <=5; $i++): ?>
                                        <?php if($i <= $reviewPoint): ?>
                                            <i class="fas fa-star"></i>
                                        <?php elseif($i> $reviewPoint ): ?>
                                            <?php if($halfReview==true): ?>
                                            <i class="fas fa-star-half-alt"></i>
                                                <?php
                                                    $halfReview=false
                                                ?>
                                            <?php else: ?>
                                            <i class="fal fa-star"></i>
                                            <?php endif; ?>
                                        <?php endif; ?>
                                    <?php endfor; ?>
                                    <span>(<?php echo e($total_review); ?> <?php echo e($websiteLang->where('lang_key','review')->first()->custom_text); ?>)</span>
                                </p class="rating">
                                <?php else: ?>
                                    <p>
                                        <span>0.0</span>
                                        <?php for($i = 1; $i <=5; $i++): ?>
                                        <i class="fal fa-star"></i>
                                        <?php endfor; ?>
                                        <span>(<?php echo e(0); ?> <?php echo e($websiteLang->where('lang_key','review')->first()->custom_text); ?>)</span>
                                    </p>
                                <?php endif; ?>

                          </td>
                          <td class="purpose">
                              <p><?php echo e($item->propertyPurpose->custom_purpose); ?></p>
                          </td>
                          <td class="status">
                                <?php if($item->status==1): ?>
                                    <?php if($item->expired_date==null): ?>
                                    <p class="active"><?php echo e($websiteLang->where('lang_key','active')->first()->custom_text); ?></p>
                                    <?php elseif($item->expired_date >= date('Y-m-d')): ?>
                                    <p class="active"><?php echo e($websiteLang->where('lang_key','active')->first()->custom_text); ?></p>
                                    <?php else: ?>
                                    <p ><?php echo e($websiteLang->where('lang_key','inactive')->first()->custom_text); ?></p>
                                    <?php endif; ?>
                                <?php else: ?>
                                <p ><?php echo e($websiteLang->where('lang_key','inactive')->first()->custom_text); ?></p>
                                <?php endif; ?>
                          </td>
                          <td class="actions">
                            <ul class="d-flex">
                              <li><a href="<?php echo e(route('property.details',$item->slug)); ?>"><i class="far fa-eye"></i></a></li>
                              <li><a href="<?php echo e(route('user.property.edit',$item->id)); ?>"><i class="fal fa-edit"></i></a></li>
                              <li><a onclick="deleteProperty('<?php echo e($item->id); ?>')"><i class="far fa-trash-alt"></i></a></li>
                            </ul>
                          </td>
                      </tr>

                      <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                  </table>
                </div>
              </div>
              <div class="col-12 mt_25">
                <?php echo e($properties->links('user.paginator')); ?>

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

<script>
    function deleteProperty(id){
        Swal.fire({
            title: "<?php echo e($websiteLang->where('lang_key','are_you_sure')->first()->custom_text); ?>",
            text: "<?php echo e($websiteLang->where('lang_key','delete_des')->first()->custom_text); ?>",
            icon: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: "<?php echo e($websiteLang->where('lang_key','yes_delete')->first()->custom_text); ?>",
            cancelButtonText: "<?php echo e($websiteLang->where('lang_key','cancel')->first()->custom_text); ?>",
        }).then((result) => {
            if (result.isConfirmed) {
                Swal.fire(
                    "<?php echo e($websiteLang->where('lang_key','delete')->first()->custom_text); ?>",
                    "<?php echo e($websiteLang->where('lang_key','delete_success')->first()->custom_text); ?>",
                    'success'
                )
                location.href = "<?php echo e(url('user/delete-property/')); ?>" + "/" + id;
            }
        })
    }
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.user.profile.layout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/cloudelite/imobi.eliteteclda.com/resources/views/user/profile/property/index.blade.php ENDPATH**/ ?>