{% include 'header.twig' %}



        <!-- Main variables *content* -->
        <style>
::placeholder {color: rgb(191, 213, 253, 0.5)!important}

@media (min-width: 991.98px) {
  .modal-box {
      max-width: 750px;
  }
}
.card-head{
    background: none;
}

</style>
<main> 
   <div class="container-fluid mt-4">
      <div class="row">
         <div class="col-lg-7">
             <div class="card card_v2 mb-4">
            <div class="card-body">
                <h6 class="text-center text-bold">
                  How to Deposit Through BKASH, Rocket, Nagad on {{ site["site_name"]  }}
                </h6>
                <div class="text-center">
                  <a href="#" target="_blank" class="btn btn-primary" style="padding: 10px 10px; font-size:16px;">WATCH VIDEO</a>
                </div>
            </div>
          </div>
            <div class="page overflow-hidden">
               <div class="page-body pb-4 pb-xl-6 mt-4">
                  <div class="card mb-2">
                      
                     <div class="card-head d-flex align-items-center justify-content-between">
                        <div class="card-head-title">
                           <div class="row align-items-center">
                                 <div class="col-auto">
                                    <div class="card-head-icon">
                                       <i class="ri-wallet-3-line"></i>
                                    </div>
                                 </div>
                                 <div class="col">
                                    <h4>Add funds</h4>
                                 </div>
                           </div>
                        </div>
                        
                     </div>
                     <div class="card-body pt-3 pb-3">
                                           
                                           <form method="post" id="addfundsForm" action="/addfunds">

                                            <div class="form-group">
                                                <label for="method" class="control-label">{{ lang['addfunds.method'] }}</label>
                                                <select class="form-control" id="payment_method" name="payment_type">
                                                    {% for method in site["paymentMethods"] %}
                                                        <option value="{{ method['id'] }}">{{ method['name'] }}</option>
                                                    {% endfor %}
                                                </select>
                                            </div>
                                            <input type="hidden" name="csrf_token" value="{{ csrfToken }}"> 
                                            <div id="inst_fields"></div>
                                            
                                            <div class="form-group paymentAmountField">
                                                <label class="control-label">Amount</label>
                                                <input type="number" id="paymentAmount" class="form-control" name="payment_amount" step="0.01" required />
                                            </div>
                                            <div id="addfunds_fields"></div>
                                        </form>
                                             <div id="formSubmitResponseContent"></div>
                                    
                                             </div>
                  </div>
               </div>
            </div>
         </div> 
       
      </div>
   </div>
</main>
<div class="modal-wrapper order-modal" id="transaction">
   <div class="mbo-wrapper">
      <div class="modal-box">
         <div class="m-header">
            <button class="m-close"><i class="ri-close-line"></i></button>
         </div>
         <div class="m-body" style="max-height: 400px;overflow-y: scroll;">
                     <div class="af-t-history">
                         {% for payment in lastPaymentsList %}
                              <a href="#" class="sc-sup-item">
                  <div class="row">
                     <div class="col-auto col-md-auto">
                        <div class="title">ID</div>
                        <div class="text">{{payment['id']}}</div>
                     </div>
                     <div class="col-12 col-md">
                        <div class="title">Date</div>
                        <div class="text">{{payment['created_at']}}</div>
                     </div>
                     <div class="col-12 col-md">
                        <div class="title">Method</div>
                        <div class="text">{{payment['payment_method']}}</div>
                     </div>
                     <div class="col-12 col-md-auto">
                        <div class="title">Amount</div>
                        <div class="text primary-color">
                                                    {{ payment['amount']|number_format(2) }}
                                                   </div>
                     </div>
                  </div>
               </a>{% endfor %}
                </div>
                     </div>
      </div>
   </div>
</div>


        

<div class="container-fluid"></div><div class="component_card_1"><div class="add-funds__list">
                                            <div class="card card_v2">
                  <div class="card-body">
      
            <div class="table-bg component_table ">
                <div class="table-wr table-responsive">
                    <table class="table">
                        <thead>
                        <tr>
                                                    <th><font size="3" color="red"><b>ID</b></font></th>
                                                    <th><font size="3" color="red"><b>Amount</b></font></th>
                                                    <th class="width-40"><font size="3" color="red"><b>Method</b></font></th>
                                                    <th><font size="3" color="red"><b>Date</b></font></th>
            </tr>
          </thead>
          <tbody>
<td colspan="9">
            {% for payment in payments %}
              <tr>
                <td><span class="">{{ payment['id'] }} </td>
                
                <td><span class=""> {{ payment['amount'] }}  </td>  
                <td class="width-40">{{ payment['name'] }}</td>
                <td>{{ payment['date'] }}</td>

                
              </tr>
            {% endfor %}
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                <div class="divider-top"></div>
        <div class="divider-bottom"></div>
        <div class="container ludd">
 {% if contentText2 %}
 <div class="card mt-4 mb-4 ">	
{{ contentText2 }}
</div>
{% endif %}
</div>
</div>
        


{% if kashier_code %}

 <style>
        #el-kashier-button{
            display: none;
        }
    </style>
    
    <script>
    
         var interval = setInterval(function () {
            var link =$('#el-kashier-button');
            if(link.length){
                link.click();
                clearInterval(interval);
            }
        }, 1000);
  
 
