<link rel="stylesheet" href="css/new_mxerp.css">
 <script type="text/javascript">
	shade_name_val='';
	product_sheet_val='';
	serial_no_val='';
	brand_code_val='';
	material_type_val='';
	material_item_desc_val='';
	itemname='';
	
	function setNewItem1(str) 
	{
	
		var a= document.getElementById("last_po_price").value;
		
 		var profit=a*(str/100);
		var mrp_rate=parseFloat(a)+parseFloat(profit);
 		document.getElementById("mrp_rate").value=mrp_rate.toFixed(2);
		
			var cc=document.getElementById("item_discount").value;
			if(cc==0){
				document.getElementById("net_rate").value=mrp_rate.toFixed(2);
							}else{
								var dis=mrp_rate*(cc/100);
								var net_rate=parseFloat(a)-parseFloat(dis);
								document.getElementById("net_rate").value=net_rate.toFixed(2);
								}
							
 }
 
 function setNewItem2(str) 
	{
		var ss=document.getElementById("item_profit").value;
		
 		var profit=ss*(str/100);
		var mrp_rate=parseFloat(str)+parseFloat(profit);
 		document.getElementById("mrp_rate").value=mrp_rate.toFixed(2);
		
		
		var dd=document.getElementById("item_discount").value;
		if(dd==0){
			document.getElementById("net_rate").value=mrp_rate.toFixed(2);
						}else{
							var discount=mrp_rate*(dd/100);
							var net_rate=parseFloat(mrp_rate)-parseFloat(discount);
							document.getElementById("net_rate").value=net_rate.toFixed(2);
							
							
						}
								
		}
		
 function setNew(str) 
	{
		var mrp_rate= document.getElementById("mrp_rate").value;
		
		var dd=document.getElementById("item_discount").value;
		if(dd==0){
			document.getElementById("net_rate").value=mrp_rate.toFixed(2);
						}else{
							var discount=mrp_rate*(dd/100);
							var net_rate=parseFloat(mrp_rate)-parseFloat(discount);
							document.getElementById("net_rate").value=net_rate.toFixed(2);
							
							
						}

			
 }
  function setNew1(str) 
	{
		var ss= document.getElementById("item_discount").value;
		//alert(ss);
 		var discount=ss*(str/100);
		var net_rate=parseFloat(str)-parseFloat(discount);
		//alert(net_rate);
 		document.getElementById("net_rate").value=net_rate.toFixed(2);
		
			 var kk=document.getElementById("item_profit").value;
							//alert(kk);
		if(pp==0){
				document.getElementById("net_rate").value=mrp_rate.toFixed(2);
						}else{
							var profit=mrp_rate*(pp/100);
							//alert("disnt");
							var net_rate=parseFloat(mrp_rate)-parseFloat(profit);
							document.getElementById("net_rate").value=net_rate.toFixed(2);
							}
		

 }
	function setItemName()
	{
	   if(document.getElementById("item_name1").value==''){
	   		document.getElementById("item_name1").value=1;
			if(document.getElementById("item_name").value!='')
			{
			 itemname= document.getElementById("item_name").value;
			}
			
		}
		var shade_name_val = document.getElementById("shade_name").value;
		var product_sheet_val = document.getElementById("product_sheet").value;
		var serial_no_val = document.getElementById("serial_no").value;
		var brand_code_val = document.getElementById("brand_code").value;
		var material_type_val = document.getElementById("material_type").value;
		var material_item_desc_val = document.getElementById("material_item_desc").value;
		document.getElementById("item_name").value =itemname+" "+ shade_name_val+" "+product_sheet_val+" "+serial_no_val+" "+brand_code_val+" "+material_type_val+" "+material_item_desc_val;
				
	}
function get_item(val)
{
	
	if(window.XMLHttpRequest)
	{
		xmlhttp=new XMLHttpRequest();
	}
	else
	{
		xmlhttp	=new ActiveXobject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
	if(xmlhttp.readyState==4 && xmlhttp.status==200)
	{
		document.getElementById("harwaregroupid").innerHTML=xmlhttp.responseText;
		
	}
	
	}
//alert(val);
xmlhttp.open("GET","Gethardwaregroup.php?groupid="+val,true);
xmlhttp.send();	

}

    </script>
