<?php
    $userDetails = $this->session->userdata('isUserLoggedIn');
    // print_r($userDetails);
    // echo $userDetails['Id'];
    // echo $userDetails['isUserType'];
?>
<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 active">Dashboard</li>
        <li class="position-absolute pos-top pos-right d-none d-sm-block"><span class="js-get-date"></span></li>
    </ol>
    <div class="subheader">
        <h1 class="subheader-title">
            <i class='subheader-icon fal fa-chart-area'></i> Dashboard <span class='fw-300'></span>
        </h1>
    </div>
    <div class="row">


        <?php if($userDetails['isUserType']=='admin'): ?>

        <div class="col-sm-4 col-xl-3">
            <a href="<?php echo base_url() ?>hotels">
                <div class="p-3 bg-primary-300 rounded overflow-hidden position-relative text-white mb-g">
                    <div class="">
                        <h3 class="display-4 d-block l-h-n m-0 fw-500">
                            <?php echo $completeHotels['count']; ?>
                            <small class="m-0 l-h-n">Hotel Property</small>
                        </h3>
                    </div>
                    <i class="fal fa-building position-absolute pos-right pos-bottom opacity-15 mb-n5 mr-n6" style="font-size: 8rem;"></i>
                </div>
            </a>

        </div>

        <div class="col-sm-4 col-xl-3">
            <a href="<?php echo base_url() ?>menu">
                <div class="p-3 bg-primary-300 rounded overflow-hidden position-relative text-white mb-g">
                    <div class="">
                        <h3 class="display-4 d-block l-h-n m-0 fw-500">
                            <?php echo $countMenu['count']; ?>
                            <small class="m-0 l-h-n">Menu</small>
                        </h3>
                    </div>
                    <i class="fal fa-table position-absolute pos-right pos-bottom opacity-15 mb-n1 mr-n1" style="font-size:6rem"></i>
                </div>
            </a>
        </div>

       <!--  <div class="col-sm-4 col-xl-3">
            <a href="<?php echo base_url() ?>category">
                <div class="p-3 bg-primary-300 rounded overflow-hidden position-relative text-white mb-g">
                    <div class="">
                        <h3 class="display-4 d-block l-h-n m-0 fw-500">
                            <?php echo $countcategory['count']; ?>
                            <small class="m-0 l-h-n">Category</small>
                        </h3>
                    </div>
                    <i class="fal fa-table position-absolute pos-right pos-bottom opacity-15 mb-n1 mr-n1" style="font-size:6rem"></i>
                </div>
            </a>
        </div> -->
       <!--  <div class="col-sm-4 col-xl-3">
            <div class="p-3 bg-warning-400 rounded overflow-hidden position-relative text-white mb-g">
                <div class="">
                    <h3 class="display-4 d-block l-h-n m-0 fw-500">
                        <?php //echo $countFacilities['count']; ?>
                        <small class="m-0 l-h-n">Facilities</small>
                    </h3>
                </div>
                <i class="fal fa-shield-alt position-absolute pos-right pos-bottom opacity-15  mb-n1 mr-n4" style="font-size: 6rem;"></i>
            </div>
        </div> -->
        

        <?php else: ?>
            <!-- <div class="col-md-4">
            <a href="<?php echo base_url() ?>hotel_category">
                <div class="p-3 bg-primary-300 rounded overflow-hidden position-relative text-white mb-g">
                    <div class="">
                        <h3 class="display-4 d-block l-h-n m-0 fw-500">
                            <?php
                                $countHotelCategory = $this->db->select('count(*) as count')->where('fiHotelId',$userDetails['Id'])->from('hotel_category')->get();
                                $count = $countHotelCategory->result_array()[0];
                            ?>
                            <?php echo $count['count']; ?>
                            <small class="m-0 l-h-n">Hotel Category</small>
                        </h3>
                    </div>
                    <i class="fal fa-table position-absolute pos-right pos-bottom opacity-15 mb-n1 mr-n1" style="font-size:6rem"></i>
                </div>
            </a>
        </div> -->


            <?php 

                $query = $this->db->select('menu.*,hotel_menu.id as hotelMenuId')
                ->join('hotel_menu','hotel_menu.fiMenuId=menu.id','left')
                ->where('fiHotelId',$userDetails['Id'])->get('menu');
                $menuLists = $query->result_array(); 

                // echo "<pre>"; print_r($query); die();

                // $bgArray = array(
                //     '0'=>'bg-primary-300',
                //     '1'=>'bg-warning-400',
                //     '2'=>'bg-success-200',
                //     '3'=>'bg-info-200',
                // );

               if(count($menuLists) > 0){
                  $i = 0;
                  foreach($menuLists as $menulistvalue){
                    // if(!isset($bgArray[$i])){
                    //     $i = 0;
                    // }
            ?>

           
                <div class="col-md-4">
                    <a href="<?php echo base_url()?>hotel_category/index/<?php echo $menulistvalue['hotelMenuId']; ?>"> 
                        <div class="p-3 bg-primary-300 rounded overflow-hidden position-relative text-white mb-g">
                            <div class="">
                                <h3 class="display-3 d-block l-h-n m-0 fw-500">
                                    <?php 
                                    // print_r($userDetails); die();
                                    $countHotelFacilities = $this->db->select('count(*) as count')->where('fiMenuId',$menulistvalue['hotelMenuId'])->where('fiHotelsId',$userDetails['Id'])->from('hotel_facilitates')->get();
                                    $count = $countHotelFacilities->result_array()[0];

                                    echo $count['count'];
                                     ?>
                                    <small class="m-0 l-h-n"><?php echo $menulistvalue['fsTitle'];?></small>
                                </h3>
                            </div>
                            <i class="fal fa-shield-alt position-absolute pos-right pos-bottom opacity-15  mb-n1 mr-n4" style="font-size: 6rem;"></i>
                        </div>
                    </a>
                </div>
            
            <?php
                $i++;
              }
            }
            ?> 

        <?php endif; ?>

    </div>
</main>