<?php

if ( ! defined( 'ABSPATH' ) ) {
	 exit;
}

// phpcs:ignoreFile WordPress.Files.FileName.NotHyphenatedLowercase
$form_row          = is_object( $row ) ? $row : (object) array();
$current_form_id   = isset( $form_row->id ) ? absint( $form_row->id ) : 0;
$current_form_name = isset( $form_row->name ) ? $form_row->name : '';
$preview_page_id   = (int) get_option( 'wpefb_preview_page_id', 0 );
$preview_url       = $preview_page_id ? get_permalink( $preview_page_id ) : home_url( '/' );
if ( ! is_string( $preview_url ) || '' === $preview_url ) {
	$preview_url = home_url( '/' );
}
$preview_url = add_query_arg( 'id', $current_form_id, $preview_url );
?>
<div class="advrf-wrapper wrap wef-forms-modern wef-dashboard-modern wef-configure-modern">
    <div class="advrf-page-title">		 
        <h1 class="wpefb-page-heading">
            <?php echo esc_html( $current_form_name ); ?></h1>
        <ul class="advrf-nav">
            <li class="advrf-nav-item">
                <a href="<?php echo esc_url( admin_url( 'admin.php?page=wpefb_manage_forms' ) ); ?>">
                    <span class="dashicons dashicons-feedback"></span>
                    <?php esc_html_e( 'All Forms', 'vedrixa-forms-registration-builder' ); ?></a>
            </li>
            <li class="advrf-nav-item">
                <a href="<?php echo esc_url( admin_url( 'admin.php?page=wpefb_form_dashboard&id=' . $current_form_id ) ); ?>">
                    <span class="dashicons dashicons-admin-generic"></span>
                    	<?php esc_html_e( 'Dashboard', 'vedrixa-forms-registration-builder' ); ?>					</a>
            </li>
            <li class="advrf-nav-item">
                <a target="_blank" href="<?php echo esc_url( $preview_url ); ?>">
                    <span class="dashicons dashicons-visibility"></span>
                     <?php esc_html_e( 'Preview', 'vedrixa-forms-registration-builder' ); ?>	</a>
            </li>    
        </ul>
        
         </div>
    <div class="clearfix">
        <div class="advrf-form-conf-wrapper">
            <form action="" method="post" id="advrf_configuration_form">
                <fieldset class="advrf-config-wrap">
                    <div>
                        <div class="group-title">
                            <?php esc_html_e( 'Auto Responder', 'vedrixa-forms-registration-builder' ); ?>				</div>
                        <div class="group-wrap">
                            
                                <div class="advrf-row">
						<div class="advrf-control-label">
							<label><?php esc_html_e( 'Auto-Reply the User', 'vedrixa-forms-registration-builder' ); ?></label>
						</div>
						<div class="advrf-control advrf-has-child">
                                                    <input class="advrf_toggle"  type="checkbox" value="1" id="wpefb_auto_reply_user" name="meta[wpefb_auto_reply_user]" data-has-child="1" data-toggle-target="wpefb_auto_reply_user_html" 
                                                    <?php
                                                    if ( isset( $meta['wpefb_auto_reply_user'] ) ) {
														checked( $meta['wpefb_auto_reply_user'], 1 );}
													?>
                                                      />
							<label></label>
							<p class="description"><?php esc_html_e( 'Turns on auto responder email for the form. After successful submission a customizable email is sent to the user.', 'vedrixa-forms-registration-builder' ); ?></p>
						</div>  
					</div>
                            
                            <div class="advrf-child-rows advrf-child-options" id="wpefb_auto_reply_user_html" style="<?php echo ! empty( $meta['wpefb_auto_reply_user'] ) ? '' : 'display:none'; ?>">
                                
                                <div class="advrf-row">
                                <div class="advrf-control-label">
                                    <label><?php esc_html_e( 'Subject', 'vedrixa-forms-registration-builder' ); ?></label>
                                </div>
                                <div class="advrf-control">
                                    <input type="text" class="advrf-input-field" name="meta[wpefb_email_subject]" value="<?php echo esc_attr( isset( $meta['wpefb_email_subject'] ) ? $meta['wpefb_email_subject'] : '' ); ?>">
                                    <p class="description"><?php esc_html_e( 'Subject of the mail sent to the user.', 'vedrixa-forms-registration-builder' ); ?></p>
                                </div>
                                 
                            </div>
                            
                            <div class="advrf-row">
						<div class="advrf-control-label">
							<label><?php esc_html_e( 'Body(Mail Merge and HTML Supported)', 'vedrixa-forms-registration-builder' ); ?></label>
						</div>
						<div class="advrf-control">
							<?php
							$editor_id                               = 'wpefb_email_content';
							$settings                                = array(
								'wpautop'           => false,
								'media_buttons'     => true,
								'textarea_name'     => 'meta[wpefb_email_content]',
								'textarea_rows'     => 20,
								'tabindex'          => '',
								'tabfocus_elements' => ':prev,:next',
								'editor_css'        => '',
								'editor_class'      => 'advrf-editor',
								'teeny'             => false,
								'dfw'               => false,
								'tinymce'           => true, // <-----
								'quicktags'         => true,
							);
                                                        $before_form = isset( $meta['wpefb_email_content'] )?$meta['wpefb_email_content']:'';
							wp_editor( $before_form, $editor_id, $settings );
							?>
							<p class="description">
								<?php esc_html_e( 'Content of the email to be sent to the user. You can use rich text and values the user submitted in the form for a more personalized message. If you are creating a new form, Add Fields drop down will be empty. You can come back after adding fields to the form. You can also use {{SUBMISSION_DATA}} placeholder in your content to send all the form submission data to the user.', 'vedrixa-forms-registration-builder' ); ?><br/>
			
							</p>
						</div>  
					</div>
                            </div>
                                
                                
                                
                    </div>


                  


                </fieldset>

                <p class="submit">
                    <input type="hidden" name="form_id" id="form_id" value="<?php echo esc_attr( $current_form_id ); ?>" />
                    <?php wp_nonce_field( 'save_wpefb_add_form' ); ?>
                    <input type="submit" value="<?php esc_attr_e( 'Save', 'vedrixa-forms-registration-builder' ); ?>" class="button button-primary" name="submit_form" id="submit_form" onClick="return add_form_validation()"/>
                    <a class="button button-secondary" href="<?php echo esc_url( admin_url( 'admin.php?page=wpefb_form_dashboard&id=' . $current_form_id ) ); ?>"><?php esc_html_e( 'Cancel', 'vedrixa-forms-registration-builder' ); ?></a>
                    <div class="all_error_text" style="display:none;"></div>
                </p>
            </form>  
        </div>    

    </div>    
</div>

