
<?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"><?php echo e($title); ?></span>
      </div>
    <div class="card-body">
        <form method="POST" action="<?php echo e(Request::url()); ?>" class="needs-validation" novalidate>
            <?php echo csrf_field(); ?>
            <input type="hidden" name="action" id="action" value="<?php echo e($action); ?>"/>
            <?php if(isset($supplier)): ?>
              <input type="hidden" name="id" id="id" value="<?php echo e($supplier['id']); ?>">
            <?php else: ?>
              <input type="hidden" name="id" id="id" value="0">
            <?php endif; ?>
            <div class="form-row">
              <div class="form-group col-md-4">
                <label for="companyname">Nombre o razón social</label>
                <?php if(isset($supplier)): ?>
                  <input type="text" class="form-control" id="companyname" name="companyname" placeholder="Ingrese el nombre del proveedor" required value="<?php echo e($supplier['companyname']); ?>">
                <?php else: ?>
                  <input type="text" class="form-control" id="companyname" name="companyname" placeholder="Ingrese el nombre del proveedor" required>
                <?php endif; ?>
                <div class="invalid-feedback">
                    Favor de ingresar el nombre del proveedor
                </div>
              </div>
              <div class="form-group col-md-2">
                <label for="typeRFC">¿Es persona fisica?</label>
                <div class="custom-control custom-switch">
                  <?php if(isset($supplier)): ?>
                    <input type="checkbox" class="custom-control-input" name="typeRFC" id="typeRFC" <?php echo e($supplier['ismoral'] == 1 ? 'checked' : ''); ?>>
                  <?php else: ?>
                    <input type="checkbox" class="custom-control-input" name="typeRFC" id="typeRFC">
                  <?php endif; ?>
                  <label class="custom-control-label" for="typeRFC">No/Si</label>
                </div>
              </div>
              <div class="form-group col-md-3">
                <label for="RFC">RFC</label>
                <?php if(isset($supplier)): ?>
                  <input type="text" class="form-control" id="RFC" name="RFC" placeholder="Ingrese el RFC" required data-mask="<?php echo e($supplier['ismoral'] == 0 ? 'SSS000000AAA' : 'SSSS000000AAA'); ?>" value="<?php echo e($supplier['RFC']); ?>">
                <?php else: ?>
                  <input type="text" class="form-control" id="RFC" name="RFC" placeholder="Ingrese el RFC" required data-mask="SSS000000AAA">
                <?php endif; ?>
                <div class="invalid-feedback">
                    Favor de ingresar el RFC del proveedor
                </div>
              </div>
              <div class="form-group col-md-2">
                <label for="active">¿Activo?</label>
                <div class="custom-control custom-switch">
                  <?php if(isset($supplier)): ?>
                    <input type="checkbox" class="custom-control-input" name="active" id="active" <?php echo e($supplier["active"] == 1 ? 'checked' : ''); ?>>
                  <?php else: ?>
                    <input type="checkbox" class="custom-control-input" name="active" id="active">
                  <?php endif; ?>
                  <label class="custom-control-label" for="active">No/Si</label>
                </div>
              </div>
            </div>
            <div class="form-row">
              <div class="form-group col-md-4">
                <label for="email">Correo electrónico</label>
                <?php if(isset($supplier)): ?>
                  <input type="text" class="form-control" id="email" name="email" placeholder="Ingresar correo electrónico" required value="<?php echo e($supplier['email']); ?>">
                <?php else: ?>
                  <input type="text" class="form-control" id="email" name="email" placeholder="Ingresar correo electrónico" required>
                <?php endif; ?>
                <div class="invalid-feedback">
                    Favor de ingresar el correo electrónico del proveedor
                </div>
              </div>
              <div class="form-group col-md-8">
                <label for="description">Descripción</label>
                <?php if(isset($supplier)): ?>
                  <input type="text" class="form-control" id="description" name="description" placeholder="Ingresar el giro y descripción del proveedor" required value="<?php echo e($supplier['description']); ?>"/>
                <?php else: ?>
                  <input type="text" class="form-control" id="description" name="description" placeholder="Ingresar el giro y descripción del proveedor" required/>
                <?php endif; ?>
                <div class="invalid-feedback">
                  Favor de ingresar la descripción del negocio del proveedor
                </div>
              </div>
            </div>
            <hr>
            <div>
              <span class="m-0 font-weight-bold text-primary title-table">Dirección(es)
                  <button type="button" id="addAddress" class="btn btn-primary float-right">Agregar</button>
              </span>
              <?php if(isset($supplier)): ?>
                <input type="hidden" name="countAddress" id="countAddress" value="<?php echo e($supplier['countAddress']); ?>">
                <input type="hidden" name="countTotalA" id="countTotalA" value="<?php echo e($supplier['countAddress']); ?>">
              <?php else: ?>
                <input type="hidden" name="countAddress" id="countAddress" value="1">
                <input type="hidden" name="countTotalA" id="countTotalA" value="1">
              <?php endif; ?>
            </div>
            <hr>
            <div class="headerAppend">Dirección Principal</div>
              <?php if(isset($supplier)): ?>
                <div class="form-row">
                  <div class="form-group col-md-3">
                    <label for="street1">Calle</label>
                    <input type="text" class="form-control" id="street1" name="street1" placeholder="Ingresar la calle" required value="<?php echo e($supplier['addresses']['street1']); ?>">
                    <div class="invalid-feedback">
                      Favor de ingresar la calle de la dirección del proveedor
                    </div>
                  </div>
                  <div class="form-group col-md-3">
                    <label for="externalNumber1">Número externo</label>
                    <input type="text" class="form-control" id="externalNumber1" name="externalNumber1" placeholder="Ingresar el número externo" required value="<?php echo e($supplier['addresses']['externalNumber1']); ?>">
                    <div class="invalid-feedback">
                      Favor de ingresar el número externo de la dirección del proveedor
                    </div>
                  </div>
                  <div class="form-group col-md-3">
                    <label for="internalNumber1">Número interno</label>
                    <input type="text" class="form-control" id="internalNumber1" name="internalNumber1" placeholder="Ingresar el número interno" value="<?php echo e($supplier['addresses']['internalNumber1']); ?>">
                  </div>
                  <div class="form-group col-md-3">
                    <label for="postalCode1">Código Postal</label>
                    <div class="input-group">
                      <input type="text" class="form-control" id="postalCode1" name="postalCode1" placeholder="Ingresa tú numero postal" required data-mask="00000" value="<?php echo e($supplier['addresses']['postalCode1']); ?>">
                      <div class="input-group-append">
                        <button class="btn btn-outline-secondary" type="button" onclick="filterCP(this)" id="filter1">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_id1">Colonia</label>
                    <select id="communities_id1" name="communities_id1" class="form-control" required>
                      <?php if(isset($supplier['addresses']['communities1'])): ?>
                        <?php $__currentLoopData = $supplier['addresses']['communities1']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $element): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                          <option value="<?php echo e($element['id']); ?>" <?php echo e($element['id'] == $supplier['addresses']['communities_id1'] ? 'selected' : ''); ?>><?php echo e($element['name']); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                      <?php endif; ?>
                    </select>
                  </div>
                  <div class="form-group col-md-4">
                    <label for="municipalities_id1">Municipio</label>
                    <select id="municipalities_id1" name="municipalities_id1" class="form-control" disabled required>
                      <?php if(isset($supplier)): ?>
                          <option value="<?php echo e($supplier['addresses']['municipalities_id1']); ?>"><?php echo e($supplier['addresses']['municipalities_name1']); ?></option>
                      <?php endif; ?>
                    </select>
                  </div>
                  <div class="form-group col-md-4">
                    <label for="states_id1">Estado</label>
                    <select id="states_id1" name="states_id1" class="form-control" disabled required>
                      <?php if(isset($supplier)): ?>
                          <option value="<?php echo e($supplier['addresses']['states_id1']); ?>"><?php echo e($supplier['addresses']['states_name1']); ?></option>
                      <?php endif; ?>
                    </select>
                  </div>
                </div>
                <?php for($i = 2 ; $i <= $supplier['countAddress'];$i++): ?>
                  <div id="<?php echo e('fDA-'.$i); ?>">
                    <hr>
                    <div class="headerAppend">Dirección <?php echo e($i); ?>

                      <button type="button" id="<?php echo e('deleteAddress-'.$i); ?>" class="btn float-right" onclick="deleteAddress(this)">
                        <i class="fas fa-trash-alt fa-2x colorIcon"></i>
                      </button>
                    </div>
                    <div class="form-row">
                      <div class="form-group col-md-3">
                        <label for="<?php echo e('street'.$i); ?>">Calle</label>
                        <input type="text" class="form-control" id="<?php echo e('street'.$i); ?>" name="<?php echo e('street'.$i); ?>" placeholder="Ingresar la calle" required value="<?php echo e($supplier['addresses']['street'.$i]); ?>">
                        <div class="invalid-feedback">
                          Favor de ingresar la calle de la dirección del proveedor
                        </div>
                      </div>
                      <div class="form-group col-md-3">
                        <label for="<?php echo e('externalNumber'.$i); ?>">Número externo</label>
                        <input type="text" class="form-control" id="<?php echo e('externalNumber'.$i); ?>" name="<?php echo e('externalNumber'.$i); ?>" placeholder="Ingresar el número externo" required value="<?php echo e($supplier['addresses']['externalNumber'.$i]); ?>">
                        <div class="invalid-feedback">
                          Favor de ingresar el número externo de la dirección del proveedor
                        </div>
                      </div>
                      <div class="form-group col-md-3">
                        <label for="<?php echo e('internalNumber'.$i); ?>">Número interno</label>
                        <input type="text" class="form-control" id="<?php echo e('internalNumber'.$i); ?>" name="<?php echo e('internalNumber'.$i); ?>" placeholder="Ingresar el número interno" value="<?php echo e($supplier['addresses']['internalNumber'.$i]); ?>">
                      </div>
                      <div class="form-group col-md-3">
                        <label for="<?php echo e('postalCode'.$i); ?>">Código Postal</label>
                        <div class="input-group">
                          <input type="text" class="form-control" id="<?php echo e('postalCode'.$i); ?>" name="<?php echo e('postalCode'.$i); ?>" placeholder="Ingresa tú numero postal" required data-mask="00000" value="<?php echo e($supplier['addresses']['postalCode'.$i]); ?>">
                          <div class="input-group-append">
                            <button class="btn btn-outline-secondary" type="button" onclick="filterCP(this)" id="<?php echo e('filter'.$i); ?>">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="<?php echo e('communities_id'.$i); ?>">Colonia</label>
                        <select id="<?php echo e('communities_id'.$i); ?>" name="<?php echo e('communities_id'.$i); ?>" class="form-control" required>
                          <?php if(isset($supplier)): ?>
                            <?php $__currentLoopData = $supplier['addresses']['communities'.$i]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $element): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                              <option value="<?php echo e($element['id']); ?>" <?php echo e(( $element['id'] == $supplier['addresses']['communities_id'.$i]) ? 'selected' : ''); ?>><?php echo e($element['name']); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                          <?php endif; ?>
                        </select>
                      </div>
                      <div class="form-group col-md-4">
                        <label for="<?php echo e('municipalities_id'.$i); ?>">Municipio</label>
                        <select id="<?php echo e('municipalities_id'.$i); ?>" name="<?php echo e('municipalities_id'.$i); ?>" class="form-control" disabled required>
                          <?php if(isset($supplier)): ?>
                            <option value="<?php echo e($supplier['addresses']['municipalities_id'.$i]); ?>" selected><?php echo e($supplier['addresses']['municipalities_name'.$i]); ?></option>
                          <?php endif; ?>
                        </select>
                      </div>
                      <div class="form-group col-md-4">
                        <label for="<?php echo e('states_id'.$i); ?>">Estado</label>
                        <select id="<?php echo e('states_id'.$i); ?>" name="<?php echo e('states_id'.$i); ?>" class="form-control" disabled required>
                          <?php if(isset($supplier)): ?>
                            <option value="<?php echo e($supplier['addresses']['states_id'.$i]); ?>" selected><?php echo e($supplier['addresses']['states_name'.$i]); ?></option>
                          <?php endif; ?>
                        </select>
                      </div>
                    </div>
                  </div>
                <?php endfor; ?>
                <div id="addresses"></div>
              <?php else: ?>
                <div class="form-row">
                  <div class="form-group col-md-3">
                    <label for="street1">Calle</label>
                    <input type="text" class="form-control" id="street1" name="street1" placeholder="Ingresar la calle" required>
                    <div class="invalid-feedback">
                      Favor de ingresar la calle de la dirección del proveedor
                    </div>
                  </div>
                  <div class="form-group col-md-3">
                    <label for="externalNumber1">Número externo</label>
                    <input type="text" class="form-control" id="externalNumber1" name="externalNumber1" placeholder="Ingresar el número externo" required>
                    <div class="invalid-feedback">
                      Favor de ingresar el número externo de la dirección del proveedor
                    </div>
                  </div>
                  <div class="form-group col-md-3">
                    <label for="internalNumber1">Número interno</label>
                    <input type="text" class="form-control" id="internalNumber1" name="internalNumber1" placeholder="Ingresar el número interno">
                  </div>
                  <div class="form-group col-md-3">
                    <label for="postalCode1">Código Postal</label>
                    <div class="input-group">
                      <input type="text" class="form-control" id="postalCode1" name="postalCode1" placeholder="Ingresa tú numero postal" required data-mask="00000">
                      <div class="input-group-append">
                        <button class="btn btn-outline-secondary" type="button" onclick="filterCP(this)" id="filter-1">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_id1">Colonia</label>
                    <select id="communities_id1" name="communities_id1" class="form-control" disabled required>
                        <option value="">Seleccione...</option>
                    </select>
                  </div>
                  <div class="form-group col-md-4">
                    <label for="municipalities_id1">Municipio</label>
                    <select id="municipalities_id1" name="municipalities_id1" class="form-control" disabled required>
                      <option value="">Seleccione...</option>
                    </select>
                  </div>
                  <div class="form-group col-md-4">
                    <label for="states_id1">Estado</label>
                    <select id="states_id1" name="states_id1" class="form-control" disabled required>
                      <option value="">Seleccione...</option>
                    </select>
                  </div>
                </div>
                <div id="addresses"></div>
              <?php endif; ?>
            <hr>
            <div>
              <span class="m-0 font-weight-bold text-primary title-table">Teléfono(s)<span class="table-add float-right">
                <button id="addPhoneNumber" type="button" class="btn btn-primary float-right">Agregar</button>
              </span>
              <?php if(isset($supplier)): ?>
                <input type="hidden" name="countPhoneNumber" id="countPhoneNumber" value="<?php echo e($supplier['countPhoneNumber']); ?>">
                <input type="hidden" name="countTotalPN" id="countTotalPN" value="<?php echo e($supplier['countPhoneNumber']); ?>">
              <?php else: ?>
                <input type="hidden" name="countPhoneNumber" id="countPhoneNumber" value="1">
                <input type="hidden" name="countTotalPN" id="countTotalPN" value="1">
              <?php endif; ?>
            </span>
            </div>
            <hr>
            <div class="headerAppend">Teléfono Principal</div>
            <?php if(isset($supplier)): ?>
              <div class="form-row">
                <div class="form-group col-md-4">
                  <label for="phonenumber1">Número telefónico</label>
                  <input type="text" class="form-control" id="phonenumber1" name="phonenumber1" placeholder="Ingresar número telefónico" required data-mask="000-000-0000" value="<?php echo e($supplier['phonesNumbers']['phoneNumber1']); ?>">
                  <div class="invalid-feedback">
                    Favor de ingresar el número telefónico del proveedor
                  </div>
                </div>
                <div class="form-group col-md-2">
                  <label for="ext">Extension (opcional)</label>
                  <input type="text" class="form-control" id="ext1" name="ext1" placeholder="Ingresar la extensión (opcional)" data-mask="Ext: 0000" value="<?php echo e($supplier['phonesNumbers']['ext1']); ?>">
                </div>
                <div class="form-group col-md-6">
                  <label for="ext">Descripción</label>
                  <input type="text" class="form-control" id="description1" name="description1" placeholder="Ingresar departamento de la línea" value="<?php echo e($supplier['phonesNumbers']['description1']); ?>" required>
                  <div class="invalid-feedback">
                    Favor de ingresar el departamento de la línea
                  </div>
                </div>
              </div>
              <?php for($a = 2 ; $a <= $supplier['countPhoneNumber'];$a++): ?>
                <div id="<?php echo e('fD-'.$a); ?>">
                  <hr>
                  <div class="headerAppend">Número Telefónico <?php echo e($a); ?>

                    <button type="button" id="<?php echo e('deletePhoneNumber-'.$a); ?>" class="btn float-right" onclick="deletePhoneNumber(this)">
                      <i class="fas fa-trash-alt fa-2x colorIcon"></i>
                    </button>
                  </div>
                  <div class="form-row">
                    <div class="form-group col-md-4">
                      <label for="<?php echo e('phonenumber'.$a); ?>">Número telefónico</label>
                      <input type="text" class="form-control" id="<?php echo e('phonenumber'.$a); ?>" name="<?php echo e('phonenumber'.$a); ?>" placeholder="Ingresar número telefónico" required data-mask="000-000-0000" value="<?php echo e($supplier['phonesNumbers']['phoneNumber'.$a]); ?>">
                      <div class="invalid-feedback">
                        Favor de ingresar el número telefónico del proveedor
                      </div>
                    </div>
                    <div class="form-group col-md-2">
                      <label for="<?php echo e('ext'.$a); ?>">Extension (opcional)</label>
                      <input type="text" class="form-control" id="<?php echo e('ext'.$a); ?>" name="<?php echo e('ext'.$a); ?>" placeholder="Ingresar la extensión (opcional)" data-mask="Ext: 0000" value="<?php echo e($supplier['phonesNumbers']['ext'.$a]); ?>">
                    </div>
                    <div class="form-group col-md-6">
                      <label for="<?php echo e('description'.$a); ?>">Descripción</label>
                      <input type="text" class="form-control" id="<?php echo e('description'.$a); ?>" name="<?php echo e('description'.$a); ?>" placeholder="Ingresar departamento de la línea" value="<?php echo e($supplier['phonesNumbers']['description'.$a]); ?>" required>
                      <div class="invalid-feedback">
                        Favor de ingresar el departamento de la línea
                      </div>
                    </div>
                  </div>
                </div>
              <?php endfor; ?>
              <div id="phoneNumbers"></div>
            <?php else: ?>
              <div class="form-row">
                <div class="form-group col-md-4">
                  <label for="phonenumber1">Número telefónico</label>
                  <input type="text" class="form-control" id="phonenumber1" name="phonenumber1" placeholder="Ingresar número telefónico" required data-mask="000-000-0000">
                  <div class="invalid-feedback">
                    Favor de ingresar el número telefónico del proveedor
                  </div>
                </div>
                <div class="form-group col-md-2">
                  <label for="ext">Extension (opcional)</label>
                  <input type="text" class="form-control" id="ext1" name="ext1" placeholder="Ingresar la extensión (opcional)" data-mask="Ext: 0000">
                </div>
                <div class="form-group col-md-6">
                  <label for="ext">Descripción</label>
                  <input type="text" class="form-control" id="description1" name="description1" placeholder="Ingresar departamento de la línea" required>
                  <div class="invalid-feedback">
                    Favor de ingresar el departamento de la línea
                  </div>
                </div>
              </div>
              <div id="phoneNumbers"></div>
            <?php endif; ?>
            <a href="proveedores"  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>

<div class="row">
  <div class="col-md-12">
      <div class="modal fade" tabindex="-1" role="dialog" id="modal-confirmation">
          <div class="modal-dialog">
              <div class="modal-content">
                  <div class="modal-header">
                      <h4>Eliminar Registro</h4>
                      <button type="button" class="close" data-dismiss="modal-confirmation" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                  </div>
                  <div class="modal-body">
                      <form method="POST" action="<?php echo e(Request::url()); ?>" id="frm-delete">
                        <?php echo csrf_field(); ?>
                          <input type="hidden" name="action" id="action3" value="delete"/>
                          <input type="hidden" name="registerId" id="registerId" value="0">
                          ¿Está usted seguro de querer eliminar este registro?
                  </div>
                  <div class="modal-footer">
                      <button type="submit" class="btn btn-primary" id="confirmation">Confirmar</button>
                      <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancelar</button>
                  </div>
                </form>
              </div>
          </div>
      </div>
  </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('jsDashboard'); ?>
  <script src="../assets/js/mainForm.js"></script>
  <script src="../assets/js/SupplierForm.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\ADIF2021\resources\views/catalogs/suppliersForm.blade.php ENDPATH**/ ?>