<?php
session_name('CAKEPHP'); session_start();
include('includes/DefinePOClass.php');
include('includes/SQL_CommonFunctions.inc');
$CompanyId = $_SESSION['ACGCompanyId'];
	if($CompanyId) {
	    $sql_query = "SELECT * FROM tbl_itemname_auto where CompanyId=".$CompanyId;
		$sqlQuery =DB_query($sql_query,$db);
		$row = DB_fetch_array($sqlQuery);
	}

 	if($_REQUEST['action']=='setItemnameAuto'){
 	
	 $item_name_auto = $_POST['item_name_auto']; 
	
		if($item_name_auto!='1'){
			$item_name_auto=0;
		}
	
		if($row['CompanyID']){
			
			$res = DB_query("update  tbl_itemname_auto set item_name_auto ='$item_name_auto' where CompanyId ='$CompanyId'",$db);
			$s->pageLocation("index.php?route=Elementory/elementmanagement&modid=9&frmid=406");	
		}
		else{
			$sql ="insert into tbl_itemname_auto(CompanyId,item_name_auto) values('$CompanyId','$item_name_auto')";//exit;	
			$res = DB_query($sql,$db);
			$s->pageLocation("index.php?route=Elementory/elementmanagement&modid=9&frmid=406");
		}
	
  }
 
?>

<div align="left">
<form  action="" name="itemNameForm" method="post" >
<input type="hidden" name="action" value="setItemnameAuto" />

I1 : Auto Item Name creation 
<input type="checkbox" <?php if($row['item_name_auto']=="1"){ ?> checked="checked" <?php }?> value="1" name="item_name_auto" />

<input type="submit" name="submit" value="save" />
</form></div>

