Estoy haciendo una aplicación WEB en la cual requiero pasar datos JSON
a PHP
e imprimir un reporte PDF
. La librería que pienso utilizar es la FPDF
.
Variable JSON
var datosReportesTickets ={GastoTotal: null, LitrosTotal: null, Rows:[null], Cuenta:[null], Fecha:[null], IdEmpleado:[null], Empleado:[null], Dependencia:[null], Unidad:[null], Combustible:[null], RFC:[null], Proveedor:[null], Folio:[null], Gasto:[null], Litros:[null]};
Función que obtiene los datos de un <Table>
de HTML
function reporteTickets(){
//var datosReportesTickets ={GastoTotal: null, LitrosTotal: null, Rows:[null], Cuenta:[null], Fecha:[null], IdEmpleado:[null], Empleado:[null], Dependencia:[null], Unidad:[null], Combustible:[null], RFC:[null], Proveedor:[null], Folio:[null], Gasto:[null], Litros[null]};
borrarDatosTicketsRep();
$("#tbl_TblFil ").find("tr").each(function(index, el) {
if(index === 0){
}else{
datosReportesTickets.Rows.push($(this).find("td").eq(0).html());
datosReportesTickets.Cuenta.push($(this).find("td").eq(2).html());
datosReportesTickets.Fecha.push($(this).find("td").eq(3).html());
datosReportesTickets.IdEmpleado.push($(this).find("td").eq(4).html());
datosReportesTickets.Empleado.push($(this).find("td").eq(5).html());
datosReportesTickets.Dependencia.push($(this).find("td").eq(7).html());
datosReportesTickets.Unidad.push($(this).find("td").eq(8).html());
datosReportesTickets.Combustible.push($(this).find("td").eq(10).html());
datosReportesTickets.RFC.push($(this).find("td").eq(11).html());
datosReportesTickets.Proveedor.push($(this).find("td").eq(12).html());
datosReportesTickets.Folio.push($(this).find("td").eq(13).html());
datosReportesTickets.Gasto.push($(this).find("td").eq(14).html());
datosReportesTickets.Litros.push($(this).find("td").eq(15).html());
}
});
}
Función que borra los datos de la Variable JSON
function borrarDatosTicketsRep(){
//var datosReportesTickets ={GastoTotal: null, LitrosTotal: null, Rows:[null],
//Cuenta:[null], Fecha:[null], IdEmpleado:[null], Empleado:[null], Dependencia:[null],
//Unidad:[null], Combustible:[null], RFC:[null], Proveedor:[null], Folio:[null],
//Gasto:[null], Litros[null]};
//For que recorre el tamaño del arreglo para borrar los datos
for (var i = 0; i < datosReportesTickets.Rows.length; i++) {
datosReportesTickets.Rows.splice(i, 1);
datosReportesTickets.Cuenta.splice(i, 1);
datosReportesTickets.Fecha.splice(i, 1);
datosReportesTickets.IdEmpleado.splice(i, 1);
datosReportesTickets.Empleado.splice(i, 1);
datosReportesTickets.Dependencia.splice(i, 1);
datosReportesTickets.Unidad.splice(i, 1);
datosReportesTickets.Combustible.splice(i, 1);
datosReportesTickets.RFC.splice(i, 1);
datosReportesTickets.Proveedor.splice(i, 1);
datosReportesTickets.Folio.splice(i, 1);
datosReportesTickets.Gasto.splice(i, 1);
datosReportesTickets.Litros.splice(i, 1);
}
datosReportesTickets.GastoTotal=null;
datosReportesTickets.GastoTotal=null;
}
Evento JQuery con el que pretendo pasar la variable
$('#generarPDF').click(function(event) {
/* Act on the event */
reporteTickets();
});
Lo que deseo hacer es pasar la variable datosReportesTickets
a PHP
para poder generar un reporte PDF
.