<?php
 $txnid= $_GET['txnId'];
 




			session_start();


if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) {
	header ("Location: ../login.php");
}
		


?>


<?php
require 'config.php';

			 $db_handle = mysqli_connect(DB_SERVER, DB_USER, DB_PASS);
			 $database = $_SESSION['database'];
			$db_found = mysqli_select_db($db_handle, $database);
			
		//$SQL = "DELETE FROM product_table WHERE product_id=$txnid";
   //$query_del = mysqli_query($db_handle, $SQL);



  if($db_found){
	 


	
	$SQL = "SELECT* FROM product_table WHERE product_id=$txnid";
   $result = mysqli_query($db_handle, $SQL);
	  $db_fd = mysqli_fetch_assoc($result) ;
	   
	  
	  
	  
	// header ("Location: inventory_ac.php");

	 
	  
	  
	  
	  
  }
	
else{
	
	echo "database not found";
}

 
if(isset($_POST['A'])){
	 
    $product_name = $_POST['product'];
	$unit_q = $_POST['unit_q'] ;
	$unit_p = $_POST['unit_p'] ;
	
	$unit_c = $_POST['unit_c'] ;
	//$bundle_q = $_POST['bundle_q'] ;
	//$bundle_p = $_POST['bundle_p'] ;

	

	$db_found = new mysqli(DB_SERVER, DB_USER, DB_PASS, $database );

		/*
			$SQL = $db_found->prepare("INSERT INTO product_table (product_name, unit_q, unit_p,bundle_q,bundle_p,user_id) VALUES (?,?,?,?,?,?)");
			$SQL->bind_param('ssssss', $product_name, $unit_q,$unit_p,$bundle_q,$bundle_p,$_SESSION['user_id'] );
			$SQL->execute();
			header ("Location: inventory_ac.php");
			
			
		*/
	/*
	
	$SQl_update = "UPDATE product_table SET  product_name='$product_name', unit_q= '$unit_q', unit_p= '$unit_p', unit_c = '$unit_c' WHERE product_name = '$product_name' ";
	
	mysqli_query($db_found,$SQl_update);
	
	*/
	
	
	$SQl_update = "UPDATE product_table SET unit_q = $unit_q WHERE product_name = '$product' ";
	
	mysqli_query($db_found,$SQl_update);
	
		echo  "operation successfull";




}

	  
	  	 



?>






	<html>
		
			<title>Delete_script</title>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
<!--===============================================================================================-->	
		 <link href="css/bootstrap-4.4.1.css" rel="stylesheet">
		
		
		
	<head>



	</head>

		
		
		
		<style>
		
		
				.loader {
  border: 16px solid #f3f3f3;
  border-radius: 50%;
  border-top: 16px solid blue;
  border-right: 16px solid green;
  border-bottom: 16px solid red;
  border-left: 16px solid pink;
  width: 120px;
  height: 120px;
  -webkit-animation: spin 2s linear infinite;
  animation: spin 1s linear infinite;
}

