IMMREX7

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

@extends('schools.school_layout')
@section('content')
<div class="row clearfix">
    <div class="col-sm-5">
        <div class="card">
            <div class="header">
                <h2><strong>Send</strong>SMS</h2>
            </div>
            <div class="body">
                {!! Form::open(['url' => 'school/sendsms', 'class' => 'form-horizontal','id'=>'sms_form']) !!}
               
                <div class="row clearfix">
                    <div class="col-sm-4 form-control-label">
                        <label for="classname">Card Holder</label>
                    </div>
                    <div class="col-sm-8">
                        <div class="form-group">
                            {!! Form::select('cardholder',cardholderType(),null,['class' => 'form-control show-tick ms']) !!}
                            @if ($errors->has('cardholder'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('cardholder') }}</strong>
                            </label>
                            @endif
                            <span id='cardholdererror'></span>
                        </div>
                    </div>
                </div>
                <div id="stdsmsform" style="display: none;">
                <div class="row clearfix">
                    <div class="col-sm-4 form-control-label">
                        <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">
                        <label for="classname">Select Section</label>
                    </div>
                    <div class="col-sm-8">
                        <div class="form-group">
                            <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>
                            
                        </div>
                    </div>
                </div>
                <div class="row clearfix">
                    <div class="col-sm-4 form-control-label">
                        <label for="classname">EC No.</label>
                    </div>
                    <div class="col-sm-8">
                        <div class="form-group">
                           <div id="idStudent" style="border:1px solid #ccc; width:250px; height: 110px; overflow-y: scroll;">
                                
                            </div>
                            @if ($errors->has('ecNO'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('ecNO') }}</strong>
                            </label>
                            @endif
                            <span id="ecnoerror"></span>
                        </div>
                    </div>
                </div>
                    <div class="row clearfix">
                    <div class="col-sm-4 form-control-label">
                        <label for="classname">SMS To</label>
                    </div>
                    <div class="col-sm-8">
                        <div class="form-group">
                           {!! Form::select('smsTo',['All'=>'All','Father'=>'Father','Mother'=>'Mother','Emergency'=>'Emergency Contact Person'],null,['class' => 'form-control show-tick ms']) !!}
                            @if ($errors->has('smsTo'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('smsTo') }}</strong>
                            </label>
                            @endif
                            <span id="ecnoerror"></span>
                        </div>
                    </div>
                </div>
                </div>
                <div id="staffsmsform" style="display: none;">
                <div class="row clearfix">
                    <div class="col-sm-4 form-control-label">
                        <label for="classname">Enrollment No.</label>
                    </div>
                    <div class="col-sm-8">
                        <div class="form-group">
                            <div style="border:1px solid #ccc; width:250px; height: 110px; overflow-y: scroll;">
                             <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-allstaff" id="selectallteachser">
                                 @foreach($teachers as $key=>$value)
                                 <div class="checkbox-inline" style="padding-left:5px;">
                                     <label style="margin-right:10px;">{{$value}}</label>
                                     <input type="checkbox" name="teachers[]" value="{{$key}}" class="chkallstaff">
                                 </div>
                                 @endforeach
                                 
                             </div>   
                            </div>
                            @if ($errors->has('idTeacher'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('idTeacher') }}</strong>
                            </label>
                            @endif
                            <span id="teachererror"></span>
                        </div>
                    </div>
                </div>
                </div>
                <div class="row clearfix">
                    <div class="col-sm-4 form-control-label">
                        <label for="classname">Message</label>
                    </div>
                    <div class="col-sm-8">
                        <div class="form-group">
                           {!! Form::textarea('message',null,['class' => 'form-control','size'=>'30x2','maxlength'=>'160']) !!}
                           @if ($errors->has('message'))
                            <label id="minmaxlength-error" class="error" for="minmaxlength">
                                <strong>{{ $errors->first('message') }}</strong>
                            </label>
                            @endif
                            <span id="smserror"></span>
                        </div>
                    </div>
                </div>
                
                
                <div class="row clearfix">
                    <div class="col-sm-8 offset-sm-2">
                        {!! Form::submit('SEND',['class' => 'btn btn-raised btn-primary btn-round waves-effect','id'=>'submit-btn']) !!}
                        {!! Form::close() !!} 
                    </div>
                </div>

            </div>
        </div>
    </div>
