915 lines
29 KiB
PHP
Executable File
915 lines
29 KiB
PHP
Executable File
<style type="text/css">
|
|
<!--
|
|
.w { display: block; }
|
|
.n { display: none; }
|
|
|
|
<!--
|
|
a.unassigned:link {
|
|
font-family: Geneva, Arial, Helvetica, sans-serif;
|
|
font-size: 12px;
|
|
color: #FF0000;
|
|
}
|
|
a.unassigned:visited {
|
|
font-family: Geneva, Arial, Helvetica, sans-serif;
|
|
font-size: 12px;
|
|
color: #FF0000;
|
|
}
|
|
a.unassigned:active {
|
|
font-family: Geneva, Arial, Helvetica, sans-serif;
|
|
font-size: 12px;
|
|
color: #FF0000;
|
|
}
|
|
a.unassigned:hover {
|
|
font-family: Geneva, Arial, Helvetica, sans-serif;
|
|
font-size: 12px;
|
|
color: #FF0000;
|
|
}
|
|
|
|
a.tree:link {
|
|
font-family: Geneva, Arial, Helvetica, sans-serif;
|
|
font-size: 11px;
|
|
color: #000000;
|
|
text-decoration: none;
|
|
}
|
|
a.tree:visited {
|
|
font-family: Geneva, Arial, Helvetica, sans-serif;
|
|
font-size: 11px;
|
|
color: #000000;
|
|
text-decoration: none;
|
|
}
|
|
a.tree:active {
|
|
font-family: Geneva, Arial, Helvetica, sans-serif;
|
|
font-size: 11px;
|
|
color: #000000;
|
|
text-decoration: none;
|
|
}
|
|
a.tree:hover {
|
|
font-family: Geneva, Arial, Helvetica, sans-serif;
|
|
font-size: 11px;
|
|
color: #990000;
|
|
text-decoration: underline;
|
|
}
|
|
a.tree_active:link {
|
|
font-family: Geneva, Arial, Helvetica, sans-serif;
|
|
font-size: 11px;
|
|
color: #FFFFFF;
|
|
text-decoration: none;
|
|
background-color: #000099;
|
|
}
|
|
a.tree_active:visited {
|
|
font-family: Geneva, Arial, Helvetica, sans-serif;
|
|
font-size: 11px;
|
|
color: #FFFFFF;
|
|
text-decoration: none;
|
|
background-color: #000099;
|
|
}
|
|
a.tree_active:active {
|
|
font-family: Geneva, Arial, Helvetica, sans-serif;
|
|
font-size: 11px;
|
|
color: #FFFFFF;
|
|
text-decoration: none;
|
|
background-color: #000099;
|
|
}
|
|
a.tree_active:hover {
|
|
font-family: Geneva, Arial, Helvetica, sans-serif;
|
|
font-size: 11px;
|
|
color: #FFFFFF;
|
|
text-decoration: none;
|
|
background-color: #000099;
|
|
}
|
|
.fade {
|
|
filter: alpha(opacity=83);
|
|
-moz-opacity: 0.83;
|
|
opacity:0.83;
|
|
}
|
|
-->
|
|
</style>
|
|
<script type="text/javascript" language="javascript" src="modules/EcmDocuments/mintajax.js"></script>
|
|
<script type="text/javascript" language="javascript">
|
|
|
|
function inserttoinput(field,to_field,id,to_id,div)
|
|
{
|
|
document.getElementById(to_field).value=field;
|
|
document.getElementById(to_id).value=id;
|
|
document.getElementById(div).style.display="none";
|
|
}
|
|
|
|
function showdescription(id,title,desc,minus)
|
|
{
|
|
if(!minus)minus=0;
|
|
var sum=17-minus;
|
|
document.getElementById("opis").style.display="inline";
|
|
document.getElementById("opis-title").innerHTML=title;
|
|
document.getElementById("opis-desc").innerHTML=desc;
|
|
posy=findPosY(document.getElementById("link-"+id))+sum;
|
|
posx=findPosX(document.getElementById("link-"+id))-80;
|
|
moveDiv(document.getElementById("opis"),posy,posx);
|
|
}
|
|
function hidedescription()
|
|
{
|
|
document.getElementById("opis").style.display="none";
|
|
}
|
|
function showdiv(desc,id)
|
|
{
|
|
document.getElementById(id).style.display="inline";
|
|
posy=findPosY(document.getElementById("link"+id))+15;
|
|
posx=findPosX(document.getElementById("link"+id));
|
|
moveDiv(document.getElementById(id),posy,posx);
|
|
}
|
|
function hidediv(desc,id)
|
|
{
|
|
document.getElementById(id).style.display="none";
|
|
}
|
|
|
|
function mintajaxget(url,tag)
|
|
{
|
|
var req=mint.Request();
|
|
req.OnLoading=function(){$(tag).innerHTML='<div style="text-align: center;"><img src="modules/EcmDocuments/loading.gif" border="0"></div>';}
|
|
req.OnSuccess = function(){if($(tag).type=='text'){$(tag).value=this.responseText;}else{$(tag).innerHTML=this.responseText;}}
|
|
req.Send(url,tag);
|
|
|
|
}
|
|
function mintajaxpost(url,tag,form)
|
|
{
|
|
var req=mint.Request();
|
|
req.OnSuccess=function(){$(tag).innerHTML=this.responseText;}
|
|
req.OnLoading=function(){$(tag).innerHTML='<div style="text-align: center;"><img src="modules/EcmDocuments/loading.gif" border="0"></div>';}
|
|
req.SendForm(form);
|
|
}
|
|
function displayshowblock(id)
|
|
{
|
|
if(document.getElementById(id+"_input").value==1)
|
|
{
|
|
document.getElementById(id+"_image").src="themes/Sugar/images/advanced_search.gif";
|
|
advAJAX.get
|
|
(
|
|
{
|
|
url: "modules/EcmDocuments/showhide_panel.php?value=0&what="+id+"&record=<?print $_GET['record'];?>",
|
|
onSuccess : function(obj){pom=0;}
|
|
}
|
|
);
|
|
document.getElementById(id).className="n";
|
|
pom=0;
|
|
}
|
|
if(document.getElementById(id+"_input").value==0)
|
|
{
|
|
document.getElementById(id+"_image").src="themes/Sugar/images/basic_search.gif";
|
|
advAJAX.get
|
|
(
|
|
{
|
|
url: "modules/EcmDocuments/showhide_panel.php?value=1&what="+id+"&record=<?print $_GET['record'];?>",
|
|
onSuccess : function(obj){pom=1;}
|
|
}
|
|
);
|
|
document.getElementById(id).className="w";
|
|
pom=1;
|
|
}
|
|
document.getElementById(id+"_input").value=pom;
|
|
}
|
|
function show_block(id,op)
|
|
{
|
|
if(document.getElementById('inputpom'+id).value==0)
|
|
{
|
|
document.getElementById('blocktree'+id).className="w";
|
|
document.getElementById('plusminus'+id).src="modules/EcmDocuments/images/minus.gif";
|
|
document.getElementById('image'+id).src="modules/EcmDocuments/images/Folder-open.gif";
|
|
pom=1;
|
|
}
|
|
if(document.getElementById('inputpom'+id).value==1)
|
|
{
|
|
document.getElementById('blocktree'+id).className="n";
|
|
document.getElementById('plusminus'+id).src="modules/EcmDocuments/images/plus.gif";
|
|
document.getElementById('image'+id).src="modules/EcmDocuments/images/Folder.gif";
|
|
pom=0;
|
|
}
|
|
document.getElementById('inputpom'+id).value=pom;
|
|
}
|
|
function click_block(id,r)
|
|
{
|
|
document.getElementById('fade').style.display="block";
|
|
document.getElementById('tree').className="fade";
|
|
if(document.getElementById('inputpom'+id).value==0)
|
|
{
|
|
document.getElementById('blocktree'+id).className="w";
|
|
document.getElementById('plusminus'+id).src="modules/EcmDocuments/images/minus.gif";
|
|
document.getElementById('image'+id).src="modules/EcmDocuments/images/Folder-open.gif";
|
|
document.getElementById('linktree'+id).className="tree_active";
|
|
pom=1;
|
|
}
|
|
if(document.getElementById('inputpom'+id).value==1)
|
|
{
|
|
document.getElementById('blocktree'+id).className="n";
|
|
document.getElementById('plusminus'+id).src="modules/EcmDocuments/images/plus.gif";
|
|
document.getElementById('image'+id).src="modules/EcmDocuments/images/Folder.gif";
|
|
document.getElementById('linktree'+id).className="tree";
|
|
pom=0;
|
|
}
|
|
if(document.getElementById('blocktree'+r))document.getElementById('blocktree'+r).className="n";
|
|
if(document.getElementById('plusminus'+r))document.getElementById('plusminus'+r).src="modules/EcmDocuments/images/plus.gif";
|
|
if(document.getElementById('image'+r))document.getElementById('image'+r).src="modules/EcmDocuments/images/Folder.gif";
|
|
if(document.getElementById('linktree'+r))document.getElementById('linktree'+r).className="tree";
|
|
|
|
document.getElementById('inputpom'+id).value=pom;
|
|
}
|
|
function cut_name(t,ile)
|
|
{
|
|
if(!ile)
|
|
{
|
|
ile=20;
|
|
}
|
|
var text="";
|
|
var i;
|
|
if(t.length>ile)
|
|
{
|
|
for(i=0;i<=ile-1;i++)
|
|
{
|
|
text+=t.charAt(i);
|
|
}
|
|
text=text+"...";
|
|
}
|
|
else
|
|
{
|
|
text=t;
|
|
}
|
|
document.write(text);
|
|
}
|
|
</script>
|
|
|
|
<div style="height:10px;width:300px;background:#ffffff;display:none;position:absolute; top:0; right:0;" id="opis"><table bgcolor="#cccccc" class="olBgClass" border="0" cellpadding="1" cellspacing="1" width="300"><tbody><tr><td><table class="olCgClass" border="0" cellpadding="2" cellspacing="0" width="100%"><tbody><tr><td class="olCgClass" width="100%"><div id="opis-title" class="olCapFontClass"></div></td><td align="right"><a href="javascript:hidedescription();" title="Click to Close" onClick="javascript:hidedescription();" class="olCloseFontClass"><img src="themes/Sugar/images/close_inline.gif" border="0"></a></td></tr></tbody></table><table class="olFgClass" border="0" cellpadding="2" cellspacing="0" width="100%"><tbody><tr><td class="olFgClass" valign="top" background="#ffffff"><div id="opis-desc" class="olFontClass"><br></div></td></tr></tbody></table></td></tr></tbody></table></div>
|
|
</div>
|
|
<?
|
|
error_reporting(E_PARSE);
|
|
function shortlinkdescription($name,$ile,$record,$description,$no,$module,$show=1,$name_to_ecm_related="")
|
|
{
|
|
$_SESSION['ecmdocuments_stamp']++;
|
|
$description=str_replace("\n","",$description);
|
|
$description=str_replace("\l","",$description);
|
|
$description=str_replace("\r","",$description);
|
|
$description=str_replace("'","·",$description);
|
|
$description=str_replace('"',""",$description);
|
|
$description=str_replace('
|
|
',"",$description);
|
|
$name_temp=$name;
|
|
$name=str_replace('"','"',$name);
|
|
$total=strlen($name);
|
|
if($total>$ile)
|
|
{
|
|
for($i=0;$i<=$ile-1;$i++)$nn.=$name[$i];
|
|
$nn.="...";
|
|
}
|
|
else $nn=$name;
|
|
if($no)$nn=$no.".".$nn;
|
|
if($no[0]=="[" &&
|
|
$no[1]=="n" &&
|
|
$no[2]=="u" &&
|
|
$no[3]=="m" &&
|
|
$no[4]=="]")
|
|
{
|
|
$nn="";
|
|
for($i=5;$i<=strlen($no)-1;$i++)$nn.=$no[$i];
|
|
|
|
}
|
|
if($name_to_ecm_related)
|
|
{
|
|
$minus=5;
|
|
$name=$name_to_ecm_related;
|
|
$nn="<img src='modules/EcmDocuments/images/Folder.gif' border=0 width=14 height=11> ";
|
|
//$description=str_replace('"','',$description);
|
|
//$description=str_replace("'","",$description);
|
|
}
|
|
$on="";
|
|
if($show)
|
|
{
|
|
$on=' onmouseover="showdescription(\''.$module.$record.'\',\''.$name.'\',\''.$description.'\',\''.$minus.'\');"';
|
|
$on.=' onmouseout="hidedescription();"';
|
|
}
|
|
else
|
|
{
|
|
if($total>=$ile)
|
|
{
|
|
$on=' onmouseover="showdescription(\''.$module.$record.'\',\''.$name.'\',\''.$description.'\',\''.$minus.'\');"';
|
|
$on.=' onmouseout="hidedescription();"';
|
|
}
|
|
else $on='';
|
|
}
|
|
if($module=="EcmDocuments")$nn=$name_temp;
|
|
return '<a'.$on.' id="link-'.$module.$record.'" href="index.php?module='.$module.'&action=DetailView&record='.$record.'&return_module=EcmDocuments&return_action=DetailView&return_id='.$record.'" class=\'listViewTdLinkS1\' >'.$nn.'</a>';
|
|
}
|
|
function print_title($tab)
|
|
{
|
|
$podz=explode("||",$tab);
|
|
$i=0;
|
|
foreach($podz as $p)
|
|
{
|
|
$z="select name,no from ecmdocuments where id='".$p."' and isdir='1'";
|
|
$w=mysql_query($z);
|
|
$r=mysql_fetch_array($w);
|
|
$name=$r['name'];
|
|
$nm[$i]=$r['no'].".".$name;
|
|
$i++;
|
|
}
|
|
for($j=$i-3;$j>=0;$j--)$html.=$nm[$j]."/";
|
|
$html=str_replace("//","/",$html);
|
|
$html=str_replace("/"," / ",$html);
|
|
return $html;
|
|
}
|
|
function check_block($id,$html)
|
|
{
|
|
$z="select iddir from ecmdocuments where id='".$id."'";
|
|
$w=mysql_query($z);
|
|
if(mysql_num_rows($w)>0)
|
|
{
|
|
$r=mysql_fetch_array($w);
|
|
$iddir=$r['iddir'];
|
|
$html.=$iddir."||";
|
|
$html=check_block($iddir,$html);
|
|
}
|
|
return $html;
|
|
}
|
|
function check_open($id)
|
|
{
|
|
$podz=explode("||",check_block($_GET['record'],"").$_GET['record']);
|
|
for($i=0;$i<=count($podz)-1;$i++)
|
|
{
|
|
if($id==$podz[$i])
|
|
{
|
|
return true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
function check_open_change($id)
|
|
{
|
|
$podz=explode("||",check_block($_GET['iddirs'],"").$_GET['iddirs']);
|
|
for($i=0;$i<=count($podz)-1;$i++)
|
|
{
|
|
if($id==$podz[$i])
|
|
{
|
|
return true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
function check_is_admin($id)
|
|
{
|
|
$z="select is_admin from users where id='".$id."'";
|
|
$r=mysql_fetch_array(mysql_query($z));
|
|
$is=$r['is_admin'];
|
|
return $is;
|
|
}
|
|
|
|
function check_admin_permission($id)
|
|
{
|
|
$z="select treeread from users where id='".$id."'";
|
|
$r=mysql_fetch_array(mysql_query($z));
|
|
$read=$r['treeread'];
|
|
if($read)return true;
|
|
else return false;
|
|
}
|
|
function permission($user)
|
|
{
|
|
$w=mysql_query("select id from ecmdocuments");
|
|
while($r=mysql_fetch_array($w))
|
|
{
|
|
$rr=mysql_fetch_array(mysql_query("select * from ecmdocuments_permissions where iddir='".$r['id']."' and userid='".$user."'"));
|
|
$read=$rr['read'];
|
|
if(check_is_admin($user) || $read || check_admin_permission($user))$html.='document.getElementById("all'.$r['id'].'").style.display="block";
|
|
';
|
|
}
|
|
return $html;
|
|
}
|
|
function diropen($id)
|
|
{
|
|
$h=check_block($id,"");
|
|
$p=explode("||",$h);
|
|
foreach($p as $pp)
|
|
{
|
|
if($pp)
|
|
{
|
|
$html.='document.getElementById("all'.$pp.'").style.display="block";
|
|
document.getElementById("blocktree'.$pp.'").style.display="block";
|
|
';
|
|
}
|
|
}
|
|
return $html;
|
|
}
|
|
function display_dir_data($id,$conn,$userid)
|
|
{
|
|
global $current_user;
|
|
$_SESSION['ecm_iddir']=$id;
|
|
$z="select id,iddir,name,no from ecmdocuments where iddir='".$id."' and isdir='1' order by no";
|
|
if($conn)$w=mysql_query($z,$conn);
|
|
else $w=mysql_query($z);
|
|
$i=0;
|
|
$r=mysql_fetch_array(mysql_query("select treeread from users where id='".$_SESSION['authenticated_user_id']."'"));
|
|
$treeread=$r['treeread'];
|
|
while($r=mysql_fetch_array($w))
|
|
{
|
|
$z1="select * from ecmdocuments_permissions where iddir='".$r['id']."' and userid='".$userid."'";
|
|
$w1=mysql_query($z1);
|
|
$r1=mysql_fetch_array($w1);
|
|
$read=$r1['read'];
|
|
if($read==1 || check_is_admin($_SESSION['authenticated_user_id']) || check_admin_permission($_SESSION['authenticated_user_id']) || $treeread)
|
|
{
|
|
$name=$r['name'];
|
|
$id1=$r['id'];
|
|
$podz=explode(".",$name);
|
|
if(strlen($podz[0])==1)$name="00".$name;
|
|
if(strlen($podz[0])==2)$name="0".$name;
|
|
$dane[$i]['name']=$name;
|
|
$dane[$i]['id']=$id1;
|
|
$dane[$i]['orgname']=$r['name'];
|
|
$dane[$i]['no']=$r['no'];
|
|
$i++;
|
|
}
|
|
}
|
|
$ile=$i;
|
|
|
|
for($i=0;$i<=count($dane)-1;$i++)
|
|
{
|
|
if($_GET['record']==$dane[$i]['id'])$class="tree_active";
|
|
else $class="tree";
|
|
if(check_open($dane[$i]['id']))
|
|
{
|
|
$display="w";
|
|
if(mysql_num_rows(mysql_query("select id from ecmdocuments where iddir='".$dane[$i]['id']."'"))>0)
|
|
{
|
|
$plusminus="modules/EcmDocuments/images/minus.gif";
|
|
$plusminus="<img id='plusminus".$dane[$i]['id']."' src='".$plusminus."' border='0'>";
|
|
}
|
|
else $plusminus="<div id='plusminus".$dane[$i]['id']."'> </div>";
|
|
$image="modules/EcmDocuments/images/Folder-open.gif";
|
|
$op=1;
|
|
}
|
|
else
|
|
{
|
|
$display="n";
|
|
if(mysql_num_rows(mysql_query("select id from ecmdocuments where iddir='".$dane[$i]['id']."'"))>0)
|
|
{
|
|
$plusminus="modules/EcmDocuments/images/plus.gif";
|
|
$plusminus="<img id='plusminus".$dane[$i]['id']."' src='".$plusminus."' border='0'>";
|
|
}
|
|
else $plusminus="<div id='plusminus".$dane[$i]['id']."'> </div>";
|
|
$image="modules/EcmDocuments/images/Folder.gif";
|
|
$op=0;
|
|
}
|
|
$margin=17;
|
|
if($dane[$i]['no']<10)$nod=0;
|
|
else $nod="";
|
|
$html.="<table cellspacing='0' cellpadding='0' border='0'>
|
|
<tr valign='top'>
|
|
<td width='10' style='width:10px;'>
|
|
<input type='hidden' id='inputpom".$dane[$i]['id']."' value='".$op."'>
|
|
<a style='cursor:pointer;' onclick='mintajaxget(\"showtree.php?iddir=".$dane[$i]['id']."\",\"blocktree".$dane[$i]['id']."\");show_block(\"".$dane[$i]['id']."\",\"blocktree".$dane[$i]['id']."\");'>
|
|
".$plusminus."
|
|
</a>
|
|
</td>
|
|
<td width='10' style='width:10px;'>
|
|
<a style='cursor:pointer;' href='index.php?module=EcmDocuments&action=DetailView&record=".$dane[$i]['id']."'>
|
|
<img id='image".$dane[$i]['id']."' src='".$image."' border='0'>
|
|
</a>
|
|
</td>
|
|
<td width='999'>
|
|
<a name='linktree".$dane[$i]['id']."' onclick='click_block(\"".$dane[$i]['id']."\",\"".$_REQUEST['record']."\");' id='linktree".$dane[$i]['id']."' class='".$class."' href='index.php?module=EcmDocuments&action=DetailView&record=".$dane[$i]['id']."'>".$nod.$dane[$i]['no'].".".$dane[$i]['orgname']."</a>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan='3'><div class='w' id='blocktree".$dane[$i]['id']."' style='margin-left:".$margin."px;'>";
|
|
if(check_open($dane[$i]['id']))$html.=display_dir_data($dane[$i]['id'],"",$userid);
|
|
$html.="</div>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
";
|
|
}
|
|
return $html;
|
|
}
|
|
function assign_user_to_dir($idu,$iddir)
|
|
{
|
|
$z="select assigned_user_id,id,iddir from ecmdocuments where iddir='".$iddir."'";
|
|
$w=mysql_query($z);
|
|
while($r=mysql_fetch_array($w))
|
|
{
|
|
$za="update ecmdocuments set assigned_user_id='".$idu."' where id='".$r['id']."'";
|
|
mysql_query($za);
|
|
assign_user_to_dir($idu,$r['id']);
|
|
}
|
|
}
|
|
function copyrelationschips($from,$to,$what,$id)
|
|
{
|
|
$z="select * from ".$what." where ecmdocument_id='".$from."'";
|
|
$w=mysql_query($z);
|
|
print $z;
|
|
while($r=mysql_fetch_array($w))
|
|
{
|
|
$z1="insert into ".$what." values('".create_guid()."','".$to."','".$r[$id]."','".$r['date_modified']."','0')";
|
|
print $z1;
|
|
mysql_query($z1);
|
|
}
|
|
}
|
|
function clonepermissions($source,$destination)
|
|
{
|
|
$z="select * from ecmdocuments_permissions where iddir='".$source."'";
|
|
$w=mysql_query($z);
|
|
while($r=mysql_fetch_array($w))mysql_query("insert into ecmdocuments_permissions values('','".$r['userid']."','".$destination."','".$r['read']."','".$r['write']."','".$r['add']."','".$r['delete']."')");
|
|
}
|
|
function clone_dir($katalog,$gdzie)
|
|
{
|
|
$z="select * from ecmdocuments where iddir='".$katalog."' order by name";
|
|
$w=mysql_query($z);
|
|
while($r=mysql_fetch_array($w))
|
|
{
|
|
$name=$r['name'];
|
|
|
|
$idx=create_guid();
|
|
$z1="insert into ecmdocuments(
|
|
id,
|
|
name,
|
|
isdir,
|
|
assigned_user_id,
|
|
modified_user_id,
|
|
date_entered,
|
|
date_modified,
|
|
created_by,
|
|
description,
|
|
iddir,
|
|
cloning,
|
|
shortcut,
|
|
show_details,
|
|
show_upload,
|
|
no
|
|
)
|
|
values(
|
|
'".$idx."',
|
|
'".$name."',
|
|
'1',
|
|
'".$r['assigned_user_id']."',
|
|
'".$r['modified_user_id']."',
|
|
'".date("Y-m-d H:m:s")."',
|
|
'".date("Y-m-d H:m:s")."',
|
|
'".$r['created_by']."',
|
|
'".$r['description']."',
|
|
'".$gdzie."',
|
|
'".$r['cloning']."',
|
|
'".$r['shortcut']."',
|
|
'".$r['show_details']."',
|
|
'".$r['show_upload']."',
|
|
'".$r['no']."'
|
|
)";
|
|
mysql_query($z1);
|
|
clonepermissions($r['id'],$idx);
|
|
copyrelationschips($r['id'],$idx,"ecmdocuments_accounts","account_id");
|
|
copyrelationschips($r['id'],$idx,"ecmdocuments_contacts","contact_id");
|
|
copyrelationschips($r['id'],$idx,"ecmdocuments_quotes","quote_id");
|
|
copyrelationschips($r['id'],$idx,"ecmdocuments_notes","note_id");
|
|
copyrelationschips($r['id'],$idx,"ecmdocuments_calls","call_id");
|
|
copyrelationschips($r['id'],$idx,"ecmdocuments_meetings","meeting_id");
|
|
copyrelationschips($r['id'],$idx,"ecmdocuments_tasks","task_id");
|
|
copyrelationschips($r['id'],$idx,"ecmdocuments_contracts","contract_id");
|
|
copyrelationschips($r['id'],$idx,"ecmdocuments_correspondences","correspondence_id");
|
|
clone_dir($r['id'],$idx);
|
|
}
|
|
return true;
|
|
}
|
|
function getnextdirnumber($id)
|
|
{
|
|
$z="select no from ecmdocuments where iddir='".$id."' order by no desc limit 1";
|
|
$w=mysql_query($z);
|
|
$r=mysql_fetch_array($w);
|
|
$no=$r['no'];
|
|
(int)$no;
|
|
$no++;
|
|
return $no;
|
|
}
|
|
function reorganizedir($id)
|
|
{
|
|
$z="select no,id from ecmdocuments where iddir='".$id."' order by no asc";
|
|
$w=mysql_query($z);
|
|
$i=1;
|
|
while($r=mysql_fetch_array($w))
|
|
{
|
|
if(mysql_query("update ecmdocuments set no='".$i."' where id='".$r['id']."'"))$i++;
|
|
}
|
|
}
|
|
function delete_recursive($id)
|
|
{
|
|
mysql_query("delete from ecmdocuments where id='".$id."'");
|
|
if($id!=0)
|
|
{
|
|
$z="select id from ecmdocuments where iddir='".$id."'";
|
|
$w=mysql_query($z);
|
|
while($r=mysql_fetch_array($w))delete_recursive($r['id']);
|
|
}
|
|
return true;
|
|
}
|
|
function createdir($iddir,$name,$no)
|
|
{
|
|
$ids=ceate_guid();
|
|
$z="insert into ecmdocuments(id,name,date_entered,date_modified,modified_user_id,assigned_user_id,created_by,iddir,isdir,no)
|
|
values('".$ids."','".$name."','".date("Y-m-d H:m:s")."','".date("Y-m-d H:m:s")."','".$current_user->id."','".$current_user->id."','".$current_user->id."','".$iddir."','1','".$no."')";
|
|
$w=mysql_query($z);
|
|
return $ids;
|
|
}
|
|
function movedir($id,$newiddir,$name,$no)
|
|
{
|
|
if($name)$n=",name='".$name."'";
|
|
else $n="";
|
|
if($no)$nn=",no='".$no."'";
|
|
else $nn="";
|
|
$z="update ecmdocuments set iddir='".$newiddir."'".$n.$nn." where id='".$id."'";
|
|
if(mysql_query($z))return true;
|
|
else return false;
|
|
}
|
|
function getmaxdirel($iddir)
|
|
{
|
|
$tabsr=array('ecmdocs','ecmcontracts','ecmcorrespondenceins','ecmcorrespondenceouts','ecminvoiceins','ecminvoiceouts');
|
|
$last=0;
|
|
foreach($tabsr as $tabsre)
|
|
{
|
|
$z="select no from ecmdocuments_".$tabsre." where ecmdocument_id='".$iddir."' and deleted='0' order by no asc";
|
|
$w=mysql_query($z);
|
|
while($r=mysql_fetch_array($w))
|
|
{
|
|
$num[(int)$r['no']]=(int)$r['no'];
|
|
if((int)$r['no']>$last)$last=(int)$r['no'];
|
|
}
|
|
}
|
|
$ok=0;
|
|
for($i=0;$i<=$last;$i++)
|
|
{
|
|
if(!isset($num[$i]))
|
|
{
|
|
$n=$i;
|
|
$ok=1;
|
|
}
|
|
}
|
|
if($ok==0)$n=$last+1;
|
|
return $n;
|
|
}
|
|
function updateno($what,$iddir)
|
|
{
|
|
$z="select id,ecmdocument_id from ".$what." where no='0' and ecmdocument_id='".$iddir."' and deleted='0'";
|
|
$w=mysql_query($z);
|
|
while($r=mysql_fetch_array($w))
|
|
{
|
|
$id=$r['id'];
|
|
$z="update ".$what." set no='".getmaxdirel($iddir)."' where id='".$id."'";
|
|
mysql_query($z);
|
|
}
|
|
}
|
|
/*
|
|
function updaterelation($what,$whatid,$iddir,$table)
|
|
{
|
|
$zz="update ".$table." set relation='0'";
|
|
mysql_query($zz);
|
|
$z="select ".$whatid." as id from ".$what." where ecmdocument_id='".$iddir."' and deleted='0'";
|
|
$w=mysql_query($z);
|
|
while($r=mysql_fetch_array($w))
|
|
{
|
|
$zz="update ".$table." set relation='1' where id='".$r['id']."'";
|
|
mysql_query($zz);
|
|
}
|
|
|
|
}
|
|
*/
|
|
function deleterelations($id,$relation,$relation_id)
|
|
{
|
|
if(mysql_query("update ".$relation." set deleted=1 where ".$relation_id."='".$id."'"))print "ok<br>";
|
|
else print "no<br>";
|
|
}
|
|
function display_dir_data_change_ecm($id,$conn,$userid)
|
|
{
|
|
global $current_user;
|
|
$_SESSION['change_ecm_iddir']=$id;
|
|
$_SESSION['change_ecm_k']="#linktree".$id;
|
|
$z="select id,iddir,name,no from ecmdocuments where iddir='".$id."' and isdir='1' order by no";
|
|
if($conn)$w=mysql_query($z,$conn);
|
|
else $w=mysql_query($z);
|
|
$i=0;
|
|
while($r=mysql_fetch_array($w))
|
|
{
|
|
$z1="select * from ecmdocuments_permissions where iddir='".$r['id']."' and userid='".$_SESSION['authenticated_user_id']."'";
|
|
$w1=mysql_query($z1);
|
|
$r1=mysql_fetch_array($w1);
|
|
$read=$r1['read'];
|
|
if($read==1 || check_is_admin($_SESSION['authenticated_user_id']) || check_admin_permission($_SESSION['authenticated_user_id']))
|
|
{
|
|
$name=$r['name'];
|
|
$id1=$r['id'];
|
|
$podz=explode(".",$name);
|
|
if(strlen($podz[0])==1)$name="00".$name;
|
|
if(strlen($podz[0])==2)$name="0".$name;
|
|
$dane[$i]['name']=$name;
|
|
$dane[$i]['id']=$id1;
|
|
$dane[$i]['orgname']=$r['name'];
|
|
$dane[$i]['no']=$r['no'];
|
|
$i++;
|
|
}
|
|
}
|
|
$ile=$i;
|
|
|
|
for($i=0;$i<=count($dane)-1;$i++)
|
|
{
|
|
if($_GET['iddirs']==$dane[$i]['id'])$class="tree_active";
|
|
else $class="tree";
|
|
if(check_open_change($dane[$i]['id']))
|
|
{
|
|
$display="w";
|
|
if(mysql_num_rows(mysql_query("select id from ecmdocuments where iddir='".$dane[$i]['id']."'"))>0)
|
|
{
|
|
$plusminus="modules/EcmDocuments/images/minus.gif";
|
|
$plusminus="<img id='plusminus".$dane[$i]['id']."' src='".$plusminus."' border='0'>";
|
|
}
|
|
else $plusminus="</a><div id='plusminus".$dane[$i]['id']."' style='width:15px;'></div><a>";
|
|
$image="modules/EcmDocuments/images/Folder-open.gif";
|
|
$op=1;
|
|
}
|
|
else
|
|
{
|
|
$display="n";
|
|
if(mysql_num_rows(mysql_query("select id from ecmdocuments where iddir='".$dane[$i]['id']."'"))>0)
|
|
{
|
|
$plusminus="modules/EcmDocuments/images/plus.gif";
|
|
$plusminus="<img id='plusminus".$dane[$i]['id']."' src='".$plusminus."' border='0'>";
|
|
}
|
|
else $plusminus="</a><div id='plusminus".$dane[$i]['id']."' style='width:15px;'></div><a>";
|
|
$image="modules/EcmDocuments/images/Folder.gif";
|
|
$op=0;
|
|
}
|
|
$margin=17;
|
|
if($dane[$i]['no']<10)$nod=0;
|
|
else $nod="";
|
|
$html.="<table cellspacing='0' cellpadding='0' border='0'>
|
|
<tr valign='top'>
|
|
<td width='10'>
|
|
<input type='hidden' id='inputpom".$dane[$i]['id']."' value='".$op."'>
|
|
<a style='cursor:pointer;' href='javascript:mintajaxget(\"showtree_change_ecm.php?iddir=".$dane[$i]['id']."&record=".$_REQUEST['record']."&ecmdocument_id=".$_REQUEST['ecmdocument_id']."&relation=".$_REQUEST['relation']."&idrelation=".$_REQUEST['idrelation']."\",\"blocktree".$dane[$i]['id']."\");show_block(\"".$dane[$i]['id']."\",\"blocktree".$dane[$i]['id']."\");'>
|
|
".$plusminus."
|
|
</a>
|
|
</td>
|
|
<td width='10'>
|
|
<a style='cursor:pointer;' href='javascript:mintajaxget(\"showtree_change_ecm.php?iddir=".$dane[$i]['id']."&record=".$_REQUEST['record']."&ecmdocument_id=".$_REQUEST['ecmdocument_id']."&relation=".$_REQUEST['relation']."&idrelation=".$_REQUEST['idrelation']."\",\"blocktree".$dane[$i]['id']."\");show_block(\"".$dane[$i]['id']."\",\"blocktree".$dane[$i]['id']."\");'>
|
|
<img id='image".$dane[$i]['id']."' src='".$image."' border='0'>
|
|
</a>
|
|
</td>
|
|
<td width='363'><a name='linktree".$dane[$i]['id']."' class='".$class."' href='change_ecm.php?iddir=".$dane[$i]['id']."&record=".$_REQUEST['record']."&ecmdocument_id=".$_REQUEST['ecmdocument_id']."&relation=".$_REQUEST['relation']."&idrelation=".$_REQUEST['idrelation']."'>".$nod.$dane[$i]['no'].".".$dane[$i]['orgname']."</a></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan='3'><div class='w' id='blocktree".$dane[$i]['id']."' style='margin-left:".$margin."px;'>";
|
|
if(check_open_change($dane[$i]['id']))$html.=display_dir_data_change_ecm($dane[$i]['id'],"",$userid);
|
|
$html.="</div>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
";
|
|
}
|
|
return $html;
|
|
}
|
|
function move_relations($relation,$relation_to,$relation_id,$relation_to_id,$id,$to_id,$no=0)
|
|
{
|
|
$z="select * from ".$relation." where ".$relation_id."='".$id."'";
|
|
$w=mysql_query($z);
|
|
while($r=mysql_fetch_array($w))
|
|
{
|
|
$no_field="";
|
|
$no_value="";
|
|
if($no)
|
|
{
|
|
$no_field=",no";
|
|
$no_value=",'".$r['no']."'";
|
|
}
|
|
mysql_query("insert into ".$relation_to."(id,ecmdocument_id,".$relation_to_id.",deleted".$no_field.") values('".create_guid()."','".$r['ecmdocument_id']."','".$to_id."','".$r['deleted']."'".$no_value.")");
|
|
}
|
|
}
|
|
function duplicate_relations($relation,$relation_id,$old_id,$new_id)
|
|
{
|
|
$z="select * from ".$relation." where ".$relation_id."='".$old_id."'";
|
|
$w=mysql_query($z);
|
|
while($r=mysql_fetch_array($w))
|
|
{
|
|
mysql_query("insert into ".$relation."(id,ecmdocument_id,".$relation_id.",deleted) values('".create_guid()."','".$r['ecmdocument_id']."','".$new_id."','".$r['deleted']."')");
|
|
}
|
|
}
|
|
function set_permissions_for_subfolders($id,$user,$read,$write,$add,$delete)
|
|
{
|
|
}
|
|
function mailashtml($email,$skrot,$message,$odKogo)
|
|
{
|
|
$naglowki=
|
|
"From: ".$odKogo."\n"
|
|
. "Reply-To: ".$odKogo."\n"
|
|
. "Content-Type: text/html; charset=utf-8; format=flowed\n"
|
|
. "MIME-Version: 1.0\n"
|
|
. "Content-Transfer-Encoding: 8bit\n"
|
|
. "X-Mailer: PHP\n";
|
|
|
|
$ret=mail($email,$skrot,$message,$naglowki);
|
|
|
|
return $ret;
|
|
}
|
|
|
|
|
|
function display_dir_data_email($id,$conn,$userid,$target,$tab)
|
|
{
|
|
global $current_user;
|
|
$_SESSION['email_iddir']=$id;
|
|
$z="select id,iddir,name,no from ecmdocuments where iddir='".$id."' and isdir='1' order by no";
|
|
if($conn)$w=mysql_query($z,$conn);
|
|
else $w=mysql_query($z);
|
|
$i=0;
|
|
$r=mysql_fetch_array(mysql_query("select treeread from users where id='".$_SESSION['authenticated_user_id']."'"));
|
|
$treeread=$r['treeread'];
|
|
while($r=mysql_fetch_array($w))
|
|
{
|
|
$z1="select * from ecmdocuments_permissions where iddir='".$r['id']."' and userid='".$userid."'";
|
|
$w1=mysql_query($z1);
|
|
$r1=mysql_fetch_array($w1);
|
|
$read=$r1['read'];
|
|
if($read==1 || check_is_admin($_SESSION['authenticated_user_id']) || check_admin_permission($_SESSION['authenticated_user_id']) || $treeread)
|
|
{
|
|
$name=$r['name'];
|
|
$id1=$r['id'];
|
|
$podz=explode(".",$name);
|
|
if(strlen($podz[0])==1)$name="00".$name;
|
|
if(strlen($podz[0])==2)$name="0".$name;
|
|
$dane[$i]['name']=$name;
|
|
$dane[$i]['id']=$id1;
|
|
$dane[$i]['orgname']=$r['name'];
|
|
$dane[$i]['no']=$r['no'];
|
|
$i++;
|
|
}
|
|
}
|
|
$ile=$i;
|
|
|
|
for($i=0;$i<=count($dane)-1;$i++)
|
|
{
|
|
if($_GET['iddirs']==$dane[$i]['id'])$class="tree_active";
|
|
else $class="tree";
|
|
if(check_open_change($dane[$i]['id']))
|
|
{
|
|
$display="w";
|
|
if(mysql_num_rows(mysql_query("select id from ecmdocuments where iddir='".$dane[$i]['id']."'"))>0)
|
|
{
|
|
$plusminus="modules/EcmDocuments/images/minus.gif";
|
|
$plusminus="<img id='plusminus".$dane[$i]['id']."' src='".$plusminus."' border='0'>";
|
|
}
|
|
else $plusminus="<div id='plusminus".$dane[$i]['id']."'> </div>";
|
|
$image="images/Folder-open.gif";
|
|
$op=1;
|
|
}
|
|
else
|
|
{
|
|
$display="n";
|
|
if(mysql_num_rows(mysql_query("select id from ecmdocuments where iddir='".$dane[$i]['id']."'"))>0)
|
|
{
|
|
$plusminus="modules/EcmDocuments/images/plus.gif";
|
|
$plusminus="<img id='plusminus".$dane[$i]['id']."' src='".$plusminus."' border='0'>";
|
|
}
|
|
else $plusminus="<div id='plusminus".$dane[$i]['id']."'> </div>";
|
|
$image="images/Folder.gif";
|
|
$op=0;
|
|
}
|
|
$margin=17;
|
|
if($dane[$i]['no']<10)$nod=0;
|
|
else $nod="";
|
|
$html.="<table cellspacing='0' cellpadding='0' border='0' width='100%'>
|
|
<tr valign='top'>
|
|
<td width='10'>
|
|
<input type='hidden' id='inputpom".$dane[$i]['id']."' value='".$op."'>
|
|
<a style='cursor:pointer;' onclick='mintajaxget(\"showtree_email.php?iddir=".$dane[$i]['id']."\",\"blocktree".$dane[$i]['id']."\");show_block(\"".$dane[$i]['id']."\",\"blocktree".$dane[$i]['id']."\");'>
|
|
".$plusminus."
|
|
</a>
|
|
</td>
|
|
<td width='10'>
|
|
<a style='cursor:pointer;' onclick='mintajaxget(\"showtree_email.php?iddir=".$dane[$i]['id']."\",\"blocktree".$dane[$i]['id']."\");show_block(\"".$dane[$i]['id']."\",\"blocktree".$dane[$i]['id']."\");'>
|
|
<img id='image".$dane[$i]['id']."' src='".$image."' border='0'>
|
|
</a>
|
|
</td>
|
|
<td width='163'>
|
|
<a name='linktree".$dane[$i]['id']."' onclick='click_block(\"".$dane[$i]['id']."\");' id='linktree".$dane[$i]['id']."' class='".$class."' href='SelectFile.php?target=".$target."&tab=".$tab."&record=".$dane[$i]['id']."#linktree".$dane[$i]['id']."'>".$nod.$dane[$i]['no'].".".$dane[$i]['orgname']."</a>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan='3'><div class='w' id='blocktree".$dane[$i]['id']."' style='margin-left:".$margin."px;'>";
|
|
if(check_open_change($dane[$i]['id']))$html.=display_dir_data_email($dane[$i]['id'],"",$userid,$target,$tab);
|
|
$html.="</div>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
";
|
|
}
|
|
return $html;
|
|
}
|
|
|
|
$aktualdir="/var/www/html/e5crm/html/test/modules/EcmDocuments/root".str_replace(" / ","/",print_title($_GET['record']."||".check_block($_GET['record'],"")));
|
|
$z1="select id from ecmdocuments";
|
|
$w1=mysql_query($z1);
|
|
$il=mysql_num_rows($w1);
|
|
$projinprogressdir=mysql_fetch_array(mysql_query("select id from ecmdocuments where projects_in_progress_dir='1'"));
|
|
$projectsinprogressdir=$projinprogressdir['id'];
|
|
$projdir=mysql_fetch_array(mysql_query("select id from ecmdocuments where projects_dir='1'"));
|
|
$projectsdir=$projdir['id'];
|
|
?>
|
|
|
|
|