<?php if ($this->origem == 'funcionario') { ?>
    <script type="text/javascript" src="/resources/javascript/sistema/treinamento.js"></script>
<?php } ?>

<? if (!$this->error){ ?>
    <? if (count($this->paginator)){ ?>
        <table class='grid' cellspacing='1' cellpadding='0' border='0' id='tablePagination'>
            <?
                $options = array();
                $options[] = array(
                        'id'        => 'dt_treinamento',
                        'nowrap'    => 'nowrap',
                        'link'      => '#',
                        'descricao' => 'Data',
                        'image'     => '/resources/imagens/'
                );

                $options[] = array(
                        'id'        => 'ds_tipo',
                        'nowrap'    => 'nowrap',
                        'link'      => '#',
                        'descricao' => 'Tipo de Vistoria',
                        'image'     => '/resources/imagens/'
                );

                if ($this->origem == "treinamento") {
                    $options[] = array(
                            'id'        => 'ds_nome_grupamento_cultura',
                            'nowrap'    => 'nowrap',
                            'link'      => '#',
                            'descricao' => 'Grupo de Cultura',
                            'image'     => '/resources/imagens/'
                    );
                }

                $options[] = array(
                        'id'        => 'ds_nome_funcionario',
                        'nowrap'    => 'nowrap',
                        'link'      => '#',
                        'descricao' => 'Vistoriador',
                        'image'     => '/resources/imagens/'
                );

                $options[] = array(
                    'id'        => 'ds_nome_agronomo',
                    'nowrap'    => 'nowrap',
                    'link'      => '#',
                    'descricao' => 'Agrônomo',
                    'image'     => '/resources/imagens/'
                );

                $options[] = array(
                        'id'        => 'ds_assuntos_abordados',
                        'nowrap'    => 'nowrap',
                        'link'      => '#',
                        'descricao' => 'Assunto(s) Abordado(s)',
                        'image'     => '/resources/imagens/'
                );

                $options[] = array(
                        'nowrap'    => 'nowrap',
                        'descricao' => 'Ações'
                );

            ?>

            <?= $this->listHeader($options, $this->order, $this->orderType); ?>

            <tbody>
                <?
                    $i = 0;
                    foreach ($this->paginator as $item) {
                        $class = ($i % 2 == 0) ? '' : 'highlight';
                ?>
                        <tr class="<?=$class?>">
                            <td nowrap='nowrap' align="center"><?=($item['dt_treinamento'] ? Agro_Util::formatDate($item['dt_treinamento'], Zend_Date::DATES) : '&nbsp;');?></td>
                            <td nowrap='nowrap'><?=($item['ds_nomes_tipo_vistorias'] ? $item['ds_nomes_tipo_vistorias'] : '&nbsp;');?></td>
                            <td nowrap='nowrap'><?=($item['ds_nomes_grupamento_culturas'] ? $item['ds_nomes_grupamento_culturas'] : '&nbsp;');?></td>
                            <?php if ($this->origem == "treinamento") { ?>
                                <td  style="width: 45%;"><?=($item['ds_nomes_vistoriadores'] ? $item['ds_nomes_vistoriadores'] : '&nbsp;');?></td>
                            <?php } ?>
                            <td><?=($item['ds_nomes_agronomos'] ? $item['ds_nomes_agronomos'] : '&nbsp;');?></td>
                            <td><?=($item['ds_assuntos_abordados'] ? $item['ds_assuntos_abordados'] : '&nbsp;');?></td>

                            <td align='center' width='1%' nowrap='nowrap'>
                                <?php if ($this->origem == "treinamento") { ?>
                                    <?=$this->iconEdit("sistema", "treinamento", $item);?>
                                <?php } ?>

                                <a href="/sistema/treinamento/fotos/id/<?=$item['id']?>/origem/<?=$this->origem?>" class="addFotos">
                                    <img src="/resources/imagens/mini/fotos.png" alt="fotos.png" title="Fotos" border="0">
                                </a>

                                <?php if ($this->origem == "treinamento") { ?>
                                    <a href="#" class="deletarTreinamento" data-id="<?=$item['id']?>">
                                        <img src='/resources/imagens/mini/delete.png' alt='delete.png' title='Excluir' />
                                    </a>
                                <?php } ?>
                            </td>
                        </tr>
                <?
                        $i++;
                    }
                ?>
            </tbody>
        </table>

        <?= $this->paginationControl($this->paginator, 'Sliding'); ?>
    <? } ?>
<? } else { ?>
    <?= $this->showListError($this->error); ?>
<? } ?>
