1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- namespace Controller;
- class SyncController
- {
- public $language;
- const TIME_LIMIT = 18000;
- public function __construct($db, $language, $shop = '')
- {
- set_time_limit( self::TIME_LIMIT );
- $this->language = $language;
- $this->settingsRepository = new \MarketplaceRepository\SettingsRepository($db, $shop);
- }
- public function sync()
- {
- if(isset($_POST['fsync_datatype']))
- {
- switch($_POST['fsync_datatype'])
- {
- case 'product': $result = $this->syncProduct();break;
- case 'order': $result = $this->syncOrderOrProforma();break;
- case 'stock': $result = $this->syncStock();break;
- default: $result = '';break;
- }
- }
- else
- {
- $result = '';
- }
- return $result;
- }
- public function syncProduct()
- {
- $controller = new \Controller\ProductController(
- $this->settingsRepository
- );
- $controller->sync();
- return $this->language->get('success_sync_prod');
- }
- public function syncOrderOrProforma()
- {
- $controller = new \Controller\OrderOrProformaController(
- $this->settingsRepository
- );
- $response = $controller->sync();
- if($response == \Core\App\Factory\SettingsFactory::SELECT_ORDER)
- {
- return $this->language->get('success_sync_order');
- }
- if($response == \Core\App\Factory\SettingsFactory::SELECT_PROFORMA)
- {
- return $this->language->get('success_sync_proforma');
- }
-
- }
- public function syncStock()
- {
- $controller = new \Controller\StockController(
- $this->settingsRepository
- );
- $controller->sync();
- return $this->language->get('success_sync_stock');
- }
- public function autoSync()
- {
- $orderController = new \Controller\OrderOrProformaController(
- $this->settingsRepository
- );
- $stockController = new \Controller\StockController(
- $this->settingsRepository
- );
- $orderController->autoSync();
- $stockController->autoSync();
- }
-
-
- }
|