Spaces:
Running

hhhh / index.html
luis35's picture
crie um site que tenha um formulario para cadastrar e registrar notas lançadas de uma empresa concreteira e puxe umalistagem dos dados registrados - Initial Deployment
9522519 verified
Raw History Blame Contribute Delete
33.5 kB
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sistema de Notas - Concreteira</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.scrollbar-hide::-webkit-scrollbar {
display: none;
}
.scrollbar-hide {
-ms-overflow-style: none;
scrollbar-width: none;
}
.gradient-bg {
background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.fade-in {
animation: fadeIn 0.5s ease-out forwards;
}
.note-item:hover {
transform: translateY(-2px);
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
</style>
</head>
<body class="bg-gray-50 min-h-screen">
<div class="gradient-bg text-white py-6 px-4 shadow-lg">
<div class="container mx-auto flex justify-between items-center">
<div class="flex items-center space-x-3">
<i class="fas fa-truck-mix text-3xl"></i>
<h1 class="text-2xl font-bold">Concreteira<span class="text-blue-200">Ltda</span></h1>
</div>
<button id="themeToggle" class="p-2 rounded-full bg-white bg-opacity-20 hover:bg-opacity-30 transition">
<i class="fas fa-moon text-white"></i>
</button>
</div>
</div>
<div class="container mx-auto px-4 py-8">
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
<!-- Formulário de Cadastro -->
<div class="bg-white rounded-xl shadow-md p-6 fade-in">
<h2 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
<i class="fas fa-file-invoice-dollar mr-2 text-blue-500"></i>
Cadastrar Nota Fiscal
</h2>
<form id="noteForm" class="space-y-4">
<div>
<label for="noteNumber" class="block text-sm font-medium text-gray-700 mb-1">Número da Nota</label>
<input type="text" id="noteNumber" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition">
</div>
<div>
<label for="client" class="block text-sm font-medium text-gray-700 mb-1">Cliente</label>
<input type="text" id="client" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition">
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label for="date" class="block text-sm font-medium text-gray-700 mb-1">Data</label>
<input type="date" id="date" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition">
</div>
<div>
<label for="value" class="block text-sm font-medium text-gray-700 mb-1">Valor (R$)</label>
<input type="number" step="0.01" id="value" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition">
</div>
</div>
<div>
<label for="mixType" class="block text-sm font-medium text-gray-700 mb-1">Tipo de Concreto</label>
<select id="mixType" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition">
<option value="">Selecione...</option>
<option value="FCK25">Concreto FCK 25 MPa</option>
<option value="FCK30">Concreto FCK 30 MPa</option>
<option value="FCK35">Concreto FCK 35 MPa</option>
<option value="FCK40">Concreto FCK 40 MPa</option>
<option value="Bombeado">Concreto Bombeado</option>
</select>
</div>
<div>
<label for="quantity" class="block text-sm font-medium text-gray-700 mb-1">Quantidade (m³)</label>
<input type="number" step="0.1" id="quantity" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition">
</div>
<div>
<label for="status" class="block text-sm font-medium text-gray-700 mb-1">Status</label>
<select id="status" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition">
<option value="pending">Pendente</option>
<option value="paid">Pago</option>
<option value="delivered">Entregue</option>
<option value="canceled">Cancelado</option>
</select>
</div>
<div>
<label for="notes" class="block text-sm font-medium text-gray-700 mb-1">Observações</label>
<textarea id="notes" rows="3" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition"></textarea>
</div>
<button type="submit" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 rounded-md transition flex items-center justify-center">
<i class="fas fa-save mr-2"></i> Cadastrar Nota
</button>
</form>
</div>
<!-- Listagem de Notas -->
<div class="bg-white rounded-xl shadow-md p-6 fade-in">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-bold text-gray-800 flex items-center">
<i class="fas fa-list-check mr-2 text-blue-500"></i>
Notas Cadastradas
</h2>
<div class="relative">
<input type="text" id="searchInput" placeholder="Buscar..." class="pl-8 pr-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition">
<i class="fas fa-search absolute left-3 top-3 text-gray-400"></i>
</div>
</div>
<div class="overflow-auto max-h-[600px] scrollbar-hide">
<table id="notesTable" class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Nota</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Cliente</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Data</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Valor</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
<th class="px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Ações</th>
</tr>
</thead>
<tbody id="notesList" class="bg-white divide-y divide-gray-200">
<!-- Notas serão adicionadas aqui via JavaScript -->
</tbody>
</table>
<p id="emptyMessage" class="text-center py-4 text-gray-500">Nenhuma nota cadastrada ainda.</p>
</div>
<div class="mt-4 flex justify-between items-center">
<div>
<label for="itemsPerPage" class="text-sm text-gray-600">Itens por página:</label>
<select id="itemsPerPage" class="ml-2 border border-gray-300 rounded-md px-2 py-1 focus:ring-blue-500 focus:border-blue-500">
<option value="5">5</option>
<option value="10" selected>10</option>
<option value="20">20</option>
<option value="50">50</option>
</select>
</div>
<div id="pagination" class="flex space-x-2">
<!-- Pagination will be added here by JavaScript -->
</div>
</div>
</div>
</div>
</div>
<!-- Modal para edição -->
<div id="editModal" class="fixed inset-0 bg-black bg-opacity-50 hidden flex items-center justify-center z-50 px-4">
<div class="bg-white rounded-xl shadow-xl w-full max-w-md max-h-[90vh] overflow-y-auto">
<div class="p-6">
<div class="flex justify-between items-center mb-4">
<h3 class="text-lg font-bold text-gray-800">Editar Nota</h3>
<button id="closeModal" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<form id="editForm" class="space-y-4">
<input type="hidden" id="editId">
<div>
<label for="editNoteNumber" class="block text-sm font-medium text-gray-700 mb-1">Número da Nota</label>
<input type="text" id="editNoteNumber" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition">
</div>
<div>
<label for="editClient" class="block text-sm font-medium text-gray-700 mb-1">Cliente</label>
<input type="text" id="editClient" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition">
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label for="editDate" class="block text-sm font-medium text-gray-700 mb-1">Data</label>
<input type="date" id="editDate" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition">
</div>
<div>
<label for="editValue" class="block text-sm font-medium text-gray-700 mb-1">Valor (R$)</label>
<input type="number" step="0.01" id="editValue" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition">
</div>
</div>
<div>
<label for="editMixType" class="block text-sm font-medium text-gray-700 mb-1">Tipo de Concreto</label>
<select id="editMixType" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition">
<option value="FCK25">Concreto FCK 25 MPa</option>
<option value="FCK30">Concreto FCK 30 MPa</option>
<option value="FCK35">Concreto FCK 35 MPa</option>
<option value="FCK40">Concreto FCK 40 MPa</option>
<option value="Bombeado">Concreto Bombeado</option>
</select>
</div>
<div>
<label for="editQuantity" class="block text-sm font-medium text-gray-700 mb-1">Quantidade (m³)</label>
<input type="number" step="0.1" id="editQuantity" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition">
</div>
<div>
<label for="editStatus" class="block text-sm font-medium text-gray-700 mb-1">Status</label>
<select id="editStatus" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition">
<option value="pending">Pendente</option>
<option value="paid">Pago</option>
<option value="delivered">Entregue</option>
<option value="canceled">Cancelado</option>
</select>
</div>
<div>
<label for="editNotes" class="block text-sm font-medium text-gray-700 mb-1">Observações</label>
<textarea id="editNotes" rows="3" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition"></textarea>
</div>
<div class="flex space-x-4">
<button type="submit" class="flex-1 bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 rounded-md transition flex items-center justify-center">
<i class="fas fa-save mr-2"></i> Salvar
</button>
<button id="deleteNote" type="button" class="flex-1 bg-red-600 hover:bg-red-700 text-white font-medium py-2 px-4 rounded-md transition flex items-center justify-center">
<i class="fas fa-trash-alt mr-2"></i> Excluir
</button>
</div>
</form>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Sample data - in a real app, this would come from a database
let notes = JSON.parse(localStorage.getItem('concreteNotes')) || [];
let currentPage = 1;
let itemsPerPage = 10;
// DOM Elements
const noteForm = document.getElementById('noteForm');
const editForm = document.getElementById('editForm');
const notesList = document.getElementById('notesList');
const emptyMessage = document.getElementById('emptyMessage');
const editModal = document.getElementById('editModal');
const closeModal = document.getElementById('closeModal');
const deleteBtn = document.getElementById('deleteNote');
const searchInput = document.getElementById('searchInput');
const itemsPerPageSelect = document.getElementById('itemsPerPage');
const paginationDiv = document.getElementById('pagination');
const themeToggle = document.getElementById('themeToggle');
// Initialize
renderNotes();
// Theme Toggle
themeToggle.addEventListener('click', () => {
document.body.classList.toggle('dark');
if (document.body.classList.contains('dark')) {
themeToggle.innerHTML = '<i class="fas fa-sun text-white"></i>';
localStorage.setItem('theme', 'dark');
} else {
themeToggle.innerHTML = '<i class="fas fa-moon text-white"></i>';
localStorage.setItem('theme', 'light');
}
});
// Check for saved theme preference
if (localStorage.getItem('theme') === 'dark') {
document.body.classList.add('dark');
themeToggle.innerHTML = '<i class="fas fa-sun text-white"></i>';
}
// Form submission - Add new note
noteForm.addEventListener('submit', function(e) {
e.preventDefault();
const noteNumber = document.getElementById('noteNumber').value;
const client = document.getElementById('client').value;
const date = document.getElementById('date').value;
const value = parseFloat(document.getElementById('value').value);
const mixType = document.getElementById('mixType').value;
const quantity = parseFloat(document.getElementById('quantity').value);
const status = document.getElementById('status').value;
const notesText = document.getElementById('notes').value;
const newNote = {
id: Date.now().toString(),
noteNumber,
client,
date,
value,
mixType,
quantity,
status,
notes: notesText,
createdAt: new Date().toISOString()
};
notes.unshift(newNote);
saveNotes();
renderNotes();
// Reset form
noteForm.reset();
// Show success message
showAlert('Nota cadastrada com sucesso!', 'success');
});
// Edit form submission
editForm.addEventListener('submit', function(e) {
e.preventDefault();
const id = document.getElementById('editId').value;
const noteNumber = document.getElementById('editNoteNumber').value;
const client = document.getElementById('editClient').value;
const date = document.getElementById('editDate').value;
const value = parseFloat(document.getElementById('editValue').value);
const mixType = document.getElementById('editMixType').value;
const quantity = parseFloat(document.getElementById('editQuantity').value);
const status = document.getElementById('editStatus').value;
const notesText = document.getElementById('editNotes').value;
// Find and update note
const noteIndex = notes.findIndex(note => note.id === id);
if (noteIndex !== -1) {
notes[noteIndex] = {
...notes[noteIndex],
noteNumber,
client,
date,
value,
mixType,
quantity,
status,
notes: notesText
};
saveNotes();
renderNotes();
closeModal.click();
// Show success message
showAlert('Nota atualizada com sucesso!', 'success');
}
});
// Delete note
deleteBtn.addEventListener('click', function() {
const id = document.getElementById('editId').value;
const confirmation = confirm('Tem certeza que deseja excluir esta nota?');
if (confirmation) {
notes = notes.filter(note => note.id !== id);
saveNotes();
renderNotes();
closeModal.click();
// Show success message
showAlert('Nota excluída com sucesso!', 'success');
}
});
// Close modal
closeModal.addEventListener('click', function() {
editModal.classList.add('hidden');
});
// Search functionality
searchInput.addEventListener('input', function() {
currentPage = 1;
renderNotes();
});
// Items per page
itemsPerPageSelect.addEventListener('change', function() {
itemsPerPage = parseInt(this.value);
currentPage = 1;
renderNotes();
});
// Helper functions
function saveNotes() {
localStorage.setItem('concreteNotes', JSON.stringify(notes));
}
function renderNotes() {
const searchTerm = searchInput.value.toLowerCase();
let filteredNotes = notes;
// Filter by search term if exists
if (searchTerm) {
filteredNotes = notes.filter(note =>
note.noteNumber.toLowerCase().includes(searchTerm) ||
note.client.toLowerCase().includes(searchTerm) ||
note.date.toLowerCase().includes(searchTerm)
);
}
// Calculate pagination
const totalPages = Math.ceil(filteredNotes.length / itemsPerPage);
const startIndex = (currentPage - 1) * itemsPerPage;
const endIndex = startIndex + itemsPerPage;
const paginatedNotes = filteredNotes.slice(startIndex, endIndex);
// Clear existing notes
notesList.innerHTML = '';
// Show empty message if no notes
if (paginatedNotes.length === 0) {
emptyMessage.classList.remove('hidden');
} else {
emptyMessage.classList.add('hidden');
// Render each note
paginatedNotes.forEach(note => {
const tr = document.createElement('tr');
tr.className = 'note-item hover:bg-gray-50 transition cursor-pointer';
// Format date
const formattedDate = formatDate(note.date);
// Format currency
const formattedValue = new Intl.NumberFormat('pt-BR', {
style: 'currency',
currency: 'BRL'
}).format(note.value);
// Status badge
let statusClass, statusText;
switch(note.status) {
case 'pending':
statusClass = 'bg-yellow-100 text-yellow-800';
statusText = 'Pendente';
break;
case 'paid':
statusClass = 'bg-green-100 text-green-800';
statusText = 'Pago';
break;
case 'delivered':
statusClass = 'bg-blue-100 text-blue-800';
statusText = 'Entregue';
break;
case 'canceled':
statusClass = 'bg-red-100 text-red-800';
statusText = 'Cancelado';
break;
}
tr.innerHTML = `
<td class="px-4 py-3 whitespace-nowrap text-sm font-medium text-gray-900">${note.noteNumber}</td>
<td class="px-4 py-3 whitespace-nowrap text-sm text-gray-500">${note.client}</td>
<td class="px-4 py-3 whitespace-nowrap text-sm text-gray-500">${formattedDate}</td>
<td class="px-4 py-3 whitespace-nowrap text-sm text-gray-500">${formattedValue}</td>
<td class="px-4 py-3 whitespace-nowrap text-sm font-medium">
<span class="px-2 py-1 text-xs rounded-full ${statusClass}">${statusText}</span>
</td>
<td class="px-4 py-3 whitespace-nowrap text-right text-sm font-medium">
<button class="text-blue-600 hover:text-blue-900 edit-btn mr-3" data-id="${note.id}">
<i class="fas fa-edit"></i>
</button>
<button class="text-red-600 hover:text-red-900 delete-btn" data-id="${note.id}">
<i class="fas fa-trash-alt"></i>
</button>
</td>
`;
notesList.appendChild(tr);
});
// Add event listeners to edit/delete buttons
document.querySelectorAll('.edit-btn').forEach(btn => {
btn.addEventListener('click', function(e) {
e.stopPropagation();
const id = this.getAttribute('data-id');
editNote(id);
});
});
document.querySelectorAll('.delete-btn').forEach(btn => {
btn.addEventListener('click', function(e) {
e.stopPropagation();
const id = this.getAttribute('data-id');
deleteNote(id);
});
});
// Add click event to row to show details
document.querySelectorAll('.note-item').forEach(row => {
row.addEventListener('click', function() {
const id = this.querySelector('.edit-btn').getAttribute('data-id');
editNote(id);
});
});
}
// Render pagination
renderPagination(filteredNotes.length, itemsPerPage, currentPage);
}
function renderPagination(totalItems, perPage, currentPage) {
const totalPages = Math.ceil(totalItems / perPage);
paginationDiv.innerHTML = '';
if (totalPages <= 1) return;
// Previous button
const prevBtn = document.createElement('button');
prevBtn.innerHTML = '<i class="fas fa-chevron-left"></i>';
prevBtn.className = `px-3 py-1 border rounded ${currentPage === 1 ? 'bg-gray-100 text-gray-400 cursor-not-allowed' : 'hover:bg-gray-100'}`;
prevBtn.disabled = currentPage === 1;
prevBtn.addEventListener('click', () => {
if (currentPage > 1) {
currentPage--;
renderNotes();
}
});
paginationDiv.appendChild(prevBtn);
// Page numbers
for (let i = 1; i <= totalPages; i++) {
const pageBtn = document.createElement('button');
pageBtn.textContent = i;
pageBtn.className = `px-3 py-1 border rounded ${currentPage === i ? 'bg-blue-500 text-white' : 'hover:bg-gray-100'}`;
pageBtn.addEventListener('click', () => {
currentPage = i;
renderNotes();
});
paginationDiv.appendChild(pageBtn);
}
// Next button
const nextBtn = document.createElement('button');
nextBtn.innerHTML = '<i class="fas fa-chevron-right"></i>';
nextBtn.className = `px-3 py-1 border rounded ${currentPage === totalPages ? 'bg-gray-100 text-gray-400 cursor-not-allowed' : 'hover:bg-gray-100'}`;
nextBtn.disabled = currentPage === totalPages;
nextBtn.addEventListener('click', () => {
if (currentPage < totalPages) {
currentPage++;
renderNotes();
}
});
paginationDiv.appendChild(nextBtn);
}
function editNote(id) {
const note = notes.find(note => note.id === id);
if (note) {
document.getElementById('editId').value = note.id;
document.getElementById('editNoteNumber').value = note.noteNumber;
document.getElementById('editClient').value = note.client;
document.getElementById('editDate').value = note.date;
document.getElementById('editValue').value = note.value;
document.getElementById('editMixType').value = note.mixType;
document.getElementById('editQuantity').value = note.quantity;
document.getElementById('editStatus').value = note.status;
document.getElementById('editNotes').value = note.notes || '';
editModal.classList.remove('hidden');
}
}
function deleteNote(id) {
const confirmation = confirm('Tem certeza que deseja excluir esta nota?');
if (confirmation) {
notes = notes.filter(note => note.id !== id);
saveNotes();
renderNotes();
// Show success message
showAlert('Nota excluída com sucesso!', 'success');
}
}
function formatDate(dateString) {
const options = { day: '2-digit', month: '2-digit', year: 'numeric' };
return new Date(dateString).toLocaleDateString('pt-BR', options);
}
function showAlert(message, type) {
const alert = document.createElement('div');
alert.className = `fixed top-4 right-4 p-4 rounded-md shadow-lg z-50 animate-fade-in-out ${type === 'success' ? 'bg-green-500 text-white' : 'bg-red-500 text-white'}`;
alert.innerHTML = `
<div class="flex items-center">
<i class="fas ${type === 'success' ? 'fa-check-circle' : 'fa-exclamation-circle'} mr-2"></i>
${message}
</div>
`;
document.body.appendChild(alert);
// Remove after 3 seconds
setTimeout(() => {
alert.classList.add('animate-fade-out');
setTimeout(() => {
document.body.removeChild(alert);
}, 500);
}, 3000);
}
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=luis35/hhhh" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>