<?php include "layouts/menu.php"; ?> <div class="right_col" role="main">
  <script>
function add()
{
var a = document.getElementById("n2000").value;
var b = document.getElementById("n500").value;
var bb = document.getElementById("n200").value;
var c = document.getElementById("n100").value;
var d = document.getElementById("n50").value;
var e = document.getElementById("n10").value;
var e2 = document.getElementById("n20").value;
var f = document.getElementById("coins").value;
var f2 = document.getElementById("coins2").value;
var f5 = document.getElementById("coins5").value;
document.getElementById("tot").value =(a*2000)+(b*500)+(bb*200)+(c*100)+(d*50)+(e*10)+(e2*20)+(f*1)+(f2*2)+(f5*5);
}
</script>   
   <div class="row">
          
                <!--end page header -->
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <!-- Form Elements -->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            ACCOUNT NOTES ENTRY
                        </div>
                        <div class="panel-body">
                            <div class="row">
<?php 
$tdy = date('Y-m-d');
$sql = mysqli_query($conn, "select * from acc where date='$tdy'");
$row = mysqli_fetch_array($sql); 
$sts = $row['sts'];
if($sts == 'Close') { ?>
Entry Denided <?php } else{
?>
   <div class="alert alert-info">Register </div>
   <form name="form1" class="form-horizontal" method="post" action="00acc.php" enctype="multipart/form-data">
   <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">2000 RS NOTES</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="n2000" name="n2000" value="<?php echo $row['n2000']; ?>" onkeyup="add()" placeholder="Amount in Rs" >
    </div>
  </div>
     <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">500 RS NOTES</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="n500" name="n500" value="<?php echo $row['n500']; ?>" onkeyup="add()" placeholder="Amount in Rs" >
    </div>
  </div>
     <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">200 RS NOTES</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="n200" name="n200" value="<?php echo $row['n200']; ?>" onkeyup="add()" placeholder="Amount in Rs" >
    </div>
  </div>
     <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">100 RS NOTES</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="n100" name="n100" value="<?php echo $row['n100']; ?>" onkeyup="add()" placeholder="Amount in Rs" >
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">50 RS NOTES</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="n50" name="n50" value="<?php echo $row['n50']; ?>" onkeyup="add()" placeholder="Amount in Rs" >
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">20 RS NOTES</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="n20" name="n20" value="<?php echo $row['n20']; ?>" onkeyup="add()" placeholder="Amount in Rs" >
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">10 RS NOTES</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="n10" name="n10" value="<?php echo $row['n10']; ?>" onkeyup="add()" placeholder="Amount in Rs" >
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">5 Rs Coins</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="coins5" name="coins5" value="<?php echo $row['coins5']; ?>" onkeyup="add()" placeholder="Amount in Rs" >
    </div>
  </div>
   <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">2 Rs Coins</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="coins2" name="coins2" value="<?php echo $row['coins2']; ?>" onkeyup="add()" placeholder="Amount in Rs" >
    </div>
  </div>
   <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">1 Rs Coins</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="coins" name="coins" value="<?php echo $row['coins']; ?>" onkeyup="add()" placeholder="Amount in Rs" >
    </div>
  </div>
   <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Total</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="tot" name="tot" value="<?php echo $row['tot']; ?>" onclick="add()" placeholder="Amount in Rs" >
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Date</label>
    <div class="col-sm-4">
      <input type="date" class="form-control" id="datepicker" name="date" value="<?php echo date('Y-m-d'); ?>" 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">Remarks</label>
    <div class="col-sm-4">
      <textarea class="form-control" rows="3" name="details" value="<?php echo $row['details']; ?>" placeholder=""><?php echo $row['details']; ?></textarea>
    </div>
  </div>  
   <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Status</label>
    <div class="col-sm-4">
      <select type="text" class="form-control" id="sts" name="sts" value="<?php echo $row['tot']; ?>" onclick="add()" placeholder="Amount in Rs" >
    <option value="<?php echo $row['sts']; ?>"><?php echo $row['sts']; ?></option>
	 <option value="Save">Save</option>
	  <option value="Close">Save & Close</option>
	  </select>
	</div>
  </div>
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-default" name="s1">Save This</button>
    </div>
  </div>
      <div class="alert alert-success">
	<?php
							if(isset($_POST['s1']))
							{
								extract($_POST);
					mysqli_query($conn, "DELETE FROM acc where mfin='$mfin' && date = '$date'");

$ctime =  date('d-m-Y h:i:sa');

								$insert=mysqli_query($conn, "insert into acc(ctime,sts,mfin,scode,n2000,n500,n200,n100,n50,n20,n10,coins,coins2,coins5,date,details,tot)
											 values('$ctime','$sts','$mfin','$scode','$n2000','$n500','$n200','$n100','$n50','$n20','$n10','$coins','$coins2','$coins5','$date','$details','$tot')");
								
								if($insert)
								{
									
										header("Location:state2.php?tot=$tot&ddd=$date");
									
								}
								else
								{
									echo "Failure";
								}
							}
?>
	  </div>
</form>
</div>
<?php } ?>
                                </div><!-- /.box-body -->
                            </div><!-- /.box -->
 
 
</div>
</div></div>
</div></div></div> <?php include "layouts/footer.php"; ?></body></html>