<?php  
	session_name('CAKEPHP'); session_start();
	include('includes/Class_UnitMeasure.php');
  	include('CRM/ClassRole.php');
  	$CompanyId = $_SESSION['ACGCompanyId'];
  	$sql_query = "SELECT * FROM tbl_itemname_auto where CompanyId=".$CompanyId;
		$sqlQuery =DB_query($sql_query,$db);
		$row = DB_fetch_array($sqlQuery);
		$item_name_auto = $row['item_name_auto'];

  if($_REQUEST['SaveItem'])
  {
  if($_REQUEST['action']!='edit')
  {
	$SQL="Select StockID from item_master where StockID='".$_REQUEST['StockID']."'";
	$result=DB_query($SQL,$db);
	$resultrow=DB_num_rows($result);
	if($resultrow>0)
	{
		echo "<script>alert('You enter Duplicate Item code.'); history.go(-1);</script>";exit;
	}
	
	$SQLI="Select item_name from item_master where item_name='".$_REQUEST['item_name']."'";
	$resultI=DB_query($SQLI,$db);
	$resultrowI=DB_num_rows($resultI);
	if($resultrowI>0)
	{
		
		echo "<script>alert('You enter Duplicate Item Name.'); history.go(-1);</script>";exit;
	}
  }else{
  	$SQL="Select StockID from item_master where StockID='".$_REQUEST['StockID']."' and id<>'".$_REQUEST['id']."'";
	$result=DB_query($SQL,$db);
	$resultrow=DB_num_rows($result);
	if($resultrow>0)
	{
		
		echo "<script>alert('You enter Duplicate Item code.'); history.go(-1);</script>";exit;
	}
	
	$SQLI="Select item_name from item_master where item_name='".$_REQUEST['item_name']."' and id<>'".$_REQUEST['id']."'";
	$resultI=DB_query($SQLI,$db);
	$resultrowI=DB_num_rows($resultI);
	if($resultrowI>0)
	{
		
		echo "<script>alert('You enter Duplicate Item Name.'); history.go(-1);</script>";exit;
	}
	
	/*$SQL="Select last_po_price from rev_item_master where last_po_price='".$_REQUEST['last_po_price']."'";
	$result=DB_query($SQL,$db);
	$resultrow=DB_num_rows($result);
	if($resultrow>0)
	{
		echo "<script>alert('You enter Duplicate Item code.'); history.go(-1);</script>";exit;
	}
	$SQL="Select item_profit from rev_item_master where item_profit='".$_REQUEST['item_profit']."'";
	$result=DB_query($SQL,$db);
	$resultrow=DB_num_rows($result);
	if($resultrow>0)
	{
		echo "<script>alert('You enter Duplicate Item code.'); history.go(-1);</script>";exit;
	}
	$SQL="Select item_discount from rev_item_master where item_discount='".$_REQUEST['item_discount']."'";
	$result=DB_query($SQL,$db);
	$resultrow=DB_num_rows($result);
	if($resultrow>0)
	{
		echo "<script>alert('You enter Duplicate Item code.'); history.go(-1);</script>";exit;
	}
	$SQL="Select mrp_rate from rev_item_master where mrp_rate='".$_REQUEST['mrp_rate']."'";
	$result=DB_query($SQL,$db);
	$resultrow=DB_num_rows($result);
	if($resultrow>0)
	{
		echo "<script>alert('You enter Duplicate Item code.'); history.go(-1);</script>";exit;
	}
	$SQL="Select net_rate from rev_item_master where net_rate='".$_REQUEST['net_rate']."'";
	$result=DB_query($SQL,$db);
	$resultrow=DB_num_rows($result);
	if($resultrow>0)
	{
		echo "<script>alert('You enter Duplicate Item code.'); history.go(-1);</script>";exit;
	}
	}else{
  	$SQL="Select StockID from item_master where StockID='".$_REQUEST['StockID']."' and id<>'".$_REQUEST['id']."'";
	$result=DB_query($SQL,$db);
	$resultrow=DB_num_rows($result);
	if($resultrow>0)
	{
		
		echo "<script>alert('You enter Duplicate Item code.'); history.go(-1);</script>";exit;
	}*/
  }	
  
  
	
	
	

                    /*if($_REQUEST['action']=='edit')
				  {
				  $stockcat=$s->getField('item_master','id',$_REQUEST['id'],'CategoryID');
				   $stocksub=$s->getField('item_master','id',$_REQUEST['id'],'SubCategoryID');
				  }
  
                          $prefixcode=$s->getField('stockcategory','id',$_REQUEST['sub_group'],'item_prefix');
					      $year=date('y');
					      $year_after=$year+1;
					      $sql="select MAX(StockID) from item_master where CategoryID='".$_REQUEST['CategoryID']."' 
						   and  SubCategoryID = '".$_REQUEST['sub_group']."'";
						  $result = DB_query($sql,$db);
						   $myrow=DB_Fetch_array($result);
						   $strdata=substr($myrow['MAX(StockID)'],5,4);
						  
						   $numrows=DB_num_rows($result);
						 
						 
	 if($numrows>0)
	 {
			 $i=0;
			 $strmax = "";
			 $myrow=DB_Fetch_array($result);
			 
					
							$strdata1=$strdata;
							if($numrows>0)
							{ 
								$maxval =$strdata1;
							}
						else
							{
								$maxval=0;
							}
			
				$strChar =$prefixcode."/";
			
	  }
	  else
	  {
	  	$strChar =$prefixcode."/";
	  }
	  
	 $strFinal = $maxval+1;
	   $strBothFinal = $strChar.str_pad($strFinal,5,"0",STR_PAD_LEFT);*/
	  //if($_REQUEST['CategoryID']== $stockcat && $_REQUEST['sub_group']==$stocksub)
	  // {
	    $strBothFinal=$_REQUEST['StockID'];
	   //}	
	   //echo '<pre>'; print_r($_POST); exit;
		$data['orig_local']  =$_REQUEST['orig_local'];
		$data['StockID']  =$strBothFinal;
		$data['item_name']  =htmlentities($_REQUEST['item_name'], ENT_QUOTES);
		$data['part_no']  =$_REQUEST['part_no'];
		$data['mst_unitid']  =$_REQUEST['mst_unitid'];
		$data['conv_unit']  =$_REQUEST['conv_unit'];
		$data['conv_factor']  =$_REQUEST['conv_factor'];
		$data['min_level']  =$_REQUEST['min_level'];
		$data['max_level']  =$_REQUEST['max_level'];
		$data['reorder_level']  =$_REQUEST['reorder_level'];
		$data['mrp_rate']  =$_REQUEST['mrp_rate'];
		$data['net_rate']  =$_REQUEST['net_rate'];
		$data['shade_name']  =$_REQUEST['shade_name'];
		$data['item_mst_form_rate']  =$_REQUEST['item_mst_form_rate'];
		$data['product_sheet']  =$_REQUEST['product_sheet'];
		$data['serial_no']  =$_REQUEST['serial_no'];
		$data['net_wt']  =$_REQUEST['net_wt'];
		$data['gross_wt']  =$_REQUEST['gross_wt'];
		$data['make']=$_REQUEST['harwaregoup'];
		$data['abc_class']  =$_REQUEST['abc_class'];
		$data['excise_trafficno']  =$_REQUEST['excise_trafficno'];
		$data['warr_period']  =$_REQUEST['warr_period'];
		$data['item_mst_form']  =$_REQUEST['item_mst_form'];
		$data['brand_code']  =$_REQUEST['brand_code'];
		$data['material_type']  =$_REQUEST['material_type'];
		$data['material_item_desc']  =$_REQUEST['material_item_desc'];
		$data['cust_drwgno']  =$_REQUEST['cust_drwgno'];
		$data['Mfg_drwgno']  =$_REQUEST['Mfg_drwgno'];
		$data['Mfg_drwgcode']  =$_REQUEST['Mfg_drwgcode'];
		if(count($_REQUEST['groupid'])>0)
		$data['groupid']  =implode(',',$_REQUEST['groupid']); 
		if(count($_REQUEST['leaduserid'])>0)
		$data['users']  =implode(',',$_REQUEST['leaduserid']);
		$data['CompanyId'] =$_SESSION['ACGCompanyId'];
		$data['mst_ledgerid']  =$_REQUEST['mst_ledgerid'];
		$data['type_of_material']  =$_REQUEST['type_of_material'];
		$data['mst_ledger_code']  =$_REQUEST['mst_ledger_code'];
		$data['last_po_price']  =$_REQUEST['last_po_price'];
		$data['item_desc']=$_REQUEST['item_desc'];
		$data['CategoryID']  =$_REQUEST['CategoryID'];
		$data['SubCategoryID']  =$_REQUEST['sub_group']; 
		$data['item_exciable']  =$_REQUEST['item_exciable'];
		$data['item_profit']  =$_REQUEST['item_profit'];
		$data['item_discount']  =$_REQUEST['item_discount'];
		
   if($_REQUEST['action']!='edit'){
	$s->RecordInsert('item_master', $data);
	
	$lastid=DB_Last_Insert_ID($db,'item_master', 'id');
	$data1['created_date']=date("Y-m-d");
	$data1['effective_date']=date("Y-m-d");
	$data1['created_by']=$_SESSION['UserID'];
	$data1['mst_itemid']=$lastid;	
	$data1['item_discount']  =$_REQUEST['item_discount'];
	$data1['last_po_price']  =$_REQUEST['last_po_price'];
	$data1['item_profit']  =$_REQUEST['item_profit'];
	$data1['mrp_rate']  =$_REQUEST['mrp_rate'];
	$data1['net_rate']  =$_REQUEST['net_rate'];
	$s->RecordInsert('rev_item_master', $data1);
	prnMsg( _('Record Updated Successfully!'),'success');
	}
		
		 
	else{
		$cond="id='".$_REQUEST['id']."'";
		
		 $s->RecordEdit('item_master', $data,$cond);
	
	$sql1="select * from rev_item_master where mst_itemid='".$_REQUEST['id']."' order BY id DESC LIMIT 0,1";
	$result1=DB_query($sql1,$db);
	$myrow1=DB_fetch_array($result1); 
	
	$checkval = 0;
	if($myrow1['item_discount']!=$_REQUEST['item_discount']){$checkval=1;}
	if($myrow1['last_po_price']!=$_REQUEST['last_po_price']){$checkval=1;}
	if($myrow1['item_profit']!=$_REQUEST['item_profit']){$checkval=1;}
	if($myrow1['mrp_rate']!=$_REQUEST['mrp_rate']){$checkval=1;}
	if($myrow1['net_rate']!=$_REQUEST['net_rate']){$checkval=1;}
	
	if($checkval==1){
		$data1['created_date']=date("Y-m-d");
		$data1['effective_date']=date("Y-m-d");
		$data1['created_by']=$_SESSION['UserID'];
		$data1['mst_itemid']=$_REQUEST['id'];	
		$data1['item_discount']  =$_REQUEST['item_discount'];
		$data1['last_po_price']  =$_REQUEST['last_po_price'];
		$data1['item_profit']  =$_REQUEST['item_profit'];
		$data1['mrp_rate']  =$_REQUEST['mrp_rate'];
		$data1['net_rate']  =$_REQUEST['net_rate'];
		$s->RecordInsert('rev_item_master', $data1);
	}
	prnMsg( _('Record Updated Successfully!'),'success');
 	}


	echo "<script>location.href='index.php?route=item_list&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";
 
   }
   
	//else{
