123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- <?php
- namespace Controller;
- class OrderOrProformaController
- {
- public $marketplaceOrders;
- public $settingsRepository;
- public function __construct($settingsRepository)
- {
- $this->settingsRepository = $settingsRepository;
- }
- public function sync()
- {
- if($this->settingsRepository->getOptionOrderOrProforma() == \Core\App\Factory\SettingsFactory::SELECT_ORDER)
- {
- $this->syncOrders();
- return \Core\App\Factory\SettingsFactory::SELECT_ORDER;
- }
- if($this->settingsRepository->getOptionOrderOrProforma() == \Core\App\Factory\SettingsFactory::SELECT_PROFORMA)
- {
- $this->syncProformas();
- return \Core\App\Factory\SettingsFactory::SELECT_PROFORMA;
- }
- }
- public function syncOrders()
- {
- $facturisCustomerRepository = new \Core\FacturisRepository\CustomerRepository(
- $this->settingsRepository->getAuthApiKey(),
- $this->settingsRepository->getAuthUsername(),
- $this->settingsRepository->getAuthPassword(),
- $this->settingsRepository->getAuthFiscalCode()
- );
-
- $facturisProductRepository = new \Core\FacturisRepository\ProductRepository(
- $this->settingsRepository->getAuthApiKey(),
- $this->settingsRepository->getAuthUsername(),
- $this->settingsRepository->getAuthPassword(),
- $this->settingsRepository->getAuthFiscalCode()
- );
-
- $marketplaceOrderRepository = new \MarketplaceRepository\OrderRepository(
- $this->settingsRepository->getToken(),
- $this->settingsRepository->getShop()
- );
- $marketplaceProductRepository = new \MarketplaceRepository\ProductRepository(
- $this->settingsRepository->getToken(),
- $this->settingsRepository->getShop()
- );
- $facturisOrderRepository = new \Core\FacturisRepository\OrderRepository(
- $this->settingsRepository->getAuthApiKey(),
- $this->settingsRepository->getAuthUsername(),
- $this->settingsRepository->getAuthPassword(),
- $this->settingsRepository->getAuthFiscalCode()
- );
-
- $service = new \Core\App\Service\OrderService(
- $marketplaceOrderRepository,
- $marketplaceProductRepository,
- $facturisCustomerRepository,
- $facturisProductRepository,
- $facturisOrderRepository,
- $this->settingsRepository
- );
-
- $service->sync();
- }
- public function syncProformas()
- {
- $facturisCustomerRepository = new \Core\FacturisRepository\CustomerRepository(
- $this->settingsRepository->getAuthApiKey(),
- $this->settingsRepository->getAuthUsername(),
- $this->settingsRepository->getAuthPassword(),
- $this->settingsRepository->getAuthFiscalCode()
- );
- $facturisProductRepository = new \Core\FacturisRepository\ProductRepository(
- $this->settingsRepository->getAuthApiKey(),
- $this->settingsRepository->getAuthUsername(),
- $this->settingsRepository->getAuthPassword(),
- $this->settingsRepository->getAuthFiscalCode()
- );
-
- $marketplaceProformaRepository = new \MarketplaceRepository\ProformaRepository(
- $this->settingsRepository->getToken(),
- $this->settingsRepository->getShop()
- );
- $marketplaceProductRepository = new \MarketplaceRepository\ProductRepository(
- $this->settingsRepository->getToken(),
- $this->settingsRepository->getShop()
- );
- $facturisProformaRepository = new \Core\FacturisRepository\ProformaRepository(
- $this->settingsRepository->getAuthApiKey(),
- $this->settingsRepository->getAuthUsername(),
- $this->settingsRepository->getAuthPassword(),
- $this->settingsRepository->getAuthFiscalCode()
- );
-
- $service = new \Core\App\Service\ProformaService(
- $marketplaceProformaRepository,
- $marketplaceProductRepository,
- $facturisCustomerRepository,
- $facturisProductRepository,
- $facturisProformaRepository,
- $this->settingsRepository
- );
-
- $service->sync();
- }
- public function autoSync()
- {
- if($this->settingsRepository->getOptionAutoOrderSync() == \Core\App\Factory\SettingsFactory::AUTO_SYNC_ENABLED)
- {
- $this->sync();
- }
- }
- }
|