<?php
/**
 * @package     productive-forms
 * @author      productiveminds.com
 * @copyright   productiveminds.com
*/

function productive_forms_render_contact_us_page( $cpt_section_args ) {
    
    $section_content_header_is_show_section_header = 1;
    $section_title = esc_html__('Message Us', 'productive-forms');
    $section_title_suffix = '';
    $section_title_html_tag = 'h2';
    $section_intro = esc_html__('Leave heading fields empty to hide the heading.', 'productive-forms');
    $section_heading_auxiliary = '';
    $section_heading_auxiliary_position = 'bottom';
    $section_header_alignment = '';
    $section_content_settings_unique_id = 'section_content_unique_id_'. rand();
    $section_initiator = 'std';
    $section_gtbg_align = '';
    $section_content_wrap_in_small_screen = 'wrap_to_one_column_in_small_screen';
    
    if ( isset( $cpt_section_args['section_content_header_is_show_section_header'] ) ) {
        $section_content_header_is_show_section_header = $cpt_section_args['section_content_header_is_show_section_header'];
    }
    if ( isset( $cpt_section_args['section_title'] ) ) {
        $section_title = $cpt_section_args['section_title'];
    }
    if ( isset( $cpt_section_args['section_title_suffix'] ) ) {
        $section_title_suffix = $cpt_section_args['section_title_suffix'];
    }
    if ( isset( $cpt_section_args['section_title_html_tag'] ) ) {
        $section_title_html_tag = $cpt_section_args['section_title_html_tag'];
    }
    if ( isset( $cpt_section_args['section_intro'] ) ) {
        $section_intro = $cpt_section_args['section_intro'];
    }
    if ( isset( $cpt_section_args['section_heading_auxiliary'] ) ) {
        $section_heading_auxiliary = $cpt_section_args['section_heading_auxiliary'];
    }
    if ( isset( $cpt_section_args['section_heading_auxiliary_position'] ) ) {
        $section_heading_auxiliary_position = $cpt_section_args['section_heading_auxiliary_position'];
    }
    if ( isset( $cpt_section_args['section_header_alignment'] ) ) {
        $section_header_alignment = $cpt_section_args['section_header_alignment'];
    }
    if ( isset( $cpt_section_args['section_content_settings_unique_id'] ) ) {
        $section_content_settings_unique_id = $cpt_section_args['section_content_settings_unique_id'];
    }
    if ( isset( $cpt_section_args['section_initiator'] ) ) {
        $section_initiator = $cpt_section_args['section_initiator'];
    }
    if ( isset( $cpt_section_args['section_gtbg_align'] ) ) {
        $section_gtbg_align = $cpt_section_args['section_gtbg_align'];
    }
    if ( isset( $cpt_section_args['section_content_wrap_in_small_screen'] ) ) {
        $section_content_wrap_in_small_screen = $cpt_section_args['section_content_wrap_in_small_screen'];
    }
    $productiveminds_section_display = 'grided';
    ?>
    <div class="productiveminds_section contact-us-page <?php echo esc_attr( $section_content_wrap_in_small_screen ); ?> <?php echo esc_attr( $productiveminds_section_display ); ?> <?php echo esc_attr( $section_initiator ); ?> <?php echo esc_attr( $section_gtbg_align ); ?>" id="<?php echo esc_attr( $section_content_settings_unique_id ); ?>">
        <div class="productiveminds_section_uno">
    <?php
    
    if ( $section_content_header_is_show_section_header ) {
        $header_misc = array(
            'section_title'                         => $section_title,
            'section_title_suffix'                  => $section_title_suffix,
            'section_title_html_tag'                => $section_title_html_tag,
            'section_heading_auxiliary'             => $section_heading_auxiliary,
            'section_heading_auxiliary_position'        => $section_heading_auxiliary_position,
            'section_intro'                         => $section_intro,
            'section_header_alignment'              => $section_header_alignment,
        );
        productive_global_render_section_header( $header_misc );
    }
    
    $is_formonly = 0;
    $productive_forms_form_submit_text = esc_html__('Send', 'productive-forms');
    $productive_forms_contact_side = 'contact_form_on_left';
    $display_contact_form_label = 0;
    $section_style_content_button_hover_animation = '';
    $contact_how_to_display_contact_name_field = 'combined_field';
    $contact_ask_for_visitor_phone = 0;
    $request_data_privacy_consent = 1;
    $submission_verify_type = 'discreet';
    $display_contact_email_address = 1;
    $display_contact_phone_number = 1;
    $display_contact_whatsapp_number = 1;
    $display_contact_location = 1;
    $display_contact_opening_hours = 1;
    $section_show_social_media_follow = 1;
    $section_show_social_media_follow_on_copy = esc_html__('Follow us on', 'productive-forms');
    $slider_swiper_css_class_from_elementor = 'via_std';

    if ( isset( $cpt_section_args['is_formonly'] ) ) {
        $is_formonly = intval( $cpt_section_args['is_formonly'] );
    }
    if ( isset( $cpt_section_args['productive_forms_form_submit_text'] ) ) {
        $productive_forms_form_submit_text = $cpt_section_args['productive_forms_form_submit_text'];
    }
    if ( isset( $cpt_section_args['productive_forms_contact_side'] ) ) {
        $productive_forms_contact_side = $cpt_section_args['productive_forms_contact_side'];
    }
    if ( isset( $cpt_section_args['display_contact_form_label'] ) ) {
        $display_contact_form_label = $cpt_section_args['display_contact_form_label'];
    }
    if ( isset( $cpt_section_args['section_style_content_button_hover_animation'] ) ) {
        $section_style_content_button_hover_animation = $cpt_section_args['section_style_content_button_hover_animation'];
    }
    if ( isset( $cpt_section_args['contact_how_to_display_contact_name_field'] ) ) {
        $contact_how_to_display_contact_name_field = $cpt_section_args['contact_how_to_display_contact_name_field'];
    }
    if ( isset( $cpt_section_args['contact_ask_for_visitor_phone'] ) ) {
        $contact_ask_for_visitor_phone = intval( $cpt_section_args['contact_ask_for_visitor_phone'] );
    }
    if ( isset( $cpt_section_args['request_data_privacy_consent'] ) ) {
        $request_data_privacy_consent = intval( $cpt_section_args['request_data_privacy_consent'] );
    }
    if ( isset( $cpt_section_args['submission_verify_type'] ) ) {
        $submission_verify_type = $cpt_section_args['submission_verify_type'];
    }
    if ( isset( $cpt_section_args['display_contact_email_address'] ) ) {
        $display_contact_email_address = intval( $cpt_section_args['display_contact_email_address'] );
    }
    if ( isset( $cpt_section_args['display_contact_phone_number'] ) ) {
        $display_contact_phone_number = intval( $cpt_section_args['display_contact_phone_number'] );
    }
    if ( isset( $cpt_section_args['display_contact_whatsapp_number'] ) ) {
        $display_contact_whatsapp_number = intval( $cpt_section_args['display_contact_whatsapp_number'] );
    }
    if ( isset( $cpt_section_args['display_contact_location'] ) ) {
        $display_contact_location = intval( $cpt_section_args['display_contact_location'] );
    }
    if ( isset( $cpt_section_args['display_contact_opening_hours'] ) ) {
        $display_contact_opening_hours = intval( $cpt_section_args['display_contact_opening_hours'] );
    }
    if ( isset( $cpt_section_args['section_show_social_media_follow'] ) ) {
        $section_show_social_media_follow = intval( $cpt_section_args['section_show_social_media_follow'] );
    }
    if ( isset( $cpt_section_args['section_show_social_media_follow_on_copy'] ) ) {
        $section_show_social_media_follow_on_copy = $cpt_section_args['section_show_social_media_follow_on_copy'];
    }
    if ( isset( $cpt_section_args['slider_swiper_css_class_from_elementor'] ) ) {
        $slider_swiper_css_class_from_elementor = $cpt_section_args['slider_swiper_css_class_from_elementor'];
    }
    
    $form_unique_id = mt_rand(1, 100);
    
    $misc = array(
        'form_unique_id'                                        => $form_unique_id,
        'productive_forms_contact_side'                         => $productive_forms_contact_side,
        'productive_forms_form_submit_text'                     => $productive_forms_form_submit_text,
        'is_formonly'                                           => $is_formonly,
        'display_contact_form_label'                            => $display_contact_form_label,
        'section_style_content_button_hover_animation'          => $section_style_content_button_hover_animation,
        'contact_how_to_display_contact_name_field'             => $contact_how_to_display_contact_name_field,
        'contact_ask_for_visitor_phone'                         => $contact_ask_for_visitor_phone,
        'request_data_privacy_consent'                          => $request_data_privacy_consent,
        'submission_verify_type'                                => $submission_verify_type,
        'display_contact_email_address'                         => $display_contact_email_address,
        'display_contact_phone_number'                          => $display_contact_phone_number,
        'display_contact_whatsapp_number'                       => $display_contact_whatsapp_number,
        'display_contact_location'                              => $display_contact_location,
        'display_contact_opening_hours'                         => $display_contact_opening_hours,
        'section_show_social_media_follow'                    => $section_show_social_media_follow,
        'section_show_social_media_follow_on_copy'              => $section_show_social_media_follow_on_copy,
    );

    productive_forms_render_contact_us_page_content( $misc );

    ?>
        </div><!-- productiveminds_section_uno -->
    </div><!-- productiveminds_section -->
    <?php
}


