<?php

include 'icl/show#record#.inc.php';

function add#record#(){
	
#iterator-fieldlist-servervars#	
	global $db;
	$user=userinfo();
	$gsid=$user['gsid']+0;
	
	checkgskey('add#record#');
	
	$query="insert into #tablename# (gsid,#iterator-fieldlist-sqlflist#) values (?,#iterator-fieldlist-sqlqlist#) ";
	$rs=sql_prep($query,$db,array($gsid,#iterator-fieldlist-sqlplist#));
	$#primarykey#=sql_insert_id($db,$rs)+0;

	if (!$#primarykey#) {
		apperror(_tr('error_creating_record'));
	}
	
	logaction("added #c_record# #$#primarykey# $#dispfield#",array('#primarykey#'=>$#primarykey#,'#dispfield#'=>"$#dispfield#"));
	
	header('newrecid:'.$#primarykey#);
	header('newkey:#record#_'.$#primarykey#);
	header('newparams:show#record#&#primarykey#='.$#primarykey#);
	
	show#record#($#primarykey#);
}
