<script>

    $(document).ready(function () {

        var NIN = '<?php echo $NIN; ?>';

        var BVN = '<?php echo $BVN; ?>';
        
        if(NIN == '' || NIN == '0' || NIN == 'NULL' || BVN == '' || BVN == '0' || BVN == 'NULL')
        {
            $('#bin_nin_modal').modal('show');
        }
        else
        {
            
            minnify_innitialization();

            abba_get_wallet_details();
    
        }
        
    });
    
    
    
    $("body").on("click", ".abba_save_bvn_nin", function () {

        var NIN = $('.nin').val();
    
        var BVN = $('.bvn').val();
        
        if(NIN == '' || NIN == '0' || NIN == 'NULL' || BVN == '' || BVN == '0' || BVN == 'NULL')
        {
            $.wnoty({
                type: 'warning',
                message: "Hey! Input both your NIN and BVN to proceed.",
                autohideDelay: 5000
            });
        }
        else
        {
            
            minnify_innitialization();
            
            abba_get_wallet_details();
    
            $('#bin_nin_modal').modal('hide');

        }
    });
            $("body").on("click", ".toggle-visibility", function () {


                var abba_var = $(this).data('id');

                var $amount = $("#" + abba_var);
                var originalText = $amount.text();
                var data_amt_Text = $("#" + abba_var).data('amt');
                var hiddenText = "₦*****";

                if (originalText === hiddenText) {
                    
                    $amount.html(data_amt_Text);
                    $("." + abba_var).html(data_amt_Text);
                    $(this).removeClass("fa-eye").addClass("fa-eye-slash");
                    
                }
                else {
                    
                    $amount.html(hiddenText);
                    $("." + abba_var).html(hiddenText);
                    $(this).removeClass("fa-eye-slash").addClass("fa-eye");
                    
                }
                
          });



                // function to get campus
    function abba_get_wallet_details() {
        
                     

        $('.wallet_balance').html('<i class="fa fa-spinner fa-spin"></i>');

        $('.pending_withdrawal').html('<i class="fa fa-spinner fa-spin"></i>');

        $('.amount_withdrawn').html('<i class="fa fa-spinner fa-spin"></i>');

        $('.abba_bank_name').html('<i class="fa fa-spinner fa-spin"></i>');

        $('.abba_account_number').html('<i class="fa fa-spinner fa-spin"></i>');

        $('.abba_account_name').html('<i class="fa fa-spinner fa-spin"></i>');

        $('.display_transactions').html('<tr><td colspan=5 align="center"><i class="fa fa-spinner fa-spin fs-5"></i></td></tr>');

        var user_id = $('#user_id_teacher').val();
        var user_type = $('#user_type_holder').val();

        var storedtoken = localStorage.getItem('storedtoken');
        
        var NIN_check = '<?php echo $NIN; ?>';

        var BVN_check = '<?php echo $BVN; ?>';
        
        if(NIN_check == '' || NIN_check == '0' || NIN_check == 'NULL' || BVN_check == '' || BVN_check == '0' || BVN_check == 'NULL'){
            
            var NIN = $('.nin').val();
    
            var BVN = $('.bvn').val();
            
            if(NIN == '' || NIN == '0' || NIN == 'NULL' || BVN == '' || BVN == '0' || BVN == 'NULL')
            {
                $.wnoty({
                    type: 'error',
                    message: "Please input your correct NIN and BVN to proceed",
                    autohideDelay: 10000
                });
            }
            else
            {
                abba_get_wallet_data();
            }
            
        }
        else
        {
            var NIN = NIN_check;
    
            var BVN = BVN_check;
            
            abba_get_wallet_data();
            
        }
        
        function abba_get_wallet_data(){
            $.ajax({
                type: "POST",
                url: "../../controller/scripts/parent/wallet/get_wallet_dashboard_summary.php",
                data: { user_id: user_id, storedtoken: storedtoken, NIN: NIN, BVN: BVN },
                //cache: false,
                success: function (output) {
                    // alert(output);
    
                    console.log(output);
    
                    var jsonData = JSON.parse(output);
    
                    var wallet_balance = jsonData.wallet_balance;
    
                    var pending_withdrawal = jsonData.pending_withdrawal;
    
                    var amount_withdrawn = jsonData.amount_withdrawn;
    
                    var abba_bank_name = jsonData.abba_bank_name;
    
                    var abba_account_number = jsonData.abba_account_number;
    
                    var abba_account_name = jsonData.abba_account_name;
                    
                    var abba_wallet_checker = jsonData.abba_wallet_checker;
                    
                    if(abba_wallet_checker === 1){
                        
                        $.wnoty({
                            type: 'error',
                            message: "An error has occured, please reload your page, input your correct BVN and NIN and try again.",
                            autohideDelay: 10000
                        });
                        
                        $('#bin_nin_modal').modal('show');
                    }
                    else
                    {
                        
                        $('.wallet_balance').html(wallet_balance);
        
                        $('.wallet_balance').data("amt", wallet_balance);
        
                        $('.pending_withdrawal').html(pending_withdrawal);
        
                        $('.pending_withdrawal').data("amt", pending_withdrawal);
        
                        $('.amount_withdrawn').html(amount_withdrawn);
        
                        $('.amount_withdrawn').data("amt", pending_withdrawal);
        
                        $('.abba_bank_name').html(abba_bank_name);
        
                        $('.abba_account_number').html(abba_account_number);
        
                        $('.abba_account_name').html(abba_account_name);
        
                        $.ajax({
                            type: "POST",
                            url: "../../controller/scripts/parent/wallet/get_wallet_dashboard_trans.php",
                            data: { user_id: user_id, storedtoken: storedtoken, user_type: user_type },
                            //cache: false,
                            success: function (result) {
                                $('.display_transactions').html(result);
            
                                    $('#table1').DataTable({
                                        responsive: true
                                    });
                            }
        
                        });
    
                    }
    
                }
            });
        }

    }

