<h1><?= ucfirst($this->localization['galerie']).' > '.$this->localization['kategorie'];?></h1>
<table id="data_table" class="data_table">
    <thead>
        <tr>
            <th width="30">Id</th>
            <th>Nazwa</th>
            <th width="200">Akcje</th>
        </tr>
    </thead>
    <tbody>
        <?php        
            if(is_array($gallery_categories))
                foreach($gallery_categories as $k=>$v)
                {
                    echo '<tr>';
                        echo '<td>'.$v['id'].'</td>';
                        echo '<td>'.$v['languages'][key($v['languages'])]['name'].'</td>';
                        echo '<td>';
                            echo 'Edytuj wersje:&nbsp;';
                            echo '<select class="edit_lang" style="width:100px;"><option value=""></option>';
                            foreach($v['languages'] as $kk=>$vv)
                                if(!empty($vv))
                                    echo '<option value="'.base_url().'admin/edit_gallery_category_language/'.$v['id'].'/'.$vv['lang_id'].'">'.$kk.'</option>';

                            echo '</select>';
                            echo '<br />';
                            echo 'Dodaj wersje:&nbsp;&nbsp;';
                            echo '<select class="add_lang" style="width:100px;"><option value=""></option>';
                            foreach($v['languages'] as $kk=>$vv)
                                if(empty($vv))
                                    foreach($langs as $kkk=>$vvv)
                                        if($kk == $vvv['shortname'])
                                            echo '<option value="'.base_url().'admin/add_gallery_category_language/'.$v['id'].'/'.$vvv['idlanguages'].'">'.$kk.'</option>';
                            echo '</select>';
                            echo '<br />';
                            echo '<a class="form_button delete_link" href="/admin/delete_gallery_category/'.$v['id'].'">'.$this->localization['usun'].'</a>';

                        echo '</td>';
                    echo '</tr>';
                }
        ?>
    </tbody>
</table>
<br class="clear"/>
<input type="button" value="<?= ucfirst($this->localization['nowa_kategoria']);?>" onClick="location.href='/admin/add_gallery_category'"/>
<script type="text/javascript">
    $(document).ready(function(){
        $(".edit_lang").change(function(){
            var url = $(this).val();
            if(url != "")
                window.location = url;
        });
        $(".add_lang").change(function(){
            var url = $(this).val();
            if(url != "")
                window.location = url;
        });
    });
</script>
