IMMREX7

aku nok ndi : /home/spdtg/www/schoolmis/resources/views/schools/north/feeheads/
File Up :
aku nok ndi : /home/spdtg/www/schoolmis/resources/views/schools/north/feeheads/feehead_script.blade.php

<script>
    // ADvance Search script
    
$(document).on('click', '.classsearch_ids', function(){
    //var checkAll = this.checked;
    var classIds = [];
    $("input:checkbox[name='classes[]']:checked").each(function () {
        classIds.push($(this).val());
    });
    if (classIds.length > 0) {
            $.ajax({
                url: "{{url('/school/schclass') }}"+'/' +classIds + "/sections",
                type: "GET",
                dataType: "json",
                success:function(data) {
                    $('#idSearchSection').empty();
                    $('#idSearchSection').append('<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;"><input type="checkbox" class="select-all" id="selectall"><label><strong>Select All</label></strong></div>');
                    $.each(data, function(key, value) {
                       $('#idSearchSection').append('<div class="checkbox-inline" style="padding-left:10px;"><input type="checkbox" name="sections[]" value="'+key+'" class="sectionsearchclass"><label>'+value+'</label></div>');
                    });
                }
            });
        }
});

$("tbody").on("change", "input", function () {
    if(this.id !=''){
        var totalAmount=0;
        $("#optional_list tr").each(function() {
          // Within tr we find the last td child element and get content
          $(this).find("td").find("input").each(function() {
                if(this.value !='Delete' && this.id !='' && this.value!='')
                 totalAmount=parseInt(totalAmount)+parseInt(this.value);
            });
        });
        $( "input[name='amount']" ).val(totalAmount);
    }
});
    
