Recordad que para pedir soporte alguno, debéis facilitar los datos de soporte oportunos por favor, mirad aquí y leer las Normas generales del foro, esto nos servirá de ayuda para dar el mejor soporte..

Gracias.

La Administración de phpBB España.

sacar reportes en forma horizontal pdf

PHP, HTML, CSS, JS, jQuery, etc.
Responder
FKalexander
Observador/a
Mensajes: 1
Registrado: 05 Mar 2015, 16:57

sacar reportes en forma horizontal pdf

#1

Mensaje por FKalexander »

BUENOS DIAS AMIGO TENGO UN PROBLEMITA HAGO UN REPORTE EN UN PROYECTO CON PHP Y POSTGRE DONDE EN EL MODULO DE REPORTE, ESPECIFICAMENTE DETALLADO MENSUAL DE RETENCIONES POR CUENTAS ME SALE EN VERTICAL AQUI EL CODIGO QUE HAGO MAL? ESPERO PUEDAN AYUDARME ADJUNTE LA IMAGEN DE COMO SE VE LOS NUMEROS DEBEN SALIR ABAJO EJEMPLO:

http://i.imgur.com/AzeGqFn.jpg


ESTADO / CIERRE DE CICLO / INICIAR Y CULMINAR EN 2015

AMAZONAS / 2 3
TACHIRA / 2 6
APURE / 3 9
MERIDA / 6 4
Y ASI SUCESIVAMENTE SE DEBEN MOSTRAR TODAS EN HORIZONTAL ASI EN FILAS
DESPUES OTRA NO COMO EN EL PRINT AHI ESTAN LOS 3 ARCHIVOS CON LOS Q ESTOY TRABAJANDO

Código: Seleccionar todo

<?php 
    define('FPDF_FONTPATH','../font/');
    require('mc_table_estado.php');
    
    $pdf=new PDF_MC_Table('P','mm','letter');
    $pdf->Open();
    $pdf->AddPage();
    $pdf->AliasNbPages();
    
    $pdf->SetWidths(array(260));
    $pdf->SetFont('Arial','B',11);
    //$pdf->Cell(260,8,'DISTRIBUCION DE MATERIALES POR SISTEMA CONSTRUCTIVO',0,0,'C');
    $pdf->Ln(15);
    
    $pdf->SetFillColor(255,0,0);
    $pdf->SetTextColor(255);

    $pdf->SetFont('Arial','B',6);
    $pdf->SetAligns(array('C','L','C','C','R','R','C'));
    $pdf->SetWidths(array(15,105,50,20,25,25,20));

    $pdf->SetDrawColor(0,0,0);
    