function minnify_innitialization() {
       

       var request = new XMLHttpRequest();
       request.open('POST', 'https://api.monnify.com/api/v1/auth/login/');
       request.setRequestHeader('Content-Type', 'application/json');
       request.setRequestHeader('Authorization', 'Basic  TUtfUFJPRF9aOTgwR0c0UFlBOjI0Wk1VNlZDQlRCOUs1RkRDVjI2VTU1OEZUTEZQMFQ5');

       request.onreadystatechange = function () {
           if (this.readyState === 4) {
               // console.log('Status:', this.status);
               // console.log('Headers:', this.getAllResponseHeaders());
               var abc = this.responseText;
               const myObj = JSON.parse(abc);
               var accessstoken = myObj["responseBody"]['accessToken'];

       
               localStorage.setItem('storedtoken', accessstoken);
               // console.log('Body:', accessstoken);
           }
       };
       request.send();
   }




   function payWithMonnify() {
    $('.abba_fund_wallet_btn').html('Processing..<i class="fa fa-spinner fa-spin"></i>');
    $('.abba_fund_wallet_btn').prop('disabled', true);
      var prosamount = $(".funding_amt").val()
      var funding_amt = parseFloat($(".funding_amt").val());
   

      if(prosamount == '' || funding_amt == '0')
      {

       
                                 $.wnoty({
                                        type: 'warning',
                                        message: "Oops! Input Amount.",
                                        autohideDelay: 5000
                                    });

                                    $('.abba_fund_wallet_btn').html('Proceed');
                                $('.abba_fund_wallet_btn').prop('disabled', false);

      }else
      {


                   var charge_percent = parseFloat(<?php echo $charge; ?>);
                    var charge_amt = (charge_percent / 100) * funding_amt;

                    if (charge_amt > 750) {
                        var final_amt_paying = funding_amt + 750;
                        var final_charge_amt = 750;
                    } else {
                        var final_amt_paying = charge_amt + funding_amt;
                        var final_charge_amt = charge_amt;
                    }

                    var UserID = '<?php echo $parentID; ?>';
                    var UserType = '<?php echo $UType; ?>';
                    var Transaction_Type = 'Credit';

                    var d = new Date();
                    var n = d.getTime();
                    var p = Math.floor((Math.random() * 100) + 1);
                    var referencenumber = "RX" + n + "-" + p;

                    MonnifySDK.initialize({
                        amount: final_amt_paying,
                        currency: "NGN",
                        reference: new String((new Date()).getTime()),
                        customerFullName: '<?php echo $ParentFirstName ; ?>',
                        customerEmail: '<?php echo $ParentEmail; ?>',
                        apiKey: "<?php echo $MonnifyLivePaymentApi; ?>",
                        contractCode: "<?php echo $MonnifyLiveContractCode; ?>",
                        paymentDescription: "Fund Wallet",
                        onLoadStart: () => {
                            console.log("loading has started");
                        },
                        onLoadComplete: () => {
                            console.log("SDK is UP");
                        },

                        onComplete: function (response) {
                            //Implement what happens when the transaction is completed.
                            // console.log(response);

                            var paymentStatus = response['paymentStatus'];
                            var status = response['status'];

                            if (status == 'FAILED') {
                                $.wnoty({
                                    type: 'warning',
                                    message: "Oops! Transaction FAILED.",
                                    autohideDelay: 5000
                                });

                                $('#fundwalletModal').modal('hide');

                                $('.abba_fund_wallet_btn').html('Proceed');
                                $('.abba_fund_wallet_btn').prop('disabled', false);
                            } else {
                                prosfundwalletcontent();
                            }
                        },
                        onClose: function (data) {
                            //Implement what should happen when the modal is closed here
                            // console.log(data);

                            var paymentStatus = data['paymentStatus'];
                            var status = data['status'];

                            if (paymentStatus == 'USER_CANCELLED') {
                                $.wnoty({
                                    type: 'warning',
                                    message: "Oops! Transaction Cancelled.",
                                    autohideDelay: 5000
                                });

                                $('#fundwalletModal').modal('hide');
                            } else {
                                if (status == 'SUCCESS') {
                                    // $.wnoty({
                                    //     type: 'success',
                                    //     message: "Great! Transaction Successful",
                                    //     autohideDelay: 5000
                                    // });
                                } else {
                                    $.wnoty({
                                        type: 'error',
                                        message: "Oops! Transaction failed please try again later.",
                                        autohideDelay: 5000
                                    });
                                }
                            }

                            $('#fundwalletModal').modal('hide');

                            $('.abba_fund_wallet_btn').html('Proceed');
                            $('.abba_fund_wallet_btn').prop('disabled', false);
                        }
                    });
        
      }
   
}




function prosfundwalletcontent() {

    var funding_amt = parseFloat($(".funding_amt").val());
    var charge_percent = parseFloat(<?php echo $charge; ?>);
    var charge_amt = (charge_percent / 100) * funding_amt;

    if (charge_amt > 750) {
        var final_amt_paying = funding_amt + 750;
        var final_charge_amt = 750;
    } else {
        var final_amt_paying = charge_amt + funding_amt;
        var final_charge_amt = charge_amt;
    }

    var UserID = '<?php echo $parentID; ?>';
    var UserType = '<?php echo $UType; ?>';
    var Transaction_Type = 'Credit';

    var d = new Date();
    var n = d.getTime();
    var p = Math.floor((Math.random() * 100) + 1);
    var referencenumber = "RX" + n + "-" + p;

    $.ajax({
        type: "POST",
        url: "../../controller/scripts/parent/wallet/abba_insert_transaction.php",
        data: { final_charge_amt: final_charge_amt, funding_amt: funding_amt, UserID: UserID, UserType: UserType, referencenumber: referencenumber, date: d, time: n, Transaction_Type: Transaction_Type },
        success: function (output) {

          

          
            if (output == '1') {
                $.wnoty({
                    type: 'success',
                    message: "Great! Transaction Successful",
                    autohideDelay: 5000
                });
            }

            abba_get_wallet_details();

            $('#fundwalletModal').modal('hide');

            $('.abba_fund_wallet_btn').html('Proceed');
            $('.abba_fund_wallet_btn').prop('disabled', false);
        }
    });
}





                




  

