IMMREX7

aku nok ndi : /home/spdtg/www/schoolmis/resources/views/schools/students/
File Up :
aku nok ndi : /home/spdtg/www/schoolmis/resources/views/schools/students/class_promotion.blade.php

@extends('schools.school_layout')

@section('content')

<div class="row clearfix">

    <div class="col-lg-12 col-md-12 col-sm-12">

        <div class="card">

            <div class="header">

                <h2><strong>Class Promotion</strong></h2>

            </div>

            <div class="body">

                {!! Form::open(['url' => 'school/classpromotion', 'class' => 'form-horizontal','id'=>'promotion']) !!}

                <div class="row clearfix">

                    <div class="col-sm-6 form-control-label">

                        <label for="classname" style="color:red;">First Select Session in which you want to Promote the Students : </label>

                    </div>

                    <div class="col-sm-4">

                        <div class="form-group">

                            {!! Form::select('idFinancialYear',fys(),null,['class' => 'form-control show-tick ms year','required'=>'required']) !!}

                        </div>

                    </div>

                </div>

                <div class="row clearfix">

                    <div class="col-sm-6">

                        <div class="row clearfix">

                            <div class="col-sm-3 form-control-label">

                                <label for="classname">Class</label>

                            </div>

                            <div class="col-sm-7">

                                <div class="form-group">

                                    {!! Form::select('idClass',$classes,null,['class' => 'form-control show-tick ms select2']) !!}

                                </div>

                                <span id='classerror'></span>

                            </div>

                        </div>

                        <div class="row clearfix">

                            <div class="col-sm-3 form-control-label">

                                <label for="classname">Section</label>

                            </div>

                            <div class="col-sm-7">

                                <div class="form-group">

                                    <select name='idSection' id="idSection" class="form-control show-tick ms"></select>

                                </div>

                                <span id='sectionerror'></span>

                            </div>

                        </div>

                        <div class="row clearfix">

                            <div class="col-sm-3 form-control-label">

                                <label for="classname">Students</label>

                            </div>

                            <div class="col-sm-3">

                                <div class="form-group">

                                    <div id="idStudent" style="border:1px solid #ccc; width:300px; height: 250px; overflow-y: scroll;">



                                    </div>

                                </div>

                                <span id='studenterror'></span>

                            </div>

                        </div>

                    </div>

                    <div class="col-sm-6">

                        <div class="row clearfix">

                            <div class="col-sm-3 form-control-label">

                                <label for="classname">Class</label>

                            </div>

                            <div class="col-sm-7">

                                <div class="form-group">

                                    {!! Form::select('idClassPromoted',$classes,null,['class' => 'form-control show-tick ms select2']) !!}

                                </div>

                                <span id='classperror'></span>

                            </div>

                        </div>

                        <div class="row clearfix">

                            <div class="col-sm-3 form-control-label">

                                <label for="classname">Section</label>

                            </div>

                            <div class="col-sm-7">

                                <div class="form-group">

                                    <select name='idSectionPromoted' class="form-control show-tick ms"></select>

                                </div>

                                <span id='sectionperror'></span>

                            </div>

                        </div>

                        <div class="row clearfix">

                            <div class="col-sm-3 form-control-label">

                                <label for="classname">Student Category</label>

                            </div>

                            <div class="col-sm-7">

                                <div class="form-group">

                                    {!! Form::select('stdCategory',$category,null,['class' => 'form-control show-tick ms select2']) !!}

                                </div>

                                <span id='classperror'></span>

                            </div>

                        </div>



                    </div>

                </div>

                <div class="row clearfix">

                    <div class="col-sm-8 offset-sm-2">

                        {!! Form::submit('SAVE',['class' => 'btn btn-raised btn-primary btn-round waves-effect']) !!}

                        {!! Form::close() !!} 

                    </div>

                </div>



            </div>

        </div>

    </div>

</div>

@stop

@section('script')

<script>

    $('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) {

                    $('select[name="idSection"]').empty();

                    $('select[name="idSection"]').append('<option value="">--- Select ---</option><option value="All">All</option>');

                    $.each(data, function (key, value) {

                        $('select[name="idSection"]').append('<option value="' + key + '">' + value + '</option>');

                    });

                }

            });

        } else {

            $('select[name="idSection"]').empty();

        }

    });

    $('select[name="idSection"]').on('change', function () {

        var sectionID = $(this).val();
        var fy = 1;
        $.each($(".year option:selected"), function(){            
             fy = $(this).val();
        });
        if (sectionID) {

            $.ajax({

                url: "{{url('/school/section') }}" + '/' + sectionID + "/students"+ '/' + fy,

                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><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 {

            $('select[name="idStudent"]').empty();

        }

    });

    $('select[name="idClassPromoted"]').on('change', function () {

        var classID = $(this).val();

        if (classID) {

            $.ajax({

                url: "{{url('/school/class') }}" + '/' + classID + "/sections",

                type: "GET",

                dataType: "json",

                success: function (data) {

                    $('select[name="idSectionPromoted"]').empty();

                    $('select[name="idSectionPromoted"]').append('<option value="">--- Select ---</option>');

                    $.each(data, function (key, value) {

                        $('select[name="idSectionPromoted"]').append('<option value="' + key + '">' + value + '</option>');

                    });

                }

            });

        } else {

            $('select[name="idSectionPromoted"]').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;

            });

        }

    });

// Saving form data

    $('#promotion').on('submit', function (e) {

        $.ajaxSetup({

            header: $('meta[name="_token"]').attr('content')

        });

        var formData = new FormData($('#promotion')[0]);

        $("#submit-btn").prop('disabled', true);

        $.ajax({

            type: "POST",

            url: "{{url('school/classpromotion') }}",

            processData: false,

            contentType: false,

            data: formData,

            dataType: 'json',

            success: function (data) {

                if (data[Object.keys(data)[0]] === 'SUCCESS') {

                    $("#submit-btn").prop('disabled', true);

                    window.location = "{{url('school/stdstrength')}}";

                } else {                  //False Case: With error msg

                    $("#msg").html(data);   //$msg is the id of empty msg

                }



            },

            error: function (data) {

                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['idSection'] === undefined) {

                        $('#sectionerror').empty();

                    } else {

                        errorname = '<span class="help-block"><strong>' + errors['idSection'] + '</strong></span>';

                        $('#sectionerror').html(errorname);

                    }

                    if (errors['idClassPromoted'] === undefined) {

                        $('#classperror').empty();

                    } else {

                        errorname = '<span class="help-block"><strong>' + errors['idClassPromoted'] + '</strong></span>';

                        $('#classperror').html(errorname);

                    }

                    if (errors['idSectionPromoted'] === undefined) {

                        $('#sectionperror').empty();

                    } else {

                        errorname = '<span class="help-block"><strong>' + errors['idSectionPromoted'] + '</strong></span>';

                        $('#sectionperror').html(errorname);

                    }

                    if (errors['idStudent'] === undefined) {

                        $('#studenterror').empty();

                    } else {

                        errorname = '<span class="help-block"><strong>' + errors['idStudent'] + '</strong></span>';

                        $('#studenterror').html(errorname);

                    }

                }

            }

        });

        return false;

    });

</script>

@stop

Copyright © 2021 - 2025 IMMREX7