<form class="formDefault" id="formDefault" method="post" action="/<?=$this->row['ds_chave']; ?>/<?=$this->row['ds_controller']; ?>/salvar">
	<input type="hidden" name="id_proposta" id="id_proposta" value="<?=$this->processo->id_proposta?>" />
	<input type="hidden" name="id_processo" id="id_processo" value="<?=$this->processo->id?>" />
	<input type="hidden" name="tp_usuario" id="tp_usuario" value="<?=$this->data['tp_usuario']?>" />
	<input type="hidden" name="isEmpresaAtiva" id="isEmpresaAtiva" value="<?=$this->isEmpresaAtiva?>" />
	
	<div id="tabs">
		<ul>
			<li><a href="#tabs-form">Processo</a></li>
		</ul>
	
		<div id="tabs-form">
			<? $this->headerSinistro($this->processo->id_proposta, $this->processo->id); ?>
			
			<!-- AREA DE AVISO DE SINISTRO -->
			<div class="area">
				<?=$this->title('Avisos de Sinistro');?>
				<table width="100%" class="grid" cellpadding="1" cellspacing="1">
					<thead>
						<tr>
							<th>Nr do Aviso</th>
							<th>Dt. Sinistro</th>
							<th>Dt. Envio</th>
							<th>Dt Aceitação</th>
							<th>Ações</th>
						</tr>
					</thead>
					<tbody align="center">
						<?
						$i = 0;
						foreach ($this->processo->avisos() as $aviso):
							$class = ($i%2==0 ? 'on' : 'off');
						?>
						<tr class="<?=$class?>">
							<td><?=$aviso['id']?></td>
							<td><?=$aviso['dt_sinistro']?></td>
							<td><?=$aviso['dt_envio']?></td>
							<td><?=$aviso['dt_aceitacao']?></td>
							<td>
								<a class="popup" href="/sinistro/avisosinistro/view/id/<?=$aviso['id']?>/idProposta/<?=$this->processo->id_proposta?>"><img src="/resources/imagens/mini/view.png" alt="view.png" title="Visualizar" /></a>
							</td>
						</tr>
						<?
						    $i++;
						endforeach;
						?>
					</tbody>
				</table>
			</div>
			<!-- /AREA DE AVISO DE SINISTRO -->
			
			<!-- AREA DE REGULACAO DE PERDAS -->
			<div class="area">
				<?=$this->title('Regulação de Perdas');?>	
				<div id="regulacao_perdas">
					<? echo $this->regulacaoPerdas($this->processo); ?>
				</div>
			</div>
			<!-- /AREA DE REGULACAO DE PERDAS -->
			
			<!-- AREA DE AVISO DE INICIO DE COLHEITA -->
			<? $Rs = $this->processo->iniciosColheita(); ?>
			<? if(count($Rs)): ?>
			<div class="area">
				<?=$this->title('Avisos de Início de colheita');?>
				<table width="100%" class="grid" cellpadding="1" cellspacing="1">
					<thead>
						<tr>
		                    <th nowrap>N° do Aviso</th>
		                    <th>Data de início da colheita</th>
		                    <th>Data de envio do aviso</th>
		                    <th>Ações</th>
		                </tr>
		            </thead>
		            <tbody align="center">
		            	<? foreach($Rs as $row): ?>
		            		<tr>
		                		<td align="center"><?=$row['id']?></td>
		                		<td><?=Agro_Util::formatDate($row['dt_inicio_colheita']);?></td>
		                		<td><?=Agro_Util::formatDate($row['dt_criacao']);?></td>
		                		<td>
		                    		<a class="popup" href="/sinistro/avisoiniciocolheita/view/id/<?=$row['id']?>">
		                        		<img src="/resources/imagens/mini/view.png" alt="view.png" title="Visualizar" />
		                    		</a>
		                		</td>
		            		</tr>
	            		<? endforeach; ?>
					</tbody>
				</table>
			</div>
			<? endif; ?>
			<!-- /AREA DE AVISO DE INICIO DE COLHEITA -->
			
			<!-- AREA DE AVISO DE ENCERRAMENTO DE COLHEITA -->
			<? $Rs = $this->processo->encerramentosColheita(); ?>
			<? if(count($Rs)): ?>
			<div class="area">
				<?=$this->title('Avisos de Encerramento de colheita');?>
		        <table width="100%" class="grid" cellpadding="1" cellspacing="1">
					<thead>
						<tr>
							<th width="9%" nowrap>N° do Aviso</th>
							<th width="45%">Data de encerramento da colheita</th>
							<th width="45%">Data de envio do aviso</th>
							<th width="1%">Ações</th>
						</tr>
					</thead>
					<tbody align="center">
						<? foreach($Rs as $row): ?>
							<tr>
								<td align="center"><?=$row['id']?></td>
								<td><?=Agro_Util::formatDate($row['dt_encerramento_colheita'])?></td>
								<td><?=Agro_Util::formatDate($row['dt_criacao'])?></td>
								<td>
									<a class="popup" href="/sinistro/avisoencerramentocolheita/view/id/<?=$row['id']?>">
										<img src="/resources/imagens/mini/view.png" alt="view.png" title="Visualizar" />
									</a>
								</td>
							</tr>
						<? endforeach; ?>
					</tbody>
				</table>
			</div>
			<? endif; ?>
			<!-- /AREA DE AVISO DE ENCERRAMENTO DE COLHEITA -->
			
			<!-- AREA DE ARQUIVOS DO PROCESSO -->
			<? if ($this->user->tp_usuario == 'F'): ?>
				<? $rs = $this->processo->arquivos(); ?>
				<div class="area">
					<?=$this->title('Arquivos do Processo');?>
					<form name="form_arquivos_proposta" action="/sinistro/processo/checkfiles" method="post">
						<input type="hidden" name="id_processo" value="<?=$this->processo->id?>">
						
						<? if (count($rs)): ?>
							<button type="submit">Conferir Marcados</button>
						<? endif; ?>
						
						<button type="button" id="newFile">Cadastrar Arquivo</button>
						<? if (count($rs)): ?>
						<table width="100%" class="grid" cellpadding="1" cellspacing="1">
							<thead>
								<tr>
									<th width="2%"><input type="checkbox" id="check_all_arquivos" /></th>
									<th>Tipo do arquivo</th>
									<th width="1%" nowrap>Data do cadastro</th>
									<th width="1%">Ações</th>
								</tr>
							</thead>
							<tbody>
								<?
								$aux = array();
								foreach ($rs as $arquivo):
									if (!isset($aux[$arquivo['id_tipo_arquivo']])) {
										$aux[$arquivo['id_tipo_arquivo']] = array('count'=>1);
									} else {
										$aux[$arquivo['id_tipo_arquivo']]['count']++;
									}
									?>
									<tr id="file_<? echo $arquivo['id']; ?>">
										<td align="center"><input class="check_file" type="checkbox" name="ar_arquivoss_proposta[]" id="arquivo_proposta_<?=$arquivo['id']?>" value="<?=$arquivo['id']?>" <? if($arquivo['fl_conferido']): echo ' checked'; endif;?>></td>
										<td>
											<?
											echo $arquivo['ds_tipo_arquivo'];
											if($aux[$arquivo['id_tipo_arquivo']]['count'] > 1){
												echo ' (' . $aux[$arquivo['id_tipo_arquivo']]['count'] . ')';
											}
											?>
										</td>
										<td align="center"><?=Agro_Util::formatDate($arquivo['dt_criacao'], Zend_Date::DATES)?></td>
										<td align="center" nowrap>
											<a target="_blank" href="/agronet/file/processoarquivo/id/<?=$arquivo['id']?>"><img src="/resources/imagens/mini/download.png" alt="download.png" title="Download" border="0"></a>
											<a class="delete_arquivo" href="/sinistro/processo/deletefile/id/<?=$arquivo['id']?>"><img src="/resources/imagens/mini/delete.png" alt="delete.png" title="Excluir" border="0"></a>
										</td>
									</tr>
								<? endforeach; ?>
							</tbody>
						</table>
						<? endif; ?>
					</form>
				</div>
			<? endif; ?>
			<!-- /AREA DE ARQUIVOS DO PROCESSO -->
			
			<!-- AREA DE OBSERVACAO DOS ARQUIVOS DO PROCESSO -->
			<? if ($this->user->tp_usuario == 'F'): ?>
				<? $rs = $this->processo->arquivos_observacoes(); ?>
				<div class="area">
					<?=$this->title('Observação sobre os arquivos');?>
					<button type="button" id="newObservacaoArquivo">Cadastrar Observação</button>
					
					<? if (count($rs)): ?>
						<table width="100%" class="grid" cellpadding="1" cellspacing="1">
							<thead>
								<tr>
					                <th width="10%">Data</th>
					                <th>Autor</th>
					                <th>Conteúdo</th>
			                	</tr>
			                </thead>
			                <tbody>
				                <? foreach ($rs as $processo_observacao_arquivos): ?>
					                <tr>
					                	<td align="center"><?=$processo_observacao_arquivos['dt_entrada'];?></td>
					                	<td width="30%" nowrap><?=$processo_observacao_arquivos['ds_nome_funcionario'];?></td>
					                	<td><?=$processo_observacao_arquivos['ds_observacao_arquivos'];?></td>
					                </tr>
				                <? endforeach; ?>
			                </tbody>
			            </table>
					<? endif; ?>
				</div>
			<? endif; ?>
			<!-- /AREA DE OBSERVACAO DOS ARQUIVOS DO PROCESSO -->
			
			<!-- AREA DE OBSERVACAO DO PROCESSO -->
			<div class="area">
				<? $observacoes = $this->processo->observacoes(); ?>	
				<?=$this->title('Observações do Processo');?>
				<button type="button" id="newObservacaoProcesso">Cadastrar Observação</button>
				
				<? if (is_array($observacoes) && count($observacoes)): ?>
		    		<table width="100%" class="grid" cellpadding="1" cellspacing="1">
						<thead>
							<tr>
								<th width="10%">Data</th>
								<th>Autor</th>
								<th>Conteúdo</th>
							</tr>
						</thead>
						<tbody>
							<? foreach ($observacoes as $observacao): ?>
								<tr>
									<td align="center"><?=$observacao['dt_entrada'];?></td>
									<td nowrap><?=$observacao['ds_nome_funcionario'];?></td>
									<td><?=$observacao['ds_observacao'];?></td>
								</tr>
							<? endforeach; ?>
						</tbody>
					</table>
				<?endif;?>
			</div>
			<!-- AREA DE OBSERVACAO DO PROCESSO -->
		</div>
	</div>
