<?php
require("../connection.php");
include("../user.php");
$user_id=$_SESSION['user'];
$username=$_SESSION['user_name'];
?>
<html class="no-js" lang=""> 
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title><?php echo TITLE;?></title>
    <meta name="description" content="Ela Admin - HTML5 Admin Template">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="apple-touch-icon" href="../images/bluebase.png">
    <link rel="shortcut icon" href="../images/bluebase.png">
    <!-- <script type="text/javascript" src="https://cdn.jsdelivr.net/html5shiv/3.7.3/html5shiv.min.js"></script> -->

	<style>
	input
	{
	text-transform:uppercase;	
	}
	textarea
	{
	text-transform:uppercase;	
	}
	</style>
</head>
<body>
<div class="col-lg-12">
	<div class="card">
	<div class="card-header">
	<strong>Item Issue New</strong>
	<a href="issue_master.php"><button class="btn btn-primary" style="width:50px;float:right;"onclick=""><i class="fa fa-backward"></i></button></a></div>
	<div class="card-body card-block">
	<form  method="post" enctype="multipart/form-data" class="form-horizontal" action="newissue_submit.php">
		<div class="row form-group">
		<div class="col col-md-3"><label for="text-input" class=" form-control-label">Date</label><span style="color:red;">*</span></div>
		<div class="col-12 col-md-9"><input type="date" id="from_date" name="from_date"  class="form-control" value="<?php echo date("Y-m-d");  ?>" autocomplete="off" required></div>
		</div>
		<div class="row form-group">
		<div class="col col-md-4">
		<input type="radio" name="q1" value="Individual" onclick="emp_share()" required />&emsp; Employee &emsp;
		</div>
		<div class="col col-md-4">
		<input type="radio" name="q1" value="location" onclick="loc()" required />&emsp;Location</td>
		</div>
		<div class="col col-md-4" id="emp_sh">
		
		</div>
		</div>
		<div class="row form-group" id="sh1" >
		
		</div>
		
<table id="upload1" class="table table-striped" style="text-transform:upper;" >
<thead>
<tr>
<th>Category</th>
<th>Item Code</th>
<th>Remarks</th>
<th></th>

</tr>
</thead>
<tbody>
<tr id="rw_1" class="row_1">
<?php
$cat=mysqli_query($con,"SELECT DISTINCT(im.category_id),cm.id,cm.prefix_name,im.status FROM `category_master` cm join item_master im on cm.id=im.category_id where im.status=0");
?>
<td><select class="form-control"  id="category_1" onchange="get_itemcode(this.value,this.id)"  name="category1" required>
<option selected disabled>Select Category</option>
<?php while($category=mysqli_fetch_array($cat))
{ ?>
<option value="<?php echo $category['id'];?>"><?php echo strtoupper($category['prefix_name']);?></option>
<?php } ?>
</select>
</td>
<input type="hidden" class="form-control" id="counter" value="1" name="counter[]" />
<td><div id="code_1"><input  class="form-control" type="text"   name="" autocomplete="off" readonly /></div></td>
<td ><textarea class="form-control"  id="remark_1"  name="remark1" autocomplete="off" placeholder="Write Your Remarks" ></textarea></td>
<td><div id="ravi1" >
<input type="button" class="btn btn-success add_new" value="Add new" />
</div></td>
</tr>
</tbody>
</table>
<div style="">
		<button type="submit" name="submit" class="btn btn-success" ><i class="fa fa-dot-circle-o"></i> Submit</button>
		
		</div>
                   </div>
		
	</form>
	</div>
	</div>
    <div class="clearfix"></div>

    <footer class="site-footer">
        
    </footer>

</div><!-- /#right-panel -->
</body>
</html>
<script language="javascript">
	   $('.add_new').click(function(){
	var len=$('#upload1 tr').length;
	//alert(len);
	//len=len+1;

	$('#upload1').append('<tr id="rw_'+len+'" class="row_'+len+'"><td><?php $cat=mysqli_query($con,"SELECT DISTINCT(im.category_id),cm.id,cm.category,cm.prefix_name,im.status FROM `category_master` cm join item_master im on cm.id=im.category_id where im.status=0");?><select onchange="get_itemcode(this.value,this.id)"  id="category_'+len+'"  class="form-control" name="category'+len+'"><option selected disabled>Select Category</option><?php while($category=mysqli_fetch_array($cat)){ ?><option value="<?php echo $category['id']; ?>"><?php echo strtoupper($category['prefix_name']); ?></option><?php } ?></select></td><input type="hidden"  class="form-control" id="counter" value="'+len+'" name="counter[]"><td><div id="code_'+len+'"> <input  class="form-control" type="text" name="d" autocomplete="off"  readonly> </div></td>	<td><textarea class="form-control"  id="remark_'+len+'"  name="remark'+len+'" autocomplete="off" placeholder="Write Your Remarks" ></textarea> </td><td><input type="button" value="Delete" class="btn btn-danger" onclick="deleteRow(this)"/></td> </tr>');
 

	});
		
	$('.delete').click(function()

{
	$('input:checkbox:checked.chk').map(function(){
	
	var id=$(this).val();
	var rw=$('#rw_ tr').length;
	if(rw==1)
	{
		alert("You Can't Delete All the Rows");
		//alert(rs);
	}
	else
	{
		//alert(rs);
		$('.row_'+id).remove();
	}
	
	});
}); 
	
	</script>

	<script>
function deleteRow(btn) {
	  var row = btn.parentNode.parentNode;
	  row.parentNode.removeChild(row);
	}
function price(id)
{
	var f=id.split("_");
	var v=f[2];
	//alert(v);
	var quantity=$("#quantity_"+v).val();
	var unit=$("#unit_price_"+v).val();
	var mul_price=(quantity)*(unit);
	//alert(mul_price);
	$('#tot_amt_'+v).val(mul_price);
}
</script>


