Sale Maangement Coding
Sale Maangement Coding
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sales Management System</title>
<style>
/* Add your CSS styles here */
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
margin: 0;
padding: 20px;
}
.container {
max-width: 800px;
margin: auto;
background: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
margin-bottom: 20px;
}
h1 {
text-align: center;
color: #333;
}
label {
font-weight: bold;
}
input[type="text"],
input[type="tel"],
input[type="date"],
input[type="number"],
textarea {
width: 100%;
padding: 10px;
margin: 5px 0;
border: 1px solid #ccc;
border-radius: 5px;
box-sizing: border-box;
}
button {
background-color: #4CAF50;
color: white;
padding: 12px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
width: 100%;
}
button:hover {
background-color: #45a049;
}
.records, .follow-ups {
margin-top: 20px;
}
.record, .follow-up {
background: #f9f9f9;
padding: 10px;
margin-bottom: 10px;
border-radius: 5px;
}
.record.done {
background: #d7ffd9;
}
.record.closed {
text-decoration: line-through;
background: #ffd7d7;
}
.download-btn {
margin-top: 20px;
}
.pagination {
display: flex;
justify-content: center;
margin-top: 20px;
}
.pagination button {
margin: 0 5px;
padding: 10px 20px;
}
</style>
</head>
<body>
<div class="container">
<h1>Sales Management System</h1>
<form id="salesForm">
<label for="customerName">Customer Name:</label>
<input type="text" id="customerName" required><br>
<label for="date">Date:</label>
<input type="date" id="date" required><br>
<label for="conversation">Conversation:</label><br>
<textarea id="conversation" rows="4" required></textarea><br>
<label for="productName">Product Name:</label>
<input type="text" id="productName" required><br>
<label for="price">Price:</label>
<input type="number" id="price" required><br>
<div class="container">
<h2>Today's Follow-ups</h2>
<div id="followUps">
<!-- Follow-up records will be displayed here -->
</div>
</div>
<script>
// Array to store records
let records = JSON.parse(localStorage.getItem('records')) || [];
const recordsPerPage = 4;
let currentPage = 1;
document.addEventListener('DOMContentLoaded', () => {
displayRecords();
displayFollowUps();
});
function createOrUpdateRecord() {
const customerName = document.getElementById('customerName').value;
const phoneNumber = document.getElementById('phoneNumber').value;
const existingRecordIndex = records.findIndex(record =>
record.customerName === customerName && record.phoneNumber === phoneNumber);
const record = {
customerName,
phoneNumber,
date: document.getElementById('date').value,
conversation: document.getElementById('conversation').value,
productName: document.getElementById('productName').value,
price: document.getElementById('price').value,
followUpDate: document.getElementById('followUpDate').value,
status: 'open'
};
if (existingRecordIndex !== -1) {
records[existingRecordIndex] = record; // Update existing record
} else {
records.unshift(record); // Add new record at the beginning
}
localStorage.setItem('records', JSON.stringify(records));
displayRecords();
displayFollowUps();
clearForm();
}
function displayRecords() {
const recordsContainer = document.getElementById('records');
recordsContainer.innerHTML = '';
const totalRecords = records.length;
const totalPages = Math.ceil(totalRecords / recordsPerPage);
const startIndex = (currentPage - 1) * recordsPerPage;
const endIndex = Math.min(startIndex + recordsPerPage, totalRecords);
if (currentPage > 1) {
const prevButton = document.createElement('button');
prevButton.textContent = 'Previous';
prevButton.onclick = () => {
currentPage--;
displayRecords();
};
paginationContainer.appendChild(prevButton);
}
function displayFollowUps() {
const followUpsContainer = document.getElementById('followUps');
followUpsContainer.innerHTML = '';
const today = new Date().toISOString().split('T')[0];
const followUps = records.filter(record => record.followUpDate ===
today && record.status === 'open');
followUps.forEach((record, index) => {
const div = document.createElement('div');
div.classList.add('follow-up');
div.innerHTML = `
<p><strong>Customer Name:</strong> ${record.customerName}</p>
<p><strong>Phone Number:</strong> ${record.phoneNumber}</p>
<p><strong>Date:</strong> ${record.date}</p>
<p><strong>Conversation:</strong> ${record.conversation}</p>
<p><strong>Product Name:</strong> ${record.productName}</p>
<p><strong>Price:</strong> ${record.price}</p>
<p><strong>Follow-up Date:</strong> ${record.followUpDate}</p>
<button onclick="markAsDone(${index})">Mark as Done</button>
<button onclick="markAsClosed(${index})">Close</button>
<button onclick="deleteRecord(${index})">Delete</button>
<button onclick="duplicateEntry(${index})">Duplicate
Entry</button>
`;
followUpsContainer.appendChild(div);
});
}
function markAsDone(index) {
records[index].status = 'done';
localStorage.setItem('records', JSON.stringify(records));
displayRecords();
displayFollowUps();
}
function markAsClosed(index) {
records[index].status = 'closed';
localStorage.setItem('records', JSON.stringify(records));
displayRecords();
displayFollowUps();
}
function deleteRecord(index) {
records.splice(index, 1);
localStorage.setItem('records', JSON.stringify(records));
displayRecords();
displayFollowUps();
}
function duplicateEntry(index) {
const record = records[index];
document.getElementById('customerName').value = record.customerName;
document.getElementById('phoneNumber').value = record.phoneNumber;
document.getElementById('date').value = record.date;
document.getElementById('conversation').value = record.conversation;
document.getElementById('productName').value = record.productName;
document.getElementById('price').value = record.price;
document.getElementById('followUpDate').value = '';
}
function clearForm() {
document.getElementById('customerName').value = '';
document.getElementById('phoneNumber').value = '';
document.getElementById('date').value = '';
document.getElementById('conversation').value = '';
document.getElementById('productName').value = '';
document.getElementById('price').value = '';
document.getElementById('followUpDate').value = '';
}
function downloadExcel() {
let csvContent = "data:text/csv;charset=utf-8,";
csvContent += "Customer Name,Phone Number,Date,Conversation,Product
Name,Price,Follow-up Date,Status\n";
records.forEach(record => {
const row = [
record.customerName,
record.phoneNumber,
record.date,
record.conversation,
record.productName,
record.price,
record.followUpDate,
record.status
].join(",");
csvContent += row + "\n";
});