//    $pdf->Row(array("Presidencial",utf8_decode("Descripción"),utf8_decode("Nº Pto Cta"),utf8_decode("Fecha Aprb."),"Monto Bs. (MM.)"));
    
    $pdf->SetFont('Arial','',6);
    $pdf->SetFillColor(255,255,255);
    $pdf->SetTextColor(0);
        
    include '../home/connect.php';
    
     $result=pg_query("
    SELECT e.nombre,SUM(ec.viviendas_totales) as viviendas,f.fase FROM estado e 
join estructura_constructiva ec ON ec.estado_id=e.id
join fase f ON f.idfase= ec.fase_id
WHERE ec.eliminar=0 
GROUP BY e.nombre, f.fase");
   // $pdf->Ln(15);
    $total = pg_num_rows($result);
$estado=0;
    while($row = pg_fetch_array($result))
    {
        $id=$row['id'];
        $nombre=$row['nombre'];
        $viviendas=$row['viviendas'];
        
        if($id==$id){
        
        $pdf->Row(array($nombre,$viviendas));    
        
        }    
        
     }

    //$pdf->SetFont('Arial','B',8);
//    $pdf->Cell(20,6,'Total de registros: '.$total,0);
    
    $pdf->Output();
?>
2 ARCHIVO

***************************************************************************************

Código: Seleccionar todo

<?php
require('../home/fpdf.php');

class PDF_MC_Table extends FPDF
{
var $widths;
var $aligns;

//Cabecera de página
function Header()
{
    //Logo
    $this->Image('../img/banner_osvh.png',10,6,100);
    $this->Image('../img/logo_gmvv.png',180,6,17);
    $this->Ln(20);
    
    $this->SetFont('Arial','B',10);
    $this->Cell(200,5,'DISTRIBUCIÓN DE VIVIENDAS TOTALES POR ESTADO 2015',0,'','C');
     $this->Ln(10);
     
    //Primera linea
    $this->SetFont('Arial','B',8);
    $this->Cell(60,6,'','LT','0','J');
    
    $this->SetFont('Arial','B',8);
    $this->Cell(135,6,'TOTALES ',"1",'1','C');
    
    //Segunda linea
    $this->SetFont('Arial','',8);
    $this->Cell(60,5,'',"LR",'0','L');
    
    $this->SetFont('Arial','B',8);
    $this->Cell(22.5,5,'',"LR",'0','C');
    
    $this->SetFont('Arial','B',8);
    $this->Cell(22.5,5,'',"LR",'0','C');

    $this->SetFont('Arial','',8);
    $this->Cell(22.5,5,'',"LR",'0','L');    

    $this->SetFont('Arial','',8);
    $this->Cell(22.5,5,'',"LR",'0','L');
    
    $this->SetFont('Arial','',8);
    $this->Cell(22.5,5,'',"LR",'0','L');
    
    $this->SetFont('Arial','',8);
    $this->Cell(22.5,5,'',"LR",'0','L');
    
    $this->SetFont('Arial','',8);
    $this->Cell(22.5,5,'',"LR",'1','L');
    
    //TERCERA LINEA
    $this->SetFont('Arial','B',10);
    $this->Cell(60,5,'ESTADO',"LR",'0','C');
    
    $this->SetFont('Arial','B',8);
    $this->Cell(22.5,4,'Cierre',"LR",'0','C');
    
    $this->SetFont('Arial','B',8);
    $this->Cell(22.5,4,'Iniciar y',"LR",'0','C');

    $this->SetFont('Arial','B',8);
    $this->Cell(22.5,4,'Iniciar en 2015',"LR",'0','C');    

    $this->SetFont('Arial','B',8);
    $this->Cell(22.5,4,'Sector',"LR",'0','C');
    
    $this->SetFont('Arial','B',8);
    $this->Cell(22.5,4,'',"LR",'0','C');
    
    $this->SetFont('Arial','B',8);
    $this->Cell(22.5,4,'',"LR",'0','C');
    
    $this->SetFont('Arial','B',8);
    $this->Cell(22.5,4,'',"LR",'1','C');
    
    //CUARTA LINEA
    $this->SetFont('Arial','',8);
    $this->Cell(60,5,'',"LR",'0','L');
    
    $this->SetFont('Arial','B',8);
    $this->Cell(22.5,4,'de',"LR",'0','C');
    
    $this->SetFont('Arial','B',8);
    $this->Cell(22.5,4,'culminar en',"LR",'0','C');

    $this->SetFont('Arial','B',8);
    $this->Cell(22.5,4,'y culminar',"LR",'0','C');    

    $this->SetFont('Arial','B',8);
    $this->Cell(22.5,4,'privado',"LR",'0','C');
    
    $this->SetFont('Arial','B',8);
    $this->Cell(22.5,4,'TOTAL',"LR",'0','C');
    
    $this->SetFont('Arial','B',8);
    $this->Cell(22.5,4,'%',"LR",'1','C');
    
    
    // QUINTA LINEA
    $this->SetFont('Arial','',8);
    $this->Cell(60,5,'',"LR",'0','L');
    
    $this->SetFont('Arial','B',8);
    $this->Cell(22.5,5,'ciclos',"LR",'0','C');
    
    $this->SetFont('Arial','B',8);
    $this->Cell(22.5,5,'2015',"LR",'0','C');

    $this->SetFont('Arial','B',8);
    $this->Cell(22.5,5,'en 2016',"LR",'0','C');    

    $this->SetFont('Arial','B',8);
    $this->Cell(22.5,5,'',"LR",'0','L');
    
    $this->SetFont('Arial','B',8);
    $this->Cell(22.5,5,'',"LR",'0','L');
    
    $this->SetFont('Arial','',8);
    $this->Cell(22.5,5,'',"LR",'0','L');
    
    $this->SetFont('Arial','',8);
    $this->Cell(22.5,5,'',"LR",'1','L');
    
    //6 linea
    $this->SetFont('Arial','',8);
    $this->Cell(60,5,'',"LRB",'0','L');
    
    $this->SetFont('Arial','B',8);
    $this->Cell(22.5,5,'',"LRB",'0','C');
    
    $this->SetFont('Arial','B',8);
    $this->Cell(22.5,5,'',"LRB",'0','C');

    $this->SetFont('Arial','',8);
    $this->Cell(22.5,5,'',"LRB",'0','L');    

    $this->SetFont('Arial','',8);
    $this->Cell(22.5,5,'',"LRB",'0','L');
    
    $this->SetFont('Arial','',8);
    $this->Cell(22.5,5,'',"LRB",'0','L');
    
    $this->SetFont('Arial','',8);
    $this->Cell(22.5,5,'',"LRB",'1','L');
    
    
}

//Pie de página
function Footer()
{
    //Posición: a 1,5 cm del final
    $this->SetY(-20);
    //Arial italic 8
    $this->SetFont('Arial','',7);
    //Número de página
    $this->Cell(0,10,date('d/m/Y'),0,0,'L');
    $this->Cell(0,10,'Página '.$this->PageNo().'/{nb}',0,0,'R');
}

function SetWidths($w)
{
    //Set the array of column widths
    $this->widths=$w;
}

function SetAligns($a)
{
    //Set the array of column alignments
    $this->aligns=$a;
}

function Row($data)
{
    //Calculate the height of the row
    $nb=0;
    for($i=0;$i<count($data);$i++)
        $nb=max($nb,$this->NbLines($this->widths[$i],$data[$i]));
    $h=5*$nb;
    //Issue a page break first if needed
    $this->CheckPageBreak($h);
    //Draw the cells of the row
    for($i=0;$i<count($data);$i++)
    {
        $w=$this->widths[$i];
        $a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
        //Save the current position
        $x=$this->GetX();
        $y=$this->GetY();
        //Draw the border
        $this->Rect($x,$y,$w,$h);
        //Print the text
        $this->MultiCell($w,5,$data[$i],0,$a,true);
        //Put the position to the right of the cell
        $this->SetXY($x+$w,$y);
    }
    //Go to the next line
    $this->Ln($h);
}

function Row2($data)
{
    //Calculate the height of the row
    $nb=0;
    for($i=0;$i<count($data);$i++)
        $nb=max($nb,$this->NbLines($this->widths[$i],$data[$i]));
    $h=5*$nb;
    //Issue a page break first if needed
    $this->CheckPageBreak($h);
    //Draw the cells of the row
    for($i=0;$i<count($data);$i++)
    {
        $w=$this->widths[$i];
        $a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
        //Save the current position
        $x=$this->GetX();
        $y=$this->GetY();
        //Draw the border
        //$this->Rect($x,$y,$w,$h);
        //Print the text
        $this->MultiCell($w,5,$data[$i],0,$a,true);
        //Put the position to the right of the cell
        $this->SetXY($x+$w,$y);
    }
    //Go to the next line
    $this->Ln($h);
}

function CheckPageBreak($h)
{
    //If the height h would cause an overflow, add a new page immediately
    if($this->GetY()+$h>$this->PageBreakTrigger)
        $this->AddPage($this->CurOrientation);
}

function NbLines($w,$txt)
{
    //Computes the number of lines a MultiCell of width w will take
    $cw=&$this->CurrentFont['cw'];
    if($w==0)
        $w=$this->w-$this->rMargin-$this->x;
    $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
    $s=str_replace("\r",'',$txt);
    $nb=strlen($s);
    if($nb>0 and $s[$nb-1]=="\n")
        $nb--;
    $sep=-1;
    $i=0;
    $j=0;
    $l=0;
    $nl=1;
    while($i<$nb)
    {
        $c=$s[$i];
        if($c=="\n")
        {
            $i++;
            $sep=-1;
            $j=$i;
            $l=0;
            $nl++;
            continue;
        }
        if($c==' ')
            $sep=$i;
        $l+=$cw[$c];
        if($l>$wmax)
        {
            if($sep==-1)
            {
                if($i==$j)
                    $i++;
            }
            else
                $i=$sep+1;
            $sep=-1;
            $j=$i;
            $l=0;
            $nl++;
        }
        else
            $i++;
    }
    return $nl;
}
}
?>
3 ARCHIVO
*************************************************************************

Código: Seleccionar todo

<script type="text/javascript">
	function valiarestado(){
		$('#fm_report002').form('submit',{
			onSubmit: function(){
				return $(this).form('validate');
			},
			success: function(){
				//var idcuenta002 = $('#idcuenta002').combogrid('getValue');
				
			//	var fecha_ini02 = $('#fecha_ini02').datebox('getValue');
           //   var fecha_fin02 = $('#fecha_fin02').datebox('getValue');
				
				var url2 = 'report_todoestado.php?';    
				window.open(url2,'Resumen de Retenciones por Cuentas','height=600,width=800');
				
			}
		});
	}
</script>
<div id="p" title="Detallado Mensual de Retenciones por Cuentas" class="easyui-panel" style="height:80px; width:100%;padding:10px;background:#fafafa;">  
    <form id="fm_report002" method="post" novalidate>
    <div style="float:right;"><a id="btnprint_report002" class="easyui-linkbutton" iconCls="icon-print" onclick="valiarestado()">Imprimir</a></div>
   </form>
</div>
Última edición por ThE KuKa el 05 Mar 2015, 19:50, editado 1 vez en total.
Razón: Editado para agregar BBCode CODE.

Avatar de Usuario
Makoto
Elite
Mensajes: 2929
Registrado: 10 Sep 2009, 23:44
Género:
Edad: 35

Re: sacar reportes en forma horizontal pdf

#2

Mensaje por Makoto »

este es un foro de soporte phpbb, no de php lo siento :3
URL del foro: FIIS-UNAC
Versión phpBB: phpBB3 ( 3.1.5)
Extensiones Instaladas
SPOILER_SHOW
  • Add User 1.0.2
  • Auto Database Backup 1.1.0
  • Auto Groups 1.0.0
  • Avatars on Memberlist 1.0.3
  • Board Announcements 1.0.2
  • Board Rules 1.0.1
  • cBB Chat 1.1.1
  • Fancy Lazy Topics loader 2.1.5
  • Genders 1.0.0
  • Last Post Avatar
  • Log failed logins
  • Rank Post Styling
  • Share On 1.0.0
  • SiteSplat BBCore 2.1.1
  • Sortables Captcha 2.0.0
  • Topic Author 1.0.1
  • Upload Extensions 3.1.2-beta2
Plantilla(s) usada(s):
  • FLATBOOTS 2.0.1
Servidor: Dattatec[/size]

Responder

Volver a “🆘 Recursos Webmaster”