<?php



if (empty($_POST['id'])) {
    echo "0+++Could not find registration.";
    exit;

} else {
    $editing = '1';
    $event   = new event;
    $rsvp    = $event->get_rsvp($_POST['id']);
    if (empty($rsvp['id'])) {
        $admin->show_popup_error('Could not find registration.');
        exit;

    } else {
        $cid = $rsvp['id'];

    }
    if ($rsvp['type'] == '1') {
        $form_id = 'event-' . $rsvp['event_id'] . '-2';

    } else {
        $form_id = 'event-' . $rsvp['event_id'] . '-4';

    }
    $field = new field('fields');
    $form  = $field->generate_form($form_id, $rsvp, '1');
    if ($rsvp['type'] != '1') {
        $prim         = $event->get_rsvp($rsvp['primary_rsvp']);
        $primary_rsvp = $prim['fields'];

    } else {
        $primary_rsvp = array(
            'last_name'  => '',
            'first_name' => '',
        );

    }



    ?>



    <script type="text/javascript">

        $.ctrl('S', function () {
            return json_add('rsvp-add', '<?php echo $cid; ?>', '<?php echo $editing; ?>', 'popupform');
        });

    </script>



    <form action="" method="post" id="popupform"
          onsubmit="return json_add('rsvp-add','<?php echo $cid; ?>','<?php echo $editing; ?>','popupform');">


        <div id="popupsave">

            <input type="submit" value="Save" class="save"/>

            <input type="hidden" name="id" value="<?php echo $cid; ?>"/>

        </div>

        <h1>Viewing Event Registration</h1>


        <div class="pad24t popupbody">


            <fieldset>

                <legend>Overview</legend>

                <div class="pad24">


                    <div class="field">

                        <label class="">Status</label>

                        <div class="field_entry">

                            <input type="radio" name="status" value="1" <?php if ($rsvp['status'] == '1') {
                                echo " checked=\"checked\"";
                            } ?> /> Paid <input type="radio" name="status" value="2" <?php if ($rsvp['status'] != '1') {
                                echo " checked=\"checked\"";
                            } ?> /> Pending Payment

                        </div>

                    </div>


                    <div class="field">

                        <label class="">Type</label>

                        <div class="field_entry">

                            <input type="radio" name="type" onclick="return hide_div('whynowork');"
                                   value="1" <?php if ($rsvp['type'] == '1') {
                                echo " checked=\"checked\"";
                            } ?> /> Registrant <input type="radio" name="type" onclick="return show_div('whynowork');"
                                                      value="2" <?php if ($rsvp['type'] != '1') {
                                echo " checked=\"checked\"";
                            } ?> /> Guest

                        </div>

                    </div>


                    <div class="field" id="whynowork" style="display:<?php if ($rsvp['type'] == '1') {
                        echo "none";
                    } else {
                        echo "block";
                    } ?>">

                        <label class="">Guest of</label>

                        <div class="field_entry">

                            <input type="text" id="primary_rsvp"
                                   value="<?php echo $primary_rsvp['first_name'] . ' ' . $primary_rsvp['last_name']; ?>"
                                   name="primary_rsvp_dud"
                                   autocomplete="off" onkeyup="return autocom(this.id,'rsvp_id','first_name,last_name','ppSD_event_rsvp_data','last_name','rsvp');"
                                   style="width:250px;"/></a>

                            <input type="hidden" name="primary_rsvp" id="primary_rsvp_id"
                                   value="<?php echo $rsvp['primary_rsvp']; ?>"/>

                            <p class="field_desc" id="source_dud_dets">Type the last name of the primary registrant of
                                whom this guest is a guest.</p>

                        </div>

                    </div>


                    <div class="field">

                        <label class="">Arrived?</label>

                        <div class="field_entry">

                            <input type="radio" name="arrived" onclick="return show_div('adate');"
                                   value="1" <?php if ($rsvp['arrived'] == '1') {
                                echo " checked=\"checked\"";
                            } ?> /> Arrived <input type="radio" name="arrived" onclick="return hide_div('adate');"
                                                   value="0" <?php if ($rsvp['arrived'] != '1') {
                                echo " checked=\"checked\"";
                            } ?> /> Has not arrived

                        </div>

                    </div>


                    <div id="adate" style="display:<?php if ($rsvp['arrived'] != '1') {
                        echo "none";
                    } else {
                        echo "block";
                    } ?>">

                        <div class="field">

                            <label class="">Arrival Date</label>

                            <div class="field_entry">

                                <?php



                                echo $af
                                    ->setSpecialType('datetime')
                                    ->setValue($data['arrived_date'])
                                    ->string('arrived_date');


                                // echo $admin->datepicker('arrived_date', $rsvp['arrived_date'], '1', '250', '1', '5');

                                ?>

                            </div>

                        </div>

                    </div>


                </div>

            </fieldset>


            <fieldset>

                <legend>Order Details</legend>

                <div class="pad24">


                    <div class="field">

                        <label class="">Order ID</label>

                        <div class="field_entry">

                            <?php





                            if (!empty($rsvp['order_id'])) {
                                echo "<p><a href=\"return_null.php\" onclick=\"return load_page('transaction','view','" . $rsvp['order_id'] . "');\">" . $rsvp['order_id'] . "</a></p>";

                            } else {
                                echo "<p>N/A</p>";

                            }

                            ?>

                        </div>

                    </div>


                </div>

            </fieldset>



            <?php





            echo $form;

            ?>


        </div>


    </form>



<?php

}

?>