Location: PHPKode > projects > PkLasku laskutusohjelma > pklasku/invoice.php
<?php
/*******************************************************************************
PkLasku : web-based invoicing software.
Copyright (C) 2004-2008 Samu Reinikainen

This program is free software. See attached LICENSE.

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

/*******************************************************************************
PkLasku : web-pohjainen laskutusohjelmisto.
Copyright (C) 2004-2008 Samu Reinikainen

Tämä ohjelma on vapaa. Lue oheinen LICENSE.

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

require "htmlfuncs.php";
require "sqlfuncs.php";
require "sessionfuncs.php";
require_once "pdfbarcode128.php";

$strSesID = $_REQUEST['ses'] ? $_REQUEST['ses'] : FALSE;

if( !sesCheckSession( $strSesID ) ) {
    die;
}
require "localize.php";
define('FPDF_FONTPATH','./font/');
require "fpdf.php";

require "datefuncs.php";
require "miscfuncs.php";

$intInvoiceId = (int)$_REQUEST['id'] ? (int)$_REQUEST['id'] : FALSE;
$strType = $_REQUEST['type'] ? $_REQUEST['type'] : 'comp';

$strJoinTable = _DB_PREFIX_. "_company";
$strJoinfield = "company_id";
$strSelect = "invoice_no, invoice_date, due_date, ref_number,". _DB_PREFIX_. "_invoice.name AS invoice_name, reference, company_name AS name, '' AS contact_person, billing_address, CONCAT(company_name, '\n', street_address, '\n', zip_code, ' ', city) AS billing_address2, base_id, ". _DB_PREFIX_. "_company.company_id";

if( $intInvoiceId ) {
    $strQuery = 
        "SELECT ". $strSelect ." ".
        "FROM ". _DB_PREFIX_. "_invoice ".
        "INNER JOIN ". $strJoinTable ." ON ". $strJoinTable .".id = ". _DB_PREFIX_. "_invoice.". $strJoinfield ." ".
        "WHERE ". _DB_PREFIX_. "_invoice.id = " . $intInvoiceId . ";";
    $intRes = mysql_query($strQuery);
    $intNRows = mysql_numrows($intRes);
    if( $intNRows ) {
       $strInvoiceName = mysql_result($intRes, 0, "invoice_name");
       $intBaseId = mysql_result($intRes, 0, "base_id");
       $strClientId = mysql_result($intRes, 0, "company_id");
       $strInvoiceNo = mysql_result($intRes, 0, "invoice_no");
       $strRefNumber = mysql_result($intRes, 0, "ref_number");
       $strInvoiceDate = dateConvIntDate2Date(mysql_result($intRes, 0, "invoice_date"));
       $strDueDate = dateConvIntDate2Date(mysql_result($intRes, 0, "due_date"));
       $strReference = mysql_result($intRes, 0, "reference");
       $strBillingAddress = mysql_result($intRes, 0, "billing_address");
       if( !$strBillingAddress ) {
           $strBillingAddress = mysql_result($intRes, 0, "billing_address2");
       }
       $strCompanyName = substr($strBillingAddress, 0, strpos($strBillingAddress, "\n"));
       $strCompanyAddress = substr($strBillingAddress, strpos($strBillingAddress, "\n")+1);
       $strName = mysql_result($intRes, 0, "name");
       $strContactPerson = mysql_result($intRes, 0, "contact_person");
       
       
       $strReference = $strReference ? $strReference : $strContactPerson;
    }
    $strRefNumber = strrev(chunk_split(strrev($strRefNumber),5,' '));
    
    $strSelect = "SELECT * FROM ". _DB_PREFIX_. "_base WHERE id = $intBaseId";
    $intRes = mysql_query($strSelect);
    
    $strAssociation = mysql_result($intRes, 0, "name");
    $strCompanyID = mysql_result($intRes, 0, "company_id");
    $strAssociation = mysql_result($intRes, 0, "name");
    $strContactPerson = mysql_result($intRes, 0, "contact_person");
    $strStreetAddress = mysql_result($intRes, 0, "street_address");
    $strZipCode = mysql_result($intRes, 0, "zip_code");
    $strCity = mysql_result($intRes, 0, "city");
    $strPhone = mysql_result($intRes, 0, "phone");
    $strBankName = mysql_result($intRes, 0, "bank_name");
    $strBankAccount = mysql_result($intRes, 0, "bank_account");
    $strWww = mysql_result($intRes, 0, "www");
    $strEmail = mysql_result($intRes, 0, "email");
        
    $strAssocAddressLine = 
        $strAssociation. " ". $strStreetAddress. " ". $strZipCode. " ". $strCity;
    $strAssocAddress = 
        $strAssociation. "\n". $strStreetAddress. "\n". $strZipCode. " ". $strCity;
    $strContactInfo = 
        $GLOBALS['locCOMPID']. " : ". $strCompanyID. " ". $GLOBALS['locPHONE']. " : ". $strPhone. " ". $GLOBALS['locEMAIL']. " : ".  $strEmail;
    $strBankInfo = $strBankName. " - ". $strBankAccount;
    
    $strQuery = 
        "SELECT description, pcs, price, row_date, vat, ". _DB_PREFIX_. "_row_type.name AS type ".
        "FROM ". _DB_PREFIX_. "_invoice_row ".
        "INNER JOIN ". _DB_PREFIX_. "_row_type ON ". _DB_PREFIX_. "_row_type.id = ".  _DB_PREFIX_. "_invoice_row.type_id ".
        "WHERE ".  _DB_PREFIX_. "_invoice_row.invoice_id = ". $intInvoiceId. " ORDER BY ". _DB_PREFIX_. "_invoice_row.order_no, row_date, description DESC";
    $intRes = mysql_query($strQuery);
    if( $intRes ) {
        $intNRes = mysql_num_rows($intRes);
        for( $i = 0; $i < $intNRes; $i++ ) {
            $astrDescription[$i] = trim(mysql_result($intRes, $i, "description"));
            $astrRowDate[$i] = dateConvIntDate2Date(mysql_result($intRes, $i, "row_date"));
            $astrRowPrice[$i] = mysql_result($intRes, $i, "price");
            $astrPieces[$i] = mysql_result($intRes, $i, "pcs");
            $astrVAT[$i] = mysql_result($intRes, $i, "vat");
            $astrRowType[$i] = mysql_result($intRes, $i, "type");
            $intRowSum[$i] = $astrPieces[$i] * $astrRowPrice[$i];
            $intRowVAT[$i] = $intRowSum[$i] * ($astrVAT[$i] / 100);
            $intRowSumVAT[$i] = $intRowSum[$i] + $intRowVAT[$i];
            $intTotSum += $intRowSum[$i];
            $intTotVAT += $intRowVAT[$i];
            $intTotSumVAT += $intRowSumVAT[$i];
        }
    }
}
else {
    die("Sorry, no can do!");
}
$pdf=new FPDF('P','mm','A4');
$pdf->AddPage();
$pdf->SetAutoPageBreak(FALSE);

//TOP
//$pdf->Image($GLOBALS['sesLANG']."_images/banner.jpg", 10, 5, 40);

//$pdf->SetFont('Helvetica','B',14);


//sender
$pdf->SetTextColor(125);
$pdf->SetFont('Helvetica','B',10);
$pdf->SetY($pdf->GetY()+5);//
//$pdf->SetX(50);
$pdf->Cell(120, 5, $strAssociation, 0, 1);
$pdf->SetFont('Helvetica','',10);
$pdf->MultiCell(120, 5, $strStreetAddress. "\n". $strZipCode. " ". $strCity,0,1);

//receiver
$pdf->SetTextColor(0);
$pdf->SetFont('Helvetica','B',14);
$pdf->SetY($pdf->GetY()+5);
$pdf->Cell(120, 6, $strCompanyName,0,1);
$pdf->SetFont('Helvetica','',14);
$pdf->MultiCell(120, 6, $strCompanyAddress,0,1);
//$pdf->MultiCell(60, 5, $strBillingAddress,0,1);

//invoiceinfo headers
$pdf->SetXY(115,10);
$pdf->SetFont('Helvetica','B',16);
$pdf->Cell(40, 3, "LASKU $strInvoiceNo", 0, 1, 'R');
$pdf->SetFont('Helvetica','',10);
$pdf->SetXY(115, $pdf->GetY()+5);
/*
$pdf->Cell(40, 5, $GLOBALS['locSENDER'] ." : ", 0, 0, 'R');
$pdf->Cell(60, 5, $strAssociation, 0, 1);
$pdf->SetX(115);
*/
$pdf->SetX(115);
$pdf->Cell(40, 5, $GLOBALS['locCLIENTNO'] ." : ", 0, 0, 'R');
$pdf->Cell(60, 5, $strClientId, 0, 1);
$pdf->SetX(115);
$pdf->Cell(40, 5, $GLOBALS['locINVNO'] ." : ", 0, 0, 'R');
$pdf->Cell(60, 5, $strInvoiceNo, 0, 1);
$pdf->SetX(115);
$pdf->Cell(40, 5, $GLOBALS['locINVDATE'] ." : ", 0, 0, 'R');
$pdf->Cell(60, 5, $strInvoiceDate, 0, 1);
$pdf->SetX(115);
$pdf->Cell(40, 5, $GLOBALS['locDUEDATE'] ." : ", 0, 0, 'R');
$pdf->Cell(60, 5, $strDueDate, 0, 1);
$pdf->SetX(115);
$pdf->Cell(40, 5, $GLOBALS['locREFNO'] ." : ", 0, 0, 'R');
$pdf->Cell(60, 5, $strRefNumber, 0, 1);
$pdf->SetX(115);
$pdf->Cell(40, 5, $GLOBALS['locREFERENCE'] ." : ", 0, 0, 'R');
$pdf->Cell(60, 5, $strReference, 0, 1);

