1<?
if (!defined(
"B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !==
true)
die();?><?
4Loc::loadMessages(__FILE__);
17if (
$params[
'BILLKZ_BACKGROUND'])
21 $params[
'BILLKZ_BACKGROUND_STYLE']
28$pdf->AddFont(
'Font',
'',
'pt_sans-regular.ttf',
true);
29$pdf->AddFont(
'Font',
'B',
'pt_sans-bold.ttf',
true);
37 'top' => intval(
$params[
'BILLKZ_MARGIN_TOP'] ?: 15) * 72/25.4,
38 'right' => intval(
$params[
'BILLKZ_MARGIN_RIGHT'] ?: 15) * 72/25.4,
39 'bottom' => intval(
$params[
'BILLKZ_MARGIN_BOTTOM'] ?: 15) * 72/25.4,
40 'left' => intval(
$params[
'BILLKZ_MARGIN_LEFT'] ?: 20) * 72/25.4
45$pdf->SetDisplayMode(100,
'continuous');
57if (
$params[
'BILLKZ_HEADER_SHOW'] ==
'Y')
59 if (
$params[
'BILLKZ_PATH_TO_LOGO'])
61 list($imageHeight, $imageWidth) =
$pdf->GetImageSize(
$params[
'BILLKZ_PATH_TO_LOGO']);
63 $imgDpi = intval(
$params[
'BILLKZ_LOGO_DPI']) ?: 96;
64 $imgZoom = 96 / $imgDpi;
70 $imgDpi = 96 * $imageWidth/(
$width*0.6 + 5);
71 $imgZoom = 96 / $imgDpi;
77 $pdf->Image(
$params[
'BILLKZ_PATH_TO_LOGO'],
$pdf->GetX(),
$pdf->GetY(), -$imgDpi, -$imgDpi);
81 if ($textLeftMargin < 95)
93 array(
'#</div>\s*<div[^>]*>#i',
'#</?div>#i'),
94 array(
'<br>',
'<br>'),
101 $pdf->SetX(
$pdf->GetX() + $textLeftMargin);
106 if (
$params[
"BILLKZ_COMMENT2"])
111 array(
'#</div>\s*<div[^>]*>#i',
'#</?div>#i'),
112 array(
'<br>',
'<br>'),
119 $pdf->SetX(
$pdf->GetX() + $textLeftMargin);
128 if (
$params[
"SELLER_COMPANY_BANK_NAME"])
130 $sellerBankCity =
'';
131 if (
$params[
"SELLER_COMPANY_BANK_CITY"])
133 $sellerBankCity =
$params[
"SELLER_COMPANY_BANK_CITY"];
134 if (is_array($sellerBankCity))
135 $sellerBankCity = implode(
', ', $sellerBankCity);
137 $sellerBankCity = str_replace(
array(
"\r\n",
"\n",
"\r"),
', ', strval($sellerBankCity));
141 $params[
"SELLER_COMPANY_BANK_NAME"],
148 $rsPattern =
'/\s*\d{10,100}\s*/';
150 $sellerBank = trim(preg_replace($rsPattern,
' ',
$params[
"SELLER_COMPANY_BANK_IIK"]));
190 $params[
"SELLER_COMPANY_BIN"] ? Loc::getMessage(
'SALE_HPS_BILLKZ_BIN').
': '.
$params[
"SELLER_COMPANY_BIN"] :
' '
250 if (
$params[
"BILLKZ_ORDER_SUBJECT"])
273 $dateValue =
$params[
"PAYMENT_DATE_INSERT"];
274 if ($dateValue instanceof \
Bitrix\Main\Type\Date || $dateValue instanceof \
Bitrix\Main\Type\DateTime)
276 $dateValue = mb_strtolower(
FormatDate(
'd F Y', $dateValue->getTimestamp()));
277 $yearPostfix = Loc::getMessage(
'SALE_HPS_BILLKZ_YEAR_POSTFIX');
278 if (!empty($yearPostfix))
279 $dateValue .= $yearPostfix;
282 else if (is_string($dateValue))
285 if ($timeStampValue !==
false)
286 $dateValue = mb_strtolower(
FormatDate(
'd F Y', $timeStampValue));
287 unset($timeStampValue);
293 'SALE_HPS_BILLKZ_SELLER_TITLE',
295 '#PAYMENT_NUM#' =>
$params[
"ACCOUNT_NUMBER"],
296 '#PAYMENT_DATE#' => $dateValue
319if (
$params[
"SELLER_COMPANY_BIN"] ||
$params[
"SELLER_COMPANY_IIN"])
321 $sellerInfo .= Loc::getMessage(
'SALE_HPS_BILLKZ_BIN').
' / '.Loc::getMessage(
'SALE_HPS_BILLKZ_IIN').
' ';
322 if (
$params[
"SELLER_COMPANY_BIN"])
323 $sellerInfo .=
$params[
"SELLER_COMPANY_BIN"];
324 else if (
$params[
"SELLER_COMPANY_IIN"])
325 $sellerInfo .=
$params[
"SELLER_COMPANY_IIN"];
327if (
$params[
"SELLER_COMPANY_NAME"])
329 if (!empty($sellerInfo))
331 $sellerInfo .=
$params[
"SELLER_COMPANY_NAME"];
333if (
$params[
"SELLER_COMPANY_ADDRESS"])
335 $buyerAddr =
$params[
"SELLER_COMPANY_ADDRESS"];
336 if (is_array($buyerAddr))
337 $buyerAddr = implode(
', ', $buyerAddr);
339 $buyerAddr = str_replace(
array(
"\r\n",
"\n",
"\r"),
', ', strval($buyerAddr));
340 if (!empty($sellerInfo))
342 $sellerInfo .= $buyerAddr;
344if (
$params[
"SELLER_COMPANY_PHONE"])
346 if (!empty($sellerInfo))
348 $sellerInfo .=
$params[
"SELLER_COMPANY_PHONE"];
350if (!empty($sellerInfo))
351 $sellerTitle = Loc::getMessage(
'SALE_HPS_BILLKZ_SELLER_NAME').
':';
354if (
$params[
'BILLKZ_PAYER_SHOW'] ==
'Y')
356 if (
$params[
"BUYER_PERSON_COMPANY_BIN"] ||
$params[
"BUYER_PERSON_COMPANY_IIN"])
358 $buyerInfo .= Loc::getMessage(
'SALE_HPS_BILLKZ_BIN').
' / '.Loc::getMessage(
'SALE_HPS_BILLKZ_IIN').
' ';
359 if (
$params[
"BUYER_PERSON_COMPANY_BIN"])
360 $buyerInfo .=
$params[
"BUYER_PERSON_COMPANY_BIN"];
361 else if (
$params[
"BUYER_PERSON_COMPANY_IIN"])
362 $buyerInfo .=
$params[
"BUYER_PERSON_COMPANY_IIN"];
364 if (
$params[
"BUYER_PERSON_COMPANY_NAME"])
366 if (!empty($buyerInfo))
368 $buyerInfo .=
$params[
"BUYER_PERSON_COMPANY_NAME"];
370 if (
$params[
"BUYER_PERSON_COMPANY_ADDRESS"])
372 $buyerAddr =
$params[
"BUYER_PERSON_COMPANY_ADDRESS"];
373 if (is_array($buyerAddr))
374 $buyerAddr = implode(
', ', $buyerAddr);
376 $buyerAddr = str_replace(
array(
"\r\n",
"\n",
"\r"),
', ', strval($buyerAddr));
377 if (!empty($buyerInfo))
379 $buyerInfo .= $buyerAddr;
381 if (
$params[
"BUYER_PERSON_COMPANY_PHONE"])
383 if (!empty($buyerInfo))
385 $buyerInfo .=
$params[
"BUYER_PERSON_COMPANY_PHONE"];
387 if (
$params[
"BUYER_PERSON_COMPANY_FAX"])
389 if (!empty($buyerInfo))
391 $buyerInfo .=
$params[
"BUYER_PERSON_COMPANY_FAX"];
393 if (
$params[
"BUYER_PERSON_COMPANY_NAME_CONTACT"])
395 if (!empty($buyerInfo))
397 $buyerInfo .=
$params[
"BUYER_PERSON_COMPANY_NAME_CONTACT"];
399 if (!empty($buyerInfo))
400 $buyerTitle = Loc::getMessage(
'SALE_HPS_BILLKZ_BUYER_NAME').
':';
461if (
$params[
'BUYER_PERSON_COMPANY_DOGOVOR'])
499 if (
$params[
'BILLKZ_COLUMN_'.$column.
'_SHOW'] ==
'Y')
503 'SORT' =>
$params[
'BILLKZ_COLUMN_'.$column.
'_SORT']
514 'SORT' =>
$val[
'SORT']
519uasort(
$arCols,
function (
$a, $b) {
return (
$a[
'SORT'] < $b[
'SORT']) ? -1 : 1;});
532 foreach (
$params[
'BASKET_ITEMS'] as $basketItem)
534 $productName = $basketItem[
"NAME"];
535 if ($productName ==
"OrderDelivery")
536 $productName = Loc::getMessage(
'SALE_HPS_BILLKZ_DELIVERY');
537 else if ($productName ==
"OrderDiscount")
538 $productName = Loc::getMessage(
'SALE_HPS_BILLKZ_DISCOUNT');
540 if ($basketItem[
'IS_VAT_IN_PRICE'])
541 $basketItemPrice = $basketItem[
'PRICE'];
543 $basketItemPrice = $basketItem[
'PRICE']*(1 + $basketItem[
'VAT_RATE']);
546 foreach (
$arCols as $columnId => $caption)
554 $arCols[$columnId][
'IS_DIGIT'] =
true;
561 $arCols[$columnId][
'IS_DIGIT'] =
true;
564 $data =
CSalePdf::prepareToPdf($basketItem[
"MEASURE_NAME"] ? $basketItem[
"MEASURE_NAME"] : Loc::getMessage(
'SALE_HPS_BILLKZ_BASKET_MEASURE_DEFAULT'));
565 $arCols[$columnId][
'IS_DIGIT'] =
true;
569 $arCols[$columnId][
'IS_DIGIT'] =
true;
573 $arCols[$columnId][
'IS_DIGIT'] =
true;
577 $arCols[$columnId][
'IS_DIGIT'] =
true;
580 if (preg_match(
'/[^0-9 ,\.]/', $basketItem[$columnId]) === 0)
582 if (!array_key_exists(
'IS_DIGIT',
$arCols[$columnId]))
583 $arCols[$columnId][
'IS_DIGIT'] =
true;
587 $arCols[$columnId][
'IS_DIGIT'] =
false;
596 foreach ($basketItem[
'PROPS'] as $basketPropertyItem)
598 if ($basketPropertyItem[
'CODE'] ==
'CATALOG.XML_ID' || $basketPropertyItem[
'CODE'] ==
'PRODUCT.XML_ID')
601 $arProps[
$n][] = $pdf::prepareToPdf(sprintf(
"%s: %s", $basketPropertyItem[
"NAME"], $basketPropertyItem[
"VALUE"]));
604 $sum += doubleval($basketItem[
'PRICE'] * $basketItem[
'QUANTITY']);
605 $vat = max(
$vat, $basketItem[
'VAT_RATE']);
617 if (
$params[
'DELIVERY_PRICE'] > 0)
619 $sDeliveryItem = Loc::getMessage(
'SALE_HPS_BILLKZ_DELIVERY');
621 $sDeliveryItem .= sprintf(
" (%s)",
$params[
'DELIVERY_NAME']);
623 foreach (
$arCols as $columnId => $col)
661 if (
$params[
'BILLKZ_TOTAL_SHOW'] ==
'Y')
676 foreach (
$params[
'TAXES'] as $tax)
684 ($tax[
"IS_IN_PRICE"] ==
"Y") ? Loc::getMessage(
'SALE_HPS_BILLKZ_INCLUDING') :
"",
712 if (
$params[
'DISCOUNT_PRICE'] > 0)
743 foreach (
$arCols as $columnId => $column)
746 if (
$vat > 0 || $columnId !==
'VAT_RATE')
749 if (
$arCols[$columnId][
'NAME'])
756 ${
"x".($i+1)} =
$pdf->GetX();
779 $accumulatedContent = 0;
780 foreach (
$arCols as $columnId => $column)
784 $accumulated += $arRowsWidth_tmp[$columnId];
785 $arRowsWidth_tmp[$columnId] =
null;
786 $accumulatedContent += $arRowsContentWidth_tmp[$columnId];
787 $arRowsContentWidth_tmp[$columnId] =
null;
791 $arRowsWidth_tmp[$columnId] += $accumulated;
792 $arRowsContentWidth_tmp[$columnId] += $accumulatedContent;
794 $accumulatedContent = 0;
807 foreach (
$arCols as $columnId => $column)
811 list($string,
$arCells[
$n][$columnId]) =
$pdf->splitString(
$arCells[
$n][$columnId], $arRowsContentWidth_tmp[$columnId]);
813 $rowWidth = $arRowsWidth_tmp[$columnId];
815 if (in_array($columnId,
array(
'QUANTITY',
'MEASURE',
'PRICE',
'SUM')))
819 $pdf->Cell($rowWidth, 15, $string, 0, 0,
'R');
822 elseif ($columnId ==
'NUMBER')
825 $pdf->Cell($rowWidth, 15, (
$l == 0) ? $string :
'', 0, 0,
'C');
827 elseif ($columnId ==
'NAME')
832 elseif ($columnId ==
'VAT_RATE')
835 $pdf->Cell($rowWidth, 15, (
$l == 0) ? $string :
'', 0, 0,
'R');
848 ${
'x'.($pos+1)} =
$pdf->GetX();
860 if (
$params[
'BILLKZ_COLUMN_NAME_SHOW'] ==
'Y')
862 if (isset($arProps[
$n]) && is_array($arProps[
$n]))
865 foreach ($arProps[
$n] as $property)
869 foreach (
$arCols as $columnId => $caption)
874 if ($columnId ==
'NAME')
875 $pdf->Cell($arRowsWidth_tmp[$columnId], 12, $property, 0, $line);
877 $pdf->Cell($arRowsWidth_tmp[$columnId], 12,
'', 0, $line);
898if (
$params[
'BILLKZ_TOTAL_SHOW'] ==
'Y')
902 'SALE_HPS_BILLKZ_BASKET_TOTAL',
911 if (in_array(
$params[
'CURRENCY'],
array(
"RUR",
"RUB",
"UAH",
"KZT",
"BYR",
"BYN")))
937if (
$params[
'BILLKZ_SIGN_SHOW'] ==
'Y')
941 if (
$params[
'SELLER_COMPANY_ACCOUNTANT_NAME'])
943 if (
$params[
'SELLER_COMPANY_ACCOUNTANT_POSITION'])
944 $executorInfo .=
$params[
'SELLER_COMPANY_ACCOUNTANT_POSITION'];
945 if (!empty($executorInfo))
946 $executorInfo .=
' ';
947 $executorInfo .=
$params[
'SELLER_COMPANY_ACCOUNTANT_NAME'];
950 else if (
$params[
'SELLER_COMPANY_DIRECTOR_NAME'])
952 if (
$params[
'SELLER_COMPANY_DIRECTOR_POSITION'])
953 $executorInfo .=
$params[
'SELLER_COMPANY_DIRECTOR_POSITION'];
954 if (!empty($executorInfo))
955 $executorInfo .=
' ';
956 $executorInfo .=
$params[
'SELLER_COMPANY_DIRECTOR_NAME'];
959 else if (
$params[
'SELLER_COMPANY_ACCOUNTANT_POSITION'])
961 $executorInfo .=
$params[
'SELLER_COMPANY_ACCOUNTANT_POSITION'];
964 else if (
$params[
'SELLER_COMPANY_DIRECTOR_POSITION'])
966 $executorInfo .=
$params[
'SELLER_COMPANY_DIRECTOR_POSITION'];
971 $executorInfo = str_pad(
'', 6 * 35,
' ');
973 $stampHeight = $stampWidth = 0;
976 list($stampHeight, $stampWidth) =
$pdf->GetImageSize(
$params[
'BILLKZ_PATH_TO_STAMP']);
978 if ($stampHeight && $stampWidth)
980 if ($stampHeight > 120 || $stampWidth > 120)
982 $ratio = 120 / max($stampHeight, $stampWidth);
983 $stampHeight = $ratio * $stampHeight;
984 $stampWidth = $ratio * $stampWidth;
987 $imageY =
$pdf->GetY();
988 $pageNumBefore =
$pdf->PageNo();
991 $params[
'BILLKZ_PATH_TO_STAMP'],
993 $stampWidth, $stampHeight
996 $pageNumAfter =
$pdf->PageNo();
997 if ($pageNumAfter === $pageNumBefore)
1000 $pdf->SetY(
$pdf->GetY() - $stampHeight);
1001 unset($imageY, $pageNumBefore, $pageNumAfter);
1005 $signHeight = $signWidth = 0;
1011 if ($signHeight && $signWidth)
1013 $ratio = min(37.5/$signHeight, 150/$signWidth);
1014 $signHeight = $ratio * $signHeight;
1015 $signWidth = $ratio * $signWidth;
1028 $y15 =
$pdf->GetY();
1029 $pdf->SetY($y15 + max(($stampHeight ?: 150), $signHeight,
$lineHeight) / 2);
1037 $y16 =
$pdf->GetY();
1040 $maxTextWidth =
$width / 2;
1045 $colInfo[2][
'width'] = $maxTextWidth;
1074 $signWidth, $signHeight
1086 'Schet No %s ot %s.pdf',
1089 chr(0), chr(1), chr(2), chr(3), chr(4), chr(5), chr(6), chr(7), chr(8), chr(9), chr(10), chr(11),
1090 chr(12), chr(13), chr(14), chr(15), chr(16), chr(17), chr(18), chr(19), chr(20), chr(21), chr(22),
1091 chr(23), chr(24), chr(25), chr(26), chr(27), chr(28), chr(29), chr(30), chr(31),
1092 '"',
'*',
'/',
':',
'<',
'>',
'?',
'\\',
'|'
1095 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)
if($NS['step']==6) if( $NS[ 'step']==7) if(COption::GetOptionInt('main', 'disk_space', 0) > 0) $info
ConvertDateTime($datetime, $to_format=false, $from_site=false, $bSearchInSitesOnly=false)
FormatDate($format="", $timestamp=false, $now=false, ?string $languageId=null)
HTMLToTxt($str, $strSiteUrl="", $aDelete=[], $maxlen=70)
MakeTimeStamp($datetime, $format=false)
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(CSalePaySystemAction::GetParamValue('BACKGROUND', false)) $margin
if(!empty($sellerData)) $dest
$arPaySysAction["ENCODING"]
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
if($params['BILLKZ_SIGN_SHOW']=='Y') $signParamName
SaleFormatCurrency($fSum, $strCurrency, $OnlyValue=false, $withoutFormat=false)
const SALE_VALUE_PRECISION
Number2Word_Rus($source, $IS_MONEY="Y", $currency="")
if($params['BILLKZ_PAYER_SHOW']=='Y') $colInfo
if($params['BILLKZ_TOTAL_SHOW']=='Y') $y14