<?php $r="../";
$id=$_GET['id'];
require_once($r."inc/funciones.php");
validNotSession($r);
$mysqli = connectDB($r);
$row1 = $mysqli->query("SELECT * FROM z_clientes WHERE id='$id'");
$row1=$row1->fetch_assoc();
$depa = $mysqli->query("SELECT * FROM z_departamentos");
?>
<!DOCTYPE html>
<html lang="en">
  <?php include $r."inc/head.php"; ?>
<body class="fixed-nav sticky-footer bg-dark" id="page-top">
  <?php include $r."inc/nav.php"; ?>
  
  <div class="content-wrapper">
    <div class="container-fluid">
      <h2 class="text-center"><i class="fa fa-user"></i> ACTUALIZAR CLIENTE</h2><hr/>
      <form action="actualizar-cliente.php" method="post">
        <input type="hidden" value="<? echo $id ?>" name="id">
        <h6>Informacion Empresa</h6><hr/>
        <div class="form-group row">
            <label for="nombre" class="col-sm-2 col-form-label"><span class="text-danger">*</span>Nombre Empresa</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" id="nombre" name="nombre" placeholder="Nombre Empresa" autocomplete="off" value="<? if($row1["nombre"]!=""){echo $row1["nombre"]; } ?>" required>
            </div>
            <label for="corto" class="col-sm-1 col-form-label"><span class="text-danger">*</span>Nit o C.C</label>
            <div class="col-sm-2">
                <input type="number" class="form-control" id="cedula" name="cedula" placeholder="Nit o Cedula" autocomplete="off" value="<? if($row1["cedula"]!=""){echo $row1["cedula"]; } ?>" required>
            </div>
            <label for="celular1" class="col-sm-1 col-form-label"><span class="text-danger">*</span>Direccion</label>
            <div class="col-sm-2">
                <input type="text" class="form-control" id="direccion" name="direccion" placeholder="Direccion Del Establecimiento" value="<? if($row1["direccion"]!=""){echo $row1["direccion"]; } ?>" autocomplete="off" required>
            </div>
        </div>
        <div class="form-group row">
            <label for="departamento" class="col-sm-2 col-form-label"><span class="text-danger">*</span>Departamento</label>
            <div class="col-sm-4">
                <select  class="form-control"  name="departamento" id="departamento" title="departamento" required>
                    <option value="<? if($row1["departamento"]!=""){echo $row1["departamento"];}else{echo'';} ?>"><? if($row1["departamento"]!=""){ $depar=sdepa($row1["departamento"]); echo $depar['departamento'];}else{echo'Seleccione un Departamento';} ?></option>
                    <?php while($row2 = $depa->fetch_assoc()) { ?>
                    <option value="<?php echo $row2["id"]; ?>"><?php echo $row2["departamento"]; ?></option>
                    <?php } ?>
                </select>
            </div>
            <label for="municipio" class="col-sm-2 col-form-label"><span class="text-danger">*</span>Ciudad</label>
            <div class="col-sm-4">
                <select  class="form-control" id="ciudad"  name="municipio" title="municipio" value="<? if($row1["municipio"]!=""){echo $row1["municipio"]; } ?>"  required>
                    <option value="<? if($row1["ciudad"]!=""){echo $row1["ciudad"];}else{echo'';} ?>"><? if($row1["ciudad"]!=""){ $city=scity($row1["ciudad"]); echo $city['municipio'];}else{echo'Seleccione un Ciudad';} ?></option>
                </select>
            </div>
        </div>
        <div class="form-group row">
            <label for="localidad" class="col-sm-2 col-form-label">Localidad</label>
            <div class="col-sm-4">
                <select  class="form-control" id="localidad"  name="localidad" title="localidad">
                </select>
            </div>
            <label for="zona" class="col-sm-2 col-form-label">Zona</label>
            <div class="col-sm-4">
                <select  class="form-control" id="zona"  name="zona" title="zona">
                </select>
            </div>
        </div>
        
        <div class="form-group row">
            <label for="nota" class="col-sm-2 col-form-label">OBSERVACION</label>
            <div class="col-sm-10">
                <textarea row="5" type="text" class="form-control" id="nota" name="nota" placeholder="Observaciones o indicaciones a tener en cuenta." autocomplete="off" value="<? if($row1["nota"]!=""){echo $row1["nota"]; } ?>"></textarea>
            </div>
        </div>
        <h6>Informacion Contacto</h6><hr/>
        <div class="form-group row">
            <label for="contacto1" class="col-sm-2 col-form-label"><span class="text-danger">*</span>Nombre</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" id="contacto1" name="contacto1" placeholder="Nombre" autocomplete="off" value="<? if($row1["contacto1"]!=""){echo $row1["contacto1"]; } ?>" required>
            </div>
            <label for="celular1" class="col-sm-1 col-form-label">Celular</label>
            <div class="col-sm-2">
                <input type="number" class="form-control" id="celular1" name="celular1" placeholder="celular" autocomplete="off" value="<? if($row1["celular1"]!=""){echo $row1["celular1"]; } ?>" required>
            </div>
            <label for="telefono1" class="col-sm-1 col-form-label">Telefono</label>
            <div class="col-sm-2">
                <input type="number" class="form-control" id="telefono1" name="telefono1" placeholder="telefono" autocomplete="off" value="<? if($row1["telefono1"]!=""){echo $row1["telefono1"]; } ?>">
            </div>
        </div>
        <h6>Informacion de Segundo Contacto <span class="text-danger">(opcional)</span></h6><hr/>
        <div class="form-group row">
            <label for="contacto2" class="col-sm-2 col-form-label">Nombre</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" id="contacto2" name="contacto2" placeholder="Nombre" autocomplete="off" value="<? if($row1["contacto2"]!=""){echo $row1["contacto2"]; } ?>">
            </div>
            <label for="celular2" class="col-sm-1 col-form-label">celular</label>
            <div class="col-sm-2">
                <input type="number" class="form-control" id="celular1" name="celular2" placeholder="celular" autocomplete="off" value="<? if($row1["celular2"]!=""){echo $row1["celular2"]; } ?>">
            </div>
            <label for="telefono2" class="col-sm-1 col-form-label">Telefono</label>
            <div class="col-sm-2">
                <input type="text" class="form-control" id="telefono2" name="telefono2" placeholder="telefono" autocomplete="off" value="<? if($row1["telefono2"]!=""){echo $row1["telefono2"]; } ?>">
            </div>
        </div>
        <hr>
        <input class="btn btn-success btn-sm btn-block" type="submit" value="actualizar">
      </form>
    </div>
  </div>
  <?php include $r."inc/foot.php"; ?>
</body>
</html>    