# Invest

#### Form Tag

* **`<form method="post" name="spendform" action="invest">`**: The form element that uses the POST method to submit data to the "invest" action endpoint. The `name="spendform"` attribute is used for referencing the form in JavaScript or other scripts.

#### Hidden Input

* **`<input type="hidden" name="action" value="invest_request">`**: A hidden input field to specify the action as "invest\_request" when the form is submitted.

#### Form Body

**Investment Plan Selection**

* **`<label>Select Investment Plan</label>`**: Label for the investment plan selection.
* **`{foreach from=$index_plans item=p}`**: Loops through each investment plan in the `$index_plans` array to populate the available plans.
  * **`<table class="table">`**: Defines a table to display the details of each investment plan.
    * **Investment Plan Radio Button**:
      * **`<input type="radio" name="package_id" data-min="{$p.plans[0].min_deposit}" value="{$p.id}" id="{$p.id}" {if ($p.a == 1)} checked {/if} />`**: Radio button for selecting the investment plan. The `data-min` attribute stores the minimum deposit for the plan. The `checked` attribute is used if the plan is pre-selected.
      * **`<label for="{$p.id}">{$p.name|escape:html}</label>`**: Displays the name of the investment plan, with HTML escaping.
    * **Investment Plan Details**:
      * **`{if $p.plans}`**: Checks if there are plans available for the investment package.
      * **Plan Details Table**:
        * **Plan** (`{$o.name|escape:html}`): The name of the investment plan.
        * **Amount Range**: Displays the range of amounts allowed for the plan. Uses infinity symbol (`&infin;`) for unlimited maximum deposits.
        * **Profit (%)**: Displays the profit percentage for the plan.
        * **Additional Details**: Shows profit percentages, frequency, and periods based on the investment package type.
    * **Reinvestment Option**:
      * **`{if $p.reinvest}`**: Checks if the reinvest option is available.
      * **`<label><input type="checkbox" name="auto_reinvest" value="1">Automatically ReInvest Funds at the end of Package Period.</label>`**: Checkbox for enabling automatic reinvestment.
    * **Compound Option**:
      * **`{if $p.compound}`**: Checks if the compound option is available.
      * **`<input type="text" name="compound" class="form-control">`**: Input field for entering the compound amount with minimum and maximum amounts displayed.
    * **Cashback Bonus**:
      * **`{if $p.cashback_bonus_amount || $p.cashback_bonus_percentage}`**: Checks if cashback bonuses are available.
      * **Displays cashback bonus amount and percentage.**

**Payment Method Selection**

* **`<table class="table table-sm">`**: Table for displaying available payment methods.
  * **Table Headers**:
    * **Processing**
    * **Topup**
    * **Balance**
    * **Faucet**
  * **Payment Methods Loop**:
    * **`{section name=p loop=$ps}`**: Loops through each payment method in the `$ps` array.
      * **Payment Method Radio Button**:
        * **`<input type="radio" name="payment_method_id" value="{$ps[p].id}" {if ($ps[p].id == 1)} checked {/if} >`**: Radio button for selecting a payment method.
      * **Balance and Faucet**:
        * **Displays the balance and faucet options for each payment method.**

**Investment Amount**

* **`<label class="form-label">Amount to Spend</label>`**: Label for the amount input field.
* **`<input type="number" step="0.00000001" class="form-control" required="" value="" name="amount" placeholder="">`**: Input field for entering the investment amount, allowing precision up to eight decimal places.

#### Form Footer

* **`<div class="card-footer text-muted">`**: Footer of the card.
  * **`<button type="submit" name="submit" value="submit" class="btn btn-primary ml-auto">Make Payment</button>`**: Submit button to process the investment request. The button is styled with Bootstrap classes.

### Templating Details

* **`{foreach from=$index_plans item=p}`**: Loops through each investment plan to display available plans.
* **`{if $p.plans}`**: Conditional check for displaying plan details.
* **`{if $p.reinvest}`**: Conditional check for displaying the reinvestment option.
* **`{if $p.compound}`**: Conditional check for displaying the compound option.
* **`{if $p.cashback_bonus_amount || $p.cashback_bonus_percentage}`**: Conditional check for displaying cashback bonuses.
* **`{section name=p loop=$ps}`**: Loops through each payment method to display payment options.

### Notes

* Ensure that the `$index_plans` and `$ps` arrays are properly populated with the relevant data for investment plans and payment methods.
* Customize the styling and attributes as needed to fit the specific requirements of your investment form.