@-webkit-keyframes spin {
  0% { -webkit-transform: rotate(0deg); }
  100% { -webkit-transform: rotate(360deg); }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
		
		</style>
		
		
		
		
		
		
		<body onLoad="spinner()">


			
	<div class="jumbotron" style="text-align: center;background-color: ">
		
		
		
		
		
		<div class="row">
		
			<div class="col-md-6">
			

				
		 			
					
					
					<?php
					
				 $req = '';
				
					if($db_fd['service'] == "cash") {
					
					
						
						$con = "hidden";
						$con_ser = "";
						
					
					}
				
				
				
				
				else if ($db_fd['service'] == "service") {
					
					
						
						$con_ser = "hidden";
						
					$con = "";
					
					}
					
					
					else{
						
						$con = "text";
						$con_ser = "";
						
						 $req = 'required';
						
					}
					
					
					
					?>
					
			
				
		
		        
	
				
				
				
			</div>
			
			
			<div class="col-md-6">
				
				<h3><b><span style="color: #ECE3E3">Transaction ID <?php echo $txnid;?></b></h3>
				
				
				<form METHOD ="POST" ACTION = "restock_delete.php" style="width: inherit">
					
						
				
								
									<div class="input-group mb-3">
											
									
										<input type="hidden" value="<?php echo $db_fd['product_id']; ?>" name="product_id">
										
										<input type="hidden" value="<?php echo $db_fd['unit_q']; ?>"  name="unit_q">
										
										<input type="hidden" value="<?php echo $db_fd['service']; ?>"  name="service">
										
										
											
											
											
											
  
										<div class="input-group-prepend">
    
											<span class="input-group-text" id="basic-addon1"  <?php  echo $con  ?>  >Product Name</span>
  
										</div>
  
										<input type="text"    <?php  echo $con  ?> class="form-control" placeholder="eg.book,rice,doors etc" aria-label="Username" aria-describedby="basic-addon1" value="<?php echo $db_fd['product_name'];?>" name="product">

									</div>
					
									
									<div class="input-group mb-3">
  
										<div class="input-group-prepend">
    
											<span class="input-group-text" id="basic-addon1" <?php echo $con_ser ?>    >Available Quantity(<?php echo $db_fd['unit_q'];?>)</span>
  
										</div>
  
										<input type="number"      <?php echo $con_ser ?>   class="form-control" placeholder="Volume of Goods" aria-label="Username" aria-describedby="basic-addon1" name="add_q" value="0">
										
										
										
											<select class="tryy"   <?php echo $con_ser ?> <?php  echo $con  ?> style="width:50px"  id="" name="unite"  >
										
											<option value="unit" selected>unit </option>
											<option value="Qty">Quantity</option>
											<option value="Vol">Volume</option>
											<option value="Bags">Bags</option>
											<option value="papers">papers</option>
											<option value="film">film</option>
											<option value="crates">crates</option>
												<option value="bottles">bottles</option>
											<option value="baskets">baskets</option>
											<option value="cups">cups</option>
											<option value="piecis">pieces</option>
											<option value="KG">KG</option>
												<option value="booklet">booklet</option>
												<option value="dozen">dozen</option>
												
											
											
											
											</select> 

									</div>
										
											
										
									
							
											
												<div class="input-group mb-3">
 
													<div class="input-group-prepend">
    
														<span class="input-group-text" id="basic-addon1"   <?php  echo $con  ?>>S P</span>
  
													</div>
  
													<input type="text"     <?php  echo $con  ?>     class="form-control" placeholder="0.00" aria-label="Username" aria-describedby="basic-addon1" name="unit_p" value="<?php echo $db_fd['unit_p'];?>" >

												</div>
												
										
											
												<div class="input-group mb-3">
  
													<div class="input-group-prepend">
    
														<span class="input-group-text"   <?php  echo $con  ?>   id="basic-addon1">C P</span>
  
													</div>
  
													<input type="text"      <?php  echo $con  ?>     class="form-control" placeholder="0.00" aria-label="Username" aria-describedby="basic-addon1" name="unit_c" value="<?php echo $db_fd['unit_c'];?>">

												</div>
					
					
					
					
					
					
					
						<div class="input-group mb-3">
  
													<div class="input-group-prepend">
    
													<span class="input-group-text" id="basic-addon1"   <?php  echo $con  ?>  <?php  echo $con_ser  ?>  > Auto Man</span>
  
													</div>
  
														 <select  style="background-color:"   name="automanage"     class="form-control" <?php  echo $con  ?>   <?php  echo $con_ser  ?> >
										
															 <option value="<?php echo $db_fd['auto_manage'];?>" selected><?php echo $db_fd['auto_manage'];?></option>
															 
											<option value="enabled" >enabled</option>
											<option value="disabled " >disabled</option>
										
											
											</select> 
							
							
							
							
							
					
													
												
							
							
							
							
							
							
											

												</div>
					
					
					
					
					
							<div class="input-group mb-3">
  
													<div class="input-group-prepend">
    
													<span class="input-group-text" id="basic-addon1"   <?php  echo $con  ?>  <?php  echo $con_ser  ?>  > Expiry Date</span>
  
													</div>
  
														 <input type="date"   class="form-control" placeholder="" aria-label="Username" aria-describedby="basic-addon1" name="expiry_date"  value=""  <?php  echo $req  ?>    value=""  <?php  echo $con  ?>  <?php  echo $con_ser  ?>  >
							
							
												
							
							
							
							
							
							
											

												</div>
												
										
						<input type="submit" value="ADD" onClick="spinner()" name = "A" style= "width:inherit; height: 70px" class="btn btn-dark" >  
											
						
					</form>
				
				
				
				
				
				
				
				
				
			
			</div>
			
			
		</div>
		
	
	
		
			
			</div>
			
	
		<div class="loader" id="spin" style="margin: auto"></div>

	
		</body>
	
			</html>

		
		

<script>


		function spinner() {
  
			var x = document.getElementById("spin");
	
	
	
  if (x.style.display === "none") {
    x.style.display = "block ";
	  
	  
  }
	else {
    x.style.display = "none";
  }
	
	
}
	
		



</script>