$pdf->SetY($pdf->GetY()+5);
$pdf->Line(5, $pdf->GetY(), 200, $pdf->GetY());
$pdf->SetY($pdf->GetY()+5);

if( $intNRes <= $invoicePdfRows ) {

//middle - invoicerows
//invoiceinfo headers
$pdf->SetXY(7,$pdf->GetY());
if( $showInvoiceRowDate ) {
    $pdf->Cell(60, 5, $GLOBALS['locROWNAME'], 0, 0, "L");
    $pdf->Cell(20, 5, $GLOBALS['locDATE'], 0, 0, "L");
}
else {
    $pdf->Cell(80, 5, $GLOBALS['locROWNAME'], 0, 0, "L");
}
$pdf->Cell(15, 5, $GLOBALS['locPRICE'], 0, 0, "R");
$pdf->Cell(15, 5, $GLOBALS['locPCS'], 0, 0, "R");
$pdf->Cell(15, 5, $GLOBALS['locUNIT'], 0, 0, "R");
$pdf->Cell(20, 5, $GLOBALS['locTOTAL'], 0, 0, "R");
$pdf->Cell(15, 5, $GLOBALS['locVATPERCENT'], 0, 0, "R");
$pdf->Cell(15, 5, $GLOBALS['locTAX'], 0, 0, "R");
$pdf->Cell(20, 5, $GLOBALS['locTOTAL'], 0, 1, "R");

//rows
$pdf->SetY($pdf->GetY()+5);
for( $i = 0; $i < $intNRes; $i++ ) {
    if( $astrRowPrice[$i] == 0 && $astrPieces[$i] == 0 ) {
        $pdf->SetX(7);
        $pdf->MultiCell(0, 5, $astrDescription[$i], 0, 'L');
    }
    else {
        //$pdf->SetY($pdf->GetY()+5);
        if( $showInvoiceRowDate ) {
            $pdf->SetX(67);
            $pdf->Cell(20, 5, $astrRowDate[$i], 0, 0, "L");
        }
        else {
            $pdf->SetX(87);
        }
        $pdf->Cell(15, 5, miscRound2Decim($astrRowPrice[$i]), 0, 0, "R");
        $pdf->Cell(15, 5, miscRound2Decim($astrPieces[$i]), 0, 0, "R");
        $pdf->Cell(15, 5, $astrRowType[$i], 0, 0, "R");
        $pdf->Cell(20, 5, miscRound2Decim($intRowSum[$i]), 0, 0, "R");
        $pdf->Cell(15, 5, $astrVAT[$i], 0, 0, "R");
        $pdf->Cell(15, 5, miscRound2Decim($intRowVAT[$i]), 0, 0, "R");
        $pdf->Cell(20, 5, miscRound2Decim($intRowSumVAT[$i]), 0, 0, "R");
        $pdf->SetX(7);
        if( $showInvoiceRowDate ) {
            $pdf->MultiCell(60, 5, $astrDescription[$i], 0, 'L');
        }
        else {
            $pdf->MultiCell(80, 5, $astrDescription[$i], 0, 'L');
        }
        
        
    }
}
$pdf->SetFont('Helvetica','B',10);
$pdf->SetY($pdf->GetY()+10);
$pdf->Cell(132, 5, $GLOBALS['locTOTAL'] ." : ", 0, 0, "R");
$pdf->Cell(20, 5, miscRound2Decim($intTotSum), 0, 0, "R");
$pdf->Cell(20, 5, miscRound2Decim($intTotVAT), 0, 0, "R");
$pdf->Cell(20, 5, miscRound2Decim($intTotSumVAT), 0, 1, "R");

}
else {
    $pdf->SetFont('Helvetica','B',20);
    $pdf->SetXY(20, $pdf->GetY()+40);
    $pdf->MultiCell(180, 5, "ks. erillinen laskuerittely", 0, 1, "L");
}

