<h2><?= ucfirst($this->site['nowa_nieruchomosc']);?></>:</h2>
<?php
    if(isset($message))
        echo '<p>'.$message.'</p>';

?>

<form action="" method="post" enctype="multipart/form-data">
    <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>Język*</td>
            <td>
                <select name="lang_id" style="width:200px;">
                    <option value=""></option>
                    <?php
                        if(!empty($languages) && is_array($languages))
                            foreach($languages as $k=>$v)
                                echo '<option value="'.$v['idlanguages'].'" '.(!empty($form_values['lang_id']) && ($v['idlanguages'] == $form_values['lang_id']) ? "selected=\"selected\"":"").'>'.$v['shortname'].'</option>';
                    ?>
                </select>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('offer_type_id'); ?></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>Typ działki*</td>
            <td>
                <input type="text" name="plot_type" value="<?php echo (!empty($form_values['plot_type']) ? $form_values['plot_type']:''); ?>"/>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('plot_type'); ?></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>Lokalizacja</td>
            <td>
                <input type="text" name="localization" value="<?php echo (!empty($form_values['localization']) ? $form_values['localization']:''); ?>"/>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('localization'); ?></td>
        </tr>

        <tr>
            <td>Cena*</td>
            <td>
                <input type="text" name="price" value="<?php echo (!empty($form_values['price']) ? $form_values['price']:''); ?>"/>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('price'); ?></td>
        </tr>
        
        <tr>
            <td>Powierzchnia</td>
            <td>
                <input type="text" name="surface" value="<?php echo (!empty($form_values['surface']) ? $form_values['surface']:''); ?>"/>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('surface'); ?></td>
        </tr>

        <tr>
            <td>Pietro</td>
            <td>
                <input type="text" name="floor" value="<?php echo (!empty($form_values['floor']) ? $form_values['floor']:''); ?>"/>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('floor'); ?></td>
        </tr>

        <tr>
            <td>Ilość pokoi</td>
            <td>
                <input type="text" name="rooms" value="<?php echo (!empty($form_values['rooms']) ? $form_values['rooms']:''); ?>"/>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('rooms'); ?></td>
        </tr>

        <tr>
            <td>Powierchia garażowa</td>
            <td>
                <input type="text" name="garage_surface" value="<?php echo (!empty($form_values['gargarage_surfacee_area']) ? $form_values['garage_surface']:''); ?>"/>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('garage_surface'); ?></td>
        </tr>

        <tr>
            <td>Opis</td>
            <td>
                <textarea name="description"><?php echo (!empty($form_values['description']) ? $form_values['description']:''); ?></textarea>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('description'); ?></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>
<script type="text/javascript">
    window.onload = function()
    {
        var oFCKeditor = new FCKeditor( 'description' ) ;
        oFCKeditor.Height = '300' ;
        oFCKeditor.Width = '600' ;
        oFCKeditor.BasePath = "/files/fckeditor/" ;
        oFCKeditor.ReplaceTextarea() ;
    }
</script>