
<table id="dt-basic-example" class="table table-hover table-striped w-100"  style="font-size: 11px;">
    <thead class="header">
        <tr>
            <th style="font-weight: bold;"></th>
            <th style="font-weight: bold;">CODE</th>
            <th style="font-weight: bold;">PROJECT</th>
            <th style="font-weight: bold;">AGREEMENT/WORK ORDER N<sup>o</sup></th>
            <th style="font-weight: bold;">SIGNED DATE</th>
            <th style="font-weight: bold;">STARTED DATE</th>
            <th style="font-weight: bold;">DURATION</th>
            <th style="font-weight: bold;">PHYSICAL PROGRESS</th>
            <th style="font-weight: bold;">STATUS</th>
        </tr>
    </thead>
    
    <tbody>
        <?php 
            $n=0;
            $sth = $db->prepare('SELECT *FROM tbl_projects p
            INNER JOIN tbl_clients c ON c.ct_id=p.clnt ORDER BY projid DESC');
            $sth->execute();
            while($getp = $sth->fetch()){
            $projid = $getp['projid'];
            $wrkp = $getp['wps'];
            $n++;

            $prjsts=$getp['prjsts'];

            $stsQue = $db->prepare('SELECT *FROM tbl_status WHERE status_id="'.$prjsts.'"');
            $stsQue->execute();
            $getSts=$stsQue->fetch();

            if($prjsts == 12){
                $icon='<i class="fa fa-exclamation-circle" aria-hidden="true"></i>';
                $btn='btn-primary';
            }elseif($prjsts == 10){
                $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';
            }
        ?>
        
            <?php 
             if($role_id==2 || $role_id==3 || $role_id==5 || $role_id==6 || $role_id==7){
            ?>
            <tr class="beam-dir" href="gate?b=boxp&pID=<?php echo $projid;?>" style="cursor: pointer;">
            <?php }else{ ?>
            <tr class="b-tr">

            <?php }?>
                <td><i class="fa fa-share" aria-hidden="true"></i></td>
                <td><?php echo $getp['codeproj'];?></td>
                <td><?php echo $getp['projname'];?></td>
                <td><?php echo $getp['aggreno'];?></td>
                <td><?php echo date('d/m/Y', strtotime($getp['signdate']));?></td>
                <td><?php echo date('d/m/Y', strtotime($getp['startDue']));?></td>

                <td><i style="color: #596d43"><?php echo $getp['durat']." Month(s)";?></i></td>
                <td> 
                <div class="demo js-progress-animated">
                    <div class="progress progress-lg">
                        <div class="progress-bar progress-bar-striped bg-primary-500" role="progressbar" style="color: #000;font-weight: bold;width: <?php echo $wrkp;?>%" aria-valuenow="<?php echo $wrkp;?>" aria-valuemin="0" aria-valuemax="100"><b><?php echo $wrkp;?>%</b></div>
                    </div>
                </div>
                </td>
                <td>
                    <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>
                </td>
            </tr>
        <?php }?>
    </tfoot>
</table>

<script>
    $(document).ready(function(){
    $('.beam-dir').click(function(){
        window.location = $(this).attr('href');
        return false;
        });
    });
</script>