$(document).on('click', '.select-all', function(){
    var checkAll = this.checked;
        if(checkAll === true){
            $('.sectionsearchclass').each(function () {
                this.checked = checkAll;
            });
        }else{
            $('.sectionsearchclass').each(function () {
                this.checked = checkAll;
            });
        }
});
$(document).ready(function() {
   var tt1 = $('#tableexp').DataTable({
      
        dom: 'Bfrtip',
         scrollY:        "500px",
        scrollX:        true,
        scrollCollapse: true,
        fixedColumns:   {
            left: 1
        },
        buttons: [
            { extend: 'csv', footer: true, text: 'Export to Excel',title:'Feeheaders',
                exportOptions: {
                    columns: [0,1,2,3,4,5,6,7,8,9]
                }}
            
        ]
    });
});
$(document).ready(function() {
    $('input[type=text][name=fine]').hide();
    $('input[type=text][name=flatFine]').hide();
    $('select[name="idClass"]').on('change', function() {
        var classID = $(this).val();
        if(classID) {
            $.ajax({
                url: "{{url('/school/class') }}"+'/' +classID + "/sections",
                type: "GET",
                dataType: "json",
                success:function(data) {
                    $('#idSection').empty();
                    $('#idSection').append('<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;"><label style="margin-right:42px;"><input type="checkbox" class="select-all" id="selectall"><strong>Select All</label></strong></div>');
                    $.each(data, function(key, value) {
                       $('#idSection').append('<div class="checkbox-inline" style="padding-left:10px;"><input type="checkbox" name="sections[]" value="'+key+'" class="sectionclass"><label style="margin-right:100px;">'+value+'</label></div>');
                        
                    });
                }
            });
        }else{
            $('select[name="idSection"]').empty();
        }
    });
});
$(document).on('click', '.select-all', function(){
    var checkAll = this.checked;
        if(checkAll === true){
            $("input:checkbox[name='sections[]']").each(function () {
                this.checked = checkAll;
            });
            var sectionIds = [];
            $("input:checkbox[name='sections[]']:checked").each(function () {
                sectionIds.push($(this).val());
            });
            if (sectionIds.length > 0) {
                    $.ajax({
                        url: "{{url('/school/sec') }}"+'/' +sectionIds + "/students",
                        type: "GET",
                        dataType: "json",
                        success:function(data) {
                            $('#idStudent').empty();
                            $('#idStudent').append('<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;"><label style="margin-right:42px;"><input type="checkbox" class="select-allstd" id="selectallstd"><strong>Select All</label></strong></div>');
                            $.each(data, function(key, value) {
                               $('#idStudent').append('<div class="checkbox-inline" style="padding-left:10px;"><input type="checkbox" name="students[]" value="'+key+'" class="stdallselect"><label>'+value+'</label></div>');

                            });
                        }
                    });
                }
        }else{
            $('#idStudent').empty();
            $('input[type=checkbox]').each(function () {
                this.checked = checkAll;
            });
        }
        
    
});
$(document).on('click', '.sectionclass', function(){
    var sectionIds = [];
        $("input:checkbox[name='sections[]']:checked").each(function () {
            sectionIds.push($(this).val());
        });
        if (sectionIds.length > 0) {
                $.ajax({
                    url: "{{url('/school/sec') }}"+'/' +sectionIds + "/students",
                    type: "GET",
                    dataType: "json",
                    success:function(data) {
                        $('#idStudent').empty();
                        $('#idStudent').append('<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;"><input type="checkbox" class="select-allstd" id="selectallstd"><label style="margin-right:42px;"><strong>Select All</label></strong></div>');
                        $.each(data, function(key, value) {
                           $('#idStudent').append('<div class="checkbox-inline" style="padding-left:10px;"><input type="checkbox" name="students[]" value="'+key+'" class="stdallselect"><label>'+value+'</label></div>');

                        });
                    }
                });
            }else{
                $('#idStudent').empty();
            }
});
// 11 july 2019
$(document).ready(function() {
    $('select[name="idSection"]').on('change', function() {
        var sectionID = $(this).val();
        if(sectionID) {
            $.ajax({
                    url: "{{url('/school/section') }}"+'/' +sectionID + "/students",
                    type: "GET",
                    dataType: "json",
                    success:function(data) {
                        $('#idStudent').empty();
                        $('#idStudent').append('<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;"><input type="checkbox" class="select-allstd" id="selectallstd"><label style="margin-right:42px;"><strong>Select All</label></strong></div>');
                        $.each(data, function(key, value) {
                           $('#idStudent').append('<div class="checkbox-inline" style="padding-left:10px;"><input type="checkbox" name="students[]" value="'+key+'" class="stdallselect"><label>'+value+'</label></div>');

                        });
                    }
                });
            }else{
                $('#idStudent').empty();
            }
    });
    
});

