<?php
  echo @$_GET['msg'];
  session_start();
  if(isset($_SESSION['userId'])){ 
    $uid= $_SESSION['userId'];
    require 'connection.php';
include 'template/header.php';

?>


<div class="ch-container">
    <div class="row">
        
<!-- SIDEBAR HERE-->
<?php

include 'template/sidebar.php';

?>

        <div id="content" class="col-lg-10 col-sm-10">
            <!-- content starts -->
            <div>
    <ul class="breadcrumb">
        <li>
            <a href="#">Home</a>
        </li>
        <li>
            <a href="#">Dashboard</a>
        </li>
    </ul>
</div>
<div class=" row">
    <div class="col-md-3 col-sm-3 col-xs-6">
        <a data-toggle="tooltip" class="well top-block" href="#">
            <i class="glyphicon  blue"></i>
<?php 
if($_SESSION['userId']==2532){


?>
            <div style="font-size: 14px; font-weight:bold; ">Broiler Customers</div>
            <div style="font-size: 18px; font-weight:bold; "><?php 
            $custBal=0;
    require 'connection.php'; 
         $qry = "SELECT sum(debit)-sum(credit) as balnc  FROM ledger inner join accreg on ledger.accid=accreg.accid where groupid=11 and activityacc=0";
             $run = mysqli_query($connect, $qry) or die(mysqli_error($connect));
   $row = mysqli_fetch_array($run);
$custBal= $row['balnc'];
if($custBal<0){
$custBal=$custBal*(-1);
echo $custBal.' Cr';
}
else{
echo $custBal.' Dr';
}
            ?></div>

<?php 
}


?>
        </a>
    </div>

    <div class="col-md-3 col-sm-3 col-xs-6">
        <a data-toggle="tooltip" class="well top-block" href="#">
            <i class="glyphicon green"></i>
            <!-- <i class="glyphicon glyphicon-star green"></i> -->

        <?php 
if($_SESSION['userId']==2532){


?>
            <div style="font-size: 14px; font-weight:bold; ">Broiler Vendors</div>
            <div style="font-size: 18px; font-weight:bold; "><?php 
            $balncs=0;
    require 'connection.php'; 
         $qry = "SELECT sum(debit)-sum(credit) as balnc  FROM ledger inner join accreg on ledger.accid=accreg.accid where groupid=15 and activityacc=0";
             $run = mysqli_query($connect, $qry) or die(mysqli_error($connect));
   $row = mysqli_fetch_array($run);
   if($row['balnc']<0){
$balncs= $row['balnc']*(-1);
echo $balncs.' Cr';
   }
   else{
echo $row['balnc'].' Dr';

   }
            ?></div>

<?php 
}
?>
        </a>
    </div>

    <div class="col-md-3 col-sm-3 col-xs-6">
        <a data-toggle="tooltip"  class="well top-block" href="#">
            <i class="glyphicon  yellow"></i>
            <!-- <i class="glyphicon glyphicon-shopping-cart yellow"></i> -->
<?php 
if($_SESSION['userId']==2532){


?>
            <div style="font-size: 14px; font-weight:bold; ">Cash at Bank</div>
            <div style="font-size: 18px; font-weight:bold; "><?php 
            $custBal=0;
    require 'connection.php'; 
         $qry = "SELECT sum(debit)-sum(credit) as balnc  FROM ledger inner join accreg on ledger.accid=accreg.accid where groupid=9 and activityacc=0";
             $run = mysqli_query($connect, $qry) or die(mysqli_error($connect));
   $row = mysqli_fetch_array($run);
$custBal= $row['balnc'];
if($custBal<0){
$custBal=$custBal*(-1);
echo $custBal.' Cr';
}
else{
echo $custBal.' Dr';
}
            ?></div>

<?php 
}


?>
        </a>
    </div>


</div>

                   
    <!-- Modal -->
    <div class="modal fade" id="imageModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-body">
                    <img style="width: 100%; height: 100%;" id="modalImage" src="darood1.jpg" alt="Image Description">
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>
                   



    <!-- content ends -->
    </div><!--/#content.col-md-0-->
</div><!--/fluid-row-->

   

   <?php

include 'template/footer.php';

?>

<script>
        $(document).ready(function () {
         
          
                $('#imageModal').modal('show');
            
        });

      
    </script>



<?php }
else{
   header('location: index.php');
}
 ?>