Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/02/2013, 12:26
Avatar de jandrogdz
jandrogdz
 
Fecha de Ingreso: julio-2012
Ubicación: public $Guadalajara
Mensajes: 397
Antigüedad: 11 años, 9 meses
Puntos: 12
Pregunta Problema al mostrar datos de una query

Buenas foro

Tengo un problema al mostrar los datos de una consulta, probandola en phpMyAdmin funciona correctamente pero al generarla en php no funciona esto es lo que tengo:

Código PHP:
Ver original
  1. $opciones=array(
  2.     'desde'=>$_GET['desde'],
  3.     'hasta'=>$_GET['hasta'],
  4.     'cliente'=>$_GET['cliente'],
  5.     'asociado'=>$_REQUEST['asociado'],
  6.     'status'=>$_REQUEST['status']
  7.     );
  8.  
  9. <table width="100%" cellpadding="0" cellspacing="0">
  10.       <thead>
  11.         <tr>
  12.             <th>Folio</th>
  13.             <th>Fecha</th>
  14.             <th>Cliente</th>
  15.             <th>Asociado</th>
  16.             <th>Subtotal</th>
  17.             <th>Impuestos</th>
  18.             <th>Total</th>
  19.             <th>Status</th>
  20.         </tr>
  21.        </thead>
  22. <?php
  23.  if($filtrado=$reportes->clientes($opciones,$RegistrosAEmpezar,$RegistrosAMostrar)):
  24.        foreach($filtrado as $filtro): ?>
  25.        <tbody>
  26.             <tr>
  27.                 <td><?php echo $filtro->folio; ?></td>
  28.                 <td><?php echo $filtro->fecha; ?></td>
  29.                 <td><?php echo $filtro->cliente; ?></td>
  30.                 <td><?php echo $filtro->nombreAsociado; ?></td>
  31.                 <td><?php echo "$ ".number_format($filtro->subtotaFactura,2,'.',','); ?></td>
  32.                 <td><?php echo "$ ".number_format($filtro->ivaFactura,2,'.',','); ?></td>
  33.                 <td><?php echo "$ ".number_format($filtro->totalFactura,2,'.',','); ?></td>
  34.                 <td><?php echo $filtro->status; ?></td>
  35.             </tr>  
  36.        </tbody>
  37.  <?php endforeach;
  38.  else:
  39.     var_dump($reportes->clientes($opciones,$RegistrosAEmpezar,$RegistrosAMostrar));
  40.  endif; ?>
  41.        <tfoot>
  42.             <tr>
  43.                 <td colspan="6">&nbsp;</td>
  44.                 <td></td>
  45.             </tr>
  46.        </tfoot>
  47. </table>


Y estas son las funciones:


Código PHP:
Ver original
  1. public function clientes($opciones,$RegistrosAEmpezar,$RegistrosAMostrar){
  2.    $where=$this->datosFiltro($opciones);
  3.         $query="SELECT c.cliente,f.folio,f.fecha,f.subtotaFactura,f.ivaFactura,f.totalFactura,a.nombreAsociado,f.status
  4. SUM(CASE WHEN MONTH( f.fecha ) = 1 THEN totalFactura ELSE 0 END) AS Enero,
  5. SUM(CASE WHEN MONTH( f.fecha ) = 2 THEN totalFactura ELSE 0 END) AS Febrero,
  6. SUM(CASE WHEN MONTH( f.fecha ) = 3 THEN totalFactura ELSE 0 END) AS Marzo,
  7. SUM(CASE WHEN MONTH( f.fecha ) = 4 THEN totalFactura ELSE 0 END) AS Abril,
  8. SUM(CASE WHEN MONTH( f.fecha ) = 5 THEN totalFactura ELSE 0 END) AS Marzo,
  9. SUM(CASE WHEN MONTH( f.fecha ) = 6 THEN totalFactura ELSE 0 END) AS Junio,
  10. SUM(CASE WHEN MONTH( f.fecha ) = 7 THEN totalFactura ELSE 0 END) AS Julio,
  11. SUM(CASE WHEN MONTH( f.fecha ) = 8 THEN totalFactura ELSE 0 END) AS Agosto,
  12. SUM(CASE WHEN MONTH( f.fecha ) = 9 THEN totalFactura ELSE 0 END) AS Septiembre,
  13. SUM(CASE WHEN MONTH( f.fecha ) = 10 THEN totalFactura ELSE 0 END) AS Octubre,
  14. SUM(CASE WHEN MONTH( f.fecha ) = 11 THEN totalFactura ELSE 0 END) AS Noviembre,
  15. SUM(CASE WHEN MONTH( f.fecha ) = 12 THEN totalFactura ELSE 0 END) AS Diciembre,
  16. SUM( f.totalFactura ) AS totalgral
  17. FROM factura AS f JOIN  cliente AS c ON f.clienteID = c.clienteID JOIN asociado AS a ON c.asociadoID=a.asociadoID ".$where." GROUP BY c.cliente WITH ROLLUP LIMIT $RegistrosAEmpezar, $RegistrosAMostrar";
  18.    }
  19.  
  20.  
  21. public function datosFiltro($opciones){
  22.         $q = "";
  23.         $bandera = true;
  24.         if(isset($opciones['desde']) && $opciones['desde'] != '' && isset($opciones['hasta']) && $opciones['hasta'] != ''):
  25.             $q .= ($bandera)?" WHERE f.fecha BETWEEN '".$opciones['desde']."' AND '".$opciones['hasta']."'" : " AND f.fecha BETWEEN '".$opciones['desde']."' AND '".$opciones['hasta']."'";
  26.             $bandera = false;
  27.         endif;
  28.         if(isset($opciones['cliente']) && $opciones['cliente'] != ''):
  29.             $q .= ($bandera)?" WHERE c.cliente = '".$opciones['cliente']."'" : " AND c.cliente = '".$opciones['cliente']."'" ;
  30.             $bandera = false;
  31.         endif;
  32.         if(isset($opciones['asociado']) && $opciones['asociado'] != ''):
  33.             $q .= ($bandera)?" WHERE a.asociadoID = '".$opciones['asociado']."'" : " AND a.asociadoID = '".$opciones['asociado']."'" ;
  34.             $bandera = false;
  35.         endif;
  36.         if(isset($opciones['status']) && $opciones['status'] != ''):
  37.             $q .= ($bandera)?" WHERE f.status = '".$opciones['status']."'" : " AND f.status = '".$opciones['status']."'" ;
  38.             $bandera = false;
  39.         endif;
  40.         return $q;
  41.     }

De antemano muchas gracias...
__________________
Lo imposible solo cuesta un poco mas