2if (!defined(
"B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !==
true)
18if (
$params[
'BILLUA_BACKGROUND'])
22 $params[
'BILLUA_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[
'BILLUA_MARGIN_TOP'] ?: 15) * 72/25.4,
37 'right' => intval(
$params[
'BILLUA_MARGIN_RIGHT'] ?: 15) * 72/25.4,
38 'bottom' => intval(
$params[
'BILLUA_MARGIN_BOTTOM'] ?: 15) * 72/25.4,
39 'left' => intval(
$params[
'BILLUA_MARGIN_LEFT'] ?: 20) * 72/25.4
44$pdf->SetDisplayMode(100,
'continuous');
58if (
$params[
'BILLUA_SELLER_SHOW'] ==
'Y')
71 Loc::getMessage(
'SALE_HPS_BILLUA_SELLER_COMPANY_RS',
null,
$billLang).
' %s, '.Loc::getMessage(
'SALE_HPS_BILLUA_SELLER_COMPANY_BANK',
null,
$billLang).
' %s, '.Loc::getMessage(
'SALE_HPS_BILLUA_SELLER_COMPANY_MFO',
null,
$billLang).
' %s',
72 $params[
"SELLER_COMPANY_BANK_ACCOUNT"],
73 $params[
"SELLER_COMPANY_BANK_NAME"],
78 if (
$params[
"SELLER_COMPANY_ADDRESS"])
87 $string = sprintf(Loc::getMessage(
'SALE_HPS_BILLUA_SELLER_COMPANY_ADDRESS',
null,
$billLang).
': %s',
$sellerAddr);
88 if (
$params[
"SELLER_COMPANY_PHONE"])
90 $string .=
', '.sprintf(Loc::getMessage(
'SALE_HPS_BILLUA_SELLER_COMPANY_PHONE',
null,
$billLang).
': %s',
$params[
"SELLER_COMPANY_PHONE"]);
99 foreach (
array(
'EDRPOY',
'IPN',
'PDV') as $value)
101 if (
$params[
"SELLER_COMPANY_".$value])
108 if (
$params[
"SELLER_COMPANY_SYS"])
117if (
$params[
'BILLUA_PAYER_SHOW'] ===
'Y')
143 if (
$params[
"BUYER_PERSON_COMPANY_ADDRESS"])
145 $buyerAddr =
$params[
"BUYER_PERSON_COMPANY_ADDRESS"];
146 if (is_array($buyerAddr))
147 $buyerAddr = implode(
', ', $buyerAddr);
149 $buyerAddr = str_replace(
array(
"\r\n",
"\n",
"\r"),
', ', strval($buyerAddr));
152 Loc::getMessage(
'SALE_HPS_BILLUA_BUYER_ADDRESS',
null,
$billLang).
': %s',
160 if (
$params[
"BUYER_PERSON_COMPANY_DOGOVOR"])
163 Loc::getMessage(
'SALE_HPS_BILLUA_BUYER_DOGOVOR',
null,
$billLang).
': %s',
164 $params[
"BUYER_PERSON_COMPANY_DOGOVOR"]
179 if (
$params[
'BILLUA_COLUMN_'.$column.
'_SHOW'] ==
'Y')
181 $caption =
$params[
'BILLUA_COLUMN_'.$column.
'_TITLE'];
182 if (in_array($column,
array(
'PRICE',
'SUM')))
183 $caption .=
', '.$currency;
187 'SORT' =>
$params[
'BILLUA_COLUMN_'.$column.
'_SORT']
198 'SORT' =>
$val[
'SORT']
203uasort(
$arCols,
function (
$a, $b) {
return (
$a[
'SORT'] < $b[
'SORT']) ? -1 : 1;});
213 $isVatInPrice =
false;
218 foreach (
$params[
'BASKET_ITEMS'] as $basketItem)
220 $productName = $basketItem[
"NAME"];
221 if ($productName ==
"OrderDelivery")
222 $productName = Loc::getMessage(
'SALE_HPS_BILLUA_DELIVERY',
null,
$billLang);
223 else if ($productName ==
"OrderDiscount")
224 $productName = Loc::getMessage(
'SALE_HPS_BILLUA_DISCOUNT',
null,
$billLang);
226 $isVatInPrice = $basketItem[
'IS_VAT_IN_PRICE'];
228 if ($basketItem[
'IS_VAT_IN_PRICE'])
229 $basketItemPrice = $basketItem[
'PRICE'];
231 $basketItemPrice = $basketItem[
'PRICE']*(1 + $basketItem[
'VAT_RATE']);
234 foreach (
$arCols as $columnId => $col)
242 $arCols[$columnId][
'IS_DIGIT'] =
true;
249 $arCols[$columnId][
'IS_DIGIT'] =
true;
253 $arCols[$columnId][
'IS_DIGIT'] =
true;
257 $arCols[$columnId][
'IS_DIGIT'] =
true;
261 $arCols[$columnId][
'IS_DIGIT'] =
true;
265 $arCols[$columnId][
'IS_DIGIT'] =
true;
268 if (preg_match(
'/[^0-9 ,\.]/', $basketItem[$columnId]) === 0)
270 if (!array_key_exists(
'IS_DIGIT',
$arCols[$columnId]))
271 $arCols[$columnId][
'IS_DIGIT'] =
true;
275 $arCols[$columnId][
'IS_DIGIT'] =
false;
285 foreach ($basketItem[
'PROPS'] as $basketPropertyItem)
287 if ($basketPropertyItem[
'CODE'] ==
'CATALOG.XML_ID' || $basketPropertyItem[
'CODE'] ==
'PRODUCT.XML_ID')
289 $arProps[
$n][] =
CSalePdf::prepareToPdf(sprintf(
"%s: %s", $basketPropertyItem[
"NAME"], $basketPropertyItem[
"VALUE"]));
292 $sum += doubleval($basketItem[
'PRICE'] * $basketItem[
'QUANTITY']);
293 $vat = max(
$vat, $basketItem[
'VAT_RATE']);
305 if (
$vat > 0 && array_key_exists(
'PRICE',
$arCols) && $isVatInPrice)
311 if (
$params[
'DELIVERY_PRICE'] > 0)
313 $sDeliveryItem = Loc::getMessage(
'SALE_HPS_BILLUA_DELIVERY',
null,
$billLang);
315 $sDeliveryItem .= sprintf(
" (%s)",
$params[
'DELVIERY_NAME']);
318 foreach (
$arCols as $columnId => $col)
357 if (
$params[
'BILLUA_TOTAL_SHOW'] ===
'Y')
361 foreach (
$params[
'TAXES'] as $tax)
369 ($tax[
"IS_IN_PRICE"] ==
"Y") ? Loc::getMessage(
'SALE_HPS_BILLUA_IN_PRICE',
null,
$billLang) :
"",
370 (
$vat <= 0) ? $tax[
"TAX_NAME"] : Loc::getMessage(
'SALE_HPS_BILLUA_TAX',
null,
$billLang),
371 (
$vat <= 0 && $tax[
"IS_PERCENT"] ==
"Y")
381 $orderTax += $tax[
"VALUE_MONEY"];
426 foreach (
$arCols as $columnId => $column)
429 if (
$vat > 0 || $columnId !==
'VAT_RATE')
432 if (
$arCols[$columnId][
'NAME'])
439 ${
"x".($i+1)} =
$pdf->GetX();
462 $accumulatedContent = 0;
463 foreach (
$arCols as $columnId => $column)
467 $accumulated += $arRowsWidth_tmp[$columnId];
468 $arRowsWidth_tmp[$columnId] =
null;
469 $accumulatedContent += $arRowsContentWidth_tmp[$columnId];
470 $arRowsContentWidth_tmp[$columnId] =
null;
474 $arRowsWidth_tmp[$columnId] += $accumulated;
475 $arRowsContentWidth_tmp[$columnId] += $accumulatedContent;
477 $accumulatedContent = 0;
490 foreach (
$arCols as $columnId => $column)
494 list($string,
$arCells[
$n][$columnId]) =
$pdf->splitString(
$arCells[
$n][$columnId], $arRowsContentWidth_tmp[$columnId]);
496 $rowWidth = $arRowsWidth_tmp[$columnId];
498 if (in_array($columnId,
array(
'QUANTITY',
'MEASURE',
'PRICE',
'SUM')))
502 $pdf->Cell($rowWidth, 15, $string, 0, 0,
'R');
505 elseif ($columnId ==
'NUMBER')
508 $pdf->Cell($rowWidth, 15, (
$l == 0) ? $string :
'', 0, 0,
'C');
510 elseif ($columnId ==
'NAME')
513 $pdf->Cell($rowWidth, 15, $string, 0, 0, (
$n >
$items) ?
'R' :
'');
515 elseif ($columnId ==
'VAT_RATE')
518 $pdf->Cell($rowWidth, 15, $string, 0, 0,
'R');
524 $pdf->Cell($rowWidth, 15, $string, 0, 0, (
$n >
$items) ?
'R' :
'L');
531 ${
'x'.($pos+1)} =
$pdf->GetX();
543 if (
$params[
'BILLUA_COLUMN_NAME_SHOW'] ==
'Y')
545 if (isset($arProps[
$n]) && is_array($arProps[
$n]))
548 foreach ($arProps[
$n] as $property)
552 foreach (
$arCols as $columnId => $col)
557 if ($columnId ==
'NAME')
558 $pdf->Cell($arRowsWidth_tmp[$columnId], 12, $property, 0, $line);
560 $pdf->Cell($arRowsWidth_tmp[$columnId], 12,
'', 0, $line);
579if (
$params[
'BILLUA_TOTAL_SHOW'] ===
'Y')
583 Loc::getMessage(
'SALE_HPS_BILLUA_BASKET_ITEMS_TOTAL',
null,
$billLang),
602 Loc::getMessage(
'SALE_HPS_BILLUA_BASKET_ITEMS_TAX',
null,
$billLang),
622 if (
$params[
"BILLUA_COMMENT1"])
625 array(
'#</div>\s*<div[^>]*>#i',
'#</?div>#i'),
array(
'<br>',
'<br>'),
632 if (
$params[
"BILLUA_COMMENT2"])
635 array(
'#</div>\s*<div[^>]*>#i',
'#</?div>#i'),
array(
'<br>',
'<br>'),
644if (
$params[
'BILLUA_FOOTER_SHOW'] ==
'Y')
646 if (
$params[
'BILLUA_PATH_TO_STAMP'])
648 $filePath =
$pdf->GetImagePath(
$params[
'BILLUA_PATH_TO_STAMP']);
649 if ($filePath !=
'' && !
$blank && \
Bitrix\Main\IO\File::isFileExists($filePath))
651 list($stampHeight, $stampWidth) =
$pdf->GetImageSize(
$params[
'BILLUA_PATH_TO_STAMP']);
652 if ($stampHeight && $stampWidth)
654 if ($stampHeight > 120 || $stampWidth > 120)
656 $ratio = 120 / max($stampHeight, $stampWidth);
657 $stampHeight = $ratio * $stampHeight;
658 $stampWidth = $ratio * $stampWidth;
661 $params[
'BILLUA_PATH_TO_STAMP'],
663 $stampWidth, $stampHeight
676 list($signHeight, $signWidth) =
$pdf->GetImageSize(
$params[
'SELLER_COMPANY_ACC_SIGN']);
678 if ($signHeight && $signWidth)
680 $ratio = min(37.5/$signHeight, 150/$signWidth);
681 $signHeight = $ratio * $signHeight;
682 $signWidth = $ratio * $signWidth;
694 $params[
'SELLER_COMPANY_ACC_SIGN'],
695 $pdf->GetX() + 80 - $signWidth/2,
$pdf->GetY() - $signHeight + 15,
696 $signWidth, $signHeight
701 $pdf->Cell(160, 15,
'',
'B', 0,
'C');
702 if (
$params[
"SELLER_COMPANY_ACCOUNTANT_NAME"])
706 if (
$params[
"SELLER_COMPANY_ACCOUNTANT_POSITION"])
722 Loc::getMessage(
'SALE_HPS_BILLUA_DATE_PAID_BEFORE',
null,
$billLang),
736 'Rakhunok No%s vid %s.pdf',
739 chr(0), chr(1), chr(2), chr(3), chr(4), chr(5), chr(6), chr(7), chr(8), chr(9), chr(10), chr(11),
740 chr(12), chr(13), chr(14), chr(15), chr(16), chr(17), chr(18), chr(19), chr(20), chr(21), chr(22),
741 chr(23), chr(24), chr(25), chr(26), chr(27), chr(28), chr(29), chr(30), chr(31),
742 '"',
'*',
'/',
':',
'<',
'>',
'?',
'\\',
'|'
745 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)
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
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
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
SaleFormatCurrency($fSum, $strCurrency, $OnlyValue=false, $withoutFormat=false)
const SALE_VALUE_PRECISION
Number2Word_Rus($source, $IS_MONEY="Y", $currency="")