Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/11/2010, 11:35
Avatar de Oviedo
Oviedo
 
Fecha de Ingreso: abril-2007
Ubicación: Venezuela
Mensajes: 128
Antigüedad: 17 años
Puntos: 0
Pregunta Mostrar reporte php

Amigos auxilio lo mio es facil de explicar, tengo un codigo que ejecuta un select perfectamente para darme un reporte en word y efectivamente lo hace.. pero quiero saber como puedo organizar la salida de esta manera.....

Asi aparecen los registros en la hoja (actualmente "tabla"):

----------------------------------------------------------
---------------------------------------------------------
---------------------------------------------------------
--------------------------------------------------------

Los quiero asi:

--------------------------- -------------------------------
----------------------------- ----------------------------
----------------------------- -------------------------
------------------------------ --------------------------

Osea dividir la hoja en dos parte que en vez de tener dos hojas tenga una sola en dos partes... auxiliooooo.... este es el codigo:

<?
header('Content-type: application/msword');
header('Content-Disposition: inline; filename=Reporte_Asignacion'.date("d/m/Y").'.xls');
include("../../../../conex/conectar.php");
conectar();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</style>
<title>ASODIAM</title>
</head>
<body>
<p><?php
$dia = time()-(1*24*60*60);
$plun = date('d-m-Y', $dia);
$plum = date('d-m-Y');
$sql="
SELECT DISTINCT
TBL_Estudios.nro_op, TBL_Estudios.unidad, TBL_Estudios.numero, TBL_Estudios.fecha, TBL_Estudios.hora, TBL_Estudios.cedula,
TBL_Estudios.nombre, TBL_Estudios.apellido, TBL_Estudios.codigo_estudio, TBL_Estudios.estudio, TBL_Estudios.equipo, TBL_Estudios.tarifa,
TBL_Estudios.precio, TBL_Estudios.descuento, TBL_Estudios.si_listo, TBL_Estudios.medico, TBL_Estudios.tecnico, TBL_Equipos.nombre AS Expr2,
TBL_Medicos.nombre AS Expr1, TBL_Tecnicos.nombre AS Expr4, TBL_Honorarios.tipo, TBL_Honorarios.medtec, TBL_Honorarios.monto1,
TBL_Honorarios.monto2, TBL_Honorarios.monto3, TBL_Honorarios.monto4
FROM TBL_Estudios INNER JOIN
TBL_Equipos ON TBL_Estudios.equipo = TBL_Equipos.codigo INNER JOIN
TBL_Tecnicos ON TBL_Estudios.tecnico = TBL_Tecnicos.codigo INNER JOIN
TBL_Honorarios ON TBL_Estudios.codigo_estudio = TBL_Honorarios.codigo AND TBL_Estudios.medico = TBL_Honorarios.medtec INNER JOIN
TBL_Medicos ON TBL_Honorarios.medtec = TBL_Medicos.codigo WHERE ( TBL_Honorarios.tipo='M')";


if (($equipo=="")and($medico=="")and($fd=="")and($fh= ="")) {
$sql .= "and (fecha >='$plun') AND (fecha <='$plum')ORDER BY TBL_Medicos.nombre,TBL_Estudios.equipo,TBL_Estudio s.estudio";
}

if (($equipo=="")and($medico!="")and($fd=="")and($fh= ="")) {
$sql .= "and ( TBL_Honorarios.medtec='$medico') AND (TBL_Estudios.medico = '$medico') ORDER BY TBL_Medicos.nombre,TBL_Estudios.equipo,TBL_Estudio s.estudio ";
}
if (($equipo!="")and($medico=="")and($fd=="")and($fh= ="")) {
$sql .= "and ( TBL_Estudios.equipo='$equipo') ORDER BY TBL_Medicos.nombre,TBL_Estudios.equipo,TBL_Estudio s.estudio ";
}
if (($equipo!="")and($medico!="")and($fd=="")and($fh= ="")) {
$sql .= "and ( TBL_Estudios.equipo='$equipo') and ( TBL_Honorarios.medtec='$medico')AND (TBL_Estudios.medico = '$medico') ORDER BY TBL_Medicos.nombre,TBL_Estudios.equipo,TBL_Estudio s.estudio ";
}

if (($equipo=="")and($medico=="")and($fd!="")and($fh! ="")) {
$sql .= "and (fecha >='$fd') AND (fecha <='$fh')ORDER BY TBL_Medicos.nombre,TBL_Estudios.equipo,TBL_Estudio s.estudio";
}
if (($equipo=="")and($medico!="")and($fd!="")and($fh! ="")) {
$sql .= "and (fecha >='$fd') AND (fecha <='$fh') and ( TBL_Honorarios.medtec='$medico') AND (TBL_Estudios.medico = '$medico')ORDER BY TBL_Medicos.nombre,TBL_Estudios.equipo,TBL_Estudio s.estudio ";
}
if (($equipo!="")and($medico=="")and($fd!="")and($fh! ="")) {
$sql .= "and (fecha >='$fd') AND (fecha <='$fh') and ( TBL_Estudios.equipo='$equipo') ORDER BY TBL_Medicos.nombre,TBL_Estudios.equipo,TBL_Estudio s.estudio ";
}
if (($equipo!="")and($medico!="")and($fd!="")and($fh! ="")) {
$sql .= "and (fecha >='$fd') AND (fecha <='$fh') and ( TBL_Estudios.equipo='$equipo') and ( TBL_Honorarios.medtec='$medico')AND (TBL_Estudios.medico = '$medico') ORDER BY TBL_Medicos.nombre,TBL_Estudios.equipo,TBL_Estudio s.estudio ";
}