$(document).on('click', '.select-allstd', function(){
    var checkAllstd = this.checked;
        if(checkAllstd === true){
            $("input:checkbox[name='students[]']").each(function () {
               this.checked = checkAllstd;
           });
        }else{
            $('.stdallselect').each(function () {
                this.checked = checkAllstd;
            });
        }
});
$(document).on('change', '.fineradio', function() {
    if (this.value == 'flat') {
        $('input[type=text][name=flatFine]').show();
        $('input[type=text][name=fine]').hide();
    }
    else if (this.value == 'per') {
        $('input[type=text][name=fine]').show();
        $('input[type=text][name=flatFine]').hide();
    }
});
$(document).on('change', '.categoryclass', function() {
    if($(this).val() == 'All') {
         if($(this).is(':checked')){
             $("input:checkbox[name='studentCategory[]']").each(function () {
                    if($(this).val() != 'All')
                        {
                            this.disabled = "disabled";
                            this.checked =false;
                        }
                });
         }else{
             $("input:checkbox[name='studentCategory[]']").each(function () {
                    if($(this).val() != 'All')
                        this.disabled = "";
                });
         }
    }
});
$(document).on('click', '.categoryclass', function(){
       var sectionIds = [];
       var catVal = [];
       var singleCatVal="None";
       $("input:checkbox[name='sections[]']:checked").each(function () {
            sectionIds.push($(this).val());
        });
         $("input:checkbox[name='studentCategory[]']:checked").each(function () {
                if($(this).val() == 'All') 
                {
                    singleCatVal=$(this).val();
                }
                else
                {
                    catVal.push($(this).val());
                }
        });
        
        if(singleCatVal == 'All' && sectionIds.length > 0) {
            $.ajax({
                    url: "{{url('/school/sec') }}"+'/' +sectionIds + "/students",
                    type: "GET",
                    dataType: "json",
                    success:function(data) {
                        $('#idStudent').empty();
                        $('#idStudent').append('<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;"><label style="margin-right:42px;"><strong>Select All</label></strong><input type="checkbox" class="select-allstd" id="selectallstd"></div>');
                        $.each(data, function(key, value) {
                           $('#idStudent').append('<div class="checkbox-inline" style="padding-left:10px;"><label style="margin-right:50px;">'+value+'</label><input type="checkbox" name="students[]" value="'+key+'" class="stdallselect"></div>');

                        });
                    }
                });
        }else
        if (catVal.length > 0 && sectionIds.length > 0) {
                $.ajax({
                url: "{{url('/school/sec') }}"+'/' +sectionIds +'/' +catVal+"/student",
                type: "GET",
                dataType: "json",
                success:function(data) {
                    $('#idStudent').empty();
                        $('#idStudent').append('<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;"><label style="margin-right:42px;"><strong>Select All</label></strong><input type="checkbox" class="select-allstd" id="selectallstd"></div>');
                        $.each(data, function(key, value) {
                           $('#idStudent').append('<div class="checkbox-inline" style="padding-left:10px;"><label style="margin-right:50px;">'+value+'</label><input type="checkbox" name="students[]" value="'+key+'" class="stdallselect"></div>');

                        });
                    }
                });
            }else{
                $('#idStudent').empty();
            }
});