if( $showBarcode ) {
    $intStartY = 190;
    $intStartYBorders = 195;
}
else {
    $intStartY = 205;
    $intStartYBorders = 210;
}

//bottom - paymentinfo
$pdf->SetFont('Helvetica','',7);
$pdf->SetXY(7, $intStartY);
$pdf->Cell(75, 5, $strAssocAddressLine, 0, 1, "L");
$pdf->SetXY(80, $intStartY);
$pdf->Cell(80, 5, $strContactInfo, 0, 1, "L");
$pdf->SetXY(150, $intStartY);
$pdf->Cell(50, 5, $strWww, 0, 1, "R");


//borders...
$intStartY = $intStartYBorders;
$intStartX = 7;

$intMaxX = 200;
$pdf->SetLineWidth(0.5);
//1. hor.line - full width
$pdf->Line($intStartX, $intStartY, $intMaxX, $intStartY);
//2. hor.line - start-half page
$pdf->Line($intStartX, $intStartY+16, $intStartX+111.4, $intStartY+16);
//3. hor.line - start-half page
$pdf->Line($intStartX, $intStartY+32, $intStartX+111.4, $intStartY+32);
//4. hor.line - half-end page
$pdf->Line($intStartX+111.4, $intStartY+57.5, $intMaxX, $intStartY+57.5);
//5. hor.line - full width
$pdf->Line($intStartX, $intStartY+66, $intMaxX, $intStartY+66);
//6. hor.line - full width
$pdf->Line($intStartX, $intStartY+74.5, $intMaxX, $intStartY+74.5);
//1. ver.line - 1.hor - 3.hor
$pdf->Line($intStartX+20, $intStartY, $intStartX+20, $intStartY+32);
//1. ver.line - 5.hor - 6.hor
$pdf->Line($intStartX+20, $intStartY+66, $intStartX+20, $intStartY+74.5);
//2. ver.line - full height
$pdf->Line($intStartX+111.4, $intStartY, $intStartX+111.4, $intStartY+74.5);
//3. ver.line - 4.hor - 6. hor
$pdf->Line($intStartX+130, $intStartY+57.5, $intStartX+130, $intStartY+74.5);
//4. ver.line - 5.hor - 6. hor
$pdf->Line($intStartX+160, $intStartY+66, $intStartX+160, $intStartY+74.5);

