<?php
/**
 * Admin add subscription 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('Add Subscription', 'subscription-system'); ?></h1>
    
    <?php if (isset($success_message)) : ?>
        <div class="ss-admin-message success">
            <?php echo esc_html($success_message); ?>
        </div>
    <?php endif; ?>
    
    <?php if (isset($error_message)) : ?>
        <div class="ss-admin-message error">
            <?php echo esc_html($error_message); ?>
        </div>
    <?php endif; ?>
    
    <form method="post" class="ss-admin-form">
        <?php wp_nonce_field('ss_add_subscription', 'ss_nonce'); ?>
        
        <div class="ss-admin-form-row">
            <label for="user_id"><?php esc_html_e('User ID', 'subscription-system'); ?></label>
            <input type="number" id="user_id" name="user_id" required>
            <p class="description"><?php esc_html_e('Enter the WordPress user ID.', 'subscription-system'); ?></p>
        </div>
        
        <div class="ss-admin-form-row">
            <label for="email"><?php esc_html_e('Email', 'subscription-system'); ?></label>
            <input type="email" id="email" name="email" required>
        </div>
        
        <div class="ss-admin-form-row">
            <label for="plan_id"><?php esc_html_e('Subscription Plan', 'subscription-system'); ?></label>
            <select id="plan_id" name="plan_id" required>
                <option value=""><?php esc_html_e('Select a plan', 'subscription-system'); ?></option>
                <?php foreach ($plans as $plan_id => $plan) : ?>
                    <option value="<?php echo esc_attr($plan_id); ?>"><?php echo esc_html($plan['name']); ?></option>
                <?php endforeach; ?>
            </select>
        </div>
        
        <div class="ss-admin-form-row">
            <label for="status"><?php esc_html_e('Status', 'subscription-system'); ?></label>
            <select id="status" name="status">
                <option value="active"><?php esc_html_e('Active', 'subscription-system'); ?></option>
                <option value="cancelled"><?php esc_html_e('Cancelled', 'subscription-system'); ?></option>
                <option value="expired"><?php esc_html_e('Expired', 'subscription-system'); ?></option>
            </select>
        </div>
        
        <div class="ss-admin-form-row">
            <label for="start_date"><?php esc_html_e('Start Date', 'subscription-system'); ?></label>
            <input type="text" id="start_date" name="start_date" value="<?php echo esc_attr(current_time('mysql')); ?>" required>
            <p class="description"><?php esc_html_e('Format: YYYY-MM-DD HH:MM:SS', 'subscription-system'); ?></p>
        </div>
        
        <div class="ss-admin-form-row">
            <button type="submit" name="ss_add_subscription" class="button button-primary"><?php esc_html_e('Add Subscription', 'subscription-system'); ?></button>
        </div>
    </form>
</div> 