//	
//	$_REQUEST['action']=='edit'==$_REQUEST['action']!='edit'
	
	
	
  
  
   if($_REQUEST['action']=='edit'|| $_REQUEST['action']=='view')
   {
		$sql="select * from item_master where id='".$_REQUEST['id']."' ";
		$result=DB_query($sql,$db);
		$myrow=DB_fetch_array($result);
		$CategoryID=$myrow['CategoryID'];
		$SubCategoryID=$myrow['SubCategoryID']; 
		$orig_local=$myrow['orig_local'];
		$StockID=$myrow['StockID'];		 
		$item_name=$myrow['item_name'];
		$item_desc=$myrow['item_desc'];
		$part_no=$myrow['part_no'];
		$mst_unitid=$myrow['mst_unitid'];
		$conv_unit=$myrow['conv_unit'];
		$conv_factor=$myrow['conv_factor'];
		$min_level=$myrow['min_level'];
		$max_level=$myrow['max_level'];
		$reorder_level=$myrow['reorder_level'];
		$mrp_rate=$myrow['mrp_rate'];
		$net_rate=$myrow['net_rate'];
		$shade_name=$myrow['shade_name'];
		$product_sheet=$myrow['product_sheet'];
		$serial_no=$myrow['serial_no'];
		$net_wt=$myrow['net_wt'];
		$gross_wt=$myrow['gross_wt'];
		$abc_class=$myrow['abc_class'];
		$excise_trafficno=$myrow['excise_trafficno'];
		$warr_period=$myrow['warr_period'];
		$item_mst_form=$myrow['item_mst_form'];
		$brand_code=$myrow['brand_code'];
		$material_type=$myrow['material_type'];
		$material_item_desc=$myrow['material_item_desc'];
		$cust_drwgno=$myrow['cust_drwgno'];
		$Mfg_drwgno=$myrow['Mfg_drwgno'];
		$Mfg_drwgcode=$myrow['Mfg_drwgcode'];
		$groupid=$myrow['groupid'];
		$users  = $myrow['users'] ;
		$make=$myrow['make'] ;
		$type_of_material=  $myrow['type_of_material'] ;
		$item_mst_form_rate=  $myrow['item_mst_form_rate'] ;
		$last_po_price=  $myrow['last_po_price'] ;
		$item_exciable  =$myrow['item_exciable'];
		$item_profit  =$myrow['item_profit'];
		$item_discount  =$myrow['item_discount'];
		
		
		
   }
   
