<?php include "layouts/menu.php"; ?>    
  <!--  page-wrapper -->
         <div class="right_col" role="main">
            <div class="row">
                 <!-- page header -->
                <div class="col-lg-12">
                    <h1 class="page-header  alert alert-info">Day Book</h1>
                </div>
                <!--end page header -->
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <!-- Form Elements -->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                             Details
                        </div>
                        <div class="panel-body">
                            <div class="row">
  
   <form class="form-horizontal" method="post" action="" enctype="multipart/form-data">
    <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Enter From Date</label>
    <div class="col-sm-4">
    <input type="text" class="form-control" id="datepicker" name="fdate" value="" placeholder="DD/MM/YYYY" onfocus="insertDate(this,'DD-MM-YYYY')">
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Enter To Date</label>
    <div class="col-sm-4">
    <input type="text" class="form-control" id="datepicker" name="tdate" value="" placeholder="DD/MM/YYYY" onfocus="insertDate(this,'DD-MM-YYYY')">
    </div>
  </div>
			<div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-default" name="s129">Total</button>
    </div>
  </div>
  <input type="button" value="Print" onclick="PrintElem('#mydiv')"  style="margin:20px;"><div id="mydiv">
    <?php
								if(isset($_POST['s129']))
								{
									extract($_POST);
									
									$tr1 = 0; $tr2= 0;$tr3 = 0; $tr4= 0;$tr5 = 0; $tr6= 0;$tr7 = 0; $tr8= 0; ?>
									<div class="table-responsive">
  <table class="table table-bordered table-hover" border="1"><thead>
										

					<font size="1">
						<tr class="danger" style="color:purple;">
						<th><font size="1">S.No</font></th>
						
						<th><font size="1">EntryDate</font></th>
					
						<th><font size="1">Particulars</font></th>
						
						<th><font size="1">Credit</font></th>
						
						<th><font size="1">Debit</font></th>
						
						
						</tr></thead>
									
									<?php $e=0;  $s=0;  $r=0;  $t=0; $d=0; $d1=0; $i=1;
								while (strtotime($fdate) <= strtotime($tdate)) 
								{
									   $paydate = $fdate;
						$qry=mysqli_query($conn, "select * from invest where mfin='$mfin' &&  date='$paydate'");
						$qry1=mysqli_query($conn, "select * from customerdetails where mfin='$mfin' &&  hpdate='$paydate'");
						$qry4=mysqli_query($conn, "select * from user where mfin='$mfin' &&  paydate='$paydate'");
					
						$qry2=mysqli_query($conn, "select * from debit where mfin='$mfin' &&  date='$paydate'");
						$qry3=mysqli_query($conn, "select * from salary where mfin='$mfin' &&  date='$paydate'");
						$qry5=mysqli_query($conn, "select * from bank where mfin='$mfin' &&  date='$paydate'");
						$n=mysqli_num_rows($qry);
						
						?></p>
				
					
					<?php 
					
					
					while($row=mysqli_fetch_array($qry))
						{
					?><tbody>
					<tr class="warning">
					<td><font size="1"><?php echo $i;?></font></td>
						
						<td><font size="1"><?php echo $paydate;?></font></td>
						
						<td><font size="1"><?php echo $row['investor'];?></font></td>
						
						<td><font size="1"><?php echo $row['invest']; ?></font></td>
						
						<td></td>
							</tr>
					<?php
					$i++;
					$e=$row['invest']+$e;
						}?>
						<?php
						
						while($row1=mysqli_fetch_array($qry1))
						{
						?>
					<tr class="warning">

					<td><font size="1"><?php echo $i;?></font></td>
						<td><font size="1"><?php echo $paydate;?></font></td>
						
						<td><font size="1"><?php echo $row1['name'];?></font></td>
						<td></td>
						<td><font size="1"><?php echo $row1['hpamount']; ?></font></td>
						
						
											</tr>
						
					<?php
					$i++;
					$s=$row1['hpamount']+$s;
					 }?>
					 
					 
					 
					 <?php
						$ss=0;
						$sd=0;
						while($row5=mysqli_fetch_array($qry5))
						{
						?>
					<tr class="warning">
	
					<td><font size="1"><?php echo $i;?></font></td>
						<td><font size="1"><?php echo $paydate;?></font></td>
						
						<td><font size="1">Bank</font></td>
						
						<td><font size="1"><?php echo $row5['debit']; ?></font></td>
						
						<td><font size="1"><?php echo $row5['credit']; ?></font></td>
											</tr>
						
					<?php
					$i++;
					$ss=$row5['credit']+$ss;
					$sd=$row5['debit']+$sd;
					 }?>
					 
					 
					 
					 
					 <?php
						
						while($row4=mysqli_fetch_array($qry4))
						{
						?>
					<tr class="warning">
					<td><font size="1"><?php echo $i;?></font></td>
						<td><font size="1"><?php echo $paydate;?></font></td>
						
						<td><font size="1"><?php echo $row4['name'];?></font></td>
						
						<td><font size="1"><?php echo $row4['amt']; ?></font></td>
						
						<td></td>
											</tr>
						
					<?php
					$i++;
					$r=$row4['amt']+$r;
					 }?>
					 
					 
					 
					 
					 
					 <?php
					
						while($row2=mysqli_fetch_array($qry2))
						{
						?>
					<tr class="warning">
					<td><font size="1"><?php echo $i;?></font></td>
						<td><font size="1"><?php echo $paydate;?></font></td>
						
						<td><font size="1"><?php echo $row2['cat'];?></font></td>
						
						<td></td>
					
						<td><font size="1"><?php echo $row2['debit']; ?></font></td>
											</tr>
						
					<?php
					$i++;
					$d=$row2['debit']+$d;
					 }
					 ?>
					 
					 
					 
					  <?php
					
						while($row3=mysqli_fetch_array($qry3))
						{
						?>
					<tr class="warning">
					<td><font size="1"><?php echo $i;?></font></td>
						<td><font size="1"><?php echo $paydate;?></font></td>
						
						<td><font size="1"><?php echo $row3['name'];?></font></td>
						
						<td></td>
						
						<td><font size="1"><?php echo $row3['debit']; ?></font></td>
											</tr>
						
					<?php
					$i++;
					$t=$row3['debit']+$t;
								} $fdate = date ("d-m-Y", strtotime("+1 day", strtotime($fdate))); }
					 ?>
				
					 <tr class="warning">
					<td><font size="1"><?php echo $i;?></font></td>
						
						
						
				
						<td></td>
						<td><B><font size="1">TOTAL</B></td>
						<td><B><font size="1"><?php echo $e+$r+$sd;?></font></B></td>
						<td><B><font size="1"><?php echo $t+$d+$ss+$s;?></font></B></td>
											</tr>
						<?php 
						$deb=$e+$r+$sd;
						$dt=$t+$d+$ss+$d1+$s;
						?>
						<tr class="warning">
					<col width="100px">
					<td><font size="1"><?php echo $i;?></font></td>
						
						
						<td></td>
						<td></td>
						<td><B><font size="1">Cash in Hand</font></B></td>
						
							<td><B><font size="1"><?php echo $deb-$dt; ?></font></B></td>
										</tr>
					 
					 <?php
					}
					
				
					?>
					</tbody></table>	</form>
					
</div>
</div></div>
</div></div></div><?php include "layouts/footer.php"; ?></body></html>
