diff -ruNa diff-1.7/img/style_print.css diff-gaco/img/style_print.css
--- diff-1.7/img/style_print.css	2006-08-28 10:20:33.000000000 +0200
+++ diff-gaco/img/style_print.css	2010-05-11 22:05:49.000000000 +0200
@@ -1,8 +1,8 @@
 BODY		{ font-size: 8pt; font-family: Tahoma, Verdana, Arial, Helvetica; padding: 0pt; background-color: #FFFFFF; }
 BODY.landscape	{ font-size: 8pt; font-family: Tahoma, Verdana, Arial, Helvetica; padding: 0pt; background-color: #FFFFFF; size: landscape; }
 
-TABLE		{ border-collapse: collapse; border-color: #000000 }
-TD		{ font-size: 8pt; }
+TABLE		{ border-collapse: collapse; border-color: #000000; font-size: 8pt; }
+#TD		{ font-size: 8pt; }
 TD.fleft	{ border-left-width: 1pt; border-left-style: solid; }
 TD.fright	{ border-right-width: 1pt; border-right-style: solid; }
 TD.ftop		{ border-top-width: 1pt; border-top-style: solid; }
@@ -14,8 +14,9 @@
 TD.fall		{ border-width: 1pt; border-style: solid; }
 TD.fbt		{ border-bottom-width: 1pt; border-bottom-style: solid; border-top-width: 1pt; border-top-style: solid; }
 TD.flr		{ border-left-width: 1pt; border-left-style: solid; border-right-width: 1pt; border-right-style: solid; }
+#TD.head		{ border-width: 1pt; border-style: solid; }
 TD.head		{ color: white; background-color: black; font-weight: bold; border-width: 1pt; border-style: solid; }
-TD.headgrey	{ color: black; background-color: #A9A9A9; font-weight: bold; border-width: 1pt; border-style: solid; }
+TD.headgrey	{ color: white; background-color: #A9A9A9; font-weight: bold; border-width: 1pt; border-style: solid; border-color: black;}
 
 A		{ text-decoration: none; }
 
@@ -30,6 +31,7 @@
 .hdf		{ font-size: 14pt; }
 .mdf		{ font-size: 12pt; }
 .sdr		{ font-size: 10pt; }
+.sdfr		{ font-size: 8pt; }
 .small		{ font-size: 6pt; }
 .blend		{ color: #888888; }
 .blendbg	{ background-color: #888888; }
diff -ruNa diff-1.7/lib/LMS.class.php diff-gaco/lib/LMS.class.php
--- diff-1.7/lib/LMS.class.php	2010-03-09 19:39:20.000000000 +0100
+++ diff-gaco/lib/LMS.class.php	2010-05-16 01:38:37.000000000 +0200
@@ -854,6 +854,133 @@
 		$saldolist['customerid'] = $id;
 		return $saldolist;
 	}
+	
+	function GetInvoiceBalanceByCustomer($invoice) {
+			
+			$balance = $this->GetCustomerBalanceList($invoice['customerid']);
+			
+			//print_r($balance);
+			$lastperiod=strtotime(date('Y/m/', $invoice['cdate'] - (28 * 24 * 3600)) . date('d', $invoice['cdate']));
+			$currentperiod=strtotime(date('Y/m/', $invoice['cdate']) . date('d', $invoice['cdate']));
+
+			$transactions;
+			$tid = 0;
+			$lastbalance = 0;
+			$currentbalance = 0;
+			$cni = 0;
+			$ini = 0;
+			$balances['current'] = 0;
+			$balances['last'] = 0;
+			$balances['lastdate'] = $lastperiod;
+			$balances['payable'] = 0;
+			$balances['currentdate'] = strtotime(date('Y/m/d', $invoice['cdate'] - (24*3600)));
+			$lastdocid = 0;
+			//echo $balances['lastdate'];
+			for ($i = 0; $i < $balance['total']; $i++) {
+			    if ($balance['time'][$i] <= $lastperiod) {
+				$balances['last'] = $balance['after'][$i];
+    			    }	
+			    $balances['current'] = $balances['last'];
+			    if ($balance['time'][$i] > $lastperiod && $balance['time'][$i] < $currentperiod) {
+				    //
+					    $transactions[$tid]['value'] = $balance['value'][$i];
+					    $transactions[$tid]['date'] = substr($balance['date'][$i], 0, -6);
+					    if($balance['value'][$i] > 0) {
+						    $transactions[$tid]['comment'] = "WPŁATA - DZIĘKUJEMY";
+						    if($balance['type'][$i] == 0) {
+							if($balance['docid'][$i] == $lastdocid && $lastdocid != 0) {
+							    $transactions[$tid-1]['value'] = $transactions[$tid-1]['value'] + $balance['value'][$i];
+							    array_pop($transactions);
+							    $tid--;
+							}			
+							if($balance['doctype'][$i] == 3) {
+								$cncontent = $this->GetInvoiceContent($balance['docid'][$i]);
+								$transactions[$tid]['comment'] = 'Faktura korygująca nr ' . docnumber($cncontent['number'], $cncontent['template'], $cncontent['cdate']);		    
+							}
+							elseif($balance['doctype'][$i] == 1) {
+								$cncontent = $this->GetInvoiceContent($balance['docid'][$i]);
+								$transactions[$tid]['comment'] = 'Faktura nr ' . docnumber($cncontent['number'], $cncontent['template'], $cncontent['cdate']);
+							}
+							else {
+							    $transactions[$tid]['comment'] = "KOREKTA ZOBOWIĄZANIA";							
+							}
+						    }	    
+					    }
+					    else {	
+						    $transactions[$tid]['comment'] = $balance['comment'][$i];
+						    if($balance['type'][$i] == 0) {
+							if($balance['docid'][$i] == $lastdocid && $lastdocid != 0) {
+							    $transactions[$tid-1]['value'] = $transactions[$tid-1]['value'] + $balance['value'][$i];
+							    array_pop($transactions);
+							    $tid--;
+							}				    
+							if($balance['doctype'][$i] == 3) {
+								$cncontent = $this->GetInvoiceContent($balance['docid'][$i]);
+								$transactions[$tid]['comment'] = 'Faktura korygująca nr ' . docnumber($cncontent['number'], $cncontent['template'], $cncontent['cdate']);	    
+							}
+							if($balance['doctype'][$i] == 1) {
+								$cncontent = $this->GetInvoiceContent($balance['docid'][$i]);
+								$transactions[$tid]['comment'] = 'Faktura nr ' . docnumber($cncontent['number'], $cncontent['template'], $cncontent['cdate']);
+							}
+						    }
+						
+					    }
+				    $tid++;
+				    $lastdocid = $balance['docid'][$i];
+			    }
+			}
+			//echo '		Stan konta z poprzedniego okresu: ' . $balances['last'] . '<br>';
+			if($transactions) {
+				foreach ($transactions as $trans) {
+			//		echo $trans['date'] . '     ' . $trans['comment'] . '    ' . $trans['value'] . "<br>";
+					$balances['current'] = $balances['current'] + $trans['value'];
+				}
+			}		
+
+			if ( $balances['last'] < 0 ) {
+				$balances['lastcomment'] = "Stan konta - niedopłata";
+			}
+			if ( $balances['last'] > 0 ) {
+				$balances['lastcomment'] = "Stan konta - nadpłata";
+			}
+			if ( $balances['last'] == 0 ) {
+				$balances['lastcomment'] = "Stan konta";
+			}
+
+			if ( $balances['current'] < 0 ) {
+				$balances['currentcomment'] = "Stan konta - niedopłata";
+			}
+			if ( $balances['current'] > 0 ) {
+				$balances['currentcomment'] = "Stan konta - nadpłata";
+			}
+			if ( $balances['current'] == 0 ) {
+				$balances['currentcomment'] = "Stan konta";
+			}
+			//echo $balances['lastdate'] . '     ' . $balances['comment'] . '      ' . $balances['current'] . ' <br> ';	
+			$balances['total'] = $balances['current'] - $invoice['total'];
+			//echo $balances['total'];
+			if ( $balances['total'] < 0 ) {
+				$balances['payable'] = abs($balances['total']);
+				$balances['totalcomment'] = "Bieżący stan konta - niedopłata";
+			}
+			if ( $balances['total'] > 0 ) {
+				$balances['totalcomment'] = "Bieżący stan konta - nadpłata";
+			}
+			if ( $balances['total'] == 0 ) {
+				$balances['totalcomment'] = "Bieżący stan konta";
+			}
+			
+			//preg_match('/(\d{2})(\d{4})(\d{4})(\d{4})(\d{4})(\d{4})(\d{4})/', bankaccount($invoice['customerid']), $baarray);
+						
+			//for ($i=1;$i<=7;$i++) {
+			//	$balances['bankaccount'] = $balances['bankaccount'] ' ' . $baarray[$i];
+			//	}
+			
+			return array($balances, $transactions);
+	}
+    
+	
+	
 
 	function CustomerStats()
 	{
diff -ruNa diff-1.7/lib/Smarty/plugins/modifier.iban_fmt.php diff-gaco/lib/Smarty/plugins/modifier.iban_fmt.php
--- diff-1.7/lib/Smarty/plugins/modifier.iban_fmt.php	1970-01-01 01:00:00.000000000 +0100
+++ diff-gaco/lib/Smarty/plugins/modifier.iban_fmt.php	2010-05-16 01:36:28.000000000 +0200
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty lower modifier plugin
+ *
+ * Type:     modifier<br>
+ * Name:     lower<br>
+ * Purpose:  convert string to lowercase
+ * @link http://smarty.php.net/manual/en/language.modifier.lower.php
+ *          lower (Smarty online manual)
+ * @author   Monte Ohrt <monte at ohrt dot com>
+ * @param string
+ * @return string
+ */
+function smarty_modifier_iban_fmt($string)
+{
+    preg_match('/(\d{2})(\d{4})(\d{4})(\d{4})(\d{4})(\d{4})(\d{4})/', $string, $matches);
+    for ($i=1;$i<=7;$i++) {
+        $bankaccount = $bankaccount . ' ' . $matches[$i];
+    }
+										    
+    return $bankaccount;
+    
+}
+
+?>
diff -ruNa diff-1.7/modules/customerbalancegaco.php diff-gaco/modules/customerbalancegaco.php
--- diff-1.7/modules/customerbalancegaco.php	1970-01-01 01:00:00.000000000 +0100
+++ diff-gaco/modules/customerbalancegaco.php	2010-05-10 19:31:50.000000000 +0200
@@ -0,0 +1,102 @@
+<?php
+
+/*
+ * LMS version 1.10.7 Sina
+ *
+ *  (C) Copyright 2001-2010 LMS Developers
+ *
+ *  Please, see the doc/AUTHORS for more information about authors!
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License Version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ *  USA.
+ *
+ *  $Id: customerbalance.php,v 1.7.2.3 2010/02/26 09:39:21 alec Exp $
+ */
+
+$SESSION->save('backto', $_SERVER['QUERY_STRING']);
+
+if(!$LMS->CustomerExists($_GET['id']))
+	header("Location: ?m=customerlist");
+
+$customername=$LMS->GetCustomerName($_GET['id']);
+$id = $_GET['id'];
+
+$layout['pagetitle'] = trans('Customer Balance: $0', '<A HREF="?m=customerinfo&id='.$_GET['id'].'">'.$customername.'</A>');
+
+$balance = $LMS->GetCustomerBalanceList($_GET['id']);
+
+#$date = new DateTime();
+#$date->setDate(2010, 04, 14);
+#$lastbalance = $date->getTimestamp();
+
+$lastperiod=strtotime('2010/04/14');
+$currentperiod=strtotime('2010/05/14');
+#echo $lastbalance;
+#strtotime(
+#print_r($balance);
+$transactions;
+$tid = 0;
+$lastbalance = 0;
+$currentbalance = 0;
+
+
+$balances['current'] = 0;
+$balances['last'] = 0;
+$balances['comment'];
+$balances['final'];
+$balances['payable'];
+$balances['lastdate'] = "2010/05/13";
+
+
+
+for ($i = 0; $i < $balance['total']; $i++) {
+    if ($balance['time'][$i] <= $lastperiod) {
+	$balances['last'] = $balance['after'][$i];
+    }
+    $balances['current'] = $balances['last'];
+    if ($balance['time'][$i] > $lastperiod && $balance['time'][$i] < $currentperiod) {
+	if($balance['type'][$i] == 1) {
+	    $transactions[$tid]['value'] = $balance['value'][$i];
+	    $transactions[$tid]['date'] = substr($balance['date'][$i], 0, -6);
+	    if($balance['value'][$i] > 0) {
+		$transactions[$tid]['comment'] = "WPŁATA - DZIĘKUJEMY";
+	    }
+	    else {
+		$transactions[$tid]['comment'] = $balance['comment'][$i];
+	    }
+	}
+#$balances['current'] = $balance['after'][$i];
+#	echo $balance['value'][$i] . ' ' . $balance['time'][$i] . ' ' . $balance['date'][$i] . '<br>';
+    }
+}
+echo 'Stan konta z poprzedniego okresu: ' . $balances['last'] . '<br>';
+if($transactions) {
+foreach ($transactions as $trans) {
+    echo $trans['date'] . '     ' . $trans['comment'] . '    ' . $trans['value'] . "<br>";
+    $balances['current'] = $balances['current'] + $trans['value'];
+}
+}
+
+
+if ( $balances['current'] < 0 ) {
+    $balances['comment'] = "Stan konta - niedopłata";
+}
+if ( $balances['current'] > 0 ) {
+    $balances['comment'] = "Stan konta - nadpłata";
+}
+if ( $balances['current'] == 0 ) {
+    $balances['comment'] = "Stan konta";
+}
+echo $balances['lastdate'] . '     ' . $balances['comment'] . '      ' . $balances['current'];
+?>
diff -ruNa diff-1.7/modules/ibanlist.php diff-gaco/modules/ibanlist.php
--- diff-1.7/modules/ibanlist.php	1970-01-01 01:00:00.000000000 +0100
+++ diff-gaco/modules/ibanlist.php	2010-03-22 15:48:11.000000000 +0100
@@ -0,0 +1,15 @@
+<?php
+    echo "name;adres;zip;city;iban";
+    $ownerid = $LMS->GetNodeOwner($_GET['nid']);
+    $customer = $LMS->GetCustomerNames();
+    foreach ($customer as $value) {
+	$customerinfo = $LMS->GetCustomer($value['id']);
+	$customername = $customerinfo['customername'];
+	$iban = $customerinfo['bankaccount'];
+	$adres = $customerinfo['address'];
+	$zip = $customerinfo['zip'];
+	$city = $customerinfo['city'];
+    echo "\r\n";
+    echo "$customername;$adres;$zip;$city;$iban";
+    }
+?>
diff -ruNa diff-1.7/modules/invoice.php diff-gaco/modules/invoice.php
--- diff-1.7/modules/invoice.php	2010-02-26 10:44:07.000000000 +0100
+++ diff-gaco/modules/invoice.php	2010-05-11 03:51:56.000000000 +0200
@@ -31,6 +31,19 @@
     die;
 }
 
+if(strtolower($CONFIG['invoices']['type']) == 'wkpdf')
+{
+    include('invoice_wkpdf.php');
+    $SESSION->close();
+    die;
+}
+
+
+
+
+
+
+
 header('Content-Type: '.$CONFIG['invoices']['content_type']);
 if(isset($CONFIG['invoices']['attachment_name']) && $CONFIG['invoices']['attachment_name'] != '')
 	header('Content-Disposition: attachment; filename='.$CONFIG['invoices']['attachment_name']);
diff -ruNa diff-1.7/modules/invoice_wkpdf.php diff-gaco/modules/invoice_wkpdf.php
--- diff-1.7/modules/invoice_wkpdf.php	1970-01-01 01:00:00.000000000 +0100
+++ diff-gaco/modules/invoice_wkpdf.php	2010-05-13 16:04:14.000000000 +0200
@@ -0,0 +1,266 @@
+<?php
+
+/*
+ * LMS version 1.10.7 Sina
+ *
+ *  (C) Copyright 2001-2010 LMS Developers
+ *
+ *  Please, see the doc/AUTHORS for more information about authors!
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License Version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ *  USA.
+ *
+ *  $Id: invoice.php,v 1.66.2.4 2010/02/26 09:39:23 alec Exp $
+ */
+require_once('wkhtmltopdf.php');
+$pdf = new WKPDF();
+					        
+header('Content-Type: '.$CONFIG['invoices']['content_type']);
+if(isset($CONFIG['invoices']['attachment_name']) && $CONFIG['invoices']['attachment_name'] != '')
+	header('Content-Disposition: attachment; filename='.$CONFIG['invoices']['attachment_name']);
+
+$SMARTY->assign('css', file('img/style_print.css')); 
+
+if(isset($_GET['print']) && $_GET['print'] == 'cached')
+{
+	$SESSION->restore('ilm', $ilm);
+	$SESSION->remove('ilm');
+
+	if(sizeof($_POST['marks']))
+		foreach($_POST['marks'] as $id => $mark)
+			$ilm[$id] = $mark;
+	if(sizeof($ilm))
+		foreach($ilm as $mark)
+			$ids[] = $mark;
+
+	if(!$ids)
+	{
+		$SESSION->close();
+		die;
+	}
+
+	$layout['pagetitle'] = trans('Invoices');
+	$invoicehtml = $SMARTY->fetch('invoiceheader.html');
+	
+	if($_GET['cash'])
+	{
+		foreach($ids as $cashid)
+		{
+			// we need to check if that document is an invoice or credit note
+			if($invoiceid = $DB->GetOne('SELECT docid FROM cash, documents WHERE docid = documents.id AND (documents.type=? OR documents.type=?) AND cash.id = ?', array(DOC_INVOICE, DOC_CNOTE, $cashid)))
+				$idsx[] = $invoiceid;
+		}
+		$ids = array_unique((array)$idsx);
+	}
+
+	sort($ids);
+	
+	if(isset($_GET['original'])) $which[] = trans('ORIGINAL');
+	if(isset($_GET['copy'])) $which[] = trans('COPY');
+	if(isset($_GET['duplicate'])) $which[] = trans('DUPLICATE');
+
+	if(!sizeof($which)) $which[] = trans('ORIGINAL');
+	
+	$count = sizeof($ids) * sizeof($which);
+	$i=0;
+	foreach($ids as $idx => $invoiceid)
+	{
+		$invoice = $LMS->GetInvoiceContent($invoiceid);
+		$invoice['serviceaddr'] = $LMS->GetCustomerServiceAddress($invoice['customerid']);
+		foreach($which as $type)
+		{
+			$i++;
+			if($i == $count) $invoice['last'] = TRUE;
+			$SMARTY->assign('type',$type);
+			$SMARTY->assign('duplicate',$type==trans('DUPLICATE') ? TRUE : FALSE);
+			$SMARTY->assign('invoice',$invoice);
+			
+			$ibalance = $LMS->GetInvoiceBalanceByCustomer($invoice);				
+			//print_r($ibalance[0]);
+			$SMARTY->assign('ibalance',$ibalance[0]);
+			$SMARTY->assign('transactions',$ibalance[1]);
+			
+			
+			
+			//$invoicehtml = $invoicehtml . ' <b> jebany test funkcji: ' . print_r($ibalance) . '</b><br>';
+				
+			
+			if(isset($invoice['invoice']))
+				    $invoicehtml = $invoicehtml . $SMARTY->fetch($CONFIG['invoices']['cnote_template_file']);
+			else	
+				    $invoicehtml = $invoicehtml . $SMARTY->fetch($CONFIG['invoices']['template_file']);
+			    
+				
+		}
+	}
+	$invoicehtml = $invoicehtml . $SMARTY->fetch('clearfooter.html');
+	$pdf->set_html($invoicehtml);
+	$pdf->render();
+	$pdf->output(WKPDF::$PDF_EMBEDDED, 'invoice.pdf');
+}
+elseif(isset($_GET['fetchallinvoices']))
+{
+	$layout['pagetitle'] = trans('Invoices');
+
+	$ids = $DB->GetCol('SELECT id FROM documents d
+				WHERE cdate >= ? AND cdate <= ? AND (type = ? OR type = ?)'
+				.($_GET['customerid'] ? ' AND customerid = '.$_GET['customerid'] : '')
+				.' AND NOT EXISTS (
+					SELECT 1 FROM customerassignments a
+				        JOIN excludedgroups e ON (a.customergroupid = e.customergroupid)
+					WHERE e.userid = lms_current_user() AND a.customerid = d.customerid)' 
+				.' ORDER BY CEIL(cdate/86400), id',
+				array($_GET['from'], $_GET['to'], DOC_INVOICE, DOC_CNOTE));
+	if(!$ids)
+	{
+		$SESSION->close();
+		die;
+	}
+
+	if(isset($_GET['original'])) $which[] = trans('ORIGINAL');
+	if(isset($_GET['copy'])) $which[] = trans('COPY');
+	if(isset($_GET['duplicate'])) $which[] = trans('DUPLICATE');
+	
+	if(!sizeof($which)) $which[] = trans('ORIGINAL');
+
+	$count = sizeof($ids) * sizeof($which);
+	$i=0;
+	$invoicehtml = $SMARTY->fetch('invoiceheader.html');
+	//$SMARTY->display('invoiceheader.html');
+
+	foreach($ids as $idx => $invoiceid)
+	{
+		$invoice = $LMS->GetInvoiceContent($invoiceid);
+		$invoice['serviceaddr'] = $LMS->GetCustomerServiceAddress($invoice['customerid']);
+		foreach($which as $type)
+		{
+			$i++;
+			if($i == $count) $invoice['last'] = TRUE;
+			$SMARTY->assign('type',$type);
+			$SMARTY->assign('duplicate',$type==trans('DUPLICATE') ? TRUE : FALSE);
+			$SMARTY->assign('invoice',$invoice);
+			
+			$ibalance = $LMS->GetInvoiceBalanceByCustomer($invoice);				
+			$SMARTY->assign('ibalance',$ibalance[0]);
+			$SMARTY->assign('transactions',$ibalance[1]);
+			//print_r($ibalance);
+			if(isset($invoice['invoice']))
+				    $invoicehtml = $invoicehtml . $SMARTY->fetch($CONFIG['invoices']['cnote_template_file']);
+			else	
+				    $invoicehtml = $invoicehtml . $SMARTY->fetch($CONFIG['invoices']['template_file']);
+			
+			
+			//if(isset($invoice['invoice']))
+			//	$SMARTY->display($CONFIG['invoices']['cnote_template_file']);
+			//else
+			//	$SMARTY->display($CONFIG['invoices']['template_file']);
+		}
+	}
+	$invoicehtml = $invoicehtml . $SMARTY->fetch('clearfooter.html');
+	$pdf->set_html($invoicehtml);
+	$pdf->render();
+	$pdf->output(WKPDF::$PDF_EMBEDDED, 'invoice.pdf');
+	
+	//$SMARTY->display('clearfooter.html');
+}
+elseif(isset($_GET['fetchsingle']))
+{
+	$invoice = $LMS->GetInvoiceContent($_GET['id']);
+	$number = docnumber($invoice['number'], $invoice['template'], $invoice['cdate']);
+	if( !$invoice['invoice'])
+		$layout['pagetitle'] = trans('Invoice No. $0', $number);
+	else
+		$layout['pagetitle'] = trans('Credit Note No. $0', $number);
+	$invoice['last'] = TRUE;
+	$invoice['serviceaddr'] = $LMS->GetCustomerServiceAddress($invoice['customerid']);
+	$SMARTY->assign('invoice',$invoice);
+	$invoicehtml = $SMARTY->fetch('invoiceheader.html');
+	//$SMARTY->display('invoiceheader.html');
+	$SMARTY->assign('type',trans('ORIGINAL'));
+	
+	$ibalance = $LMS->GetInvoiceBalanceByCustomer($invoice);				
+	$SMARTY->assign('ibalance',$ibalance[0]);
+	$SMARTY->assign('transactions',$ibalance[1]);
+	
+	
+	if(isset($invoice['invoice']))
+		$invoicehtml = $invoicehtml . $SMARTY->fetch($CONFIG['invoices']['cnote_template_file']);
+	else	
+		$invoicehtml = $invoicehtml . $SMARTY->fetch($CONFIG['invoices']['template_file']);
+	
+	//if(isset($invoice['invoice']))
+	//	$SMARTY->display($CONFIG['invoices']['cnote_template_file']);
+	//else
+	//	$SMARTY->display($CONFIG['invoices']['template_file']);
+	
+	$invoicehtml = $invoicehtml . $SMARTY->fetch('clearfooter.html');
+	$pdf->set_html($invoicehtml);
+	$pdf->render();
+	$pdf->output(WKPDF::$PDF_EMBEDDED, 'invoice.pdf');
+	//echo $invoicehtml;
+	//$SMARTY->display('clearfooter.html');
+}
+elseif($invoice = $LMS->GetInvoiceContent($_GET['id']))
+{
+	$number = docnumber($invoice['number'], $invoice['template'], $invoice['cdate']);
+	if(!isset($invoice['invoice']))
+		$layout['pagetitle'] = trans('Invoice No. $0', $number);
+	else
+		$layout['pagetitle'] = trans('Credit Note No. $0', $number);
+	$invoice['serviceaddr'] = $LMS->GetCustomerServiceAddress($invoice['customerid']);
+	$SMARTY->assign('invoice',$invoice);
+	$invoicehtml = $SMARTY->fetch('invoiceheader.html');
+	//$SMARTY->display('invoiceheader.html');
+	$SMARTY->assign('type',trans('ORIGINAL'));
+	
+	$ibalance = $LMS->GetInvoiceBalanceByCustomer($invoice);				
+	$SMARTY->assign('ibalance',$ibalance[0]);
+	$SMARTY->assign('transactions',$ibalance[1]);
+	
+	if(isset($invoice['invoice']))
+		    $invoicehtml = $invoicehtml . $SMARTY->fetch($CONFIG['invoices']['cnote_template_file']);
+	else	
+		    $invoicehtml = $invoicehtml . $SMARTY->fetch($CONFIG['invoices']['template_file']);
+	
+	//if(isset($invoice['invoice']))
+	//	$SMARTY->display($CONFIG['invoices']['cnote_template_file']);
+	//else
+	//	$SMARTY->display($CONFIG['invoices']['template_file']);
+	$SMARTY->assign('type',trans('COPY'));
+	$invoice['last'] = TRUE;
+	$SMARTY->assign('invoice',$invoice);
+	
+	if(isset($invoice['invoice']))
+		    $invoicehtml = $invoicehtml . $SMARTY->fetch($CONFIG['invoices']['cnote_template_file']);
+	else	
+		    $invoicehtml = $invoicehtml . $SMARTY->fetch($CONFIG['invoices']['template_file']);
+	
+	//if(isset($invoice['invoice']))
+	//	$SMARTY->display($CONFIG['invoices']['cnote_template_file']);
+	//else
+	//	$SMARTY->display($CONFIG['invoices']['template_file']);
+	
+	$invoicehtml = $invoicehtml . $SMARTY->fetch('clearfooter.html');
+	$pdf->set_html($invoicehtml);
+	$pdf->render();
+	$pdf->output(WKPDF::$PDF_EMBEDDED, 'invoice.pdf');
+	//echo $invoicehtml;
+	//$SMARTY->display('clearfooter.html');
+}
+else
+{
+	$SESSION->redirect('?m=invoicelist');
+}
+
+?>
diff -ruNa diff-1.7/templates/customerinfobox.html diff-gaco/templates/customerinfobox.html
--- diff-1.7/templates/customerinfobox.html	2009-12-14 15:37:15.000000000 +0100
+++ diff-gaco/templates/customerinfobox.html	2010-05-16 01:37:49.000000000 +0200
@@ -158,7 +158,7 @@
 			<IMG SRC="img/card.gif" ALT="">
 		</TD>
 		<TD WIDTH="99%" COLSPAN="2" NOWRAP>
-			{$customerinfo.bankaccount}
+			{$customerinfo.bankaccount|iban_fmt}
 		</TD>
 	</TR>
 {/if}	
diff -ruNa diff-1.7/templates/invoice_wkpdf.html diff-gaco/templates/invoice_wkpdf.html
--- diff-1.7/templates/invoice_wkpdf.html	1970-01-01 01:00:00.000000000 +0100
+++ diff-gaco/templates/invoice_wkpdf.html	2010-05-16 02:08:58.000000000 +0200
@@ -0,0 +1,494 @@
+<!--// $Id: invoice.html,v 1.63 2007/07/17 11:13:03 alec Exp $ //-->
+
+<DIV{if !$invoice.last} STYLE="page-break-after: always"{/if}>
+<div STYLE="position: relative; top:324px; left:-685px;"><hr color="gray" size="1"></div>
+<TABLE WIDTH="100%" CELLSPACING="3" CELLPADDING="3">
+	<TR>
+		<TD WIDTH="75%" CLASS="hdf" VALIGN="TOP">
+			{number number=$invoice.number template=$invoice.template time=$invoice.cdate assign=number}
+			{if $invoice.invoice}
+			    {number number=$invoice.invoice.number template=$invoice.invoice.template time=$invoice.invoice.cdate assign=number_ref}
+			    <B>{t 0=$number}Credit Note No. $0{/t}</B><BR>
+			    <B class="mdf">{t 0=$number_ref}for Invoice No. $0{/t}</B><BR>
+			{else}
+			    <B>{t 0=$number}Invoice No. $0{/t}</B><BR>
+			{/if}
+			<B>{$type}</B>
+			{if $duplicate}
+			<BR><font class="sdr">{t}Duplicate draw-up date:{/t} {$smarty.now|date_format:"%d.%m.%Y"}</font>
+			{/if}
+		</TD>
+		<TD WIDTH="24%" NOWRAP ALIGN="LEFT" VALIGN="TOP" CLASS="sdr">
+			{t}Draw-up date:{/t}<BR>
+			{t}Sale date:{/t}<BR>
+			<B>{t}Deadline:{/t}<BR>
+			{t}Payment type:{/t}</B>
+		</TD>
+		<TD WIDTH="1%" NOWRAP ALIGN="RIGHT" VALIGN="TOP" CLASS="sdr">
+			{$invoice.cdate|date_format:"%d.%m.%Y"}{if $_config.invoices.cplace neq ""}, {$_config.invoices.cplace}{/if}<BR>
+			{$invoice.cdate|date_format:"%d.%m.%Y"}<BR>
+			<B>{$invoice.pdate|date_format:"%d.%m.%Y"}<BR>
+			{$invoice.paytype}</B>
+		</TD>
+	</TR>
+	<TR>
+		<TD COLSPAN="3" ALIGN="CENTER" WIDTH="100%">
+			&nbsp;
+		</TD>
+	</TR>
+</TABLE>
+<TABLE WIDTH="100%" CELLSPACING="3">
+	<TR>
+		<TD WIDTH="50%" VALIGN="TOP">
+			<B>{t}Seller:{/t}</B><BR>
+			<BR>
+			{$_config.invoices.header|replace:"\\n":"<BR>"}
+			<!--
+			Nr rach: {$ibalance.bankaccount}
+			<BR>
+			-->
+			<B>{t}Purchaser:{/t}</B><BR>
+			<BR>
+			ID Klienta: {$invoice.customerid|string_format:"%04d"}<BR>
+			<b>{$invoice.name}</b><BR>
+			{$invoice.address}<BR>
+			{$invoice.zip} {$invoice.city}<BR>
+			{if $invoice.ten neq ""}{t}TEN:{/t} {$invoice.ten}<BR>{/if}
+			<BR>
+		</TD>
+		<TD WIDTH="10%">
+		    &nbsp;
+		</TD>
+		<TD WIDTH="50%" VALIGN="TOP" CLASS="sdr">
+			<BR>
+			<BR>
+			<BR>
+			{if $invoice.serviceaddr neq ""}
+				<b>{$invoice.serviceaddr|replace:"\n":"<BR>"}</b><BR>
+			{else}
+			<B>{$invoice.name}<BR>
+			{$invoice.address}<BR>
+			{$invoice.zip} {$invoice.city}<BR>
+			{/if}</B>
+		</TD>
+	</TR>
+	<TR>
+		<TD WIDTH="100%" COLSPAN="2">
+			&nbsp;<BR>
+			&nbsp;
+		</TD>
+	</TR>
+</TABLE><BR>
+<TABLE WIDTH="100%" CELLPADDING="3" class="sdfr">
+    <TR class="FALL">
+	<TD WIDTH="1%" CLASS="headgrey" ALIGN="CENTER">
+		<B>{t}No.{/t}</B>
+	</TD>
+	<TD WIDTH="{if $invoice.discount}90{else}91{/if}%" CLASS="headgrey" ALIGN="CENTER">
+		<B>{t}Name of Product, Commodity or Service:{/t}</B>
+	</TD>
+	<!--
+	<TD WIDTH="1%" CLASS="headgrey" ALIGN="CENTER">
+		<B>{t}Product ID:{/t}</B>
+	</TD>
+	-->
+	<TD WIDTH="1%" CLASS="headgrey" ALIGN="CENTER">
+		<B>{t}Unit:{/t}</B>
+	</TD>
+	<TD WIDTH="10%" CLASS="headgrey" ALIGN="CENTER">
+		<B>{t}Amount:{/t}</B>
+	</TD>
+	{if $invoice.discount}
+	<TD WIDTH="1%" CLASS="headgrey" ALIGN="CENTER">
+		<B>{t}Discount:{/t}</B>
+	</TD>
+	{/if}
+	<TD WIDTH="1%" CLASS="headgrey" ALIGN="CENTER">
+		<B>Cena netto</B>
+	</TD>
+	<TD WIDTH="1%" CLASS="headgrey" ALIGN="CENTER">
+		<B>{t}Net Value:{/t}</B>
+	</TD>
+	<TD WIDTH="1%" CLASS="headgrey" ALIGN="CENTER">
+		<B>{t}Tax Rate:{/t}</B>
+	</TD>
+	<TD WIDTH="1%" CLASS="headgrey" ALIGN="CENTER">
+		<B>{t}Tax Value:{/t}</B>
+	</TD>
+	<TD WIDTH="1%" CLASS="headgrey" ALIGN="CENTER">
+		<B>{t}Gross Value:{/t}</B>
+	</TD>
+    </TR>
+{if $invoice.invoice}
+    <TR>
+	<TD COLSPAN="{if $invoice.discount}10{else}9{/if}" CLASS="fbottom">
+		<B>{t}Was:{/t}</B>
+	</TD>
+    </TR>
+{cycle values="grey,white" print=false}
+{counter start=0 print=false}
+{foreach from=$invoice.invoice.content item=item}
+    <TR class="{cycle}">
+	<TD WIDTH="1%" CLASS="FLR" ALIGN="RIGHT">{counter}.</TD>
+	<TD WIDTH="{if $invoice.discount}90{else}91{/if}%" CLASS="FLR">
+		{$item.description}
+	</TD>
+	<!--
+	<TD WIDTH="1%" CLASS="FLR">
+		{$item.prodid}
+	</TD>
+	-->
+	<TD WIDTH="1%" CLASS="FLR" ALIGN="CENTER">
+		{$item.content}
+	</TD>
+	<TD CLASS="FLR" ALIGN="CENTER">
+		{$item.count|string_format:"%.2f"}
+	</TD>
+	{if $invoice.discount}
+	<TD WIDTH="1%" CLASS="FLR" ALIGN="RIGHT" NOWRAP>
+		{$item.discount|string_format:"%.2f"} %
+	</TD>
+	{/if}
+	<TD WIDTH="1%" CLASS="FLR" ALIGN="RIGHT" NOWRAP>
+		{$item.basevalue|money_format}
+	</TD>
+	<TD WIDTH="1%" CLASS="FLR" ALIGN="RIGHT" NOWRAP>
+		{$item.totalbase|money_format}
+	</TD>
+	<TD WIDTH="1%" CLASS="FLR" ALIGN="RIGHT" NOWRAP>
+		{$item.taxlabel}
+	</TD>
+	<TD WIDTH="1%" CLASS="FLR" ALIGN="RIGHT" NOWRAP>
+		{$item.totaltax|money_format}
+	</TD>
+	<TD WIDTH="1%" CLASS="FLR" ALIGN="RIGHT" NOWRAP>
+		{$item.total|money_format}
+	</TD>
+    </TR>
+{/foreach}
+    <TR>
+	<TD COLSPAN="{if $invoice.discount}6{else}5{/if}" ALIGN="RIGHT" CLASS="ftop" STYLE="text-align: right">
+		<P ALIGN="RIGHT"><B>{t}Total:{/t}</B></P>
+	</TD>
+	<TD WIDTH="1%" ALIGN="RIGHT" CLASS="fall" NOWRAP>
+		{$invoice.invoice.totalbase|money_format}
+	</TD>
+	<TD WIDTH="1%" CLASS="fall" ALIGN="RIGHT">
+		<B>x</B>
+	</TD>
+	<TD WIDTH="1%" CLASS="fall" ALIGN="RIGHT" NOWRAP>
+		{$invoice.invoice.totaltax|money_format}
+	</TD>
+	<TD WIDTH="1%" CLASS="fall" ALIGN="RIGHT" NOWRAP>
+		{$invoice.invoice.total|money_format}
+	</TD>
+    </TR>
+<!--
+    <TR>
+	<TD COLSPAN="{if $invoice.discount}6{else}5{/if}" ALIGN="RIGHT">
+		&nbsp;
+	</TD>
+	<TD COLSPAN="4" WIDTH="4%" ALIGN="CENTER">
+		<B>{t}in it:{/t}</B>
+	</TD>
+    </TR>
+{foreach from=$invoice.invoice.taxest item=item}
+    <TR>
+	<TD COLSPAN="{if $invoice.discount}6{else}5{/if}" ALIGN="RIGHT">
+		&nbsp;
+	</TD>
+	<TD WIDTH="1%" ALIGN="RIGHT" CLASS="fall" NOWRAP>
+		{$item.base|money_format}
+	</TD>
+	<TD WIDTH="1%" CLASS="fall" ALIGN="RIGHT">
+		{$item.taxlabel}
+	</TD>
+	<TD WIDTH="1%" CLASS="fall" ALIGN="RIGHT" NOWRAP>
+		{$item.tax|money_format}
+	</TD>
+	<TD WIDTH="1%" CLASS="fall" ALIGN="RIGHT" NOWRAP>
+		{$item.total|money_format}
+	</TD>
+    </TR>
+{/foreach}
+-->
+    <TR>
+	<TD COLSPAN="{if $invoice.discount}10{else}9{/if}" CLASS="fbottom">
+		<B>{t}Corrected to:{/t}</B>
+	</TD>
+    </TR>
+{/if}
+{cycle values="grey,white" print=false reset=true name=cycle2}
+{counter start=0 print=false}
+{foreach from=$invoice.content item=item}
+    <TR class="{cycle name=cycle2}">
+	<TD WIDTH="1%" CLASS="FLR" ALIGN="RIGHT">{counter}.</TD>
+	<TD WIDTH="{if $invoice.discount}90{else}91{/if}%" CLASS="FLR">
+		{$item.description}
+	</TD>
+	<!--
+	<TD WIDTH="1%" CLASS="FLR">
+		{$item.prodid}
+	</TD>
+	-->
+	
+	<TD WIDTH="1%" CLASS="FLR" ALIGN="CENTER">
+		{$item.content}
+	</TD>
+	<TD CLASS="FLR" ALIGN="CENTER">
+		{$item.count|string_format:"%.2f"}
+	</TD>
+	{if $invoice.discount}
+	<TD WIDTH="1%" CLASS="FLR" ALIGN="RIGHT" NOWRAP>
+		{$item.discount|string_format:"%.2f"} %
+	</TD>
+	{/if}
+	<TD WIDTH="1%" CLASS="FLR" ALIGN="RIGHT" NOWRAP>
+		{$item.basevalue|money_format}
+	</TD>
+	<TD WIDTH="1%" CLASS="FLR" ALIGN="RIGHT" NOWRAP>
+		{$item.totalbase|money_format}
+	</TD>
+	<TD WIDTH="1%" CLASS="FLR" ALIGN="RIGHT" NOWRAP>
+		{$item.taxlabel}
+	</TD>
+	<TD WIDTH="1%" CLASS="FLR" ALIGN="RIGHT" NOWRAP>
+		{$item.totaltax|money_format}
+	</TD>
+	<TD WIDTH="1%" CLASS="FLR" ALIGN="RIGHT" NOWRAP>
+		{$item.total|money_format}
+	</TD>
+    </TR>
+    {/foreach}
+    <TR>
+	<TD COLSPAN="{if $invoice.discount}6{else}5{/if}" ALIGN="RIGHT" CLASS="ftop" STYLE="text-align: right">
+		<P ALIGN="RIGHT"><B>{t}Total:{/t}</B></P>
+	</TD>
+	<TD WIDTH="1%" ALIGN="RIGHT" CLASS="fall" NOWRAP>
+		{$invoice.totalbase|money_format}
+	</TD>
+	<TD WIDTH="1%" CLASS="fall" ALIGN="RIGHT">
+		<B>x</B>
+	</TD>
+	<TD WIDTH="1%" CLASS="fall" ALIGN="RIGHT" NOWRAP>
+		{$invoice.totaltax|money_format}
+	</TD>
+	<TD WIDTH="1%" CLASS="fall" ALIGN="RIGHT" NOWRAP>
+		{$invoice.total|money_format}
+	</TD>
+    </TR>
+<!--
+    <TR>
+	<TD COLSPAN="{if $invoice.discount}6{else}5{/if}" ALIGN="RIGHT">
+		&nbsp;
+	</TD>
+	<TD COLSPAN="4" WIDTH="4%" ALIGN="CENTER">
+		<B>{t}in it:{/t}</B>
+	</TD>
+    </TR>
+    {foreach from=$invoice.taxest item=item}
+    <TR>
+	<TD COLSPAN="{if $invoice.discount}6{else}5{/if}" ALIGN="RIGHT">
+		&nbsp;
+	</TD>
+	<TD WIDTH="1%" ALIGN="RIGHT" CLASS="fall" NOWRAP>
+		{$item.base|money_format}
+	</TD>
+	<TD WIDTH="1%" CLASS="fall" ALIGN="RIGHT">
+		{$item.taxlabel}
+	</TD>
+	<TD WIDTH="1%" CLASS="fall" ALIGN="RIGHT" NOWRAP>
+		{$item.tax|money_format}
+	</TD>
+	<TD WIDTH="1%" CLASS="fall" ALIGN="RIGHT" NOWRAP>
+		{$item.total|money_format}
+	</TD>
+    </TR>
+    {/foreach}
+-->
+    {if $invoice.invoice}
+	{math assign=totalbase equation="x-y" x=$invoice.totalbase y=$invoice.invoice.totalbase}
+	{math assign=totaltax equation="x-y" x=$invoice.totaltax y=$invoice.invoice.totaltax}
+	{math assign=total equation="x-y" x=$invoice.total y=$invoice.invoice.total}
+    <TR>
+	<TD COLSPAN="{if $invoice.discount}10{else}9{/if}"></TD>
+    </TR>
+    <TR>
+	<TD COLSPAN="{if $invoice.discount}6{else}5{/if}" ALIGN="RIGHT">
+		<B>{t}Difference value:{/t}</B>
+	</TD>
+	<TD WIDTH="1%" ALIGN="RIGHT" CLASS="fall" NOWRAP>
+		{if $totalbase > 0}+{/if}{$totalbase|money_format}
+	</TD>
+	<TD WIDTH="1%" CLASS="fall" ALIGN="RIGHT">
+		<B>x</B>
+	</TD>
+	<TD WIDTH="1%" CLASS="fall" ALIGN="RIGHT" NOWRAP>
+		{if $totaltax > 0}+{/if}{$totaltax|money_format}
+	</TD>
+	<TD WIDTH="1%" CLASS="fall" ALIGN="RIGHT" NOWRAP>
+		{if $total > 0}+{/if}{$total|money_format}
+	</TD>
+    </TR>
+    {/if}
+    {if $invoice.reason}
+    <TR>
+	<TD COLSPAN="{if $invoice.reason}10{else}9{/if}">
+		<B>{t}Reason:{/t}</B> {$invoice.reason}
+	</TD>
+    </TR>
+    {/if}
+</TABLE>
+
+
+<TABLE WIDTH="100%" CELLPADDING="3">
+	<TR>
+		<TD WIDTH="100%" COLSPAN="2">
+			&nbsp;
+		</TD>
+	</TR>
+	<TR>
+		<TD WIDTH="50%" ALIGN="CENTER" ROWSPAN="2">
+			{t}Expositor:{/t} {if $invoice.user}{$invoice.user}{else}{$_config.invoices.default_author}{/if}
+			
+		</TD>
+		<TD WIDTH="50%" ALIGN="RIGHT" CLASS="hdf">
+			{if $invoice.rebate}
+			{t}To repay:{/t} {$invoice.value|money_format}
+			{else}
+			{t}To pay:{/t} {$invoice.value|money_format}
+			{/if}
+		</TD>
+	</TR>
+	<TR>
+		<TD WIDTH="50%" ALIGN="RIGHT" CLASS="SDR">
+			{t}In words:{/t}
+			{if $_config.phpui.to_words_short_version}
+				{$invoice.value|string_format:"%d"|to_words:0:"":1} {$invoice.valuep|string_format:"%02d"}/100
+			{else}
+				{t 0=$invoice.value|string_format:"%d"|to_words 1=$invoice.valuep|to_words}$0 dollars $1 cents{/t}
+			{/if}
+		</TD>
+	</TR>
+	<TR>
+		<TD>
+		</TD>
+		<TD WIDTH="50%" >
+			&nbsp;
+			{if $invoice.invoice}<br><br><br><p align="center">Podpis odbiorcy: </p>{/if}
+		</TD>
+	</TR>
+	
+</TABLE>
+<br><br>
+{if not $invoice.invoice}
+<TABLE WIDTH="100%">
+<TR>
+<td WIDTH="42%">
+</td>
+<TD WIDTJ="58%">
+<table WIDTH="100%" CELLPADDING="1" CELLSPACING="1" class="sdfr">
+<tr class="sdr">
+    <td colspan="3" ALIGN="CENTER" VALIGN="MIDDLE" class="headgrey"><b>ROZLICZENIE ZOBOWIĄZAŃ</b></td>
+</tr>
+<tr>
+    <td width="17%"><b>Data</b></td>
+    <td width="56%"><b>Tranzakcja</b></td>
+    <td width="27%" ALIGN="RIGHT"><b>Kwota brutto</b></td>
+</tr>
+<tr>
+    <td colspan="3" CELLPADDING="0"><hr color="black" size="1"></hr></td>
+</tr>
+<tr>
+    <td>{$ibalance.lastdate|date_format:"%d.%m.%y"}</td>
+    <td>{$ibalance.lastcomment}</td>
+    <td ALIGN="RIGHT">{$ibalance.last|money_format}</td>
+</tr>
+
+{cycle values="white,grey" print=false reset=true name=cycle2}
+{foreach from=$transactions item=item}
+<tr class="{cycle name=cycle2}">
+    <td>{$item.date|date_format:"%d.%m.%y"}</td>
+    <td VALIGN="TOP">{$item.comment}</td>
+    <td ALIGN="RIGHT">{$item.value|money_format}</td>
+</tr>
+{/foreach}
+<tr>
+    <td colspan="3" CELLPADDING="0"><hr color="black" size="1"></hr></td>
+</tr>
+<tr>
+    <td>{$ibalance.currentdate|date_format:"%d.%m.%y"}</td>
+    <td>{$ibalance.currentcomment}</td>
+    <td ALIGN="RIGHT">{$ibalance.current|money_format}</td>
+</tr>
+<tr>
+    <td>{$invoice.cdate|date_format:"%d.%m.%y"}</td>
+    <td>Faktura bieżąca nr {$number}</td>
+    <td ALIGN="RIGHT">-{$invoice.total|money_format}</td>
+</tr>
+<tr>
+    <td colspan="3" CELLPADDING="0"><hr color="black" size="1"></hr></td>
+</tr>
+<tr class="sdr">
+    <td></td>
+    <td>{$ibalance.totalcomment}</td>
+    <td ALIGN="RIGHT">{$ibalance.total|money_format}</td>
+</tr>
+<tr class="hdf">
+    <td></td>
+    <td class="">Pozostało do zapłaty</td>
+    <td ALIGN="RIGHT" class=""><b>{$ibalance.payable|money_format}</b></td>
+</tr>
+
+</table>
+</td>
+
+</tr>
+</table>
+</TD>
+</TR>
+<br><br><br>
+<center>Wpłat należy dokonywać na indywidualny numer rachunku rozliczeniowego przypisany do Państwa: <br><b class="sdr">{bankaccount|iban_fmt id=$invoice.customerid}</b></center><br>
+{/if}
+<br><br>
+
+<TABLE WIDTH="100%" CELLPADDING="3">
+<TR>
+		<TD WIDTH="100%" COLSPAN="2">
+			<B>{t}Cautions:{/t}</B><BR>
+			<BLOCKQUOTE>
+			
+			W przypadku pytań lub niejasności prosimy o kontakt z biurem obsługi pod numerem <b class="sdr">728-998-903</b><BR>
+			</BLOCKQUOTE>
+			<BR>
+		</TD>
+</TR>
+</TABLE>
+<br>
+<TABLE WIDTH="100%" CELLPADDING="3">
+	<TR>
+		<TD WIDTH="100%" ALIGN="CENTER" COLSPAN="2" CLASS="hd1">
+			<B>{t}Thanks for using our services!{/t}</B>
+		</TD>
+	</TR>
+	<TR>
+		<TD WIDTH="100%" ALIGN="CENTER" COLSPAN="2">
+			{$_config.invoices.footer|replace:"\\n":"<BR>"}
+		</TD>
+	</TR>
+</TABLE>
+
+
+
+
+<!-- The Other Page of Invoice customerbalancelist + customerpin -->
+<!-- insert page break here and buy auto-duplex printer :p -->
+
+<!-- {if $invoice.customerpin}
+	<BR><BR>
+	<B>{t}Customer ID:{/t} {$invoice.customerid|string_format:"%04d"}</B><BR>
+	PIN: <CODE>{$invoice.customerpin|string_format:"%04d"}</CODE>
+	<BR><BR>
+{/if} -->
+
+</DIV>
diff -ruNa diff-1.7/wkhtmltopdf.php diff-gaco/wkhtmltopdf.php
--- diff-1.7/wkhtmltopdf.php	1970-01-01 01:00:00.000000000 +0100
+++ diff-gaco/wkhtmltopdf.php	2010-05-11 01:55:02.000000000 +0200
@@ -0,0 +1,267 @@
+<?php
+
+        // Automated configuration. Modify these if they fail. (they shouldn't ;) )
+        $GLOBALS['WKPDF_BASE_PATH']=str_replace(str_replace('\\','/',getcwd().'/'),'',dirname(str_replace('\\','/',__FILE__))).'/';
+        $GLOBALS['WKPDF_BASE_SITE']='http://'.$_SERVER['SERVER_NAME'].'/';
+
+        /**
+         * @author Christian Sciberras
+         * @see <a href="http://code.google.com/p/wkhtmltopdf/">http://code.google.com/p/wkhtmltopdf/</a>
+         * @copyright 2010 Christian Sciberras / Covac Software.
+         * @license None. There are no restrictions on use, however keep copyright intact.
+         *   Modification is allowed, keep track of modifications below in this comment block.
+         * @example
+         *   <font color="#008800"><i>//-- Create sample PDF and embed in browser. --//</i></font><br>
+         *   <br>
+         *   <font color="#008800"><i>// Include WKPDF class.</i></font><br>
+         *   <font color="#0000FF">require_once</font>(<font color="#FF0000">'wkhtmltopdf/wkhtmltopdf.php'</font>);<br>
+         *   <font color="#008800"><i>// Create PDF object.</i></font><br>
+         *   <font color="#EE00EE">$pdf</font>=new <b>WKPDF</b>();<br>
+         *   <font color="#008800"><i>// Set PDF's HTML</i></font><br>
+         *   <font color="#EE00EE">$pdf</font>-><font color="#0000FF">set_html</font>(<font color="#FF0000">'Hello &lt;b&gt;Mars&lt;/b&gt;!'</font>);<br>
+         *   <font color="#008800"><i>// Convert HTML to PDF</i></font><br>
+         *   <font color="#EE00EE">$pdf</font>-><font color="#0000FF">render</font>();<br>
+         *   <font color="#008800"><i>// Output PDF. The file name is suggested to the browser.</i></font><br>
+         *   <font color="#EE00EE">$pdf</font>-><font color="#0000FF">output</font>(<b>WKPDF</b>::<font color="#EE00EE">$PDF_EMBEDDED</font>,<font color="#FF0000">'sample.pdf'</font>);<br>
+         * @version
+         *   0.0 Chris - Created class.<br>
+         *   0.1 Chris - Variable paths fixes.<br>
+         *   0.2 Chris - Better error handlng (via exceptions).<br>
+         * <font color="#FF0000"><b>IMPORTANT: Make sure that there is a folder in %LIBRARY_PATH%/tmp that is writable!</b></font>
+         * <br><br>
+         * <b>Features/Bugs/Contact</b><br>
+         * Found a bug? Want a modification? Contact me at <a href="mailto:uuf6429@gmail.com">uuf6429@gmail.com</a> or <a href="mailto:contact@covac-software.com">contact@covac-software.com</a>...
+         *   guaranteed to get a reply within 2 hours at most (daytime GMT+1).
+         */
+        class WKPDF {
+                /**
+                 * Private use variables.
+                 */
+                private $html='';
+                private $cmd='';
+                private $tmp='';
+                private $pdf='';
+                private $status='';
+                private $orient='Portrait';
+                private $size='A4';
+                private $toc=false;
+                private $copies=1;
+                private $grayscale=false;
+                private $title='';
+                private static $cpu='';
+                /**
+                 * Advanced execution routine.
+                 * @param string $cmd The command to execute.
+                 * @param string $input Any input not in arguments.
+                 * @return array An array of execution data; stdout, stderr and return "error" code.
+                 */
+                private static function _pipeExec($cmd,$input=''){
+                        $proc=proc_open($cmd,array(0=>array('pipe','r'),1=>array('pipe','w'),2=>array('pipe','w')),$pipes);
+                        fwrite($pipes[0],$input);
+                        fclose($pipes[0]);
+                        $stdout=stream_get_contents($pipes[1]);
+                        fclose($pipes[1]);
+                        $stderr=stream_get_contents($pipes[2]);
+                        fclose($pipes[2]);
+                        $rtn=proc_close($proc);
+                        return array(
+                                        'stdout'=>$stdout,
+                                        'stderr'=>$stderr,
+                                        'return'=>$rtn
+                                );
+                }
+                /**
+                 * Function that attempts to return the kind of CPU.
+                 * @return string CPU kind ('amd64' or 'i386').
+                 */
+                private static function _getCPU(){
+                        if(self::$cpu==''){
+                                if(`grep -i amd /proc/cpuinfo`!='')                     self::$cpu='amd64';
+                                elseif(`grep -i intel /proc/cpuinfo`!='')       self::$cpu='i386';
+                                else throw new Exception('WKPDF couldn\'t determine CPU ("'.`grep -i vendor_id /proc/cpuinfo`.'").');
+                        }
+                        return self::$cpu;
+                }
+                /**
+                 * Force the client to download PDF file when finish() is called.
+                 */
+                public static $PDF_DOWNLOAD='D';
+                /**
+                 * Returns the PDF file as a string when finish() is called.
+                 */
+                public static $PDF_ASSTRING='S';
+                /**
+                 * When possible, force the client to embed PDF file when finish() is called.
+                 */
+                public static $PDF_EMBEDDED='I';
+                /**
+                 * PDF file is saved into the server space when finish() is called. The path is returned.
+                 */
+                public static $PDF_SAVEFILE='F';
+                /**
+                 * PDF generated as landscape (vertical).
+                 */
+                public static $PDF_PORTRAIT='Portrait';
+                /**
+                 * PDF generated as landscape (horizontal).
+                 */
+                public static $PDF_LANDSCAPE='Landscape';
+                /**
+                 * Constructor: initialize command line and reserve temporary file.
+                 */
+                public function __construct(){
+                        $this->cmd=$GLOBALS['WKPDF_BASE_PATH'].'wkhtmltopdf-'.self::_getCPU();
+                        if(!file_exists($this->cmd))throw new Exception('WKPDF static executable "'.htmlspecialchars($this->cmd,ENT_QUOTES).'" was not found.');
+                        do{
+                                $this->tmp=$GLOBALS['WKPDF_BASE_PATH'].'tmp/'.mt_rand().'.html';
+                        } while(file_exists($this->tmp));
+                }
+                /**
+                 * Set orientation, use constants from this class.
+                 * By default orientation is portrait.
+                 * @param string $mode Use constants from this class.
+                 */
+                public function set_orientation($mode){
+                        $this->orient=$mode;
+                }
+                /**
+                 * Set page/paper size.
+                 * By default page size is A4.
+                 * @param string $size Formal paper size (eg; A4, letter...)
+                 */
+                public function set_page_size($size){
+                        $this->size=$size;
+                }
+                /**
+                 * Whether to automatically generate a TOC (table of contents) or not.
+                 * By default TOC is disabled.
+                 * @param boolean $enabled True use TOC, false disable TOC.
+                 */
+                public function set_toc($enabled){
+                        $this->toc=$enabled;
+                }
+                /**
+                 * Set the number of copies to be printed.
+                 * By default it is one.
+                 * @param integer $count Number of page copies.
+                 */
+                public function set_copies($count){
+                        $this->copies=$count;
+                }
+                /**
+                 * Whether to print in grayscale or not.
+                 * By default it is OFF.
+                 * @param boolean True to print in grayscale, false in full color.
+                 */
+                public function set_grayscale($mode){
+                        $this->grayscale=$mode;
+                }
+                /**
+                 * Set PDF title. If empty, HTML <title> of first document is used.
+                 * By default it is empty.
+                 * @param string Title text.
+                 */
+                public function set_title($text){
+                        $this->title=$text;
+                }
+                /**
+                 * Set html content.
+                 * @param string $html New html content. It *replaces* any previous content.
+                 */
+                public function set_html($html){
+                        $this->html=$html;
+                        file_put_contents($this->tmp,$html);
+                }
+                /**
+                 * Returns WKPDF print status.
+                 * @return string WPDF print status.
+                 */
+                public function get_status(){
+                        return $this->status;
+                }
+                /**
+                 * Attempts to return the library's full help.
+                 * @return string WKHTMLTOPDF HTML help.
+                 */
+                public function get_help(){
+                        $tmp=self::_pipeExec('"'.$this->cmd.'" --extended-help');
+                        return $tmp['stdout'];
+                }
+                /**
+                 * Convert HTML to PDF.
+                 */
+                public function render(){
+                        $web='tmp/'.basename($this->tmp);
+                        $this->pdf=self::_pipeExec(
+                                '"'.$this->cmd.'"'
+                                .(($this->copies>1)?' --copies '.$this->copies:'')                              // number of copies
+                                .' --orientation '.$this->orient                                                                // orientation
+                                .' --page-size '.$this->size                                                                    // page size
+                                .($this->toc?' --toc':'')                                                                               // table of contents
+                                .($this->grayscale?' --grayscale':'')                                                   // grayscale
+                                .(($this->title!='')?' --title "'.$this->title.'"':'')                  // title
+                            	.' "'.$web.'" -'                                                                                                // URL and optional to write to STDOUT
+                        );
+                        if(strpos(strtolower($this->pdf['stderr']),'error')!==false)throw new Exception('WKPDF system error: <pre>'.$this->pdf['stderr'].'</pre>');
+                        if($this->pdf['stdout']=='')throw new Exception('WKPDF didn\'t return any data. <pre>'.$this->pdf['stderr'].'</pre>');
+                        if(((int)$this->pdf['return'])>1)throw new Exception('WKPDF shell error, return code '.(int)$this->pdf['return'].'.');
+                        $this->status=$this->pdf['stderr'];
+                        $this->pdf=$this->pdf['stdout'];
+                        unlink($this->tmp);
+                }
+                /**
+                 * Return PDF with various options.
+                 * @param string $mode How two output (constants from this same class).
+                 * @param string $file The PDF's filename (the usage depends on $mode.
+                 * @return string|boolean Depending on $mode, this may be success (boolean) or PDF (string).
+                 */
+                public function output($mode,$file){
+                        switch($mode){
+                                case self::$PDF_DOWNLOAD:
+                                        if(!headers_sent()){
+                                                header('Content-Description: File Transfer');
+                                                header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
+                                                header('Pragma: public');
+                                                header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
+                                                header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
+                                                // force download dialog
+                                                header('Content-Type: application/force-download');
+                                                header('Content-Type: application/octet-stream', false);
+                                                header('Content-Type: application/download', false);
+                                                header('Content-Type: application/pdf', false);
+                                                // use the Content-Disposition header to supply a recommended filename
+                                                header('Content-Disposition: attachment; filename="'.basename($file).'";');
+                                                header('Content-Transfer-Encoding: binary');
+                                                header('Content-Length: '.strlen($this->pdf));
+                                                echo $this->pdf;
+                                        }else{
+                                                throw new Exception('WKPDF download headers were already sent.');
+                                        }
+                                        break;
+                                case self::$PDF_ASSTRING:
+                                        return $this->pdf;
+                                        break;
+                                case self::$PDF_EMBEDDED:
+                                        if(!headers_sent()){
+                                                header('Content-Type: application/pdf');
+                                                header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
+                                                header('Pragma: public');
+                                                header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
+                                                header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
+                                                header('Content-Length: '.strlen($this->pdf));
+                                                header('Content-Disposition: inline; filename="'.basename($file).'";');
+                                                echo $this->pdf;
+                                        }else{
+                                                throw new Exception('WKPDF embed headers were already sent.');
+                                        }
+                                        break;
+                                case self::$PDF_SAVEFILE:
+                                        return file_put_contents($file,$this->pdf);
+                                        break;
+                                default:
+                                        throw new Exception('WKPDF invalid mode "'.htmlspecialchars($mode,ENT_QUOTES).'".');
+                        }
+                        return false;
+                }
+        }
+?>

