SettingsFactory.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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_DOC_UPD = 'inactiv';
  8. const DEFAULT_PDLS = '';
  9. const DEFAULT_SHOW_OBS = 'activ';
  10. const DEFAULT_ORDER_OR_PROFORMA = 'order';
  11. const DEFAULT_PROFORMA_SERIE = '';
  12. const DEFAULT_AVIZE_SERIE = '';
  13. const DEFAULT_EXPFACTURA_SERIE = '';
  14. const DEFAULT_ORDERED_DAYS_AGO = '7';
  15. const DEFAULT_STOCK_FILTER = '';
  16. const AUTO_SYNC_ENABLED = 'activ';
  17. const AUTO_SYNC_DISABLED = 'inactiv';
  18. const DOC_UPD_ENABLED = 'activ';
  19. const DOC_UPD_DISABLED = 'inactiv';
  20. const SHOW_OBS_ENABLED = 'activ';
  21. const SHOW_OBS_DISABLED = 'inactiv';
  22. const SYNC_ENABLED = 'activ';
  23. const SYNC_DISABLED = 'inactiv';
  24. const SELECT_ORDER = 'order';
  25. const SELECT_PROFORMA = 'proforma';
  26. const SELECT_FACTURA = 'factura';
  27. const SELECT_AVIZE = 'avize';
  28. const SELECT_EXPFACTURA = 'expfactura';
  29. const DEFAULT_ADD_PROFORMA = 'inactiv';
  30. const DEFAULT_ADD_AVIZE = 'inactiv';
  31. const DEFAULT_ADD_EXPFACTURA = 'inactiv';
  32. const DEFAULT_ADD_INVOICE = 'activ';
  33. const DEFAULT_VIEW_PROFORMA = 'activ';
  34. const DEFAULT_VIEW_AVIZE = 'activ';
  35. const DEFAULT_VIEW_EXPFACTURA = 'activ';
  36. const DEFAULT_VIEW_INVOICE = 'activ';
  37. const DEFAULT_EDIT_PROFORMA = 'inactiv';
  38. const DEFAULT_EDIT_AVIZE = 'inactiv';
  39. const DEFAULT_EDIT_EXPFACTURA = 'inactiv';
  40. const DEFAULT_EDIT_INVOICE = 'inactiv';
  41. const DEFAULT_LOCATIONS = null;
  42. const DEFAULT_WITH_DISCOUNT = 'activ';
  43. const DEFAULT_PROFORMA_SERIE2 = '';
  44. const DEFAULT_AVIZE_SERIE2 = '';
  45. const DEFAULT_EXPFACTURA_SERIE2 = '';
  46. const DEFAULT_INVOICE_SERIE = '';
  47. public function createSettings(
  48. $auth_api_key = '',
  49. $auth_username = '',
  50. $auth_password = '',
  51. $auth_fiscal_code = '',
  52. $option_auto_stock_sync = '',
  53. $option_auto_order_sync = '',
  54. $option_pdls = '',
  55. $option_stock_filter = '',
  56. $option_order_or_proforma = '',
  57. $option_proforma_serie = '',
  58. $option_avize_serie = '',
  59. $option_expfactura_serie = '',
  60. $option_ordered_days_ago = '',
  61. $option_locations = null,
  62. $option_with_discount = ''
  63. ) {
  64. $settings = new \Core\App\Entity\Settings();
  65. $settings->setAuthApiKey($auth_api_key);
  66. $settings->setAuthUsername($auth_username);
  67. $settings->setAuthPassword($auth_password);
  68. $settings->setAuthFiscalCode($auth_fiscal_code);
  69. $settings->setOptionAutoStockSync(($option_auto_stock_sync != '') ? $option_auto_stock_sync : self::DEFAULT_AUTO_STOCK_SYNC);
  70. $settings->setOptionAutoOrderSync(($option_auto_order_sync != '') ? $option_auto_order_sync : self::DEFAULT_AUTO_ORDER_SYNC);
  71. $settings->setOptionStockFilter(($option_stock_filter != '') ? $option_stock_filter : self::DEFAULT_STOCK_FILTER);
  72. $settings->setOptionOrderOrProforma(($option_order_or_proforma != '') ? $option_order_or_proforma : self::DEFAULT_ORDER_OR_PROFORMA);
  73. $settings->setOptionProformaSerie(($option_proforma_serie != '') ? $option_proforma_serie : self::DEFAULT_PROFORMA_SERIE);
  74. $settings->setOptionAvizeSerie(($option_avize_serie != '') ? $option_avize_serie : self::DEFAULT_AVIZE_SERIE);
  75. $settings->setOptionExpfacturaSerie(($option_expfactura_serie != '') ? $option_expfactura_serie : self::DEFAULT_EXPFACTURA_SERIE);
  76. $settings->setOptionPdls(($option_pdls != '') ? $option_pdls : self::DEFAULT_PDLS);
  77. $settings->setOptionOrderedDaysAgo(($option_ordered_days_ago != '') ? $option_ordered_days_ago : self::DEFAULT_ORDERED_DAYS_AGO);
  78. $settings->setOptionLocations(!is_null($option_locations) ? explode(", ", $option_locations) : self::DEFAULT_LOCATIONS);
  79. $settings->setOptionWithDiscount(($option_with_discount != '') ? $option_with_discount : self::DEFAULT_WITH_DISCOUNT);
  80. $settings->setCustomFieldBank(array(
  81. 'Banca',
  82. 'Nume banca',
  83. 'Numele bancii',
  84. 'Bancă',
  85. ));
  86. $settings->setCustomFieldAccount(array(
  87. 'Cont bancar',
  88. 'Contul bancii',
  89. 'Cont',
  90. 'Contul bancar',
  91. ));
  92. $settings->setCustomFieldCompany(array(
  93. 'Denumire firmă',
  94. 'Denumire firma',
  95. 'Denumirea firmei',
  96. 'Nume firmă',
  97. 'Nume firma',
  98. 'Firma',
  99. 'Firmă'
  100. ));
  101. $settings->setCustomFieldFiscalCode(array(
  102. 'CUI',
  103. 'Cod Fiscal',
  104. 'Codul Fiscal'
  105. ));
  106. $settings->setCustomFieldRegNumber(array(
  107. 'Număr de înregistrare',
  108. 'Numar de inregistrare',
  109. ));
  110. $settings->setAutoSyncOptions(array(self::AUTO_SYNC_ENABLED, self::AUTO_SYNC_DISABLED));
  111. // $settings->setDocUpdOptions(array(self::DOC_UPD_ENABLED, self::DOC_UPD_DISABLED));
  112. // $settings->setShowObsOptions(array(self::SHOW_OBS_ENABLED, self::SHOW_OBS_DISABLED));
  113. $settings->setOrderOrProformaOptions(array(self::SELECT_ORDER, self::SELECT_PROFORMA, self::SELECT_EXPFACTURA, self::SELECT_AVIZE));
  114. $settings->setSyncDataTypes(array(
  115. 'product',
  116. 'order',
  117. 'stock'
  118. ));
  119. return $settings;
  120. }
  121. }