
<div class="subheader">
    <h1 class="subheader-title" style="font-weight: bold;">
        <i class='subheader-icon fa fa-dashboard'></i>Dashboard
    </h1>
    <div class="d-flex mr-4">
        <div>
          <a href="<?php echo web_root;?>beam/bm?b=box">
            <label class="fs-sm mb-0 mt-2 mt-md-0">Unread Message</label>
            <h4 class="font-weight-bold mb-0"><i class="fa fa-envelope-o" aria-hidden="true"></i> <?php echo $notifieIncom;?></h4>
          </a>
        </div>
    </div>
</div>

   <div class="card">
        <div class="panel-container show">
            <div class="panel-content">         
            
                <div class="tab-content p-3">
                <br>
                    <table id="dt-basic-example" class="table table-bordered table-striped w-100" style="font-size: 11px;">
                        <thead class="header">
                            <tr>
                                <th></th>
                                <th style="font-weight: bold;">TRACKING CODE</th>
                                <th style="font-weight: bold;">CLIENT NAME</th>
                                <th style="font-weight: bold;">SUBJECT MATTER</th>
                                <th style="font-weight: bold;">TYPE</th>
                                <th style="font-weight: bold;">REQUEST DATE</th>
                                <th style="font-weight: bold;width: 30%;">OFFICE</th>
                            </tr>
                        </thead>

                        <tbody id="rests">
                            <?php 
                                $rn=0;
                                ####### FETCH ######
                                
                                $stmtReq = $db->prepare('SELECT DISTINCT(regst_id) AS regid, track_id, ct_names, sub_matt, reqtype_name,
                                requestDate 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.stts_reg=5 AND con_doctype=3 ORDER BY regst_id DESC');

                                $stmtReq->execute();
                                while($ffReq = $stmtReq->fetch()):
                                $regid = $ffReq['regid'];
                                $rn++;

                                ####### Check Receiver #####
                                $recvr=$db->prepare('SELECT *FROM tbl_role r
                                INNER JOIN tbl_con_infos c ON c.dRcv=r.role_id WHERE reg_info_id="'.$regid.'"');
                                $recvr->execute();
                                $gtnum=$recvr->rowCount();                        
                            ?>
                            <tr>
                                <td><?php echo $rn;?></td>
                                <td><?php echo $ffReq['track_id'];?></td>
                                <td>
                                    <?php echo $ffReq['ct_names'];?>
                                    <br>
                                    <?php include 'recdoc.php';?>
                                </td>
                                <td><?php echo $ffReq['sub_matt'];?></td>            
                                <td><?php echo "REQUEST FOR ".$ffReq['reqtype_name'];?></td>  
                                <td><?php echo date('d/m/Y',strtotime($ffReq['requestDate']));?></td>
                            <td>
                            <ul id="js-emails" class="notification notification-layout-2">   
                            <?php 
                                while($getRcvr=$recvr->fetch()){
                                $rcvName=$getRcvr['role_name'];
                                if($getRcvr['receivTrm']!=NULL){
                                    $receivTrm=date('d/m/Y',strtotime($getRcvr['receivTrm']));
                                }else{
                                    $receivTrm="---";
                                }
                                $infosts=$getRcvr['info_sts'];
                                $stsQue = $db->prepare('SELECT *FROM tbl_status WHERE status_id="'.$infosts.'"');
                                $stsQue->execute();
                                $getSts=$stsQue->fetch();

                                if($infosts == 2){
                                    $icon='<i class="fa fa-exclamation-circle" aria-hidden="true"></i>';
                                    $btn='btn-warning';
                                }elseif($infosts == 9){
                                    $icon='<i class="fa fa-check" aria-hidden="true"></i>';
                                    $btn='btn-success';
                                }else{
                                    $icon='<i class="fa fa-folder-open" aria-hidden="true"></i>';
                                    $btn='btn-default';
                                }

                                ?>
                                <li class="b-tr" style="list-style-position:inside;border: 1px solid black;padding: 10px;">
                                    <a href="javascript:void(0)" title="starred" class="d-flex align-items-center py-1 ml-2 mt-4 mt-lg-0
                                    ml-lg-0 mr-lg-4 fs-lg color-primary-500 order-3 order-lg-2">
                                    <?php echo $rcvName;?>
                                    </a>
                                        
                                    <div class="d-flex flex-row flex-wrap flex-1 align-items-stretch align-self-stretch order-2 order-lg-3">
                                        <div class="row w-100">
                                            <a href="javascript:void(0)" class="name d-flex width-sm align-items-center pt-1 pb-0 py-lg-1 col-12 col-lg-auto">
                                            <i>Assigned date:</i> <?php echo date('d/m/Y',strtotime($getRcvr['conTrm']));?>
                                            </a>
                                            <a href="javascript:void(0)" class="name d-flex align-items-center pt-0 pb-1 py-lg-1 flex-1 col-12 col-lg-auto">
                                            <i>Received date:</i> <?php echo $receivTrm;?>
                                            </a>
                                        </div>
                                    </div>

                                    <div class="fs-sm text-muted ml-auto hide-on-hover-parent order-4 position-on-mobile-absolute
                                        pos-top pos-right mt-2 mr-3 mr-sm-4 mt-lg-0 mr-lg-0">
                                        <label class="btn <?php echo $btn;?> btn-xs" style="font-weight: bold;"><?php echo  $icon." ".$getSts['status_name'];?></label>
                                    </div>
                                </li>
                                <br>

                                <?php }?>
                                </ul>
                            </td>
                            </tr>
                            
                        <?php 
                            // endwhile;
                        endwhile;
                        ?>
                        </tbody>                           
                    </table>
              
                </div>
        </div>
    </div>
</div>
