<?php
namespace App\Amadeus\StructureParser\Structures\EMD; class ServiceDetails extends \App\Amadeus\StructureParser\Structures\MCO\ServiceDetails { public function getDetails() { if($this->CACHE[__METHOD__]) return $this->CACHE[__METHOD__]; $parsedStructure = $this->transaction->getParsedStructure(); $indexType = $this->transaction->getIndexType(); $index = $this->transaction->getIndex(); $U = $parsedStructure['U'][$index->segment??null]; if($indexType=='EMD'){ $details = $this->getDetails_EMD(); if($details){ $this->CACHE[__METHOD__] = $details; return $details; } } if($indexType=='U' && $U['_type']=='19'){ $pax = $this->getDetails_U_19(); if($pax){ $this->CACHE[__METHOD__] = $pax; return $pax; } } return null; } public function getRelations() { if($this->CACHE[__METHOD__]) return $this->CACHE[__METHOD__]; $parsedStructure = $this->transaction->getParsedStructure(); $indexType = $this->transaction->getIndexType(); $index = $this->transaction->getIndex(); $U = $parsedStructure['U'][$index->segment??null]; if($indexType=='EMD'){ $details = $this->getRelations_EMD(); if($details){ $this->CACHE[__METHOD__] = $details; return $details; } } if($indexType=='U' && $U['_type']=='19'){ $details = $this->getRelations_U_19(); if($details){ $this->CACHE[__METHOD__] = $details; return $details; } } return null; } public function getRemarks() { if($this->CACHE[__METHOD__]) return $this->CACHE[__METHOD__]; $parsedStructure = $this->transaction->getParsedStructure(); $indexType = $this->transaction->getIndexType(); $index = $this->transaction->getIndex(); $item = new \App\Amadeus\StructureParser\Types\Remarks(); if ($indexType=='EMD') { $EMD = $parsedStructure['EMD'][$index->EMD[0]]; $I = \App\Amadeus\StructureParser\Helpers::internal_MCO_MCO_to_I($parsedStructure, $EMD, $this->transaction); $item = $this->getRemarksFromPassenger($parsedStructure, $index, $item, $I, $indexType); } $this->CACHE[__METHOD__] = $item; return $item; } protected function getDetails_EMD() { $parsedStructure = $this->transaction->getParsedStructure(); $index = $this->transaction->getIndex(); $item = null; $EMD = $parsedStructure['EMD'][$index->EMD[0]]; if($EMD){ $item = new \App\Amadeus\StructureParser\Types\ServiceDetails(); $item->reasonCode = $EMD['REASON']; $item->reasonCode_text = $EMD['RFICDESC']; $item->reasonSubCode = $EMD['RFISC']; $item->reasonSubCode_text = $EMD['RFISCDESC']; $item = $this->extractCommonServiceDetails($parsedStructure, $item); return $item; } return $item; } protected function getRelations_EMD() { $parsedStructure = $this->transaction->getParsedStructure(); $index = $this->transaction->getIndex(); $EMD = $parsedStructure['EMD'][$index->EMD[0]]; $relations = new \App\Amadeus\StructureParser\Types\Relations(); if ($EMD && $EMD['ICW']) { $documentRelations = []; foreach ($EMD['ICW'] as $ICW) { foreach ($ICW['ICW'] as $subICW) { if ($subICW['ICWTKT1_']['tktNo']) { $r = new \App\Amadeus\StructureParser\Types\Relation(); $r->docNumber = $subICW['ICWTKT1_']['tktNo']; $r->relationType = "reference"; $documentRelations[$r->docNumber] = $r; } if ($subICW['ICWTKT2_']['tktNo']) { $r = new \App\Amadeus\StructureParser\Types\Relation(); $r->docNumber = $subICW['ICWTKT2_']['tktNo']; $r->relationType = "reference"; $documentRelations[$r->docNumber] = $r; } } } foreach ($documentRelations as $r) { $relations->relations[] = $r; } } return $relations; } protected function getDetails_U_19() { $parsedStructure = $this->transaction->getParsedStructure(); $index = $this->transaction->getIndex(); $item = null; $U = $parsedStructure['U'][$index->segment]; if($U){ $item = new \App\Amadeus\StructureParser\Types\ServiceDetails(); $item->reasonCode = $U['REASON']; $item->reasonCode_text = $U['RFICDESC']; $item->reasonSubCode = $U['RFISC']; $item->reasonSubCode_text = $U['RFISCDESC']; $item = $this->extractCommonServiceDetails($parsedStructure, $item); return $item; } return $item; } protected function getRelations_U_19() { return parent::getRelations(); } } 