ntakproduct.class.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
  3. require_once DOL_DOCUMENT_ROOT.'/custom/ntak/class/ntakconnector/ntak_const.class.php';
  4. class NtakProduct extends Product
  5. {
  6. public $associtedProducts;
  7. public $isIndividualProgram = true;
  8. public $isCombinedProgram = false;
  9. /**
  10. *
  11. */
  12. public function getNtakTicketValidType(): string
  13. {
  14. $type = NtakConst::TICKET_VALIDITY_TYPE_OTHER;
  15. $occasion = $this->array_options['options_occasions'];
  16. if ($occasion == 1) {
  17. $type = NtakConst::TICKET_VALIDITY_TYPE_ONE_TIME;
  18. } else if ($occasion > 1) {
  19. $type = NtakConst::TICKET_VALIDITY_TYPE_OTHER;
  20. } else {
  21. $duration = $this->duration_value;
  22. $durationUnit = $this->duration_unit;
  23. // daily by hours
  24. if ($durationUnit == 'h' && ($duration == 24 || $duration == 25)) {
  25. $type = NtakConst::TICKET_VALIDITY_TYPE_DAILY;
  26. }
  27. // daily by days
  28. if ($durationUnit == 'd' && $duration == 1) {
  29. $type = NtakConst::TICKET_VALIDITY_TYPE_DAILY;
  30. }
  31. // weekly
  32. if ($durationUnit == 'w' && $duration == 1) {
  33. $type = NtakConst::TICKET_VALIDITY_TYPE_WEEKLY;
  34. }
  35. // monthly
  36. if ($durationUnit == 'm' && $duration == 1) {
  37. $type = NtakConst::TICKET_VALIDITY_TYPE_MONTHLY;
  38. }
  39. }
  40. return $type;
  41. }
  42. /**
  43. *
  44. */
  45. public function getNtakMaxNumberOfUse(): int
  46. {
  47. $use = 999; // unlimited use/occasion
  48. $occasion = $this->array_options['options_occasions'];
  49. if ($occasion > 0) {
  50. $use = $occasion;
  51. }
  52. return $use;
  53. }
  54. /**
  55. *
  56. */
  57. public function getNtakVatCode(): string
  58. {
  59. $vat = (int) $this->default_vat_code;
  60. return NtakConst::getVatCodeByVat($vat);
  61. }
  62. /**
  63. *
  64. */
  65. public function getNtakProgramDetails(): array
  66. {
  67. $result = [
  68. 'helyszinAdatok' => new stdClass,
  69. 'programAlkategoria' => $this->array_options['options_sub_category'],
  70. 'programFokategoria' => $this->array_options['options_main_category'],
  71. 'programGyakorisaga' => "ALLANDO",
  72. 'onlineProgram' => boolval($this->array_options['options_online']),
  73. 'programKezdete' => date('Y-m-01\TH:i:sP'),
  74. 'programVege' => date('Y-m-t\TH:i:sP'), //"2022-04-30T23:59:59.99+02:00",
  75. 'programNeve' => $this->label,
  76. //'programTipusa' => ($this->isCombinedProgram) ? NtakConst::PROGRAM_TYPE_COMBINED : NtakConst::PROGRAM_TYPE_INDEPENDENT,
  77. 'programTipusa' => NtakConst::PROGRAM_TYPE_INDEPENDENT,
  78. //'szolgHelyProgramAzonosito' => "",
  79. 'tssProgramAzonosito' => $this->ref,
  80. 'utolsoModositasIdeje' => NtakDate::timestampToRfc3339(strtotime($this->date_modification))
  81. ];
  82. //if ($this->isIndividualProgram) {
  83. $result['helyszinAdatok'] = [
  84. 'helyszin' => "kossuth utca",
  85. 'iranyitoszam' => "1111"
  86. ];
  87. //}
  88. /*
  89. if ($this->isCombinedProgram) {
  90. if (empty($this->associtedProducts) || !is_array($this->associtedProducts)) {
  91. throw new \Exception('Missing associated products to bundle ('.$this->ref.')');
  92. }
  93. $result['kapcsolodoProgramok'] = [];
  94. foreach ($this->associtedProducts as $associtedProduct) {
  95. if ($associtedProduct->ref == $this->ref) {
  96. continue;
  97. }
  98. $result['kapcsolodoProgramok'][] = [
  99. 'tssProgramAzonosito' => $associtedProduct->ref,
  100. 'utolsoModositasIdeje' => NtakDate::timestampToRfc3339(strtotime($associtedProduct->date_modification))
  101. ];
  102. }
  103. }
  104. */
  105. return $result;
  106. }
  107. }