GIF89a php
Current File : /home/hencockfreshchic/public_html/erp/debitledger.php
<?php
include("session.php");
include("connect.php");
include("libs.php");
include("page_content.php");
include("user_profile.php");
include("menu_links.php");
include("subCals/total_users.php");
?>
<!DOCTYPE html>
<html>

<head>

  <script type="text/javascript" src="editor/ed.js"></script>
  
<!--<script src="https://cloud.tinymce.com/stable/tinymce.min.js?apiKey=hmj5wmc3u49zbs29zpa584l5kaml1l4wvmt6o9k9u0k3uzci"></script>
  <script src="https://cloud.tinymce.com/stable/tinymce.min.js"></script>
  <script>tinymce.init({ selector:'textarea' });</script> -->   
  
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title><?php echo $page_title17; ?></title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.7 -->
  <link rel="stylesheet" href="css/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="css/font-awesome.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="css/AdminLTE.css">
  <link rel="stylesheet" href="css/all-skins.min.css">
  <script src='https://kit.fontawesome.com/a076d05399.js' crossorigin='anonymous'></script>
  <script src="https://kit.fontawesome.com/67adbbaee5.js" crossorigin="anonymous"></script>
  <link rel="stylesheet" href="css/bootstrap-tagsinput.css">

  
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

  <link rel="stylesheet" href="ckeditor/sample/css/samples.css">
  <link rel="stylesheet" href="ckeditor/toolbarconfigurator/lib/codemirror/neo.css">
  <link rel="stylesheet" href="ckeditor/sample/css/samples.css">
  <link rel="stylesheet" href="ckeditor/toolbarconfigurator/lib/codemirror/neo.css">
  <script src="ckeditor/ckeditor.js"></script>
      <script src="ckeditor/sample/js/sample.js"></script>


<script type="text/javascript" src="js/saveDebit.js"></script>
<script type="text/javascript" src="js/deleteData.js"></script>
<script type="text/javascript" src="js/searchMe5.js"></script>

