<?php

global $wpdb;
$msg = "";
$seating_chart_id = $_REQUEST['seating_chart_id'];
$seating_chart = $wpdb->get_row("select * from " . EVENTS_SEATING_CHART_TABLE . " where id = {$seating_chart_id} ");
if ($seating_chart == NULL) {
    echo __('Sorry no seating chart was selected', 'event_espresso');
    exit;
}
if (isset($_POST['save_seating_chart_level_section_alignment'])) {
    seating_chart::delete_section_alignment($seating_chart_id);
    //$sections = $wpdb->get_results("select distinct level, section from " . EVENTS_SEATING_CHART_LEVEL_SECTION_ALIGNMENT_TABLE . " where seating_chart_id = $seating_chart_id order by level, section");
    foreach ($_POST['section_alignment'] as $level => $sections) {
        foreach ($sections as $section => $value) {
            $alignment = isset($_POST['section_alignment'][$level][$section]) ? $_POST['section_alignment'][$level][$section] : "left";
            $sort_order = isset($_POST['section_sort_order'][$level][$section]) ? $_POST['section_sort_order'][$level][$section] : "asc";
            seating_chart::save_section_alignment($seating_chart_id, $level, $section, $alignment, $sort_order);
        }
    }
    $msg = __('Alignment updated', 'event_espresso');
}
?>
<div class="clear">&nbsp;</div>

<div class="wrap">
    <div id="icon-options-event" class="icon32"></div>
    <h2><?php 
_e('Manage Seating Charts', 'event_espresso');
?>
</h2>