<?php
namespace App\Worldspan\LineParser\Types\Line;

/**
 *
 * @author Lucian Sirbu
 */
class R04 extends \App\Worldspan\LineParser\Types\WorldspanBaseLine
{
	protected $extractRegexp = "/^(?P<rawData>(0|\*)4.+)/sm";

	protected $children = [
        /**
         * This record contains the fare basis codes and validity date restrictions for tickets of passengers belonging to the second, third, and fourth PTC groups
         * The status code and endorsements unique to the Infant PTC are sent in this record
         * A new field (BP-) has been added to accommodate a new commission structure instituted by British Airways
         */

        ['key'=> 'RecordIdentifier',                  'type'=> 'StringRaw',            'len'=> 1,                                   'req'=> false,],             // Record identifier
        ['key'=> 'key',                               'type'=> 'Constant',          'len'=> 2,                    'val'=> '4\\', 'req'=> true,],              // Additional PTC code
        ['key'=> 'FareBasisCodeTicketDesignator',     'type'=> 'StringDelimitedByChar',   'len'=> [0, 15],         'val'=> '\\',  'req'=> false,],             // Fare basis code/Ticket Designator
        ['key'=> '#020',                              'type'=> 'Separator',                                                      'req'=> false,],             // Field Separator
        ['key'=> 'NotValidBeforeDate',                'type'=> 'Date',              'len'=> 5,     'fmt'=> 'DDMMM',              'req'=> false, 'ref'=>'BookingDateAndYear', 'onlyFuture'=>true,],             // Not valid before date
        ['key'=> '#022',                              'type'=> 'Separator',                                                      'req'=> false,],             // Field Separator
        ['key'=> 'NotValidAfterDate',                 'type'=> 'Date',              'len'=> 5,     'fmt'=> 'DDMMM',              'req'=> false,],             // Not valid after date
        ['key'=> '#024',                              'type'=> 'Separator',                                                      'req'=> false, 'ref'=>'BookingDateAndYear', 'onlyFuture'=>true,],             // Field Separator

        ['key'=> 'SteatStatus',                       'type'=> 'StringDelimitedByChar',                                'val'=> '\\',   'req'=> true,],              // Seat Status â€“(See Note 7)
        ['key'=> '#026',                              'type'=> 'Separator',                                                      'req'=> false,],             // Field Separator

        ['key'=> 'complex:12',                        'type'=> 'Complex', 'merge'=>true,                                         'req'=> false, 'children'=> [
            ['key'=> 'key',                               'type'=> 'Constant',          'len'=> 3,                    'val'=> 'BG-', 'req'=> true,],              // Baggage Field identifier
            ['key'=> 'BaggageAllowance',                  'type'=> 'StringDelimitedByChar',   'len'=> [0, 3],          'val'=> '\\',  'req'=> false,],             // Baggage allowance (See note 8)
		]],
        ['key'=> '#029',                              'type'=> 'Separator',                                                      'req'=> false,],             // Field Separator

        ['key'=> 'complex:14',                        'type'=> 'Complex', 'merge'=>true,                                         'req'=> false, 'children'=> [
            ['key'=> 'key',                               'type'=> 'Constant',          'len'=> 2,                    'val'=> 'E-',  'req'=> true,],              // Endorsement identifier
		]],
        ['key'=> '#031',                              'type'=> 'Separator',                                                      'req'=> false,],             // Field Separator
        ['key'=> 'key',                               'type'=> 'Constant',          'len'=> 3,                    'val'=> 'BP-', 'req'=> false,],             // Booking Payment field identifier
        ['key'=> 'BookingPaymentAmount',              'type'=> 'StringRaw',            'len'=> [0, 6],                         'req'=> false,],             // Booking Payment amount


	];
}