$pdf->SetLineWidth(0.17);
//underscript
$pdf->Line($intStartX+23, $intStartY+63, $intStartX+90, $intStartY+63);
//account-lines
$tmpStartX = $intStartX+20;
for( $i = 0; $i <= 15; $i++ ) {
    $pdf->Line( $tmpStartX+(5*$i), $intStartY+72.5, $tmpStartX+(5*$i), $intStartY+74.5);
}

//right side
//receiver bank
$pdf->SetFont('Helvetica','',7);
$pdf->SetXY($intStartX, $intStartY + 3);
$pdf->Cell(15, 5, "Saajan", 0, 1, "L");
$pdf->SetXY($intStartX, $intStartY + 8);
$pdf->Cell(15, 5, "tilinumero", 0, 1, "L");
$pdf->SetXY($intStartX + 22,$intStartY + 3);
$pdf->SetFont('Helvetica','',10);
//$pdf->Cell(15, 5, $strBankInfo, 0, 1, "L");
$pdf->Cell(15, 5, $strBankName, 0, 1, "L");
$pdf->SetX($intStartX + 22);
$pdf->Cell(15, 5, $strBankAccount, 0, 1, "L");
//receiver
$pdf->SetFont('Helvetica','',7);
$pdf->SetXY($intStartX, $intStartY + 18);
$pdf->Cell(15, 5, "Saaja", 0, 1, "L");
$pdf->SetFont('Helvetica','',10);
$pdf->SetXY($intStartX + 22,$intStartY + 18);
$pdf->MultiCell(100, 4, $strAssocAddress,0,1);
//payer
$pdf->SetFont('Helvetica','',7);
$pdf->SetXY($intStartX, $intStartY + 35);
$pdf->Cell(15, 5, "Maksaja", 0, 1, "L");
$pdf->SetFont('Helvetica','',10);
$pdf->SetXY($intStartX + 22, $intStartY + 35);
$pdf->MultiCell(100, 4, $strBillingAddress,0,1);
//underscript
$intStartY = $intStartYBorders;
$pdf->SetFont('Helvetica','',7);
$pdf->SetXY($intStartX, $intStartY + 60);
$pdf->Cell(15, 5, "Allekirjoitus", 0, 1, "L");
//from account
$pdf->SetXY($intStartX, $intStartY + 68);
$pdf->Cell(15, 5, "Tililtä", 0, 1, "L");
$pdf->SetXY($intStartX + 51, $intStartY + 68);
$pdf->Cell(15, 5, "-", 0, 1, "L");