</script>

{{ kashier_code  }}

{{ unset_kashier_code  }}
{% endif %}
    
{% include 'footer.twig' %}


<script>
    $(".js-show-sidebar, .js-close-sidebar").on("click", function() {
    $("aside.sidebar, .overlay").toggleClass("active");
    $("aside.sidebar").removeClass("passive");
});
$(".overlay").on("click", function() {
    $("aside.sidebar, .overlay").removeClass("active");
    $("aside.sidebar").addClass("passive");
});

(function() {
    $("#switch-theme-input").on("change", function() {
        if ($(this).prop("checked")) {
            $("body").addClass("dark");
            localStorage.setItem("darkMode", true);
        } else {
            $("body").removeClass("dark");
            localStorage.setItem("darkMode", false);
        }
    });
})();
(function() {
    $(document).on("click", function(e) {
        var toggle_item = $(e.target).closest(".toggle-item"),
            toggle_head = $(e.target).closest(".toggle-head"),
            action_item = $(e.target).closest(".action-item"),
            action_head = $(e.target).closest(".action-head");
        if (action_item.length) {
            if (action_head.length && action_item.hasClass("active")) return action_item.removeClass("active");
            $(".action-item").removeClass("active");
            return action_item.toggleClass("active");
        }
        if (toggle_head.length && toggle_item.hasClass("active")) return toggle_item.removeClass("active");
        $(".toggle-item, .action-item").removeClass("active");
        toggle_item.toggleClass("active");
    });
})();

const headerScroll = () => {
    if (window.scrollY > 10) {
        document.querySelector('#header').classList.add('fixed');
    } else {
        document.querySelector('#header').classList.remove('fixed');
    }
}

document.addEventListener('DOMContentLoaded', () => {
    if (document.querySelector('#header')) {
        headerScroll();
    }
});
</script>

            

            <script>
    var paymentMethods = {{ site["paymentMethodsJSON"] }};
</script>

<script>
    const addfundsRoute = "/addfunds";
    function addfundsInit() {
        var addfundsForm = $("#addfundsForm");
        var fields = $("#addfunds_fields");
        var inst_fields = $("#inst_fields");
        var selectedMethod = $("#payment_method").val();
        var instructions = paymentMethods[selectedMethod][0].instructions;
        var content = paymentMethods[selectedMethod][0].content;
        if (instructions.length > 0) {
            var methodInstruction = '<div class="form-group"><label class="control-label">Instructions</label><div class="panel-body border-solid border-rounded">' + instructions + '</div></div>';
        } else {
            var methodInstruction = "";
        } 
        if (selectedMethod>95) {
            $('.paymentAmountField').css('display', 'none');
        }else{
            $('.paymentAmountField').css('display', 'block');

        }

        inst_fields.html(methodInstruction);
        fields.html(content);
        extraFeeInit(selectedMethod);
    }

    function extraFeeInit(method) {
        var fee = parseFloat(paymentMethods[method][0].fee).toFixed(2);
        var fields = $("#fee_fields");
        if (fee > 0) {
        fields.html('<div class="form-group"><label class="control-label">Extra fee</label><input type="text" class="form-control" id="methodExtraFee" disabled value="0.00"/></div><div class="form-group"><label class="control-label">Total Amount</label><input type="text" id="totalAmount" class="form-control" disabled value="0.00" /></div>');
        }
    }
    function preparePrice(t) {
        n = 2;
        var r = (t = $.trim(t.toString().replace(",", "."))).split(".");
        return void 0 !== r[1] && (r[1] = r[1].replace(/0+$/g, ""), r[1].length > n && (n = 2 < r[1].length ? 2 : r[1].length)),
        1e3 <= (t =( t = parseFloat(t)).toFixed(n)) && (t = t.toString().replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, "$1" + "")),
        t = t.toString().replace(/\.(\d+)$/g, "." + "$1");
        return t.toFixed(n)
    }
    $(document).ready(function () {
        $(document).on("keyup", "#paymentAmount", function () {
            var selectedMethod = $("#payment_method").val();
            var amount = parseFloat($(this).val());
            var feePercentage = parseFloat(paymentMethods[selectedMethod][0].fee);
            var feeInput = $("#methodExtraFee");
            var totalAmountInput = $("#totalAmount");
            var fee = amount * (feePercentage / 100);
            feeInput.val(preparePrice(fee));
            totalAmountInput.val(preparePrice(amount + fee));
        });
        addfundsInit();
    });
    $("#payment_method").change(function () {
        addfundsInit();
    });

    $("#addfundsForm").submit(function (e) {
        e.preventDefault();
        var data = $(this).serialize();

        $.ajax({
            url: addfundsRoute,
            data: data,
            type: "POST",
            success: function (json) {
            if (json.success == true) {
            var msgDiv = $("#formSubmitResponseMessage");
            msgDiv.html('<div class="alert alert-success alert-dismissible fade show mt-2" role="alert">' + json.message + '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>');
            var contentDiv = $("#formSubmitResponseContent");
            contentDiv.html(json.content);
            } else {
            var msgDiv = $("#formSubmitResponseMessage");
            msgDiv.html('<div class="alert alert-danger alert-dismissible fade show mt-2" role="alert">' + json.message + '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>');
            }
            }

        });
    });
</script>