Primer commit del sistema avantika sin cambios
This commit is contained in:
331
javascript/facturacion-nueva.js
Executable file
331
javascript/facturacion-nueva.js
Executable file
@@ -0,0 +1,331 @@
|
||||
Event.observe(window, 'load', function(){
|
||||
|
||||
if($('noIdentificacion'))
|
||||
Event.observe($('noIdentificacion'), "keyup", SuggestProducto);
|
||||
|
||||
if($('agregarConceptoDiv'))
|
||||
Event.observe($('agregarConceptoDiv'), "click", AgregarConcepto);
|
||||
|
||||
if($('vistaPrevia'))
|
||||
Event.observe($('vistaPrevia'), "click", VistaPreviaComprobante);
|
||||
|
||||
if($('generarFactura'))
|
||||
Event.observe($('generarFactura'), "click", GenerarComprobante);
|
||||
|
||||
});
|
||||
|
||||
function AgregarConcepto()
|
||||
{
|
||||
$("type").value = "agregarConcepto";
|
||||
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/facturacion-nueva.php',
|
||||
{
|
||||
parameters: $('conceptoForm').serialize(),
|
||||
method:'post',
|
||||
onLoading: function(){
|
||||
$("loader2").show();
|
||||
},
|
||||
onSuccess: function(transport){
|
||||
var response = transport.responseText || "no response text";
|
||||
var splitResponse = response.split("[#]");
|
||||
|
||||
$("loader2").hide();
|
||||
|
||||
if(splitResponse[0] == "fail"){
|
||||
$('divStatus').innerHTML = splitResponse[1];
|
||||
$('centeredDiv').show();
|
||||
HideFview();
|
||||
}else{
|
||||
$('conceptos').innerHTML = splitResponse[1];
|
||||
}
|
||||
|
||||
UpdateTotalesDesglosados();
|
||||
},
|
||||
onFailure: function(){ alert('Something went wrong...') }
|
||||
});
|
||||
}
|
||||
|
||||
function BorrarConcepto(id)
|
||||
{
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/facturacion-nueva.php',
|
||||
{
|
||||
parameters: {id: id, type: "borrarConcepto"},
|
||||
method:'post',
|
||||
onLoading: function(){
|
||||
$("loader2").show();
|
||||
},
|
||||
onSuccess: function(transport){
|
||||
var response = transport.responseText || "no response text";
|
||||
|
||||
$("loader2").hide();
|
||||
$('conceptos').innerHTML = response;
|
||||
|
||||
UpdateTotalesDesglosados();
|
||||
|
||||
},
|
||||
onFailure: function(){ alert('Something went wrong...') }
|
||||
});
|
||||
}
|
||||
|
||||
function UpdateTotalesDesglosados()
|
||||
{
|
||||
var form = $('nuevaFactura').serialize();
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/facturacion-nueva.php',
|
||||
{
|
||||
parameters: {form: form, type: "updateTotalesDesglosados"},
|
||||
method:'post',
|
||||
onSuccess: function(transport){
|
||||
var response = transport.responseText || "no response text";
|
||||
|
||||
$('totalesDesglosadosDiv').innerHTML = response;
|
||||
},
|
||||
onFailure: function(){ alert('Something went wrong...') }
|
||||
});
|
||||
}
|
||||
|
||||
function GenerarComprobante()
|
||||
{
|
||||
var message = "Realmente deseas generar un comprobante. Asegurate de que lo estes generando para tu RFC Correcto.";
|
||||
if(!confirm(message)){
|
||||
return;
|
||||
}
|
||||
|
||||
$('contTemp').innerHTML = '';
|
||||
|
||||
$('nuevaFactura').enable();
|
||||
var nuevaFactura = $('nuevaFactura').serialize();
|
||||
$('nuevaFactura').disable();
|
||||
$('rfc').enable();
|
||||
$('userId').enable();
|
||||
$('formaDePago').enable();
|
||||
$('condicionesDePago').enable();
|
||||
$('metodoDePago').enable();
|
||||
$('tasaIva').enable();
|
||||
$('tiposDeMoneda').enable();
|
||||
$('porcentajeRetIva').enable();
|
||||
$('porcentajeDescuento').enable();
|
||||
$('tipoDeCambio').enable();
|
||||
$('porcentajeRetIsr').enable();
|
||||
$('tiposComprobanteId').enable();
|
||||
$('sucursalId').enable();
|
||||
$('porcentajeIEPS').enable();
|
||||
$('nuevaFactura').enable();
|
||||
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/facturacion-nueva.php',
|
||||
{
|
||||
parameters: {nuevaFactura: nuevaFactura, observaciones: $('observaciones').value, type: "generarComprobante"},
|
||||
method:'post',
|
||||
onLoading: function(){
|
||||
$("loader").show();
|
||||
},
|
||||
onSuccess: function(transport){
|
||||
var response = transport.responseText || "no response text";
|
||||
var splitResponse = response.split("[#]");
|
||||
|
||||
$("loader").hide();
|
||||
|
||||
if(splitResponse[0] == "fail")
|
||||
{
|
||||
$('divStatus').innerHTML = splitResponse[1];
|
||||
$('centeredDiv').show();
|
||||
grayOut(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
$("frmNvaFact").hide();
|
||||
$("dwnPdf").show();
|
||||
$('dwnPdf').innerHTML = splitResponse[1];
|
||||
}
|
||||
},
|
||||
onFailure: function(){ alert('Something went wrong...') }
|
||||
});
|
||||
}
|
||||
|
||||
function VistaPreviaComprobante()
|
||||
{
|
||||
var message = "Esto solo generara una vista previa. Para generar un comprobante da click en Generar Comprobante.";
|
||||
if(!confirm(message)){
|
||||
return;
|
||||
}
|
||||
|
||||
$('contTemp').innerHTML = '';
|
||||
$('loaderPrev').show();
|
||||
|
||||
$('nuevaFactura').enable();
|
||||
var nuevaFactura = $('nuevaFactura').serialize();
|
||||
$('nuevaFactura').disable();
|
||||
$('rfc').enable();
|
||||
$('userId').enable();
|
||||
$('formaDePago').enable();
|
||||
$('condicionesDePago').enable();
|
||||
$('metodoDePago').enable();
|
||||
$('tasaIva').enable();
|
||||
$('tiposDeMoneda').enable();
|
||||
$('porcentajeRetIva').enable();
|
||||
$('porcentajeDescuento').enable();
|
||||
$('tipoDeCambio').enable();
|
||||
$('porcentajeRetIsr').enable();
|
||||
$('tiposComprobanteId').enable();
|
||||
$('sucursalId').enable();
|
||||
$('porcentajeIEPS').enable();
|
||||
$('nuevaFactura').enable();
|
||||
|
||||
if($('reviso')) var reviso = $('reviso').value;
|
||||
else var reviso = "";
|
||||
|
||||
if($('autorizo')) var autorizo = $('autorizo').value;
|
||||
else var autorizo = "";
|
||||
|
||||
if($('recibio')) var recibio = $('recibio').value;
|
||||
else var recibio = "";
|
||||
|
||||
if($('vobo')) var vobo = $('vobo').value;
|
||||
else var vobo = "";
|
||||
|
||||
if($('pago')) var pago = $('pago').value;
|
||||
else var pago = "";
|
||||
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/facturacion-nueva.php',
|
||||
{
|
||||
parameters: {nuevaFactura: nuevaFactura, observaciones: $('observaciones').value, type: "vistaPreviaComprobante", reviso: reviso, autorizo: autorizo, recibio: recibio, vobo: vobo, pago: pago},
|
||||
method:'post',
|
||||
onSuccess: function(transport){
|
||||
var response = transport.responseText || "no response text";
|
||||
var splitResponse = response.split("[#]");
|
||||
|
||||
$('loaderPrev').hide();
|
||||
|
||||
if(splitResponse[0] == "fail")
|
||||
{
|
||||
$('divStatus').innerHTML = splitResponse[1];
|
||||
$('centeredDiv').show();
|
||||
grayOut(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('contTemp').innerHTML = splitResponse[1];
|
||||
}
|
||||
},
|
||||
onFailure: function(){ alert('Something went wrong...') }
|
||||
});
|
||||
}
|
||||
|
||||
//Suggest Clientes
|
||||
|
||||
function SuggestCliente()
|
||||
{
|
||||
var vNombre = $("rfc").value;
|
||||
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/suggest_gral.php',
|
||||
{
|
||||
parameters: {nombre: vNombre, type: "cliente"},
|
||||
method:'post',
|
||||
onSuccess: function(transport){
|
||||
var response = transport.responseText || "no response text";
|
||||
|
||||
$('sugClteDiv').show();
|
||||
$('sugClteDiv').innerHTML = response;
|
||||
|
||||
},
|
||||
onFailure: function(){ alert('Something went wrong...') }
|
||||
});
|
||||
}
|
||||
|
||||
function FillInfoClte(id){
|
||||
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/clientes.php',
|
||||
{
|
||||
parameters: {type: "fillInfoClte", clienteId:id},
|
||||
method:'post',
|
||||
onSuccess: function(transport){
|
||||
var response = transport.responseText || "no response text";
|
||||
var splitResponse = response.split("[#]");
|
||||
|
||||
$('loadingDivDatosFactura').innerHTML = LOADER;
|
||||
|
||||
if(splitResponse[0] == "ok"){
|
||||
|
||||
$('userId').value = splitResponse[1];
|
||||
$("rfc").value = splitResponse[2];
|
||||
$('razonSocial').value = splitResponse[3];
|
||||
$('calle').value = splitResponse[4];
|
||||
$('noExt').value = splitResponse[5];
|
||||
$('noInt').value = splitResponse[6];
|
||||
$('colonia').value = splitResponse[7];
|
||||
$('municipio').value = splitResponse[8];
|
||||
$('cp').value = splitResponse[9];
|
||||
$('estado').value = splitResponse[10];
|
||||
$('localidad').value = splitResponse[11];
|
||||
$('pais').value = splitResponse[12];
|
||||
$('referencia').value = splitResponse[13];
|
||||
$('email').value = splitResponse[14];
|
||||
|
||||
$('loadingDivDatosFactura').innerHTML = '';
|
||||
|
||||
}
|
||||
|
||||
CloseSugClte();
|
||||
},
|
||||
onFailure: function(){ alert('Something went wrong...') }
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function CloseSugClte(){
|
||||
|
||||
$('sugClteDiv').hide();
|
||||
|
||||
}
|
||||
|
||||
//Suggest Productos
|
||||
|
||||
function SuggestProducto()
|
||||
{
|
||||
var vNoIdent = $("noIdentificacion").value;
|
||||
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/suggest_gral.php',
|
||||
{
|
||||
parameters: {noIdent: vNoIdent, type: "prodFact"},
|
||||
method:'post',
|
||||
onSuccess: function(transport){
|
||||
var response = transport.responseText || "no response text";
|
||||
|
||||
$('sugProdDiv').show();
|
||||
$('sugProdDiv').innerHTML = response;
|
||||
|
||||
},
|
||||
onFailure: function(){ alert('Something went wrong...') }
|
||||
});
|
||||
}
|
||||
|
||||
function FillInfoProd(id){
|
||||
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/productos.php',
|
||||
{
|
||||
parameters: {type: "fillInfoProdFact", prodItemId:id},
|
||||
method:'post',
|
||||
onSuccess: function(transport){
|
||||
var response = transport.responseText || "no response text";
|
||||
var splitResponse = response.split("[#]");
|
||||
|
||||
if(splitResponse[0] == "ok"){
|
||||
|
||||
$('noIdentificacion').value = splitResponse[1];
|
||||
$("unidad").value = splitResponse[2];
|
||||
$('valorUnitario').value = splitResponse[3];
|
||||
$('descripcion').value = splitResponse[4];
|
||||
|
||||
}
|
||||
|
||||
CloseSugProd();
|
||||
},
|
||||
onFailure: function(){ alert('Something went wrong...') }
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function CloseSugProd(){
|
||||
|
||||
$('sugProdDiv').hide();
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user