<div class="ui-layout-content ui-widget-content-panel">
	 <label class="lbfield95">PART NO</label><label class="lbcolon">:</label>
		<input id="ms_item_<?php echo $ms_type_id;  ?>_part_no" name="ms_item_<?php echo $ms_type_id;  ?>_part_no"  style="width:200px;margin-bottom:2px"   type="text" /><br \>
	 <label class="lbfield95">PART NAME</label><label class="lbcolon">:</label>
		<input id="ms_item_<?php echo $ms_type_id;  ?>_part_name" name="ms_item_<?php echo $ms_type_id;  ?>_part_name"   style="width:360px;margin-bottom:2px"  type="text" /><br \>
	 <label class="lbfield95">BASE NO</label><label class="lbcolon">:</label>
		<input id="ms_item_<?php echo $ms_type_id;  ?>_base_no" name="ms_item_<?php echo $ms_type_id;  ?>_base_no"   style="width:100px;margin-bottom:2px"  type="text" />
		<input id="ms_item_<?php echo $ms_type_id;  ?>_base_name"name="ms_item_<?php echo $ms_type_id;  ?>_base_name"   style="width:250px;margin-bottom:2px" disabled type="text" /><br \>
	 <label class="lbfield95">PART CUSTOM</label><label class="lbcolon">:</label>
		<input id="ms_item_<?php echo $ms_type_id;  ?>_part_custom_no"name="ms_item_<?php echo $ms_type_id;  ?>_part_custom_no"   style="width:100px;margin-bottom:2px"  type="text" />
		<input id="ms_item_<?php echo $ms_type_id;  ?>_part_custom_name"name="ms_item_<?php echo $ms_type_id;  ?>_part_custom_name"   style="width:250px;margin-bottom:2px" disabled type="text" /><br \>
	 <label class="lbfield95">UOM</label><label class="lbcolon">:</label>
		<input id="ms_item_<?php echo $ms_type_id;  ?>_uom" name="ms_item_<?php echo $ms_type_id;  ?>_uom" type="text" style="width:60px;margin-bottom:2px;background-color:#FFFF00" /><br \>
	 <label class="lbfield95">RACK NO</label><label class="lbcolon">:</label>
		<input id="ms_item_<?php echo $ms_type_id;  ?>_rack_no" name="ms_item_<?php echo $ms_type_id;  ?>_rack_no" type="text" style="width:100px;margin-bottom:2px;" value="" /><br \>
	 <label   class="lbfield95">MIN QTY</label><label class="lbcolon">:</label>
		<input readonly id="ms_item_<?php echo $ms_type_id;  ?>_min_qty" name="ms_item_<?php echo $ms_type_id;  ?>_min_qty" type="text" style="width:100px;margin-bottom:2px; text-align: right" class ="numeric" value="0" />(Stock Control) Readonly  <br \>
	 <label  class="lbfield95">MAX QTY</label><label class="lbcolon">:</label>
		<input readonly id="ms_item_<?php echo $ms_type_id;  ?>_max_qty" name="ms_item_<?php echo $ms_type_id;  ?>_max_qty" type="text" style="width:100px;margin-bottom:2px; text-align: right" class ="numeric" value="0" />(Stock Control) Readonly  <br \>
	 <label  class="lbfield95">LAST QTY</label><label class="lbcolon">:</label>
		<input readonly id="ms_item_<?php echo $ms_type_id;  ?>_last_qty" name="ms_item_<?php echo $ms_type_id;  ?>_last_qty" type="text" style="width:100px;margin-bottom:2px; text-align: right" class ="numeric" value="0" />(Stock Control) Readonly  <br \>
	 <label class="lbfield95">SERVICE LEVEL</label><label class="lbcolon">:</label>
		<input id="ms_item_<?php echo $ms_type_id;  ?>_service_level" name="ms_item_<?php echo $ms_type_id;  ?>_service_level" type="text" style="width:100px;margin-bottom:2px; text-align: right" class ="numeric" value="80" />(Stock Control)<br \>
	 <label class="lbfield95">CONSUMABLE</label><label class="lbcolon">:</label>
		<input  name="ms_item_<?php echo $ms_type_id;  ?>_consumable" type="checkbox" id="ms_item_<?php echo $ms_type_id;  ?>_consumable"  value='Yes' offval='No'  /><label  for="ms_item_<?php echo $ms_type_id;  ?>_consumable"> (Consumable)</label><br \>
	 <label class="lbfield95">STA QTY</label><label class="lbcolon">:</label>
		<input id="ms_item_<?php echo $ms_type_id;  ?>_sta_qty" name="ms_item_<?php echo $ms_type_id;  ?>_sta_qty" type="text" style="width:100px;margin-bottom:2px; text-align: right" class ="numeric" value="0" /><br \>
	 <label class="lbfield95">STA PRICE</label><label class="lbcolon">:</label>
		<input id="ms_item_<?php echo $ms_type_id;  ?>_sta_price" name="ms_item_<?php echo $ms_type_id;  ?>_sta_price" type="text" style="width:100px;margin-bottom:2px; text-align: right" class ="numeric" value="0"  /><br \>
