<?php 
session_start(); 
require_once('../conexion.php');
require_once('../include/sesiones.php');
require_once('../php_api/api.php');

//FACTURA ELECTRONICA
$api_software_fac=$_POST["api_software_fac"]; 
$api_pin_fac=$_POST["api_pin_fac"]; 
$settestid_fac=$_POST["settestid_fac"];

$json_fac = array(
    "id" => $api_software_fac,
    "pin" => $api_pin_fac,
);

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "{$configuration->base_url}ubl2.1/config/software",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'PUT',
  CURLOPT_POSTFIELDS =>json_encode($json_fac),

  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'cache-control: no-cache',
    'Connection: keep-alive',
    'Accept-Encoding: gzip, deflate',
    'accept: application/json',
    'X-CSRF-TOKEN: ',
    'Authorization: Bearer '.$token
  ),
));

$response = curl_exec($curl);
curl_close($curl);

$sql=mysqli_query($con,"UPDATE configuracion_electronica Set iden_soft_ele='$api_software_fac', ele_settestid='$settestid_fac' Where empresa='$empresa'") or die(mysqli_error($con)); 

echo '<div class="alert alert-success alert-dismissable">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
        <strong> Software Registrado Correctamente</strong> 
   </div></br>'; 
?>