<?
require_once('include/formbase.php');
require_once("modules/EcmDocuments/dirstree.php");

$z="select id,name from ecmdocuments where iddir='".$_GET['idkatalogu']."' order by name desc limit 1";
$r=mysql_fetch_array(mysql_query($z));
$name=$r['name'];

$nn=getnextdirnumber($_GET['idkatalogu']);

	$name=$r[count($r)];
	$idx=create_guid();
	$z="insert into ecmdocuments(id,iddir,name,isdir,assigned_user_id,modified_user_id,date_entered,date_modified,no) values('".$idx."','".$_GET['idkatalogu']."','".$_GET['dirname']."','1','".$current_user->id."','".$current_user->id."','".date("Y-m-d H:m:s")."','".date("Y-m-d H:m:s")."','".$nn."')";
	$w=mysql_query($z);
	
	clone_dir($_REQUEST['idkat'],$idx);
	clonepermissions($_REQUEST['idkat'],$idx);
	handleRedirect($_GET['idkat'],'EcmDocuments');
?>