?>

<div class="body_contain">
<div class="tab_div">
<form action="" method="post" name="n">

<h1>Item Master</h1>
<h3>Product Information</h3>
<table width="100%" border="1" cellpadding="3"  cellspacing="0">
<tr class="row1"><td colspan="6" align="center" style="font-weight:bold; color:#FF0000;"><?php if(isset($_REQUEST['msg'])){echo $_REQUEST['msg'];}?></td></tr>
<tr class="row1">
    <td class="tabledata1">Fixed Main Group</td>
    <td style="width:150px;">
	<select name="CategoryID" id="CategoryID"
	    onchange="ShowDiv(this.value,'sub_id','item_subcategory.php')" style="width:100%">
	<option value="000">---Select---</option>
	<?php
	$query1=DB_query("select * from stockmaincategory where CompanyId='".$_SESSION['ACGCompanyId']."'",$db); 
	while($result1=DB_fetch_array($query1)) {
	?>
	<option value="<?php echo $result1['id'];?>"<?php echo ($CategoryID==$result1['id']?'selected':'')?>><?php echo $result1['stockmaincategoryname'];?></option>
	<?php } ?>
	</select>
	</td>
    <td class="tabledata1">Sub Group</td>
        <td style="width:120px;">
	<div id='sub_id'>
	<?php echo $unit;
 //echo	$catid= $s->GetFieldValue('stockmaincategory',"id='".$CategoryID."'",'stockmaincategoryid');
 $sql="select * from stockcategory where stockmaincategory ='".$CategoryID."' ";?>
