D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
crsys_ant
/
Filename :
testeconsulta.php
back
Copy
<!DOCTYPE html> <html lang="pt-br"> <head> <meta charset="UTF-8"> <title>Busca de Orçamentos</title> </head> <body> <input type="text" id="busca" placeholder="Digite parte do nome ou obra" autocomplete="off"> <div class="table-responsive"> <table class="table table-striped table-nowrap"> <thead> <tr> <th>Nº Orc.</th> <th>Revisão</th> <th>Nome</th> <th>Obra</th> <th class="text-center">Status</th> <th class="text-center">Selecione</th> </tr> </thead> <tbody id="resultado"></tbody> </table> </div> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet"> <script> document.getElementById('busca').addEventListener('keyup', function () { const termo = this.value.trim(); const resultado = document.getElementById('resultado'); if (termo.length < 2) { resultado.innerHTML = ''; return; } console.log('busca: ', encodeURIComponent(termo)); fetch('buscar_orcamento.php?q=' + encodeURIComponent(termo)) .then(resp => resp.json()) .then(dados => { let html = ''; if (!dados.length) { html = '<tr><td colspan="2">Nenhum resultado</td></tr>'; } else { dados.forEach(item => { html += ` <tr> <td>${item.orca_id}</td> <td>${item.num_revisao}</td> <td>${item.nome}</td> <td>${item.obra}</td> <!-- Coluna STATUS --> <td class="text-center"> <span class="badge bg-${item.cor_cr}"> ${item.nome_stat} </span> </td> <!-- Coluna SELECIONE --> <td class="text-center"> <button class="btn btn-sm btn-primary" title="Selecionar" onclick="selecionar('${item.orca_id}', '${item.num_revisao}')"> <i class="bi bi-check-lg"></i> </button> </td> </tr> `; }); } resultado.innerHTML = html; }) .catch(err => { console.error('Erro na busca:', err); }); }); </script> </body> </html>