{include file="header.tpl"}

<section class="content">
	<div class="container">
		<section class="content">
			<div class="container">
				<style>
				.theme-cyan .checkbox input[type="checkbox"]:checked + label::after {
					border-color: #fff;
					background: #f6b827;
					color: #000;
				}
				</style>
			    <div class="row clearfix">
                    <div class="col-lg-12">
                        <div class="card" style="margin-top: 30px">
                            <div class="body block-header">
                                <div class="row">
                                    <div class="col-lg-6 col-md-8 col-sm-12">
                                        <h2>Welcome, Kulbov</h2>
                                        <ul class="breadcrumb p-l-0 p-b-0 ">
                                            <li class="breadcrumb-item"><a href="/?a=account"><i class="fas fa-home"></i></a></li>
                                            <li class="breadcrumb-item"><a href="/?a=account">Dashboard</a></li>
                                            <li class="breadcrumb-item active">Make an Investment</li>
                                        </ul>
                                    </div>
                                    <div class="col-lg-6 col-md-4 col-sm-12 text-right">
                                        <a href="/?a=deposit"><button class="btn btn-primary btn-round btn-simple float-right hidden-xs m-l-10 btn-warning waves-effect">Make an investment</button></a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                {if $fatal}
                {if $fatal == 'one_per_month'}
                You can deposit once a month only.
                {/if}
                
                {else}
                
                {literal}
                <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
                <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
                <script language="javascript"><!--
                function openCalculator(id)
                {
                
                  w = 225; h = 400;
                  t = (screen.height-h-30)/2;
                  l = (screen.width-w-30)/2;
                  window.open('?a=calendar&type=' + id, 'calculator' + id, "top="+t+",left="+l+",width="+w+",height="+h+",resizable=1,scrollbars=0");
                
                {/literal}
                  {if $qplans > 1}
                {literal}
                  for (i = 0; i < document.spendform.h_id.length; i++)
                  {
                    if (document.spendform.h_id[i].value == id)
                    {
                      document.spendform.h_id[i].checked = true;
                    }
                  }
                {/literal}
                  {/if}
                {literal}
                
                }
                
                function updateCompound() {
                  var id = 0;
                  var tt = document.spendform.h_id.type;
                  if (tt && tt.toLowerCase() == 'hidden') {
                    id = document.spendform.h_id.value;
                  } else {
                    for (i = 0; i < document.spendform.h_id.length; i++) {
                      if (document.spendform.h_id[i].checked) {
                        id = document.spendform.h_id[i].value;
                      }
                    }
                  }
                
                  var cpObj = document.getElementById('compound_percents');
                  if (cpObj) {
                    while (cpObj.options.length != 0) {
                      cpObj.options[0] = null;
                    }
                  }
                
                  if (cps[id] && cps[id].length > 0) {
                    document.getElementById('coumpond_block').style.display = '';
                
                    for (i in cps[id]) {
                      cpObj.options[cpObj.options.length] = new Option(cps[id][i]);
                    }
                  } else {
                    document.getElementById('coumpond_block').style.display = 'none';
                  }
                }
                var cps = {};
                --></script>
                {/literal}
                
                {if $frm.say eq 'deposit_success'}
                {literal}
                <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
                    <script>
                    swal({
                      title: "Success!",
                      text: "Your deposit has been successfully saved.",
                      icon: "success",
                    });
                        </script>
                        {/literal}
                <div class="alert alert-success">Your deposit has been successfully saved.</div><br><br>
                <br><br>
                {/if}
                            
                {if $frm.say eq 'deposit_saved'}
                {literal}
                <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
                    <script>
                    swal({
                      title: "Success!",
                      text: "Your deposit has been saved. It will become active after the blockchain confirmation is complete.",
                      icon: "success",
                    });
                        </script>
                        {/literal}
                <div class="alert alert-success">Your deposit has been saved. It will become active after the blockchain confirmation is complete.</div><br><br>
                {/if}

                {if $errors}
                    {if $errors.less_min}
                        <div class="alert alert-danger">
                            Sorry, you can deposit not less than {$currency_sign}{$errors.less_min} with selected processing.
                        </div>
                    {/if}
                    
                    {if $errors.greater_max}
                        <div class="alert alert-danger">
                            Sorry, you can deposit not greater than {$currency_sign}{$errors.greater_max} with selected processing.
                        </div>
                    {/if}
                    
                    {if $errors.ec_forbidden}
                        <div class="alert alert-danger">
                            Sorry, deposit with selected processing is temporary forbidden.
                        </div>
                    {/if}
                {/if}

                
                <br> <br>
                <form method=post name="spendform">
                <input type=hidden name=a value=deposit>
                {if $qplans > 1}{/if}
				<div class="row clearfix">
					<div class="col-xl-4 col-lg-12 col-md-12">
                    	<div class="card">
                            <div class="header">
                                <h2>Make an <strong>Investment</strong></h2>
                            </div>
                            <div class="body">
                                <script src="web/js/calc/jquery.min.js" type="text/javascript"></script>
                        
                                <!-- Investment Plan Selection -->
                                <h2 class="card-inside-title">Investment Plan</h2>
                                <select name="h_id" id="plancalc" class="calculate-select form-control">
                                    {foreach from=$plans item=plan}
                                        <option value="{$plan.id}" {if $plan.id == $frm.h_id}selected{/if}>{$plan.name|escape:html}</option>
                                    {/foreach}
                                </select>
                        
                                <!-- Payment Processor Selection -->
                                <h2 class="card-inside-title">Payment Processor</h2>
                                <select name="type" id="type" class="calculate-select form-control">
                                    {foreach from=$dps item=p}
                                        <option value="process_{$p.id}" {if $frm.type == "process_`$p.id`"}selected{/if}>
                                            Deposit from {$p.name}
                                        </option>
                                    {/foreach}
                                </select>
                        
                                <!-- Deposit Amount -->
                                <h2 class="card-inside-title">Deposit Amount ({$currency_sign})</h2>
                                <input type="text" value="{$frm.amount|default:$min_deposit|amount_format}" class="calculate-amount form-control" 
                                       name="amount" style="font-size: 14px; padding: 10px 22px; text-align: right;">
                        
                                <!-- Submit Button -->
                                <br>
                                <button type="button" id="submitInvestmentButton" class="btn btn-warning btn-round btn-lg">Make Deposit</button>
                            </div>
                        </div>
                        
                        
                    	</form>
                        {literal}
                        <script>
                            document.getElementById("submitInvestmentButton").addEventListener("click", function() {
                                // Show SweetAlert confirmation dialog
                                Swal.fire({
                                    title: 'Confirm Investment',
                                    text: 'Are you sure you want to make this deposit?',
                                    icon: 'question',
                                    showCancelButton: true,
                                    confirmButtonText: 'Yes, proceed',
                                    cancelButtonText: 'Cancel',
                                    confirmButtonColor: '#28a745',
                                    cancelButtonColor: '#d33'
                                }).then((result) => {
                                    if (result.isConfirmed) {
                                        // Submit the form only if confirmed
                                        document.forms[0].submit();
                                    }
                                });
                            });
                        </script>
                        <script language=javascript>
                        /*
                        for (i = 0; i<document.spendform.type.length; i++) {
                          if ((document.spendform.type[i].value.match(/^process_/))) {
                            document.spendform.type[i].checked = true;
                            break;
                          }
                        }
                        */
                        updateCompound();
                        </script>
                        {/literal}
                        
                        {/if}
                                                <div class="card">
                            <div class="header">
                                <h2><strong>Available</strong> Balance</h2>
                            </div>
                            <div class="body">
                                <div class="row">
                                    <div class="col-md-12">
                                        <h2 class="m-b-0">{$currency_sign}{$userinfo.balance_totals.balance|amount_format}</h2>
                                        <p>Account balance</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    
                    </div>
                    
					<div class="col-xl-8 col-lg-12 col-md-12">
						<div class="card">
                            <div class="body">
                                {foreach from=$plans item=plan name=fplans}
                                    <div style="background: #1c2024; padding: 20px; margin: 0; color: #fff; text-align: justify">
                                        <h3 style="color: #ffb534; text-align: left">{$smarty.foreach.fplans.index+1}. {$plan.name|escape:html}</h3>
                                        {foreach from=$plan.plans item=o}
                                            <h4 style="margin: 20px 0; text-align: left">Profit {$o.percent}% daily for {$o.period} hours</h4>
                                            Minimum investment {$o.min_deposit|fiat} / Maximum investment 
                                            {if $o.max_deposit == 0}∞{else}{$o.max_deposit|fiat}{/if}
                                        {/foreach}
                                    </div>
                                    {if !$smarty.foreach.fplans.last}
                                        <div style="margin: 40px 0 0;"></div>
                                    {/if}
                                {/foreach}
                            </div>

						</div>
					</div>
				</div>
				<div class="row clearfix"></div>
				<div class="row clearfix">
					<div class="col-md-12 col-lg-12">
						<div class="card active-bg">
							<div class="body">
								<p class="copyright m-b-0 text-dark">Copyright 2024 {$settings.site_name}.</p>
							</div>
						</div>
					</div>
				</div>
			</div>
		</section>
{include file="footer.tpl"}