<?php 

    ###### INVOICE #####
    $invce = $db->query('SELECT SUM(invceMont) AS totInv FROM tbl_invoices WHERE stsinvce=1 AND invtpe=1');
    $invce->execute();
    $ffinv = $invce->fetch();
    $totInv = $ffinv['totInv'];

    ###### PO #####
    $invce2 = $db->query('SELECT SUM(invceMont) AS totInv FROM tbl_invoices WHERE stsinvce=1 AND invtpe=2');
    $invce2->execute();
    $ffinv2 = $invce2->fetch();
    $totInv2 = $ffinv2['totInv'];

    ###### PAYMENT #####
    $pymt = $db->query('SELECT SUM(payMont) AS totPymt FROM tbl_payments WHERE pmtSts=1 AND paytpe=1');
    $pymt->execute();
    $ffpmt = $pymt->fetch();
    $totPmnt = $ffpmt['totPymt'];

    ###### PAYABLES #####
    $pymt2 = $db->query('SELECT SUM(payMont) AS totPymt FROM tbl_payments WHERE pmtSts=1 AND paytpe=2');
    $pymt2->execute();
    $ffpmt2 = $pymt2->fetch();
    $totPmnt2 = $ffpmt2['totPymt'];
?>


<div class="row">
<?php 
    if($pvge==1){
    ?>
    <div class="col-lg-3 col-md-3 col-sm-3">        
        <a href="<?php echo web_root;?>res/gate?b=getmytsk">
            <div class="p-3 bg-primary-500 rounded overflow-hidden position-relative text-white mb-g">
                <div class="">
                    <h3 class="display-4 d-block l-h-n m-0 fw-500">
                        <?php 
                        $infQue = $db->prepare('SELECT *FROM tbl_info_register i
                        INNER JOIN tbl_con_infos c ON c.reg_info_id=i.regst_id 
                        WHERE dRcv="'.$role_id.'" AND con_doctype=3 AND i.stts_reg=1');
                        $infQue->execute();
                        echo $infQue->rowCount();
                        ?>
                        <small class="m-0 l-h-n">My Task(s)</small>
                    </h3>
                </div>
                <i class="fa fa-bell position-absolute pos-right pos-bottom opacity-15 mb-n1 mr-n1" style="font-size:6rem"></i>
            </div>        
        </a>   
    </div>
    <?php 
    }
    ?>

    <div class="col-lg-3 col-md-3 col-sm-3">        
        <a href="<?php echo web_root;?>/res/gate?b=vassreq">
            <div class="p-3 bg-primary-500 rounded overflow-hidden position-relative text-white mb-g">
                <div class="">
                    <h3 class="display-4 d-block l-h-n m-0 fw-500">
                        <?php 
                        $infQue = $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');
                        $infQue->execute();
                        echo $infQue->rowCount();
                        ?>
                        <small class="m-0 l-h-n">Assigned Request(s)</small>
                    </h3>
                </div>
                <i class="fa fa-bell position-absolute pos-right pos-bottom opacity-15 mb-n1 mr-n1" style="font-size:6rem"></i>
            </div>        
        </a>   
    </div>
   
    <div class="col-lg-3 col-md-3 col-sm-3">        
        <a href="<?php echo web_root;?>/res/gate?b=dashnewpj">
            <div class="p-3 bg-primary-500 rounded overflow-hidden position-relative text-white mb-g">
                <div class="">
                    <h3 class="display-4 d-block l-h-n m-0 fw-500">
                        <?php 
                        $newpj=$db->prepare('SELECT *FROM tbl_projects WHERE prjsts=1');      
                        $newpj->execute();    
                        echo $newpj->rowCount();         
                        ?>                        
                        <small class="m-0 l-h-n">New Project(s)</small>
                    </h3>
                </div>
                <i class="fa fa-folder-open position-absolute pos-right pos-bottom opacity-15 mb-n1 mr-n1" style="font-size:6rem"></i>
            </div>        
        </a>   
    </div>

    <div class="col-lg-3 col-md-3 col-sm-3">        
        <a href="<?php echo web_root;?>/res/gate?b=ongoingp">
            <div class="p-3 bg-primary-500 rounded overflow-hidden position-relative text-white mb-g">
                <div class="">
                    <h3 class="display-4 d-block l-h-n m-0 fw-500">
                        <?php 
                        $newpj=$db->prepare('SELECT *FROM tbl_projects WHERE prjsts=12');      
                        $newpj->execute();    
                        echo $newpj->rowCount();         
                        ?>                        
                        <small class="m-0 l-h-n">Ongoing Project(s)</small>
                    </h3>
                </div>

                <i class="fa fa-circle-o-notch position-absolute pos-right pos-bottom opacity-15 mb-n1 mr-n1" style="font-size:6rem"></i>
            </div>        
        </a>   
    </div>

    <div class="col-lg-3 col-md-3 col-sm-3">        
        <a href="<?php echo web_root;?>/res/gate?b=cpteproj">
            <div class="p-3 bg-primary-500 rounded overflow-hidden position-relative text-white mb-g">
                <div class="">
                    <h3 class="display-4 d-block l-h-n m-0 fw-500">
                        <?php 
                        $newpj=$db->prepare('SELECT *FROM tbl_projects WHERE prjsts=10');      
                        $newpj->execute();    
                        echo $newpj->rowCount();         
                        ?>                        
                        <small class="m-0 l-h-n">Completed Project(s)</small>
                    </h3>
                </div>

                <i class="fa fa-check-circle position-absolute pos-right pos-bottom opacity-15 mb-n1 mr-n1" style="font-size:6rem"></i>
            </div>        
        </a>   
    </div>

    <div class="col-lg-3 col-md-3 col-sm-3">        
        <a href="<?php echo web_root;?>/res/gate?b=#">
            <div class="p-3 bg-primary-500 rounded overflow-hidden position-relative text-white mb-g">
                <div class="">
                    <h3 class="display-4 d-block l-h-n m-0 fw-500">
                    <?php 
                       $pendinvce = $totInv-$totPmnt;
                       echo number_format($pendinvce);
                    ?>
                        <small class="m-0 l-h-n">Pending Invoices</small>
                    </h3>
                </div>
                <i class="fa fa-exclamation-circle position-absolute pos-right pos-bottom opacity-15 mb-n1 mr-n1" style="font-size:6rem"></i>
            </div>        
        </a>   
    </div>

    <div class="col-lg-3 col-md-3 col-sm-3">        
        <a href="<?php echo web_root;?>/res/gate?b=#">
            <div class="p-3 bg-primary-500 rounded overflow-hidden position-relative text-white mb-g">
                <div class="">
                    <h3 class="display-4 d-block l-h-n m-0 fw-500">
                    <?php 
                       $pendpayables = $totInv2-$totPmnt2;
                       echo number_format($pendpayables);
                    ?>
                        <small class="m-0 l-h-n">Pending Payables</small>
                    </h3>
                </div>
                <i class="fa fa-exclamation-triangle position-absolute pos-right pos-bottom opacity-15 mb-n1 mr-n1" style="font-size:6rem"></i>
            </div>        
        </a>   
    </div>

    <div class="col-lg-3 col-md-3 col-sm-3">        
        <a href="#">
            <div class="p-3 bg-primary-500 rounded overflow-hidden position-relative text-white mb-g">
                <div class="">
                    <h3 class="display-4 d-block l-h-n m-0 fw-500">
                      <?php 
                        $completeReq=$db->prepare('SELECT *FROM tbl_con_infos c
                        INNER JOIN tbl_info_register i ON i.regst_id=c.reg_info_id
                        WHERE con_doctype=3 AND c.info_sts=3');
                        $completeReq->execute();
                        echo $completeReq->rowCount();
                      ?>
                      <small class="m-0 l-h-n">Validate Quotation</small>
                    </h3>
                </div>
                <i class="fa fa-check position-absolute pos-right pos-bottom opacity-15 mb-n1 mr-n1" style="font-size:6rem"></i>
            </div>        
        </a>           
    </div>

</div>