send corp client in CRM
This commit is contained in:
parent
bbfb2f600a
commit
9b1347e710
7 changed files with 1313 additions and 140 deletions
|
@ -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 customersСorporateСreate(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 customersСorporateUpload(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('customerCorporate' => 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
|
||||
*
|
||||
|
|
|
@ -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') {
|
||||
|
@ -440,8 +439,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,6 +450,7 @@ class RCrmActions
|
|||
case 'ordersEdit':
|
||||
case 'customersGet':
|
||||
case 'customersEdit':
|
||||
case 'customersСorporateGet':
|
||||
return self::proxy($api, $methodApi, $method, array($params, 'externalId', $site));
|
||||
|
||||
case 'paymentEditById':
|
||||
|
@ -469,7 +471,7 @@ class RCrmActions
|
|||
$result = call_user_func_array(array($api, $methodApi), $params);
|
||||
|
||||
if ($result->getStatusCode() !== 200 && $result->getStatusCode() !== 201) {
|
||||
if ($methodApi == 'ordersGet' || $methodApi == 'customersGet') {
|
||||
if ($methodApi == 'ordersGet' || $methodApi == 'customersGet' || $methodApi == 'customersСorporateGet') {
|
||||
$log->write(array(
|
||||
'api' => $version,
|
||||
'methodApi' => $methodApi,
|
||||
|
|
|
@ -169,6 +169,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 +220,10 @@
|
|||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "datetime",
|
||||
"format": "Y-m-d H:i:s"
|
||||
|
@ -453,9 +500,6 @@
|
|||
"house": {
|
||||
"type": "string"
|
||||
},
|
||||
"housing": {
|
||||
"type": "string"
|
||||
},
|
||||
"metro": {
|
||||
"type": "string"
|
||||
},
|
||||
|
|
|
@ -19,6 +19,8 @@ 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';
|
||||
|
||||
/**
|
||||
* @param $arFields
|
||||
|
@ -129,7 +131,7 @@ class RetailCrmEvent
|
|||
return false;
|
||||
}
|
||||
|
||||
//exists getParameter("ENTITY")
|
||||
//exists getParameter("ENTITY")
|
||||
if (method_exists($event, 'getId')) {
|
||||
$obOrder = $event;
|
||||
} elseif (method_exists($event, 'getParameter')) {
|
||||
|
@ -159,6 +161,9 @@ class RetailCrmEvent
|
|||
$optionsContragentType = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_CONTRAGENT_TYPE, 0));
|
||||
$optionsCustomFields = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_CUSTOM_FIELDS, 0));
|
||||
|
||||
//corp cliente swich
|
||||
$optionCorpClient = COption::GetOptionString(self::$MODULE_ID, self::$CRM_CC, 0);
|
||||
|
||||
$arParams = RCrmActions::clearArr(array(
|
||||
'optionsOrderTypes' => $optionsOrderTypes,
|
||||
'optionsDelivTypes' => $optionsDelivTypes,
|
||||
|
@ -192,15 +197,74 @@ 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');
|
||||
if ("Y" == $optionCorpClient && $optionsContragentType[$arOrder['PERSON_TYPE_ID']] == 'legal-entity') {
|
||||
//corparate cliente
|
||||
$corpName = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_CORP_NAME, 0));
|
||||
foreach ($arOrder['PROPS']['properties'] as $prop) {
|
||||
if ($prop['CODE'] == $corpName) {
|
||||
$nickName = $prop['VALUE'][0];
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
$response = $api->customersCorporateList(array('nickName' => array($nickName)));
|
||||
if ($response->getStatusCode() == 200) {
|
||||
$customersCorporate = $response['customersCorporate'];
|
||||
}
|
||||
|
||||
//TODO нужен фильтр по compani name
|
||||
foreach ($customersCorporate as $corp) {
|
||||
if ($nickName == $corp['nickName']) {
|
||||
$userCorp['customerCorporate'] = $corp;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//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, "individual", true, $site);
|
||||
if (!$resultUser) {
|
||||
RCrmActions::eventLog('RetailCrmEvent::orderSave', 'RetailCrmUser::customerSend', 'error during creating customer');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($userCorp['customerCorporate'])) {
|
||||
|
||||
$resultUserCorp = RetailCrmCorporateClient::clientSend($arOrder, $api, $optionsContragentType[$arOrder['PERSON_TYPE_ID']], true, $site);
|
||||
|
||||
$log = new Logger();
|
||||
$log->write($resultUserCorp, 'resultUserCorp');
|
||||
|
||||
if (!$resultUserCorp) {
|
||||
RCrmActions::eventLog('RetailCrmEvent::orderSave', 'RetailCrmCorporateClient::clientSend', 'error during creating client');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$arParams['customerCorporate'] = $resultUserCorp;
|
||||
|
||||
} else {
|
||||
$arParams['customerCorporate'] = $userCorp['customerCorporate'];
|
||||
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ class RetailCrmHistory
|
|||
public static $CRM_ORDER_FAILED_IDS = 'order_failed_ids';
|
||||
public static $CRM_ORDER_HISTORY = 'order_history';
|
||||
public static $CRM_CUSTOMER_HISTORY = 'customer_history';
|
||||
public static $CRM_CUSTOMER_CORPORATE_HISTORY = 'customer_corp_history';
|
||||
public static $CRM_CATALOG_BASE_PRICE = 'catalog_base_price';
|
||||
public static $CRM_ORDER_NUMBERS = 'order_numbers';
|
||||
public static $CRM_CANSEL_ORDER = 'cansel_order';
|
||||
|
@ -332,6 +333,12 @@ class RetailCrmHistory
|
|||
|
||||
if (isset($order['customer']['externalId']) && !is_numeric($order['customer']['externalId'])) {
|
||||
unset($order['customer']['externalId']);
|
||||
|
||||
if ($order['customer']['type'] == 'customer_corporate') {
|
||||
// TODO Устанавливать идентификатор пользователя равным идентификатору контактного лица для корректной синхронизщации данных пользователя
|
||||
//$order['customer']['externalId'] = $order['customer']['mainCustomerContact']['customer']['externalId'];
|
||||
$order['customer']['email'] = $order['email'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($order['externalId'])) {
|
||||
|
@ -607,6 +614,17 @@ class RetailCrmHistory
|
|||
}
|
||||
}
|
||||
|
||||
//corp-client
|
||||
$cFilter['isMain'] = true;
|
||||
$response = $api->customersCorporateCompanies($order['customer']['id'], $cFilter,null, null,'id');
|
||||
|
||||
if (isset($response['companies'])) {
|
||||
$companiesList = $response['companies'];
|
||||
foreach ($companiesList as $compani) {
|
||||
$companiProps = $compani['contragent'];
|
||||
}
|
||||
}
|
||||
|
||||
//optionsLegalDetails
|
||||
if ($optionsLegalDetails[$personType]) {
|
||||
foreach ($optionsLegalDetails[$personType] as $key => $orderProp) {
|
||||
|
@ -616,6 +634,9 @@ class RetailCrmHistory
|
|||
} elseif(array_key_exists($key, $order['contragent'])) {
|
||||
$somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']);
|
||||
self::setProp($somePropValue, RCrmActions::fromJSON($order['contragent'][$key]));
|
||||
} elseif (array_key_exists($key, $companiProps)) {
|
||||
$somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']);
|
||||
self::setProp($somePropValue, RCrmActions::fromJSON($companiProps[$key]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -866,7 +887,7 @@ class RetailCrmHistory
|
|||
|
||||
if (!$order['externalId']) {
|
||||
$order["externalId"] = $newOrder->getId();
|
||||
if (RCrmActions::apiMethod($api, 'ordersFixExternalIds', __METHOD__, array(array('id' => $order['id'], 'externalId' => $newOrder->getId()))) == false){
|
||||
if (RCrmActions::apiMethod($api, 'ordersFixExternalIds', __METHOD__, array(array('id' => $order['id'], 'externalId' => $newOrder->getId()))) == false) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -1013,10 +1034,6 @@ class RetailCrmHistory
|
|||
$orders[$change['order']['id']] = $change['order'];
|
||||
}
|
||||
|
||||
if ($change['field'] == 'number') {
|
||||
$orders[$change['order']['id']]['number'] = $change['newValue'];
|
||||
}
|
||||
|
||||
if ($change['item']) {
|
||||
if ($orders[$change['order']['id']]['items'][$change['item']['id']]) {
|
||||
$orders[$change['order']['id']]['items'][$change['item']['id']] = array_merge($orders[$change['order']['id']]['items'][$change['item']['id']], $change['item']);
|
||||
|
|
|
@ -22,6 +22,7 @@ class RetailCrmOrder
|
|||
public static $CRM_ORDER_NUMBERS = 'order_numbers';
|
||||
public static $CRM_ORDER_DIMENSIONS = 'order_dimensions';
|
||||
public static $CRM_CURRENCY = 'currency';
|
||||
public static $CRM_CC = 'cc';
|
||||
|
||||
const CANCEL_PROPERTY_CODE = 'INTAROCRM_IS_CANCELED';
|
||||
|
||||
|
@ -54,12 +55,13 @@ class RetailCrmOrder
|
|||
$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();
|
||||
$optionCorpClient = COption::GetOptionString(self::$MODULE_ID, self::$CRM_CC, 0);
|
||||
|
||||
$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 +72,15 @@ class RetailCrmOrder
|
|||
'cost' => $arFields['PRICE_DELIVERY']
|
||||
),
|
||||
);
|
||||
|
||||
if (isset($arParams['contactExId'])) {
|
||||
$order['contact']['externalId'] = $arParams['contactExId'];
|
||||
}
|
||||
|
||||
if ($send && isset($_COOKIE['_rc']) && $_COOKIE['_rc'] != '') {
|
||||
$order['customer']['browserId'] = $_COOKIE['_rc'];
|
||||
}
|
||||
|
||||
$order['contragent']['contragentType'] = $arParams['optionsContragentType'][$arFields['PERSON_TYPE_ID']];
|
||||
|
||||
if ($methodApi == 'ordersEdit') {
|
||||
|
@ -144,44 +152,10 @@ class RetailCrmOrder
|
|||
$height = 0;
|
||||
$length = 0;
|
||||
|
||||
if ('ordersEdit' == $methodApi) {
|
||||
$response = RCrmActions::apiMethod($api, 'ordersGet', __METHOD__, $order['externalId']);
|
||||
if (isset($response['order'])) {
|
||||
foreach ($response['order']['items'] as $k => $item) {
|
||||
$externalId = $k ."_". $item['offer']['externalId'];
|
||||
$orderItems[$externalId] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//basket
|
||||
foreach ($arFields['BASKET'] as $position => $product) {
|
||||
$externalId = $position ."_". $product['PRODUCT_ID'];
|
||||
if (isset($orderItems[$externalId])) { //update
|
||||
$externalIds = $orderItems[$externalId]['externalIds'];
|
||||
$key = array_search("bitrix", array_column($externalIds, 'code'));
|
||||
if ($externalIds[$key]['code'] == "bitrix") {
|
||||
$externalIds[$key] = array(
|
||||
'code' => 'bitrix',
|
||||
'value' => $externalId,
|
||||
);
|
||||
} else {
|
||||
$externalIds[] = array(
|
||||
'code' => 'bitrix',
|
||||
'value' => $externalId,
|
||||
);
|
||||
}
|
||||
} else { //create
|
||||
$externalIds = array(
|
||||
array(
|
||||
'code' => 'bitrix',
|
||||
'value' => $externalId,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($arFields['BASKET'] as $product) {
|
||||
$item = array(
|
||||
'externalIds' => $externalIds,
|
||||
'externalId' => $product['PRODUCT_ID'],
|
||||
'quantity' => $product['QUANTITY'],
|
||||
'offer' => array('externalId' => $product['PRODUCT_ID'],
|
||||
'xmlId' => $product['PRODUCT_XML_ID']
|
||||
|
@ -284,6 +258,10 @@ class RetailCrmOrder
|
|||
}
|
||||
}
|
||||
|
||||
$f = fopen($_SERVER["DOCUMENT_ROOT"]."/goev_order_send123456.txt", "a+");
|
||||
fwrite($f, print_r(array(date('Y-m-d H:i:s'), $order),true));
|
||||
fclose($f);
|
||||
|
||||
$normalizer = new RestNormalizer();
|
||||
$order = $normalizer->normalize($order, 'orders');
|
||||
|
||||
|
@ -354,97 +332,114 @@ 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);
|
||||
$optionCorpClient = COption::GetOptionString(self::$MODULE_ID, self::$CRM_CC, 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));
|
||||
if ("Y" == $optionCorpClient) {
|
||||
$eventProcessor = new RetailCrmEvent();
|
||||
|
||||
$api = new RetailCrm\ApiClient($api_host, $api_key);
|
||||
foreach ($orderIds as $orderId) {
|
||||
$orderObject = \Bitrix\Sale\Order::load($orderId);
|
||||
|
||||
$arParams = array(
|
||||
'optionsOrderTypes' => $optionsOrderTypes,
|
||||
'optionsDelivTypes' => $optionsDelivTypes,
|
||||
'optionsPayTypes' => $optionsPayTypes,
|
||||
'optionsPayStatuses' => $optionsPayStatuses,
|
||||
'optionsPayment' => $optionsPayment,
|
||||
'optionsOrderProps' => $optionsOrderProps,
|
||||
'optionsLegalDetails' => $optionsLegalDetails,
|
||||
'optionsContragentType' => $optionsContragentType,
|
||||
'optionsSitesList' => $optionsSitesList,
|
||||
'optionsCustomFields' => $optionsCustomFields,
|
||||
);
|
||||
if (!$orderObject) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$recOrders = array();
|
||||
foreach ($orderIds as $orderId) {
|
||||
$id = \Bitrix\Sale\Order::load($orderId);
|
||||
if (!$id) {
|
||||
continue;
|
||||
$eventProcessor->orderSave($orderObject);
|
||||
time_nanosleep(0, 250000000);
|
||||
}
|
||||
$order = self::orderObjToArr($id);
|
||||
$user = Bitrix\Main\UserTable::getById($order['USER_ID'])->fetch();
|
||||
} else {
|
||||
$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);
|
||||
|
||||
$arCustomers = RetailCrmUser::customerSend($user, $api, $optionsContragentType[$order['PERSON_TYPE_ID']], false, $site);
|
||||
$arOrders = self::orderSend($order, $api, $arParams, false, $site);
|
||||
$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));
|
||||
|
||||
if (!$arCustomers || !$arOrders) {
|
||||
continue;
|
||||
$api = new RetailCrm\ApiClient($api_host, $api_key);
|
||||
|
||||
$arParams = array(
|
||||
'optionsOrderTypes' => $optionsOrderTypes,
|
||||
'optionsDelivTypes' => $optionsDelivTypes,
|
||||
'optionsPayTypes' => $optionsPayTypes,
|
||||
'optionsPayStatuses' => $optionsPayStatuses,
|
||||
'optionsPayment' => $optionsPayment,
|
||||
'optionsOrderProps' => $optionsOrderProps,
|
||||
'optionsLegalDetails' => $optionsLegalDetails,
|
||||
'optionsContragentType' => $optionsContragentType,
|
||||
'optionsSitesList' => $optionsSitesList,
|
||||
'optionsCustomFields' => $optionsCustomFields,
|
||||
);
|
||||
|
||||
$recOrders = array();
|
||||
foreach ($orderIds as $orderId) {
|
||||
$id = \Bitrix\Sale\Order::load($orderId);
|
||||
if (!$id) {
|
||||
continue;
|
||||
}
|
||||
$order = self::orderObjToArr($id);
|
||||
$user = Bitrix\Main\UserTable::getById($order['USER_ID'])->fetch();
|
||||
|
||||
$arCustomers = RetailCrmUser::customerSend($user, $api, $optionsContragentType[$order['PERSON_TYPE_ID']], false, $site);
|
||||
$arOrders = self::orderSend($order, $api, $arParams, false, $site);
|
||||
|
||||
if (!$arCustomers || !$arOrders) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$resCustomers[$order['LID']][] = $arCustomers;
|
||||
$resOrders[$order['LID']][] = $arOrders;
|
||||
|
||||
$recOrders[] = $orderId;
|
||||
}
|
||||
|
||||
$resCustomers[$order['LID']][] = $arCustomers;
|
||||
$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 {
|
||||
continue;
|
||||
if (count($resOrders) > 0) {
|
||||
foreach ($resCustomers as $key => $customerLoad) {
|
||||
if ($optionsSitesList) {
|
||||
if (array_key_exists($key, $optionsSitesList) && $optionsSitesList[$key] != null) {
|
||||
$site = $optionsSitesList[$key];
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} elseif (!$optionsSitesList) {
|
||||
$site = null;
|
||||
}
|
||||
} 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;
|
||||
if (RCrmActions::apiMethod($api, 'customersUpload', __METHOD__, $customerLoad, $site) === false) {
|
||||
return false;
|
||||
}
|
||||
if (count($optionsSitesList) > 1) {
|
||||
time_nanosleep(0, 250000000);
|
||||
}
|
||||
} elseif (!$optionsSitesList) {
|
||||
$site = null;
|
||||
}
|
||||
if (RCrmActions::apiMethod($api, 'ordersUpload', __METHOD__, $orderLoad, $site) === false) {
|
||||
return false;
|
||||
foreach ($resOrders as $key => $orderLoad) {
|
||||
if ($optionsSitesList) {
|
||||
if (array_key_exists($key, $optionsSitesList) && $optionsSitesList[$key] != null) {
|
||||
$site = $optionsSitesList[$key];
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} elseif (!$optionsSitesList) {
|
||||
$site = null;
|
||||
}
|
||||
if (RCrmActions::apiMethod($api, 'ordersUpload', __METHOD__, $orderLoad, $site) === false) {
|
||||
return false;
|
||||
}
|
||||
if (count($optionsSitesList) > 1) {
|
||||
time_nanosleep(0, 250000000);
|
||||
}
|
||||
}
|
||||
if (count($optionsSitesList) > 1) {
|
||||
time_nanosleep(0, 250000000);
|
||||
if ($failed == true && $failedIds !== false && count($failedIds) > 0) {
|
||||
COption::SetOptionString(self::$MODULE_ID, self::$CRM_ORDER_FAILED_IDS, serialize(array_diff($failedIds, $recOrders)));
|
||||
} elseif ($lastUpOrderId < max($recOrders) && $orderList === false) {
|
||||
COption::SetOptionString(self::$MODULE_ID, self::$CRM_ORDER_LAST_ID, max($recOrders));
|
||||
}
|
||||
}
|
||||
if ($failed == true && $failedIds !== false && count($failedIds) > 0) {
|
||||
COption::SetOptionString(self::$MODULE_ID, self::$CRM_ORDER_FAILED_IDS, serialize(array_diff($failedIds, $recOrders)));
|
||||
} elseif ($lastUpOrderId < max($recOrders) && $orderList === false) {
|
||||
COption::SetOptionString(self::$MODULE_ID, self::$CRM_ORDER_LAST_ID, max($recOrders));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -38,6 +38,11 @@ $CRM_COLL_KEY = 'coll_key';
|
|||
$CRM_UA = 'ua';
|
||||
$CRM_UA_KEYS = 'ua_keys';
|
||||
|
||||
$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';
|
||||
|
@ -348,7 +353,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 +393,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
|
||||
|
@ -443,14 +448,30 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
|||
UnRegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmUa", "add");
|
||||
}
|
||||
|
||||
|
||||
//discount_round
|
||||
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') {
|
||||
|
@ -475,7 +496,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 +559,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 +658,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 +674,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
|
||||
|
@ -699,6 +732,14 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
|||
$('tr.address-detail-' + orderType).hide('slow');
|
||||
});
|
||||
|
||||
$('tr.contragent-type select').change(function(){
|
||||
splitName = $(this).attr('name').split('-');
|
||||
contragentType = $(this).val();
|
||||
orderType = splitName[2];
|
||||
|
||||
$('tr.legal-detail-' + orderType).hide();
|
||||
$('.legal-detail-title-' + orderType).hide();
|
||||
|
||||
$('tr.contragent-type select').change(function(){
|
||||
splitName = $(this).attr('name').split('-');
|
||||
contragentType = $(this).val();
|
||||
|
@ -750,6 +791,12 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
|||
$('tr.r-coll').show('slow');
|
||||
} else if($(this).find('input').is(':checked') === false){
|
||||
$('tr.r-coll').hide('slow');
|
||||
|
||||
$('.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;
|
||||
|
@ -760,6 +807,12 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
|||
$('tr.r-dc').show('slow');
|
||||
} else if($(this).find('input').is(':checked') === false){
|
||||
$('tr.r-dc').hide('slow');
|
||||
|
||||
$('.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;
|
||||
|
@ -941,6 +994,73 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
|||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<?php foreach($arResult['bitrixPaymentStatusesList'] as $bitrixPaymentStatus): ?>
|
||||
<tr>
|
||||
<td width="50%" class="adm-detail-content-cell-l" name="<?php echo $bitrixPaymentStatus['ID']; ?>">
|
||||
<?php echo $bitrixPaymentStatus['NAME']; ?>
|
||||
</td>
|
||||
<td width="50%" class="adm-detail-content-cell-r">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td width="70%">
|
||||
<select name="payment-status-<?php echo $bitrixPaymentStatus['ID']; ?>" class="typeselect">
|
||||
<option value=""></option>
|
||||
<?php foreach($arResult['paymentGroupList'] as $orderStatusGroup): if(!empty($orderStatusGroup['statuses'])) : ?>
|
||||
<optgroup label="<?php echo $APPLICATION->ConvertCharset($orderStatusGroup['name'], 'utf-8', SITE_CHARSET); ?>">
|
||||
<?php foreach($orderStatusGroup['statuses'] as $payment): ?>
|
||||
<?php if(isset($arResult['paymentList'][$payment])): ?>
|
||||
<option value="<?php echo $arResult['paymentList'][$payment]['code']; ?>" <?php if ($optionsPayStatuses[$bitrixPaymentStatus['ID']] == $arResult['paymentList'][$payment]['code']) echo 'selected'; ?>>
|
||||
<?php echo $APPLICATION->ConvertCharset($arResult['paymentList'][$payment]['name'], 'utf-8', SITE_CHARSET); ?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
<?php endif; endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
<td width="30%">
|
||||
<input name="order-cansel-<?php echo $bitrixPaymentStatus['ID']; ?>" <?php if(in_array($bitrixPaymentStatus['ID'], $canselOrderArr)) echo "checked";?> value="Y" type="checkbox" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<td colspan="2">
|
||||
<input type="submit" name="update-delivery-services" value="<?php echo GetMessage('UPDATE_DELIVERY_SERVICES'); ?>" class="adm-btn-save">
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="heading">
|
||||
<td colspan="2"><b><?php echo GetMessage('PAYMENT_TYPES_LIST'); ?></b></td>
|
||||
</tr>
|
||||
<?php foreach($arResult['bitrixPaymentTypesList'] as $bitrixPaymentType): ?>
|
||||
<tr>
|
||||
<td width="50%" class="adm-detail-content-cell-l" name="<?php echo $bitrixPaymentType['ID']; ?>">
|
||||
<?php echo $bitrixPaymentType['NAME']; ?>
|
||||
</td>
|
||||
<td width="50%" class="adm-detail-content-cell-r">
|
||||
<select name="payment-type-<?php echo $bitrixPaymentType['ID']; ?>" class="typeselect">
|
||||
<option value="" selected=""></option>
|
||||
<?php foreach($arResult['paymentTypesList'] as $paymentType): ?>
|
||||
<option value="<?php echo $paymentType['code']; ?>" <?php if ($optionsPayTypes[$bitrixPaymentType['ID']] == $paymentType['code']) echo 'selected'; ?>>
|
||||
<?php echo $APPLICATION->ConvertCharset($paymentType['name'], 'utf-8', SITE_CHARSET); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<tr class="heading">
|
||||
<td colspan="2"><b><?php echo GetMessage('PAYMENT_STATUS_LIST'); ?></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="50%"></td>
|
||||
<td width="50%">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td width="50%"></td>
|
||||
<td width="50%"><?php echo GetMessage('CANCELED'); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<?php foreach($arResult['bitrixPaymentStatusesList'] as $bitrixPaymentStatus): ?>
|
||||
<tr>
|
||||
<td width="50%" class="adm-detail-content-cell-l" name="<?php echo $bitrixPaymentStatus['ID']; ?>">
|
||||
|
@ -1120,6 +1240,62 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
|||
<?php endforeach; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php $tabControl->BeginNextTab(); ?>
|
||||
<input type="hidden" name="tab" value="catalog">
|
||||
<tr class="heading">
|
||||
<td colspan="2" class="option-other-bottom"><b><?php echo GetMessage('ORDERS_OPTIONS'); ?></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="option-head option-other-top option-other-bottom">
|
||||
<b>
|
||||
<label><input class="addr" type="checkbox" name="order-numbers" value="Y" <?php if($optionsOrderNumbers == 'Y') echo "checked"; ?>> <?php echo GetMessage('ORDER_NUMBERS'); ?></label>
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="option-head option-other-top option-other-bottom">
|
||||
<b>
|
||||
<label>
|
||||
<input class="addr" type="checkbox" name="order_dimensions" value="Y" <?php if($optionsOrderDimensions == 'Y') echo "checked"; ?>> <?php echo GetMessage('ORDER_DIMENSIONS'); ?>
|
||||
</label>
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="option-head option-other-top option-other-bottom">
|
||||
<b>
|
||||
<label><input class="addr" type="radio" name="order-discharge" value="1" <?php if($optionsDischarge == 1) echo "checked"; ?>><?php echo GetMessage('DISCHARGE_EVENTS'); ?></label>
|
||||
<label><input class="addr" type="radio" name="order-discharge" value="0" <?php if($optionsDischarge == 0) echo "checked"; ?>><?php echo GetMessage('DISCHARGE_AGENT'); ?></label>
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="heading">
|
||||
<td colspan="2" class="option-other-heading"><b><?php echo GetMessage('CRM_API_VERSION'); ?></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="option-head option-other-top option-other-bottom">
|
||||
<select name="api_version" class="typeselect">
|
||||
<?php for($v = 4; $v <= 5; $v++) {
|
||||
$ver = 'v' . $v; ?>
|
||||
<option value="<?php echo $ver; ?>" <?php if ($ver == $version) echo 'selected'; ?>>
|
||||
API V<?php echo $v; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="heading">
|
||||
<td colspan="2" class="option-other-heading"><b><?php echo GetMessage('CURRENCY'); ?></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="option-head option-other-top option-other-bottom">
|
||||
<select name="currency" class="typeselect">
|
||||
<?php foreach ($currencyList as $currencyCode => $currencyName) : ?>
|
||||
<option value="<?php echo $currencyCode; ?>" <?php if ($currencyCode == $currencyOption) echo 'selected'; ?>>
|
||||
<?php echo $currencyName; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php $tabControl->BeginNextTab(); ?>
|
||||
<input type="hidden" name="tab" value="catalog">
|
||||
<tr class="heading">
|
||||
|
@ -1291,6 +1467,206 @@ 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-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>
|
||||
|
||||
<?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 +1745,25 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
|
|||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
|
||||
<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…
Add table
Reference in a new issue