<?php
namespace App\Amadeus\FileParser;

/**
 * Parser for the Ground Transportation segments
 * @author Lucian
 */
class Line_U_10 extends \App\Amadeus\FileParser\Line_U_09
{
	/**
	 * 4.36. U- Ground Transportation Segment
	 * see page 116(158)
	 *
	 * Contains booking and confirmation information of ground transportation, limousine, or taxi, to or from airports.
	 *
	 * @see http://www.amadeus.com/ir/documents/aco/ir/en/Amadeus_EK_Chauffeur-Drive.pdf
	 * @see http://vip-asb.vipservice.ru/attach/file_9519_2.doc
	 *
	 * see MAIL:[AMA] ground transportation
	 * 	- de unde se preiau preturi pt acest segment?
	 * 		[Alina Popescu] sunt servicii fara cost pe care liniile le pot pune la dispozitie pentru pasagerii care calatoresc
	 * 		in first sau business (aici ma refer la limo). Sunt si alte servicii (ex: bus intre punctele de conexiune) pe care
	 * 		liniile le pot pune la dispozitie si pentru alte clase, dar depinde de companie si de ruta.
	 * 	- in afara de CHFD, ce alte tag-uri mai pot veni? Exista o lista cu ele?
	 * 		[Alina Popescu] nu am o lista cu aceste coduri, depinde foarte tare de ceea ce pune la dispozitie compania si de procedura de lucru transmisa.
	 */
	protected $structure_10 = [
		['name'=> 'MSGTAG',     'val' => 'U-',    'type' => 'AN',   'req' => 'M',                    'len' => 2,],                          // 1 : Message Tag (U-)
		['name'=> 'TTONBR',                       'type' => 'N',    'req' => 'M',                    'len' => 3,],                          // 2 : Tattoo Number in the PNR
		['name'=> 'DATAMODI',                     'type' => 'AN',                                    'len' => 1,],                          // 3 : Modification indicator.N = segment/element newly created,M = segment/element modified,U = segment/element unchangedX = modification indicator not available for the segment/element
		['name'=> 'DELIM',      'val' => ';',     'type' => 'AN',   'req' => 'M',                    'len' => 1,],                          // 4 : Delimiter (Constant value of ';')
		['name'=> 'SEGNBR',                       'type' => 'N',    'req' => 'M',                    'len' => 3,],                          // 5 : Segment number in the PNR
		['name'=> 'SEGID',      'val' => 'SUR',   'type' => 'AN',   'req' => 'M',                    'len' => 3,],                          // 6 : Segment Identifier Tag (Constant value of 'SUR')
		['name'=> 'DELIM',      'val' => ' ',     'type' => 'AN',   'req' => 'M',                    'len' => 1,],                          // 7 : Delimiter (Constant value of blank)
		['name'=> 'AIRCDE',                       'type' => 'AN',   'req' => 'M',                    'len_min' => 2,   'len_max' => 4,],    // 8 : Airline Code/Supplier Code.
		['name'=> 'DELIM',      'val' => ' ',     'type' => 'AN',   'req' => 'M',                    'len' => 1,],                          // 9 : Delimiter (Constant value of blank)
		['name'=> 'STATUS',                       'type' => 'AN',   'req' => 'M',                    'len' => 2,],                          // 10 : Status Code
		['name'=> 'NBRSVC',                       'type' => 'N',    'req' => 'M',                    'len' => 2,],                          // 11 : Number in party.
		['name'=> 'DELIM',      'val' => ';',     'type' => 'AN',   'req' => 'M',                    'len' => 1,],                          // 12 : Delimiter (Constant value of ';')
		['name'=> 'PNRSTAT',                      'type' => 'AN',   'req' => 'M',                    'len' => 4,],                          // 13 : PNR Status Code and Number in Party
		['name'=> 'DELIM',      'val' => ' ',     'type' => 'AN',   'req' => 'M',                    'len' => 1,],                          // 14 : Delimiter (Constant value of blank)
		['name'=> 'PICKUP',                       'type' => 'D:DDMMMYYYY|DDMMM:PNRDTE','req'=>'M',],                          // 15 : Pick Up Date (DDMMM)
		['name'=> 'DELIM',      'val' => ';',     'type' => 'AN',   'req' => 'M',                    'len' => 1,],                          // 16 : Delimiter (Constant value of ';')
		['name'=> 'AIRPRT',                       'type' => 'AN',   'req' => 'M',                    'len_min' => 3,   'len_max' => 5,],    // 17 : Pickup/Dropoff Airport City Code
		['name'=> 'DELIM',      'val' => ';',     'type' => 'AN',   'req' => 'M',                    'len' => 1,],                          // 18 : Delimiter (Constant value of ';')
		['name'=> 'CDETRAN1',                     'type' => 'AN',],                                                                         // 19 : Airport/City Code Translation
		['name'=> 'DELIM',      'val' => ';',     'type' => 'AN',   'req' => 'M',                    'len' => 1,],                          // 20 : Delimiter (Constant value of ';')
		['name'=> 'GRNDCDE',                      'type' => 'AN',   'req' => 'M',                    'len' => 4,],                          // 21 : Ground Transportation Code
		['name'=> 'DELIM',      'val' => ';',     'type' => 'AN',   'req' => 'M',                    'len' => 1,],                          // 22 : Delimiter (Constant value of ';')
		['name'=> 'CDETRAN2',                     'type' => 'AN',],                                                                         // 23 : Ground Transportation Translation
		['name'=> 'DELIM',      'val' => ';',     'type' => 'AN',   'req' => 'M',                    'len' => 1,],                          // 24 : Delimiter (Constant value of ';')
		['name'=> 'TIME',                         'type' => 'HR',   'req' => 'M',                    'len' => 5,],                          // 25 : Pick up time (24 Hour Clock HHMM) 24 Hour Clock HHMM 12 Hour Clock HHMMx where x is: A=AM, P=PM, N=Noon, M=Midnight
		['name'=> 'DEPARR',                       'type' => 'AN',   'req' => 'M',                    'len' => 1,],                          // 26 : Departure/Arrival Code (D or A)
		['name'=> 'DELIM',      'val' => ';',     'type' => 'AN',   'req' => 'M',                    'len' => 1,],                          // 27 : Delimiter (Constant value of ';')
		['name'=> 'ZONECD',                       'type' => 'AN',   'req' => 'M',                    'len' => 1,],                          // 28 : Transportation Zone Code (1 or 2)
		['name'=> 'DELIM',      'val' => ';',     'type' => 'AN',   'req' => 'M',                    'len' => 1,],                          // 29 : Delimiter (Constant value of ';')
		['name'=> 'PSGRINFO',                     'type' => 'AN',   'req' => 'M',                    'len_min' => 3,   'len_max' => 40,],   // 30 : Pseudo City Code Name and Passenger Address
		['name'=> 'DELIM',      'val' => ';',     'type' => 'AN',   'req' => 'M',                    'len' => 1,],                          // 31 : Delimiter (Constant value of ';')
		['name'=> 'PHONE',                        'type' => 'AN',                                    'len_min' => 6,   'len_max' => 40,],   // 32 : Passenger Contact Phone Field
		['name'=> 'DELIM',      'val' => ';',     'type' => 'AN',   'req' => 'M',                    'len' => 1,],                          // 33 : Delimiter (Constant value of ';')
		['name'=> 'FREE',                         'type' => 'AN',],                                                                         // 34 : Free Flow Data
		['name'=> 'DELIM',      'val' => ';',     'type' => 'AN',   'req' => 'M',                    'len' => 1,],                          // 35 : Delimiter (Constant value of ';')
		['name'=> 'FLNTAG',                       'type' => 'AN',                                    'len' => 4,],                          // 36 : FLWN' (flown/past date segment tag when present in the PNR)
		['name'=> 'PSGASS',     'val' => ';P',    'type' => 'ASSOC',],
	];

	protected static $structure_10_GRNDCDE = [
		'CHFD' => 'EK Chauffeur Drive',
	];

	/**
	 * (non-PHPdoc)
	 * @see \App\Amadeus\FileParser\Line_U_09::postParse()
	 */
	protected function postParse()
	{
		parent::postParse();

		if($this->tree['_type'] == '10'){	// ground transportation
			$this->tree['GRNDCDE_'] = 	self::$structure_10_GRNDCDE[$this->tree['GRNDCDE']];
		}
	}
}
