@extends('adminlte::page')
@section('content_header')
    <h1>{{request()->session()->get('session_fname')}}_Group</h1>
@stop
<script src="//code.jquery.com/jquery.js"></script>
@section('content')
@notifyCss
@notifyJs
@if ($errors->any())
    <div class="alert alert-danger">
        <ul>
            @foreach ($errors->all() as $error)
                <li>{{ $error }}</li>
            @endforeach
        </ul>
    </div>
@endif
@if (session('status'))
    <div class="alert alert-success">
        {{ session('status') }}
    </div>
@endif
@include('notify::messages')
<div class="row">
    <!--row starts-->
    <div class="col-md-12">   
        <div class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title">
                    {{request()->session()->get('session_fname')}} Group
                </h3>
            </div>
            <div class="panel-body">
                <form class="form-horizontal" action="{{ url('file_grouppost') }}" method="post" id="filegrp" onsubmit="return validation();">
                    <!-- CSRF Token -->
                    <input type="hidden" name="_token" value="{{csrf_token()}}">
                    <!-- Name input-->
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="name">{{request()->session()->get('session_fname')}} Group<span style="color: red;">*</span></label>
                        <div class="col-md-6">
                            <input id="file_group" name="file_group" type="text" placeholder="Enter the subject group" class="form-control" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="remarks">Description<span style="color: red;">*</span></label>
                        <div class="col-md-6">
                            <textarea class="form-control resize_vertical" id="description" name="description" placeholder="Please enter description here..." rows="3" required></textarea>
                        </div>
                    </div>
                    <!-- Form actions -->
                    <div class="form-position">
                        <div class="col-md-5 text-right">
                            <button type="submit" class="btn btn-responsive btn-primary btn-sm" id="btn">Submit</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <div class="panel panel-body">  
            <table class="table table-bordered" id="file_group_table">
                <thead>
                    <tr>
                        <th>Id</th>
                        <th>{{request()->session()->get('session_fname')}} Group</th>
                        <th>Description</th>
                        <th>Updated At</th>
                        <th>Actions</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
    <!--md-12 ends-->
</div>
<script>
    $(function() 
    {
        $('#file_group_table').DataTable({
            processing: true,
            serverSide: true,
            ajax: '{!! url('file_grouppostdata') !!}',
            columns: [
                { data: 'id', name: 'id' },
                { data: 'file_group', name: 'file_group' },
                { data: 'description', name: 'description' },
                { data: 'updated_at', name: 'updated_at' },
                { data: 'action', name: 'action' }
            ]
        });
    });

    function validation()
    {  
        if(document.getElementById('file_group').value=="")
        {
            alert(" Please enter the File_Group");
            document.getElementById('file_group').focus();
            return false;
        }
        if(document.getElementById('description').value=="")
        {
            alert(" Please enter the Description");
            document.getElementById('description').focus();
            return false;
        }
        document.getElementById("btn").disabled='true';
        return true;
    }
</script>
@stop