1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
einvoice.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Rest\Controller;
4
5
use Bitrix\Main\ArgumentException;
6
use Bitrix\Main\Engine\Controller;
7
use Bitrix\Main\Engine\Response\AjaxJson;
8
use Bitrix\Main\Error;
9
use Bitrix\Main\Web\HttpClient;
10
use Bitrix\Main\Web\Json;
11
use Bitrix\Main\Web\Uri;
12
use Bitrix\Main\Engine\ActionFilter;
13
use Bitrix\Rest\AppTable;
14
use Bitrix\Rest\Event\Sender;
15
use Bitrix\Main\Engine\CurrentUser;
16
17
class
EInvoice
extends
Controller
18
{
19
public
function
saveAction
(
string
$clientId
,
array
$settings
,
string
$handler):
AjaxJson
20
{
21
$formData =
$settings
;
22
23
$uri
=
new
Uri
($handler);
24
$httpClient =
new
HttpClient
();
25
$params
= Sender::getDefaultEventParams();
26
$params
[
'sendRefreshToken'
] =
true
;
27
$event
= [
28
'data'
=> $formData,
29
'auth'
=> Sender::getAuth(
30
$clientId
,
31
CurrentUser::get()->getId() ?? 0,
32
[],
33
$params
34
)
35
];
36
$result
= $httpClient->post(
$uri
,
$event
);
37
try
38
{
39
$responseData = Json::decode(
$result
);
40
if
($httpClient->getStatus() !== 200)
41
{
42
$errors
= $responseData[
'errors'
] ?? [];
43
foreach
(
$errors
as
$error
)
44
{
45
$this->errorCollection->setError(
46
new
Error
(
$error
[
'message'
] ??
''
, customData: [
'fieldName'
=>
$error
[
'field'
] ??
'unknown'
])
47
);
48
}
49
}
50
}
51
catch
(
ArgumentException
$e)
52
{
53
$this->errorCollection->setError(
new
Error
($e->getMessage()));
54
}
55
56
if
($this->errorCollection->count() > 0)
57
{
58
return
AjaxJson::createError($this->errorCollection);
59
}
60
61
return
AjaxJson::createSuccess();
62
}
63
64
public
function
configureActions
():
array
65
{
66
$configureActions = [];
67
$configureActions[
'save'
] = [
68
'+prefilters'
=> [
69
new
ActionFilter\Authentication
(),
70
new
ActionFilter\Scope
(
ActionFilter
\
Scope::NOT_REST
),
71
],
72
];
73
74
return
$configureActions;
75
}
76
}
Bitrix\Main\ArgumentException
Определения
ArgumentException.php:9
Bitrix\Main\Engine\ActionFilter\Scope
Определения
scope.php:12
Bitrix\Main\Engine\ActionFilter\Scope\NOT_REST
const NOT_REST
Определения
scope.php:19
Bitrix\Main\Engine\Response\AjaxJson
Определения
ajaxjson.php:11
Bitrix\Main\Error
Определения
error.php:15
Bitrix\Main\Web\HttpClient
Определения
httpclient.php:24
Bitrix\Main\Web\Uri
Определения
uri.php:17
Bitrix\Rest\Controller\EInvoice
Определения
einvoice.php:18
Bitrix\Rest\Controller\EInvoice\saveAction
saveAction(string $clientId, array $settings, string $handler)
Определения
einvoice.php:19
Bitrix\Rest\Controller\EInvoice\configureActions
configureActions()
Определения
einvoice.php:64
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
$errors
$errors
Определения
iblock_catalog_edit.php:74
$uri
if(file_exists($_SERVER['DOCUMENT_ROOT'] . "/urlrewrite.php")) $uri
Определения
urlrewrite.php:61
Bitrix\Main\Authentication
Определения
application.php:9
Bitrix\Main\Controller
Определения
agreement.php:2
Bitrix\Main\Engine\ActionFilter
$settings
$settings
Определения
product_settings.php:43
$event
$event
Определения
prolog_after.php:141
$params
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения
template.php:799
$clientId
$clientId
Определения
seo_client.php:18
$error
$error
Определения
subscription_card_product.php:20
bitrix
modules
rest
lib
controller
einvoice.php
Создано системой
1.14.0