<div class="">
    <div class="page-title">
        <div class="title_left">
            <h3>Reticula</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>Actualizar materia en retícula</h2>
                    <div class="clearfix"></div>
                </div>
                <div class="x_content">
                    <form id="form-nueva" data-parsley-validate class="form-horizontal form-label-left"
                        enctype="multipart/form-data">
                        <div class="mb-1 row">
                            <div class="col-form-label col-md-3 col-sm-3 col-xs-12 text-left text-md-right">
                                <label class="text-sm-left" for="materia">Materia
                                    <span class="required">*</span>
                                </label>
                            </div>
                            <div class="col-md-5 col-sm-6 col-xs-12">
                                <input type="hidden" name="ejex" id="ejex" value="{{ $dm->x_detmat }}">
                                <input type="hidden" name="ejey" id="ejey" value="{{ $dm->y_detmat }}">
                                <select id="materia" name="materia" required="required"
                                    class="form-control form-control-sm">
                                    <option value="">--Seleccione--</option>
                                    @foreach ($mat as $m)
                                        @if ($m->cve_mat == $dm->cve_mat)
                                            <option value="{{ $m->cve_mat }}" selected>{{ $m->nombre_mat }}</option>
                                        @else
                                            <option value="{{ $m->cve_mat }}">{{ $m->nombre_mat }}</option>
                                        @endif
                                    @endforeach


                                </select>
                            </div>
                        </div>
                        <div class="mb-1 row">
                            <div class="col-label col-md-3 col-sm-3 col-xs-12 text-left text-md-right">
                                <label class="text-sm-left" for="cadena">Cadena
                                </label>
                            </div>
                            <div class="col-md-5 col-sm-6 col-xs-12">
                                <select id="cadena" name="cadena" class="form-control form-control-sm">
                                    <option value="">--Seleccione--</option>
                                    @foreach ($mat as $m)
                                        <option value="{{ $m->cve_mat }}">{{ $m->nombre_mat }}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="col-md-1 col-sm-2 col-xs-12">
                                <button type="button" class="btn btn-block btn-secondary btn-sm"
                                    onclick="mas_cadena()"><i class="fa fa-plus"></i>
                                </button>
                            </div>
                        </div>
                        <div id="contenedor_cadenas">
                            @foreach ($dm->DetalleMatateriaP as $p)
                                <div class="mb-1 row row_correquisito" id="row_requisito_11">
                                    <input type="hidden" class="cadena_id" value="clave">
                                    <div class="col-form-label col-md-3 col-sm-3 col-xs-12 text-left text-md-right">
                                        <label class="text-sm-left" for="cadena"> <span
                                                class="required"></span></label></div>
                                    <div class="col-md-5 col-sm-6 col-xs-12"><label for="">Materia</label>
                                    </div>
                                    <div class="col-md-1 col-sm-2 col-xs-12"><button type="button"
                                            class="btn btn-danger btn-block btn-sm" onclick="menos_elementos(1)"><i
                                                class="fa fa-trash"></i></button>
                                    </div>
                                </div>
                            @endforeach

                        </div>
                        <div class="mb-1 row">
                            <div class="col-form-label col-md-3 col-sm-3 col-xs-12 text-left text-md-right">
                                <label class="text-sm-left" for="depto">Departamento al que pertenece
                                    <span class="required">*</span>
                                </label>
                            </div>
                            <div class="col-md-5 col-sm-6 col-xs-12">
                                <select id="depto" name="depto" required="required"
                                    class="form-control form-control-sm">
                                    <option value="">--Seleccione--</option>
                                    @foreach ($deto as $dp)
                                        @if ($dp->idDpto == $dm->departamento->idDpto)
                                            <option value="{{ $dp->idDpto }}" selected>{{ $dp->nombre }}</option>
                                        @else
                                            <option value="{{ $dp->idDpto }}">{{ $dp->nombre }}</option>
                                        @endif
                                    @endforeach

                                </select>
                            </div>
                        </div>
                        <div class="mb-1 row">
                            <div class="col-form-label col-md-3 col-sm-3 col-xs-12 text-left text-md-right">
                                <label class="text-sm-left" for="correqusito">Correquisito
                                </label>
                            </div>
                            <div class="col-md-5 col-sm-6 col-xs-12">
                                <select id="correquisito" name="correquisito" class="form-control form-control-sm">
                                    <option value="">--Seleccione--</option>
                                    @foreach ($mat as $m)
                                        <option value="{{ $m->cve_mat }}">{{ $m->nombre_mat }}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="col-md-1 col-sm-2 col-xs-12 m">
                                <button type="button" class="btn btn-secondary btn-sm btn-block"
                                    onclick="mas_correquisitos()"><i class="fa fa-plus"></i>
                                </button>
                            </div>
                        </div>
                        <div id="contenedor_correquisitos">
                        </div>
                        <div class="mb-1 row">
                            <div class="col-form-label col-md-3 col-sm-3 col-xs-12 text-left text-md-right">
                                <label class="text-sm-left" for="prerrequisito">Prerrequisito
                                </label>
                            </div>
                            <div class="col-md-5 col-sm-6 col-xs-12">
                                <select id="prerrequisito" name="prerrequisito" class="form-control form-control-sm">
                                    <option value="">--Seleccione--</option>
                                    @foreach ($mat as $m)
                                        <option value="{{ $m->cve_mat }}">{{ $m->nombre_mat }}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="col-md-1 col-sm-2 col-xs-12 m">
                                <button type="button" class="btn btn-secondary btn-sm btn-block"
                                    onclick="mas_prerrequisitos()"><i class="fa fa-plus"></i>
                                </button>
                            </div>
                        </div>
                        <div id="contenedor_prerrequisitos">
                        </div>
                        <div class="mb-1 row">
                            <div class="col-form-label col-md-3 col-sm-3 col-xs-12 text-left text-md-right">
                                <label class="text-sm-left" for="matesp">Materia de especialidad
                                    <span class="required">*</span>
                                </label>
                            </div>
                            <div class="col-md-5 col-sm-6 col-xs-12">
                                <select id="matesp" name="matesp" required="required"
                                    class="form-control form-control-sm">
                                    <?php $l = '';
                                    $m = ''; ?>
                                    @if ($dm->esp_detmat == 'LICENCIATURA')
                                        <?php $l = 'selected'; ?>
                                    @else
                                        <?php $m = 'selected'; ?>
                                    @endif
                                    <option value="">--Seleccione--</option>
                                    <option value="LICENCIATURA" {{ $l }}>LICENCIATURA</option>
                                    <option value="MAESTRIA" {{ $m }}>MAESTRÍA</option>
                                </select>
                            </div>
                        </div>
                        <div class="ln_solid"></div>
                        <div class="mb-1 row">
                            <div class="col-md-3 col-sm-12"></div>
                            <div class="col-md-6 col-sm-12">
                                <div class="row">
                                    <div class="col">
                                        <button type="button" onclick="update_materiareticula(this.form,{{ $dm->cve_detmat }})"
                                            class="btn btn-success btn-block" form="form-nueva"><i
                                                class=" fa fas fa-pencil"></i> Guardar </button>
                                    </div>
                                    <div class="col">
                                        <button class="btn btn-dark btn-block" type="button"
                                            onclick="edit_reticula({{ $sem->cve_rec }})"><i class="fa fa-times"></i>
                                            Cancelar</button>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3 col-sm-12"></div>
                        </div>
                    </form>
                    <br>

                </div>
            </div>
        </div>
    </div>
</div>
