<?php

add_action( 'acf/include_fields', function() {
	if ( ! function_exists( 'acf_add_local_field_group' ) ) {
		return;
	}

    if ( function_exists( 'acf_add_options_sub_page' ) ) {

    $options_page = acf_add_options_sub_page( array(
        'page_title'  => 'Fees Calculator Settings',
        'menu_title'  => 'Fees Calculator',
        'parent_slug' => 'rentpress',
        'menu_slug'   => 'fee-calculator-settings',
        'capability'  => 'manage_options',
    ) );

		acf_add_local_field_group( array(
		'key' => 'group_69430b8789914',
		'title' => 'Apartment Fees Calculator',
		'fields' => array(
			array(
				'key' => 'field_69430b872e8e6',
				'label' => 'Apartment Fees',
				'name' => 'apartment_fees',
				'aria-label' => '',
				'type' => 'repeater',
				'instructions' => 'Individual property Apartment fees will override the Global Apartment Fees.',
				'required' => 0,
				'conditional_logic' => 0,
				'wrapper' => array(
					'width' => '',
					'class' => '',
					'id' => '',
				),
				'layout' => 'block',
				'pagination' => 0,
				'min' => 0,
				'max' => 0,
				'collapsed' => '',
				'button_label' => 'Add Fee',
				'rows_per_page' => 20,
				'sub_fields' => array(
					array(
						'key' => 'field_69430c782e8e7',
						'label' => 'Fee Name',
						'name' => 'fee_name',
						'aria-label' => '',
						'type' => 'text',
						'instructions' => '',
						'required' => 1,
						'conditional_logic' => 0,
						'wrapper' => array(
							'width' => '100',
							'class' => '',
							'id' => '',
						),
						'default_value' => '',
						'maxlength' => '',
						'allow_in_bindings' => 0,
						'placeholder' => '',
						'prepend' => '',
						'append' => '',
						'parent_repeater' => 'field_69430b872e8e6',
					),
					array(
						'key' => 'field_694acad5e1c40',
						'label' => 'Show Fee Details',
						'name' => '',
						'aria-label' => '',
						'type' => 'accordion',
						'instructions' => '',
						'required' => 0,
						'conditional_logic' => 0,
						'wrapper' => array(
							'width' => '',
							'class' => '',
							'id' => '',
						),
						'open' => 0,
						'multi_expand' => 0,
						'endpoint' => 0,
						'parent_repeater' => 'field_69430b872e8e6',
					),
					array(
						'key' => 'field_69430c892e8e8',
						'label' => 'Description',
						'name' => 'description',
						'aria-label' => '',
						'type' => 'text',
						'instructions' => '',
						'required' => 0,
						'conditional_logic' => 0,
						'wrapper' => array(
							'width' => '100',
							'class' => '',
							'id' => '',
						),
						'default_value' => '',
						'maxlength' => '',
						'allow_in_bindings' => 0,
						'placeholder' => '',
						'prepend' => '',
						'append' => '',
						'parent_repeater' => 'field_69430b872e8e6',
					),
					array(
						'key' => 'field_69430caf2e8e9',
						'label' => 'Amount',
						'name' => 'amount',
						'aria-label' => '',
						'type' => 'number',
						'instructions' => '',
						'required' => 0,
						'conditional_logic' => 0,
						'wrapper' => array(
							'width' => '33.33',
							'class' => '',
							'id' => '',
						),
						'default_value' => '',
						'min' => '',
						'max' => '',
						'allow_in_bindings' => 0,
						'placeholder' => '',
						'step' => '.01',
						'prepend' => '$',
						'append' => '',
						'parent_repeater' => 'field_69430b872e8e6',
					),
					array(
						'key' => 'field_69430cf62e8ea',
						'label' => 'Frequency',
						'name' => 'frequency',
						'aria-label' => '',
						'type' => 'select',
						'instructions' => '',
						'required' => 0,
						'conditional_logic' => 0,
						'wrapper' => array(
							'width' => '66.66',
							'class' => '',
							'id' => '',
						),
						'choices' => array(
							'onetime' => 'One Time',
							'monthly' => 'Monthly',
							'annual' => 'Annual',
						),
						'default_value' => 'monthly',
						'return_format' => 'value',
						'multiple' => 0,
						'allow_null' => 0,
						'allow_in_bindings' => 0,
						'ui' => 0,
						'ajax' => 0,
						'placeholder' => '',
						'create_options' => 0,
						'save_options' => 0,
						'parent_repeater' => 'field_69430b872e8e6',
					),
					array(
						'key' => 'field_69430d572e8eb',
						'label' => 'Transactional',
						'name' => 'transactional',
						'type' => 'true_false',
						'message' => 'Transactional fee that residents can opt out of.',
						'ui' => 1,
						'wrapper' => array(
							'width' => '33',
							'class' => 'flip-ui',
						),
					),
					array(
						'key' => 'field_min_one_qty',
						'label' => 'Min One',
						'name' => 'min_one',
						'type' => 'true_false',
						'message' => 'Always require at least 1.',
						'ui' => 1,
						'conditional_logic' => array(
							array(
								array(
									'field' => 'field_69430d572e8eb',
									'operator' => '==',
									'value' => '1',
								),
							),
						),
						'wrapper' => array(
							'width' => '33',
							'class' => 'flip-ui',
						),
					),
					array(
						'key' => 'field_695d54de04dc1',
						'label' => 'Max Number',
						'name' => 'max_number',
						'type' => 'number',
						'step' => 1,
						'conditional_logic' => array(
							array(
								array(
									'field' => 'field_69430d572e8eb',
									'operator' => '==',
									'value' => '1',
								),
							),
						),
						'wrapper' => array(
							'width' => '33',
							'class' => 'flip-ui',
						),
					),
				),
			),
			array(
				'key' => 'field_69430e972e8ec',
				'label' => 'Message Box',
				'name' => 'message_box',
				'aria-label' => '',
				'type' => 'wysiwyg',
				'instructions' => 'Add text or additional info under the totals container.',
				'required' => 0,
				'conditional_logic' => 0,
				'wrapper' => array(
					'width' => '',
					'class' => '',
					'id' => '',
				),
				'default_value' => '',
				'allow_in_bindings' => 0,
				'tabs' => 'all',
				'toolbar' => 'basic',
				'media_upload' => 0,
				'delay' => 1,
			),
		),
		'location' => array(
			array(
				array(
					'param' => 'post_type',
					'operator' => '==',
					'value' => 'rentpress_property',
				),
			),
			array(
				array(
	                'param'    => 'options_page',
	                'operator' => '==',
	                'value'    => 'fee-calculator-settings', 
	            ),
			),
		),
		'menu_order' => 20,
		'position' => 'normal',
		'style' => 'default',
		'label_placement' => 'top',
		'instruction_placement' => 'label',
		'hide_on_screen' => '',
		'active' => true,
		'description' => '',
		'show_in_rest' => 1,
		'display_title' => '',
		) );
	}
} );