SettingsFactory.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. namespace Core\App\Factory;
  3. class SettingsFactory extends EntityFactory
  4. {
  5. const DEFAULT_AUTO_STOCK_SYNC = 'activ';
  6. const DEFAULT_AUTO_ORDER_SYNC = 'activ';
  7. const DEFAULT_ORDER_OR_PROFORMA = 'order';
  8. const DEFAULT_PROFORMA_SERIE = '';
  9. const DEFAULT_ORDERED_DAYS_AGO = '7';
  10. const DEFAULT_STOCK_FILTER = '';
  11. const AUTO_SYNC_ENABLED = 'activ';
  12. const AUTO_SYNC_DISABLED = 'inactiv';
  13. const SYNC_ENABLED = 'activ';
  14. const SYNC_DISABLED = 'inactiv';
  15. const SELECT_ORDER = 'order';
  16. const SELECT_PROFORMA = 'proforma';
  17. const DEFAULT_LOCATIONS = null;
  18. const DEFAULT_WITH_DISCOUNT = 'activ';
  19. public function createSettings(
  20. $auth_api_key = '',
  21. $auth_username = '',
  22. $auth_password = '',
  23. $auth_fiscal_code = '',
  24. $option_auto_stock_sync = '',
  25. $option_auto_order_sync = '',
  26. $option_stock_filter = '',
  27. $option_order_or_proforma = '',
  28. $option_proforma_serie = '',
  29. $option_ordered_days_ago = '',
  30. $option_locations = null,
  31. $option_with_discount = ''
  32. )
  33. {
  34. $settings = new \Core\App\Entity\Settings();
  35. $settings->setAuthApiKey($auth_api_key);
  36. $settings->setAuthUsername($auth_username);
  37. $settings->setAuthPassword($auth_password);
  38. $settings->setAuthFiscalCode($auth_fiscal_code);
  39. $settings->setOptionAutoStockSync(($option_auto_stock_sync != '') ? $option_auto_stock_sync : self::DEFAULT_AUTO_STOCK_SYNC);
  40. $settings->setOptionAutoOrderSync(($option_auto_order_sync != '') ? $option_auto_order_sync : self::DEFAULT_AUTO_ORDER_SYNC);
  41. $settings->setOptionStockFilter(($option_stock_filter != '') ? $option_stock_filter : self::DEFAULT_STOCK_FILTER);
  42. $settings->setOptionOrderOrProforma(($option_order_or_proforma != '') ? $option_order_or_proforma : self::DEFAULT_ORDER_OR_PROFORMA);
  43. $settings->setOptionProformaSerie(($option_proforma_serie != '') ? $option_proforma_serie : self::DEFAULT_PROFORMA_SERIE);
  44. $settings->setOptionOrderedDaysAgo(($option_ordered_days_ago != '') ? $option_ordered_days_ago : self::DEFAULT_ORDERED_DAYS_AGO);
  45. $settings->setOptionLocations(!is_null($option_locations) ? explode(", ", $option_locations) : self::DEFAULT_LOCATIONS);
  46. $settings->setOptionWithDiscount(($option_with_discount != '') ? $option_with_discount : self::DEFAULT_WITH_DISCOUNT);
  47. $settings->setCustomFieldBank(array(
  48. 'Banca',
  49. 'Nume banca',
  50. 'Numele bancii',
  51. 'Bancă',
  52. ));
  53. $settings->setCustomFieldAccount(array(
  54. 'Cont bancar',
  55. 'Contul bancii',
  56. 'Cont',
  57. 'Contul bancar',
  58. ));
  59. $settings->setCustomFieldCompany(array(
  60. 'Denumire firmă',
  61. 'Denumire firma',
  62. 'Denumirea firmei',
  63. 'Nume firmă',
  64. 'Nume firma',
  65. 'Firma',
  66. 'Firmă'
  67. ));
  68. $settings->setCustomFieldFiscalCode(array(
  69. 'CUI',
  70. 'Cod Fiscal',
  71. 'Codul Fiscal'
  72. ));
  73. $settings->setCustomFieldRegNumber(array(
  74. 'Număr de înregistrare',
  75. 'Numar de inregistrare',
  76. ));
  77. $settings->setAutoSyncOptions(array(self::AUTO_SYNC_ENABLED, self::AUTO_SYNC_DISABLED));
  78. $settings->setOrderOrProformaOptions(array(self::SELECT_ORDER, self::SELECT_PROFORMA));
  79. $settings->setSyncDataTypes(array(
  80. 'product',
  81. 'order',
  82. 'stock'
  83. ));
  84. return $settings;
  85. }
  86. }