<?php
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals

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

$dbhandler = new WPEFB_DBhandler();
?>

<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 esc_html_e( 'User Accounts', 'vedrixa-forms-registration-builder' ); ?></h1>
        <ul class="advrf-nav">
            <li class="advrf-nav-item">
                <a href="<?php echo esc_url( admin_url( 'admin.php?page=wpefb_global_settings' ) ); ?>">
                    <span class="dashicons dashicons-admin-generic"></span>
                    <?php esc_html_e( 'Global Settings', 'vedrixa-forms-registration-builder' ); ?></a>
            </li>
            <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>    
        </ul>

    </div>
    <div class="clearfix">
        <div class="advrf-form-conf-wrapper">
            <?php if ( absint( filter_input( INPUT_GET, 'updated', FILTER_SANITIZE_NUMBER_INT ) ) ) : ?>
                <div class="notice notice-success is-dismissible"><p><?php esc_html_e( 'User Account settings saved.', 'vedrixa-forms-registration-builder' ); ?></p></div>
            <?php endif; ?>
            <form action="" method="post" id="advrf_configuration_form">
                <fieldset class="advrf-config-wrap">
                    <div>
                        <div class="group-title"><?php esc_html_e( 'Account Basics', 'vedrixa-forms-registration-builder' ); ?></div>
                        <div class="group-wrap">

                          <div class="advrf-row">
                                    <div class="advrf-control-label">
                                            <label><?php esc_html_e( 'Account Activation Method', 'vedrixa-forms-registration-builder' ); ?></label>
                                    </div>
                                    <div class="advrf-control advrf-has-child">
                                        <div class="wef-radio-group">
                                            <label class="wef-radio-option">
                                                <input type="radio" value="auto_activate" name="wpefb_account_activation" data-child-index="-1" <?php checked( $dbhandler->get_global_option_value( 'wpefb_account_activation' ), 'auto_activate' ); ?> />
                                                <span><?php esc_html_e( 'Activate User Automatically', 'vedrixa-forms-registration-builder' ); ?></span>
                                            </label>
                                            <label class="wef-radio-option">
                                                <input type="radio" value="manual" name="wpefb_account_activation"  data-child-index="1" <?php checked( $dbhandler->get_global_option_value( 'wpefb_account_activation' ), 'manual' ); ?> />
                                                <span><?php esc_html_e( 'Deactivate User for Manual Approval', 'vedrixa-forms-registration-builder' ); ?></span>
                                            </label>
                                            <label class="wef-radio-option">
                                                <input type="radio" value="verify" name="wpefb_account_activation"  data-child-index="1" <?php checked( $dbhandler->get_global_option_value( 'wpefb_account_activation' ), 'verify' ); ?> />
                                                <span><?php esc_html_e( 'Send Verification Email', 'vedrixa-forms-registration-builder' ); ?></span>
                                            </label>
                                        </div>
                                        <p class="description"><?php esc_html_e( 'Select the action to be performed when a user submits a registration form for the first time. Content of the account verification email can be modified from Dashboard->Email Templates.', 'vedrixa-forms-registration-builder' ); ?></p>
                                    </div>  
                                </div>
                            
                            <div class="advrf-row">
                                <div class="advrf-control-label">
                                    <label for="wpefb_registration_page_id"><?php esc_html_e( 'Registration Page', 'vedrixa-forms-registration-builder' ); ?></label>
                                </div>
                                <div class="advrf-control advrf-has-child">
                                    <?php
                                    wp_dropdown_pages(
                                        array(
                                            'name'     => 'wpefb_registration_page_id',
                                            'id'       => 'wpefb_registration_page_id',
                                            'show_option_none' => esc_html__( 'Select a page', 'vedrixa-forms-registration-builder' ),
                                            'option_none_value' => '0',
                                            'selected' => absint( $dbhandler->get_global_option_value( 'wpefb_registration_page_id', 0 ) ),
                                            'class'    => 'advrf-input-field',
                                        )
                                    );
                                    ?>
                                    <p class="description"><?php esc_html_e( 'Activation links and WordPress registration links will use this page. If the page contains the form shortcode, activation status appears above the form.', 'vedrixa-forms-registration-builder' ); ?></p>
                                </div>
                            </div>

                            <div class="advrf-row">
                                <div class="advrf-control-label">
                                    <label><?php esc_html_e( 'Send Username and Password to the User through Email', 'vedrixa-forms-registration-builder' ); ?></label>
                                </div>
                                <div class="advrf-control advrf-has-child">
                                    <input class="advrf_toggle"  type="checkbox" value="1" id="wpefb_usr_pass_to_user" name="wpefb_usr_pass_to_user" data-has-child="1" <?php checked( $dbhandler->get_global_option_value( 'wpefb_usr_pass_to_user' ), '1' ); ?> />
                                    <label></label>
                                    <p class="description"><?php esc_html_e( 'Send users an email with their selected username and password after successful registration.', 'vedrixa-forms-registration-builder' ); ?></p>
                                </div>  
                            </div>

                            <?php do_action( 'wpefb_render_user_accounts_settings_extensions', $dbhandler ); ?>

                            <?php if ( ! WPEFB_Features::is_pro_active() ) : ?>
                                <div class="group-title"><?php esc_html_e( 'User Accounts Pro', 'vedrixa-forms-registration-builder' ); ?></div>
                                <div class="group-wrap wpefb-settings-upsell">
                                    <div class="wpefb-settings-upsell-hero">
                                        <div>
                                            <h3><?php esc_html_e( 'Turn registration into a real account experience.', 'vedrixa-forms-registration-builder' ); ?></h3>
                                            <p><?php esc_html_e( 'Upgrade to unlock frontend account pages, profile editing, login tools, user redirects, and self-service areas for drafts and submissions.', 'vedrixa-forms-registration-builder' ); ?></p>
                                        </div>
                                        <div class="wpefb-settings-upsell-actions">
                                            <a class="button button-primary" href="<?php echo esc_url( admin_url( 'admin.php?page=wpefb_pro' ) ); ?>"><?php esc_html_e( 'Explore Pro Features', 'vedrixa-forms-registration-builder' ); ?></a>
                                            <a class="button button-secondary" href="https://registrationformbuilder.com/pricing/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'View Pricing', 'vedrixa-forms-registration-builder' ); ?></a>
                                        </div>
                                    </div>

                                    <div class="wpefb-settings-upsell-grid">
                                        <div class="wpefb-settings-upsell-card">
                                            <span class="dashicons dashicons-admin-users"></span>
                                            <h4><?php esc_html_e( 'Frontend Account Dashboard', 'vedrixa-forms-registration-builder' ); ?></h4>
                                            <p><?php esc_html_e( 'Give users a dedicated account area instead of pushing them into wp-admin.', 'vedrixa-forms-registration-builder' ); ?></p>
                                        </div>
                                        <div class="wpefb-settings-upsell-card">
                                            <span class="dashicons dashicons-id-alt"></span>
                                            <h4><?php esc_html_e( 'Profile Editing & Meta Mapping', 'vedrixa-forms-registration-builder' ); ?></h4>
                                            <p><?php esc_html_e( 'Reuse registration forms for profile editing and map values into custom user meta.', 'vedrixa-forms-registration-builder' ); ?></p>
                                        </div>
                                        <div class="wpefb-settings-upsell-card">
                                            <span class="dashicons dashicons-lock"></span>
                                            <h4><?php esc_html_e( 'Login, Logout & Redirects', 'vedrixa-forms-registration-builder' ); ?></h4>
                                            <p><?php esc_html_e( 'Control where users land after login or logout and add frontend account access pages.', 'vedrixa-forms-registration-builder' ); ?></p>
                                        </div>
                                        <div class="wpefb-settings-upsell-card">
                                            <span class="dashicons dashicons-feedback"></span>
                                            <h4><?php esc_html_e( 'My Drafts & My Submissions', 'vedrixa-forms-registration-builder' ); ?></h4>
                                            <p><?php esc_html_e( 'Let users manage saved drafts and view their own submissions without admin access.', 'vedrixa-forms-registration-builder' ); ?></p>
                                        </div>
                                    </div>
                                </div>
                            <?php endif; ?>
                            
                        
                                
                                
                                
                                </div>
                    </div>





                </fieldset>

                <p class="submit">
                    <?php wp_nonce_field( 'save_wpefb_global_settings' ); ?>
                    <input type="submit" value="<?php esc_attr_e( 'Save', 'vedrixa-forms-registration-builder' ); ?>" class="button button-primary" name="submit_settings" id="submit_settings" onClick="return advrf_global_settings_validation('security')"/>
                    <a class="button button-secondary" href="<?php echo esc_url( admin_url( 'admin.php?page=wpefb_global_settings' ) ); ?>"><?php esc_html_e( 'Cancel', 'vedrixa-forms-registration-builder' ); ?></a>
                    <div class="all_error_text" style="display:none;"></div>
                </p>
            </form>  
        </div>    

    </div>    
</div>