//left side
//label
$pdf->SetFont('Helvetica','B',10);
$pdf->SetXY($intStartX + 112.4, $intStartY + 3);
$pdf->Cell(15, 5, "TILISIIRTO", 0, 1, "L");
//info
$pdf->SetFont('Helvetica','',5);
$pdf->SetXY($intStartX + 112.4, $intStartY + 8);
$pdf->MultiCell(70, 2, "Maksu välitetään saajalle vain Suomessa Kotimaan maksujenvälityksen yleisten\nehtojen mukaisesti ja vain maksajan ilmoittaman tilinumeron perusteella.",0,1);
$pdf->SetFont('Helvetica','',10);
$pdf->SetXY($intStartX + 112.4, $intStartY + 20);
$pdf->Cell(70, 5, "Laskunumero ".$strInvoiceNo, 0, 1, "L");
$pdf->SetXY($intStartX + 112.4, $intStartY + 30);
$pdf->Cell(70, 5, "Maksettaessa käytettävä viitenumeroa.", 0, 1, "L");

//pic
$pdf->Image($GLOBALS['sesLANG']."_images/tslogob.jpg", $intMaxX - 10, $intStartY + 3);
$pdf->SetFont('Helvetica','',7);
//refno
$pdf->SetFont('Helvetica','',7);
$pdf->SetXY($intStartX + 112.4, $intStartY + 59);
$pdf->Cell(15, 5, "Viitenro", 0, 1, "L");
$pdf->SetFont('Helvetica','',10);
$pdf->SetXY($intStartX + 131, $intStartY + 59);
$pdf->Cell(15, 5, $strRefNumber, 0, 1, "L");

//duedate
$pdf->SetFont('Helvetica','',7);
$pdf->SetXY($intStartX + 112.4, $intStartY + 68);
$pdf->Cell(15, 5, "Eräpäivä", 0, 1, "L");
$pdf->SetFont('Helvetica','',10);
$pdf->SetXY($intStartX + 131.4, $intStartY + 68);
$pdf->Cell(25, 5, $strDueDate, 0, 1, "L");

//eur
$pdf->SetFont('Helvetica','',7);
$pdf->SetXY($intStartX + 161, $intStartY + 68);
$pdf->Cell(15, 5, "Euro", 0, 1, "L");
$pdf->SetFont('Helvetica','',10);
$pdf->SetXY($intStartX + 151, $intStartY + 68);
$pdf->Cell(40, 5, miscRound2Decim($intTotSumVAT), 0, 1, "R");

//barcode
/*
1  	Currency (1=FIM, 2=EURO. EURO must not be used before 1.1.1999!)
14 	Zero-padded account number. The zeroes are added after the sixth number except in numbers that begin with 4 or 5. Those are padded after the seventh number.
8 	Amount. The format is xxxxxx.xx, so you can't charge your customers millions ;)
20 	Reference Number
6 	Due Date. Format is YYMMDD.
4 	Zero padding
1 	Check code 1
*/
if( $showBarcode ) {
    $tmpAccount = str_replace("-", str_repeat('0', 14 -(strlen($strBankAccount)-1)),$strBankAccount);
    $tmpSum = str_replace(",", "", miscRound2Decim($intTotSumVAT));
    $tmpSum = str_repeat('0', 8 - strlen($tmpSum)). $tmpSum;
    $tmpRefNumber = str_replace(" ", "", $strRefNumber);
    $tmpRefNumber = str_repeat('0', 20 - strlen($tmpRefNumber)). $tmpRefNumber;
    $atmdDueDate = explode(".", $strDueDate);
    $tmpDueDate = substr($atmdDueDate[2], -2). $atmdDueDate[1]. $atmdDueDate[0];
    
    $code_string = "2". $tmpAccount. $tmpSum. $tmpRefNumber. $tmpDueDate. "0000";
    $code_string = $code_string. miscCalcCheckNo($code_string);
    
    $code = new pdfbarcode128($code_string, 3 );
    
    $code->set_pdf_document($pdf);
    $width = $code->get_width();
    $code->draw_barcode(50, 280, 11, FALSE );
    //$code->_dump_pattern();
    //echo "<br><br>". $code_string;
}