</form>

<!-- AREA DOS POPUPS -->
<div title="Cadastrar Arquivo" id="formFile" class="hide">
	<form class="formDefault" id="formUploadFile" method="post" enctype="multipart/form-data">
        <input type="hidden" name="id_processo" value="<?=$this->processo->id;?>">
        
		<div class="row">
			<div class="field"><?=$this->form_file->id_tipo_arquivo?></div>
			<div class="field"><?=$this->form_file->arquivo?></div>
		</div>
	</form>
</div>

<div id="divObservacaoArquivo" title="Cadastrar nova observação para os arquivos" class="hide">
	<form id ="formObservacaoArquivo" name="form_observacao_processo_arquivos" method="post" action="/sinistro/processo/saveobservacao">
    	<input type="hidden" name="id_processo" value="<?=$this->processo->id;?>">
		<label for="ds_observacao">Observação:</label>
        <textarea rows="5" cols="80" name="ds_observacao_arquivos" id="ds_observacao_arquivos" maxlength="255"></textarea>
	</form>
</div>

<div id="divObservacaoProcesso" title="Cadastrar nova observação para o processo" class="hide">
	<form id="formObservacaoProcesso" name="form_observacao_proposta" method="post" action="/sinistro/processo/saveobservacao">
    	<input type="hidden" name="id_processo" value="<?=$this->processo->id;?>">
		<label for="ds_observacao">Observação</label>
		<textarea rows="5" cols="80" name="ds_observacao" id="ds_observacao" maxlength="255"></textarea>
    </form>
