Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/07/2005, 13:53
Suyta
(Desactivado)
 
Fecha de Ingreso: septiembre-2004
Mensajes: 360
Antigüedad: 19 años, 7 meses
Puntos: 1
Paginator y sumas parciales

Hola JPINEDO

Es un poco largo pero si no pego el código no sé cómo explicarte el problema.
Tengo esto que logré con ayuda de Uds. y me falta adaptarlo para que funcione ok con tu Paginator. Lo que hago es ir sumando resultados parciales pero al paginarlos vuelve a '0' y arranca de nuevo... no sé cómo hacer para que arrastre el saldo anterior.
Código PHP:
//de aquí para arriba es la parte de variables de sesión y header.html que no vienen al caso
if(isset($_POST['from_date'])){
   $dia_in = $_POST['from_date'];
}else{
   $dia_in = $_GET['from_date'];
}
if(isset($_POST['to_date'])){
   $dia_fin = $_POST['to_date'];
}else{
   $dia_fin = $_GET['to_date'];
}
if(isset($_POST['from_month'])){
   $mes_in = $_POST['from_month'];
}else{
   $mes_in = $_GET['from_month'];
}
if(isset($_POST['to_month'])){
   $mes_fin = $_POST['to_month'];
}else{
   $mes_fin = $_GET['to_month'];
}
if(isset($_POST['from_year'])){
   $ano_in = $_POST['from_year'];
}else{
   $ano_in = $_GET['from_year'];
}
if(isset($_POST['to_year'])){
   $ano_fin = $_POST['to_year'];
}else{
   $ano_fin = $_GET['to_year'];
}
//hago mi consulta para saber cantidad de fees
$form_date1=$mes_in."/".$dia_in."/".$ano_in;
$form_date2=$mes_fin."/".$dia_fin."/".$ano_fin;
$convert1=mktime(0, 0, 0, $mes_in, $dia_in, $ano_in);
$convert2=mktime(23, 59, 59, $mes_fin, $dia_fin, $ano_fin);
$sqlalt="SELECT SUM(trans_fee) AS TOTAL_FEES, COUNT(trans_fee) AS NUMBER_FEES FROM transactions WHERE timestamp>=$convert1 AND timestamp<=$convert2 AND trans_fee>0 ORDER BY timestamp desc";
$resultalt = mysql_query($sqlalt, $con) or die("error en consulta <b>$con</b> :".mysql_error());
if ($row= mysql_fetch_array($resultalt))
{
$tot=$row['TOTAL_FEES'];
$num=$row['NUMBER_FEES'];
/* Liberar conjunto de resultados */
mysql_free_result($resultalt);

/* Cerrar la conexion */
mysql_close($con);
?>
<?php
//consulta para listar fees por fechas
include("config_alter.php");
if(isset(
$_POST['from_date'])){
   
$dia_in $_POST['from_date'];
}else{
   
$dia_in $_GET['from_date'];
}
if(isset(
$_POST['to_date'])){
   
$dia_fin $_POST['to_date'];
}else{
   
$dia_fin $_GET['to_date'];
}
if(isset(
$_POST['from_month'])){
   
$mes_in $_POST['from_month'];
}else{
   
$mes_in $_GET['from_month'];
}
if(isset(
$_POST['to_month'])){
   
$mes_fin $_POST['to_month'];
}else{
   
$mes_fin $_GET['to_month'];
}
if(isset(
$_POST['from_year'])){
   
$ano_in $_POST['from_year'];
}else{
   
$ano_in $_GET['from_year'];
}
if(isset(
$_POST['to_year'])){
   
$ano_fin $_POST['to_year'];
}else{
   
$ano_fin $_GET['to_year'];
}
$form_date1=$mes_in."/".$dia_in."/".$ano_in;
$form_date2=$mes_fin."/".$dia_fin."/".$ano_fin;
$convert1=mktime(000$mes_in$dia_in$ano_in);
$convert2=mktime(235959$mes_fin$dia_fin$ano_fin);

$_pagi_sql=("SELECT trans_fee AS FEE, timestamp AS DATETIME, status AS STATUS FROM transactions WHERE timestamp>=$convert1 AND timestamp<=$convert2 AND trans_fee>0 ORDER BY timestamp DESC ");
//Incluimos el script de paginación. Éste ya ejecuta la consulta
include("paginator.inc.php");
if (
$rowmysql_fetch_array($_pagi_result))
{
  
$fee=$row['FEE'];
  
$status=$row['STATUS'];
  
$i=0;
  
$buffer=0;
/* Impresion de resultados en HTML */
   
echo "<BR><br><center><strong>Commissions Details  $form_date1 - $form_date2<br><br></center></strong>";
   echo 
"<center><TABLE BORDER='1'>\n";
   echo 
"<TR BGCOLOR='e6e6e6'><TD><center><strong><small><small>DATETIME</small></small></center></TD><TD><center><strong><small><small>COMMISSION</small></small></center></TD><TD><center><strong><small><small>PARTIAL SUMS</small></small></center></strong></TD><TD><center><strong><small><small>STATUS</small></small></center></strong></TD></TR>";
DO
   {
     
$time =getdate($row['DATETIME']);
            
$time $time['mon']."/".$time['mday']."/".$time['year']."&nbsp;&nbsp;".$time['hours'].":".$time['minutes'].":".$time['seconds'];
            if(
$status=='1')
            {
                
$stat="Completed";
            }
            elseif(
$status=='0')
            {
                
$stat="Pending";
            }
  
$buffer+=$row['FEE'];
  
$subtotales["$i"]=$buffer;
  
$i++;
   echo 
"<TR><TD><small><small>".$time."</small></small></TD><TD align='right'><small><small>".$row["FEE"]."</small></small></TD><TD align='right'><small><small>".number_format($buffer,2,".",",")."</small></small></TD><TD align='right'><small><small>".$stat."</small></small></TD></TR>";
   }
   WHILE (
$row=mysql_fetch_array($_pagi_result));
   echo 
"\t</tr>\n";
   echo 
"</TABLE>";
   echo 
"<br><center><strong>Total Quantity: $num - Total Amount: $ $buffer</center></strong>";
echo 
"<br>";
 
//echo "Records on this page: ".mysql_num_rows($_pagi_result);
//Incluimos la barra de navegación
echo"<p>".$_pagi_navegacion."</p>";
echo
"<p>".$_pagi_info."</p>";
echo 
"<br><center><strong><a href='form_viewfees.php'>View Commissions by Date </a><br>";
echo 
"<center><strong><a href='viewallfees.php'>View All Commissions</a><br><br><br><br>";
}
else{
echo 
"<strong><big><center><br><br><br>No fees in this period</big></center></strong>";
echo 
"<center><strong><a href='form_viewfees.php'>Back </a><br><br><br><br>";
}
}
?>
No se rían mucho de mi codiguito
Alguna ayudita ?