function productive_forms_render_contact_form_with_shortcode() {
    $cpt_section_args = array(
        'is_formonly'       => 1,
    );
    productive_forms_render_contact_us_page( $cpt_section_args );
}
add_shortcode('productive_contact_form', 'productive_forms_render_contact_form_with_shortcode');
add_shortcode('productive_contact_form_ajax', 'productive_forms_render_contact_form_with_shortcode');

function productive_forms_render_contact_us_page_with_shortcode() {
    $cpt_section_args = array(
        'is_formonly'       => 0,
    );
    
//    productive_forms_render_contact_us_page( $cpt_section_args );
    
    $attributes = array();
    $attributes['section_bg_color_scheme'] = 'section_with_themed_bg';
    $attributes['section_block_max_width'] = 'siteMaxWidth_Std';
    $attributes['section_block_spacing'] = 'section_spacing_default';
    $attributes['section_content_show_url_button_shape'] = 'shapeable-content-button-rounded-corner';
    $attributes['section_content_show_url_button_width'] = 'button-width-auto';
    $attributes['display_contact_social_media_icons_style'] = 'brand_color_around_white_icon';

    $section_gtbg_align = '';    
    
    $section_bg_color_scheme        = 'productive-paddable-section page_main_section_container ' . $section_gtbg_align 
        . ' ' . $attributes['section_bg_color_scheme'] . ' ' . $attributes['section_block_max_width'] . ' ' . $attributes['section_block_spacing'];
    
    $section_content_show_url_button_shape = '';
    if( isset($attributes['section_content_show_url_button_shape']) ) {
        $section_content_show_url_button_shape = $attributes['section_content_show_url_button_shape'];
    }
    $section_content_show_url_button_width = '';
    if( isset($attributes['section_content_show_url_button_width']) ) {
        $section_content_show_url_button_width = $attributes['section_content_show_url_button_width'];
    }
    $display_contact_social_media_icons_style = '';
    if( isset($attributes['display_contact_social_media_icons_style']) ) {
        $display_contact_social_media_icons_style = $attributes['display_contact_social_media_icons_style'];
    }
    $section_content_items_css_classes = ' ' . $section_content_show_url_button_shape . ' ' . $display_contact_social_media_icons_style 
        . ' ' . $section_content_show_url_button_width;
    
    ob_start();
    
    do_action( 'productive_global_render_content_wrapper_full_full_top', $section_bg_color_scheme );
        do_action( 'productive_global_render_content_wrapper_full_top', $section_content_items_css_classes );
            productive_forms_render_contact_us_page( $cpt_section_args );
        do_action('productive_global_render_content_wrapper_full_bottom');
    do_action('productive_global_render_content_wrapper_full_full_bottom');
    
    $content_to_render = ob_get_clean();
    
    return $content_to_render; 
    
}
add_shortcode('productive_contact_page', 'productive_forms_render_contact_us_page_with_shortcode');
add_shortcode('productive_contact_page_ajax', 'productive_forms_render_contact_us_page_with_shortcode');