/*$(document).ready(function() {
    $('select[name="studentCategory"]').on('change', function() {
        var sectionIds = [];
        $("input:checkbox[name='sections[]']:checked").each(function () {
            sectionIds.push($(this).val());
        });
            
        var catVal = $(this).val();
        if(catVal == 'All') {
            $.ajax({
                    url: "{{url('/school/sec') }}"+'/' +sectionIds + "/students",
                    type: "GET",
                    dataType: "json",
                    success:function(data) {
                        $('#idStudent').empty();
                        $('#idStudent').append('<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;"><label style="margin-right:42px;"><strong>Select All</label></strong><input type="checkbox" class="select-allstd" id="selectallstd"></div>');
                        $.each(data, function(key, value) {
                           $('#idStudent').append('<div class="checkbox-inline" style="padding-left:10px;"><label style="margin-right:50px;">'+value+'</label><input type="checkbox" name="students[]" value="'+key+'" class="stdallselect"></div>');

                        });
                    }
                });
        }else{
            $.ajax({
                url: "{{url('/school/sec') }}"+'/' +sectionIds +'/' +catVal+"/students",
                type: "GET",
                dataType: "json",
                success:function(data) {
                    $('#idStudent').empty();
                        $('#idStudent').append('<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;"><label style="margin-right:42px;"><strong>Select All</label></strong><input type="checkbox" class="select-allstd" id="selectallstd"></div>');
                        $.each(data, function(key, value) {
                           $('#idStudent').append('<div class="checkbox-inline" style="padding-left:10px;"><label style="margin-right:50px;">'+value+'</label><input type="checkbox" name="students[]" value="'+key+'" class="stdallselect"></div>');

                        });
                }
            });
        }
    });
});*/
// Delete Feehead
$(document).on('click', '.js-sweetalert', function (e) {
    $.ajaxSetup({
        headers: {
          'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });
    e.preventDefault();
    var id = $(this).data('id');
    swal({
            title: "Are you sure?",
            text: "Are You sure you want to delete this feeheader!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "Yes, delete it!",
            closeOnConfirm: true
        },
        function() {
         //   console.log('here');
            $.ajax({
                type: "DELETE",
                url: "{{url('/school/north/feeheads/')}}" +"/"+id,
                data: {id:id}
                       
            })
            .done(function(data) {
                swal({
                    title: "Deleted", 
                    text: "Feehead has been successfully deleted", 
                    type: "success"
                },function() {
                    location.reload();
                });
            })
            .error(function(data) {
              swal("Oops", "We couldn't connect to the server!", "error");
            });
            return false;
    });
});

// Saving form data
$('#feehead_form').on('submit',function(e){
    $.ajaxSetup({
    header:$('meta[name="_token"]').attr('content')
   });
 $('.page-loader-wrapper').css('display','block');  
 var formData =  new FormData($('#feehead_form')[0]);
 //$("#submit-btn").prop('disabled', true);
    $.ajax({
        type:"POST",
        url: "{{url('school/north/feeheads') }}",
        processData: false,
        contentType: false,
        data:formData,
        dataType: 'json',
        success:function(data){
            console.log(data);
             $('.page-loader-wrapper').css('display','none');
            if( data[Object.keys(data)[0]] === 'SUCCESS' ){
               $("#success_msg").html("Fee Header Successfully Saved");
               $("#success_msg").show();
               $("html, body").animate({ scrollTop: 0 }, "slow");
               setTimeout(
				function() 
				{
					$("#success_msg").hide();

				}, 10000);
            }
            else {                  //False Case: With error msg
            $("#msg").html(data);   //$msg is the id of empty msg
            }

           },
        error: function(data){
             console.log(data);
             $('.page-loader-wrapper').css('display','none'); 
                    if( data.status === 422 ) {
                        $("#submit-btn").prop('disabled', false);
                        var errors = data.responseJSON.errors;
                        var errorHtml = '<div class="alert alert-danger"><ul>';
                           $('#formerrors').html(errorHtml);
                                if(errors['idClass']=== undefined){
                                    $( '#classerror' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['idClass']+'</strong></span>';
                                   $( '#classerror' ).html( errorname );
                                }
                                
                                if(errors['studentCategory']=== undefined){
                                    $( '#categoryerror' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['studentCategory']+'</strong></span>';
                                   $( '#categoryerror' ).html( errorname );
                                }
                                
                                if(errors['idSection']=== undefined){
                                    $( '#sectionerror' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['idSection']+'</strong></span>';
                                   $( '#sectionerror' ).html( errorname );
                                }
                                if(errors['demandName']=== undefined){
                                    $( '#feeheaderror' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['demandName']+'</strong></span>';
                                   $( '#feeheaderror' ).html( errorname );
                                }
                                if(errors['fromDate']=== undefined){
                                    $( '#fdate_error' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['fromDate']+'</strong></span>';
                                   $( '#fdate_error' ).html( errorname );
                                }
                                if(errors['toDate']=== undefined){
                                    $( '#todate_error' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['toDate']+'</strong></span>';
                                   $( '#todate_error' ).html( errorname );
                                }
                                if(errors['amount']=== undefined){
                                    $( '#amounterror' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['amount']+'</strong></span>';
                                   $( '#amounterror' ).html( errorname );
                                }
                                if(errors['fine']=== undefined){
                                    $( '#fineerror' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['fine']+'</strong></span>';
                                   $( '#fineerror' ).html( errorname );
                                }
                                if(errors['students']=== undefined){
                                    $( '#search_error' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['students']+'</strong></span>';
                                   $( '#search_error' ).html( errorname );
                                }
                                
                    }
            }
    });
    return false;
});

</script>

Copyright © 2021 - 2025 IMMREX7