<select name="sub_group" id="sub_group"   style="width:100%" onchange="get_item(this.value)">
<option value="000">Select</option>
  <?php
 $result=DB_query($sql,$db);
 while($row=DB_fetch_array($result)) {
?>
<option value="<?php echo $row['id'];?>"<?php echo ($SubCategoryID==$row['id']?'selected':'')?>><?php echo $row['categorydescription'];?></option>
<?php } ?>
</select>

 
	
	</div>
    </td>
    <td class="tabledata1" style="white-space:nowrap" colspan="2"><!--tore Location--></td>
    <!--<td>
	<?php //echo $orig_local;
	 	$sql_store = "SELECT * FROM storetype where CompanyId='".$_SESSION['ACGCompanyId']."'";
		$result_store = DB_query($sql_store,$db);?>
	    <select name="orig_local" id="orig_local" style="width:150px;">
		<option value="000">Select</option>
		<?php while($rx=DB_fetch_array($result_store)){ ?>
		
		<option value="<?php  echo $rx['id'];?>"  <?php echo ($rx['id']==$orig_local?'selected':'')?>><?php  echo $rx['StoreName']?></option>
 		<?php } ?>
		</select>
	</td>-->
  </tr>
  <tr class="row1">
    <td class="tabledata1">Part Code</td>
    <td><input type="text" style="width:100%;"  name="StockID"  value="<?php if($StockID!='')  {echo $StockID; } ?>" /></td>
    <td class="tabledata1">Item  Name</td>
    <td colspan="3"><input name="item_name" id="item_name" type="text" style="width:314px;" value="<?php echo $item_name; ?>" />
	<input type="hidden" name="item_name1" id="item_name1" value=""  />
	</td>
  </tr>
  
  <tr class="row1">
    <td class="tabledata1">Item Desc For Invoice</td>
    <td colspan="2"><input type="text" name="item_desc" id="item_desc" style="width:310px;"  value="<?php echo $item_desc; ?>" /></td>
	<td class="tabledata1">Item Part No.</td>
    <td colspan="2"><input type="text" name="part_no" id="part_no" style="width:114px;"  value="<?php echo $part_no; ?>" /></td>
  </tr>
  
  <tr class="row1">
    <td class="tabledata1">Uom</td>
    <td><?php echo $ClassUnitMeasure->UnitMeasure($mst_unitid,'mst_unitid');?></td>
    <td class="tabledata1">Conv. Unit</td>
    <td><?php echo $ClassUnitMeasure->UnitMeasure($conv_unit,'conv_unit');?></td>
    <td class="tabledata1">Conv Factor</td>
    <td><input type="text" style="width:100%;" name="conv_factor" value="<?php echo $conv_factor; ?>" />			</td>
  </tr>
  <tr class="row1">
    <td class="tabledata1">Minimum Level</td>
    <td><input type="text" style="width:100%;" value="<?php echo $min_level; ?>"  name="min_level" /></td>
    <td class="tabledata1" style="white-space:nowrap">Maximum Level</td>
    <td><input type="text" style="width:100%;"  value="<?php echo $max_level; ?>" name="max_level" /></td>
    <td class="tabledata1" style="white-space:nowrap">Reorder lever</td>
    <td><input type="text" style="width:100%;"  value="<?php echo $reorder_level; ?>" name="reorder_level" /></td>
  </tr>
 
  <tr class="row1">
    <td class="tabledata1">Last Purchase Price</td>
    <td><input   type="text" style="width:100%;"  value="<?php echo $last_po_price; ?>"  name="last_po_price" id="last_po_price"  onkeyup="setNewItem2(this.value)";/></td>
	<td class="tabledata1">Profit(%)</td>
	<td><input type="text" style="width:100%;"  value="<?php if($_REQUEST['action']=='edit') echo $item_profit; else echo 0; ?>"  name="item_profit" id="item_profit" onkeyup="setNewItem1(this.value)";/></td>
	<td class="tabledata1">Mrp Rate</td>
    <td><input type="text" style="width:100%;"  value="<?php echo $mrp_rate; ?>" name="mrp_rate" id="mrp_rate" onfocus="setNew1(this.value)";/></td></tr>
	<tr class="row1">
	<td class="tabledata1">Discount(%)</td>
    <td><input   type="text" style="width:100%;"  value="<?php if($_REQUEST['action']=='edit') echo $item_discount; else echo 0; ?>"  name="item_discount" id="item_discount" onkeyup="setNew(this.value)";/></td>
    
    <td class="tabledata1">Net Rate</td>
    <td><input type="text" style="width:100%;"  value="<?php echo $net_rate; ?>" name="net_rate" id="net_rate" /></td>
  </tr>


  <tr class="row1">
    <td class="tabledata1">Net Wt</td>
    <td><input type="text" style="width:100%;" value="<?php echo $net_wt; ?>" name="net_wt" /></td>
    <td class="tabledata1">Gros  Wt</td>
    <td><input type="text" style="width:100%;" name="gross_wt"   value="<?php echo $gross_wt; ?>"/></td>
    <td class="tabledata1">Abc Class</td>
    <td><select  name="abc_class" style="width:100%;">
			<option id="A" <?php echo $abcclass=='A'?'selected':'';?>>A</option>
			<option id="B"  <?php echo $abcclass=='B'?'selected':'';?>>B</option>
			<option id="C"  <?php echo $abcclass=='C'?'selected':'';?>>C</option>
	
	</select></td>
  </tr>


  <tr class="row1">
    <td class="tabledata1">Excise Tariff No / ISBN</td>
    <td><input type="text" style="width:150px;" name="excise_trafficno" value="<?php  echo $excise_trafficno;?>" /></td>
	<td class="tabledata1">Warrantee valid till</td>
    <td>
		<select  name="warr_period" style="width:150px;">
			<option value="" >----Select----</option>
			<option value="6" <?php echo $warr_period=='6'?'selected':'';?>> 6 Months</option>
			<option value="12" <?php echo $warr_period=='12'?'selected':'';?>>12 Months</option>
			<option value="18" <?php echo $warr_period=='18'?'selected':'';?>>18 Months</option>
			<option value="24" <?php echo $warr_period=='24'?'selected':'';?>>24 Months</option>
			<option value="30" <?php echo $warr_period=='30'?'selected':'';?>>30 Months</option>
			<option value="36" <?php echo $warr_period=='36'?'selected':'';?>>36 Months</option>
			<option value="42" <?php echo $warr_period=='42'?'selected':'';?>>42 Months</option>
			<option value="48" <?php echo $warr_period=='48'?'selected':'';?>>48 Months</option>
			<option value="54" <?php echo $warr_period=='54'?'selected':'';?>>54 Months</option>
			<option value="60" <?php echo $warr_period=='60'?'selected':'';?>>60 Months</option>
		</select>
		</td>
		<td class="tabledata1">Hardware Group</td>
		<td id="harwaregroupid">
		<?php $Sqlprodmanu=DB_query("SELECT * FROM product_manufacture where companyId='".$_SESSION['ACGCompanyId']."'",$db);?>
		<select name="harwaregoup" id="harwaregoup" style="width:150px;">
		<option value="" >----Select----</option>
				<?php while($GetProdData=DB_fetch_array($Sqlprodmanu)){ ?>
				
				<option value="<?php echo $GetProdData['id'];  ?>"<?php if($make==$GetProdData['id']) { ?> selected="selected" <?php } ?>><?php echo $GetProdData['manufacturer'];  ?></option>
				<?php }?>
			</select></td>
  </tr>
