2016-01-29 18:02:44 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once DIR_SYSTEM . 'library/retailcrm/bootstrap.php';
|
|
|
|
|
2017-03-22 12:12:54 +03:00
|
|
|
class ModelExtensionRetailcrmReferences extends Model
|
2016-01-29 18:02:44 +03:00
|
|
|
{
|
|
|
|
protected $retailcrm;
|
2017-04-07 12:35:53 +03:00
|
|
|
private $opencartApiClient;
|
|
|
|
|
|
|
|
public function getOpercartDeliveryTypes()
|
|
|
|
{
|
|
|
|
$this->load->model('user/api');
|
|
|
|
$this->opencartApiClient = new OpencartApiClient($this->registry);
|
|
|
|
|
|
|
|
return $this->opencartApiClient->request('retailcrm/getDeliveryTypes', array(), array());
|
|
|
|
}
|
2016-01-29 18:02:44 +03:00
|
|
|
|
|
|
|
public function getDeliveryTypes()
|
|
|
|
{
|
2017-04-07 12:35:53 +03:00
|
|
|
$this->load->model('setting/store');
|
|
|
|
|
2016-01-29 18:02:44 +03:00
|
|
|
return array(
|
|
|
|
'opencart' => $this->getOpercartDeliveryTypes(),
|
|
|
|
'retailcrm' => $this->getApiDeliveryTypes()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getOrderStatuses()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
'opencart' => $this->getOpercartOrderStatuses(),
|
|
|
|
'retailcrm' => $this->getApiOrderStatuses()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPaymentTypes()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
'opencart' => $this->getOpercartPaymentTypes(),
|
|
|
|
'retailcrm' => $this->getApiPaymentTypes()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-02-09 04:22:06 +03:00
|
|
|
public function getOpercartOrderStatuses()
|
2016-01-29 18:02:44 +03:00
|
|
|
{
|
|
|
|
$this->load->model('localisation/order_status');
|
|
|
|
|
|
|
|
return $this->model_localisation_order_status
|
|
|
|
->getOrderStatuses(array());
|
|
|
|
}
|
|
|
|
|
2016-02-09 04:22:06 +03:00
|
|
|
public function getOpercartPaymentTypes()
|
2016-01-29 18:02:44 +03:00
|
|
|
{
|
|
|
|
$paymentTypes = array();
|
2017-03-22 12:12:54 +03:00
|
|
|
$files = glob(DIR_APPLICATION . 'controller/extension/payment/*.php');
|
2016-01-29 18:02:44 +03:00
|
|
|
|
|
|
|
if ($files) {
|
|
|
|
foreach ($files as $file) {
|
|
|
|
$extension = basename($file, '.php');
|
|
|
|
|
2017-03-22 12:12:54 +03:00
|
|
|
$this->load->language('extension/payment/' . $extension);
|
2016-01-29 18:02:44 +03:00
|
|
|
|
|
|
|
if ($this->config->get($extension . '_status')) {
|
|
|
|
$paymentTypes[$extension] = strip_tags(
|
|
|
|
$this->language->get('heading_title')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $paymentTypes;
|
|
|
|
}
|
|
|
|
|
2016-02-09 04:22:06 +03:00
|
|
|
public function getApiDeliveryTypes()
|
2016-01-29 18:02:44 +03:00
|
|
|
{
|
|
|
|
$this->load->model('setting/setting');
|
|
|
|
$settings = $this->model_setting_setting->getSetting('retailcrm');
|
|
|
|
|
|
|
|
if(!empty($settings['retailcrm_url']) && !empty($settings['retailcrm_apikey'])) {
|
|
|
|
$this->retailcrm = new RetailcrmProxy(
|
|
|
|
$settings['retailcrm_url'],
|
|
|
|
$settings['retailcrm_apikey'],
|
2017-03-22 12:12:54 +03:00
|
|
|
DIR_SYSTEM . 'storage/logs/retailcrm.log'
|
2016-01-29 18:02:44 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
$response = $this->retailcrm->deliveryTypesList();
|
|
|
|
|
|
|
|
return ($response === false) ? array() : $response->deliveryTypes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-09 04:22:06 +03:00
|
|
|
public function getApiOrderStatuses()
|
2016-01-29 18:02:44 +03:00
|
|
|
{
|
|
|
|
$this->load->model('setting/setting');
|
|
|
|
$settings = $this->model_setting_setting->getSetting('retailcrm');
|
|
|
|
|
|
|
|
if(!empty($settings['retailcrm_url']) && !empty($settings['retailcrm_apikey'])) {
|
|
|
|
$this->retailcrm = new RetailcrmProxy(
|
|
|
|
$settings['retailcrm_url'],
|
|
|
|
$settings['retailcrm_apikey'],
|
2017-03-22 12:12:54 +03:00
|
|
|
DIR_SYSTEM . 'storage/logs/retailcrm.log'
|
2016-01-29 18:02:44 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
$response = $this->retailcrm->statusesList();
|
|
|
|
|
|
|
|
return ($response === false) ? array() : $response->statuses;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-09 04:22:06 +03:00
|
|
|
public function getApiPaymentTypes()
|
2016-01-29 18:02:44 +03:00
|
|
|
{
|
|
|
|
$this->load->model('setting/setting');
|
|
|
|
$settings = $this->model_setting_setting->getSetting('retailcrm');
|
|
|
|
|
|
|
|
if(!empty($settings['retailcrm_url']) && !empty($settings['retailcrm_apikey'])) {
|
|
|
|
$this->retailcrm = new RetailcrmProxy(
|
|
|
|
$settings['retailcrm_url'],
|
|
|
|
$settings['retailcrm_apikey'],
|
2017-03-22 12:12:54 +03:00
|
|
|
DIR_SYSTEM . 'storage/logs/retailcrm.log'
|
2016-01-29 18:02:44 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
$response = $this->retailcrm->paymentTypesList();
|
|
|
|
|
|
|
|
return ($response === false) ? array() : $response->paymentTypes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|