<?php
/**
 * Admin settings view.
 *
 * @since      1.0.0
 * @package    Subscription_System
 */

// If this file is called directly, abort.
if (!defined('ABSPATH')) {
    exit;
}
?>

<div class="wrap ss-admin-container">
    <h1 class="ss-admin-title"><?php esc_html_e('Subscription Settings', 'subscription-system'); ?></h1>
    
    <?php if (isset($success_message)) : ?>
        <div class="ss-admin-message success">
            <?php echo esc_html($success_message); ?>
        </div>
    <?php endif; ?>
    
    <form method="post" class="ss-admin-form">
        <?php wp_nonce_field('ss_save_settings', 'ss_nonce'); ?>
        
        <h2><?php esc_html_e('General Settings', 'subscription-system'); ?></h2>
        
        <div class="ss-admin-form-row">
            <label for="currency"><?php esc_html_e('Currency', 'subscription-system'); ?></label>
            <select id="currency" name="settings[currency]">
                <option value="USD" <?php selected($settings['currency'], 'USD'); ?>><?php esc_html_e('US Dollar ($)', 'subscription-system'); ?></option>
                <option value="EUR" <?php selected($settings['currency'], 'EUR'); ?>><?php esc_html_e('Euro (€)', 'subscription-system'); ?></option>
                <option value="GBP" <?php selected($settings['currency'], 'GBP'); ?>><?php esc_html_e('British Pound (£)', 'subscription-system'); ?></option>
                <option value="JPY" <?php selected($settings['currency'], 'JPY'); ?>><?php esc_html_e('Japanese Yen (¥)', 'subscription-system'); ?></option>
                <option value="AUD" <?php selected($settings['currency'], 'AUD'); ?>><?php esc_html_e('Australian Dollar ($)', 'subscription-system'); ?></option>
                <option value="CAD" <?php selected($settings['currency'], 'CAD'); ?>><?php esc_html_e('Canadian Dollar ($)', 'subscription-system'); ?></option>
            </select>
        </div>
        
        <div class="ss-admin-form-row">
            <label for="currency_position"><?php esc_html_e('Currency Position', 'subscription-system'); ?></label>
            <select id="currency_position" name="settings[currency_position]">
                <option value="before" <?php selected($settings['currency_position'], 'before'); ?>><?php esc_html_e('Before - $10', 'subscription-system'); ?></option>
                <option value="after" <?php selected($settings['currency_position'], 'after'); ?>><?php esc_html_e('After - 10$', 'subscription-system'); ?></option>
            </select>
        </div>
        
        <h2><?php esc_html_e('Page Settings', 'subscription-system'); ?></h2>
        
        <div class="ss-admin-form-row">
            <label for="success_page"><?php esc_html_e('Success Page', 'subscription-system'); ?></label>
            <select id="success_page" name="settings[success_page]">
                <option value="0"><?php esc_html_e('Select a page', 'subscription-system'); ?></option>
                <?php
                $pages = get_pages();
                foreach ($pages as $page) {
                    echo '<option value="' . esc_attr($page->ID) . '" ' . selected($settings['success_page'], $page->ID, false) . '>' . esc_html($page->post_title) . '</option>';
                }
                ?>
            </select>
            <p class="description"><?php esc_html_e('The page users will be redirected to after successful subscription.', 'subscription-system'); ?></p>
        </div>
        
        <div class="ss-admin-form-row">
            <label for="cancel_page"><?php esc_html_e('Cancel Page', 'subscription-system'); ?></label>
            <select id="cancel_page" name="settings[cancel_page]">
                <option value="0"><?php esc_html_e('Select a page', 'subscription-system'); ?></option>
                <?php
                foreach ($pages as $page) {
                    echo '<option value="' . esc_attr($page->ID) . '" ' . selected($settings['cancel_page'], $page->ID, false) . '>' . esc_html($page->post_title) . '</option>';
                }
                ?>
            </select>
            <p class="description"><?php esc_html_e('The page users will be redirected to after cancelling their subscription.', 'subscription-system'); ?></p>
        </div>
        
        <h2><?php esc_html_e('Email Settings', 'subscription-system'); ?></h2>
        
        <div class="ss-admin-form-row">
            <label for="email_notifications">
                <input type="checkbox" id="email_notifications" name="settings[email_notifications]" value="1" <?php checked($settings['email_notifications'], 1); ?>>
                <?php esc_html_e('Enable Email Notifications', 'subscription-system'); ?>
            </label>
            <p class="description"><?php esc_html_e('Send email notifications for subscription events (new subscription, cancellation, etc.).', 'subscription-system'); ?></p>
        </div>
        
        <div class="ss-admin-form-row">
            <button type="submit" name="ss_save_settings" class="button button-primary"><?php esc_html_e('Save Settings', 'subscription-system'); ?></button>
        </div>
    </form>
</div> 