I have a problem, when sending and registering in the bd a sale sends me a confirmation message and that I show on the screen:
This code captures the submit and receives the message:
$(".frm-ventas").submit(function(event) {
event.preventDefault();
var url = $(this).attr('action');
var data = $(this).serialize();
$.ajax({
type:'POST',
dataType:'json',
url:url,
data:data,
success:function(response){
$('#caja').toggle();
$("span").remove( ".mensaje" );
$("i").remove('.glyphicon');
$("#caja").fadeOut(5000);
if (response.respuesta == true) {
$(".box-pago").hide();
setTimeout(function(){
window.open("example/report/factura.php?invoice=reponse.invoice");
}, 5000); // 5000 ms
$('#caja').removeClass('alert-danger').addClass('alert-info');
$("#caja").append("<i class='glyphicon glyphicon-info-sign' aria-hidden='true'></i>");
$("#caja").append("<span class='mensaje'>"+" ok: "+response.mensaje+"</span>");
$('.cargando').toggle();
$('.cargando p').html('Limpiando el carrito...');
setTimeout(llenar_tabla_json, 2000);
limpiarformulario($(".frm-ventas"));
}else{
$('#caja').removeClass('alert-info').addClass('alert-danger');
$("#caja").append("<i class='glyphicon glyphicon-exclamation-sign' aria-hidden='true'></i>");
$("#caja").append("<span class='mensaje'>"+" Error: "+response.mensaje+"</span>");
}
},error:function(){
alert("Ha ocurrido un error");
}
});
});
And this is the message:
$salidaJson=array('respuesta' => $mensajeOk,'mensaje' => $mensajeError, 'invoice' => $invoice);
echo json_encode($salidaJson);
I want to open that page with window.open
and send the variable $invoice
try with this code and nothing
window.open("example/report/factura.php?invoice=reponse.invoice");
Any ideas?
this is the 'variable' $ invoice that I want to send
$ client = new Client ();
$client->setTipoDoc('6')
->setNumDoc(trim($_POST['ruc']))
->setRznSocial(trim($_POST['cliente']))
->setAddress((new Address())
->setDireccion(trim($_POST['direccion'])));
// Emisor
$address = new Address();
$address->setUbigueo($ubigeo)
->setDepartamento($departamento)
->setProvincia($provincia)
->setDistrito($distrito)
->setUrbanizacion($urbanizacion)
->setDireccion($direccionempresa);
$company = new Company();
$company->setRuc($rucempresa)
->setRazonSocial($razonempresa)
->setNombreComercial($nombre_comercial)
->setAddress($address);
// Venta
$invoice = new Invoice();
$invoice
->setFecVencimiento(new DateTime())
->setTipoDoc($tipo_documento)
->setSerie(trim($_POST['serie']))
->setCorrelativo(trim($_POST['numero']))
->setFechaEmision(new DateTime())
->setTipoMoneda(trim($_POST['pago']))
->setClient($client)
->setMtoOperGravadas($gravadas)
->setMtoIGV($importeIGV)
->setMtoImpVenta($importe)
->setCompany($company);
$leyenda = trim($_POST['total']);
$centimos = substr($leyenda, -2);
$legn = validar::convertir($leyenda,'CON '.$centimos.'/100 SOLES');
$legend = new Legend();
$legend->setCode('1000')
->setValue($legn);
$invoice->setDetails($items)
->setLegends([$legend]);