1<?
if (!defined(
"B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !==
true)
die();?><?
4Loc::loadMessages(__FILE__);
21 $params[
'BILL_BACKGROUND_STYLE']
28$pdf->AddFont(
'Font',
'',
'pt_sans-regular.ttf',
true);
29$pdf->AddFont(
'Font',
'B',
'pt_sans-bold.ttf',
true);
35 'top' => intval(
$params[
'BILL_MARGIN_TOP'] ?: 15) * 72/25.4,
36 'right' => intval(
$params[
'BILL_MARGIN_RIGHT'] ?: 15) * 72/25.4,
37 'bottom' => intval(
$params[
'BILL_MARGIN_BOTTOM'] ?: 15) * 72/25.4,
38 'left' => intval(
$params[
'BILL_MARGIN_LEFT'] ?: 20) * 72/25.4
43$pdf->SetDisplayMode(100,
'continuous');
54if (
$params[
'BILL_HEADER_SHOW'] ==
'Y')
56 if (
$params[
'BILL_PATH_TO_LOGO'])
58 list($imageHeight, $imageWidth) =
$pdf->GetImageSize(
$params[
'BILL_PATH_TO_LOGO']);
60 $imgDpi = intval(
$params[
'BILL_LOGO_DPI']) ?: 96;
61 $imgZoom = 96 / $imgDpi;
68 $imgDpi = 96 * $imageWidth/(
$width*0.6 + 5);
69 $imgZoom = 96 / $imgDpi;
90 if (
$params[
"SELLER_COMPANY_ADDRESS"])
101 if (
$params[
"SELLER_COMPANY_PHONE"])
117 if (
$params[
"SELLER_COMPANY_BANK_NAME"])
119 $sellerBankCity =
'';
120 if (
$params[
"SELLER_COMPANY_BANK_CITY"])
122 $sellerBankCity =
$params[
"SELLER_COMPANY_BANK_CITY"];
123 if (is_array($sellerBankCity))
124 $sellerBankCity = implode(
', ', $sellerBankCity);
126 $sellerBankCity = str_replace(
array(
"\r\n",
"\n",
"\r"),
', ', strval($sellerBankCity));
130 $params[
"SELLER_COMPANY_BANK_NAME"],
133 unset($sellerBankCity);
138 $rsPattern =
'/\s*\d{10,100}\s*/';
140 $sellerBank = trim(preg_replace($rsPattern,
' ',
$params[
"SELLER_COMPANY_BANK_ACCOUNT"]));
142 preg_match($rsPattern,
$params[
"SELLER_COMPANY_BANK_ACCOUNT"],
$matches);
153 (
$params[
"SELLER_COMPANY_INN"])
160 (
$params[
"SELLER_COMPANY_KPP"])
191 $pdf->Cell(300, 18, $string);
202 $pdf->Cell(0, 18, $string);
206 $pdf->Cell(300, 18,
'');
207 $pdf->Cell(50, 18,
'');
228 $pdf->Cell(300, 18, $string);
235 while (
$pdf->GetStringWidth($bankAccountCorr) > 0)
237 list($string, $bankAccountCorr) =
$pdf->splitString($bankAccountCorr, $size-5);
239 $pdf->Cell(0, 18, $string);
240 if ($bankAccountCorr)
243 $pdf->Cell(300, 18,
'');
244 $pdf->Cell(50, 18,
'');
265 $params[
'BILL_HEADER'].
' '.Loc::getMessage(
'SALE_HPS_BILL_SELLER_TITLE',
array(
'#PAYMENT_NUM#' =>
$params[
"ACCOUNT_NUMBER"],
'#PAYMENT_DATE#' =>
$params[
"PAYMENT_DATE_INSERT"]))
274if (
$params[
"BILL_ORDER_SUBJECT"])
280if (
$params[
"PAYMENT_DATE_PAY_BEFORE"])
288if (
$params[
'BILL_PAYER_SHOW'] ==
'Y')
290 if (
$params[
"BUYER_PERSON_COMPANY_NAME"])
293 if (
$params[
"BUYER_PERSON_COMPANY_INN"])
295 if (
$params[
"BUYER_PERSON_COMPANY_ADDRESS"])
297 $buyerAddr =
$params[
"BUYER_PERSON_COMPANY_ADDRESS"];
298 if (is_array($buyerAddr))
299 $buyerAddr = implode(
', ', $buyerAddr);
301 $buyerAddr = str_replace(
array(
"\r\n",
"\n",
"\r"),
', ', strval($buyerAddr));
304 if (
$params[
"BUYER_PERSON_COMPANY_PHONE"])
306 if (
$params[
"BUYER_PERSON_COMPANY_FAX"])
308 if (
$params[
"BUYER_PERSON_COMPANY_NAME_CONTACT"])
323 if (
$params[
'BILL_COLUMN_'.$column.
'_SHOW'] ==
'Y')
325 $caption =
$params[
'BILL_COLUMN_'.$column.
'_TITLE'];
326 if (in_array($column,
array(
'PRICE',
'SUM')))
327 $caption .=
', '.$currency;
331 'SORT' =>
$params[
'BILL_COLUMN_'.$column.
'_SORT']
342 'SORT' =>
$val[
'SORT']
347uasort(
$arCols,
function (
$a, $b) {
return (
$a[
'SORT'] < $b[
'SORT']) ? -1 : 1;});
359 foreach (
$params[
'BASKET_ITEMS'] as $basketItem)
361 $productName = $basketItem[
"NAME"];
362 if ($productName ==
"OrderDelivery")
363 $productName = Loc::getMessage(
'SALE_HPS_BILL_DELIVERY');
364 else if ($productName ==
"OrderDiscount")
365 $productName = Loc::getMessage(
'SALE_HPS_BILL_DISCOUNT');
367 if ($basketItem[
'IS_VAT_IN_PRICE'])
368 $basketItemPrice = $basketItem[
'PRICE'];
370 $basketItemPrice = $basketItem[
'PRICE']*(1 + $basketItem[
'VAT_RATE']);
373 foreach (
$arCols as $columnId => $col)
381 $arCols[$columnId][
'IS_DIGIT'] =
true;
388 $arCols[$columnId][
'IS_DIGIT'] =
true;
391 $data =
CSalePdf::prepareToPdf($basketItem[
"MEASURE_NAME"] ? $basketItem[
"MEASURE_NAME"] : Loc::getMessage(
'SALE_HPS_BILL_BASKET_MEASURE_DEFAULT'));
392 $arCols[$columnId][
'IS_DIGIT'] =
true;
396 $arCols[$columnId][
'IS_DIGIT'] =
true;
400 $arCols[$columnId][
'IS_DIGIT'] =
true;
404 $arCols[$columnId][
'IS_DIGIT'] =
true;
407 if (preg_match(
'/[^0-9 ,\.]/', $basketItem[$columnId]) === 0)
409 if (!array_key_exists(
'IS_DIGIT',
$arCols[$columnId]))
410 $arCols[$columnId][
'IS_DIGIT'] =
true;
414 $arCols[$columnId][
'IS_DIGIT'] =
false;
423 foreach ($basketItem[
'PROPS'] as $basketPropertyItem)
425 if ($basketPropertyItem[
'CODE'] ==
'CATALOG.XML_ID' || $basketPropertyItem[
'CODE'] ==
'PRODUCT.XML_ID')
428 $arProps[
$n][] = $pdf::prepareToPdf(sprintf(
"%s: %s", $basketPropertyItem[
"NAME"], $basketPropertyItem[
"VALUE"]));
431 $sum += doubleval($basketItem[
'PRICE'] * $basketItem[
'QUANTITY']);
432 $vat = max(
$vat, $basketItem[
'VAT_RATE']);
444 if (
$params[
'DELIVERY_PRICE'] > 0)
446 $sDeliveryItem = Loc::getMessage(
'SALE_HPS_BILL_DELIVERY');
448 $sDeliveryItem .= sprintf(
" (%s)",
$params[
'DELIVERY_NAME']);
450 foreach (
$arCols as $columnId => $col)
488 if (
$params[
'BILL_TOTAL_SHOW'] ==
'Y')
503 foreach (
$params[
'TAXES'] as $tax)
511 ($tax[
"IS_IN_PRICE"] ==
"Y") ? Loc::getMessage(
'SALE_HPS_BILL_INCLUDING') :
"",
539 if (
$params[
'DISCOUNT_PRICE'] > 0)
571 foreach (
$arCols as $columnId => $column)
574 if (
$vat > 0 || $columnId !==
'VAT_RATE')
577 if (
$arCols[$columnId][
'NAME'])
584 ${
"x".($i+1)} =
$pdf->GetX();
607 $accumulatedContent = 0;
608 foreach (
$arCols as $columnId => $column)
612 $accumulated += $arRowsWidth_tmp[$columnId];
613 $arRowsWidth_tmp[$columnId] =
null;
614 $accumulatedContent += $arRowsContentWidth_tmp[$columnId];
615 $arRowsContentWidth_tmp[$columnId] =
null;
619 $arRowsWidth_tmp[$columnId] += $accumulated;
620 $arRowsContentWidth_tmp[$columnId] += $accumulatedContent;
622 $accumulatedContent = 0;
635 foreach (
$arCols as $columnId => $column)
639 list($string,
$arCells[
$n][$columnId]) =
$pdf->splitString(
$arCells[
$n][$columnId], $arRowsContentWidth_tmp[$columnId]);
641 $rowWidth = $arRowsWidth_tmp[$columnId];
643 if (in_array($columnId,
array(
'QUANTITY',
'MEASURE',
'PRICE',
'SUM')))
647 $pdf->Cell($rowWidth, 15, $string, 0, 0,
'R');
650 elseif ($columnId ==
'NUMBER')
653 $pdf->Cell($rowWidth, 15, (
$l == 0) ? $string :
'', 0, 0,
'C');
655 elseif ($columnId ==
'NAME')
660 elseif ($columnId ==
'VAT_RATE')
663 $pdf->Cell($rowWidth, 15, $string, 0, 0,
'R');
676 ${
'x'.($pos+1)} =
$pdf->GetX();
688 if (
$params[
'BILL_COLUMN_NAME_SHOW'] ==
'Y')
690 if (isset($arProps[
$n]) && is_array($arProps[
$n]))
693 foreach ($arProps[
$n] as $property)
697 foreach (
$arCols as $columnId => $caption)
702 if ($columnId ==
'NAME')
703 $pdf->Cell($arRowsWidth_tmp[$columnId], 12, $property, 0, $line);
705 $pdf->Cell($arRowsWidth_tmp[$columnId], 12,
'', 0, $line);
726if (
$params[
'BILL_TOTAL_SHOW'] ==
'Y')
730 'SALE_HPS_BILL_BASKET_TOTAL',
764 array(
'#</div>\s*<div[^>]*>#i',
'#</?div>#i'),
array(
'<br>',
'<br>'),
774 array(
'#</div>\s*<div[^>]*>#i',
'#</?div>#i'),
array(
'<br>',
'<br>'),
785if (
$params[
'BILL_SIGN_SHOW'] ==
'Y')
787 if (
$params[
'BILL_PATH_TO_STAMP'])
789 $filePath =
$pdf->GetImagePath(
$params[
'BILL_PATH_TO_STAMP']);
791 if ($filePath !=
'' && !
$blank && \
Bitrix\Main\IO\File::isFileExists($filePath))
793 list($stampHeight, $stampWidth) =
$pdf->GetImageSize(
$params[
'BILL_PATH_TO_STAMP']);
794 if ($stampHeight && $stampWidth)
796 if ($stampHeight > 120 || $stampWidth > 120)
798 $ratio = 120 / max($stampHeight, $stampWidth);
799 $stampHeight = $ratio * $stampHeight;
800 $stampWidth = $ratio * $stampWidth;
809 $stampWidth, $stampHeight
817 if (
$params[
"SELLER_COMPANY_DIRECTOR_POSITION"])
822 list($signHeight, $signWidth) =
$pdf->GetImageSize(
$params[
'SELLER_COMPANY_DIR_SIGN']);
824 if ($signHeight && $signWidth)
826 $ratio = min(37.5/$signHeight, 150/$signWidth);
827 $signHeight = $ratio * $signHeight;
828 $signWidth = $ratio * $signWidth;
835 if ($isDirSign &&
$pdf->GetStringWidth($sellerDirPos) <= 160)
836 $pdf->SetY(
$pdf->GetY() + min($signHeight, 30) - 15);
837 $pdf->MultiCell(150, 15, $sellerDirPos, 0,
'L');
843 $params[
'SELLER_COMPANY_DIR_SIGN'],
844 $pdf->GetX() + 80 - $signWidth/2,
$pdf->GetY() - $signHeight + 15,
845 $signWidth, $signHeight
850 $pdf->Cell(160, 15,
'');
853 if (
$params[
"SELLER_COMPANY_DIRECTOR_NAME"])
863 if (
$params[
"SELLER_COMPANY_ACCOUNTANT_POSITION"])
868 list($signHeight, $signWidth) =
$pdf->GetImageSize(
$params[
'SELLER_COMPANY_ACC_SIGN']);
870 if ($signHeight && $signWidth)
872 $ratio = min(37.5/$signHeight, 150/$signWidth);
873 $signHeight = $ratio * $signHeight;
874 $signWidth = $ratio * $signWidth;
882 $pdf->SetY(
$pdf->GetY() + min($signHeight, 30) - 15);
883 $pdf->MultiCell(150, 15, $sellerAccPos, 0,
'L');
889 $params[
'SELLER_COMPANY_ACC_SIGN'],
890 $pdf->GetX() + 80 - $signWidth/2,
$pdf->GetY() - $signHeight + 15,
891 $signWidth, $signHeight
899 if (
$params[
"SELLER_COMPANY_ACCOUNTANT_NAME"])
915 'Schet No %s ot %s.pdf',
918 chr(0), chr(1), chr(2), chr(3), chr(4), chr(5), chr(6), chr(7), chr(8), chr(9), chr(10), chr(11),
919 chr(12), chr(13), chr(14), chr(15), chr(16), chr(17), chr(18), chr(19), chr(20), chr(21), chr(22),
920 chr(23), chr(24), chr(25), chr(26), chr(27), chr(28), chr(29), chr(30), chr(31),
921 '"',
'*',
'/',
':',
'<',
'>',
'?',
'\\',
'|'
924 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(CSalePaySystemAction::GetParamValue('BACKGROUND', false)) $margin
if(!empty($sellerData)) $dest
$arPaySysAction["ENCODING"]
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="")