<?php
namespace App\Galileo\LineParser\Types;

/**
 * Data line
 * @author Lucian Sirbu
 */
class Data_A166 extends \App\Galileo\LineParser\Types\GalileoBase
{
	/**
	 * 6 - TUR - PASSIVE APOLLO TOUR OR ACTIVE GALILEO TOUR AND SURFACE AND 5 - AIR TAXI
	 */

	/**
	 * Children elements
	 */
	protected $children = [
		[ 'key'=>'A16SEC',  'type'=>'Constant', 	'len'=>3, 'val'=>'A16',  	'label'=>'SECTION LABEL "A16"' ],
		[ 'key'=>'A16TYP',  'type'=>'Constant', 	'len'=>1, 'val'=>'6',    	'label'=>'SEGMENT TYPE CODE' ],
		[ 'key'=>'A16NUM',  'type'=>'Integer',  	'len'=>2,                	'label'=>'ITINERARY INDEX NUMBER -' ],
		[ 'key'=>'A16DTE',  'type'=>'Date',     	'len'=>7,                	'label'=>'ARRIVAL DATE -' ],
		[ 'key'=>'A16TTY',  'type'=>'Letters',  	'len'=>1,                	'label'=>'TOUR TYPE ID APO: GCS:' ],
		[ 'key'=>'A16VEN',  'type'=>'StringRaw',    'len'=>2,                	'label'=>'VENDOR CODES' ],
		[ 'key'=>'A16VNN',  'type'=>'Letters',  	'len'=>32,               	'label'=>'VENDOR NAME' ],
		[ 'key'=>'A16CCC',  'type'=>'StringTrim',	'len'=>4,               	'label'=>'ALPHA CITY CODE' ],
		[ 'key'=>'A16STT',  'type'=>'Letters',  	'len'=>2,                	'label'=>'ACTION/STATUS CODE' ],
		[ 'key'=>'A16CDT',  'type'=>'DateDDMMM',	'len'=>5,             		'label'=>'RETURN DATE -' ],
		[ 'key'=>'A16DAY',  'type'=>'Integer',  	'len'=>3,                	'label'=>'NUMBER OF DAYS/NIGHTS' ],
		[ 'key'=>'A16CNI',  'type'=>'Integer',  	'len'=>1,                	'label'=>'NUMBER OF UNITS' ],
	];

	protected function postExtract(\App\Utils\BaseParser\TextParser\ExtractedBlock $ret)
	{
		$statuses = [
			'HK' => 'confirmed',
			'BK' => 'manual',
		];

		$ret->extractedData['A16STT_'] = $statuses[$ret->extractedData['A16STT']];

		// translate tour type
		$tourTypes = [
			'A'	=>	'airTaxi',
			'T' =>	'tour',
			'S' =>	'surface',
		];

		$ret->extractedData['A16TTY_'] = $tourTypes[$ret->extractedData['A16TTY']];

		return $ret;
	}
}
