<?php
session_start();
if(!isset($_SESSION['LOGIN_STATUS']))
{
header('location:../index.php');
}
require "../model/configuration.php";
if(isset($_POST['cser']))
   {
   $cusid=$_POST['cusid']; 
                                   
    }
    else{ $cusid=$_GET['cusid']; 
  }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title><?php echo $_SESSION['title'];?></title>
    <link rel='stylesheet' type='text/css' href='../css/fonts.googleapis.com/css_cd14c140.css' />
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" type="text/css" href="../vendor/bootstrap/css/bootstrap.min.css" />
    <!-- Theme CSS -->
    <link rel="stylesheet" type="text/css" href="../css/vendor.css" />
    <link rel="stylesheet" type="text/css" href="../css/theme.css" />
    <link rel="stylesheet" type="text/css" href="../css/utility.css" />
    <link rel="stylesheet" type="text/css" href="../css/custom.css" />
  </head>
  <body class="dashboard-page">
    <script> var boxtest = localStorage.getItem('boxed'); if (boxtest === 'true') {document.body.className+=' boxed-layout';} </script>
    <!-- Start: Theme Preview Pane -->
    <!-- Start: Header -->
    <header class="navbar navbar-fixed-top">
      
      <?php include_once("../include/top_menu.php");?>
    </header>
    <!-- Start: Main -->
    <div id="main">
      
      <!-- Start: Sidebar -->
      <?php include_once("../include/left_menu.php");?>
      <!-- Start: Content -->
      <section id="content_wrapper">
        <div id="topbar">
          <div class="topbar-left">
            <ol class="breadcrumb">
              <li class="crumb-icon"><a href="#"><span class="glyphicon glyphicon-home"></span></a></li>
              <li class="crumb-link"><a href="#">Customer</a></li>
              <li class="crumb-trail">Customer Transaction Details</li>
            </ol>
          </div>
          
        </div>
        
        
        <div id="content">
          <div class="row" id="divToPrint">

          
            
            
            <div class="col-md-6">
              <div class="panel panel-visible">
                <div class="panel-heading">
                  <div class="panel-title "> <span class="glyphicon glyphicon-tasks"></span>Customer : 
                     <?php
                                                       $qryvender=$db->execute("select * from clients where client_id='".$cusid."' and delet='0'");
                                                    $vndror=$qryvender->fetch_assoc();
                                                     echo $vndror['client_name']."&nbsp(".$vndror['phone'].")"; 
                                                    ?>

                  </div>
                </div>
                <div class="panel-body pbn">
                  <table class="table table-striped table-bordered table-hover" >
                    <thead>
                      <tr>
                        <th>#</th>
                        <th>Estimate No</th>
                        <th>Estimate Date</th>
                        <th>Advance</th>
                        <th>Balance Amount</th>
                        
                       </tr>
                    </thead>
                    <tbody>
                     <?php
                      $c=0; 
                      $gtot=0;         
                     $sqry=$db->execute("select *  from cust_tran_main where delet='0' and custid='".$cusid."'");
                              while($row=$sqry->fetch_assoc())
                            { 
                             $c++; 
                             $gtot=$gtot+$row['total_amt']-$row['adv_amt'];
                             ?>
                      <tr>
                      <td><?php echo $c; ?></td>
                         <td><?php echo $row['estimateno'] ?> </td>

                          <td><?php echo date('d-m-Y',strtotime($row['date'])); ?></td>
                          <td><?php echo round($row['adv_amt']) ?> </td>
                          <td><?php echo round($row['total_amt']-$row['adv_amt']); ?> </td>
                          


                     </tr>
                     <?php
                   }
                     ?>
                     <tr>
                     <td colspan="4">Total</td>
                     <td><?php echo round($gtot) ?></td>
                     </tr>
                      
                    </tbody>
                  </table>
                </div>
              </div>
              
            </div>
               
      
          
      
             
            <div class="col-md-6">
              <div class="panel panel-visible">
                <div class="panel-heading">
                  <div class="panel-title "> <span class="glyphicon glyphicon-tasks"></span> Traansaction Details</div>
                </div>
                <div class="panel-body pbn">
                  <table class="table table-striped table-bordered table-hover" >
                    <thead>
                      <tr>
                        <th>#</th>
                        <th>Date</th>
                        <th>Amount</th>
                        <th>Type</th>
                        <th>Details</th>
                        <th>Action</th>
                        
                       </tr>
                    </thead>
                    <tbody>
                     <?php
                      $c=0; 
                           $btot=0; 
                     $sqry=$db->execute("select *  from cust_tran where delet='0' and cust_id='".$cusid."'");
                              while($row=$sqry->fetch_assoc())
                            { 

                             $c++; 
                             
                             $btot=$btot+$row['amt'];
                             ?>
                      <tr>
                      <td><?php echo $c; ?></td>
                         <td ><?php echo date('d-m-Y',strtotime($row['date'])); ?> </td>

                          <td><?php echo round($row['amt']) ?> </td>
                          <td><?php echo $row['type'] ?> </td>
                          <td><?php echo $row['detail'] ?></td>
                          <td><a href="../controler/delete_transaction.php?id=<?php echo $row['id'] ;?> && cusid=<?php echo $cusid; ?>"><i class="fa fa-trash-o"></i> </a></td>


                     </tr>
                     <?php
                   }
                     ?>
                     <tr>
                     <td colspan="2">Total</td>
                     <td colspan="4"><?php echo round($btot) ?></td>
                     </tr>
                     <tr>
                     <td colspan="2">Balance Amount</td>
                     <td colspan="4"><?php echo round($gtot-$btot) ?></td>
                     </tr>
                      
                    </tbody>
                  </table>
                </div>
              </div>
              
            </div>
               



              </div>
              
              <div class="col-md-12 col-sm-12 col-xs-12">
               <a href="coustomer_transaction.php?cusid=<?php echo $cusid;?>"  class="btn btn-alert" >Back</a></td>
                      
                        <input type="submit" class="btn btn-success" onclick="PrintDiv();" name="sub" value="Print">
                      </div>
          <?php //include_once("dashboard_content.php");?>
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
        </div>
        
        
      </section>
      
      <!-- Start: Right Sidebar -->
      
    </div>
    <!-- End #Main -->
    <!-- jQuery -->
    
    <script type="text/javascript">

                                                                function PrintDiv() {

                                                                    var divToPrint = document.getElementById('divToPrint');
                                                                    var popupWin = window.open('', '_blank', 'width=595,height=842');
                                                                    popupWin.document.open();
                                                                    popupWin.document.write('<html><link href="../vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" /><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
                                                                    popupWin.document.close();
                                                                }
        </script>
    <script type="text/javascript" src="../vendor/jquery/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="../vendor/jquery/jquery_ui/jquery-ui.min.js"></script> <!-- Bootstrap -->
    <script type="text/javascript" src="../vendor/bootstrap/js/bootstrap.min.js"></script>
    <!-- Page Plugins -->
    <script type="text/javascript" src="../vendor/plugins/validate/jquery.validate.js"></script>
    <script type="text/javascript" src="../vendor/plugins/morris/morris.js"></script>
    <script type="text/javascript" src="../vendor/plugins/datatables/js/jquery.dataTables.min.js"></script>
    <script type="text/javascript" src="../vendor/plugins/datatables/js/datatables.js"></script>
    <script type="text/javascript" src="../vendor/plugins/jvectormap/jquery-jvectormap.min.js"></script>
    <script type="text/javascript" src="../vendor/plugins/datepicker/bootstrap-datepicker.js"></script>
    <script type="text/javascript" src="../vendor/plugins/jquerymask/jquery.maskedinput.min.js"></script>
    <script type="text/javascript" src="../vendor/editors/xeditable/js/bootstrap-editable.js"></script>
    <!-- Flot Plugins -->
    <script type="text/javascript" src="../vendor/plugins/jqueryflot/jquery.flot.min.js"></script>
    <!-- Theme Javascript -->
    <script type="text/javascript" src="../js/utility/spin.min.js"></script>
    <script type="text/javascript" src="../js/utility/underscore-min.js"></script>
    <script type="text/javascript" src="../js/main.js"></script>
    <script type="text/javascript" src="../js/ajax.js"></script>
    <script type="text/javascript" src="../js/custom.js"></script>
    <script type="text/javascript">
    jQuery(document).ready(function () {
      
      "use strict";
      // Init Theme Core
    Core.init();
      // Enable Ajax Loading
    Ajax.init();
    
      
        
      // validate the comment form when it is submitted
      $("#altForm").validate();
      //Init jquery Date Picker
      $('.datepicker').datepicker()
      
      
        // Init Datatables with Tabletools Addon
    $('#datatable').dataTable( {
      "aoColumnDefs": [{ 'bSortable': false, 'aTargets': [ -1 ] }],
      "oLanguage": { "oPaginate": {"sPrevious": "", "sNext": ""} },
      "iDisplayLength": 5,
      "aLengthMenu": [[5, 10, 25, 50, -1], [5, 10, 25, 50, "All"]],
      "sDom": 'T<"panel-menu dt-panelmenu"lfr><"clearfix">tip',
      "oTableTools": {
        "sSwfPath": "./vendor/plugins/datatables/extras/TableTools/media/swf/copy_csv_xls_pdf.swf"
      }
      });
    
    // Add Placeholder text to datatables filter bar
    $('.dataTables_filter input').attr("placeholder", "Enter Filter Terms Here....");
    
    // Manually Init Chosen on Datatables Filters
      $("select[name='datatable_length']").chosen();
    
    // Init Xeditable Plugin
    $.fn.editable.defaults.mode = 'popup';
    $('.xedit').editable();
      
      
    });
    </script>
  </body>
</html>