<h2>Edytuj nieruchomość:</h2>
<?php
    if(isset($message))
        echo '<p>'.$message.'</p>';

?>
<form action="" method="post" enctype="multipart/form-data">
    <input type="hidden" name="id" value="<?php echo $form_values['id']; ?>"/>
    <table>
        <tr>
            <td>Nazwa*</td>
            <td>
                <input type="text" name="name" value="<?php echo (!empty($form_values['name']) ? $form_values['name']:''); ?>"/>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('name'); ?></td>
        </tr>
        


        <tr>
            <td>Typ budynku*</td>
            <td>
                <select name="building_type_id" style="width:200px;">
                    <option value=""></option>
                    <?php
                        if(!empty($building_types) && is_array($building_types))
                            foreach($building_types as $k=>$v)
                                echo '<option value="'.$v['id'].'" '.(!empty($form_values['building_type_id']) && ($v['id'] == $form_values['building_type_id']) ? "selected=\"selected\"":"").'>'.$v['name'].'</option>';
                    ?>
                </select>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('building_type_id'); ?></td>
        </tr>

        <tr>
            <td>Typ oferty*</td>
            <td>
                <select name="offer_type_id" style="width:200px;">
                    <option value=""></option>
                    <?php
                        if(!empty($offer_types) && is_array($offer_types))
                            foreach($offer_types as $k=>$v)
                                echo '<option value="'.$v['id'].'" '.(!empty($form_values['offer_type_id']) && ($v['id'] == $form_values['offer_type_id']) ? "selected=\"selected\"":"").'>'.$v['name'].'</option>';
                    ?>
                </select>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('offer_type_id'); ?></td>
        </tr>

        <tr>
            <td>Galeria*</td>
            <td>
                <select name="gallery_id" style="width:200px;">
                    <option value=""></option>
                    <?php
                        if(!empty($galleries) && is_array($galleries))
                            foreach($galleries as $k=>$v)
                                echo '<option value="'.$v['idgalleries'].'" '.(!empty($form_values['gallery_id']) && ($v['idgalleries'] == $form_values['gallery_id']) ? "selected=\"selected\"":"").'>'.$v['title'].'</option>';
                    ?>
                </select>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('gallery_id'); ?></td>
        </tr>

         <tr>
            <td>Nowość</td>
            <td>
                <input type="checkbox" name="nowelty" value="1" <?php echo (!empty($form_values['nowelty']) ? 'checked="checked"':''); ?>/>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('nowelty'); ?></td>
        </tr>

        <tr>
            <td>Aktywność</td>
            <td>            
                <input type="checkbox" name="active" value="1" <?php echo (!empty($form_values['active']) ? 'checked="checked"':''); ?>/>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('active'); ?></td>
        </tr>

        <tr>
            <td>* - pole wymagane</td>
            <td><input type="submit" value="Zatwierdź"/></td>
            <td></td>
        </tr>
    </table>
</form>
