249 lines
6.0 KiB
JavaScript
Executable File
249 lines
6.0 KiB
JavaScript
Executable File
function AddProducto(){
|
|
|
|
$("type").value = "saveProducto";
|
|
$("tmpImg").value = $("imagen").value;
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/productos.php',
|
|
{
|
|
method:'post',
|
|
parameters: $('frmAgregarProducto').serialize(),
|
|
onLoading: function(){
|
|
$("loader").show();
|
|
},
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok"){
|
|
$('frmAgregarProducto').submit();
|
|
}else{
|
|
ShowStatusPopUp(splitResponse[1]);
|
|
HideFview();
|
|
$("loader").hide();
|
|
}
|
|
},
|
|
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
|
|
});
|
|
|
|
}//AddProducto
|
|
|
|
function LoadSubcats(){
|
|
|
|
var catId = $("prodCatId").value;
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/productos.php',{
|
|
method:'post',
|
|
parameters: {type:"loadSubcats", prodCatId:catId},
|
|
onLoading: function(){
|
|
$("enumSubcats").innerHTML = LOADER;
|
|
},
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok")
|
|
$("enumSubcats").innerHTML = splitResponse[1];
|
|
|
|
},
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
});
|
|
|
|
}//LoadSubcats
|
|
|
|
function LoadBarCodes(){
|
|
|
|
$("type").value = "loadBarCodes";
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/productos.php',{
|
|
method:'post',
|
|
parameters: $('frmAgregarProducto').serialize(),
|
|
onLoading: function(){
|
|
$("codigos").innerHTML = LOADER;
|
|
},
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok"){
|
|
$("codigos").innerHTML = splitResponse[1];
|
|
}
|
|
|
|
},
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
});
|
|
|
|
}
|
|
|
|
function LoadAtributos(){
|
|
|
|
var id = $("prodSubcatId").value;
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/productos.php',{
|
|
method:'post',
|
|
parameters: {type:"loadAtributos", prodSubcatId:id},
|
|
onLoading: function(){
|
|
$("enumAtributos").innerHTML = LOADER;
|
|
},
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok"){
|
|
$("enumAtributos").innerHTML = splitResponse[1];
|
|
}
|
|
|
|
},
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
});
|
|
|
|
}
|
|
|
|
function LoadTallas(){
|
|
return true;
|
|
var idConTalla = $("conTallaId").value;
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/productos.php',{
|
|
method:'post',
|
|
parameters: {type:"loadTallas", conTallaId:idConTalla},
|
|
onLoading: function(){
|
|
$("listTallas").innerHTML = LOADER;
|
|
},
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok")
|
|
$("listTallas").innerHTML = splitResponse[1];
|
|
|
|
LoadBarCodes();
|
|
|
|
},
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
});
|
|
|
|
}
|
|
|
|
function CheckMaterials()
|
|
{
|
|
$("type").value = "checkMaterials";
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/productos.php',
|
|
{
|
|
method:'post',
|
|
parameters: $('frmAgregarProducto').serialize(true),
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
|
|
if(splitResponse[0] == "fail")
|
|
{
|
|
ShowStatusPopUp(splitResponse[1]);
|
|
HideFview();
|
|
}
|
|
|
|
},
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
});
|
|
}
|
|
|
|
function CalcUtilidad(){
|
|
|
|
var vCosto = $("costo").value;
|
|
var vPrecioVenta = $("precioVenta").value;
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/productos.php',
|
|
{
|
|
method:'post',
|
|
parameters: {type:"calcUtilidad", costo:vCosto, precioVenta:vPrecioVenta},
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok"){
|
|
$("utilidad").value = splitResponse[1];
|
|
$("porcUtilidad").innerHTML = splitResponse[2];
|
|
}
|
|
|
|
},
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
});
|
|
|
|
}
|
|
|
|
function CalcPrecioSinIva(){
|
|
|
|
var vPrecioVentaIva = $("precioVentaIva").value;
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/productos.php',
|
|
{
|
|
method:'post',
|
|
parameters: {type:"calcPrecioSinIva", precioVentaIva:vPrecioVentaIva},
|
|
onLoading: function(){
|
|
$("txtPrecioVenta").innerHTML = LOADER;
|
|
},
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok"){
|
|
$("txtPrecioVenta").innerHTML = splitResponse[1];
|
|
$("precioVenta").value = splitResponse[1];
|
|
}
|
|
|
|
CalcUtilidad();
|
|
},
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
});
|
|
|
|
}
|
|
|
|
//Suggest Proveedores
|
|
|
|
function SuggestProveedor()
|
|
{
|
|
var vNombre = $("proveedor").value;
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/suggest_gral.php',
|
|
{
|
|
parameters: {nombre: vNombre, type: "proveedor"},
|
|
method:'post',
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
|
|
$('sugProvDiv').show();
|
|
$('sugProvDiv').innerHTML = response;
|
|
|
|
},
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
});
|
|
}
|
|
|
|
function FillInfoProv(id){
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/proveedores.php',
|
|
{
|
|
parameters: {type: "fillInfoProv", proveedorId:id},
|
|
method:'post',
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok"){
|
|
$("proveedorId").value = splitResponse[1];
|
|
$("proveedor").value = splitResponse[2];
|
|
}
|
|
|
|
CloseSugProv();
|
|
},
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
});
|
|
|
|
}
|
|
|
|
function CloseSugProv(){
|
|
|
|
$('sugProvDiv').hide();
|
|
|
|
} |