<?php
include ('../include/cache.php'); 
include "../conexion.php";
$facd_id=$_GET['id'];   
$can=mysqli_query($con,"SELECT * from fac_detalle_temp where facd_id='$facd_id'" ) or die(mysqli_error($con)); 
$dato=mysqli_fetch_array($can);
$facd_id=$dato['facd_id'];
$facd_referencia=$dato['facd_referencia'];
$facd_nombre=$dato['facd_nombre'];
$facd_precio=$dato['facd_precio'];
$facd_cantidad=$dato['facd_cantidad'];
$facd_desc=$dato['facd_desc'];
?>
<form role="form" id="actualizar" >      
      <div class="modal-body"  style="padding-left:40px;">
      <div class="row">
        <div class="col-md-6">
          <label for="codigo_item" class="control-label">Referencia</label>
          <input type="text" class="form-control" id="codigo_item" name="codigo_item" placeholder="" value="<?php echo $facd_referencia; ?>" disabled required>
          <input type="hidden" name="id" value="<?php echo $facd_id; ?>">
        </div>
        <div class="col-md-6">
          <label for="cantidad_item" class="control-label">Cantidad</label>
          <input type="text" class="form-control" value="<?php echo $facd_cantidad; ?>" name="cantidad" required>
        </div>
      </div>
      <div class="row">
        <div class="col-md-12">
          <label for="art_nombre" class="control-label">Descripción</label>
          <textarea  name="art_nombre" id="art_nombre" readonly="" class="form-control" rows="2"><?php echo $facd_nombre; ?></textarea>
        </div>
      </div>
      <div class="row">
        <div class="col-md-6">
          <label for="precio_item" class="control-label">Precio</label>
          <div class="input-group">
                  <span class="input-group-addon">$</span>
                  <input type="text" class="form-control" value="<?php echo $facd_precio; ?>" name="precio" required>
                  <span class="input-group-addon">.00</span>
                </div>
        </div>
        <div class="col-md-6">
          <label for="descuento_item" class="control-label">Descuento</label>
          <div class="input-group">
             <span class="input-group-addon">%</span>
            <input type="text" class="form-control" name="descuento" id="descuento" value="<?php echo $facd_desc; ?>">
          </div>  
        </div>

      </div>      
    </div>
      <div class="modal-footer">
      <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
      <button type="submit" class="btn btn-success">Actualizar datos</button>
      </div>
</form>

<script>
    $("#actualizar").submit(function(e){
    e.preventDefault();
    $.post("./php_facturacion_periodica/editar_articulo.php",$("#actualizar").serialize(),function(data){
    });
    alert("Agregado exitosamente!");
    //$("#actualizar")[0].reset();
    $('#editModal').modal('hide');
    $('body').removeClass('modal-open');
    $('.modal-backdrop').remove();
    loadTabla();
    loadtotal();
    loadventa();

  });
</script>