{"id":103,"date":"2025-07-09T11:48:34","date_gmt":"2025-07-09T11:48:34","guid":{"rendered":"https:\/\/invest.alphabusiness.media\/?page_id=103"},"modified":"2025-07-09T13:56:03","modified_gmt":"2025-07-09T13:56:03","slug":"admin-dashboard","status":"publish","type":"page","link":"https:\/\/invest.alphabusiness.media\/index.php\/admin-dashboard\/","title":{"rendered":"Admin Dashboard"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"103\" class=\"elementor elementor-103\" data-elementor-post-type=\"page\">\n\t\t\t\t<div class=\"elementor-element elementor-element-f9d2607 e-flex e-con-boxed e-con e-parent\" data-id=\"f9d2607\" data-element_type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-8404909 elementor-widget elementor-widget-shortcode\" data-id=\"8404909\" data-element_type=\"widget\" data-widget_type=\"shortcode.default\">\n\t\t\t\t\t\t\t<div class=\"elementor-shortcode\"><!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>Admin Panel<\/title>\n    <!-- Tailwind CSS -->\n    <script src=\"https:\/\/cdn.tailwindcss.com\"><\/script>\n    <style>\n        \/* Custom Styles matching Investor Dashboard *\/\n        @import url('https:\/\/fonts.googleapis.com\/css2?family=Open+Sans:wght@400;600;700;900&display=swap');\n        body {\n          \n            font-family: 'Open Sans', sans-serif;\n        }\n        \n        .main-title {\n            font-size: 3.25rem;\n            line-height: 1.1em;\n            font-weight: 700;\n            color: #191B1D; \/* Adjusted for dark theme *\/\n        }\n        .subtitle {\n            margin-top: 0.9rem;\n            color: #191B1D; \/* Adjusted for dark theme *\/\n        }\n        .btn-outline {\n            background-color: #33629a;\n            border: 1px solid #88888826;\n            color: #fff;\n            transition: all 0.3s ease;\n            font-weight: 700;\n            border-radius: 8px;\n            padding: 0.75rem 1.5rem;\n        }\n        .btn-outline:hover {\n            background-color: #374151;\n            color: #ffffff;\n        }\n        .btn-danger {\n            background-color: transparent;\n            border: 1px solid #ef4444;\n            color: #ef4444;\n        }\n        .btn-danger:hover {\n             background-color: #ef4444;\n             color: #ffffff;\n        }\n        .info-card {\n            border: 1px solid #88888826;\n            border-radius: 8px;\n        }\n        .admin-input {\n            background-color: transparent;\n            color: #191B1D;\n            border: 1px solid #88888826;\n            border-radius: 8px;\n        }\n        .admin-textarea-light {\n             background-color: #ffffff;\n             color: #191B1D;\n             border-radius: 8px;\n        }\n        .hidden {\n            display: none;\n        }\n    <\/style>\n<\/head>\n<body class=\"text-white\">\n\n    <div id=\"app\" class=\"container mx-auto px-1.5 py-6\">\n        \n        <header class=\"text-left mb-10\">\n            <h1 class=\"main-title\">Project Admin Panel<\/h1>\n            <p class=\"subtitle\">Manage investors, token price, and project updates.<\/p>\n        <\/header>\n\n        <!-- #################### ADMIN LOGIN FLOW #################### -->\n        <div id=\"admin-login-flow\">\n            <div id=\"admin-connect-section\" class=\"text-center py-10\">\n                <button id=\"admin-connect-button\" class=\"btn-outline text-xl\">Connect Admin Wallet<\/button>\n            <\/div>\n\n            <div id=\"admin-password-section\" class=\"hidden max-w-sm mx-auto\">\n                 <h2 class=\"text-2xl font-bold mb-4 text-center\">Enter Password<\/h2>\n                <input type=\"password\" id=\"admin-password\" placeholder=\"Enter password\" class=\"w-full p-3 bg-gray-700 rounded-md border border-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-500 mb-4\">\n                <button id=\"login-submit-button\" class=\"btn-outline w-full py-3\">Login<\/button>\n            <\/div>\n        <\/div>\n\n        <!-- #################### ADMIN PANEL #################### -->\n        <div id=\"admin-panel\" class=\"hidden info-card p-6 space-y-8\">\n            <div class=\"flex justify-between items-center\">\n                <h2 class=\"text-3xl font-bold\">Management Console<\/h2>\n                <a href=\"#\" id=\"admin-logout-button\" class=\"text-sm text-red-400 hover:underline\">Logout<\/a>\n            <\/div>\n            \n            <!-- ADD\/EDIT FORMS -->\n            <div class=\"space-y-4\">\n                <h3 class=\"text-2xl font-bold border-b border-gray-700 pb-2\">Entry Forms<\/h3>\n                <div class=\"grid md:grid-cols-2 lg:grid-cols-3 gap-2.5\">\n                    <div class=\"info-card p-4\">\n                        <label for=\"new-price\" class=\"block mb-2 font-semibold\">Token Price (USD)<\/label>\n                        <input type=\"number\" id=\"new-price\" step=\"0.0001\" class=\"w-full p-3 admin-input\">\n                        <button id=\"update-price-button\" class=\"mt-3 w-full btn-outline font-bold py-2\">Update Price<\/button>\n                    <\/div>\n                    <div class=\"info-card p-4\">\n                        <h3 class=\"font-semibold mb-2\">Add Investment \/ Dividend<\/h3>\n                        <select id=\"entry-investor-select\" class=\"w-full p-3 admin-input mb-2\"><\/select>\n                        <select id=\"entry-type-select\" class=\"w-full p-3 admin-input mb-2\">\n                            <option value=\"investment\">Investment<\/option>\n                            <option value=\"dividend\">Dividend<\/option>\n                        <\/select>\n                        <input type=\"date\" id=\"entry-date\" class=\"w-full p-3 admin-input mb-2\">\n                        <input type=\"number\" id=\"entry-amount\" placeholder=\"Amount\" class=\"w-full p-3 admin-input\">\n                        <button id=\"add-entry-button\" class=\"mt-3 w-full btn-outline font-bold py-2\">Add Entry<\/button>\n                    <\/div>\n                    <div class=\"info-card p-4\">\n                        <h3 class=\"font-semibold mb-2\">Add Document<\/h3>\n                        <select id=\"doc-investor-select\" class=\"w-full p-3 admin-input mb-2\"><\/select>\n                        <input type=\"text\" id=\"doc-name\" placeholder=\"Document Name\" class=\"w-full p-3 admin-input mb-2\">\n                        <input type=\"text\" id=\"doc-url\" placeholder=\"Document URL\" class=\"w-full p-3 admin-input\">\n                        <button id=\"add-doc-button\" class=\"mt-3 w-full btn-outline font-bold py-2\">Add Document<\/button>\n                    <\/div>\n                <\/div>\n            <\/div>\n\n            <!-- ALL INVESTORS OVERVIEW -->\n            <div class=\"space-y-4\">\n                <h3 class=\"text-2xl font-bold border-b border-gray-700 pb-2\">All Investors<\/h3>\n                <div id=\"all-investors-list\" class=\"space-y-4\"><\/div>\n            <\/div>\n\n            <!-- NEWS MANAGEMENT -->\n            <div class=\"space-y-4\">\n                 <h3 class=\"text-2xl font-bold border-b border-gray-700 pb-2\">News Management<\/h3>\n                 <div class=\"info-card p-4\">\n                    <h3 class=\"font-semibold mb-2\" id=\"news-form-title\">Post New Update<\/h3>\n                    <input type=\"hidden\" id=\"news-id-input\">\n                    <input type=\"text\" id=\"news-title\" placeholder=\"News Title\" class=\"w-full p-3 admin-input mb-2\">\n                    <textarea id=\"news-text\" rows=\"3\" placeholder=\"News Text\" class=\"w-full p-3 admin-textarea-light\"><\/textarea>\n                    <button id=\"add-news-button\" class=\"mt-3 w-full btn-outline font-bold py-2\">Post Update<\/button>\n                    <button id=\"cancel-edit-news-button\" class=\"hidden mt-2 w-full btn-outline btn-danger\">Cancel Edit<\/button>\n                <\/div>\n                <div id=\"news-editor-list\" class=\"space-y-2\"><\/div>\n            <\/div>\n        <\/div>\n    <\/div>\n\n<script>\n    \/\/ #################### CONFIGURATION ####################\n    const ADMIN_PASSWORD = \"super\";\n\n    \/\/ #################### DATABASE (localStorage) ####################\n    const db = {\n        data: {},\n        load() {\n            const storedData = localStorage.getItem('investorDB_v6');\n            this.data = storedData ? JSON.parse(storedData) : { tokenPrice: 0.07, investors: {}, news: [] };\n        },\n        save() {\n            localStorage.setItem('investorDB_v6', JSON.stringify(this.data));\n        }\n    };\n    db.load();\n\n    \/\/ #################### DOM ELEMENTS ####################\n    const adminPanel = document.getElementById('admin-panel');\n\n    \/\/ #################### ADMIN PANEL LOGIC ####################\n    \n    function renderAllInvestors() {\n        const listEl = document.getElementById('all-investors-list');\n        listEl.innerHTML = '';\n        const investors = db.data.investors;\n\n        for (const address in investors) {\n            const investor = investors[address];\n            const totalInvested = investor.investmentTransactions.reduce((sum, tx) => sum + tx.amount, 0);\n            const totalDividends = investor.dividendRecords.reduce((sum, rec) => sum + rec.amount, 0);\n\n            const investorCard = document.createElement('div');\n            investorCard.className = 'info-card p-4 space-y-3';\n            \n            investorCard.innerHTML = `\n                <div>\n                    <p class=\"text-sm text-gray-400\">Investor #${String(investor.investorCode).padStart(3, '0')}<\/p>\n                    <p class=\"font-mono text-xs\">${address}<\/p>\n                <\/div>\n                <div class=\"grid grid-cols-2 gap-4 text-center\">\n                    <div>\n                        <p class=\"text-sm text-gray-400\">Total Invested (Tokens)<\/p>\n                        <p class=\"text-xl font-bold\">${totalInvested.toLocaleString('en-US')}<\/p>\n                    <\/div>\n                    <div>\n                        <p class=\"text-sm text-gray-400\">Total Dividends (USD)<\/p>\n                        <p class=\"text-xl font-bold\">$${totalDividends.toLocaleString('en-US')}<\/p>\n                    <\/div>\n                <\/div>\n                <div class=\"grid grid-cols-1 md:grid-cols-3 gap-4\">\n                    <!-- Investment History -->\n                    <div>\n                        <p class=\"text-sm font-semibold mb-1\">Investment History:<\/p>\n                        <ul class=\"space-y-2 record-list\" data-address=\"${address}\" data-type=\"investment\">\n                            ${investor.investmentTransactions.map((tx, index) => `\n                                <li class=\"flex justify-between items-center text-sm\">\n                                    <span>${new Date(tx.date).toLocaleDateString()}: ${tx.amount.toLocaleString('en-US')}<\/span>\n                                    <button class=\"delete-record-btn text-xs text-red-500 hover:underline\" data-index=\"${index}\">Delete<\/button>\n                                <\/li>\n                            `).join('') || '<li class=\"text-xs text-gray-500\">No investments.<\/li>'}\n                        <\/ul>\n                    <\/div>\n                    <!-- Dividend History -->\n                    <div>\n                        <p class=\"text-sm font-semibold mb-1\">Dividend History:<\/p>\n                        <ul class=\"space-y-2 record-list\" data-address=\"${address}\" data-type=\"dividend\">\n                             ${investor.dividendRecords.map((rec, index) => `\n                                <li class=\"flex justify-between items-center text-sm\">\n                                    <span>${new Date(rec.date).toLocaleDateString()}: $${rec.amount.toLocaleString('en-US')}<\/span>\n                                    <button class=\"delete-record-btn text-xs text-red-500 hover:underline\" data-index=\"${index}\">Delete<\/button>\n                                <\/li>\n                            `).join('') || '<li class=\"text-xs text-gray-500\">No dividends.<\/li>'}\n                        <\/ul>\n                    <\/div>\n                    <!-- Documents -->\n                    <div>\n                        <p class=\"text-sm font-semibold mb-1\">Documents:<\/p>\n                        <ul class=\"space-y-2 record-list\" data-address=\"${address}\" data-type=\"document\">\n                            ${investor.documents.map((doc, index) => `\n                                <li class=\"flex justify-between items-center text-sm\">\n                                    <span>${index + 1}. ${doc.name}<\/span>\n                                    <button class=\"delete-record-btn text-xs text-red-500 hover:underline\" data-index=\"${index}\">Delete<\/button>\n                                <\/li>\n                            `).join('') || '<li class=\"text-xs text-gray-500\">No documents.<\/li>'}\n                        <\/ul>\n                    <\/div>\n                <\/div>\n            `;\n            listEl.appendChild(investorCard);\n        }\n        \n        \/\/ Add event listeners for all delete buttons\n        document.querySelectorAll('.delete-record-btn').forEach(button => {\n            button.addEventListener('click', (e) => {\n                const list = e.target.closest('.record-list');\n                const address = list.dataset.address;\n                const type = list.dataset.type;\n                const index = parseInt(e.target.dataset.index, 10);\n                \n                let recordType;\n                if (type === 'investment') recordType = 'investmentTransactions';\n                else if (type === 'dividend') recordType = 'dividendRecords';\n                else if (type === 'document') recordType = 'documents';\n\n                if (confirm(`Are you sure you want to delete this ${type}?`)) {\n                    db.data.investors[address][recordType].splice(index, 1);\n                    db.save();\n                    renderAllInvestors(); \/\/ Re-render the entire list\n                }\n            });\n        });\n    }\n\n    function renderNewsEditor() {\n        const listEl = document.getElementById('news-editor-list');\n        listEl.innerHTML = '';\n        const sortedNews = [...db.data.news].sort((a,b) => new Date(b.date) - new Date(a.date));\n\n        sortedNews.forEach((newsItem, index) => {\n            const originalIndex = db.data.news.indexOf(newsItem); \/\/ Get original index before sorting\n            const newsCard = document.createElement('div');\n            newsCard.className = 'info-card p-3 flex justify-between items-center';\n            newsCard.innerHTML = `\n                <div>\n                    <p class=\"font-semibold\">${newsItem.title}<\/p>\n                    <p class=\"text-xs text-gray-400\">${new Date(newsItem.date).toLocaleDateString()}<\/p>\n                <\/div>\n                <div class=\"space-x-2\">\n                    <button class=\"edit-news-btn text-xs btn-outline px-2 py-1\" data-news-index=\"${originalIndex}\">Edit<\/button>\n                    <button class=\"delete-news-btn text-xs btn-danger px-2 py-1\" data-news-index=\"${originalIndex}\">Delete<\/button>\n                <\/div>\n            `;\n            listEl.appendChild(newsCard);\n        });\n\n        document.querySelectorAll('.edit-news-btn').forEach(btn => {\n            btn.addEventListener('click', (e) => {\n                const index = e.target.dataset.newsIndex;\n                const newsItem = db.data.news[index];\n                document.getElementById('news-form-title').textContent = 'Edit Update';\n                document.getElementById('news-id-input').value = index;\n                document.getElementById('news-title').value = newsItem.title;\n                document.getElementById('news-text').value = newsItem.text;\n                document.getElementById('add-news-button').textContent = 'Save Changes';\n                document.getElementById('cancel-edit-news-button').classList.remove('hidden');\n            });\n        });\n        \n        document.querySelectorAll('.delete-news-btn').forEach(btn => {\n            btn.addEventListener('click', (e) => {\n                 const index = e.target.dataset.newsIndex;\n                 if (confirm('Are you sure you want to delete this news update?')) {\n                    db.data.news.splice(index, 1);\n                    db.save();\n                    renderNewsEditor();\n                 }\n            });\n        });\n    }\n\n    function populateSelects() {\n        const selects = [document.getElementById('entry-investor-select'), document.getElementById('doc-investor-select')];\n        const investors = db.data.investors;\n        selects.forEach(select => {\n            select.innerHTML = '<option value=\"\">-- Select an Investor --<\/option>';\n            for (const address in investors) {\n                const option = document.createElement('option');\n                option.value = address;\n                const code = String(investors[address].investorCode).padStart(3, '0');\n                option.textContent = `Investor #${code} (${address.substring(0,6)}...${address.substring(38)})`;\n                select.appendChild(option);\n            }\n        });\n    }\n\n    function setupAdminPanel() {\n        document.getElementById('update-price-button').onclick = () => {\n            const newPrice = parseFloat(document.getElementById('new-price').value);\n            if (!isNaN(newPrice) && newPrice >= 0) {\n                db.data.tokenPrice = newPrice;\n                db.save();\n                alert('Token price updated.');\n            }\n        };\n        \n        document.getElementById('add-entry-button').onclick = () => {\n            const selectedAddress = document.getElementById('entry-investor-select').value;\n            if (!selectedAddress) return alert('Please select an investor first.');\n            \n            const type = document.getElementById('entry-type-select').value;\n            const date = document.getElementById('entry-date').value;\n            const amount = parseFloat(document.getElementById('entry-amount').value);\n\n            if (!date || !amount || amount <= 0) return alert('Please provide a valid date and amount.');\n\n            if (type === 'investment') {\n                db.data.investors[selectedAddress].investmentTransactions.push({ date, amount });\n            } else {\n                 db.data.investors[selectedAddress].dividendRecords.push({ date, amount });\n            }\n            db.save();\n            alert(`${type.charAt(0).toUpperCase() + type.slice(1)} for investor ${selectedAddress.substring(0,6)}... added.`);\n            renderAllInvestors();\n        };\n\n        document.getElementById('add-doc-button').onclick = () => {\n            const selectedAddress = document.getElementById('doc-investor-select').value;\n            if (!selectedAddress) return alert('Please select an investor first.');\n            const docName = document.getElementById('doc-name').value;\n            const docUrl = document.getElementById('doc-url').value;\n            if (docName && docUrl) {\n                db.data.investors[selectedAddress].documents.push({ name: docName, url: docUrl, addedDate: new Date().toISOString() });\n                db.save();\n                alert(`Document for investor ${selectedAddress.substring(0,6)}... added.`);\n                renderAllInvestors();\n            }\n        };\n\n        document.getElementById('add-news-button').onclick = () => {\n            const title = document.getElementById('news-title').value;\n            const text = document.getElementById('news-text').value;\n            const newsId = document.getElementById('news-id-input').value;\n\n            if (title && text) {\n                if (newsId) { \/\/ Editing existing news\n                    db.data.news[newsId] = { ...db.data.news[newsId], title, text };\n                    alert('Project update saved.');\n                } else { \/\/ Adding new news\n                    db.data.news.push({ title: title, text: text, date: new Date().toISOString() });\n                    alert('Project update posted.');\n                }\n                db.save();\n                renderNewsEditor();\n                resetNewsForm();\n            }\n        };\n\n        document.getElementById('cancel-edit-news-button').onclick = resetNewsForm;\n    }\n    \n    function resetNewsForm() {\n        document.getElementById('news-form-title').textContent = 'Post New Update';\n        document.getElementById('news-id-input').value = '';\n        document.getElementById('news-title').value = '';\n        document.getElementById('news-text').value = '';\n        document.getElementById('add-news-button').textContent = 'Post Update';\n        document.getElementById('cancel-edit-news-button').classList.add('hidden');\n    }\n\n    \/\/ #################### INITIALIZATION ####################\n    window.addEventListener('load', () => {\n        document.getElementById('admin-connect-button').addEventListener('click', async () => {\n            if (typeof window.ethereum === 'undefined') return alert(\"MetaMask is not installed.\");\n            await window.ethereum.request({ method: 'eth_requestAccounts' });\n            document.getElementById('admin-connect-section').classList.add('hidden');\n            document.getElementById('admin-password-section').classList.remove('hidden');\n        });\n        \n        document.getElementById('login-submit-button').addEventListener('click', () => {\n            if (document.getElementById('admin-password').value === ADMIN_PASSWORD) {\n                document.getElementById('admin-login-flow').classList.add('hidden');\n                adminPanel.classList.remove('hidden');\n                document.getElementById('new-price').value = db.data.tokenPrice;\n                populateSelects();\n                renderAllInvestors();\n                renderNewsEditor();\n            } else {\n                alert('Incorrect password!');\n            }\n        });\n\n        document.getElementById('admin-logout-button').addEventListener('click', () => {\n            adminPanel.classList.add('hidden');\n            document.getElementById('admin-password-section').classList.add('hidden');\n            document.getElementById('admin-login-flow').classList.remove('hidden');\n            document.getElementById('admin-connect-section').classList.remove('hidden');\n        });\n\n        setupAdminPanel();\n    });\n<\/script>\n\n<\/body>\n<\/html>\n\n<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-103","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/invest.alphabusiness.media\/index.php\/wp-json\/wp\/v2\/pages\/103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/invest.alphabusiness.media\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/invest.alphabusiness.media\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/invest.alphabusiness.media\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/invest.alphabusiness.media\/index.php\/wp-json\/wp\/v2\/comments?post=103"}],"version-history":[{"count":13,"href":"https:\/\/invest.alphabusiness.media\/index.php\/wp-json\/wp\/v2\/pages\/103\/revisions"}],"predecessor-version":[{"id":229,"href":"https:\/\/invest.alphabusiness.media\/index.php\/wp-json\/wp\/v2\/pages\/103\/revisions\/229"}],"wp:attachment":[{"href":"https:\/\/invest.alphabusiness.media\/index.php\/wp-json\/wp\/v2\/media?parent=103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}