Viewing File: /home/quiczmwg/solixproperties.org/finance.php

<?php
session_start();

include_once ("include/header.php");
// Check if the 'userid' session is not set
if (!isset($_SESSION['userid'])) {
    header("Location: login.php");
    exit();
}
?>
<?php
include_once ("include/topbar.php");
?> 

<?php include_once ("search.php"); ?>

<!-- Category Start -->
<div class="container-xxl py-3">
    <div class="container">
        <div class="text-center mx-auto mb-5 wow fadeInUp" data-wow-delay="0.1s" style="max-width: 600px;">
            <h1 class="mb-3">Invest Now</h1>
        </div>
        <form id="deposit_form" class="form-group flex-wrap" method="POST" action="confirmation_page.php">
            <div class="row g-3">
                <div class="col-md-4">
                    <div class="form-floating mt-4">
                        <select name="plan_title" class="form-select" id="investmentPlan" onchange="calculateProfit()">
                            <option value="" disabled selected>Select Investment Plan</option>
                            <!-- Options will be dynamically populated here -->
                        </select>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-floating">
                        <div class="d-">
                            <label for="profit" class="me-2">Profit:</label>
                            <input type="text" name="profit" class="form-control" id="profit" readonly>
                        </div>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-floating">
                        <div class="d-">
                            <label for="minimum" class="me-2">Minimum Investment:</label>
                            <input type="text" name="minimum" class="form-control" id="minimum" readonly>
                        </div>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-floating">
                        <div class="d-">
                            <label for="maximum" class="me-2">Maximum Investment:</label>
                            <input type="text" name="maximum" class="form-control" id="maximum" readonly>
                        </div>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-floating">
                        <div class="d-">
                            <label for="days" class="me-2">Number of Days:</label>
                            <input type="text" name="days" class="form-control" id="days" readonly>
                        </div>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-floating">
                        <div class="d-">
                            <label for="totalProfit" class="me-2">Profit * Minimum Investment:</label>
                            <input type="text" name="total_profit" class="form-control" id="totalProfit" readonly>
                        </div>
                    </div>
                </div>
                <div class="col-md-12 mt-3">
                    <button class="btn btn-primary w-100 py-3" type="submit">Invest Now</button>
                </div>
            </div>
        </form>

        <script>
            function fetchInvestmentPlans() {
                fetch('./authenticator/fetch-plans.php')
                    .then(response => response.json())
                    .then(planTitles => {
                        const dropdown = document.getElementById('investmentPlan');
                        dropdown.innerHTML = '';
                        const defaultOption = document.createElement('option');
                        defaultOption.value = "";
                        defaultOption.disabled = true;
                        defaultOption.selected = true;
                        defaultOption.textContent = 'Select Investment Plan';
                        dropdown.appendChild(defaultOption);
                        planTitles.forEach(planTitle => {
                            const option = document.createElement('option');
                            option.value = planTitle;
                            option.textContent = planTitle;
                            dropdown.appendChild(option);
                        });
                        calculateProfit();
                    })
                    .catch(error => console.error('Error fetching plan titles:', error));
            }

            function calculateProfit() {
                var investmentPlanTitle = document.getElementById("investmentPlan").value;
                if (investmentPlanTitle === "") {
                    document.getElementById("profit").value = "";
                    document.getElementById("minimum").value = "";
                    document.getElementById("maximum").value = "";
                    document.getElementById("days").value = "";
                    document.getElementById("totalProfit").value = "";
                    return;
                }
                fetch('./authenticator/fetch-plan-details.php?title=' + investmentPlanTitle)
                    .then(response => response.json())
                    .then(planDetails => {
                        var roi = parseFloat(planDetails.roi);
                        var minimum = parseFloat(planDetails.minimum);
                        var maximum = parseFloat(planDetails.maximum);
                        var days = parseInt(planDetails.days);
                        document.getElementById("profit").value = roi.toFixed(2) + "%";
                        document.getElementById("minimum").value = "$" + minimum.toLocaleString();
                        document.getElementById("maximum").value = "$" + maximum.toLocaleString();
                        document.getElementById("days").value = days;
                        document.getElementById("totalProfit").value = "$" + (roi * minimum).toLocaleString();
                    })
                    .catch(error => console.error('Error fetching plan details:', error));
            }

            document.addEventListener('DOMContentLoaded', fetchInvestmentPlans);
        </script>
    </div>
</div>

<?php include_once("include/footer.php") ?>
Back to Directory File Manager
<