<?php
/**
 * Plugin Name: Vollstart Repair Desk
 * Plugin URI: https://vollstart.com/wordpress-plugins/repair-desk/
 * Description: Repair management for workshops, bike shops, electronics repair, and service businesses. Track repairs, notify customers via QR code status page, and manage your workshop efficiently.
 * Version: 1.0.4
 * Author: Vollstart
 * Author URI: https://vollstart.com/
 * Text Domain: vollstart-repair-desk
 * Domain Path: /languages
 * Requires at least: 6.2
 * Tested up to: 7.0
 * Requires PHP: 7.4
 * License: GPL v2 or later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 */
defined('ABSPATH') or die('Direct access not allowed');

if (!defined('VOLLSTART_RD_PLUGIN_VERSION'))
    define('VOLLSTART_RD_PLUGIN_VERSION', '1.0.4');
if (!defined('VOLLSTART_RD_PLUGIN_DIR_PATH'))
    define('VOLLSTART_RD_PLUGIN_DIR_PATH', plugin_dir_path(__FILE__));
if (!defined('VOLLSTART_RD_PLUGIN_DIR_URL'))
    define('VOLLSTART_RD_PLUGIN_DIR_URL', plugin_dir_url(__FILE__));

// Main class — lazy-loads everything else
require_once VOLLSTART_RD_PLUGIN_DIR_PATH . 'includes/class-main.php';

// Boot
VollstartRD::Instance();

// Activation hook — ensure tables exist + record first activation
register_activation_hook(__FILE__, function () {
    VollstartRD::Instance()->getDB()->installiereTabellen(true);
    // Free-to-paid analytics: record first activation timestamp ONCE.
    if (get_option('vollstart_rd_first_activated_at') === false) {
        add_option('vollstart_rd_first_activated_at', gmdate('Y-m-d H:i:s'), '', 'no');
    }
});

// Deactivation hook — clean up scheduled events
register_deactivation_hook(__FILE__, function () {
    wp_clear_scheduled_hook('vollstart_rd_cleanup_files');
    require_once plugin_dir_path(__FILE__) . 'includes/class-notifications.php';
    VollstartRD_Notifications::unschedulePickupReminder();
});
