32 private static $order =
null;
33 private static $defaultFields =
null;
35 private static function prepareData($item, $error =
false)
39 global $USER, $APPLICATION;
40 static $users = array();
41 static $userCompanyList = array();
45 $orderClass = $registry->getOrderClassName();
47 if (is_null(self::$order))
48 self::$order = $item->getCollection()->getOrder();
50 $fields = ($error) ? self::$defaultFields : $item->getFieldValues();
52 $fields[
'EMP_PAID_ID_NAME'] =
'';
53 $fields[
'EMP_PAID_ID_LAST_NAME'] =
'';
55 $empPaidId = (int)($fields[
'EMP_PAID_ID'] ?? 0);
58 if (!array_key_exists($item->getField(
'EMP_PAID_ID'), $users))
59 $users[$empPaidId] = $USER->GetByID($empPaidId)->Fetch();
60 $fields[
'EMP_PAID_ID_NAME'] = $users[$empPaidId][
'NAME'];
61 $fields[
'EMP_PAID_ID_LAST_NAME'] = $users[$empPaidId][
'LAST_NAME'];
64 $fields[
'ORDER_ID'] = self::$order->getId();
65 $fields[
'SUM'] = $item->getSum();
66 $fields[
'ORDER_PRICE'] = self::$order->getPrice();
67 $fields[
'ORDER_PAYMENT_SUM'] = $item->getCollection()->getSum();
68 $fields[
'CURRENCY'] = self::$order->getCurrency();
69 $fields[
'PERSON_TYPE_ID'] = self::$order->getPersonTypeId();
70 $fields[
'SITE_ID'] = self::$order->getSiteId();
71 $fields[
'STATUS_ID'] = self::$order->getField(
'STATUS_ID');
72 $fields[
'ORDER_LOCKED'] = $orderClass::isLocked($fields[
'ORDER_ID']);
74 $saleModulePermissions = $APPLICATION->GetGroupRight(
"sale");
76 if($saleModulePermissions ==
"P")
78 if (empty($userCompanyList))
80 $userCompanyList = Company\Manager::getUserCompanyList($USER->GetID());
83 $isUserResponsible =
false;
85 if (self::$order->getField(
'RESPONSIBLE_ID') == $USER->GetID()
86 || ($fields[
'RESPONSIBLE_ID'] == $USER->GetID()))
88 $isUserResponsible =
true;
91 $isAllowCompany = in_array($item->getField(
'COMPANY_ID'), $userCompanyList) || in_array(self::$order->getField(
'COMPANY_ID'), $userCompanyList);
94 if (!$isUserResponsible && !$isAllowCompany)
96 foreach ($fields as $fieldName => $fieldValue)
98 if (in_array($fieldName, static::getDisallowFields()))
100 unset($fields[$fieldName]);
105 $fields[
'IS_USER_RESPONSIBLE'] = $isUserResponsible;
106 $fields[
'IS_ALLOW_COMPANY'] = $isAllowCompany;
109 $fields[
'PAY_SYSTEM_LIST'] = self::getPaySystemList($item);
111 $fields[
'CHECK'] = CheckManager::getCheckInfo($item);
113 $paySystemId = (int)($fields[
'PAY_SYSTEM_ID'] ?? 0);
114 $fields[
'CAN_PRINT_CHECK'] = $fields[
'PAY_SYSTEM_LIST'][$paySystemId][
'CAN_PRINT_CHECK'] ??
'N';
115 if (
Sale\
Cashbox\Manager::isEnabledPaySystemPrint())
117 $fields[
'CAN_PRINT_CHECK'] =
'N';
120 $dbRes = CashboxTable::getList(array(
'filter' => array(
'=ACTIVE' =>
'Y',
'=ENABLED' =>
'Y')));
121 $fields[
'HAS_ENABLED_CASHBOX'] = ($dbRes->fetch()) ?
'Y' :
'N';
123 $service = $item->getPaySystem();
124 $fields[
'HAS_PREVIEW'] = $service && $service->isAffordPdf();
130 private static function getDisallowFields()
134 'EMP_PAID_ID_LAST_NAME',
145 static $result = array();
147 if (!isset($result[$paySystemId]))
150 if ($paySystemId > 0)
152 $data = PaySystemActionTable::getRow(array(
153 'select' => array(
'NAME',
'LOGOTIP',
'HAVE_RESULT',
'RESULT_FILE',
'ACTION_FILE'),
154 'filter' => array(
'ID' => $paySystemId),
158 $result[$paySystemId] = $data;
160 $logotip = (int)($data[
"LOGOTIP"] ?? 0);
163 $tmp = \CFile::ResizeImageGet($logotip, array(
'width' => 100,
'height' => 60));
164 $result[$paySystemId][
"LOGOTIP_PATH"] = $tmp[
'src'];
165 $tmp = \CFile::ResizeImageGet($logotip, array(
'width' => 80,
'height' => 50));
166 $result[$paySystemId][
"LOGOTIP_SHORT_PATH"] = $tmp[
'src'];
170 $result[$paySystemId][
"LOGOTIP_PATH"] =
'/bitrix/images/sale/nopaysystem.gif';
171 $result[$paySystemId][
"LOGOTIP_SHORT_PATH"] =
'/bitrix/images/sale/nopaysystem.gif';
175 return $result[$paySystemId];
183 public static function modifyData($payment, $data)
187 if (is_null(self::$order))
188 self::$order = $payment->getCollection()->getOrder();
191 $data[
'ERROR'] =
'Y';
192 $data[
'ID'] = $data[
'PAYMENT_ID'];
193 $data[
'CURRENCY'] = self::$order->getCurrency();
194 $data[
'PERSON_TYPE_ID'] = self::$order->getPersonTypeId();
195 $data[
'SITE_ID'] = self::$order->getSiteId();
207 public static function getEdit($payment, $index = 1, $dataForRecovery = array())
209 global $USER, $APPLICATION;
211 $saleModulePermissions = $APPLICATION->GetGroupRight(
"sale");
213 $data = self::prepareData($payment, !empty($dataForRecovery));
215 $data[
'COMPANIES'] = Company\Manager::getListWithRestrictions($payment, Company\Restrictions\Manager::MODE_MANAGER);
217 $userCompanyId =
null;
218 if($saleModulePermissions ==
"P")
220 $userCompanyList = Company\Manager::getUserCompanyList($USER->GetID());
221 if (!empty($userCompanyList) && is_array($userCompanyList) && count($userCompanyList) == 1)
223 $userCompanyId = reset($userCompanyList);
226 if ($payment->getId() == 0)
228 if (intval($userCompanyId) > 0)
230 $payment->setField(
'COMPANY_ID', $userCompanyId);
232 $payment->setField(
'RESPONSIBLE_ID', $USER->GetID());
236 $result = self::getEditTemplate($data, $index, $dataForRecovery);
248 public static function getView($payment, $index = 1, $form=
'')
250 $data = self::prepareData($payment);
251 return self::getViewTemplate($data, $index, $form);
260 Asset::getInstance()->addJs(
"/bitrix/js/sale/admin/order_payment.js");
261 $imgPathList = self::getImgPathList();
264 'PAYMENT_PAID_YES' =>
Loc::getMessage(
'SALE_ORDER_PAYMENT_STATUS_YES'),
267 'PAYMENT_RETURN_COMMENT' =>
Loc::getMessage(
'SALE_ORDER_PAYMENT_RETURN_COMMENT'),
268 'PAYMENT_RETURN_NUM' =>
Loc::getMessage(
'SALE_ORDER_PAYMENT_RETURN_NUM'),
269 'PAYMENT_RETURN_DATE' =>
Loc::getMessage(
'SALE_ORDER_PAYMENT_RETURN_DATE'),
270 'PAYMENT_OPERATION_TITLE' =>
Loc::getMessage(
'SALE_ORDER_PAYMENT_OPERATION_TITLE'),
271 'PAYMENT_OPERATION_RETURN' =>
Loc::getMessage(
'SALE_ORDER_PAYMENT_OPERATION_RETURN'),
272 'PAYMENT_RETURN_DATE_ALT' =>
Loc::getMessage(
'SALE_ORDER_PAYMENT_RETURN_DATE_ALT'),
273 'PAYMENT_WINDOW_RETURN_TITLE' =>
Loc::getMessage(
'SALE_ORDER_PAYMENT_WINDOW_RETURN_TITLE'),
274 'PAYMENT_WINDOW_CANCEL_TITLE' =>
Loc::getMessage(
'SALE_ORDER_PAYMENT_WINDOW_CANCEL_TITLE'),
275 'PAYMENT_WINDOW_RETURN_BUTTON_SAVE' =>
Loc::getMessage(
'SALE_ORDER_PAYMENT_WINDOW_RETURN_BUTTON_SAVE'),
276 'PAYMENT_RETURN_NUM_DOC' =>
Loc::getMessage(
'SALE_ORDER_PAYMENT_RETURN_NUM_DOC'),
277 'PAYMENT_RETURN_SUM' =>
Loc::getMessage(
'SALE_ORDER_PAYMENT_RETURN_SUM'),
278 'PAYMENT_OPERATION_CANCEL' =>
Loc::getMessage(
'SALE_ORDER_PAYMENT_OPERATION_CANCEL'),
279 'PAYMENT_TOGGLE_DOWN' =>
Loc::getMessage(
'SALE_ORDER_PAYMENT_TOGGLE_DOWN'),
280 'PAYMENT_TOGGLE_UP' =>
Loc::getMessage(
'SALE_ORDER_PAYMENT_TOGGLE_UP'),
281 'PAYMENT_PAY_VOUCHER_NUM' =>
Loc::getMessage(
'SALE_ORDER_PAYMENT_PAY_VOUCHER_NUM'),
282 'PAYMENT_PAY_VOUCHER_DATE' =>
Loc::getMessage(
'SALE_ORDER_PAYMENT_PAY_VOUCHER_DATE'),
283 'PAYMENT_WINDOW_VOUCHER_TITLE' =>
Loc::getMessage(
'SALE_ORDER_PAYMENT_WINDOW_VOUCHER_TITLE'),
284 'PAYMENT_USE_INNER_BUDGET' =>
Loc::getMessage(
'SALE_ORDER_PAYMENT_USE_INNER_BUDGET'),
285 'PAYMENT_ORDER_STATUS' =>
Loc::getMessage(
'SALE_ORDER_PAYMENT_ORDER_STATUS'),
286 'PAYMENT_CONFIRM_DELETE' =>
Loc::getMessage(
'SALE_ORDER_PAYMENT_CONFIRM_DELETE'),
287 'PAYMENT_CASHBOX_CHECK_ADD_WINDOW_TITLE' =>
Loc::getMessage(
'PAYMENT_CASHBOX_CHECK_ADD_WINDOW_TITLE')
289 return '<script type="text/javascript">
290 BX.message('.\CUtil::PhpToJSObject($message).
');
291 logoList = '.\CUtil::PhpToJSObject($imgPathList).
';
294 if(BX.Sale.Admin.OrderEditPage && BX.Sale.Admin.OrderEditPage.registerFieldsUpdaters)
295 BX.Sale.Admin.OrderEditPage.registerFieldsUpdaters( BX.Sale.Admin.OrderPayment.prototype.getCreateOrderFieldsUpdaters() );
301 private static function getEditTemplate($data, $index, $post = array())
303 global $USER, $APPLICATION;
305 $saleModulePermissions = $APPLICATION->GetGroupRight(
"sale");
307 $paid = ($post) ? htmlspecialcharsbx($post[
'PAID']) : $data[
'PAID'];
308 $id = ($post) ? (
int)$post[
'PAYMENT_ID'] : ($data[
'ID'] ?? 0);
309 $priceCod = ($post) ? htmlspecialcharsbx($post[
'PRICE_COD']) : ($data[
'PRICE_COD'] ?? 0);
310 $paidString = ($paid ==
'Y') ?
'YES' :
'NO';
313 if ($data[
'SUM'] > 0)
316 $sum = ($data[
'ORDER_PRICE'] - $data[
'ORDER_PAYMENT_SUM'] <= 0) ? 0 : $data[
'ORDER_PRICE'] - $data[
'ORDER_PAYMENT_SUM'];
324 (isset($post[
'PAY_SYSTEM_ID'])) ? $post[
'PAY_SYSTEM_ID'] : ($data[
'PAY_SYSTEM_ID'] ?? 0)
327 if (isset($psData[
"LOGOTIP_PATH"]))
328 $data[
'PAY_SYSTEM_LOGOTIP'] = $psData[
"LOGOTIP_PATH"];
331 $isAllowPayment = in_array($data[
"STATUS_ID"], $allowedOrderStatusesPayment);
332 $triangle = ($isAllowPayment) ?
'<span class="triangle"> ▾</span>' :
'';
333 $class = ($paid !=
'Y') ?
'notpay' :
'';
334 $class .= (!$isAllowPayment) ?
' not_active' :
'';
336 $paymentStatus =
'<span><span id="BUTTON_PAID_'.$index.
'" class="'.$class.
'">'.
Loc::getMessage(
'SALE_ORDER_PAYMENT_STATUS_'.$paidString).
'</span>'.$triangle.
'</span>';
342 $hiddenPaySystemInnerId =
'';
344 $hiddenPaySystemInnerId =
'<input type="hidden" value="'.PaySystem\Manager::getInnerPaySystemId().
'" id="PAYMENT_INNER_BUDGET_ID">';
346 $notPaidBlock = ($paid ==
'N' && !empty($data[
'EMP_PAID_ID'])) ?
'' :
'style="display:none;"';
348 $return = isset($post[
'IS_RETURN']) && $post[
'IS_RETURN'] ===
'Y' ?
'' :
'style="display:none;"';
350 $option =
'<option value="Y">'.Loc::getMessage(
'SALE_ORDER_PAYMENT_RETURN_ACCOUNT').
'</option>';
352 if (isset($data[
'PAY_SYSTEM_ID']) && $data[
'PAY_SYSTEM_ID'] != PaySystem\Manager::getInnerPaySystemId())
355 $service = PaySystem\Manager::getObjectById($data[
'PAY_SYSTEM_ID']);
356 if ($service && $service->isRefundable())
357 $option .=
'<option value="P">'.htmlspecialcharsbx($service->getField(
'NAME')).
'</option>';
360 $payReturnNum = $post[
'PAY_RETURN_NUM'] ?? $data[
'PAY_RETURN_NUM'] ??
'';
361 $payReturnDate = $post[
'PAY_RETURN_DATE'] ?? $data[
'PAY_RETURN_DATE'] ??
'';
362 $payReturnComment = $post[
'PAY_RETURN_COMMENT'] ?? $data[
'PAY_RETURN_COMMENT'] ??
'';
364 $returnInformation =
'
365 <tr '.$return.
' class="return">
366 <td class="adm-detail-content-cell-l fwb">'.
Loc::getMessage(
'SALE_ORDER_PAYMENT_RETURN_TO').
':</td>
367 <td class="adm-detail-content-cell-r">
368 <select name="PAYMENT['.$index.
'][OPERATION_ID]" id="OPERATION_ID_'.$index.
'" class="adm-bus-select">
373 <tr '.$return.
' class="return">
374 <td colspan="2" style="text-align: center">'.$note.
'</td>
376 <tr '.$notPaidBlock.
' class="not_paid">
377 <td class="adm-detail-content-cell-l" width="40%"><br>'.
Loc::getMessage(
'SALE_ORDER_PAYMENT_PAY_RETURN_NUM').
':</td>
378 <td class="adm-detail-content-cell-r tal">
380 <input type="text" class="adm-bus-input" name="PAYMENT['.$index.
'][PAY_RETURN_NUM]" id="PAYMENT_RETURN_NUM_'.$index.
'" value="'.htmlspecialcharsbx($payReturnNum).
'" maxlength="20">
383 <tr '.$notPaidBlock.
' class="not_paid">
384 <td class="adm-detail-content-cell-l" width="40%">'.
Loc::getMessage(
'SALE_ORDER_PAYMENT_PAY_RETURN_DATE').
':</td>
385 <td class="adm-detail-content-cell-r tal">
386 <div class="adm-input-wrap adm-calendar-second" style="display: inline-block;">
387 <input type="text" class="adm-input adm-calendar-to" name="PAYMENT['.$index.
'][PAY_RETURN_DATE]" id="PAYMENT_RETURN_DATE_'.$index.
'" size="15" value="'.htmlspecialcharsbx($payReturnDate).
'">
388 <span class="adm-calendar-icon" title="'.
Loc::getMessage(
'SALE_ORDER_PAYMENT_CHOOSE_DATE').
'" onclick="BX.calendar({node:this, field:\'PAYMENT_RETURN_DATE_'.$index.
'\', form: \
'\', bTime:
false, bHideTime:
false});
"></span>
392 <tr '.$notPaidBlock.' class="not_paid
">
393 <td class="adm-detail-content-cell-l
" width="40%
">'.Loc::getMessage('SALE_ORDER_PAYMENT_RETURN_COMMENT').':</td>
394 <td class="adm-detail-content-cell-r tal
">
395 <div class="adm-input-wrap adm-calendar-second
" style="display:
inline-block;
">
396 <textarea name="PAYMENT[
'.$index.'][PAY_RETURN_COMMENT]
" id="PAYMENT_RETURN_COMMENTS_
'.$index.'">'.htmlspecialcharsbx($payReturnComment).'</textarea>
401 $lang = Main\Application::getInstance()->getContext()->getLanguage();
405 $dateBill = new Date($data['DATE_BILL']);
406 $title = Loc::getMessage('SALE_ORDER_PAYMENT_BLOCK_EDIT_PAYMENT_TITLE', array('#ID#' => $data['ID'], '#DATE_BILL#' => $dateBill));
410 $title = Loc::getMessage('SALE_ORDER_PAYMENT_BLOCK_NEW_PAYMENT_TITLE');
413 $disabled = isset($data['PAID']) && $data['PAID'] === 'Y' ? 'readonly' : '';
415 $companyList = $data['COMPANIES'];
418 if (!empty($companyList))
420 if ($saleModulePermissions == "P
")
422 $userCompanyId = null;
423 $userCompanyList = Company\Manager::getUserCompanyList($USER->GetID());
424 if (is_array($userCompanyList) && count($userCompanyList) == 1)
426 $userCompanyId = reset($userCompanyList);
427 $companyName = $data['COMPANIES'][$userCompanyId]["NAME
"]." [
".$data['COMPANIES'][$userCompanyId]["ID
"]."]
";
428 $companies = htmlspecialcharsbx($companyName);
432 foreach ($data['COMPANIES'] as $companyId => $companyData)
434 $foundCompany = false;
436 if (!empty($userCompanyList) && is_array($userCompanyList))
438 foreach ($userCompanyList as $userCompanyId)
440 if ($userCompanyId == $companyId)
442 $foundCompany = true;
450 unset($data['COMPANIES'][$companyId]);
454 if (count($data['COMPANIES']) == 1)
456 $company = reset($data['COMPANIES']);
457 $companies = htmlspecialcharsbx($company["NAME
"]." [
".$company["ID
"]."]
");
462 if (empty($companies))
464 $companies = OrderEdit::makeSelectHtmlWithRestricted(
465 'PAYMENT['.$index.'][COMPANY_ID]',
467 isset($post["COMPANY_ID
"]) ? $post["COMPANY_ID
"] : $data["COMPANY_ID
"],
470 "class" => "adm-bus-select
",
471 "id" => "PAYMENT_COMPANY_ID_
".$index
478 if ($saleModulePermissions >= "W
")
480 $companies = str_replace("#URL#
", "/
bitrix/admin/sale_company_edit.php?lang=
".$lang, Loc::getMessage('SALE_ORDER_PAYMENT_ADD_COMPANY'));
485 $checkLink .= '<tr><td class="tac
" id="PAYMENT_CHECK_LIST_ID_
'.($data['ID
'] ?? 0).'">';
486 if (!empty($data['CHECK']))
488 $checkLink .= static::buildCheckHtml($data['CHECK']);
490 $checkLink .= '</td></tr>';
491 if ($data['CAN_PRINT_CHECK'] == 'Y' && $data['HAS_ENABLED_CASHBOX'] === 'Y')
493 $checkLink .= '<tr><td class="adm-detail-content-cell-r tac
"><a href="javascript:void(0);
" onclick="BX.Sale.Admin.OrderPayment.prototype.showCreateCheckWindow(
'.$data['ID
'].');
">'.Loc::getMessage('SALE_ORDER_PAYMENT_CHECK_ADD').'</a></td></tr>';
496 $isReturn = $post['IS_RETURN'] ?? 'N';
497 $paySystemId = $post['PAY_SYSTEM_ID'] ?? $data['PAY_SYSTEM_ID'] ?? 0;
498 $payVoucherNum = $post['PAY_VOUCHER_NUM'] ?? $data['PAY_VOUCHER_NUM'] ?? '';
499 $payVoucherDate = $post['PAY_VOUCHER_DATE'] ?? $data['PAY_VOUCHER_DATE'] ?? '';
501 $data['DATE_PAID'] ??= '';
502 $data['EMP_PAID_ID'] ??= '';
503 $data['EMP_PAID_ID_NAME'] ??= '';
504 $data['EMP_PAID_ID_LAST_NAME'] ??= '';
507 <div class="adm-bus-pay
" id="payment_container_
'.$index.'">
508 <input type="hidden
" name="PAYMENT[
'.$index.'][PAYMENT_ID]
" id="payment_id_
'.$index.'" value="'.$id.'">
509 <input type="hidden
" name="PAYMENT[
'.$index.'][INDEX]
" value="'.$index.'" class="index
">
510 <input type="hidden
" name="PAYMENT[
'.$index.'][PAID]
" id="PAYMENT_PAID_
'.$index.'" value="'.(empty($paid) ? 'N
' : $paid).'">
511 <input type="hidden
" name="PAYMENT[
'.$index.'][IS_RETURN]
" id="PAYMENT_IS_RETURN_
'.$index.'" value="'.(htmlspecialcharsbx($isReturn)).'">
512 <input type="hidden
" name="PAYMENT[
'.$index.'][IS_RETURN_CHANGED]
" id="PAYMENT_IS_RETURN_CHANGED_
'.$index.'" value="N
">
513 '.$hiddenPaySystemInnerId.'
514 <div class="adm-bus-component-content-container
">
515 <div class="adm-bus-pay-section
">
516 <div class="adm-bus-pay-section-title-container
">
517 <div class="adm-bus-pay-section-title
">'.$title.'</div>
518 <div class="adm-bus-pay-section-action-block
">'.
519 ((!isset($data['ID']) || $data['ID'] <= 0) ? '<div class="adm-bus-pay-section-action
" id="SECTION_
'.$index.'_DELETE
">'.Loc::getMessage('SALE_ORDER_PAYMENT_DELETE').'</div>' : '')
522 <div class="adm-bus-pay-section-content
" id="SECTION_
'.$index.'">
523 <div class="adm-bus-pay-section-sidebar
">
524 <div style="background: url(\
''.$data[
'PAY_SYSTEM_LOGOTIP'].
'\')
" class="adm-shipment-block-logo
" id="LOGOTIP_
'.$index.'"></div>
526 <div class="adm-bus-pay-section-right
">
527 <div class="adm-bus-table-container caption border
">
528 <div class="adm-bus-table-caption-title
" style="background: #eef5f5;
">'.Loc::getMessage('SALE_ORDER_PAYMENT_METHOD').'</div>
529 <table border="0
" cellspacing="0
" cellpadding="0
" width="100%
" class="adm-detail-content-table edit-table
">
532 <td class="adm-detail-content-cell-l fwb
" width="40%
">'.Loc::getMessage('SALE_ORDER_PAYMENT_PAY_SYSTEM').':</td>
533 <td class="adm-detail-content-cell-r
">'.
534 OrderEdit::makeSelectHtmlWithRestricted(
535 'PAYMENT['.$index.'][PAY_SYSTEM_ID]',
536 $data['PAY_SYSTEM_LIST'],
540 "class" => "adm-bus-select
",
541 "id" => "PAY_SYSTEM_ID_
".$index
549 <div class="adm-bus-table-container caption border
">
550 <div class="adm-bus-table-caption-title
" style="background: #eef5f5;
">'.Loc::getMessage('SALE_ORDER_PAYMENT_SUM').'</div>
551 <table border="0
" cellspacing="0
" cellpadding="0
" width="100%
" class="adm-detail-content-table edit-table
">
554 <td class="adm-detail-content-cell-l
" width="40%
">'.Loc::getMessage('SALE_ORDER_PAYMENT_PAYABLE_SUM').':</td>
555 <td class="adm-detail-content-cell-r tal
">'
556 . \CCurrencyLang::getPriceControl(
557 '<input type="text
" class="adm-bus-input-price
" name="PAYMENT[
'.$index.'][SUM]
" id="PAYMENT_SUM_
'.$index.'" value="'.round($sum, 2).'" '.$disabled.'>',
562 <tr '.($priceCod > 0 ?: 'style="display: none
"').'>
563 <td class="adm-detail-content-cell-l
" width="40%
">'.Loc::getMessage('SALE_ORDER_PAYMENT_PAYABLE_PRICE_COD').':</td>
564 <td class="adm-detail-content-cell-r tal
">'
565 . \CCurrencyLang::getPriceControl(
566 '<input type="text
" class="adm-bus-input-price
" name="PAYMENT[
'.$index.'][PRICE_COD]
" id="PAYMENT_PRICE_COD_
'.$index.'" value="'.round($priceCod, 2).'" readonly>',
574 <div class="adm-bus-table-container caption border
" style="padding-top:10px;
">
575 <div class="adm-bus-table-caption-title
" style="background: #eef5f5;
">'.Loc::getMessage('SALE_ORDER_PAYMENT_STATUS').'</div>
576 <table border="0
" cellspacing="0
" cellpadding="0
" width="100%
" class="adm-detail-content-table alternation edit-table
" id="PAYMENT_BLOCK_STATUS_
'.$index.'">
579 <td class="adm-detail-content-cell-l vat payment-status
" width="40%
">
582 <td class="adm-detail-content-cell-r tal
" id="PAYMENT_CHANGE_USER_INFO_
'.$index.'">
583 '.$data['DATE_PAID'].'
584 <a href="/
bitrix/admin/user_edit.php?lang=
'.$lang.'&ID=
'.$data['EMP_PAID_ID
'].'">'.htmlspecialcharsbx($data['EMP_PAID_ID_NAME']).' '.htmlspecialcharsbx($data['EMP_PAID_ID_LAST_NAME']).'</a>
589 <table border="0
" cellspacing="0
" cellpadding="0
" width="100%
" class="adm-detail-content-table edit-table
" id="PAYMENT_BLOCK_STATUS_INFO_
'.$index.'">
592 <td class="adm-detail-content-cell-l
" width="40%
">'.Loc::getMessage('SALE_ORDER_PAYMENT_PAY_VOUCHER_NUM').':</td>
593 <td class="adm-detail-content-cell-r tal
">
594 <input type="text
" class="adm-bus-input
" id="PAYMENT_NUM
" name="PAYMENT[
'.$index.'][PAY_VOUCHER_NUM]
" value="'.htmlspecialcharsbx($payVoucherNum).'" maxlength="20
">
598 <td class="adm-detail-content-cell-l
" width="40%
">'.Loc::getMessage('SALE_ORDER_PAYMENT_PAY_VOUCHER_DATE').':</td>
599 <td class="adm-detail-content-cell-r tal
">
600 <div class="adm-input-wrap adm-calendar-second
" style="display:
inline-block;
">
601 <input type="text
" class="adm-input adm-calendar-to
" id="PAYMENT_DATE_
'.$index.'" name="PAYMENT[
'.$index.'][PAY_VOUCHER_DATE]
" size="15
" value="'.htmlspecialcharsbx($payVoucherDate).'">
602 <span class="adm-calendar-icon
" title="'.Loc::getMessage('SALE_ORDER_PAYMENT_CHOOSE_DATE
').'" onclick="BX.calendar({node:
this, field:\
'PAYMENT_DATE_'.$index.
'\', form: \
'\', bTime:
false, bHideTime:
false});
"></span>
606 '.$returnInformation.'
610 if ($data['CAN_PRINT_CHECK'] == 'Y' && $data['ID'] > 0)
612 $result .= '<div class="adm-bus-table-container caption border
" style="padding-top:10px;
">
613 <div class="adm-bus-table-caption-title
" style="background: #eef5f5;
">'.Loc::getMessage('SALE_ORDER_PAYMENT_CHECK_LINK_TITLE').'</div>
614 <table border="0
" cellspacing="0
" cellpadding="0
" width="100%
" class="adm-detail-content-table edit-table
">
622 if (isset($data['PS_STATUS']) && !empty($data['PS_STATUS']))
624 $result .= '<div class="adm-bus-table-container caption border
">
625 <div class="adm-bus-table-caption-title
" style="background: #eef5f5;
">'.Loc::getMessage('SALE_ORDER_PAYMENT_PS_STATUS_TITLE').'</div>
626 <a href="javascript:void(0);
" id="PS_INFO_
'.$index.'">'.Loc::getMessage('SALE_ORDER_PAYMENT_TOGGLE_DOWN').'</a>
627 <table border="0
" cellspacing="0
" cellpadding="0
" width="100%
" class="adm-detail-content-table edit-table
" style="display: none
">
630 <td class="adm-detail-content-cell-l vat
" width="40%
">'.Loc::getMessage('SALE_ORDER_PAYMENT_PS_STATUS').':</td>
631 <td class="adm-detail-content-cell-r tal
">'.$data['PS_STATUS'].'</td>
634 <td class="adm-detail-content-cell-l vat
" width="40%
">'.Loc::getMessage('SALE_ORDER_PAYMENT_PS_STATUS_CODE').':</td>
635 <td class="adm-detail-content-cell-r tal
">'.$data['PS_STATUS_CODE'].'</td>
638 <td class="adm-detail-content-cell-l vat
" width="40%
">'.Loc::getMessage('SALE_ORDER_PAYMENT_PS_STATUS_DESCRIPTION').':</td>
639 <td class="adm-detail-content-cell-r tal
">'.$data['PS_STATUS_DESCRIPTION'].'</td>
642 <td class="adm-detail-content-cell-l vat
" width="40%
">'.Loc::getMessage('SALE_ORDER_PAYMENT_PS_CURRENCY').':</td>
643 <td class="adm-detail-content-cell-r tal
">'.$data['PS_CURRENCY'].'</td>
646 <td class="adm-detail-content-cell-l vat
" width="40%
">'.Loc::getMessage('SALE_ORDER_PAYMENT_PS_STATUS_MESSAGE').':</td>
647 <td class="adm-detail-content-cell-r tal
">'.$data['PS_STATUS_MESSAGE'].'</td>
650 <td class="adm-detail-content-cell-l vat
" width="40%
">'.Loc::getMessage('SALE_ORDER_PAYMENT_PS_SUM').':</td>
651 <td class="adm-detail-content-cell-r tal
">'.$data['PS_SUM'].'</td>
654 <td class="adm-detail-content-cell-l vat
" width="40%
">'.Loc::getMessage('SALE_ORDER_PAYMENT_PS_DATE').':</td>
655 <td class="adm-detail-content-cell-r tal
">'.$data['PS_RESPONSE_DATE'].'</td>
661 if ($companies !== '')
663 $result .= '<div class="adm-bus-table-container caption border
">
664 <div class="adm-bus-table-caption-title
" style="background: #eef5f5;
">'.Loc::getMessage('SALE_ORDER_PAYMENT_BLOCK_COMPANY').'</div>
665 <table border="0
" cellspacing="0
" cellpadding="0
" width="100%
" class="adm-detail-content-table edit-table
">
668 <td class="adm-detail-content-cell-l
" width="40%
">'.Loc::getMessage('SALE_ORDER_PAYMENT_COMPANY_BY').':</td>
669 <td class="adm-detail-content-cell-r
">'.$companies.'</td>
675 $result .= '</div><div class="clb
"></div></div></div></div></div></div>';
677 $refundablePs = array();
678 if (isset($data['ID']) && $data['ID'] > 0)
680 $innerService = PaySystem\Manager::getObjectById(PaySystem\Manager::getInnerPaySystemId());
681 $refundablePs[Payment::RETURN_INNER] = $innerService->getField('NAME');
682 if ($data['PAY_SYSTEM_ID'] != $innerService->getField('ID'))
684 $service = PaySystem\Manager::getObjectById($data['PAY_SYSTEM_ID']);
685 if ($service && $service->isRefundable())
686 $refundablePs[Payment::RETURN_PS] = $service->getField('NAME');
692 'functionOnSave' => 'saveInHiddenFields',
693 'isPaid' => isset($data['PAID']) && $data['PAID'] === 'Y',
695 'isAvailableChangeStatus' => $isAllowPayment,
696 'psToReturn' => $refundablePs
698 $result .= self::initJsPayment($params);
702 private static function getViewTemplate($data, $index, $form)
706 $isUserResponsible = null;
707 $isAllowCompany = null;
708 $link = Link::getInstance();
710 if (array_key_exists('IS_USER_RESPONSIBLE', $data))
712 $isUserResponsible = $data['IS_USER_RESPONSIBLE'];
715 if (array_key_exists('IS_ALLOW_COMPANY', $data))
717 $isAllowCompany = $data['IS_ALLOW_COMPANY'];
720 $psData = self::getPaySystemParams($data['PAY_SYSTEM_ID']);
722 if ($isAllowCompany === false)
724 $data['PAY_VOUCHER_NUM'] = '';
725 $data['PAY_VOUCHER_DATE'] = '';
726 $data['PAY_RETURN_NUM'] = '';
727 $data['PAY_RETURN_DATE'] = '';
728 $data['PS_STATUS'] = '';
732 if (isset($psData["LOGOTIP_PATH
"]))
734 $data['PAY_SYSTEM_LOGOTIP'] = $psData["LOGOTIP_PATH
"];
735 $data['PAY_SYSTEM_LOGOTIP_SHORT'] = $psData["LOGOTIP_SHORT_PATH
"];
740 if ($psData['HAVE_RESULT'] == 'Y' && $form != 'edit')
742 $psResult .= ' <span style="border-bottom: 1px dashed #658d0f; color: #658d0f; cursor: pointer
" id="ps_update_
'.$index.'">'.Loc::getMessage('SALE_ORDER_PAYMENT_PAY_SYSTEM_CHECK').'</span>';
745 $lang = Main\Application::getInstance()->getContext()->getLanguage();
746 $paidString = ($data['PAID'] == 'Y') ? 'YES' : 'NO';
748 $allowedOrderStatusesPayment = OrderStatus::getStatusesUserCanDoOperations($USER->GetID(), array('payment'));
749 $isAllowPayment = in_array($data["STATUS_ID
"], $allowedOrderStatusesPayment);
751 $isActive = ($form != 'edit' && $form != 'archive') && !$data['ORDER_LOCKED'] && $isAllowPayment;
752 $triangle = ($isActive) ? '<span class="triangle
"> ▾</span>' : '';
754 if ($data['PAID'] == 'Y')
755 $class = (!$isActive) ? 'class="not_active
"' : '';
757 $class = (!$isActive) ? 'class="notpay not_active
"' : 'class="notpay
"';
758 $paymentStatus = '<span><span id="BUTTON_PAID_
'.$index.'" '.$class.'>'.Loc::getMessage('SALE_ORDER_PAYMENT_STATUS_'.$paidString).'</span>'.$triangle.'</span>';
760 $res = CompanyTable::getList(array(
761 'select' => array('NAME'),
762 'filter' => array('ID' => $data['COMPANY_ID'])
764 $company = $res->fetch();
766 $paymentStatusBlockVoucherNum = '';
767 if ($data['PAY_VOUCHER_NUM'] <> '')
769 $paymentStatusBlockVoucherNum = '<tr>
770 <td class="adm-detail-content-cell-l
" width="40%
"><br>'.Loc::getMessage('SALE_ORDER_PAYMENT_PAY_VOUCHER_NUM').':</td>
771 <td class="adm-detail-content-cell-r tal
">
773 '.htmlspecialcharsbx($data['PAY_VOUCHER_NUM']).'
778 $paymentStatusBlockVoucherDate = '';
779 if ($data['PAY_VOUCHER_DATE'] <> '')
781 $paymentStatusBlockVoucherDate = '<tr>
782 <td class="adm-detail-content-cell-l
" width="40%
">'.Loc::getMessage('SALE_ORDER_PAYMENT_PAY_VOUCHER_DATE').':</td>
783 <td class="adm-detail-content-cell-r tal
">
784 <div class="adm-input-wrap adm-calendar-second
" style="display:
inline-block;
">'.htmlspecialcharsbx($data['PAY_VOUCHER_DATE']).'</div>
789 $paymentStatusBlockReturnNum = '';
790 if ($data['PAY_RETURN_NUM'] <> '')
792 $paymentStatusBlockReturnNum = '<tr>
793 <td class="adm-detail-content-cell-l
" width="40%
"><br>'.Loc::getMessage('SALE_ORDER_PAYMENT_PAY_RETURN_NUM').':</td>
794 <td class="adm-detail-content-cell-r tal
">
795 <br>'.htmlspecialcharsbx($data['PAY_RETURN_NUM']).'</td>
799 $paymentStatusBlockReturnDate = '';
800 if ($data['PAY_RETURN_DATE'] <> '')
802 $paymentStatusBlockReturnDate = '<tr>
803 <td class="adm-detail-content-cell-l
" width="40%
">'.Loc::getMessage('SALE_ORDER_PAYMENT_PAY_RETURN_DATE').':</td>
804 <td class="adm-detail-content-cell-r tal
">
805 <div class="adm-input-wrap adm-calendar-second
" style="display:
inline-block;
">'.htmlspecialcharsbx($data['PAY_RETURN_DATE']).'</div>
810 $dateBill = new Date($data['DATE_BILL']);
812 $allowedOrderStatusesEdit = OrderStatus::getStatusesUserCanDoOperations($USER->GetID(), array('update'));
813 $isAllowEdit = in_array($data["STATUS_ID
"], $allowedOrderStatusesEdit) && $form != 'archive';
817 ->setPageByType(Registry::SALE_ORDER_PAYMENT_EDIT)
818 ->setFilterParams(false)
820 ->setField('order_id', $data['ORDER_ID'])
821 ->setField('payment_id', $data['ID'])
822 ->setField('backurl', $_SERVER['REQUEST_URI'])
825 if ($isAllowEdit && !$data['ORDER_LOCKED'])
826 $sectionEdit = '<div class="adm-bus-pay-section-action
" id="SECTION_
'.$index.'_EDIT
"><a href="'.$href.'">'.Loc::getMessage('SALE_ORDER_PAYMENT_EDIT').'</a></div>';
828 $allowedOrderStatusesDelete = OrderStatus::getStatusesUserCanDoOperations($USER->GetID(), array('delete'));
829 $isAllowDelete = in_array($data["STATUS_ID
"], $allowedOrderStatusesDelete) && $form != 'archive';
831 if ($isAllowDelete && !$data['ORDER_LOCKED'])
832 $sectionDelete = '<div class="adm-bus-pay-section-action
" id="SECTION_
'.$index.'_DELETE
">'.Loc::getMessage('SALE_ORDER_PAYMENT_DELETE').'</div>';
834 $checkLink = '<tr><td class="tac
" id="PAYMENT_CHECK_LIST_ID_
'.$data['ID
'].'">';
835 if (!empty($data['CHECK']))
837 $checkLink .= static::buildCheckHtml($data['CHECK']);
839 $checkLink .= "</td></tr>
";
841 if($form != 'archive' && $data['CAN_PRINT_CHECK'] == 'Y' && $data['HAS_ENABLED_CASHBOX'] === 'Y')
843 $checkLink .= '<tr><td class="adm-detail-content-cell-r tac
"><a href="javascript:void(0);
" onclick="BX.Sale.Admin.OrderPayment.prototype.showCreateCheckWindow(
'.$data['ID
'].');
">'.Loc::getMessage('SALE_ORDER_PAYMENT_CHECK_ADD').'</a></td></tr>';
846 if ($isAllowCompany === false && $isUserResponsible === false)
848 $psName = Loc::getMessage('SALE_ORDER_PAYMENT_HIDDEN');
852 $psName = htmlspecialcharsbx($data['PAY_SYSTEM_NAME']).' ['.$data['PAY_SYSTEM_ID'].'] '.$psResult;
853 if ($data['HAS_PREVIEW'])
855 $psName .= " (<a target=
'_blank' href=
'/bitrix/admin/sale_payment_doc_preview.php?PAYMENT_ID={$data['ID
']}&ORDER_ID={$data['ORDER_ID
']}'>
".Loc::getMessage('SALE_ORDER_PAYMENT_DOC_PREVIEW')."</a>)
";
861 <div class="adm-bus-pay
" id="payment_container_
'.$index.'">
862 <input type="hidden
" name="PAYMENT[
'.$index.'][PAYMENT_ID]
" id="PAYMENT_ID_
'.$index.'" value="'.$data['ID
'].'">
863 <div class="adm-bus-component-content-container
">
864 <div class="adm-bus-pay-section
">
865 <div class="adm-bus-pay-section-title-container
">
866 <div class="adm-bus-pay-section-title
" id="payment_
'.$data['ID
'].'">'.$tabTitle = Loc::getMessage('SALE_ORDER_PAYMENT_BLOCK_EDIT_PAYMENT_TITLE', array('#ID#' => $data['ID'], '#DATE_BILL#' => $dateBill)).'</div>
867 <div class="adm-bus-pay-section-action-block
">
868 '.$sectionDelete.$sectionEdit.'
869 <div class="adm-bus-pay-section-action
" id="SECTION_
'.$index.'_TOGGLE
">'.Loc::getMessage('SALE_ORDER_PAYMENT_TOGGLE_DOWN').'</div>
872 <div class="adm-bus-pay-section-content
" id="SECTION_
'.$index.'" style="display:none
">
873 <div class="adm-bus-pay-section-sidebar
">
874 <div style="background: url(\
''.$data[
'PAY_SYSTEM_LOGOTIP'].
'\')" class="adm-shipment-block-logo" id="LOGOTIP_'.$index.
'"></div>
876 <div class="adm-bus-pay-section-right">
877 <div class="adm-bus-table-container caption border">
878 <div class="adm-bus-table-caption-title" style="background: #eef5f5;">'.Loc::getMessage(
'SALE_ORDER_PAYMENT_METHOD').
'</div>
879 <table border="0" cellspacing="0" cellpadding="0" width="100%" class="adm-detail-content-table edit-table ">
882 <td class="adm-detail-content-cell-l" width="40%">'.Loc::getMessage(
'SALE_ORDER_PAYMENT_PAY_SYSTEM').
':</td>
883 <td class="adm-detail-content-cell-r">'.$psName.
'</td>
888 <div class="adm-bus-table-container caption border">
889 <div class="adm-bus-table-caption-title" style="background: #eef5f5;">'.Loc::getMessage(
'SALE_ORDER_PAYMENT_SUM').
'</div>
890 <table border="0" cellspacing="0" cellpadding="0" width="100%" class="adm-detail-content-table edit-table ">
893 <td class="adm-detail-content-cell-l" width="40%">'.Loc::getMessage(
'SALE_ORDER_PAYMENT_PAYABLE_SUM').
':</td>
894 <td class="adm-detail-content-cell-r tal">'.SaleFormatCurrency($data[
'SUM'], $data[
'CURRENCY']).
'<br></td>
896 <tr '.($data[
'PRICE_COD'] > 0 ?:
'style="display: none"').
'>
897 <td class="adm-detail-content-cell-l" width="40%">'.Loc::getMessage(
'SALE_ORDER_PAYMENT_PAYABLE_PRICE_COD').
':</td>
898 <td class="adm-detail-content-cell-r tal" id="PAYMENT_PRICE_COD_'.$index.
'">'.SaleFormatCurrency($data[
'PRICE_COD'], $data[
'CURRENCY']).
'</td>
903 <div class="adm-bus-table-container caption border" style="padding-top:10px;">
904 <div class="adm-bus-table-caption-title" style="background: #eef5f5;">'.Loc::getMessage(
'SALE_ORDER_PAYMENT_STATUS').
'</div>
905 <table border="0" cellspacing="0" cellpadding="0" width="100%" class="adm-detail-content-table alternation edit-table" id="PAYMENT_BLOCK_STATUS_'.$index.
'">
908 <td class="adm-detail-content-cell-l vat payment-status" width="40%">
911 <td class="adm-detail-content-cell-r tal" id="PAYMENT_CHANGE_USER_INFO_'.$index.
'">
912 '.$data[
'DATE_PAID'].
'
913 <a href="/bitrix/admin/user_edit.php?lang='.$lang.
'&ID='.$data[
'EMP_PAID_ID'].
'">'.htmlspecialcharsbx($data[
'EMP_PAID_ID_NAME']).
' '.htmlspecialcharsbx($data[
'EMP_PAID_ID_LAST_NAME']).
'</a>
918 <table border="0" cellspacing="0" cellpadding="0" width="100%" class="adm-detail-content-table edit-table">
920 '.$paymentStatusBlockVoucherNum.$paymentStatusBlockVoucherDate.$paymentStatusBlockReturnNum.$paymentStatusBlockReturnDate.
'
926 $result .=
'<div class="adm-bus-table-container caption border" style="padding-top:10px;">
927 <div class="adm-bus-table-caption-title" style="background: #eef5f5;">'.Loc::getMessage(
'SALE_ORDER_PAYMENT_CHECK_LINK_TITLE').
'</div>
928 <table border="0" cellspacing="0" cellpadding="0" width="100%" class="adm-detail-content-table edit-table">
936 if (isset($data[
'PS_STATUS']) && !empty($data[
'PS_STATUS']))
938 $result .=
'<div class="adm-bus-table-container caption border">
939 <div class="adm-bus-table-caption-title" style="background: #eef5f5;">'.Loc::getMessage(
'SALE_ORDER_PAYMENT_PS_STATUS_TITLE').
'</div>
940 <a href="javascript:void(0);" id="PS_INFO_'.$index.
'">'.
Loc::getMessage(
'SALE_ORDER_PAYMENT_TOGGLE_UP').
'</a>
941 <table border="0" cellspacing="0" cellpadding="0" width="100%" class="adm-detail-content-table edit-table">
944 <td class="adm-detail-content-cell-l vat" width="40%">'.
Loc::getMessage(
'SALE_ORDER_PAYMENT_PS_STATUS').
':</td>
945 <td class="adm-detail-content-cell-r tal">'.htmlspecialcharsbx($data[
'PS_STATUS']).
'</td>
948 <td class="adm-detail-content-cell-l vat" width="40%">'.
Loc::getMessage(
'SALE_ORDER_PAYMENT_PS_STATUS_CODE').
':</td>
949 <td class="adm-detail-content-cell-r tal">'.htmlspecialcharsbx($data[
'PS_STATUS_CODE']).
'</td>
952 <td class="adm-detail-content-cell-l vat" width="40%">'.
Loc::getMessage(
'SALE_ORDER_PAYMENT_PS_STATUS_DESCRIPTION').
':</td>
953 <td class="adm-detail-content-cell-r tal">'.htmlspecialcharsbx($data[
'PS_STATUS_DESCRIPTION']).
'</td>
956 <td class="adm-detail-content-cell-l vat" width="40%">'.
Loc::getMessage(
'SALE_ORDER_PAYMENT_PS_CURRENCY').
':</td>
957 <td class="adm-detail-content-cell-r tal">'.htmlspecialcharsbx($data[
'PS_CURRENCY']).
'</td>
960 <td class="adm-detail-content-cell-l vat" width="40%">'.
Loc::getMessage(
'SALE_ORDER_PAYMENT_PS_STATUS_MESSAGE').
':</td>
961 <td class="adm-detail-content-cell-r tal">'.htmlspecialcharsbx($data[
'PS_STATUS_MESSAGE']).
'</td>
964 <td class="adm-detail-content-cell-l vat" width="40%">'.
Loc::getMessage(
'SALE_ORDER_PAYMENT_PS_SUM').
':</td>
965 <td class="adm-detail-content-cell-r tal">'.htmlspecialcharsbx($data[
'PS_SUM']).
'</td>
968 <td class="adm-detail-content-cell-l vat" width="40%">'.
Loc::getMessage(
'SALE_ORDER_PAYMENT_PS_DATE').
':</td>
969 <td class="adm-detail-content-cell-r tal">'.htmlspecialcharsbx($data[
'PS_RESPONSE_DATE']).
'</td>
975 $result .=
'<div class="adm-bus-table-container caption border">
976 <div class="adm-bus-table-caption-title" style="background: #eef5f5;">'.Loc::getMessage(
'SALE_ORDER_PAYMENT_BLOCK_COMPANY').
'</div>
977 <table border="0" cellspacing="0" cellpadding="0" width="100%" class="adm-detail-content-table edit-table ">
980 <td class="adm-detail-content-cell-l" width="40%">'.
Loc::getMessage(
'SALE_ORDER_PAYMENT_COMPANY_BY').
':</td>
981 <td class="adm-detail-content-cell-r">'.
982 ($isAllowCompany ===
false && $isUserResponsible ===
false ?
Loc::getMessage(
'SALE_ORDER_PAYMENT_HIDDEN') :
983 (isset($company[
'NAME']) && !empty($company[
'NAME']) ? htmlspecialcharsbx($company[
'NAME']).
' ['.$data[
'COMPANY_ID'].
']' : Loc::getMessage(
'SALE_ORDER_PAYMENT_NO_COMPANY')))
991 <div class="clb"></div>
993 '.self::getShortViewTemplate($data, $index, $form).
'
999 $innerService = PaySystem\Manager::getObjectById(PaySystem\Manager::getInnerPaySystemId());
1004 if ($data[
'PAY_SYSTEM_ID'] != $innerService->getField(
'ID'))
1006 $service = PaySystem\Manager::getObjectById($data[
'PAY_SYSTEM_ID']);
1007 if ($service && $service->isRefundable())
1013 $refundablePs = array();
1018 'functionOnSave' =>
'sendAjax',
1020 'isPaid' => ($data[
'PAID'] ==
'Y'),
1021 'isAvailableChangeStatus' => $isActive,
1022 'psToReturn' => $refundablePs
1024 $result .= self::initJsPayment($params);
1028 private static function getShortViewTemplate($data, $index, $form)
1031 $lang = Main\Application::getInstance()->getContext()->getLanguage();
1032 $paidString = ($data[
'PAID'] ==
'Y') ?
'YES' :
'NO';
1036 $isUserResponsible =
null;
1037 $isAllowCompany =
null;
1039 if (array_key_exists(
'IS_USER_RESPONSIBLE', $data))
1041 $isUserResponsible = $data[
'IS_USER_RESPONSIBLE'];
1044 if (array_key_exists(
'IS_ALLOW_COMPANY', $data))
1046 $isAllowCompany = $data[
'IS_ALLOW_COMPANY'];
1050 $orderStatusClass = $registry->getOrderStatusClassName();
1052 $allowedOrderStatusesPayment = $orderStatusClass::getStatusesUserCanDoOperations($USER->GetID(), array(
'payment'));
1053 $isAllowPayment = in_array($data[
"STATUS_ID"], $allowedOrderStatusesPayment);
1055 $isActive = ($form !=
'edit' && $form !=
'archive') && !$data[
'ORDER_LOCKED'] && $isAllowPayment;
1056 $triangle = ($isActive) ?
'<span class="triangle"> ▾</span>' :
'';
1058 if ($data[
'PAID'] ==
'Y')
1059 $class = (!$isActive) ?
'class="not_active"' :
'';
1061 $class = (!$isActive) ?
'class="notpay not_active"' :
'class="notpay"';
1062 $paymentStatus =
'<span><span id="BUTTON_PAID_'.$index.
'_SHORT" '.$class.
'>'.
Loc::getMessage(
'SALE_ORDER_PAYMENT_STATUS_'.$paidString).
'</span>'.$triangle.
'</span>';
1065 if (($data[
'CAN_PRINT_CHECK'] ==
'Y' && $form !=
'archive' && $data[
'HAS_ENABLED_CASHBOX'] ===
'Y') || !empty($data[
'CHECK']))
1067 $checkLink =
'<td width="80px">'.Loc::getMessage(
'SALE_ORDER_PAYMENT_CHECK_LINK_TITLE').
':</td><td>';
1068 $checkLink .=
'<div id="PAYMENT_CHECK_LIST_ID_SHORT_VIEW'.$data[
'ID'].
'">';
1069 if (!empty($data[
'CHECK']))
1071 $checkLink .= static::buildCheckHtml($data[
'CHECK']);
1073 $checkLink .=
"</div>";
1074 if ($form !=
'archive' && $data[
'CAN_PRINT_CHECK'] ==
'Y' && $data[
'HAS_ENABLED_CASHBOX'] ===
'Y')
1076 $checkLink .=
'<div><a href="javascript:void(0);" onclick="BX.Sale.Admin.OrderPayment.prototype.showCreateCheckWindow('.$data[
'ID'].
');">'.
Loc::getMessage(
'SALE_ORDER_PAYMENT_CHECK_ADD').
'</a></div>';
1078 $checkLink .=
'</td>';
1081 if ($isAllowCompany ===
false && $isUserResponsible ===
false)
1087 $psName = htmlspecialcharsbx($data[
'PAY_SYSTEM_NAME']);
1089 if ($data[
'HAS_PREVIEW'])
1091 $psName .=
" (<a target='_blank' href='/bitrix/admin/sale_payment_doc_preview.php?PAYMENT_ID={$data['ID']}&ORDER_ID={$data['ORDER_ID']}'>".Loc::getMessage(
'SALE_ORDER_PAYMENT_DOC_PREVIEW').
"</a>)";
1096 <div class="adm-bus-section-container-section-content" style="padding: 10px;" id="SECTION_SHORT_'.$index.
'">
1097 <table class="adm-bus-section-container-section-status" id="PAYMENT_BLOCK_STATUS_'.$index.
'">
1100 <div style="background: url(\''.$data[
'PAY_SYSTEM_LOGOTIP_SHORT'].
'\');
" class="adm-shipment-block-
short-logo
" id="LOGOTIP_SHORT_
'.$index.'"></div>
1102 <td class="adm-bus-section-container-section-status-service
">'.Loc::getMessage('SALE_ORDER_PAYMENT_PAY_SYSTEM').': '.$psName.'</td>
1103 <td class="adm-bus-section-container-section-status-summ
">'.Loc::getMessage('SALE_ORDER_PAYMENT_PAYABLE_SUM').': '.SaleFormatCurrency($data['SUM'], $data['CURRENCY']).'</td>
1104 <td class="adm-bus-section-container-section-status-status payment-status
">'.Loc::getMessage('SALE_ORDER_PAYMENT_STATUS').': '.$paymentStatus.'</td>
1106 <td class="adm-bus-section-container-section-status-others
" id="PAYMENT_CHANGE_USER_INFO_
'.$index.'">'.$data['DATE_PAID'].'
1107 <a href="/
bitrix/admin/user_edit.php?lang=
'.$lang.'&ID=
'.$data['EMP_PAID_ID
'].'">'.htmlspecialcharsbx($data['EMP_PAID_ID_NAME']).' '.htmlspecialcharsbx($data['EMP_PAID_ID_LAST_NAME']).'</a>
1116 private static function initJsPayment($params)
1119 BX.ready(
function(){
1120 var obPayment_
".$params['index']." =
new BX.Sale.Admin.OrderPayment(
".\CUtil::PhpToJSObject($params).");
1130 public static function buildCheckHtml($checkList)
1133 foreach ($checkList as $check)
1137 if ($check['LINK'] <> '')
1139 $result .= '<a href="
'.$check['LINK
'].'" target="_blank
">'.Loc::getMessage('SALE_ORDER_PAYMENT_CHECK_LINK', array('#CHECK_ID#' => $check['ID'])).'</a>';
1143 $result .='<tspan>'.Loc::getMessage('SALE_ORDER_PAYMENT_CHECK_LINK', array('#CHECK_ID#' => $check['ID']));
1144 if ($check['STATUS'] === 'P')
1146 $result .= ' (<a href="javascript:void(0);
" onclick="BX.Sale.Admin.OrderPayment.prototype.sendQueryCheckStatus(
'.$check['ID
'].');
">'.Loc::getMessage('SALE_ORDER_PAYMENT_CHECK_CHECK_STATUS').'</a>)';
1148 $result .= '</tspan>';
1151 $result .= '</div>';
1161 public static function getPaySystemList(Payment $payment)
1167 'NAME' => Loc::getMessage('SALE_ORDER_PAYMENT_NO_PAYSYSTEM')
1170 if (self::$order === null)
1173 $collection = $payment->getCollection();
1176 self::$order = $collection->getOrder();
1179 $paySystems = PaySystem\Manager::getListWithRestrictions($payment, Restrictions\Manager::MODE_MANAGER);
1181 foreach ($paySystems as $paySystem)
1184 'ID' => $paySystem['ID'],
1185 'NAME' => "[
".$paySystem["ID
"]."]
".$paySystem["NAME
"],
1186 'CAN_PRINT_CHECK' => $paySystem['CAN_PRINT_CHECK']
1189 if (isset($paySystem['RESTRICTED']))
1190 $params['RESTRICTED'] = $paySystem['RESTRICTED'];
1192 $result[$paySystem['ID']] = $params;
1198 private static function getImgPathList()
1200 $dbRes = PaySystem\Manager::getList(
1202 'select' => array('ID', 'LOGOTIP')
1205 $paySystems = $dbRes->fetchAll();
1207 $logotypes = array('/bitrix/images/sale/nopaysystem.gif');
1208 foreach ($paySystems as $paySystem)
1210 if (empty($paySystem['LOGOTIP']))
1212 $logotypes[$paySystem['ID']] = $logotypes[0];
1216 $image = \CFile::ResizeImageGet($paySystem["LOGOTIP
"], array('width' => 100, 'height' => 60));
1217 $logotypes[$paySystem['ID']] = $image['src'];
1228 public static function createButtonAddPayment($params=[])
1230 return '<input type="button
" class="adm-order-block-add-button
" value="'.Loc::getMessage('SALE_ORDER_PAYMENT_BUTTON_ADD
').'" onclick="BX.Sale.Admin.GeneralPayment.addNewPayment(
this,
'.\CUtil::PhpToJSObject($params).')
">';
1242 public static function updateData(Sale\Order &$order, $payments, $canSetPaid = false)
1244 global $USER, $APPLICATION;
1246 $saleModulePermissions = $APPLICATION->GetGroupRight("sale
");
1248 $result = new Result();
1249 $data['PAYMENT'] = array();
1252 throw new UserMessageException('Order does not exist');
1254 foreach ($payments as $payment)
1256 $paymentId = intval($payment['PAYMENT_ID']);
1257 $isNew = ($paymentId <= 0);
1258 $paymentCollection = $order->getPaymentCollection();
1263 $paymentItem = $paymentCollection->createItem();
1267 $paymentItem = $paymentCollection->getItemById($paymentId);
1270 throw new UserMessageException('Payment does not exist');
1273 self::$defaultFields = $paymentItem->getFieldValues();
1275 $isReturn = (isset($payment['IS_RETURN']) && ($payment['IS_RETURN'] == 'Y' || $payment['IS_RETURN'] == 'P'));
1278 if ($payment['PAY_SYSTEM_ID'] > 0)
1279 $psService = PaySystem\Manager::getObjectById($payment['PAY_SYSTEM_ID']);
1281 $paymentFields = array(
1282 'PAY_SYSTEM_ID' => $payment['PAY_SYSTEM_ID'],
1283 'COMPANY_ID' => (isset($payment['COMPANY_ID']) && intval($payment['COMPANY_ID']) > 0) ? intval($payment['COMPANY_ID']) : 0,
1284 'PAY_VOUCHER_NUM' => $payment['PAY_VOUCHER_NUM'],
1285 'PAY_RETURN_NUM' => $payment['PAY_RETURN_NUM'],
1286 'PAY_RETURN_COMMENT' => $payment['PAY_RETURN_COMMENT'],
1287 'COMMENTS' => $payment['COMMENTS'] ?? null,
1288 'PAY_SYSTEM_NAME' => ($psService) ? $psService->getField('NAME') : ''
1291 if ($isNew && $saleModulePermissions == "P
")
1293 if (empty($payment['COMPANY_ID']))
1295 $paymentFields['COMPANY_ID'] = $order->getField('COMPANY_ID');
1297 if (empty($payment['RESPONSIBLE_ID']))
1299 $paymentFields['RESPONSIBLE_ID'] = $order->getField('RESPONSIBLE_ID');
1300 $paymentFields['EMP_RESPONSIBLE_ID'] = $USER->GetID();
1301 $paymentFields['DATE_RESPONSIBLE_ID'] = new DateTime();
1306 if (!$paymentItem->isPaid())
1307 $paymentFields['SUM'] = (float)str_replace(',', '.', $payment['SUM']);
1309 if ($payment['PRICE_COD'])
1310 $paymentFields['PRICE_COD'] = $payment['PRICE_COD'];
1313 $paymentFields['DATE_BILL'] = new DateTime();
1315 if (!empty($payment['PAY_RETURN_DATE']))
1319 $paymentFields['PAY_RETURN_DATE'] = new Date($payment['PAY_RETURN_DATE']);
1321 catch (Main\ObjectException $exception)
1324 new EntityError(Loc::getMessage('SALE_ORDER_PAYMENT_ERROR_RETURN_DATE_FORMAT'))
1329 if (!empty($payment['PAY_VOUCHER_DATE']))
1333 $paymentFields['PAY_VOUCHER_DATE'] = new Date($payment['PAY_VOUCHER_DATE']);
1335 catch (Main\ObjectException $exception)
1338 new EntityError(Loc::getMessage('SALE_ORDER_PAYMENT_ERROR_VOUCHER_DATE_FORMAT'))
1343 if (isset($payment['RESPONSIBLE_ID']))
1345 $paymentFields['RESPONSIBLE_ID'] = !empty($payment['RESPONSIBLE_ID']) ? $payment['RESPONSIBLE_ID'] : $USER->GetID();
1346 if ($payment['RESPONSIBLE_ID'] != $paymentItem->getField('RESPONSIBLE_ID'))
1348 $paymentFields['DATE_RESPONSIBLE_ID'] = new DateTime();
1350 $paymentFields['EMP_RESPONSIBLE_ID'] = $USER->GetID();
1354 if ($result->isSuccess())
1356 $setResult = $paymentItem->setFields($paymentFields);
1357 if (!$setResult->isSuccess())
1358 $result->addErrors($setResult->getErrors());
1360 if ($isReturn && $payment['OPERATION_ID'])
1362 $setResult = $paymentItem->setReturn($payment['OPERATION_ID']);
1363 if (!$setResult->isSuccess())
1364 $result->addErrors($setResult->getErrors());
1367 $isReturnChanged = $payment['IS_RETURN_CHANGED'] === 'Y';
1369 if (!$canSetPaid && !$isReturnChanged)
1371 $setResult = $paymentItem->setPaid($payment['PAID']);
1372 if (!$setResult->isSuccess())
1373 $result->addErrors($setResult->getErrors());
1376 if (isset($payment['ORDER_STATUS_ID']) && $payment['ORDER_STATUS_ID'])
1378 $order->setField('STATUS_ID', $payment['ORDER_STATUS_ID']);
1382 $verify = $paymentItem->verify();
1383 if (!$verify->isSuccess())
1385 $result->addErrors($verify->getErrors());
1388 $data['PAYMENT'][] = $paymentItem;
1391 $result->setData($data);