</div> 

<script type="text/javascript">

$(document).ready(function(){
	

		$("input.numeric").numeric();		
	
	
		$("#ms_item_<?php echo $ms_type_id;  ?>_uom").mcautocomplete({
			showHeader: true,
			 classes: {
						"ui-autocomplete": "highlight"
						},
			columns: [	{name: 'Code', width: '60px', valueField: 'rID'},
						{name: 'Name', width: '250px', valueField: 'r1'}],
			select: function(event, ui) {
				this.value = (ui.item ? ui.item.rID : ''); 
				$("#ms_item_<?php echo $ms_type_id;  ?>_uom").val((ui.item ? ui.item.rID: '')); 
				return false;
			},
			 change: function( event, ui ) { 
			 }, 
			minLength: 1,
			delay: 500,
			position: { my : "left top"
					  , at: "left bottom" },
			source: function(request, response) {
				$.ajax({
					url: '<?php echo base_url().'ms_master/ct_ms_find/find_uom'; ?>',
					dataType: 'json',
					data: {
						limit: 15,
						findtext: request.term
					},
					success: function(data) {
						var result;
						if (!data || data.length === 0 || !data.rows || data.rows.length === 0) {
							result = [{label: 'No match found.'}];
							this.value = '';
							$("#ms_item_<?php echo $ms_type_id;  ?>_uom").val(''); 
						}
						else {
							result = data.rows;
						}
						response(result);
					}
				});
			}
		});		
       		 
		
		$("#ms_item_<?php echo $ms_type_id;  ?>_part_custom_no").mcautocomplete({
			showHeader: true,
			 classes: {
						"ui-autocomplete": "highlight"
						},
			columns: [	{name: 'Code', width: '120px', valueField: 'rID'},
						{name: 'Name', width: '250px', valueField: 'r1'}],
			select: function(event, ui) {
				this.value = (ui.item ? ui.item.rID : ''); 
				$("#ms_item_<?php echo $ms_type_id;  ?>_part_custom_no").val((ui.item ? ui.item.rID: '')); 
				$("#ms_item_<?php echo $ms_type_id;  ?>_part_custom_name").val((ui.item ? ui.item.r1: '')); 				
				return false;
			},
			 change: function( event, ui ) { 
			 }, 
			minLength: 1,
			delay: 500,
			position: { my : "left top"
					  , at: "left bottom" },
			source: function(request, response) {
				$.ajax({
					url: '<?php echo base_url().'ms_master/ct_ms_item_custom/find_part_custom'; ?>',
					dataType: 'json',
					data: {
						limit: 15,
						findtext: request.term
					},
					success: function(data) {
						var result;
						if (!data || data.length === 0 || !data.rows || data.rows.length === 0) {
							result = [{label: 'No match found.'}];
							this.value = '';
							$("#ms_item_<?php echo $ms_type_id;  ?>_part_custom_no").val(''); 
							$("#ms_item_<?php echo $ms_type_id;  ?>_part_custom_name").val(''); 
						}
						else {
							result = data.rows;
						}
						response(result);
					}
				});
			}
		});		
       		 
			  
		$("#ms_item_<?php echo $ms_type_id;  ?>_base_no").mcautocomplete({
			showHeader: true,
			 classes: {
						"ui-autocomplete": "highlight"
						},
			columns: [	{name: 'Code', width: '120px', valueField: 'rID'},
						{name: 'Name', width: '250px', valueField: 'r1'}],
			select: function(event, ui) {
				this.value = (ui.item ? ui.item.rID : ''); 
				$("#ms_item_<?php echo $ms_type_id;  ?>_base_no").val((ui.item ? ui.item.rID: '')); 
				$("#ms_item_<?php echo $ms_type_id;  ?>_base_name").val((ui.item ? ui.item.r1: '')); 				
				return false;
			},
			 change: function( event, ui ) { 
			 }, 
			minLength: 1,
			delay: 500,
			position: { my : "left top"
					  , at: "left bottom" },
			source: function(request, response) {
				$.ajax({
					url: '<?php echo base_url().'ms_master/ct_ms_find/find_base_part'; ?>',
					dataType: 'json',
					data: {
						limit: 15,
						findtext: request.term
					},
					success: function(data) {
						var result;
						if (!data || data.length === 0 || !data.rows || data.rows.length === 0) {
							result = [{label: 'No match found.'}];
							this.value = '';
							$("#ms_item_<?php echo $ms_type_id;  ?>_base_no").val(''); 
							$("#ms_item_<?php echo $ms_type_id;  ?>_base_name").val(''); 
						}
						else {
							result = data.rows;
						}
						response(result);
					}
				});
			}
		});		
       		 
			  
	 
		 
	 
		if ('<?php echo isset($row_data)?'1':'0';  ?>'=='1')
		{
			var row_data=<?php echo isset($row_data)?json_encode($row_data):'[]';  ?>; 
			console.log(row_data.r14);
			$('#ms_item_<?php echo $ms_type_id;  ?>_part_no').val(row_data.r3);     
			$('#ms_item_<?php echo $ms_type_id;  ?>_part_name').val(row_data.r4);     
			$('#ms_item_<?php echo $ms_type_id;  ?>_base_no').val(row_data.r5);     
			$('#ms_item_<?php echo $ms_type_id;  ?>_base_name').val(row_data.r11);     
			$('#ms_item_<?php echo $ms_type_id;  ?>_part_custom_no').val(row_data.r6);     
			$('#ms_item_<?php echo $ms_type_id;  ?>_part_custom_name').val(row_data.r7);     
			$('#ms_item_<?php echo $ms_type_id;  ?>_uom').val(row_data.r9);      
			$('#ms_item_<?php echo $ms_type_id;  ?>_rack_no').val(row_data.r30);     
			$('#ms_item_<?php echo $ms_type_id;  ?>_min_qty').val(row_data.r14?parseFloat(row_data.r14):''); 
			$('#ms_item_<?php echo $ms_type_id;  ?>_max_qty').val(row_data.r14x?parseFloat(row_data.r14x):'');   
			$('#ms_item_<?php echo $ms_type_id;  ?>_last_qty').val(row_data.r31?parseFloat(row_data.r31):'');      
			$('#ms_item_<?php echo $ms_type_id;  ?>_service_level').val(parseFloat(row_data.r28)); 
			$('#ms_item_<?php echo $ms_type_id;  ?>_sta_qty').val(parseFloat(row_data.r12));      
			$('#ms_item_<?php echo $ms_type_id;  ?>_sta_price').val(parseFloat(row_data.r13d));      
			$("#ms_item_<?php echo $ms_type_id;  ?>_consumable").prop("checked", (row_data.r10=='Yes')?true:false);
			   
			
		} 
		
		$('#ms_item_<?php echo $ms_type_id;  ?>_part_no').focus();     
		
});
		  	
</script>

	
	