</div>

<!-- Pop-up agendamento vistoria final*********************************************************************** -->
<div class="divDialog hide" id="agendamentoVistFinal" style="width: 400px;height: 50%"></div>

<!-- Pop-up revistoria -->
<div class="divDialog hide" id="Revistoria" style="width: 50%; height: 65%">
	<div class="row">
		<div id="msgContainerRevistoria" align="center" style="display:none; background-color: #FFBBBC; color: #DB0912; font-weight: bold;"></div>
	</div>
	<form class="formDefault" id="formRevistoria" method="post">
		
		<input type="hidden" name="id_revistoria" id="id_revistoria" value="" />
		
		<?=$this->title('Solicitar Revistoria')?>
		
		<div id="msgFormRevistoria" align="center" style="display:none; background-color: #FFBBBC; color: #DB0912; font-weight: bold;"></div>
		<div class="geral">
			<div id="div_container_revistoria">
				<div>
					<label>Motivo da revistoria:</label>
					<textarea name="ds_motivo" id="ds_motivo" rows="3" cols="60"></textarea>
				</div>
				<br>
				<div>
					<table cellpadding="0" width="100%">
						<tr>
							<td width="35%">
								<label>Revistoria remunerada:</label>
							</td>
							<td width="15%">
								<input type='radio' name='fl_remunerada' id='fl_remunerada-S' value='S' />
								<label for="fl_remunerada-S">Sim</label>
							</td>
							<td>
								<input type='radio' name='fl_remunerada' id='fl_remunerada-N' value='N' />
								<label for="fl_remunerada-N">Não</label>
							</td>
						</tr>
					</table>
				</div>		
				<br>
				<div class="row" style="width: 100%">
					<div class="title">
						<span>
							Selecione as vistorias as quais esta revistoria se refere:
						</span>
					</div>
					<div id="msgCampoVariavelRevistoria" align="center" style="display:none; background-color: #FFBBBC; color: #DB0912; font-weight: bold;"></div>
					<div id="div_select_itens_revistoria"></div><br />
				</div>
			</div>
			
			<div class="row" style="margin-top:15px">
				<div class="field">
					<input type="button" id="btnSalvarRevistoria" value="Salvar" />
				</div>
				<div class="field">
					<input type="button" id="btnCancelarRevistoria" value="Cancelar" />
				</div>
			</div>
		</div>
	
	</form>
