<script>



    $(document).ready(function () {

        var WhatsappNumber = window.intlTelInput(document.querySelector("#WhatsappNumber"), {
            separateDialCode: true,
            preferredCountries: ["ng"],
            hiddenInput: "full",
            utilsScript: "//cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.3/js/utils.js"
        });
        
        
        var WhatsappNumbermain = window.intlTelInput(document.querySelector("#WhatsappNumbermain"), {
            separateDialCode: true,
            preferredCountries: ["ng"],
            hiddenInput: "full",
            utilsScript: "//cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.3/js/utils.js"
        });


        // GET LOAD COUNTRY INTO STATE

        var country = $('#parentcountry').val();
        var dataString = '&country=' + country;

        $('#parentstate').html('<option value="0">Loading...</option>');

        $.ajax({
            type: "POST",
            url: "../controller/scripts/website/get-state-admisssion.php",
            data: dataString,
            success: function (result) {
                $('#parentstate').html(result);

            }
        });


        $("body").on('change', "#parentcountry", function () {
            var country = $(this).val();
            var countdataid = $(this).data('id');
            var dataString = '&country=' + country;

            $('#parentstate').html('<option value="0">Loading...</option>');

            $.ajax({
                type: "POST",
                url: "../controller/scripts/website/get-state-admisssion.php",
                data: dataString,

                success: function (result) {

                    $('#parentstate').html(result);
                }
            });
        });
        //GET LOAD COUNTRY INTO STATE




        // select LGA base on state selected 
        $("body").on("change", "#parentstate", function () {

            var state = $(this).val();
            var dataString = '&state=' + state;

            $('#parentlga').html('<option value="0">Loading...</option>');

            $.ajax({
                type: "POST",
                url: "../controller/scripts/website/get-local-govenrment-amission.php",
                data: dataString,
                success: function (result) {
                    $('#parentlga').html(result);
                }
            });
        });
    });
    // select LGA base on state selected 


    //ADD NEW CHILDREEN
    $("body").on("click", "#pros-addnew-childbtn", function () {

        var numappended = $("#appendinput").val();
        numappended++;
        var numofcampus = numappended + 1;
        



      
        var appenamissionchildren = '<div  id="pros-campuscontainer' + numappended + '"><br><div class="row" style="margin: 25px;"><div class="col-10"></div><div class="col-2"><span class="fa fa-close removecampusbtn " style="color:red;cursor:pointer;"  data-id="pros-campuscontainer' + numappended + '"  data-camcnt="' + numofcampus + '">Remove</span></div><div class="col-12 mb-2"><div class="form-floating ">' +
            '<select class="form-select generalcampus" style="font-size: 13px; height: 53px;border: none; border-bottom: #b3b3b3 solid 1px;" id="selectcampus' + numappended + '"  data-id="'+numappended+'" aria-label="Floating label select example"><option value="0"  data-amount="0" data-status="0">select campus</option>' +
                             
                             <?php
                             
                             $selectcampusnew = mysqli_query($link, "SELECT DISTINCT `admissionclass`.`CampusID`, campus.CampusName, `admissionclass`.`PaymentAmount`, `admissionclass`.`PaymentStatus` FROM `campus` INNER JOIN `admissionclass` ON `campus`.`CampusID` = `admissionclass`.`CampusID` WHERE campus.InstitutionID='$GroupOfSchoolID' ORDER BY campus.CampusName ASC");
                             $selectcampuscntnew = mysqli_num_rows($selectcampusnew);
                             $selectcampuscntrownew = mysqli_fetch_assoc($selectcampusnew);

                             if ($selectcampuscntnew > 0) {
                                 do {
                                     $campusIDnew = $selectcampuscntrownew['CampusID'];
                                     $campusnamenew = $selectcampuscntrownew['CampusName'];
                                     $paymentamountnew = $selectcampuscntrownew['PaymentAmount'];
                                     $PaymentStatusnew = $selectcampuscntrownew['PaymentStatus'];



                                     $escapedStrcampus = htmlspecialchars($campusnamenew, ENT_QUOTES, 'UTF-8');
                                     ?>
                            '<option value="<?php echo $campusIDnew ?>" data-amount="<?php echo $paymentamountnew; ?>" data-status="<?php echo $PaymentStatusnew; ?>"><?php echo $escapedStrcampus; ?></option>' +    
                                                                                                                            <?php


                                 } while ($selectcampuscntrownew = mysqli_fetch_assoc($selectcampusnew));

                             } else {

                                 echo '<option value="0">No appliaction set for any campus</option>';
                             }
                             
                             ?>
            '</select><label for="floatingSelect">Select campus*</label></div></div> <div class="col-12 mb-2"><div class="form-floating "><select class="form-select generalclassname" style="font-size: 13px; height: 53px;border: none; border-bottom: #b3b3b3 solid 1px;" id="prosclassname' + numappended + '" data-id="' + numappended + '" aria-label="Floating label select example">' +
            '<option value="0" data-amount="0" data-status="">select class</option></select>' +
            '<label for="floatingSelect">Select Class*</label></div></div>' +
            '<div class="col-12"><div class="form-floating mb-3"><input type="text" style="height: 50px; border: none; border-bottom: #b3b3b3 solid 1px;" class="form-control form-control-sm generalstudenfirsname" id="studentnameid' + numappended + '" data-id="' + numappended + '" placeholder="name">' +
            '<label for="floatingInput" style="color: #afafaf; margin-top: 2px; font-weight: 500;">First Name*</label>' +
            '</div></div><div class="col-6"><div class="form-floating mb-3"><input type="text" style="height: 50px; border: none; border-bottom: #b3b3b3 solid 1px;" class="form-control form-control-sm generalstudensecondname" id="studentnameidmiddle' + numappended + '" data-id="' + numappended + '"  placeholder="name"><label for="floatingInput" style="color: #afafaf; margin-top: 2px; font-weight: 500;">Middle Name*</label>' +
            '</div> </div><div class="col-6"><div class="form-floating mb-3"><input type="text" style="height: 50px; border: none; border-bottom: #b3b3b3 solid 1px;" class="form-control form-control-sm generalstudenlastname" id="studentnameidlast' + numappended + '" data-id="' + numappended + '" placeholder="name"><label for="floatingInput" style="color: #afafaf; margin-top: 2px; font-weight: 500;">Last Name*</label>' +
            '</div></div><div class="col-6"><div style="color: #afafaf; font-weight: 500;">Gender*</div><div class="form-check form-check-inline" style="margin-top: 15px;"><input class="form-check-input generalstudengender" type="radio" name="inlineRadioOptions' + numappended + '" id="studentidgender1' + numappended + '" data-id="' + numappended + '" value="Male">' +
            '<label class="form-check-label" for="studentidgender1' + numappended + '">Male</label></div><div class="form-check form-check-inline"><input class="form-check-input generalstudengender" type="radio" name="inlineRadioOptions' + numappended + '" id="studentidgender2' + numappended + '" data-id="' + numappended + '" value="Female">' +
            '<label class="form-check-label" for="studentidgender2' + numappended + '">Female</label></div></div> <div class="col-6"><div>' +
            '<label for="exampleFormControlInput1" style="color: #afafaf; font-weight: 500;" class="form-label">DOB</label>' +
            '<input type="date" style="height: 40px; border: none; border-bottom: #b3b3b3 solid 1px;"  class="form-control geraldobclass" id="dateofbirthid' + numappended + '" data-id="' + numappended + '" >' +
            '</div></div></div></div>';


        $(document.createElement('div')).append(appenamissionchildren).appendTo('#prosperdisplaychildrenhere');
        $("#appendinput").val(numappended);


    });
    //ADD NEW CHILDREEN




    //remove appended input here
    $('body').on('click', '.removecampusbtn', function (e) {

        e.preventDefault();
        var dividd = $(this).data('id');

        var camcnt = 1;
        $('#' + dividd).remove();
        var numappended = $("#appendinput").val();

        // $('#' + camcnt).html(numappended);
        numappended--;
        $("#appendinput").val(numappended);
        
        
                
         var amounttotal = [];

        $.each($('.generalclassname').find('option:selected'), function () {
            amounttotal.push($(this).data('amount'));
        });



        var total = 0;

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


       
        if (total == '' || total == 0) {
            $('#displaytotalamt').html('');
            $('#prosadmissionamounthere').val(0);
            $('#prosdisplayamountinthebutton').html('');
        }
        else {
            let percentecntage = total.toLocaleString("en-US");
            $('#displaytotalamt').html('<p class="textmuted fw-bold  mb-0"  style="font-size:12px;">Total FEE</p><span class="h5  d-flex"> ₦ <span class="textmuted" >' + percentecntage + '</span></span> ');
            $('#prosadmissionamounthere').val(total);

            $('#prosdisplayamountinthebutton').html('<i class="fa fa-long-arrow-right"></i>  ₦' + percentecntage);

        }        
                    
        



    });
    //remove appended input 



    //load classes for each campus here
    
    $(document).ready(function() {
    $('body').on('change', '.generalcampus', function (e) {

        var campusID = $(this).val();
        var campusData = $(this).data('id');

    
     
       


        $('#prosclassname' + campusData).html('<option value="0">loading...</option>');

        $.ajax({
            type: "POST",
            url: "../controller/scripts/website/prosloadadmissionclasses.php",
            data: { campusID: campusID },
            success: function (result) {
                $('#prosclassname' + campusData).html(result);
            }
        });
    });
    });
    //load classes for each campus here


    $('body').on('change', '.generalclassname', function (e) {

        // var Status = $('option:selected', this).data('status');
        // var Amount = $('option:selected', this).data('amount');


        
        var amounttotal = [];

        $.each($('.generalclassname').find('option:selected'), function () {
            amounttotal.push($(this).data('amount'));
        });
        
        
     

        var total = 0;

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

       
        if (total == '' || total == 0) {
            
            $('#displaytotalamt').html('');
            $('#prosadmissionamounthere').val(0);
            $('#prosdisplayamountinthebutton').html('');
            
        }
        else {
            
            let percentecntage = total.toLocaleString("en-US");
            
            $('#displaytotalamt').html('<p class="textmuted fw-bold  mb-0"  style="font-size:12px;">Total FEE</p><span class="h5  d-flex"> ₦ <span class="textmuted" >' + percentecntage + '</span></span> ');
            $('#prosadmissionamounthere').val(total);

            $('#prosdisplayamountinthebutton').html('<i class="fa fa-long-arrow-right"></i>  ₦' + percentecntage);

        }



    });
    

        


    $('body').on('click', '.pros-submitapplication', function (e) {
        prossubmittenapplicationfinal();

    });


    function prossubmittenapplicationfinal() {
        
        $('.pros-submitapplication').html('<i class="fa fa-circle-o-notch fa-spin"></i>..submitting');

        $('.pros-submitapplication').prop('disabled', true);

        var parent_firstname = $('#parentfirtname').val();
        var parent_middlename = $('#parentmiddlename').val();
        var parent_lastname = $('#parentlname').val();
        var phone_no = $('#WhatsappNumber').val();
         var phone_no_mainwa = $('#WhatsappNumbermain').val();
        var email = $('#parentemail').val();
        var country = $('#parentcountry').val();
        var state = $('#parentstate').val();
        var lga = $('#parentlga').val();
        var cityorigin = $('#parentcity').val();
        var parentaddress = $('#parentaddress').val();
        var emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;

        var numappended = $("#appendinput").val();

        

        var session = '<?php  echo $Session; ?>';
        var term = $('#prosloadtermforregisteration').val();
        var GroupofSchool = '<?php echo $GroupOfSchoolID ; ?>';


       

        var amountopay = parseFloat($("#prosadmissionamounthere").val());

        var input = document.getElementById('WhatsappNumber');
        var iti = window.intlTelInputGlobals.getInstance(input);
        var numberFormat = input.value;
        
         var inputwanum = document.getElementById('WhatsappNumbermain');
        var itiwanum = window.intlTelInputGlobals.getInstance(inputwanum);
        var numberFormatwanum = inputwanum.value;
        
        
        var WhatsappNumberfull = intlTelInputUtils.formatNumber(numberFormat, iti.getSelectedCountryData().iso2);


            
           
        var WhatsappNumberfullmainwanum = intlTelInputUtils.formatNumber(numberFormatwanum, itiwanum.getSelectedCountryData().iso2);

            



        var studentinstitution = [];

        $('.generalcampus').each(function () {
            studentinstitution.push($(this).val());

            var studcampudata = $(this).data('id');
            var studcampudatavalid = $('#selectcampus' + studcampudata).val();

            if (studcampudatavalid == '' || studcampudatavalid == '0') {
                $('#selectcampus' + studcampudata).css('outline', '1px solid red');

                

            }
            else {
                $('#selectcampus' + studcampudata).css('outline', '1px solid green');
            }
        });



            // $charge = floatval($row_edumesspaymentcharges['ChargeAmount']);
            // $Cap = floatval($row_edumesspaymentcharges['Cap']);
            // $StampDuty = floatval($row_edumesspaymentcharges['StampDuty']);



                

            var student_class = [];
        
            var amounttotal = [];
            var edumesscharge = [];
            var vat_by_gov = [];
            var student_classcharge = [];
      
      
         var percentagenew = <?php echo $charge; ?>;
          var Capnew = <?php echo $Cap; ?>;
         
          var Vatnew = <?php echo $StampDuty; ?>;
      

        $.each($('.generalclassname'), function () {
            
            
             student_class.push($(this).val());
            //  vat_by_gov edumesscharge

            var datagotten = $(this).data('id');
            var valuegotten = $(this).val();
            
           
              
              
               // amounttotal.push($(this).data('amount'));
                        
            
                     var prostitotalchargeamount =  $(this).find(':selected').data('amount');
                     
                     
            
               

                    // Calculate charge amount
                    var chargeAmount = ((parseFloat(percentagenew) + parseFloat(Vatnew)) / 100) * parseFloat(prostitotalchargeamount);
                    
                    // Calculate VAT amount
                    var vatAmount = (parseFloat(Vatnew) / 100) * parseFloat(prostitotalchargeamount);
                    
                    
                    if (chargeAmount > Cap) {
                        var overallTotalAmount = Capnew + parseFloat(prostitotalchargeamount);
                        var finalChargeAmount = Capnew;
                    } else {
                        var overallTotalAmount = chargeAmount + parseFloat(prostitotalchargeamount);
                        var finalChargeAmount = chargeAmount;
                    }
            
            
             
          
            
                   amounttotal.push(overallTotalAmount);
                   edumesscharge.push(finalChargeAmount);
                   vat_by_gov.push(vatAmount);
                    student_classcharge.push(prostitotalchargeamount);
                   
                 


            if (valuegotten == '' || valuegotten == '0') {
                
                
                $('#prosclassname' + datagotten).css('outline', '1px solid red');


            }
            else {
                $('#prosclassname' + datagotten).css('outline', '1px solid green');
                $('.pros-submitapplication').html('Submit');
            }

        });
        
        
        
                 


        var childFirstName = [];
        $.each($('.generalstudenfirsname'), function () {

            childFirstName.push($(this).val());
            var Firstnamecheck = $(this).val();
            var Firstnamecheckid = $(this).data('id');

            if (Firstnamecheck == '' || Firstnamecheck == '0') {

                $('#studentnameid' + Firstnamecheckid).css('outline', '1px solid red');

                // $.wnoty({
                //     type: 'warning',
                //     message: "Hey!! Student first name should not be left empty",
                //     autohideDelay: 5000
                // });
                // $('.pros-submitapplication').html('Submit');
            }
            else {
                $('#studentnameid' + Firstnamecheckid).css('outline', '1px solid green');

                $('.pros-submitapplication').html('Submit');
            }

        });
        
        
        



                

        var childmiddlename = [];

        $.each($('.generalstudensecondname'), function () {

            childmiddlename.push($(this).val());
            var secondnamecheck = $(this).val();
            var secondtnamecheckid = $(this).data('id');

            if (secondnamecheck == '' || secondnamecheck == '0') {

                $('#studentnameidmiddle' + secondtnamecheckid).css('outline', '1px solid red');

               
                $('.pros-submitapplication').html('Submit');
            }
            else {
                $('#studentnameidmiddle' + secondtnamecheckid).css('outline', '1px solid green');

                $('.pros-submitapplication').html('Submit');
            }

        });






        var childslastname = [];

        $.each($('.generalstudenlastname'), function () {

            childslastname.push($(this).val());
            var lastnamecheck = $(this).val();
            var latsnamecheckid = $(this).data('id');

            if (lastnamecheck == '' || lastnamecheck == '0') {

                $('#studentnameidlast' + latsnamecheckid).css('outline', '1px solid red');

                // $.wnoty({
                //     type: 'warning',
                //     message: "Hey!! Student last name should not be left empty",
                //     autohideDelay: 5000
                // });

                // $('.pros-submitapplication').html('Submit');
            }
            else {
                $('#studentnameidlast' + latsnamecheckid).css('outline', '1px solid green');

                $('.pros-submitapplication').html('Submit');
            }

        });




        var studentgender = [];
        $.each($("input[type='radio']:checked"), function () {
            studentgender.push($(this).val());
        });


      

        
        
        var studentdob = [];
        
        
        
          
          
        $.each($(".geraldobclass"), function () {
            
                        studentdob.push($(this).val());
                       
            
             
                        var dobcheckval = $(this).val();
                        var dobcheckvalid = $(this).data('id');

            if (dobcheckval === '' || dobcheckval == '0') {

                $('#dateofbirthid' + dobcheckvalid).css('outline', '1px solid red');

               

            }
            else {
                $('#dateofbirthid' + dobcheckvalid).css('outline', '1px solid green');

                $('.pros-submitapplication').html('Submit');
            }

        });




        var studentinstitutionempty = studentinstitution.some(function (value) {
            return value.trim() === '0';
        });

        var student_classempty = student_class.some(function (value) {
            return value.trim() === '0';
        });

        var childFirstNameempty = childFirstName.some(function (value) {
            return value.trim() === '';
        });

        var childslastnameempty = childslastname.some(function (value) {
            return value.trim() === '';
        });

        var studentdobempty = studentdob.some(function (value) {
            return value.trim() === '';
        });







        if (parent_firstname == '') {
            $('#parentfirtname').css('outline', '1px solid red');
            $('.pros-submitapplication').html('Submit');

            $.wnoty({
                type: 'warning',
                message: "Hey!! enter your first name",
                autohideDelay: 5000
            });

            $('html, body').scrollTop($('#prosdisplayscroll').offset().top);

            $('.pros-submitapplication').prop('disabled', false);

        } else if (parent_lastname == '') {
            $('#parentfirtname').css('outline', '1px solid green');
            $('#parentlname').css('outline', '1px solid red');
            $('.pros-submitapplication').html('Submit');

            $.wnoty({
                type: 'warning',
                message: "Hey!! enter your last name",
                autohideDelay: 5000
            });

            $('html, body').scrollTop($('#prosdisplayscroll').offset().top);
            $('.pros-submitapplication').prop('disabled', false);

        }else if (email == '') {

            $('#parentfirtname').css('outline', '1px solid green');
            $('#parentlname').css('outline', '1px solid green');
            $('#parentNum').css('outline', '1px solid green');
            $('#parentemail').css('outline', '1px solid red');

            $.wnoty({
                type: 'warning',
                message: "Hey!! email should not be left blank",
                autohideDelay: 5000
            });
            $('html, body').scrollTop($('#prosdisplayscroll').offset().top);
            $('.pros-submitapplication').html('Submit');
            $('.pros-submitapplication').prop('disabled', false);

        }
        
        else if (phone_no == '') {

            $('#parentfirtname').css('outline', '1px solid green');
            $('#parentlname').css('outline', '1px solid green');
            $('#WhatsappNumber').css('outline', '1px solid red');
            $('.pros-submitapplication').html('Submit');

            $.wnoty({
                type: 'warning',
                message: "Hey!! phone number should not be left blank",
                autohideDelay: 5000
            });
            
            

            $('html, body').scrollTop($('#prosdisplayscroll').offset().top);
            $('.pros-submitapplication').prop('disabled', false);
            
        }else if(phone_no_mainwa == '')
        {
            
            
            
            $('#parentfirtname').css('outline', '1px solid green');
            $('#parentlname').css('outline', '1px solid green');
            $('#WhatsappNumber').css('outline', '1px solid green');
            $('#WhatsappNumbermain').css('outline', '1px solid red');
            
            
            $('.pros-submitapplication').html('Submit');

            $.wnoty({
                type: 'warning',
                message: "Hey!! whatsApp number should not be left blank",
                autohideDelay: 5000
            });
            
            $('html, body').scrollTop($('#prosdisplayscroll').offset().top);
            $('.pros-submitapplication').prop('disabled', false);
            
        }
        
         else if (!emailPattern.test(email)) {

            $('#parentfirtname').css('outline', '1px solid green');
            $('#parentlname').css('outline', '1px solid green');
            $('#parentNum').css('outline', '1px solid green');
            $('#parentemail').css('outline', '1px solid red');

            $.wnoty({
                type: 'warning',
                message: "Hey!! kindly provide a vlid email",
                autohideDelay: 5000
            });
            $('html, body').scrollTop($('#prosdisplayscroll').offset().top);
            $('.pros-submitapplication').html('Submit');
            $('.pros-submitapplication').prop('disabled', false);

        } else if (country == '' || country == '0') {


            $('#parentfirtname').css('outline', '1px solid green');
            $('#parentlname').css('outline', '1px solid green');
            $('#parentNum').css('outline', '1px solid green');
            $('#parentemail').css('outline', '1px solid green');
            $('#parentcountry').css('outline', '1px solid red');

            $.wnoty({
                type: 'warning',
                message: "Hey!! select country before proceeding",
                autohideDelay: 5000
            });
            $('html, body').scrollTop($('#prosdisplayscroll').offset().top);

            $('.pros-submitapplication').html('Submit');
            $('.pros-submitapplication').prop('disabled', false);

        } else if (state == '' || state == '0') {


            $('#parentfirtname').css('outline', '1px solid green');
            $('#parentlname').css('outline', '1px solid green');
            $('#parentNum').css('outline', '1px solid green');
            $('#parentemail').css('outline', '1px solid green');
            $('#parentcountry').css('outline', '1px solid green');
            $('#parentstate').css('outline', '1px solid red');

            $.wnoty({
                type: 'warning',
                message: "Hey!! select state before proceeding",
                autohideDelay: 5000
            });
            $('html, body').scrollTop($('#prosdisplayscroll').offset().top);
            $('.pros-submitapplication').html('Submit');
            $('.pros-submitapplication').prop('disabled', false);

        } else if (lga == '' || lga == '0') {

            $('#parentfirtname').css('outline', '1px solid green');
            $('#parentlname').css('outline', '1px solid green');
            $('#parentNum').css('outline', '1px solid green');
            $('#parentemail').css('outline', '1px solid green');
            $('#parentcountry').css('outline', '1px solid green');
            $('#parentstate').css('outline', '1px solid green');
            $('#parentlga').css('outline', '1px solid red');


            $.wnoty({
                type: 'warning',
                message: "Hey!! select state before proceeding.",
                autohideDelay: 5000
            });
            $('html, body').scrollTop($('#prosdisplayscroll').offset().top);
            $('.pros-submitapplication').html('Submit');
            $('.pros-submitapplication').prop('disabled', false);
        } else if (cityorigin == '' || cityorigin == '0') {


            $('#parentfirtname').css('outline', '1px solid green');
            $('#parentlname').css('outline', '1px solid green');
            $('#parentNum').css('outline', '1px solid green');
            $('#parentemail').css('outline', '1px solid green');
            $('#parentcountry').css('outline', '1px solid green');
            $('#parentstate').css('outline', '1px solid green');
            $('#parentlga').css('outline', '1px solid green');
            $('#parentcity').css('outline', '1px solid red');

            $.wnoty({
                type: 'warning',
                message: "Hey!! input your city before proceeding.",
                autohideDelay: 5000
            });

            $('html, body').scrollTop($('#prosdisplayscroll').offset().top);
            $('.pros-submitapplication').html('Submit');
            $('.pros-submitapplication').prop('disabled', false);
        } else if (parentaddress == '' || parentaddress == '0') {

            $('#parentfirtname').css('outline', '1px solid green');
            $('#parentlname').css('outline', '1px solid green');
            $('#parentNum').css('outline', '1px solid green');
            $('#parentemail').css('outline', '1px solid green');
            $('#parentcountry').css('outline', '1px solid green');
            $('#parentstate').css('outline', '1px solid green');
            $('#parentlga').css('outline', '1px solid green');
            $('#parentcity').css('outline', '1px solid green');
            $('#parentaddress').css('outline', '1px solid red');

            $.wnoty({
                type: 'warning',
                message: "Hey!! input your city before proceeding.",
                autohideDelay: 5000
            });

            $('html, body').scrollTop($('#prosdisplayscroll').offset().top);
            $('.pros-submitapplication').html('Submit');
            $('.pros-submitapplication').prop('disabled', false);



        } else if (studentinstitutionempty) {
            
                $.wnoty({
                    type: 'warning',
                    message: "Hey!! ensure every campus is selected",
                    autohideDelay: 5000
                });
            
            $('.pros-submitapplication').html('Submit');
            $('.pros-submitapplication').prop('disabled', false);

        }else if(student_classempty)
        {
            
               $.wnoty({
                    type: 'warning',
                    message: "Hey!! ensure every class is selected",
                    autohideDelay: 5000
                });
                
                $('.pros-submitapplication').html('Submit');
               $('.pros-submitapplication').prop('disabled', false);

            
        }else if(childFirstNameempty)
        {
            
            
            
                $.wnoty({
                    type: 'warning',
                    message: "Hey!! Student first name should not be left empty",
                    autohideDelay: 5000
                });
                
                  $('.pros-submitapplication').html('Submit');
               $('.pros-submitapplication').prop('disabled', false);
        }else if(childslastnameempty)
        {
            
            
                   $.wnoty({
                    type: 'warning',
                    message: "Hey!! Student last name should not be left empty",
                    autohideDelay: 5000
                });
                
                  $('.pros-submitapplication').html('Submit');
                 $('.pros-submitapplication').prop('disabled', false);
                 
                 
        }else if(studentdobempty)
        {
                $.wnoty({
                    type: 'warning',
                    message: "Hey!! Student date of birth should not be left empty",
                    autohideDelay: 5000
                });
                
                $('.pros-submitapplication').html('Submit');
                 $('.pros-submitapplication').prop('disabled', false);
        }
        else if (studentgender.length < numappended) {
            
            $.wnoty({
                type: 'warning',
                message: "Hey!! make sure gender no gender is left empty.",
                autohideDelay: 5000
            });
            
            $('.pros-submitapplication').html('Submit');
            $('.pros-submitapplication').prop('disabled', false);
            
        } else {
            

                var prosperFormData = new FormData()
                var fullname = parent_firstname;
                prosperFormData.append('parent_firstname', parent_firstname);
                prosperFormData.append('parent_middlename', parent_middlename);
                prosperFormData.append('parent_lastname', parent_lastname);
                prosperFormData.append('WhatsappNumberfull', WhatsappNumberfull);
                prosperFormData.append('email', email);
                prosperFormData.append('country', country);
                prosperFormData.append('state', state);
                prosperFormData.append('lga', lga);
                prosperFormData.append('cityorigin', cityorigin);
                prosperFormData.append('parentaddress', parentaddress);
                prosperFormData.append('childFirstName', childFirstName);
                prosperFormData.append('childmiddlename', childmiddlename);
                prosperFormData.append('childslastname', childslastname);
                prosperFormData.append('studentgender', studentgender);
                prosperFormData.append('studentdob', studentdob);
                prosperFormData.append('studentinstitution', studentinstitution);
                prosperFormData.append('student_class', student_class);
                prosperFormData.append('session', session);
                prosperFormData.append('term', term);
                prosperFormData.append('GroupofSchool', GroupofSchool);
                prosperFormData.append('WhatsappNumberfullmainwanum', WhatsappNumberfullmainwanum);
               prosperFormData.append('amounttotal', amounttotal);
               prosperFormData.append('edumesscharge', edumesscharge);
               prosperFormData.append('vat_by_gov', vat_by_gov);
                prosperFormData.append('student_classcharge', student_classcharge);



   
            


            if (amountopay == '0') {
                
                $('.pros-submitapplication').prop('disabled', true);
                
                $.ajax({
                    url: '../controller/scripts/website/prosinsertadmission-register.php',
                    method: 'POST',
                    data: prosperFormData,
                    contentType: false,
                    cache: false,
                    processData: false,
                    success: function (prosperoutput) {
                        

                        // $('#display-feedback').html(prosperoutput);

                        var feedback = (prosperoutput);


                            if(feedback.trim() == 'success')
                            {
                                    $.wnoty({
                                        type: 'success',
                                        message: "Great! Registered Successfully",
                                        autohideDelay: 5000
                                    });
                            }
                        

                         $('.pros-submitapplication').html('Submit');
                         $('.pros-submitapplication').prop('disabled', false);

                    }
                });
            }
            else {


//     $charge = floatval($row_edumesspaymentcharges['ChargeAmount']);
// 	$Cap = floatval($row_edumesspaymentcharges['Cap']);


          
	
                    var percentage = '<?php echo $charge; ?>';
                    var Cap = '<?php echo $Cap; ?>';
                    
                    var Vat = '<?php echo $StampDuty; ?>';
                    
                var chargecheck = ((parseFloat(percentage) + parseFloat(Vat)) / 100) * parseFloat(amountopay) 
                   
                if (chargecheck > Cap) {

                    var overalltotalamount = Cap + amountopay;
                    
                    var final_charge_amt = Cap;
                }
                else {

                    var overalltotalamount = chargecheck + amountopay;
                    
                     var final_charge_amt = chargecheck;

                }

                    
                      

                // alert(overalltotalamount+' '+amountopay);

                MonnifySDK.initialize({
                    amount: overalltotalamount,
                    currency: "NGN",
                    reference: '' + Math.floor((Math.random() * 1000000000) + 1),
                    customerFullName: fullname,
                    customerEmail: email,
                    apiKey: "<?php echo $MonnifyLivePaymentApi ;?>",
                    contractCode: "<?php echo $MonnifyLiveContractCode ; ?>",
                    paymentDescription: "Admission Fee",

                    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);

                        $.ajax({
                            url: '../controller/scripts/website/prosinsertadmission-register.php',
                            method: 'POST',
                            data: prosperFormData,
                            contentType: false,
                            cache: false,
                            processData: false,
                            success: function (prosperoutput) {

                                var feedback = (prosperoutput);
                                
                                if(feedback.trim() == 'success')
                                {
                                        $.wnoty({
                                            type: 'success',
                                            message: "Great! Registered Successfully",
                                            autohideDelay: 5000
                                        });
                                }

                                 $('.pros-submitapplication').html('Submit');
                                 $('.pros-submitapplication').prop('disabled', false);
                            }
                        });

                    },
                    onClose: function (data) {
                        console.log(data);

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

                        if (paymentStatus == 'USER_CANCELLED') {

                                $.wnoty({
                                    type: 'warning',
                                    message: "Oops! Transaction Cancelled.",
                                    autohideDelay: 5000
                                });
                           
                             $('.pros-submitapplication').html('Submit');
                             $('.pros-submitapplication').prop('disabled', false);
                            $('#modalbodyid').animate({ scrollTop: 0 }, 'fast');

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

                           
                             $('.pros-submitapplication').html('Submit');
                             $('.pros-submitapplication').prop('disabled', false);
                           

                          
                        }

                    }
                });

            }

        }
    }




    $(document).ready(function () {

        var stardate = '<?php  echo  $meetingStartDate; ?>';
        var endate = '<?php echo $meetingEndDate; ?>';
        var currentdate = '<?php echo $currentDate ; ?>';
                
      
        if (currentdate < stardate || currentdate > endate) {

                $('#prosadmissionnot-open-modal').modal('show');
            
        }else if(stardate == '' || endate == '')
        {
            $('#prosadmissionnot-open-modal').modal('show');


        }else
        {

        }


    });








</script>