<style type="text/css">
.pagination li.active {background-color: #886ab5; color: #FFF; }
.pagination li {margin-left: 10px; padding: 3px 15px 3px 15px; background-color: #efefff; color: #000; }
.pagination {display: flex; float: right; padding: 7px; background-color: #FFF; box-shadow: 0 0 10px 0 rgba(183,192,206,.2); margin-bottom: 1.5rem; border: 1px solid rgba(238,238,238,.75); }
</style>


<?php 
  $userDetails = $this->session->userdata('isUserLoggedIn');
    $query = $this->db->select('*')->where('id',$menu_id)->get('hotel_menu');
    $menuName = $query->result_array();
    $menuName = $menuName[0];
      //echo "<pre>"; print_r($menuName); die();
?>


<main id="js-page-content" role="main" class="page-content">
    <ol class="breadcrumb page-breadcrumb">
        <li class="breadcrumb-item"><a href="javascript:void(0);">Dashboard </a></li>
        <li class="breadcrumb-item">Facility Informations  Table</li>
        <li class="position-absolute pos-top pos-right d-none d-sm-block"><span class="js-get-date"></span></li>
    </ol>
    <div class="row">
        <?php 
            // print_r($_REQUEST); die();
            $query = $this->db->select('*')->from('hotel_category')->where('id',$_REQUEST['categoryid'])->get();
            $hotelCategory = $query->result_array();
                // print_r($hotelCategory); die();
            $action = site_url('hotel_facilitates/update_action/'.$_REQUEST['categoryid']);
            $fiMenuId = $hotelCategory[0]['fiMenuId'];
            $fsTitle = $hotelCategory[0]['fsTitle'];
            $fsImage = $hotelCategory[0]['fsImage'];
            $id = $_REQUEST['categoryid'];

        ?>
        <div class="col-lg-12 col-xl-12">
            <div id="panel-2" class="panel">
                <div class="panel-hdr">
                    <h2>
                       <?php echo $menuName['fsTitle']; ?> /Facility Details <span class="fw-300"></span>
                    </h2>
                </div>
                <div class="panel-container show">
                    <div class="panel-content p-0">
                        <form class="needs-validation"  action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" novalidate >
                            <div class="panel-content">
                                <div class="form-row">
                                    <div class="form-group" hidden="">
                                        <label for="int">FiMenuId <?php echo form_error('fiMenuId') ?></label>
                                        <input type="text" class="form-control" name="fiMenuId" id="fiMenuId" placeholder="FiMenuId" value="<?php echo $fiMenuId; ?>" />
                                    </div>
                                    <div class="col-md-12 mb-3">
                                        <label class="form-label" for="validationCustom01"> Facility Title<span class="text-danger">*</span> </label>
                                        <input type="text" class="form-control" id="validationCustom01" name="fsTitle" id="fsTitle" placeholder=" Hotel Facility name" value="<?php echo $fsTitle; ?>" required>
                                        <div class="valid-feedback">
                                            Looks good!
                                        </div>
                                    </div>
                                    <div class="col-md-12 mb-3">
                                        <label class="form-label" for="validationCustom01">  Facility Icon (250x250)<span class="text-danger">*</span> </label>
                                       <?php if($fsImage!=""): ?>
                                           
                                           <img style="background: #CCC; padding: 5px; max-width: auto;  margin-bottom:  10px; margin-left: 10px;  object-fit: cover; object-position: center; height: 60px;" class="alignment_speech" target="_blank" src="<?php echo base_url().$fsImage; ?>"></img>
                                        <?php endif; ?>
                                        <input style="padding-top: 5px;" accept=".jpeg,.png,.jpg" cols="12" rows="5" type="file" class="form-control form-control-file" name="fsImage" id="fsImage" placeholder="Description" value="<?php echo $fsImage; ?>" ></input>
                                    </div>
                                </div>
                                
                            </div>
                            <div class="panel-content border-faded border-left-0 border-right-0 border-bottom-0 d-flex flex-row align-items-center">
                                <input type="hidden" name="id" value="<?php echo $id; ?>" /> 
                                <button class="btn btn-primary ml-auto" value="Upload Image" type="submit">Submit</button>
                               <!--  <a style="    margin-left: 5px;" href="<?php //echo site_url('hotel_facilitates/menus/'.$fiMenuId.'') ?>" class="btn btn-danger">Cancel</a> -->
                            </div>
                        </form>
                    </div>
                </div>
            </div>

            <div id="panel-1" class="panel">
               <!--  <div class="panel-hdr">
                    <h2>
                        Facility Informations  <span class="fw-300"><i>Tables</i></span>
                    </h2>
                </div> -->
                <div class="panel-container show">
                    <div class="panel-content">
                        <div class="row" style="margin-bottom: 10px">
                            <div class="col-md-3">

                                <a data-toggle="modal" data-menu-id="<?php echo $menu_id ?>" data-category-id="<?php echo $_REQUEST['categoryid'] ?>" data-facilitates-id="0" class="btn btn-primary btn-light-primary facilitates_model">
                                Add Informations</a>

                                                              
                                <!-- <?php //echo anchor(site_url('hotel_facilitates/create/'.$menu_id.'/?categoryid='.$_REQUEST['categoryid']),'Add '.$menuName['fsTitle'].' Informations', 'class="btn btn-primary"'); ?> -->
                            </div>
                            <div class="col-md-4 text-center">
                                <?php if($this->session->userdata('message') <> ''): ?>
                                <div style="padding: 0.3rem 0.2rem;" id="message" class="panel-tag">
                                    <?php echo $this->session->userdata('message') <> '' ? $this->session->userdata('message') : ''; ?>
                                </div>
                              <?php endif; ?>
                            </div>
                            <div class="col-md-1 text-right">
                            </div>
                            <div class="col-md-4 text-right">

                                <form action="<?php echo site_url('hotel_facilitates/menus/'.$menu_id.'/?categoryid='.$_REQUEST['categoryid']); ?>" class="form-inline" method="get">
                                    <div class="input-group">
                                        <input type="text" class="form-control" name="q" value="<?php echo $q; ?>">
                                        <input type="hidden" class="form-control" name="categoryid" value="<?php echo $_REQUEST['categoryid']; ?>" >
                                        <span class="input-group-btn">
                                          <button class="btn btn-primary" type="submit">Search</button>
                                          <?php 
                                                if ($q <> '')
                                                {
                                                    ?>
                                                    <a href="<?php echo site_url('hotel_facilitates/menus/'.$menu_id.'/?categoryid='.$_REQUEST['categoryid']); ?>" class="btn btn-danger">Reset</a>
                                                    <?php
                                                }
                                            ?>

                                        </span>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <div class="frame-wrap">
                            <table class="table m-0">
                                <thead>
                                    <tr>
                                        <th>Title</th>
                                        <!-- <th>Facility Informations</th> -->
                                        <th>Action</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                    <?php
                                        foreach ($hotel_facilitates_data as $hotel_facilitates)
                                        {
                                    ?>  
                                        <td><?php echo $hotel_facilitates->fsTitle ?></td>
                                        <!-- <td><?php echo $hotel_facilitates->fsCategory ?></td>  -->
                                        <td width="200px">
                                            <div class="btn btn-outline-success btn-icon waves-effect waves-themed ">
                                                 <a data-toggle="modal" data-menu-id="<?php echo $menu_id ?>" data-category-id="<?php echo $_REQUEST['categoryid'] ?>" data-facilitates-id="<?php echo $hotel_facilitates->id ?>" class="facilitates_model">Edit</a>
                                            <!-- <?php  
                                            //echo anchor(site_url('hotel_facilitates/update/'.$hotel_facilitates->id.'?categoryId='.$_REQUEST['categoryid'].'&menu_id='.$menu_id),'Edit'); 
                                            ?> -->
                                            </div>
                                            <div class="btn btn-outline-danger btn-icon waves-effect waves-themed">
                                            <?php
                                            echo anchor(site_url('hotel_facilitates/delete/'.$hotel_facilitates->id.'?categoryId='.$_REQUEST['categoryid'].'&menu_id='.$menu_id),'Delete','onclick="javasciprt: return confirm(\'Are You Sure ?\')"'); 
                                            ?>
                                            </div>

                                        </td>
                                    </tr>
                                    <?php
                                    }
                                    ?>
                                </tbody>
                                
                            </table>
                            
                        </div>
                        <div class="row">
                            <div class="col-md-6">
                                <a href="#" class="btn btn-primary">Total Record : <?php echo $total_rows ?></a>
                           </div>
                            <div class="col-md-6 text-right">
                                <?php echo $pagination ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</main>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="<?php echo base_url() ?>/assets/ckeditor/ckeditor.js"></script>
<!-- Modal -->

   <div class="modal fade facilitates_model-popup" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
     <div class="modal-dialog" role="document">
       <div class="modal-content replaceDetails">
         
       </div>
     </div>
   </div>

<script type="text/javascript">
  jQuery(function($){
    $(document).on('click','.facilitates_model',function(){
      var $this = $(this);
      var popup = $(document).find('.facilitates_model-popup');
      var replaceItems = popup.find('.replaceDetails');
      replaceItems.html('<i class="fal fa-spinner fa-spin" style="font-size: 24px !important; text-align: center; color: #2b7acc; margin-top: 15px; margin-bottom: 15px;"></i>');
      popup.modal('show');

      $.ajax({
        'url':'<?php echo base_url() ?>hotel_facilitates/getFacilitatesPopup',
        'method':'get',
        data: {menu_id : $this.attr('data-menu-id'),category_id : $this.attr('data-category-id'),facilitates_id : +$this.attr('data-facilitates-id')} ,
        success : function(res){
          replaceItems.html(res);
          CKEDITOR.replace( 'editor', {
                        height: 300,
                        filebrowserUploadUrl: "http://localhost/jay/advice_management/hotel_facilitates/ajexfile?type=file",
                        filebrowserImageUploadUrl: "http://localhost/jay/advice_management/hotel_facilitates/ajexfile?type=image"
                    } );
        }
      })
    });
  });
</script>

<script>
    // Example starter JavaScript for disabling form submissions if there are invalid fields
    (function()
    {
        'use strict';
        window.addEventListener('load', function()
        {
            // Fetch all the forms we want to apply custom Bootstrap validation styles to
            var forms = document.getElementsByClassName('needs-validation');
            // Loop over them and prevent submission
            var validation = Array.prototype.filter.call(forms, function(form)
            {
                form.addEventListener('submit', function(event)
                {
                    if (form.checkValidity() === false)
                    {
                        event.preventDefault();
                        event.stopPropagation();
                    }
                    form.classList.add('was-validated');
                }, false);
            });
        }, false);
    })();

</script>
<style type="text/css">
    .panel-content > div:nth-child(1) .col-md-4.text-right input {    border-radius: 5px 0px 0px 5px !important;}
    .panel-content > div:nth-child(1) .col-md-4.text-right button {border-radius: 0px 5px 5px 0px !important;}
    /*a.btn.btn-danger.waves-effect.waves-themed {border-radius: 0; box-shadow: unset; }*/
    .modal-header {background-color: #a1956e; color: #FFF;}
    button.close {color: #FFF; }
    .btn-primary {color: #FFF !important;}
   body .modal.fade .modal-dialog {  transform: unset !important;}
   .fade:not(.show) {opacity: 1;     background: #998d6d3b;}
   .modal-dialog {  max-width: 700px;}
   i.fal.fa-edit {  padding: 10px; font-weight: 600; color: #1dc9b7 !important;}
   i.fal.fa-edit:hover { color: #fff !important;}
   i.fal.fa-trash {padding: 10px; color: #fd3995 !important; font-weight: 600; }
   i.fal.fa-trash:hover {color: #FFF !important; }
   .table img{    max-width: 150px; height: auto; width: 100%;}
</style>