IMMREX7

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

@extends('schools.school_layout')
@section('content')
<div class="row clearfix">
    <div class="col-sm-5">
        <div class="card">
            <div class="header">
                <h2><strong>Period Master</strong></h2>
            </div>
            <div class="body">
                @if(isset($period))
                {!! Form::model($period, ['method' => 'PATCH', 'action' => ['School\PeriodController@update', $period->idPeriod], 'class' => 'form-horizontal','files'=>true]) !!}
                @else
                {!! Form::open(['url' => 'school/periods', 'class' => 'form-horizontal','id'=>'timetable_form','files'=>true]) !!}
                @endif
                <div class="row clearfix">
                    <div class="col-sm-4 form-control-label required">
                        <label for="classname">Class</label>
                    </div>
                    <div class="col-sm-8">
                        <div class="form-group">
                            {!! Form::select('idClass',$classes,null,['class' => 'form-control show-tick ms select2']) !!}
                            @if ($errors->has('idClass'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('idClass') }}</strong>
                            </label>
                            @endif
                            <span id='classerror'></span>
                        </div>
                    </div>
                </div>
                <div class="row clearfix">
                    <div class="col-sm-4 form-control-label required">
                        <label for="classname">Select Section</label>
                    </div>
                    <div class="col-sm-8">
                        <div class="form-group">
                            @if(isset($period))
                            {!! Form::select('idSection',$section,null,['class' => 'form-control show-tick ms select2']) !!}
                            @else
                            <div id="idSection" style="border:1px solid #ccc; width:250px; height: 110px; overflow-y: scroll;">
                                
                            </div>
                            @if ($errors->has('idSection'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('idSection') }}</strong>
                            </label>
                            @endif
                            <span id='sectionerror'></span>
                            @endif
                        </div>
                    </div>
                </div>
                <div class="row clearfix">
                    <div class="col-sm-4 form-control-label required">
                        <label for="classname">Period Name</label>
                    </div>
                    <div class="col-sm-8">
                        <div class="form-group">
                           {!! Form::text('periodName',null,['class' => 'form-control','minlength'=>'2','maxlength'=>'120']) !!}
                           @if ($errors->has('periodName'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('periodName') }}</strong>
                            </label>
                            @endif
                            <span id='perioderror'></span>
                        </div>
                    </div>
                </div>
                <div class="row clearfix demo-masked-input">
                    <div class="col-sm-2 form-control-label required">
                        <label for="classname">From</label>
                    </div>
                    <div class="col-sm-4">
                        <div class="form-group">
                           {!! Form::text('fromTime',null,['class' => 'form-control time24']) !!}
                           @if ($errors->has('fromTime'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('fromTime') }}</strong>
                            </label>
                            @endif
                            <span id='fromerror'></span>
                        </div>
                    </div>
                    <div class="col-sm-1 form-control-label required">
                        <label for="classname">To</label>
                    </div>
                    <div class="col-sm-5">
                        <div class="form-group">
                           {!! Form::text('toTime',null,['class' => 'form-control time24']) !!}
                           @if ($errors->has('toTime'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('toTime') }}</strong>
                            </label>
                            @endif
                            <span id='toerror'></span>
                        </div>
                    </div>
                </div>
                <div class="row clearfix">
                    <div class="col-sm-4 form-control-label">
                        <label for="classname">Is Lunch Break</label>
                    </div>
                    <div class="col-sm-8">
                        <div class="form-group">
                            <input type="checkbox" name="isLunchBreak" @if(isset($period) && $period->isLunchBreak == 'Y') checked @endif> 
                           @if ($errors->has('isLunchBreak'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('isLunchBreak') }}</strong>
                            </label>
                            @endif
                        </div>
                    </div>
                </div>
                <div class="row clearfix">
                    <div class="col-sm-8 offset-sm-2">
                        @if(isset($period))
                        {!! Form::submit('UPDATE',['class' => 'btn btn-raised btn-primary btn-round waves-effect']) !!}
                        @else
                        {!! Form::submit('SAVE',['class' => 'btn btn-raised btn-primary btn-round waves-effect','id'=>'submit-btn']) !!}
                        @endif
                        {!! Form::close() !!} 
                    </div>
                </div>

            </div>
        </div>
    </div>
