<?php 
 ####### UPDATE START STATUS#######
 if(isset($_POST['wkstste'])){
    try{
        $wkstste=$_REQUEST['wkstste'];
        $projcid=$_REQUEST['projcid'];
        $sql = $db->query("UPDATE `tbl_projects` SET `wrk_state` = '$wkstste',prjsts=12 WHERE `projid` = '$projcid'");
        $msg = "Updated Successfully";
        
    }catch(PDOException $e){
        echo $e->getMessage();
    }
}

?>

<div class="card mb-g border shadow-0">
    <div class="card-header bg-white p-0 header">
        <div class="p-3 d-flex flex-row">
            <div class="d-block ml-2">
                <span class="h6 font-weight-bold text-uppercase d-block m-0">
                    <?php echo $title;?> 
                </span>
                <div class="clearfix"></div>  
            </div>
        </div>
    </div>

    <div class="card-body">
     <br>
                 
        <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;"></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 
                    WHERE prjsts=1 AND prces!=1
                    ORDER BY projid DESC');
                    $sth->execute();
                    while($getp = $sth->fetch()){
                    $projid = $getp['projid'];
                    $wrkp = $getp['wps'];
                    $process = $getp['prces'];
                    $n++;

                    $prjsts=$getp['prjsts'];
                  
                ?>
                
                    <tr class="b-tr">
                        <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="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">
                            <a href="javascript:void(0)"  data-toggle="modal" data-target="#startp<?php echo $projid;?>"  class="btn btn-success btn-xs" style="font-weight: bold;">
                            <i class="fa fa-check"></i> Start
                            </a>
                            </div>
                        </td>
                    </tr>
                <?php
                  include 'jobstart.php';
                }
                ?>
            </tfoot>
        </table>

    </div>
</div>