Jump to content
Sign in to follow this  
ruimcosta

FPDF + Header + Footer

Recommended Posts

ruimcosta

Biba,

Estou aqui com um problema e já não vejo nada à minha frente (ainda hoje é 2ª!).

Tenho um pdf criado via fpdf e preciso de implementar as classes Header() e Footer() para gerar facturas que tenham mais que uma página.

Daí para um teste simples, utilizei o exemplo do fpdf.org:

function Footer()
{
    $this->setXY("8","24.8");
    $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}


$pdf = new FPDF("P","cm", array(21, 29.9));
$pdf->Open();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetAuthor($emp_nome);
$pdf->SetTitle('Documento proveniente de higicol.com');
$pdf->SetAutoPageBreak(false);
$pdf->SetMargins(0,0,0);

Sem qualquer erro o pdf é gerado mas sem aparecer "Page XX/ YY". Alguém tem alguma sugestão?

Obrigado


Abraços e beijinhos,Rui Costa

Share this post


Link to post
Share on other sites
IvanGS

tens o output?

no fim tens qu meter isto:

//Instanciation of inherited class
$pdf=new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times','',12);
for($i=1;$i<=40;$i++)
    $pdf->Cell(0,10,'Printing line number '.$i,0,1);
$pdf->Output();

Share this post


Link to post
Share on other sites
ruimcosta

Biba Ivan

Sim, tem o output. O pdf está a funcionar bem, exceptuando o Footer() e o Header, que embora não esteja aí, já tentei cria-lo mas sem sucesso.

Não aparece o numero de páginas nem o que quer que eu mande escrever dentro do footer ou dentro do header. Estranhíssimo!!


Abraços e beijinhos,Rui Costa

Share this post


Link to post
Share on other sites
IvanGS

eu uso esta linha para o número de páginas...

$pdf->Cell(0,5,'Página '.$pdf->PageNo());

Share this post


Link to post
Share on other sites
ruimcosta

A questão não passa pelo número da página em si. Nem que eu utilize:

