AddPage();
$pdf->SetAutoPageBreak(FALSE);
//TOP
//$pdf->Image($GLOBALS['sesLANG']."_images/banner.jpg", 10, 5, 40);
//$pdf->SetFont('Helvetica','B',12);
//sender
//$pdf->SetTextColor(125);
$pdf->SetFont('Helvetica','B',12);
$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',12);
$pdf->SetY($pdf->GetY()+5);
$pdf->Cell(120, 6, $strCompanyName,0,1);
$pdf->SetFont('Helvetica','',12);
$pdf->MultiCell(120, 6, $strCompanyAddress,0,1);
//$pdf->MultiCell(60, 5, $strBillingAddress,0,1);
//invoiceinfo headers
$pdf->SetXY(115,10);
$pdf->SetFont('Helvetica','B',12);
//$pdf->Cell(40, 3, "LASKU $strInvoiceNo", 0, 1, 'R');
$pdf->Cell(40, 3, "LASKU", 0, 1, 'R');
$pdf->SetFont('Helvetica','',10);
$pdf->SetXY(115, $pdf->GetY()+5);
/*
//$pdf->Cell(40, 5, $GLOBALS[' '] ." : ", 0, 0, 'R');
//$pdf->Cell(40, 5, [' '] ." : ", 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 "
". $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");
?>