
<?php
        $ReqNo = '';
        $ReqType = '';
        $Requestedby = '';
        $FirstName ='';
		$Designation ='';
		$DepartmentName = '';
		$Status = '';
		$CostCenterCode = '';
	 	
		
if(!empty($ReqDetails))
{
    foreach ($ReqDetails as $Req)
    {
		$ReqNo = $Req->ReqNo;
        $ReqType = $Req->ReqType;
        $Requestedby = $Req->Requestedby;
        $FirstName =$Req->FirstName;
		$Designation =$Req->Designation;
		$DepartmentName = $Req->DepartmentName;
		$Status	 = 	$Req->Status;	
		$CostCenterCode = $Req->CostCenterCode;		
    }
}


?>
<style>
            .table-bordered>thead>tr>th, .table-bordered>tbody>tr>th, .table-bordered>tfoot>tr>th, .table-bordered>thead>tr>td, .table-bordered>tbody>tr>td, .table-bordered>tfoot>tr>td {border: 1px solid #333;}
            </style>
<div class="content-wrapper">
    
 
	 <section class="content">
	  
	 <div>
         <center><b><h2>Siddharth Industries - Edit Requisition Form</h2></b></center>
         <div class="container-fluid">
		  <div id="content"></div>
		
		   <?php
                      $attributes = array('class' => 'form-label-left requistion ','name'  => 'requistion','id'  => 'requistion');
                        
                        echo form_open($this->config->base_url().'requisitionform/EditRequistion',$attributes); ?>
	 <div class="row">
	 <div class="col-md-12">
	   <div class="row" align="right">
		   <a class="btn btn-primary"  href="<?php echo base_url(); ?>Requisition" ID="cancel">&nbsp;&nbsp;<span class="bold">Back</span></a> 
</div>
		 <div class="col-md-3">
		 <label>Request Type</label>
			<div class="form-group">
				  
				<?php
                                         $data = array('name' => 'RequestType','value' => set_value('RequestType',$ReqType),'id'=>'RequestType',  'class' => 'form-control' ,'readonly' => 'true');
                                        echo form_input($data);
										
                                        ?>  
										
			 <input type="hidden" name="txtReqNo" id="txtReqNo"  value="<?php echo $ReqNo?>"/>	 
			</div>
		 </div>
		 <div class="col-md-3">
		 <label>Requested By</label>
			<div class="form-group">
			 
				<?php
                                         $data = array('name' => 'EmpID','value' => set_value('EmpID',$FirstName),'id'=>'EmpID',  'class' => 'form-control' ,'readonly' => 'true');
                                        echo form_input($data);
										
                                        ?>  
				 
			</div>
		 </div>
		 <div class="col-md-3">
		 <label>Department Name</label>
		 	<div class="form-group">
									<?php
                                         $data = array('name' => 'DeptName','value' => set_value('DeptName',$DepartmentName),'id'=>'DeptName',  'class' => 'form-control' ,'readonly' => 'true');
                                        echo form_input($data);
                                        ?>   
                                </div>
		 </div>
		 <div class="col-md-3">
		 <label>Designation</label>
		 	<div class="form-group">
									<?php
                                         $data = array('name' => 'Designation','value' => set_value('Designation',$Designation),'id'=>'Designation',  'class' => 'form-control' ,'readonly' => 'true');
                                        echo form_input($data);
                                        ?>   
                                </div>
		 </div>
	 </div>
	 <div class="col-md-12">
	
	  <div class="col-md-3">
		 <label>Cost Center Name</label>
		 
				<div class="form-group">
									 <?php
				$Costs = array($CostCenterCode=>$CostCenterCode);
				//print_r(  $options);		
												
					if(!empty($CostCenter))
										{
									    foreach ($CostCenter as $SID):
                                         // echo $SID->ConfigValue;
									   	  $Costs[$SID->CostCenterCode] =  $SID->CostCenterCode .'-'. $SID->CostCenterName ;

										endforeach;
											
										}
				echo form_dropdown('CostCenter', $Costs,set_value('CostCenter'),'id="CostCenter"' ,'class = "form-control"');

		?> 
                                </div> 
			</div>
		  
	 <div class="col-md-3">
		 <label>Available Budget Amount</label>&nbsp;<img id="AlertImg"  src="<?php echo base_url(); ?>assets/dist/img/red.png" alt="your image" width="25px"  style="display:none"/>
		 	<div class="form-group">
				<?php
					 $data = array('name' => 'AvlBudgetAmount','value' => set_value('AvlBudgetAmount'),'id'=>'AvlBudgetAmount',  'class' => 'form-control' ,'readonly' => 'true');
					echo form_input($data);
					?>  
					
			</div>
			
		 </div>
		 	
	 </div>
	 
	 </div>
         </div>
		
          <div class="container-fluid">    
  <table class="table table-bordered" style="border:1px solid #333">
  <div align="right" style="padding-right:10px">
<div align="right">
<?php if(count($MaterialCode) != 0)
{ 
?>
  <a data-toggle="modal" data-target="#myModal1"  class="btn btn-primary">Add Line Item</a>
<?php } ?>
  <div class="modal fade" id="myModal1" role="dialog">
		<div class="modal-dialog">
		
		  <!-- Modal content-->
		  <div class="modal-content">
			<div class="modal-header">
			  <button type="button" class="close" data-dismiss="modal">&times;</button>
			  <center><h4>Add Line Item </h4></center>				
			</div>
			<div align="left"> 
			 
			 <div class="col-md-6">
				<label>Material Code</label>
					<div >
						 <?php
						$options = array("0"=>'Material Code');     
						//print_r(  $options);
						
						if(!empty($MaterialCode))
						{
						foreach ($MaterialCode as $MID):
						  
					   
						  $options[$MID->MaterialCode] =  $MID->MaterialCode.' '.' - '.' '.$MID->MaterialName;

						endforeach;
						}										
			
						echo form_dropdown('drpMaterial', $options,set_value('drpMaterial'),'id="drpMaterial"' ,'class="form-control"');

						?>						 
					</div>
			</div>

			<div class="col-md-6">
				<label>Description</label>
				<div class="form-group">
						<?php
						 $data = array('name' => 'Description','value' => set_value('Description'),'id'=>'Description',  'class' => 'form-control','readonly' => 'true' );
						echo form_input($data);
						?>   
				</div>
			</div>
			<div class="col-md-6">
				<label>UOM</label>
					<div>
					<?php
						 $data = array('name' => 'UOM','value' => set_value('UOM'),'id'=>'UOM',  'class' => 'form-control','readonly' => 'true' );
						echo form_input($data);
						?>  
									 
					</div>
			</div>
			<div class="col-md-6">
				<label>Quantity</label>
					<div class="form-group">
								<?php
						 $data = array('name' => 'Quantity','value' => set_value('Quantity'),'id'=>'Quantity',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event)','maxlength'=>'20');
						echo form_input($data);
						?>   
					</div>
			</div>
			
		 
			</div>
			
			<div class="modal-footer">
			<a class="btn btn-info font addClick"  ID="addClick"  ><i class="fa fa-plus"></i>&nbsp;&nbsp;<span 	class="bold">Add</span></a>
						<a  class="btn btn-info" data-dismiss="modal"  value="Cancel">cancel</a>
			</div>
		  </div>
						  
						</div>
					  </div>
   
  
  </div><br/> <div class="modal fade" id="EditItem" role="dialog">
		<div class="modal-dialog">
		
		  <!-- Modal content-->
		  <div class="modal-content">
			<div class="modal-header">
			  <button type="button" class="close" data-dismiss="modal">&times;</button>
			  <center><h4>Edit Line Item </h4></center>				
			</div>
			<div align="left"> 
			 
			 <div class="col-md-6">
				<label>Material Code</label>
					<div >						
							<?php
                                         $data = array('name' => 'EditMaterialCode', 'value' => set_value('EditMaterialCode'),'id'=>'EditMaterialCode', 'class' => 'form-control','readonly'=>'true');
                                        echo form_input($data);
                                        ?>  						
					</div>
			</div>

			<div class="col-md-6">
				<label>Description</label>
				<div class="form-group">
						<?php
						 $data = array('name' => 'EditDescription','value' => set_value('EditDescription'),'id'=>'EditDescription',  'class' => 'form-control','readonly' => 'true' );
						echo form_input($data);
						?>   
				</div>
			</div>
			<div class="col-md-6">
				<label>UOM</label>
					<div>
					<?php
						 $data = array('name' => 'EditUOM','value' => set_value('EditUOM'),'id'=>'EditUOM',  'class' => 'form-control','readonly' => 'true' );
						echo form_input($data);
						?>  
									 
					</div>
			</div>
			<div class="col-md-6">
				<label>Quantity</label>
					<div class="form-group">
								<?php
						 $data = array('name' => 'EditQuantity','value' => set_value('EditQuantity'),'id'=>'EditQuantity',  'class' => 'form-control','onkeypress'=>'return isNumberKey(event)','maxlength'=>'20');
						echo form_input($data);
						?>   
					</div>
			</div>
			
		 
			</div>
			
			<div class="modal-footer">
			<a class="btn btn-info font EditClick"  ID="EditClick"  ><i class="fa fa-plus"></i>&nbsp;&nbsp;<span 	class="bold">Edit</span></a>
						<a  class="btn btn-info" data-dismiss="modal"  value="Cancel">Cancel</a>
			</div>
		  </div>
						  
						</div>
					  </div>
   
  
  </div></br>
  
   <table id="Items" class="table table-bordered table-hover" style="background-color:#fff;font-size:12px;">
                <thead style="background-color:#ddf">
        <tr>
        <th>SNo</th>
        <th>Material Code</th>
        <th>Material Name</th>
        <th>Uom</th>
		
<th>RequestedQuantity</th>
		<th>PoQuantity</th>
		<th>Status</th>
         <th>Action</th>
      </tr>
    </thead>
    <tbody id="tempAppend">
<?php
                    if(!empty($LineItem))
                    { 
				        $index = 0;
                        foreach($LineItem as $record)
                        {	
							$index = $index + 1;
                    ?>
							<tr  id="<?php echo $index ; ?>">
							<td align="left"><?php echo $index ; ?></td> 
							 <input type="hidden" name="<?php echo 'MaterialCode'.$index ?>" id="<?php echo 'MaterialCode'.$index ?>" value="<?php echo $record->MaterialCode ; ?>" />
							 <input type="hidden" name="<?php echo 'Quantity'.$index ?>" id="<?php echo 'Quantity'.$index ?>" value="<?php echo $record->Quantity ; ?>" />
							   
					<td align="left"><?php echo $record->MaterialCode ; ?></td>
					<td align="left"><?php echo $record->MaterialName ; ?></td>
 
					<td align="left"><?php echo $record->UOM ; ?></td>
  
					<td align="left"><?php echo $record->Quantity ; ?></td>
					<td align="left"><?php echo $record->POQTY ; ?></td>
					<td align="left"><?php echo $record->StatusName ;?></td>
						<td>
                          <a   data-id="<?php echo $index ; ?>" data-userid="<?php echo $index ; ?>" data-target='#EditItem'	 data-toggle="modal" href="#EditItem"><i class="fa fa-pencil" data-toggle="tooltip" title="Click here to view/Edit the  <?php echo $record->MaterialCode ; ?> Material details"></i>&nbsp;&nbsp;&nbsp;</a> <a  onclick = "DeleteRow(<?php echo $index ; ?>)" class="link" data-id="<?php echo $record->MaterialCode  ; ?>" data-userid="<?php echo $index ; ?>"  id="Del" ><span class="glyphicon glyphicon-trash"></span></a>
						 
						  
                      </td>
</tr>
						<?php   }
						?>
						  <input type="hidden" name="txtRowCount" id="txtRowCount"  value="<?php echo $index ; ?>"/>
						<?php
					}?>
    </tbody>
	
  </table>
         
 <div align="right" style="padding-right:10px">
    <input type="hidden" name="txtStatus" id="txtStatus" />
   <input type="hidden" name="txtDeletedRow" id="txtDeletedRow" />
   <?php if($Status == REQ_DRAFT)
   { ?>
		<a class="btn btn-primary Save"  ID="Save" onclick="Save(0)" >&nbsp;&nbsp;<span class="bold">Save</span></a> 
		<a class="btn btn-primary submit"  ID="submit" onclick="Save(1)" >&nbsp;&nbsp;<span class="bold">Submit</span></a> 
		
		<input type="reset" class="btn btn-primary">
    <?php }
	else if($Status == REQ_PENDING_APPROVAL)
	{?>
  <!--<a class="btn btn-primary"  ID="update" onclick="update()" >&nbsp;&nbsp;<span class="bold">Update</span></a> 
  <a class="btn btn-primary"  href="<?php echo base_url(); ?>Requisition" ID="cancel">&nbsp;&nbsp;<span class="bold">Cancel</span></a> -->
  <a class="btn btn-primary Save"  ID="submit" onclick="Save(1)" >&nbsp;&nbsp;<span class="bold">Update</span></a> 
   <input type="reset" class="btn btn-primary">
	<?php } ?>
  
  
   
  </div>
         <br>
	 </div>
         </div>
         
        </section>
</div>

<script> 
function isNumberKey(evt)
       {
          var charCode = (evt.which) ? evt.which : evt.keyCode;
          if (charCode != 46 && charCode > 31 
            && (charCode < 48 || charCode > 57))
             return false;

          return true;
       }
	
$(function() {
	
    $( ".datePicker" ).datepicker({ dateFormat: 'dd/mm/yy' });

    //Initialize Select2 Elements
    $(".select2").select2();
	
	var id = '<?php echo  $CostCenterCode?>';
	var ReqType = '<?php echo  $ReqType?>';
	$.ajax({ 
			data:{id:id},
			type:"POST",
			url:"<?php echo base_url() ?>servicepurchaseorder/AvilBudgetAmount?ReqType="+ReqType, 
			success:function(data) {
			if(data)
			{
				$('#content').loader('hide'); 
				$("#AvlBudgetAmount").val(data);
				
				if(parseFloat($("#AvlBudgetAmount").val()) <= 0)
				{
					$('#AlertImg').removeAttr("style");					
				}
				else
				{
					 $('#AlertImg').attr("style","display:none;");
				}
			}
			else
			{
				$('#content').loader('hide'); 
				alert("Error");	
			}
			}			
			  
			});	
 

$('#CostCenter').change(function() {
    
 var id = $('#CostCenter').val();
 $("#AvlBudgetAmount").val('');
 var ReqType = $('#RequestType').val();
		if(id != '-1')
		{
			$('#content').loader('show');
		  $.ajax({ 
			data:{id:id},
			type:"POST",
			url:"<?php echo base_url() ?>servicepurchaseorder/AvilBudgetAmount?ReqType="+ReqType, 
			success:function(data) {
			if(data)
			{
				$('#content').loader('hide'); 
				$("#AvlBudgetAmount").val(number_format(data,2));
				
				if(parseFloat($("#AvlBudgetAmount").val()) <= 0)
				{
					$('#AlertImg').removeAttr("style");					
				}
				else
				{
					 $('#AlertImg').attr("style","display:none;");
				}
			}
			else
			{
				$('#content').loader('hide'); 
				alert("Error");	
			}
			}			
			  
			});	
			
		}
		else
		{
			alert('Please select the Employee details');
			return false;
		}
  
});
	$('#RequestType').change(function() 
	{
		
	$('#txtRowCount').val('');
	$('#txtDeletedRow').val('');	
    $("#Description").val('');
	$("#UOM").val('');
	removeHiddenRows($('#Items').find('tr').length);
	var id = $('#RequestType').val(); 

		if(id != '-1')
		{
			$('#content').loader('show');

			$.ajax({
			data:{id:id},
			dataType: 'json',
			type:"POST",
			url:"<?php echo base_url();?>requisitionform/getMaterialCode",
			success:function(json) {		
			$('#content').loader('hide');
				
				$("#drpMaterial").empty();
				$("#drpMaterial").append(json.Material);
               // $("#Description").val(json.MaterialName);	
				//$("#UOM").val(json.UOM);					
		      }
			  
			});	
			//$('#content').loader('hide');
		}
		else
		{
			alert('Please select the RequestType');
			return false;
		}
  
});

$('#drpMaterial').change(function() {
    
	 var id = $('#drpMaterial').val(); 

$("#Description").val('');	
$("#UOM").val('');	
		if(id != '-1')
		{
			$('#content').loader('show');

			$.ajax({
			data:{id:id},
			dataType: 'json',
			type:"POST",
			url:"<?php echo base_url();?>requisitionform/getMaterialDetails",
			success:function(json) {		
			$('#content').loader('hide');
			//alert(json.MatDetail);
					$("#Description").val(json.MatDetail[0]['MaterialName']);	
					$("#UOM").val(json.MatDetail[0]['UOM']);									
		      }
			  
			});	
			//$('#content').loader('hide');
		}
		else
		{
			alert('Please select the RequestType');
			return false;
		}
	
	
});
});
	</script>
	<script type="text/html" id="tempList">
<tr  id="<%=index%>">
<td align="left"><%=index%></td>
 <td align="left"><%=MaterialCode%></td>
 
  <td align="left"><%=MaterialName%></td>
  
  <td align="left"><%=UOM%></td>

  <td align="left"><%=Quantity%></td> 
   <td>
                          <a    data-target='#EditItem'	data-id="<%=index%>" data-userid="<%=index%>" data-toggle="modal" href="#EditItem"><i class="fa fa-pencil" data-toggle="tooltip" title="Click here to view/Edit the  <%=MaterialCode%> Material details"></i>&nbsp;&nbsp;&nbsp;</a> <a href='#' onclick = "DeleteRow(<%=index%>)" class="link" data-id="<%=index%>" data-userid="<%=index%>"  id="Del" ><span class="glyphicon glyphicon-trash"></span></a>
						 
						  
                      </td>
</tr>
</script>
<script>
var index     = $('#txtRowCount').val();
var userid  = '';
function removeHiddenRows(rowcount)
{
	var step;
	//alert(rowcount);
for (step = 1; step < rowcount-1; step++) {
	var td = document.getElementById(step);
	td.parentNode.removeChild(td);
	$("#MaterialCode"+step).remove();
	$("#Description"+step).remove();
	$("#UOM"+step).remove();
	$("#Quantity"+step).remove();
	index     = '1';
	userid  = '';	
}
}



function Save(status)
{  
if(status == '0')
{
	stat = '<?php echo REQ_DRAFT; ?>';
}
else
{
	stat = '<?php echo REQ_PENDING_APPROVAL; ?>';
}
  
  
	if(validate())
		{ 	
			if(document.getElementById('Items').rows.length < 2)
			{
				alert('Please Select Line item to update the Requisition');
				$('#Deliverydt').focus();
				return false;
			}
			else
			{
			//alert(document.getElementById('Items').rows.length);
			$('#content').loader('show');
				$('#txtStatus').val(stat);
		    $.ajax({ 
			data:$('.requistion').serialize(),
			type:"POST",
			url:"<?php echo base_url() ?>requisitionform/EditRequistion", 
			success:function(data) {
			if(data)
			{
				$('#content').loader('hide'); 
				alert(data);
				$('#txtRowCount').val('');
				$('#txtDeletedRow').val('');
				
			   window.location =	"Requisition";
			
			}
			else
			{
				alert("Error");	
			}			
		
		}
  
});  
			}
}
}
function validate()
{
	
	if($("option:selected", $("#RequestType")).val() == '-1')
	{
		alert('Please Select ReqType Names');
		return false;
	}
	else if($("option:selected", $("#EmpID")).val() == '-1')
	{
		alert('Please Select Reqby');
		return false;
	}
	else if(index < 1)
	{
		alert('Please Add Line Item');
		return false;
	}
	else
	{
	return true;
	}
	
}	
function DeleteRow(rowid)
{
	
	    var id = [];
	     var tr= document.getElementById(rowid);
		 var cellval = tr.cells;
		 var MaterialCode = cellval[1].innerHTML;
		// alert(cellval[1].innerHTML);
		 id[0] = $('#txtReqNo').val();		 
		 id[1] = MaterialCode;
	    var answer = confirm(" Do you want to delete the Item from the List?")
		if (answer) 
		{ 	
	        // To delete the item from list
				
				var x = <?php echo json_encode($LineItem, JSON_PRETTY_PRINT) ?>;
	            var result = '0';
					//alert(x);
					//alert(MaterialCode);
				if(MaterialCode != "0")
				{			
					$.each(x, function(idx, obj) {
						if(obj.MaterialCode === MaterialCode)
						{			 
						  result = '1';
						   return  false;	
						}
						
					   });
				   }
				  
				   
			if(result == '0')
			{
				var DelRows  = $('#txtDeletedRow').val();
				tr.parentNode.removeChild(tr);
				if(DelRows != '')
					{
					DelRows = DelRows + ":" + rowid;
					}
				else
					{
					DelRows=  "0" + ":" + rowid;
					}
				$('#txtDeletedRow').val(DelRows);
			}
           	// To delete the value from Tables
			else  if(result == '1')
			{
				var DelRows  = $('#txtDeletedRow').val();
				tr.parentNode.removeChild(tr);
				if(DelRows != '')
					{
					DelRows = DelRows + ":" + rowid;
					}
				else
					{
					DelRows=  "0" + ":" + rowid;
					}
				$('#txtDeletedRow').val(DelRows);				
					
			 $.ajax({ 
			data:{id:id},
			type:"POST",
			url:"<?php echo base_url() ?>requisitionform/DeleteRequistionForm", 
			success:function(data) {
			if(data)
			{
				$('#content').loader('hide'); 
				alert(data);
				
				
			
			}
			else
			{
				alert("Error");	
			}			
		
		}}); 
			}
		}
       	
} 


$('.addClick').click(function(){
         
       if ($("#drpMaterial option:selected").val() =='-1' )
		{
			 alert('Please Select the MaterialCode ');
		}	
			
    	if(document.getElementById('Quantity').value == '' )
		{
		  alert('Please Enter the Quantity');
		  
		}	  
		
        if ($("#drpMaterial option:selected").val() !='-1' &&  $('#Quantity').val() != ''  )
        {		       
         var temp = parseInt(index) + 1;
         var materialCode = $("#drpMaterial option:selected").val();
         var materialName =  $("#Description").val();
         var uom = $("#UOM").val();
		 var quantity = $("#Quantity").val();
		 
		$('#drpMaterial option[value='+materialCode+']').remove();
		 $('#Description').val(''); 
		  $('#UOM').val(''); 
		   $('#Quantity').val('');       
			
			index = parseInt(index)+1;		
		  
		 
	      var template = jQuery("#tempList").html();
	   
	     
          $('#tempAppend').append(_.template(template,{index:temp,MaterialCode:materialCode,MaterialName:materialName,UOM:uom,Quantity:quantity}));
		  
		  
		 var theForm = $(".requistion");
		
		 addHidden(theForm,"MaterialCode"+temp,materialCode);
		 addHidden(theForm,"Description"+temp,materialName);
	     addHidden(theForm,"UOM"+temp,uom);
		 addHidden(theForm,"Quantity"+temp,quantity);		
		 
		 $('#txtRowCount').val(temp); 			
		
      }    
   
 });
 function addHidden(theForm, key, value) {
    // Create a hidden input element, and append it to the form:
    var input = document.createElement('input');
    input.type = 'hidden';
    input.name = key;'name-as-seen-at-the-server';
    input.id = key;'name-as-seen-at-the-server';
    input.value = value;
    theForm.append(input);
}
$("#myModal1").on("shown.bs.modal", function(e) {
    if($("option:selected", $("#RequestType")).val() == '-1')
	{
		alert('Please select the Request Type ');
		e.close();
	}
});

$("#EditItem").on("shown.bs.modal", function(e) {
     userid = $(e.relatedTarget).data('userid');
	// alert(userid);
	 var tr= document.getElementById(userid);
	 var cellval = tr.cells;
	 //alert(x[1].innerHTML);
	$('#EditMaterialCode').val(cellval[1].innerHTML);
	$('#EditDescription').val(cellval[2].innerHTML);
   $('#EditUOM').val(cellval[3].innerHTML);
    $('#EditQuantity').val(cellval[4].innerHTML);
});

$('.EditClick').click(function(){
         
   		if(document.getElementById('EditQuantity').value == '' )
		{
		  alert('Please Enter the Quantity' );
		 }  
		
        if ( $('#EditQuantity').val() != '' )
        {	
      
			var editMaterialCode =  $("#EditMaterialCode").val();
			var editDescription = $("#EditDescription").val();		
			var editUOM = $('#EditUOM').val();
			var editQuantity = $('#EditQuantity').val();
     	
            var tr= document.getElementById(userid);
			var cellval = tr.cells;   
			cellval[1].innerHTML = editMaterialCode;
			cellval[2].innerHTML = editDescription;
			cellval[3].innerHTML =editUOM;
			cellval[4].innerHTML = editQuantity;
			
			$('#MaterialCode'+userid).val(editMaterialCode);
			$('#Description'+userid).val(editDescription);
			$('#UOM'+userid).val(editUOM);
			$('#Quantity'+userid).val(editQuantity);
            			
		
      }
    
 });
 $(function () {  
    $('#Items').DataTable({
      "paging": true,
      "lengthChange": true,
      "searching": true,
      "ordering": true,
     "info": true,
      "autoWidth": true
	   
    }); 
  });
</script>
