<?php $user = PersonData::getById($_GET["id"]);?>
<div class="row">
	<div class="col-md-12">
	<h1>Editar Proveedor</h1>
	<br>
		<form class="form-horizontal" method="post" id="addproduct" action="index.php?view=updateprovider" role="form">

  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <div class="checkbox">
        <label>
          <input type="checkbox" name="is_company" <?php if($user->is_company){ echo "checked"; }?>> Es empresa
        </label>
      </div>
    </div>
  </div>
  <div class="form-group">
    <label for="inputEmail1" class="col-lg-2 control-label">RUT*</label>
    <div class="col-md-6">
      <input type="text" name="rut" class="form-control" value="<?php echo $user->rut;?>" required id="rut" placeholder="RUT">
    </div>
  </div>
  <div class="form-group">
    <label for="inputEmail1" class="col-lg-2 control-label">Nombre*</label>
    <div class="col-md-6">
      <input type="text" name="name" value="<?php echo $user->name;?>" class="form-control" id="name" placeholder="Nombre">
    </div>
  </div>
  <div class="form-group">
    <label for="inputEmail1" class="col-lg-2 control-label">Apellido*</label>
    <div class="col-md-6">
      <input type="text" name="lastname" value="<?php echo $user->lastname;?>" required class="form-control" id="lastname" placeholder="Apellido">
    </div>
  </div>
  <div class="form-group">
    <label for="inputEmail1" class="col-lg-2 control-label">Direccion*</label>
    <div class="col-md-6">
      <input type="text" name="address1" value="<?php echo $user->address1;?>" class="form-control" required id="username" placeholder="Direccion">
    </div>
  </div>

  <div class="form-group">
    <label for="inputEmail1" class="col-lg-2 control-label">Giro</label>
    <div class="col-md-6">
    <select name="giro_id" class="form-control">
    <option value="">-- NINGUNA --</option>
    <?php foreach(GiroData::getAll() as $category):?>
      <option value="<?php echo $category->id;?>" <?php if($user->giro_id==$category->id){ echo "selected"; }?>><?php echo $category->name;?></option>
    <?php endforeach;?>
      </select>    </div>
  </div>
    <div class="form-group">
    <label for="inputEmail1" class="col-lg-2 control-label">Ciudad</label>
    <div class="col-md-6">
    <select name="city_id" class="form-control">
    <option value="">-- NINGUNA --</option>
    <?php foreach(CityData::getAll() as $category):?>
      <option value="<?php echo $category->id;?>" <?php if($user->city_id==$category->id){ echo "selected"; }?>><?php echo $category->name;?></option>
    <?php endforeach;?>
      </select>    </div>
  </div>
    <div class="form-group">
    <label for="inputEmail1" class="col-lg-2 control-label">Comuna</label>
    <div class="col-md-6">
    <select name="comun_id" class="form-control">
    <option value="">-- NINGUNA --</option>
    <?php foreach(ComunData::getAll() as $category):?>
      <option value="<?php echo $category->id;?>" <?php if($user->comun_id==$category->id){ echo "selected"; }?>><?php echo $category->name;?></option>
    <?php endforeach;?>
      </select>    </div>
  </div>    
    


  <div class="form-group">
    <label for="inputEmail1" class="col-lg-2 control-label">Email*</label>
    <div class="col-md-6">
      <input type="text" name="email1" value="<?php echo $user->email1;?>" class="form-control" id="email" placeholder="Email">
    </div>
  </div>

  <div class="form-group">
    <label for="inputEmail1" class="col-lg-2 control-label">Telefono</label>
    <div class="col-md-6">
      <input type="text" name="phone1"  value="<?php echo $user->phone1;?>"  class="form-control" id="inputEmail1" placeholder="Telefono">
    </div>
  </div>


  <div class="form-group">
    <label for="inputEmail1" class="col-lg-2 control-label">Celular</label>
    <div class="col-md-6">
      <input type="text" name="phone2"  value="<?php echo $user->phone2;?>"  class="form-control" id="inputEmail1" placeholder="Celular">
    </div>
  </div>

  <div class="form-group">
    <label for="inputEmail1" class="col-lg-2 control-label">Contacto</label>
    <div class="col-md-6">
      <input type="text" name="contact"  value="<?php echo $user->contact;?>"  class="form-control" id="inputEmail1" placeholder="Contacto">
    </div>
  </div>

  <div class="form-group">
    <label for="inputEmail1" class="col-lg-2 control-label">Telefono</label>
    <div class="col-md-6">
      <input type="text" name="website"  value="<?php echo $user->website;?>"  class="form-control" id="inputEmail1" placeholder="Telefono">
    </div>
  </div>

  <p class="alert alert-info">* Campos obligatorios</p>

  <div class="form-group">
    <div class="col-lg-offset-2 col-lg-10">
    <input type="hidden" name="user_id" value="<?php echo $user->id;?>">
      <button type="submit" class="btn btn-primary">Actualizar Proveedor</button>
    </div>
  </div>
</form>
	</div>
</div>