123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- <?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');
- }
-
- 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);
- }
- }
|