// Real-time data simulation function simulateData() { return { production: Math.floor(Math.random() * 500) + 1000, inventory: Math.floor(Math.random() * 2000) + 4000, revenue: Math.floor(Math.random() * 30000) + 15000, dues: Math.floor(Math.random() * 10000) + 8000 }; } // Update dashboard stats in real-time function updateDashboardStats() { const data = simulateData(); document.querySelectorAll('[data-stat="production"]').forEach(el => el.textContent = data.production.toLocaleString()); document.querySelectorAll('[data-stat="inventory"]').forEach(el => el.textContent = data.inventory.toLocaleString()); document.querySelectorAll('[data-stat="revenue"]').forEach(el => `₹${data.revenue.toLocaleString()}`); document.querySelectorAll('[data-stat="dues"]').forEach(el => `₹${data.dues.toLocaleString()}`); } // Initialize app document.addEventListener('DOMContentLoaded', function() { // Start real-time updates setInterval(updateDashboardStats, 5000); updateDashboardStats(); console.log('BrickMaster Pro initialized'); // Check subscription status (mock function) function checkSubscription() { // In a real app, this would call your backend API const subscriptionStatus = 'active'; // 'trial', 'active', or 'inactive' const trialEndDate = '2024-03-15'; // Only relevant for trial status const planExpiryDate = '2024-12-31'; // Only relevant for active status if (subscriptionStatus === 'inactive') { showPaywall(); } } // Show paywall function function showPaywall() { const paywallHTML = `

Your Free Trial Has Ended

Please subscribe to continue managing your factory.

Monthly Plan

Billed monthly

₹999/month

Yearly Plan

Billed annually (save 17%)

₹9,999/year
`; document.body.insertAdjacentHTML('beforeend', paywallHTML); feather.replace(); document.getElementById('subscribeBtn').addEventListener('click', function() { // In a real app, this would initiate Razorpay checkout alert('Redirecting to payment gateway...'); }); } // Run subscription check checkSubscription(); // Toast notification function window.showToast = function(message, type = 'success') { const toast = document.createElement('div'); const colors = { success: 'bg-green-100 border-green-200 text-green-800', error: 'bg-red-100 border-red-200 text-red-800', warning: 'bg-yellow-100 border-yellow-200 text-yellow-800', info: 'bg-blue-100 border-blue-200 text-blue-800' }; toast.className = `fixed bottom-4 right-4 border rounded-lg px-4 py-2 shadow-lg ${colors[type]} z-50`; toast.textContent = message; document.body.appendChild(toast); setTimeout(() => { toast.classList.add('opacity-0', 'transition-opacity', 'duration-300'); setTimeout(() => toast.remove(), 300); }, 3000); }; });