<?php include "layouts/menu.php"; ?> 
    <?php $hpl=$_REQUEST['hpl'];?>
	<script> 
function add() 
{ 
var x = document.getElementById("int2").value; 
var z = document.getElementById("bm1").value; 
var w = document.getElementById("totam").value; 
document.getElementById("totot").value =(((x*1)+(1*w))*(z*1));
} 
</script>
<script> 
function add1() 
{ 
var x = document.getElementById("t1").value; 
var y = document.getElementById("t2").value; 
document.getElementById("totam").value =(x*1)*(y*1); 
} 
</script>
<script>
function add2()
{
var x1 = document.getElementById("1").value;
var y1 = document.getElementById("2").value;
document.getElementById("int3").value =(x1*1)*(y1/100);
}
</script>
<script> 
function add3() 
{ 
var x = document.getElementById("no").value; 
var y = document.getElementById("t2").value; 
document.getElementById("bm1").value =(x*1)-(y*1); 
} 
</script>
<script> 
function adds() 
{ 
var x = document.getElementById("int2").value; 
var y = document.getElementById("int3").value; 
document.getElementById("int3").value =(x*1)*(y/30); 
} 
</script>
<script>
    function diff()
{
    var date14 = document.getElementById("gh").value;
    var date15 = document.getElementById("bm1").value;
	
	var date11 = date14.split("-").reverse().join("-");
	var date22 = date15.split("-").reverse().join("-");

    var one_day=1000*60*60*24;

    var date1 = new Date(date11);
    var date2 = new Date(date22);

      // Convert both dates to milliseconds
      var date1_ms = date1.getTime();
      var date2_ms = date2.getTime();

      // Calculate the difference in milliseconds
      var difference_ms = date2_ms - date1_ms;

      // Convert back to days and return
document.getElementById("int2").value =  Math.round(difference_ms/one_day); 

}
</script>
<script> 
function addss() 
{ 
var x = document.getElementById("int3").value; 
var y = document.getElementById("1").value; 
var z = document.getElementById("totam").value; 
document.getElementById("totot").value =(((x*1)+(y*1))-(z*1)); 
} 
</script>
<script> 
function add4() 
{ 
var x = document.getElementById("totot").value; 
var y = document.getElementById("bm1").value; 
document.getElementById("tamt").value =(x*1)*(y*1); 
} 
</script>
  <!--  page-wrapper -->
         <div class="right_col" role="main">
           
            <div class="row">
                <div class="col-lg-12">
                    <!-- Form Elements -->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                           Seized Entry Details
                        </div>
                        <div class="panel-body">
                            <div class="row">
  <div class="col-xs-12 col-md-8">
    <form name="form1" class="form-horizontal" method="post" action="" enctype="multipart/form-data">
	
 <?php	$qry=mysqli_query($conn, "select * from net");
						$n=mysqli_num_rows($qry);
						if($n==0)
						{
							$rty = 1;
						}
						else
					    {
						while($row=mysqli_fetch_array($qry))
						{
						$sss = $row['rno'];
						}
						$rty = $sss + 1;
						} ?>	
	<?php
	$x=$hpl; 
  $qry2 = "SELECT * FROM customerdetails where mfin='$mfin' &&  hpl='$x'";
  $result = mysqli_query($conn, $qry2);
	if (mysqli_num_rows($result) >= 1) 
				{ 
	  $rs = mysqli_query($conn, $qry2);
	  // Loop the recordset $rs
	// Each row will be made into an array ($row) using mysqli_fetch_array
	while($row2 = mysqli_fetch_array($rs)) {

	    $row2 = str_replace('/', '-', $row2['hpdate']);
  $d1 = strtotime($row2);
$d2 = strtotime("today");
$min_date = min($d1, $d2);
$max_date = max($d1, $d2);
$i = 0;
while (($min_date = strtotime("+1 MONTH", $min_date)) <= $max_date) {
    $i++;
}}
$qry=mysqli_query($conn, "select * from user where mfin='$mfin' &&  hpl=$x");
$nn=mysqli_num_rows($qry);
$e = $i - $nn;
			
				}
				$qry=mysqli_query($conn, "select * from customerdetails where mfin='$mfin' &&  hpl='$hpl'");
				$query=mysqli_query($conn, "select * from user where mfin='$mfin' &&  hpl='$hpl'");
				$row=mysqli_fetch_array($qry);
				$row1=mysqli_fetch_array($query);
				$pp = $row['duemnt'];
			$sad = $row['duemnt'];

$sql1 = "select sum(paymnt) from user where mfin='$mfin' &&  hpl=$hpl";
$qt = mysqli_query($conn, $sql1);
$row1 = mysqli_fetch_array($qt);

$sql5=$row1[0];
$sql6=$sql5 + 1;


