<?php 
session_start();
ob_start(); 
include "header.php";
//$objIms->Semifinisheditem_alter();
?>

<link href="../css/select2.css" rel="stylesheet" />

<?php






if(isset($_POST["Save"]))
{

$counter = count($_POST["hsn"]); /* COUNT THE PASSED ON NAME */

  for($x=0; $x<=$counter; $x++){

    if(!empty($_POST["hsn"][$x])){
     
	  $hsn = $_REQUEST['hsn'][$x];
	
	$cgst = $_REQUEST['cgst'][$x];
	$sgst = $_REQUEST['sgst'][$x];
	$igst = $_REQUEST['igst'][$x];
	
	
  $sql = "INSERT INTO `tbl_hsn` (`hsn`, `cgst`, `sgst`, `igst`) VALUES ('$hsn', '$cgst', '$sgst', '$igst');";
						$result = mysql_query($sql);
						
	} 
	
    } /* END OF CHECKING THE CHECKBOX IF SELECTED */
	 
						
						?>
						<script>
						alert('Added');
						location='hsn_list.php';
						</script>
						
						<?php

}

?>

	 <?php 

?>



		
	
		 <style>
			select.error { background-color:#ffa8a8; border: 1px dotted red;  }
			input.error{ background-color:#ffa8a8;   }
			textarea.error{ background-color:#ffa8a8; border: 1px dotted red;  }
         </style>
		 
        <script type="text/javascript"> 
 		/*jQuery(document).ready(function(){
			$('#item_nm').autocomplete({source:'../ProgramFile/auto/suggest_POitem.php', minLength:1,
			select: function (event, ui) {
        	$("#item_id").val(ui.item.id); // display the selected id
       		$("#item_nm").val(ui.item.value); // display the selected text.
			
		    }
			});

}); */
</script>


	
<style type="text/css">
<!--
.table_bg{ border:#CCCCCC solid 1px; border-radius:5px; height:auto; width:auto; padding:20px; margin-bottom:10px;}


-->
</style>
<!-- Page wrapper  -->
        <div class="page-wrapper">
           
            <!-- Container fluid  -->
            <div class="container-fluid">
                <!-- Start Page Content -->
                <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body">
							<h4>Add Hsn <span style="float:right"><button onclick="goBack()" class="btn btn-info btn-sm">Go Back</button><script>
function goBack() {
    window.history.back();
}
</script></span></h4>
						<hr />
<form id="form1" name="form1" method="post" action="">

<div class="panel">

			 <table id="dynamic" class="display nowrap table   " cellspacing="0" width="100%">
			 <tbody>
            <tr  align="left">
            
            
            <td >HSN Code</td>
           
            <td ><input type="text" name="hsn[]" id="hsn" class="form-control"  style="width:200px" onkeypress="return isNumberKey(event)"/></td>
			
			<td >CGST</td>
           
            <td ><select type="text" name="cgst[]" id="cgst" class="form-control" style="width:75px" >
			<option value="0">0</option>
			<option value="2.5">2.5</option>
			<option value="6">6</option>
			<option value="9">9</option>
			<option value="14">14</option>
			<option value="1.5">1.5</option>
			<option value="0.125">0.125</option>
			</select>
			</td>
			<td >SGST</td>
           
            <td >
			<select type="text" name="sgst[]" id="sgst" class="form-control" style="width:75px" >
			<option value="0">0</option>
			<option value="2.5">2.5</option>
			<option value="6">6</option>
			<option value="9">9</option>
			<option value="14">14</option>
			<option value="1.5">1.5</option>
			<option value="0.125">0.125</option>
			</select>
			</td>
			<td >IGST</td>
           
            <td >
			<select type="text" name="igst[]" id="igst" class="form-control" style="width:75px" >
			<option value="0">0</option>
			<option value="5">5</option>
			<option value="12">12</option>
			<option value="18">18</option>
			<option value="28">28</option>
			<option value="3">3</option>
			<option value="0.25">0.25</option>
			</select>
			</td>
           
              <td><button type="button" name="add" class="btn btn-info btn-sm" id="add_input">Add</button></td>
              </tr>
			  </tbody>
           </table>
			
</div>

     
	
		

   
<p></p>
		<br />
        <div align="center" style="color:#990000; font-weight:bold;">
          <?php   
		     echo $mas;
		  ?>
        </div>
    <table>     
          <tr>
            <td height="35" ><input type="submit" id="Save" name="Save" value="Save" class="btn btn-primary" style="margin:inherit; width:100px"/></td>
          </tr>
    </table>

</form>       </div>
                        </div>
                    </div>
                </div>
                <!-- End PAge Content -->
            </div>
            <!-- End Container fluid  -->
			
    
  <script src="../js/lib/jquery/jquery.min.js"></script>
    <script src="../js/lib/bootstrap/js/popper.min.js"></script>
    <script src="../js/lib/bootstrap/js/bootstrap.min.js"></script>
    <!-- slimscrollbar scrollbar JavaScript -->
    <script src="../js/jquery.slimscroll.js"></script>
    <!--Menu sidebar -->
    <script src="../js/sidebarmenu.js"></script>
    <!--stickey kit -->
    <script src="../js/lib/sticky-kit-master/dist/sticky-kit.min.js"></script>
    <!--Custom JavaScript -->
    <script src="../js/custom.min.js"></script>
	<script src="../js/select2.js"></script>
	<script>
$(document).ready(function(){
 var i=1;
 $('#add_input').click(function(){
 i++;
 $('#dynamic').append('<tr id="row'+i+'"><td >HSN Code</td><td ><input type="text" name="hsn[]" id="hsn" class="form-control"  style="width:200px" onkeypress="return isNumberKey(event)"/></td><td >CGST</td><td ><select type="text" name="cgst[]" id="cgst" class="form-control" style="width:75px" ><option value="0">0</option><option value="2.5">2.5</option><option value="6">6</option><option value="9">9</option><option value="14">14</option><option value="1.5">1.5</option><option value="0.125">0.125</option></select></td><td >SGST</td><td ><select type="text" name="sgst[]" id="sgst" class="form-control" style="width:75px" ><option value="0">0</option><option value="2.5">2.5</option><option value="6">6</option><option value="9">9</option><option value="14">14</option><option value="1.5">1.5</option><option value="0.125">0.125</option></select></td><td >IGST</td><td ><select type="text" name="igst[]" id="igst" class="form-control" style="width:75px" ><option value="0">0</option><option value="5">5</option><option value="12">12</option><option value="18">18</option><option value="28">28</option><option value="3">3</option><option value="0.25">0.25</option></select></td><td><button type="button" name="remove" id="'+i+'" class="btn btn-danger btn-sm btn_remove">Remove</button></td></tr>');
 });
 $(document).on('click', '.btn_remove', function(){
 var button_id = $(this).attr("id");
 $('#row'+button_id+'').remove();
 });

 
});
</script>

</body>

</html>