<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>

<?php //\Zend\Debug\Debug::dump($userListing);  ?>
<!--<table id="myTable" class="table table-bordered table-striped">
    <thead>
        <tr>
            <th><label class="pos-rel"><input type="checkbox" class="selectall" /><span class="lbl"></span> All</label></th>
            <th>S.No</th>
            <th>Document Name</th>
            <th>Document</th>
            <th>Status</th>
        </tr>
    </thead>
    <tbody>
<?php
if ($documentListing) {
    $i = 1;
    foreach ($documentListing as $listing) {
        ?>
                        <tr>
                            <td class="center"><label class="pos-rel">
                                    <input type="checkbox" rel="<?php echo $listing['upload_doc_id']; ?>" class="check" />
                                    <span class="lbl"></span> </label>
                            </td>
                            <td><?php echo $i; ?></td>
                            <td><?php echo $listing['document_name']; ?></a></td>
                            <td><a download href="<?php echo $this->url('dashboard', array('action' => 'download-file-data'), ['query' => ['userid' => $userId, 'filename' => $listing['doc_level_name']]]); ?>"><img alt="download" title="Download <?php echo $listing['document_name']; ?>" src="/images/file_preview_icon.png" height="25px" width="26px"/></a></td>
                            <td class="hidden-480">
                                <div style="float:left;">
        <?php
        if ($listing['doc_approval_status'] == 1): $buttonClass = "aprovestatus";
        else: $buttonClass = "unaprovestatus";
        endif;
        ?>
                                    <div class="iconsize <?php echo $buttonClass; ?>" name="ChangeStatus" > </div>
                                </div>
                            </td>
                        </tr>
        <?php
        $i++;
    }
} else {
    ?>
                <tr><th colspan="11" style="text-align: center;">No Record Found</th></tr>
<?php } ?>
    </tbody>
    <thead>
        <tr>
            <th> <label class="pos-rel"><input type="checkbox" class="selectall" /><span class="lbl"></span> All</label></th>
            <th>S.No</th>
            <th>Document Name</th>
            <th>Document</th>
            <th>Status</th>
        </tr>
    </thead>
</table>-->

<?php
$group = array();
foreach ($documentListing as $value) {
    $group[$value['document_name']][] = $value;
}


$output = array();

foreach ($group as $type => $labels) {
    $output[] = array(
        'document_name' => $type,
        'document_files' => $labels
    );
}
$documents = $output;

?>

<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]['document_name'];
                    $doc_file = $documents[$docid]['document_files'];
            ?>
                <h5><?php echo $doc_name;?></h5>
                <div class="col-sm-12">
                      <?php if(!empty($doc_file)){
                        foreach($doc_file as $files){
                          $image_name = isset($files['doc_file_upload']) ? $files['doc_file_upload'] : '';
                          $image_title = isset($files['document_name']) ? $files['document_name']: '';
                          if ($files['doc_approval_status'] == 1): $buttonClass = "Approved";
                          else: $buttonClass = "Un-Approved";
                          endif;
                          $imagepath = B2B_IMAGE_LINK .$userId."/".$image_name;
                          $basepath = BASE_PATH."/public/upload/".$userId."/".$image_name;
                          if(file_exists($basepath)){
                      ?>
                      <div class="avatar-view userimg_byratio preview_img" title="<?php echo $image_title; ?>">
                          <div class="highslide-gallery">
                              <input type="checkbox" class="set_default" <?php if($files['doc_default_status']==1){ echo "checked";}?> relDocTypeId="<?php echo $files['document_type_id'] ?>" relDocId="<?php echo $files['upload_doc_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['document_name']; ?>
                            </div>
                            <!--<h6><center><b><a download href="<?php echo $imagepath; ?>"><?php echo $image_title; ?></a></b></center></h6><br/>-->
                            <h6><center><b><?php echo $buttonClass; ?></b></center></h6><br/>
                            <!--<a download href="<?php echo $imagepath; ?>">Download</a>-->
                            <a href="javascript:void(0)" onclick="changeDocStatus('publish','usermanagement','update-doc-status','<?php echo $files['upload_doc_id'];?>')">Approve</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:void(0)" onclick="changeDocStatus('unpublish','usermanagement','update-doc-status','<?php echo $files['upload_doc_id'];?>')">Un-Approve</a>
                          </div>
                        </div>
                          <?php } } }?>
                  </div>
                <?php } } else { ?>
                No Documents Available
            <?php } ?>

    </div>
</div>