?> 

	<div class="alert alert-info">Welcome <?php echo $row['name'];?></div>
	<img style="margin-left:150px;margin-bottom:20px;"" src="user/<?php echo $row['uimg'];?>" height="100" width="100"/>
   <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">HPL</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="inputPassword3" name="hpl" value="<?php echo $row['hpl'];?>" placeholder="E.g 1008" readonly>
    </div>
    <label for="inputPassword3" class="col-sm-2 control-label">Name</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="inputPassword3" name="name" value="<?php echo $row['name'];?>" placeholder="" readonly>
    </div>
  </div>	
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">Due Month</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="no" name="no" value="<?php echo $pp; ?>" placeholder="" readonly> 
    </div>
    <label for="inputPassword3" class="col-sm-2 control-label">H.p Date</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="gh" name="duedate" readonly value="<?php echo $row['hpdate'];?>" placeholder="Due Date" onfocus="insertDate(this,'<?php echo $row['hpdate'];?>--/MM/YYYY')">
    </div>
  </div>
    <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Due Amount</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="t1" name="dueamount" readonly value="<?php echo $row['total'];?>" placeholder="Due Amount">
    </div>
	   <label for="inputPassword3" class="col-sm-2 control-label">H.P Amount</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="1" name="dueamt" readonly value="<?php echo $row['hpamount'];?>" placeholder="H.P Amount">
	    <input type="hidden" class="form-control"  name="vno" readonly value="<?php echo $row['vno'];?>" placeholder="H.P Amount">
		 <input type="hidden" class="form-control"  name="vname" readonly value="<?php echo $row['vname'];?>" placeholder="H.P Amount">
		  <input type="hidden" class="form-control"  name="model" readonly value="<?php echo $row['model'];?>" placeholder="H.P Amount">
		   <input type="hidden" class="form-control"  name="color" readonly value="<?php echo $row['color'];?>" placeholder="H.P Amount">
    </div>
  </div>
   <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Sizzing Date</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="t1" name="sizdate" value="" placeholder="Sizzing Date" onfocus="insertDate(this,'DD-MM-YYYY')" required="required">
    </div>
	 
 
    <label for="inputPassword3" class="col-sm-2 control-label">Godown</label>
    <div class="col-sm-4">
      <select type="text" class="form-control"  name="godown" value="" placeholder="" >
	  <option>Select</option>
	  <?php $sql5 = mysqli_query($conn, "select * from godown"); while($row5 = mysqli_fetch_array($sql5)) { ?>
	  <option><?php echo $row5['name']; ?></option> <?php } ?></select>
    </div>
	 
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Sizzed by</label>
    <div class="col-sm-4">
      <select type="text" class="form-control" name="byy" value="" placeholder="" >
	   <option>Select</option>
	  <?php $sql55 = mysqli_query($conn, "select * from customer"); while($row55 = mysqli_fetch_array($sql55)) { ?>
	  <option><?php echo $row55['name']; ?></option> <?php } ?></select> 
    </div>
	 
 
    <label for="inputPassword3" class="col-sm-2 control-label">Sizzing Charges</label>
    <div class="col-sm-4">
       <input type="text" class="form-control" name="sizamt" value="" placeholder="" >
    </div>
	 
  </div>
        <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-primary  btn-lg btn-block" name="s11">Add as sizzing</button>
    </div>
  </div>
													<div class="alert alert-warning">
							<?php
							if(isset($_POST['s11']))
							{
								extract($_POST);
								//$insert=mysqli_query($conn, "insert into sizzing(mfin,scode,hpl,sizdate,godown,vno,vname,model,color,byy,sizamt)
									//		 values('$mfin','$scode','$hpl','$sizdate','$godown','$vno','$vname','$model','$color','$byy','$sizamt')");
								$selected_date=$sizdate;
		  	$selected_date=strtotime( $selected_date );
			$mysqldate = date( 'Y-m-d', $selected_date );		
$insert=mysqli_query($conn, "insert into sizzing(mfin,scode,hpl,sizdate,sizdate2,vno,vname,name,godown,model,color,byy,sizamt)
											 values('$mfin','$scode','$hpl','$sizdate','$mysqldate','$vno','$vname','$name','$godown','$model','$color','$byy','$sizamt')");			
								if($insert)
								{
								    
											 
$update=mysqli_query($conn, "update customerdetails set status='Sized' where hpl='$hpl' && mfin='$mfin'");		
				$delete2=mysqli_query($conn, "delete from pending where mfin='$mfin' && hpl='$hpl'");         

	$uupdate=mysqli_query($conn, "insert into otherentry (mfin,scode,postdate,postdate2,result,hpl,name,promdate,agentname,postamt,postamt2,remark) 
values('$mfin','$scode','$mysqldate','$mysqldate','Seized','$hpl','$name','','$byy','$sizamt','$sizamt','Seized')");
      

									echo "Registered Successfully";
									
								}
								else
								{
									echo "Failure";
								}
							}		
							
						   
								
?>	
	  </div>
</form>
</div>
 <div class="col-xs-6 col-md-4">

</div>
</div></div>
</div></div></div> <?php include "layouts/footer.php"; ?></body></html>