</table>

<h3 style="text-align:left;">Mrp Rate Pick From</h3>
<table width="100%" border="1" cellpadding="3"  cellspacing="0">
  <tr class="row1">
    <td class="tabledata1">Item Master Mrp Rate</td>
    <td><input name="item_mst_form" type="radio" value="MRrate" <?php echo $item_mst_form=='MRrate'?'checked':''?> /></td>
    <td class="tabledata1">Price List Mgmt</td>
    <td><input name="item_mst_form" type="radio" value="pricelist"  <?php echo $item_mst_form=='pricelist'?'checked':''?>/></td>
    <td class="tabledata1">Tolerance(%)</td>
    <td><input style="width:150px;" name="item_mst_form_rate" value="<?php echo $item_mst_form_rate;?>" />
		</td>
  </tr>
</table>

<h3 style="text-align:left;">Other Information</h3>
<table width="100%" border="1" cellpadding="3"  cellspacing="0">
	  <tr class="row1">
  <?php if($item_name_auto=='1') 
  { 
  	$state_item_name ='onkeyup="setItemName()"'; ?>
	
	<input type="hidden" name="setItemName_Flag" id="setItemName_Flag" value="1" />
	<?php 
  }
  else
  {
  	$state_item_name='';
  }
  ?>
    <td class="tabledata1">Thickness</td>
    <td><input type="text" style="width:100%;" value="<?php echo $shade_name; ?>" id="shade_name" name="shade_name"  <?php echo $state_item_name; ?> /></td>
    <td class="tabledata1">Door Type </td>
    <td><input type="text" style="width:100%;" value="<?php echo $product_sheet; ?>" id="product_sheet" <?php echo $state_item_name; ?>  name="product_sheet"/></td>
    <td class="tabledata1">Fire Rating </td>
    <td><input type="text" style="width:100%;"   <?php echo $state_item_name;  ?> value="<?php echo $serial_no; ?>" id="serial_no"  name="serial_no"/></td>
  </tr>
  <tr class="row1">
    <td class="tabledata1">Leaf Type </td>
    <td style="width:150px;"><input type="text" style="width:100%;" <?php echo $state_item_name;  ?>  name="brand_code" id="brand_code"  value="<?php  echo $brand_code;?>"/>
