

<?php


if(isset($submit)){
  ob_start();
}
echo '<html>';
echo '<head>';

echo '</head>';
echo '<body id="theDocument">';

//Inline styles (only for printing)
echo '<style type="text/css">
    body
    {
        font-family: "Arial", sans-serif;
        width:90%;
        margin: 0 auto;
    }
    .header-text
    {
        text-align:center;
        font-weight: bold;
        margin:0;
    }

    h1.header-text
    {
      margin: 15px auto;
      width:75%;
      font-size: 25px;
    }

    table
    {
        border-collapse: collapse;
        border: 1px solid black;
        width: 100%;
        margin: 30px auto;
        font-size:1.5vw;
    }
    td, th
    {
        border: 1px solid black;
        padding: 5px;
    }

    .activity-name-row
    {
      background:black;
      color:white;
    }

    .activity-headers-row
    {
      background:lightgrey;
      font-weight:bold;
    }

    .report-info
    {
      margin:5px 0;
      font-size: 16px;
    }

    .criterion-field
    {
      text-align:left;
    }

    .score-field, .total, .percentage
    {
      text-align:center;
    }

    .header
    {
      margin: 30px 0;
    }

    .content
    {
      font-size: 12px;
    }

    .logo
    {
      position:absolute;
      right:0;
      top: 30px;
      width: 100px;
    }

    ol{
      list-style-type:none;
    }

    @media print{@page {size: landscape}}
</style>';

echo '<style type="text/css" media="print">
	  @page { size: landscape; }
	</style>';

?>
<img class="logo" src="{{ asset('images/logo_uprrp_bw.png') }}" alt="UPRRP Logo">

<div class="header">
    <p class="header-text">University of Puerto Rico, Río Piedras Campus</p>
    <p class="header-text">Online Learning Assessment System</p>

    <h1 class="header-text">Three Year Plan for {{ $program->name }} from {{ $three_year_plan->year_start }} to
        {{ $three_year_plan->year_end }}</h1>
</div>



@foreach ($typ_semesters as $semester)
    <br>
    <br>
    <h2 class='header-text'>{{ $semester->name }}</h2>
    <br>
    @foreach ($typ_semester_outcome[$semester->semester_id] as $outcome)
      @if(count($outcome->objectives))
        <span>
            <h3>{{ $outcome->name }}</h3>
        </span>
        <table class="table table-striped table-condensed" style="table-layout: fixed">
            <thead>
                <tr>

                    <th>Objectives</th>
                    <th>Courses</th>

                </tr>
            </thead>
            <tbody>

                @foreach ($outcome->objectives as $index => $objective)
                    <tr>

                        <td>
                            {{ $index + 1 }}. {{ $objective->text }}
                        </td>
                        <td>
                            <ol>
                                @foreach ($objective->courses as $course)
                                    <li>[{{ $course->code }}{{ $course->number }}] {{ $course->name }}</li>
                                @endforeach
                            </ol>
                        </td>

                    </tr>
                @endforeach

            </tbody>
        </table>
        <br>
        <br>
        @endif
        @endforeach
@endforeach 


</body></html>


<script>

  @if($view==0 && !isset($submit))
    window.print();

  @elseif(isset($submit))

    window.close();
  @endif



  </script>


@if(isset($submit))
<?php 

  $path = app_path() . '/views/three_year_plan_htmls/' . date('d-m-Y') . '-for-' . $program->id . '-by-' . Auth::user()->id . '.blade.php';
  $ob = ob_get_contents();
  $ob = str_replace("window.close();", '', $ob);
  file_put_contents($path, $ob);
  ob_end_flush();

  //return Redirect::action('AnnualPlansController@showPlan', array($program->id));

  ?>

  @endif



