123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- <?php
- namespace Controller;
- class FormController
- {
- public function getForm($db, $language)
- {
- $data = array();
- $settingsRepository = new \MarketplaceRepository\SettingsRepository($db);
-
- $settingsService = new \Core\App\Service\SettingsService(
- $settingsRepository
- );
-
- $data['title'] = $language->get('title');
- $data['description'] = $language->get('description');
- //tab1
- $data['tab_name_1'] = $language->get('tab_name_1');
- $data['tab_description_1'] = $language->get('tab_description_1');
- $dataTypes = $settingsService->getSyncDataTypes();
- $data['dataTypes'] = array(array('id' => '', 'label' => $language->get('data_type')));
- if(!empty($dataTypes))
- {
- foreach($dataTypes as $dataType)
- {
- $data['dataTypes'][] = array('id' => $dataType, 'label' => $language->get($dataType));
- }
- }
- sort($data['dataTypes']);
- $data['sync_btn'] = $language->get('sync_btn');
- $data['download_btn'] = $language->get('download_btn');
- $data['clear_btn'] = $language->get('clear_btn');
- $data['datatype_error'] = $language->get('datatype_error');
- $data['authform_error'] = $language->get('authform_error');
- $data['sync_please_wait'] = $language->get('sync_please_wait');
- $data['download_log_error_1'] = $language->get('download_log_error_1');
- $data['download_log_error_2'] = $language->get('download_log_error_2');
-
- $data['select_text'] = $language->get('select_text');
-
- //tab 2
- $data['tab_name_2'] = $language->get('tab_name_2');
- $data['tab_description_2'] = $language->get('tab_description_2');
- $data['auth_apikey'] = $language->get('auth_api_key');
- $data['auth_username'] = $language->get('auth_username');
- $data['auth_password'] = $language->get('auth_password');
- $data['auth_fiscalcode'] = $language->get('auth_fiscal_code');
- $data['auth_apikey_error'] = $language->get('auth_apikey_error');
- $data['auth_username_error'] = $language->get('auth_username_error');
- $data['auth_password_error'] = $language->get('auth_password_error');
- $data['auth_fiscalcode_error'] = $language->get('auth_fiscalcode_error');
- $data['save_btn'] = $language->get('save_btn');
- //tab 3
- $data['tab_name_3'] = $language->get('tab_name_3');
- $data['tab_name_3_1'] = $language->get('tab_name_3_1');
- $data['tab_name_3_2'] = $language->get('tab_name_3_2');
- $data['proforma_invoice_options_title'] = $language->get('proforma_invoice_options_title');
- $data['add_proforma'] = $language->get('add_proforma');
- $data['add_avize'] = $language->get('add_avize');
- $data['add_expfactura'] = $language->get('add_expfactura');
- $data['with_discount'] = $language->get('with_discount');
- $data['with_discount_desc'] = $language->get('with_discount_desc');
- $data['add_invoice'] = $language->get('add_invoice');
- $data['view_proforma'] = $language->get('view_proforma');
- $data['view_invoice'] = $language->get('view_invoice');
- $data['view_avize'] = $language->get('view_avize');
- $data['view_expfactura'] = $language->get('view_expfactura');
- $data['edit_proforma'] = $language->get('edit_proforma');
- $data['edit_invoice'] = $language->get('edit_invoice');
- $data['edit_avize'] = $language->get('edit_avize');
- $data['edit_expfactura'] = $language->get('edit_expfactura');
- $data['fosync_proforma_series2_label'] = $language->get('fosync_proforma_series2_label');
- $data['fosync_invoice_series_label'] = $language->get('fosync_invoice_series_label');
- $data['fosync_avize_series2_label'] = $language->get('fosync_avize_series2_label');
- $data['fosync_expfactura_series2_label'] = $language->get('fosync_expfactura_series2_label');
- //tab4
- $data['tab_name_4'] = $language->get('tab_name_4');
- //tab 5
- $data['tab_name_5'] = $language->get('tab_name_5');
- $data['datepicker'] = $language->get('datepicker');
- $data['tab_description_5_1'] = $language->get('tab_description_5_1');
- $data['tab_description_5_2'] = $language->get('tab_description_5_2');
- $data['confirm_clear_log'] = $language->get('confirm_clear_log');
- $syncOrdersAs = $settingsService->getSyncOrdersAs();
- $data['syncOrdersAs'] = array();
- if(!empty($syncOrdersAs))
- {
- foreach($syncOrdersAs as $syncOrdersAsElement)
- {
- $data['syncOrdersAs'][] = array('id' => $syncOrdersAsElement, 'label' => $language->get($syncOrdersAsElement));
- }
- }
- $data['sync_orders_as'] = $language->get('sync_orders_as');
- $data['proforma_series'] = $language->get('proforma_series');
- $data['avize_series'] = $language->get('avize_series');
- $data['expfactura_series'] = $language->get('expfactura_series');
- $data['days_ago'] = $language->get('days_ago');
- $data['auto_order_sync'] = $language->get('auto_order_sync');
- $data['auto_stock_sync'] = $language->get('auto_stock_sync');
- $autoSyncOptions = $settingsService->getAutoSyncOptions();
- $data['autoSyncOptions'] = array();
- if(!empty($autoSyncOptions))
- {
- foreach($autoSyncOptions as $autoSyncOptionsElement)
- {
- $data['autoSyncOptions'][] = array('id' => $autoSyncOptionsElement, 'label' => $language->get($autoSyncOptionsElement));
- }
- }
- $data['shopLocations'] = $this->getShopLocations($settingsRepository);
- $data['locations'] = $language->get('locations');
-
- $enabledDisabledOptions = $settingsService->getEnabledDisabledOptions();
- $data['withDiscountOptions'] = array();
- if(!empty($enabledDisabledOptions))
- {
- foreach($enabledDisabledOptions as $enabledDisabledOption)
- {
- $data['withDiscountOptions'][] = array('id' => $enabledDisabledOption, 'label' => $language->get($enabledDisabledOption));
- }
- }
- $data['filter_stock'] = $language->get('filter_stock');
- $data['filter_pdls'] = $language->get('filter_pdls');
- $data['loading_data_please_wait'] = $language->get('loading_data_please_wait');
- $data['option_proformaserie_error'] = $language->get('option_proformaserie_error');
- $data['option_avizeserie_error'] = $language->get('option_avizeserie_error');
- $data['option_expfacturaserie_error'] = $language->get('option_expfacturaserie_error');
- $data['option_daysago_error'] = $language->get('option_daysago_error');
- $data['version_text'] = $language->get('version_text');
-
- $data['option'] = $settingsService->getOptions();
-
- $data['auth'] = $settingsService->getAuth();
- $data['version_number'] = $settingsService->getVersion();
- $data['version_link'] = $settingsService->getVersionLink();
- $data['check_latest_version'] = $language->get('check_latest_version');
-
- //tutorials
- $data['tutorial_title'] = $language->get('tutorial_title');
- $data['tutorial_p'] = $language->get('tutorial_p');
- $data['tutorial_1'] = $language->get('tutorial_1');
- $data['tutorial_2'] = $language->get('tutorial_2');
- $data['tutorial_3'] = $language->get('tutorial_3');
- $data['tutorial_4'] = $language->get('tutorial_4');
- $data['show_tutorial'] = $settingsService->showTutorial();
- $data['authform_error'] = $language->get('authform_error');
-
-
- return $data;
-
- }
- public function testAuth($db)
- {
- $this->settingsRepository = new \MarketplaceRepository\SettingsRepository($db);
- $settingsService = new \Core\App\Service\SettingsService(
- $this->settingsRepository
- );
- $remoteStockRepository = new \Core\FacturisRepository\StockRepository(
- $_GET['fsync_auth_apikey'],
- $_GET['fsync_auth_username'],
- $_GET['fsync_auth_password'],
- $_GET['fsync_auth_fiscalcode']
- );
- $settingsService->testAuth($remoteStockRepository);
- }
- public function getPdlGestiuni($db, $language)
- {
- $settingsRepository = new \MarketplaceRepository\SettingsRepository($db);
- $settingsService = new \Core\App\Service\SettingsService(
- $settingsRepository
- );
-
- $remoteStockRepository = new \Core\FacturisRepository\StockRepository(
- $settingsRepository->getAuthApiKey(),
- $settingsRepository->getAuthUsername(),
- $settingsRepository->getAuthPassword(),
- $settingsRepository->getAuthFiscalCode()
- );
-
- $pdl_gestiuni = $settingsService->getPdlGestiuni($remoteStockRepository);
-
- $result = '';
- $result .= '<option value=""';
- $result .= (isset($_GET['fsync_option_filterstock']) && $_GET['fsync_option_filterstock'] == '') ? ' selected="selected" ' : '';
- $result .= ' >' . $language->get('filter_stock_all') . '</option>';
- if(!empty($pdl_gestiuni))
- {
- foreach($pdl_gestiuni as $pdl_gestiune)
- {
- $result .= '<option value=' . $pdl_gestiune['id'] . ' ';
- $result .= (isset($_GET['fsync_option_filterstock']) && $_GET['fsync_option_filterstock'] == $pdl_gestiune['id']) ? ' selected="selected" ' : '';
- $result .= ' >' . $pdl_gestiune['name'] . '</option>';
- }
- }
- echo $result;
- }
- public function getPdls($db, $language)
- {
- $settingsRepository = new \MarketplaceRepository\SettingsRepository($db);
- $settingsService = new \Core\App\Service\SettingsService(
- $settingsRepository
- );
- $remoteStockRepository = new \Core\FacturisRepository\StockRepository(
- $settingsRepository->getAuthApiKey(),
- $settingsRepository->getAuthUsername(),
- $settingsRepository->getAuthPassword(),
- $settingsRepository->getAuthFiscalCode()
- );
- $pdl_gestiuni = $settingsService->getPdls($remoteStockRepository);
- $result = '';
- $result .= '<option value=""';
- $result .= (isset($_GET['fsync_option_pdls']) && $_GET['fsync_option_pdls'] == '') ? ' selected="selected" ' : '';
- $result .= ' >' . $language->get('filter_pdls_all') . '</option>';
- if (!empty($pdl_gestiuni)) {
- foreach ($pdl_gestiuni as $pdl_gestiune) {
- $result .= '<option value=' . $pdl_gestiune['id'] . ' ';
- $result .= (isset($_GET['fsync_option_pdls']) && $_GET['fsync_option_pdls'] == $pdl_gestiune['id']) ? ' selected="selected" ' : '';
- $result .= ' >' . $pdl_gestiune['name'] . '</option>';
- }
- }
- echo $result;
- }
- public function checkLatestVersion($db, $language)
- {
- $settingsRepository = new \MarketplaceRepository\SettingsRepository($db);
- $settingsService = new \Core\App\Service\SettingsService(
- $settingsRepository
- );
- $settingsService->checkLatestVersion($language);
- }
- private function getShopLocations($settingsRepository)
- {
- $marketplaceStockRepository = new \MarketplaceRepository\StockRepository(
- $settingsRepository->getToken(),
- $settingsRepository->getShop()
- );
-
- return $marketplaceStockRepository->getShopLocations();
- }
- }
|