$(document).ready(function () {
var typingTimer;
var doneTypingInterval = 1500; // 1 second (adjust as needed)

$('.account_name').on('keyup', function () {
    clearTimeout(typingTimer);
    typingTimer = setTimeout(doneTyping, doneTypingInterval);
});



$('.account_name').on('keydown', function () {
    clearTimeout(typingTimer);
});

function doneTyping() {
    // The user has finished typing. You can perform your actions here.
    var account_number = $('.account_name').val();

    var bank_code = $('.bank_code option:selected').val();

    var numDigits = account_number.replace(/\D/g, "").length;

    if (numDigits === 10) {
        $('.account_user_name').html('<i class="fa fa-spinner fa-spin"></i>');

        var request = new XMLHttpRequest();

        var apiUrl = `https://api.monnify.com/api/v1/disbursements/account/validate?accountNumber=${account_number}&bankCode=${bank_code}`;

        request.open('GET', apiUrl);

        request.onreadystatechange = function () {
            if (this.readyState === 4) {
                if (this.status === 200) {
                    // console.log('Status:', this.status);
                    // console.log('Headers:', this.getAllResponseHeaders());

                    try {
                        var response = JSON.parse(this.responseText);
                        if (response.requestSuccessful) {
                            var accountNumber = response.responseBody.accountNumber;
                            var accountName = response.responseBody.accountName;
                            var bankCode = response.responseBody.bankCode;

                            $('.account_user_name').html(`<div class="mb-2" style="font-weight:600;"><i class="fas fa-user-circle text-primary" style="font-size:18px;"></i> <span class="account_holder_name">` + accountName + `</span></div>`);

                            // Now you can use accountNumber, accountName, and bankCode as needed
                            // console.log('Account Number:', accountNumber);
                            // console.log('Account Name:', accountName);
                            // console.log('Bank Code:', bankCode);
                        } else {
                            console.error('Request not successful:', response.responseMessage);

                            $('.account_user_name').val('Account Name Unavailable');
                        }
                    } catch (error) {
                        console.error('Error parsing JSON:', error);

                        $('.account_user_name').val('Account Name Unavailable');
                    }
                } else {
                    console.error('Request failed with status:', this.status);

                    $('.account_user_name').val('Account Name Unavailable');
                }
            }
        };

        request.send();

    }
    else {
        $('.account_user_name').val('Invalid Account Number');
    }
}
});


$('body').on('click', '.abba_transfer', function () {

        $('.abba_transfer').html('Transferring..<i class="fa fa-spinner fa-spin"></i>');
        $('.abba_transfer').prop('disabled', true);

        minnify_innitialization();

        var account_number = $('.account_name').val();

        // alert(account_number);

        var bank_code = $('.bank_code option:selected').val();

        var account_name = $('.account_holder_name').html();

        var transfer_amt = $('.transfer_amt').val();

        var narration = 'From - <?php echo $ParentFirstName . ' ' . $ParentLastName; ?>';

        var storedtoken = localStorage.getItem('storedtoken');

        var UserID = '<?php echo $parentID; ?>';

        var UserType = '<?php echo $UType; ?>';



        if (account_number == '' || account_number == 0 || bank_code == '' || bank_code == 0 || account_name == '' || account_name == 0 || transfer_amt == '' || transfer_amt == 0) {
            $.wnoty({
                type: 'error',
                message: "No field should be empty",
                autohideDelay: 5000
            });

            $('.abba_transfer').html('<i class="fas fa-exchange-alt"></i> Transfer');
            $('.abba_transfer').prop('disabled', false);

        }
        else {



            $.ajax({
                type: "POST",
                url: "../../controller/scripts/parent/wallet/abba_transfer_money.php",
                data: { account_number: account_number, bank_code: bank_code, account_name: account_name, transfer_amt: transfer_amt, storedtoken: storedtoken, narration: narration, UserID: UserID, UserType: UserType },
                success: function (output) {

                    

                if (output == 1) {

                    $('#set_transfer_pin_Modal').modal('show');
                    $('#withdrawModal').css('z-index', 1040);

                                                
                        var abba_modal = localStorage.getItem('pinstat');

                            if (abba_modal === '1') { // Use strict equality and compare with '1'
                                var OTPContainer = $("#abba-otp-input");
                                var OTPValueContainer = $("#abba-otp-value");
                                var inputs = OTPContainer.find("input:not(#abba-otp-value)");
                            } else {
                                var OTPContainer = $("#abba-enter-otp-input");
                                var OTPValueContainer = $("#abba-enter-otp-value");
                                var inputs = OTPContainer.find("input:not(#abba-enter-otp-value)");
                            }

                            // Convert the jQuery object to an array for better alert output



                                inputs.on("keyup", function (e) {
                                    handleKeyUp(e, $(this));
                                
                                });



                                            
                                    inputs.on("input", function () {
                                        handleInput($(this));
                                    });

                                    inputs.on("keydown", function (e) {
                                        handleKeyDown(e, $(this));
                                    });

                                    inputs.on("keyup", function (e) {
                                        handleKeyUp(e, $(this));
                                    });



                                    $('body').on('click', '.abba-pin-btn', function () {
                                    

                                        localStorage.setItem('pinstat', 1);

                                        $('.abba-pin-btn').html('Setting Pin..<i class="fa fa-spinner fa-spin"></i>');
                                        $('.abba-pin-btn').prop('disabled', true);
                                        
                                        // var otpValue = $("#abba-otp-value").val();
                                        var OTPContainer = $("#abba-otp-input");

                                        var otpValues = OTPContainer.find("input:lt(4)").map(function() {
                                                return $(this).val().trim();
                                            }).get();

                                            var isValid = otpValues.some(function(value) {
                                                return value == '';
                                            });

                                        

                                            if (isValid) {
                                                // At least one of the first four OTP fields is non-empty
                                                $('.abba-pin-btn').html('<i class="fas fa-key"></i> Set Pin');
                                                $('.abba-pin-btn').prop('disabled', false);

                                                $.wnoty({
                                                    type: 'warning',
                                                    message: "Input your four digits pin to proceed.",
                                                    autohideDelay: 5000
                                                });
                                            } else {

                                                            
                                                            $.ajax({
                                                                type: "POST",
                                                                url: "../../controller/scripts/parent/wallet/abba_inser_transaction_pin.php",
                                                                data: { UserID: UserID, UserType: UserType, otpValue: otpValues },
                                                                success: function (result) {
                                                            

                                                                    $('.abba-pin-btn').html('<i class="fas fa-key"></i> Set Pin');
                                                                    $('.abba-pin-btn').prop('disabled', false);

                                                                    $('#set_transfer_pin_Modal').modal('hide');
                                                                    $('#withdrawModal').css('z-index', 1050);

                                                                    $.wnoty({
                                                                        type: 'success',
                                                                        message: "Great, Pin Set Successfully",
                                                                        autohideDelay: 5000
                                                                    });


                                                                    $.ajax({
                                                                        type: "POST",
                                                                        url: "../../controller/scripts/parent/wallet/abba_transfer_money.php",
                                                                        data: { account_number: account_number, bank_code: bank_code, account_name: account_name, transfer_amt: transfer_amt, storedtoken: storedtoken, narration: narration, UserID: UserID, UserType: UserType },
                                                                        success: function (data) {

                                                                            if(data.trim() === 'success')
                                                                            {
                                                                                $.wnoty({
                                                                                    type: 'success',
                                                                                    message: "Transfer Successful",
                                                                                    autohideDelay: 5000
                                                                                });

                                                                                $('.abba_transfer').html('<i class="fas fa-exchange-alt"></i> Transfer');
                                                                                $('.abba_transfer').prop('disabled', false);
                                                                            }
                                                                            else{
                                                                                $.wnoty({
                                                                                    type: 'warning',
                                                                                    message: data,
                                                                                    autohideDelay: 5000
                                                                                });

                                                                                $('.abba_transfer').html('<i class="fas fa-exchange-alt"></i> Transfer');
                                                                                $('.abba_transfer').prop('disabled', false);
                                                                            }

                                                                        }
                                                                    });
                                                                }
                                                            });


                                            
                                            }
                                        

                                    });
                        
                    }
                    else {

                        localStorage.setItem('pinstat', 0);

                        $('#enter_transfer_pin_Modal').modal('show');
                        
                        $('#enter_transfer_pin_Modal').modal('hide');
                        $('#withdrawModal').css('z-index', 1050);


                        $('body').on('click', '.abba-enter-pin-btn', function () {

                            var otpValue = parseFloat($("#abba-enter-otp-value").val());
                            
                            var TransactionPin = parseFloat(<?php echo $TransactionPin; ?>);

                            if(otpValue === TransactionPin)
                            {
                                $('#enter_transfer_pin_Modal').modal('hide');
                                $('#withdrawModal').css('z-index', 1050);

                                $.ajax({
                                    type: "POST",
                                    url: "../../controller/scripts/parent/wallet/abba_transfer_money.php",
                                    data: { account_number: account_number, bank_code: bank_code, account_name: account_name, transfer_amt: transfer_amt, storedtoken: storedtoken, narration: narration, UserID: UserID, UserType: UserType },
                                    success: function (data) {
            
                                        if(data.trim() === 'success')
                                        {
                                            $.wnoty({
                                                type: 'success',
                                                message: "Transfer Successful",
                                                autohideDelay: 5000
                                            });

                                            $('.abba_transfer').html('<i class="fas fa-exchange-alt"></i> Transfer');
                                            $('.abba_transfer').prop('disabled', false);
                                        }
                                        else{
                                            $.wnoty({
                                                type: 'warning',
                                                message: data,
                                                autohideDelay: 5000
                                            });

                                            $('.abba_transfer').html('<i class="fas fa-exchange-alt"></i> Transfer');
                                            $('.abba_transfer').prop('disabled', false);
                                        }
                                        
                                        abba_get_wallet_details();

                                    }
                                });
                            }
                            else{

                                $.wnoty({
                                    type: 'error',
                                    message: 'Incorrect Pin',
                                    autohideDelay: 5000
                                });
                                
                            }
                        });

                    }

                    $('.abba_transfer').html('<i class="fas fa-exchange-alt"></i> Transfer');
                    $('.abba_transfer').prop('disabled', false);
                }

            });




           
        }

});






 // $(document).ready(function () {

    var abba_modal = localStorage.getItem('pinstat');

      