<!--</div>
<div class="row clearfix">-->
    <div class="col-sm-7">
        <div class="card">
            <div class="header">
                <h2><strong>Sent SMS</strong></h2>
            </div>
            <div class="body table-responsive">
                {!! Form::open(['method' => 'GET',  'action' => ['School\SmsController@index'], 'class' => 'form-horizontal']) !!}
                <div class="row clearfix">
                    <div class="col-sm-3 form-control-label">
                        <label for="classname">From Date</label>
                    </div>
                    <div class="col-sm-5">
                        <div class="form-group">
                           {!! Form::text('fromDate',null,['class' => 'form-control datepicker']) !!}
                        </div>
                    </div>
                </div>
                <div class="row clearfix">
                    <div class="col-sm-3 form-control-label">
                        <label for="classname">To Date</label>
                    </div>
                    <div class="col-sm-5">
                        <div class="form-group">
                           {!! Form::text('toDate',null,['class' => 'form-control datepicker']) !!}
                        </div>
                    </div>
                     <div class="col-sm-2">
                        {!! Form::submit('Search',['class' => 'btn btn-raised btn-primary btn-round waves-effect']) !!}
                        {!! Form::close() !!} 
                    </div>
                </div>
                <table class="table table-bordered table-striped table-hover js-basic-example dataTable">
                    <thead>
                        <tr>
                            <th>S. No.</th>
                            <th>Date</th>
                            <th>Card Holder Type</th>
                            <th>Class</th>
                            <th>EC No.</th>
                            <th>Section</th>
                            <!--<th>Subject</th>-->
                            <th>SMS</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $i = 1; ?>
                        @foreach($sms as $value)
                        <tr>
                            <th scope="row">{{$i}}</th>
                            <td>{{$value->created_at->format('d-m-Y')}}</td>
                            <td>{{$value->cardholder}}</td>
                            <td>
                                @if($value->cardholder == 'Student')
                                {{$value->classM->className or 'All'}}
                                @endif
                            </td>
                            <td>
                                @if($value->cardholder == 'Student')
                                {{$value->student->ecNo or 'All'}}
                                @endif
                            </td>
                            <td>
                                @if($value->cardholder == 'Student')
                                {{$value->section->sectionName or 'All'}}
                                @endif
                            </td>
                            <!--<td>{{$value->subject}}</td>-->
                            <td>{{$value->message}}</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!='All') {
            $.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" name="allsection"></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).ready(function() {
    $('select[name="cardholder"]').on('change', function() {
        var cardholderVal = $(this).val();
        if(cardholderVal == 'Student') {
            $('#stdsmsform').show();
            $('#staffsmsform').hide();
        }else{
            $('#stdsmsform').hide();
            $.ajax({
                url: "{{url('/school/emptype') }}"+'/' +cardholderVal + "/employees",
                type: "GET",
                dataType: "json",
                success:function(data) {
                    $('#staffsmsform').show();
                    $('#idTeacher').empty();
                    $('#idTeacher').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" name="allsection"></div>');
                    $.each(data, function(key, value) {
                       $('#idTeacher').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>');
                        
                    });
                }
            });
            
           
        }
    });
});
$(document).on('click', '.select-allstaff', function(){
    var checkAllstaff = this.checked;
    if(checkAllstaff === true){
            $('.chkallstaff').each(function () {
                this.checked = checkAllstaff;
            });
    }else{
        $('.chkallstaff').each(function () {
                this.checked = checkAllstaff;
        });
    }
 });
$(document).on('click', '.select-all', function(){
    var checkAll = this.checked;
        if(checkAll === true){
            $('input[type=checkbox]').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;"><strong>Select All</label></strong><input type="checkbox" class="select-allstd" id="selectallstd" name="allstd"></div>');
                            $.each(data, function(key, value) {
                               $('#idStudent').append('<div class="checkbox-inline" style="padding-left:10px;"><label style="margin-right:10px;">'+value+'</label><input type="checkbox" name="students[]" value="'+key+'" class="stdallselect"></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;"><label style="margin-right:42px;"><strong>Select All</label></strong><input type="checkbox" class="select-allstd" id="selectallstd" name="allstd"></div>');
                        $.each(data, function(key, value) {
                           $('#idStudent').append('<div class="checkbox-inline" style="padding-left:10px;"><label style="margin-right:10px;">'+value+'</label><input type="checkbox" name="students[]" value="'+key+'" class="stdallselect"></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;
            });
        }
});

// 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 Homework!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "Yes, delete it!",
            closeOnConfirm: true
        },
        function() {
         //   console.log('here');
            $.ajax({
                type: "DELETE",
                url: "{{url('/school/sendsms/')}}" +"/"+id,
                data: {id:id}
                       
            })
            .done(function(data) {
                swal({
                    title: "Deleted", 
                    text: "Homework 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
$('#sms_form').on('submit',function(e){
    $.ajaxSetup({
    header:$('meta[name="_token"]').attr('content')
});
 var formData =  new FormData($('#sms_form')[0]);
 $("#submit-btn").prop('disabled', true);
    $.ajax({
        type:"POST",
        url: "{{url('school/sendsms') }}",
        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/sendsms')}}";
            }
            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['idStudent']=== undefined){
                                    $( '#ecnoerror' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['idStudent']+'</strong></span>';
                                   $( '#ecnoerror' ).html( errorname );
                                }
                                if(errors['subject']=== undefined){
                                    $( '#subjecterror' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['subject']+'</strong></span>';
                                   $( '#subjecterror' ).html( errorname );
                                }
                                if(errors['message']=== undefined){
                                    $( '#smserror' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['message']+'</strong></span>';
                                   $( '#smserror' ).html( errorname );
                                }
                                if(errors['cardholder']=== undefined){
                                    $( '#cardholdererror' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['cardholder']+'</strong></span>';
                                   $( '#cardholdererror' ).html( errorname );
                                }
                                if(errors['idTeacher']=== undefined){
                                    $( '#teachererror' ).empty();
                                }else{
                                   errorname = '<span class="help-block"><strong>'+errors['idTeacher']+'</strong></span>';
                                   $( '#teachererror' ).html( errorname );
                                }
                                
                             
                                
                    }
            }
    });
    return false;
});
</script>
@stop

Copyright © 2021 - 2025 IMMREX7