@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 ='annual_cycle' class="form-control selectpicker" onchange="fetchSubmit('#annual_cycle')">
                @foreach($annual_cycle as $a)
                <option value = {{$a->id}}> Cycle {{$a->academic_year}}  </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>
                        @if($report ==0)
                        <a href="{{ URL::action('AnnualPlansController@annualPlansShow', ['plan',$program->id]) }}">
                            {{ $program->name }}
                        @else
                        <a href="{{ URL::action('AnnualPlansController@annualPlansShow', ['report',$program->id]) }}">
                            {{ $program->name }}

                        @endif
                    </td>
                    <td id = "is_submit-{{$program->id}}" class='submitted'>

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

            
        </div>
    <script>

function fetchSubmit(annual_cycle){
            $.post(
                "{{URL::action('AnnualPlansController@fetchSubmitted')}}",
                {
                    annual_cycle:$(annual_cycle).val(),
                    report:{{$report}}

                },
                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
