<? 
require("../conectar.php");
$empid=array();
$empnom=array();
$sql="SELECT d.id, d.descripcion,sb.id_subdir,sb.descripcion as dessub  FROM `directorios` as d,subdirectorios as sb WHERE d.id=sb.id_directorio and d.`borrar` <>'1' AND sb.borrar<>'1'  AND d.descripcion<>''  ORDER BY RAND() ";
$query=mysql_query($sql);
$sql="SELECT e.id_empleado,e.nombre, e.email2 FROM empleados as e WHERE e.fechabaja='0000-00-00' and puesto IN (4,5)"; 
$emp=mysql_query($sql);
$numemp=mysql_num_rows($emp);
while($emp1=mysql_fetch_array($emp))
	{
	$empid[]=$emp1["id_empleado"];
	$empnom[]=$emp1["nombre"];
	$empmail.=$emp1["email2"].",";
	}
$numpag=mysql_num_rows($query);
$numpaginas=round(($numpag/$numemp),0);
$tabla="<body><p>Buen d&iacute;a, esta es la lista de p&aacute;ginas en donde deben publicar sus anuncios el d&iacute;a de hoy saludos. Sistemas</p><div class='datagrid'><table>";
$cont2=0;
$inc=1;
while($e=mysql_fetch_array($query))
{
$quitar =base64_encode($e["id"]);
$quitarsub =base64_encode($e["id_subdir"]);
$pagina=base64_encode($e["descripcion"]);
if($cont==0)$tabla.="<tr><th colspan='3'>".$empnom[$cont2]."</td></tr><th align='center'><font color='orange'>No</font></th><th align=''><font color='orange'>Pagina</font></th><th align=''><font color='orange'>Categoria</font></th><tr></tr>";
$cont++;
$tabla.="<tr><td align='center'>".$inc."</td><td><a href='http://www.mexicoenrenta.com.mx/quitarpagina.php?id=$quitar'>".$e["descripcion"]."</a></td><td><a href='http://www.mexicoenrenta.com.mx/quitarsubdirectorio.php?id=$quitarsub&pagdir=$pagina'>".$e["dessub"]."</a></td></tr>";
$sql="INSERT INTO rollanuncios (idemp,iddir,fecha,idsub) VALUES ('".$empid[$cont2]."','".$e["id"]."',CURDATE(),'".$e["id_subdir"]."')";
mysql_query($sql);
$inc++;
if($cont==$numpaginas){$tabla.="</table></div><div class='datagrid'><table>"; $inc=1;$cont=0;$cont2++;}
}
$tabla.="</table></div></body>";
$cabecera="<html><head><style>
	.datagrid
		{
		display:inline-block; 
		margin:5px;
		font: normal 12px/150% Arial, Helvetica, sans-serif; 
		-webkit-border-top-left-radius: 6px;
		-webkit-border-top-right-radius: 6px;
		-moz-border-radius-topleft: 6px;
		-moz-border-radius-topright: 6px;
		border-top-left-radius: 6px;
		border-top-right-radius: 6px;
		border: 1px solid #00557F;
		}
		.datagrid table
		{
		display:inline; 
		border-collapse:collapse;
		width: 150px;
		-webkit-border-top-left-radius: 5px;
		-webkit-border-top-right-radius: 5px;
		-moz-border-radius-topleft: 5px;
		-moz-border-radius-topright: 5px;
		border-top-left-radius: 5px;
		border-top-right-radius: 5px;
		}
	.datagrid table tr th 
		{
		-webkit-border-top-left-radius: 5px;
		-webkit-border-top-right-radius: 5px;
		-moz-border-radius-topleft: 5px;
		-moz-border-radius-topright: 5px;
		border-top-left-radius: 5px;
		border-top-right-radius: 5px;
		text-align: center; 
		background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #006699), color-stop(1, #00557F) );
		background:-moz-linear-gradient( center top, #006699 5%, #00557F 100% );filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#006699', endColorstr='#00557F');
		background-color:#006699; 
		color:#FFFFFF; 
		font-size: 15px;
		font-weight: bold;  
		} 
	.datagrid table tr td 
		{
		border-bottom: 1px solid #00557F;
		-webkit-border-radius: 5px; 
		-moz-border-radius: 5px; 
		border-radius: 5px;	
		text-align: left;  
		color: #00557F;
		font-size: 12px;
		font-weight: normal; 
		}
	</style></head>";
	 $tabla;
	 $from="turisiscom@hotmail.com";
	 $destinatario=$empmail."gerenciamexrent@mexicoenrenta.com.mx"; 
     $asunto ="Roll de anuncios ".date("Y-m-d"); 
     $cuerpo =$cabecera.$tabla;
     $headers = "MIME-Version: 1.0\r\n"; 
     $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
     $headers .= "From: $from\r\n"; 
     $headers .= "Reply-To: turisiscom@hotmail.com\r\n"; 
     $headers .= "Return-path: turisiscom@hotmail.com\r\n";  
     $headers .= "Cc: turisiscom@hotmail.com,gerenciamexrent@mexicoenrenta.com.mx\r\n"; 
mail($destinatario,$asunto,$cuerpo,$headers); 
?>