</div>

<!-- Pop-up agendamento revistoria -->
<div class="divDialog hide" id="agendamentoRevistoria" style="width: 50%; height: 40%">
	<div class="row">
		<div id="msgContainerAgendamentoRevistoria" align="center" style="display:none; background-color: #FFBBBC; color: #DB0912; font-weight: bold;"></div>
	</div>
	<form class="formDefault" id="formAgendamentoRevistoria" method="post">

		<input type="hidden" name="id_revistoria_agendamento" id="id_revistoria_agendamento" value="" />
		<input type="hidden" name="id_agendamento_revistoria" id="id_agendamento_revistoria" value="" />
		
		<?=$this->title('Agendamento de Revistoria')?>
		
		<div id="msgFormAgendamentoRevistoria" align="center" style="display:none; background-color: #FFBBBC; color: #DB0912; font-weight: bold;"></div>
		<div class="geral">
			<div id="div_container_agendamento_revistoria">
				<div class="row">
					<div class="field"><?=$this->formAgRevistoria->turno_revistoria?></div>
					<div class="field"><?=$this->formAgRevistoria->dt_revistoria?></div>
				</div>
			</div>
			
			<div class="row" style="margin-top:60px">
				<div class="field"><?=$this->formAgRevistoria->btt_agendar?></div>
				<div class="field"><?=$this->formAgRevistoria->btt_fechar?></div>
			</div>
		</div>
	
	</form>
</div>
<!-- /AREA DOS POPUPS -->