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'); } if ($response == \Core\App\Factory\SettingsFactory::SELECT_EXPFACTURA) { return $this->language->get('success_sync_expfactura'); } if ($response == \Core\App\Factory\SettingsFactory::SELECT_AVIZE) { return $this->language->get('success_sync_avize'); } } 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(); } public function addProforma($orderId) { $controller = new \Controller\OrderOrProformaController( $this->settingsRepository ); $result = $controller->addProforma($orderId); if (isset($result['serie_fact']) && isset($result['numar_fact'])) { return $this->language->get( 'success_add_proforma_a', array($result['serie_fact'], $result['numar_fact'], $orderId) ); } else { return $this->language->get('success_add_proforma_b', array($orderId)); } } public function viewProforma($orderId) { $controller = new \Controller\OrderOrProformaController( $this->settingsRepository ); $controller->viewProforma($orderId); } public function addInvoice($orderId) { $controller = new \Controller\OrderOrProformaController( $this->settingsRepository ); $result = $controller->addInvoice($orderId); if (isset($result['serie_fact']) && isset($result['numar_fact'])) { return $this->language->get( 'success_add_invoice_a', array($result['serie_fact'], $result['numar_fact'], $orderId) ); } else { return $this->language->get('success_add_invoice_b', array($orderId)); } } public function viewInvoice($orderId) { $controller = new \Controller\OrderOrProformaController( $this->settingsRepository ); $controller->viewInvoice($orderId); } }