IMMREX7

aku nok ndi : /home/spdtg/www/schoolmis/resources/views/schools/busroutes/
File Up :
aku nok ndi : /home/spdtg/www/schoolmis/resources/views/schools/busroutes/index.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>@if(isset($route))Edit @else  Add @endif</strong> Bus Route</h2>
            </div>
            <div class="body">
                @if(isset($route))
                {!! Form::model( $route, ['route' => ['busroutes.update', $route->idBusRoute], 'method' => 'put','class'=>'form-horizontal'] ) !!}
                @else
                {!! Form::open(['url' => 'school/busroutes','class'=>'form-horizontal']) !!}
                @endif
                <div class="row clearfix">
                    <table class="table">
                    <thead>
                        <tr>
                            <th>S.NO.</th>
                            <th>Route Name</th>
                            <th>Rate</th>
                            <th>Bus No</th>
                            <th>Driver Name</th>
                            <th>Supporter Name</th>
                            <th>Contact No</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody  id="optional_list">
                        <tr>
                            <td class="sno">1</td>
                            <td>
                                <input class="form-control" type="text" id="busroute1"  name = "busroute[1][routeName]" required="required">
                            </td>
                            <td>
                                <input class="form-control" type="text" onkeypress = "return onlyNumbersandSpecialChar(event)" id="busrouterate1"  name = "busroute[1][rate]" required="required">
                            </td>
                            <td>
                                <input class="form-control" type="text" id="busrouterate1"  name = "busroute[1][busNo]" required="required">
                            </td>
                            <td>
                                <input class="form-control" type="text" id="busrouterate1"  name = "busroute[1][driverName]" required="required">
                            </td>
                            <td>
                                <input class="form-control" type="text" id="busrouterate1"  name = "busroute[1][supporterName]" required="required">
                            </td>
                             <td>
                                 <input class="form-control" type="text" id="busrouterate1"  name = "busroute[1][contactNo]" required="required" minlength="10" maxlength="10" onkeypress = 'return isNumber(event)'>
                            </td>
                        </tr>
                       
                        
                   </tbody>
                    <tr>
                            <td colspan="7" style="text-align: right"><input type="button" class="add-row btn btn-sm btn-danger" value="Add Row"></td>
                        </tr>
                </table>
                </div>
                <div class="row clearfix">
                    <div class="col-sm-8 offset-sm-2">
                        @if(isset($route))
                        {!! 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']) !!}
                        @endif
                        {!! Form::close() !!} 
                    </div>
                </div>
            </div>
        </div>
    </div
</div>
</div>
<div class="row clearfix">
    <div class="col-sm-12">
        <div class="card">
            <div class="header">
                <h2><strong>List Of Bus Route</strong></h2>
            </div>
            <div class="body table-responsive">
                <table class="table table-bordered table-striped table-hover js-basic-example dataTable">
                    <thead>
                        <tr>
                            <th>S.NO.</th>
                            <th>Route Name</th>
                            <th>Rate</th>
                            <th>Bus No</th>
                            <th>Driver Name</th>
                            <th>Supporter Name</th>
                            <th>Contact No</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $i = 1; ?>
                        @foreach($routes as $var)
                        <tr>
                            <td>{{ $i }}</td>
                            <td>{{ $var->routeName }}</td>
                            <td>{{ $var->rate }}</td>
                            <td>{{ $var->busNo }}</td>
                            <td>{{ $var->driverName }}</td>
                            <td>{{ $var->supporterName }}</td>
                            <td>{{ $var->contactNo }}</td>
                            <td>
                                <a href='{{url('/school/busroutes/'.$var->idBusRoute.'/edit')}}' class="btn btn-raised btn-info waves-effect btn-round"><i class="fa fa-edit"></i> Edit</a>
                                <button class="btn btn-raised btn-danger waves-effect btn-round js-sweetalert" data-id="{{$var->idBusRoute}}" data-type="confirm">DELETE</button>
                            </td>
                        </tr>
                        <?php $i++; ?>
                        @endforeach

                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
@stop
@section('script')
<script>
$(document).ready(function() {
    var i = 1;
    $(".add-row").click(function(){
        i++;  
        var markup = '<tr><td class="sno">'+i+'</td>\
                <td><input class="form-control" type="text" name="busroute['+i+'][routeName]"  required="required" autocomplete="off"></td>\n\
                <td><input class="form-control" type="text" name="busroute['+i+'][rate]" onkeypress = "return onlyNumbersandSpecialChar(event)" required="required"</td>\n\
                <td><input class="form-control" type="text" name="busroute['+i+'][busNo]" required="required"></td>\n\
                <td><input class="form-control" type="text" name="busroute['+i+'][driverName]" required="required"></td>\n\
                <td><input class="form-control" type="text" name="busroute['+i+'][supporterName]" required="required"></td>\n\
                <td><input class="form-control" type="text" name="busroute['+i+'][contactNo]" required="required"></td>\n\
                <td style="text-align:right;vertical-align: middle;"><input type="button" required="required" class="btn btn-sm btn-danger" value="Delete" id="remove_row"></td></tr>';
            $("#optional_list").append(markup);
    });
    $('#optional_list').on('click', 'input[type="button"]', function () {
        $(this).closest('tr').remove();
         i = $('.sno:last').text();
         
    });
    //Add Input field if others is selecyted
});
$(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 Bus Route!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "Yes, delete it!",
            closeOnConfirm: true
        },
        function() {
         //   console.log('here');
            $.ajax({
                type: "DELETE",
                url: "{{url('/school/busroutes/')}}" +"/"+id,
                data: {id:id}
                       
            })
            .done(function(data) {
                swal({
                    title: "Deleted", 
                    text: "Bus Route has been successfully deleted", 
                    type: "success"
                },function() {
                    location.reload();
                });
            })
            .error(function(data) {
              swal("Oops", "We couldn't connect to the server!", "error");
            });
            return false;
    });
});
</script>
@stop

Copyright © 2021 - 2025 IMMREX7