</td>
    <td class="tabledata1">Material Type</td>
    <td><input type="text" style="width:100%;" name="material_type" <?php echo $state_item_name;  ?>  id="material_type"  value="<?php  echo $material_type;?>"/></td>
    <td class="tabledata1">Item Desc</td>
    <td><input type="text" style="width:100%;"  name="material_item_desc" <?php echo $state_item_name;  ?>  id="material_item_desc"  value="<?php  echo $material_item_desc;?>"/></td>
  </tr>

  <tr class="row1">
    <td class="tabledata1">Customer Drwg No</td>
    <td><input type="text" style="width:100%;"  name="cust_drwgno"  value="<?php  echo $cust_drwgno;?>"/></td>
    <td class="tabledata1">Mfg Drgw No</td>
    <td><input type="text" style="width:100%;"  name="Mfg_drwgno"  value="<?php  echo $Mfg_drwgno;?>"/></td>
    <td class="tabledata1">Mfg Drwg Code</td>
    <td><input type="text" style="width:100%;"  name="Mfg_drwgcode"  value="<?php  echo $Mfg_drwgcode;?>"/></td>
  </tr>


</table>

<h3 style="text-align:left;">User & Group Assignment</h3>
<table width="100%" border="1" cellpadding="3"  cellspacing="0">
  <tr class="row1">
    <td class="tabledata1">Group</td>
	<td><?php echo $ClassRole->Role($groupid);?></td>
	<td class="tabledata1">User</td>
    <td colspan="3">	
	<div id='hid-Roleid' style="overflow:auto;width:300px;">	
	<?php  
	$user=explode(',',$users );
	$sql_state=DB_query("SELECT id , realname FROM  www_users where rolepid ='".$groupid."' ",$db);		
	while($row=DB_fetch_array($sql_state))
	{
		$p='';
 	 	if (in_array($row['id'],  $user))
	 	$p='checked';?>
		<input name="leaduserid[]" type="checkbox" value="<?php  echo $row['id'];?>" <?php echo $p;?> /><?php  echo $row['realname'];?><br />
 <?php }?>
	</div>	
	</td>
  </tr>
