anycoder-5bcab292 / index.html
ishash's picture
Upload folder using huggingface_hub
af75f61 verified
Raw History Blame Contribute Delete
28.4 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sales Goal ERP Module</title>
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<!-- Icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<!-- Chart.js -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
/* --- CSS VARIABLES & RESET --- */
:root {
--primary: #4f46e5; /* Indigo 600 */
--primary-light: #e0e7ff;
--secondary: #64748b; /* Slate 500 */
--bg-body: #f3f4f6; /* Gray 100 */
--bg-card: #ffffff;
--text-main: #1e293b; /* Slate 800 */
--text-muted: #94a3b8; /* Slate 400 */
--border: #e2e8f0;
--success: #10b981;
--warning: #f59e0b;
--danger: #ef4444;
--radius: 12px;
--shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
--transition: all 0.3s ease;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: 'Inter', sans-serif;
background-color: var(--bg-body);
color: var(--text-main);
line-height: 1.6;
}
/* --- HEADER --- */
header {
background: var(--bg-card);
border-bottom: 1px solid var(--border);
padding: 1rem 2rem;
display: flex;
justify-content: space-between;
align-items: center;
position: sticky;
top: 0;
z-index: 100;
box-shadow: var(--shadow);
}
.brand {
display: flex;
align-items: center;
gap: 10px;
font-size: 1.25rem;
font-weight: 700;
color: var(--primary);
}
.user-nav {
display: flex;
align-items: center;
gap: 20px;
}
.user-profile {
display: flex;
align-items: center;
gap: 10px;
cursor: pointer;
}
.avatar {
width: 35px;
height: 35px;
background: var(--primary-light);
color: var(--primary);
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
font-weight: 600;
}
.anycoder-link {
font-size: 0.85rem;
color: var(--secondary);
text-decoration: none;
border-bottom: 1px dashed var(--secondary);
transition: var(--transition);
}
.anycoder-link:hover {
color: var(--primary);
border-color: var(--primary);
}
/* --- NAVIGATION TABS --- */
.tabs-container {
max-width: 1200px;
margin: 2rem auto;
padding: 0 1rem;
}
.tabs {
display: flex;
gap: 1rem;
margin-bottom: 1.5rem;
border-bottom: 1px solid var(--border);
}
.tab-btn {
background: none;
border: none;
padding: 10px 20px;
font-size: 1rem;
font-weight: 500;
color: var(--text-muted);
cursor: pointer;
position: relative;
transition: var(--transition);
}
.tab-btn:hover {
color: var(--primary);
}
.tab-btn.active {
color: var(--primary);
}
.tab-btn.active::after {
content: '';
position: absolute;
bottom: -1px;
left: 0;
width: 100%;
height: 2px;
background: var(--primary);
}
/* --- CONTENT AREAS --- */
.tab-content {
display: none;
animation: fadeIn 0.4s ease;
}
.tab-content.active {
display: block;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
/* --- GRID SYSTEM --- */
.grid-layout {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 1.5rem;
}
.card {
background: var(--bg-card);
border-radius: var(--radius);
padding: 1.5rem;
box-shadow: var(--shadow);
border: 1px solid var(--border);
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1.5rem;
}
.card-title {
font-size: 1.1rem;
font-weight: 600;
}
/* --- FORMS (TAB 1) --- */
.form-group {
margin-bottom: 1rem;
}
label {
display: block;
margin-bottom: 0.5rem;
font-size: 0.9rem;
font-weight: 500;
color: var(--text-main);
}
input, select {
width: 100%;
padding: 0.75rem;
border: 1px solid var(--border);
border-radius: 8px;
font-family: inherit;
font-size: 0.95rem;
transition: var(--transition);
}
input:focus, select:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 0 3px var(--primary-light);
}
.btn {
padding: 0.75rem 1.5rem;
border: none;
border-radius: 8px;
font-weight: 600;
cursor: pointer;
transition: var(--transition);
display: inline-flex;
align-items: center;
gap: 8px;
}
.btn-primary {
background: var(--primary);
color: white;
width: 100%;
justify-content: center;
}
.btn-primary:hover {
background: #4338ca;
}
/* --- GOAL LIST CARDS --- */
.goal-item {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: 10px;
padding: 1rem;
margin-bottom: 1rem;
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.goal-header {
display: flex;
justify-content: space-between;
font-weight: 600;
}
.goal-details {
font-size: 0.85rem;
color: var(--secondary);
}
.progress-bar-bg {
width: 100%;
height: 8px;
background: #e2e8f0;
border-radius: 4px;
overflow: hidden;
margin-top: 5px;
}
.progress-bar-fill {
height: 100%;
background: var(--success);
border-radius: 4px;
transition: width 1s ease-in-out;
}
/* --- DASHBOARD (TAB 2) --- */
.stats-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 1.5rem;
margin-bottom: 2rem;
}
.stat-card {
background: var(--bg-card);
padding: 1.5rem;
border-radius: var(--radius);
box-shadow: var(--shadow);
display: flex;
align-items: center;
gap: 1rem;
}
.stat-icon {
width: 50px;
height: 50px;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.5rem;
}
.stat-info h3 {
font-size: 0.9rem;
color: var(--secondary);
font-weight: 500;
}
.stat-info p {
font-size: 1.5rem;
font-weight: 700;
}
.bg-blue { background: #dbeafe; color: #2563eb; }
.bg-green { background: #dcfce7; color: #16a34a; }
.bg-purple { background: #f3e8ff; color: #9333ea; }
.bg-orange { background: #ffedd5; color: #ea580c; }
/* --- REPORTS TABLE (TAB 3) --- */
.table-container {
overflow-x: auto;
background: var(--bg-card);
border-radius: var(--radius);
box-shadow: var(--shadow);
}
table {
width: 100%;
border-collapse: collapse;
text-align: left;
}
th {
background: #f8fafc;
padding: 1rem;
font-weight: 600;
font-size: 0.9rem;
color: var(--secondary);
border-bottom: 1px solid var(--border);
}
td {
padding: 1rem;
border-bottom: 1px solid var(--border);
font-size: 0.95rem;
}
tr:last-child td {
border-bottom: none;
}
.status-badge {
padding: 4px 12px;
border-radius: 20px;
font-size: 0.8rem;
font-weight: 600;
}
.status-achieved { background: #dcfce7; color: #16a34a; }
.status-active { background: #dbeafe; color: #2563eb; }
.status-risk { background: #fee2e2; color: #dc2626; }
/* Responsive adjustments */
@media (max-width: 768px) {
header {
padding: 1rem;
}
.tabs {
overflow-x: auto;
white-space: nowrap;
padding-bottom: 5px;
}
.tab-btn {
padding: 8px 12px;
}
}
</style>
</head>
<body>
<!-- HEADER -->
<header>
<div class="brand">
<i class="fa-solid fa-bullseye"></i>
<span>SalesGoal<span style="color:var(--text-muted)">ERP</span></span>
</div>
<div class="user-nav">
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="anycoder-link">Built with AnyCoder</a>
<i class="fa-solid fa-message" style="color: var(--secondary); cursor: pointer;"></i>
<div class="user-profile">
<div class="avatar">AI</div>
<span style="font-weight: 500;">ash ishash</span>
<i class="fa-solid fa-chevron-down" style="font-size: 0.8rem; color: var(--secondary);"></i>
</div>
</div>
</header>
<!-- MAIN CONTENT -->
<main class="tabs-container">
<!-- NAVIGATION TABS -->
<nav class="tabs">
<button class="tab-btn active" onclick="switchTab('tab-goals')">
<i class="fa-solid fa-pen-to-square"></i> Set Goals
</button>
<button class="tab-btn" onclick="switchTab('tab-dashboard')">
<i class="fa-solid fa-chart-pie"></i> Dashboard
</button>
<button class="tab-btn" onclick="switchTab('tab-reports')">
<i class="fa-solid fa-file-lines"></i> Reports
</button>
</nav>
<!-- TAB 1: SET GOALS -->
<section id="tab-goals" class="tab-content active">
<div class="grid-layout">
<!-- Input Form -->
<div class="card">
<div class="card-header">
<h2 class="card-title">Create New Goal</h2>
</div>
<form id="goalForm" onsubmit="addGoal(event)">
<div class="form-group">
<label>Sales Rep</label>
<select id="repSelect" required>
<option value="" disabled selected>Select Rep...</option>
<option value="Alice Johnson">Alice Johnson</option>
<option value="Bob Smith">Bob Smith</option>
<option value="Charlie Davis">Charlie Davis</option>
<option value="Dana Lee">Dana Lee</option>
</select>
</div>
<div class="grid-layout" style="grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px;">
<div class="form-group">
<label>Period</label>
<select id="periodSelect" required>
<option value="Monthly">Monthly</option>
<option value="Weekly">Weekly</option>
<option value="Daily">Daily</option>
</select>
</div>
<div class="form-group">
<label>Target Type</label>
<select id="typeSelect" required>
<option value="Revenue">Revenue ($)</option>
<option value="Quantity">Quantity (Units)</option>
</select>
</div>
</div>
<div class="form-group">
<label>Item Group</label>
<select id="itemSelect" required>
<option value="All Items">All Items</option>
<option value="Electronics">Electronics</option>
<option value="Software Licenses">Software Licenses</option>
<option value="Consulting">Consulting Services</option>
</select>
</div>
<div class="form-group">
<label>Target Value</label>
<input type="number" id="targetValue" placeholder="e.g. 50000" min="1" required>
</div>
<button type="submit" class="btn btn-primary">
<i class="fa-solid fa-plus"></i> Add Goal
</button>
</form>
</div>
<!-- Current Goals List -->
<div class="card">
<div class="card-header">
<h2 class="card-title">Active Goals</h2>
<button class="btn" style="padding: 5px 10px; font-size: 0.8rem;" onclick="clearGoals()">Clear All</button>
</div>
<div id="goalsListContainer" style="max-height: 500px; overflow-y: auto;">
<!-- Goals will be injected here via JS -->
<p style="color: var(--secondary); text-align: center; padding: 20px;">No active goals set.</p>
</div>
</div>
</div>
</section>
<!-- TAB 2: DASHBOARD -->
<section id="tab-dashboard" class="tab-content">
<!-- Summary Cards -->
<div class="stats-grid">
<div class="stat-card">
<div class="stat-icon bg-blue"><i class="fa-solid fa-dollar-sign"></i></div>
<div class="stat-info">
<h3>Total Revenue</h3>
<p>$124,500</p>
</div>
</div>
<div class="stat-card">
<div class="stat-icon bg-green"><i class="fa-solid fa-cubes"></i></div>
<div class="stat-info">
<h3>Units Sold</h3>
<p>1,245</p>
</div>
</div>
<div class="stat-card">
<div class="stat-icon bg-purple"><i class="fa-solid fa-trophy"></i></div>
<div class="stat-info">
<h3>Top Performer</h3>
<p>Alice Johnson</p>
</div>
</div>
<div class="stat-card">
<div class="stat-icon bg-orange"><i class="fa-solid fa-bullseye"></i></div>
<div class="stat-info">
<h3>Goal Completion</h3>
<p>78%</p>
</div>
</div>
</div>
<!-- Charts -->
<div class="grid-layout">
<div class="card">
<div class="card-header">
<h2 class="card-title">Revenue vs Target (Current Month)</h2>
</div>
<canvas id="revenueChart"></canvas>
</div>
<div class="card">
<div class="card-header">
<h2 class="card-title">Daily Sales Trend</h2>
</div>
<canvas id="trendChart"></canvas>
</div>
</div>
</section>
<!-- TAB 3: REPORTS -->
<section id="tab-reports" class="tab-content">
<div class="card" style="margin-bottom: 1.5rem;">
<div class="card-header">
<h2 class="card-title">Sales Representative Performance Report</h2>
<div>
<button class="btn" style="background: #e2e8f0; color: var(--text-main);" onclick="exportReport()"><i class="fa-solid fa-download"></i> Export CSV</button>
</div>
</div>
<div class="table-container">
<table>
<thead>
<tr>
<th>Rep Name</th>
<th>Goal Item Group</th>
<th>Period</th>
<th>Target</th>
<th>Actual</th>
<th>Variance</th>
<th>Status</th>
</tr>
</thead>
<tbody id="reportTableBody">
<!-- Report rows generated by JS -->
</tbody>
</table>
</div>
</div>
</section>
</main>
<!-- JAVASCRIPT LOGIC -->
<script>
// --- STATE MANAGEMENT ---
// Mock data to simulate a backend
let goals = [
{ id: 1, rep: 'Alice Johnson', period: 'Monthly', type: 'Revenue', group: 'All Items', target: 50000, current: 42500 },
{ id: 2, rep: 'Bob Smith', period: 'Monthly', type: 'Quantity', group: 'Software Licenses', target: 100, current: 45 },
{ id: 3, rep: 'Charlie Davis', period: 'Weekly', type: 'Revenue', group: 'Consulting', target: 5000, current: 5200 },
{ id: 4, rep: 'Dana Lee', period: 'Monthly', type: 'Quantity', group: 'Electronics', target: 200, current: 120 }
];
// Chart instances
let revenueChartInstance = null;
let trendChartInstance = null;
// --- TAB SWITCHING ---
function switchTab(tabId) {
// Remove active class from all tabs and contents
document.querySelectorAll('.tab-btn').forEach(btn => btn.classList.remove('active'));
document.querySelectorAll('.tab-content').forEach(content => content.classList.remove('active'));
// Add active class to clicked tab and target content
const activeBtn = Array.from(document.querySelectorAll('.tab-btn')).find(btn => btn.getAttribute('onclick').includes(tabId));
if(activeBtn) activeBtn.classList.add('active');
document.getElementById(tabId).classList.add('active');
// If dashboard, render charts
if (tabId === 'tab-dashboard') {
setTimeout(initCharts, 100); // Small delay to ensure container is visible
}
}
// --- GOAL LOGIC ---
function renderGoals() {
const container = document.getElementById('goalsListContainer');
container.innerHTML = '';
if (goals.length === 0) {
container.innerHTML = '<p style="color: var(--secondary); text-align: center; padding: 20px;">No active goals set.</p>';
return;
}
goals.forEach(goal => {
const percentage = Math.min(100, Math.round((goal.current / goal.target) * 100));
let color = 'var(--success)';
if (percentage < 50) color = 'var(--danger)';
else if (percentage < 80) color = 'var(--warning)';
const div = document.createElement('div');
div.className = 'goal-item';
div.innerHTML = `
<div class="goal-header">
<span>${goal.rep}</span>
<span style="color: var(--primary)">${goal.type}: ${formatNumber(goal.target)}</span>
</div>
<div class="goal-details">
<span>${goal.period} - ${goal.group}</span> |
<span>Achieved: ${formatNumber(goal.current)}</span>
</div>
<div class="progress-bar-bg">
<div class="progress-bar-fill" style="width: ${percentage}%; background: ${color};"></div>
</div>
`;
container.appendChild(div);
});
}
function addGoal(e) {
e.preventDefault();
const rep = document.getElementById('repSelect').value;
const period = document.getElementById('periodSelect').value;
const type = document.getElementById('typeSelect').value;
const group = document.getElementById('itemSelect').value;
const target = parseFloat(document.getElementById('targetValue').value);
// Add new goal with 0 progress
goals.push({
id: Date.now(),
rep, period, type, group, target, current: 0
});
document.getElementById('goalForm').reset();
renderGoals();
renderReports();
}
function clearGoals() {
if(confirm('Are you sure you want to clear all goals?')) {
goals = [];
renderGoals();
renderReports();
}
}
// --- REPORT LOGIC ---
function renderReports() {
const tbody = document.getElementById('reportTableBody');
tbody.innerHTML = '';
goals.forEach(goal => {
const variance = goal.current - goal.target;
const varianceText = (variance >= 0 ? '+' : '') + formatNumber(variance);
let statusClass = 'status-active';
let statusText = 'In Progress';
const pct = (goal.current / goal.target);
if (pct >= 1) {
statusClass = 'status-achieved';
statusText = 'Achieved';
} else if (pct < 0.5) {
statusClass = 'status-risk';
statusText = 'At Risk';
}
const row = `
<tr>
<td><strong>${goal.rep}</strong></td>
<td>${goal.group}</td>
<td>${goal.period}</td>
<td>${goal.type === 'Revenue' ? '$' : ''}${formatNumber(goal.target)}</td>
<td>${goal.type === 'Revenue' ? '$' : ''}${formatNumber(goal.current)}</td>
<td style="color: ${variance >= 0 ? 'green' : 'red'}">${varianceText}</td>
<td><span class="status-badge ${statusClass}">${statusText}</span></td>
</tr>
`;
tbody.innerHTML += row;
});
}
function exportReport() {
alert("This would download the table data as a CSV file.");
}
// --- CHARTS (CHART.JS) ---
function initCharts() {
const ctxRev = document.getElementById('revenueChart');
const ctxTrend = document.getElementById('trendChart');
if (!ctxRev || !ctxTrend) return;
// Destroy existing charts if they exist to prevent duplication/glitches
if (revenueChartInstance) revenueChartInstance.destroy();
if (trendChartInstance) trendChartInstance.destroy();
// 1. Bar Chart: Rep vs Target vs Actual
const reps = [...new Set(goals.map(g => g.rep))];
const targets = reps.map(r => {
const g = goals.find(x => x.rep === r && x.type === 'Revenue');
return g ? g.target : 0;
});
const actuals = reps.map(r => {
const g = goals.find(x => x.rep === r && x.type === 'Revenue');
return g ? g.current : 0;
});
revenueChartInstance = new Chart(ctxRev, {
type: 'bar',
data: {
labels: reps,
datasets: [
{
label: 'Target Revenue',
data: targets,
backgroundColor: '#e2e8f0',
borderRadius: 4
},
{
label: 'Actual Revenue',
data: actuals,
backgroundColor: '#4f46e5',
borderRadius: 4
}
]
},
options: {
responsive: true,
plugins: {
legend: { position: 'top' }
},
scales: {
y: { beginAtZero: true }
}
}
});
// 2. Line Chart: Mock Daily Trend
const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
const dataPoints = [1200, 1900, 3000, 5000, 2000, 3000, 4500];
trendChartInstance = new Chart(ctxTrend, {
type: 'line',
data: {
labels: days,
datasets: [{
label: 'Daily Sales ($)',
data: dataPoints,
borderColor: '#10b981',
backgroundColor: 'rgba(16, 185, 129, 0.1)',
fill: true,
tension: 0.4
}]
},
options: {
responsive: true,
plugins: {
legend: { display: false }
},
scales: {
y: { beginAtZero: true }
}
}
});
}
// --- UTILS ---
function formatNumber(num) {
return num.toLocaleString('en-US');
}
// --- INITIALIZATION ---
window.addEventListener('DOMContentLoaded', () => {
renderGoals();
renderReports();
// Check if starting tab is dashboard to init charts immediately
if(document.querySelector('.tab-content.active').id === 'tab-dashboard') {
initCharts();
}
});
</script>
</body>
</html>