if(abba_modal === 1)
{
    var OTPContainer = $("#abba-otp-input");
    var OTPValueContainer = $("#abba-otp-value");
    var inputs = OTPContainer.find("input:not(#abba-otp-value)");

}
else{
    var OTPContainer = $("#abba-enter-otp-input");
    var OTPValueContainer = $("#abba-enter-otp-value");
    var inputs = OTPContainer.find("input:not(#abba-enter-otp-value)");

}

// Focus first input
const firstInput = inputs.first();
firstInput.focus();

inputs.on("input", function () {
    handleInput($(this));
});

inputs.on("keydown", function (e) {
    handleKeyDown(e, $(this));
});

inputs.on("keyup", function (e) {
    handleKeyUp(e, $(this));
});

inputs.on("focus", function () {
    $(this).select();
});

function updateValue(inputs) {
    const value = inputs.toArray().map(input => input.value ? input.value : "*").join("");
   
    OTPValueContainer.val(value);
}

function isValidInput(input) {
    return Number(input.val()) === 0 && input.val() !== "0" ? false : true;
}

function setInputValue(input, value) {
    input.val(value);
  

}

function resetInput(input) {
    setInputValue(input, "");
}

function focusNext(input) {
    const nextInput = input.next("input");
    if (nextInput.length > 0) {
        nextInput.focus().select();
    }
}

function focusPrev(input) {
    const prevInput = input.prev("input");
    if (prevInput.length > 0) {
        prevInput.focus().select();
    }
}

function handleValidMultiInput(input) {
    const inputLength = input.val().length;
    const curIndex = inputs.index(input);
    const endIndex = Math.min(curIndex + inputLength - 1, inputs.length - 1);
    const inputsToChange = inputs.slice(curIndex, endIndex + 1);
    inputsToChange.each(function (index) {
        setInputValue($(this), input.val()[index]);
    });
    focusPrev(inputs.eq(endIndex));
}

function handleInput(input) {
    if (!isValidInput(input)) {
        handleInvalidInput(input);
        return;
    }
    if (input.val().length === 1) {
        handleValidSingleInput(input);
    } else {
        handleValidMultiInput(input);
    }
    updateValue(inputs);
   
}

function handleValidSingleInput(input) {
    setInputValue(input, input.val().slice(-1));
    focusNext(input);
   
}

function handleInvalidInput(input) {
    resetInput(input);
}

function handleKeyDown(e, input) {
    const key = e.key;
    const curIndex = inputs.index(input);
    if (key === "Delete") {
        resetInput(input);
        focusPrev(input);
    }
    if (key === "ArrowLeft") {
        e.preventDefault();
        focusPrev(input);
    }
    if (key === "ArrowRight") {
        e.preventDefault();
        focusNext(input);
    }
}

function handleKeyUp(e, input) {
    const key = e.key;
    if (key === "Backspace") {
        focusPrev(input);
    }
}


$('body').on('click', '.pros_pay_fee_btn',function () {
             prosloadstudentfeepayemntcontent();      
            //  prosloadstudentfeepayterm();
});








$('body').on('keyup', '.prosamountforschfees', function () {
    var  proamountfield = $('.prosamountforschfees').val();

    if(proamountfield == '')
    {
          $('.pros_transfer_payfess-btn').prop('disabled', true);

    }else
    {
          $('.pros_transfer_payfess-btn').prop('disabled', false);
    }
   

});



