<?php $__env->startSection('main-container'); ?>
<main id="main" class="main">
<?php echo $__env->make('cdn', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

<div class="row page-titles mx-0">

    <div class="col-sm-6 p-md-0">

        <div class="breadcrumb-range-picker">

             <h3>Suggestions</h3>

        </div>

    </div>

    <div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">

        <a href="<?php echo e(route('/')); ?>" class="btns primary-btn ml-4">

            <span class="btn-icon-left" style="color: white">Back</span>

       </a>

   </div>

</div>

<div class="container-fluid" style="margin-top: 15px">

    <?php echo $__env->make('flash_msg', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

    <div class="row">

        <div class="col-12">

            <div class="card">

                <div class="card-body">

                    <form action="<?php echo e(route('user_by_search_suggestion.search')); ?>" method="get">
                        <div class="row">
                            <div class="form-group col-md-4">
                                <select class="form-control dropdown-toggle" name="user_id" type="button" data-toggle="dropdown">
                                    <option value="">Select User</option>
                                    <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($user->id); ?>" <?php echo e($user->id == $request->user_id ? 'selected' : ''); ?>><?php echo e($user->name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                            <div class="col-md-2 form-group">
                                <input type="submit" class="btns primary-btn" value="Filter">
                            </div>
                        </div>
                    </form>

                    <hr>

                    <div class="table-responsive">

                        <table class="table table-border table-hover table-sm" >
                            <thead>

                                <tr>

                                    <th>#</th>

                                    <th>IMAGE</th>

                                    <th>NAME</th>

                                    <th>DATE</th>

                                    <th>MESSAGE</th>



                                    <th class="text-right">Action</th>

                                </tr>

                            </thead>


                            <tbody>

                                <?php if(!empty($suggestions)): ?>

                                <?php $__currentLoopData = $suggestions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                                <tr>

                                    <td><?php echo e(++$key); ?></td>

                                    <td>
                                        <?php if($value->image): ?>
                                        <img src="<?php echo e(url('/uploads/suggestion/'.$value->image)); ?>" height="50" width="50">
                                        <?php endif; ?>
                                    </td>

                                    <td><?php echo e($value->User->name ?? 'N/A'); ?></td>

                                    <td><?php echo e(\Carbon\Carbon::parse($value->created_at)->format('d-m-Y')); ?></td>

                                    
                                    <td style="max-width: 190px">

                                        <?php echo e($value->message); ?>


                                    </td>

                                    <td class="text-right">

                                    <a role="button" data-toggle="modal" data-target="#editSuggestion-<?php echo e($value->id); ?>">
                                        <button type="button" class="btns success-btn btn-sm" id="remarkButton-<?php echo e($value->id); ?>">
                                            <i class="fas fa-comment"></i>
                                            <?php if($value->remark): ?>
                                                <span>Edit Remark</span>
                                            <?php else: ?>
                                                <span>Add Remark</span>
                                            <?php endif; ?>
                                        </button>
                                    </a>

                                    <a role="button" data-toggle="modal" data-target="#viewSuggestion-<?php echo e($value->id); ?>">
                                    <button type="button" class="btns success-btn btn-sm" title="View Remark" alt="View Remark"><i class="fas fa-eye"></i>
                                        </button>
                                    </a>

                                   <!-- Modal view remark-->
                                    <div class="modal fade" id="viewSuggestion-<?php echo e($value->id); ?>" tabindex="-1" role="dialog" aria-labelledby="editModalLabel" aria-hidden="true">
                                    <div class="modal-dialog" role="document">
                                    <div class="modal-content">
                                      <div class="modal-header btns primary-btn">
                                        <h5 class="modal-title" id="editModalLabel">Remark</h5>
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                          <span aria-hidden="true">&times;</span>
                                        </button>
                                      </div>
                                      <div class="modal-body">
                                        <div class="row">
                                            <div class="col-lg-12 mb-3" style="text-align: left;">
                                                  <label for="exampleFormControlTextarea1" >Remark</label>
                                                  <textarea class="form-control" name="remark" id="exampleFormControlTextarea1" rows="5" required><?php echo e($value->remark); ?></textarea>
                                
                                            </div>
                                            </div>
                                          </div>
                                        </div>
                                        </div>
                                        </div>

                                  <!-- Modal -->
                                    <div class="modal fade" id="editSuggestion-<?php echo e($value->id); ?>" tabindex="-1" role="dialog" aria-labelledby="editModalLabel" aria-hidden="true">
                                    <div class="modal-dialog" role="document">
                                    <div class="modal-content">
                                      <div class="modal-header btns primary-btn">
                                        <h5 class="modal-title" id="editModalLabel">Add Remark</h5>
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                          <span aria-hidden="true">&times;</span>
                                        </button>
                                      </div>

                                       <form action="<?php echo e(route('suggestion.update', ['id' => $value->id])); ?>" method="post">
                                        <?php echo e(csrf_field()); ?>


                                      <div class="modal-body">
                                        <div class="row">
                                            <div class="col-lg-12 mb-3" style="text-align: left;">
                                                  <label for="exampleFormControlTextarea1" >Remark</label>
                                                  <textarea class="form-control" name="remark" id="exampleFormControlTextarea1" rows="5" required><?php echo e($value->remark); ?></textarea>
                                
                                                  </div>
                                        </div>
                                      </div>
                                      <div class="modal-footer">
                                        <button type="button" class="btns primary-btn" data-dismiss="modal">Close</button>
                                        <button type="submit" class="btns primary-btn">Submit</button>
                                      </div>
                                    </form>
                                    </div>
                                    </div>
                                    </div>


                                         <a href="<?php echo e(route('suggestion.delete',encrypt($value->id))); ?>" onclick="return confirm('Are you sure?')">
                                        <button type="button" class="btns success-btn btn-sm" title="Delete" alt="Delete"><i class="fas fa-trash-alt"></i>
                                        </button>
                                    </a>

                                    </td>

                                    </tr>

                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                                    <?php if($suggestions->count() == 0): ?>

                                    <tr class="text-center">

                                        <td colspan="6">No Suggestion to display.</td>

                                    </tr>

                                    <?php endif; ?>

                                <?php endif; ?>

                            </tbody>

                            <tfoot>

                                <tr>
                                    <th>#</th>

                                    <th>IMAGE</th>

                                    <th>Name</th>

                                    <th>Date</th>

                                    <th>Message</th>




                                    <th class="text-right">Action</th>

                                </tr>


                            </tfoot>

                        </table>

                    </div>

                     <div class="text-left float-left mt-1">

                           <p>Displaying <?php echo e($suggestions->count()); ?> of <?php echo e($suggestions->total()); ?> Add suggestion.</p>

                    </div>




                    <div class="pagination">
                        <ul class="pagination-list">
                            <?php if($suggestions->currentPage() > 1): ?>
                                <li class="pagination-item">
                                    <a href="<?php echo e($suggestions->appends(request()->all())->previousPageUrl()); ?>" class="pagination-link">&lt;</a>
                                </li>
                            <?php endif; ?>

                            <?php if($suggestions->currentPage() > 3): ?>
                                <li class="pagination-item">
                                    <a href="<?php echo e($suggestions->appends(request()->all())->url(1)); ?>" class="pagination-link">1</a>
                                </li>
                                <li class="pagination-item disabled">
                                    <span class="pagination-link">...</span>
                                </li>
                            <?php endif; ?>

                            <?php $__currentLoopData = range(max(1, $suggestions->currentPage() - 2), min($suggestions->lastPage(), $suggestions->currentPage() + 2)); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $page): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <li class="pagination-item <?php echo e($page == $suggestions->currentPage() ? 'active' : ''); ?>">
                                    <a href="<?php echo e($suggestions->appends(request()->all())->url($page)); ?>" class="pagination-link"><?php echo e($page); ?></a>
                                </li>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                            <?php if($suggestions->currentPage() < $suggestions->lastPage() - 2): ?>
                                <li class="pagination-item disabled">
                                    <span class="pagination-link">...</span>
                                </li>
                                <li class="pagination-item">
                                    <a href="<?php echo e($suggestions->appends(request()->all())->url($suggestions->lastPage())); ?>" class="pagination-link"><?php echo e($suggestions->lastPage()); ?></a>
                                </li>
                            <?php endif; ?>

                            <?php if($suggestions->hasMorePages()): ?>
                                <li class="pagination-item">
                                    <a href="<?php echo e($suggestions->appends(request()->all())->nextPageUrl()); ?>" class="pagination-link">&gt;</a>
                                </li>
                            <?php endif; ?>
                        </ul>
                    </div>

                </div>

            </div>

        </div>

    </div>

</div>



</main><!-- End #main -->
 <?php $__env->stopSection(); ?>

<?php echo $__env->make('frontend.layouts.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/vinecork/public_html/webdev/Company/resources/views/suggestion/index.blade.php ENDPATH**/ ?>