

<div class="subheader">
    <h1 class="subheader-title" style="font-weight: bold;">
        <i class='subheader-icon fa fa-bars text-primary'></i><?php echo $title;?> 
    </h1>
    <div class="d-flex mr-4">
    <li class="position-absolute pos-top pos-right d-none d-sm-block"><span class="js-get-date"></span></li>
    </div>
</div>

<div id="panel-1" class="panel">
    <table class="table table-bordered table-striped w-100" style="font-size: 11px;">
        <thead class="header bg-primary" style="color: #fff;">
            <tr>  
                <th style="font-weight: bold;width: 5px;"></th>       
                <th style="font-weight: bold;">SUBJECT MATTER</th>
                <th style="font-weight: bold;">DOCS</th>
                <th colspan="2" style="font-weight: bold;">ASSIGNED TO</th>
            </tr>
        </thead>

        <tbody>
            <?php 
                $ii=0;
                ####### FETCH ######
                $stmtReq = $db->prepare('SELECT *FROM tbl_info_register i
                INNER JOIN tbl_con_infos cn ON cn.reg_info_id=i.regst_id 
                INNER JOIN tbl_clients c ON c.ct_id=i.clnt_id 
                INNER JOIN tbl_reqs_type r ON r.reqtype_id=i.reqtype
                WHERE i.doctype=3 AND i.reqtype=1 AND cn.info_sts=8 AND cn.dRcv="'.$role_id.'"');
                $stmtReq->execute();
                while($ffReq = $stmtReq->fetch()):
                $regstid = $ffReq['regst_id'];
                $con_info_id = $ffReq['con_info_id'];
                $dSent=$ffReq['dSent'];
                $ii++;
                
                $asgnQue=$db->prepare('SELECT *FROM tbl_assign_reqs a
                INNER JOIN tbl_title t ON t.title_id=a.asgn_appoint 
                WHERE conasgn="'.$con_info_id.'"');
                $asgnQue->execute();
                $num=$asgnQue->rowCount();
            ?>

            <tr> 
                <td rowspan="<?php echo $num;?>">
                    <ahref="#" data-toggle="modal" data-target="#compBoq_<?php echo $con_info_id;?>" class="btn btn-success btn-sm" title="Completed">
                        <i class="fa fa-check-circle" aria-hidden="true"></i>
                    </a>
                </td>    

                <td rowspan="<?php echo $num;?>">
                <?php echo $ffReq['sub_matt'];?><br/>
                <i class="text-primary"><b>Client:</b> <?php echo $ffReq['ct_names'];?></i><br>
                </td>    
                
                <td rowspan="<?php echo $num;?>">
                <?php 
                    $i=0;
                    $select = $db->prepare("SELECT * FROM `tbl_docs` WHERE registID = '".$regstid."' ORDER BY doc_id DESC");
                    $select->execute(); 
                    while($row = $select->fetch()){
                        $doc_id = $row['doc_id'];
                        $uploaded_on = $row['uploaded_on'];
                        $docName = $row['docName'];
                        $rec_dpt = $row['rec_dpt'];
                        $usID = $row['usID'];
                        $stts_doc = $row['stts_doc'];
                        $i++;
                         
                         //Hide Extension
                         $file = new SplFileInfo($docName);
                         $ext  = $file->getExtension();
                         //Get File Name
                         $fileName = basename($docName);
                         $fileNameNoExtension = preg_replace("/\.[^.]+$/", "", $fileName);

                         //DOC ICON
                         if($ext == "pdf"){
                            $imgIcon = "pdf.png";
                         }if($ext == 'xls' || $ext == 'xlsx'){
                            $imgIcon = "excel.png";  
                         }if($ext == 'doc' || $ext == 'docx'){
                             $imgIcon = "docx.png";
                         }if($ext == 'ppt' || $ext == 'pptx'){
                             $imgIcon = "pptx.png";
                        }if($ext == 'zip' || $ext == 'rar' || $ext == 'tar'){
                            $imgIcon = "zip.png";
                        }
                   ?>   
                        <a href="../docs/<?php echo $docName;?>" target="_blank" class="text-center d-flex position-relative" title="<?php echo $docName;?>">
                         <img src="../img/icon/<?php echo $imgIcon;?>" width="30" style="padding: 2px;margin-left: 5px;" title="<?php echo $docName;?>">
                        </a>   
                    <?php 
                    }
                   ?>
                </td>

                <?php 
                while($rr=$asgnQue->fetch()):
                ?>
                <td><?php echo $rr['title_name'];?></td>

                <td>
                    <a href="gate?b=genboq&req=<?php echo $regstid;?>&conreq=<?php echo $con_info_id;?>&asgnid=<?php echo $rr['assreq_id'];?>&appoint=<?php echo $rr['asgn_appoint'];?>" class="btn btn-primary btn-xs" title="Create BOQ">
                        <i class="fa fa-pencil" aria-hidden="true"></i>
                    </a>
                </td>
            </tr>
            
        <?php 
            endwhile;
            endwhile;
        ?>
        </tbody>                           
    </table>

</div>