//pros pay schhool fees btn 




$('body').on('click', '.pros_transfer_payfess-btn', function () {


           $('.pros_transfer_payfess-btn').html('Processing..<i class="fa fa-spinner fa-spin"></i>');

            var UserID = '<?php echo $parentID; ?>';
            var UserType = '<?php echo $UType; ?>';

           

           var amount = $('.prosamountforschfees').val();
          
           var term = $('.pros_term_input').val();
           var session = $('.pros_session_input').val();
          

           var paymentypeamount = $('.prosclassforeacpayementtype').val();
           var proscheckedpayementtype = $('.prosgeneralpaymenttypecheck:checked').val();

           

           var d = new Date();
            var n = d.getTime();
            var p = Math.floor((Math.random() * 100) + 1);
            var referencenumber = "RX" + n + "-" + p;


            





            var campusID = [];
            var studentID = [];
            var totalsalarytobepaid = [];
           
           


            $.each($('.proscheckedainputnamesalaryeach:checked'),function(){
                totalsalarytobepaid.push($(this).data('amount'));
                studentID.push($(this).val());
                campusID.push($(this).data('id'));
            });


           
              
            
            if(studentID == '' || studentID == '0' ||  studentID == 'NULL')
            {

                         $.wnoty({
                            type: 'warning',
                            message: 'Hey!! Select student to proceed with payment.',
                            autohideDelay: 5000
                        });


                        $('.pros_transfer_payfess-btn').html('<i class="fa fa-credit-card"></i> Pay Now');

            }else if(session == '' || session == '0' ||  session == 'NULL')
            {


                        $.wnoty({
                            type: 'warning',
                            message: 'Hey!! Select Session to proceed.',
                            autohideDelay: 5000
                        });


                        $('.pros_transfer_payfess-btn').html('<i class="fa fa-credit-card"></i> Pay Now');

            }else if(term == '' || term == '0' ||  term == 'NULL')
            {

                        $.wnoty({
                            type: 'warning',
                            message: 'Hey!! Select Term to proceed.',
                            autohideDelay: 5000
                        });


                        $('.pros_transfer_payfess-btn').html('<i class="fa fa-credit-card"></i> Pay Now');


            }else  if(parseInt(amount) > parseInt(paymentypeamount))
            {


                       $.wnoty({
                            type: 'warning',
                            message: 'Insufficient!! Seems Amount inputed is greater than what you have in your' +proscheckedpayementtype+'.',
                            autohideDelay: 5000
                        });


                        $('.pros_transfer_payfess-btn').html('<i class="fa fa-credit-card"></i> Pay Now');


            }
            
            else{
                      $('.pros_transfer_payfess-btn').prop('disabled', true);

                        $.ajax({
                            type: "POST",
                            url: "../../controller/scripts/parent/wallet/prospaystatudentfeewallet.php",
                            data: { 

                                    UserID:UserID,
                                    UserType:UserType,
                                    amount:amount,
                                    term:term,
                                    session:session,
                                    studentID:studentID,
                                    paymentypeamount:paymentypeamount,
                                    proscheckedpayementtype:proscheckedpayementtype,
                                    referencenumber:referencenumber,
                                    campusID:campusID,
                                    totalsalarytobepaid:totalsalarytobepaid
                            },
                            success: function (data) {
                                       

                                    $('.pros_transfer_payfess-btn').prop('disabled', false);
                                
                      


                                    $('.pros_transfer_payfess-btn').html('<i class="fa fa-credit-card"></i> Pay Now');

                                        if(data.trim() == '1'){


                                              $.wnoty({
                                                    type: 'success',
                                                    message: 'Great!! Transaction made successfully.',
                                                    autohideDelay: 5000
                                                });
                                               
                                        }else
                                        {

                                                    $.wnoty({
                                                            type: 'warning',
                                                            message: 'Hey!! Transaction was not successfull please try again',
                                                            autohideDelay: 5000
                                                        });
                                               

                                        }
                                    

                                        abba_get_wallet_details();
                                        prosloadstudentforpayemnt();
                                          prosloadpayementtypecontenthere();    

                                        
                            }
                        });



                

            }
            
           


            // ||



});









function prosloadstudentfeepayemntcontent()
{
   
                $('.prosloadparentstudentforpayement').html('<div align="center"> <i class="fa fa-spinner fa-spin fs-1" style="color:#007ffb;"></i></div>');

                var UserID = '<?php echo $parentID; ?>';
                var UserType = '<?php echo $UType; ?>';

               
                

                

                $('.pros_term_input').html('<option value="NULL">loading..</option>');

                $.ajax({
                    type: "POST",
                    url: "../../controller/scripts/parent/wallet/prosload-term-alias.php",
                    data: { 

                        UserID:UserID,
                        UserType:UserType,
                    },
                    success: function (data) {
                      
                        $('.pros_term_input').html(data);

                                
                    }
                });








}






$('body').on('click', '.propayfeemodalbtn', function() {

    prosloadpayementtypecontenthere();    
    prosloadpayementtypecontenthereschedule();  
    prosloadstudentforpayemnt();
    prosloadstudentforpayemnt_schedule();

   
});



$('body').on('change', '.prosgeneralpaymenttypecheck', function() {
    prosloadpayementtypecontenthere();    
});


$('body').on('change', '.prosgeneralpaymenttypecheck_schedule', function() {
    prosloadpayementtypecontenthereschedule();    
});







function prosloadpayementtypecontenthere()
{
      

    var UserID = '<?php echo $parentID; ?>';
    var UserType = '<?php echo $UType; ?>';
    var proscheckedpayementtype = $('.prosgeneralpaymenttypecheck:checked').val();


    $('.prosloadcontenttypeinstant').html('<i class="fa fa-spinner fa-spin"></i>');


    
        $.ajax({
                type: "POST",
                url: "../../controller/scripts/parent/wallet/pros-loadpayementtypecontent.php",
                data: {
                    UserID:UserID,
                    UserType:UserType,
                    proscheckedpayementtype:proscheckedpayementtype
                },
                success: function(output) {
                    


                            $('.prosloadcontenttypeinstant').html(output);
                }
        });



}



