2if (!defined(
"B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !==
true)
18if (
$params[
'BILLFR_BACKGROUND'])
22 $params[
'BILLFR_BACKGROUND_STYLE']
29$pdf->AddFont(
'Font',
'',
'pt_sans-regular.ttf',
true);
30$pdf->AddFont(
'Font',
'B',
'pt_sans-bold.ttf',
true);
36 'top' => intval(
$params[
'BILLFR_MARGIN_TOP'] ?: 15) * 72/25.4,
37 'right' => intval(
$params[
'BILLFR_MARGIN_RIGHT'] ?: 15) * 72/25.4,
38 'bottom' => intval(
$params[
'BILLFR_MARGIN_BOTTOM'] ?: 15) * 72/25.4,
39 'left' => intval(
$params[
'BILLFR_MARGIN_LEFT'] ?: 20) * 72/25.4
44$pdf->SetDisplayMode(100,
'continuous');
55if (
$params[
'BILLFR_PATH_TO_LOGO'])
57 list($imageHeight, $imageWidth) =
$pdf->GetImageSize(
$params[
'BILLFR_PATH_TO_LOGO']);
59 $imgDpi = intval(
$params[
'BILLFR_LOGO_DPI']) ?: 96;
60 $imgZoom = 96 / $imgDpi;
67 $imgDpi = 96 * $imageWidth/(
$width*0.6 + 5);
68 $imgZoom = 96 / $imgDpi;
74 $pdf->Image(
$params[
'BILLFR_PATH_TO_LOGO'],
$pdf->GetX(),
$pdf->GetY(), -$imgDpi, -$imgDpi);
89if (
$params[
"SELLER_COMPANY_ADDRESS"])
91 $sellerAddress =
$params[
"SELLER_COMPANY_ADDRESS"];
92 if (is_string($sellerAddress))
94 $sellerAddress = explode(
"\n", str_replace(
array(
"\r\n",
"\n",
"\r"),
"\n", $sellerAddress));
95 if (
count($sellerAddress) === 1)
96 $sellerAddress = $sellerAddress[0];
98 if (is_array($sellerAddress))
100 if (!empty($sellerAddress))
102 foreach ($sellerAddress as $item)
119 $text =
$pdf->prepareToPdf($sellerAddress);
131if (
$params[
"SELLER_COMPANY_PHONE"])
159if (
$params[
"BUYER_PERSON_COMPANY_NAME"])
180if (
$params[
'BILLFR_PAYER_SHOW'] ===
'Y')
195if (
$params[
"BUYER_PERSON_COMPANY_NAME"])
200if (
$params[
'BILLFR_PAYER_SHOW'] ===
'Y')
215if (
$params[
"BUYER_PERSON_COMPANY_NAME"])
217 if (
$params[
"BUYER_PERSON_COMPANY_ADDRESS"])
219 $buyerAddress =
$params[
"BUYER_PERSON_COMPANY_ADDRESS"];
220 if (is_string($buyerAddress))
222 $buyerAddress = explode(
"\n", str_replace(
array(
"\r\n",
"\n",
"\r"),
"\n", $buyerAddress));
223 if (
count($buyerAddress) === 1)
224 $buyerAddress = $buyerAddress[0];
228 if (is_array($buyerAddress))
230 if (!empty($buyerAddress))
232 foreach ($buyerAddress as $item)
272 if (
$params[
'BILLFR_COLUMN_'.$column.
'_SHOW'] ==
'Y')
276 'SORT' =>
$params[
'BILLFR_COLUMN_'.$column.
'_SORT']
287 'SORT' =>
$val[
'SORT']
292uasort(
$arCols,
function (
$a, $b) {
return (
$a[
'SORT'] < $b[
'SORT']) ? -1 : 1;});
307 foreach (
$params[
'BASKET_ITEMS'] as $basketItem)
310 if ($basketItem[
'IS_VAT_IN_PRICE'])
313 $vatLessPrice = $basketItem[
'PRICE'];
315 $productName = $basketItem[
"NAME"];
316 if ($productName ==
"OrderDelivery")
317 $productName = Loc::getMessage(
'SALE_HPS_BILLFR_DELIVERY',
null,
$billLang);
318 else if ($productName ==
"OrderDiscount")
319 $productName = Loc::getMessage(
'SALE_HPS_BILLFR_DISCOUNT',
null,
$billLang);
322 foreach (
$arCols as $columnId => $col)
330 $arCols[$columnId][
'IS_DIGIT'] =
true;
337 $arCols[$columnId][
'IS_DIGIT'] =
true;
341 $arCols[$columnId][
'IS_DIGIT'] =
true;
345 $arCols[$columnId][
'IS_DIGIT'] =
true;
352 $arCols[$columnId][
'IS_DIGIT'] =
true;
355 if (preg_match(
'/[^0-9 ,\.]/', $basketItem[$columnId]) === 0)
357 if (!array_key_exists(
'IS_DIGIT',
$arCols[$columnId]))
358 $arCols[$columnId][
'IS_DIGIT'] =
true;
362 $arCols[$columnId][
'IS_DIGIT'] =
false;
370 if ($basketItem[
'PROPS'])
374 foreach ($basketItem[
'PROPS'] as $basketPropertyItem)
376 if ($basketPropertyItem[
'CODE'] ==
'CATALOG.XML_ID' || $basketPropertyItem[
'CODE'] ==
'PRODUCT.XML_ID')
378 $arProps[
$n][] =
CSalePdf::prepareToPdf(sprintf(
"%s: %s", $basketPropertyItem[
"NAME"], $basketPropertyItem[
"VALUE"]));
382 $sum += doubleval($vatLessPrice * $basketItem[
'QUANTITY']);
383 $vat = max(
$vat, $basketItem[
'VAT_RATE']);
384 if ($basketItem[
'VAT_RATE'] > 0)
386 if (!isset($vats[$basketItem[
'VAT_RATE']]))
387 $vats[$basketItem[
'VAT_RATE']] = 0;
389 if ($basketItem[
'IS_VAT_IN_PRICE'])
390 $vats[$basketItem[
'VAT_RATE']] += ($basketItem[
'PRICE'] - $vatLessPrice) * $basketItem[
'QUANTITY'];
392 $vats[$basketItem[
'VAT_RATE']] += ($basketItem[
'PRICE']*(1 + $basketItem[
'VAT_RATE']) - $vatLessPrice) * $basketItem[
'QUANTITY'];
405 if (
$params[
'DELIVERY_PRICE'] > 0)
407 $sDeliveryItem = Loc::getMessage(
'SALE_HPS_BILLFR_DELIVERY',
null,
$billLang);
409 $sDeliveryItem .= sprintf(
" (%s)",
$params[
'DELIVERY_NAME']);
412 foreach (
$arCols as $columnId => $col)
459 if (
$params[
'BILLFR_TOTAL_SHOW'] ==
'Y')
498 foreach ($vats as $vatRate => $vatSum)
505 Loc::getMessage(
'SALE_HPS_BILLFR_TAX',
null,
$billLang).
" (%s%%):",
519 foreach (
$params[
'TAXES'] as $tax)
527 ($tax[
"IS_IN_PRICE"] ==
"Y") ? Loc::getMessage(
'SALE_HPS_BILLFR_TAX_IN',
null,
$billLang) :
"",
577 foreach (
$arCols as $columnId => $column)
580 if (
$vat > 0 || $columnId !==
'VAT_RATE')
583 if (
$arCols[$columnId][
'NAME'])
590 ${
"x".($i+1)} =
$pdf->GetX();
613 $accumulatedContent = 0;
614 foreach (
$arCols as $columnId => $column)
618 $accumulated += $arRowsWidth_tmp[$columnId];
619 $arRowsWidth_tmp[$columnId] =
null;
620 $accumulatedContent += $arRowsContentWidth_tmp[$columnId];
621 $arRowsContentWidth_tmp[$columnId] =
null;
625 $arRowsWidth_tmp[$columnId] += $accumulated;
626 $arRowsContentWidth_tmp[$columnId] += $accumulatedContent;
628 $accumulatedContent = 0;
641 foreach (
$arCols as $columnId => $column)
645 list($string,
$arCells[
$n][$columnId]) =
$pdf->splitString(
$arCells[
$n][$columnId], $arRowsContentWidth_tmp[$columnId]);
647 $rowWidth = $arRowsWidth_tmp[$columnId];
649 if (in_array($columnId,
array(
'QUANTITY',
'MEASURE',
'PRICE',
'SUM')))
653 $pdf->Cell($rowWidth, 15, $string, 0, 0,
'R');
656 elseif ($columnId ==
'NUMBER')
659 $pdf->Cell($rowWidth, 15, (
$l == 0) ? $string :
'', 0, 0,
'C');
661 elseif ($columnId ==
'NAME')
664 $pdf->Cell($rowWidth, 15, $string, 0, 0, (
$n >
$items) ?
'R' :
'');
666 elseif ($columnId ==
'VAT_RATE')
669 $pdf->Cell($rowWidth, 15, $string, 0, 0,
'R');
675 $pdf->Cell($rowWidth, 15, $string, 0, 0, (
$n >
$items) ?
'R' :
'L');
682 ${
'x'.($pos+1)} =
$pdf->GetX();
694 if (
$params[
'BILLFR_COLUMN_NAME_SHOW'] ==
'Y')
696 if (isset($arProps[
$n]) && is_array($arProps[
$n]))
699 foreach ($arProps[
$n] as $property)
703 foreach (
$arCols as $columnId => $col)
708 if ($columnId ==
'NAME')
709 $pdf->Cell($arRowsWidth_tmp[$columnId], 12, $property, 0, $line);
711 $pdf->Cell($arRowsWidth_tmp[$columnId], 12,
'', 0, $line);
744 if (
$params[
"BILLFR_COMMENT1"])
747 array(
'#</div>\s*<div[^>]*>#i',
'#</?div>#i'),
array(
'<br>',
'<br>'),
754 if (
$params[
"BILLFR_COMMENT2"])
757 array(
'#</div>\s*<div[^>]*>#i',
'#</?div>#i'),
array(
'<br>',
'<br>'),
769if (
$params[
'BILLFR_PATH_TO_STAMP'])
771 $filePath =
$pdf->GetImagePath(
$params[
'BILLFR_PATH_TO_STAMP']);
772 if ($filePath !=
'' && !
$blank && \
Bitrix\Main\IO\File::isFileExists($filePath))
774 list($stampHeight, $stampWidth) =
$pdf->GetImageSize(
$params[
'BILLFR_PATH_TO_STAMP']);
775 if ($stampHeight && $stampWidth)
777 if ($stampHeight > 120 || $stampWidth > 120)
779 $ratio = 120 / max($stampHeight, $stampWidth);
780 $stampHeight = $ratio * $stampHeight;
781 $stampWidth = $ratio * $stampWidth;
784 $params[
'BILLFR_PATH_TO_STAMP'],
786 $stampWidth, $stampHeight
809 if (
$params[
"SELLER_COMPANY_NAME"])
812 Loc::getMessage(
'SALE_HPS_BILLFR_COMPANY_NAME',
null,
$billLang).
": %s\n",
820 $bankAddr =
$params[
"SELLER_COMPANY_BANK_ADDR"];
821 $bankPhone =
$params[
"SELLER_COMPANY_BANK_PHONE"];
823 if (
$bank || $bankAddr || $bankPhone)
842 $pdf->MultiCell(
$width/2, 15, $bankDetails, 0,
'L');
846if (
$params[
"SELLER_COMPANY_DIRECTOR_POSITION"])
848 if (
$params[
"SELLER_COMPANY_DIRECTOR_NAME"] ||
$params[
"SELLER_COMPANY_DIR_SIGN"])
853 list($signHeight, $signWidth) =
$pdf->GetImageSize(
$params[
'SELLER_COMPANY_DIR_SIGN']);
855 if ($signHeight && $signWidth)
857 $ratio = min(37.5/$signHeight, 150/$signWidth);
858 $signHeight = $ratio * $signHeight;
859 $signWidth = $ratio * $signWidth;
865 if (
$params[
"SELLER_COMPANY_DIRECTOR_NAME"])
876 $pdf->Cell(0, 15,
'',
'B');
881 $params[
'SELLER_COMPANY_DIR_SIGN'],
882 $pdf->GetX() - 150,
$pdf->GetY() - $signHeight + 15,
883 $signWidth, $signHeight
892if (
$params[
"SELLER_COMPANY_ACCOUNTANT_POSITION"])
894 if (
$params[
"SELLER_COMPANY_ACCOUNTANT_NAME"] ||
$params[
"SELLER_COMPANY_ACC_SIGN"])
899 list($signHeight, $signWidth) =
$pdf->GetImageSize(
$params[
'SELLER_COMPANY_ACC_SIGN']);
901 if ($signHeight && $signWidth)
903 $ratio = min(37.5/$signHeight, 150/$signWidth);
904 $signHeight = $ratio * $signHeight;
905 $signWidth = $ratio * $signWidth;
911 if (
$params[
"SELLER_COMPANY_ACCOUNTANT_NAME"])
922 $pdf->Cell(0, 15,
'',
'B');
927 $params[
'SELLER_COMPANY_ACC_SIGN'],
928 $pdf->GetX() - 150,
$pdf->GetY() - $signHeight + 15,
929 $signWidth, $signHeight
945 'Invoice # %s (Issue Date %s).pdf',
948 chr(0), chr(1), chr(2), chr(3), chr(4), chr(5), chr(6), chr(7), chr(8), chr(9), chr(10), chr(11),
949 chr(12), chr(13), chr(14), chr(15), chr(16), chr(17), chr(18), chr(19), chr(20), chr(21), chr(22),
950 chr(23), chr(24), chr(25), chr(26), chr(27), chr(28), chr(29), chr(30), chr(31),
951 '"',
'*',
'/',
':',
'<',
'>',
'?',
'\\',
'|'
954 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