KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.4.62
System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64
User : www ( 80)
PHP Version : 8.3.8
Disable Function : NONE
Directory :  /domains/logicswapweb/aplicaciones/admon/documentos/fnc/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /domains/logicswapweb/aplicaciones/admon/documentos/fnc/documento.php
<?php
class Documento extends Componente{

var $ruta="./aplicaciones/admon/documentos/docs/archivos/";
var $cantidad=0;
var $filas=0;
var $filas1=0;

function Documento() {
    $this->DBManager('MySQL');
	$this->connect();

}

function categoria(){
	$sql1="SELECT id,nombre FROM carpeta WHERE tipo='carpeta' ORDER BY nombre";
	if($this->execute($sql1)){
		$i=0;
		$resultado[0][0]=NULL;
		while(list($id,$name)=$this->fetchRow()){
			$resultado[$i][0]=$id;
			$resultado[$i][1]=$name;
			$i++;
		}
	}
	
	$this->filas=$i;
	return $resultado;
}

function subcategoria($id_car){
	$sql1="SELECT id,nombre FROM carpeta WHERE tipo='subcarpeta' AND parent='$id_car' ";
	if($this->execute($sql1)){
		$i=0;
		$resultado[0][0]=NULL;
		while(list($id,$name)=$this->fetchRow()){
			$resultado[$i][0]=$id;
			$resultado[$i][1]=$name;
			$i++;
		}
	}
	
	$this->filas1=$i;
	return $resultado;
}

function matrix(){
	$db1=new Documento();
	$db2=new Documento();
	$db3=new Documento();
	$db4=new Documento();

	//nivel 1
	$filas=0;
	$matrix["0"]["0"]="*";
	$matrix["0"]["1"]="*";
	$matrix["0"]["2"]="*";
	$matrix["0"]["3"]="*";
	$matrix["0"]["4"]="*";
	$matrix["0"]["5"]="*";
	$matrix["0"]["6"]="*";
	$matrix["0"]["7"]="*";
	$sql1="SELECT id,nombre FROM carpeta WHERE tipo='carpeta' ORDER BY nombre";
	if($db1->execute($sql1)){
		while(list($id,$name)=$db1->fetchRow()){
			$matrix[$filas]["0"]=$id;
			$matrix[$filas]["1"]=$name;
			$matrix[$filas]["2"]="-";
			$matrix[$filas]["3"]="-";
			$matrix[$filas]["4"]="-";
			$matrix[$filas]["5"]="-";
			$matrix[$filas]["6"]="-";
			$matrix[$filas]["7"]="-";
	//nivel 2
			$sql2="SELECT id,nombre FROM carpeta WHERE tipo='subcarpeta' AND parent='$id' ORDER BY nombre";
			if($db2->execute($sql2)){
				while(list($ids,$names)=$db2->fetchRow()){
	//nivel 3				
					$filas++;
					$matrix[$filas]["0"]="*";
					$matrix[$filas]["1"]="*";
					$matrix[$filas]["2"]=$ids;
					$matrix[$filas]["3"]=$names;
					$matrix[$filas]["4"]="-";
					$matrix[$filas]["5"]="-";				
					$matrix[$filas]["6"]="-";
					$matrix[$filas]["7"]="-";				
					$sql3="SELECT id,nombre FROM carpeta WHERE tipo='subcarpeta' AND parent='$ids' ORDER BY nombre";
					if($db3->execute($sql3)){
						while(list($idss,$namess)=$db3->fetchRow()){
	//nivel 4 
							$filas++;
							$matrix[$filas]["0"]="*";
							$matrix[$filas]["1"]="*";
							$matrix[$filas]["2"]="*";
							$matrix[$filas]["3"]="*";						
							$matrix[$filas]["4"]=$idss;
							$matrix[$filas]["5"]=$namess;						
							$matrix[$filas]["6"]="-";
							$matrix[$filas]["7"]="-";						
							$sql4="SELECT id,nombre FROM carpeta WHERE tipo='subcarpeta' AND parent='$idss' ORDER BY nombre";
							if($db4->execute($sql4)){
								while(list($idsss,$namesss)=$db4->fetchRow()){												
									$filas++;
									$matrix[$filas]["0"]="*";
									$matrix[$filas]["1"]="*";
									$matrix[$filas]["2"]="*";
									$matrix[$filas]["3"]="*";					
									$matrix[$filas]["4"]="*";
									$matrix[$filas]["5"]="*";									
									$matrix[$filas]["6"]=$idsss;
									$matrix[$filas]["7"]=$namesss;			
								}
							}else{
								echo "�Impossible to consult the database!";
							}	
						}
	//cierre nivel 4					
					}else{
						echo "�Impossible to consult the database!";
					}
				}
	//cierre nivel 3	
			}else{
				echo "�Impossible to consult the database!";
			}
			$filas++;
		}
	// cierra nivel 2	
	}else{
		echo "�Impossible to consult the database!";
	}
	//cierra nivel 1
	$matrix[$filas]["0"]="-";
	$matrix[$filas]["1"]="-";
	$matrix[$filas]["2"]="-";
	$matrix[$filas]["3"]="-";					
	$matrix[$filas]["4"]="-";
	$matrix[$filas]["5"]="-";									
	$matrix[$filas]["6"]="-";
	$matrix[$filas]["7"]="-";	

	$this->filas = $filas;
	return $matrix;
}

function documentos($id_car,$ini){
	$sql = "SELECT nombre FROM carpeta WHERE id='$id_car'";
    $this->execute($sql);
    list($nombre_carpeta) = $this->fetchRow();
	echo '<div align="center" class="menu1">Carpeta: '.$nombre_carpeta.'</div><br>';
	$db2=new Documento();
	$tabla=0;
	$control=0;
	$sql = "SELECT id,titulo,texto,fecha_ing,fecha_fin FROM documentos WHERE carpeta='$id_car' order by titulo";
    $this->execute($sql);
	if($this->numRows()){	
		$i = 1; $j=0; $limite =10; $write=0;
        while((list($id_pro, $titulo,$descripcion,$fecha_ing,$fecha_fin) = $this->fetchRow())){
			$fechaing=$this->fecha($fecha_ing);
			$fechafin=$this->fecha($fecha_fin);
			$sql2="SELECT titulo,fichero FROM archivo WHERE documento='$id_pro' order by titulo";
			$db2->execute($sql2);	
			$this->cantidad=$this->cantidad+$db2->numRows();
	 
    		while((list($titulo_arc,$fichero) = $db2->fetchRow()) && ($j<$limite)){	
			
			if($write>=$ini){
				if($i==1){ 
					$i++;
								
				$length=strlen($fichero); 
				$ext=substr($fichero,$length-3,$length);
				$tabla++;
				if($control==0){
					echo '<tr>';
				}
				echo '<td width="50%"><table width="100%" border="0">';
				echo '<tr><td width="50%" valign="top" align="left"><strong>Documento</strong><br>'.$titulo.'<br><br><strong>Archivo</strong><br><a href="'.$this->ruta.$fichero.'" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">'.$titulo_arc.'</a></td><td width="50%" valign="top" align="left"><strong>Ingreso<br></strong>'.$fechaing.'<br><br><strong>Vence<br></strong>'.$fechafin.'</td></tr>';
				if($ext=="pdf" || $ext=="PDF"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoPdf.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="mp3" || $ext=="MP3" || $ext=="wav" || $ext=="WAV" || $ext=="ogg" || $ext=="OGG" || $ext=="wma" || $ext=="WMA" || $ext=="rmp" || $ext=="RMP"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/audio.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:100%; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="avi" || $ext=="AVI" || $ext=="mpg" || $ext=="MPG" || $ext=="pge" || $ext=="PGE"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoAvi.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%"><br><strong>Descripcion</strong><br><div style="width:100%; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="xls" || $ext=="XLS"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoExcel.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="gif" || $ext=="GIF"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoGif.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="jpg" || $ext=="JPG" || $ext=="PEG" || $ext=="peg"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoJpg.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="mov" || $ext=="MOV"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoMov.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="ppt" || $ext=="PPT"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoPpt.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="swf" || $ext=="SWF"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoSwf.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="txt" || $ext=="TXT"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoTxt.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="doc" || $ext=="DOC"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoWord.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="zip" || $ext=="ZIP" || $ext=="rar" || $ext=="RAR"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoZip.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="bmp" || $ext=="BMP"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoBmp.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="htm" || $ext=="HTM" || $ext=="TML" || $ext=="tml"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoHtml.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}else{
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/Documento.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}
				
				echo '</table></td>';
				
				if($control==1){
					echo '</tr>';
					$control++;
				}
				
				if($control==2){
					$control=0;
				}else{
					$control++;	
				}	
				
			}else{
			
				$length=strlen($fichero); 
				$ext=substr($fichero,$length-3,$length);
				$tabla++;
				if($control==0){
					echo '<tr>';
				}
				echo '<td width="50%"><table width="100%" border="0">';
				echo '<tr><td width="50%" valign="top" align="left"><strong>Documento</strong><br>'.$titulo.'<br><br><strong>Archivo</strong><br><a href="'.$this->ruta.$fichero.'" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">'.$titulo_arc.'</a></td><td width="50%" valign="top" align="left"><strong>Ingreso<br></strong>'.$fechaing.'<br><br><strong>Vence<br></strong>'.$fechafin.'</td></tr>';
				if($ext=="pdf" || $ext=="PDF"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoPdf.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="mp3" || $ext=="MP3" || $ext=="wav" || $ext=="WAV" || $ext=="ogg" || $ext=="OGG" || $ext=="wma" || $ext=="WMA" || $ext=="rmp" || $ext=="RMP"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/audio.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:100%; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="avi" || $ext=="AVI" || $ext=="mpg" || $ext=="MPG" || $ext=="pge" || $ext=="PGE"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoAvi.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%"><br><strong>Descripcion</strong><br><div style="width:100%; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="xls" || $ext=="XLS"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoExcel.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="gif" || $ext=="GIF"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoGif.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="jpg" || $ext=="JPG" || $ext=="PEG" || $ext=="peg"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoJpg.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="mov" || $ext=="MOV"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoMov.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="ppt" || $ext=="PPT"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoPpt.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="swf" || $ext=="SWF"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoSwf.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="txt" || $ext=="TXT"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoTxt.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="doc" || $ext=="DOC"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoWord.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="zip" || $ext=="ZIP" || $ext=="rar" || $ext=="RAR"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoZip.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="bmp" || $ext=="BMP"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoBmp.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}elseif($ext=="htm" || $ext=="HTM" || $ext=="TML" || $ext=="tml"){
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/DocumentoHtml.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}else{
					echo '<tr><td onMouseover="this.bgColor=\'#e0e0e0\'" onMouseout="this.bgColor=\'#ffffff\'" width="50%" valign="middle" align="center"><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';"><img src="aplicaciones/admon/documentos/img/Documento.gif"></a><br><a href="'.$this->ruta.$fichero.'" target="_blank" title="Descargar" style="cursor:hand; text-decoration:none; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000" onMouseover="this.style.color=\'0000FF\'" onMouseOut="this.style.color=\'000000\';">Descargar</a></td><td width="50%" valign="top" align="left"><br><strong>Descripcion</strong><br><div style="width:120px; height:50px; overflow:auto ">'.$descripcion.'</div></td></tr>';
				}
								
				echo '</table></td>';
				
				if($control==1){
					echo '</tr>';
					$control++;
				}
				
				if($control==2){
					$control=0;
				}else{
					$control++;	
				}				
			
			}
			$j++;
			}
			$write++;
			
			}
			
		}
    } else {
        echo '<tr><td width="100%" ><div align="center">No documents registered</div></td></tr>';       
    }
	
	if($tabla%2!=0){
		echo '<td></td></tr>';
	}
}

function fecha($fecha_ing){
	if(substr(substr($fecha_ing,5),0,2)=="01"){
		$dia=substr(substr($fecha_ing,8),0,2);
		$ano=substr($fecha_ing,0,4);
		$fechaing="Enero ".$dia." del ".$ano;
	}
	if(substr(substr($fecha_ing,5),0,2)=="02"){
		$dia=substr(substr($fecha_ing,8),0,2);
		$ano=substr($fecha_ing,0,4);
		$fechaing="Febrero ".$dia." del ".$ano;
	}
	if(substr(substr($fecha_ing,5),0,2)=="03"){
		$dia=substr(substr($fecha_ing,8),0,2);
		$ano=substr($fecha_ing,0,4);
		$fechaing="Marzo ".$dia." del ".$ano;
	}
	if(substr(substr($fecha_ing,5),0,2)=="04"){
		$dia=substr(substr($fecha_ing,8),0,2);
		$ano=substr($fecha_ing,0,4);
		$fechaing="Abril ".$dia." del ".$ano;
	}
	if(substr(substr($fecha_ing,5),0,2)=="05"){
		$dia=substr(substr($fecha_ing,8),0,2);
		$ano=substr($fecha_ing,0,4);
		$fechaing="Mayo ".$dia." del ".$ano;
	}
	if(substr(substr($fecha_ing,5),0,2)=="06"){
		$dia=substr(substr($fecha_ing,8),0,2);
		$ano=substr($fecha_ing,0,4);
		$fechaing="Junio ".$dia." del ".$ano;
	}
	if(substr(substr($fecha_ing,5),0,2)=="07"){
		$dia=substr(substr($fecha_ing,8),0,2);
		$ano=substr($fecha_ing,0,4);
		$fechaing="Julio ".$dia." del ".$ano;
	}
	if(substr(substr($fecha_ing,5),0,2)=="08"){
		$dia=substr(substr($fecha_ing,8),0,2);
		$ano=substr($fecha_ing,0,4);
		$fechaing="Agosto ".$dia." del ".$ano;
	}
	if(substr(substr($fecha_ing,5),0,2)=="09"){
		$dia=substr(substr($fecha_ing,8),0,2);
		$ano=substr($fecha_ing,0,4);
		$fechaing="Septiembre ".$dia." del ".$ano;
	}
	if(substr(substr($fecha_ing,5),0,2)=="10"){
		$dia=substr(substr($fecha_ing,8),0,2);
		$ano=substr($fecha_ing,0,4);
		$fechaing="Octubre ".$dia." del ".$ano;
	}
	if(substr(substr($fecha_ing,5),0,2)=="11"){
		$dia=substr(substr($fecha_ing,8),0,2);
		$ano=substr($fecha_ing,0,4);
		$fechaing="Noviembre ".$dia." del ".$ano;
	}
	if(substr(substr($fecha_ing,5),0,2)=="12"){
		$dia=substr(substr($fecha_ing,8),0,2);
		$ano=substr($fecha_ing,0,4);
		$fechaing="Diciembre ".$dia." del ".$ano;
	}
	return $fechaing;
}



///// Archivos Multiples

function getCarpetaDownload($id_usuario){
	$sql = "SELECT id FROM carpeta WHERE nivel=2 AND nombre='DOWNLOAD' AND id_usuario=$id_usuario ";
	$this->execute($sql);
	list($id_carpeta) = $this->fetchRow();
	return $id_carpeta;
}


function addFileMultipleUsers ($arrUsers,$nivel=2,$fecha_ing,$fecha_fin,$encabezado,$descripcion,$permiso,$adjunto1,$url1){
	if($url1!="none"){ 
		$response = NULL;
		list($success,$response) = $this->captureUpload('../docs/archivos/',false,'url1');						
		if(!$success) { 
			$msg = "archivo: ".$response;
			$this->mostrarMensaje($msg);
		}
	}
	for($i=0; $i<count($arrUsers); $i++){
		$id_carpeta_usuario = $this->getCarpetaDownload($arrUsers[$i]);
		//////Inicio////////////
		if($nivel==1){
			$sql = "SELECT id FROM documentos WHERE carpeta='$id' AND titulo='$encabezado'";
		}
		if($nivel==2){
			$sql = "SELECT id FROM documentos WHERE carpeta='$ids' AND titulo='$encabezado'";
		}
		if($nivel==3){
			$sql = "SELECT id FROM documentos WHERE carpeta='$idss' AND titulo='$encabezado'";
		}	
		if($nivel==4){
			$sql = "SELECT id FROM documentos WHERE carpeta='$idsss' AND titulo='$encabezado'";
		}	
		$this->execute($sql);
		$cant=$this->numRows();
		if($cant==0){	
			//$response = NULL;
			$sql = "INSERT INTO documentos (carpeta,fecha_ing,fecha_fin,titulo,texto,permiso) VALUES('$id_carpeta_usuario','$fecha_ing','$fecha_fin','$encabezado','$descripcion','$permiso')";
			
			if (!$this->execute($sql)) {
				$this->mostrarMensaje("Error: Document not saved.");
				$sql = '';
			} else {
				$sql = '';
				$msg = "Document Saved.\\n";						
				if($url1!="none"){ 
					$documento = mysql_insert_id();
					$hora = date('H:i:s',time());
					$sql2 = "INSERT INTO archivo (documento, titulo, fichero, hora) values('$documento'";
					$sql2.= ($adjunto1) ? ",'".$adjunto1."'": ", NULL";
					$sql2.= ($url1!= "none") ? ",'".$response."'": ", NULL";
					$sql2.= ", '".$hora."')";
					if(!$this->execute($sql2)){
					$msg.="File: ".$adjunto1." no Saved";
					}else{
						$msg.="File: ".$adjunto1." Saved!";
					}
				}
				//$this->mostrarMensaje($msg);
			}
		}else{
			$this->mostrarMensaje("Try with another Name.");
		}			
		//////Final/////////////
		//$this->add_documento( $nivel,$id_carpeta_usuario,$fecha_ing,$fecha_fin,$encabezado,$descripcion,$permiso,$adjunto1,$url1 );
	}
	$this->mostrarMensaje("The multiple users assignation has been done.");
	echo "<script>window.open(\"../index.php\",\"contenido\");</script>";
	
}

function addFileCommon($nivel=2,$fecha_ing,$fecha_fin,$encabezado,$descripcion,$permiso,$adjunto1,$url1){
	$sql = "SELECT c.id_usuario FROM carpeta c, usuario_web u WHERE c.nivel=2 AND c.nombre='DOWNLOAD' AND u.id = c.id_usuario";
	if ($this->execute($sql)){
		if ($this->numRows() > 0){
			$i=0;
			while (list($id_usuario)=$this->fetchRow()){
				$array[$i] = $id_usuario;
				$i++;
			}
			$this->addFileMultipleUsers ($array,$nivel=2,$fecha_ing,$fecha_fin,$encabezado,$descripcion,$permiso,$adjunto1,$url1);
		}
	}
	$this->mostrarMensaje("The multiple users assignation has been done.");
	echo "<script>window.open(\"../index.php\",\"contenido\");</script>";
}



function add_documento($nivel=2,$id_carpeta_usuario,$fecha_ing,$fecha_fin,$encabezado,$descripcion,$permiso,$adjunto1,$url1){
	if($nivel==1){
		$sql = "SELECT id FROM documentos WHERE carpeta='$id' AND titulo='$encabezado'";
	}
	if($nivel==2){
		$sql = "SELECT id FROM documentos WHERE carpeta='$ids' AND titulo='$encabezado'";
	}
	if($nivel==3){
		$sql = "SELECT id FROM documentos WHERE carpeta='$idss' AND titulo='$encabezado'";
	}	
	if($nivel==4){
		$sql = "SELECT id FROM documentos WHERE carpeta='$idsss' AND titulo='$encabezado'";
	}	
	$this->execute($sql);
	$cant=$this->numRows();
	if($cant==0){	
	
		$response = NULL;
		
		$sql = "INSERT INTO documentos (carpeta,fecha_ing,fecha_fin,titulo,texto,permiso) VALUES('$id_carpeta_usuario','$fecha_ing','$fecha_fin','$encabezado','$descripcion','$permiso')";
		
		if (!$this->execute($sql)) {
			$this->mostrarMensaje("Error: Document not saved.");
		} else {
			$msg = "Document Saved.\\n";						
			if($url1!="none"){ 
				//se sube el fichero al servidor
				list($success,$response) = $this->captureUpload('../docs/archivos/',false,'url1');						
				if(!$success) { 
					$msg = "archivo: ".$response;
					$this->mostrarMensaje($msg);
				}
				//sql para registrar fichero en la DB
				$documento = mysql_insert_id();
				
				$hora = date('H:i:s',time());
			
				$sql2 = "INSERT INTO archivo (documento, titulo, fichero, hora) values('$documento'";
										
				$sql2.= ($adjunto1) ? ",'".$adjunto1."'": ", NULL";
				$sql2.= ($url1!= "none") ? ",'".$response."'": ", NULL";
				$sql2.= ", '".$hora."')";
				if(!$this->execute($sql2)){
				$msg.="File: ".$adjunto1." no Saved";
				}else{
					$msg.="File: ".$adjunto1." Saved!";
				}
			}
			//$this->mostrarMensaje($msg);
		}
	}else{
		$this->mostrarMensaje("Try with another Name.");
	}			

}



/*cargar archivo*/
function captureUpload($destDir,$nameCallback = false,$fieldName = '_upload',$maxFileSize = false){
   //make sure something is there
   if(!isset($_FILES[$fieldName]) || !isset($_FILES)|| !is_array($_FILES[$fieldName]) || !$_FILES[$fieldName]['name'])
       return array(false,"El formulario no tiene la etiqueta enctype=\"multipart/form-data\"");
   //normalize the file variable
   $file = $_FILES[$fieldName];
   if (!isset($file['type']))      $file['type']      = '';
   if (!isset($file['size']))      $file['size']      = '';
   if (!isset($file['tmp_name']))  $file['tmp_name']  = '';
   $file['name'] = preg_replace('/[^a-zA-Z0-9\.\$\%\'\`\-\@\{\}\~\!\#\(\)\&\_\^]/','',str_replace(array(' ','%20'),array('_','_'),$file['name']));
   //was it to big?
   if($maxFileSize && ($file['size'] > $maxFileSize))
       return array(false,"El tama�o del archivo es muy grande");
   //normalize destDir
   if(strlen($destDir)>0 && $destDir[strlen($destDir)-1] != "/")
       $destDir = $destDir.'/';
   //should we change the filename via a callback?
   if($nameCallback)
       $file['name'] = call_user_func_array($nameCallback, array($file,$destDir));
   $i = 0;    
   //if the filename already exists, append _copy_x (with extension)
   if(strpos($file['name'],'.') !== false){
       $bits = explode('.',$file['name']);
       $ext = array_pop($bits);
       while(file_exists($destDir.implode('.', $bits).($i?'_copy_'.$i:'').'.'.$ext)){
           ++$i;
           $file['name'] = implode('.',$bits).($i?'_copy_'.$i:'').'.'.$ext;
       }
   //if the filename already exists, append _copy_x (no extension)
   } else {
       while(file_exists($destDir.$file['name'].($i ?'_copy_'.$i:''))){
           ++$i;
           $file['name'] = $file['name'].($i?'_copy_'.$i:'');
       }
   }
   //and now the big moment
   if(!@copy($file['tmp_name'], $destDir.$file['name']))
       return array(false,"Permission denied to copy the file");
   else
       return array(true,$file['name']);
} 


function listadoUsuariosDownload(){
	$sql = "SELECT c.id_usuario FROM carpeta c, usuario_web u WHERE c.nivel=2 AND c.nombre='DOWNLOAD' AND u.id = c.id_usuario ORDER BY u.nombres";
	if ($this->execute($sql)){
		if ($this->numRows() > 0){
			echo '<table class="texto1" border="1" cellpadding="0" cellspacing="0" width="530px">';
			echo '<tr align="center"> <td><b>Name</b></td> <td><b>Second Name</b></td> <td><b>User</b></td> <td><b>Select <br> <input type="checkbox" name="alldays" value="checkbox" onclick=dayGroup.check(this)  /> <br>(All)</b></td> </tr>';
			$i=0;
			while (list($id_usuario)=$this->fetchRow()){
				$user=$this->getUsuario($id_usuario);
				echo '<tr> <td>'.strtoupper($user['nombres']).'</b></td> <td>'.strtoupper($user['apellidos']).'</b></td>  <td>'.strtoupper($user['login']).'</b></td>  <td align="center"><input type="checkbox" name="day" value="'.$id_usuario.'" onclick=dayGroup.check(this)  /> </td> </tr>';
				$i++;
			}
			echo '</table>';
		}
	}
}



function getUsuario($id){
	$db = new DBManager('MySql');
	$db->connect();
		
	$sql="select * from usuario_web where id='$id'";
	
	if ($db->execute($sql)) {
		if($db->numRows()>0){
			return $db->fetchRow();
		}else{
			$out=$this->getMensaje("[027]","confirmacion");
			$this->setSalida(false,$out,"getUsuario($campo,$valor)",$this->aplicacion);
			return false;
		}		
	} else {
		$out=trim($this->getMensaje("[017]","error"));
		$out.="\\n:Desc: ".trim($this->getException());
		$this->setSalida(false,$out,"getUsuario($campo,$valor)",$this->aplicacion);
		return false;
	}	
	
}


}
?>

Anon7 - 2021