<link rel="stylesheet" href="/resources/css/seguro/propostaview.css" type="text/css" media="screen" />
<link rel="stylesheet" href="/resources/css/seguro/laudoview.css" type="text/css" media="screen" />
<link rel="stylesheet" href="/resources/css/regulacao/form.css" type="text/css" media="all" />

<?php if($this->sucesso === false): ?>
<div class="messageDesigner"><div id="message" class="error">Não foi! possível salvar o(s) arquivo(s) por exceder(em) o limite máximo de 1.5Mb por foto.</div></div><br>
<?php endif;?>

<?php if($this->sucesso === true): ?>
<div class="messageDesigner"><div id="message" class="success">Arquivo(s) salvo(s) com sucesso!</div></div><br>
<?php endif;?>

<form name="formItemLaudoFinal" id="formItemLaudoFinal" method="post" style="background:#FFF;"  enctype="multipart/form-data"> 
    <input type='hidden' id='id_laudo' name='id_laudo' value='<?php echo $this->idLaudoFinal?>'>
    <input type='hidden' id='id_laudo_final_item_segurado' name='id_laudo_final_item_segurado' value='<?php echo $this->idLaudoFinalItemSegurado?>'>
    
    <div class="gadget">
        <div class="gadget-caption">Fotos Item</div>
        <div class="info">
            <table width='100%'>
                <tr>
                    <td>
                        <b>Vistoria Número</b><br />
                        <?php echo $this->idVistoria?>
                    </td>
                    <td>
                        <b>Laudo Final Número</b><br />
                        <?php echo $this->idLaudoFinal?>
                    </td>
                    <td>
                        <b>Item Laudo Final Número</b><br />
                        <?php echo $this->idLaudoFinalItemSegurado?>
                    </td>
                </tr>
            </table>
        </div>
    </div>

    <div class="gadget">
        <?php if(!empty($this->fotos)): ?>
            <div align="right">
                <button id="btnBaixarFotos">Baixar fotos</button>
            </div>
        <?php endif; ?>
        
        <div class="gadget-caption">
            <?php if ($this->fotos): ?>
                <div id="row">
                    <table width="100%" cellpadding="2" cellspacing="1" class="grid">
						<thead>
							<tr>
								<th>Tipo de Arquivo</th>
								<th>Nome do Arquivo</th>
								<th>Data</th>
								<th>Status</th>
								<th>Ações</th>
							</tr>
						</thead>
                        <tbody>
                            <?php foreach($this->fotos as $key => $arquivo): ?>
                                <tr id='arquivo_<?= $key?>'>
                                    <td><?=$arquivo['ds_tipo_arquivo'];?></td>
									<td><?=$arquivo['descricao_arquivo'];?></td>
									<td><?=$arquivo['dt_criacao'];?></td>
									<td><?=$arquivo['status_recebimento'];?></td>
									<td class="images-files" style="width: 6%; text-align: center;">
										<? if ($arquivo['arquivo_existe']) { ?>
											<a class="download-arquivo" href="/agronet/file/laudofinal/id/<?php echo $arquivo['id']?>/isArquivoItem/1" target='_blank'><img src="/resources/imagens/mini/download.png" alt="download.png" title="Baixar Arquivo" border="0"></a>
											<?	if (file_exists(APPLICATION . $arquivo['file_thumb'])) { ?>
												<div class="image-thumb">
													<img src="<?=($arquivo['file_thumb']);?>" alt="thumb">
												</div>
											<? } ?>
										<? } ?>
                                        
                                        <? if ($arquivo['permite_excluir']) { ?>
                                            <a href="/sinistro2/processo/deletefotolaudofinalitem/id/<?php echo $arquivo['id']?>" id="delete_foto" rel="/sinistro2/processo/deletefotolaudofinalitem/id/<?php echo $arquivo['id']?>" class='excluir_arquivo'><img src="/resources/imagens/mini/delete.png" alt="delete.png" title="Deletar" border="0"></a>
                                        <? } ?>
                                    </td>
                                </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                </div>
            <?php endif; ?>

            <table width='100%'>
                <tr>
                    <td>
                        <label for="foto" class="optional">Foto</label>
                        <input name="foto[]" id="foto" class="multi" size="50" type="file" multiple="1" title="Tamanho máximo por arquivo: 1.5Mb">
                    </td>
                </tr>
            </table>
        </div>
    </div>

    <div style="text-align: center;">
        <button type="submit" id="enviar_form">Salvar</button>
    </div>
</form>