<?
	if (!$this->error): ?>
	<? if(count($this->paginator)): ?>
		<table class='grid' cellspacing='2' cellpadding='2 border='0' id='tablePagination'>
			<?
			$previa = false;
			foreach ($this->paginator as $item){
				if($item['tp_vistoria'] == 'Previa'){
					$previa = true;
				}
				break;
			}
?>
			<table class='grid' cellspacing='1' cellpadding='0' border='0' id='tablePagination'>
				<thead>
					<tr>
						<th nowrap="nowrap"></th>
						<th nowrap="nowrap"><?echo ($previa == true ? 'Proposta' : 'Processo') ?></th>
						<th nowrap="nowrap">Vistoria</th>
						<th nowrap="nowrap">Segurado</th>
						<th nowrap="nowrap">Empresa</th>
						<th nowrap="nowrap">Perito</th>
                        <th nowrap="nowrap">UF</th>						
						<th nowrap="nowrap">Município</th>
						<th nowrap="nowrap">Cultura</th>
						<?if(!$previa){?>
							<th nowrap="nowrap">Variedade</th>
							<th nowrap="nowrap">Itens</th>
						<?}?>
						<th nowrap="nowrap">Tipo</th>
						<th nowrap="nowrap">Data</th>
					</tr>
				</thead>
				<tbody>
			<tbody>
				<?
				$i = 0;
				foreach ($this->paginator as $item):

					if ($i % 2 == 0) {
						$class = '';
					} else {
						$class = "highlight";
					}

					if(!$previa){
						$itens = $item['itens'];
						$variedade = $item['variedade'];
					}

						?>
						<tr class="<?=$class?>">
							<td align='center'>
								<input type='checkbox' name='id_vistoria' class='id_vistoria_id' value='<?= $item['id_vistoria']; ?>'>
								<input type='hidden' name='dt_vistoria' class='dt_vistoria_id' value='<?= $item['dt_vistoria']; ?>'>
							</td>
							<?if($item['tp_vistoria'] == 'Previa'){ ?>
								<td width="1%"  align="center" nowrap><?=$item['id_proposta_mae'];?></td>
							<?}else{?>
								<td width="1%"  align="center" nowrap><?=$item['id_processo']?> <i>(<?=$item['id_proposta_mae'];?>)</i></td>
							<?}?>
							<td width="1%"  align="center" nowrap><?=$item['id_vistoria']?></td>
							<td><?=$item['ds_nome_proponente']?></td>
							<td><?=$item['ds_nome_fantasia']?></td>
							<td><?=$item['perito']?></td>
							<td><?=$item['ds_sigla']?></td>
							<td><?=$item['ds_nome_municipio']?></td>
							<td><?=$item['ds_nome_cultura']?></td>
							<?php if(!$previa){?>
								<td><?=$variedade?></td>
								<td><?=$itens?></td>
							<?php }?>
							<td id="tipo_vistoria"><?=$item['tp_vistoria']?></td>
							<td><?=Agro_Util::formatDate($item['dt_vistoria'])?></td>
						</tr>
						<?

					$i++;
				endforeach;
				?>
				 <tr align="right" class="">
					<td colspan="12">
							<div class="row">
								<?= $this->form->id_empresa?>
								<div class="field">
									<label for="enviar" class="optional">&nbsp;</label>
									<button name="enviar" id="enviar" type="button">Gerar Relatório</button>
								</div>
							</div>
					</td>
				</tr>

			</tbody>
		<tfoot>

		</tfoot>
		</table>

		<?//=$this->paginationControl($this->paginator, 'Sliding'); ?>
	<? endif; ?>
<? else: ?>
	<?= $this->showListError($this->error); ?>
<? endif; ?>
