2if (!defined(
"B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !==
true)
13if (
$params[
'BILLEN_BACKGROUND'])
17 $params[
'BILLEN_BACKGROUND_STYLE']
24$pdf->AddFont(
'Font',
'',
'pt_sans-regular.ttf',
true);
25$pdf->AddFont(
'Font',
'B',
'pt_sans-bold.ttf',
true);
31 'top' => intval(
$params[
'BILLEN_MARGIN_TOP'] ?: 15) * 72/25.4,
32 'right' => intval(
$params[
'BILLEN_MARGIN_RIGHT'] ?: 15) * 72/25.4,
33 'bottom' => intval(
$params[
'BILLEN_MARGIN_BOTTOM'] ?: 15) * 72/25.4,
34 'left' => intval(
$params[
'BILLEN_MARGIN_LEFT'] ?: 20) * 72/25.4
39$pdf->SetDisplayMode(100,
'continuous');
50if (
$params[
'BILLEN_PATH_TO_LOGO'])
52 list($imageHeight, $imageWidth) =
$pdf->GetImageSize(
$params[
'BILLEN_PATH_TO_LOGO']);
54 $imgDpi = intval(
$params[
'BILLEN_LOGO_DPI']) ?: 96;
55 $imgZoom = 96 / $imgDpi;
62 $imgDpi = 96 * $imageWidth/(
$width*0.6 + 5);
63 $imgZoom = 96 / $imgDpi;
69 $pdf->Image(
$params[
'BILLEN_PATH_TO_LOGO'],
$pdf->GetX(),
$pdf->GetY(), -$imgDpi, -$imgDpi);
84if (
$params[
"SELLER_COMPANY_ADDRESS"])
86 $sellerAddress =
$params[
"SELLER_COMPANY_ADDRESS"];
87 if (is_string($sellerAddress))
89 $sellerAddress = explode(
"\n", str_replace(
array(
"\r\n",
"\n",
"\r"),
"\n", $sellerAddress));
90 if (
count($sellerAddress) === 1)
91 $sellerAddress = $sellerAddress[0];
93 if (is_array($sellerAddress))
95 if (!empty($sellerAddress))
97 foreach ($sellerAddress as $item)
114 $text =
$pdf->prepareToPdf($sellerAddress);
126if (
$params[
"SELLER_COMPANY_PHONE"])
155if (
$params[
'BILLEN_PAYER_SHOW'] ===
'Y')
157 if (
$params[
"BUYER_PERSON_COMPANY_NAME"])
181 $titleWidth = max(
$pdf->GetStringWidth($headerTitle),
$pdf->GetStringWidth($issueDateTitle),
$pdf->GetStringWidth($dueDateTitle));
185 $invoiceInfoTitleX = $invoiceInfoValueX -
$titleWidth - 3;
186 $pdf->SetX($invoiceInfoValueX);
191 $pdf->SetX($invoiceInfoTitleX);
192 $pdf->Write(15, $headerTitle);
197 if (
$params[
"BUYER_PERSON_COMPANY_NAME"])
203 $pdf->SetX($invoiceInfoValueX);
208 $pdf->SetX($invoiceInfoTitleX);
209 $pdf->Write(15, $issueDateTitle);
211 $invoiceInfoY =
$pdf->GetY();
215if (
$params[
"BUYER_PERSON_COMPANY_NAME"])
217 if (
$params[
"BUYER_PERSON_COMPANY_ADDRESS"])
219 $buyerAddress =
$params[
"BUYER_PERSON_COMPANY_ADDRESS"];
222 if (is_string($buyerAddress))
224 $buyerAddress = explode(
"\n", str_replace(
array(
"\r\n",
"\n",
"\r"),
"\n", $buyerAddress));
225 if (
count($buyerAddress) === 1)
226 $buyerAddress = $buyerAddress[0];
228 if (is_array($buyerAddress))
230 if (!empty($buyerAddress))
232 foreach ($buyerAddress as $item)
248 if (
$params[
'BUYER_PERSON_COMPANY_PHONE'])
254 if (
$params[
'BUYER_PERSON_COMPANY_FAX'])
260 if (
$params[
'BUYER_PERSON_COMPANY_NAME_CONTACT'])
266if (
$params[
'BILLEN_PAYER_SHOW'] ===
'Y')
268 if (
$params[
"DATE_PAY_BEFORE"])
270 $lastY =
$pdf->GetY();
271 $pdf->SetY($invoiceInfoY);
274 $pdf->SetX($invoiceInfoValueX);
279 $pdf->SetX($invoiceInfoTitleX);
280 $pdf->Write(15, $dueDateTitle);
295 if (
$params[
'BILLEN_COLUMN_'.$column.
'_SHOW'] ==
'Y')
299 'SORT' =>
$params[
'BILLEN_COLUMN_'.$column.
'_SORT']
310 'SORT' =>
$val[
'SORT']
315uasort(
$arCols,
function (
$a, $b) {
return (
$a[
'SORT'] < $b[
'SORT']) ? -1 : 1;});
330 foreach (
$params[
'BASKET_ITEMS'] as $basketItem)
333 if ($basketItem[
'IS_VAT_IN_PRICE'])
336 $vatLessPrice = $basketItem[
'PRICE'];
338 $productName = $basketItem[
"NAME"];
339 if ($productName ==
"OrderDelivery")
340 $productName =
"Shipping";
341 else if ($productName ==
"OrderDiscount")
342 $productName =
"Discount";
345 foreach (
$arCols as $columnId => $col)
353 $arCols[$columnId][
'IS_DIGIT'] =
true;
360 $arCols[$columnId][
'IS_DIGIT'] =
true;
364 $arCols[$columnId][
'IS_DIGIT'] =
true;
368 $arCols[$columnId][
'IS_DIGIT'] =
true;
375 $arCols[$columnId][
'IS_DIGIT'] =
true;
378 if (preg_match(
'/[^0-9 ,\.]/', $basketItem[$columnId]) === 0)
380 if (!array_key_exists(
'IS_DIGIT',
$arCols[$columnId]))
381 $arCols[$columnId][
'IS_DIGIT'] =
true;
385 $arCols[$columnId][
'IS_DIGIT'] =
false;
395 if ($basketItem[
'PROPS'])
397 foreach ($basketItem[
'PROPS'] as $basketItemProperty)
399 if ($basketItemProperty[
'CODE'] ==
'CATALOG.XML_ID' || $basketItemProperty[
'CODE'] ==
'PRODUCT.XML_ID')
402 $arProps[
$n][] =
CSalePdf::prepareToPdf(sprintf(
"%s: %s", $basketItemProperty[
"NAME"], $basketItemProperty[
"VALUE"]));
406 $sum += doubleval($vatLessPrice * $basketItem[
'QUANTITY']);
407 $vat = max(
$vat, $basketItem[
'VAT_RATE']);
408 if ($basketItem[
'VAT_RATE'] > 0)
410 if (!isset($vats[$basketItem[
'VAT_RATE']]))
411 $vats[$basketItem[
'VAT_RATE']] = 0;
413 if ($basketItem[
'IS_VAT_IN_PRICE'])
414 $vats[$basketItem[
'VAT_RATE']] += ($basketItem[
'PRICE'] - $vatLessPrice) * $basketItem[
'QUANTITY'];
416 $vats[$basketItem[
'VAT_RATE']] += ($basketItem[
'PRICE']*(1 + $basketItem[
'VAT_RATE']) - $vatLessPrice) * $basketItem[
'QUANTITY'];
429 if (
$params[
'DELIVERY_PRICE'] > 0)
431 $sDeliveryItem =
"Shipping";
433 $sDeliveryItem .= sprintf(
" (%s)",
$params[
'DELIVERY_NAME']);
436 foreach (
$arCols as $columnId => $col)
483 if (
$params[
'BILLEN_TOTAL_SHOW'] ==
'Y')
521 foreach ($vats as $vatRate => $vatSum)
535 foreach (
$params[
'TAXES'] as $tax)
543 ($tax[
"IS_IN_PRICE"] ==
"Y") ?
"Included " :
"",
571 if (
$params[
'DISCOUNT_PRICE'] > 0)
602 foreach (
$arCols as $columnId => $column)
605 if (
$vat > 0 || $columnId !==
'VAT_RATE')
608 if (
$arCols[$columnId][
'NAME'])
615 ${
"x".($i+1)} =
$pdf->GetX();
638 $accumulatedContent = 0;
639 foreach (
$arCols as $columnId => $column)
643 $accumulated += $arRowsWidth_tmp[$columnId];
644 $arRowsWidth_tmp[$columnId] =
null;
645 $accumulatedContent += $arRowsContentWidth_tmp[$columnId];
646 $arRowsContentWidth_tmp[$columnId] =
null;
650 $arRowsWidth_tmp[$columnId] += $accumulated;
651 $arRowsContentWidth_tmp[$columnId] += $accumulatedContent;
653 $accumulatedContent = 0;
666 foreach (
$arCols as $columnId => $column)
670 list($string,
$arCells[
$n][$columnId]) =
$pdf->splitString(
$arCells[
$n][$columnId], $arRowsContentWidth_tmp[$columnId]);
672 $rowWidth = $arRowsWidth_tmp[$columnId];
674 if (in_array($columnId,
array(
'QUANTITY',
'MEASURE',
'PRICE',
'SUM')))
678 $pdf->Cell($rowWidth, 15, $string, 0, 0,
'R');
681 elseif ($columnId ==
'NUMBER')
684 $pdf->Cell($rowWidth, 15, (
$l == 0) ? $string :
'', 0, 0,
'C');
686 elseif ($columnId ==
'NAME')
689 $pdf->Cell($rowWidth, 15, $string, 0, 0, (
$n >
$items) ?
'R' :
'');
691 elseif ($columnId ==
'VAT_RATE')
694 $pdf->Cell($rowWidth, 15, $string, 0, 0,
'R');
700 $pdf->Cell($rowWidth, 15, $string, 0, 0, (
$n >
$items) ?
'R' :
'L');
707 ${
'x'.($pos+1)} =
$pdf->GetX();
720 if (
$params[
'BILLEN_COLUMN_NAME_SHOW'] ==
'Y')
722 if (isset($arProps[
$n]) && is_array($arProps[
$n]))
725 foreach ($arProps[
$n] as $property)
729 foreach (
$arCols as $columnId => $col)
734 if ($columnId ==
'NAME')
735 $pdf->Cell($arRowsWidth_tmp[$columnId], 12, $property, 0, $line);
737 $pdf->Cell($arRowsWidth_tmp[$columnId], 12,
'', 0, $line);
772 if (
$params[
"BILLEN_COMMENT1"])
775 array(
'#</div>\s*<div[^>]*>#i',
'#</?div>#i'),
array(
'<br>',
'<br>'),
782 if (
$params[
"BILLEN_COMMENT2"])
785 array(
'#</div>\s*<div[^>]*>#i',
'#</?div>#i'),
array(
'<br>',
'<br>'),
797if (
$params[
'BILLEN_PATH_TO_STAMP'])
799 $filePath =
$pdf->GetImagePath(
$params[
'BILLEN_PATH_TO_STAMP']);
800 if ($filePath !=
'' && !
$blank && \
Bitrix\Main\IO\File::isFileExists($filePath))
802 list($stampHeight, $stampWidth) =
$pdf->GetImageSize(
$params[
'BILLEN_PATH_TO_STAMP']);
804 if ($stampHeight && $stampWidth)
806 if ($stampHeight > 120 || $stampWidth > 120)
808 $ratio = 120 / max($stampHeight, $stampWidth);
809 $stampHeight = $ratio * $stampHeight;
810 $stampWidth = $ratio * $stampWidth;
814 $params[
'BILLEN_PATH_TO_STAMP'],
816 $stampWidth, $stampHeight
839 if (
$params[
"SELLER_COMPANY_NAME"])
842 "Account Name: %s\n",
850 $bankAddr =
$params[
"SELLER_COMPANY_BANK_ADDR"];
851 $bankPhone =
$params[
"SELLER_COMPANY_BANK_PHONE"];
853 if (
$bank || $bankAddr || $bankPhone)
872 $pdf->MultiCell(
$width/2, 15, $bankDetails, 0,
'L');
876if (
$params[
"SELLER_COMPANY_DIRECTOR_POSITION"])
878 if (
$params[
"SELLER_COMPANY_DIRECTOR_NAME"] ||
$params[
"SELLER_COMPANY_DIR_SIGN"])
883 list($signHeight, $signWidth) =
$pdf->GetImageSize(
$params[
'SELLER_COMPANY_DIR_SIGN']);
885 if ($signHeight && $signWidth)
887 $ratio = min(37.5/$signHeight, 150/$signWidth);
888 $signHeight = $ratio * $signHeight;
889 $signWidth = $ratio * $signWidth;
895 if (
$params[
"SELLER_COMPANY_DIRECTOR_NAME"])
906 $pdf->Cell(0, 15,
'',
'B');
911 $params[
'SELLER_COMPANY_DIR_SIGN'],
912 $pdf->GetX() - 150,
$pdf->GetY() - $signHeight + 15,
913 $signWidth, $signHeight
922if (
$params[
"SELLER_COMPANY_ACCOUNTANT_POSITION"])
924 if (
$params[
"SELLER_COMPANY_ACCOUNTANT_NAME"] ||
$params[
"SELLER_COMPANY_ACC_SIGN"])
929 list($signHeight, $signWidth) =
$pdf->GetImageSize(
$params[
'SELLER_COMPANY_ACC_SIGN']);
931 if ($signHeight && $signWidth)
933 $ratio = min(37.5/$signHeight, 150/$signWidth);
934 $signHeight = $ratio * $signHeight;
935 $signWidth = $ratio * $signWidth;
941 if (
$params[
"SELLER_COMPANY_ACCOUNTANT_NAME"])
952 $pdf->Cell(0, 15,
'',
'B');
957 $params[
'SELLER_COMPANY_ACC_SIGN'],
958 $pdf->GetX() - 150,
$pdf->GetY() - $signHeight + 15,
959 $signWidth, $signHeight
974 'Invoice # %s (Issue Date %s).pdf',
977 chr(0), chr(1), chr(2), chr(3), chr(4), chr(5), chr(6), chr(7), chr(8), chr(9), chr(10), chr(11),
978 chr(12), chr(13), chr(14), chr(15), chr(16), chr(17), chr(18), chr(19), chr(20), chr(21), chr(22),
979 chr(23), chr(24), chr(25), chr(26), chr(27), chr(28), chr(29), chr(30), chr(31),
980 '"',
'*',
'/',
':',
'<',
'>',
'?',
'\\',
'|'
983 strval(
$params[
"ACCOUNT_NUMBER"])
static prepareToPdf($string)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
ConvertDateTime($datetime, $to_format=false, $from_site=false, $bSearchInSitesOnly=false)
HTMLToTxt($str, $strSiteUrl="", $aDelete=[], $maxlen=70)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
if( $arBasket=$dbBasket->Fetch()) if($vat > 0) $rowsCnt
if(!empty($sellerData)) $bankAccNo
if(CSalePaySystemAction::GetParamValue('BACKGROUND', false)) $margin
if(!empty($sellerData)) $dest
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
SaleFormatCurrency($fSum, $strCurrency, $OnlyValue=false, $withoutFormat=false)
const SALE_VALUE_PRECISION