<!--</div>
<div class="row clearfix">-->
    <div class="col-sm-7">
        <div class="card">
            <div class="header">
                <!--<p style="float: left;"><a href="{{url('school/viewtimetable')}}" class="btn btn-sm btn-warning">View Timetable</a></p>-->
            </div>
            <div class="body table-responsive">
                {!! Form::open(['method' => 'GET',  'action' => ['School\PeriodController@index'], 'class' => 'form-horizontal']) !!}
                <div class="row clearfix">
                    <div class="col-sm-3 form-control-label">
                        <label for="classname">Financial Year</label>
                    </div>
                    <div class="col-sm-5">
                        <div class="form-group">
                           {!! Form::select('idFinancialYear',fys(),null,['class' => 'form-control show-tick ms']) !!}
                        </div>
                    </div>
                    <div class="col-sm-2">
                        {!! Form::submit('Search',['class' => 'btn btn-raised btn-primary btn-round waves-effect']) !!}
                    </div>
                </div>
                {!! Form::close() !!} 
                <br>
                <table class="table table-bordered table-striped table-hover js-basic-example dataTable">
                    <thead>
                        <tr>
                            <th>S. No.</th>
                            <th>Class</th>
                            <th>Section</th>
                            <th>Name</th>
                            <th>From </th>
                            <th>Till</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $i = 1; ?>
                        @foreach($periods as $value)
                        <tr>
                            <th scope="row">{{$i}}</th>
                            <td>{{$value->classM->className}}</td>
                            <td>{{$value->section->sectionName}}</td>
                            <td>{{$value->periodName}}</td>
                            <td>{{$value->fromTime}}</td>
                            <td>{{$value->toTime}}</td>
                            <td>
                                <a href="{{ url('school/periods/' . $value->idPeriod . '/edit') }}"  class="btn btn-raised btn-info waves-effect btn-round">Edit </a>
                                <button class="btn btn-raised btn-danger waves-effect btn-round js-sweetalert" data-id="{{$value->idPeriod}}" data-type="confirm">DELETE</button>
                            </td>
                        </tr>
                        <?php $i++; ?>
                        @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
@stop
@section('script')
<script>
$(document).ready(function() {
    $('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;"><strong>Select All</label></strong><input type="checkbox" class="select-all" id="selectall"></div>');
                    $.each(data, function(key, value) {
                       $('#idSection').append('<div class="checkbox-inline" style="padding-left:10px;"><label style="margin-right:100px;">'+value+'</label><input type="checkbox" name="sections[]" value="'+key+'" class="sectionclass"></div>');
                        
                    });
                }
            });
        }else{
            $('select[name="idSection"]').empty();
        }
    });
    
});
$(document).on('click', '.select-all', function(){
    var checkAll = this.checked;
    if(checkAll === true){
        $('.sectionclass').each(function () {
            this.checked = checkAll;
        });
    }else{
        $('.sectionclass').each(function () {
            this.checked = checkAll;
        });
    }
});

// Delete Period
$(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 Period!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "Yes, delete it!",
            closeOnConfirm: true
        },
        function() {
         //   console.log('here');
            $.ajax({
                type: "DELETE",
                url: "{{url('/school/periods/')}}" +"/"+id,
                data: {id:id}
                       
            })
            .done(function(data) {
                swal({
                    title: "Deleted", 
                    text: "Period 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
$('#timetable_form').on('submit',function(e){
    $.ajaxSetup({
         header:$('meta[name="_token"]').attr('content')
    });
    var formData =  new FormData($('#timetable_form')[0]);
    $("#submit-btn").prop('disabled', true);
        $.ajax({
            type:"POST",
            url: "{{url('school/periods') }}",
            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/periods')}}";
                }
                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['periodName']=== undefined){
                                        $( '#perioderror' ).empty();
                                    }else{
                                       errorname = '<span class="help-block"><strong>'+errors['periodName']+'</strong></span>';
                                       $( '#perioderror' ).html( errorname );
                                    }
                                    if(errors['fromTime']=== undefined){
                                        $( '#fromerror' ).empty();
                                    }else{
                                       errorname = '<span class="help-block"><strong>'+errors['fromTime']+'</strong></span>';
                                       $( '#fromerror' ).html( errorname );
                                    }
                                    if(errors['toTime']=== undefined){
                                        $( '#toerror' ).empty();
                                    }else{
                                       errorname = '<span class="help-block"><strong>'+errors['toTime']+'</strong></span>';
                                       $( '#toerror' ).html( errorname );
                                    }
                        }
                }
        });
    return false;
});
</script>
@stop

Copyright © 2021 - 2025 IMMREX7