function prosloadpayementtypecontenthereschedule()
{
      

    var UserID = '<?php echo $parentID; ?>';
    var UserType = '<?php echo $UType; ?>';
    var proscheckedpayementtype = $('.prosgeneralpaymenttypecheck_schedule:checked').val();


    $('.prosloadcontenttypeinstant_schedule').html('<i class="fa fa-spinner fa-spin"></i>');


    
        $.ajax({
                type: "POST",
                url: "../../controller/scripts/parent/wallet/pros-loadpayementtypecontent.php",
                data: {
                    UserID:UserID,
                    UserType:UserType,
                    proscheckedpayementtype:proscheckedpayementtype
                },
                success: function(output) {



                            $('.prosloadcontenttypeinstant_schedule').html(output);
                }
        });



}


//PROS SCHEDULE FEE TOBE PAID 

        $('body').on('click', '.pros_transfer_prosschedule', function() {
            
            $('.pros_transfer_prosschedule').html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> <span class="visually-hidden">Loading...</span>');


            var monthschedule = $('.prosstartamountmonth-scheule').val();
            var datteshedule = $('.schedulepaymentdate').val();
            var amount = $('.pros_general_schedule_input_amount').val();
           


            var UserID = '<?php echo $parentID; ?>';
            var UserType = '<?php echo $UType; ?>';


   
            var paymentypeamount = $('.prosclassforeacpayementtype').val();

            var proscheckedpayementtype = $('.prosgeneralpaymenttypecheck_schedule').val();



            
                                       
            var campusID = [];
            var studentID = [];
            var totalsalarytobepaid = [];
            var studentname = [];
           
            


            $.each($('.proscheckedainputnamesalaryeach_schedule:checked'),function(){
                totalsalarytobepaid.push($(this).data('amount'));
                studentID.push($(this).val());
                campusID.push($(this).data('id'));
                studentname.push($(this).data('studname'));
            });

            
           

                // Validate inputs
        if (monthschedule == '' || datteshedule == '' || amount == '') {


                    $.wnoty({
                        type: 'warning',
                        message: 'Hey!! Make sure no field is left blank.',
                        autohideDelay: 5000
                    });
                    $('.pros_transfer_prosschedule').html('<i class="fa fa-save"></i> Schedule Now');

        }else if(studentID == '' || studentID == '0' || studentID == 'NULL')
        {

                   $.wnoty({
                        type: 'warning',
                        message: 'Hey!! Select the student you want to schedule payment for.',
                        autohideDelay: 5000
                    });

                    $('.pros_transfer_prosschedule').html('<i class="fa fa-save"></i> Schedule Now');

        }
        
        else  if(parseInt(amount) > parseInt(paymentypeamount))
         {

                           $.wnoty({
                                type: 'warning',
                                message: 'Insufficient!! Seems Amount inputed is greater than what you have in your' +proscheckedpayementtype+'.',
                                autohideDelay: 5000
                            });


                            $('.pros_transfer_prosschedule').html('<i class="fas fa-save"></i> Schedule Now');

        }else
        {


            $('.pros_transfer_prosschedule').prop('disabled', true);
           
                 
                $.ajax({
                        type: "POST",
                        url: "../../controller/scripts/parent/wallet/pros_proceeed_scheedule_salary.php",
                        data: {
                            
                                monthschedule:monthschedule,
                                datteshedule:datteshedule,
                                UserID:UserID,
                                UserType:UserType,
                                paymentypeamount:paymentypeamount,
                                proscheckedpayementtype:proscheckedpayementtype,
                                amount:amount,
                                campusID:campusID,
                                 studentID:studentID,
                                 studentname:studentname
                        },
                        success: function(output) {

                               

                            $('.pros_transfer_prosschedule').prop('disabled', false);

                                   $('.pros_transfer_prosschedule').html('<i class="fas fa-save"></i> Schedule Now');


                           
                                   if(output.trim() == '1')
                                   {




                                         $.wnoty({
                                            type: 'success',
                                            message: 'Great!! Fees Scheduled Successfullys.',
                                            autohideDelay: 5000
                                        });




                                   }else if(output.trim() == '2')
                                   {


                                             $.wnoty({
                                                    type: 'warning',
                                                    message: 'Hey!! Seems fee has been for the Date and Month selected already.',
                                                    autohideDelay: 5000
                                                });

                                   }
                                   
                                   else{


                                          $.wnoty({
                                                type: 'warning',
                                                message: 'Hey!! Fee failed to be Scheduled Successfully.',
                                                autohideDelay: 5000
                                            });


                                   }


                                    
                        }
                });

        }               

            

        });

//PROS SCHEDULE FEE TOBE PAID 
















//SAVING PLAN CONTENT HERE







$('body').on('click', '.pros_transfer_prossavebtn', function() {
    $('.pros_transfer_prossavebtn').html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> <span class="visually-hidden">Loading...</span>');

    // Retrieve the values
    var prossavititle_title = $('.prossavingplan_dessave').val();
    var Amount = $('.proscollectamountname').val();
    var Datenew = $('.prosgetsave_end_date').val();
    var datastatus = $(this).data('id');


    var UserID = '<?php echo $parentID; ?>';
    var UserType = '<?php echo $UType; ?>';




    
 
            

    
    

    // Validate inputs
    if (prossavititle_title == '' || Amount == '' || Datenew == '') {


        $.wnoty({
            type: 'warning',
            message: 'Hey!! Make sure no field is left blank.',
            autohideDelay: 5000
        });
        
        $('.pros_transfer_prossavebtn').html('<i class="fa fa-save"></i> Save Now');

    }

    else {


                 var amount_new  = parseInt(Amount);
            //    var staffamount  = parseInt(prostaffamountall);

       


             
                 $('.pros_transfer_prossavebtn').prop('disabled', true);

                    $.ajax({
                        type: "POST",
                        url: "../../controller/scripts/parent/wallet/pros-savefunds-edumess.php",
                        data: {
                            prossavititle_title: prossavititle_title,
                            Amount: Amount,
                            Date: Datenew,
                            UserID:UserID,
                            UserType:UserType,
                            datastatus:datastatus
                        },
                        success: function(output) {

                             
                        
                            $('.pros_transfer_prossavebtn').prop('disabled', false);
                            $('.pros_transfer_prossavebtn').html('<i class="fa fa-save"></i> Save Now');

                            if(output.trim() == '1')
                            {

                                        $.wnoty({
                                            type: 'success',
                                            message: 'Great!! ' + prossavititle_title + 'saved successfully',
                                            autohideDelay: 5000
                                        });

                                        prosloadsavescontent();
                                        abba_get_wallet_details();

                            }else if(output.trim() == '2')
                            {


                                        $.wnoty({
                                            type: 'warning',
                                            message: 'Hey!!  this plan has been set for this month by you already',
                                            autohideDelay: 5000
                                        });


                            }else if(output.trim() == '3')
                            {

                                         $.wnoty({
                                            type: 'warning',
                                            message: 'Insuficient Funds!! Fund your wallet to proceed with saving',
                                            autohideDelay: 5000
                                        });

                            }
                        

                            
                    
                        }
                    });



        

       
    }
});