<script src="js/hideForm.js"></script>  
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

  <header class="main-header">
    <!-- Logo -->
    <a href="index.php" class="logo" style="background-color:<?php echo $header_color_light; ?> !important">
      <!-- mini logo for sidebar mini 50x50 pixels -->
      <span class="logo-mini"><?php echo $page_title17; ?></span>
      <!-- logo for regular state and mobile devices -->
      <span class="logo-lg" style="background-color:<?php echo $header_color_light; ?> !important"><?php echo $logo; ?></span>
    </a>
    <!-- Header Navbar: style can be found in header.less -->
    <nav class="navbar navbar-static-top" style="background-color:<?php echo $header_color; ?> !important">
      <!-- Sidebar toggle button-->
      <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
        <span class="sr-only">Toggle navigation</span>
      </a>


       <div class="navbar-custom-menu">
        <ul class="nav navbar-nav">
        
          <li class="dropdown user user-menu">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown">              
              <span class="hidden-xs"><?php echo $user_name; ?><i class="fa fa-caret-down"></i></span>
            </a>
            <ul class="dropdown-menu">
              <!-- User image -->
              <li class="user-header">
               <!-- <img src="dist/img/user2-160x160.jpg" class="img-circle" alt="User Image">  -->

                <p>
                  <?php echo getUser($conn,$_COOKIE["sr"]); ?>
                </p>
              </li>
             
              <!-- Menu Footer-->
              <li class="user-footer">          
                <div class="pull-right">
                  <a href="logout.php?page=index" class="btn btn-default btn-flat">Sign out</a>
                </div>
              </li>
            </ul>
          </li>
          <!-- Control Sidebar Toggle Button -->
         
        </ul>
      </div>
    </nav>
  </header>
  <!-- Left side column. contains the logo and sidebar -->
  <aside class="main-sidebar">
    <!-- sidebar: style can be found in sidebar.less -->
    <section class="sidebar">
      <!-- sidebar menu: : style can be found in sidebar.less -->
      <ul class="sidebar-menu" data-widget="tree">
        <li class="header">MAIN NAVIGATION</li>    
           
           <?php include("menus.php"); ?>           
      
      </ul>
    </section>
    <!-- /.sidebar -->
  </aside>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        Dashboard
        <small><?php echo $page_title17; ?></small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="index.php"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="active">Dashboard</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
      <!-- Small boxes (Stat box) -->
      <div class="row">
        <div class="col-md-1 col-sm-1 col-xs-1">
        </div>
        <div class="col-md-10 col-sm-10 col-xs-10">
          <div class="form">
      
          
              </div>
        </div> 
            
            
            
     
      <input type="date" max="<?php echo date('Y-m-d'); ?>" id="date" name="date" title="Select start date">
      <input type="date" max="<?php echo date('Y-m-d'); ?>" id="end_date" name="end_date" title="Select date">
      <select id="uname1">
        <option value="">Select customer</option>
        <?php
            $sqlU="SELECT * FROM `records`";
            $rsU=mysqli_query($conn,$sqlU);
            while($rowU=mysqli_fetch_array($rsU)){
        ?>
        <option value="<?php echo $rowU['uname']; ?>"><?php echo $rowU['uname']; ?></option>
      <?php } ?>
      </select>
      <select id="typee">
        <option value="">Select bird</option>
        <option value="Live Bird">Live Bird</option>
      </select>
      <button onclick="searchMe5('debitledger.php')">Search</button>

        <div class="col-md-6 col-sm-6 col-xs-6">
          <span style="color: red">Debit Records</span>
          <div class="table">
          <div class="table-responsive" style="height:auto;">
                <table class="table no-margin">
                 <thead> 
                  <tr>
                    <th style="background-color: red !important;">Sr</th>
                    <th style="background-color: red !important;">Name <br>Mobile No</th>
                    <th style="background-color: red !important;">Type</th>
                    <th style="background-color: red !important;">Amount</th>
                    <th style="background-color: red !important;">Weight<br>Price</th>
                    <th style="background-color: red !important;">Date<br>Time</th>
                    
                  </tr>
                 </thead>
                  <tbody>
                  <?php 
          $SR=0;
          if($_GET['date']<>"" && $_GET['type']<>"" && $_GET['uname']=="")
          {
              $sqlT="SELECT * FROM `debit_record` WHERE `datee`>='".$_GET['date']."' && `datee`<='".$_GET['end_date']."' && `type`='".$_GET['type']."' ORDER BY `sr` DESC";
          }
          else if($_GET['date']<>"" && $_GET['type']<>"" && $_GET['uname']<>"")
          {
              $sqlT="SELECT * FROM `debit_record` WHERE `datee`>='".$_GET['date']."' && `datee`<='".$_GET['end_date']."' && `type`='".$_GET['type']."' && `uname`='".$_GET['uname']."' ORDER BY `sr` DESC";
          }
          else if($_GET['date']=="" && $_GET['type']=="" && $_GET['uname']<>"")
          {
              $sqlT="SELECT * FROM `debit_record` WHERE `uname`='".$_GET['uname']."' ORDER BY `sr` DESC";
          }
          
          $rsT=mysqli_query($conn,$sqlT);
          while($rowT=mysqli_fetch_array($rsT))
          {
            $SR=$SR+1;
            $sqlU="SELECT * FROM `records` WHERE `uname`='".$rowT['uname']."'";
            $rsU=mysqli_query($conn,$sqlU);
            $rowU=mysqli_fetch_assoc($rsU);
          ?><tr>
                    <td><?php echo $SR; ?></td>
                    <td><?php echo $rowU["uname"]; ?><br><?php echo $rowU["mobb"]; ?></td>
                    <td><?php echo $rowT['type']; ?></td>
                    <td style="color: red"><?php echo "Total Rs. ".($rowT['weight']*$rowT['actual_price'])." /-"; ?></td>
                    <td><?php echo $rowT['weight']." KG"; ?><br><?php echo "Rate. ".$rowT['actual_price']; ?></td>
                    <td><?php echo $rowT['datee']; ?><br><?php echo $rowT['timee']; ?></td>   

                       
                    </tr>
                 <?php
          }
         ?>
                 
                  </tbody>
                </table>
              </div>
            </div>
        </div>






        <div class="col-md-6 col-sm-6 col-xs-6">
          <span style="color: green">Credit Records</span>
          <div class="table">
          <div class="table-responsive" style="height:auto;">
                <table class="table no-margin">
                 <thead> 
                  <tr>
                    <th style="background-color: green !important;">Sr</th>
                    <th style="background-color: green !important;">Name <br>Mobile No</th>
                    <th style="background-color: green !important;">Type</th>
                    <th style="background-color: green !important;">Amount</th>
                    <th style="background-color: green !important;">Date<br>Time</th>
                    
                  </tr>
                 </thead>
                  <tbody>
                  <?php 
          $SR2=0;
          if($_GET['date']<>"" && $_GET['type']<>"" && $_GET['uname']=="")
          {
              $sqlT2="SELECT * FROM `credit_record` WHERE `datee`>='".$_GET['date']."' && `datee`<='".$_GET['end_date']."' && `type`='".$_GET['type']."' ORDER BY `sr` DESC";
          }
          else if($_GET['date']<>"" && $_GET['type']<>"" && $_GET['uname']<>"")
          {
              $sqlT2="SELECT * FROM `credit_record` WHERE `datee`>='".$_GET['date']."' && `datee`<='".$_GET['end_date']."' && `type`='".$_GET['type']."' && `uname`='".$_GET['uname']."' ORDER BY `sr` DESC";
          }
          else if($_GET['date']=="" && $_GET['type']=="" && $_GET['uname']<>"")
          {
              $sqlT2="SELECT * FROM `credit_record` WHERE `uname`='".$_GET['uname']."' ORDER BY `sr` DESC";
          }
          
          $rsT2=mysqli_query($conn,$sqlT2);
          while($rowT2=mysqli_fetch_array($rsT2))
          {
            $SR2=$SR2+1;
            $sqlU2="SELECT * FROM `records` WHERE `uname`='".$rowT2['uname']."'";
            $rsU2=mysqli_query($conn,$sqlU2);
            $rowU2=mysqli_fetch_assoc($rsU2);
          ?><tr>

                    <td><?php echo $SR2; ?></td>
                    <td><?php echo $rowU2["uname"]; ?><br><?php echo $rowU2["mobb"]; ?></td>
                    <td><?php echo $rowT2['type']; ?></td>
                    <td style="color: green"><?php echo "Rs. ".$rowT2['amount']." /-"; ?></td>
                    <td><?php echo $rowT2['datee']; ?><br><?php echo $rowT2['timee']; ?></td>   

                       
                    </tr>
                 <?php
          }
         ?>
                 
                  </tbody>
                </table>
              </div>
            </div>
        </div>


        <div class="col-md-12 col-sm-12 col-xs-12">
          <div class="table">
          <div class="table-responsive" style="height:auto;">
                <table class="table no-margin">
                 <thead> 
                  <tr>
                    <th>Grand Total Debit(Dr)</th>                    
                    <th>Total Weight(Dr)</th>                    
                    <th>Grand Total Credit(Cr)</th>                    
                    <th>Pending Amount</th>                    
                  </tr>
                 </thead>
                  <tbody>
               <tr>
                <?php
                    $totalDebit=totalDebit($conn,$rowU["type"],$rowU['uname'],$_GET['date'],$_GET['end_date']);
                    $totalCredit=totalCredit($conn,$rowU["type"],$rowU['uname'],$_GET['date'],$_GET['end_date']);
                    $totalDebitWeight=totalDebitWeight($conn,$rowU2["type"],$rowU2['uname'],$_GET['date'],$_GET['end_date']);
                ?>
                    <td style="color: red"><?php echo "Rs. ".$totalDebit." /-"; ?></td> 
                    <td><?php echo $totalDebitWeight." KG"; ?></td>  
                    <td style="color: red"><?php echo "Rs. ".$totalDebit." /-"; ?></td>                    
                    <td><?php echo "Rs. ".($totalDebit-$totalCredit)." /-"; ?></td>  

                       
                    </tr>
              
                 
                  </tbody>
                </table>
              </div>
            </div>
        </div>


      </div>
      <!-- /.row -->

    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
  <footer class="main-footer">
    <div class="pull-right hidden-xs">
      <b><span class="logo-lg" style="margin-bottom:10px">

        <?php echo $logo; ?></span></b>
      
    </div>
    <strong><?php echo $copywite; ?></strong> All rights
    reserved.
  </footer>


</div>
<!-- ./wrapper -->

<!-- jQuery 3 -->
<script src="js/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="js/bootstrap.min.js"></script>
<!-- AdminLTE App -->
<script src="js/adminlte.min.js"></script>

<script src="js/bootstrap-tagsinput.min.js"></script>

<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.11.1/typeahead.bundle.min.js"></script>

</body>
</html>

<?php
function getUser($conn,$sr)
{
  $sqlUser="SELECT * FROM `admin_user` WHERE `sr`='".$sr."'";
  $rsUser=mysqli_query($conn,$sqlUser);
  $rowUser=mysqli_fetch_assoc($rsUser);
  $user_name=$rowUser["user_name"];

  return $user_name;
}




?>