$this->setXY("8","24.8");
    $this->Cell(0,10,'"XXX",0,0,'C');

Nada aparece. A questão está no chamar a função Header() ou Footer, que segundo me consta, a sua chamada será automática


Abraços e beijinhos,Rui Costa

Share this post


Link to post
Share on other sites
ruimcosta

No PDF gerado? Aparece tudo menos o que eu tenho no header..... :wallbash:


Abraços e beijinhos,Rui Costa

Share this post


Link to post
Share on other sites
IvanGS

quando usei o FPDF encontrei também muitos problemas

e o site deles tem muitos bons exemplos...

Share this post


Link to post
Share on other sites
ruimcosta

Alguma coisa falha de certeza...ja vasculhei a referência da biblioteca deles, tutoriais, exemplos noutros sites.... 😡


Abraços e beijinhos,Rui Costa

Share this post


Link to post
Share on other sites
ruimcosta

Biba,

Aqui vai, mas aviso que so tem 660 linhas.....

<?php
header('Cache-Control: no-cache');
header('Pragma: no-cache');

require_once "connectsqlserver.php";
require_once "connect.php";
require_once "classes/fpdf16/fpdf.php";
require_once "classes/SQLInjection.class.php";
require_once "classes/GExtenso.php";
//require_once "classes/phpmailer/class.phpmailer.php";

define('FPDF_FONTPATH','classes/fpdf16/font/');

$ano   = SQLInjection($_GET['ano'],"int");
$serie = SQLInjection($_GET['serie'],"int");
$ndoc  = SQLInjection($_GET['ndoc'],"int");
$tdoc  = strtoupper( $_GET['tdoc'] );
//$utilizador  = $_GET['utilizador'];

// Logotipo inserido pelo cliente
$sql = "select * from config where variavel = 'logopdf'";
$rs  = mysql_query($sql);

if( mysql_num_rows($rs) == 1 ){
    $row = mysql_fetch_array($rs);
    
    $logot = $row['valor'];    
}

function empresa( $info ){
    $sql = "select valor from config where variavel = '$info'";
    $rs  = mysql_query($sql);
    $row = mysql_fetch_array($rs);
    
    return $row['valor'];
}

$emp_nome      = empresa('emp_nome');
$emp_morada    = empresa('emp_morada');
$emp_cp        = empresa('codpostal');
$emp_local     = empresa('localidade');
$emp_tlf       = empresa('emp_tlf');
$emp_fax       = empresa('emp_fax');
$emp_nif       = empresa('emp_nif');
$emp_capsocial = empresa('capsocial');
$emp_regc      = empresa('regconserv');
$emp_email     = empresa('emp_email');

// Descrição do documento
$sql = "select DESCR from TPDOC where CODIGO = '$tdoc'";
$rs  = mssql_query($sql);
$row = mssql_fetch_array($rs);
$descr = $row['DESCR'];

// Numero do documento
$sql = "SELECT 
            DATA, SERIE, TERCEIRO, VENDEDOR, TOTDOCMB, TOTMERC, TOTOUTRO, DESCCAB, TOTDCPT, BASE1, BASE2, BASE3, BASE4, TOTIVA1, TOTIVA2, 
            TOTIVA3, TOTIVA4, DTCARGA, DTVENC, LOCALCG, CAST(OBSERV AS TEXT) AS OBSERV, VENDEDOR
        FROM DOCGCCAB WHERE ANO = '$ano' AND NNUMDOC = '$ndoc' AND SERIE = '$serie' AND TPDOC = '$tdoc'";

$rs  = mssql_query($sql);
$row = mssql_fetch_array($rs);

$terceiro  = $row['TERCEIRO'];

if( $row['DTVENC'] == "" ){
    $dtvenc = date("Y-m-d");
}else{
    $dtvenc = $row['DTVENC'];
}

$desccab   = $row['DESCCAB'];
$subtotal  = $row['TOTDCPT'];
$totaldoc  = $row['TOTDOCMB'];
$totmerc   = $row['TOTMERC'] + $row['TOTOUTRO'];
$base1     = $row['BASE1'];
$base2     = $row['BASE2'];
$base3     = $row['BASE3'];
$base4     = $row['BASE4'];
$totiva1   = $row['TOTIVA1'];
$totiva2   = $row['TOTIVA2'];
$totiva3   = $row['TOTIVA3'];
$totiva4   = $row['TOTIVA4'];
$serie     = $row['SERIE'];
$obs       = $row['OBSERV'];
$vendedor  = $row['VENDEDOR'];
$totaliva  = $totiva1 + $totiva2 + $totiva3 + $totiva4;

if( $row['DTCARGA'] == "" ){
    $dtcarga = date("Y-m-d");
}else{
    $dtcarga = $row['DTCARGA'];
}

$lcarga    = $row['LOCALCG'];

$datadoc = date("d/m/Y", strtotime($row['DATA']));

// Dados do cliente
$sql = "SELECT NOME, MORADA, CDPOSTAL, NCONTRIB, REGIVA FROM CLIENTES WHERE CODIGO = '$terceiro'";
$rs  = mssql_query($sql);
$row = mssql_fetch_array($rs);

$nome   = $row['NOME'];
$morada = $row['MORADA'];
$cdp    = $row['CDPOSTAL'];
$nif    = $row['NCONTRIB'];
$riva   = $row['REGIVA'];

// Taxas de IVA
$sql = "select TX1, TX2, TX3, TX4 from RGIVA where CODIGO = '$riva'";
$rs  = mssql_query($sql);
$row = mssql_fetch_array($rs);
$tx1 = $row['TX1'];
$tx2 = $row['TX2'];
$tx3 = $row['TX3'];
$tx4 = $row['TX4'];

// Localidade
$sql = "select DESCR from CODPOST where COD = '$cdp'";
$rs  = mssql_query($sql);
$row = mssql_fetch_array($rs);
$localidade = $row['DESCR'];

// Envio de email a avisar a DATAMAGNA que o cliente leu este documento
/*********************************************************************/
$enc   = '<table>'."\r\n";
$enc  .= '   <tr>'."\r\n";
$enc  .= '       <td style="font-family:verdana;color#5d1d5c;">Dados do Cliente</td>'."\r\n";
$enc  .= '   </tr>'."\r\n";
$enc  .= '   <tr>'."\r\n";
$enc  .= '      <td style="font-family:verdana">';
$enc  .= '          <p>O cliente '.$nome.' leu o documento '.$tdoc.' Nº '.$ndoc.'/'.$serie.' na data '.date("d-m-Y").' às '.date("H:i:s").'</p>';
$enc  .= '      </td>'."\r\n";
$enc  .= '   </tr>'."\r\n";
$enc  .= '</table><br /><br />'."\r\n";


//Obtem emails de destino para enviar email
//Tipo de Acção: 1 - Aviso de leitura de documento
//$mail = new PHPMailer(true);

$sql = "select accao, nome, email_destino from def_emails_envios
        	inner join def_emails_envios_tipos
        		on def_emails_envios.nid_tipo_accao = def_emails_envios_tipos.nid
         where nid_tipo_accao = 1";
$rs  = mysql_query($sql);

if( mysql_num_rows($rs) > 0 ){
    while( $row = mysql_fetch_array($rs) ){
        $accao = $row['accao'];
        $from  = $row['email_destino'];
        $fromn = $row['nome'];
        $to    = $row['email_destino'];
        $ton   = $row['nome'];
        
        try {
            $mail->AddReplyTo($from, $fromname);
            $mail->AddAddress($to, $toname);
            $mail->SetFrom($from, $fromname);
            $mail->AddReplyTo($from, $fromname);
        
            $mail->Subject = 'datamagna.com - '.$accao;
            $html = file_get_contents('tpl/tpl_email.html');
            
            $html = str_replace('{$titulo}', $mail->Subject, $html);
            $html = str_replace('{$conteudo}', $enc, $html);
            
            $mail->MsgHTML($html);
            
            $mail->Send();
        
        } catch (phpmailerException $e) {
            echo $e->errorMessage(); //Pretty error messages from PHPMailer
        } catch (Exception $e) {
            echo $e->getMessage(); //Boring error messages from anything else!
        }
        
        
    }
}
/*********************************************************************/

// Regista na tabela bck_estatisticas  abertura deste documento;
/*********************************************************************/
$dreg = date("Y-m-d H:i:s");

$sql = "insert into bck_estatisticas(utilizador, dreg, tpdoc, ndoc, obs, ano, serie) 
            values('$utilizador', '$dreg', '$tdoc', '$ndoc', '$accao', '$ano', '$serie')";
$rs  = mysql_query($sql);
/*********************************************************************/

function Footer()
{
    $this->SetY(1);
    //Select Arial italic 8
    $this->SetFont('Arial','I',8);
    //Print centered page number
    $this->Cell(0,10,'Page sfffffff',0,0,'C');

}

$pdf = new FPDF("P","cm", array(21, 29.9));
$pdf->AliasNbPages();
$pdf->SetAuthor($emp_nome);
$pdf->SetTitle('Documento proveniente de higicol.com');
$pdf->SetAutoPageBreak(false);
$pdf->SetMargins(0,0,0);
$pdf->AddPage();

$pdf->SetFont('Arial','B',9);

//Dados do cliente
$pdf->Rect("11.5", "3.7", "8.5", "2.3");

if( file_exists("../$logot") ){
    $pdf->Image("../$logot");
}

$pdf->SetFont('Arial','B',8);

$pdf->setXY("0.5", "4.2");
$pdf->Cell( 0, 0, $emp_nome);

$pdf->setXY("0.5", "4.6");
$pdf->Cell( 0, 0, "Contribuinte:");

$pdf->SetFont('Arial','',8);

$pdf->setXY("2.3", "4.6");
$pdf->Cell( 0, 0, $emp_nif);

$pdf->SetFont('Arial','',8);
$pdf->setXY("0.5", "5");
$pdf->Cell( 0, 0, $emp_morada." ".$emp_cp." - ".$emp_local);

$pdf->SetFont('Arial','B',8);
$pdf->setXY("0.5", "5.4");
$pdf->Cell( 0, 0, "Tlf:");

$pdf->SetFont('Arial','',8);
$pdf->setXY("1", "5.4");
$pdf->Cell( 0, 0, $emp_tlf);

$pdf->SetFont('Arial','B',8);
$pdf->setXY("2.8", "5.4");
$pdf->Cell( 0, 0, "Fax:");

$pdf->SetFont('Arial','',8);
$pdf->setXY("3.5", "5.4");
$pdf->Cell( 0, 0, $emp_fax);

$pdf->SetFont('Arial','B',8);
$pdf->setXY("0.5", "5.8");
$pdf->Cell( 0, 0, "Email:");

$pdf->SetFont('Arial','',8);
$pdf->setXY("1.4", "5.8");
$pdf->Cell( 0, 0, $emp_email);

$pdf->setXY("0.5", "6.2");
$pdf->Cell( 0, 0, "Capital Social € ".$emp_capsocial." - Reg. ".$emp_regc." C.R.C. STS");

$pdf->SetFont('Arial','IB',9);

// Descrição do Documento
$pdf->SetFillColor( 172, 172, 172);
$pdf->SetTextColor(0,0,0);
$pdf->setXY("11.5", "0.7");
$pdf->Cell("8.5", "0.5", $descr, 1, 0, "C");

// Original
/********************************************************/

$pdf->setXY("11.5", "1.3");
$pdf->Cell("8.5", "0.5", "ORIGINAL", 1, 0, "C");

$pdf->SetFont('Arial','B',9);

$pdf->setXY("11.5", "1.9");
$pdf->Cell("2", "0.5", "Número", 1, 0, "R");

$pdf->setXY("15.8", "1.9");
$pdf->Cell("2", "0.5", "Data", 1, 0, "R");

$pdf->setXY("13.6", "1.9");
$pdf->Cell("2", "0.5", $ndoc, 1, 0, "L");

$pdf->setXY("17.9", "1.9");
//$pdf->Cell("2.1", "0.5", date("d-m-Y", strtotime($datadoc)), 1, 0, "C");
$pdf->Cell("2.1", "0.5", $datadoc, 1, 0, "C");
/********************************************************/

$x = "10.4";
$pdf->setXY("11.6", "3.9");
$pdf->Cell( 0, 0, $nome);

$pdf->SetFont('Arial','',8);

$pdf->setXY("11.6", "4.4");
$pdf->Cell( 0, 0, $morada);

$pdf->setXY("11.6", "4.9");
$pdf->Cell( 0, 0, $cdp);

$pdf->setXY("13.5", "4.9");
$pdf->Cell( 0, 0, $localidade);

$pdf->SetFont('Arial','B',9);

$pdf->setXY("0.5", "6.4");
$pdf->Cell("2.5","0.5",'Cliente',1,0, "C");

$pdf->setXY("3", "6.4");
$pdf->Cell("3.5","0.5",'Contribuinte',1,0, "C");

$pdf->setXY("6.5", "6.4");
$pdf->Cell("2.2","0.5",'Desconto',1,0, "C");

$pdf->setXY("8.7", "6.4");
$pdf->Cell("1.6","0.5",'Zona',1,0, "C");

$pdf->setXY("10.3", "6.4");
$pdf->Cell("1.8","0.5",'Vendedor',1,0, "C");

$pdf->setXY("12.1", "6.4");
$pdf->Cell("3.3","0.5",'Referência',1,0, "C");

$pdf->setXY("15.4", "6.4");
$pdf->Cell("2.2","0.5",'Expedição',1,0, "C");

$pdf->setXY("17.6", "6.4");
$pdf->Cell("2.4","0.5",'Vencim.',1,0, "C");

$pdf->SetFont('Arial','',9);

$pdf->setXY("0.5", "6.9");
$pdf->Cell("2.5","0.5", $terceiro,1,0, "C");

$pdf->setXY("3", "6.9");
$pdf->Cell("3.5","0.5", $nif, 1, 0, "C");

$pdf->setXY("6.5", "6.9");
$pdf->Cell("2.2","0.5", number_format($desccab,2)." %", 1, 0, "C");

$pdf->setXY("8.7", "6.9");
$pdf->Cell("1.6","0.5", '',1,0, "C");

$pdf->setXY("10.3", "6.9");
$pdf->Cell("1.8","0.5",$vendedor,1,0, "C");

$pdf->setXY("12.1", "6.9");
$pdf->Cell("3.3","0.5",'',1,0, "C");

$pdf->setXY("15.4", "6.9");
$pdf->Cell("2.2","0.5",'',1,0, "C");

$dtvenc = date("d/m/Y", strtotime($dtvenc));
$pdf->setXY("17.6", "6.9");
$pdf->Cell("2.4","0.5", $dtvenc,1,0, "C");


/* Detalhes da Factura*/
/****************************************************************/
// Barra de título das linhas da factura

$pdf->SetFont('Arial','B',9);

$pdf->setXY("0.5", "7.6");
$pdf->Cell("2.5","0.5",'Artigo',1,0, "C");

$pdf->setXY("3", "7.6");
$pdf->Cell("7","0.5",'Descrição',1,0, "C");

$pdf->setXY("10", "7.6");
$pdf->Cell("1.5","0.5",'Qtd',1,0, "C");

$pdf->setXY("11.5", "7.6");
$pdf->Cell("2.4","0.5",'Preço',1,0, "C");

$pdf->setXY("13.9", "7.6");
$pdf->Cell("1.4","0.5",'Desc',1,0, "C");

$pdf->setXY("15.3", "7.6");
$pdf->Cell("1","0.5",'Iva',1,0, "C");

$pdf->setXY("16.3", "7.6");
$pdf->Cell("3.7","0.5",'Valor',1,0, "C");

/* Linhas da Factura */
/*****************************************************/

$sql = "SELECT ARTIGO, DESCR, PRUNIT, QUANT, VALOR, DESCONTO, IVA 
            FROM DOCGCLIN 
            WHERE NNUMDOC = '$ndoc' AND TPDOCUM = '$tdoc' AND ANO = '$ano' ORDER BY NUMLINHA asc";
$rs  = mssql_query($sql);

$pdf->SetFont('Arial','',7);

$pdf->Rect("0.5", "8.1", "19.5", "7");

$pdf->Line("0.5", "8.5", "20", "8.5");

$pdf->Line("3", "8.1", "3", "15.6");
$pdf->Line("10", "8.1", "10", "15.6");
$pdf->Line("11.5", "8.1", "11.5", "15.6");
$pdf->Line("13.9", "8.1", "13.9", "15.6");
$pdf->Line("15.3", "8.1", "15.3", "15.6");
$pdf->Line("16.3", "8.1", "16.3", "15.6");



if( mssql_num_rows($rs) > 0 ){
    
    $y      = "8.5";
    $incr   = "0.4";
    $border = 0;
    $max    = 16;
    $i      = 0;
    
    while( $row = mssql_fetch_array($rs) ){
        if( $i == $max ){
            $pdf->AddPage();
            $i = 0;
            $y = "8.5";
        }
        
        $pdf->setXY("0.5", $y);
        $pdf->Cell("2.5","0.5", $row['ARTIGO'], $border,0, "L");
        
        $pdf->setXY("3",$y);
        $pdf->Cell("7","0.5", $row['DESCR'], $border,0, "L");

        $pdf->setXY("10",$y);
        
        if( $row['QUANT'] > 0 ){
            $pdf->Cell("1.5","0.5", number_format($row['QUANT'],3), $border,0, "R");    
        }else{
            $pdf->Cell("1.5","0.5", "", $border,0, "R");
        }
        
        $pdf->setXY("11.5",$y);
                
        if( $row['PRUNIT'] > 0 ){
            $pdf->Cell("2.4","0.5", number_format($row['PRUNIT'],2,",","."), $border,0, "R"); 
        }else{
            $pdf->Cell("2.4","0.5", "", $border,0, "R");
        }

        $pdf->setXY("13.9", $y);
        
        if( $row['DESCONTO'] > 0 ){
            $pdf->Cell("1.4","0.5", number_format($row['DESCONTO'],2,",","."), $border,0, "R"); 
        }else{
            $pdf->Cell("1.4","0.5", "", $border,0, "R");
        }

        $pdf->setXY("15.3", $y);
        
        if( $row['IVA'] > 0 ){
            $pdf->Cell("1","0.5",number_format($row['IVA'],0), $border,0, "R"); 
        }else{
            $pdf->Cell("1","0.5", "", $border,0, "R");
        }

        $pdf->setXY("16.3", $y);
        
        if( $row['VALOR'] > 0 ){
            $pdf->Cell("3.7","0.5", number_format($row['VALOR'],2,",","."), $border,0, "R"); 
        }else{
            $pdf->Cell("3.7","0.5", "", $border,0, "R");
        }
                                                
        $y = $y + $incr;
        $i++;
    }
} 

/******************************************************/

/* Fim da tabela dos detalhes */

$pdf->Rect("0.5", "15.1", "19.5", "0.5");


$pdf->SetFont('Arial','B',6);
$pdf->setXY("0.5", "15.1");
$pdf->Cell("0","0.5",'Total',0,0, "L");

$pdf->setXY("16.5", "15.1");
$pdf->Cell("3.4","0.5", number_format($totmerc,2,",","."), 0, 0, "R");

$pdf->setXY("0.5", "16");
$pdf->MultiCell("19.5", "0.4", "Esta venda é feita sob reserva de propriedade, nos termos do artº 409 do Cod. Civil, pelo que enquanto o valor total deste documento não estiver totalmente liquidado , a mercadoria nele constante permanece nossa propriedade.");

$pdf->setXY("0.5", "17");
$pdf->MultiCell("19.5", "0.4", "Para cumprimento de nº 5 da alínea f) do artº 35 do CIVA, a mercadoria constante neste documento foi colocada à disposição do adquirente em ____/___/___.");

$pdf->SetFont('Arial','B',8);
$pdf->setXY("0.5","17.6");
$pdf->Cell("2.4","0.5", "Incidência", 1, 0, "C");

$pdf->setXY("3","17.6");
$pdf->Cell("1.6","0.5", "Taxa", 1, 0, "C");

$pdf->setXY("4.7","17.6");
$pdf->Cell("2.5","0.5", "Valor Imposto", 1, 0, "C");

$pdf->SetFont('Arial','',7);
$pdf->setXY("0.5","18.2");
$pdf->Cell("2.4","0.4", number_format($base1,2,",","."), 1, 0, "R");

$pdf->setXY("0.5","18.6");
$pdf->Cell("2.4","0.4", number_format($base2,2,",","."), 1, 0, "R");

$pdf->setXY("0.5","19.0");
$pdf->Cell("2.4","0.4", number_format($base3,2,",","."), 1, 0, "R");

$pdf->setXY("0.5","19.4");
$pdf->Cell("2.4","0.4", number_format($base4,2,",","."), 1, 0, "R");

$pdf->setXY("3","18.2");
$pdf->Cell("1.6","0.4", number_format($tx1,2,",","."), 1, 0, "R");

$pdf->setXY("3","18.6");
$pdf->Cell("1.6","0.4", number_format($tx2,2,",","."), 1, 0, "R");

$pdf->setXY("3","19");
$pdf->Cell("1.6","0.4", number_format($tx3,2,",","."), 1, 0, "R");

$pdf->setXY("3","19.4");
$pdf->Cell("1.6","0.4", number_format($tx4,2,",","."), 1, 0, "R");

$pdf->setXY("4.7","18.2");
$pdf->Cell("2.5","0.4", number_format($totiva1,2,",","."), 1, 0, "R");

$pdf->setXY("4.7","18.6");
$pdf->Cell("2.5","0.4", number_format($totiva2,2,",","."), 1, 0, "R");

$pdf->setXY("4.7","19");
$pdf->Cell("2.5","0.4", number_format($totiva3,2,",","."), 1, 0, "R");

$pdf->setXY("4.7","19.4");
$pdf->Cell("2.5","0.4", number_format($totiva4,2,",","."), 1, 0, "R");

$pdf->SetFont('Arial','B',8);
$pdf->setXY("7.4","17.6");
$pdf->Cell("18","0.5", "Observações");

$pdf->Rect("7.3", "18.2", "7", "3.5");
$pdf->setXY("7.4","18.2");
$pdf->MultiCell("5","0.5", $obs, 0);


// Sub Totais no rodape
$pdf->SetFont('Arial','BI',8);
$pdf->setXY("14.8", "17.6");
$pdf->Cell("2.8","0.5", "Total Mercadoria", 1);

$pdf->setXY("17.7", "17.6");
$pdf->Cell("2.2","0.5", number_format($totmerc,2,",","."), 1, 0, "R");

$pdf->setXY("14.8", "18.1");
$pdf->Cell("2.8","0.5", "Despesas", 1);

$pdf->setXY("17.7", "18.1");
$pdf->Cell("2.2","0.5", "", 1);

$pdf->setXY("14.8", "18.6");
$pdf->Cell("2.8","0.5", "Adiantamentos", 1);

$pdf->setXY("17.7", "18.6");
$pdf->Cell("2.2","0.5", "", 1);

$pdf->setXY("14.8", "19.1");
$pdf->Cell("2.8","0.5", "Desc. Cabeçalho", 1);

$pdf->setXY("17.7", "19.1");
$pdf->Cell("2.2","0.5", number_format($desccab,2,",","."), 1, 0, "R");

$pdf->setXY("14.8", "19.6");
$pdf->Cell("2.8","0.5", "Desc. Linhas", 1);

$pdf->setXY("17.7", "19.6");
$pdf->Cell("2.2","0.5", "", 1);

$pdf->setXY("14.8", "20.1");
$pdf->Cell("2.8","0.5", "Total Iva", 1);

$pdf->setXY("17.7", "20.1");
$pdf->Cell("2.2","0.5", number_format($totaliva,2,",","."), 1, 0, "R");

$pdf->setXY("14.8", "20.6");
$pdf->Cell("2.8","0.5", "Total em EUR", 1);

$pdf->setXY("17.7", "20.6");
$pdf->Cell("2.2","0.5", number_format($totaldoc,2,",","."), 1, 0, "R");

$pdf->SetFont('Arial','B',8);
$pdf->setXY("0.5", "22.5");
$pdf->Cell("0","0.5", "Extenso");

if( $totaldoc > 0 ){
    $pdf->SetFont('Arial','',8);
    $extenso = GExtenso::moeda(number_format($totaldoc,2,"",""), 2, array('euro', 'euros', GExtenso::GENERO_MASC), array('cêntimo', 'cêntimos', GExtenso::GENERO_MASC));
}

$pdf->setXY("0.5", "22.9");
$pdf->Cell("19.3","0.5", $extenso, 1);

$pdf->SetFont('Arial','',8);

$pdf->setXY("0.5", "23.6");
$pdf->Cell("1.7","0.4", "Data Carga", 1);

$dtcarga = date("d-m-Y", strtotime($dtcarga));
$hcarga  = date("H:i", strtotime($dtcarga));

$pdf->setXY("2.2", "23.6");
$pdf->Cell("1.8","0.4", $dtcarga, 1);

$pdf->setXY("4.1", "23.6");
$pdf->Cell("1.8","0.4", "Hora Carga", 1);

$pdf->setXY("5.9", "23.6");
$pdf->Cell("1.7","0.4", $hcarga, 1);

$pdf->setXY("0.5", "24.1");
$pdf->Cell("1.7","0.4", "Local Carga", 1);

$pdf->setXY("2.2", "24.1");
$pdf->Cell("5.4","0.4", $lcarga, 1);

$pdf->setXY("0.5", "24.6");
$pdf->Cell("1.7","0.4", "Descarga", 1);

$pdf->setXY("2.2", "24.6");
$pdf->Cell("5.4","0.4", "", 1);

$pdf->setXY("0.5", "25.1");
$pdf->Cell("1.7","0.4", "Transporte", 1);

$pdf->setXY("2.2", "25.1");
$pdf->Cell("5.4","0.4", "", 1);

$pdf->SetFont('Arial','',6);

$pdf->setXY("8", "23.6");
$pdf->Cell("2", "0.4", $descr, 0, 0, "L");

$sql = "select certificado from certificados_docs where tpdoc = '$tdoc' and serie = $serie and numdoc = '$ndoc'";
$rs  = mysql_query($sql);
$row = mysql_fetch_array($rs);
$cert = $row['certificado'];

$pdf->setXY("8","24");
$pdf->Cell("18","0.5", $cert." - Processado por programa certificado nº 17/DGCI - Sage NEXT");

$pdf->Output("Documento","I");
?>


Abraços e beijinhos,Rui Costa

Share this post


Link to post
Share on other sites
IvanGS

mete as code tag's

<?php
header('Cache-Control: no-cache');
header('Pragma: no-cache');

require_once "connectsqlserver.php";
require_once "connect.php";
require_once "classes/fpdf16/fpdf.php";
require_once "classes/SQLInjection.class.php";
require_once "classes/GExtenso.php";
//require_once "classes/phpmailer/class.phpmailer.php";

define('FPDF_FONTPATH','classes/fpdf16/font/');

$ano   = SQLInjection($_GET['ano'],"int");
$serie = SQLInjection($_GET['serie'],"int");
$ndoc  = SQLInjection($_GET['ndoc'],"int");
$tdoc  = strtoupper( $_GET['tdoc'] );
//$utilizador  = $_GET['utilizador'];

// Logotipo inserido pelo cliente
$sql = "select * from config where variavel = 'logopdf'";
$rs  = mysql_query($sql);

if( mysql_num_rows($rs) == 1 ){
    $row = mysql_fetch_array($rs);
    
    $logot = $row['valor'];    
}

function empresa( $info ){
    $sql = "select valor from config where variavel = '$info'";
    $rs  = mysql_query($sql);
    $row = mysql_fetch_array($rs);
    
    return $row['valor'];
}

$emp_nome      = empresa('emp_nome');
$emp_morada    = empresa('emp_morada');
$emp_cp        = empresa('codpostal');
$emp_local     = empresa('localidade');
$emp_tlf       = empresa('emp_tlf');
$emp_fax       = empresa('emp_fax');
$emp_nif       = empresa('emp_nif');
$emp_capsocial = empresa('capsocial');
$emp_regc      = empresa('regconserv');
$emp_email     = empresa('emp_email');

// Descrição do documento
$sql = "select DESCR from TPDOC where CODIGO = '$tdoc'";
$rs  = mssql_query($sql);
$row = mssql_fetch_array($rs);
$descr = $row['DESCR'];

// Numero do documento
$sql = "SELECT 
            DATA, SERIE, TERCEIRO, VENDEDOR, TOTDOCMB, TOTMERC, TOTOUTRO, DESCCAB, TOTDCPT, BASE1, BASE2, BASE3, BASE4, TOTIVA1, TOTIVA2, 
            TOTIVA3, TOTIVA4, DTCARGA, DTVENC, LOCALCG, CAST(OBSERV AS TEXT) AS OBSERV, VENDEDOR
        FROM DOCGCCAB WHERE ANO = '$ano' AND NNUMDOC = '$ndoc' AND SERIE = '$serie' AND TPDOC = '$tdoc'";

$rs  = mssql_query($sql);
$row = mssql_fetch_array($rs);

$terceiro  = $row['TERCEIRO'];

if( $row['DTVENC'] == "" ){
    $dtvenc = date("Y-m-d");
}else{
    $dtvenc = $row['DTVENC'];
}

$desccab   = $row['DESCCAB'];
$subtotal  = $row['TOTDCPT'];
$totaldoc  = $row['TOTDOCMB'];
$totmerc   = $row['TOTMERC'] + $row['TOTOUTRO'];
$base1     = $row['BASE1'];
$base2     = $row['BASE2'];
$base3     = $row['BASE3'];
$base4     = $row['BASE4'];
$totiva1   = $row['TOTIVA1'];
$totiva2   = $row['TOTIVA2'];
$totiva3   = $row['TOTIVA3'];
$totiva4   = $row['TOTIVA4'];
$serie     = $row['SERIE'];
$obs       = $row['OBSERV'];
$vendedor  = $row['VENDEDOR'];
$totaliva  = $totiva1 + $totiva2 + $totiva3 + $totiva4;

if( $row['DTCARGA'] == "" ){
    $dtcarga = date("Y-m-d");
}else{
    $dtcarga = $row['DTCARGA'];
}

$lcarga    = $row['LOCALCG'];

$datadoc = date("d/m/Y", strtotime($row['DATA']));

// Dados do cliente
$sql = "SELECT NOME, MORADA, CDPOSTAL, NCONTRIB, REGIVA FROM CLIENTES WHERE CODIGO = '$terceiro'";
$rs  = mssql_query($sql);
$row = mssql_fetch_array($rs);

$nome   = $row['NOME'];
$morada = $row['MORADA'];
$cdp    = $row['CDPOSTAL'];
$nif    = $row['NCONTRIB'];
$riva   = $row['REGIVA'];

// Taxas de IVA
$sql = "select TX1, TX2, TX3, TX4 from RGIVA where CODIGO = '$riva'";
$rs  = mssql_query($sql);
$row = mssql_fetch_array($rs);
$tx1 = $row['TX1'];
$tx2 = $row['TX2'];
$tx3 = $row['TX3'];
$tx4 = $row['TX4'];

// Localidade
$sql = "select DESCR from CODPOST where COD = '$cdp'";
$rs  = mssql_query($sql);
$row = mssql_fetch_array($rs);
$localidade = $row['DESCR'];

// Envio de email a avisar a DATAMAGNA que o cliente leu este documento
/*********************************************************************/
$enc   = '<table>'."\r\n";
$enc  .= '   <tr>'."\r\n";
$enc  .= '       <td style="font-family:verdana;color#5d1d5c;">Dados do Cliente</td>'."\r\n";
$enc  .= '   </tr>'."\r\n";
$enc  .= '   <tr>'."\r\n";
$enc  .= '      <td style="font-family:verdana">';
$enc  .= '          <p>O cliente '.$nome.' leu o documento '.$tdoc.' Nº '.$ndoc.'/'.$serie.' na data '.date("d-m-Y").' às '.date("H:i:s").'</p>';
$enc  .= '      </td>'."\r\n";
$enc  .= '   </tr>'."\r\n";
$enc  .= '</table><br /><br />'."\r\n";


//Obtem emails de destino para enviar email
//Tipo de Acção: 1 - Aviso de leitura de documento
//$mail = new PHPMailer(true);

$sql = "select accao, nome, email_destino from def_emails_envios
                inner join def_emails_envios_tipos
                        on def_emails_envios.nid_tipo_accao = def_emails_envios_tipos.nid
         where nid_tipo_accao = 1";
$rs  = mysql_query($sql);

if( mysql_num_rows($rs) > 0 ){
    while( $row = mysql_fetch_array($rs) ){
        $accao = $row['accao'];
        $from  = $row['email_destino'];
        $fromn = $row['nome'];
        $to    = $row['email_destino'];
        $ton   = $row['nome'];
        
        try {
            $mail->AddReplyTo($from, $fromname);
            $mail->AddAddress($to, $toname);
            $mail->SetFrom($from, $fromname);
            $mail->AddReplyTo($from, $fromname);
        
            $mail->Subject = 'datamagna.com - '.$accao;
            $html = file_get_contents('tpl/tpl_email.html');
            
            $html = str_replace('{$titulo}', $mail->Subject, $html);
            $html = str_replace('{$conteudo}', $enc, $html);
            
            $mail->MsgHTML($html);
            
            $mail->Send();
        
        } catch (phpmailerException $e) {
            echo $e->errorMessage(); //Pretty error messages from PHPMailer
        } catch (Exception $e) {
            echo $e->getMessage(); //Boring error messages from anything else!
        }
        
        
    }
}
/*********************************************************************/

// Regista na tabela bck_estatisticas  abertura deste documento;
/*********************************************************************/
$dreg = date("Y-m-d H:i:s");

$sql = "insert into bck_estatisticas(utilizador, dreg, tpdoc, ndoc, obs, ano, serie) 
            values('$utilizador', '$dreg', '$tdoc', '$ndoc', '$accao', '$ano', '$serie')";
$rs  = mysql_query($sql);
/*********************************************************************/

function Footer()
{
    $this->SetY(1);
    //Select Arial italic 8
    $this->SetFont('Arial','I',8);
    //Print centered page number
    $this->Cell(0,10,'Page sfffffff',0,0,'C');

}

$pdf = new FPDF("P","cm", array(21, 29.9));
$pdf->AliasNbPages();
$pdf->SetAuthor($emp_nome);
$pdf->SetTitle('Documento proveniente de higicol.com');
$pdf->SetAutoPageBreak(false);
$pdf->SetMargins(0,0,0);
$pdf->AddPage();

$pdf->SetFont('Arial','B',9);

//Dados do cliente
$pdf->Rect("11.5", "3.7", "8.5", "2.3");

if( file_exists("../$logot") ){
    $pdf->Image("../$logot");
}

$pdf->SetFont('Arial','B',8);

$pdf->setXY("0.5", "4.2");
$pdf->Cell( 0, 0, $emp_nome);

$pdf->setXY("0.5", "4.6");
$pdf->Cell( 0, 0, "Contribuinte:");

$pdf->SetFont('Arial','',8);

$pdf->setXY("2.3", "4.6");
$pdf->Cell( 0, 0, $emp_nif);

$pdf->SetFont('Arial','',8);
$pdf->setXY("0.5", "5");
$pdf->Cell( 0, 0, $emp_morada." ".$emp_cp." - ".$emp_local);

$pdf->SetFont('Arial','B',8);
$pdf->setXY("0.5", "5.4");
$pdf->Cell( 0, 0, "Tlf:");

$pdf->SetFont('Arial','',8);
$pdf->setXY("1", "5.4");
$pdf->Cell( 0, 0, $emp_tlf);

$pdf->SetFont('Arial','B',8);
$pdf->setXY("2.8", "5.4");
$pdf->Cell( 0, 0, "Fax:");

$pdf->SetFont('Arial','',8);
$pdf->setXY("3.5", "5.4");
$pdf->Cell( 0, 0, $emp_fax);

$pdf->SetFont('Arial','B',8);
$pdf->setXY("0.5", "5.8");
$pdf->Cell( 0, 0, "Email:");

$pdf->SetFont('Arial','',8);
$pdf->setXY("1.4", "5.8");
$pdf->Cell( 0, 0, $emp_email);

$pdf->setXY("0.5", "6.2");
$pdf->Cell( 0, 0, "Capital Social € ".$emp_capsocial." - Reg. ".$emp_regc." C.R.C. STS");

$pdf->SetFont('Arial','IB',9);

// Descrição do Documento
$pdf->SetFillColor( 172, 172, 172);
$pdf->SetTextColor(0,0,0);
$pdf->setXY("11.5", "0.7");
$pdf->Cell("8.5", "0.5", $descr, 1, 0, "C");

// Original
/********************************************************/

$pdf->setXY("11.5", "1.3");
$pdf->Cell("8.5", "0.5", "ORIGINAL", 1, 0, "C");

$pdf->SetFont('Arial','B',9);

$pdf->setXY("11.5", "1.9");
$pdf->Cell("2", "0.5", "Número", 1, 0, "R");

$pdf->setXY("15.8", "1.9");
$pdf->Cell("2", "0.5", "Data", 1, 0, "R");

$pdf->setXY("13.6", "1.9");
$pdf->Cell("2", "0.5", $ndoc, 1, 0, "L");

$pdf->setXY("17.9", "1.9");
//$pdf->Cell("2.1", "0.5", date("d-m-Y", strtotime($datadoc)), 1, 0, "C");
$pdf->Cell("2.1", "0.5", $datadoc, 1, 0, "C");
/********************************************************/

$x = "10.4";
$pdf->setXY("11.6", "3.9");
$pdf->Cell( 0, 0, $nome);

$pdf->SetFont('Arial','',8);

$pdf->setXY("11.6", "4.4");
$pdf->Cell( 0, 0, $morada);

$pdf->setXY("11.6", "4.9");
$pdf->Cell( 0, 0, $cdp);

$pdf->setXY("13.5", "4.9");
$pdf->Cell( 0, 0, $localidade);

$pdf->SetFont('Arial','B',9);

$pdf->setXY("0.5", "6.4");
$pdf->Cell("2.5","0.5",'Cliente',1,0, "C");

$pdf->setXY("3", "6.4");
$pdf->Cell("3.5","0.5",'Contribuinte',1,0, "C");

$pdf->setXY("6.5", "6.4");
$pdf->Cell("2.2","0.5",'Desconto',1,0, "C");

$pdf->setXY("8.7", "6.4");
$pdf->Cell("1.6","0.5",'Zona',1,0, "C");

$pdf->setXY("10.3", "6.4");
$pdf->Cell("1.8","0.5",'Vendedor',1,0, "C");

$pdf->setXY("12.1", "6.4");
$pdf->Cell("3.3","0.5",'Referência',1,0, "C");

$pdf->setXY("15.4", "6.4");
$pdf->Cell("2.2","0.5",'Expedição',1,0, "C");

$pdf->setXY("17.6", "6.4");
$pdf->Cell("2.4","0.5",'Vencim.',1,0, "C");

$pdf->SetFont('Arial','',9);

$pdf->setXY("0.5", "6.9");
$pdf->Cell("2.5","0.5", $terceiro,1,0, "C");

$pdf->setXY("3", "6.9");
$pdf->Cell("3.5","0.5", $nif, 1, 0, "C");

$pdf->setXY("6.5", "6.9");
$pdf->Cell("2.2","0.5", number_format($desccab,2)." %", 1, 0, "C");

$pdf->setXY("8.7", "6.9");
$pdf->Cell("1.6","0.5", '',1,0, "C");

$pdf->setXY("10.3", "6.9");
$pdf->Cell("1.8","0.5",$vendedor,1,0, "C");

$pdf->setXY("12.1", "6.9");
$pdf->Cell("3.3","0.5",'',1,0, "C");

$pdf->setXY("15.4", "6.9");
$pdf->Cell("2.2","0.5",'',1,0, "C");

$dtvenc = date("d/m/Y", strtotime($dtvenc));
$pdf->setXY("17.6", "6.9");
$pdf->Cell("2.4","0.5", $dtvenc,1,0, "C");


/* Detalhes da Factura*/
/****************************************************************/
// Barra de título das linhas da factura

$pdf->SetFont('Arial','B',9);

$pdf->setXY("0.5", "7.6");
$pdf->Cell("2.5","0.5",'Artigo',1,0, "C");

$pdf->setXY("3", "7.6");
$pdf->Cell("7","0.5",'Descrição',1,0, "C");

$pdf->setXY("10", "7.6");
$pdf->Cell("1.5","0.5",'Qtd',1,0, "C");

$pdf->setXY("11.5", "7.6");
$pdf->Cell("2.4","0.5",'Preço',1,0, "C");

$pdf->setXY("13.9", "7.6");
$pdf->Cell("1.4","0.5",'Desc',1,0, "C");

$pdf->setXY("15.3", "7.6");
$pdf->Cell("1","0.5",'Iva',1,0, "C");

$pdf->setXY("16.3", "7.6");
$pdf->Cell("3.7","0.5",'Valor',1,0, "C");

/* Linhas da Factura */
/*****************************************************/

$sql = "SELECT ARTIGO, DESCR, PRUNIT, QUANT, VALOR, DESCONTO, IVA 
            FROM DOCGCLIN 
            WHERE NNUMDOC = '$ndoc' AND TPDOCUM = '$tdoc' AND ANO = '$ano' ORDER BY NUMLINHA asc";
$rs  = mssql_query($sql);

$pdf->SetFont('Arial','',7);

$pdf->Rect("0.5", "8.1", "19.5", "7");

$pdf->Line("0.5", "8.5", "20", "8.5");

$pdf->Line("3", "8.1", "3", "15.6");
$pdf->Line("10", "8.1", "10", "15.6");
$pdf->Line("11.5", "8.1", "11.5", "15.6");
$pdf->Line("13.9", "8.1", "13.9", "15.6");
$pdf->Line("15.3", "8.1", "15.3", "15.6");
$pdf->Line("16.3", "8.1", "16.3", "15.6");



if( mssql_num_rows($rs) > 0 ){
    
    $y      = "8.5";
    $incr   = "0.4";
    $border = 0;
    $max    = 16;
    $i      = 0;
    
    while( $row = mssql_fetch_array($rs) ){
        if( $i == $max ){
            $pdf->AddPage();
            $i = 0;
            $y = "8.5";
        }
        
        $pdf->setXY("0.5", $y);
        $pdf->Cell("2.5","0.5", $row['ARTIGO'], $border,0, "L");
        
        $pdf->setXY("3",$y);
        $pdf->Cell("7","0.5", $row['DESCR'], $border,0, "L");

        $pdf->setXY("10",$y);
        
        if( $row['QUANT'] > 0 ){
            $pdf->Cell("1.5","0.5", number_format($row['QUANT'],3), $border,0, "R");    
        }else{
            $pdf->Cell("1.5","0.5", "", $border,0, "R");
        }
        
        $pdf->setXY("11.5",$y);
                
        if( $row['PRUNIT'] > 0 ){
            $pdf->Cell("2.4","0.5", number_format($row['PRUNIT'],2,",","."), $border,0, "R"); 
        }else{
            $pdf->Cell("2.4","0.5", "", $border,0, "R");
        }

        $pdf->setXY("13.9", $y);
        
        if( $row['DESCONTO'] > 0 ){
            $pdf->Cell("1.4","0.5", number_format($row['DESCONTO'],2,",","."), $border,0, "R"); 
        }else{
            $pdf->Cell("1.4","0.5", "", $border,0, "R");
        }

        $pdf->setXY("15.3", $y);
        
        if( $row['IVA'] > 0 ){
            $pdf->Cell("1","0.5",number_format($row['IVA'],0), $border,0, "R"); 
        }else{
            $pdf->Cell("1","0.5", "", $border,0, "R");
        }

        $pdf->setXY("16.3", $y);
        
        if( $row['VALOR'] > 0 ){
            $pdf->Cell("3.7","0.5", number_format($row['VALOR'],2,",","."), $border,0, "R"); 
        }else{
            $pdf->Cell("3.7","0.5", "", $border,0, "R");
        }
                                                
        $y = $y + $incr;
        $i++;
    }
} 

/******************************************************/

/* Fim da tabela dos detalhes */

$pdf->Rect("0.5", "15.1", "19.5", "0.5");


$pdf->SetFont('Arial','B',6);
$pdf->setXY("0.5", "15.1");
$pdf->Cell("0","0.5",'Total',0,0, "L");

$pdf->setXY("16.5", "15.1");
$pdf->Cell("3.4","0.5", number_format($totmerc,2,",","."), 0, 0, "R");

$pdf->setXY("0.5", "16");
$pdf->MultiCell("19.5", "0.4", "Esta venda é feita sob reserva de propriedade, nos termos do artº 409 do Cod. Civil, pelo que enquanto o valor total deste documento não estiver totalmente liquidado , a mercadoria nele constante permanece nossa propriedade.");

$pdf->setXY("0.5", "17");
$pdf->MultiCell("19.5", "0.4", "Para cumprimento de nº 5 da alínea f) do artº 35 do CIVA, a mercadoria constante neste documento foi colocada à disposição do adquirente em ____/___/___.");

$pdf->SetFont('Arial','B',8);
$pdf->setXY("0.5","17.6");
$pdf->Cell("2.4","0.5", "Incidência", 1, 0, "C");

$pdf->setXY("3","17.6");
$pdf->Cell("1.6","0.5", "Taxa", 1, 0, "C");

$pdf->setXY("4.7","17.6");
$pdf->Cell("2.5","0.5", "Valor Imposto", 1, 0, "C");

$pdf->SetFont('Arial','',7);
$pdf->setXY("0.5","18.2");
$pdf->Cell("2.4","0.4", number_format($base1,2,",","."), 1, 0, "R");

$pdf->setXY("0.5","18.6");
$pdf->Cell("2.4","0.4", number_format($base2,2,",","."), 1, 0, "R");

$pdf->setXY("0.5","19.0");
$pdf->Cell("2.4","0.4", number_format($base3,2,",","."), 1, 0, "R");

$pdf->setXY("0.5","19.4");
$pdf->Cell("2.4","0.4", number_format($base4,2,",","."), 1, 0, "R");

$pdf->setXY("3","18.2");
$pdf->Cell("1.6","0.4", number_format($tx1,2,",","."), 1, 0, "R");

$pdf->setXY("3","18.6");
$pdf->Cell("1.6","0.4", number_format($tx2,2,",","."), 1, 0, "R");

$pdf->setXY("3","19");
$pdf->Cell("1.6","0.4", number_format($tx3,2,",","."), 1, 0, "R");

$pdf->setXY("3","19.4");
$pdf->Cell("1.6","0.4", number_format($tx4,2,",","."), 1, 0, "R");

$pdf->setXY("4.7","18.2");
$pdf->Cell("2.5","0.4", number_format($totiva1,2,",","."), 1, 0, "R");

$pdf->setXY("4.7","18.6");
$pdf->Cell("2.5","0.4", number_format($totiva2,2,",","."), 1, 0, "R");

$pdf->setXY("4.7","19");
$pdf->Cell("2.5","0.4", number_format($totiva3,2,",","."), 1, 0, "R");

$pdf->setXY("4.7","19.4");
$pdf->Cell("2.5","0.4", number_format($totiva4,2,",","."), 1, 0, "R");

$pdf->SetFont('Arial','B',8);
$pdf->setXY("7.4","17.6");
$pdf->Cell("18","0.5", "Observações");

$pdf->Rect("7.3", "18.2", "7", "3.5");
$pdf->setXY("7.4","18.2");
$pdf->MultiCell("5","0.5", $obs, 0);


// Sub Totais no rodape
$pdf->SetFont('Arial','BI',8);
$pdf->setXY("14.8", "17.6");
$pdf->Cell("2.8","0.5", "Total Mercadoria", 1);

$pdf->setXY("17.7", "17.6");
$pdf->Cell("2.2","0.5", number_format($totmerc,2,",","."), 1, 0, "R");

$pdf->setXY("14.8", "18.1");
$pdf->Cell("2.8","0.5", "Despesas", 1);

$pdf->setXY("17.7", "18.1");
$pdf->Cell("2.2","0.5", "", 1);

$pdf->setXY("14.8", "18.6");
$pdf->Cell("2.8","0.5", "Adiantamentos", 1);

$pdf->setXY("17.7", "18.6");
$pdf->Cell("2.2","0.5", "", 1);

$pdf->setXY("14.8", "19.1");
$pdf->Cell("2.8","0.5", "Desc. Cabeçalho", 1);

$pdf->setXY("17.7", "19.1");
$pdf->Cell("2.2","0.5", number_format($desccab,2,",","."), 1, 0, "R");

$pdf->setXY("14.8", "19.6");
$pdf->Cell("2.8","0.5", "Desc. Linhas", 1);

$pdf->setXY("17.7", "19.6");
$pdf->Cell("2.2","0.5", "", 1);

$pdf->setXY("14.8", "20.1");
$pdf->Cell("2.8","0.5", "Total Iva", 1);

$pdf->setXY("17.7", "20.1");
$pdf->Cell("2.2","0.5", number_format($totaliva,2,",","."), 1, 0, "R");

$pdf->setXY("14.8", "20.6");
$pdf->Cell("2.8","0.5", "Total em EUR", 1);

$pdf->setXY("17.7", "20.6");
$pdf->Cell("2.2","0.5", number_format($totaldoc,2,",","."), 1, 0, "R");

$pdf->SetFont('Arial','B',8);
$pdf->setXY("0.5", "22.5");
$pdf->Cell("0","0.5", "Extenso");

if( $totaldoc > 0 ){
    $pdf->SetFont('Arial','',8);
    $extenso = GExtenso::moeda(number_format($totaldoc,2,"",""), 2, array('euro', 'euros', GExtenso::GENERO_MASC), array('cêntimo', 'cêntimos', GExtenso::GENERO_MASC));
}

$pdf->setXY("0.5", "22.9");
$pdf->Cell("19.3","0.5", $extenso, 1);

$pdf->SetFont('Arial','',8);

$pdf->setXY("0.5", "23.6");
$pdf->Cell("1.7","0.4", "Data Carga", 1);

$dtcarga = date("d-m-Y", strtotime($dtcarga));
$hcarga  = date("H:i", strtotime($dtcarga));

$pdf->setXY("2.2", "23.6");
$pdf->Cell("1.8","0.4", $dtcarga, 1);

$pdf->setXY("4.1", "23.6");
$pdf->Cell("1.8","0.4", "Hora Carga", 1);

$pdf->setXY("5.9", "23.6");
$pdf->Cell("1.7","0.4", $hcarga, 1);

$pdf->setXY("0.5", "24.1");
$pdf->Cell("1.7","0.4", "Local Carga", 1);

$pdf->setXY("2.2", "24.1");
$pdf->Cell("5.4","0.4", $lcarga, 1);

$pdf->setXY("0.5", "24.6");
$pdf->Cell("1.7","0.4", "Descarga", 1);

$pdf->setXY("2.2", "24.6");
$pdf->Cell("5.4","0.4", "", 1);

$pdf->setXY("0.5", "25.1");
$pdf->Cell("1.7","0.4", "Transporte", 1);

$pdf->setXY("2.2", "25.1");
$pdf->Cell("5.4","0.4", "", 1);

$pdf->SetFont('Arial','',6);

$pdf->setXY("8", "23.6");
$pdf->Cell("2", "0.4", $descr, 0, 0, "L");

$sql = "select certificado from certificados_docs where tpdoc = '$tdoc' and serie = $serie and numdoc = '$ndoc'";
$rs  = mysql_query($sql);
$row = mysql_fetch_array($rs);
$cert = $row['certificado'];

$pdf->setXY("8","24");
$pdf->Cell("18","0.5", $cert." - Processado por programa certificado nº 17/DGCI - Sage NEXT");

$pdf->Output("Documento","I");
?>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.