Corporate client support
This commit is contained in:
parent
bbfb2f600a
commit
acaaf98c56
2
.gitignore
vendored
2
.gitignore
vendored
@ -8,7 +8,7 @@
|
||||
/.idea
|
||||
/.idea/*
|
||||
|
||||
|
||||
/intaro.retailcrm/log/*
|
||||
/vendor/
|
||||
.env
|
||||
.phpunit.result.cache
|
||||
|
@ -1,3 +1,6 @@
|
||||
## 2020-04-23 v.5.3.0
|
||||
* Добавлена поддержка корпоративных клиентов
|
||||
|
||||
## 2020-01-09 v.5.2.5
|
||||
* Добавлена передача "externalIds" у позиций товаров в заказе
|
||||
* Добавлено разделение поля строение/корпус на два отдельных
|
||||
|
@ -200,6 +200,662 @@ class ApiClient
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Create customers corporate
|
||||
*
|
||||
* @param array $customer customer corporate data
|
||||
* @param string $site (default: null)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public function customersCorporateCreate(array $customer, $site = null)
|
||||
{
|
||||
if (! count($customer)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Parameter `customer` must contains a data'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
'/customers-corporate/create',
|
||||
Client::METHOD_POST,
|
||||
$this->fillSite($site, array('customerCorporate' => json_encode($customer)))
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Save customer corporate IDs' (id and externalId) association in the CRM
|
||||
*
|
||||
* @param array $ids ids mapping
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public function customersСorporateFixExternalIds(array $ids)
|
||||
{
|
||||
if (! count($ids)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Method parameter must contains at least one IDs pair'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
'/customers-corporate/fix-external-ids',
|
||||
Client::METHOD_POST,
|
||||
array('customerCorporate' => json_encode($ids))
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Upload array of the customers corporate
|
||||
*
|
||||
* @param array $customers array of customers
|
||||
* @param string $site (default: null)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public function customersCorporateUpload(array $customers, $site = null)
|
||||
{
|
||||
if (! count($customers)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Parameter `customers` must contains array of the customers'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
'/customers-corporate/upload',
|
||||
Client::METHOD_POST,
|
||||
$this->fillSite($site, array('customersCorporate' => json_encode($customers)))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get customer corporate by id or externalId
|
||||
*
|
||||
* @param string $id customers-corporate identificator
|
||||
* @param string $by (default: 'externalId')
|
||||
* @param string $site (default: null)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public function customersСorporateGet($id, $by = 'externalId', $site = null)
|
||||
{
|
||||
$this->checkIdParameter($by);
|
||||
|
||||
return $this->client->makeRequest(
|
||||
"/customers-corporate/$id",
|
||||
Client::METHOD_GET,
|
||||
$this->fillSite($site, array('by' => $by))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get corporate customer companies by id or externalId
|
||||
*
|
||||
* @param string $id corporate customer identifier
|
||||
* @param array $filter (default: array())
|
||||
* @param int $page (default: null)
|
||||
* @param int $limit (default: null)
|
||||
* @param string $by (default: 'externalId')
|
||||
* @param string $site (default: null)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return \RetailCrm\Response\ApiResponse
|
||||
*/
|
||||
public function customersCorporateCompanies(
|
||||
$id,
|
||||
array $filter = [],
|
||||
$page = null,
|
||||
$limit = null,
|
||||
$by = 'externalId',
|
||||
$site = null
|
||||
) {
|
||||
|
||||
$this->checkIdParameter($by);
|
||||
|
||||
$parameters = ['by' => $by];
|
||||
if (count($filter)) {
|
||||
$parameters['filter'] = $filter;
|
||||
}
|
||||
if (null !== $page) {
|
||||
$parameters['page'] = (int) $page;
|
||||
}
|
||||
if (null !== $limit) {
|
||||
$parameters['limit'] = (int) $limit;
|
||||
}
|
||||
/* @noinspection PhpUndefinedMethodInspection */
|
||||
return $this->client->makeRequest(
|
||||
"/customers-corporate/$id/companies",
|
||||
Client::METHOD_GET,
|
||||
$this->fillSite($site, $parameters)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a customer corporate
|
||||
*
|
||||
* @param array $customer customer data
|
||||
* @param string $by (default: 'externalId')
|
||||
* @param string $site (default: null)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public function customersСorporateEdit(array $customer, $by = 'externalId', $site = null)
|
||||
{
|
||||
if (!count($customer)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Parameter `customer` must contains a data'
|
||||
);
|
||||
}
|
||||
|
||||
$this->checkIdParameter($by);
|
||||
|
||||
if (!array_key_exists($by, $customer)) {
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf('Customer array must contain the "%s" parameter.', $by)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
sprintf('/customers-corporate/%s/edit', $customer[$by]),
|
||||
Client::METHOD_POST,
|
||||
$this->fillSite(
|
||||
$site,
|
||||
array('customerCorporate' => json_encode($customer), 'by' => $by)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get customers corporate history
|
||||
*
|
||||
* @param array $filter
|
||||
* @param null $page
|
||||
* @param null $limit
|
||||
*
|
||||
* @return ApiResponse
|
||||
*
|
||||
*/
|
||||
public function customersСorporateHistory(array $filter = array(), $page = null, $limit = null)
|
||||
{
|
||||
$parameters = array();
|
||||
|
||||
if (count($filter)) {
|
||||
$parameters['filter'] = $filter;
|
||||
}
|
||||
if (null !== $page) {
|
||||
$parameters['page'] = (int) $page;
|
||||
}
|
||||
if (null !== $limit) {
|
||||
$parameters['limit'] = (int) $limit;
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
'/customers-corporate/history',
|
||||
Client::METHOD_GET,
|
||||
$parameters
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create corporate customer contact
|
||||
*
|
||||
* @param string $id corporate customer identifier
|
||||
* @param array $contact (default: array())
|
||||
* @param string $by (default: 'externalId')
|
||||
* @param string $site (default: null)
|
||||
*
|
||||
* @return \RetailCrm\Response\ApiResponse
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function customersCorporateContactsCreate($id, array $contact = [], $by = 'externalId', $site = null)
|
||||
{
|
||||
if (! count($contact)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Parameter `contact` must contains a data'
|
||||
);
|
||||
}
|
||||
|
||||
/* @noinspection PhpUndefinedMethodInspection */
|
||||
return $this->client->makeRequest(
|
||||
"/customers-corporate/$id/contacts/create",
|
||||
Client::METHOD_POST,
|
||||
$this->fillSite($site, ['contact' => json_encode($contact), 'by' => $by])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get corporate customer contacts by id or externalId
|
||||
*
|
||||
* @param string $id corporate customer identifier
|
||||
* @param array $filter (default: array())
|
||||
* @param int $page (default: null)
|
||||
* @param int $limit (default: null)
|
||||
* @param string $by (default: 'externalId')
|
||||
* @param string $site (default: null)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return \RetailCrm\Response\ApiResponse
|
||||
*/
|
||||
public function customersCorporateContacts(
|
||||
$id,
|
||||
array $filter = [],
|
||||
$page = null,
|
||||
$limit = null,
|
||||
$by = 'externalId',
|
||||
$site = null
|
||||
) {
|
||||
$this->checkIdParameter($by);
|
||||
$parameters = ['by' => $by];
|
||||
if (count($filter)) {
|
||||
$parameters['filter'] = $filter;
|
||||
}
|
||||
if (null !== $page) {
|
||||
$parameters['page'] = (int) $page;
|
||||
}
|
||||
if (null !== $limit) {
|
||||
$parameters['limit'] = (int) $limit;
|
||||
}
|
||||
/* @noinspection PhpUndefinedMethodInspection */
|
||||
return $this->client->makeRequest(
|
||||
"/customers-corporate/$id/contacts",
|
||||
Client::METHOD_GET,
|
||||
$this->fillSite($site, $parameters)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns filtered corporate customers list
|
||||
*
|
||||
* @param array $filter (default: array())
|
||||
* @param int $page (default: null)
|
||||
* @param int $limit (default: null)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return \RetailCrm\Response\ApiResponse
|
||||
*/
|
||||
public function customersCorporateList(array $filter = [], $page = null, $limit = null)
|
||||
{
|
||||
$parameters = [];
|
||||
if (count($filter)) {
|
||||
$parameters['filter'] = $filter;
|
||||
}
|
||||
if (null !== $page) {
|
||||
$parameters['page'] = (int) $page;
|
||||
}
|
||||
if (null !== $limit) {
|
||||
$parameters['limit'] = (int) $limit;
|
||||
}
|
||||
/* @noinspection PhpUndefinedMethodInspection */
|
||||
return $this->client->makeRequest(
|
||||
'/customers-corporate',
|
||||
Client::METHOD_GET,
|
||||
$parameters
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns filtered corporate customers notes list
|
||||
*
|
||||
* @param array $filter (default: array())
|
||||
* @param int $page (default: null)
|
||||
* @param int $limit (default: null)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return \RetailCrm\Response\ApiResponse
|
||||
*/
|
||||
public function customersCorporateNotesList(array $filter = [], $page = null, $limit = null)
|
||||
{
|
||||
$parameters = [];
|
||||
if (count($filter)) {
|
||||
$parameters['filter'] = $filter;
|
||||
}
|
||||
if (null !== $page) {
|
||||
$parameters['page'] = (int) $page;
|
||||
}
|
||||
if (null !== $limit) {
|
||||
$parameters['limit'] = (int) $limit;
|
||||
}
|
||||
/* @noinspection PhpUndefinedMethodInspection */
|
||||
return $this->client->makeRequest(
|
||||
'/customers-corporate/notes',
|
||||
Client::METHOD_GET,
|
||||
$parameters
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create corporate customer note
|
||||
*
|
||||
* @param array $note (default: array())
|
||||
* @param string $site (default: null)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return \RetailCrm\Response\ApiResponse
|
||||
*/
|
||||
public function customersCorporateNotesCreate($note, $site = null)
|
||||
{
|
||||
if (empty($note['customer']['id']) && empty($note['customer']['externalId'])) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Customer identifier must be set'
|
||||
);
|
||||
}
|
||||
/* @noinspection PhpUndefinedMethodInspection */
|
||||
return $this->client->makeRequest(
|
||||
'/customers-corporate/notes/create',
|
||||
Client::METHOD_POST,
|
||||
$this->fillSite($site, ['note' => json_encode($note)])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete corporate customer note
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return \RetailCrm\Response\ApiResponse
|
||||
*/
|
||||
public function customersCorporateNotesDelete($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Note id must be set'
|
||||
);
|
||||
}
|
||||
/* @noinspection PhpUndefinedMethodInspection */
|
||||
return $this->client->makeRequest(
|
||||
"/customers-corporate/notes/$id/delete",
|
||||
Client::METHOD_POST
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get corporate customer addresses by id or externalId
|
||||
*
|
||||
* @param string $id corporate customer identifier
|
||||
* @param array $filter (default: array())
|
||||
* @param int $page (default: null)
|
||||
* @param int $limit (default: null)
|
||||
* @param string $by (default: 'externalId')
|
||||
* @param string $site (default: null)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return \RetailCrm\Response\ApiResponse
|
||||
*/
|
||||
public function customersCorporateAddresses(
|
||||
$id,
|
||||
array $filter = [],
|
||||
$page = null,
|
||||
$limit = null,
|
||||
$by = 'externalId',
|
||||
$site = null
|
||||
) {
|
||||
$this->checkIdParameter($by);
|
||||
$parameters = ['by' => $by];
|
||||
if (count($filter)) {
|
||||
$parameters['filter'] = $filter;
|
||||
}
|
||||
if (null !== $page) {
|
||||
$parameters['page'] = (int) $page;
|
||||
}
|
||||
if (null !== $limit) {
|
||||
$parameters['limit'] = (int) $limit;
|
||||
}
|
||||
/* @noinspection PhpUndefinedMethodInspection */
|
||||
return $this->client->makeRequest(
|
||||
"/customers-corporate/$id/addresses",
|
||||
Client::METHOD_GET,
|
||||
$this->fillSite($site, $parameters)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create corporate customer address
|
||||
*
|
||||
* @param string $id corporate customer identifier
|
||||
* @param array $address (default: array())
|
||||
* @param string $by (default: 'externalId')
|
||||
* @param string $site (default: null)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return \RetailCrm\Response\ApiResponse
|
||||
*/
|
||||
public function customersCorporateAddressesCreate($id, array $address = [], $by = 'externalId', $site = null)
|
||||
{
|
||||
/* @noinspection PhpUndefinedMethodInspection */
|
||||
return $this->client->makeRequest(
|
||||
"/customers-corporate/$id/addresses/create",
|
||||
Client::METHOD_POST,
|
||||
$this->fillSite($site, ['address' => json_encode($address), 'by' => $by])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit corporate customer address
|
||||
*
|
||||
* @param string $customerId corporate customer identifier
|
||||
* @param string $addressId corporate customer identifier
|
||||
* @param array $address (default: array())
|
||||
* @param string $customerBy (default: 'externalId')
|
||||
* @param string $addressBy (default: 'externalId')
|
||||
* @param string $site (default: null)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return \RetailCrm\Response\ApiResponse
|
||||
*/
|
||||
public function customersCorporateAddressesEdit(
|
||||
$customerId,
|
||||
$addressId,
|
||||
array $address = [],
|
||||
$customerBy = 'externalId',
|
||||
$addressBy = 'externalId',
|
||||
$site = null
|
||||
) {
|
||||
$addressFiltered = array_filter($address);
|
||||
if ((count(array_keys($addressFiltered)) <= 1)
|
||||
&& (!isset($addressFiltered['text'])
|
||||
|| (isset($addressFiltered['text']) && empty($addressFiltered['text']))
|
||||
)
|
||||
) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Parameter `address` must contain address text or all other address field'
|
||||
);
|
||||
}
|
||||
/* @noinspection PhpUndefinedMethodInspection */
|
||||
return $this->client->makeRequest(
|
||||
"/customers-corporate/$customerId/addresses/$addressId/edit",
|
||||
Client::METHOD_POST,
|
||||
$this->fillSite($site, [
|
||||
'address' => json_encode($address),
|
||||
'by' => $customerBy,
|
||||
'entityBy' => $addressBy
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create corporate customer company
|
||||
*
|
||||
* @param string $id corporate customer identifier
|
||||
* @param array $company (default: array())
|
||||
* @param string $by (default: 'externalId')
|
||||
* @param string $site (default: null)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return \RetailCrm\Response\ApiResponse
|
||||
*/
|
||||
public function customersCorporateCompaniesCreate($id, array $company = [], $by = 'externalId', $site = null)
|
||||
{
|
||||
/* @noinspection PhpUndefinedMethodInspection */
|
||||
return $this->client->makeRequest(
|
||||
"/customers-corporate/$id/companies/create",
|
||||
Client::METHOD_POST,
|
||||
$this->fillSite($site, ['company' => json_encode($company), 'by' => $by])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit corporate customer company
|
||||
*
|
||||
* @param string $customerId corporate customer identifier
|
||||
* @param string $companyId corporate customer identifier
|
||||
* @param array $company (default: array())
|
||||
* @param string $customerBy (default: 'externalId')
|
||||
* @param string $companyBy (default: 'externalId')
|
||||
* @param string $site (default: null)
|
||||
*
|
||||
* @return \RetailCrm\Response\ApiResponse
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
*/
|
||||
public function customersCorporateCompaniesEdit(
|
||||
$customerId,
|
||||
$companyId,
|
||||
array $company = [],
|
||||
$customerBy = 'externalId',
|
||||
$companyBy = 'externalId',
|
||||
$site = null
|
||||
) {
|
||||
/* @noinspection PhpUndefinedMethodInspection */
|
||||
return $this->client->makeRequest(
|
||||
"/customers-corporate/$customerId/companies/$companyId/edit",
|
||||
Client::METHOD_POST,
|
||||
$this->fillSite($site, [
|
||||
'company' => json_encode($company),
|
||||
'by' => $customerBy,
|
||||
'entityBy' => $companyBy
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit corporate customer contact
|
||||
*
|
||||
* @param string $customerId corporate customer identifier
|
||||
* @param string $contactId corporate customer identifier
|
||||
* @param array $contact (default: array())
|
||||
* @param string $customerBy (default: 'externalId')
|
||||
* @param string $contactBy (default: 'externalId')
|
||||
* @param string $site (default: null)
|
||||
*
|
||||
* @return \RetailCrm\Response\ApiResponse
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
*/
|
||||
public function customersCorporateContactsEdit(
|
||||
$customerId,
|
||||
$contactId,
|
||||
array $contact = [],
|
||||
$customerBy = 'externalId',
|
||||
$contactBy = 'externalId',
|
||||
$site = null
|
||||
) {
|
||||
/* @noinspection PhpUndefinedMethodInspection */
|
||||
return $this->client->makeRequest(
|
||||
"/customers-corporate/$customerId/contacts/$contactId/edit",
|
||||
Client::METHOD_POST,
|
||||
$this->fillSite($site, [
|
||||
'contact' => json_encode($contact),
|
||||
'by' => $customerBy,
|
||||
'entityBy' => $contactBy
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a corporate customer
|
||||
*
|
||||
* @param array $customerCorporate corporate customer data
|
||||
* @param string $by (default: 'externalId')
|
||||
* @param string $site (default: null)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return \RetailCrm\Response\ApiResponse
|
||||
*/
|
||||
public function customersCorporateEdit(array $customerCorporate, $by = 'externalId', $site = null)
|
||||
{
|
||||
if (!count($customerCorporate)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Parameter `customerCorporate` must contains a data'
|
||||
);
|
||||
}
|
||||
$this->checkIdParameter($by);
|
||||
if (!array_key_exists($by, $customerCorporate)) {
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf('Corporate customer array must contain the "%s" parameter.', $by)
|
||||
);
|
||||
}
|
||||
/* @noinspection PhpUndefinedMethodInspection */
|
||||
return $this->client->makeRequest(
|
||||
sprintf('/customers-corporate/%s/edit', $customerCorporate[$by]),
|
||||
Client::METHOD_POST,
|
||||
$this->fillSite(
|
||||
$site,
|
||||
['customerCorporate' => json_encode($customerCorporate), 'by' => $by]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a order
|
||||
*
|
||||
|
@ -1,10 +1,50 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class Logger
|
||||
*
|
||||
* @author pavel
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class Logger
|
||||
{
|
||||
/** @var self $instance */
|
||||
private static $instance;
|
||||
|
||||
/** @var string $logPath */
|
||||
private $logPath;
|
||||
|
||||
/** @var int $files */
|
||||
private $files;
|
||||
|
||||
public function __construct($logPath = '/bitrix/modules/intaro.retailcrm/log', $files = 3)
|
||||
/**
|
||||
* Get logger instance or re-initialize it with new parameters
|
||||
*
|
||||
* @param string $logPath
|
||||
* @param int $files
|
||||
*
|
||||
* @return \Logger
|
||||
*/
|
||||
public static function getInstance($logPath = '/bitrix/modules/intaro.retailcrm/log', $files = 3)
|
||||
{
|
||||
if (empty(self::$instance)
|
||||
|| self::$instance instanceof Logger
|
||||
&& (self::$instance->logPath != $logPath || self::$instance->files != $files)
|
||||
) {
|
||||
self::$instance = new Logger($logPath, $files);
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logger constructor.
|
||||
*
|
||||
* @param string $logPath
|
||||
* @param int $files
|
||||
*/
|
||||
private function __construct($logPath = '/bitrix/modules/intaro.retailcrm/log', $files = 3)
|
||||
{
|
||||
$this->logPath = $logPath;
|
||||
$this->files = $files;
|
||||
|
@ -50,9 +50,9 @@ class RCrmActions
|
||||
}
|
||||
foreach ($arDeliveryServiceAll as $arDeliveryService) {
|
||||
if ((($arDeliveryService['PARENT_ID'] == '0' || $arDeliveryService['PARENT_ID'] == null) ||
|
||||
in_array($arDeliveryService['PARENT_ID'], $groups)) &&
|
||||
$arDeliveryService['ID'] != $noOrderId &&
|
||||
$arDeliveryService['CLASS_NAME'] != '\Bitrix\Sale\Delivery\Services\Group') {
|
||||
in_array($arDeliveryService['PARENT_ID'], $groups)) &&
|
||||
$arDeliveryService['ID'] != $noOrderId &&
|
||||
$arDeliveryService['CLASS_NAME'] != '\Bitrix\Sale\Delivery\Services\Group') {
|
||||
if (in_array($arDeliveryService['PARENT_ID'], $groups)) {
|
||||
$arDeliveryService['PARENT_ID'] = 0;
|
||||
}
|
||||
@ -204,7 +204,6 @@ class RCrmActions
|
||||
*
|
||||
* @return self name
|
||||
*/
|
||||
|
||||
public static function orderAgent()
|
||||
{
|
||||
if (COption::GetOptionString('main', 'agents_use_crontab', 'N') != 'N') {
|
||||
@ -244,9 +243,10 @@ class RCrmActions
|
||||
|
||||
/**
|
||||
*
|
||||
* @global $APPLICATION
|
||||
* @param $str in SITE_CHARSET
|
||||
* @return $str in utf-8
|
||||
* @param array|bool|\SplFixedArray|string $str in SITE_CHARSET
|
||||
*
|
||||
* @return array|bool|\SplFixedArray|string $str in utf-8
|
||||
* @global $APPLICATION
|
||||
*/
|
||||
public static function toJSON($str)
|
||||
{
|
||||
@ -257,9 +257,10 @@ class RCrmActions
|
||||
|
||||
/**
|
||||
*
|
||||
* @global $APPLICATION
|
||||
* @param $str in utf-8
|
||||
* @return $str in SITE_CHARSET
|
||||
* @param string|array|\SplFixedArray $str in utf-8
|
||||
*
|
||||
* @return array|bool|\SplFixedArray|string $str in SITE_CHARSET
|
||||
* @global $APPLICATION
|
||||
*/
|
||||
public static function fromJSON($str)
|
||||
{
|
||||
@ -440,8 +441,10 @@ class RCrmActions
|
||||
case 'customerHistory':
|
||||
case 'ordersFixExternalIds':
|
||||
case 'customersFixExternalIds':
|
||||
case 'customersCorporateContacts':
|
||||
case 'customersList':
|
||||
case 'customersCorporateList':
|
||||
return self::proxy($api, $methodApi, $method, array($params));
|
||||
|
||||
case 'orderGet':
|
||||
return self::proxy($api, 'ordersGet', $method, array($params, 'id', $site));
|
||||
|
||||
@ -449,7 +452,10 @@ class RCrmActions
|
||||
case 'ordersEdit':
|
||||
case 'customersGet':
|
||||
case 'customersEdit':
|
||||
case 'customersСorporateGet':
|
||||
return self::proxy($api, $methodApi, $method, array($params, 'externalId', $site));
|
||||
case 'customersGetById':
|
||||
return self::proxy($api, 'customersGet', $method, array($params, 'id', $site));
|
||||
|
||||
case 'paymentEditById':
|
||||
return self::proxy($api, 'ordersPaymentEdit', $method, array($params, 'id', $site));
|
||||
@ -463,14 +469,30 @@ class RCrmActions
|
||||
}
|
||||
|
||||
private static function proxy($api, $methodApi, $method, $params) {
|
||||
$log = new Logger();
|
||||
$version = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_VERSION, 0);
|
||||
try {
|
||||
$result = call_user_func_array(array($api, $methodApi), $params);
|
||||
|
||||
if (!$result) {
|
||||
$err = new RuntimeException(
|
||||
$methodApi . ": Got null instead of valid result!"
|
||||
);
|
||||
Logger::getInstance()->write(sprintf(
|
||||
'%s%s%s',
|
||||
$err->getMessage(),
|
||||
PHP_EOL,
|
||||
$err->getTraceAsString()
|
||||
), 'apiErrors');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($result->getStatusCode() !== 200 && $result->getStatusCode() !== 201) {
|
||||
if ($methodApi == 'ordersGet' || $methodApi == 'customersGet') {
|
||||
$log->write(array(
|
||||
if ($methodApi == 'ordersGet'
|
||||
|| $methodApi == 'customersGet'
|
||||
|| $methodApi == 'customersСorporateGet'
|
||||
) {
|
||||
Logger::getInstance()->write(array(
|
||||
'api' => $version,
|
||||
'methodApi' => $methodApi,
|
||||
'errorMsg' => !empty($result['errorMsg']) ? $result['errorMsg'] : '',
|
||||
@ -478,7 +500,7 @@ class RCrmActions
|
||||
'params' => $params
|
||||
), 'apiErrors');
|
||||
} elseif ($methodApi == 'customersUpload' || $methodApi == 'ordersUpload') {
|
||||
$log->write(array(
|
||||
Logger::getInstance()->write(array(
|
||||
'api' => $version,
|
||||
'methodApi' => $methodApi,
|
||||
'errorMsg' => !empty($result['errorMsg']) ? $result['errorMsg'] : '',
|
||||
@ -486,8 +508,12 @@ class RCrmActions
|
||||
'params' => $params
|
||||
), 'uploadApiErrors');
|
||||
} else {
|
||||
self::eventLog(__CLASS__ . '::' . $method, 'RetailCrm\ApiClient::' . $methodApi, !empty($result['errorMsg']) ? $result['errorMsg'] : '');
|
||||
$log->write(array(
|
||||
self::eventLog(
|
||||
__CLASS__ . '::' . $method,
|
||||
'RetailCrm\ApiClient::' . $methodApi,
|
||||
!empty($result['errorMsg']) ? $result['errorMsg'] : ''
|
||||
);
|
||||
Logger::getInstance()->write(array(
|
||||
'api' => $version,
|
||||
'methodApi' => $methodApi,
|
||||
'errorMsg' => !empty($result['errorMsg']) ? $result['errorMsg'] : '',
|
||||
@ -507,63 +533,83 @@ class RCrmActions
|
||||
return false;
|
||||
}
|
||||
} catch (\RetailCrm\Exception\CurlException $e) {
|
||||
self::eventLog(
|
||||
__CLASS__ . '::' . $method, 'RetailCrm\ApiClient::' . $methodApi . '::CurlException',
|
||||
$e->getCode() . ': ' . $e->getMessage()
|
||||
static::logException(
|
||||
$method,
|
||||
$methodApi,
|
||||
'CurlException',
|
||||
'CurlException',
|
||||
$e,
|
||||
$version,
|
||||
$params
|
||||
);
|
||||
$log->write(array(
|
||||
'api' => $version,
|
||||
'methodApi' => $methodApi,
|
||||
'errorMsg' => $e->getMessage(),
|
||||
'errors' => $e->getCode(),
|
||||
'params' => $params
|
||||
), 'apiErrors');
|
||||
|
||||
if (function_exists('retailCrmApiResult')) {
|
||||
retailCrmApiResult($methodApi, false, 'CurlException');
|
||||
}
|
||||
|
||||
return false;
|
||||
} catch (InvalidArgumentException $e) {
|
||||
self::eventLog(
|
||||
__CLASS__ . '::' . $method, 'RetailCrm\ApiClient::' . $methodApi . '::InvalidArgumentException',
|
||||
$e->getCode() . ': ' . $e->getMessage()
|
||||
static::logException(
|
||||
$method,
|
||||
$methodApi,
|
||||
'InvalidArgumentException',
|
||||
'ArgumentException',
|
||||
$e,
|
||||
$version,
|
||||
$params
|
||||
);
|
||||
$log->write(array(
|
||||
'api' => $version,
|
||||
'methodApi' => $methodApi,
|
||||
'errorMsg' => $e->getMessage(),
|
||||
'errors' => $e->getCode(),
|
||||
'params' => $params
|
||||
), 'apiErrors');
|
||||
|
||||
if (function_exists('retailCrmApiResult')) {
|
||||
retailCrmApiResult($methodApi, false, 'ArgumentException');
|
||||
}
|
||||
|
||||
return false;
|
||||
} catch (\RetailCrm\Exception\InvalidJsonException $e) {
|
||||
self::eventLog(
|
||||
__CLASS__ . '::' . $method, 'RetailCrm\ApiClient::' . $methodApi . '::InvalidJsonException',
|
||||
$e->getCode() . ': ' . $e->getMessage()
|
||||
static::logException(
|
||||
$method,
|
||||
$methodApi,
|
||||
'InvalidJsonException',
|
||||
'ArgumentException',
|
||||
$e,
|
||||
$version,
|
||||
$params
|
||||
);
|
||||
$log->write(array(
|
||||
'api' => $version,
|
||||
'methodApi' => $methodApi,
|
||||
'errorMsg' => $e->getMessage(),
|
||||
'errors' => $e->getCode(),
|
||||
'params' => $params
|
||||
), 'apiErrors');
|
||||
|
||||
if (function_exists('retailCrmApiResult')) {
|
||||
retailCrmApiResult($methodApi, false, 'ArgumentException');
|
||||
}
|
||||
}
|
||||
|
||||
if (function_exists('retailCrmApiResult')) {
|
||||
retailCrmApiResult($methodApi, true, $result->getStatusCode());
|
||||
retailCrmApiResult($methodApi, true, isset($result) ? $result->getStatusCode() : 0);
|
||||
}
|
||||
|
||||
return isset($result) ? $result : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log exception into log file and event log
|
||||
*
|
||||
* @param string $method
|
||||
* @param string $methodApi
|
||||
* @param string $exceptionName
|
||||
* @param string $apiResultExceptionName
|
||||
* @param \Exception|\Error|\Throwable $exception
|
||||
* @param string $version
|
||||
* @param array $params
|
||||
*/
|
||||
protected static function logException(
|
||||
$method,
|
||||
$methodApi,
|
||||
$exceptionName,
|
||||
$apiResultExceptionName,
|
||||
$exception,
|
||||
$version,
|
||||
$params
|
||||
) {
|
||||
self::eventLog(
|
||||
__CLASS__ . '::' . $method, 'RetailCrm\ApiClient::' . $methodApi . '::' . $exceptionName,
|
||||
$exception->getCode() . ': ' . $exception->getMessage()
|
||||
);
|
||||
|
||||
Logger::getInstance()->write(array(
|
||||
'api' => $version,
|
||||
'methodApi' => $methodApi,
|
||||
'errorMsg' => $exception->getMessage(),
|
||||
'errors' => $exception->getCode(),
|
||||
'params' => $params
|
||||
), 'apiErrors');
|
||||
|
||||
if (function_exists('retailCrmApiResult')) {
|
||||
retailCrmApiResult($methodApi, false, $apiResultExceptionName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
560
intaro.retailcrm/classes/general/RetailcrmConfigProvider.php
Normal file
560
intaro.retailcrm/classes/general/RetailcrmConfigProvider.php
Normal file
@ -0,0 +1,560 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.3
|
||||
*
|
||||
* RetailcrmConfigProvider class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||
*/
|
||||
|
||||
IncludeModuleLangFile(__FILE__);
|
||||
|
||||
/**
|
||||
* PHP version 5.3
|
||||
*
|
||||
* RetailcrmConfigProvider class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||
*/
|
||||
class RetailcrmConfigProvider
|
||||
{
|
||||
/** @var bool|null|string */
|
||||
private static $apiUrl;
|
||||
|
||||
/** @var bool|null|string */
|
||||
private static $apiKey;
|
||||
|
||||
/** @var bool|null|string */
|
||||
private static $catalogBasePrice;
|
||||
|
||||
/** @var bool|null|string */
|
||||
private static $currency;
|
||||
|
||||
/** @var bool|null|string */
|
||||
private static $orderDimensions;
|
||||
|
||||
/** @var bool|null|string */
|
||||
private static $corporateClientName;
|
||||
|
||||
/** @var bool|null|string */
|
||||
private static $corporateClientAddress;
|
||||
|
||||
/** @var bool|null|string */
|
||||
private static $corporateClient;
|
||||
|
||||
/** @var array $sitesList */
|
||||
private static $sitesList;
|
||||
|
||||
/** @var array $sitesListCorporate */
|
||||
private static $sitesListCorporate;
|
||||
|
||||
/** @var bool|null|string $orderNumbers */
|
||||
private static $orderNumbers;
|
||||
|
||||
/** @var array $orderTypes */
|
||||
private static $orderTypes;
|
||||
|
||||
/** @var array $deliveryTypes */
|
||||
private static $deliveryTypes;
|
||||
|
||||
/** @var array $paymentTypes */
|
||||
private static $paymentTypes;
|
||||
|
||||
/** @var array $paymentStatuses */
|
||||
private static $paymentStatuses;
|
||||
|
||||
/** @var array $payment */
|
||||
private static $payment;
|
||||
|
||||
/** @var array $orderProps */
|
||||
private static $orderProps;
|
||||
|
||||
/** @var array $legalDetails */
|
||||
private static $legalDetails;
|
||||
|
||||
/** @var array $contragentTypes */
|
||||
private static $contragentTypes;
|
||||
|
||||
/** @var array $cancellableOrderPaymentStatuses */
|
||||
private static $cancellableOrderPaymentStatuses;
|
||||
|
||||
/** @var array $customFields */
|
||||
private static $customFields;
|
||||
|
||||
/** @var array $infoblocksInventories */
|
||||
private static $infoblocksInventories;
|
||||
|
||||
/** @var array $stores */
|
||||
private static $stores;
|
||||
|
||||
/** @var array $shops */
|
||||
private static $shops;
|
||||
|
||||
/**
|
||||
* @return bool|string|null
|
||||
*/
|
||||
public static function getApiUrl()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$apiUrl)) {
|
||||
static::$apiUrl = static::getOption(RetailcrmConstants::CRM_API_HOST_OPTION);
|
||||
}
|
||||
|
||||
return static::$apiUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool|string|null
|
||||
*/
|
||||
public static function getApiKey()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$apiKey)) {
|
||||
static::$apiKey = static::getOption(RetailcrmConstants::CRM_API_KEY_OPTION);
|
||||
}
|
||||
|
||||
return static::$apiKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* getCorporateClientName
|
||||
*
|
||||
* @return bool|string|null
|
||||
*/
|
||||
public static function getCorporateClientName()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$corporateClientName)) {
|
||||
static::$corporateClientName = static::getUnserializedOption(RetailcrmConstants::CRM_CORP_NAME);
|
||||
}
|
||||
|
||||
return static::$corporateClientName;
|
||||
}
|
||||
|
||||
/**
|
||||
* getCorporateClientAddress
|
||||
*
|
||||
* @return bool|string|null
|
||||
*/
|
||||
public static function getCorporateClientAddress()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$corporateClientAddress)) {
|
||||
static::$corporateClientAddress = static::getUnserializedOption(RetailcrmConstants::CRM_CORP_ADDRESS);
|
||||
}
|
||||
|
||||
return static::$corporateClientAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* getCorporateClient
|
||||
*
|
||||
* @return bool|string|null
|
||||
*/
|
||||
public static function getCorporateClientStatus()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$corporateClient)) {
|
||||
static::$corporateClient = static::getOption(RetailcrmConstants::CRM_CC);
|
||||
}
|
||||
|
||||
return static::$corporateClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* getSitesList
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getSitesList()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$sitesList)) {
|
||||
static::$sitesList = static::getUnserializedOption(RetailcrmConstants::CRM_SITES_LIST);
|
||||
}
|
||||
|
||||
return static::$sitesList;
|
||||
}
|
||||
|
||||
/**
|
||||
* getSitesListCorporate
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getSitesListCorporate()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$sitesListCorporate)) {
|
||||
static::$sitesListCorporate = static::getUnserializedOption(
|
||||
RetailcrmConstants::CRM_SITES_LIST_CORPORATE
|
||||
);
|
||||
}
|
||||
|
||||
return static::$sitesListCorporate;
|
||||
}
|
||||
|
||||
/**
|
||||
* getOrderTypes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getOrderTypes()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$orderTypes)) {
|
||||
static::$orderTypes = static::getUnserializedOption(RetailcrmConstants::CRM_ORDER_TYPES_ARR);
|
||||
}
|
||||
|
||||
return static::$orderTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* getDeliveryTypes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getDeliveryTypes()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$deliveryTypes)) {
|
||||
static::$deliveryTypes = static::getUnserializedOption(RetailcrmConstants::CRM_DELIVERY_TYPES_ARR);
|
||||
}
|
||||
|
||||
return static::$deliveryTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* getPaymentTypes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getPaymentTypes()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$paymentTypes)) {
|
||||
static::$paymentTypes = static::getUnserializedOption(RetailcrmConstants::CRM_PAYMENT_TYPES);
|
||||
}
|
||||
|
||||
return static::$paymentTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* getPaymentStatuses
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getPaymentStatuses()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$paymentStatuses)) {
|
||||
static::$paymentStatuses = static::getUnserializedOption(RetailcrmConstants::CRM_PAYMENT_STATUSES);
|
||||
}
|
||||
|
||||
return static::$paymentStatuses;
|
||||
}
|
||||
|
||||
/**
|
||||
* getPayment
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getPayment()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$payment)) {
|
||||
static::$payment = static::getUnserializedOption(RetailcrmConstants::CRM_PAYMENT);
|
||||
}
|
||||
|
||||
return static::$payment;
|
||||
}
|
||||
|
||||
/**
|
||||
* getOrderProps
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getOrderProps()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$orderProps)) {
|
||||
static::$orderProps = static::getUnserializedOption(RetailcrmConstants::CRM_ORDER_PROPS);
|
||||
}
|
||||
|
||||
return static::$orderProps;
|
||||
}
|
||||
|
||||
/**
|
||||
* getLegalDetails
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getLegalDetails()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$legalDetails)) {
|
||||
static::$legalDetails = static::getUnserializedOption(RetailcrmConstants::CRM_LEGAL_DETAILS);
|
||||
}
|
||||
|
||||
return static::$legalDetails;
|
||||
}
|
||||
|
||||
/**
|
||||
* getContragentTypes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getContragentTypes()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$contragentTypes)) {
|
||||
static::$contragentTypes = static::getUnserializedOption(RetailcrmConstants::CRM_CONTRAGENT_TYPE);
|
||||
}
|
||||
|
||||
return static::$contragentTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* getCustomFields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getCustomFields()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$customFields)) {
|
||||
static::$customFields = static::getUnserializedOption(RetailcrmConstants::CRM_CUSTOM_FIELDS);
|
||||
}
|
||||
|
||||
return static::$customFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* getCancellableOrderPaymentStatuses
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getCancellableOrderPaymentStatuses()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$cancellableOrderPaymentStatuses)) {
|
||||
static::$cancellableOrderPaymentStatuses = static::getUnserializedOption(
|
||||
RetailcrmConstants::CRM_CANCEL_ORDER
|
||||
);
|
||||
}
|
||||
|
||||
return static::$cancellableOrderPaymentStatuses;
|
||||
}
|
||||
|
||||
/**
|
||||
* getLastOrderId
|
||||
*
|
||||
* @return bool|string|null
|
||||
*/
|
||||
public static function getLastOrderId()
|
||||
{
|
||||
return static::getOption(RetailcrmConstants::CRM_ORDER_LAST_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* setLastOrderId
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
public static function setLastOrderId($id)
|
||||
{
|
||||
static::setOption(RetailcrmConstants::CRM_ORDER_LAST_ID, $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* getFailedOrdersIds
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getFailedOrdersIds()
|
||||
{
|
||||
return static::getUnserializedOption(RetailcrmConstants::CRM_ORDER_FAILED_IDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* setFailedOrdersIds
|
||||
*
|
||||
* @param $ids
|
||||
*/
|
||||
public static function setFailedOrdersIds($ids)
|
||||
{
|
||||
static::setOption(RetailcrmConstants::CRM_ORDER_FAILED_IDS, serialize($ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* getOrderNumbers
|
||||
*
|
||||
* @return bool|string|null
|
||||
*/
|
||||
public static function getOrderNumbers()
|
||||
{
|
||||
if (self::isEmptyNotZero(self::$orderNumbers)) {
|
||||
self::$orderNumbers = static::getOption(RetailcrmConstants::CRM_ORDER_NUMBERS);
|
||||
}
|
||||
|
||||
return self::$orderNumbers;
|
||||
}
|
||||
|
||||
/**
|
||||
* getOrderHistoryDate
|
||||
*
|
||||
* @return bool|string|null
|
||||
*/
|
||||
public static function getOrderHistoryDate()
|
||||
{
|
||||
return static::getOption(RetailcrmConstants::CRM_ORDER_HISTORY_DATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* getCatalogBasePrice
|
||||
*
|
||||
* @return bool|string|null
|
||||
*/
|
||||
public static function getCatalogBasePrice()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$catalogBasePrice)) {
|
||||
static::$catalogBasePrice = static::getOption(RetailcrmConstants::CRM_CATALOG_BASE_PRICE);
|
||||
}
|
||||
|
||||
return static::$catalogBasePrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* getOrderDimensions
|
||||
*
|
||||
* @return bool|string|null
|
||||
*/
|
||||
public static function getOrderDimensions()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$orderDimensions)) {
|
||||
static::$orderDimensions = static::getOption(RetailcrmConstants::CRM_ORDER_DIMENSIONS, 'N');
|
||||
}
|
||||
|
||||
return static::$orderDimensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* getCurrency
|
||||
*
|
||||
* @return bool|string|null
|
||||
*/
|
||||
public static function getCurrency()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$currency)) {
|
||||
static::$currency = static::getOption(RetailcrmConstants::CRM_CURRENCY);
|
||||
}
|
||||
|
||||
return static::$currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns currency from settings. If it's not set - returns Bitrix base currency.
|
||||
*
|
||||
* @return bool|string|null
|
||||
*/
|
||||
public static function getCurrencyOrDefault()
|
||||
{
|
||||
return self::getCurrency() ? self::getCurrency() : \Bitrix\Currency\CurrencyManager::getBaseCurrency();
|
||||
}
|
||||
|
||||
/**
|
||||
* getInfoblocksInventories
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getInfoblocksInventories()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$infoblocksInventories)) {
|
||||
static::$infoblocksInventories = static::getUnserializedOption(
|
||||
RetailcrmConstants::CRM_IBLOCKS_INVENTORIES
|
||||
);
|
||||
}
|
||||
|
||||
return static::$infoblocksInventories;
|
||||
}
|
||||
|
||||
/**
|
||||
* getStores
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getStores()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$stores)) {
|
||||
static::$stores = static::getUnserializedOption(RetailcrmConstants::CRM_STORES);
|
||||
}
|
||||
|
||||
return static::$stores;
|
||||
}
|
||||
|
||||
/**
|
||||
* getShops
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getShops()
|
||||
{
|
||||
if (self::isEmptyNotZero(static::$shops)) {
|
||||
static::$shops = static::getUnserializedOption(RetailcrmConstants::CRM_SHOPS);
|
||||
}
|
||||
|
||||
return static::$shops;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps Bitrix COption::GetOptionString(...)
|
||||
*
|
||||
* @param string $option
|
||||
* @param int|string $def
|
||||
*
|
||||
* @return bool|string|null
|
||||
*/
|
||||
private static function getOption($option, $def = 0)
|
||||
{
|
||||
return COption::GetOptionString(
|
||||
RetailcrmConstants::MODULE_ID,
|
||||
$option,
|
||||
$def
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* setOption
|
||||
*
|
||||
* @param $name
|
||||
* @param string $value
|
||||
* @param bool $desc
|
||||
* @param string $site
|
||||
*/
|
||||
private static function setOption($name, $value = "", $desc = false, $site = "")
|
||||
{
|
||||
COption::SetOptionString(
|
||||
RetailcrmConstants::MODULE_ID,
|
||||
$name,
|
||||
$value,
|
||||
$desc,
|
||||
$site
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps Bitrix unserialize(COption::GetOptionString(...))
|
||||
*
|
||||
* @param string $option
|
||||
* @param int|string $def
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private static function getUnserializedOption($option, $def = 0)
|
||||
{
|
||||
return unserialize(static::getOption($option, $def));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if value is empty and not zero (0 - digit)
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private static function isEmptyNotZero($value)
|
||||
{
|
||||
return empty($value) && $value !== 0;
|
||||
}
|
||||
}
|
77
intaro.retailcrm/classes/general/RetailcrmConstants.php
Normal file
77
intaro.retailcrm/classes/general/RetailcrmConstants.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.3
|
||||
*
|
||||
* RetailcrmConstants
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||
*/
|
||||
|
||||
IncludeModuleLangFile(__FILE__);
|
||||
|
||||
/**
|
||||
* PHP version 5.3
|
||||
*
|
||||
* RetailcrmConstants
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||
*/
|
||||
class RetailcrmConstants
|
||||
{
|
||||
const MODULE_ID = 'intaro.retailcrm';
|
||||
const CRM_API_HOST_OPTION = 'api_host';
|
||||
const CRM_API_KEY_OPTION = 'api_key';
|
||||
const CRM_ORDER_TYPES_ARR = 'order_types_arr';
|
||||
const CRM_DELIVERY_TYPES_ARR = 'deliv_types_arr';
|
||||
const CRM_DELIVERY_SERVICES_ARR = 'deliv_services_arr';
|
||||
const CRM_PAYMENT_TYPES = 'pay_types_arr';
|
||||
const CRM_PAYMENT_STATUSES = 'pay_statuses_arr';
|
||||
const CRM_PAYMENT = 'payment_arr'; //order payment Y/N
|
||||
const CRM_ORDER_LAST_ID = 'order_last_id';
|
||||
const CRM_ORDER_SITES = 'sites_ids';
|
||||
const CRM_ORDER_DISCHARGE = 'order_discharge';
|
||||
const CRM_ORDER_PROPS = 'order_props';
|
||||
const CRM_LEGAL_DETAILS = 'legal_details';
|
||||
const CRM_CUSTOM_FIELDS = 'custom_fields';
|
||||
const CRM_CONTRAGENT_TYPE = 'contragent_type';
|
||||
const CRM_SITES_LIST = 'sites_list';
|
||||
const CRM_SITES_LIST_CORPORATE = 'shops-corporate';
|
||||
const CRM_ORDER_NUMBERS = 'order_numbers';
|
||||
const CRM_CANCEL_ORDER = 'cansel_order';
|
||||
const CRM_INVENTORIES_UPLOAD = 'inventories_upload';
|
||||
const CRM_STORES = 'stores';
|
||||
const CRM_SHOPS = 'shops';
|
||||
const CRM_IBLOCKS_INVENTORIES = 'iblocks_inventories';
|
||||
const CRM_PRICES_UPLOAD = 'prices_upload';
|
||||
const CRM_PRICES = 'prices';
|
||||
const CRM_PRICE_SHOPS = 'price_shops';
|
||||
const CRM_IBLOCKS_PRICES = 'iblock_prices';
|
||||
const CRM_COLLECTOR = 'collector';
|
||||
const CRM_COLL_KEY = 'coll_key';
|
||||
const CRM_UA = 'ua';
|
||||
const CRM_UA_KEYS = 'ua_keys';
|
||||
const CRM_DISCOUNT_ROUND = 'discount_round';
|
||||
const CRM_CC = 'cc';
|
||||
const CRM_CORP_SHOPS = 'shops-corporate';
|
||||
const CRM_CORP_NAME = 'nickName-corporate';
|
||||
const CRM_CORP_ADDRESS = 'adres-corporate';
|
||||
const CRM_API_VERSION = 'api_version';
|
||||
const CRM_CURRENCY = 'currency';
|
||||
const CRM_ADDRESS_OPTIONS = 'address_options';
|
||||
const CRM_DIMENSIONS = 'order_dimensions';
|
||||
const PROTOCOL = 'protocol';
|
||||
const CRM_ORDER_FAILED_IDS = 'order_failed_ids';
|
||||
const CRM_ORDER_HISTORY_DATE = 'order_history_date';
|
||||
const CRM_CATALOG_BASE_PRICE = 'catalog_base_price';
|
||||
const CRM_ORDER_DIMENSIONS = 'order_dimensions';
|
||||
const CANCEL_PROPERTY_CODE = 'INTAROCRM_IS_CANCELED';
|
||||
}
|
104
intaro.retailcrm/classes/general/RetailcrmDependencyLoader.php
Normal file
104
intaro.retailcrm/classes/general/RetailcrmDependencyLoader.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.3
|
||||
*
|
||||
* RetailcrmDependencyLoader class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||
*/
|
||||
|
||||
IncludeModuleLangFile(__FILE__);
|
||||
|
||||
/**
|
||||
* PHP version 5.3
|
||||
*
|
||||
* RetailcrmDependencyLoader class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||
*/
|
||||
class RetailcrmDependencyLoader
|
||||
{
|
||||
/** @var int */
|
||||
const LEGACY_LOADER = 0;
|
||||
|
||||
/** @var int */
|
||||
const D7_LOADER = 1;
|
||||
|
||||
/** @var int $loader */
|
||||
private static $loader = self::D7_LOADER;
|
||||
|
||||
/**
|
||||
* Loads dependencies
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function loadDependencies()
|
||||
{
|
||||
foreach (self::getDependencies() as $dependency) {
|
||||
if (self::LEGACY_LOADER == self::$loader) {
|
||||
if (!CModule::IncludeModule($dependency)) {
|
||||
RCrmActions::eventLog(
|
||||
__CLASS__ . '::' . __METHOD__,
|
||||
$dependency,
|
||||
'module not found'
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
if (!\Bitrix\Main\Loader::includeModule($dependency)) {
|
||||
RCrmActions::eventLog(
|
||||
__CLASS__ . '::' . __METHOD__,
|
||||
$dependency,
|
||||
'module not found'
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
} catch (\Bitrix\Main\LoaderException $exception) {
|
||||
RCrmActions::eventLog(
|
||||
__CLASS__ . '::' . __METHOD__,
|
||||
$dependency,
|
||||
sprintf('error while trying to load module: %s', $exception->getMessage())
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set loader mode. Use RetailcrmDependencyLoader::LEGACY_LOADER or RetailcrmDependencyLoader::D7_LOADER
|
||||
*
|
||||
* @param $loader
|
||||
*/
|
||||
public static function setLoader($loader)
|
||||
{
|
||||
if (in_array($loader, array(self::LEGACY_LOADER, self::D7_LOADER))) {
|
||||
self::$loader = $loader;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of required modules names
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function getDependencies()
|
||||
{
|
||||
return array("iblock", "sale", "catalog");
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@
|
||||
<field id="patronymic" group="customer">patronymic</field>
|
||||
<field id="email" group="customer">email</field>
|
||||
<field id="birthday" group="customer">birthday</field>
|
||||
<field id="sex" group="customer">sex</field>
|
||||
<field id="phones" group="customer">phones</field>
|
||||
<field id="manager" group="customer">manager</field>
|
||||
<field id="commentary" group="customer">commentary</field>
|
||||
|
@ -80,6 +80,10 @@
|
||||
"type": "bool",
|
||||
"default": false
|
||||
},
|
||||
"subscribed": {
|
||||
"type": "bool",
|
||||
"default": false
|
||||
},
|
||||
"commentary": {
|
||||
"type": "string"
|
||||
},
|
||||
@ -169,6 +173,49 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"customerCorporate": {
|
||||
"externalId": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "datetime",
|
||||
"format": "Y-m-d H:i:s"
|
||||
},
|
||||
"contragentType": {
|
||||
"type": "enum",
|
||||
"default": "legal-entity",
|
||||
"values": ["individual", "legal-entity", "enterpreneur"]
|
||||
},
|
||||
"isMain": {
|
||||
"type": "bool",
|
||||
"default": false
|
||||
},
|
||||
"site": {
|
||||
"type": "string"
|
||||
},
|
||||
"nickName": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"text": {
|
||||
"type": "string"
|
||||
},
|
||||
"legalName": {
|
||||
"type": "string"
|
||||
},
|
||||
"legalAddress": {
|
||||
"type": "string"
|
||||
},
|
||||
"INN": {
|
||||
"type": "string"
|
||||
},
|
||||
"KPP": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"orders": {
|
||||
"number": {
|
||||
"type": "string"
|
||||
@ -177,6 +224,10 @@
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "datetime",
|
||||
"format": "Y-m-d H:i:s"
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class RetailCrmEvent
|
||||
*/
|
||||
@ -19,6 +20,9 @@ class RetailCrmEvent
|
||||
protected static $CRM_CONTRAGENT_TYPE = 'contragent_type';
|
||||
protected static $CRM_ORDER_FAILED_IDS = 'order_failed_ids';
|
||||
protected static $CRM_SITES_LIST = 'sites_list';
|
||||
protected static $CRM_CC = 'cc';
|
||||
protected static $CRM_CORP_NAME = 'nickName-corporate';
|
||||
protected static $CRM_CORP_ADRES = 'adres-corporate';
|
||||
|
||||
/**
|
||||
* @param $arFields
|
||||
@ -36,11 +40,8 @@ class RetailCrmEvent
|
||||
return false;
|
||||
}
|
||||
|
||||
$api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0);
|
||||
$api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0);
|
||||
$optionsSitesList = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_SITES_LIST, 0));
|
||||
|
||||
$api = new RetailCrm\ApiClient($api_host, $api_key);
|
||||
$optionsSitesList = RetailcrmConfigProvider::getSitesList();
|
||||
$api = new RetailCrm\ApiClient(RetailcrmConfigProvider::getApiUrl(), RetailcrmConfigProvider::getApiKey());
|
||||
$resultOrder = RetailCrmUser::customerEdit($arFields, $api, $optionsSitesList);
|
||||
|
||||
if (!$resultOrder) {
|
||||
@ -53,7 +54,7 @@ class RetailCrmEvent
|
||||
/**
|
||||
* onUpdateOrder
|
||||
*
|
||||
* @param mixed $ID - Order id
|
||||
* @param mixed $ID - Order id
|
||||
* @param mixed $arFields - Order arFields
|
||||
*/
|
||||
function onUpdateOrder($ID, $arFields)
|
||||
@ -66,8 +67,8 @@ class RetailCrmEvent
|
||||
$GLOBALS['RETAILCRM_ORDER_OLD_EVENT'] = true;
|
||||
|
||||
if (($arFields['CANCELED'] == 'Y')
|
||||
&& (sizeof($arFields['BASKET_ITEMS']) == 0 )
|
||||
&& (sizeof($arFields['ORDER_PROP']) == 0 )
|
||||
&& (sizeof($arFields['BASKET_ITEMS']) == 0)
|
||||
&& (sizeof($arFields['ORDER_PROP']) == 0)
|
||||
) {
|
||||
$GLOBALS['ORDER_DELETE_USER_ADMIN'] = true;
|
||||
}
|
||||
@ -129,7 +130,7 @@ class RetailCrmEvent
|
||||
return false;
|
||||
}
|
||||
|
||||
//exists getParameter("ENTITY")
|
||||
//exists getParameter("ENTITY")
|
||||
if (method_exists($event, 'getId')) {
|
||||
$obOrder = $event;
|
||||
} elseif (method_exists($event, 'getParameter')) {
|
||||
@ -142,34 +143,34 @@ class RetailCrmEvent
|
||||
|
||||
$arOrder = RetailCrmOrder::orderObjToArr($obOrder);
|
||||
|
||||
//api
|
||||
$api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0);
|
||||
$api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0);
|
||||
$api = new RetailCrm\ApiClient($api_host, $api_key);
|
||||
$api = new RetailCrm\ApiClient(RetailcrmConfigProvider::getApiUrl(), RetailcrmConfigProvider::getApiKey());
|
||||
|
||||
//params
|
||||
$optionsOrderTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_TYPES_ARR, 0));
|
||||
$optionsDelivTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_DELIVERY_TYPES_ARR, 0));
|
||||
$optionsPayTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_TYPES, 0));
|
||||
$optionsPayStatuses = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_STATUSES, 0)); // --statuses
|
||||
$optionsPayment = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT, 0));
|
||||
$optionsSitesList = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_SITES_LIST, 0));
|
||||
$optionsOrderProps = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_PROPS, 0));
|
||||
$optionsLegalDetails = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_LEGAL_DETAILS, 0));
|
||||
$optionsContragentType = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_CONTRAGENT_TYPE, 0));
|
||||
$optionsCustomFields = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_CUSTOM_FIELDS, 0));
|
||||
$optionsOrderTypes = RetailcrmConfigProvider::getOrderTypes();
|
||||
$optionsDelivTypes = RetailcrmConfigProvider::getDeliveryTypes();
|
||||
$optionsPayTypes = RetailcrmConfigProvider::getPaymentTypes();
|
||||
$optionsPayStatuses = RetailcrmConfigProvider::getPaymentStatuses(); // --statuses
|
||||
$optionsPayment = RetailcrmConfigProvider::getPayment();
|
||||
$optionsSitesList = RetailcrmConfigProvider::getSitesList();
|
||||
$optionsOrderProps = RetailcrmConfigProvider::getOrderProps();
|
||||
$optionsLegalDetails = RetailcrmConfigProvider::getLegalDetails();
|
||||
$optionsContragentType = RetailcrmConfigProvider::getContragentTypes();
|
||||
$optionsCustomFields = RetailcrmConfigProvider::getCustomFields();
|
||||
|
||||
//corp cliente swich
|
||||
$optionCorpClient = RetailcrmConfigProvider::getCorporateClientStatus();
|
||||
|
||||
$arParams = RCrmActions::clearArr(array(
|
||||
'optionsOrderTypes' => $optionsOrderTypes,
|
||||
'optionsDelivTypes' => $optionsDelivTypes,
|
||||
'optionsPayTypes' => $optionsPayTypes,
|
||||
'optionsPayStatuses' => $optionsPayStatuses,
|
||||
'optionsPayment' => $optionsPayment,
|
||||
'optionsOrderProps' => $optionsOrderProps,
|
||||
'optionsLegalDetails' => $optionsLegalDetails,
|
||||
'optionsOrderTypes' => $optionsOrderTypes,
|
||||
'optionsDelivTypes' => $optionsDelivTypes,
|
||||
'optionsPayTypes' => $optionsPayTypes,
|
||||
'optionsPayStatuses' => $optionsPayStatuses,
|
||||
'optionsPayment' => $optionsPayment,
|
||||
'optionsOrderProps' => $optionsOrderProps,
|
||||
'optionsLegalDetails' => $optionsLegalDetails,
|
||||
'optionsContragentType' => $optionsContragentType,
|
||||
'optionsSitesList' => $optionsSitesList,
|
||||
'optionsCustomFields' => $optionsCustomFields
|
||||
'optionsSitesList' => $optionsSitesList,
|
||||
'optionsCustomFields' => $optionsCustomFields
|
||||
));
|
||||
|
||||
//many sites?
|
||||
@ -192,20 +193,215 @@ class RetailCrmEvent
|
||||
$methodApi = 'ordersCreate';
|
||||
}
|
||||
|
||||
//user
|
||||
$userCrm = RCrmActions::apiMethod($api, 'customersGet', __METHOD__, $arOrder['USER_ID'], $site);
|
||||
if (!isset($userCrm['customer'])) {
|
||||
$arUser = Bitrix\Main\UserTable::getById($arOrder['USER_ID'])->fetch();
|
||||
$resultUser = RetailCrmUser::customerSend($arUser, $api, $optionsContragentType[$arOrder['PERSON_TYPE_ID']], true, $site);
|
||||
if (!$resultUser) {
|
||||
RCrmActions::eventLog('RetailCrmEvent::orderSave', 'RetailCrmUser::customerSend', 'error during creating customer');
|
||||
$orderCompany = null;
|
||||
|
||||
if ("Y" == $optionCorpClient && $optionsContragentType[$arOrder['PERSON_TYPE_ID']] == 'legal-entity') {
|
||||
//corparate cliente
|
||||
$nickName = '';
|
||||
$address = '';
|
||||
$corpAddress = '';
|
||||
$contragent = array();
|
||||
$userCorp = array();
|
||||
$corpName = RetailcrmConfigProvider::getCorporateClientName();
|
||||
$corpAddress = RetailcrmConfigProvider::getCorporateClientAddress();
|
||||
|
||||
foreach ($arOrder['PROPS']['properties'] as $prop) {
|
||||
if ($prop['CODE'] == $corpName) {
|
||||
$nickName = $prop['VALUE'][0];
|
||||
}
|
||||
|
||||
if ($prop['CODE'] == $corpAddress) {
|
||||
$address = $prop['VALUE'][0];
|
||||
}
|
||||
|
||||
if (!empty($optionsLegalDetails)
|
||||
&& $search = array_search($prop['CODE'], $optionsLegalDetails[$arOrder['PERSON_TYPE_ID']])
|
||||
) {
|
||||
$contragent[$search] = $prop['VALUE'][0];//legal order data
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($contragentType)) {
|
||||
$contragent['contragentType'] = $contragentType;
|
||||
}
|
||||
|
||||
$customersCorporate = false;
|
||||
$response = $api->customersCorporateList(array('companyName' => $nickName));
|
||||
|
||||
if ($response && $response->getStatusCode() == 200) {
|
||||
$customersCorporate = $response['customersCorporate'];
|
||||
$singleCorp = reset($customersCorporate);
|
||||
|
||||
if (!empty($singleCorp)) {
|
||||
$userCorp['customerCorporate'] = $singleCorp;
|
||||
$companiesResponse = $api->customersCorporateCompanies(
|
||||
$singleCorp['id'],
|
||||
array(),
|
||||
null,
|
||||
null,
|
||||
'id',
|
||||
$site
|
||||
);
|
||||
|
||||
if ($companiesResponse && $companiesResponse->isSuccessful()) {
|
||||
$orderCompany = array_reduce(
|
||||
$companiesResponse['companies'],
|
||||
function ($carry, $item) use ($nickName) {
|
||||
if (is_array($item) && $item['name'] == $nickName) {
|
||||
$carry = $item;
|
||||
}
|
||||
|
||||
return $carry;
|
||||
},
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
RCrmActions::eventLog(
|
||||
'RetailCrmEvent::orderSave',
|
||||
'ApiClient::customersCorporateList',
|
||||
'error during fetching corporate customers'
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//user
|
||||
$userCrm = RCrmActions::apiMethod($api, 'customersGet', __METHOD__, $arOrder['USER_ID'], $site);
|
||||
|
||||
if (!isset($userCrm['customer'])) {
|
||||
$arUser = Bitrix\Main\UserTable::getById($arOrder['USER_ID'])->fetch();
|
||||
|
||||
if (!empty($address)) {
|
||||
$arUser['PERSONAL_STREET'] = $address;
|
||||
}
|
||||
|
||||
$resultUser = RetailCrmUser::customerSend($arUser, $api, "individual", true, $site);
|
||||
|
||||
if (!$resultUser) {
|
||||
RCrmActions::eventLog(
|
||||
__CLASS__ . '::' . __METHOD__,
|
||||
'RetailCrmUser::customerSend',
|
||||
'error during creating customer'
|
||||
);
|
||||
|
||||
return false;
|
||||
} else {
|
||||
$userCrm = array('customer' => array('externalId' => $arOrder['USER_ID']));
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($userCorp['customerCorporate'])) {
|
||||
$resultUserCorp = RetailCrmCorporateClient::clientSend(
|
||||
$arOrder,
|
||||
$api,
|
||||
$optionsContragentType[$arOrder['PERSON_TYPE_ID']],
|
||||
true,
|
||||
false,
|
||||
$site
|
||||
);
|
||||
|
||||
Logger::getInstance()->write($resultUserCorp, 'resultUserCorp');
|
||||
|
||||
if (!$resultUserCorp) {
|
||||
RCrmActions::eventLog('RetailCrmEvent::orderSave', 'RetailCrmCorporateClient::clientSend', 'error during creating client');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$arParams['customerCorporate'] = $resultUserCorp;
|
||||
$arParams['orderCompany'] = isset($resultUserCorp['mainCompany']) ? $resultUserCorp['mainCompany'] : null;
|
||||
|
||||
$customerCorporateAddress = array();
|
||||
$customerCorporateCompany = array();
|
||||
$addressResult = null;
|
||||
$companyResult = null;
|
||||
|
||||
if (!empty($address)) {
|
||||
//TODO address builder add
|
||||
$customerCorporateAddress = array(
|
||||
'name' => $nickName,
|
||||
'isMain' => true,
|
||||
'text' => $address
|
||||
);
|
||||
|
||||
$addressResult = $api->customersCorporateAddressesCreate($resultUserCorp['id'], $customerCorporateAddress, 'id', $site);
|
||||
}
|
||||
|
||||
$customerCorporateCompany = array(
|
||||
'name' => $nickName,
|
||||
'isMain' => true,
|
||||
'contragent' => $contragent
|
||||
);
|
||||
|
||||
if (!empty($addressResult)) {
|
||||
$customerCorporateCompany['address'] = array(
|
||||
'id' => $addressResult['id']
|
||||
);
|
||||
}
|
||||
|
||||
$companyResult = $api->customersCorporateCompaniesCreate($resultUserCorp['id'], $customerCorporateCompany, 'id', $site);
|
||||
|
||||
$customerCorporateContact = array(
|
||||
'isMain' => true,
|
||||
'customer' => array(
|
||||
'externalId' => $arOrder['USER_ID'],
|
||||
'site' => $site
|
||||
)
|
||||
);
|
||||
|
||||
if (!empty($companyResult)) {
|
||||
$customerCorporateContact['companies'] = array(
|
||||
array(
|
||||
'company' => array(
|
||||
'id' => $companyResult['id']
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$contactResult = $api->customersCorporateContactsCreate(
|
||||
$resultUserCorp['id'],
|
||||
$customerCorporateContact,
|
||||
'id',
|
||||
$site
|
||||
);
|
||||
} else {
|
||||
|
||||
RetailCrmCorporateClient::addCustomersCorporateAddresses(
|
||||
$userCorp['customerCorporate']['id'],
|
||||
$nickName,
|
||||
$address,
|
||||
$api,
|
||||
$site = null
|
||||
);
|
||||
|
||||
$arParams['customerCorporate'] = $userCorp['customerCorporate'];
|
||||
|
||||
if (!empty($orderCompany)) {
|
||||
$arParams['orderCompany'] = $orderCompany;
|
||||
}
|
||||
}
|
||||
|
||||
$arParams['contactExId'] = $userCrm['customer']['externalId'];
|
||||
} else {
|
||||
//user
|
||||
$userCrm = RCrmActions::apiMethod($api, 'customersGet', __METHOD__, $arOrder['USER_ID'], $site);
|
||||
if (!isset($userCrm['customer'])) {
|
||||
$arUser = Bitrix\Main\UserTable::getById($arOrder['USER_ID'])->fetch();
|
||||
$resultUser = RetailCrmUser::customerSend($arUser, $api, $optionsContragentType[$arOrder['PERSON_TYPE_ID']], true, $site);
|
||||
if (!$resultUser) {
|
||||
RCrmActions::eventLog('RetailCrmEvent::orderSave', 'RetailCrmUser::customerSend', 'error during creating customer');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//order
|
||||
$resultOrder = RetailCrmOrder::orderSend($arOrder, $api, $arParams, true, $site, $methodApi);
|
||||
|
||||
if (!$resultOrder) {
|
||||
RCrmActions::eventLog('RetailCrmEvent::orderSave', 'RetailCrmOrder::orderSend', 'error during creating order');
|
||||
|
||||
@ -218,9 +414,9 @@ class RetailCrmEvent
|
||||
/**
|
||||
* @param \Bitrix\Sale\Payment $event
|
||||
*
|
||||
* @return bool
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function paymentSave($event)
|
||||
{
|
||||
@ -236,18 +432,18 @@ class RetailCrmEvent
|
||||
return false;
|
||||
}
|
||||
|
||||
$optionsSitesList = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_SITES_LIST, 0));
|
||||
$optionsPaymentTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_TYPES, 0));
|
||||
$optionsPayStatuses = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT, 0));
|
||||
$optionsSitesList = RetailcrmConfigProvider::getSitesList();
|
||||
$optionsPaymentTypes = RetailcrmConfigProvider::getPaymentTypes();
|
||||
$optionsPayStatuses = RetailcrmConfigProvider::getPayment();
|
||||
|
||||
$arPayment = array(
|
||||
'ID' => $event->getId(),
|
||||
'ORDER_ID' => $event->getField('ORDER_ID'),
|
||||
'PAID' => $event->getField('PAID'),
|
||||
'ID' => $event->getId(),
|
||||
'ORDER_ID' => $event->getField('ORDER_ID'),
|
||||
'PAID' => $event->getField('PAID'),
|
||||
'PAY_SYSTEM_ID' => $event->getField('PAY_SYSTEM_ID'),
|
||||
'SUM' => $event->getField('SUM'),
|
||||
'LID' => $order->getSiteId(),
|
||||
'DATE_PAID' => $event->getField('DATE_PAID'),
|
||||
'SUM' => $event->getField('SUM'),
|
||||
'LID' => $order->getSiteId(),
|
||||
'DATE_PAID' => $event->getField('DATE_PAID'),
|
||||
);
|
||||
|
||||
if ($optionsSitesList) {
|
||||
@ -360,9 +556,9 @@ class RetailCrmEvent
|
||||
$optionsSitesList = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_SITES_LIST, 0));
|
||||
|
||||
$arPayment = array(
|
||||
'ID' => $event->getId(),
|
||||
'ORDER_ID' => $event->getField('ORDER_ID'),
|
||||
'LID' => $event->getCollection()->getOrder()->getSiteId()
|
||||
'ID' => $event->getId(),
|
||||
'ORDER_ID' => $event->getField('ORDER_ID'),
|
||||
'LID' => $event->getCollection()->getOrder()->getSiteId()
|
||||
);
|
||||
|
||||
if ($optionsSitesList) {
|
||||
|
@ -60,8 +60,7 @@ class RetailCrmHistory
|
||||
|
||||
$customerH = isset($customerHistory['history']) ? $customerHistory['history'] : array();
|
||||
|
||||
$log = new Logger();
|
||||
$log->write($customerH, 'customerHistory');
|
||||
Logger::getInstance()->write($customerH, 'customerHistory');
|
||||
|
||||
if (count($customerH) == 0) {
|
||||
if ($customerHistory['history']['totalPageCount'] > $customerHistory['history']['currentPage']) {
|
||||
@ -275,8 +274,7 @@ class RetailCrmHistory
|
||||
|
||||
$orderH = isset($orderHistory['history']) ? $orderHistory['history'] : array();
|
||||
|
||||
$log = new Logger();
|
||||
$log->write($orderH, 'orderHistory');
|
||||
Logger::getInstance()->write($orderH, 'orderHistory');
|
||||
|
||||
if (count($orderH) == 0) {
|
||||
if ($orderHistory['history']['totalPageCount'] > $orderHistory['history']['currentPage']) {
|
||||
@ -305,7 +303,7 @@ class RetailCrmHistory
|
||||
}
|
||||
}
|
||||
|
||||
$log->write($order, 'assemblyOrderHistory');
|
||||
Logger::getInstance()->write($order, 'assemblyOrderHistory');
|
||||
|
||||
if ($order['deleted']) {
|
||||
continue;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2,13 +2,6 @@
|
||||
IncludeModuleLangFile(__FILE__);
|
||||
class RetailCrmInventories
|
||||
{
|
||||
public static $MODULE_ID = 'intaro.retailcrm';
|
||||
public static $CRM_API_HOST_OPTION = 'api_host';
|
||||
public static $CRM_API_KEY_OPTION = 'api_key';
|
||||
public static $CRM_INVENTORIES_UPLOAD = 'inventories_upload';
|
||||
public static $CRM_STORES = 'stores';
|
||||
public static $CRM_SHOPS = 'shops';
|
||||
public static $CRM_IBLOCKS_INVENTORIES = 'iblocks_inventories';
|
||||
public static $pageSize = 500;
|
||||
|
||||
public static function inventoriesUpload()
|
||||
@ -29,13 +22,10 @@ class RetailCrmInventories
|
||||
return false;
|
||||
}
|
||||
|
||||
$api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0);
|
||||
$api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0);
|
||||
$api = new RetailCrm\ApiClient($api_host, $api_key);
|
||||
|
||||
$infoBlocks = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_IBLOCKS_INVENTORIES, 0));
|
||||
$stores = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_STORES, 0));
|
||||
$shops = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_SHOPS, 0));
|
||||
$api = new RetailCrm\ApiClient(RetailcrmConfigProvider::getApiUrl(), RetailcrmConfigProvider::getApiKey());
|
||||
$infoBlocks = RetailcrmConfigProvider::getInfoblocksInventories();
|
||||
$stores = RetailcrmConfigProvider::getStores();
|
||||
$shops = RetailcrmConfigProvider::getShops();
|
||||
|
||||
try {
|
||||
$inventoriesList = $api->storesList()->stores;
|
||||
@ -65,8 +55,6 @@ class RetailCrmInventories
|
||||
}
|
||||
|
||||
if (count($infoBlocks) > 0) {
|
||||
$log = new Logger();
|
||||
|
||||
foreach ($infoBlocks as $id) {
|
||||
$iblockOffer = CCatalogSKU::GetInfoByProductIBlock($id);
|
||||
|
||||
@ -128,7 +116,7 @@ class RetailCrmInventories
|
||||
//for log
|
||||
$splitedItems = array_chunk($invUpload, 200);
|
||||
foreach ($splitedItems as $chunk) {
|
||||
$log->write($chunk, 'inventoriesUpload');
|
||||
Logger::getInstance()->write($chunk, 'inventoriesUpload');
|
||||
|
||||
foreach ($shops as $shop) {
|
||||
RCrmActions::apiMethod($api, 'storeInventoriesUpload', __METHOD__, $chunk, $shop);
|
||||
|
@ -40,14 +40,13 @@ class RetailCrmOrder
|
||||
if (!$api || empty($arParams)) { // add cond to check $arParams
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($arFields)) {
|
||||
RCrmActions::eventLog('RetailCrmOrder::orderSend', 'empty($arFields)', 'incorrect order');
|
||||
return false;
|
||||
}
|
||||
|
||||
$optionsCurrency = COption::GetOptionString(self::$MODULE_ID, self::$CRM_CURRENCY, 0);
|
||||
$currency = $optionsCurrency ? $optionsCurrency : \Bitrix\Currency\CurrencyManager::getBaseCurrency();
|
||||
|
||||
$currency = RetailcrmConfigProvider::getCurrencyOrDefault();
|
||||
$order = array(
|
||||
'number' => $arFields['NUMBER'],
|
||||
'externalId' => $arFields['ID'],
|
||||
@ -67,9 +66,11 @@ class RetailCrmOrder
|
||||
'cost' => $arFields['PRICE_DELIVERY']
|
||||
),
|
||||
);
|
||||
|
||||
if ($send && isset($_COOKIE['_rc']) && $_COOKIE['_rc'] != '') {
|
||||
$order['customer']['browserId'] = $_COOKIE['_rc'];
|
||||
}
|
||||
|
||||
$order['contragent']['contragentType'] = $arParams['optionsContragentType'][$arFields['PERSON_TYPE_ID']];
|
||||
|
||||
//fields
|
||||
@ -175,8 +176,7 @@ class RetailCrmOrder
|
||||
$normalizer = new RestNormalizer();
|
||||
$order = $normalizer->normalize($order, 'orders');
|
||||
|
||||
$log = new Logger();
|
||||
$log->write($order, 'orderSend');
|
||||
Logger::getInstance()->write($order, 'orderSend');
|
||||
|
||||
if($send) {
|
||||
if (!RCrmActions::apiMethod($api, $methodApi, __METHOD__, $order, $site)) {
|
||||
@ -189,31 +189,29 @@ class RetailCrmOrder
|
||||
|
||||
/**
|
||||
* Mass order uploading, without repeating; always returns true, but writes error log
|
||||
* @param $pSize
|
||||
* @param $failed -- flag to export failed orders
|
||||
*
|
||||
* @param int $pSize
|
||||
* @param bool $failed -- flag to export failed orders
|
||||
* @param bool $orderList
|
||||
*
|
||||
* @return boolean
|
||||
* @throws \Bitrix\Main\ArgumentNullException
|
||||
* @throws \Bitrix\Main\ObjectPropertyException
|
||||
* @throws \Bitrix\Main\SystemException
|
||||
* @throws \Bitrix\Main\ArgumentException
|
||||
*/
|
||||
public static function uploadOrders($pSize = 50, $failed = false, $orderList = false)
|
||||
{
|
||||
if (!CModule::IncludeModule("iblock")) {
|
||||
RCrmActions::eventLog('RetailCrmOrder::uploadOrders', 'iblock', 'module not found');
|
||||
return true;
|
||||
}
|
||||
if (!CModule::IncludeModule("sale")) {
|
||||
RCrmActions::eventLog('RetailCrmOrder::uploadOrders', 'sale', 'module not found');
|
||||
return true;
|
||||
}
|
||||
if (!CModule::IncludeModule("catalog")) {
|
||||
RCrmActions::eventLog('RetailCrmOrder::uploadOrders', 'catalog', 'module not found');
|
||||
return true;
|
||||
if (!RetailcrmDependencyLoader::loadDependencies()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$resOrders = array();
|
||||
$resCustomers = array();
|
||||
$orderIds = array();
|
||||
|
||||
$lastUpOrderId = COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_LAST_ID, 0);
|
||||
$failedIds = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_FAILED_IDS, 0));
|
||||
$lastUpOrderId = RetailcrmConfigProvider::getLastOrderId();
|
||||
$failedIds = RetailcrmConfigProvider::getFailedOrdersIds();
|
||||
|
||||
if ($failed == true && $failedIds !== false && count($failedIds) > 0) {
|
||||
$orderIds = $failedIds;
|
||||
@ -238,18 +236,18 @@ class RetailCrmOrder
|
||||
$api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0);
|
||||
$api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0);
|
||||
|
||||
$optionsSitesList = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_SITES_LIST, 0));
|
||||
$optionsOrderTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_TYPES_ARR, 0));
|
||||
$optionsDelivTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_DELIVERY_TYPES_ARR, 0));
|
||||
$optionsPayTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_TYPES, 0));
|
||||
$optionsPayStatuses = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_STATUSES, 0)); // --statuses
|
||||
$optionsPayment = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT, 0));
|
||||
$optionsOrderProps = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_PROPS, 0));
|
||||
$optionsLegalDetails = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_LEGAL_DETAILS, 0));
|
||||
$optionsContragentType = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_CONTRAGENT_TYPE, 0));
|
||||
$optionsCustomFields = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_CUSTOM_FIELDS, 0));
|
||||
$optionsSitesList = RetailcrmConfigProvider::getSitesList();
|
||||
$optionsOrderTypes = RetailcrmConfigProvider::getOrderTypes();
|
||||
$optionsDelivTypes = RetailcrmConfigProvider::getDeliveryTypes();
|
||||
$optionsPayTypes = RetailcrmConfigProvider::getPaymentTypes();
|
||||
$optionsPayStatuses = RetailcrmConfigProvider::getPaymentStatuses(); // --statuses
|
||||
$optionsPayment = RetailcrmConfigProvider::getPayment();
|
||||
$optionsOrderProps = RetailcrmConfigProvider::getOrderProps();
|
||||
$optionsLegalDetails = RetailcrmConfigProvider::getLegalDetails();
|
||||
$optionsContragentType = RetailcrmConfigProvider::getContragentTypes();
|
||||
$optionsCustomFields = RetailcrmConfigProvider::getCustomFields();
|
||||
|
||||
$api = new RetailCrm\ApiClient($api_host, $api_key);
|
||||
$api = new RetailCrm\ApiClient(RetailcrmConfigProvider::getApiUrl(), RetailcrmConfigProvider::getApiKey());
|
||||
|
||||
$arParams = array(
|
||||
'optionsOrderTypes' => $optionsOrderTypes,
|
||||
@ -333,6 +331,18 @@ class RetailCrmOrder
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if provided order array is corporate order data. v4 doesn't have corporate orders.
|
||||
*
|
||||
* @param array|\ArrayAccess $order
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isOrderCorporate($order)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function orderObjToArr($obOrder)
|
||||
{
|
||||
$culture = new \Bitrix\Main\Context\Culture(array("FORMAT_DATETIME" => "Y-m-d HH:i:s"));
|
||||
|
@ -2,29 +2,6 @@
|
||||
IncludeModuleLangFile(__FILE__);
|
||||
class RetailCrmOrder
|
||||
{
|
||||
public static $MODULE_ID = 'intaro.retailcrm';
|
||||
public static $CRM_API_HOST_OPTION = 'api_host';
|
||||
public static $CRM_API_KEY_OPTION = 'api_key';
|
||||
public static $CRM_ORDER_TYPES_ARR = 'order_types_arr';
|
||||
public static $CRM_DELIVERY_TYPES_ARR = 'deliv_types_arr';
|
||||
public static $CRM_PAYMENT_TYPES = 'pay_types_arr';
|
||||
public static $CRM_PAYMENT_STATUSES = 'pay_statuses_arr';
|
||||
public static $CRM_PAYMENT = 'payment_arr'; //order payment Y/N
|
||||
public static $CRM_ORDER_LAST_ID = 'order_last_id';
|
||||
public static $CRM_SITES_LIST = 'sites_list';
|
||||
public static $CRM_ORDER_PROPS = 'order_props';
|
||||
public static $CRM_LEGAL_DETAILS = 'legal_details';
|
||||
public static $CRM_CUSTOM_FIELDS = 'custom_fields';
|
||||
public static $CRM_CONTRAGENT_TYPE = 'contragent_type';
|
||||
public static $CRM_ORDER_FAILED_IDS = 'order_failed_ids';
|
||||
public static $CRM_ORDER_HISTORY_DATE = 'order_history_date';
|
||||
public static $CRM_CATALOG_BASE_PRICE = 'catalog_base_price';
|
||||
public static $CRM_ORDER_NUMBERS = 'order_numbers';
|
||||
public static $CRM_ORDER_DIMENSIONS = 'order_dimensions';
|
||||
public static $CRM_CURRENCY = 'currency';
|
||||
|
||||
const CANCEL_PROPERTY_CODE = 'INTAROCRM_IS_CANCELED';
|
||||
|
||||
/**
|
||||
*
|
||||
* Creates order or returns order for mass upload
|
||||
@ -51,15 +28,17 @@ class RetailCrmOrder
|
||||
return false;
|
||||
}
|
||||
|
||||
$dimensionsSetting = COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_DIMENSIONS, 'N');
|
||||
$optionsCurrency = COption::GetOptionString(self::$MODULE_ID, self::$CRM_CURRENCY, 0);
|
||||
$currency = $optionsCurrency ? $optionsCurrency : \Bitrix\Currency\CurrencyManager::getBaseCurrency();
|
||||
$dimensionsSetting = RetailcrmConfigProvider::getOrderDimensions();
|
||||
$currency = RetailcrmConfigProvider::getCurrencyOrDefault();
|
||||
$optionCorpClient = RetailcrmConfigProvider::getCorporateClientStatus();
|
||||
|
||||
$order = array(
|
||||
'number' => $arFields['NUMBER'],
|
||||
'externalId' => $arFields['ID'],
|
||||
'createdAt' => $arFields['DATE_INSERT'],
|
||||
'customer' => array('externalId' => $arFields['USER_ID']),
|
||||
'customer' => isset($arParams['customerCorporate'])
|
||||
? array('id' => $arParams['customerCorporate']['id'])
|
||||
: array('externalId' => $arFields['USER_ID']),
|
||||
'orderType' => isset($arParams['optionsOrderTypes'][$arFields['PERSON_TYPE_ID']]) ?
|
||||
$arParams['optionsOrderTypes'][$arFields['PERSON_TYPE_ID']] : '',
|
||||
'status' => isset($arParams['optionsPayStatuses'][$arFields['STATUS_ID']]) ?
|
||||
@ -70,9 +49,27 @@ class RetailCrmOrder
|
||||
'cost' => $arFields['PRICE_DELIVERY']
|
||||
),
|
||||
);
|
||||
|
||||
if (isset($arParams['contactExId'])) {
|
||||
$order['contact']['externalId'] = $arParams['contactExId'];
|
||||
}
|
||||
|
||||
if (isset($arParams['orderCompany']) && !empty($arParams['orderCompany'])) {
|
||||
$company = $arParams['orderCompany'];
|
||||
|
||||
if (isset($company['id'])) {
|
||||
$order['company']['id'] = $company['id'];
|
||||
}
|
||||
|
||||
if (isset($company['name'])) {
|
||||
$order['contragent']['legalName'] = $company['name'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($send && isset($_COOKIE['_rc']) && $_COOKIE['_rc'] != '') {
|
||||
$order['customer']['browserId'] = $_COOKIE['_rc'];
|
||||
}
|
||||
|
||||
$order['contragent']['contragentType'] = $arParams['optionsContragentType'][$arFields['PERSON_TYPE_ID']];
|
||||
|
||||
if ($methodApi == 'ordersEdit') {
|
||||
@ -103,15 +100,18 @@ class RetailCrmOrder
|
||||
if ($arLoc) {
|
||||
$server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot();
|
||||
$countrys = array();
|
||||
|
||||
if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml')) {
|
||||
$countrysFile = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml');
|
||||
foreach ($countrysFile->country as $country) {
|
||||
$countrys[RCrmActions::fromJSON((string) $country->name)] = (string) $country->alpha;
|
||||
}
|
||||
}
|
||||
|
||||
$location = \Bitrix\Sale\Location\Name\LocationTable::getList(array(
|
||||
'filter' => array('=LOCATION_ID' => $arLoc['CITY_ID'], 'LANGUAGE_ID' => 'ru')
|
||||
))->fetch();
|
||||
|
||||
if (count($countrys) > 0) {
|
||||
$countryOrder = \Bitrix\Sale\Location\Name\LocationTable::getList(array(
|
||||
'filter' => array('=LOCATION_ID' => $arLoc['COUNTRY_ID'], 'LANGUAGE_ID' => 'ru')
|
||||
@ -156,7 +156,7 @@ class RetailCrmOrder
|
||||
|
||||
//basket
|
||||
foreach ($arFields['BASKET'] as $position => $product) {
|
||||
$externalId = $position ."_". $product['PRODUCT_ID'];
|
||||
$externalId = $position . "_" . $product['PRODUCT_ID'];
|
||||
if (isset($orderItems[$externalId])) { //update
|
||||
$externalIds = $orderItems[$externalId]['externalIds'];
|
||||
$key = array_search("bitrix", array_column($externalIds, 'code'));
|
||||
@ -181,7 +181,7 @@ class RetailCrmOrder
|
||||
}
|
||||
|
||||
$item = array(
|
||||
'externalIds' => $externalIds,
|
||||
'externalIds' => $externalIds,
|
||||
'quantity' => $product['QUANTITY'],
|
||||
'offer' => array('externalId' => $product['PRODUCT_ID'],
|
||||
'xmlId' => $product['PRODUCT_XML_ID']
|
||||
@ -287,10 +287,9 @@ class RetailCrmOrder
|
||||
$normalizer = new RestNormalizer();
|
||||
$order = $normalizer->normalize($order, 'orders');
|
||||
|
||||
$log = new Logger();
|
||||
$log->write($order, 'orderSend');
|
||||
Logger::getInstance()->write($order, 'orderSend');
|
||||
|
||||
if($send) {
|
||||
if ($send) {
|
||||
if (!RCrmActions::apiMethod($api, $methodApi, __METHOD__, $order, $site)) {
|
||||
return false;
|
||||
}
|
||||
@ -314,25 +313,18 @@ class RetailCrmOrder
|
||||
*/
|
||||
public static function uploadOrders($pSize = 50, $failed = false, $orderList = false)
|
||||
{
|
||||
if (!CModule::IncludeModule("iblock")) {
|
||||
RCrmActions::eventLog('RetailCrmOrder::uploadOrders', 'iblock', 'module not found');
|
||||
return true;
|
||||
}
|
||||
if (!CModule::IncludeModule("sale")) {
|
||||
RCrmActions::eventLog('RetailCrmOrder::uploadOrders', 'sale', 'module not found');
|
||||
return true;
|
||||
}
|
||||
if (!CModule::IncludeModule("catalog")) {
|
||||
RCrmActions::eventLog('RetailCrmOrder::uploadOrders', 'catalog', 'module not found');
|
||||
if (!RetailcrmDependencyLoader::loadDependencies()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$resOrders = array();
|
||||
$resCustomers = array();
|
||||
$resCustomersAdded = array();
|
||||
$resCustomersCorporate = array();
|
||||
$orderIds = array();
|
||||
|
||||
$lastUpOrderId = COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_LAST_ID, 0);
|
||||
$failedIds = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_FAILED_IDS, 0));
|
||||
$lastUpOrderId = RetailcrmConfigProvider::getLastOrderId();
|
||||
$failedIds = RetailcrmConfigProvider::getFailedOrdersIds();
|
||||
|
||||
if ($failed == true && $failedIds !== false && count($failedIds) > 0) {
|
||||
$orderIds = $failedIds;
|
||||
@ -345,6 +337,7 @@ class RetailCrmOrder
|
||||
'limit' => $pSize,
|
||||
'select' => array('ID')
|
||||
));
|
||||
|
||||
while ($arOrder = $dbOrder->fetch()) {
|
||||
$orderIds[] = $arOrder['ID'];
|
||||
}
|
||||
@ -354,21 +347,30 @@ class RetailCrmOrder
|
||||
return false;
|
||||
}
|
||||
|
||||
$api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0);
|
||||
$api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0);
|
||||
$optionsSitesList = RetailcrmConfigProvider::getSitesList();
|
||||
$optionsOrderTypes = RetailcrmConfigProvider::getOrderTypes();
|
||||
$optionsDelivTypes = RetailcrmConfigProvider::getDeliveryTypes();
|
||||
$optionsPayTypes = RetailcrmConfigProvider::getPaymentTypes();
|
||||
$optionsPayStatuses = RetailcrmConfigProvider::getPaymentStatuses(); // --statuses
|
||||
$optionsPayment = RetailcrmConfigProvider::getPayment();
|
||||
$optionsOrderProps = RetailcrmConfigProvider::getOrderProps();
|
||||
$optionsLegalDetails = RetailcrmConfigProvider::getLegalDetails();
|
||||
$optionsContragentType = RetailcrmConfigProvider::getContragentTypes();
|
||||
$optionsCustomFields = RetailcrmConfigProvider::getCustomFields();
|
||||
|
||||
$optionsSitesList = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_SITES_LIST, 0));
|
||||
$optionsOrderTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_TYPES_ARR, 0));
|
||||
$optionsDelivTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_DELIVERY_TYPES_ARR, 0));
|
||||
$optionsPayTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_TYPES, 0));
|
||||
$optionsPayStatuses = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_STATUSES, 0)); // --statuses
|
||||
$optionsPayment = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT, 0));
|
||||
$optionsOrderProps = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_PROPS, 0));
|
||||
$optionsLegalDetails = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_LEGAL_DETAILS, 0));
|
||||
$optionsContragentType = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_CONTRAGENT_TYPE, 0));
|
||||
$optionsCustomFields = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_CUSTOM_FIELDS, 0));
|
||||
$getSite = function ($key) use ($optionsSitesList) {
|
||||
if ($optionsSitesList) {
|
||||
if (array_key_exists($key, $optionsSitesList) && $optionsSitesList[$key] != null) {
|
||||
return $optionsSitesList[$key];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$api = new RetailCrm\ApiClient($api_host, $api_key);
|
||||
return null;
|
||||
};
|
||||
|
||||
$api = new RetailCrm\ApiClient(RetailcrmConfigProvider::getApiUrl(), RetailcrmConfigProvider::getApiKey());
|
||||
|
||||
$arParams = array(
|
||||
'optionsOrderTypes' => $optionsOrderTypes,
|
||||
@ -384,72 +386,222 @@ class RetailCrmOrder
|
||||
);
|
||||
|
||||
$recOrders = array();
|
||||
|
||||
foreach ($orderIds as $orderId) {
|
||||
$site = null;
|
||||
$id = \Bitrix\Sale\Order::load($orderId);
|
||||
|
||||
if (!$id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$arCustomer = array();
|
||||
$arCustomerCorporate = array();
|
||||
$order = self::orderObjToArr($id);
|
||||
$user = Bitrix\Main\UserTable::getById($order['USER_ID'])->fetch();
|
||||
$site = $getSite($order['LID']);
|
||||
|
||||
$arCustomers = RetailCrmUser::customerSend($user, $api, $optionsContragentType[$order['PERSON_TYPE_ID']], false, $site);
|
||||
$arOrders = self::orderSend($order, $api, $arParams, false, $site);
|
||||
|
||||
if (!$arCustomers || !$arOrders) {
|
||||
if (true === $site) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$resCustomers[$order['LID']][] = $arCustomers;
|
||||
$resOrders[$order['LID']][] = $arOrders;
|
||||
if ("Y" == RetailcrmConfigProvider::getCorporateClientStatus()
|
||||
&& $optionsContragentType[$order['PERSON_TYPE_ID']] == 'legal-entity'
|
||||
) {
|
||||
// TODO check if order is corporate, and if it IS - make corporate order
|
||||
$arCustomer = RetailCrmUser::customerSend(
|
||||
$user,
|
||||
$api,
|
||||
'individual',
|
||||
false,
|
||||
$site
|
||||
);
|
||||
|
||||
$arCustomerCorporate = RetailCrmCorporateClient::clientSend(
|
||||
$order,
|
||||
$api,
|
||||
'legal-entity',
|
||||
false,
|
||||
true,
|
||||
$site
|
||||
);
|
||||
|
||||
$arParams['orderCompany'] = isset($arCustomerCorporate['companies'])
|
||||
? reset($arCustomerCorporate['companies']) : null;
|
||||
$arParams['contactExId'] = $user['ID'];
|
||||
} else {
|
||||
$arCustomer = RetailCrmUser::customerSend(
|
||||
$user,
|
||||
$api,
|
||||
$optionsContragentType[$order['PERSON_TYPE_ID']],
|
||||
false,
|
||||
$site
|
||||
);
|
||||
|
||||
if (isset($arParams['contactExId'])) {
|
||||
unset($arParams['contactExId']);
|
||||
}
|
||||
}
|
||||
|
||||
$arOrders = self::orderSend($order, $api, $arParams, false, $site);
|
||||
|
||||
if (!$arCustomer || !$arOrders) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($arCustomerCorporate) && !empty($arCustomerCorporate['nickName'])) {
|
||||
$resCustomersCorporate[$arCustomerCorporate['nickName']] = $arCustomerCorporate;
|
||||
}
|
||||
|
||||
$email = isset($arCustomer['email']) ? $arCustomer['email'] : '';
|
||||
|
||||
if (!in_array($email, $resCustomersAdded)) {
|
||||
$resCustomersAdded[] = $email;
|
||||
$resCustomers[$order['LID']][] = $arCustomer;
|
||||
}
|
||||
|
||||
$resOrders[$order['LID']][] = $arOrders;
|
||||
$recOrders[] = $orderId;
|
||||
}
|
||||
|
||||
if (count($resOrders) > 0) {
|
||||
foreach ($resCustomers as $key => $customerLoad) {
|
||||
if ($optionsSitesList) {
|
||||
if (array_key_exists($key, $optionsSitesList) && $optionsSitesList[$key] != null) {
|
||||
$site = $optionsSitesList[$key];
|
||||
} else {
|
||||
$uploadItems = function ($pack, $method) use ($getSite, $api, $optionsSitesList) {
|
||||
$uploaded = array();
|
||||
|
||||
foreach ($pack as $key => $itemLoad) {
|
||||
$site = $getSite($key);
|
||||
|
||||
if (true === $site) {
|
||||
continue;
|
||||
}
|
||||
} elseif (!$optionsSitesList) {
|
||||
$site = null;
|
||||
}
|
||||
if (RCrmActions::apiMethod($api, 'customersUpload', __METHOD__, $customerLoad, $site) === false) {
|
||||
return false;
|
||||
}
|
||||
if (count($optionsSitesList) > 1) {
|
||||
time_nanosleep(0, 250000000);
|
||||
}
|
||||
}
|
||||
foreach ($resOrders as $key => $orderLoad) {
|
||||
if ($optionsSitesList) {
|
||||
if (array_key_exists($key, $optionsSitesList) && $optionsSitesList[$key] != null) {
|
||||
$site = $optionsSitesList[$key];
|
||||
} else {
|
||||
continue;
|
||||
|
||||
/** @var \RetailCrm\Response\ApiResponse|bool $response */
|
||||
$response = RCrmActions::apiMethod(
|
||||
$api,
|
||||
$method,
|
||||
__METHOD__,
|
||||
$itemLoad,
|
||||
$site
|
||||
);
|
||||
|
||||
if ($response === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($response instanceof \RetailCrm\Response\ApiResponse) {
|
||||
if ($response->offsetExists('uploadedCustomers')) {
|
||||
$uploaded = array_merge($uploaded, $response['uploadedCustomers']);
|
||||
}
|
||||
|
||||
if ($response->offsetExists('uploadedOrders')) {
|
||||
$uploaded = array_merge($uploaded, $response['uploadedOrders']);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($optionsSitesList) > 1) {
|
||||
time_nanosleep(0, 250000000);
|
||||
}
|
||||
} elseif (!$optionsSitesList) {
|
||||
$site = null;
|
||||
}
|
||||
if (RCrmActions::apiMethod($api, 'ordersUpload', __METHOD__, $orderLoad, $site) === false) {
|
||||
return false;
|
||||
}
|
||||
if (count($optionsSitesList) > 1) {
|
||||
time_nanosleep(0, 250000000);
|
||||
|
||||
return $uploaded;
|
||||
};
|
||||
|
||||
if (false === $uploadItems($resCustomers, 'customersUpload')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ("Y" == RetailcrmConfigProvider::getCorporateClientStatus()) {
|
||||
$cachedCorporateIds = array();
|
||||
|
||||
foreach ($resOrders as $packKey => $pack) {
|
||||
foreach ($pack as $key => $orderData) {
|
||||
if (isset($orderData['contragent']['contragentType'])
|
||||
&& $orderData['contragent']['contragentType'] == 'legal-entity'
|
||||
&& !empty($orderData['contragent']['legalName'])
|
||||
) {
|
||||
if (isset($cachedCorporateIds[$orderData['contragent']['legalName']])) {
|
||||
$orderData['customer'] = array(
|
||||
'id' => $cachedCorporateIds[$orderData['contragent']['legalName']]
|
||||
);
|
||||
} else {
|
||||
$corpData = $api->customersCorporateList(array(
|
||||
'nickName' => array($orderData['contragent']['legalName'])
|
||||
));
|
||||
|
||||
if ($corpData
|
||||
&& $corpData->isSuccessful()
|
||||
&& $corpData->offsetExists('customersCorporate')
|
||||
&& !empty($corpData['customersCorporate'])
|
||||
) {
|
||||
$corpData = $corpData['customersCorporate'];
|
||||
$corpData = reset($corpData);
|
||||
|
||||
$orderData['customer'] = array('id' => $corpData['id']);
|
||||
$cachedCorporateIds[$orderData['contragent']['legalName']] = $corpData['id'];
|
||||
|
||||
RetailCrmCorporateClient::addCustomersCorporateAddresses(
|
||||
$orderData['customer']['id'],
|
||||
$orderData['contragent']['legalName'],
|
||||
$orderData['delivery']['address']['text'],
|
||||
$api,
|
||||
$site = null
|
||||
);
|
||||
} elseif (array_key_exists(
|
||||
$orderData['contragent']['legalName'],
|
||||
$resCustomersCorporate
|
||||
)) {
|
||||
$createResponse = $api
|
||||
->customersCorporateCreate(
|
||||
$resCustomersCorporate[$orderData['contragent']['legalName']]
|
||||
);
|
||||
|
||||
if ($createResponse && $createResponse->isSuccessful()) {
|
||||
$orderData['customer'] = array('id' => $createResponse['id']);
|
||||
$cachedCorporateIds[$orderData['contragent']['legalName']]
|
||||
= $createResponse['id'];
|
||||
}
|
||||
}
|
||||
|
||||
time_nanosleep(0, 250000000);
|
||||
}
|
||||
|
||||
$pack[$key] = $orderData;
|
||||
}
|
||||
}
|
||||
|
||||
$resOrders[$packKey] = $pack;
|
||||
}
|
||||
}
|
||||
|
||||
if (false === $uploadItems($resOrders, 'ordersUpload')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($failed == true && $failedIds !== false && count($failedIds) > 0) {
|
||||
COption::SetOptionString(self::$MODULE_ID, self::$CRM_ORDER_FAILED_IDS, serialize(array_diff($failedIds, $recOrders)));
|
||||
RetailcrmConfigProvider::setFailedOrdersIds(array_diff($failedIds, $recOrders));
|
||||
} elseif ($lastUpOrderId < max($recOrders) && $orderList === false) {
|
||||
COption::SetOptionString(self::$MODULE_ID, self::$CRM_ORDER_LAST_ID, max($recOrders));
|
||||
RetailcrmConfigProvider::setLastOrderId(max($recOrders));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if provided order array is corporate order data
|
||||
*
|
||||
* @param array|\ArrayAccess $order
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isOrderCorporate($order)
|
||||
{
|
||||
return (is_array($order) || $order instanceof ArrayAccess)
|
||||
&& isset($order['customer'])
|
||||
&& isset($order['customer']['type'])
|
||||
&& $order['customer']['type'] == 'customer_corporate';
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts order object to array
|
||||
*
|
||||
@ -478,10 +630,11 @@ class RetailCrmOrder
|
||||
'BASKET' => array(),
|
||||
'USER_DESCRIPTION' => $obOrder->getField('USER_DESCRIPTION'),
|
||||
'COMMENTS' => $obOrder->getField('COMMENTS'),
|
||||
'REASON_CANCELED' => $obOrder->getField('REASON_CANCELED'),
|
||||
'REASON_CANCELED' => $obOrder->getField('REASON_CANCELED')
|
||||
);
|
||||
|
||||
$shipmentList = $obOrder->getShipmentCollection();
|
||||
|
||||
foreach ($shipmentList as $shipmentData) {
|
||||
if ($shipmentData->isSystem()) {
|
||||
continue;
|
||||
@ -506,11 +659,13 @@ class RetailCrmOrder
|
||||
}
|
||||
|
||||
$paymentList = $obOrder->getPaymentCollection();
|
||||
|
||||
foreach ($paymentList as $paymentData) {
|
||||
$arOrder['PAYMENTS'][] = $paymentData->getFields()->getValues();
|
||||
}
|
||||
|
||||
$basketItems = $obOrder->getBasket();
|
||||
|
||||
foreach ($basketItems as $item) {
|
||||
$arOrder['BASKET'][] = $item->getFields();
|
||||
}
|
||||
|
@ -50,8 +50,6 @@ class RetailCrmPrices
|
||||
}
|
||||
|
||||
if (count($infoBlocks) > 0) {
|
||||
$log = new Logger();
|
||||
|
||||
foreach ($infoBlocks as $id) {
|
||||
$iblockOffer = CCatalogSKU::GetInfoByProductIBlock($id);
|
||||
|
||||
@ -133,7 +131,7 @@ class RetailCrmPrices
|
||||
//for log
|
||||
$splitedItems = array_chunk($pricesUpload, 200);
|
||||
foreach ($splitedItems as $chunk) {
|
||||
$log->write($chunk, 'storePricesUpload');
|
||||
Logger::getInstance()->write($chunk, 'storePricesUpload');
|
||||
|
||||
foreach ($shops as $shop) {
|
||||
RCrmActions::apiMethod($api, 'storePricesUpload', __METHOD__, $chunk, $shop);
|
||||
|
@ -0,0 +1,157 @@
|
||||
<?php
|
||||
IncludeModuleLangFile(__FILE__);
|
||||
class RetailCrmCorporateClient
|
||||
{
|
||||
public static function clientSend($arOrder, $api, $contragentType, $send = false, $fillCorp = false, $site = null)
|
||||
{
|
||||
if (!$api || empty($contragentType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$address = array();
|
||||
$contragent = array();
|
||||
$shops = RetailcrmConfigProvider::getSitesListCorporate();
|
||||
$optionsLegalDetails = RetailcrmConfigProvider::getLegalDetails();
|
||||
|
||||
$arUser = Bitrix\Main\UserTable::getById($arOrder['USER_ID'])->fetch();
|
||||
|
||||
if (count($shops) == 0) {
|
||||
RCrmActions::eventLog('RetailCrmCorporateClient::clientSend()', '$shops', 'No stores selected for download');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($arOrder['PROPS']['properties'] as $prop) {
|
||||
if ($prop['CODE'] == RetailcrmConfigProvider::getCorporateClientName()) {
|
||||
$nickName = $prop['VALUE'][0];
|
||||
}
|
||||
|
||||
if ($prop['CODE'] == RetailcrmConfigProvider::getCorporateClientAddress()) {
|
||||
$address = $prop['VALUE'][0];
|
||||
}
|
||||
|
||||
if (!empty($optionsLegalDetails)
|
||||
&& $search = array_search($prop['CODE'], $optionsLegalDetails[$arOrder['PERSON_TYPE_ID']])
|
||||
) {
|
||||
$contragent[$search] = $prop['VALUE'][0];//legal order data
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($nickName)) {
|
||||
$nickName = $arUser['WORK_COMPANY'];
|
||||
}
|
||||
|
||||
if (!empty($contragentType)) {
|
||||
$contragent['contragentType'] = $contragentType;
|
||||
}
|
||||
|
||||
foreach ($shops as $shop) {
|
||||
$customerCorporate = array(
|
||||
'createdAt' => $arOrder['DATE_INSERT'],
|
||||
"nickName" => $nickName,
|
||||
);
|
||||
|
||||
if ($fillCorp) {
|
||||
$customerCorporate = array_merge(
|
||||
$customerCorporate,
|
||||
array(
|
||||
'customerContacts' => array(
|
||||
array(
|
||||
'isMain' => true,
|
||||
'customer' => array(
|
||||
'externalId' => $arUser['ID'],
|
||||
'site' => $shop
|
||||
)
|
||||
)
|
||||
),
|
||||
'companies' => array(
|
||||
array(
|
||||
'name' => $nickName,
|
||||
'isMain' => true,
|
||||
)
|
||||
),
|
||||
'addresses' => array(
|
||||
array(
|
||||
'name' => $nickName,
|
||||
'isMain' => true,
|
||||
'text' => $address
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($customerCorporate)) {
|
||||
if ($send && isset($_COOKIE['_rc']) && $_COOKIE['_rc'] != '') {
|
||||
$customerCorporate['browserId'] = $_COOKIE['_rc'];
|
||||
}
|
||||
|
||||
$normalizer = new RestNormalizer();
|
||||
$customerCorporate = $normalizer->normalize($customerCorporate, 'customerCorporate');
|
||||
|
||||
Logger::getInstance()->write($customerCorporate, 'clientCorporate');
|
||||
|
||||
if ($send) {
|
||||
$result = RCrmActions::apiMethod($api, 'customersCorporateCreate', __METHOD__, $customerCorporate, $site);
|
||||
if (!$result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$customerCorporate['id'] = $result['id'];
|
||||
}
|
||||
|
||||
return $customerCorporate;
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
public static function addCustomersCorporateAddresses($customeId, $legalName, $adress, $api, $site)
|
||||
{
|
||||
$found = false;
|
||||
$addresses = $api->customersCorporateAddresses(
|
||||
$customeId,
|
||||
array(),
|
||||
null,
|
||||
100,
|
||||
'id',
|
||||
$site
|
||||
);
|
||||
|
||||
if ($addresses && $addresses->isSuccessful() && $addresses->offsetExists('addresses')) {
|
||||
foreach ($addresses['addresses'] as $corpAddress) {
|
||||
if (isset($corpAddress['text']) && $corpAddress['text'] == $adress) {
|
||||
$found = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found) {
|
||||
$customerCorporateAddress = array(
|
||||
'name' => $legalName,
|
||||
'text' => $adress
|
||||
);
|
||||
|
||||
$addressResult = $api->customersCorporateAddressesCreate(
|
||||
$customeId,
|
||||
$customerCorporateAddress,
|
||||
'id',
|
||||
$site
|
||||
);
|
||||
|
||||
if (!$addressResult || ($addressResult && !$addressResult->isSuccessful())) {
|
||||
Logger::getInstance()->write(sprintf(
|
||||
'error while trying to append address to corporate customer%s%s',
|
||||
PHP_EOL,
|
||||
print_r(array(
|
||||
'address' => $customerCorporateAddress,
|
||||
'customer' => $customeId
|
||||
), true)
|
||||
), 'apiErrors');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ class RetailCrmUser
|
||||
'externalId' => $arFields['ID'],
|
||||
'email' => $arFields['EMAIL'],
|
||||
'createdAt' => new \DateTime($arFields['DATE_REGISTER']),
|
||||
'subscribed' => false,
|
||||
'contragent' => array(
|
||||
'contragentType' => $contragentType
|
||||
)
|
||||
@ -66,8 +67,7 @@ class RetailCrmUser
|
||||
$normalizer = new RestNormalizer();
|
||||
$customer = $normalizer->normalize($customer, 'customers');
|
||||
|
||||
$log = new Logger();
|
||||
$log->write($customer, 'customerSend');
|
||||
Logger::getInstance()->write($customer, 'customerSend');
|
||||
|
||||
if ($send) {
|
||||
if (!RCrmActions::apiMethod($api, 'customersCreate', __METHOD__, $customer, $site)) {
|
||||
@ -148,8 +148,7 @@ class RetailCrmUser
|
||||
}
|
||||
}
|
||||
|
||||
$log = new Logger();
|
||||
$log->write($customer, 'customerSend');
|
||||
Logger::getInstance()->write($customer, 'customerSend');
|
||||
|
||||
RCrmActions::apiMethod($api, 'customersEdit', __METHOD__, $customer, $site);
|
||||
}
|
||||
|
@ -1,2 +1 @@
|
||||
- Улучшена работа со скидками
|
||||
- Добавлен сброс закупочной цены в icml при её отсутствии
|
||||
- Добавлена поддержка корпоративных клиентов
|
||||
|
@ -5,6 +5,7 @@ $version = COption::GetOptionString('intaro.retailcrm', 'api_version');
|
||||
CModule::AddAutoloadClasses(
|
||||
'intaro.retailcrm', // module name
|
||||
array (
|
||||
'RetailcrmDependencyLoader' => 'classes/general/RetailcrmDependencyLoader.php',
|
||||
'RestNormalizer' => file_exists($server . '/bitrix/php_interface/retailcrm/RestNormalizer.php') ? '../../php_interface/retailcrm/RestNormalizer.php' : 'classes/general/RestNormalizer.php',
|
||||
'Logger' => file_exists($server . '/bitrix/php_interface/retailcrm/Logger.php') ? '../../php_interface/retailcrm/Logger.php' : 'classes/general/Logger.php',
|
||||
'RetailCrm\ApiClient' => file_exists($server . '/bitrix/php_interface/retailcrm/ApiClient.php') ? '../../php_interface/retailcrm/ApiClient.php' : 'classes/general/ApiClient_' . $version . '.php',
|
||||
@ -22,5 +23,8 @@ CModule::AddAutoloadClasses(
|
||||
'RetailCrm\Response\ApiResponse' => 'classes/general/Response/ApiResponse.php',
|
||||
'RetailCrm\Exception\InvalidJsonException' => 'classes/general/Exception/InvalidJsonException.php',
|
||||
'RetailCrm\Exception\CurlException' => 'classes/general/Exception/CurlException.php',
|
||||
'RetailCrmCorporateClient' => file_exists($server . '/bitrix/php_interface/retailcrm/RetailCrmCorporateClient.php') ? '../../php_interface/retailcrm/RetailCrmCorporateClient.php' : 'classes/general/user/RetailCrmCorporateClient.php',
|
||||
'RetailcrmConfigProvider' => 'classes/general/RetailcrmConfigProvider.php',
|
||||
'RetailcrmConstants' => 'classes/general/RetailcrmConstants.php',
|
||||
)
|
||||
);
|
||||
|
@ -89,6 +89,20 @@ class intaro_retailcrm extends CModule
|
||||
$this->PARTNER_URI = GetMessage('MODULE_PARTNER_URI');
|
||||
}
|
||||
|
||||
function loadDeps()
|
||||
{
|
||||
if (!class_exists('RetailcrmConstants')) {
|
||||
require_once dirname(__FILE__) . '/../classes/general/RetailcrmConstants.php';
|
||||
}
|
||||
if (!class_exists('RetailcrmConfigProvider')) {
|
||||
require_once dirname(__FILE__) . '/../classes/general/RetailcrmConfigProvider.php';
|
||||
}
|
||||
|
||||
if (!class_exists('RetailcrmDependencyLoader')) {
|
||||
require_once dirname(__FILE__) . '/../classes/general/RetailcrmDependencyLoader.php';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Functions DoInstall and DoUninstall are
|
||||
* All other functions are optional
|
||||
@ -564,6 +578,7 @@ class intaro_retailcrm extends CModule
|
||||
&& $_POST['ajax'] == 1
|
||||
) {
|
||||
$historyTime = Date('');
|
||||
self::loadDeps();
|
||||
RetailCrmOrder::uploadOrders(); // each 50
|
||||
|
||||
$lastUpOrderId = COption::GetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0);
|
||||
@ -745,6 +760,12 @@ class intaro_retailcrm extends CModule
|
||||
$arResult['PRICE_TYPES'][$arPriceType['ID']] = $arPriceType;
|
||||
}
|
||||
|
||||
if (isset($_POST['back']) && $_POST['back']) {
|
||||
$APPLICATION->IncludeAdminFile(
|
||||
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step3.php'
|
||||
);
|
||||
}
|
||||
|
||||
$APPLICATION->IncludeAdminFile(
|
||||
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step5.php'
|
||||
);
|
||||
@ -769,7 +790,7 @@ class intaro_retailcrm extends CModule
|
||||
|
||||
if (isset($_POST['back']) && $_POST['back']) {
|
||||
$APPLICATION->IncludeAdminFile(
|
||||
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step3.php'
|
||||
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step4.php'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,13 @@
|
||||
|
||||
if(isset($arResult['errCode']) && $arResult['errCode'])
|
||||
echo CAdminMessage::ShowMessage(GetMessage($arResult['errCode']));
|
||||
|
||||
$MODULE_ID = 'intaro.retailcrm';
|
||||
$CRM_API_HOST_OPTION = 'api_host';
|
||||
$CRM_API_KEY_OPTION = 'api_key';
|
||||
|
||||
$arResult['API_HOST'] = COption::GetOptionString($MODULE_ID, $CRM_API_HOST_OPTION);
|
||||
$arResult['API_KEY'] = COption::GetOptionString($MODULE_ID, $CRM_API_KEY_OPTION);
|
||||
?>
|
||||
|
||||
<div class="adm-detail-content-item-block">
|
||||
|
@ -3,7 +3,58 @@ IncludeModuleLangFile(__FILE__);
|
||||
|
||||
$MODULE_ID = 'intaro.retailcrm';
|
||||
$CRM_API_HOST_OPTION = 'api_host';
|
||||
$CRM_API_KEY_OPTION = 'api_key';
|
||||
$CRM_SITES_LIST= 'sites_list';
|
||||
$CRM_PAYMENT_TYPES = 'pay_types_arr';
|
||||
$CRM_DELIVERY_TYPES_ARR = 'deliv_types_arr';
|
||||
$CRM_PAYMENT_TYPES = 'pay_types_arr';
|
||||
$CRM_PAYMENT_STATUSES = 'pay_statuses_arr';
|
||||
$CRM_PAYMENT = 'payment_arr';
|
||||
$CRM_ORDER_TYPES_ARR = 'order_types_arr';
|
||||
$api_host = COption::GetOptionString($MODULE_ID, $CRM_API_HOST_OPTION, 0);
|
||||
$api_key = COption::GetOptionString($MODULE_ID, $CRM_API_KEY_OPTION, 0);
|
||||
$arResult['arSites'] = RCrmActions::SitesList();
|
||||
|
||||
$RETAIL_CRM_API = new \RetailCrm\ApiClient($api_host, $api_key);
|
||||
COption::SetOptionString($MODULE_ID, $CRM_API_HOST_OPTION, $api_host);
|
||||
COption::SetOptionString($MODULE_ID, $CRM_API_KEY_OPTION, $api_key);
|
||||
COption::SetOptionString($MODULE_ID, $CRM_SITES_LIST, serialize(array()));
|
||||
|
||||
if (!isset($arResult['PAYMENT'])) {
|
||||
$arResult['PAYMENT'] = unserialize(COption::GetOptionString($MODULE_ID, $CRM_PAYMENT, 0));
|
||||
}
|
||||
|
||||
if (!isset($arResult['ORDER_TYPES'])) {
|
||||
$arResult['ORDER_TYPES'] = unserialize(COption::GetOptionString($MODULE_ID, $CRM_ORDER_TYPES_ARR, 0));
|
||||
}
|
||||
|
||||
if (!isset($arResult['paymentTypesList'])) {
|
||||
$arResult['bitrixPaymentTypesList'] = RCrmActions::PaymentList();
|
||||
$arResult['paymentTypesList'] = $RETAIL_CRM_API->paymentTypesList()->paymentTypes;
|
||||
$arResult['PAYMENT_TYPES'] = unserialize(COption::GetOptionString($MODULE_ID, $CRM_PAYMENT_TYPES, 0));
|
||||
}
|
||||
|
||||
if (!isset($arResult['bitrixStatusesList'])) {
|
||||
$arResult['bitrixStatusesList'] = RCrmActions::StatusesList();
|
||||
$arResult['paymentList'] = $RETAIL_CRM_API->statusesList()->statuses;
|
||||
$arResult['paymentGroupList'] = $RETAIL_CRM_API->statusGroupsList()->statusGroups;
|
||||
}
|
||||
|
||||
if (!isset($arResult['orderTypesList'])) {
|
||||
$arResult['bitrixOrderTypesList'] = RCrmActions::OrderTypesList($arResult['arSites']);
|
||||
$arResult['orderTypesList'] = $RETAIL_CRM_API->orderTypesList()->orderTypes;
|
||||
}
|
||||
|
||||
if (!isset($arResult['paymentStatusesList'])) {
|
||||
$arResult['paymentStatusesList'] = $RETAIL_CRM_API->paymentStatusesList()->paymentStatuses;
|
||||
$arResult['PAYMENT_STATUSES'] = unserialize(COption::GetOptionString($MODULE_ID, $CRM_PAYMENT_STATUSES, 0));
|
||||
}
|
||||
|
||||
if (!isset($arResult['bitrixDeliveryTypesList'])) {
|
||||
$arResult['bitrixDeliveryTypesList'] = RCrmActions::DeliveryList();
|
||||
$arResult['deliveryTypesList'] = $RETAIL_CRM_API->deliveryTypesList()->deliveryTypes;
|
||||
$arResult['DELIVERY_TYPES'] = unserialize(COption::GetOptionString($MODULE_ID, $CRM_DELIVERY_TYPES_ARR, 0));
|
||||
}
|
||||
|
||||
//bitrix pyament Y/N
|
||||
$arResult['bitrixPaymentList'][0]['NAME'] = GetMessage('PAYMENT_Y');
|
||||
|
@ -3,6 +3,36 @@ if (!check_bitrix_sessid())
|
||||
return;
|
||||
IncludeModuleLangFile(__FILE__);
|
||||
|
||||
$MODULE_ID = 'intaro.retailcrm';
|
||||
$CRM_API_HOST_OPTION = 'api_host';
|
||||
$CRM_API_KEY_OPTION = 'api_key';
|
||||
$CRM_SITES_LIST= 'sites_list';
|
||||
$CRM_ORDER_PROPS = 'order_props';
|
||||
$CRM_CONTRAGENT_TYPE = 'contragent_type';
|
||||
$CRM_LEGAL_DETAILS = 'legal_details';
|
||||
$api_host = COption::GetOptionString($MODULE_ID, $CRM_API_HOST_OPTION, 0);
|
||||
$api_key = COption::GetOptionString($MODULE_ID, $CRM_API_KEY_OPTION, 0);
|
||||
$arResult['arSites'] = RCrmActions::SitesList();
|
||||
|
||||
$RETAIL_CRM_API = new \RetailCrm\ApiClient($api_host, $api_key);
|
||||
COption::SetOptionString($MODULE_ID, $CRM_API_HOST_OPTION, $api_host);
|
||||
COption::SetOptionString($MODULE_ID, $CRM_API_KEY_OPTION, $api_key);
|
||||
COption::SetOptionString($MODULE_ID, $CRM_SITES_LIST, serialize(array()));
|
||||
|
||||
if (!isset($arResult['bitrixOrderTypesList'])) {
|
||||
$arResult['bitrixOrderTypesList'] = RCrmActions::OrderTypesList($arResult['arSites']);
|
||||
$arResult['arProp'] = RCrmActions::OrderPropsList();
|
||||
$arResult['ORDER_PROPS'] = unserialize(COption::GetOptionString($MODULE_ID, $CRM_ORDER_PROPS, 0));
|
||||
}
|
||||
|
||||
if (!isset($arResult['LEGAL_DETAILS'])) {
|
||||
$arResult['LEGAL_DETAILS'] = unserialize(COption::GetOptionString($MODULE_ID, $CRM_LEGAL_DETAILS, 0));
|
||||
}
|
||||
|
||||
if (!isset($arResult['CONTRAGENT_TYPES'])) {
|
||||
$arResult['CONTRAGENT_TYPES'] = unserialize(COption::GetOptionString($MODULE_ID, $CRM_CONTRAGENT_TYPE, 0));
|
||||
}
|
||||
|
||||
if(isset($arResult['ORDER_PROPS'])){
|
||||
$defaultOrderProps = $arResult['ORDER_PROPS'];
|
||||
}
|
||||
@ -28,6 +58,27 @@ else{
|
||||
<script type="text/javascript" src="/bitrix/js/main/jquery/jquery-1.7.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
individual = $("[name='contragent-type-1']").val();
|
||||
legalEntity = $("[name='contragent-type-2']").val();
|
||||
|
||||
if (legalEntity != 'individual') {
|
||||
$('tr.legal-detail-2').each(function(){
|
||||
if($(this).hasClass(legalEntity)){
|
||||
$(this).show();
|
||||
$('.legal-detail-title-2').show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (individual != 'individual') {
|
||||
$('tr.legal-detail-1').each(function(){
|
||||
if($(this).hasClass(individual)){
|
||||
$(this).show();
|
||||
$('.legal-detail-title-1').show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$('input.addr').change(function(){
|
||||
splitName = $(this).attr('name').split('-');
|
||||
orderType = splitName[2];
|
||||
@ -42,7 +93,6 @@ else{
|
||||
splitName = $(this).attr('name').split('-');
|
||||
contragentType = $(this).val();
|
||||
orderType = splitName[2];
|
||||
|
||||
$('tr.legal-detail-' + orderType).hide();
|
||||
$('.legal-detail-title-' + orderType).hide();
|
||||
|
||||
|
@ -193,6 +193,7 @@ IncludeModuleLangFile(__FILE__);
|
||||
<br />
|
||||
<div style="padding: 1px 13px 2px; height:28px;">
|
||||
<div align="right" style="float:right; width:50%; position:relative;">
|
||||
<input type="submit" name="back" value="<?php echo GetMessage("MOD_PREV_STEP"); ?>" class="adm-btn-save">
|
||||
<input type="submit" name="inst" value="<?php echo GetMessage("MOD_NEXT_STEP"); ?>" class="adm-btn-save">
|
||||
</div>
|
||||
<div align="left" style="float:right; width:50%; position:relative; visible: none;">
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?
|
||||
$arModuleVersion = array(
|
||||
"VERSION" => "5.2.6",
|
||||
"VERSION_DATE" => "2020-04-15 17:27:00"
|
||||
"VERSION" => "5.3.0",
|
||||
"VERSION_DATE" => "2020-04-23 16:00:00"
|
||||
);
|
||||
|
@ -10,3 +10,4 @@ $MESS ['START_1'] = 'Начать выгрузку';
|
||||
$MESS ['START_2'] = 'Приостановить выгрузку';
|
||||
$MESS ['START_3'] = 'Возобновить выгрузку';
|
||||
$MESS ['MOD_NEXT_STEP'] = 'Следующий шаг';
|
||||
$MESS ['MOD_PREV_STEP'] = 'Предыдущий шаг';
|
@ -93,3 +93,8 @@ $MESS ['INDEX_UA'] = 'Индекс пользовательского парам
|
||||
|
||||
$MESS ['API_NOT_FOUND'] = 'Неверная версия API';
|
||||
$MESS ['API_NOT_WORK'] = 'Выбранная версия API не поддерживается';
|
||||
|
||||
$MESS['CORP_CLIENTE'] = 'Корпоративный клиент';
|
||||
$MESS['CORP_NAME'] = "Наименование";
|
||||
$MESS['CORP_ADRESS'] = "Адрес";
|
||||
$MESS['CORP_LABEL'] = "Магазины в которые будут грузиться корпоративные клиенты";
|
||||
|
@ -38,6 +38,13 @@ $CRM_COLL_KEY = 'coll_key';
|
||||
$CRM_UA = 'ua';
|
||||
$CRM_UA_KEYS = 'ua_keys';
|
||||
|
||||
$CRM_DISCOUNT_ROUND = 'discount_round';
|
||||
|
||||
$CRM_CC = 'cc';
|
||||
$CRM_CORP_SHOPS = 'shops-corporate';
|
||||
$CRM_CORP_NAME = 'nickName-corporate';
|
||||
$CRM_CORP_ADRES = 'adres-corporate';
|
||||
|
||||
$CRM_API_VERSION = 'api_version';
|
||||
|
||||
$CRM_CURRENCY = 'currency';
|
||||
@ -45,7 +52,6 @@ $CRM_ADDRESS_OPTIONS = 'address_options';
|
||||
$CRM_DIMENSIONS = 'order_dimensions';
|
||||
$PROTOCOL = 'protocol';
|
||||
|
||||
$CRM_DISCOUNT_ROUND = 'discount_round';
|
||||
$CRM_PURCHASE_PRICE_NULL = 'purchasePrice_null';
|
||||
|
||||
if(!CModule::IncludeModule('intaro.retailcrm') || !CModule::IncludeModule('sale') || !CModule::IncludeModule('iblock') || !CModule::IncludeModule('catalog'))
|
||||
@ -348,7 +354,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
$dateAgent->add($intAgent);
|
||||
|
||||
CAgent::AddAgent(
|
||||
"RetailCrmInventories::inventoriesUpload();", $mid, "N", 3600, // interval - 1 час
|
||||
"RetailCrmInventories::inventoriesUpload();", $mid, "N", 3600, // interval - 1 <EFBFBD><EFBFBD><EFBFBD>
|
||||
$dateAgent->format('d.m.Y H:i:s'), // date of first check
|
||||
"Y", // agent is active
|
||||
$dateAgent->format('d.m.Y H:i:s'), // date of first start
|
||||
@ -388,7 +394,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
$dateAgent->add($intAgent);
|
||||
|
||||
CAgent::AddAgent(
|
||||
"RetailCrmPrices::pricesUpload();", $mid, "N", 86400, // interval - 24 часа
|
||||
"RetailCrmPrices::pricesUpload();", $mid, "N", 86400, // interval - 24 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
$dateAgent->format('d.m.Y H:i:s'), // date of first check
|
||||
"Y", // agent is active
|
||||
$dateAgent->format('d.m.Y H:i:s'), // date of first start
|
||||
@ -447,11 +453,27 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
if (htmlspecialchars(trim($_POST['discount_round'])) == 'Y') {
|
||||
$discount_round = 'Y';
|
||||
RegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmDc", "add");
|
||||
} else {
|
||||
} else {
|
||||
$discount_round = 'N';
|
||||
UnRegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmDc", "add");
|
||||
}
|
||||
|
||||
//corporate-cliente
|
||||
if (htmlspecialchars(trim($_POST['corp-client'])) == 'Y') {
|
||||
$cc = 'Y';
|
||||
$bitrixCorpName = htmlspecialchars(trim($_POST['nickName-corporate']));
|
||||
$bitrixCorpAdres = htmlspecialchars(trim($_POST['adres-corporate']));
|
||||
function maskCorp($var) {
|
||||
return preg_match("/^shops-corporate/", $var);
|
||||
}
|
||||
$bitrixCorpShopsArr = str_replace('shops-corporate-', '', array_filter(array_keys($_POST), 'maskCorp'));
|
||||
|
||||
RegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmCc", "add");
|
||||
} else {
|
||||
$cc = 'N';
|
||||
UnRegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmCc", "add");
|
||||
}
|
||||
|
||||
//purchasePrice_null
|
||||
if (htmlspecialchars(trim($_POST['purchasePrice_null'])) == 'Y') {
|
||||
$purchasePrice_null = 'Y';
|
||||
@ -475,7 +497,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
echo CAdminMessage::ShowMessage(GetMessage('API_NOT_FOUND'));
|
||||
}
|
||||
|
||||
//запрос к апи с $version
|
||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD> <20> $version
|
||||
$crmUrl = htmlspecialchars(trim($_POST['api_host']));
|
||||
$apiKey = htmlspecialchars(trim($_POST['api_key']));
|
||||
|
||||
@ -538,6 +560,11 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
COption::SetOptionString($mid, $CRM_DISCOUNT_ROUND, $discount_round);
|
||||
COption::SetOptionString($mid, $CRM_PURCHASE_PRICE_NULL, $purchasePrice_null);
|
||||
|
||||
COption::SetOptionString($mid, $CRM_CC, $cc);
|
||||
COption::SetOptionString($mid, $CRM_CORP_SHOPS, serialize(RCrmActions::clearArr($bitrixCorpShopsArr)));
|
||||
COption::SetOptionString($mid, $CRM_CORP_NAME, serialize(RCrmActions::clearArr($bitrixCorpName)));
|
||||
COption::SetOptionString($mid, $CRM_CORP_ADRES, serialize(RCrmActions::clearArr($bitrixCorpAdres)));
|
||||
|
||||
$request = \Bitrix\Main\Application::getInstance()->getContext()->getRequest();
|
||||
|
||||
if ($request->isHttps() === true) {
|
||||
@ -632,6 +659,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
$optionStores = unserialize(COption::GetOptionString($mid, $CRM_STORES, 0));
|
||||
$optionShops = unserialize(COption::GetOptionString($mid, $CRM_SHOPS, 0));
|
||||
$optionIblocksInventories = unserialize(COption::GetOptionString($mid, $CRM_IBLOCKS_INVENTORIES, 0));
|
||||
$optionShopsCorporate = unserialize(COption::GetOptionString($mid, $CRM_SHOPS, 0));
|
||||
|
||||
$optionPricesUpload = COption::GetOptionString($mid, $CRM_PRICES_UPLOAD, 0);
|
||||
$optionPrices = unserialize(COption::GetOptionString($mid, $CRM_PRICES, 0));
|
||||
@ -647,6 +675,12 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
$optionDiscRound = COption::GetOptionString($mid, $CRM_DISCOUNT_ROUND, 0);
|
||||
$optionPricePrchaseNull = COption::GetOptionString($mid, $CRM_PURCHASE_PRICE_NULL, 0);
|
||||
|
||||
//corporate-cliente
|
||||
$optionCorpClient = COption::GetOptionString($mid, $CRM_CC, 0);
|
||||
$optionCorpShops = unserialize(COption::GetOptionString($mid, $CRM_CORP_SHOPS, 0));
|
||||
$optionsCorpComName = unserialize(COption::GetOptionString($mid, $CRM_CORP_NAME, 0));
|
||||
$optionsCorpAdres = unserialize(COption::GetOptionString($mid, $CRM_CORP_ADRES, 0));
|
||||
|
||||
$version = COption::GetOptionString($mid, $CRM_API_VERSION, 0);
|
||||
|
||||
//currency
|
||||
@ -745,16 +779,6 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
return true;
|
||||
});
|
||||
|
||||
$('.r-coll-button label').change(function(){
|
||||
if($(this).find('input').is(':checked') === true){
|
||||
$('tr.r-coll').show('slow');
|
||||
} else if($(this).find('input').is(':checked') === false){
|
||||
$('tr.r-coll').hide('slow');
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
$('.r-dc-button label').change(function(){
|
||||
if($(this).find('input').is(':checked') === true){
|
||||
$('tr.r-dc').show('slow');
|
||||
@ -765,6 +789,26 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
return true;
|
||||
});
|
||||
|
||||
$('.r-cc-button label').change(function(){
|
||||
if($(this).find('input').is(':checked') === true){
|
||||
$('tr.r-cc').show('slow');
|
||||
} else if($(this).find('input').is(':checked') === false){
|
||||
$('tr.r-cc').hide('slow');
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
$('.r-coll-button label').change(function(){
|
||||
if($(this).find('input').is(':checked') === true){
|
||||
$('tr.r-coll').show('slow');
|
||||
} else if($(this).find('input').is(':checked') === false){
|
||||
$('tr.r-coll').hide('slow');
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
$('.r-purchaseprice-button label').change(function() {
|
||||
if($(this).find('input').is(':checked') === true) {
|
||||
$('tr.r-purchaseprice').show('slow');
|
||||
@ -1291,6 +1335,221 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
<?php endforeach;?>
|
||||
<?php endif;?>
|
||||
|
||||
<tr class="heading r-coll-button">
|
||||
<td colspan="2" class="option-other-heading">
|
||||
<b>
|
||||
<label><input class="addr" type="checkbox" name="collector" value="Y" <?php if($optionCollector === 'Y') echo "checked"; ?>><?php echo GetMessage('DEMON_COLLECTOR'); ?></label>
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="r-coll" <?php if($optionCollector !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td class="option-head" colspan="2">
|
||||
<b><?php echo GetMessage('ICRM_SITES'); ?></b>
|
||||
</td>
|
||||
</tr>
|
||||
<?php foreach ($arResult['arSites'] as $sitesList): ?>
|
||||
<tr class="r-coll" <?php if($optionCollector !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td class="adm-detail-content-cell-l" width="50%"><?php echo GetMessage('DEMON_KEY'); ?> <?php echo $sitesList['NAME']; ?> (<?php echo $sitesList['LID']; ?>)</td>
|
||||
<td class="adm-detail-content-cell-r" width="50%">
|
||||
<input name="collector-id-<?echo $sitesList['LID'];?>" value="<?php echo $optionCollectorKeys[$sitesList['LID']]; ?>" type="text">
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
<tr class="heading r-ua-button">
|
||||
<td colspan="2" class="option-other-heading">
|
||||
<b>
|
||||
<label><input class="addr" type="checkbox" name="ua-integration" value="Y" <?php if($optionUa === 'Y') echo "checked"; ?>><?php echo GetMessage('UNIVERSAL_ANALYTICS'); ?></label>
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
<?php foreach ($arResult['arSites'] as $sitesList): ?>
|
||||
<tr class="r-ua" <?php if($optionUa !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td class="option-head" colspan="2">
|
||||
<b><?php echo $sitesList['NAME']; ?> (<?php echo $sitesList['LID']; ?>)</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="r-ua" <?php if($optionUa !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td class="adm-detail-content-cell-l" width="50%"><?php echo GetMessage('ID_UA'); ?></td>
|
||||
<td class="adm-detail-content-cell-r" width="50%">
|
||||
<input name="ua-id-<?echo $sitesList['LID'];?>" value="<?php echo $optionUaKeys[$sitesList['LID']]['ID']; ?>" type="text">
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="r-ua" <?php if($optionUa !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td class="adm-detail-content-cell-l" width="50%"><?php echo GetMessage('INDEX_UA'); ?></td>
|
||||
<td class="adm-detail-content-cell-r" width="50%">
|
||||
<input name="ua-index-<?echo $sitesList['LID'];?>" value="<?php echo $optionUaKeys[$sitesList['LID']]['INDEX']; ?>" type="text">
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
|
||||
<tr class="heading r-dc-button">
|
||||
<td colspan="2" class="option-other-heading">
|
||||
<b>
|
||||
<label><input class="addr" type="checkbox" name="discount_round" value="Y" <?php if($optionDiscRound === 'Y') echo "checked"; ?>><?php echo "Округление цены товара при сборе одинаковых товарных позиций" ?></label>
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="r-dc" <?php if($optionDiscRound !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td class="option-head" colspan="2">
|
||||
<b><?php echo "При включенной опции округление будет происходить в меньшую сторону" ?></b>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="heading r-cc-button">
|
||||
<td colspan="2" class="option-other-heading">
|
||||
<b>
|
||||
<label><input class="addr" type="checkbox" name="corp-client" value="Y" <?php if($optionCorpClient === 'Y') echo "checked"; ?>><?php echo GetMessage('CORP_CLIENTE'); ?></label>
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="r-cc" <?php if($optionCorpClient !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td width="50%" class="" name="<?php ?>">
|
||||
<?php echo GetMessage('CORP_NAME');?>
|
||||
</td>
|
||||
<td width="50%" class="">
|
||||
<select name="nickName-corporate" class="typeselect">
|
||||
<option value=""></option>
|
||||
<?php foreach ($arResult['arProp'][$bitrixOrderType['ID']] as $arProp): ?>
|
||||
<option value="<?php echo $arProp['CODE']; ?>" <?php if ($optionsCorpComName == $arProp['CODE']) echo 'selected'; ?>>
|
||||
<?php echo $arProp['NAME']; ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="r-cc" <?php if($optionCorpClient !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td width="50%" class="" name="<?php ?>">
|
||||
<?php echo GetMessage('CORP_ADRESS');?>
|
||||
</td>
|
||||
<td width="50%" class="">
|
||||
<select name="adres-corporate" class="typeselect">
|
||||
<option value=""></option>
|
||||
<?php foreach ($arResult['arProp'][$bitrixOrderType['ID']] as $arProp): ?>
|
||||
<option value="<?php echo $arProp['CODE']; ?>" <?php if ($optionsCorpAdres == $arProp['CODE']) echo 'selected'; ?>>
|
||||
<?php echo $arProp['NAME']; ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<<<<<<< HEAD
|
||||
<?php if ($optionInventotiesUpload === 'Y' || count($arResult['bitrixStoresExportList']) > 0) :?>
|
||||
<tr class="heading inventories-batton">
|
||||
<td colspan="2" class="option-other-heading">
|
||||
<b>
|
||||
<label><input class="addr" type="checkbox" name="inventories-upload" value="Y" <?php if($optionInventotiesUpload === 'Y') echo "checked"; ?>><?php echo GetMessage('INVENTORIES_UPLOAD'); ?></label>
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="inventories" <?php if($optionInventotiesUpload !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td colspan="2" class="option-head option-other-top option-other-bottom">
|
||||
<b><label><?php echo GetMessage('INVENTORIES'); ?></label></b>
|
||||
</td>
|
||||
</tr>
|
||||
<?php foreach ($arResult['bitrixStoresExportList'] as $catalogExportStore): ?>
|
||||
<tr class="inventories" <?php if($optionInventotiesUpload !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td width="50%" class="adm-detail-content-cell-l"><?php echo $catalogExportStore['TITLE'] ?></td>
|
||||
<td width="50%" class="adm-detail-content-cell-r">
|
||||
<select class="typeselect" name="stores-export-<?php echo $catalogExportStore['ID']?>">
|
||||
<option value=""></option>
|
||||
<?php foreach ($arResult['inventoriesList'] as $inventoriesList): ?>
|
||||
<option value="<?php echo $inventoriesList['code'] ?>" <?php if($optionStores[$catalogExportStore['ID']] == $inventoriesList['code']) echo 'selected="selected"'; ?>><?php echo $inventoriesList['name']?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<tr class="inventories" <?php if($optionInventotiesUpload !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td colspan="2" class="option-head option-other-top option-other-bottom">
|
||||
<b>
|
||||
<label><?php echo GetMessage('SHOPS_INVENTORIES_UPLOAD'); ?></label>
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
<?php foreach ($arResult['sitesList'] as $sitesList): ?>
|
||||
<tr class="inventories" align="center" <?php if($optionInventotiesUpload !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td colspan="2" class="option-other-center">
|
||||
<label><input class="addr" type="checkbox" name="shops-exoprt-<?echo $sitesList['code'];?>" value="Y" <?php if(in_array($sitesList['code'], $optionShops)) echo "checked"; ?>> <?php echo $sitesList['name'].' ('.$sitesList['code'].')'; ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
<tr class="inventories" <?php if($optionInventotiesUpload !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td colspan="2" class="option-head option-other-top option-other-bottom">
|
||||
<b>
|
||||
<label><?php echo GetMessage('IBLOCKS_UPLOAD'); ?></label>
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
<?php foreach ($arResult['bitrixIblocksExportList'] as $catalogExportIblock) :?>
|
||||
<tr class="inventories" align="center" <?php if($optionInventotiesUpload !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td colspan="2" class="option-other-center">
|
||||
<label><input class="addr" type="checkbox" name="iblocks-stores-<?echo $catalogExportIblock['ID'];?>" value="Y" <?php if(in_array($catalogExportIblock['ID'], $optionIblocksInventories)) echo "checked"; ?>> <?php echo '['. $catalogExportIblock['CODE']. '] ' . $catalogExportIblock['NAME'] . ' (' . $catalogExportIblock['LID'] . ')'; ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
<?php endif;?>
|
||||
<?php if ($optionPricesUpload === 'Y' || count($arResult['bitrixPricesExportList']) > 0) :?>
|
||||
<tr class="heading prices-batton">
|
||||
<td colspan="2" class="option-other-heading">
|
||||
<b>
|
||||
<label><input class="addr" type="checkbox" name="prices-upload" value="Y" <?php if($optionPricesUpload === 'Y') echo "checked"; ?>><?php echo GetMessage('PRICES_UPLOAD'); ?></label>
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="prices" <?php if($optionPricesUpload !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td colspan="2" class="option-head option-other-top option-other-bottom">
|
||||
<b>
|
||||
<label><?php echo GetMessage('PRICE_TYPES'); ?></label>
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
<?php foreach ($arResult['bitrixPricesExportList'] as $catalogExportPrice) :?>
|
||||
<tr class="prices" <?php if($optionPricesUpload !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td width="50%" class="adm-detail-content-cell-l"><?php echo $catalogExportPrice['NAME_LANG'] . ' (' . $catalogExportPrice['NAME'] . ')'; ?></td>
|
||||
<td width="50%" class="adm-detail-content-cell-r">
|
||||
<select class="typeselect" name="price-type-export-<?php echo $catalogExportPrice['ID'];?>">
|
||||
<option value=""></option>
|
||||
<?php foreach ($arResult['priceTypeList'] as $priceTypeList): ?>
|
||||
<option value="<?php echo $priceTypeList['code'] ?>" <?php if($optionPrices[$catalogExportPrice['ID']] == $priceTypeList['code']) echo 'selected="selected"'; ?>><?php echo $priceTypeList['name']?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
<tr class="prices" <?php if($optionPricesUpload !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td colspan="2" class="option-head option-other-top option-other-bottom">
|
||||
<b>
|
||||
<label><?php echo GetMessage('SHOPS_PRICES_UPLOAD'); ?></label>
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
<?php foreach ($arResult['sitesList'] as $sitesList): ?>
|
||||
<tr class="prices" align="center" <?php if($optionPricesUpload !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td colspan="2" class="option-other-center">
|
||||
<label><input class="addr" type="checkbox" name="shops-price-<?echo $sitesList['code'];?>" value="Y" <?php if(in_array($sitesList['code'], $optionPriceShops)) echo "checked"; ?>> <?php echo $sitesList['name'].' ('.$sitesList['code'].')'; ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
<tr class="prices" <?php if($optionPricesUpload !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td colspan="2" class="option-head option-other-top option-other-bottom">
|
||||
<b>
|
||||
<label><?php echo GetMessage('IBLOCKS_UPLOAD'); ?></label>
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
<?php foreach ($arResult['bitrixIblocksExportList'] as $catalogExportIblock) :?>
|
||||
<tr class="prices" align="center" <?php if($optionPricesUpload !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td colspan="2" class="option-other-center">
|
||||
<label><input class="addr" type="checkbox" name="iblocks-prices-<?echo $catalogExportIblock['ID'];?>" value="Y" <?php if(in_array($catalogExportIblock['ID'], $optionIblocksPrices)) echo "checked"; ?>> <?php echo '['. $catalogExportIblock['CODE']. '] ' . $catalogExportIblock['NAME'] . ' (' . $catalogExportIblock['LID'] . ')'; ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
<?php endif;?>
|
||||
|
||||
<tr class="heading r-coll-button">
|
||||
<td colspan="2" class="option-other-heading">
|
||||
<b>
|
||||
@ -1369,6 +1628,27 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
|
||||
=======
|
||||
>>>>>>> fix options
|
||||
<tr class="r-cc" <?php if($optionCorpClient !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td colspan="2" class="option-head option-other-top option-other-bottom">
|
||||
<b>
|
||||
<label><?php echo GetMessage('CORP_LABEL');?></label>
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="r-cc" <?php if($optionCorpClient !== 'Y') echo 'style="display: none;"'; ?>>
|
||||
<td width="50%" class="" name="<?php ?>" align="center">
|
||||
<?php foreach ($arResult['sitesList'] as $sitesList): ?>
|
||||
<td colspan="2" class="option-other-center">
|
||||
<label><input class="addr" type="checkbox" name="shops-corporate-<?echo $sitesList['code'];?>" value="Y" <?php if(in_array($sitesList['code'], $optionCorpShops)) echo "checked"; ?>> <?php echo $sitesList['name'].' ('.$sitesList['code'].')'; ?></label>
|
||||
</td>
|
||||
<?php endforeach;?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php endif;?>
|
||||
<?php $tabControl->Buttons(); ?>
|
||||
<input type="hidden" name="Update" value="Y" />
|
||||
|
Loading…
Reference in New Issue
Block a user