if( $intNRes > $invoicePdfRows ) {
    $pdf->AddPage();
    $pdf->SetAutoPageBreak(TRUE);
//middle - invoicerows
//invoiceinfo headers
$pdf->SetXY(7,20);

$pdf->SetFont('Helvetica','B',20);
$pdf->SetXY(20, $pdf->GetY());
$pdf->Cell(80, 5, "Laskuerittely", 0, 0, "L");
$pdf->SetFont('Helvetica','',10);
$pdf->Cell(80, 5, "Laskunro: $strInvoiceNo", 0, 1, "L");
$pdf->SetXY(7, $pdf->GetY()+10);
if( $showInvoiceRowDate ) {
    $pdf->Cell(60, 5, $GLOBALS['locROWNAME'], 0, 0, "L");
    $pdf->Cell(20, 5, $GLOBALS['locDATE'], 0, 0, "L");
}
else {
    $pdf->Cell(80, 5, $GLOBALS['locROWNAME'], 0, 0, "L");
}
$pdf->Cell(15, 5, $GLOBALS['locPRICE'], 0, 0, "R");
$pdf->Cell(15, 5, $GLOBALS['locPCS'], 0, 0, "R");
$pdf->Cell(15, 5, $GLOBALS['locUNIT'], 0, 0, "R");
$pdf->Cell(20, 5, $GLOBALS['locTOTAL'], 0, 0, "R");
$pdf->Cell(15, 5, $GLOBALS['locVATPERCENT'], 0, 0, "R");
$pdf->Cell(15, 5, $GLOBALS['locTAX'], 0, 0, "R");
$pdf->Cell(20, 5, $GLOBALS['locTOTAL'], 0, 1, "R");

//rows
$pdf->SetY($pdf->GetY()+5);
for( $i = 0; $i < $intNRes; $i++ ) {
    if( $astrRowPrice[$i] == 0 && $astrPieces[$i] == 0 ) {
        $pdf->SetX(7);
        $pdf->MultiCell(0, 5, $astrDescription[$i], 0, 'L');
    }
    else {
        //$pdf->SetY($pdf->GetY()+5);
        if( $showInvoiceRowDate ) {
            $pdf->SetX(67);
            $pdf->Cell(20, 5, $astrRowDate[$i], 0, 0, "L");
        }
        else {
            $pdf->SetX(87);
        }
        $pdf->Cell(15, 5, miscRound2Decim($astrRowPrice[$i]), 0, 0, "R");
        $pdf->Cell(15, 5, miscRound2Decim($astrPieces[$i]), 0, 0, "R");
        $pdf->Cell(15, 5, $astrRowType[$i], 0, 0, "R");
        $pdf->Cell(20, 5, miscRound2Decim($intRowSum[$i]), 0, 0, "R");
        $pdf->Cell(15, 5, $astrVAT[$i], 0, 0, "R");
        $pdf->Cell(15, 5, miscRound2Decim($intRowVAT[$i]), 0, 0, "R");
        $pdf->Cell(20, 5, miscRound2Decim($intRowSumVAT[$i]), 0, 0, "R");
        $pdf->SetX(7);
        if( $showInvoiceRowDate ) {
            $pdf->MultiCell(60, 5, $astrDescription[$i], 0, 'L');
        }
        else {
            $pdf->MultiCell(80, 5, $astrDescription[$i], 0, 'L');
        }
        
        
    }
}
$pdf->SetFont('Helvetica','B',10);
$pdf->SetY($pdf->GetY()+10);
$pdf->Cell(132, 5, $GLOBALS['locTOTAL'] ." : ", 0, 0, "R");
$pdf->Cell(20, 5, miscRound2Decim($intTotSum), 0, 0, "R");
$pdf->Cell(20, 5, miscRound2Decim($intTotVAT), 0, 0, "R");
$pdf->Cell(20, 5, miscRound2Decim($intTotSumVAT), 0, 1, "R");

}

$pdf->Output("invoice_". $strInvoiceNo .".pdf","I");
?>
Return current item: PkLasku laskutusohjelma