Foros del Web » Programando para Internet » PHP »

Cambiar color celda FPDF

Estas en el tema de Cambiar color celda FPDF en el foro de PHP en Foros del Web. Estimados, Quisiera que me ayudaran, resulta que programe en php una tabla que según cierta variable cambia de color una fila y funciona a la ...
  #1 (permalink)  
Antiguo 04/10/2016, 13:29
Avatar de p5ych0  
Fecha de Ingreso: julio-2010
Mensajes: 11
Antigüedad: 13 años, 9 meses
Puntos: 0
Pregunta Cambiar color celda FPDF

Estimados,

Quisiera que me ayudaran, resulta que programe en php una tabla que según cierta variable cambia de color una fila y funciona a la perfección pero me gustaría realizar lo mismo con FPDF.

PHP:

Código PHP:
Ver original
  1. if (is_array($lista[0])){
  2.         foreach($lista as $i => $rows){
  3.            
  4.         $prioridad_color = array(  
  5.             1 => '#F00',  
  6.             0 => '#FFF'  
  7.          );  
  8.    
  9.    
  10.             echo "<tr bgcolor='".$prioridad_color[$rows["ANULAR_PAGO"]]."'>";
  11.            
  12.                 echo "<td>";
  13.                 echo $rows["TIPO_PAGO"];
  14.                 echo "</td>";
  15.                 echo "<td>";
  16.                 echo $rows["DEPOSITO_PAGO"];
  17.                 echo "</td>";
  18.                 echo "<td>";
  19.                 echo $rows["BANCODEPOSITO_PAGO"];
  20.                 echo "</td>";
  21.                 echo "<td>";
  22.                 echo $rows["SERIECHEQUE_PAGO"];
  23.                 echo "</td>";
  24.                 echo "<td>";
  25.                 echo $rows["BANCOEMISOR_PAGO"];
  26.                 echo "</td>";  
  27.                 echo "<td>";
  28.                 echo $rows["NCUENTA_PAGO"];
  29.                 echo "</td>";  
  30.                 echo "<td>";
  31.                 echo $rows["RECIBOINTERNO_PAGO"];
  32.                 echo "</td>";
  33.                 echo "<td>";
  34.                 echo $rows["DIRECCION_PROPIEDAD"];
  35.                 echo "</td>";
  36.                 echo "<td>";
  37.                 echo $rows["NOMBRE_ARRENDATARIO"];
  38.                 echo "</td>";
  39.                 echo "<td>";
  40.                 echo number_format($rows["MONTO_PAGO"], 0, ',', '.');
  41.                 echo "</td>";              
  42.             echo "</tr>";  
  43.        
  44.         }
  45.     }




en FPDF tengo lo siguiente:

Código PHP:
Ver original
  1. $this->pdf->SetFont('Arial','',8);
  2.         $this->pdf->Cell(0,3,'',0,1,'C');
  3.         $this->pdf->Cell(23,5,'Forma de Pago',1,0,'C',1);  
  4.         $this->pdf->Cell(19,5,'Nº Deposito',1,0,'C',1);
  5.         $this->pdf->Cell(21,5,'Banco Deposito',1,0,'C',1);
  6.         $this->pdf->Cell(20,5,'Serie Cheque',1,0,'C',1);
  7.         $this->pdf->Cell(20,5,'Banco Emisor',1,0,'C',1);
  8.         $this->pdf->Cell(19,5,'Nº Cuenta',1,0,'C',1);
  9.         $this->pdf->Cell(15,5,'Nº R.I',1,0,'C',1);
  10.                 $this->pdf->Cell(15,5,'Estado',1,0,'C',1);
  11.         $this->pdf->Cell(55,5,'Propiedad',1,0,'C',1);
  12.         $this->pdf->Cell(50,5,'Arrendatario',1,0,'C',1);
  13.         $this->pdf->Cell(18,5,'Valor',1,1,'C',1);
  14.        
  15.         if (is_array($lista[0])){
  16.         foreach($lista as $i => $rows){
  17.             $this->pdf->Cell(23,5,$rows["TIPO_PAGO"],1,0,'L');
  18.             $this->pdf->Cell(19,5,$rows["DEPOSITO_PAGO"],1,0,'L');
  19.             $this->pdf->Cell(21,5,$rows["BANCODEPOSITO_PAGO"],1,0,'L');
  20.             $this->pdf->Cell(20,5,$rows["SERIECHEQUE_PAGO"],1,0,'L');
  21.             $this->pdf->Cell(20,5,$rows["BANCOEMISOR_PAGO"],1,0,'L');
  22.             $this->pdf->Cell(19,5,$rows["NCUENTA_PAGO"],1,0,'L');
  23.             $this->pdf->Cell(15,5,$rows["RECIBOINTERNO_PAGO"],1,0,'L');
  24.                         $this->pdf->Cell(15,5,$rows["ANULAR_PAGO_PAGO"],1,0,'L');
  25.             $this->pdf->Cell(55,5,$rows["DIRECCION_PROPIEDAD"],1,0,'L');
  26.             $this->pdf->Cell(50,5,$rows["NOMBRE_ARRENDATARIO"],1,0,'L');
  27.             $this->pdf->Cell(18,5,number_format($rows["MONTO_PAGO"], 0, ',', '.'),1,1,'L');
  28.         }
  29.         }
  30.         else {
  31.         $rows = $lista;
  32.             $this->pdf->Cell(23,5,$rows["TIPO_PAGO"],1,0,'L');
  33.             $this->pdf->Cell(19,5,$rows["DEPOSITO_PAGO"],1,0,'L');
  34.             $this->pdf->Cell(21,5,$rows["BANCODEPOSITO_PAGO"],1,0,'L');
  35.             $this->pdf->Cell(20,5,$rows["SERIECHEQUE_PAGO"],1,0,'L');
  36.             $this->pdf->Cell(20,5,$rows["BANCOEMISOR_PAGO"],1,0,'L');
  37.             $this->pdf->Cell(19,5,$rows["NCUENTA_PAGO"],1,0,'L');
  38.             $this->pdf->Cell(15,5,$rows["RECIBOINTERNO_PAGO"],1,0,'L');
  39.                         $this->pdf->Cell(15,5,$rows["ANULAR_PAGO_PAGO"],1,0,'L');
  40.             $this->pdf->Cell(55,5,$rows["DIRECCION_PROPIEDAD"],1,0,'L');
  41.             $this->pdf->Cell(50,5,$rows["NOMBRE_ARRENDATARIO"],1,0,'L');
  42.             $this->pdf->Cell(18,5,number_format($rows["MONTO_PAGO"], 0, ',', '.'),1,1,'L');
  43.         }

Donde me gustaría que la celda de ANULAR_PAGO cambie de color según su estado que es 1 o 0 tal cual esta en el ejemplo de la imagen.

Espero me puedan ayudar.
  #2 (permalink)  
Antiguo 05/10/2016, 17:24
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: Cambiar color celda FPDF

Al menos en mi experiencia, FPDF no es muy flexible y prefiero usar DomPDF, simplemente generas un HTML válido donde puedes incluir estilos, ya sea con etiqueta <style> o directamente con <td style="/* atributos */"><td> y funciona a la perfección.
__________________
- León, Guanajuato
- GV-Foto

Etiquetas: fpdf
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:13.