<?php
/**
 * Template Name: Master Google Sheets
 * Description: Template for master trainer Google Sheets integration page
 */

// Define constant to indicate we are in a page template
define('HVAC_IN_PAGE_TEMPLATE', true);

get_header();

// Authentication handled by centralized HVAC_Access_Control system
// Redundant template-level auth check removed to prevent content blocking

echo '<div class="hvac-page-wrapper hvac-master-google-sheets-page">';
echo '<div class="container">';

// Render master trainer navigation inside the wrapper
if (class_exists('HVAC_Master_Menu_System')) {
    $master_menu = HVAC_Master_Menu_System::instance();
    $master_menu->render_master_menu();
}

// Render breadcrumbs inside the wrapper
if (class_exists('HVAC_Breadcrumbs')) {
    // Fix: The method is render_breadcrumbs(), not render()
    $breadcrumbs_instance = HVAC_Breadcrumbs::instance();
    echo $breadcrumbs_instance->render_breadcrumbs();
}
?>

<div class="hvac-master-google-sheets">
    <h1 class="page-title">Google Sheets Integration</h1>
    
    <div class="google-sheets-intro">
        <p>Sync trainer and event data with Google Sheets for advanced reporting and analysis.</p>
    </div>
    
    <div class="google-sheets-connection">
        <h2>Connection Status</h2>
        <div class="connection-status">
            <span class="status-indicator status-connected"></span>
            <span class="status-text">Connected to Google Sheets</span>
        </div>
        <button class="button">Reconnect Account</button>
    </div>
    
    <div class="google-sheets-sync">
        <h2>Data Synchronization</h2>
        
        <div class="sync-options">
            <div class="sync-card">
                <h3>Trainer Data</h3>
                <p>Export all trainer profiles and certification status to Google Sheets.</p>
                <div class="sync-info">
                    <span>Last sync: August 20, 2025 at 3:45 PM</span>
                </div>
                <button class="button button-primary">Sync Trainers</button>
            </div>
            
            <div class="sync-card">
                <h3>Event Data</h3>
                <p>Export all events and attendance records to Google Sheets.</p>
                <div class="sync-info">
                    <span>Last sync: August 21, 2025 at 10:30 AM</span>
                </div>
                <button class="button button-primary">Sync Events</button>
            </div>
            
            <div class="sync-card">
                <h3>Certificate Reports</h3>
                <p>Export certificate generation reports and analytics.</p>
                <div class="sync-info">
                    <span>Last sync: August 19, 2025 at 2:15 PM</span>
                </div>
                <button class="button button-primary">Sync Certificates</button>
            </div>
        </div>
    </div>
    
    <div class="google-sheets-templates">
        <h2>Sheet Templates</h2>
        <p>Download pre-configured Google Sheets templates for your data.</p>
        
        <div class="template-list">
            <div class="template-item">
                <h4>Master Trainer Dashboard Template</h4>
                <p>Complete dashboard with charts and pivot tables.</p>
                <a href="#" class="button button-small">Download Template</a>
            </div>
            
            <div class="template-item">
                <h4>Monthly Report Template</h4>
                <p>Automated monthly reporting template.</p>
                <a href="#" class="button button-small">Download Template</a>
            </div>
            
            <div class="template-item">
                <h4>Trainer Performance Template</h4>
                <p>Track individual trainer metrics and KPIs.</p>
                <a href="#" class="button button-small">Download Template</a>
            </div>
        </div>
    </div>
    
    <div class="google-sheets-settings">
        <h2>Sync Settings</h2>
        
        <form class="sync-settings-form">
            <div class="form-group">
                <label>
                    <input type="checkbox" checked> Enable automatic daily sync
                </label>
            </div>
            
            <div class="form-group">
                <label>Sync Time</label>
                <select>
                    <option>12:00 AM</option>
                    <option>3:00 AM</option>
                    <option selected>6:00 AM</option>
                    <option>9:00 AM</option>
                    <option>12:00 PM</option>
                    <option>3:00 PM</option>
                    <option>6:00 PM</option>
                    <option>9:00 PM</option>
                </select>
            </div>
            
            <div class="form-group">
                <label>Google Sheets Folder ID</label>
                <input type="text" placeholder="Enter folder ID from Google Drive" />
            </div>
            
            <button type="submit" class="button button-primary">Save Settings</button>
        </form>
    </div>
</div>

<?php
echo '</div>'; // .container
echo '</div>'; // .hvac-page-wrapper

get_footer();
?>