tgb
This commit is contained in:
parent
00a5c5a638
commit
b20a76b7ff
31
api/leads.php
Normal file
31
api/leads.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require_once __DIR__ . '/../db/config.php';
|
||||
require_once __DIR__ . '/../mail/MailService.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
echo json_encode(['success' => false, 'error' => 'Invalid request method']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$name = trim($_POST['name'] ?? '');
|
||||
$email = trim($_POST['email'] ?? '');
|
||||
$message = trim($_POST['message'] ?? '');
|
||||
|
||||
if (empty($name) || empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
echo json_encode(['success' => false, 'error' => 'Please provide a valid name and email address.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$stmt = db()->prepare("INSERT INTO leads (name, email, message) VALUES (?, ?, ?)");
|
||||
$stmt->execute([$name, $email, $message]);
|
||||
|
||||
// Optional: Send email notification
|
||||
// MailService::sendContactMessage($name, $email, $message);
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Thank you! We will get back to you shortly.']);
|
||||
} catch (Exception $e) {
|
||||
error_log($e->getMessage());
|
||||
echo json_encode(['success' => false, 'error' => 'Something went wrong. Please try again later.']);
|
||||
}
|
||||
@ -1,118 +1,120 @@
|
||||
/* Inter font from Google Fonts */
|
||||
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
|
||||
:root {
|
||||
--primary-color: #8A2BE2; /* Electric Purple */
|
||||
--secondary-color: #1A1A1A; /* Deep Charcoal */
|
||||
--accent-color: #FF3E00; /* Vibrant Orange/Red */
|
||||
--bg-color: #0F0F0F;
|
||||
--text-color: #FFFFFF;
|
||||
--text-muted: #A0A0A0;
|
||||
--card-bg: #1A1A1A;
|
||||
--border-color: #333333;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
background-color: #F8F9FA;
|
||||
color: #212529;
|
||||
background-color: var(--bg-color);
|
||||
color: var(--text-color);
|
||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.text-primary { color: var(--primary-color) !important; }
|
||||
.bg-primary { background-color: var(--primary-color) !important; }
|
||||
|
||||
.btn-primary {
|
||||
background-color: var(--primary-color);
|
||||
border: none;
|
||||
padding: 12px 24px;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s ease;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background-color: #7A1BD2;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 15px rgba(138, 43, 226, 0.4);
|
||||
}
|
||||
|
||||
.navbar {
|
||||
background-color: rgba(15, 15, 15, 0.9) !important;
|
||||
backdrop-filter: blur(10px);
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.hero-section {
|
||||
padding: 120px 0;
|
||||
background: radial-gradient(circle at 50% 50%, rgba(138, 43, 226, 0.1) 0%, rgba(15, 15, 15, 1) 70%);
|
||||
}
|
||||
|
||||
.section-padding {
|
||||
padding: 100px 0;
|
||||
}
|
||||
|
||||
.card {
|
||||
border-radius: 0.25rem;
|
||||
border: 1px solid #DEE2E6;
|
||||
background-color: var(--card-bg);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 4px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.table {
|
||||
border: 1px solid #DEE2E6;
|
||||
.card:hover {
|
||||
border-color: var(--primary-color);
|
||||
}
|
||||
|
||||
.badge-ai {
|
||||
background-color: #007BFF;
|
||||
.service-card {
|
||||
padding: 40px;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.service-icon {
|
||||
font-size: 2.5rem;
|
||||
margin-bottom: 20px;
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
.form-control {
|
||||
background-color: #222;
|
||||
border: 1px solid var(--border-color);
|
||||
color: #fff;
|
||||
padding: 12px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.form-control:focus {
|
||||
background-color: #2a2a2a;
|
||||
border-color: var(--primary-color);
|
||||
color: #fff;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.footer {
|
||||
border-top: 1px solid var(--border-color);
|
||||
padding: 60px 0;
|
||||
background-color: #0A0A0A;
|
||||
}
|
||||
|
||||
.badge-vibrant {
|
||||
background-color: var(--accent-color);
|
||||
color: white;
|
||||
font-size: 0.8rem;
|
||||
padding: 5px 12px;
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
/* Toast styling */
|
||||
.toast-container {
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
z-index: 1050;
|
||||
}
|
||||
|
||||
.toast {
|
||||
background-color: var(--card-bg);
|
||||
border: 1px solid var(--primary-color);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.badge-human {
|
||||
background-color: #6C757D;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#chat-container {
|
||||
height: 70vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
#chat-box {
|
||||
flex-grow: 1;
|
||||
overflow-y: auto;
|
||||
padding: 1rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.message {
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 1rem;
|
||||
max-width: 80%;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.user-message {
|
||||
background-color: #007BFF;
|
||||
color: white;
|
||||
align-self: flex-end;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
|
||||
.bot-message {
|
||||
background-color: #E9ECEF;
|
||||
color: #212529;
|
||||
align-self: flex-start;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
|
||||
.bot-message.typing-indicator {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.dot-flashing {
|
||||
position: relative;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 5px;
|
||||
background-color: #6C757D;
|
||||
color: #6C757D;
|
||||
animation: dotFlashing 1s infinite linear alternate;
|
||||
animation-delay: .5s;
|
||||
}
|
||||
|
||||
.dot-flashing::before, .dot-flashing::after {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.dot-flashing::before {
|
||||
left: -10px;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 5px;
|
||||
background-color: #6C757D;
|
||||
color: #6C757D;
|
||||
animation: dotFlashing 1s infinite alternate;
|
||||
animation-delay: 0s;
|
||||
}
|
||||
|
||||
.dot-flashing::after {
|
||||
left: 10px;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 5px;
|
||||
background-color: #6C757D;
|
||||
color: #6C757D;
|
||||
animation: dotFlashing 1s infinite alternate;
|
||||
animation-delay: 1s;
|
||||
}
|
||||
|
||||
@keyframes dotFlashing {
|
||||
0% {
|
||||
background-color: #6C757D;
|
||||
}
|
||||
50%, 100% {
|
||||
background-color: #E9ECEF;
|
||||
}
|
||||
}
|
||||
@ -1,276 +1,66 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const chatForm = document.getElementById('chat-form');
|
||||
const chatInput = document.getElementById('chat-input');
|
||||
const chatBox = document.getElementById('chat-box');
|
||||
const activityLogBody = document.getElementById('activity-log-body');
|
||||
const logCount = document.getElementById('log-count');
|
||||
const emptyLogRew = document.getElementById('empty-log-row');
|
||||
const manualLogForm = document.getElementById('manual-log-form');
|
||||
const clockElement = document.getElementById('clock');
|
||||
const pastTimesheetsTab = document.getElementById('past-timesheets-tab');
|
||||
const pastTimesheetsContainer = document.getElementById('past-timesheets');
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const contactForm = document.getElementById('contactForm');
|
||||
const toastContainer = document.getElementById('toast-container');
|
||||
|
||||
function updateClock() {
|
||||
if (clockElement) {
|
||||
const now = new Date();
|
||||
const time = now.toLocaleTimeString();
|
||||
const month = String(now.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(now.getDate()).padStart(2, '0');
|
||||
const year = now.getFullYear();
|
||||
const date = `${month}-${day}-${year}`;
|
||||
clockElement.textContent = `${time} ${date}`;
|
||||
}
|
||||
}
|
||||
if (contactForm) {
|
||||
contactForm.addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
updateClock();
|
||||
setInterval(updateClock, 1000);
|
||||
const submitBtn = contactForm.querySelector('button[type="submit"]');
|
||||
const originalBtnText = submitBtn.innerHTML;
|
||||
submitBtn.disabled = true;
|
||||
submitBtn.innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Sending...';
|
||||
|
||||
if (pastTimesheetsTab) {
|
||||
pastTimesheetsTab.addEventListener('shown.bs.tab', () => {
|
||||
loadPastTimesheets();
|
||||
const formData = new FormData(contactForm);
|
||||
|
||||
fetch('api/leads.php', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
showToast(data.message, 'success');
|
||||
contactForm.reset();
|
||||
} else {
|
||||
showToast(data.error || 'Something went wrong.', 'danger');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
showToast('An error occurred. Please try again.', 'danger');
|
||||
})
|
||||
.finally(() => {
|
||||
submitBtn.disabled = false;
|
||||
submitBtn.innerHTML = originalBtnText;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function loadPastTimesheets() {
|
||||
pastTimesheetsContainer.innerHTML = '<div class="text-center"><div class="spinner-border" role="status"><span class="visually-hidden">Loading...</span></div></div>';
|
||||
|
||||
try {
|
||||
const response = await fetch('api/chat.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ action: 'get_past_timesheets' })
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
pastTimesheetsContainer.innerHTML = '<p class="text-center text-danger">Failed to load past timesheets.</p>';
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.error) {
|
||||
pastTimesheetsContainer.innerHTML = `<p class="text-center text-danger">${data.error}</p>`;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.past_timesheets || data.past_timesheets.length === 0) {
|
||||
pastTimesheetsContainer.innerHTML = '<div class="card"><div class="card-body text-center text-muted">No past timesheets found.</div></div>';
|
||||
return;
|
||||
}
|
||||
|
||||
const accordion = document.createElement('div');
|
||||
accordion.className = 'accordion';
|
||||
accordion.id = 'past-timesheets-accordion';
|
||||
|
||||
data.past_timesheets.forEach((sheet, index) => {
|
||||
const activities = JSON.parse(sheet.activities);
|
||||
const item = document.createElement('div');
|
||||
item.className = 'accordion-item';
|
||||
|
||||
const header = document.createElement('h2');
|
||||
header.className = 'accordion-header';
|
||||
header.innerHTML = `
|
||||
<button class="accordion-button ${index === 0 ? '' : 'collapsed'}" type="button" data-bs-toggle="collapse" data-bs-target="#collapse-${index}" aria-expanded="${index === 0}" aria-controls="collapse-${index}">
|
||||
${sheet.timesheet_date}
|
||||
</button>
|
||||
`;
|
||||
|
||||
const collapse = document.createElement('div');
|
||||
collapse.id = `collapse-${index}`;
|
||||
collapse.className = `accordion-collapse collapse ${index === 0 ? 'show' : ''}`;
|
||||
collapse.setAttribute('data-bs-parent', '#past-timesheets-accordion');
|
||||
|
||||
const body = document.createElement('div');
|
||||
body.className = 'accordion-body';
|
||||
|
||||
let tableHtml = `
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Timestamp</th>
|
||||
<th>Task</th>
|
||||
<th>Project</th>
|
||||
<th class="text-center">Output</th>
|
||||
<th class="text-end">Duration</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
`;
|
||||
|
||||
activities.forEach(activity => {
|
||||
const badgeClass = activity.output_type === 'AI' ? 'badge-ai' : 'badge-human';
|
||||
tableHtml += `
|
||||
<tr>
|
||||
<td>${activity.timestamp}</td>
|
||||
<td>${escapeHTML(activity.task)}</td>
|
||||
<td>${escapeHTML(activity.project)}</td>
|
||||
<td class="text-center"><span class="badge rounded-pill ${badgeClass}">${escapeHTML(activity.output_type)}</span></td>
|
||||
<td class="text-end">${escapeHTML(activity.duration)}</td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
|
||||
tableHtml += '</tbody></table></div>';
|
||||
body.innerHTML = tableHtml;
|
||||
|
||||
collapse.appendChild(body);
|
||||
item.appendChild(header);
|
||||
item.appendChild(collapse);
|
||||
accordion.appendChild(item);
|
||||
});
|
||||
|
||||
pastTimesheetsContainer.innerHTML = '';
|
||||
pastTimesheetsContainer.appendChild(accordion);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading past timesheets:', error);
|
||||
pastTimesheetsContainer.innerHTML = '<p class="text-center text-danger">An error occurred while fetching data.</p>';
|
||||
}
|
||||
}
|
||||
|
||||
chatForm.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const userMessage = chatInput.value.trim();
|
||||
if (!userMessage) return;
|
||||
|
||||
appendMessage(userMessage, 'user');
|
||||
chatInput.value = '';
|
||||
showTypingIndicator();
|
||||
|
||||
try {
|
||||
const response = await fetch('api/chat.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ message: userMessage })
|
||||
});
|
||||
|
||||
removeTypingIndicator();
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json();
|
||||
const errorMsg = errorData.error || 'An unknown error occurred.';
|
||||
appendMessage(`Error: ${errorMsg}`, 'bot');
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.error) {
|
||||
appendMessage(`Error: ${data.error}`, 'bot');
|
||||
return;
|
||||
}
|
||||
|
||||
appendMessage(data.reply, 'bot');
|
||||
|
||||
if (data.new_log_entry) {
|
||||
updateActivityLog(data.new_log_entry);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
removeTypingIndicator();
|
||||
appendMessage('Could not connect to the server. Please try again later.', 'bot');
|
||||
console.error("Fetch Error:", error);
|
||||
}
|
||||
});
|
||||
|
||||
manualLogForm.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const actionType = document.getElementById('action-type').value;
|
||||
const project = document.getElementById('manual-project').value.trim();
|
||||
const task = document.getElementById('manual-task').value.trim();
|
||||
|
||||
if (!project || !task) {
|
||||
// You might want to show an error to the user
|
||||
return;
|
||||
}
|
||||
|
||||
const payload = {
|
||||
action: 'manual_log',
|
||||
type: actionType,
|
||||
project: project,
|
||||
task: task
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await fetch('api/chat.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
console.error('Manual log submission failed');
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.new_log_entry) {
|
||||
updateActivityLog(data.new_log_entry);
|
||||
manualLogForm.reset();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Fetch Error:", error);
|
||||
}
|
||||
});
|
||||
|
||||
function appendMessage(message, sender) {
|
||||
const messageElement = document.createElement('div');
|
||||
messageElement.classList.add('message', `${sender}-message`);
|
||||
messageElement.textContent = message;
|
||||
chatBox.appendChild(messageElement);
|
||||
chatBox.scrollTop = chatBox.scrollHeight;
|
||||
}
|
||||
|
||||
function showTypingIndicator() {
|
||||
const typingIndicator = document.createElement('div');
|
||||
typingIndicator.classList.add('message', 'bot-message', 'typing-indicator');
|
||||
typingIndicator.innerHTML = '<div class="dot-flashing"></div>';
|
||||
typingIndicator.id = 'typing-indicator';
|
||||
chatBox.appendChild(typingIndicator);
|
||||
chatBox.scrollTop = chatBox.scrollHeight;
|
||||
}
|
||||
|
||||
function removeTypingIndicator() {
|
||||
const typingIndicator = document.getElementById('typing-indicator');
|
||||
if (typingIndicator) {
|
||||
typingIndicator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
function updateActivityLog(logEntry) {
|
||||
if(emptyLogRew) {
|
||||
emptyLogRew.remove();
|
||||
}
|
||||
|
||||
const newRow = document.createElement('tr');
|
||||
const badgeClass = logEntry.output_type === 'AI' ? 'badge-ai' : 'badge-human';
|
||||
newRow.innerHTML = `
|
||||
<td>${logEntry.timestamp}</td>
|
||||
<td>${escapeHTML(logEntry.task)}</td>
|
||||
<td>${escapeHTML(logEntry.project)}</td>
|
||||
<td class="text-center">
|
||||
<span class="badge rounded-pill ${badgeClass}">
|
||||
${escapeHTML(logEntry.output_type)}
|
||||
</span>
|
||||
</td>
|
||||
<td class="text-end">${escapeHTML(logEntry.duration)}</td>
|
||||
function showToast(message, type) {
|
||||
const toastId = 'toast-' + Date.now();
|
||||
const toastHTML = `
|
||||
<div id="${toastId}" class="toast show" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="toast-header bg-dark text-white border-bottom border-secondary">
|
||||
<strong class="me-auto">${type === 'success' ? 'Success' : 'Error'}</strong>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="toast-body">
|
||||
${message}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
activityLogBody.prepend(newRow);
|
||||
logCount.textContent = parseInt(logCount.textContent) + 1;
|
||||
}
|
||||
|
||||
function escapeHTML(str) {
|
||||
if (typeof str !== 'string') return '';
|
||||
const p = document.createElement('p');
|
||||
p.appendChild(document.createTextNode(str));
|
||||
return p.innerHTML;
|
||||
const toastElement = document.createElement('div');
|
||||
toastElement.innerHTML = toastHTML;
|
||||
toastContainer.appendChild(toastElement);
|
||||
|
||||
setTimeout(() => {
|
||||
const toast = document.getElementById(toastId);
|
||||
if (toast) {
|
||||
toast.classList.remove('show');
|
||||
setTimeout(() => toast.remove(), 500);
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
});
|
||||
7
db/migrations/001_create_leads.sql
Normal file
7
db/migrations/001_create_leads.sql
Normal file
@ -0,0 +1,7 @@
|
||||
CREATE TABLE IF NOT EXISTS leads (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
email VARCHAR(255) NOT NULL,
|
||||
message TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
418
index.php
418
index.php
@ -1,234 +1,224 @@
|
||||
<?php
|
||||
require_once 'db/config.php';
|
||||
|
||||
// Handle form submission
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$task = $_POST['task'] ?? '';
|
||||
$project = $_POST['project'] ?? '';
|
||||
$output_type = $_POST['output_type'] ?? '';
|
||||
$duration = $_POST['duration'] ?? '';
|
||||
|
||||
if ($task && $project && $output_type && $duration) {
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("INSERT INTO activity_log (task, project, output_type, duration) VALUES (?, ?, ?, ?)");
|
||||
$stmt->execute([$task, $project, $output_type, $duration]);
|
||||
header("Location: " . $_SERVER['PHP_SELF']);
|
||||
exit;
|
||||
} catch (PDOException $e) {
|
||||
error_log("DB Error: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
$pdo = db();
|
||||
|
||||
// Seed data if the table is empty
|
||||
$stmt = $pdo->query("SELECT COUNT(*) FROM activity_log");
|
||||
if ($stmt->fetchColumn() == 0) {
|
||||
$seed_data = [
|
||||
['task' => 'Analyzed quarterly sales report for new market trends.', 'output_type' => 'AI', 'duration' => '00:02:35', 'project' => 'Q1 Sales Analysis'],
|
||||
['task' => 'Verified data extraction accuracy from scanned invoices.', 'output_type' => 'Human', 'duration' => '00:05:10', 'project' => 'Invoice Processing'],
|
||||
['task' => 'Generated Python script for automating data cleanup.', 'output_type' => 'AI', 'duration' => '00:03:50', 'project' => 'Data Migration Tool'],
|
||||
];
|
||||
|
||||
$stmt = $pdo->prepare("INSERT INTO activity_log (task, output_type, duration, project) VALUES (?, ?, ?, ?)");
|
||||
foreach ($seed_data as $row) {
|
||||
$stmt->execute([$row['task'], $row['output_type'], $row['duration'], $row['project']]);
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch data for the log
|
||||
$log_stmt = $pdo->query("SELECT *, DATE_FORMAT(created_at, '%Y-%m-%d %H:%i:%s') as timestamp FROM activity_log ORDER BY created_at DESC");
|
||||
$log_data = $log_stmt->fetchAll();
|
||||
|
||||
} catch (PDOException $e) {
|
||||
die("DB ERROR: " . $e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
// Calculate AI vs Human contribution
|
||||
$total_duration_ai = 0;
|
||||
$total_duration_human = 0;
|
||||
|
||||
foreach ($log_data as $log) {
|
||||
list($h, $m, $s) = explode(':', $log['duration']);
|
||||
$duration_in_seconds = $h * 3600 + $m * 60 + $s;
|
||||
if ($log['output_type'] === 'AI') {
|
||||
$total_duration_ai += $duration_in_seconds;
|
||||
} else {
|
||||
$total_duration_human += $duration_in_seconds;
|
||||
}
|
||||
}
|
||||
|
||||
$total_duration = $total_duration_ai + $total_duration_human;
|
||||
$ai_percentage = $total_duration > 0 ? round(($total_duration_ai / $total_duration) * 100) : 0;
|
||||
$human_percentage = $total_duration > 0 ? round(($total_duration_human / $total_duration) * 100) : 0;
|
||||
|
||||
$projectName = $_SERVER['PROJECT_NAME'] ?? 'VibeSocial Agency';
|
||||
$projectDesc = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Modern Social Media Marketing for high-growth startups and SMBs.';
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><?php echo htmlspecialchars($_SERVER['PROJECT_NAME'] ?? 'AI Agent Digital Labor'); ?></title>
|
||||
<title><?php echo htmlspecialchars($projectName); ?> | Premium SMM Agency</title>
|
||||
<meta name="description" content="<?php echo htmlspecialchars($projectDesc); ?>">
|
||||
|
||||
<!-- Bootstrap 5 CSS -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- Google Fonts - Inter -->
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap" rel="stylesheet">
|
||||
<!-- Custom CSS -->
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container my-5">
|
||||
<header class="mb-5 text-center">
|
||||
<h1 class="display-5 fw-bold"><?php echo htmlspecialchars($_SERVER['PROJECT_NAME'] ?? 'AI Agent Digital Labor'); ?></h1>
|
||||
<p class="lead text-secondary"><?php echo htmlspecialchars($_SERVER['PROJECT_DESCRIPTION'] ?? 'A real-time demonstration of an AI Agent for enterprise automation.'); ?></p>
|
||||
<div id="clock" class="fs-4 text-muted"></div>
|
||||
</header>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="card" id="chat-container">
|
||||
<div class="card-header">
|
||||
AI Agent Chat
|
||||
</div>
|
||||
<div class="card-body" id="chat-box">
|
||||
<div class="message bot-message">
|
||||
Hello! How can I help you today?
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<form id="chat-form">
|
||||
<div class="input-group">
|
||||
<input type="text" id="chat-input" class="form-control" placeholder="Type your message..." autocomplete="off">
|
||||
<button class="btn btn-primary" type="submit" id="chat-submit">Send</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
<div class="card mb-4" id="manual-log-container">
|
||||
<div class="card-header">
|
||||
Log Human Action
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form id="manual-log-form">
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="action-type" class="form-label">Action Type</label>
|
||||
<select id="action-type" class="form-select">
|
||||
<option>Opened App</option>
|
||||
<option>Browsed URL</option>
|
||||
<option>Typing</option>
|
||||
<option>Cursor Control</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="manual-project" class="form-label">Project</label>
|
||||
<input type="text" id="manual-project" class="form-control" placeholder="E.g., Q2 Marketing">
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="manual-task" class="form-label">Task Description</label>
|
||||
<textarea id="manual-task" class="form-control" rows="2" placeholder="Describe the action taken..."></textarea>
|
||||
</div>
|
||||
<button class="btn btn-secondary w-100" type="submit" id="manual-log-submit">Log Action</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<main>
|
||||
<div class="row justify-content-center mb-4">
|
||||
<div class="col-lg-8">
|
||||
<div class="card text-center">
|
||||
<div class="card-header">
|
||||
Today's Contribution
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h3 class="fw-bold text-primary"><?php echo $ai_percentage; ?>%</h3>
|
||||
<p class="text-secondary mb-0">AI Contribution</p>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h3 class="fw-bold text-secondary"><?php echo $human_percentage; ?>%</h3>
|
||||
<p class="text-secondary mb-0">Human Contribution</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul class="nav nav-tabs" id="timesheetTabs" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link active" id="live-activity-tab" data-bs-toggle="tab" data-bs-target="#live-activity" type="button" role="tab" aria-controls="live-activity" aria-selected="true">Live Activity</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="past-timesheets-tab" data-bs-toggle="tab" data-bs-target="#past-timesheets" type="button" role="tab" aria-controls="past-timesheets" aria-selected="false">Past Daily Timesheets</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content" id="timesheetTabsContent">
|
||||
<div class="tab-pane fade show active" id="live-activity" role="tabpanel" aria-labelledby="live-activity-tab">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Live Activity Log
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th scope="col">Timestamp</th>
|
||||
<th scope="col">Task</th>
|
||||
<th scope="col">Project</th>
|
||||
<th scope="col" class="text-center">Output Type</th>
|
||||
<th scope="col" class="text-end">Duration</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="activity-log-body">
|
||||
<?php foreach ($log_data as $log): ?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($log['timestamp']); ?></td>
|
||||
<td><?php echo htmlspecialchars($log['task']); ?></td>
|
||||
<td><?php echo htmlspecialchars($log['project']); ?></td>
|
||||
<td class="text-center">
|
||||
<span class="badge rounded-pill <?php echo $log['output_type'] === 'AI' ? 'badge-ai' : 'badge-human'; ?>">
|
||||
<?php echo htmlspecialchars($log['output_type']); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td class="text-end"><?php echo htmlspecialchars($log['duration']); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php if (empty($log_data)): ?>
|
||||
<tr id="empty-log-row">
|
||||
<td colspan="5" class="text-center text-muted">No activity logged yet.</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card-footer text-muted">
|
||||
Showing <span id="log-count"><?php echo count($log_data); ?></span> most recent events.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="past-timesheets" role="tabpanel" aria-labelledby="past-timesheets-tab">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Past Daily Timesheets
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p class="text-center text-muted">Past timesheets will be shown here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<!-- Navigation -->
|
||||
<nav class="navbar navbar-expand-lg navbar-dark sticky-top">
|
||||
<div class="container">
|
||||
<a class="navbar-brand fw-bold fs-4" href="#"><?php echo htmlspecialchars($projectName); ?></a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item"><a class="nav-link" href="#services">Services</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="#portfolio">Portfolio</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="#pricing">Pricing</a></li>
|
||||
<li class="nav-item"><a class="nav-link btn btn-primary ms-lg-3 text-white" href="#contact">Book a Call</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- Hero Section -->
|
||||
<section class="hero-section text-center">
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-10">
|
||||
<span class="badge badge-vibrant mb-3">#1 Rated SMM Agency 2026</span>
|
||||
<h1 class="display-3 fw-bold mb-4">We Scale Your Brand via <span class="text-primary">Social Excellence.</span></h1>
|
||||
<p class="lead text-muted mb-5 fs-4"><?php echo htmlspecialchars($projectDesc); ?></p>
|
||||
<div class="d-flex justify-content-center gap-3">
|
||||
<a href="#contact" class="btn btn-primary btn-lg">Start Growing Now</a>
|
||||
<a href="#services" class="btn btn-outline-light btn-lg">Our Services</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Services Section -->
|
||||
<section id="services" class="section-padding">
|
||||
<div class="container">
|
||||
<div class="text-center mb-5">
|
||||
<h2 class="display-5 fw-bold">Our Core Expertise</h2>
|
||||
<p class="text-muted">Tailored strategies to dominate every platform.</p>
|
||||
</div>
|
||||
<div class="row g-4">
|
||||
<div class="col-md-4">
|
||||
<div class="card service-card">
|
||||
<div class="service-icon">✦</div>
|
||||
<h3>Content Strategy</h3>
|
||||
<p class="text-muted">High-converting viral content designed to capture attention and drive engagement across TikTok, Reels, and YouTube.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card service-card">
|
||||
<div class="service-icon">⚡</div>
|
||||
<h3>Paid Acquisition</h3>
|
||||
<p class="text-muted">Data-driven Meta and TikTok ad campaigns focused on ROI and scalable customer acquisition for your business.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card service-card">
|
||||
<div class="service-icon">✺</div>
|
||||
<h3>Community Management</h3>
|
||||
<p class="text-muted">Building loyal fanbases and handling 24/7 engagement to turn followers into lifelong brand advocates.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Portfolio Stub -->
|
||||
<section id="portfolio" class="section-padding bg-dark">
|
||||
<div class="container">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-lg-6">
|
||||
<h2 class="display-5 fw-bold mb-4">Real Results for <span class="text-primary">Real Brands.</span></h2>
|
||||
<p class="text-muted mb-4">We don't just post; we perform. Our clients see an average of 300% growth in organic reach within the first 90 days.</p>
|
||||
<ul class="list-unstyled text-muted mb-5">
|
||||
<li class="mb-2">✓ 50M+ Organic Impressions Generated</li>
|
||||
<li class="mb-2">✓ $10M+ Managed Ad Spend</li>
|
||||
<li class="mb-2">✓ 500+ Viral Videos Produced</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="row g-3">
|
||||
<div class="col-6">
|
||||
<div class="card h-100 p-4 text-center">
|
||||
<h4 class="text-primary fw-bold">12.5%</h4>
|
||||
<small class="text-muted">Avg. CTR</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="card h-100 p-4 text-center">
|
||||
<h4 class="text-primary fw-bold">2.4M</h4>
|
||||
<small class="text-muted">Followers Gained</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<div class="card h-100 p-4 text-center">
|
||||
<h4 class="text-primary fw-bold">4.8x</h4>
|
||||
<small class="text-muted">Average ROAS</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Pricing Section -->
|
||||
<section id="pricing" class="section-padding">
|
||||
<div class="container">
|
||||
<div class="text-center mb-5">
|
||||
<h2 class="display-5 fw-bold">Simple, Transparent Pricing</h2>
|
||||
<p class="text-muted">No hidden fees. Just growth.</p>
|
||||
</div>
|
||||
<div class="row g-4 justify-content-center">
|
||||
<div class="col-md-4">
|
||||
<div class="card p-5 h-100">
|
||||
<h3 class="fs-5">Growth</h3>
|
||||
<div class="display-6 fw-bold my-3">$1,999<span class="fs-6 text-muted">/mo</span></div>
|
||||
<p class="text-muted small">Perfect for startups.</p>
|
||||
<hr class="border-secondary">
|
||||
<ul class="list-unstyled mb-5">
|
||||
<li>• 3 Platforms Managed</li>
|
||||
<li>• 12 Original Videos/mo</li>
|
||||
<li>• Basic Paid Ad Setup</li>
|
||||
<li>• Monthly Reporting</li>
|
||||
</ul>
|
||||
<a href="#contact" class="btn btn-outline-light mt-auto">Choose Plan</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card p-5 h-100 border-primary">
|
||||
<div class="badge bg-primary mb-2">Most Popular</div>
|
||||
<h3 class="fs-5">Scale</h3>
|
||||
<div class="display-6 fw-bold my-3">$3,999<span class="fs-6 text-muted">/mo</span></div>
|
||||
<p class="text-muted small">For established brands.</p>
|
||||
<hr class="border-secondary">
|
||||
<ul class="list-unstyled mb-5">
|
||||
<li>• 5 Platforms Managed</li>
|
||||
<li>• 25 Original Videos/mo</li>
|
||||
<li>• Advanced Paid Ads + Retargeting</li>
|
||||
<li>• 24/7 Community Support</li>
|
||||
</ul>
|
||||
<a href="#contact" class="btn btn-primary mt-auto">Choose Plan</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Contact Section -->
|
||||
<section id="contact" class="section-padding bg-dark">
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-8 text-center mb-5">
|
||||
<h2 class="display-5 fw-bold">Ready to Dominate?</h2>
|
||||
<p class="text-muted">Fill out the form below and our strategy team will be in touch within 24 hours.</p>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="card p-4 p-md-5">
|
||||
<form id="contactForm">
|
||||
<div class="mb-4">
|
||||
<label for="name" class="form-label">Full Name</label>
|
||||
<input type="text" class="form-control" id="name" name="name" placeholder="John Doe" required>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label for="email" class="form-label">Work Email</label>
|
||||
<input type="email" class="form-control" id="email" name="email" placeholder="john@company.com" required>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label for="message" class="form-label">How can we help?</label>
|
||||
<textarea class="form-control" id="message" name="message" rows="4" placeholder="Tell us about your project goals..."></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary w-100 btn-lg">Send Message</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Footer -->
|
||||
<footer class="footer text-center">
|
||||
<div class="container">
|
||||
<h3 class="fw-bold mb-4"><?php echo htmlspecialchars($projectName); ?></h3>
|
||||
<div class="d-flex justify-content-center gap-4 mb-4">
|
||||
<a href="#" class="text-muted text-decoration-none">Twitter</a>
|
||||
<a href="#" class="text-muted text-decoration-none">Instagram</a>
|
||||
<a href="#" class="text-muted text-decoration-none">LinkedIn</a>
|
||||
</div>
|
||||
<p class="text-muted small">© <?php echo date('Y'); ?> <?php echo htmlspecialchars($projectName); ?>. All rights reserved.</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- Toast Container -->
|
||||
<div id="toast-container" class="toast-container"></div>
|
||||
|
||||
<!-- Scripts -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||
</body>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user