<?
global $db;

require("modules/EcmProducts/vardefs.php");
require("modules/EcmProducts/language/en_us.lang.php");

$fields=$dictionary['EcmProduct']['fields'];

$columns=$_REQUEST['column1']."||".$_REQUEST['column2']."||".$_REQUEST['column3']."||".$_REQUEST['column4']."||".$_REQUEST['column5']."||".$_REQUEST['column6']."||".$_REQUEST['column7']."||".$_REQUEST['column8']."||".$_REQUEST['column9'];

$fields=$dictionary['EcmProduct']['fields'];

for($i=1;$i<=9;$i++)
{
	$str=$fields[$_REQUEST['column'.$i]]['vname'];
	if(!$_REQUEST['title'.$i])$_REQUEST['title'.$i]=$mod_strings[$str];
}

$titles=$_REQUEST['title1']."||".$_REQUEST['title2']."||".$_REQUEST['title3']."||".$_REQUEST['title4']."||".$_REQUEST['title5']."||".$_REQUEST['title6']."||".$_REQUEST['title7']."||".$_REQUEST['title8']."||".$_REQUEST['title9'];

for($i=1;$i<=9;$i++){
	if($_REQUEST['order'.$i] && $_REQUEST['sorder'.$i]){
		$ord[$i]=$_REQUEST['order'.$i]." ".$_REQUEST['sorder'.$i];
	}
}

$orders=implode("||",$ord);

if($_REQUEST['record'])$db->query("update ecmdevices_customview set name='".$_REQUEST['name']."',columns='".$columns."',titles='".$titles."',orders='".$orders."' where id='".$_REQUEST['record']."'");
else $db->query("insert into ecmdevices_customview values('".create_guid()."','".$_REQUEST['name']."','".$columns."','".$titles."','".$orders."')");

header("Location: index.php?module=EcmDevices&action=DetailView&record=".$_SESSION['pricebook_id']."&tab=items");
?>
