setColor(0.8,0.4,0.1);
$pdf->addtext(28+$x,281+$y,7,"nazwa odbiorcy");
$pdf->addtext(28+$x,221+$y,7,"nr rachunku odbiorcy");
$pdf->addtext(28+$x,193+$y,7,iconv('UTF-8', 'ISO-8859-2',"kwota do zap��aty"));
$pdf->addtext(28+$x,160+$y,7,"nazwa zleceniodawcy");
if ($ks_w) {
$pdf->addtext(28+$x,100+$y,7,"identyfikator Abonenta");
} else {
$pdf->addtext(28+$x,100+$y,7,"nr faktury");
}
$pdf->addtext(28+$x,43+$y,7,iconv('UTF-8', 'ISO-8859-2',"Op��ata"));
$pdf->addtext(12+$x,100+$y,7,iconv('UTF-8', 'ISO-8859-2',"Odcinek dla wp��acaj��cego"),-90);
$pdf->setColor(0,0,0);
$pdf->setLineStyle(0.5);
$pdf->setStrokeColor(0.8,0.4,0.1);
$pdf->saveState();
$pdf->setLineStyle(0.5,'','',array(3,3));
$pdf->line( $x,$y, $x,289+$y);
$pdf->line(178+$x,$y,178+$x,289+$y);
$pdf->ellipse(142+$x,34+$y,21);
// $pdf->ellipse(490+$x,34+$y,21);
$pdf->restoreState();
// Op��ata
$pdf->line( 20+$x, 20+$y, 80+$x, 20+$y);
$pdf->line( 20+$x, 35+$y, 80+$x, 35+$y);
for ($i=20;$i<=80;$i+=15) {
$pdf->line( $i+$x, 20+$y, $i+$x, 35+$y);
}
$pdf->line( $x, $y,176+$x, $y);
$pdf->line(108+$x, 68+$y,176+$x, 68+$y);
$pdf->line( 20+$x, 74+$y,176+$x, 74+$y);
$pdf->line( 20+$x,108+$y,176+$x,108+$y);
$pdf->line( 20+$x,168+$y,176+$x,168+$y);
$pdf->line( 20+$x,201+$y,176+$x,201+$y);
$pdf->line( 20+$x,229+$y,176+$x,229+$y);
$pdf->line( $x,289+$y,176+$x,289+$y);
// Pionowe kreski
$pdf->line( 20+$x, 74+$y, 20+$x,289+$y);
$pdf->line(108+$x, $y,108+$x, 68+$y);
$pdf->line(176+$x, $y,176+$x,289+$y);
}
$pdf->addtext(28+$x,265+$y,12, iconv('UTF-8', 'ISO-8859-2',$shortname));
$pdf->addtext(28+$x,251+$y,12, iconv('UTF-8', 'ISO-8859-2',$address));
$pdf->addtext(28+$x,237+$y,12, iconv('UTF-8', 'ISO-8859-2',$zip." ".$city));
if ($invoice['pdate']<1323094300) {
$pdf->addtext(28+$x,208+$y,9, "95 1140 2004 0000 3202 4508 6418");
} else {
//$pdf->addtext(28+$x,208+$y,9, bankaccount($invoice['customerid']));
$pdf->addtext(28+$x,208+$y,9, format_bankaccount($account));
}
$pdf->addtext(70+$x,176+$y,12,'**'.number_format($invoice['total'],2,',','').'**');
//$pdf->addtext(15+$x,310+$y,30,$invoice['name']);
$font_size=12;
while ($pdf->getTextWidth($font_size, iconv('UTF-8', 'ISO-8859-2',$invoice['name']))>150)
$font_size=$font_size-1;
$pdf->addtext(28+$x,145+$y,$font_size, iconv('UTF-8', 'ISO-8859-2',$invoice['name']));
$font_size=12;
while ($pdf->getTextWidth($font_size, iconv('UTF-8', 'ISO-8859-2',$invoice['address']))>150)
$font_size=$font_size-1;
$pdf->addtext(28+$x,131+$y,$font_size, iconv('UTF-8', 'ISO-8859-2',$invoice['address']));
$pdf->addtext(28+$x,117+$y,$font_size, iconv('UTF-8', 'ISO-8859-2',$invoice['zip']." ".$invoice['city']));
$font_size=12;
if ($ks_w) {
while ($pdf->getTextWidth($font_size, iconv('UTF-8', 'ISO-8859-2',"ID Abonenta ".$invoice['customerid']))>150)
$font_size=$font_size-1;
$pdf->addtext(28+$x,85+$y,$font_size, iconv('UTF-8', 'ISO-8859-2',"ID Abonenta ".$invoice['customerid']));
} else {
while ($pdf->getTextWidth($font_size, iconv('UTF-8', 'ISO-8859-2',$invoice['t_number']))>150)
$font_size=$font_size-1;
$pdf->addtext(45+$x,85+$y,$font_size, iconv('UTF-8', 'ISO-8859-2',$invoice['t_number']));
}
}
function main_fill($x,$y)
{
global $pdf,$ks_w,$template,$invoice;
$shortname = $invoice['division_shortname'];
$address = $invoice['division_address'];
$zip = $invoice['division_zip'];
$city = $invoice['division_city'];
if ($template) {
// Napisy pomara��czowe
$pdf->setColor(0.8,0.4,0.1);
$pdf->addtext(28+$x,281+$y,7,"nazwa odbiorcy");
$pdf->addtext(28+$x,234+$y,7,"nr rachunku odbiorcy");
$pdf->addtext(184+$x,206+$y,7,"waluta");
$pdf->addtext(240+$x,206+$y,7,iconv('UTF-8', 'ISO-8859-2',"kwota do zap��aty"));
$pdf->addtext(28+$x,185+$y,6,iconv('UTF-8', 'ISO-8859-2',"nr rachunku zleceniodawcy (przelew) / kwota s��ownie (wp��ata)"));
$pdf->addtext(28+$x,160+$y,7,"nazwa zleceniodawcy");
$pdf->addtext(28+$x,100+$y,7,iconv('UTF-8', 'ISO-8859-2',"tytu��em"));
$pdf->addtext(221+$x,43+$y,7,iconv('UTF-8', 'ISO-8859-2',"Op��ata"));
$pdf->addtext(12+$x,80+$y,7,iconv('UTF-8', 'ISO-8859-2',"Op��ata przelewu / wp��ata got��wkowa"),-90);
$pdf->setColor(0,0,0);
}
$pdf->setLineStyle(0.5);
$pdf->setStrokeColor(0.8,0.4,0.1);
// Poziome linie
$pdf->line( $x, $y,403+$x, $y);
$pdf->line( 215+$x,58+$y,287+$x, 58+$y);
$pdf->line( 355+$x,58+$y,403+$x, 58+$y);
$pdf->line( 375+$x,60+$y,403+$x, 60+$y);
$pdf->line( 20+$x, 68+$y,215+$x, 68+$y);
$pdf->line( 20+$x, 74+$y,403+$x, 74+$y);
$pdf->line( 20+$x,108+$y,403+$x,108+$y);
$pdf->line( 20+$x,168+$y,403+$x,168+$y);
$pdf->line( 39+$x,183+$y,403+$x,183+$y);
$pdf->line( 20+$x,191+$y,403+$x,191+$y);
$pdf->line( 20+$x,214+$y,403+$x,214+$y);
$pdf->line( 20+$x,243+$y,403+$x,243+$y);
$pdf->line( $x,289+$y,403+$x,289+$y);
// Op��ata i kratki
$pdf->line(221+$x,20+$y,281+$x,20+$y);
$pdf->line(221+$x,35+$y,281+$x,35+$y);
for ($i=221;$i<=281;$i+=15) {
$pdf->line( $i+$x, 20+$y, $i+$x, 35+$y);
}
// Pionowe linie
$pdf->line(20+$x,$y,20+$x,68+$y);
$pdf->line(375+$x,60+$y,375+$x,74+$y);
$pdf->line(215+$x,$y,215+$x,68+$y);
$pdf->line(20+$x,74+$y,20+$x,289+$y);
$pdf->line(130+$x,191+$y,130+$x,214+$y);
$pdf->line(230+$x,191+$y,230+$x,214+$y);
for ($i=389;$i>=39;$i-=14) {
$pdf->line( $x+$i, 168+$y, $x+$i, 183+$y);
}
$pdf->line(403+$x,$y,403+$x,289+$y);
// Stempel
$pdf->line(287+$x,$y,287+$x,68+$y);
$pdf->line(287+$x,68+$y,355+$x,68+$y);
$pdf->line(355+$x,68+$y,355+$x,$y);
$pdf->saveState();
$pdf->setLineStyle(0.5,'','',array(3,3));
$pdf->ellipse(321+$x,34+$y,21);
$pdf->restoreState();
$pdf->addtext(28+$x,270+$y,12, iconv('UTF-8', 'ISO-8859-2',$shortname));
$pdf->addtext(28+$x,258+$y,12, iconv('UTF-8', 'ISO-8859-2',$address));
$pdf->addtext(28+$x,246+$y,12, iconv('UTF-8', 'ISO-8859-2',$zip." ".$city));
if ($invoice['pdate']<1323094300) {
$pdf->addtext(145+$x,234+$y,9, "95 1140 2004 0000 3202 4508 6418");
$ii = "95114020040000320245086418";
} else {
$pdf->addtext(145+$x,234+$y,9, bankaccount($invoice['customerid']));
$ii = str_replace(' ', '',bankaccount($invoice['customerid']));
}
// barcode(130+$x,252+$y,$ii);
$pdf->Code128(130+$x,217+$y,$ii,190,15);
$pdf->addtext(300+$x,195+$y,12,'**'.number_format($invoice['total'],2,',','').'**');
$pdf->addtext(190+$x,195+$y,12,'PLN');
// Kwadraciki z W i P
$x1 = 136+$x;
$y1 = 194+$y;
$x2 = 136+$x;
$y2 = 209+$y;
$x3 = $x1+17;
$x4 = $x2+17;
$pdf->line($x1 ,$y1 ,$x2 ,$y2);
$pdf->line($x1 ,$y1+15,$x2+15,$y2);
$pdf->line($x1+15,$y1 ,$x2+15,$y2);
$pdf->line($x1+15,$y1 ,$x1 ,$y1);
$pdf->line($x3 ,$y1 ,$x4 ,$y2);
$pdf->line($x3 ,$y1+15,$x4+15,$y2);
$pdf->line($x3+15,$y1 ,$x4+15,$y2);
$pdf->line($x3+15,$y1 ,$x3 ,$y1);
$pdf->setColor(0.8,0.4,0.1);
$pdf->addtext($x1+1,$y1+2,14,'W');
$pdf->addtext($x3+3,$y1+2,14,'P');
$pdf->setColor(0,0,0);
$font_size=12;
while ($pdf->getTextWidth($font_size, iconv('UTF-8', 'ISO-8859-2',$invoice['name']))>360)
$font_size=$font_size-1;
$pdf->addtext(28+$x,145+$y,$font_size, iconv('UTF-8', 'ISO-8859-2',$invoice['name']));
$font_size=12;
$pdf->addtext(28+$x,131+$y,12, iconv('UTF-8', 'ISO-8859-2',$invoice['address']));
$pdf->addtext(28+$x,117+$y,12, iconv('UTF-8', 'ISO-8859-2',$invoice['zip']." ".$invoice['city']));
if ($ks_w) {
if ($invoice['pdate']<1323094300) {
$crc = sprintf("%010u", crc32($invoice['customerid']));
$pdf->addtext(145+$x,97+$y,10, iconv('UTF-8', 'ISO-8859-2',"IDA".$crc."IDA"));
$pdf->Code128(145+$x,79+$y,"IDA".$crc."IDA",190,15);
} else {
$tmp = docnumber($invoice['number'], $invoice['template'], $invoice['cdate']);
$pdf->addtext(145+$x,97+$y,10, iconv('UTF-8', 'ISO-8859-2',$tmp));
$pdf->Code128(145+$x,79+$y,$tmp,190,15);
}
} else {
$pdf->addtext(227+$x,68+$y,6,iconv('UTF-8', 'ISO-8859-2',"Termin p��atno��ci"));
$pdf->addtext(233+$x,60+$y,7,iconv('UTF-8', 'ISO-8859-2',date("Y/m/d",$invoice['pdate'])));
$pdf->addtext(145+$x,97+$y,10, iconv('UTF-8', 'ISO-8859-2',$invoice['t_number']));
}
$pdf->setColor(0,0,0);
}
function invoice_simple_form_fill($x,$y,$scale)
{
global $pdf,$invoice;
$pdf->setlinestyle(1);
$pdf->line(7*$scale+$x,724*$scale+$y,7*$scale+$x,694*$scale+$y);
$pdf->line(7*$scale+$x,724*$scale+$y,37*$scale+$x,724*$scale+$y);
$pdf->line(370*$scale+$x,724*$scale+$y,370*$scale+$x,694*$scale+$y);
$pdf->line(370*$scale+$x,724*$scale+$y,340*$scale+$x,724*$scale+$y);
$pdf->line(7*$scale+$x,197*$scale+$y,7*$scale+$x,227*$scale+$y);
$pdf->line(7*$scale+$x,197*$scale+$y,37*$scale+$x,197*$scale+$y);
$pdf->line(370*$scale+$x,197*$scale+$y,370*$scale+$x,227*$scale+$y);
$pdf->line(370*$scale+$x,197*$scale+$y,340*$scale+$x,197*$scale+$y);
$shortname = $invoice['division_shortname'];
$address = $invoice['division_address'];
$zip = $invoice['division_zip'];
$city = $invoice['division_city'];
text_autosize(15*$scale+$x,568*$scale+$y,30*$scale, iconv("UTF-8","ISO-8859-2//TRANSLIT", $shortname),350*$scale);
text_autosize(15*$scale+$x,534*$scale+$y,30*$scale, iconv("UTF-8","ISO-8859-2//TRANSLIT", $address),350*$scale);
text_autosize(15*$scale+$x,500*$scale+$y,30*$scale, iconv("UTF-8","ISO-8859-2//TRANSLIT", $zip.' '.$city),350*$scale);
//text_autosize(15*$scale+$x,683*$scale+$y,30*$scale, substr($tmp,0,17),350*$scale);
//text_autosize(15*$scale+$x,626*$scale+$y,30*$scale, substr($tmp,18,200),350*$scale);
text_autosize(15*$scale+$x,683*$scale+$y,30*$scale, $tmp,350*$scale);
text_autosize(15*$scale+$x,445*$scale+$y,30*$scale,"*".number_format($invoice['total'],2,',','')."*",350*$scale);
text_autosize(15*$scale+$x,390*$scale+$y,30*$scale, iconv("UTF-8","ISO-8859-2//TRANSLIT",$invoice['name']),350*$scale);
text_autosize(15*$scale+$x,356*$scale+$y,30*$scale, iconv("UTF-8","ISO-8859-2//TRANSLIT",$invoice['address']),350*$scale);
text_autosize(15*$scale+$x,322*$scale+$y,30*$scale, iconv("UTF-8","ISO-8859-2//TRANSLIT",$invoice['zip'].' '.$invoice['city']),350*$scale);
$tmp = docnumber($invoice['number'], $invoice['template'], $invoice['cdate']);
text_autosize(15*$scale+$x,215*$scale+$y,30*$scale,iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Payment for invoice No. $a', $account)),350*$scale);
}
function invoice_dates($x,$y)
{
global $invoice,$pdf;
$font_size=12;
text_align_right($x,$y,$font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Settlement date:')).' ');
$y=$y-text_align_left($x,$y,$font_size,date("Y/m/d",$invoice['cdate']));
text_align_right($x,$y,$font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Sale date:')).' ');
$y=$y-text_align_left($x,$y,$font_size,date("Y/m/d",$invoice['cdate']));
text_align_right($x,$y,$font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Deadline:')).' ');
$y=$y-text_align_left($x,$y,$font_size,date("Y/m/d",$invoice['pdate']));
text_align_right($x,$y,$font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Payment type:')).' ');
$y=$y-text_align_left($x,$y,$font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",$invoice['paytypename']));
return $y;
}
function invoice_buyer($x,$y)
{
global $invoice,$pdf;
$font_size=10;
$y=$y-text_align_left($x,$y,$font_size,''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Purchaser:')).'');
$y=text_wrap($x,$y,350,$font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",$invoice['name']),'left');
$y=$y-text_align_left($x,$y,$font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",$invoice['address']));
$y=$y-text_align_left($x,$y,$font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",$invoice['zip']." ".$invoice['city']));
if ($invoice['division_countryid'] && $invoice['countryid'] && $invoice['division_countryid'] != $invoice['countryid'])
$y=$y-text_align_left($x,$y,$font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",trans($invoice['country'])));
if ($invoice['ten'])
$y=$y-text_align_left($x,$y,$font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('TEN')).' '.$invoice['ten']);
// else if ($invoice['ssn'])
// $y=$y-text_align_left($x,$y,$font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('SSN')).' '.$invoice['ssn']);
// $y=$y-text_align_left($x,$y,$font_size,''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Customer No.: $0',sprintf('%04d',$invoice['customerid']))).'');
return $y;
}
function invoice_seller($x,$y)
{
global $pdf, $invoice;
$font_size=10;
$y=$y-text_align_left($x,$y,$font_size,''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Seller:')).'');
$tmp = iconv("UTF-8","ISO-8859-2//TRANSLIT", $invoice['division_header']);
$tmp = preg_split('/\r?\n/', $tmp);
foreach ($tmp as $line) $y=$y-text_align_left($x,$y,$font_size,$line);
return $y;
}
function invoice_title($x,$y)
{
global $invoice,$pdf,$type;
$font_size = 16;
$tmp = docnumber($invoice['number'], $invoice['template'], $invoice['cdate']);
if(isset($invoice['invoice']))
$y=$y-text_align_left($x,$y,$font_size,''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Credit Note No. $a',$tmp)).'');
else
$y=$y-text_align_left($x,$y,$font_size,''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Invoice No. $a',$tmp)).'');
if(isset($invoice['invoice']))
{
$font_size = 12; $y += 8;
$tmp = docnumber($invoice['invoice']['number'], $invoice['invoice']['template'], $invoice['invoice']['cdate']);
$y=$y-text_align_left($x,$y,$font_size,''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('for Invoice No. $a',$tmp)).'');
$y -= 5;
}
$font_size = 16;
$y=$y-text_align_left($x,$y,$font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",$type));
if($type==trans('DUPLICATE'))
{
$font_size = 12;
$y=$y-text_align_left($x,$y+4,$font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Duplicate draw-up date:').' '.date('Y/m/d')));
}
if(isset($invoice['invoice']))
$y += 10;
return $y;
}
function invoice_address_box($x,$y)
{
global $invoice,$pdf;
$font_size=12;
/*
$invoice_name = $invoice['name'];
if (strlen($invoice_name)>25)
$invoice_name = preg_replace('/(.{25})/',"$1>\n",$invoice_name);
$tmp = preg_split('/\r?\n/', iconv("UTF-8","ISO-8859-2",$invoice_name));
foreach ($tmp as $line) $y=$y-text_align_left($x,$y,$font_size,"".$line."");
*/
$y = text_wrap($x, $y, 160, $font_size, ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",$invoice['name'].''), 'left');
if ($invoice['serviceaddr']) {
$tmp = preg_split('/\r?\n/', iconv("UTF-8","ISO-8859-2//TRANSLIT",$invoice['serviceaddr']));
foreach ($tmp as $line) $y=$y-text_align_left($x,$y,$font_size,''.$line.'');
} else {
$y=$y-text_align_left($x,$y,$font_size,''.iconv('UTF-8','ISO-8859-2//TRANSLIT',$invoice['address']).'');
$y=$y-text_align_left($x,$y,$font_size,''.iconv('UTF-8','ISO-8859-2//TRANSLIT',$invoice['zip']." ".$invoice['city']).'');
}
return $y;
}
function invoice_data_row($x,$y,$width,$font_size,$margin,$data,$t_width,$t_justify)
{
global $pdf;
$fy=$y-$margin-$pdf->GetFontHeight($font_size);
$left = $x+$margin;
$ny = $fy;
$cols = sizeof($data);
for ($i = 1; $i <= $cols; $i++) {
$ly = text_wrap($left+$margin, $fy, $t_width[$i]-2*$margin, $font_size,$data[$i],$t_justify[$i]);
$left = $left + $t_width[$i]+2*$margin;
if ($ly<$ny) $ny=$ly;
}
$left = $x;
for ($i = 1; $i <= $cols; $i++) {
$pdf->line($left, $y, $left, $ny+$font_size/2);
$left = $left + $t_width[$i]+2*$margin;
}
$pdf->line($left, $y, $left, $ny+$font_size/2);
$y=$ny+$font_size/2;
$pdf->line($x,$y,$x+$width,$y);
return($y);
}
function invoice_short_data_row($x,$y,$width,$font_size,$margin,$data,$t_width,$t_justify)
{
global $pdf;
$fy=$y-$margin-$pdf->GetFontHeight($font_size);
$left = $x+$margin;
$ny = $fy;
$cols = sizeof($data);
for ($i = $cols-3; $i <= $cols; $i++) {
$ly = text_wrap($left+$margin, $fy, $t_width[$i]-2*$margin, $font_size,$data[$i],$t_justify[$i]);
$left = $left + $t_width[$i]+2*$margin;
if ($ly<$ny) $ny=$ly;
}
$left = $x;
for ($i = $cols-3; $i <= $cols; $i++) {
$pdf->line($left, $y, $left, $ny+$font_size/2);
$left = $left + $t_width[$i]+2*$margin;
}
$pdf->line($left, $y, $left, $ny+$font_size/2);
$y=$ny+$font_size/2;
//$pdf->line($x,$y,$x+$width,$y);
$v = $cols-3;
$pdf->line($x,$y,$x+$t_width[$v++]+$t_width[$v++]+$t_width[$v++]+$t_width[$v++]+8*$margin,$y);
return($y);
}
function invoice_data($x,$y,$width,$font_size,$margin)
{
global $invoice,$pdf;
$pdf->setlinestyle(0.5);
$pdf->line($x,$y,$x+$width,$y);
$v = 1;
$t_data[$v++] = ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('No.')).'';
$t_data[$v++] = ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Name of Product, Commodity or Service:')).'';
$t_data[$v++] = ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Product ID:')).'';
$t_data[$v++] = ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Unit:')).'';
$t_data[$v++] = ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Amount:')).'';
if($invoice['discount'])
$t_data[$v++] = ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Discount:')).'';
$t_data[$v++] = ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Unitary Net Value:')).'';
$t_data[$v++] = ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Net Value:')).'';
$t_data[$v++] = ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Tax Rate:')).'';
$t_data[$v++] = ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Tax Value:')).'';
$t_data[$v++] = ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Gross Value:')).'';
for ($i = 1; $i < $v; $i++) $t_justify[$i]="center";
for ($i = 1; $i < $v; $i++) $t_width[$i] = getWrapTextWidth($font_size,$t_data[$i])+2*$margin+2;
// tutaj jeszcze trzeba b�dzie sprawdzi� jak� szeroko�� maj� pola w tabelce p��niej
if ($invoice['content']) foreach ($invoice['content'] as $item)
{
$v = 2;
$tt_width[$v++] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",$item['description']));
$tt_width[$v++] = $pdf->getTextWidth($font_size,$item['prodid']);
$tt_width[$v++] = $pdf->getTextWidth($font_size,$item['content']);
$tt_width[$v++] = $pdf->getTextWidth($font_size,sprintf('%.2f',$item['count']));
if($invoice['discount'])
$tt_width[$v++] = $pdf->getTextWidth($font_size,sprintf('%.2f%%',$item['discount']));
$tt_width[$v++] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['basevalue'])))+6;
$tt_width[$v++] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['totalbase'])))+6;
$tt_width[$v++] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",$item['taxlabel']))+6;
$tt_width[$v++] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['totaltax'])))+6;
$tt_width[$v++] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['total'])))+6;
for ($i = 2; $i < $v; $i++)
if(($tt_width[$i]+2*$margin+2)>$t_width[$i])
$t_width[$i] = $tt_width[$i]+2*$margin+2;
}
if(isset($invoice['invoice']['content'])) foreach ($invoice['invoice']['content'] as $item)
{
$v = 2;
$tt_width[$v++] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",$item['description']));
$tt_width[$v++] = $pdf->getTextWidth($font_size,$item['prodid']);
$tt_width[$v++] = $pdf->getTextWidth($font_size,$item['content']);
$tt_width[$v++] = $pdf->getTextWidth($font_size,sprintf('%.2f',$item['count']));
if($invoice['discount'])
$tt_width[$v++] = $pdf->getTextWidth($font_size,sprintf('%.2f%%',$item['discount']));
$tt_width[$v++] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['basevalue'])))+6;
$tt_width[$v++] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['totalbase'])))+6;
$tt_width[$v++] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",$item['taxlabel']))+6;
$tt_width[$v++] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['totaltax'])))+6;
$tt_width[$v++] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['total'])))+6;
for ($i = 2; $i < $v; $i++)
if(($tt_width[$i]+2*$margin+2)>$t_width[$i])
$t_width[$i] = $tt_width[$i]+2*$margin+2;
}
// Kolumna 2 b�dzie mia�a rozmiar ustalany dynamicznie
$t_width[2] = $width-($t_width[1]+$t_width[3]+$t_width[4]+$t_width[5]+$t_width[6]+$t_width[7]+$t_width[8]+$t_width[9]+$t_width[10]+($invoice['discount'] ? $t_width[11] : 0)+ 2*$margin*($invoice['discount'] ? 11 : 10));
$y = invoice_data_row($x,$y,$width,$font_size,$margin,$t_data,$t_width,$t_justify);
$t_justify[11] = $t_justify[10] = $t_justify[9] = $t_justify[8] = $t_justify[7] = $t_justify[6] = $t_justify[5] = "right";
$t_justify[2] = 'left';
if(isset($invoice['invoice']))
{
// we have credit note, so first print corrected invoice data
$xx = $x;
$y = $y-text_align_left($x,$y-10,$font_size,''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Was:')).'');
$y -= 6;
$pdf->line($x,$y,$x+$width,$y);
$lp = 1;
if ($invoice['invoice']['content'])
foreach ($invoice['invoice']['content'] as $item)
{
$v = 1;
$t_data[$v++] = $lp;
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",$item['description']);
$t_data[$v++] = $item['prodid'];
$t_data[$v++] = $item['content'];
$t_data[$v++] = sprintf('%.2f',$item['count']);
if($invoice['discount'])
$t_data[$v++] = sprintf('%.2f%%',$item['discount']);
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['basevalue']));
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['totalbase']));
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",$item['taxlabel']);
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['totaltax']));
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['total']));
$lp++;
$y = invoice_data_row($x,$y,$width,$font_size,$margin,$t_data,$t_width,$t_justify);
}
$x = $x + ($invoice['discount'] ? 7 : 6)*2*$margin + $t_width[1] + $t_width[2] + $t_width[3] + $t_width[4] + $t_width[5] + $t_width[6] + ($invoice['discount'] ? $t_width[7] : 0);
$fy=$y-$margin-$pdf->GetFontHeight($font_size);
text_align_right($x-$margin,$fy,$font_size,''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Total:')).'');
$v = $invoice['discount'] ? 8 : 7;
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($invoice['invoice']['totalbase']));
$t_data[$v++] = "x";
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($invoice['invoice']['totaltax']));
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($invoice['invoice']['total']));
$y = invoice_short_data_row($x,$y,$width,$font_size,$margin,$t_data,$t_width,$t_justify);
$y -= 5;
$fy=$y-$margin-$pdf->GetFontHeight($font_size);
text_align_right($x-$margin,$fy,$font_size,''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('in it:')).'');
$v = $invoice['discount'] ? 8 : 7;
$pdf->line($x,$y,$x+$t_width[$v++]+$t_width[$v++]+$t_width[$v++]+$t_width[$v++]+8*$margin,$y);
if ($invoice['invoice']['taxest'])
foreach ($invoice['invoice']['taxest'] as $item)
{
$v = $invoice['discount'] ? 8 : 7;
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['base']));
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",$item['taxlabel']);
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['tax']));
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['total']));
$y = invoice_short_data_row($x,$y,$width,$font_size,$margin,$t_data,$t_width,$t_justify);
}
$x = $xx;
if ($invoice['reason'] != '')
{
$y = $y-text_align_left($x,$y-10,$font_size,''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Reason:').' '.$invoice['reason']).'');
$y -= 10;
}
$y = $y-text_align_left($x,$y-10,$font_size,''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Corrected to:')).'');
$y -= 5;
$pdf->line($x,$y,$x+$width,$y);
}
$lp = 1;
if($invoice['content']) foreach ($invoice['content'] as $item)
{
$v = 1;
$t_data[$v++] = $lp;
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",$item['description']);
$t_data[$v++] = $item['prodid'];
$t_data[$v++] = $item['content'];
$t_data[$v++] = sprintf('%.2f',$item['count']);
if($invoice['discount'])
$t_data[$v++] = sprintf('%.2f%%',$item['discount']);
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['basevalue']));
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['totalbase']));
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",$item['taxlabel']);
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['totaltax']));
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['total']));
$lp++;
$y = invoice_data_row($x,$y,$width,$font_size,$margin,$t_data,$t_width,$t_justify);
}
$return[1] = $y;
$x = $x + ($invoice['discount'] ? 7 : 6)*2*$margin + $t_width[1] + $t_width[2] + $t_width[3] + $t_width[4] + $t_width[5] + $t_width[6] + ($invoice['discount'] ? $t_width[7] : 0);
$fy=$y-$margin-$pdf->GetFontHeight($font_size);
text_align_right($x-$margin,$fy,$font_size,''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Total:')).'');
$v = $invoice['discount'] ? 8 : 7;
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($invoice['totalbase']));
$t_data[$v++] = "x";
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($invoice['totaltax']));
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($invoice['total']));
$y = invoice_short_data_row($x,$y,$width,$font_size,$margin,$t_data,$t_width,$t_justify);
$y = $y - 5;
$fy=$y-$margin-$pdf->GetFontHeight($font_size);
text_align_right($x-$margin,$fy,$font_size,''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('in it:')).'');
$v = $invoice['discount'] ? 8 : 7;
$pdf->line($x,$y,$x+$t_width[$v++]+$t_width[$v++]+$t_width[$v++]+$t_width[$v++]+8*$margin,$y);
if ($invoice['taxest']) foreach ($invoice['taxest'] as $item)
{
$v = $invoice['discount'] ? 8 : 7;
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['base']));
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",$item['taxlabel']);
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['tax']));
$t_data[$v++] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['total']));
$y = invoice_short_data_row($x,$y,$width,$font_size,$margin,$t_data,$t_width,$t_justify);
}
if(isset($invoice['invoice']))
{
$total = $invoice['total'] - $invoice['invoice']['total'];
$totalbase = $invoice['totalbase'] - $invoice['invoice']['totalbase'];
$totaltax = $invoice['totaltax'] - $invoice['invoice']['totaltax'];
$y = $y - 5;
$fy=$y-$margin-$pdf->GetFontHeight($font_size);
$v = $invoice['discount'] ? 8 : 7;
$pdf->line($x,$y,$x+$t_width[$v++]+$t_width[$v++]+$t_width[$v++]+$t_width[$v++]+8*$margin,$y);
text_align_right($x-$margin,$fy,$font_size,''.iconv("UTF-8","ISO-8859-2//TRANSLIT", trans('Difference value:')).'');
$v = $invoice['discount'] ? 8 : 7;
$t_data[$v++] = ($totalbase>0 ? '+' : '') . iconv("UTF-8","ISO-8859-2//TRANSLIT", moneyf($totalbase));
$t_data[$v++] = "x";
$t_data[$v++] = ($totaltax>0 ? '+' : '') . iconv("UTF-8","ISO-8859-2//TRANSLIT", moneyf($totaltax));
$t_data[$v++] = ($total>0 ? '+' : '') . iconv("UTF-8","ISO-8859-2//TRANSLIT", moneyf($total));
$y = invoice_short_data_row($x,$y,$width,$font_size,$margin,$t_data,$t_width,$t_justify);
}
$return[2] = $y;
return $return;
}
function new_invoice_data($x,$y,$width,$font_size,$margin)
{
global $invoice, $pdf;
$pdf->setlinestyle(0.5);
$data = array();
$cols = array();
$params = array(
'fontSize' => $font_size,
'xPos' => $x,
'xOrientation' => 'right', // I think it should be left here (bug?)
'rowGap' => 2,
'colGap' => 2,
'showHeadings' => 0,
'cols' => array(),
);
// tabelka glowna
$cols['no'] = ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('No.')).'';
$cols['name'] = ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Name of Product, Commodity or Service:')).'';
$cols['prodid'] = ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Product ID:')).'';
$cols['content'] = ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Unit:')).'';
$cols['count'] = ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Amount:')).'';
if($invoice['discount'])
$cols['discount'] = ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Discount:')).'';
$cols['basevalue'] = ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Unitary Net Value:')).'';
$cols['totalbase'] = ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Net Value:')).'';
$cols['taxlabel'] = ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Tax Rate:')).'';
$cols['totaltax'] = ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Tax Value:')).'';
$cols['total'] = ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Gross Value:')).'';
foreach($cols as $name => $text)
{
$params['cols'][$name] = array(
'justification' => 'center',
'width' => getWrapTextWidth($font_size,$text)+2*$margin+2,
);
}
// tutaj jeszcze trzeba b�dzie sprawdzi� jak� szeroko�� maj� pola w tabelce p��niej
if ($invoice['content']) foreach ($invoice['content'] as $item)
{
$tt_width['name'] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",$item['description']));
$tt_width['prodid'] = $pdf->getTextWidth($font_size,$item['prodid']);
$tt_width['content'] = $pdf->getTextWidth($font_size,$item['content']);
$tt_width['count'] = $pdf->getTextWidth($font_size,sprintf('%.2f',$item['count']));
if($invoice['discount'])
$tt_width['discount'] = $pdf->getTextWidth($font_size,sprintf('%.2f%%',$item['discount']));
$tt_width['basevalue'] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['basevalue'])))+6;
$tt_width['totalbase'] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['totalbase'])))+6;
$tt_width['taxlabel'] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",$item['taxlabel']))+6;
$tt_width['totaltax'] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['totaltax'])))+6;
$tt_width['total'] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['total'])))+6;
foreach($tt_width as $name => $w)
if(($w+2*$margin+2) > $params['cols'][$name]['width'])
$params['cols'][$name]['width'] = $w+2*$margin+2;
}
if(isset($invoice['invoice']['content'])) foreach ($invoice['invoice']['content'] as $item)
{
$tt_width['name'] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",$item['description']));
$tt_width['prodid'] = $pdf->getTextWidth($font_size,$item['prodid']);
$tt_width['content'] = $pdf->getTextWidth($font_size,$item['content']);
$tt_width['count'] = $pdf->getTextWidth($font_size,sprintf('%.2f',$item['count']));
if($invoice['discount'])
$tt_width['discount'] = $pdf->getTextWidth($font_size,sprintf('%.2f%%',$item['discount']));
$tt_width['basevalue'] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['basevalue'])))+6;
$tt_width['totalbase'] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['totalbase'])))+6;
$tt_width['taxlabel'] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",$item['taxlabel']))+6;
$tt_width['totaltax'] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['totaltax'])))+6;
$tt_width['total'] = $pdf->getTextWidth($font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['total'])))+6;
foreach($tt_width as $name => $w)
if(($w+2*$margin+2) > $params['cols'][$name]['width'])
$params['cols'][$name]['width'] = $w+2*$margin+2;
}
// Kolumna 'name' bedzie miala rozmiar ustalany dynamicznie
$sum = 0;
foreach($params['cols'] as $name => $col)
if($name != 'name')
$sum += $col['width'];
$params['cols']['name']['width'] = $width - $sum;
// table header
$pdf->ezSetY($y);
$data = array(0=>$cols);
$y = $pdf->ezTable($data, $cols,'', $params);
$data = array();
foreach($cols as $name => $text)
{
switch($name)
{
case 'no': $params['cols'][$name]['justification'] = 'center'; break;
case 'name': $params['cols'][$name]['justification'] = 'left'; break;
default: $params['cols'][$name]['justification'] = 'right'; break;
}
}
// size of taxes summary table
$xx = $x;
foreach($params['cols'] as $name => $value)
if(in_array($name, array('no','name','prodid','content','count','discount','basevalue')))
{
$xx += $params['cols'][$name]['width'];
}
else
$cols2[$name] = $params['cols'][$name];
$data2 = array();
$params2 = array(
'fontSize' => $font_size,
'xPos' => $xx,
'xOrientation' => 'right',
'rowGap' => 2,
'colGap' => 2,
'showHeadings' => 0,
'cols' => $cols2,
);
if(isset($invoice['invoice']))
{
// we have credit note, so first print corrected invoice data
$y -= 20;
check_page_length($y);
$y = $y-text_align_left($x,$y,$font_size,''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Was:')).'');
$i = 0;
if ($invoice['invoice']['content'])
foreach ($invoice['invoice']['content'] as $item)
{
$data[$i]['no'] = $i+1;
$data[$i]['name'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",$item['description']);
$data[$i]['prodid'] = $item['prodid'];
$data[$i]['content'] = $item['content'];
$data[$i]['count'] = sprintf('%.2f',$item['count']);
if($invoice['discount'])
$data[$i]['discount'] = sprintf('%.2f%%',$item['discount']);
$data[$i]['basevalue'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['basevalue']));
$data[$i]['totalbase'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['totalbase']));
$data[$i]['taxlabel'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",$item['taxlabel']);
$data[$i]['totaltax'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['totaltax']));
$data[$i]['total'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['total']));
$i++;
}
$pdf->ezSetY($y);
$y = $pdf->ezTable($data, $cols,'', $params);
$data = array();
$y -= 10;
check_page_length($y);
$data2[0]['totalbase'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($invoice['invoice']['totalbase']));
$data2[0]['taxlabel'] = "x";
$data2[0]['totaltax'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($invoice['invoice']['totaltax']));
$data2[0]['total'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($invoice['invoice']['total']));
$pdf->ezSetY($y);
$y = $pdf->ezTable($data2, NULL,'', $params2);
$data2 = array();
$fy = $y + $pdf->GetFontHeight($font_size)/2;
text_align_right($xx-5, $fy, $font_size, ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Total:')).'');
check_page_length($y);
$fy = $y - $margin - $pdf->GetFontHeight($font_size);
text_align_right($xx-5,$fy,$font_size,''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('in it:')).'');
if ($invoice['invoice']['taxest'])
{
$i = 0;
foreach ($invoice['invoice']['taxest'] as $item)
{
$data2[$i]['totalbase'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['base']));
$data2[$i]['taxlabel'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",$item['taxlabel']);
$data2[$i]['totaltax'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['tax']));
$data2[$i]['total'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['total']));
$i++;
}
$pdf->ezSetY($y);
$y = $pdf->ezTable($data2, NULL,'', $params2);
$data2 = array();
}
$y -= 20;
if($invoice['reason'] != '')
{
check_page_length($y);
$y = text_wrap($x,$y,$width,$font_size,''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Reason:').' '.$invoice['reason']).'','left');
$y -= 10;
}
check_page_length($y);
$y = $y-text_align_left($x,$y,$font_size,''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Corrected to:')).'');
}
// pozycje faktury
$i = 0;
if(isset($invoice['content'])) foreach ($invoice['content'] as $item)
{
$data[$i]['no'] = $i+1;
$data[$i]['name'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",$item['description']);
$data[$i]['prodid'] = $item['prodid'];
$data[$i]['content'] = $item['content'];
$data[$i]['count'] = sprintf('%.2f',$item['count']);
if($invoice['discount'])
$data[$i]['discount'] = sprintf('%.2f%%',$item['discount']);
$data[$i]['basevalue'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['basevalue']));
$data[$i]['totalbase'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['totalbase']));
$data[$i]['taxlabel'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",$item['taxlabel']);
$data[$i]['totaltax'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['totaltax']));
$data[$i]['total'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['total']));
$i++;
}
$pdf->ezSetY($y);
$y = $pdf->ezTable($data, $cols,'', $params);
$y -= 10;
check_page_length($y);
// podsumowanie podatku
$data2[0]['totalbase'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($invoice['totalbase']));
$data2[0]['taxlabel'] = "x";
$data2[0]['totaltax'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($invoice['totaltax']));
$data2[0]['total'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($invoice['total']));
$pdf->ezSetY($y);
$y = $pdf->ezTable($data2, NULL,'', $params2);
$data2 = array();
$fy = $y + $pdf->GetFontHeight($font_size)/2;
text_align_right($xx-5, $fy, $font_size, ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Total:')).'');
$return[1] = $y;
check_page_length($y);
$fy = $y - $margin - $pdf->GetFontHeight($font_size);
text_align_right($xx-5,$fy,$font_size,''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('in it:')).'');
if(isset($invoice['taxest']))
{
$i = 0;
foreach ($invoice['taxest'] as $item)
{
$data2[$i]['totalbase'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['base']));
$data2[$i]['taxlabel'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",$item['taxlabel']);
$data2[$i]['totaltax'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['tax']));
$data2[$i]['total'] = iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($item['total']));
$i++;
}
$pdf->ezSetY($y);
$y = $pdf->ezTable($data2, NULL,'', $params2);
$data2 = array();
}
if(isset($invoice['invoice']))
{
$total = $invoice['total'] - $invoice['invoice']['total'];
$totalbase = $invoice['totalbase'] - $invoice['invoice']['totalbase'];
$totaltax = $invoice['totaltax'] - $invoice['invoice']['totaltax'];
$y -= 10;
$fy = $y - $margin - $pdf->GetFontHeight($font_size);
text_align_right($xx-5,$fy,$font_size,''.iconv("UTF-8","ISO-8859-2//TRANSLIT", trans('Difference value:')).'');
$data2[0]['totalbase'] = ($totalbase>0 ? '+' : '') . iconv("UTF-8","ISO-8859-2//TRANSLIT", moneyf($totalbase));
$data2[0]['taxlabel'] = "x";
$data2[0]['totaltax'] = ($totaltax>0 ? '+' : '') . iconv("UTF-8","ISO-8859-2//TRANSLIT", moneyf($totaltax));
$data2[0]['total'] = ($total>0 ? '+' : '') . iconv("UTF-8","ISO-8859-2//TRANSLIT", moneyf($total));
$pdf->ezSetY($y);
$y = $pdf->ezTable($data2, NULL,'', $params2);
$data2 = array();
}
$return[2] = $y;
return $return;
}
function invoice_to_pay($x,$y)
{
global $pdf, $invoice;
if(isset($invoice['rebate']))
$y = $y - text_align_left($x,$y,14,iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('To repay:')).' '.iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($invoice['value'])));
else
$y = $y - text_align_left($x,$y,14,iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('To pay:')).' '.iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($invoice['value'])));
$y = $y - text_align_left($x,$y,10,iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('In words:')).' '.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('$a dollars $b cents',to_words(floor($invoice['value'])),to_words(round(($invoice['value']-floor($invoice['value']))*100)))));
return $y;
}
function invoice_expositor ($x,$y)
{
global $pdf, $invoice;
$expositor = isset($invoice['user']) ? $invoice['user'] : $invoice['division_author'];
$y = $y - text_align_left($x,$y,10,iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Expositor:')).' '.iconv("UTF-8","ISO-8859-2//TRANSLIT",$expositor));
return $y;
}
function invoice_footnote($x, $y, $width, $font_size)
{
global $pdf, $invoice;
if(!empty($invoice['division_footer']))
{
$y = $y - $pdf->getFontHeight($font_size);
$y = $y - text_align_left($x,$y,$font_size,''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Notes:')).'');
$tmp = iconv("UTF-8","ISO-8859-2//TRANSLIT", $invoice['division_footer']);
$tmp = preg_split('/\r?\n/', $tmp);
foreach ($tmp as $line) $y = text_wrap($x,$y,$width,$font_size,$line,"full");
}
}
function data_for_user($x,$y)
{
global $pdf, $invoice, $CONFIG;
$font_size=12;
$scale=0.4;
$pdf->setStrokeColor(0.8,0.8,0.8); //kolor wypelnienia
$pdf->setlinestyle(16);
$pdf->line($x,$y,560,$y);
$pdf->setlinestyle(1);
$pdf->rectangle($x+0.5,$y-8.5,529,-30); //ramka
$pdf->setColor(0,0,0);
text_align_left($x+10,$y-4,12,iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('KWOTA DO ZAP��ATY')));
text_align_left($x+220,$y-4,12,iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('S��OWNIE')));
text_align_left($x+361,$y-4,12,iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('TERMIN P��ATNO��CI DO')));
text_align_left($x+49,$y-28,14,''.iconv("UTF-8","ISO-8859-2//TRANSLIT",moneyf($invoice['value'])).'');
text_align_left($x+168,$y-28,10,iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('$a dollars $b cents',to_words(floor($invoice['value'])),to_words(round(($invoice['value']-floor($invoice['value']))*100)))));
text_align_left($x+392,$y-28,14,''.date("d.m.Y \\r.",$invoice['pdate']).'');
$y = $y-70;
text_align_left($x,$y,12,iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('P��ATNO���� NA KONTO:')));
if ($invoice['pdate']<1323094300) {
text_align_left($x+200,$y,12,"95 1140 2004 0000 3202 4508 6418");
} else {
text_align_left($x+200,$y,12,iconv("UTF-8","ISO-8859-2//TRANSLIT",bankaccount($invoice['customerid'])));
}
text_align_left($x,$y-25,12,iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('TYTU�� PRZELEWU:')));
if ($invoice['pdate']<1323094300) {
$crc = sprintf("%010u", crc32($invoice['customerid']));
text_align_left($x+200,$y-24,12,iconv("UTF-8","ISO-8859-2//TRANSLIT","IDA".$crc."IDA"),950*$scale);
} else {
$tmp = docnumber($invoice['number'], $invoice['template'], $invoice['cdate']);
text_align_left($x+200,$y-24,12,iconv("UTF-8","ISO-8859-2//TRANSLIT","Zap��ata za faktur�� VAT nr ".$tmp),950*$scale);
}
// text_align_left($x+200,$y-24,12,iconv("UTF-8","ISO-8859-2//TRANSLIT","IDA".$invoice['customerid']."IDA"),950*$scale);
// text_align_left($x+200,$y-24,12,iconv("UTF-8","ISO-8859-2//TRANSLIT","Zap��ata za faktur�� VAT nr ".$tmp),950*$scale);
$pdf->setStrokeColor(0,0,0); //kolor wypelnienia
}
function invoice_body_ft0100_druk()
{
global $pdf;
global $template;
global $ks_w;
$template = 1;
$ks_w = 1;
// $page = $pdf->ezStartPageNumbers($pdf->ez['pageWidth']/2+10,$pdf->ez['pageHeight']-30,8,'',trans('Page $0 of $1', '{PAGENUM}','{TOTALPAGENUM}'),1);
$top=$pdf->ez['pageHeight']-50;
main_fill(186,8);
simple_fill_mip(8,8);
invoice_dates(500,$top);
invoice_address_box(400,700);
$top=invoice_title(30,$top);
$top=$top-10;
$top=invoice_seller(30,$top);
$top=$top-10;
$top=invoice_buyer(30,$top);
$top=$top-10;
$return=new_invoice_data(30,$top,530,7,2);
invoice_expositor(30,$return[1]-20);
$top=$return[2]-10;
check_page_length($top, 200);
$top=data_for_user(30,$top-25);
$page = $pdf->ezStopPageNumbers(1,1,$page);
}
//$template = 1;
//$ks_w = 1;
?>