//die($sql);
$resultado=mssql_query($sql);
$cantidad=mssql_num_rows($resultado);
$fecha=""; //VARIABLE RECOMENDADA ANTES DEL BUCLE
$primeratabla=1;
?><!-----------------------------TABLA-------------------------------------------->
<a href="reporte_asignacion_direccion_m.php"></a></p>
<form action="" method="post" name="frm" >
<table align="center" cellspacing="0" cellpadding="0" border="1" width="85%">
<tr bgcolor="#006699">
<td><div align="center" class="Estilo18 Estilo17"><font color="white">FECHA</font></div></td>
<td><div align="center" class="Estilo18 Estilo17"><font color="white">FICHA</font></div></td>
<td><div align="center" class="Estilo18 Estilo17"><font color="white">CÉDULA</font></div></td>
<td><div align="center" class="Estilo18 Estilo17"><font color="white">NOMBRE</font></div></td>
<td><div align="center" class="Estilo18 Estilo17"><font color="white">APELLIDO</font></div></td>
<td><div align="center" class="Estilo18"><font color="white">CODIGO</font></div></td>
<td><div align="center" class="Estilo18 Estilo17"><font color="white">ESTUDIO</font></div></td>
<td><div align="center" class="Estilo18 Estilo17"><font color="white">EQUIPO</font></div></td>
<td><div align="center" class="Estilo18 Estilo17"><font color="white">MEDICO</font></div></td>
<td><div align="center" class="Estilo18 Estilo17"><font color="white">MONTO</font></div></td>
<td><div align="center" class="Estilo18 Estilo17"><font color="white">CANT.</font></div></td>
<?php
while ($registro= mssql_fetch_array ($resultado)) {
if ($fecha!=$registro["9"]) {
$fecha=$registro["9"];
$total=0;
$nro_fila=0;
?>
<?php
} // Fin MOSTRAR CABECERA
$total= $nro_fila;
?>
</tr>
<tr bgcolor="<?php if ($nro_fila%2!=0) echo "#F2F2F2"; else echo "#FFFFFF"; ?>"
onmouseout="this.style.backgroundColor='<?php if ($nro_fila%2!=0) echo "#F2F2F2"; else echo "#FFFFFF" ?>'"o="o""];">
<td width="94" height="20"><div align="center" class="Estilo17"><font face="Tahoma" color="#000000"><? echo $registro["3"]; ?></font></div></td>
<td width="94"><div align="center" class="Estilo17"><font face="Tahoma" color="#000000"><? echo $registro["2"]; ?></font></div></td>
<td width="71"><div align="center" class="Estilo17"><font face="Tahoma" color="#000000"><? echo $registro["5"]; ?></font></div></td>
<td width="110"><div align="center" class="Estilo17"><font face="Tahoma" color="#000000"><? echo $registro["6"]; ?></font></div></td>
<td width="100"><div align="center" class="Estilo17"><font face="Tahoma" color="#000000"><? echo $registro["7"]; ?></font></div></td>
<td width="59"><div align="center" class="Estilo17"><font face="Tahoma" color="#000000"><? echo $registro["8"]; ?></font></div></td>
<td width="143"><div align="center" class="Estilo17"><font face="Tahoma" color="#000000"><? echo $registro["9"]; ?></font></div></td>
<td width="99"><div align="center" class="Estilo17"><font face="Tahoma" color="#000000"><? echo $registro["17"]; ?></font></div></td>
<td width="119"><div align="center" class="Estilo17"><font face="Tahoma" color="#000000"><? echo $registro["18"]; ?></font></div></td>
<td width="72"><div align="center" class="Estilo17"><font face="Tahoma" color="#000000"><?
if (($registro["11"]=='A') or ($registro["11"]=='C')){
$calculo=$registro["22"];

echo $calculo;
}else{

$calculo=$registro["23"];
echo $calculo;
}
?></font></div></td>

<td width="61"><div align="center" class="Estilo17"><font face="Tahoma" color="#000000"><? echo $total+1; ?></font></div></td>
</tr>
<?php
//$suma+=number_format($registro["monto"],2);
// $fin+=number_format($calculo,2);
$fin+=$calculo;
$nro_fila++;
} // fin del while

mssql_free_result ($resultado);//Liberar Memorias

echo "<td colspan='9'><div align='center'>TOTALES</div></td>";
echo "<td><div align='center'>"; echo $fin ;echo "</div></td>";
echo "<td><div align='center'>"; echo $cantidad;echo "</div></td>";

?></table>



<p>&nbsp;</p>
<table width="1492" height="193" border="0" cellpadding="0">
<tr>
<td width="205" height="189">&nbsp;</td>
<td width="101">&nbsp;</td>
<td width="101">&nbsp;</td>
<td width="101">&nbsp;</td>
<td width="101">&nbsp;</td>
<td width="101">&nbsp;</td>
<td width="101">&nbsp;</td>
<td width="32">&nbsp;</td>
<td width="526"><table width="498" border="1" cellpadding="0">
<tr>
<td width="490">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table></td>
</tr>
</table>
</form>