@extends('layouts.master')

@section('navigation')
    @if (Auth::user()->role == 1)
        @include('local.managers.admins._new_navigation')
    @elseif(Auth::user()->role == 2)
        @include('local.managers.sCoords._new_navigation')
    @elseif(Auth::user()->role == 3)
        @include('local.managers.pCoords._new_navigation')
    @endif
@stop

@section('main')
    <div class="row">
        <div class="col-md-12">
            <p>Click the links below to see annual appraisal plans for a specific program with assessed courses:</p>

        </div>

        <div class='col-md-12'>
            <select id ='typ' class="form-control selectpicker" onchange="fetchSubmit('#typ')">
                @foreach($typ as $t)
                <option value = {{$t->id}}> Cycle {{$t->year_start}}-{{$t->year_end}}  </option>
                @endforeach

            </select>
        </div>


            <table class='table table-striped table-condensed '>
                <thead>
                    <tr>
                        <th>Program</th>
                        <th>Submitted this cycle</th>
                    </tr>
                </thead>
                <tbody>
                @foreach ($programs as $program)

                    <tr>
                        <td>
                            <a href="{{ URL::action('ThreeYearPlanController@showPDFs', [$program->id]) }}">
                            {{ $program->name }}
                        </td>
                        <td id = "is_submit-{{$program->id}}" class='submitted'>

                        </td>
                    </tr>
                @endforeach
                </tbody>
                </table>
        </div>
   

    <script>

        function fetchSubmit(typ){
            $.post(
                "{{URL::action('ThreeYearPlanController@fetchSubmitted')}}",
                {
                    typ:$(typ).val()
                },
                function(programs){
                    $(".submitted").html(' ');
                    $.each(programs, function(ind, program){
                        if(program.is_submitted){
                            $('#is_submit-'+program.program_id).html(
                                '<span class="glyphicon glyphicon-ok-sign"></span>'
                            )
                        }
                    })
                }
            )
        }

        fetchSubmit("#typ");


</script>
@stop
