<script type="text/javascript" src="/resources/jquery/jquery.upload.js"></script>
<form class="formDefault" method="post">
    <div id="tabs">
        <ul>
            <? if ($this->estados->count()): ?>
                <? foreach ($this->estados as $estado): ?>
                    <li><a href="#tabs-<?=$estado['ds_sigla']?>"><?=$estado['ds_sigla']?></a></li>
                <? endforeach; ?>
            <? endif; ?>
        </ul>

        <div class="geral">
                <input type="hidden" name="id" value="<?=$this->id?>" />

                <div id="div_importar_municipios">
                    <form enctype="multipart/form-data" id="importar_municipios_form" method="post" action="">
                        <dl class="zend_form" style="margin-top: 10px;">
                            <dd style="margin-left:13x;">
                                <input type="hidden" id="id" name="id" value="<?=Zend_Controller_Front::getInstance()->getRequest()->getParam('id');?>" />
                                <input name="municipios_csv" id="municipios_csv" size="50" type="file">
                                <button name="importar_municipios" id="importar_municipios" type="button">Importar Arquivos de Municípios</button>
                                <img src="/resources/imagens/icon/help.png" border="0" id="help_form"><br>
                                <div id="tip_form">
                                    A primeira linha do arquivo deve conter o cabeçalho com as colunas (id_municipio).<br>
                                    <span id="span_form">&nbsp;</span>
                                </div>
                            </dd>
                        </dl>
                    </form>
                </div><br>

            <? if ($this->estados->count()): ?>
                <? foreach ($this->estados as $estado): ?>
                    <div id="tabs-<?=$estado['ds_sigla']?>">
                        <?=$this->title('Relacionar municípios para: '.$estado['ds_nome_estado']);?>
                        <? $municipios = $estado->municipios(); ?>

                        <? if (count($municipios)): ?>
                            <table cellpadding="1" cellspacing="1">
                                <tr>
                                    <td align='right'><button type="button" class="marcarTodos">Marcar Todos</button></td>
                                    <td align='right'><button type="button" class="desmarcarTodos">Desmarcar Todos</button></td>
                                    <td align='right'><button type="button" class="inverterSelecao">Inverter Seleção</button></td>
                                </tr>
                            </table>
                            <br />

                            <table width="100%" cellpadding="3" cellspacing="0">
                                <tr>
                                    <? $i = 1; ?>
                                    <? foreach ($municipios as $municipio): ?>
                                        <? if ($municipio['id'] && $municipio['ds_nome_municipio']): ?>
                                            <td width="1%"><input <?=(in_array($municipio['id'], $this->checked) ? 'checked' : '')?> id="input-<?=$municipio['id']?>" type="checkbox" name="municipios[<?=$municipio['id']?>]" value="<?=$municipio['id']?>" /></td>
                                            <td><label for="input-<?=$municipio['id']?>"><?=$municipio['ds_nome_municipio']?></label></td>

                                            <?=($i % 6 == 0 ? '</tr><tr>' : '');?>
                                            <? $i++; ?>
                                        <? endif; ?>
                                    <? endforeach; ?>
                                </tr>
                            </table>
                            <br />

                            <table cellpadding="1" cellspacing="1">
                                <tr>
                                    <td align='right'><button type="button" class="marcarTodos">Marcar Todos</button></td>
                                    <td align='right'><button type="button" class="desmarcarTodos">Desmarcar Todos</button></td>
                                    <td align='right'><button type="button" class="inverterSelecao">Inverter Seleção</button></td>
                                </tr>
                            </table>
                         <? endif; ?>
                    </div>
                <? endforeach; ?>
            <? endif; ?>
        </div>

        <ul id="buttons" class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
            <li><button name="salvar" id="salvar" type="submit">Salvar</button></li>
        </ul>
    </div>
</form>

