<style>
    .ui-accordion .ui-accordion-header {
        font-size: 16px !important;
        font-weight:bold !important;
    }
    .ui-accordion .ui-accordion-content{
        padding: 0px !important;
        height: auto !important;
    }
    .ui-state-active {
        background-color: #d2d6de !important;
        border:1px solid #d2d6de !important;
    }
    .preview_img{
        margin: 10px 10px !important;
        width: 200px !important;
    }
</style>
<span class="message"></span>
<?php
$group = array();
foreach ($documentListing as $value) {
    $group[$value['image_type']][] = $value;
}


$output = array();

foreach ($group as $type => $labels) {
    $output[] = array(
        'image_type' => $type,
        'document_files' => $labels
    );
}
$documents = $output;
//echo "<pre>";print_r($documents); die;
?>

<div class="col-sm-12 col-md-8 col-lg-12 clearfix userprofileimg">
    <div id="crop-avatar">

            <?php if($documents>0) {
                for ($docid = 0; $docid < count($documents); $docid++) {
                    $doc_name = $documents[$docid]['image_type'];
                    $doc_file = $documents[$docid]['document_files'];
                   
            ?>
                <h4><?php echo ucwords(str_replace('_', ' ', $doc_name));?></h4>
                <div class="col-sm-12">
                      <?php if(!empty($doc_file)){
                          $name = "";
                        foreach($doc_file as $files){
                          $image_name = isset($files['image']) ? $files['image'] : '';
                          $image_title = isset($files['image_type']) ? $files['image_type']: '';
                          $image_type = isset($files['image_type']) ? $files['image_type']: '';
                                                  
                          if ($files['image_approval_status'] == 1): $buttonClass = "Approved";
                          else: $buttonClass = "Un-Approved";
                          endif;
                          $imagepath = B2B_IMAGE_LINK ."hotel_room_image/".$image_name;
                          $basepath = BASE_PATH."/public/upload/hotel_room_image/".$image_name;
                          if(file_exists($basepath)){
                      ?>
                    
                      <div class="avatar-view preview_img" title="<?php echo $image_title; ?>">
                          <span><strong><?php echo $name; ?></strong></span>
                          <div class="highslide-gallery">
                             <input type="checkbox" class="set_room_image_default" <?php if($files['image_default_status']==1){ echo "checked";}?> imageType="<?php echo $files['image_type'] ?>" hotelId="<?php echo $files['room_id'];?>" relDocId="<?php echo $files['id']; ?>"> Set Default<br/>                                            
                             <a href="<?php echo $imagepath; ?>" class="highslide" onclick="return hs.expand(this)"><img src="<?php echo $imagepath; ?>" id="residential_proof" alt="<?php echo $image_title; ?>"></a>
                            <div class="highslide-caption">
                                <?php echo $files['image'];?>
                            </div>
                            
                            <h6><center><b><?php echo $buttonClass; ?></b></center></h6><br/>
                            <a href="javascript:void(0)"  onclick="changeImageStatus('publish','hotel','update-room-image-status','<?php echo $files['id'];?>')">Approve</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:void(0)" onclick="changeImageStatus('unpublish','hotel','update-room-image-status','<?php echo $files['id'];?>')">Un-Approve</a>
                          </div>
                        </div>
                          <?php } } }?>
                  </div>
                <?php } } else { ?>
                No Images Available
            <?php } ?>

    </div>
</div>
