From 87a6c6ee344b6c6435a1b64e8b4fd43685643938 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Wed, 27 Sep 2017 14:38:24 +0200 Subject: [PATCH] Settings default status in export (#25) --- retailcrm/job/export.php | 5 +++-- retailcrm/lib/RetailcrmReferences.php | 5 +++++ retailcrm/retailcrm.php | 26 +++++++++++++++++++++++--- retailcrm/translations/ru.php | 6 ++++-- 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/retailcrm/job/export.php b/retailcrm/job/export.php index 4a4bb4e..cb23a96 100644 --- a/retailcrm/job/export.php +++ b/retailcrm/job/export.php @@ -17,6 +17,7 @@ require(dirname(__FILE__) . '/../bootstrap.php'); $apiUrl = Configuration::get('RETAILCRM_ADDRESS'); $apiKey = Configuration::get('RETAILCRM_API_TOKEN'); $apiVersion = Configuration::get('RETAILCRM_API_VERSION'); +$statusExport = Configuration::get('RETAILCRM_STATUS_EXPORT'); if (!empty($apiUrl) && !empty($apiKey)) { $api = new RetailcrmProxy($apiUrl, $apiKey, _PS_ROOT_DIR_ . '/retailcrm.log', $apiVersion); @@ -59,11 +60,11 @@ foreach ($orderRecords as $record) { } if ($record['current_state'] == 0) { - $order_status = 'completed'; + $order_status = $statusExport; } else { $order_status = array_key_exists($record['current_state'], $status) ? $status[$record['current_state']] - : 'completed' + : $statusExport ; } diff --git a/retailcrm/lib/RetailcrmReferences.php b/retailcrm/lib/RetailcrmReferences.php index ab8eed7..4bba661 100644 --- a/retailcrm/lib/RetailcrmReferences.php +++ b/retailcrm/lib/RetailcrmReferences.php @@ -202,6 +202,11 @@ class RetailcrmReferences return $this->payment_modules; } + public function getStatuseDefaultExport() + { + return $this->getApiStatuses(); + } + protected function getApiDeliveryTypes() { $crmDeliveryTypes = array(); diff --git a/retailcrm/retailcrm.php b/retailcrm/retailcrm.php index 671d9c9..7f90b92 100644 --- a/retailcrm/retailcrm.php +++ b/retailcrm/retailcrm.php @@ -3,7 +3,7 @@ * @author Retail Driver LCC * @copyright RetailCRM * @license GPL - * @version 2.1.1 + * @version 2.1.2 * @link https://retailcrm.ru * */ @@ -25,7 +25,7 @@ class RetailCRM extends Module { $this->name = 'retailcrm'; $this->tab = 'export'; - $this->version = '2.1.1'; + $this->version = '2.1.2'; $this->author = 'Retail Driver LCC'; $this->displayName = $this->l('RetailCRM'); $this->description = $this->l('Integration module for RetailCRM'); @@ -94,6 +94,7 @@ class RetailCRM extends Module $payment = json_encode(Tools::getValue('RETAILCRM_API_PAYMENT')); $deliveryDefault = json_encode(Tools::getValue('RETAILCRM_API_DELIVERY_DEFAULT')); $paymentDefault = json_encode(Tools::getValue('RETAILCRM_API_PAYMENT_DEFAULT')); + $statusExport = (string)(Tools::getValue('RETAILCRM_STATUS_EXPORT')); $settings = array( 'address' => $address, 'token' => $token, @@ -111,6 +112,7 @@ class RetailCRM extends Module Configuration::updateValue('RETAILCRM_API_PAYMENT', $payment); Configuration::updateValue('RETAILCRM_API_DELIVERY_DEFAULT', $deliveryDefault); Configuration::updateValue('RETAILCRM_API_PAYMENT_DEFAULT', $paymentDefault); + Configuration::updateValue('RETAILCRM_STATUS_EXPORT', $statusExport); $output .= $this->displayConfirmation($this->l('Settings updated')); } @@ -229,6 +231,23 @@ class RetailCRM extends Module array($this->l('Delivery method'), $this->l('Payment type')) ), ); + + /* + * Status in export + */ + $fields_form[5]['form'] = array( + 'legend' => array('title' => $this->l('Default status')), + 'input' => array(array( + 'type' => 'select', + 'name' => 'RETAILCRM_STATUS_EXPORT', + 'label' => $this->l('Default status in export'), + 'options' => array( + 'query' => $this->reference->getStatuseDefaultExport(), + 'id' => 'id_option', + 'name' => 'name' + ) + )), + ); } /* @@ -270,7 +289,8 @@ class RetailCRM extends Module $helper->fields_value['RETAILCRM_ADDRESS'] = Configuration::get('RETAILCRM_ADDRESS'); $helper->fields_value['RETAILCRM_API_TOKEN'] = Configuration::get('RETAILCRM_API_TOKEN'); $helper->fields_value['RETAILCRM_API_VERSION'] = Configuration::get('RETAILCRM_API_VERSION'); - + $helper->fields_value['RETAILCRM_STATUS_EXPORT'] = Configuration::get('RETAILCRM_STATUS_EXPORT'); + $deliverySettings = Configuration::get('RETAILCRM_API_DELIVERY'); if (isset($deliverySettings) && $deliverySettings != '') { $deliveryTypes = json_decode($deliverySettings); diff --git a/retailcrm/translations/ru.php b/retailcrm/translations/ru.php index edc5325..d3e5602 100644 --- a/retailcrm/translations/ru.php +++ b/retailcrm/translations/ru.php @@ -46,8 +46,10 @@ $_MODULE['<{retailcrm}prestashop>retailcrm_1aadcc03a9dbba84a3c5a5cbfde8a162'] = $_MODULE['<{retailcrm}prestashop>retailcrm_93d03fe37ab3c6abc2a19dd8e41543bd'] = 'Адрес строка 1'; $_MODULE['<{retailcrm}prestashop>retailcrm_22fcffe02ab9eda5b769387122f2ddce'] = 'Адрес строка 2'; $_MODULE['<{retailcrm}prestashop>retailcrm_8bcdc441379cbf584638b0589a3f9adb'] = 'Почтовый индекс'; -$_MODULE['<{retailcrm}prestashop>retailcrm_69aede266809f89b89fe70681f6a129f'] = 'Область/Край/Республика'; $_MODULE['<{retailcrm}prestashop>retailcrm_57d056ed0984166336b7879c2af3657f'] = 'Город'; $_MODULE['<{retailcrm}prestashop>retailcrm_bcc254b55c4a1babdf1dcb82c207506b'] = 'Телефон'; $_MODULE['<{retailcrm}prestashop>retailcrm_f0e1fc6f97d36cb80f29196e2662ffde'] = 'Мобильный телефон'; -$_MODULE['<{retailcrm}prestashop>retailcrm_7a1920d61156abc05a60135aefe8bc67'] = 'По умолчанию'; \ No newline at end of file +$_MODULE['<{retailcrm}prestashop>retailcrm_7a1920d61156abc05a60135aefe8bc67'] = 'По умолчанию'; +$_MODULE['<{retailcrm}prestashop>retailcrm_cc18dd262eff97c4dd4b56f750896adb'] = 'Статус по умолчанию'; +$_MODULE['<{retailcrm}prestashop>retailcrm_a33b96f0ce0f1227132f1cb3cf1c9e88'] = 'Статус заказа при пакетной выгрузке '; +$_MODULE['<{retailcrm}prestashop>retailcrm_1bd340aeb42a5ee0318784c2cffed8a9'] = 'Выбранная версия API недоступна'; \ No newline at end of file