$(document).ready(function () {
    prosloadsavescontent();
    prosloadsavescontentlock();
});




function prosloadsavescontent(){




    var UserID = '<?php echo $parentID; ?>';
    var UserType = '<?php echo $UType; ?>';

 $('.prosloadsavenspincont').html('<i class="fa fa-spinner fa-spin"></i>');



 $.ajax({
        type: "POST",
        url: "../../controller/scripts/parent/wallet/pros-loadsave-edumess.php",
        data: {
            UserID:UserID,
            UserType:UserType
        },
        success: function(output) {

                    $('.prosloadsavenspincont').html(output);
        }
 });



}

//SAVING PLAN CONTENT HERE








//LOCKING PLAN CONTENT HERE





//LOCKING PLAN CONTENT HERE


$('body').on('click', '.pros_transfer_proslockbtn', function() {
    $('.pros_transfer_proslockbtn').html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> <span class="visually-hidden">Loading...</span>');

    // Retrieve the values
    var prossavititle_title = $('.proslockplan_deslock').val();
    var Amount = $('.proscollectamountnamelock').val();
    var Datenew = $('.prosgetlock_end_date').val();
    var datastatus = $(this).data('id');


    var UserID = '<?php echo $parentID; ?>';
    var UserType = '<?php echo $UType; ?>';;



     var prostaffamountall = $('.prosloadsalaybulkamount_schedule').val();
 



    
    

    // Validate inputs
    if (prossavititle_title == '' || Amount == '' || Datenew == '') {


        $.wnoty({
            type: 'warning',
            message: 'Hey!! Make sure no field is left blank.',
            autohideDelay: 5000
        });
        $('.pros_transfer_proslockbtn').html('<i class="fas fa-block"></i> Lock Now');

    } else {


      var amount_new  = parseInt(Amount);
      var staffamount  = parseInt(prostaffamountall);

       


             
                 $('.pros_transfer_proslockbtn').prop('disabled', true);

                    $.ajax({
                        type: "POST",
                        url: "../../controller/scripts/parent/wallet/pros-savefunds-edumess.php",
                        data: {
                            prossavititle_title: prossavititle_title,
                            Amount: Amount,
                            Date: Datenew,
                            UserID:UserID,
                            UserType:UserType,
                            datastatus:datastatus
                        },
                        success: function(output) {


                           
                        
                            $('.pros_transfer_proslockbtn').prop('disabled', false);
                            $('.pros_transfer_proslockbtn').html('<i class="fas fa-lock"></i> Lock Now');

                            if(output.trim() == '1')
                            {

                                        $.wnoty({
                                            type: 'success',
                                            message: 'Great!! ' + prossavititle_title + 'saved successfully',
                                            autohideDelay: 5000
                                        });

                                        prosloadsavescontentlock();
                                        abba_get_wallet_details();

                            }else if(output.trim() == '2')
                            {


                                        $.wnoty({
                                            type: 'warning',
                                            message: 'Hey!!  this plan has been set for this month by you already',
                                            autohideDelay: 5000
                                        });


                            }else if(output.trim() == '3')
                            {

                                         $.wnoty({
                                            type: 'warning',
                                            message: 'Insuficient Funds!! Fund your wallet to proceed with saving',
                                            autohideDelay: 5000
                                        });

                            }
                        

                            
                    
                        }
                    });

       
    }
});



function prosloadsavescontentlock(){




    var UserID = '<?php echo $parentID; ?>';
    var UserType = '<?php echo $UType; ?>';


 $('.prosloadsavenspincontlock').html('<i class="fa fa-spinner fa-spin"></i>');



 $.ajax({
        type: "POST",
        url: "../../controller/scripts/parent/wallet/pros-loadlock-edumess.php",
        data: {
            UserID:UserID,
            UserType:UserType
        },
        success: function(output) {

                    $('.prosloadsavenspincontlock').html(output);
        }
 });



}



//PROS LOAD RECEIPT CONTENT HERE

    $('body').on('click', '.prosprintreseceict-transctionbtn', function() {

            var UserID = '<?php echo $parentID; ?>';
            var UserType = '<?php echo $UType; ?>';
            var ReceiptID = $(this).data('id');


            $('#prosloadreceiiptcontenthere').html('<i class="fa fa-spinner fa-spin"></i>');

            $.ajax({
                type: "POST",
                url: "../../controller/scripts/parent/wallet/prosloadreceiptcontethere.php",
                data: {
                    UserID:UserID,
                    UserType:UserType,
                    ReceiptID:ReceiptID
                },
                success: function(output) {
                            $('#prosloadreceiiptcontenthere').html(output);
                            
                }
            });

        
    });
