| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
- require_once DOL_DOCUMENT_ROOT.'/custom/ntak/class/ntakconnector/ntak_const.class.php';
- class NtakProduct extends Product
- {
- public $associtedProducts;
- public $isIndividualProgram = true;
- public $isCombinedProgram = false;
- /**
- *
- */
- public function getNtakTicketValidType(): string
- {
- $type = NtakConst::TICKET_VALIDITY_TYPE_OTHER;
- $occasion = $this->array_options['options_occasions'];
- if ($occasion == 1) {
- $type = NtakConst::TICKET_VALIDITY_TYPE_ONE_TIME;
- } else if ($occasion > 1) {
- $type = NtakConst::TICKET_VALIDITY_TYPE_OTHER;
- } else {
- $duration = $this->duration_value;
- $durationUnit = $this->duration_unit;
- // daily by hours
- if ($durationUnit == 'h' && ($duration == 24 || $duration == 25)) {
- $type = NtakConst::TICKET_VALIDITY_TYPE_DAILY;
- }
- // daily by days
- if ($durationUnit == 'd' && $duration == 1) {
- $type = NtakConst::TICKET_VALIDITY_TYPE_DAILY;
- }
- // weekly
- if ($durationUnit == 'w' && $duration == 1) {
- $type = NtakConst::TICKET_VALIDITY_TYPE_WEEKLY;
- }
- // monthly
- if ($durationUnit == 'm' && $duration == 1) {
- $type = NtakConst::TICKET_VALIDITY_TYPE_MONTHLY;
- }
- }
- return $type;
- }
- /**
- *
- */
- public function getNtakMaxNumberOfUse(): int
- {
- $use = 999; // unlimited use/occasion
- $occasion = $this->array_options['options_occasions'];
- if ($occasion > 0) {
- $use = $occasion;
- }
- return $use;
- }
- /**
- *
- */
- public function getNtakVatCode(): string
- {
- $vat = (int) $this->default_vat_code;
- return NtakConst::getVatCodeByVat($vat);
- }
- /**
- *
- */
- public function getNtakProgramDetails(): array
- {
- $result = [
- 'helyszinAdatok' => new stdClass,
- 'programAlkategoria' => $this->array_options['options_sub_category'],
- 'programFokategoria' => $this->array_options['options_main_category'],
- 'programGyakorisaga' => "ALLANDO",
- 'onlineProgram' => boolval($this->array_options['options_online']),
- 'programKezdete' => date('Y-m-01\TH:i:sP'),
- 'programVege' => date('Y-m-t\TH:i:sP'), //"2022-04-30T23:59:59.99+02:00",
- 'programNeve' => $this->label,
- //'programTipusa' => ($this->isCombinedProgram) ? NtakConst::PROGRAM_TYPE_COMBINED : NtakConst::PROGRAM_TYPE_INDEPENDENT,
- 'programTipusa' => NtakConst::PROGRAM_TYPE_INDEPENDENT,
- //'szolgHelyProgramAzonosito' => "",
- 'tssProgramAzonosito' => $this->ref,
- 'utolsoModositasIdeje' => NtakDate::timestampToRfc3339(strtotime($this->date_modification))
- ];
- //if ($this->isIndividualProgram) {
- $result['helyszinAdatok'] = [
- 'helyszin' => "kossuth utca",
- 'iranyitoszam' => "1111"
- ];
- //}
- /*
- if ($this->isCombinedProgram) {
- if (empty($this->associtedProducts) || !is_array($this->associtedProducts)) {
- throw new \Exception('Missing associated products to bundle ('.$this->ref.')');
- }
- $result['kapcsolodoProgramok'] = [];
- foreach ($this->associtedProducts as $associtedProduct) {
- if ($associtedProduct->ref == $this->ref) {
- continue;
- }
- $result['kapcsolodoProgramok'][] = [
- 'tssProgramAzonosito' => $associtedProduct->ref,
- 'utolsoModositasIdeje' => NtakDate::timestampToRfc3339(strtotime($associtedProduct->date_modification))
- ];
- }
- }
- */
- return $result;
- }
- }
|