
<?php $__env->startSection('cssDashboard'); ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('text'); ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<div class="card shadow mb-4">
    <div class="card-header py-3">
        <span class="m-0 font-weight-bold text-primary title-table">Relacionar departamento e institución</span>
      </div>
    <div class="card-body">
        <form method="POST" action="<?php echo e(Request::url()); ?>" class="needs-validation" enctype="multipart/form-data" novalidate>
            <?php echo csrf_field(); ?>
            <input type="hidden" name="action" id="action" value="<?php echo e($action); ?>"/>
            <?php if(isset($department_institute)): ?>
              <input type="hidden" name="id" id="id" value="<?php echo e($department_institute['id']); ?>">
            <?php else: ?>
              <input type="hidden" name="id" id="id" value="0">
            <?php endif; ?>

            <div class="form-row">
                <div class="form-group col-md-6">
                    <label for="institutes_id">Instituto:</label>
                    <select type="text" class="form-control" id="institutes_id" name="institutes_id" required>
                        <option value="">Selecciona...</option>
                        <?php if(isset($institutes)): ?>
                            <?php if(isset($department_institute)): ?>
                                <?php $__currentLoopData = $institutes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $element): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($element['id']); ?>" <?php echo e($element['id'] == $department_institute->institutes_id ? 'selected' : ''); ?>><?php echo e($element['name']); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <?php else: ?>
                                <?php $__currentLoopData = $institutes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $element): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($element['id']); ?>"><?php echo e($element['name']); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <?php endif; ?>
                        <?php endif; ?>
                    </select>
                    <div class="invalid-feedback">
                        Favor de seleccionar el insistuto a relacionar
                    </div>
                </div>
                <div class="form-group col-md-6">
                    <label for="departments_id">Departamento:</label>
                    <select type="text" class="form-control" id="departments_id" name="departments_id" required>
                        <option value="">Selecciona...</option>
                        <?php if(isset($departments)): ?>
                            <?php if(isset($department_institute)): ?>
                                <?php $__currentLoopData = $departments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $element): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($element['id']); ?>" <?php echo e($element['id'] == $department_institute->departments_id ? 'selected' : ''); ?>><?php echo e($element['name']); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <?php else: ?>
                                <?php $__currentLoopData = $departments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $element): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($element['id']); ?>"><?php echo e($element['name']); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <?php endif; ?>
                        <?php endif; ?>
                    </select>
                    <div class="invalid-feedback">
                        Favor de seleccionar el insistuto a relacionar
                    </div>
                </div>
            </div>
            <div class="form-row">
                <div class="form-group files-div col-md-3">
                    <?php if(isset($department_institute->stamp)): ?>                        
                        <span class="file stamp-img">
                            <input type="file" accept="image/*" name="stamp" id="stamp" class="form-control">
                            <div class="invalid-feedback">
                                Favor de ingresar la imagen del sello del departamento
                            </div>
                        </span>
                        <label for="stamp" class="label-button">
                            <span id="title-dept"><?php echo e($department_institute->stamp); ?></span>
                        </label>
                    <?php else: ?>
                        <span class="file stamp-img">
                            <input type="file" accept="image/*" name="stamp" id="stamp" class="form-control" required>
                            <div class="invalid-feedback">
                                Favor de ingresar la imagen del sello del departamento
                            </div>
                        </span>
                        <label for="stamp" class="label-button">
                            <span id="title-dept">Subir el sello del departamento</span>
                        </label>
                    <?php endif; ?>
                </div>
                <div class="form-group files-div col-md-3">
                    <?php if(isset($department_institute->stampSRC)): ?>
                        <img id="imagenPrevisualizacion" src="<?php echo e($department_institute->stampSRC); ?>">
                    <?php else: ?>
                        <img id="imagenPrevisualizacion">
                    <?php endif; ?>
                </div>
                <div class="form-group files-div col-md-3">
                    <?php if(isset($department_institute->image)): ?>
                        <span class="file image-img">
                            <input type="file" accept="image/*" name="image" id="image" class="form-control">
                            <div class="invalid-feedback">
                                Favor de ingresar la imagen del departamento
                            </div>
                        </span>
                        <label for="image" class="label-button">
                            <span><?php echo e($department_institute->image); ?></span>
                        </label>  
                    <?php else: ?>
                        <span class="file image-img">
                            <input type="file" accept="image/*" name="image" id="image" class="form-control" required>
                            <div class="invalid-feedback">
                                Favor de ingresar la imagen del departamento
                            </div>
                        </span>
                        <label for="image" class="label-button">
                            <span>Subir la imagen del departamento</span>
                        </label>  
                    <?php endif; ?>
                </div>
                <div class="form-group files-div col-md-3">
                    <?php if(isset($department_institute->imageSRC)): ?>
                        <img id="imagenPrevisualizacion2" src="<?php echo e($department_institute->imageSRC); ?>">
                    <?php else: ?>
                        <img id="imagenPrevisualizacion2">
                    <?php endif; ?>
                </div>
            </div>
            <div class="headerAppend">Dirección Principal</div>
            <div class="form-row">
                <div class="form-group col-md-3">
                    <label for="street">Calle</label>
                    <?php if(isset($address)): ?>
                        <input type="text" class="form-control" id="street" name="street" placeholder="Ingresar la calle" required value="<?php echo e($address->street); ?>">
                    <?php else: ?>
                        <input type="text" class="form-control" id="street" name="street" placeholder="Ingresar la calle" required>
                    <?php endif; ?>
                    <div class="invalid-feedback">
                    Favor de ingresar la calle de la dirección del departamento
                    </div>
                </div>
                <div class="form-group col-md-3">
                    <label for="externalNumber">Número externo</label>
                    <?php if(isset($address)): ?>
                        <input type="text" class="form-control" id="externalNumber" name="externalNumber" placeholder="Ingresar el número externo" required value="<?php echo e($address->externalNumber); ?>">
                    <?php else: ?>
                        <input type="text" class="form-control" id="externalNumber" name="externalNumber" placeholder="Ingresar el número externo" required>
                    <?php endif; ?>
                    <div class="invalid-feedback">
                    Favor de ingresar el número externo de la dirección del departamento
                    </div>  
                </div>
                <div class="form-group col-md-3">
                    <label for="internalNumber">Número interno</label>
                    <?php if(isset($address)): ?>
                        <input type="text" class="form-control" id="internalNumber" name="internalNumber" placeholder="Ingresar el número interno" value="<?php echo e($address->internalNumber); ?>">
                    <?php else: ?>
                        <input type="text" class="form-control" id="internalNumber" name="internalNumber" placeholder="Ingresar el número interno">
                    <?php endif; ?>
                </div>
                <div class="form-group col-md-3">
                    <label for="postalCode">Código Postal</label>
                    <div class="input-group">
                        <?php if(isset($community)): ?>
                            <input type="text" class="form-control" id="postalCode" name="postalCode" placeholder="Ingresa tú numero postal" required data-mask="00000" value="<?php echo e($community->postalCode); ?>">
                        <?php else: ?>
                            <input type="text" class="form-control" id="postalCode" name="postalCode" placeholder="Ingresa tú numero postal" required data-mask="00000">
                        <?php endif; ?>
                        <div class="input-group-append">
                            <button class="btn btn-outline-secondary" type="button" onclick="filterCP(this)" id="filter">Filtrar</button>
                        </div>
                        <div class="invalid-feedback">
                            Favor de ingresar el código postal de la dirección del proveedor
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-row">
                <div class="form-group col-md-4">
                    <label for="communities_id">Colonia</label>
                    <?php if(isset($address)): ?>
                        <select id="communities_id" name="communities_id" class="form-control" required>
                            <option value="">Selecciona...</option>
                            <?php if(isset($communities)): ?>
                                <?php $__currentLoopData = $communities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $element): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($element['id']); ?>" <?php echo e($element['id'] == $address->communities_id ? 'selected' : ''); ?>><?php echo e($element['name']); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <?php endif; ?>
                        </select>
                    <?php else: ?>
                        <select id="communities_id" name="communities_id" class="form-control" disabled required>
                            <option value="">Selecciona...</option>
                            <?php if(isset($communities)): ?>
                                <?php $__currentLoopData = $communities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $element): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($element['id']); ?>" <?php echo e($element['id'] == $address->communities_id ? 'selected' : ''); ?>><?php echo e($element['name']); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <?php endif; ?>
                        </select>
                    <?php endif; ?>
                </div>
                <div class="form-group col-md-4">
                    <label for="municipalities_id">Municipio</label>
                    <select id="municipalities_id" name="municipalities_id" class="form-control" disabled required>
                        <option value="">Selecciona...</option>
                        <?php if(isset($address)): ?>
                            <?php if(isset($municipalities)): ?>
                                <option value="<?php echo e($municipalities->id); ?>" selected><?php echo e($municipalities->name); ?></option>
                            <?php endif; ?>
                        <?php endif; ?>
                    </select>
                </div>
                <div class="form-group col-md-4">
                    <label for="states_id">Estado</label>
                    <select id="states_id" name="states_id" class="form-control" disabled required>
                        <option value="">Selecciona...</option>
                        <?php if(isset($address)): ?>
                            <?php if(isset($states)): ?>
                            <option value="<?php echo e($states->id); ?>" selected><?php echo e($states->name); ?></option>
                            <?php endif; ?>
                        <?php endif; ?>
                    </select>
                </div>
            </div>

            <a href="instituto_departamento "  class="btn btn-primary float-right">Cancelar</a>
            <button type="submit" class="btn btn-primary float-right" style="margin-right: 3px;">Guardar</button>
          </form>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('jsDashboard'); ?>
  <script src="../assets/js/mainForm.js"></script>
  <script src="../assets/js/departmentInstituteForm.js"></script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('base.base', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\laragon\www\ApoyosPresidencia\resources\views/catalogs/departmentInstituteForm.blade.php ENDPATH**/ ?>