
<div class="">
  <div class="page-title">
    <div class="title_left">
      <h3>Materia</h3>
    </div>
  </div>

  <div class="clearfix"></div>

  <div class="row">
    <div class="col-md-12 col-sm-12 col-xs-12">
      <div class="x_panel">
        <div class="x_title">
          <h2>Listado de Unidades</h2>
          <div class="clearfix"></div>
        </div>
        <div class="x_content">
            <div class="table-responsive">
                <table class="table table-striped jambo_table bulk_action">
                    <thead>
                        <tr class="headings">
                            <th class="column-title">No.</th>
                            <th class="column-title">Materia </th>
                            <th class="column-title">No. Unidad</th>
                            <th class="column-title">Tema</th>
                            <th class="column-title">Subtema</th>
                            <th class="column-title no-link last"><span class="nobr">Action</span>
                            </th>
                            <th class="bulk-actions" colspan="7">
                                <a class="antoo" style="color:#fff; font-weight:500;">Bulk Actions ( <span class="action-cnt"> </span> ) <i class="fa fa-chevron-down"></i></a>
                            </th>
                        </tr>
                    </thead>

                    <tbody>
                        @foreach ($unidad as $u)
                        <tr>
                            <td>{{$loop->iteration}}</td>
                            <?php $bandera=false;?>
                                @foreach ($materia as $m)
                                @foreach ($m->TemariosMaterias as $mtm)
                                    @if($mtm->unidad_id == $u->id)
                                    <?php $bandera=true; ?>
                                    <td>{{$m->nombre}}</td>
                                    @endif
                                @endforeach 
                                @if($bandera != true)
                                    <?php $bandera=false; ?>
                                    <td></td>
                                @endif
                                @endforeach
                            
                            <td>{{$u->numero}}</td>
                            <td>{{$u->tema}}</td>
                            <td>{{$u->subtema}}</td>
                            <td>
                                <button type="button" class="btn btn-default" onclick="consultar_unidad({{ $u->id}})"><span class="fa fa-eye"></span></button>
                                <button type="button" class="btn btn-default" onclick="modificar_unidad({{ $u->id}}, {{$m->id}})"><span class="fa fa-pencil"></span></button>
                                <button type="button" class="btn btn-default" onclick="delete_materia({{ $m->id }})"><span class="fa fa-trash"></span></button>
                            </td>
                        </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>
        </div>
      </div>
    </div>
  </div>
</div>
