getTextWidth($size,$text)>$width) $size=$size-1;
$pdf->addtext($x,$y,$size,$text);
}
function text_align_right($x,$y,$size,$text)
{
global $pdf;
$pdf->addText($x-$pdf->getTextWidth($size,$text),$y,$size,$text);
return($pdf->getFontHeight($size));
}
function text_align_left($x,$y,$size,$text)
{
global $pdf;
$pdf->addText($x,$y,$size,$text);
return($pdf->getFontHeight($size));
}
function text_wrap($x,$y,$width,$size,$text,$justify)
{
global $pdf;
while ($text!='') {
$text = $pdf->addTextWrap($x, $y, $width, $size,$text,$justify);
$y = $y - $pdf->getFontHeight($size);
}
return($y);
}
function getWrapTextWidth($font_size,$txt)
{
global $pdf;
$long = '';
if($words = explode(' ', $txt))
{
foreach($words as $word)
if(strlen($word) > strlen($long))
$long = $word;
}
else
$long = $txt;
return $pdf->getTextWidth($font_size, $long)+2*$margin+1;
}
function paycall_simple_form_fill($x,$y,$scale)
{
global $pdf,$customer,$CONFIG;
$finances = $CONFIG['finances'];
$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);
text_autosize(15*$scale+$x,568*$scale+$y,30*$scale, iconv("UTF-8","ISO-8859-2//TRANSLIT",$finances['shortname']),350*$scale);
text_autosize(15*$scale+$x,534*$scale+$y,30*$scale, iconv("UTF-8","ISO-8859-2//TRANSLIT",$finances['address']),350*$scale);
text_autosize(15*$scale+$x,500*$scale+$y,30*$scale, iconv("UTF-8","ISO-8859-2//TRANSLIT",$finances['zip']." ".$finances['city']),350*$scale);
$tmp = bankaccount($invoice['customerid']);
//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($customer['balance'],2,',','')."*",350*$scale);
text_autosize(15*$scale+$x,390*$scale+$y,30*$scale, iconv("UTF-8","ISO-8859-2//TRANSLIT",$customer['lastname'].' '.$customer['name']),350*$scale);
text_autosize(15*$scale+$x,356*$scale+$y,30*$scale, iconv("UTF-8","ISO-8859-2//TRANSLIT",$customer['address']),350*$scale);
text_autosize(15*$scale+$x,322*$scale+$y,30*$scale, iconv("UTF-8","ISO-8859-2//TRANSLIT",$customer['zip']." ".$customer['city']),350*$scale);
text_autosize(15*$scale+$x,215*$scale+$y,30*$scale,"ID: $customer[id] Sp�ata zaleg�ych zobowi�za�",350*$scale);
}
function paycall_main_form_fill($x,$y,$scale)
{
global $pdf,$customer,$CONFIG;
$finances = $CONFIG['finances'];
$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(970*$scale+$x,724*$scale+$y,970*$scale+$x,694*$scale+$y);
$pdf->line(970*$scale+$x,724*$scale+$y,940*$scale+$x,724*$scale+$y);
$pdf->line(7*$scale+$x,172*$scale+$y,7*$scale+$x,202*$scale+$y);
$pdf->line(7*$scale+$x,172*$scale+$y,37*$scale+$x,172*$scale+$y);
text_autosize(15*$scale+$x,680*$scale+$y,30*$scale,iconv("UTF-8","ISO-8859-2//TRANSLIT",$finances['name']),950*$scale);
text_autosize(15*$scale+$x,617*$scale+$y,30*$scale,iconv("UTF-8","ISO-8859-2//TRANSLIT",$finances['address']." ".$finances['zip']." ".$finances['city']),950*$scale);
text_autosize(15*$scale+$x,555*$scale+$y,30*$scale,bankaccount($_GET['id']),950*$scale);
$pdf->addtext(330*$scale+$x,495*$scale+$y,30*$scale,'X');
text_autosize(550*$scale+$x,495*$scale+$y,30*$scale,"*".number_format($customer['balance'],2,',','')."*",400*$scale);
text_autosize(15*$scale+$x,434*$scale+$y,30*$scale,iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('$0 dollars $1 cents',to_words(floor($customer['balance'])),to_words(round(($customer['balance']-floor($customer['balance']))*100)))),950*$scale);
text_autosize(15*$scale+$x,372*$scale+$y,30*$scale, iconv("UTF-8","ISO-8859-2//TRANSLIT",$customer['lastname'].' '.$customer['name']),950*$scale);
text_autosize(15*$scale+$x,312*$scale+$y,30*$scale, iconv("UTF-8","ISO-8859-2//TRANSLIT",$customer['address']." ".$customer['zip']." ".$customer['city']),950*$scale);
text_autosize(15*$scale+$x,250*$scale+$y,30*$scale,"ID: $customer[id] Sp�ata zaleg�ych zobowi�za� ",950*$scale);
}
function paycall_formal_statement($x,$y,$customer)
{
$text = "Niniejszym zawiadamiamy, i� na dzie� dzisiejszy, Pa�stwa zaleg�o�� z tytu�u nie op�acunych faktur za wy�wiadczone przez nasz� firm� us�ugi wynosi $customer[balance] z�";
$y = text_wrap($x,$y,520,12,$text,'left');
$y = text_wrap($x,$y,520,12," ",'left');
$text = "Wymienion� sum� prosimy przekaza� na nasz rachunek bankowy w ci�gu 7 dni od daty otrzymania niniejszego wezwania. ";
$text = $text."W przypadku nie przekazania nale�nej sumy w wyznaczonym terminie, skierujemy spraw� na drog� post�powania s�dowego ";
$text = $text."bez ponownego wezwania do zap�aty, co narazi Pa�stwa na konieczno�� zap�aty znacznych dodatkowych koszt�w post�powania wndykacyjnego. ";
$y = text_wrap($x,$y,520,12,$text,'left');
$text = "W przypadku gdy dokonali ju� Pa�stwo zap�aty, prosimy o przes�anie nam faksem kopii polecenia przelewu.";
$y = text_wrap($x,$y,520,12,$text,'left');
}
function paycall_title($x,$y)
{
text_align_left($x,$y,18,"OSTATECZNE WEZWANIE DO ZAP�ATY");
}
function paycall_seller($x,$y)
{
global $pdf,$CONFIG;
$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",$CONFIG['invoices']['header']);
$tmp = str_replace('\n',"\n",$tmp);
$tmp = explode("\n",$tmp);
foreach ($tmp as $line) $y=$y-text_align_left($x,$y,$font_size,$line);
return $y;
}
function paycall_address_box($x,$y)
{
global $customer,$pdf;
$font_size=12;
$y = text_wrap($x, $y, 160, $font_size, ''.iconv("UTF-8","ISO-8859-2//TRANSLIT",$customer['lastname'].' '.$customer['name'].''), 'left');
if ($customer['serviceaddr']) {
$tmp = explode("\n",iconv("UTF-8","ISO-8859-2//TRANSLIT",$customer['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',$customer['address']).'');
$y=$y-text_align_left($x,$y,$font_size,''.iconv('UTF-8','ISO-8859-2//TRANSLIT',$customer['zip']." ".$customer['city']).'');
}
return $y;
}
function paycall_customer($x,$y)
{
global $customer,$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",$customer['lastname'].' '.$customer['name']),'left');
$y=$y-text_align_left($x,$y,$font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",$customer['address']));
$y=$y-text_align_left($x,$y,$font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",$customer['zip']." ".$customer['city']));
if ($invoice['ten'])
$y=$y-text_align_left($x,$y,$font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('TEN:')).' '.$customer['ten']);
else if ($invoice['ssn'])
$y=$y-text_align_left($x,$y,$font_size,iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('SSN:')).' '.$customer['ssn']);
$y=$y-text_align_left($x,$y,$font_size,''.iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Customer No.: $0',sprintf('%04d',$customer['id']))).'');
return $y;
}
function paycall_date($x,$y)
{
global $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",time()));
return $y;
}
function paycall_sign($x,$y)
{
text_align_right($x,$y,12,'specjalista d/s windykacji');
}
function paycall_body()
{
global $customer,$pdf,$id,$CONFIG;
$template = $CONFIG['invoices']['template_file'];
switch ($template)
{
case "standard":
$top=800;
paycall_date(520,800);
$y = paycall_seller(10,800);
paycall_customer(10,$y-10);
paycall_address_box(400,690);
paycall_title(120,610);
paycall_formal_statement(40,570,$customer);
paycall_sign(400,400);
break;
case "FT-0100":
if(file_exists('./img/ft-0100.jpg'))$pdf->addJpegFromFile('./img/ft-0100.jpg',0,0,600,840);
$top=800;
paycall_date(520,800);
$y = paycall_seller(10,800);
paycall_customer(10,$y-10);
paycall_address_box(400,690);
paycall_title(120,610);
paycall_formal_statement(40,570,$customer);
paycall_sign(400,400);
paycall_simple_form_fill(14,3,0.4);
paycall_main_form_fill(187,3,0.4);
break;
default:
require($template);
}
}
// brzydki hack dla ezpdf
setlocale(LC_ALL,'C');
require_once($_LIB_DIR.'/ezpdf/class.ezpdf.php');
$diff=array(177=>'aogonek',161=>'Aogonek',230=>'cacute',198=>'Cacute',234=>'eogonek',202=>'Eogonek',
241=>'nacute',209=>'Nacute',179=>'lslash',163=>'Lslash',182=>'sacute',166=>'Sacute',
188=>'zacute',172=>'Zacute',191=>'zdot',175=>'Zdot');
//$pdf =& new Cezpdf('A4','landscape');
$pdf =& new Cezpdf('A4','portrait');
$pdf->addInfo('Producer','LMS Developers');
$pdf->addInfo('Title',iconv("UTF-8","ISO-8859-2//TRANSLIT",trans('Invoices')));
$pdf->addInfo('Creator','LMS '.$layout['lmsv']);
$pdf->setPreferences('FitWindow','1');
$pdf->ezSetMargins(0,0,0,0);
$tmp = array(
'b'=>'arialbd.afm',
);
$pdf->setFontFamily('arial.afm',$tmp);
$pdf->selectFont($_LIB_DIR.'/ezpdf/arialbd.afm',array('encoding'=>'WinAnsiEncoding','differences'=>$diff));
$pdf->selectFont($_LIB_DIR.'/ezpdf/arial.afm',array('encoding'=>'WinAnsiEncoding','differences'=>$diff));
$id=$pdf->getFirstPageId();
if($customer = $LMS->GetCustomer($_GET['id']))
{
$customer['balance'] *= -1;
paycall_body();
}
$pdf->ezStream();
?>