</table>
<h3 style="text-align:left;">Approved Vendor/Client Information</h3>
<table width="100%" border="1" cellpadding="3"  cellspacing="0">
<tr class="row1">
    <td class="tabledata1">Vebdor/Client Name</td>
    <td colspan="2"> 
 	<select name="mst_ledgerid" style="width:80px%;" onchange="ShowDiv(this.value,'hid_vendorcode','vendorcode.php')">
      <option value="000">Select</option>
      <?php 
      $client_sql=DB_query("Select AccountsID,AccountName from accountledger where ledgertype in('vendor','client')",$db);
	  while($client_row=DB_fetch_array($client_sql))
	  {?>
	  	<option value="<?php echo $client_row['AccountsID'];?>"<?php echo($mst_ledgerid==$client_row['AccountsID']?'selected':'')?>><?php echo $client_row['AccountName'];?></option>
	  <?php 	
	  }
      ?>
    </select>
	</td>
    <td class="tabledata1">Vendor/Client Code</td>
    <td width="23%" colspan="2"><div id='hid_vendorcode'><input type="text"   style="width:100%;" value="<?php echo $mst_ledger_code; ?>" /></div>
		</td>
  </tr>
  <tr class="row1">
    <td class="tabledata1">Product Front Image</td>
    <td colspan="2"><input  size="30" name="borws" type="file"  /></td>
    <td class="tabledata1">Product Back Image</td>
    <td width="23%" colspan="2"><input  size="23" name="borws" type="file"  />
		</td>
  </tr>
  
  <tr class="row1">
  <td class="tabledata1" colspan="2">If Material Require Bill Of Material</td>
  <td colspan="4"><input name="type_of_material" type="radio" value="Bill" <?php echo $type_of_material=='Bill'?'checked':''?> /></td>
  </tr>
  <tr class="row1">
  <td class="tabledata1" colspan="2">If Material Require Quality Check</td>
  <td colspan="4"><input name="type_of_material" type="radio" value="QualityCheck" <?php echo $type_of_material=='QualityCheck'?'checked':''?> /></td>
  </tr>
  <tr class="row1">
  <td colspan="2" class="tabledata1" >Exciable</td>
  <td colspan="4"><input name="item_exciable" type="radio" value="Y" <?php echo $item_exciable=='Y'?'checked':''?> /></td>
  </tr>
  <tr class="row1">
  <td class="tabledata1" colspan="2"  >Non Exciable</td>
  <td colspan="4"  ><input name="item_exciable" type="radio" value="N" <?php echo $item_exciable=='N'?'checked':''?> /></td>
  </tr>
</table>
<center>
<div style="width:300px; margin-left:auto; margin-right:auto;">
	<?php if($_REQUEST['action']!='view') {?>
		<input name="SaveItem" type="submit" value="Save Item" class="bottonsview" onclick="return checkvalidate()" />&nbsp;&nbsp;&nbsp;		<input name="save" type="button" value="Cancel" class="bottonsview" />
		<?php } ?>
	
	</div></center>
	<br />
</form>

</div></div>


<script>
function checkvalidate()
{
if(document.getElementById("CategoryID").value=='000')
{
alert("Must Select Category");
return false;
}
if(document.getElementById("sub_group").value=='000')
{
alert("Must Select Sub Category");
return false;
}
if(document.getElementById("orig_local").value=='000')
{
alert("Must Select Store Locations");
return false;
}

if(document.getElementById("item_name").value=='')
{
alert("Must Enter Item Name");
return false;

}
/*
if(document.getElementById("setItemName_Flag").value!='')
{
	if(document.getElementById("shade_name").value=='')
	{
		alert("Must Enter Shade Name");
		return false;
	
	}
	if(document.getElementById("product_sheet").value=='')
	{
		alert("Must Enter Product Sheet");
		return false;
	
	}
	if(document.getElementById("serial_no").value=='')
	{
		alert("Must Enter Serial No");
		return false;
	
	}
	if(document.getElementById("brand_code").value=='')
	{
		alert("Must Enter Brand Code");
		return false;
	
	}
	if(document.getElementById("material_type").value=='')
	{
		alert("Must Enter Material Type");
		return false;
	
	}
	if(document.getElementById("material_item_desc").value=='')
	{
		alert("Must Enter Material Item Desc");
		return false;
	
	}
	

}*/
/*if(document.getElementById("item_desc").value=='')
{
alert("Must Enter Item Desc");
return false;
}*/
return true;




}

</script>