//PROS LOAD RECEIPT CONTENT HERE
   

    


    $('body').on('click', '.pros-print-receiptcontent-btn', function() {
            const element = document.getElementById("prosloadreceiptcontprin");
                // Choose the element and save the PDF for your user.
                html2pdf().from(element).save();

    });




    $('body').on('click', '.prossharereceptcontentbtn', function() {
        const element = document.getElementById("prosloadreceiptcontprin");
                const pdfInstance = html2pdf();

                // Generate the PDF from the specified element
                pdfInstance.from(element).outputPdf().then(pdf => {
                    // Create a Blob from the PDF data
                    const pdfBlob = new Blob([pdf], { type: 'application/pdf' });

                    // Create a FormData object and append the PDF Blob
                    const formData = new FormData();
                    formData.append('file', pdfBlob, 'receipt.pdf');

                    // Create a URL for the PDF Blob
                    const pdfUrl = URL.createObjectURL(pdfBlob);

                    // Create a link for sharing the PDF (e.g., a download link)
                    const downloadLink = document.createElement('a');
                    downloadLink.href = pdfUrl;
                    downloadLink.download = 'receipt.pdf';

          

              

                    // Add the link to the document
                        document.body.appendChild(downloadLink);

                        // Trigger a click on the link to initiate the download
                        downloadLink.click();


                        // Optionally, you can open WhatsApp with a pre-filled message containing the PDF download link
                        const whatsappLink = `whatsapp://send?text=Here is your receipt: ${window.location.origin}/path/to/receipts/receipt.pdf`;
                        window.location.href = whatsappLink;
                    });

    });



    //get student paying for school here #


    function  prosloadstudentforpayemnt()
    {


              var UserID = '<?php echo $parentID; ?>';
              var UserType = '<?php echo $UType; ?>';
              var session = $('.pros_session_input').val();
              var statustype  = 'instant';



              $('#prosloadstudentconforfeehere').html('<i class="fa fa-spinner fa-spin"></i>');

            $.ajax({
                type: "POST",
                url: "../../controller/scripts/parent/wallet/prosloaadfeeforcontent.php",
                data: {

                    UserID:UserID,
                    UserType:UserType,
                    session:session,
                    statustype:statustype
                },
                success: function(output) {
                            $('#prosloadstudentconforfeehere').html(output);
                            
                }
            });
                    



    }



    //load stuent fee for shedule payment
    function  prosloadstudentforpayemnt_schedule()
    {


              var UserID = '<?php echo $parentID; ?>';
              var UserType = '<?php echo $UType; ?>';
              var statustype  = 'schedule';



              $('#prosloadstudentconforfeehere_schedule').html('<i class="fa fa-spinner fa-spin"></i>');

            $.ajax({
                type: "POST",
                url: "../../controller/scripts/parent/wallet/prosloaadfeeforcontent.php",
                data: {

                    UserID:UserID,
                    UserType:UserType,
                    statustype:statustype
                },
                success: function(output) {
                            $('#prosloadstudentconforfeehere_schedule').html(output);
                            
                }
            });
                    



    }//load stuent fee for shedule payment
    




 //check all student for instant payment

    $('body').on('change', '.prosselectallcheckedall', function() {

        var checkStatus = $(this).prop('checked');


            if(checkStatus == true)
            {
                $(".proscheckedainputnamesalaryeach").prop('checked', $(this).prop("checked"));
            

                    var totalsalarytobepaid = [];
                        $.each($('.proscheckedainputnamesalaryeach:checked'),function(){
                            totalsalarytobepaid.push($(this).data('amount'));
                        });
                        
                        
                        var total = 0;

                        for (var i in totalsalarytobepaid) {
                                    total += totalsalarytobepaid[i];
                        }
                    

                        $('.prosloadsalaybulkamount_inititated').val(total);

                        if(total == '0')
                        {
                            var grandtotal =  '0.00';
                        }else
                        {
                            var grandtotal =  total.toLocaleString("en-US");
                        }
                    

                        
        
            }
            else if(checkStatus == false)
            {

                $(".proscheckedainputnamesalaryeach").prop('checked', false);
                var grandtotal =  '0.00';

                $('.prosloadsalaybulkamount_inititated').val(0);
            }
        
            $('.prosloadamountcontent').html(grandtotal);




});
//check all student for instant payment






//check all student for schedule  payment

$('body').on('change', '.prosselectallcheckedall_schedule', function() {

var checkStatus = $(this).prop('checked');


    if(checkStatus == true)
    {
        $(".proscheckedainputnamesalaryeach_schedule").prop('checked', $(this).prop("checked"));
    

            var totalsalarytobepaid = [];
                $.each($('.proscheckedainputnamesalaryeach_schedule:checked'),function(){
                    totalsalarytobepaid.push($(this).data('amount'));
                });
                
                
                var total = 0;

                for (var i in totalsalarytobepaid) {
                            total += totalsalarytobepaid[i];
                }
            

                $('.prosloadsalaybulkamount_inititated_schedule').val(total);

                if(total == '0')
                {
                    var grandtotal =  '0.00';
                }else
                {
                    var grandtotal =  total.toLocaleString("en-US");
                }
            

                

    }
    else if(checkStatus == false)
    {

        $(".proscheckedainputnamesalaryeach_schedule").prop('checked', false);
        var grandtotal =  '0.00';

        $('.prosloadsalaybulkamount_inititated_schedule').val(0);
    }

    $('.prosloadamountcontent_schedule').html(grandtotal);





});
//check all student for schedule payment




//check single student for instant  payment

$('body').on('change', '.proscheckedainputnamesalaryeach', function() {
    if ($('.proscheckedainputnamesalaryeach:checked').length === $('.proscheckedainputnamesalaryeach').length) {
    
        $(".prosselectallcheckedall").prop('checked', true);
        var selTotalSingle = $('.proscheckedainputnamesalaryeach:checked').length;
        
    } else {
        $(".prosselectallcheckedall").prop('checked', false);

        var selTotalSingle = $('.proscheckedainputnamesalaryeach:checked').length;

    }


        var totalsalarytobepaid = [];
        $.each($('.proscheckedainputnamesalaryeach:checked'),function(){
            totalsalarytobepaid.push($(this).data('amount'));
        });
    
        
        var total = 0;

        for (var i in totalsalarytobepaid) {
                    total += totalsalarytobepaid[i];
        }

        $('.prosloadsalaybulkamount_inititated').val(total);

            if(total == '0')
            {
                var grandtotal =  '0.00';

            }else
            {
                var grandtotal =  total.toLocaleString("en-US");
            }

    $('.prosloadamountcontent').html(grandtotal);
});
//check single student for instant  payment




//check single student for schedule  payment

$('body').on('change', '.proscheckedainputnamesalaryeach_schedule', function() {
    if ($('.proscheckedainputnamesalaryeach_schedule:checked').length === $('.proscheckedainputnamesalaryeach_schedule').length) {
    
        $(".prosselectallcheckedall").prop('checked', true);
        var selTotalSingle = $('.proscheckedainputnamesalaryeach_schedule:checked').length;
        
    } else {
        $(".prosselectallcheckedall_schedule").prop('checked', false);

        var selTotalSingle = $('.proscheckedainputnamesalaryeach_schedule:checked').length;

    }


        var totalsalarytobepaid = [];
        $.each($('.proscheckedainputnamesalaryeach_schedule:checked'),function(){
            totalsalarytobepaid.push($(this).data('amount'));
        });
    
        
        var total = 0;

        for (var i in totalsalarytobepaid) {
                    total += totalsalarytobepaid[i];
        }

        $('.prosloadsalaybulkamount_inititated_schedule').val(total);

            if(total == '0')
            {
                var grandtotal =  '0.00';

            }else
            {
                var grandtotal =  total.toLocaleString("en-US");
            }

    $('.prosloadamountcontent_schedule').html(grandtotal);
});
//check single student for schedule  payment






</script>