payout

mail@pastecode.io avatar
unknown
plain_text
a year ago
9.7 kB
0
Indexable
Never
<%- include('../../include/header.ejs') %>
 <%- include('../../include/navbar.ejs') %> 

<body>
        <!-- ============================================================== -->
        <!-- Start right Content here -->
        <!-- ============================================================== -->

    <div id="page-wrapper">
            
        <div class="main-content">

            <div class="page-content">
                <div class="container-fluid">
        
                    <!-- start page title -->
                    <div class="row">
                        <div class="col-12">
                            <div class="page-title-box d-sm-flex align-items-center justify-content-between">
                                <h4 class="mb-sm-0">Add Payout Request</h4>
        
                               
                            </div>
                            <div class="alert alert-success" style="display:none"> </div>
                            <div class="alert alert-danger" style="display:none"></div>
                        </div>
                    </div>
                    <!-- end page title -->
        
        
                    <!-- --------------------------------------------table----------------------------------------------------- -->
                    <div class="row">
                        
                        <form action="javascript:void(0)" method="post" class="card">
                            <div class="col">  
                                <div class="col-md-6" id="leddata" style="display:none"> 
                            <div class="alert alert-success" id="datad" style="font-size: 18px;margin: 18px 18px 18px 18px;"> </div>
                                </div>
                            </div>
                          <div class="row d-flex flex-column flex-lg-row">
                            
                              <div class="col-auto d-flex flex-column flex-lg-row gap-3" style="padding-top: 17px;">
                                <% let type = ""
                                    if(role_name =="CL"){
                                        type="none";
                                  } %>
                                   <div class="clientCodeDiv" style=" flex-direction: column;min-height: 100px;display: <%= type%>;!important">
                                    <label for="placeholderInput" class="form-label fw-semibold">Client Code</label>
                                  <div style="width: 100%;" class="form-icon right">
                                    <% if(role_name =="CL"){ %>
                                        <input type="text" placeholder="Enter Client Code" class="form-control" value="<%= login_id %>" id="client_coded" name="client_code" onkeyup="this.value = this.value.toUpperCase()" onkeyup="checkEmpty()" >
                                      <%  }else{%>
                                        <input type="text" placeholder="Enter Client Code" class="form-control" id="client_code" name="client_code" onkeyup="this.value = this.value.toUpperCase()" onkeyup="checkEmpty()" >
                                        <input type="hidden" placeholder="Enter Client Code" class="form-control" id="client_coded" name="client_code" onkeyup="checkEmpty()" >
                                      <% } %>
                                      <i class="ri-close-circle-fill" onclick="clientCodeClearFn()" style="color: #4572ca;"></i>
                                      <input type="hidden" class="form-control" id="source" name="source" value="web"> 
                                       <input type="hidden" class="form-control" id="logged_in_userid" name="logged_in_userid" value="<%= logged_in_userid%>">
                                                           
                                </div>
                                    <span class="text-danger" id="client_code_err"></span>
                                  </div>
                                  
                              <div style="display: flex; flex-direction: column;">
                                <label for="placeholderInput" class="form-label fw-semibold">Available Balance</label>
                                <input type="text"  id="available_balance"  class="form-control" name="available_balance" placeholder="" disabled>
                               </div>
                              <div style="display: flex; flex-direction: column;">
                                <label for="placeholderInput" class="form-label fw-semibold">Request Balance</label>
                                <input type="text"  id="request_amount" name="request_amount" class="form-control" onkeyup="checkAvailableBalance()" placeholder="Request balance..">
                                <span id="request_amount_err" class="text-danger"></span>
                               </div>
                            <div class="col-auto">
                              <button id="submitBtn" class="custom-primary-btn" onclick="savePayoutRequest()"  style="margin-top: 1.8rem;">Submit</button>
                              </div>
                          </div>
                         
                          
                        </div>
                      </form>
                    </div>
                    
 
                    <!------------------------------------------------------table end---------------------------------------  -->
        
        
        
        
        
                </div>
                <!-- container-fluid -->
            </div>
            <!-- End Page-content -->
        
            <%- include('../../include/footer.ejs') %>
        
        </div>
        <!-- end main content-->
        
    </div>
        <!-- END layout-wrapper -->

    <%- include('../../include/scripts.ejs') %>

    <script>
        $(function(){
            getAvailableBalance();
            
            $("#client_code").autocomplete({            
                source:function(req,res){            
                    $.ajax({
                            
                        url: 'client-master-search',            
                        dataType: "jsonp",            
                        type: 'GET',            
                        data:req,            
                                    
                        success: function (data){
                            if(data[0].name != undefined && data[0].name){
                                res(data)    
                            }else{
                            $("#client_code").html("")        
                            }                      
                        },            
                        error: function (err) {            
                            console.log(err);            
                        }
                    });            
                },
                minLength:1,            
                select:function(event,ui){            
                    if(ui.item){            
                        // $("#txt1").text(ui.item.BackOfficeLogin);    
                        //console.log(ui.item);
                        $("#client_code").val(ui.item.name)  
                        $("#client_coded").val(ui.item.backOfficeLogin)
                        getAvailableBalance()     
                        $("#client_code_err").html("");    
                    }            
                }            
            })  
        })
        function checkEmpty(){
            let client_code = $("#client_code").val();
            if(client_code == ""){
                $("#available_balance").val("")
            }
        }
        function checkAvailableBalance(){
            let available_balance = parseFloat($("#available_balance").val())
            let request_amount = parseFloat($("#request_amount").val())
                if( request_amount > available_balance ){
                    $("#request_amount_err").html('Request amount should not greater than available balance');
                    return false;
                }else{
                    $("#request_amount_err").html('');
                    return true;
                }   
        }
        function getAvailableBalance(){
            
            let client_code = $("#client_coded").val();
            //console.log("Dhaval" + client_code);
            var formData = {
                'client_code':client_code,
            };  
            $.ajax({
                type: 'POST',
                url: '/get-clientwise-available-balance',
                data: JSON.stringify(formData),
                contentType: "application/json",
                dataType: "json",
                success: function(data) {
                    //console.log(data);
                    if (data.status == 200) {
                        $("#available_balance").val(data.data[0].Amount)
                        $("#leddata").css("display","block");
                        $("#datad").html(data.data[0].DISPLAY);
                    } else {
                        $("#available_balance").val("")
                    }
                }
            });
        }
    </script>

    <script>
        function clientCodeClearFn(){
        document.querySelector('.form-control').value = '' 
        document.querySelector('#available_balance').value = ''
        }
    </script>

</body>