328 lines
7.3 KiB
JavaScript
Executable File
328 lines
7.3 KiB
JavaScript
Executable File
function SendMercancia(){
|
|
|
|
var message = "Realmente desea enviar esta mercancia?";
|
|
|
|
if(!confirm(message)){
|
|
return;
|
|
}
|
|
|
|
$("type").value = "sendMercanciaTienda";
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/envios.php',
|
|
{
|
|
method:'post',
|
|
parameters: $('frmMercancia').serialize(),
|
|
onLoading: function(){
|
|
$("loader").show();
|
|
},
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
|
|
$("loader").hide();
|
|
|
|
if(splitResponse[0] == "ok"){
|
|
location.href = WEB_ROOT + "/envios-tienda";
|
|
}else{
|
|
ShowStatus(splitResponse[1]);
|
|
HideFview();
|
|
}
|
|
},
|
|
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
|
|
});
|
|
|
|
}//SendMercancia
|
|
|
|
//Productos
|
|
|
|
function AddProductos(){
|
|
|
|
$("type").value = "addProductos";
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/envios.php',
|
|
{
|
|
method:'post',
|
|
parameters: $('frmMercancia').serialize(),
|
|
onLoading: function(){
|
|
$("loader").show();
|
|
},
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
|
|
$("loader").hide();
|
|
|
|
if(splitResponse[0] == "ok"){
|
|
$("productos").innerHTML = splitResponse[1];
|
|
$("tblProds").innerHTML = splitResponse[2];
|
|
$("modelo").value = "";
|
|
$("productoId").value = "";
|
|
$("enumAtributos").innerHTML = "";
|
|
}else{
|
|
ShowStatus(splitResponse[1]);
|
|
HideFview();
|
|
}
|
|
},
|
|
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
|
|
});
|
|
|
|
}//AddProductos
|
|
|
|
function DeleteProducto(id){
|
|
|
|
$("type").value = "deleteProducto";
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/envios.php',
|
|
{
|
|
method:'post',
|
|
parameters: {type:"deleteProducto", k:id},
|
|
onLoading: function(){
|
|
$("loader").show();
|
|
},
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
|
|
$("loader").hide();
|
|
|
|
if(splitResponse[0] == "ok"){
|
|
$("productos").innerHTML = splitResponse[1];
|
|
}else{
|
|
ShowStatus(splitResponse[1]);
|
|
HideFview();
|
|
}
|
|
},
|
|
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
|
|
});
|
|
|
|
}//DeleteProducto
|
|
|
|
function LoadSubcats(){
|
|
|
|
var idCat = $("prodCatId").value;
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',{
|
|
method:'post',
|
|
parameters: {type:"loadLineas", prodCatId:idCat},
|
|
onLoading: function(){
|
|
$("enumLineas").innerHTML = LOADER;
|
|
},
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok")
|
|
$("enumLineas").innerHTML = splitResponse[1];
|
|
|
|
LoadModelos();
|
|
|
|
},
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
});
|
|
|
|
}//LoadSubcats
|
|
|
|
function LoadModelos(){
|
|
|
|
$("modelo").value = '';
|
|
$("productoId").value = '';
|
|
|
|
LoadAtributos();
|
|
|
|
}//LoadModelos
|
|
|
|
function LoadAtributos(){
|
|
|
|
var idProd = $("productoId").value;
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',{
|
|
method:'post',
|
|
parameters: {type:"loadAtributos", productoId:idProd},
|
|
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];
|
|
|
|
LoadProductos();
|
|
|
|
},
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
});
|
|
|
|
}//LoadAtributos
|
|
|
|
function LoadProductos(){
|
|
|
|
var idProd = $("productoId").value;
|
|
var idSuc = $("sucursalId").value;
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/envios.php',{
|
|
method:'post',
|
|
parameters: {type:"loadProductos", productoId:idProd, sucursalId:idSuc},
|
|
onLoading: function(){
|
|
$("tblProds").innerHTML = LOADER;
|
|
},
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok")
|
|
$("tblProds").innerHTML = splitResponse[1];
|
|
|
|
},
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
});
|
|
|
|
}//LoadProductos
|
|
|
|
//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();
|
|
LoadModelos();
|
|
},
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
});
|
|
|
|
}
|
|
|
|
function CloseSugProv(){
|
|
|
|
$('sugProvDiv').hide();
|
|
|
|
}
|
|
|
|
//Suggest Productos
|
|
|
|
function CheckKey(e){
|
|
|
|
if(window.event)
|
|
keyCode = window.event.keyCode;
|
|
else if(e)
|
|
keyCode=e.which;
|
|
|
|
if(keyCode == 13){
|
|
SearchProducto();
|
|
}
|
|
|
|
}//CheckKey
|
|
|
|
function SearchProducto()
|
|
{
|
|
var modelo = $("modelo").value;
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/suggest_gral.php',
|
|
{
|
|
parameters: {codigoBarra:modelo, type:"prodByCode"},
|
|
method:'post',
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok"){
|
|
FillInfoProd(splitResponse[2]);
|
|
}else
|
|
{
|
|
ShowStatus(splitResponse[1]);
|
|
HideFview();
|
|
}
|
|
},
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
});
|
|
|
|
}//SearchProducto
|
|
|
|
function SuggestProducto()
|
|
{
|
|
var idProveedor = $("proveedorId").value;
|
|
var idProdCat = $("prodCatId").value;
|
|
var idProdSubcat = $("prodSubcatId").value;
|
|
var vNombre = $("modelo").value;
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/suggest_gral.php',
|
|
{
|
|
parameters: {nombre:vNombre, type:"producto", proveedorId:idProveedor, prodCatId:idProdCat, prodSubcatId:idProdSubcat},
|
|
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: "fillInfoProd", productoId:id},
|
|
method:'post',
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok"){
|
|
$("productoId").value = splitResponse[1];
|
|
$("modelo").value = splitResponse[2];
|
|
}
|
|
|
|
CloseSugProd();
|
|
LoadAtributos();
|
|
},
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
});
|
|
|
|
}
|
|
|
|
function CloseSugProd(){
|
|
|
|
$('sugProdDiv').hide();
|
|
|
|
} |