Primer commit del sistema avantika sin cambios

This commit is contained in:
2026-01-06 19:42:24 -06:00
commit 3ae4be5957
7127 changed files with 440072 additions and 0 deletions

65
javascript/analisis-venta.js Executable file
View File

@@ -0,0 +1,65 @@
function Generar(){
new Ajax.Request(WEB_ROOT+'/ajax/analisis-venta.php',
{
method:'post',
parameters: $('frmAnalisisVta').serialize(),
onLoading: function(){
$("loader").innerHTML = LOADER2;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$("loader").innerHTML = '';
if(splitResponse[0] == "fail"){
ShowStatus(splitResponse[1]);
HideFview();
}else{
$('contenido').innerHTML = splitResponse[1];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ShowProveedores(kS){
var status = $("prov_"+kS).style.display;
var icon;
if(status == "none"){
status = "";
icon = "[-]";
}else{
status = "none";
icon = "[+]";
}
$("iconSuc_"+kS).innerHTML = icon;
$("prov_"+kS).style.display = status;
}//ShowProveedores
function ShowProductos(kS, kP){
var status = $("prod_"+kS+"_"+kP).style.display;
var icon;
if(status == "none"){
status = "";
icon = "[-]";
}else{
status = "none";
icon = "[+]";
}
$("iconProv_"+kS+"_"+kP).innerHTML = icon;
$("prod_"+kS+"_"+kP).style.display = status;
}//ShowProductos

134
javascript/atributos-valores.js Executable file
View File

@@ -0,0 +1,134 @@
function AddValorDiv(id){
grayOut(true);
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/atributos-valores.php',{
method:'post',
parameters: {type: "addValor", atributoId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('btnSave'), "click", AddValor);
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddValorDiv
function AddValor(){
var id = 0;
new Ajax.Request(WEB_ROOT+'/ajax/atributos-valores.php',
{
method:'post',
parameters: $('frmAgregarValor').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] != "ok"){
ShowStatusPopUp(splitResponse[1]);
}else{
ShowStatusPopUp(splitResponse[1]);
id = splitResponse[2];
$('contValores_'+id).innerHTML = splitResponse[3];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddValor
function EditValorPopup(id){
grayOut(true);
$('fview').show();
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/atributos-valores.php',{
method:'post',
parameters: {type: "editValor", atribValId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); });
Event.observe($('btnUpdate'), "click", EditValor);
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditValorPopup
function EditValor(){
new Ajax.Request(WEB_ROOT+'/ajax/atributos-valores.php', {
method:'post',
parameters: $('frmEditarValor').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] != "ok")
{
ShowStatusPopUp(splitResponse[1]);
}
else
{
ShowStatusPopUp(splitResponse[1]);
id = splitResponse[2];
$('contValores_'+id).innerHTML = splitResponse[3];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditValor
function DeleteValorPopup(id){
var message = "Realmente deseas eliminar este valor?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/atributos-valores.php',{
method:'post',
parameters: {type: "deleteValor", atribValId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1]);
id = splitResponse[2];
$('contValores_'+id).innerHTML = splitResponse[3];
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeleteValorPopup

169
javascript/atributos.js Executable file
View File

@@ -0,0 +1,169 @@
Event.observe(window, 'load', function() {
AddEditProductosListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true){
DeleteAtributoPopup(id);
return;
}
del = el.hasClassName('spanEdit');
if(del == true)
EditAtributoPopup(id);
}
if($('contenido')!= undefined)
$('contenido').observe("click", AddEditProductosListeners);
if($("addAtributo") != undefined)
$('addAtributo').observe("click", function(){ AddAtributoDiv(1); });
});
function AddAtributoDiv(id){
grayOut(true);
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/atributos.php',{
method:'post',
parameters: {type: "addAtributo"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('btnSave'), "click", AddAtributo);
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddAtributoDiv
function AddAtributo(){
new Ajax.Request(WEB_ROOT+'/ajax/atributos.php',
{
method:'post',
parameters: $('frmAgregarAtributo').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail"){
ShowStatusPopUp(splitResponse[1]);
}else{
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddAtributo
function EditAtributoPopup(id){
grayOut(true);
$('fview').show();
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/atributos.php',{
method:'post',
parameters: {type: "editAtributo", atributoId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); });
Event.observe($('btnUpdate'), "click", EditAtributo);
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditAtributoPopup
function EditAtributo(){
var form = $('frmEditarAtributo').serialize();
new Ajax.Request(WEB_ROOT+'/ajax/atributos.php', {
method:'post',
parameters: $('frmEditarAtributo').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1])
}
else
{
ShowStatusPopUp(splitResponse[1])
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditAtributo
function DeleteAtributoPopup(id){
var message = "Realmente deseas eliminar este atributo?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/atributos.php',{
method:'post',
parameters: {type: "deleteAtributo", atributoId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeleteAtributoPopup
function ViewValores(id){
var obj = $('valores_'+id);
if(obj.style.display == "none")
obj.style.display = "";
else
obj.style.display = "none";
}

View File

@@ -0,0 +1,104 @@
Event.observe(window, 'load', function() {
AddEditProductosListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true){
DeletePoliticaPopup(id);
return;
}
del = el.hasClassName('spanEdit');
if(del == true)
EditPolitica(id);
}
if($('contenido')!= undefined)
$('contenido').observe("click", AddEditProductosListeners);
if($("addPolitica") != undefined)
$('addPolitica').observe("click", function(){ AddPoliticaDiv(1); });
});
function AddPoliticaDiv(id){
grayOut(true);
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/politicas.php',{
method:'post',
parameters: {type: "addPolitica"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('btnSave'), "click", AddPolitica);
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddAtributoDiv
function AddPolitica(){
new Ajax.Request(WEB_ROOT+'/ajax/politicas.php',
{
method:'post',
parameters: $('frmAgregarPolitica').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail"){
ShowStatusPopUp(splitResponse[1]);
}else{
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddAtributo
function DeletePoliticaPopup(id){
var message = "Realmente deseas eliminar esta Politica?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/politicas.php',{
method:'post',
parameters: {type: "deletePolitica", politicaId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeleteAtributoPopup

View File

@@ -0,0 +1,109 @@
function AplicarBonifDev(productoId){
var resp = confirm("Esta seguro de aplicar la evaluacion?")
if(!resp)
return;
var pedidoId = $("pedidoId").value;
new Ajax.Request(WEB_ROOT+'/ajax/bonificaciones-agregar.php',
{
parameters: {pedidoId:pedidoId, productoId:productoId, type:"aplicarEval"},
method:'post',
onLoading: function(){
$("btnAp_" + productoId).innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$("btnAp_" + productoId).innerHTML = "Aplicado";
if(splitResponse[0] == "ok"){
ShowStatus(splitResponse[1]);
HideFview();
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function BuscarFactura()
{
var folioProv = $("folioProv").value;
new Ajax.Request(WEB_ROOT+'/ajax/bonificaciones-agregar.php',
{
parameters: {folioProv:folioProv, type:"buscarFactura"},
method:'post',
onLoading: function(){
$("pedidoId").value = "";
$("txtProveedor").innerHTML = LOADER;
$("txtNoPedido").innerHTML = LOADER;
$("txtStatus").innerHTML = LOADER;
$("txtFechaPed").innerHTML = LOADER;
$("txtFechaRec").innerHTML = LOADER;
$("txtDiasTrans").innerHTML = LOADER;
$("enumProds").innerHTML = LOADER2;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$("pedidoId").value = "";
$("txtProveedor").innerHTML = "";
$("txtNoPedido").innerHTML = "";
$("txtStatus").innerHTML = "";
$("txtFechaPed").innerHTML = "";
$("txtFechaRec").innerHTML = "";
$("txtDiasTrans").innerHTML = "";
$("enumProds").innerHTML = "";
if(splitResponse[0] == "ok"){
$("pedidoId").value = splitResponse[1];
$("txtProveedor").innerHTML = splitResponse[2];
$("txtNoPedido").innerHTML = splitResponse[3];
$("txtStatus").innerHTML = splitResponse[4];
$("txtFechaPed").innerHTML = splitResponse[5];
$("txtFechaRec").innerHTML = splitResponse[6];
$("txtDiasTrans").innerHTML = splitResponse[7];
$("enumProds").innerHTML = splitResponse[8];
}else
{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//BuscarProd
function CancelEval(){
var resp = confirm("Esta seguro de cancelar la evaluacion?");
if(!resp)
return;
window.location = WEB_ROOT + "/bonificaciones";
}//CancelEval
function CheckKey(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13){
BuscarProd();
}
}//CheckKey

View File

@@ -0,0 +1,306 @@
Event.observe(window, 'load', function() {
AddEditProductosListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true){
DeleteAtributoPopup(id);
return;
}
del = el.hasClassName('spanEdit');
if(del == true)
EditAtributoPopup(id);
del = el.hasClassName('guardaStatus');
if(del == true)
cambiaStatus(id);
}
if($('contenido')!= undefined)
$('contenido').observe("click", AddEditProductosListeners);
if($("addPolitica") != undefined)
$('addPolitica').observe("click", function(){ AddPoliticaDiv(1); });
if($("search1") != undefined)
$('search1').observe("keyup", SearchBonificacion);
if($("search2") != undefined)
$('search2').observe("keyup", SearchBonificacion);
});
function aplicarBonifDev(id)
{
var totalBonificacion = $('totalBonificacion_'+id).value;
var totalDevolucion = $('totalDevolucion_'+id).value;
alert(totalBonificacion+" "+totalDevolucion);
var message = "Realmente deseas aplicar estas bonficaciones/devoluciones?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/evaluar-pedidos.php',
{
method:'post',
parameters: {type: "cambiarStatus", pedidoId: id, totalBonificacion: totalBonificacion, totalDevolucion: totalDevolucion},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "Rechazo")
{
grayOut(true);
$('fview').show();
FViewOffSet(splitResponse[1]);
Event.observe($('agregarJustificante'), "click", SaveJustificante);
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
}else{
if(splitResponse[0] == "fail"){
ShowStatusPopUp(splitResponse[1]);
}else{
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function SearchBonificacion()
{
var pedidoId = $('search1').value;
var nombreProveedor = $('search2').value;
new Ajax.Request(WEB_ROOT+'/ajax/evaluar-pedidos.php',
{
method:'post',
parameters: $('filtraBonificacion').serialize()/*{type: "suggestBonificacion", pedidoId: pedidoId, nombreProveedor: nombreProveedor}*/,
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail"){
ShowStatusPopUp(splitResponse[1]);
}else{
$('contenido').innerHTML = splitResponse[1];
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function SaveJustificante()
{
var status = $('status').value;
var bonificacionId = $('bonificacionId').value;
var justificante = $('justificante').value;
new Ajax.Request(WEB_ROOT+'/ajax/evaluar-pedidos.php',
{
method:'post',
parameters: {bonificacionId: bonificacionId, status: status, type: "cambiarStatus", aux: 0, justificante: justificante},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail"){
ShowStatusPopUp(splitResponse[1]);
}else{
ShowStatusPopUp(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function cambiaStatus(id){
var totalBonificacion = $('totalBonificacion_'+id).value;
var aux = 0;
if(status == "Rechazado")
aux = 1;
new Ajax.Request(WEB_ROOT+'/ajax/evaluar-pedidos.php',
{
method:'post',
parameters: {bonificacionId: id, totalBonificacion: totalBonificacion, type: "cambiarStatus", aux: aux},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "Rechazo")
{
grayOut(true);
$('fview').show();
FViewOffSet(splitResponse[1]);
Event.observe($('agregarJustificante'), "click", SaveJustificante);
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
}else{
if(splitResponse[0] == "fail"){
ShowStatusPopUp(splitResponse[1]);
}else{
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AddPoliticaDiv(id){
grayOut(true);
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/politicas.php',{
method:'post',
parameters: {type: "addPolitica"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('btnSave'), "click", AddPolitica);
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddAtributoDiv
function AddPolitica(){
new Ajax.Request(WEB_ROOT+'/ajax/politicas.php',
{
method:'post',
parameters: $('frmAgregarPolitica').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail"){
ShowStatusPopUp(splitResponse[1]);
}else{
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function EditAtributoPopup(id){
grayOut(true);
$('fview').show();
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/atributos.php',{
method:'post',
parameters: {type: "editAtributo", atributoId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); });
Event.observe($('btnUpdate'), "click", EditAtributo);
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditAtributoPopup
function EditAtributo(){
var form = $('frmEditarAtributo').serialize();
new Ajax.Request(WEB_ROOT+'/ajax/atributos.php', {
method:'post',
parameters: $('frmEditarAtributo').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1])
}
else
{
ShowStatusPopUp(splitResponse[1])
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditAtributo
function DeleteAtributoPopup(id){
var message = "Realmente deseas eliminar este atributo?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/atributos.php',{
method:'post',
parameters: {type: "deleteAtributo", atributoId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeleteAtributoPopup
function ViewValores(id){
var obj = $('valores_'+id);
if(obj.style.display == "none")
obj.style.display = "";
else
obj.style.display = "none";
}

73
javascript/clearbox.js Executable file
View File

@@ -0,0 +1,73 @@
/*
clearbox by Kreatura Media
script home: http://www.clearbox.hu
http://kreaturamedia.com
Facebook: http://www.facebook.com/ClearBoxJS
http://www.facebook.com/kreaturamedia
LICENSZ FELTÉTELEK:
A clearbox szabadon felhasználható bármely honlapon,
A clearbox a készítő beleegyezése nélkül pénzért harmadik félnek tovább nem adható!
LICENSE:
ClearBox can be used free for all web pages.
*/
var CB_ScriptDir=WEB_ROOT+ '/clearbox'; // RELATIVE to your html file!
var CB_Language='en';
//
// ClearBox load:
//
var CB_Scripts = document.getElementsByTagName('script');
for(i=0;i<CB_Scripts.length;i++){
if (CB_Scripts[i].getAttribute('src')){
var q=CB_Scripts[i].getAttribute('src');
if(q.match('clearbox.js')){
var url = q.split('clearbox.js');
var path = url[0];
var query = url[1].substring(1);
var pars = query.split('&');
for(j=0; j<pars.length; j++) {
par = pars[j].split('=');
switch(par[0]) {
case 'config': {
CB_Config = par[1];
break;
}
case 'dir': {
CB_ScriptDir = par[1];
break;
}
case 'lng': {
CB_Language = par[1];
break;
}
case 'debugmode': {
CB_DebugMode = 'on';
break;
}
}
}
}
}
}
if(!CB_Config){
var CB_Config='default';
}
document.write('<link rel="stylesheet" type="text/css" href="'+CB_ScriptDir+'/config/'+CB_Config+'/cb_style.css" />');
document.write('<script type="text/javascript" src="'+CB_ScriptDir+'/config/'+CB_Config+'/cb_config.js"></script>');
document.write('<script type="text/javascript" src="'+CB_ScriptDir+'/language/'+CB_Language+'/cb_language.js"></script>');
document.write('<script type="text/javascript" src="'+CB_ScriptDir+'/core/cb_core.js"></script>');

213
javascript/clientes.js Executable file
View File

@@ -0,0 +1,213 @@
Event.observe(window, 'load', function() {
Event.observe($('addCliente'), "click", AddClienteDiv);
AddEditClienteListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true)
{
DeleteClientePopup(id);
return;
}
del = el.hasClassName('spanEdit');
if(del == true)
{
EditClientePopup(id);
}
del = el.hasClassName('spanView');
if(del == true)
{
ViewClientePopup(id);
}
}
$('contenido').observe("click", AddEditClienteListeners);
});
function AddClienteDiv(id)
{
grayOut(true);
if(id == 0)
{
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/clientes.php',
{
method:'post',
parameters: {type: "addCliente"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('agregarCliente'), "click", AddCliente);
Event.observe($('fviewclose'), "click", function(){ AddClienteDiv(0); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AddCliente()
{
new Ajax.Request(WEB_ROOT+'/ajax/clientes.php',
{
method:'post',
parameters: $('agregarClienteForm').serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1])
}
else
{
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
Event.observe($('addCliente'), "click", AddClienteDiv);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function EditClientePopup(id)
{
grayOut(true);
$('fview').show();
if(id == 0)
{
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/clientes.php',
{
method:'post',
parameters: {type: "editCliente", id:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ AddClienteDiv(0); });
Event.observe($('editarCliente'), "click", EditarCliente);
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function EditarCliente()
{
new Ajax.Request(WEB_ROOT+'/ajax/clientes.php',
{
method:'post',
parameters: $('editarClienteForm').serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1]);
}
else
{
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
Event.observe($('addCliente'), "click", AddClienteDiv);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ViewClientePopup(id)
{
grayOut(true);
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/clientes.php',
{
method:'post',
parameters: {type: "viewCliente", id:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ AddClienteDiv(0); });
Event.observe($('btnClose'), "click", function(){ AddClienteDiv(0); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function DeleteClientePopup(id)
{
var message = "Realmente deseas eliminar a este cliente?";
if(!confirm(message))
{
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/clientes.php',
{
method:'post',
parameters: {type: "deleteCliente", id: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
Event.observe($('addCliente'), "click", AddClienteDiv);
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function Search()
{
new Ajax.Request(WEB_ROOT+'/ajax/clientes.php',
{
method:'post',
parameters: {word: $('word').value, type: "search"},
onLoading: function(){
$("contenido").innerHTML = LOADER2;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('contenido').innerHTML = response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function CheckKey(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13)
Search();
}//CheckKey

155
javascript/colores.js Executable file
View File

@@ -0,0 +1,155 @@
Event.observe(window, 'load', function() {
Event.observe($('addColor'), "click", AddColorDiv);
AddEditColorListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true)
{
DeleteColorPopup(id);
return;
}
del = el.hasClassName('spanEdit');
if(del == true)
{
EditColorPopup(id);
}
}
$('coloresDiv').observe("click", AddEditColorListeners);
});
function AddColorDiv(id)
{
grayOut(true);
if(id == 0)
{
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/colores.php',
{
method:'post',
parameters: {type: "addColor"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('agregarColor'), "click", AddColor);
Event.observe($('fviewclose'), "click", function(){ AddColorDiv(0); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AddColor()
{
new Ajax.Request(WEB_ROOT+'/ajax/colores.php',
{
method:'post',
parameters: $('agregarColorForm').serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1]);
}
else
{
ShowStatusPopUp(splitResponse[1]);
$('coloresDiv').innerHTML = splitResponse[2];
Event.observe($('addColor'), "click", AddColorDiv);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function EditColorPopup(id)
{
grayOut(true);
$('fview').show();
if(id == 0)
{
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/colores.php',
{
method:'post',
parameters: {type: "editColor", id:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ AddColorDiv(0); });
Event.observe($('editarColor'), "click", EditarColor);
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function EditarColor()
{
new Ajax.Request(WEB_ROOT+'/ajax/colores.php',
{
method:'post',
parameters: $('editarColorForm').serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1])
}
else
{
ShowStatusPopUp(splitResponse[1])
$('coloresDiv').innerHTML = splitResponse[2];
Event.observe($('addColor'), "click", AddColorDiv);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function DeleteColorPopup(id)
{
var message = "Realmente deseas eliminar este color?";
if(!confirm(message))
{
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/colores.php',
{
method:'post',
parameters: {type: "deleteColor", id: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1])
$('coloresDiv').innerHTML = splitResponse[2];
Event.observe($('addColor'), "click", AddColorDiv);
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}

169
javascript/comisiones.js Executable file
View File

@@ -0,0 +1,169 @@
Event.observe(window, 'load', function() {
AddEditProductosListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true){
DeleteComisionPopup(id);
return;
}
del = el.hasClassName('spanEdit');
if(del == true)
EditComisionPopup(id);
}
if($('contenido')!= undefined)
$('contenido').observe("click", AddEditProductosListeners);
if($("addComision") != undefined)
$('addComision').observe("click", function(){ AddComisionDiv(1); });
});
function AddComisionDiv(id){
grayOut(true);
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/comisiones.php',{
method:'post',
parameters: {type: "addComision"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('btnSave'), "click", AddComision);
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddAtributoDiv
function AddComision(){
new Ajax.Request(WEB_ROOT+'/ajax/comisiones.php',
{
method:'post',
parameters: $('frmAgregarComision').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail"){
ShowStatusPopUp(splitResponse[1]);
}else{
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddAtributo
function EditComisionPopup(id){
grayOut(true);
$('fview').show();
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/comisiones.php',{
method:'post',
parameters: {type: "editComision", comisionId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); });
Event.observe($('btnUpdate'), "click", EditComision);
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditAtributoPopup
function EditComision(){
var form = $('frmEditarComision').serialize();
new Ajax.Request(WEB_ROOT+'/ajax/comisiones.php', {
method:'post',
parameters: $('frmEditarComision').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1])
}
else
{
ShowStatusPopUp(splitResponse[1])
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditAtributo
function DeleteComisionPopup(id){
var message = "Realmente deseas eliminar esta politica de comision?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/comisiones.php',{
method:'post',
parameters: {type: "deleteComision", comisionId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeleteAtributoPopup
function ViewValores(id){
var obj = $('valores_'+id);
if(obj.style.display == "none")
obj.style.display = "";
else
obj.style.display = "none";
}

251
javascript/conjunto-tallas.js Executable file
View File

@@ -0,0 +1,251 @@
Event.observe(window, 'load', function() {
AddEditProductosListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true){
DeleteConjuntoPopup(id);
return;
}
del = el.hasClassName('spanEdit');
if(del == true)
EditConjuntoPopup(id);
}
if($('contenido')!= undefined)
$('contenido').observe("click", AddEditProductosListeners);
if($("addConjunto") != undefined)
$('addConjunto').observe("click", function(){ AddConjuntoDiv(1); });
});
function AddConjuntoDiv(id){
grayOut(true);
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/conjunto-tallas.php',{
method:'post',
parameters: {type: "addConjunto"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('btnSave'), "click", AddConjunto);
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddConjuntoDiv
function AddConjunto(){
$("type").value = "saveConjunto";
new Ajax.Request(WEB_ROOT+'/ajax/conjunto-tallas.php',
{
method:'post',
parameters: $('frmAgregarConjunto').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail"){
ShowStatusPopUp(splitResponse[1]);
}else{
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddConjunto
function EditConjuntoPopup(id){
grayOut(true);
$('fview').show();
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/conjunto-tallas.php',{
method:'post',
parameters: {type: "editConjunto", conTallaId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); });
Event.observe($('btnUpdate'), "click", EditConjunto);
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditConjuntoPopup
function EditConjunto(){
$("type").value = "saveEditConjunto";
new Ajax.Request(WEB_ROOT+'/ajax/conjunto-tallas.php', {
method:'post',
parameters: $('frmEditarConjunto').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1])
}
else
{
ShowStatusPopUp(splitResponse[1])
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditConjunto
function DeleteConjuntoPopup(id){
var message = "Realmente deseas eliminar este conjunto?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/conjunto-tallas.php',{
method:'post',
parameters: {type: "deleteConjunto", conTallaId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeleteConjuntoPopup
/*** TALLAS ***/
function AddTalla()
{
var form = $("formName").value;
$("type").value = "saveTallas";
new Ajax.Request(WEB_ROOT+'/ajax/conjunto-tallas.php',
{
method:'post',
parameters: $(form).serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
AddTalla2();
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AddTalla2()
{
new Ajax.Request(WEB_ROOT+'/ajax/conjunto-tallas.php',
{
method:'post',
parameters: {type:"addTalla"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
{
$('listTallas').innerHTML = splitResponse[1];
}
else
{
alert("Ocurrio un error al agregar la talla");
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function DelTalla(id)
{
var form = $("formName").value;
$("type").value = "saveTallas";
new Ajax.Request(WEB_ROOT+'/ajax/conjunto-tallas.php',
{
method:'post',
parameters: $(form).serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
DelTalla2(id);
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function DelTalla2(id)
{
new Ajax.Request(WEB_ROOT+'/ajax/conjunto-tallas.php',
{
method:'post',
parameters: {type:"delTalla", k:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
{
$('listTallas').innerHTML = splitResponse[1];
}
else
{
alert("Ocurrio un error al agregar la talla");
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}

181
javascript/cuentas-bancarias.js Executable file
View File

@@ -0,0 +1,181 @@
Event.observe(window, 'load', function() {
Event.observe($('addCuentaBancaria'), "click", AddCuentaBancariaDiv);
AddEditCuentaBancariaListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true)
{
DeleteCuentaBancariaPopup(id);
return;
}
del = el.hasClassName('spanEdit');
if(del == true)
{
EditCuentaBancariaPopup(id);
}
del = el.hasClassName('spanView');
if(del == true)
{
ViewCuentaBancariaPopup(id);
}
}
$('contenido').observe("click", AddEditCuentaBancariaListeners);
});
function AddCuentaBancariaDiv(id)
{
grayOut(true);
if(id == 0)
{
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/cuentas-bancarias.php',
{
method:'post',
parameters: {type: "addCuentaBancaria"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('agregarCuentaBancaria'), "click", AddCuentaBancaria);
Event.observe($('fviewclose'), "click", function(){ AddCuentaBancariaDiv(0); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AddCuentaBancaria()
{
new Ajax.Request(WEB_ROOT+'/ajax/cuentas-bancarias.php',
{
method:'post',
parameters: $('agregarCuentaBancariaForm').serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1]);
}
else
{
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
Event.observe($('addCuentaBancaria'), "click", AddCuentaBancariaDiv);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function EditCuentaBancariaPopup(id)
{
grayOut(true);
$('fview').show();
if(id == 0)
{
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/cuentas-bancarias.php',
{
method:'post',
parameters: {type: "editCuentaBancaria", id:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ AddCuentaBancariaDiv(0); });
Event.observe($('editarCuentaBancaria'), "click", EditarCuentaBancaria);
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function EditarCuentaBancaria()
{
new Ajax.Request(WEB_ROOT+'/ajax/cuentas-bancarias.php',
{
method:'post',
parameters: $('editarCuentaBancariaForm').serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1])
}
else
{
ShowStatusPopUp(splitResponse[1])
$('contenido').innerHTML = splitResponse[2];
Event.observe($('addCuentaBancaria'), "click", AddCuentaBancariaDiv);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ViewCuentaBancariaPopup(id)
{
grayOut(true);
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/cuentas-bancarias.php',
{
method:'post',
parameters: {type: "viewCuentaBancaria", id:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ AddCuentaBancariaDiv(0); });
Event.observe($('btnClose'), "click", function(){ AddCuentaBancariaDiv(0); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function DeleteCuentaBancariaPopup(id)
{
var message = "Realmente deseas eliminar esta cuenta bancaria?";
if(!confirm(message))
{
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/cuentas-bancarias.php',
{
method:'post',
parameters: {type: "deleteCuentaBancaria", id: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1])
$('contenido').innerHTML = splitResponse[2];
Event.observe($('addCuentaBancaria'), "click", AddCuentaBancariaDiv);
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}

View File

@@ -0,0 +1,192 @@
function EditSaldoCtaPagar(id)
{
grayOut(true);
$('fview').show();
if(id == 0)
{
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/cuentas-pagar-saldos.php',
{
method:'post',
parameters: {type: "editSaldoCtaPagar", id:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ EditSaldoCtaPagar(0); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function SaveSaldoCtaPagar()
{
new Ajax.Request(WEB_ROOT+'/ajax/cuentas-pagar-saldos.php',
{
method:'post',
parameters: $('editarProveedorForm').serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1])
}
else
{
ShowStatusPopUp(splitResponse[1])
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function Buscar()
{
new Ajax.Request(WEB_ROOT+'/ajax/cuentas-pagar-saldos.php',
{
method:'post',
parameters:$('frmSaldos').serialize(true),
onLoading: function(req){
$('loadBusqueda').show();
$('contenido').innerHTML = "";
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$("contenido").innerHTML=response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ExportReport()
{
$('frmSaldos').submit();
return true;
}
function ViewPagos(id){
var obj = $('pagos_'+id);
if(obj.style.display == "none")
obj.style.display = "";
else
obj.style.display = "none";
}
//PAGOS
function AddPagoDiv(id)
{
grayOut(true);
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/cuentas-pagar-saldos.php',
{
method:'post',
parameters: {type: "addPago", proveedorId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('btnAddPago'), "click", AddPago);
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AddPago()
{
new Ajax.Request(WEB_ROOT+'/ajax/cuentas-pagar-saldos.php',
{
method:'post',
parameters: $('addPagoForm').serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
{
var id = splitResponse[1];
if(splitResponse[4] == 1){
pagado = "Pagado";
$('btnPago_'+id).style.display = 'none';
}else{
pagado = "Pendiente";
$('btnPago_'+id).style.display = '';
}
$('txtAbonos_'+id).innerHTML = splitResponse[2];
$('txtSaldo_'+id).innerHTML = splitResponse[3];
$('txtStatus_'+id).innerHTML = pagado;
ShowStatusPopUp(splitResponse[5]);
$('contPagos_'+id).innerHTML = splitResponse[6];
HideFview();
}
else
{
ShowStatusPopUp(splitResponse[1]);
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function DeletePago(id)
{
var message = "Realmente deseas eliminar este pago?";
if(!confirm(message))
{
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/cuentas-pagar-saldos.php',{
method:'post',
parameters: {type: "deletePago", id: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
var id = splitResponse[1];
$('txtAbonos_'+id).innerHTML = splitResponse[2];
$('txtSaldo_'+id).innerHTML = splitResponse[3];
ShowStatusPopUp(splitResponse[4]);
$('contPagos_'+id).innerHTML = splitResponse[5];
$('txtStatus_'+id).innerHTML = "Pendiente";
$('btnPago_'+id).style.display = '';
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}
//Others
function CheckKey(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13)
SaveSaldoCtaPagar();
}//CheckKey

276
javascript/cuentas-pagar.js Executable file
View File

@@ -0,0 +1,276 @@
Event.observe(window, 'load', function() {
if($("addProveedor") != undefined)
Event.observe($('addProveedor'), "click", AddProveedorDiv);
AddEditProveedorListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDescuentos');
var id = el.identify();
if(del == true)
{
ViewDescuentosPopup(id);
return;
}
}
$('contenido').observe("click", AddEditProveedorListeners);
});
function ViewDescuentosPopup(value)
{
grayOut(true);
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/cuentas-pagar.php',
{
method:'post',
parameters: {type: "viewDescuentos", value:value},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ViewFacturas(id){
var obj = $('facturas_'+id);
if(obj.style.display == "none")
obj.style.display = "";
else
obj.style.display = "none";
}
function ViewPagos(id){
var obj = $('pagos_'+id);
if(obj.style.display == "none")
obj.style.display = "";
else
obj.style.display = "none";
}
function ViewNotas(id){
var obj = $('notas_'+id);
if(obj.style.display == "none")
obj.style.display = "";
else
obj.style.display = "none";
}
//PAGOS
function AddPagoDiv(id)
{
grayOut(true);
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/cuentas-pagar.php',
{
method:'post',
parameters: {type: "addPago", pedidoId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('btnAddPago'), "click", AddPago);
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AddPago()
{
new Ajax.Request(WEB_ROOT+'/ajax/cuentas-pagar.php',
{
method:'post',
parameters: $('addPagoForm').serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
{
ShowStatusPopUp(splitResponse[1]);
HideFview();
Buscar();
}
else
{
ShowStatusPopUp(splitResponse[1]);
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function DeletePago(id)
{
var message = "Realmente deseas eliminar este pago?";
if(!confirm(message))
{
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/cuentas-pagar.php',{
method:'post',
parameters: {type: "deletePago", id: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatusPopUp(splitResponse[1]);
HideFview();
Buscar();
},
onFailure: function(){ alert('Something went wrong...') }
});
}
//NOTAS CREDITO
function AddNotaDiv(id)
{
grayOut(true);
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/cuentas-pagar.php',
{
method:'post',
parameters: {type: "addNota", pedidoId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('btnAddNota'), "click", AddNota);
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AddNota()
{
new Ajax.Request(WEB_ROOT+'/ajax/cuentas-pagar.php',
{
method:'post',
parameters: $('addNotaForm').serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
{
var id = splitResponse[1];
if(splitResponse[4] == 1){
pagado = "Pagado";
if($('btnPago_'+id))
$('btnPago_'+id).style.display = 'none';
if($('btnNota_'+id))
$('btnNota_'+id).style.display = 'none';
}else{
pagado = "Pendiente";
if($('btnNota_'+id))
$('btnNota_'+id).style.display = '';
if($('btnPago_'+id))
$('btnPago_'+id).style.display = '';
}
$('txtNotas_'+id).innerHTML = splitResponse[2];
$('txtSaldo_'+id).innerHTML = splitResponse[3];
$('txtStatus_'+id).innerHTML = pagado;
ShowStatusPopUp(splitResponse[5]);
$('contNotas_'+id).innerHTML = splitResponse[6];
HideFview();
}
else
{
ShowStatusPopUp(splitResponse[1]);
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function DeleteNota(id)
{
var message = "Realmente deseas eliminar esta nota de credito?";
if(!confirm(message))
{
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/cuentas-pagar.php',{
method:'post',
parameters: {type: "deleteNota", id: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
var id = splitResponse[1];
$('txtNotas_'+id).innerHTML = splitResponse[2];
$('txtSaldo_'+id).innerHTML = splitResponse[3];
ShowStatusPopUp(splitResponse[4]);
$('contNotas_'+id).innerHTML = splitResponse[5];
$('txtStatus_'+id).innerHTML = "Pendiente";
if($('btnNota_'+id))
$('btnNota_'+id).style.display = '';
if($('btnPago_'+id))
$('btnPago_'+id).style.display = '';
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function Buscar()
{
var global = $("global").checked;
if(global == true)
$("action").value = "search2";
else
$("action").value = "search";
new Ajax.Request(WEB_ROOT+'/ajax/cuentas-pagar.php',
{
method:'post',
parameters:$('frmSaldos').serialize(true),
onLoading: function(req){
$('loadBusqueda').show();
$('contenido').innerHTML = "";
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$("contenido").innerHTML=response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ExportReport()
{
$('frmSaldos').submit();
return true;
}

491
javascript/datetimepicker.js Executable file
View File

@@ -0,0 +1,491 @@
//Javascript name: My Date Time Picker
//Date created: 16-Nov-2003 23:19
//Scripter: TengYong Ng
//Website: http://www.rainforestnet.com
//Copyright (c) 2003 TengYong Ng
//FileName: DateTimePicker.js
//Version: 0.8
//Contact: contact@rainforestnet.com
// Note: Permission given to use this script in ANY kind of applications if
// header lines are left unchanged.
//Global variables
var winCal;
var dtToday=new Date();
var Cal;
var docCal;
var MonthName=["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio","Julio",
"Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"];
var WeekDayName=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
var exDateTime;//Existing Date and Time
//Configurable parameters
var cnTop="200";//top coordinate of calendar window.
var cnLeft="500";//left coordinate of calendar window
var WindowTitle ="DateTime Picker";//Date Time Picker title.
var WeekChar=2;//number of character for week day. if 2 then Mo,Tu,We. if 3 then Mon,Tue,Wed.
var CellWidth=20;//Width of day cell.
var DateSeparator="-";//Date Separator, you can change it to "/" if you want.
var TimeMode=24;//default TimeMode value. 12 or 24
var ShowLongMonth=true;//Show long month name in Calendar header. example: "January".
var ShowMonthYear=true;//Show Month and Year in Calendar header.
var MonthYearColor="#cc0033";//Font Color of Month and Year in Calendar header.
var WeekHeadColor="#0099CC";//Background Color in Week header.
var SundayColor="#6699FF";//Background color of Sunday.
var SaturdayColor="#CCCCFF";//Background color of Saturday.
var WeekDayColor="white";//Background color of weekdays.
var FontColor="blue";//color of font in Calendar day cell.
var TodayColor="#FFFF33";//Background color of today.
var SelDateColor="#FFFF99";//Backgrond color of selected date in textbox.
var YrSelColor="#cc0033";//color of font of Year selector.
var ThemeBg="";//Background image of Calendar window.
//end Configurable parameters
//end Global variable
function NewCal(pCtrl,pFormat,pShowTime,pTimeMode)
{
Cal=new Calendar(dtToday);
if ((pShowTime!=null) && (pShowTime))
{
Cal.ShowTime=true;
if ((pTimeMode!=null) &&((pTimeMode=='12')||(pTimeMode=='24')))
{
TimeMode=pTimeMode;
}
}
if (pCtrl!=null)
Cal.Ctrl=pCtrl;
if (pFormat!=null)
Cal.Format=pFormat.toUpperCase();
exDateTime=document.getElementById(pCtrl).value;
if (exDateTime!="")//Parse Date String
{
var Sp1;//Index of Date Separator 1
var Sp2;//Index of Date Separator 2
var tSp1;//Index of Time Separator 1
var tSp1;//Index of Time Separator 2
var strMonth;
var strDate;
var strYear;
var intMonth;
var YearPattern;
var strHour;
var strMinute;
var strSecond;
//parse month
Sp1=exDateTime.indexOf(DateSeparator,0)
Sp2=exDateTime.indexOf(DateSeparator,(parseInt(Sp1)+1));
if ((Cal.Format.toUpperCase()=="DDMMYYYY") || (Cal.Format.toUpperCase()=="DDMMMYYYY"))
{
strMonth=exDateTime.substring(Sp1+1,Sp2);
strDate=exDateTime.substring(0,Sp1);
}
else if ((Cal.Format.toUpperCase()=="MMDDYYYY") || (Cal.Format.toUpperCase()=="MMMDDYYYY"))
{
strMonth=exDateTime.substring(0,Sp1);
strDate=exDateTime.substring(Sp1+1,Sp2);
}
if (isNaN(strMonth))
intMonth=Cal.GetMonthIndex(strMonth);
else
intMonth=parseInt(strMonth,10)-1;
if ((parseInt(intMonth,10)>=0) && (parseInt(intMonth,10)<12))
Cal.Month=intMonth;
//end parse month
//parse Date
if ((parseInt(strDate,10)<=Cal.GetMonDays()) && (parseInt(strDate,10)>=1))
Cal.Date=strDate;
//end parse Date
//parse year
strYear=exDateTime.substring(Sp2+1,Sp2+5);
YearPattern=/^\d{4}$/;
if (YearPattern.test(strYear))
Cal.Year=parseInt(strYear,10);
//end parse year
//parse time
if (Cal.ShowTime==true)
{
tSp1=exDateTime.indexOf(":",0)
tSp2=exDateTime.indexOf(":",(parseInt(tSp1)+1));
strHour=exDateTime.substring(tSp1,(tSp1)-2);
Cal.SetHour(strHour);
strMinute=exDateTime.substring(tSp1+1,tSp2);
Cal.SetMinute(strMinute);
strSecond=exDateTime.substring(tSp2+1,tSp2+3);
Cal.SetSecond(strSecond);
}
}
winCal=window.open("","DateTimePicker","toolbar=0,status=0,menubar=0,fullscreen=no,width=195,height=245,resizable=0,top="+cnTop+",left="+cnLeft);
docCal=winCal.document;
RenderCal();
}
function RenderCal()
{
var vCalHeader;
var vCalData;
var vCalTime;
var i;
var j;
var SelectStr;
var vDayCount=0;
var vFirstDay;
docCal.open();
docCal.writeln("<html><head><title>"+WindowTitle+"</title>");
docCal.writeln("<script>var winMain=window.opener;</script>");
docCal.writeln("</head><body background='"+ThemeBg+"' link="+FontColor+" vlink="+FontColor+"><form name='Calendar'>");
vCalHeader="<table border=1 cellpadding=1 cellspacing=1 width='100%' align=\"center\" valign=\"top\">\n";
//Month Selector
vCalHeader+="<tr>\n<td colspan='7'><table border=0 width='100%' cellpadding=0 cellspacing=0><tr><td align='left'>\n";
vCalHeader+="<select name=\"MonthSelector\" onChange=\"javascript:winMain.Cal.SwitchMth(this.selectedIndex);winMain.RenderCal();\">\n";
for (i=0;i<12;i++)
{
if (i==Cal.Month)
SelectStr="Selected";
else
SelectStr="";
vCalHeader+="<option "+SelectStr+" value >"+MonthName[i]+"\n";
}
vCalHeader+="</select></td>";
//Year selector
vCalHeader+="\n<td align='right'><a href=\"javascript:winMain.Cal.DecYear();winMain.RenderCal()\"><b><font color=\""+YrSelColor+"\"><</font></b></a><font face=\"Verdana\" color=\""+YrSelColor+"\" size=2><b> "+Cal.Year+" </b></font><a href=\"javascript:winMain.Cal.IncYear();winMain.RenderCal()\"><b><font color=\""+YrSelColor+"\">></font></b></a></td></tr></table></td>\n";
vCalHeader+="</tr>";
//Calendar header shows Month and Year
if (ShowMonthYear)
vCalHeader+="<tr><td colspan='7'><font face='Verdana' size='2' align='center' color='"+MonthYearColor+"'><b>"+Cal.GetMonthName(ShowLongMonth)+" "+Cal.Year+"</b></font></td></tr>\n";
//Week day header
vCalHeader+="<tr bgcolor="+WeekHeadColor+">";
for (i=0;i<7;i++)
{
vCalHeader+="<td align='center'><font face='Verdana' size='2'>"+WeekDayName[i].substr(0,WeekChar)+"</font></td>";
}
vCalHeader+="</tr>";
docCal.write(vCalHeader);
//Calendar detail
CalDate=new Date(Cal.Year,Cal.Month);
CalDate.setDate(1);
vFirstDay=CalDate.getDay();
vCalData="<tr>";
for (i=0;i<vFirstDay;i++)
{
vCalData=vCalData+GenCell();
vDayCount=vDayCount+1;
}
for (j=1;j<=Cal.GetMonDays();j++)
{
var strCell;
vDayCount=vDayCount+1;
if ((j==dtToday.getDate())&&(Cal.Month==dtToday.getMonth())&&(Cal.Year==dtToday.getFullYear()))
strCell=GenCell(j,true,TodayColor);//Highlight today's date
else
{
if (j==Cal.Date)
{
strCell=GenCell(j,true,SelDateColor);
}
else
{
if (vDayCount%7==0)
strCell=GenCell(j,false,SaturdayColor);
else if ((vDayCount+6)%7==0)
strCell=GenCell(j,false,SundayColor);
else
strCell=GenCell(j,null,WeekDayColor);
}
}
vCalData=vCalData+strCell;
if((vDayCount%7==0)&&(j<Cal.GetMonDays()))
{
vCalData=vCalData+"</tr>\n<tr>";
}
}
docCal.writeln(vCalData);
//Time picker
if (Cal.ShowTime)
{
var showHour;
showHour=Cal.getShowHour();
vCalTime="<tr>\n<td colspan='7' align='center'>";
vCalTime+="<input type='text' name='hour' maxlength=2 size=1 style=\"WIDTH: 22px\" value="+showHour+" onchange=\"javascript:winMain.Cal.SetHour(this.value)\">";
vCalTime+=" : ";
vCalTime+="<input type='text' name='minute' maxlength=2 size=1 style=\"WIDTH: 22px\" value="+Cal.Minutes+" onchange=\"javascript:winMain.Cal.SetMinute(this.value)\">";
vCalTime+=" : ";
vCalTime+="<input type='text' name='second' maxlength=2 size=1 style=\"WIDTH: 22px\" value="+Cal.Seconds+" onchange=\"javascript:winMain.Cal.SetSecond(this.value)\">";
if (TimeMode==12)
{
var SelectAm =(parseInt(Cal.Hours,10)<12)? "Selected":"";
var SelectPm =(parseInt(Cal.Hours,10)>=12)? "Selected":"";
vCalTime+="<select name=\"ampm\" onchange=\"javascript:winMain.Cal.SetAmPm(this.options[this.selectedIndex].value);\">";
vCalTime+="<option "+SelectAm+" value=\"AM\">AM</option>";
vCalTime+="<option "+SelectPm+" value=\"PM\">PM<option>";
vCalTime+="</select>";
}
vCalTime+="\n</td>\n</tr>";
docCal.write(vCalTime);
}
//end time picker
docCal.writeln("\n</table>");
docCal.writeln("</form></body></html>");
docCal.close();
}
function GenCell(pValue,pHighLight,pColor)//Generate table cell with value
{
var PValue;
var PCellStr;
var vColor;
var vHLstr1;//HighLight string
var vHlstr2;
var vTimeStr;
if (pValue==null)
PValue="";
else
PValue=pValue;
if (pColor!=null)
vColor="bgcolor=\""+pColor+"\"";
else
vColor="";
if ((pHighLight!=null)&&(pHighLight))
{vHLstr1="color='red'><b>";vHLstr2="</b>";}
else
{vHLstr1=">";vHLstr2="";}
if (Cal.ShowTime)
{
vTimeStr="winMain.document.getElementById('"+Cal.Ctrl+"').value+=' '+"+"winMain.Cal.getShowHour()"+"+':'+"+"winMain.Cal.Minutes"+"+':'+"+"winMain.Cal.Seconds";
if (TimeMode==12)
vTimeStr+="+' '+winMain.Cal.AMorPM";
}
else
vTimeStr="";
PCellStr="<td "+vColor+" width="+CellWidth+" align='center'><font face='verdana' size='2'"+vHLstr1+"<a href=\"javascript:winMain.document.getElementById('"+Cal.Ctrl+"').value='"+Cal.FormatDate(PValue)+"';"+vTimeStr+";window.close();\">"+PValue+"</a>"+vHLstr2+"</font></td>";
return PCellStr;
}
function Calendar(pDate,pCtrl)
{
//Properties
this.Date=pDate.getDate();//selected date
this.Month=pDate.getMonth();//selected month number
this.Year=pDate.getFullYear();//selected year in 4 digits
this.Hours=pDate.getHours();
if (pDate.getMinutes()<10)
this.Minutes="0"+pDate.getMinutes();
else
this.Minutes=pDate.getMinutes();
if (pDate.getSeconds()<10)
this.Seconds="0"+pDate.getSeconds();
else
this.Seconds=pDate.getSeconds();
this.MyWindow=winCal;
this.Ctrl=pCtrl;
this.Format="ddMMyyyy";
this.Separator=DateSeparator;
this.ShowTime=false;
if (pDate.getHours()<12)
this.AMorPM="AM";
else
this.AMorPM="PM";
}
function GetMonthIndex(shortMonthName)
{
for (i=0;i<12;i++)
{
if (MonthName[i].substring(0,3).toUpperCase()==shortMonthName.toUpperCase())
{ return i;}
}
}
Calendar.prototype.GetMonthIndex=GetMonthIndex;
function IncYear()
{ Cal.Year++;}
Calendar.prototype.IncYear=IncYear;
function DecYear()
{ Cal.Year--;}
Calendar.prototype.DecYear=DecYear;
function SwitchMth(intMth)
{ Cal.Month=intMth;}
Calendar.prototype.SwitchMth=SwitchMth;
function SetHour(intHour)
{
var MaxHour;
var MinHour;
if (TimeMode==24)
{ MaxHour=23;MinHour=0}
else if (TimeMode==12)
{ MaxHour=12;MinHour=1}
else
alert("TimeMode can only be 12 or 24");
var HourExp=new RegExp("^\\d\\d$");
if (HourExp.test(intHour) && (parseInt(intHour,10)<=MaxHour) && (parseInt(intHour,10)>=MinHour))
{
if ((TimeMode==12) && (Cal.AMorPM=="PM"))
{
if (parseInt(intHour,10)==12)
Cal.Hours=12;
else
Cal.Hours=parseInt(intHour,10)+12;
}
else if ((TimeMode==12) && (Cal.AMorPM=="AM"))
{
if (intHour==12)
intHour-=12;
Cal.Hours=parseInt(intHour,10);
}
else if (TimeMode==24)
Cal.Hours=parseInt(intHour,10);
}
}
Calendar.prototype.SetHour=SetHour;
function SetMinute(intMin)
{
var MinExp=new RegExp("^\\d\\d$");
if (MinExp.test(intMin) && (intMin<60))
Cal.Minutes=intMin;
}
Calendar.prototype.SetMinute=SetMinute;
function SetSecond(intSec)
{
var SecExp=new RegExp("^\\d\\d$");
if (SecExp.test(intSec) && (intSec<60))
Cal.Seconds=intSec;
}
Calendar.prototype.SetSecond=SetSecond;
function SetAmPm(pvalue)
{
this.AMorPM=pvalue;
if (pvalue=="PM")
{
this.Hours=(parseInt(this.Hours,10))+12;
if (this.Hours==24)
this.Hours=12;
}
else if (pvalue=="AM")
this.Hours-=12;
}
Calendar.prototype.SetAmPm=SetAmPm;
function getShowHour()
{
var finalHour;
if (TimeMode==12)
{
if (parseInt(this.Hours,10)==0)
{
this.AMorPM="AM";
finalHour=parseInt(this.Hours,10)+12;
}
else if (parseInt(this.Hours,10)==12)
{
this.AMorPM="PM";
finalHour=12;
}
else if (this.Hours>12)
{
this.AMorPM="PM";
if ((this.Hours-12)<10)
finalHour="0"+((parseInt(this.Hours,10))-12);
else
finalHour=parseInt(this.Hours,10)-12;
}
else
{
this.AMorPM="AM";
if (this.Hours<10)
finalHour="0"+parseInt(this.Hours,10);
else
finalHour=this.Hours;
}
}
else if (TimeMode==24)
{
if (this.Hours<10)
finalHour="0"+parseInt(this.Hours,10);
else
finalHour=this.Hours;
}
return finalHour;
}
Calendar.prototype.getShowHour=getShowHour;
function GetMonthName(IsLong)
{
var Month=MonthName[this.Month];
if (IsLong)
return Month;
else
return Month.substr(0,3);
}
Calendar.prototype.GetMonthName=GetMonthName;
function GetMonDays()//Get number of days in a month
{
var DaysInMonth=[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
if (this.IsLeapYear())
{
DaysInMonth[1]=29;
}
return DaysInMonth[this.Month];
}
Calendar.prototype.GetMonDays=GetMonDays;
function IsLeapYear()
{
if ((this.Year%4)==0)
{
if ((this.Year%100==0) && (this.Year%400)!=0)
{
return false;
}
else
{
return true;
}
}
else
{
return false;
}
}
Calendar.prototype.IsLeapYear=IsLeapYear;
function FormatDate(pDate)
{
var mes = this.Month + 1;
if(pDate < 10)
pDate = "0" + pDate;
if(mes < 10)
mes = "0" + mes;
if (this.Format.toUpperCase()=="DDMMYYYY")
return (pDate+DateSeparator+mes+DateSeparator+this.Year);
else if (this.Format.toUpperCase()=="DDMMMYYYY")
return (pDate+DateSeparator+this.GetMonthName(false)+DateSeparator+this.Year);
else if (this.Format.toUpperCase()=="MMDDYYYY")
return ((this.Month+1)+DateSeparator+pDate+DateSeparator+this.Year);
else if (this.Format.toUpperCase()=="MMMDDYYYY")
return (this.GetMonthName(false)+DateSeparator+pDate+DateSeparator+this.Year);
}
Calendar.prototype.FormatDate=FormatDate;

314
javascript/datos-generales.js Executable file
View File

@@ -0,0 +1,314 @@
Event.observe(window, 'load', function() {
AddEditRfcListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true)
{
DeleteRfcPopup(id);
return;
}
del = el.hasClassName('spanEdit');
if(del == true)
{
EditRfcPopup(id);
}
del = el.hasClassName('spanView');
if(del == true)
{
ViewRfcPopup(id);
}
del = el.hasClassName('spanSucursales');
if(del == true)
{
ShowSucursales(id);
}
}
$('contenido').observe("click", AddEditRfcListeners);
SucursalesListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDeleteSucursal');
var id = el.identify();
if(del == true)
{
DeleteSucursal(id);
return;
}
del = el.hasClassName('spanEditSucursal');
if(del == true)
{
EditSucursalPopup(id);
return;
}
del = el.hasClassName('spanViewSucursal');
if(del == true)
{
ViewSucursalPopup(id);
return;
}
}
$('empresaSucursalesDiv').observe("click", SucursalesListeners);
});
function EditRfcPopup(id)
{
grayOut(true);
$('fview').show();
if(id == 0)
{
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/datos-generales.php',
{
method:'post',
parameters: {type: "editRfc", id:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); });
Event.observe($('editarRfc'), "click", EditarRfc);
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function EditarRfc()
{
new Ajax.Request(WEB_ROOT+'/ajax/datos-generales.php',
{
method:'post',
parameters: $('editRfcForm').serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1]);
}
else
{
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ViewRfcPopup(id)
{
grayOut(true);
$('fview').show();
if(id == 0)
{
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/datos-generales.php',
{
method:'post',
parameters: {type: "viewRfc", id:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); });
Event.observe($('btnClose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}
/** SUCURSALES ***/
function AddSucursal(rfcId)
{
var form = $('agregarSucursalForm').serialize();
new Ajax.Request(WEB_ROOT+'/ajax/sucursales.php',
{
method:'post',
parameters: {form:form, rfcId:rfcId, type: "saveSucursal"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1])
}
else
{
ShowStatusPopUp(splitResponse[1])
ShowSucursales(rfcId);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AddSucursalDiv(id, rfcId)
{
grayOut(true);
$('fview').show();
if(id == 0)
{
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/sucursales.php',
{
method:'post',
parameters: {type: "addSucursal"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ AddSucursalDiv(0); });
Event.observe($('agregarSucursal'), "click", function(){ AddSucursal(rfcId); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function EditSucursalPopup(id)
{
grayOut(true);
$('fview').show();
if(id == 0)
{
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/sucursales.php',
{
method:'post',
parameters: {type: "editSucursal", id:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); });
Event.observe($('editarSucursal'), "click", EditarSucursal);
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function EditarSucursal()
{
var form = $('editSucursalForm').serialize();
new Ajax.Request(WEB_ROOT+'/ajax/sucursales.php',
{
method:'post',
parameters: {form:form, type: "saveEditSucursal", sucursalId:$('sucursalId').value},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1])
}
else
{
ShowStatusPopUp(splitResponse[1]);
ShowSucursales(splitResponse[2]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ViewSucursalPopup(id)
{
grayOut(true);
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/sucursales.php',
{
method:'post',
parameters: {type: "viewSucursal", id:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); });
Event.observe($('btnClose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function DeleteSucursal(id)
{
var message = "Realmente deseas eliminar esta sucursal?";
if(!confirm(message))
{
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/sucursales.php',
{
method:'post',
parameters: {type: "deleteSucursal", sucursalId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1]);
ShowSucursales(splitResponse[2]);
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ShowSucursales(id)
{
var rfcId = id;
new Ajax.Request(WEB_ROOT+'/ajax/sucursales.php',
{
method:'post',
parameters: {type: "listSucursales", rfc: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('empresaSucursalesDiv').innerHTML = response;
Event.observe($('addSucursal'), "click", function(){ AddSucursalDiv(1, rfcId); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}

104
javascript/descuentos-nuevo.js Executable file
View File

@@ -0,0 +1,104 @@
function SaveDescuentos(k){
var descTipo = $("tipoDescGral").value;
var descVal = $("valDescGral").value;
var idVenta = $("ventaId").value;
new Ajax.Request(WEB_ROOT+'/ajax/descuentos.php',{
method:'post',
parameters: {type: "saveDescuentos", tipoDesc:descTipo, valDesc:descVal, ventaId:idVenta},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
console.log(response);
if(splitResponse[0] == "ok"){
alert("El descuento fue aplicado correctamente.");
CerrarDesc();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function UpdatePrecios(k){
var descTipo = $("tipoDesc_"+k).value;
var descVal = $("valDesc_"+k).value;
var idVenta = $("ventaId").value;
new Ajax.Request(WEB_ROOT+'/ajax/descuentos.php',{
method:'post',
parameters: {type: "updatePrecios", k:k, tipoDesc:descTipo, valDesc:descVal, ventaId:idVenta},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
console.log(response);
if(splitResponse[0] == "ok"){
$("txtTotalProd_"+k).innerHTML = splitResponse[1];
UpdateTotales();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function UpdateTotales(){
var descTipo = $("tipoDescGral").value;
var descVal = $("valDescGral").value;
var idVenta = $("ventaId").value;
new Ajax.Request(WEB_ROOT+'/ajax/descuentos.php',{
method:'post',
parameters: {type: "updateTotales", tipoDesc:descTipo, valDesc:descVal, ventaId:idVenta},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
console.log(response);
if(splitResponse[0] == "ok"){
$("txtSubtotal").innerHTML = splitResponse[1];
$("txtIva").innerHTML = splitResponse[2];
$("txtTotal").innerHTML = splitResponse[3];
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function CancelarDescuentos(){
new Ajax.Request(WEB_ROOT+'/ajax/descuentos.php',{
method:'post',
parameters: {type: "cancelarDescuentos"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
CerrarDesc();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//CancelarDescuento
function CerrarDesc(){
window.parent.HideFviewVta();
window.parent.location.reload();
}

82
javascript/descuentos.js Executable file
View File

@@ -0,0 +1,82 @@
function AplicarDescuento(id){
grayOut(true);
$('fviewVta').show();
new Ajax.Request(WEB_ROOT+'/ajax/ventas.php',{
method:'post',
parameters: {type: "addVenta"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSetVta(response);
$("divIframe").innerHTML = '<iframe width="1000" height="700" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'+WEB_ROOT+'/descuentos-nuevo/ventaId/'+id+'">Lo sentimos, pero tu navegador no soporta IFRAMES.</iframe>';
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AplicarDescuento
function CobrarVenta(id){
grayOut(true);
$('fviewVta').show();
new Ajax.Request(WEB_ROOT+'/ajax/ventas.php',{
method:'post',
parameters: {type: "addVenta"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSetVta(response);
$("divIframe").innerHTML = '<iframe width="1000" height="700" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'+WEB_ROOT+'/ventas-cobrar/ventaId/'+id+'">Lo sentimos, pero tu navegador no soporta IFRAMES.</iframe>';
},
onFailure: function(){ alert('Something went wrong...') }
});
}//CobrarVenta
function CancelarVenta(id)
{
var message = "Realmente deseas cancelar este descuento?";
if(!confirm(message))
{
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/descuentos.php',
{
method:'post',
parameters: {type: "cancelVenta", ventaId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatus(splitResponse[1]);
}
else
{
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function PrintTicket(id){
window.open(WEB_ROOT + "/ventas-ticket/descuentoId/" + id , "Ticket" , "width=350,height=300,scrollbars=YES")
}//printTicket

View File

@@ -0,0 +1,161 @@
function AddPedido(){
$("type").value = "saveDevolucion";
new Ajax.Request(WEB_ROOT+'/ajax/devoluciones-cedis.php',
{
method:'post',
parameters: $('frmDevolucion').serialize(),
onLoading: function(){
$("loader").show();
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
location.href = WEB_ROOT + "/devoluciones-cedis";
}else{
ShowStatus(splitResponse[1]);
HideFview();
$("loader").hide();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddPedido
function CancelDevolucion(id){
var message = "Realmente deseas cancelar esta devolucion?";
if(!confirm(message)){
return;
}
location.href = WEB_ROOT + "/devoluciones-cedis";
}
//PRODUCTOS
function AddProducto(){
$("type").value = "addProducto";
new Ajax.Request(WEB_ROOT+'/ajax/devoluciones-cedis.php',{
method:'post',
parameters: $('frmDevolucion').serialize(),
onLoading: function(){
$("productos").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("productos").innerHTML = splitResponse[1];
$("codigoBarra").value = "";
$("productoId").value = "";
$("enumAtributos").innerHTML = "";
$("txtProveedor").innerHTML = "";
$("txtDisponible").innerHTML = "";
$("sucursalId").value = "";
$("cantidad").value = "";
}else{
ShowStatus(splitResponse[1]);
$("productos").innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddProducto
function DeleteProducto(id){
var message = "Realmente deseas eliminar este producto?";
if(!confirm(message)){
return;
}
$("type").value = "deleteProducto";
new Ajax.Request(WEB_ROOT+'/ajax/devoluciones-cedis.php',{
method:'post',
parameters: {type:"deleteProducto", k:id},
onLoading: function(){
$("productos").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("productos").innerHTML = splitResponse[1];
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeleteProducto
function SearchProducto()
{
var codigoBarra = $("codigoBarra").value;
var sucursalId = $("sucursalId").value;
new Ajax.Request(WEB_ROOT+'/ajax/suggest_gral.php',
{
parameters: {codigoBarra:codigoBarra, type:"prodByCode2", sucursalId:sucursalId},
method:'post',
onLoading: function(){
$("enumAtributos").innerHTML = LOADER;
$("txtProveedor").innerHTML = LOADER;
$("txtDisponible").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$("enumAtributos").innerHTML = "";
$("txtProveedor").innerHTML = "";
$("txtDisponible").innerHTML = "";
if(splitResponse[0] == "ok"){
$("enumAtributos").innerHTML = splitResponse[1];
$("productoId").value = splitResponse[2];
$("txtProveedor").innerHTML = splitResponse[3];
$("txtDisponible").innerHTML = splitResponse[4];
}else
{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//SearchProducto
function CheckKey(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13){
SearchProducto();
}
}//CheckKey

View File

@@ -0,0 +1,31 @@
function DeleteDev(id){
var message = "Realmente deseas eliminar esta devolucion?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/devoluciones-cedis.php',{
method:'post',
parameters: {type:"deleteDev", devCedisId:id},
onLoading: function(){
$("productos").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}else{
ShowStatusPopUp(splitResponse[1]);
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeleteDev

380
javascript/devoluciones-nueva.js Executable file
View File

@@ -0,0 +1,380 @@
function AddProduct(){
var prodItemId = jQ("#idProdItem").val();
var cantidad = jQ("#cantidad").val();
var ventaId = jQ("#ventaId").val();
var disponible = jQ("#disponible").val();
if(prodItemId == ""){
alert("Ningún producto seleccionado.");
jQ('#codigoBarra').focus();
return;
}else if(parseInt(cantidad) > parseInt(disponible)){
alert("La cantidad es mayor que el disponible. Por favor, verifique.");
jQ('#codigoBarra').focus();
return;
}
jQ.ajax({
type: "POST",
url: 'ajax/devoluciones.php',
data: "type=addProduct&prodItemId="+prodItemId+"&cantidad="+cantidad+"&ventaId="+ventaId,
success: function(data) {
var splitResponse = data.split("[#]");
if(splitResponse[0] == "ok"){
jQ('#tblConceptos').html(splitResponse[1]);
jQ('#txtTotal').html(splitResponse[2]);
jQ('#cantidad').focus();
//Actualizamos los Datos para obtener los roductos disponibles
UpdateInfoProd(prodItemId);
}
}
});
}
function DeleteProduct(k){
jQ.ajax({
type: "POST",
url: 'ajax/devoluciones.php',
data: "type=deleteProduct&k="+k,
beforeSend: function(){
//jQ("#tblConceptos").html(LOADER);
},
success: function(data) {
var splitResponse = data.split("[#]");
if(splitResponse[0] == "ok"){
jQ('#tblConceptos').html(splitResponse[1]);
jQ('#txtTotal').html(splitResponse[2]);
//Actualizamos los Datos para obtener los roductos disponibles
UpdateInfoProd(splitResponse[3]);
}
}
});
}
function SaveDevolucion(){
var ventaId = jQ("#ventaId").val();
var codigo = jQ("#codigo").val();
jQ.ajax({
type: "POST",
url: 'ajax/devoluciones.php',
data: "action=saveDevolucion&ventaId="+ventaId+"&codigo="+codigo,
success: function(data) {
var splitResponse = data.split("[#]");
if(splitResponse[0] == "ok"){
window.parent.HideFviewVta();
window.parent.AddVentaDiv();
alert("Para finalizar la devolucion, debe ingresar la nueva prenda a cobrar.");
/*
HideFviewCobro();
LimpiarFormulario();
PrintTicket(splitResponse[1]);
*/
}else if(splitResponse[0] == "fail"){
alert(splitResponse[1]);
}
}//success
});
}
function ProdSelected(event, ui){
var producto = ui.item.value;
var prodItemId = producto.prodItemId;
jQ("#codigoBarra").val(producto.codigoBarra);
jQ("#txtProducto").html(producto.descripcion);
event.preventDefault();
jQ("#cantidad").focus();
UpdateInfoProd(prodItemId);
}//ProdSelected
function UpdateInfoProd(prodItemId){
var ventaId = jQ("#ventaId").val();
//Recuperamos el Precio y la cantidad Disponible
jQ.ajax({
type: "POST",
url: 'ajax/devoluciones.php',
data: "type=getProdInfoDev&prodItemId=" + prodItemId + "&ventaId=" + ventaId,
success: function(data) {
var splitResponse = data.split("[#]");
if(splitResponse[0] == "ok"){
jQ('#txtPrecioUni').html(splitResponse[1]);
jQ('#txtDisp').html(splitResponse[2]);
jQ('#disponible').val(splitResponse[2]);
jQ('#idProdItem').val(prodItemId);
}
}
});
}
function UpdateInfoProdByCode(){
//Recuperamos el Precio y la cantidad Disponible
var ventaId = jQ("#ventaId").val();
var codigoBarra = jQ("#codigoBarra").val();
jQ.ajax({
type: "POST",
url: 'ajax/devoluciones.php',
data: "type=getProdInfoDevByCode&codigoBarra=" + codigoBarra + "&ventaId=" + ventaId,
beforeSend: function(){
jQ('#txtProducto').html(LOADER);
},
success: function(data) {
var splitResponse = data.split("[#]");
jQ('#txtProducto').html('&nbsp;');
if(splitResponse[0] == "ok"){
jQ('#txtPrecioUni').html(splitResponse[1]);
jQ('#txtDisp').html(splitResponse[2]);
jQ('#disponible').val(splitResponse[2]);
jQ('#txtProducto').html(splitResponse[3]);
jQ('#idProdItem').val(splitResponse[4]);
document.getElementById('cantidad').focus();
}else if(splitResponse[0] == "fail"){
alert(splitResponse[1]);
}
}
});
}
function UpdateInfoProdB(prodItemId){
//Recuperamos el Precio y la cantidad Disponible
jQ.ajax({
type: "POST",
url: 'ajax/ventas.php',
data: "type=getProdInfoVta&prodItemId="+prodItemId,
success: function(data) {
var splitResponse = data.split("[#]");
if(splitResponse[0] == "ok"){
jQ('#txtPrecioUni').html(splitResponse[1]);
jQ('#txtDisp').html(splitResponse[2]);
jQ('#disponible').val(splitResponse[2]);
jQ("#txtProducto").html(splitResponse[3]);
jQ('#idProdItem').val(prodItemId);
HideFviewCobro();
}
}
});
}
function ProdFocus(event, ui){
event.preventDefault();
}//ProdFocus
//Venta
/*
function CobrarDevolucionDiv(){
jQ.ajax({
type: "POST",
url: 'ajax/devoluciones.php',
data: 'type=cobrarDev',
success: function(data) {
var splitResponse = data.split("[#]");
if(splitResponse[0] == "ok"){
FViewOffSetCobro(splitResponse[1]);
jQ('#fviewCobro').show();
}else if(splitResponse[0] == "fail"){
alert(splitResponse[1]);
}
}
});
}//CobrarVentaDiv
*/
function CerrarVta(){
window.parent.HideFviewVta();
window.parent.location.reload();
}
function CancelarDevolucion(){
jQ.ajax({
type: "POST",
url: 'ajax/devoluciones.php',
data: "action=cancelarDevolucion",
success: function(data) {
var splitResponse = data.split("[#]");
if(splitResponse[0] == "ok")
jQ("#tblConceptos").html(splitResponse[1]);
LimpiarFormulario();
}
});
}//CancelarDevolucion
function LimpiarFormulario(){
jQ.ajax({
type: "POST",
url: 'ajax/devoluciones.php',
data: "action=limpiarForm",
success: function(data) {
var splitResponse = data.split("[#]");
if(splitResponse[0] == "ok")
jQ("#tblConceptos").html(splitResponse[1]);
jQ("#txtProducto").html('&nbsp;');
jQ("#txtPrecioUni").html('0.00');
jQ("#txtDisp").html('0');
jQ("#cantidad").val(1);
jQ("#codigoBarra").val('');
jQ("#disponible").val('');
jQ("#idProdItem").val('');
jQ('#ventaId').val('');
jQ('#txtTotal').html('0.00');
}
});
}
function BuscarProducto(){
jQ.ajax({
type: "POST",
url: 'ajax/ventas.php',
data: 'type=buscarProducto',
success: function(data) {
var splitResponse = data.split("[#]");
if(splitResponse[0] == "ok"){
FViewOffSetCobro(splitResponse[1]);
jQ('#fviewCobro').show();
}else if(splitResponse[0] == "fail"){
alert(splitResponse[1]);
}
}
});
}
function LoadSubcats(){
var catId = $("prodCatId2").value;
new Ajax.Request(WEB_ROOT+'/ajax/ventas.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 LoadProductos(){
var idProveedor = $("proveedorId2").value;
var idProdCat = $("prodCatId2").value;
var idProdSubcat = $("prodSubcatId2").value;
var vDisponible = 0;
if($("disponible2").checked)
vDisponible = 1;
new Ajax.Request(WEB_ROOT+'/ajax/ventas.php',{
method:'post',
parameters: {type:"loadProductos", prodCatId:idProdCat, prodSubcatId:idProdSubcat, proveedorId:idProveedor, disponible:vDisponible},
onLoading: function(){
$("enumProductos").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
$("enumProductos").innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}//LoadProductos
function CheckKey(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13)
UpdateInfoProdByCode();
}//CheckKey
function PrintTicket(id){
window.open(WEB_ROOT + "/devoluciones-ticket/devolucionId/" + id , "Ticket Devolucion" , "width=350,height=300,scrollbars=YES")
}//PrintTicket
function PrintTicketVta(id){
window.open(WEB_ROOT + "/ventas-ticket/id/" + id , "Ticket Venta" , "width=350,height=300,scrollbars=YES")
}//PrintTicket

155
javascript/devoluciones.js Executable file
View File

@@ -0,0 +1,155 @@
Event.observe(window, 'load', function() {
AddEditUsuarioListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanCancel');
var id = el.identify();
if(del == true)
{
CancelDevolucion(id);
return;
}
}
$('contenido').observe("click", AddEditUsuarioListeners);
});
function AddDevolucionDiv(id){
grayOut(true);
$('fviewVta').show();
new Ajax.Request(WEB_ROOT+'/ajax/devoluciones.php',{
method:'post',
parameters: {type: "addDevolucion"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSetVta(response);
$("divIframe").innerHTML = '<iframe width="1000" height="700" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'+WEB_ROOT+'/devoluciones-nueva">Lo sentimos, pero tu navegador no soporta IFRAMES.</iframe>';
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddDevolucionDiv
function CancelDevolucion(id)
{
var message = "Realmente deseas cancelar esta venta?";
if(!confirm(message))
{
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/devoluciones.php',
{
method:'post',
parameters: {type: "cancelDevolucion", ventaId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatus(splitResponse[1]);
}
else
{
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AddVentaDiv(id){
grayOut(true);
$('fviewVta').show();
new Ajax.Request(WEB_ROOT+'/ajax/ventas.php',{
method:'post',
parameters: {type: "addVenta"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSetVta(response);
$("divIframe").innerHTML = '<iframe width="1000" height="700" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'+WEB_ROOT+'/ventas-nueva">Lo sentimos, pero tu navegador no soporta IFRAMES.</iframe>';
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddVentaDiv
function LoadUsers(){
var sucursalId = $("sucursalId2").value;
new Ajax.Request(WEB_ROOT+'/ajax/usuarios.php',
{
method:'post',
parameters: {type: "loadUsersVtas", sucursalId:sucursalId},
onLoading: function(){
$("enumUsr").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("enumUsr").innerHTML = splitResponse[1];
}else{
ShowStatus(splitResponse[1]);
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function Search(){
var sucursalId = $("sucursalId2").value;
new Ajax.Request(WEB_ROOT+'/ajax/devoluciones.php',
{
method:'post',
parameters: $('frmSearch').serialize(true),
onLoading: function(){
$("loadBusqueda").show();
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$("loadBusqueda").hide();
if(splitResponse[0] == "ok"){
$("contenido").innerHTML = splitResponse[1];
}else{
ShowStatus(splitResponse[1]);
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function PrintTicket(id){
window.open(WEB_ROOT + "/devoluciones-ticket/devolucionId/" + id , "Ticket" , "width=350,height=300,scrollbars=YES")
}//printTicket

View File

@@ -0,0 +1,59 @@
function LoadOrdenesCompra(){
var idSucursal = $("sucursalId").value;
new Ajax.Request(WEB_ROOT+'/ajax/envios.php',
{
method:'post',
parameters: {type:"loadOrdenesCompra", sucursalId:idSucursal},
onLoading: function(){
$("ordenes").innerHTML = LOADER2;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$('ordenes').innerHTML = splitResponse[1];
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//LoadOrdenesCompra
function SendMercancia(){
var resp = confirm("Esta seguro de enviar la mercancia?");
if(!resp)
return;
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";
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//SendMercancia

View File

@@ -0,0 +1,226 @@
Event.observe(window, 'load', function() {
AddEditProductosListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true){
DeleteProductoPopup(id);
return;
}
}
if($('contenido')!= undefined)
$('contenido').observe("click", AddEditProductosListeners);
if($("addProducto") != undefined)
$('addProducto').observe("click", function(){ AddProductoDiv(1); });
});
function AddProductoDiv(id){
grayOut(true);
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/envios-recibir-reporte.php',{
method:'post',
parameters: {type: "addProducto"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('btnSave'), "click", AddProducto);
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddProductoDiv
function AddProducto(){
new Ajax.Request(WEB_ROOT+'/ajax/envios-recibir-reporte.php',
{
method:'post',
parameters: $('frmAgregarProducto').serialize(),
onLoading: function(){
$("txtLoaderF").innerHTML = LOADER2;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$("txtLoaderF").innerHTML = "";
if(splitResponse[0] == "fail"){
ShowStatusPopUp(splitResponse[1]);
}else{
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddProducto
function DeleteProductoPopup(id){
var message = "Realmente deseas eliminar este producto?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/envios-recibir-reporte.php',{
method:'post',
parameters: {type: "deleteProducto", envRepProdId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeleteProductoPopup
function LoadInfoProd(){
var envioId = $("envioId").value;
var code = $("codigoBarra").value;
new Ajax.Request(WEB_ROOT+'/ajax/envios-recibir-reporte.php',{
method:'post',
parameters: {type: "loadInfoProd", codigoBarra: code, envioId:envioId},
onLoading: function(){
$("txtModelo").innerHTML = LOADER;
$("txtCantRec").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$("txtModelo").innerHTML = splitResponse[1];
$("txtCantRec").innerHTML = splitResponse[2];
},
onFailure: function(){ alert('Something went wrong...') }
});
}//LoadInfoProd
function Search(){
new Ajax.Request(WEB_ROOT+'/ajax/envios-recibir-reporte.php',{
method:'post',
parameters: $('frmSearch').serialize(),
onLoading: function(){
$("loadBusqueda").show();
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$("loadBusqueda").hide();
$('contenido').innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}//Search
function AutorizarProducto(id){
var message = "Realmente desea autorizar este producto?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/envios-recibir-reporte.php',{
method:'post',
parameters: {type: "autorizarProducto", envRepProdId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail"){
ShowStatusPopUp(splitResponse[1]);
}else{
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AutorizarProducto
function RechazarProducto(id){
var message = "Realmente desea rechazar este producto?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/envios-recibir-reporte.php',{
method:'post',
parameters: {type: "rechazarProducto", envRepProdId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail"){
ShowStatusPopUp(splitResponse[1]);
}else{
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//RechazarProducto
function CheckKey(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13)
Search();
}//CheckKey

69
javascript/envios-recibir.js Executable file
View File

@@ -0,0 +1,69 @@
function RecibirMercancia(id){
var message = "Realmente deseas confirmar la recepción del envío No. " + id +" ?";
if(!confirm(message)){
return;
}
$("type").value = "recibirMercancia";
new Ajax.Request(WEB_ROOT+'/ajax/envios.php',
{
method:'post',
parameters: $('frmRecibir').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";
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//RecibirMercancia
function ToogleFields(pedidoId, id){
var completo = $("completo_"+pedidoId+"_"+id).checked;
var noPrendasEnv = $("noPrendasEnv_"+pedidoId+"_"+id).value;
if(completo){
$("cantPrendas_"+pedidoId+"_"+id).value = noPrendasEnv;
$("faltantes_"+pedidoId+"_"+id).value = "";
$("cantPrendas_"+pedidoId+"_"+id).style.display = "none";
$("faltantes_"+pedidoId+"_"+id).style.display = "none";
}else{
$("cantPrendas_"+pedidoId+"_"+id).value = "";
$("faltantes_"+pedidoId+"_"+id).value = "";
$("cantPrendas_"+pedidoId+"_"+id).style.display = "";
$("faltantes_"+pedidoId+"_"+id).style.display = "";
}
}
function UpdateFaltantes(pedidoId, id){
var cantPrendas = $("cantPrendas_"+pedidoId+"_"+id).value;
var noPrendasEnv = $("noPrendasEnv_"+pedidoId+"_"+id).value;
var faltantes = noPrendasEnv - cantPrendas;
if(faltantes < 0)
faltantes = 0;
$("faltantes_"+pedidoId+"_"+id).value = faltantes;
}

51
javascript/envios-reporte.js Executable file
View File

@@ -0,0 +1,51 @@
function ExportGral()
{
new Ajax.Request(WEB_ROOT+'/ajax/envios-reporte.php',
{
method:'post',
parameters: $('frmSearch').serialize(),
onLoading: function(){
$('loadBusqueda').show();
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$('loadBusqueda').hide();
if(splitResponse[0] == "ok"){
$('frmSearch').submit();return true;
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function Search()
{
new Ajax.Request(WEB_ROOT+'/ajax/envios-reporte.php',
{
method:'post',
parameters: $('frmSearch').serialize(),
onLoading: function(){
$('loadBusqueda').show();
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$('loadBusqueda').hide();
if(splitResponse[0] == "ok"){
$('contenido').innerHTML = splitResponse[1];
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}

View File

@@ -0,0 +1,328 @@
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();
}

View File

@@ -0,0 +1,98 @@
Event.observe(window, 'load', function() {
AddEditEnviosListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanEnviar');
var id = el.identify();
if(del == true){
EnviarEnvio(id);
return;
}
del = el.hasClassName('spanAdd');
if(del == true){
RecibirEnvio(id);
return;
}
}
if($('contenido')!= undefined)
$('contenido').observe("click", AddEditEnviosListeners);
});
function EnviarEnvio(id){
var message = "Enviar Productos?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/envios.php',{
method:'post',
parameters: {type: "updateEnvioDevolucion", envioId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
//ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function RecibirEnvio(id){
var message = "Productos recibido?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/envios.php',{
method:'post',
parameters: {type: "updateEnvioDevolucion", envioId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
//ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function Search()
{
new Ajax.Request(WEB_ROOT+'/ajax/envios.php',
{
method:'post',
parameters: $('frmSearch').serialize(),
onLoading: function(){
$('loadBusqueda').show();
$('contenido').innerHTML = '';
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$('loadBusqueda').hide();
if(splitResponse[0] == "ok")
$('contenido').innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}

View File

@@ -0,0 +1,155 @@
function AutorizarEnvio(id){
var message = "Realmente deseas autorizar este envio?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/envios.php',
{
method:'post',
parameters: {type:"autorizarEnvio", envioId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
window.location.href = WEB_ROOT + "/envios-tienda";
else
ShowStatus(splitResponse[1]);
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AutorizarEnvio
function AutorizarEnvioSuc(id){
var message = "Realmente deseas autorizar este envio?";
if(!confirm(message)){
return;
}
var noCajas = $("noCajas").value;
new Ajax.Request(WEB_ROOT+'/ajax/envios.php',
{
method:'post',
parameters: {type:"autorizarEnvioSuc", envioId:id, noCajas:noCajas},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
window.location.href = WEB_ROOT + "/envios-tienda";
else
ShowStatus(splitResponse[1]);
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AutorizarEnvioSuc
function RechazarEnvioPopup(id){
grayOut(true);
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/envios.php',{
method:'post',
parameters: {type: "rechazarEnvioPopup", envioId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('btnSave'), "click", RechazarEnvio);
Event.observe($('btnCancel'), "click", function(){ HideFview(); });
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}//RechazarEnvioPopup
function RechazarEnvio(){
new Ajax.Request(WEB_ROOT+'/ajax/envios.php',
{
method:'post',
parameters: $('frmRechazarEnvio').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
window.location.href = WEB_ROOT + "/envios-tienda";
else
ShowStatusPopUp(splitResponse[1]);
},
onFailure: function(){ alert('Something went wrong...') }
});
}//RechazarEnvio
function RecibirMercancia(){
new Ajax.Request(WEB_ROOT+'/ajax/envios.php',
{
method:'post',
parameters: $('frmRecibir').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")
window.location.href = WEB_ROOT + "/envios-tienda";
else
ShowStatus(splitResponse[1]);
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//RecibirMercancia
function ShowOtroMotivo(){
var motivoId = $("motivoId").value;
var status;
if(motivoId == 3)
status = "";
else
status = "none";
$("inputOtroMotivo").style.display = status;
}

68
javascript/envios-tienda.js Executable file
View File

@@ -0,0 +1,68 @@
Event.observe(window, 'load', function() {
AddEditEnviosListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true){
DeleteEnvioPopup(id);
return;
}
}
if($('contenido')!= undefined)
$('contenido').observe("click", AddEditEnviosListeners);
});
function DeleteEnvioPopup(id){
var message = "Realmente deseas eliminar este envío?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/envios.php',{
method:'post',
parameters: {type: "deleteEnvio", envioId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeleteEnvioPopup
function Search()
{
new Ajax.Request(WEB_ROOT+'/ajax/envios.php',
{
method:'post',
parameters: $('frmSearch').serialize(),
onLoading: function(){
$('loadBusqueda').show();
$('contenido').innerHTML = '';
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$('loadBusqueda').hide();
if(splitResponse[0] == "ok")
$('contenido').innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}

31
javascript/envios-transito.js Executable file
View File

@@ -0,0 +1,31 @@
function Search()
{
new Ajax.Request(WEB_ROOT+'/ajax/envios-transito.php',
{
method:'post',
parameters: $('frmSearch').serialize(),
onLoading: function(){
$('contenido').innerHTML = LOADER2;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$('contenido').innerHTML = "";
if(splitResponse[0] == "ok"){
$('contenido').innerHTML = splitResponse[1];
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ExportGral(){
$("frmSearch").submit();
}

40
javascript/envios-traspasos.js Executable file
View File

@@ -0,0 +1,40 @@
function Search()
{
new Ajax.Request(WEB_ROOT+'/ajax/envios.php',
{
method:'post',
parameters: $('frmSearch').serialize(),
onLoading: function(){
$('loadBusqueda').show();
$('contenido').innerHTML = '';
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$('loadBusqueda').hide();
if(splitResponse[0] == "ok")
$('contenido').innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ExportPdf(){
$("frmSearch").submit();
}
function CheckKey(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13)
Search();
}//CheckKey

80
javascript/envios.js Executable file
View File

@@ -0,0 +1,80 @@
Event.observe(window, 'load', function() {
AddEditEnviosListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true){
DeleteEnvioPopup(id);
return;
}
}
if($('contenido')!= undefined)
$('contenido').observe("click", AddEditEnviosListeners);
});
function DeleteEnvioPopup(id){
var message = "Realmente deseas eliminar este envío?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/envios.php',{
method:'post',
parameters: {type: "deleteEnvio", envioId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeleteEnvioPopup
function Search()
{
new Ajax.Request(WEB_ROOT+'/ajax/envios.php',
{
method:'post',
parameters: $('frmSearch').serialize(),
onLoading: function(){
$('loadBusqueda').show();
$('contenido').innerHTML = '';
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$('loadBusqueda').hide();
if(splitResponse[0] == "ok")
$('contenido').innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function CheckKey(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13)
Search();
}//CheckKey

129
javascript/evaluar-pedidos.js Executable file
View File

@@ -0,0 +1,129 @@
Event.observe(window, 'load', function() {
AddEditEnviosListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true){
aplicarDevolucion(id);
return;
}
del = el.hasClassName('spanAdd');
if(del == true){
aplicarBonificacion(id);
return;
}
}
if($('contenido')!= undefined)
$('contenido').observe("click", AddEditEnviosListeners);
});
function aplicarBonificacion(id)
{
grayOut(true);
if(id == 0)
{
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/evaluar-pedidos.php',
{
method:'post',
parameters: {type: "addPago", id:id, menu: "bonificacion"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('btnAddPago'), "click", AddPago);
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AddPago()
{
var message = "Realmente deseas aplicar ésta bonificacion?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/evaluar-pedidos.php',
{
method:'post',
parameters: $('addPagoForm').serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
{
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
aplicarBonificacion(0);
}
else
{
ShowStatusPopUp(splitResponse[1]);
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function aplicarDevolucion(id)
{
alert(id);
var message = "Realmente deseas aplicar ésta devolucion?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/evaluar-pedidos.php',
{
method:'post',
parameters: {type: "saveDevolucion", id:id, menu: "devolucion"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('btnAddPago'), "click", AddPago);
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeleteEnvioPopup
/*function Search()
{
new Ajax.Request(WEB_ROOT+'/ajax/envios.php',
{
method:'post',
parameters: $('frmSearch').serialize(),
onLoading: function(){
$('loadBusqueda').show();
$('contenido').innerHTML = '';
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$('loadBusqueda').hide();
if(splitResponse[0] == "ok")
$('contenido').innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}*/

View File

@@ -0,0 +1,13 @@
Event.observe(window, 'load', function() {
if($('agregarCertificado')!= undefined)
Event.observe($('agregarCertificado'), "click", AgregarCertificado);
});
function AgregarCertificado(){
$("loader").show();
$('frmCertificado').submit();
}//AgregarCertificado

165
javascript/facturacion-folios.js Executable file
View File

@@ -0,0 +1,165 @@
Event.observe(window, 'load', function() {
AddEditFoliosListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true){
DeleteFoliosPopup(id);
return;
}
del = el.hasClassName('spanEdit');
if(del == true)
EditFoliosPopup(id);
}
if($('contenido')!= undefined)
$('contenido').observe("click", AddEditFoliosListeners);
Event.observe($('addFolios'), "click", AddFoliosDiv);
});
function AddFoliosDiv(){
grayOut(true);
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/facturacion-folios.php',{
method:'post',
parameters: {type: "addFolios"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('fviewclose'), "click", HideFview);
Event.observe($('btnSaveFolios'), "click", AddFolios);
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddFoliosDiv
function AddFolios(){
new Ajax.Request(WEB_ROOT+'/ajax/facturacion-folios.php',
{
method:'post',
parameters: $('frmAgregarFolios').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail"){
ShowStatusPopUp(splitResponse[1]);
}else{
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddFolios
function EditFoliosPopup(id){
grayOut(true);
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/facturacion-folios.php',{
method:'post',
parameters: {type: "editFolios", id_serie:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", HideFview);
Event.observe($('btnEditarFolios'), "click", EditarFolios);
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditFoliosPopup
function EditarFolios(){
new Ajax.Request(WEB_ROOT+'/ajax/facturacion-folios.php', {
method:'post',
parameters: $('frmEditarFolios').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1]);
}
else
{
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditarFolios
function DeleteFoliosPopup(id){
var message = "Realmente deseas eliminar estos folios?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/facturacion-folios.php',{
method:'post',
parameters: {type: "deleteFolios", id_serie: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1])
$('contenido').innerHTML = splitResponse[2];
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeleteFoliosPopup
function DeleteLogo(id){
var message = "Realmente deseas eliminar este logo?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/facturacion-folios.php',{
method:'post',
parameters: {type: "deleteLogo", serieId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1])
$('contenido').innerHTML = splitResponse[2];
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeleteLogo
function SaveLogo(id){
$("loader_"+id).show();
$("frmCedula_"+id).submit();
}

179
javascript/facturacion-mensual.js Executable file
View File

@@ -0,0 +1,179 @@
Event.observe(window, 'load', function() {
AddEditItemsListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDetails');
var id = el.identify();
if(del == true)
ShowDetailsPopup(id);
del = el.hasClassName('spanCancel');
if(del == true)
CancelarFactura(id);
}
SendItemsListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanSend');
var id = el.identify();
if(del == true)
EnviarPdf(id);
}
$('contenido').observe("click", AddEditItemsListeners);
});
function Buscar()
{
new Ajax.Request(WEB_ROOT+'/ajax/facturacion.php',
{
parameters: $('frmBusqueda').serialize(),
method:'post',
onLoading: function(){
$("contenido").innerHTML = LOADER2;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$('contenido').innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}//Buscar
function ShowDetailsPopup(id){
grayOut(true);
$('fview').show();
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/facturacion.php',{
method:'post',
parameters: {type: "showDetails", comprobanteId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ ShowDetailsPopup(0); });
$('accionList').observe("click", SendItemsListeners);
},
onFailure: function(){ alert('Something went wrong...') }
});
}//ShowDetailsPopup
function EnviarPdf(id){
new Ajax.Request(WEB_ROOT+'/ajax/facturacion.php',
{
method:'post',
parameters: {type: 'enviarPdf', comprobanteId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
ShowStatusPopUp(splitResponse[1])
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EnviarEmail
function CancelarFactura(id){
grayOut(true);
$('fview').show();
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/facturacion.php',{
method:'post',
parameters: {type: "cancelarDiv", comprobanteId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ ShowDetailsPopup(0); });
Event.observe($('btnCancelar'), "click", DoCancelacion);
},
onFailure: function(){ alert('Something went wrong...') }
});
}//CancelarFactura
function DoCancelacion(){
new Ajax.Request(WEB_ROOT+'/ajax/facturacion.php',
{
method:'post',
parameters: $('frmCancelar').serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail"){
ShowStatusPopUp(splitResponse[1])
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DoCancelacion
function FacturaMensual(){
new Ajax.Request(WEB_ROOT+'/ajax/facturacion-nueva.php',{
method:'post',
parameters: {type: "facturaMensual"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
window.location.href = WEB_ROOT + "/facturacion-nueva/mensual/1";
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function CheckKey(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13)
Buscar();
}//CheckKey

331
javascript/facturacion-nueva.js Executable file
View 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();
}

157
javascript/facturacion.js Executable file
View File

@@ -0,0 +1,157 @@
Event.observe(window, 'load', function() {
AddEditItemsListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDetails');
var id = el.identify();
if(del == true)
ShowDetailsPopup(id);
del = el.hasClassName('spanCancel');
if(del == true)
CancelarFactura(id);
}
SendItemsListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanSend');
var id = el.identify();
if(del == true)
EnviarPdf(id);
}
$('contenido').observe("click", AddEditItemsListeners);
});
function Buscar()
{
new Ajax.Request(WEB_ROOT+'/ajax/facturacion.php',
{
parameters: $('frmBusqueda').serialize(),
method:'post',
onLoading: function(){
$("contenido").innerHTML = LOADER2;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$('contenido').innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}//Buscar
function ShowDetailsPopup(id){
grayOut(true);
$('fview').show();
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/facturacion.php',{
method:'post',
parameters: {type: "showDetails", comprobanteId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ ShowDetailsPopup(0); });
$('accionList').observe("click", SendItemsListeners);
},
onFailure: function(){ alert('Something went wrong...') }
});
}//ShowDetailsPopup
function EnviarPdf(id){
new Ajax.Request(WEB_ROOT+'/ajax/facturacion.php',
{
method:'post',
parameters: {type: 'enviarPdf', comprobanteId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
ShowStatusPopUp(splitResponse[1])
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EnviarEmail
function CancelarFactura(id){
grayOut(true);
$('fview').show();
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/facturacion.php',{
method:'post',
parameters: {type: "cancelarDiv", comprobanteId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ ShowDetailsPopup(0); });
Event.observe($('btnCancelar'), "click", DoCancelacion);
},
onFailure: function(){ alert('Something went wrong...') }
});
}//CancelarFactura
function DoCancelacion(){
new Ajax.Request(WEB_ROOT+'/ajax/facturacion.php',
{
method:'post',
parameters: $('frmCancelar').serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
console.log(response);
if(splitResponse[0] == "fail"){
ShowStatusPopUp(splitResponse[1])
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DoCancelacion
function CheckKey(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13)
Buscar();
}//CheckKey

28
javascript/facturas-datos.js Executable file
View File

@@ -0,0 +1,28 @@
function UpdateClte()
{
new Ajax.Request(WEB_ROOT+'/ajax/facturas.php',
{
method:'post',
parameters: $('frmDatosClte').serialize(true),
onLoading: function(){
$("loader").show();
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
console.log(response);
var splitResponse = response.split("[#]");
$("loader").hide();
if(splitResponse[0] == "ok")
ShowStatus(splitResponse[1]);
else
ShowStatus(splitResponse[1]);
$("clienteId").value = splitResponse[2];
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}

117
javascript/facturas-listado.js Executable file
View File

@@ -0,0 +1,117 @@
Event.observe(window, 'load', function() {
AddEditItemsListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDetails');
var id = el.identify();
if(del == true)
ShowDetailsPopup(id);
}
$('contenido').observe("click", AddEditItemsListeners);
});
function AddTicket(id)
{
grayOut(true);
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/facturas.php',
{
method:'post',
parameters: {type: "addTicket"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('fviewclose'), "click", function(){ AddTicket(0); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function SaveTicket()
{
new Ajax.Request(WEB_ROOT+'/ajax/facturas.php',
{
method:'post',
parameters: $('frmTicket').serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
console.log(response);
if(splitResponse[0] == "ok")
window.location.href = WEB_ROOT + "/facturas-nueva/ventaId/"+ splitResponse[1];
else
ShowStatusPopUp(splitResponse[1]);
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ShowDetailsPopup(id){
grayOut(true);
$('fview').show();
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/facturacion.php',{
method:'post',
parameters: {type: "showDetails", comprobanteId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ ShowDetailsPopup(0); });
$('accionList').observe("click", SendItemsListeners);
},
onFailure: function(){ alert('Something went wrong...') }
});
}//ShowDetailsPopup
function EnviarPdf(id){
new Ajax.Request(WEB_ROOT+'/ajax/facturacion.php',
{
method:'post',
parameters: {type: 'enviarPdf', comprobanteId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
ShowStatusPopUp(splitResponse[1])
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EnviarEmail
function CheckKey(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13)
Buscar();
}//CheckKey

136
javascript/facturas-nueva.js Executable file
View File

@@ -0,0 +1,136 @@
Event.observe(window, 'load', function(){
if($('vistaPrevia'))
Event.observe($('vistaPrevia'), "click", VistaPreviaComprobante);
if($('generarFactura'))
Event.observe($('generarFactura'), "click", GenerarComprobante);
});
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, 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] == "ok"){
$("titH1").innerHTML = "Paso 3 de 3: Guarde los archivos generados.";
$("frmNvaFact").hide();
$("dwnPdf").show();
$('dwnPdf').innerHTML = splitResponse[1];
}else{
$('divStatus').innerHTML = splitResponse[1];
$('centeredDiv').show();
grayOut(true);
}
},
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, 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...') }
});
}

34
javascript/facturas.js Executable file
View File

@@ -0,0 +1,34 @@
function DoLogin(){
new Ajax.Request(WEB_ROOT+'/ajax/facturas.php',
{
method:'post',
parameters: $('frmLogin').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
window.location.href = WEB_ROOT + "/facturas-listado";
}else{
ShowStatus(splitResponse[1]);
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DoLogin
function CheckKeyL(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13)
DoLogin();
}//CheckKeyL

24
javascript/flowplayer-3.2.4.min.js vendored Executable file

File diff suppressed because one or more lines are too long

146
javascript/functions.js Executable file
View File

@@ -0,0 +1,146 @@
var DOC_ROOT = "../";
var DOC_ROOT_TRUE = "../";
var DOC_ROOT_SECTION = "../../";
var WEB_ROOT = "http://" + document.location.hostname + "/html";
var LOADER = "<img src='"+WEB_ROOT+"/images/load.gif'>";
var LOADER2 = "<div align='center'><img src='"+WEB_ROOT+"/images/loading.gif'><br>Cargando...</div>";
Event.observe(window, 'load', function() {
if($('login_0'))
{
Event.observe($('login_0'), "click", LoginCheck);
Event.observe($('password'), "keypress", function(evt) {
if(evt.keyCode == 13)
LoginCheck();
});
}
if($("logoutDiv") != undefined)
Event.observe($('logoutDiv'), "click", Logout);
});
function LoginCheck()
{
new Ajax.Request(WEB_ROOT+'/ajax/login.php',
{
parameters: $('loginForm').serialize(true),
method:'post',
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
{
Redirect('/homepage');
}
else
{
ShowStatus(splitResponse[1]);
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AddNewVtaDiv(){
grayOut(true);
$('fviewVta').show();
new Ajax.Request(WEB_ROOT+'/ajax/ventas.php',{
method:'post',
parameters: {type: "addVenta"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSetVta(response);
$("divIframe").innerHTML = '<iframe width="1000" height="700" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'+WEB_ROOT+'/ventas-nueva">Lo sentimos, pero tu navegador no soporta IFRAMES.</iframe>';
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddNewVtaDiv
function ToogleStatusDiv()
{
$('centeredDiv').toggle();
grayOut(false);
}
function ToogleStatusDivOnPopup()
{
$('centeredDivOnPopup').toggle();
}
function HideDivOnPopup()
{
if($('centeredDivOnPopup') != undefined){
if($('centeredDivOnPopup').style.display == "none")
HideFview();
else
$('centeredDivOnPopup').hide();
}else if($('centeredDiv') != undefined){
if($('centeredDiv').style.display == "none")
HideFview();
else
$('centeredDiv').hide();
}else if($('fview') != undefined){
HideFview();
}
}
function Redirect(page)
{
window.location = WEB_ROOT+page;
}
function RedirectRoot(page)
{
window.location = page;
}
function Logout()
{
new Ajax.Request(WEB_ROOT+'/ajax/logout.php',
{
method:'post',
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[1] == "login")
RedirectRoot(WEB_ROOT);
else
window.location.href = WEB_ROOT + "/facturas";
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function HideFview(){
$('fview').hide();
grayOut(false);
}
function HideFviewVta(){
$('fviewVta').hide();
grayOut(false);
}
function HideFviewCobro(){
$('fviewCobro').hide();
grayOut(false);
if($('btnCobVta')!= undefined)
$("btnCobVta").removeAttribute('disabled');
}

146
javascript/functions.js~ Executable file
View File

@@ -0,0 +1,146 @@
var DOC_ROOT = "../";
var DOC_ROOT_TRUE = "../";
var DOC_ROOT_SECTION = "../../";
var WEB_ROOT = "http://" + document.location.hostname + "/html";
var LOADER = "<img src='"+WEB_ROOT+"/images/load.gif'>";
var LOADER2 = "<div align='center'><img src='"+WEB_ROOT+"/images/loading.gif'><br>Cargando...</div>";
Event.observe(window, 'load', function() {
if($('login_0'))
{
Event.observe($('login_0'), "click", LoginCheck);
Event.observe($('password'), "keypress", function(evt) {
if(evt.keyCode == 13)
LoginCheck();
});
}
if($("logoutDiv") != undefined)
Event.observe($('logoutDiv'), "click", Logout);
});
function LoginCheck()
{
new Ajax.Request(WEB_ROOT+'/ajax/login.php',
{
parameters: $('loginForm').serialize(true),
method:'post',
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
console.log(response);
if(splitResponse[0] == "ok")
{
Redirect('/homepage');
}
else
{
ShowStatus(splitResponse[1]);
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AddNewVtaDiv(){
grayOut(true);
$('fviewVta').show();
new Ajax.Request(WEB_ROOT+'/ajax/ventas.php',{
method:'post',
parameters: {type: "addVenta"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSetVta(response);
$("divIframe").innerHTML = '<iframe width="1000" height="700" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'+WEB_ROOT+'/ventas-nueva">Lo sentimos, pero tu navegador no soporta IFRAMES.</iframe>';
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddNewVtaDiv
function ToogleStatusDiv()
{
$('centeredDiv').toggle();
grayOut(false);
}
function ToogleStatusDivOnPopup()
{
$('centeredDivOnPopup').toggle();
}
function HideDivOnPopup()
{
if($('centeredDivOnPopup') != undefined){
if($('centeredDivOnPopup').style.display == "none")
HideFview();
else
$('centeredDivOnPopup').hide();
}else if($('centeredDiv') != undefined){
if($('centeredDiv').style.display == "none")
HideFview();
else
$('centeredDiv').hide();
}else if($('fview') != undefined){
HideFview();
}
}
function Redirect(page)
{
window.location = WEB_ROOT+page;
}
function RedirectRoot(page)
{
window.location = page;
}
function Logout()
{
new Ajax.Request(WEB_ROOT+'/ajax/logout.php',
{
method:'post',
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[1] == "login")
RedirectRoot(WEB_ROOT);
else
window.location.href = WEB_ROOT + "/facturas";
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function HideFview(){
$('fview').hide();
grayOut(false);
}
function HideFviewVta(){
$('fviewVta').hide();
grayOut(false);
}
function HideFviewCobro(){
$('fviewCobro').hide();
grayOut(false);
if($('btnCobVta')!= undefined)
$("btnCobVta").removeAttribute('disabled');
}

View File

@@ -0,0 +1,82 @@
function AjustarInventario()
{
var resp = confirm("Esta seguro de ajustar el inventario de ese producto?");
if(!resp)
return;
$("type").value = "ajustarInventario";
new Ajax.Request(WEB_ROOT+'/ajax/inventario-ajustar.php',
{
method:'post',
parameters: $('frmAjustar').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"){
ShowStatus(splitResponse[1]);
$("frmAjustar").reset();
$('nomProd').innerHTML = "";
$('cantProd').innerHTML = "";
}else{
ShowStatus(splitResponse[1]);
}
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function BuscarProducto()
{
$("type").value = "buscarProducto";
new Ajax.Request(WEB_ROOT+'/ajax/inventario-ajustar.php',
{
method:'post',
parameters: $('frmAjustar').serialize(),
onLoading: function(){
$('nomProd').innerHTML = LOADER;
$('cantProd').innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$('nomProd').innerHTML = "";
$('cantProd').innerHTML = "";
if(splitResponse[0] == "ok"){
$('nomProd').innerHTML = splitResponse[1];
$('cantProd').innerHTML = splitResponse[2];
}else{
ShowStatus(splitResponse[1]);
}
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function CheckKey(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13)
AjustarInventario();
}//CheckKey

View File

@@ -0,0 +1,56 @@
function Search()
{
$("action").value = "searchBloq";
new Ajax.Request(WEB_ROOT+'/ajax/inventario.php',
{
method:'post',
parameters: $('frmSearch').serialize(),
onLoading: function(){
$('loadBusqueda').show();
$('contenido').innerHTML = '';
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$('contenido').innerHTML = response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function LoadSubcats(){
var catId = $("prodCatId2").value;
new Ajax.Request(WEB_ROOT+'/ajax/inventario.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 CheckKey(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13)
Search();
}//CheckKey

View File

@@ -0,0 +1,177 @@
function UpdateSucursal(){
var sucursalId = $("sucursalId").value;
var invFisicoId = $("invFisicoId").value;
new Ajax.Request(WEB_ROOT+'/ajax/inventario-fisico.php',
{
method:'post',
parameters: {type:"updateSucursal", sucursalId:sucursalId, invFisicoId:invFisicoId},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("txtSucMsg").innerHTML = splitResponse[1];
Effect.Appear('txtSucMsg');
setTimeout(function(){
Effect.Fade('txtSucMsg',{duration:2});
}, 3000);
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AgregarProducto()
{
$("type").value = "agregarProducto";
new Ajax.Request(WEB_ROOT+'/ajax/inventario-fisico.php',
{
method:'post',
parameters: $('frmInvFisico').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"){
$('nomProd').innerHTML = "";
$("codigoBarra").value = "";
$("cantidad").value = "";
$("productoId").value = "";
$("codigoBarra").focus();
$("txtSucMsg").innerHTML = splitResponse[1];
Effect.Appear('txtSucMsg');
setTimeout(function(){
Effect.Fade('txtSucMsg',{duration:2});
}, 3000);
$("contProds").innerHTML = splitResponse[2];
}else{
$("txtErrMsg").innerHTML = splitResponse[1];
Effect.Appear('txtErrMsg');
setTimeout(function(){
Effect.Fade('txtErrMsg',{duration:2});
}, 3000);
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function EliminarProd(id)
{
var resp = confirm("Esta seguro de eliminar este producto?");
if(!resp)
return;
new Ajax.Request(WEB_ROOT+'/ajax/inventario-fisico.php',
{
method:'post',
parameters: {type:"eliminarProducto", invFisProdId: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"){
$("txtSucMsg").innerHTML = splitResponse[1];
Effect.Appear('txtSucMsg');
setTimeout(function(){
Effect.Fade('txtSucMsg',{duration:2});
}, 3000);
$("contProds").innerHTML = splitResponse[2];
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function BuscarProducto()
{
$("type").value = "buscarProducto";
new Ajax.Request(WEB_ROOT+'/ajax/inventario-fisico.php',
{
method:'post',
parameters: $('frmInvFisico').serialize(),
onLoading: function(){
$('nomProd').innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$('nomProd').innerHTML = "";
if(splitResponse[0] == "ok"){
$('nomProd').innerHTML = splitResponse[1];
$("productoId").value = splitResponse[2];
$("cantidad").focus();
}else{
$("txtErrMsg").innerHTML = splitResponse[1];
$("productoId").value = "";
Effect.Appear('txtErrMsg');
setTimeout(function(){
Effect.Fade('txtErrMsg',{duration:2});
}, 3000);
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function CheckKey(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13){
BuscarProducto();
}
}//CheckKey
function CheckKey2(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13){
AgregarProducto();
}
}//CheckKey2

View File

@@ -0,0 +1,33 @@
function AjustarInventario(invFisicoId){
var resp = confirm("Esta seguro de ajustar el inventario? Los productos se ajustaran a la cantidad fisica.");
if(!resp)
return;
new Ajax.Request(WEB_ROOT+'/ajax/inventario-fisico.php',
{
method:'post',
parameters: {type:"ajustarInventario", invFisicoId:invFisicoId},
onLoading: function(){
$("loader").show();
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$("loader").hide();
if(splitResponse[0] == "ok"){
$("btnAjustar").hide();
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}

51
javascript/inventario-fisico.js Executable file
View File

@@ -0,0 +1,51 @@
function AgregarReporte()
{
new Ajax.Request(WEB_ROOT+'/ajax/inventario-fisico.php',
{
method:'post',
parameters: {type:"agregarReporte"},
onLoading: function(){
$('nomProd').innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
window.location.href = WEB_ROOT + "/inventario-fisico-agregar/id/" + splitResponse[1];
}else{
alert("Ocurrio un error al agregar el reporte");
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function EliminarReporte(id)
{
var resp = confirm("Esta seguro de eliminar este reporte?");
if(!resp)
return;
new Ajax.Request(WEB_ROOT+'/ajax/inventario-fisico.php',
{
method:'post',
parameters: {type:"eliminarReporte", invFisicoId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}else{
alert("Ocurrio un error al eliminar el reporte");
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}

View File

@@ -0,0 +1,32 @@
function LiberarProductos(){
var resp = confirm("Esta seguro de liberar los productos para esta sucursal?");
if(!resp)
return;
new Ajax.Request(WEB_ROOT+'/ajax/inventario.php',{
method:'post',
parameters: {type:"liberarProductos"},
onLoading: function(){
$("loader").innerHTML = LOADER2;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$("loader").innerHTML = '';
if(splitResponse[0] == "ok")
ShowStatus(splitResponse[1]);
else if(splitResponse[0] == "fail")
ShowStatus(splitResponse[1]);
else
alert("Ocurrio un error al liberar los productos");
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}

107
javascript/inventario-wizard.js Executable file
View File

@@ -0,0 +1,107 @@
function LoadProds(idSuc){
var sucursal = $("sucursal").value;
var totalProds = $("totalProds").value;
var resp = confirm("Esta seguro de cargar los " + totalProds + " productos a la sucursal " + sucursal +"?");
if(!resp)
return;
$("loader").show();
new Ajax.Request(WEB_ROOT+'/ajax/inventario-wizard.php',
{
method:'post',
parameters: "type=loadProds&sucursalId=" + idSuc,
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
location.href = WEB_ROOT + "/inventario-wizard/step/3";
}else{
$("loader").hide();
alert("Ocurrio un error al cargar los productos");
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//LoadProds
function UploadFile(){
var xlsFile = $("excelFile").value;
var idSuc = $("sucursalId").value;
$("loader").show();
new Ajax.Request(WEB_ROOT+'/ajax/inventario-wizard.php',
{
method:'post',
parameters: "type=uploadFile&xlsFile=" + xlsFile + "&sucursalId=" + idSuc,
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail"){
$("loader").hide();
ShowStatus(splitResponse[1]);
grayOut(false);
}else{
$("frmStep1").submit();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//UploadFile
function DelXlsFile(){
var resp = confirm("Esta seguro de eliminar este archivo?");
if(!resp)
return;
new Ajax.Request(WEB_ROOT+'/ajax/inventario-wizard.php',
{
method:'post',
parameters: "type=delXlsFile",
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail"){
ShowStatus(splitResponse[1]);
}else{
ShowStatus(splitResponse[1]);
grayOut(false);
$("showFile").hide();
$("showInput").show();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DelXlsFile
function Anterior(){
location.href = WEB_ROOT + "/inventario-wizard";
}//Anterior
function Finalizar(){
location.href = WEB_ROOT + "/inventario-wizard-list";
}//Finalizar

107
javascript/inventario-wizard2.js Executable file
View File

@@ -0,0 +1,107 @@
function LoadProds(idSuc){
var sucursal = $("sucursal").value;
var totalProds = $("totalProds").value;
var resp = confirm("Esta seguro de cargar los " + totalProds + " productos a la sucursal " + sucursal +"?");
if(!resp)
return;
$("loader").show();
new Ajax.Request(WEB_ROOT+'/ajax/inventario-wizard2.php',
{
method:'post',
parameters: "type=loadProds&sucursalId=" + idSuc,
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
location.href = WEB_ROOT + "/inventario-wizard2/step/3";
}else{
$("loader").hide();
alert("Ocurrio un error al cargar los productos");
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//LoadProds
function UploadFile(){
var xlsFile = $("excelFile").value;
var idSuc = $("sucursalId").value;
$("loader").show();
new Ajax.Request(WEB_ROOT+'/ajax/inventario-wizard2.php',
{
method:'post',
parameters: "type=uploadFile&xlsFile=" + xlsFile + "&sucursalId=" + idSuc,
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("frmStep1").submit();
}else{
$("loader").hide();
ShowStatus(splitResponse[1]);
grayOut(false);
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//UploadFile
function DelXlsFile(){
var resp = confirm("Esta seguro de eliminar este archivo?");
if(!resp)
return;
new Ajax.Request(WEB_ROOT+'/ajax/inventario-wizard2.php',
{
method:'post',
parameters: "type=delXlsFile",
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail"){
ShowStatus(splitResponse[1]);
}else{
ShowStatus(splitResponse[1]);
grayOut(false);
$("showFile").hide();
$("showInput").show();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DelXlsFile
function Anterior(){
location.href = WEB_ROOT + "/inventario-wizard2";
}//Anterior
function Finalizar(){
location.href = WEB_ROOT + "/inventario-wizard-list2";
}//Finalizar

90
javascript/inventario.js Executable file
View File

@@ -0,0 +1,90 @@
function Search()
{
new Ajax.Request(WEB_ROOT+'/ajax/inventario.php',
{
method:'post',
parameters: $('frmSearch').serialize(),
onLoading: function(){
$('loadBusqueda').show();
$('contenido').innerHTML = '';
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$('contenido').innerHTML = response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function LoadSubcats(){
var catId = $("prodCatId2").value;
new Ajax.Request(WEB_ROOT+'/ajax/inventario.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 SaveReportParcial(){
new Ajax.Request(WEB_ROOT+'/ajax/inventario.php',{
method:'post',
parameters: $('frmReport').serialize(),
onLoading: function(){
$("loader").innerHTML = LOADER2;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$("loader").innerHTML = '';
if(splitResponse[0] == "ok"){
$("btnSendR").hide();
$("contenido").innerHTML = splitResponse[1];
}else if(splitResponse[0] == "fail"){
ShowStatus(splitResponse[1]);
HideFview();
}else
alert("Ocurrio un error al enviar el reporte");
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function SaveReportTotal(){
$("loader").innerHTML = LOADER2;
$("frmReporte").submit();
}
function CheckKey(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13)
Search();
}//CheckKey

155
javascript/materiales.js Executable file
View File

@@ -0,0 +1,155 @@
Event.observe(window, 'load', function() {
Event.observe($('addMaterial'), "click", AddMaterialDiv);
AddEditMaterialListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true)
{
DeleteMaterialPopup(id);
return;
}
del = el.hasClassName('spanEdit');
if(del == true)
{
EditMaterialPopup(id);
}
}
$('contenido').observe("click", AddEditMaterialListeners);
});
function AddMaterialDiv(id)
{
grayOut(true);
if(id == 0)
{
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/materiales.php',
{
method:'post',
parameters: {type: "addMaterial"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('agregarMaterial'), "click", AddMaterial);
Event.observe($('fviewclose'), "click", function(){ AddMaterialDiv(0); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AddMaterial()
{
new Ajax.Request(WEB_ROOT+'/ajax/materiales.php',
{
method:'post',
parameters: $('agregarMaterialForm').serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1]);
}
else
{
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
Event.observe($('addMaterial'), "click", AddMaterialDiv);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function EditMaterialPopup(id)
{
grayOut(true);
$('fview').show();
if(id == 0)
{
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/materiales.php',
{
method:'post',
parameters: {type: "editMaterial", id:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ AddMaterialDiv(0); });
Event.observe($('editarMaterial'), "click", EditarMaterial);
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function EditarMaterial()
{
new Ajax.Request(WEB_ROOT+'/ajax/materiales.php',
{
method:'post',
parameters: $('editarMaterialForm').serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1])
}
else
{
ShowStatusPopUp(splitResponse[1])
$('contenido').innerHTML = splitResponse[2];
Event.observe($('addMaterial'), "click", AddMaterialDiv);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function DeleteMaterialPopup(id)
{
var message = "Realmente deseas eliminar este material?";
if(!confirm(message))
{
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/materiales.php',
{
method:'post',
parameters: {type: "deleteMaterial", id: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1])
$('contenido').innerHTML = splitResponse[2];
Event.observe($('addMaterial'), "click", AddMaterialDiv);
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}

154
javascript/metodos-pago.js Executable file
View File

@@ -0,0 +1,154 @@
Event.observe(window, 'load', function() {
Event.observe($('addMetodoPago'), "click", AddMetodoPagoDiv);
AddEditMetodoPagoListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true)
{
DeleteMetodoPagoPopup(id);
return;
}
del = el.hasClassName('spanEdit');
if(del == true)
{
EditMetodoPagoPopup(id);
}
}
$('contenido').observe("click", AddEditMetodoPagoListeners);
});
function AddMetodoPagoDiv(id)
{
grayOut(true);
if(id == 0)
{
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/metodos-pago.php',
{
method:'post',
parameters: {type: "addMetodoPago"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('agregarMetodoPago'), "click", AddMetodoPago);
Event.observe($('fviewclose'), "click", function(){ AddMetodoPagoDiv(0); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AddMetodoPago()
{
new Ajax.Request(WEB_ROOT+'/ajax/metodos-pago.php',
{
method:'post',
parameters: $('agregarMetodoPagoForm').serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1])
}
else
{
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
Event.observe($('addMetodoPago'), "click", AddMetodoPagoDiv);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function EditMetodoPagoPopup(id)
{
grayOut(true);
$('fview').show();
if(id == 0)
{
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/metodos-pago.php',
{
method:'post',
parameters: {type: "editMetodoPago", id:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ AddMetodoPagoDiv(0); });
Event.observe($('editarMetodoPago'), "click", EditarMetodoPago);
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function EditarMetodoPago()
{
new Ajax.Request(WEB_ROOT+'/ajax/metodos-pago.php',
{
method:'post',
parameters: $('editarMetodoPagoForm').serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1])
}
else
{
ShowStatusPopUp(splitResponse[1])
$('contenido').innerHTML = splitResponse[2];
Event.observe($('addMetodoPago'), "click", AddMetodoPagoDiv);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function DeleteMetodoPagoPopup(id)
{
var message = "Realmente deseas eliminar este Metodo de Pago?";
if(!confirm(message))
{
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/metodos-pago.php',
{
method:'post',
parameters: {type: "deleteMetodoPago", id: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1])
$('contenido').innerHTML = splitResponse[2];
Event.observe($('addMetodoPago'), "click", AddMetodoPagoDiv);
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}

213
javascript/monederos.js Executable file
View File

@@ -0,0 +1,213 @@
Event.observe(window, 'load', function() {
AddEditMonederosListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true){
DeleteMonederoPopup(id);
return;
}
del = el.hasClassName('spanEdit');
if(del == true)
EditMonederoPopup(id);
}
if($('contenido')!= undefined)
$('contenido').observe("click", AddEditMonederosListeners);
if($("addMonedero") != undefined)
$('addMonedero').observe("click", function(){ AddMonederoDiv(1); });
});
function AddMonederoDiv(id){
grayOut(true);
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/monederos.php',{
method:'post',
parameters: {type: "addMonedero"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('btnSave'), "click", AddMonedero);
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddMonederoDiv
function AddMonedero(){
new Ajax.Request(WEB_ROOT+'/ajax/monederos.php',
{
method:'post',
parameters: $('frmAgregarMonedero').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail"){
ShowStatusPopUp(splitResponse[1]);
}else{
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddMonedero
function EditMonederoPopup(id){
grayOut(true);
$('fview').show();
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/monederos.php',{
method:'post',
parameters: {type: "editMonedero", monederoId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); });
Event.observe($('btnUpdate'), "click", EditMonedero);
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditMonederoPopup
function EditMonedero(){
var form = $('frmEditarMonedero').serialize();
new Ajax.Request(WEB_ROOT+'/ajax/monederos.php', {
method:'post',
parameters: $('frmEditarMonedero').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1])
}
else
{
ShowStatusPopUp(splitResponse[1])
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditMonedero
function DeleteMonederoPopup(id){
var message = "Realmente deseas eliminar este monedero?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/monederos.php',{
method:'post',
parameters: {type: "deleteMonedero", monederoId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeleteMonederoPopup
function Search()
{
var tipo = $('tipo2').value;
var status = $('status2').value;
new Ajax.Request(WEB_ROOT+'/ajax/monederos.php',
{
method:'post',
parameters: {tipo: tipo, type: "search", status: status},
onLoading: function(){
$('loadBusqueda').show();
$('contenido').innerHTML = '';
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$('contenido').innerHTML = response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ShowStatusMon(){
var tipo = $('tipo').value;
new Ajax.Request(WEB_ROOT+'/ajax/monederos.php',
{
method:'post',
parameters: {tipo: tipo, type: "loadStatus"},
onLoading: function(){
$("enumStatus").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$("enumStatus").innerHTML = response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ShowHistorial(id){
var obj = $('historial_'+id);
if(obj.style.display == "none")
obj.style.display = "";
else
obj.style.display = "none";
}

159
javascript/motivos.js Executable file
View File

@@ -0,0 +1,159 @@
Event.observe(window, 'load', function() {
AddEditProductosListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true){
DeleteMotivoPopup(id);
return;
}
del = el.hasClassName('spanEdit');
if(del == true)
EditMotivoPopup(id);
}
if($('contenido')!= undefined)
$('contenido').observe("click", AddEditProductosListeners);
if($("addMotivo") != undefined)
$('addMotivo').observe("click", function(){ AddMotivoDiv(1); });
});
function AddMotivoDiv(id){
grayOut(true);
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/motivos.php',{
method:'post',
parameters: {type: "addMotivo"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('btnSave'), "click", AddMotivo);
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddMotivoDiv
function AddMotivo(){
new Ajax.Request(WEB_ROOT+'/ajax/motivos.php',
{
method:'post',
parameters: $('frmAgregarMotivo').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail"){
ShowStatusPopUp(splitResponse[1]);
}else{
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddMotivo
function EditMotivoPopup(id){
grayOut(true);
$('fview').show();
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/motivos.php',{
method:'post',
parameters: {type: "editMotivo", motivoId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); });
Event.observe($('btnUpdate'), "click", EditMotivo);
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditMotivoPopup
function EditMotivo(){
var form = $('frmEditarMotivo').serialize();
new Ajax.Request(WEB_ROOT+'/ajax/motivos.php', {
method:'post',
parameters: $('frmEditarMotivo').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1])
}
else
{
ShowStatusPopUp(splitResponse[1])
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditMotivo
function DeleteMotivoPopup(id){
var message = "Realmente deseas eliminar este motivo?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/motivos.php',{
method:'post',
parameters: {type: "deleteMotivo", motivoId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeleteMotivoPopup

542
javascript/pedidos-agregar.js Executable file
View File

@@ -0,0 +1,542 @@
function AddPedido(){
$("type").value = "savePedido";
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: $('frmAgregarPedido').serialize(),
onLoading: function(){
$("loader").show();
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
location.href = WEB_ROOT + "/pedidos";
}else{
ShowStatus(splitResponse[1]);
HideFview();
$("loader").hide();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddPedido
function CancelPedido(id){
var message = "Realmente deseas cancelar este pedido?";
if(!confirm(message)){
return;
}
location.href = WEB_ROOT + "/pedidos";
}
function ShowDistribucion(){
var checked = $("resurtido").checked;
if(checked)
$("tblDistribucion").show();
else
$("tblDistribucion").hide();
}
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];
LoadProporciones();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//LoadAtributos
function LoadProporciones(){
var idProd = $("productoId").value;
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',{
method:'post',
parameters: {type:"loadProporciones", productoId:idProd},
onLoading: function(){
$("tblProporcion").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
$("tblProporcion").innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}//LoadProporciones
function UpdateProporcion(){
$("type").value = "updateProporcion";
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: $('frmAgregarPedido').serialize(),
onLoading: function(){
$("tblLoader").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$("tblLoader").innerHTML = '';
if(splitResponse[0] == "ok")
$("tblProporcion").innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function CalcCantLotes(){
var vTotalLote = $("totalLote").value;
var vCantPrendas = $("cantPrendas").value;
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: {type:"calcCantLotes", totalLote:vTotalLote, cantPrendas:vCantPrendas},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("cantLotes").value = splitResponse[1];
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AddTalla(){
$("type").value = "addTalla";
new Ajax.Request(WEB_ROOT+'/ajax/pedidos-agregar.php',
{
method:'post',
parameters: $('frmAgregarPedido').serialize(),
onLoading: function(){
$("tblProporcion").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("tblProporcion").innerHTML = splitResponse[1];
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function DelTalla(key){
$("key").value = key;
$("type").value = "delTalla";
new Ajax.Request(WEB_ROOT+'/ajax/pedidos-agregar.php',
{
method:'post',
parameters: $('frmAgregarPedido').serialize(),
onLoading: function(){
$("tblProporcion").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("tblProporcion").innerHTML = splitResponse[1];
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AddColor(){
$("type").value = "addColor";
new Ajax.Request(WEB_ROOT+'/ajax/pedidos-agregar.php',
{
method:'post',
parameters: $('frmAgregarPedido').serialize(),
onLoading: function(){
$("tblProporcion").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("tblProporcion").innerHTML = splitResponse[1];
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function DelColor(key){
$("key").value = key;
$("type").value = "delColor";
new Ajax.Request(WEB_ROOT+'/ajax/pedidos-agregar.php',
{
method:'post',
parameters: $('frmAgregarPedido').serialize(),
onLoading: function(){
$("tblProporcion").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("tblProporcion").innerHTML = splitResponse[1];
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
//PRODUCTOS
function AddProducto(){
$("type").value = "addProducto";
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',{
method:'post',
parameters: $('frmAgregarPedido').serialize(),
onLoading: function(){
$("productos").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("productos").innerHTML = splitResponse[1];
$("listDist").innerHTML = splitResponse[2];
$("modelo").value = "";
$("productoId").value = "";
$("prodCatId").value = "";
$("prodSubcatId").value = "";
$("enumAtributos").innerHTML = "";
LoadProporciones();
}else{
ShowStatus(splitResponse[1]);
$("productos").innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddProducto
function DeleteProducto(id){
var message = "Realmente deseas eliminar este producto?";
if(!confirm(message)){
return;
}
$("type").value = "deleteProducto";
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',{
method:'post',
parameters: {type:"deleteProducto", k:id},
onLoading: function(){
$("productos").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("productos").innerHTML = splitResponse[1];
$("listDist").innerHTML = splitResponse[2];
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeleteProducto
function SearchProducto()
{
var modelo = $("modelo").value;
var proveedorId = $("proveedorId").value;
new Ajax.Request(WEB_ROOT+'/ajax/suggest_gral.php',
{
parameters: {codigoBarra:modelo, type:"prodByCode", proveedorId:proveedorId},
method:'post',
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("enumAtributos").innerHTML = splitResponse[1];
$("productoId").value = splitResponse[2];
$("prodCatId").value = splitResponse[3];
$("prodSubcatId").value = splitResponse[4];
LoadProporciones();
}else
{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//SearchProducto
//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();
CheckProdProv();
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function CloseSugProv(){
$('sugProvDiv').hide();
}
function CheckProdProv(){
var idProveedor = $("proveedorId").value;
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
parameters: {type: "checkProdProv", proveedorId:idProveedor},
method:'post',
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail"){
ShowStatus(splitResponse[1]);
HideFview();
$("proveedorId").value = '';
$("proveedor").value = '';
return false;
}
return true;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
//Suggest Productos
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();
}
function CheckKey(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13){
SearchProducto();
}
}//CheckKey

782
javascript/pedidos-detalles.js Executable file
View File

@@ -0,0 +1,782 @@
function AprobarPedido(id, noPedido, proveedor, monto, tipo){
var message = "Esta seguro que desea autorizar el pedido No. " + noPedido;
message += "\n al proveedor "+ proveedor;
message += "\n y por un monto de $"+ monto;
message += "\n Compra tipo "+ tipo +" ?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',{
method:'post',
parameters: {type: "aprobarPedido", pedidoId: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")
location.href = WEB_ROOT + "/pedidos";
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AprobarPedido
function AutorizarPedido(id, noPedido, proveedor, monto, tipo){
var message = "Está seguro que desea autorizar la distribución del pedido No. " + noPedido;
message += "\n al proveedor "+ proveedor;
message += "\n y por un monto de $"+ monto;
message += "\n Compra tipo "+ tipo;
message += "\n y GENERAR LA ORDEN DE COMPRA AL PROVEEDOR?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',{
method:'post',
parameters: {type: "autorizarPedido", pedidoId: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"){
location.href = WEB_ROOT + "/pedidos";
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AutorizarPedido
function RechazarPedidoPopup(id){
grayOut(true);
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',{
method:'post',
parameters: {type: "rechazarPedidoPopup", pedidoId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('btnSave'), "click", RechazarPedido);
Event.observe($('btnCancel'), "click", function(){ HideFview(); });
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}//RechazarPedidoPopup
function RechazarPedido(){
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: $('frmRechazarPedido').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")
window.location.href = WEB_ROOT + "/pedidos";
else
ShowStatusPopUp(splitResponse[1]);
},
onFailure: function(){ alert('Something went wrong...') }
});
}//RechazarPedido
function DistribucionPedido(){
var message = "Esta seguro que desea ENVIAR A AUTORIZACION su distribucion?";
if(!confirm(message)){
return;
}
$("type").value = "distribucionPedido";
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: $('frmDistribucion').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")
window.location.href = WEB_ROOT + "/pedidos";
else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DistribucionPedido
function DistribucionPedido2(id){
var message = "Esta seguro que desea ENVIAR A AUTORIZACION su distribucion?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: {type:"distribucionPedido2", pedidoId: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")
window.location.href = WEB_ROOT + "/pedidos";
else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DistribucionPedido2
function EnviarSugerencias(id){
var message = "Desea enviar las sugerencias de distribucion?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',{
method:'post',
parameters: {type: "sugerenciasPedido", pedidoId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
location.href = WEB_ROOT + "/pedidos";
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EnviarSugerencias
function EnviarOrdenCompra(id, enviar){
if(enviar == 1)
var message = "Desea enviar la Orden de Compra al Proveedor?";
else
var message = "Desea marcar como enviada la Orden de Compra al Proveedor?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',{
method:'post',
parameters: {type: "enviarOrdenCompra", pedidoId:id, enviar:enviar},
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 + "/pedidos-enviar-prov/id/"+id;
}else if(splitResponse[0] == "ok2"){
location.href = WEB_ROOT + "/pedidos";
}else if(splitResponse[0] == "noPzas"){
if(enviar == 1)
var resp = confirm("Aun no se han ingresado las Piezas por Caja. Esta seguro de enviar la Orden Compra al Proveedor?");
else
var resp = confirm("Aun no se han ingresado las Piezas por Caja. Esta seguro de marcar como enviada la Orden Compra?");
if(!resp)
return
EnviarOrdenCompra2(id,enviar);
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EnviarOrdenCompra
function EnviarOrdenCompra2(id,enviar){
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',{
method:'post',
parameters: {type: "enviarOrdenCompra", pedidoId:id, aprobado:1, enviar:enviar},
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 + "/pedidos-enviar-prov/id/"+id;
else if(splitResponse[0] == "ok2")
location.href = WEB_ROOT + "/pedidos";
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EnviarOrdenCompra2
function CancelarOrdenCompraEnv(id){
var message = "Desea CANCELAR la Orden de Compra Enviada al Proveedor?";
if(!confirm(message)){
return;
}
var enviarProv = confirm("Desea ENVIAR la Orden Cancelada al Proveedor?");
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',{
method:'post',
parameters: {type: "cancelarOrdenCompraEnv", pedidoId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
if(enviarProv == true)
location.href = WEB_ROOT + "/pedidos-enviar-prov/cancelarId/"+id;
else
location.href = WEB_ROOT + "/pedidos";
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//CancelarOrdenCompraEnv
function IngresarOrdenCompra(id, noPedido, proveedor, cantidad, total){
var message = "Esta seguro que desea ingresar la Orden de Compra No. " + noPedido;
message += "\ndel proveedor " + proveedor +",";
if(!confirm(message)){
return;
}
for(var ii=1; ii <= 5; ii++){
var vFolio = $("folioProv_"+ii).value;
$("folio_"+ii).value = vFolio;
var vFechaFolio = $("fechaFolioProv_"+ii).value;
$("fechaFolio_"+ii).value = vFechaFolio;
}
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',{
method:'post',
parameters: $("frmProdRec").serialize(true),
onLoading: function(){
$("loader").show();
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$("loader").hide();
if(splitResponse[0] == "ok"){
window.open(WEB_ROOT + "/pedidos-acuse/pedidoId/"+id , "Acuse de Recibo" , "scrollbars=NO")
location.href = WEB_ROOT + "/pedidos";
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//IngresarOrdenCompra
function ShowOtroMotivo(){
var motivoId = $("motivoId").value;
var status;
if(motivoId == 3)
status = "";
else
status = "none";
$("inputOtroMotivo").style.display = status;
if(motivoId == 4)
status = "";
else
status = "none";
$("tblProdsE").style.display = status;
}
function ShowProductos(){
var resp = $("productos").style.display;
var status;
var txt
if(resp == "none"){
status = "";
txt = "[-]";
}else{
status = "none";
txt = "[+]";
}
$("productos").style.display = status;
$("showProd").innerHTML = txt;
}
function ShowTotales(){
var resp = $("totales").style.display;
var status;
var txt
if(resp == "none"){
status = "";
txt = "[-]";
}else{
status = "none";
txt = "[+]";
}
$("totales").style.display = status;
$("showTotal").innerHTML = txt;
}
//Productos Distribucion
function AprobarProd(idPedido, idProducto){
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: {type:"aprobarProd", pedidoId:idPedido, productoId:idProducto},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
$("listProds").innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AprobarProd2(idPedido, idProducto){
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: {type:"aprobarProd2", pedidoId:idPedido, productoId:idProducto},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
$("listProds").innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function CancelProd(idPedido, idProducto){
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: {type:"cancelProd", pedidoId:idPedido, productoId:idProducto},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("listProds").innerHTML = splitResponse[1];
ShowBtnSug(idPedido);
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function CancelProd2(idPedido, idProducto){
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: {type:"cancelProd2", pedidoId:idPedido, productoId:idProducto},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("listProds").innerHTML = splitResponse[1];
ShowBtnSug(idPedido);
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function SugerirProd(idPedido, idProducto){
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: {type:"sugerirProd", pedidoId:idPedido, productoId:idProducto},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
$("listProds").innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function SugerirProd2(idPedido, idProducto){
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: {type:"sugerirProd2", pedidoId:idPedido, productoId:idProducto},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
$("listProds").innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function SaveSug(idPedido, idProducto){
$("pedidoId").value = idPedido;
$("productoId").value = idProducto;
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: $('frmDistribucion').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("listProds").innerHTML = splitResponse[1];
ShowBtnSug(idPedido);
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function DeleteSug(idPedido, idProducto){
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: {type:"deleteSug", pedidoId:idPedido, productoId:idProducto},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("listProds").innerHTML = splitResponse[1];
ShowBtnSug(idPedido);
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function DeleteSug2(idPedido, idProducto){
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: {type:"deleteSug2", pedidoId:idPedido, productoId:idProducto},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("listProds").innerHTML = splitResponse[1];
ShowBtnSug(idPedido);
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function CancelSug(idPedido, idProducto){
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: {type:"cancelSug", pedidoId:idPedido, productoId:idProducto},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
$("listProds").innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function CancelSug2(idPedido, idProducto){
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: {type:"cancelSug2", pedidoId:idPedido, productoId:idProducto},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
$("listProds").innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function UpdateSaldoPrendas(id){
$("type").value = "updateSaldoPrendas";
$("idProd").value = id;
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: $('frmDistribucion').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
$("txtCantPrendas_"+id).innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function SavePiezasCaja(){
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: $('frmPzasCaja').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 + "/pedidos";
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ShowBtnSug(idPedido){
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: {type:"showBtnSug", pedidoId:idPedido},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
if(splitResponse[1] > 0){
$("btnSug").show();
$("btnAutorizar").hide();
}else{
$("btnSug").hide();
$("btnAutorizar").show();
}
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ShowInpProdsRec(id){
var entrego = $("prodsComp_"+id).value;
if(entrego == 1)
$("inpProdsRec_"+id).hide();
else
$("inpProdsRec_"+id).show();
}

View File

@@ -0,0 +1,55 @@
function DistribucionPedido(){
$("type").value = "actualizarDist";
new Ajax.Request(WEB_ROOT+'/ajax/pedidos-distribucion.php',
{
method:'post',
parameters: $('frmDistribucion').serialize(),
onLoading: function(){
$("loader").show();
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
console.log(response);
$("loader").hide();
if(splitResponse[0] == "ok")
window.location.href = WEB_ROOT + "/pedidos";
else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DistribucionPedido
function UpdateSaldoPrendas(id){
$("type").value = "updateSaldoPrendas";
$("idProd").value = id;
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: $('frmDistribucion').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
$("txtCantPrendas_"+id).innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}

439
javascript/pedidos-editar.js Executable file
View File

@@ -0,0 +1,439 @@
function EditPedido(){
$("type").value = "saveEditPedido";
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: $('frmEditarPedido').serialize(),
onLoading: function(){
$("loader").show();
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
location.href = WEB_ROOT + "/pedidos";
}else{
ShowStatusPopUp(splitResponse[1]);
HideFview();
$("loader").hide();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditPedido
function EditPedido2(){
$("type").value = "saveEditPedido2";
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: $('frmEditarPedido').serialize(),
onLoading: function(){
$("loader").show();
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
location.href = WEB_ROOT + "/pedidos";
}else{
ShowStatusPopUp(splitResponse[1]);
HideFview();
$("loader").hide();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditPedido
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];
LoadProporciones();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//LoadAtributos
function LoadProporciones(){
var idProd = $("productoId").value;
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',{
method:'post',
parameters: {type:"loadProporciones", productoId:idProd},
onLoading: function(){
$("tblProporcion").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
$("tblProporcion").innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}//LoadProporciones
function UpdateProporcion(){
$("type").value = "updateProporcion";
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: $('frmEditarPedido').serialize(),
onLoading: function(){
$("tblLoader").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$("tblLoader").innerHTML = '';
if(splitResponse[0] == "ok")
$("tblProporcion").innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AddTalla(){
$("type").value = "addTalla";
new Ajax.Request(WEB_ROOT+'/ajax/pedidos-agregar.php',
{
method:'post',
parameters: $('frmEditarPedido').serialize(),
onLoading: function(){
$("tblProporcion").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("tblProporcion").innerHTML = splitResponse[1];
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function DelTalla(key){
$("key").value = key;
$("type").value = "delTalla";
new Ajax.Request(WEB_ROOT+'/ajax/pedidos-agregar.php',
{
method:'post',
parameters: $('frmEditarPedido').serialize(),
onLoading: function(){
$("tblProporcion").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("tblProporcion").innerHTML = splitResponse[1];
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AddColor(){
$("type").value = "addColor";
new Ajax.Request(WEB_ROOT+'/ajax/pedidos-agregar.php',
{
method:'post',
parameters: $('frmEditarPedido').serialize(),
onLoading: function(){
$("tblProporcion").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("tblProporcion").innerHTML = splitResponse[1];
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function DelColor(key){
$("key").value = key;
$("type").value = "delColor";
new Ajax.Request(WEB_ROOT+'/ajax/pedidos-agregar.php',
{
method:'post',
parameters: $('frmEditarPedido').serialize(),
onLoading: function(){
$("tblProporcion").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("tblProporcion").innerHTML = splitResponse[1];
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
//PRODUCTOS
function AddProducto(){
$("type").value = "addProdEdit";
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',{
method:'post',
parameters: $('frmEditarPedido').serialize(),
onLoading: function(){
$("productos").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("productos").innerHTML = splitResponse[1];
$("modelo").value = "";
$("productoId").value = "";
$("prodCatId").value = "";
$("prodSubcatId").value = "";
$("enumAtributos").innerHTML = "";
LoadProporciones();
}else{
ShowStatus(splitResponse[1]);
$("productos").innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddProducto
function DeleteProducto(id){
var message = "Realmente deseas eliminar este producto?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',{
method:'post',
parameters: {type:"deleteProdEdit", k:id},
onLoading: function(){
$("productos").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
$("productos").innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeleteProducto
function SearchProducto()
{
var modelo = $("modelo").value;
var proveedorId = $("proveedorId").value;
new Ajax.Request(WEB_ROOT+'/ajax/suggest_gral.php',
{
parameters: {codigoBarra:modelo, type:"prodByCode", proveedorId:proveedorId},
method:'post',
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("enumAtributos").innerHTML = splitResponse[1];
$("productoId").value = splitResponse[2];
$("prodCatId").value = splitResponse[3];
$("prodSubcatId").value = splitResponse[4];
LoadProporciones();
}else
{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//SearchProducto
//Suggest Productos
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();
}
function CheckKey(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13){
SearchProducto();
}
}//CheckKey

311
javascript/pedidos-revivir.js Executable file
View File

@@ -0,0 +1,311 @@
function AddPedido(){
$("type").value = "savePedido";
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: $('frmAgregarPedido').serialize(),
onLoading: function(){
$("loader").show();
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
location.href = WEB_ROOT + "/pedidos";
}else{
ShowStatus(splitResponse[1]);
HideFview();
$("loader").hide();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddPedido
function CancelPedido(id){
var message = "Realmente deseas cancelar este pedido?";
if(!confirm(message)){
return;
}
location.href = WEB_ROOT + "/pedidos";
}
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];
LoadProporciones();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//LoadAtributos
function LoadProporciones(){
var idProd = $("productoId").value;
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',{
method:'post',
parameters: {type:"loadProporciones", productoId:idProd},
onLoading: function(){
$("tblProporcion").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
$("tblProporcion").innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}//LoadProporciones
function UpdateProporcion(){
$("type").value = "updateProporcion";
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: $('frmAgregarPedido').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
$("tblProporcion").innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}
//PRODUCTOS
function AddProducto(){
$("type").value = "addProducto";
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',{
method:'post',
parameters: $('frmAgregarPedido').serialize(),
onLoading: function(){
$("productos").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("productos").innerHTML = splitResponse[1];
$("listDist").innerHTML = splitResponse[2];
}else{
ShowStatus(splitResponse[1]);
$("productos").innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddProducto
function DeleteProducto(id){
var message = "Realmente deseas eliminar este producto?";
if(!confirm(message)){
return;
}
$("type").value = "deleteProducto";
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',{
method:'post',
parameters: {type:"deleteProducto", k:id},
onLoading: function(){
$("productos").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("productos").innerHTML = splitResponse[1];
$("listDist").innerHTML = splitResponse[2];
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeleteProducto
//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 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();
}

170
javascript/pedidos.js Executable file
View File

@@ -0,0 +1,170 @@
Event.observe(window, 'load', function() {
AddEditPedidosListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true){
DeletePedidoPopup(id);
return;
}
}
$('contenido').observe("click", AddEditPedidosListeners);
});
function DeletePedidoPopup(id){
var message = "Realmente deseas eliminar este pedido?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',{
method:'post',
parameters: {type: "deletePedido", pedidoId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeletePedidoPopup
function Search()
{
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: $('frmSearch').serialize(),
onLoading: function(){
$('loadBusqueda').show();
$('contenido').innerHTML = '';
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$('contenido').innerHTML = response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function UpdateFrecuente(idPedido)
{
var checked = $("frecuente_"+idPedido).checked;
var vStatus = 0;
if(checked)
vStatus = 1;
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: {type:"updateFrecuente", pedidoId:idPedido, status:vStatus},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ContinuarPedido(idPedido){
var resp = confirm("Esta seguro de activar este pedido para continuar con el proceso?");
if(!resp)
return;
new Ajax.Request(WEB_ROOT+'/ajax/pedidos.php',
{
method:'post',
parameters: {type:"continuarPedido", pedidoId:idPedido},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
window.location.reload();
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function CalificarProv(id){
grayOut(true);
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/proveedores.php',{
method:'post',
parameters: {type: "calificarProv", pedidoId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('btnSave'), "click", SaveCalificacionProv);
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}//CalificarProv
function SaveCalificacionProv(){
new Ajax.Request(WEB_ROOT+'/ajax/proveedores.php',
{
method:'post',
parameters: $('frmCalificarProv').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
ShowStatusPopUp(splitResponse[1]);
HideFview();
}else{
ShowStatusPopUp(splitResponse[1]);
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//SaveCalificacionProv
function CheckKey(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13)
Search();
}//CheckKey

249
javascript/productos-agregar.js Executable file
View File

@@ -0,0 +1,249 @@
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();
}

View File

@@ -0,0 +1,170 @@
Event.observe(window, 'load', function() {
AddEditProductosListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true){
DeleteCategoryPopup(id);
return;
}
del = el.hasClassName('spanEdit');
if(del == true)
EditCategoryPopup(id);
}
if($('contenido')!= undefined)
$('contenido').observe("click", AddEditProductosListeners);
if($("addCategory") != undefined)
$('addCategory').observe("click", function(){ AddCategoryDiv(1); });
});
function AddCategoryDiv(id){
grayOut(true);
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/productos-categorias.php',{
method:'post',
parameters: {type: "addCategory"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('btnSave'), "click", AddCategory);
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddCategoryDiv
function AddCategory(){
new Ajax.Request(WEB_ROOT+'/ajax/productos-categorias.php',
{
method:'post',
parameters: $('frmAgregarCategoria').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail"){
ShowStatusPopUp(splitResponse[1]);
}else{
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddCategory
function EditCategoryPopup(id){
grayOut(true);
$('fview').show();
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/productos-categorias.php',{
method:'post',
parameters: {type: "editCategory", prodCatId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); });
Event.observe($('btnUpdate'), "click", EditCategory);
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditCategoryPopup
function EditCategory(){
var form = $('frmEditarCategoria').serialize();
new Ajax.Request(WEB_ROOT+'/ajax/productos-categorias.php', {
method:'post',
parameters: $('frmEditarCategoria').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1])
}
else
{
ShowStatusPopUp(splitResponse[1])
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditCategory
function DeleteCategoryPopup(id){
var message = "Realmente deseas eliminar este departamento?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/productos-categorias.php',{
method:'post',
parameters: {type: "deleteCategory", prodCatId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeleteCategoryPopup
function ViewSubcats(id){
var obj = $('subcats_'+id);
if(obj.style.display == "none")
obj.style.display = "";
else
obj.style.display = "none";
}

View File

@@ -0,0 +1,37 @@
function Search()
{
var vWord = $('word').value;
var codigoBarra = $('codigoBarra').value;
var vProdCatId = $("idProdCat").value;
var vProvId = $("proveedorId2").value;
var vNoProv = $("noProv").value;
new Ajax.Request(WEB_ROOT+'/ajax/productos.php',
{
method:'post',
parameters: {codigoBarra: codigoBarra, word: vWord, prodCatId: vProdCatId, proveedorId2:vProvId, noProveedor:vNoProv, type: "searchDuplicados"},
onLoading: function(){
$('loadBusqueda').show();
$('contenido').innerHTML = '';
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$('contenido').innerHTML = response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function CheckKey(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13)
Search();
}//CheckKey

259
javascript/productos-editar.js Executable file
View File

@@ -0,0 +1,259 @@
function EditProducto(){
if($("delImage") != undefined){
if($("delImage").checked == true)
$("tmpImg").value = $("imagen").value;
else
$("tmpImg").value = "miImg";
}else{
$("tmpImg").value = $("imagen").value;
}
$("type").value = "saveEditProducto";
new Ajax.Request(WEB_ROOT+'/ajax/productos.php',
{
method:'post',
parameters: $('frmEditarProducto').serialize(),
onLoading: function(){
$("loader").show();
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$('frmEditarProducto').submit();
}else{
ShowStatusPopUp(splitResponse[1]);
HideFview();
$("loader").hide();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditProducto
function LoadSubcats(){
var catId = $("prodCatId").value;
$("enumSubcats").innerHTML = '';
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: $('frmEditarProducto').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: $('frmEditarProducto').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(k);
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function CloseSugProv(k){
$('sugProvDiv').hide();
}

View File

@@ -0,0 +1,54 @@
function AddMaterial(){
CheckMaterials();
$("type").value = "addMaterial";
new Ajax.Request(WEB_ROOT+'/ajax/productos-materiales.php',{
method:'post',
parameters: $('frmAgregarProducto').serialize(),
onLoading: function(){
$("materiales").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$("materiales").innerHTML = '';
if(splitResponse[0] == "ok"){
$("materiales").innerHTML = splitResponse[1];
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function DeleteMaterial(k){
$("type").value = "deleteMaterial";
$("k").value = k;
new Ajax.Request(WEB_ROOT+'/ajax/productos-materiales.php',{
method:'post',
parameters: $('frmAgregarProducto').serialize(),
onLoading: function(){
$("materiales").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$("materiales").innerHTML = '';
if(splitResponse[0] == "ok"){
$("materiales").innerHTML = splitResponse[1];
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}

View File

@@ -0,0 +1,54 @@
function AddMaterial(){
CheckMaterials();
$("type").value = "addMaterial";
new Ajax.Request(WEB_ROOT+'/ajax/productos-materiales.php',{
method:'post',
parameters: $('frmEditarProducto').serialize(),
onLoading: function(){
$("materiales").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$("materiales").innerHTML = '';
if(splitResponse[0] == "ok"){
$("materiales").innerHTML = splitResponse[1];
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function DeleteMaterial(k){
$("type").value = "deleteMaterial";
$("k").value = k;
new Ajax.Request(WEB_ROOT+'/ajax/productos-materiales.php',{
method:'post',
parameters: $('frmEditarProducto').serialize(),
onLoading: function(){
$("materiales").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$("materiales").innerHTML = '';
if(splitResponse[0] == "ok"){
$("materiales").innerHTML = splitResponse[1];
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}

View File

@@ -0,0 +1,134 @@
function AddSubcategoryDiv(id){
grayOut(true);
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/productos-subcategorias.php',{
method:'post',
parameters: {type: "addSubcategory", prodCatId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('btnSave'), "click", AddSubcategory);
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddSubcategoryDiv
function AddSubcategory(){
var id = 0;
new Ajax.Request(WEB_ROOT+'/ajax/productos-subcategorias.php',
{
method:'post',
parameters: $('frmAgregarSubcategoria').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] != "ok"){
ShowStatusPopUp(splitResponse[1]);
}else{
ShowStatusPopUp(splitResponse[1]);
id = splitResponse[2];
$('contSubcats_'+id).innerHTML = splitResponse[3];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddSubcategory
function EditSubcategoryPopup(id){
grayOut(true);
$('fview').show();
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/productos-subcategorias.php',{
method:'post',
parameters: {type: "editSubcategory", prodSubcatId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); });
Event.observe($('btnUpdate'), "click", EditSubcategory);
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditSubcategoryPopup
function EditSubcategory(){
new Ajax.Request(WEB_ROOT+'/ajax/productos-subcategorias.php', {
method:'post',
parameters: $('frmEditarSubcategoria').serialize(),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] != "ok")
{
ShowStatusPopUp(splitResponse[1]);
}
else
{
ShowStatusPopUp(splitResponse[1]);
id = splitResponse[2];
$('contSubcats_'+id).innerHTML = splitResponse[3];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditSubcategory
function DeleteSubcategoryPopup(id){
var message = "Realmente deseas eliminar esta linea?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/productos-subcategorias.php',{
method:'post',
parameters: {type: "deleteSubcategory", prodSubcatId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1]);
id = splitResponse[2];
$('contSubcats_'+id).innerHTML = splitResponse[3];
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeleteSubcategoryPopup

113
javascript/productos.js Executable file
View File

@@ -0,0 +1,113 @@
Event.observe(window, 'load', function() {
AddEditProductosListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true){
DeleteProductoPopup(id);
return;
}
}
$('contenido').observe("click", AddEditProductosListeners);
});
function DeleteProductoPopup(id){
var message = "Realmente deseas eliminar este producto?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/productos.php',{
method:'post',
parameters: {type: "deleteProducto", productoId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeleteProductoPopup
function LoadSubcats(){
var catId = $("prodCatId").value;
$("enumSubcats").innerHTML = '';
$("txtSubcat").style.display = "none";
new Ajax.Request(WEB_ROOT+'/ajax/productos.php',{
method:'post',
parameters: {type:"loadSubcats", prodCatId:catId},
onLoading: function(){
$("loadSubcat").style.display = "";
$("loadSubcat").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$("loadSubcat").innerHTML = "";
if(splitResponse[0] == "ok"){
$("txtSubcat").style.display = "";
$("enumSubcats").innerHTML = splitResponse[1];
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//LoadSubcats
function Search()
{
var vWord = $('word').value;
var codigoBarra = $('codigoBarra').value;
var vProdCatId = $("idProdCat").value;
var vProvId = $("proveedorId2").value;
var vNoProv = $("noProv").value;
new Ajax.Request(WEB_ROOT+'/ajax/productos.php',
{
method:'post',
parameters: {codigoBarra: codigoBarra, word: vWord, prodCatId: vProdCatId, proveedorId2:vProvId, noProveedor:vNoProv, type: "search"},
onLoading: function(){
$('loadBusqueda').show();
$('contenido').innerHTML = '';
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$('contenido').innerHTML = response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function CheckKey(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13)
Search();
}//CheckKey

618
javascript/promociones.js Executable file
View File

@@ -0,0 +1,618 @@
Event.observe(window, 'load', function() {
AddEditProductosListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true){
DeletePromocionPopup(id);
return;
}
del = el.hasClassName('spanEdit');
if(del == true)
EditPromocionPopup(id);
del = el.hasClassName('spanView');
if(del == true)
ViewPromocionPopup(id);
del = el.hasClassName('spanExcluir');
if(del == true)
ExcluirPromocionPopup(id);
}
if($('contenido')!= undefined)
$('contenido').observe("click", AddEditProductosListeners);
if($("addPromocion") != undefined)
$('addPromocion').observe("click", function(){ AddPromocionDiv(1); });
});
function AddPromocionDiv(id){
grayOut(true);
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/promociones.php',{
method:'post',
parameters: {type: "addPromocion"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('btnSave'), "click", AddPromocion);
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddPromocionDiv
function AddPromocion(){
$("type").value = "savePromocion";
new Ajax.Request(WEB_ROOT+'/ajax/promociones.php',
{
method:'post',
parameters: $('frmPromocion').serialize(),
onLoading: function(){
$("loader").show();
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$("loader").hide();
if(splitResponse[0] == "fail"){
ShowStatusPopUp(splitResponse[1]);
}else{
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//AddPromocion
function EditPromocionPopup(id){
grayOut(true);
$('fview').show();
if(id == 0){
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/promociones.php',{
method:'post',
parameters: {type: "editPromocion", promocionId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); });
Event.observe($('btnEdit'), "click", EditPromocion);
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditPromocionPopup
function EditPromocion(){
$("type").value = "saveEditPromocion";
new Ajax.Request(WEB_ROOT+'/ajax/promociones.php', {
method:'post',
parameters: $('frmPromocion').serialize(),
onLoading: function(){
$("loader").show();
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$("loader").hide();
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1])
}
else
{
ShowStatusPopUp(splitResponse[1])
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//EditPromocion
function DeletePromocionPopup(id){
var message = "Realmente deseas eliminar esta promocion?";
if(!confirm(message)){
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/promociones.php',{
method:'post',
parameters: {type: "deletePromocion", promocionId: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//DeletePromocionPopup
function ViewPromocionPopup(id){
grayOut(true);
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/promociones.php',{
method:'post',
parameters: {type: "viewPromocion", promocionId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); });
Event.observe($('btnClose'), "click", function(){ HideFview(); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}//ViewPromocionPopup
function LoadSubcats(){
$("type").value = "loadSubcats";
new Ajax.Request(WEB_ROOT+'/ajax/promociones.php',{
method:'post',
parameters: $('frmPromocion').serialize(),
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 LoadProductos(){
$("type").value = "loadProductos";
var checkDepto = $("checkDepto").checked;
var checkLinea = $("checkLinea").checked;
var checkProv = $("checkProv").checked;
if(checkDepto == true && checkLinea == true && checkProv == true){
alert("Si desea aplicar la promocion a todos los productos, debe seleccionarlo en la parte superior.");
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/promociones.php',{
method:'post',
parameters: $('frmPromocion').serialize(),
onLoading: function(){
$("enumProds").innerHTML = LOADER;
$("cantProds").innerHTML = "";
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("cantProds").innerHTML = splitResponse[1];
$("enumProds").innerHTML = splitResponse[2];
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//LoadProductos
function LoadAplica(){
var tipo = $("tipo").value;
new Ajax.Request(WEB_ROOT+'/ajax/promociones.php',{
method:'post',
parameters: {type:"loadAplica", tipo:tipo},
onLoading: function(){
$("enumAplica").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("enumAplica").innerHTML = splitResponse[1];
ShowInputsAplica();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//LoadAplica
function ShowInputsAplica(){
var aplica = $("aplica").value;
if(aplica == "XxY"){
$("rowXY").show();
$("rowTipoDesc").hide();
$("rowTotalVentaB").hide();
$("rowTotalVentaM").hide();
$("rowProdVentaB").hide();
}else if(aplica == "N1Desc"){
$("rowTipoDesc").show();
$("txtValorN").show();
$("txtTotalCompra").hide();
$("rowTotalVentaB").hide();
$("rowTotalVentaM").hide();
$("rowProdVentaB").hide();
$("rowXY").hide();
}else if(aplica == "CompraX"){
$("rowTotalVentaB").show();
$("rowProdVentaB").show();
$("rowTotalVentaM").hide();
$("rowTipoDesc").hide();
$("txtValorN").hide();
$("txtTotalCompra").hide();
$("rowXY").hide();
}else if(aplica == "CompraXabonoM"){
$("rowTotalVentaM").show();
$("rowTotalVentaB").hide();
$("rowProdVentaB").hide();
$("rowTipoDesc").hide();
$("txtValorN").hide();
$("txtTotalCompra").hide();
$("rowXY").hide();
}else if(aplica == "DescCuenta"){
$("rowTipoDesc").show();
$("rowTotalVentaB").hide();
$("rowTotalVentaM").hide();
$("rowProdVentaB").hide();
$("txtTotalCompra").show();
$("txtValorN").hide();
$("rowXY").hide();
}else if(aplica == "ArtConDesc"){
$("rowTipoDesc").show();
$("txtTotalCompra").show();
$("rowTotalVentaB").hide();
$("rowTotalVentaM").hide();
$("rowProdVentaB").hide();
$("rowXY").hide();
}else{
$("rowTipoDesc").hide();
$("rowTotalVentaB").hide();
$("rowTotalVentaM").hide();
$("rowProdVentaB").hide();
$("rowXY").hide();
}
}
function ShowCalendars(){
var vigencia = $("vigencia").value;
if(vigencia == "Periodo"){
$("txtFechaIni").show();
$("txtFechaFin").show();
}else{
$("txtFechaIni").hide();
$("txtFechaFin").hide();
}
}
function CheckAllSuc(){
var checked = $("checkSuc").checked;
var checkBoxes = document.getElementsByTagName("input");
for(i=0; i<checkBoxes.length; i++){
if(checkBoxes[i].type == "checkbox"){
if(checkBoxes[i].name == "idSucursal[]"){
checkBoxes[i].checked = checked;
}
}
}
}
function CheckAllDepto(){
var checked = $("checkDepto").checked;
var checkBoxes = document.getElementsByTagName("input");
for(i=0; i<checkBoxes.length; i++){
if(checkBoxes[i].type == "checkbox"){
if(checkBoxes[i].name == "idProdCat[]"){
checkBoxes[i].checked = checked;
}
}
}
}
function CheckAllLinea(){
var checked = $("checkLinea").checked;
var checkBoxes = document.getElementsByTagName("input");
for(i=0; i<checkBoxes.length; i++){
if(checkBoxes[i].type == "checkbox"){
if(checkBoxes[i].name == "idProdSubcat[]"){
checkBoxes[i].checked = checked;
}
}
}
}
function CheckAllProv(){
var checked = $("checkProv").checked;
var checkBoxes = document.getElementsByTagName("input");
for(i=0; i<checkBoxes.length; i++){
if(checkBoxes[i].type == "checkbox"){
if(checkBoxes[i].name == "idProveedor[]"){
checkBoxes[i].checked = checked;
}
}
}
}
function CheckAllProd(){
var checked = $("checkProd").checked;
var checkBoxes = document.getElementsByTagName("input");
for(i=0; i<checkBoxes.length; i++){
if(checkBoxes[i].type == "checkbox"){
if(checkBoxes[i].name == "idProducto[]"){
checkBoxes[i].checked = checked;
}
}
}
}
function ShowProducts(){
var aplicaTodos = $("aplicaTodos").value;
if(aplicaTodos == 1)
$("listProducts").hide();
else
$("listProducts").show();
}
function LoadInfoProd(){
var codigo = $("codigoProd").value;
new Ajax.Request(WEB_ROOT+'/ajax/promociones.php',{
method:'post',
parameters: {type:"loadInfoProd", codigo:codigo},
onLoading: function(){
$("infoProd").innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("infoProd").innerHTML = splitResponse[1];
$("prodId").value = splitResponse[2];
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function LoadSubcatsExc(){
var prodCatId = $("prodCatId").value;
var promocionId = $("promocionId").value;
new Ajax.Request(WEB_ROOT+'/ajax/promociones.php',{
method:'post',
parameters: {type:"loadSubcatsExc", prodCatId:prodCatId, promocionId:promocionId},
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...') }
});
}//LoadSubcatsExc
function LoadProdsExc(){
var proveedorId = $("proveedorId").value;
if(proveedorId == ""){
alert("Seleccione el proveedor");
return;
}
$("type").value = "loadProdsExc";
new Ajax.Request(WEB_ROOT+'/ajax/promociones.php',{
method:'post',
parameters: $('frmPromocion').serialize(),
onLoading: function(){
$("enumProds").innerHTML = LOADER;
$("cantProds").innerHTML = "";
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok"){
$("cantProds").innerHTML = splitResponse[1];
$("enumProds").innerHTML = splitResponse[2];
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}//LoadProdsExc
function ExcluirPromocionPopup(id){
grayOut(true);
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/promociones.php',{
method:'post',
parameters: {type: "excluirPromocion", promocionId:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); });
Event.observe($('btnEdit'), "click", ExcluirPromocion);
},
onFailure: function(){ alert('Something went wrong...') }
});
}//ExcluirPromocionPopup
function ExcluirPromocion(){
$("type").value = "saveExcluirProds";
new Ajax.Request(WEB_ROOT+'/ajax/promociones.php',{
method:'post',
parameters: $("frmPromocion").serialize(),
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...') }
});
}
function DeleteProdExc(id){
var resp = confirm("Esta seguro de eliminar este producto?");
if(!resp)
return;
var promocionId = $("promocionId").value;
new Ajax.Request(WEB_ROOT+'/ajax/promociones.php',{
method:'post',
parameters: {type:"deleteProdExc",promoProdExcId:id, promocionId:promocionId},
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...') }
});
}

4874
javascript/prototype.js vendored Executable file

File diff suppressed because it is too large Load Diff

218
javascript/proveedores.js Executable file
View File

@@ -0,0 +1,218 @@
Event.observe(window, 'load', function() {
if($("addProveedor") != undefined)
Event.observe($('addProveedor'), "click", AddProveedorDiv);
AddEditProveedorListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true)
{
DeleteProveedorPopup(id);
return;
}
del = el.hasClassName('spanEdit');
if(del == true)
{
EditProveedorPopup(id);
}
del = el.hasClassName('spanView');
if(del == true)
{
ViewProveedorPopup(id);
}
}
$('contenido').observe("click", AddEditProveedorListeners);
});
function AddProveedorDiv(id)
{
grayOut(true);
if(id == 0)
{
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/proveedores.php',
{
method:'post',
parameters: {type: "addProveedor"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('agregarProveedor'), "click", AddProveedor);
Event.observe($('fviewclose'), "click", function(){ AddProveedorDiv(0); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AddProveedor()
{
new Ajax.Request(WEB_ROOT+'/ajax/proveedores.php',
{
method:'post',
parameters: $('agregarProveedorForm').serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1]);
}
else
{
ShowStatusPopUp(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function EditProveedorPopup(id)
{
grayOut(true);
$('fview').show();
if(id == 0)
{
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/proveedores.php',
{
method:'post',
parameters: {type: "editProveedor", id:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ AddProveedorDiv(0); });
Event.observe($('editarProveedor'), "click", EditarProveedor);
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function EditarProveedor()
{
new Ajax.Request(WEB_ROOT+'/ajax/proveedores.php',
{
method:'post',
parameters: $('editarProveedorForm').serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1])
}
else
{
ShowStatusPopUp(splitResponse[1])
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function DeleteProveedorPopup(id)
{
var message = "Realmente deseas eliminar a este proveedor?";
if(!confirm(message))
{
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/proveedores.php',
{
method:'post',
parameters: {type: "deleteProveedor", id: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ViewProveedorPopup(id)
{
grayOut(true);
$('fview').show();
if(id == 0)
{
$('fview').hide();
grayOut(false);
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/proveedores.php',
{
method:'post',
parameters: {type: "viewProveedor", id:id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('closePopUpDiv'), "click", function(){ AddProveedorDiv(0); });
Event.observe($('btnClose'), "click", HideFview);
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function Search()
{
var noProv = $("noProv").value;
new Ajax.Request(WEB_ROOT+'/ajax/proveedores.php',
{
method:'post',
parameters: {word: $('word').value, noProv:noProv, type: "search"},
onLoading: function(){
$("contenido").innerHTML = LOADER2;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('contenido').innerHTML = response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function CheckKey(e){
if(window.event)
keyCode = window.event.keyCode;
else if(e)
keyCode=e.which;
if(keyCode == 13)
Search();
}//CheckKey

90
javascript/reportes-compras.js Executable file
View File

@@ -0,0 +1,90 @@
function ReporteComprados()
{
new Ajax.Request(WEB_ROOT+'/ajax/reportes-compras.php',
{
method:'post',
parameters: $('formComprado').serialize(true),
onLoading:function(req)
{
$('loadBusqueda').show();
$('contenido').innerHTML="";
},
onSuccess: function(transport)
{
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$("contenido").innerHTML=response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ExportProdC()
{
var fechaini=$("fechaI").value;
var fechafin=$("fechaF").value;
if(ValidaCamposFecha(fechaini,fechafin))
{
$('formComprado').submit();return true;
}
else
{
return false;
}
}
function ShowDesc(id)
{
var resp = $("grupo"+id).style.display;
var status;
var txt;
if(resp == "none"){
status = "";
txt = "[-]";
}else{
status = "none";
txt = "[+]";
}
$("grupo"+id).style.display = status;
$("showHide"+id).innerHTML = txt;
}
//valida
function ValidaCamposFecha(fechaini,fechafin) {
var validaFecha = false;
if (fechaini == '' && fechafin == '')
{
validaFecha = true;
}
else
{
if (fechaini == '' || fechafin == '')
{
alert('no puedes dejar fecha inicial o final vacia');validaFecha = false;
}
else
{
var fechaIniVal = fechaini;
var fechaFinVal = fechafin;
var inicio = fechaIniVal.split("-");
var fin = fechaFinVal.split("-");
if (fin[2] >= inicio[2]) {
if(fin[1] >= inicio[1]){
if(fin[0] < inicio[0] && fin[1]<=inicio[1]){
alert('fecha inicial no puede ser mayor que la fecha final');validaFecha =false;
}else {
validaFecha = true;
}
}else{
validaFecha = false;
}
}else{
validaFecha = false;
}
}
} //else
return validaFecha;
}

View File

@@ -0,0 +1,230 @@
function ReporteCuentasPend()
{
new Ajax.Request(WEB_ROOT+'/ajax/reportes-cuentaspagar.php',
{
method:'post',
parameters: $('frmCuentasPend').serialize(true),
onLoading:function(req)
{
$('loadBusqueda').show();
$('contenido').innerHTML="";
},
onSuccess: function(transport)
{
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$("contenido").innerHTML=response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ExportCuentasPend()
{
/*var fechaini=$("fechaI").value;
var fechafin=$("fechaF").value;
if(ValidaCamposFecha(fechaini,fechafin))
{*/
$('frmCuentasPend').submit();return true;
/* }
else
{
return false;
}*/
}
function ReporteMasComprado()
{
new Ajax.Request(WEB_ROOT+'/ajax/reportes-productos.php',
{
method:'post',
parameters: $('formMcomprado').serialize(true),
onLoading:function(req)
{
$('loadBusqueda').show();
$('contenido').innerHTML="";
},
onSuccess: function(transport)
{
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$("contenido").innerHTML=response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ExportProdMC()
{
var fechaini=$("fechaI").value;
var fechafin=$("fechaF").value;
if(ValidaCamposFecha(fechaini,fechafin))
{
$('formMcomprado').submit();return true;
}
else
{
return false;
}
}
function ReporteMenosVendido()
{
new Ajax.Request(WEB_ROOT+'/ajax/reportes-productos.php',
{
method:'post',
parameters: $('formMenVendido').serialize(true),
onLoading:function(req)
{
$('loadBusqueda').show();
$('contenido').innerHTML="";
},
onSuccess: function(transport)
{
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$("contenido").innerHTML=response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ExportProdMenV()
{
var fechaini=$("fechaI").value;
var fechafin=$("fechaF").value;
if(ValidaCamposFecha(fechaini,fechafin))
{
$('formMenVendido').submit();return true;
}
else
{
return false;
}
}
function ReporteMenosComprado()
{
new Ajax.Request(WEB_ROOT+'/ajax/reportes-productos.php',
{
method:'post',
parameters: $('formMenComprado').serialize(true),
onLoading:function(req)
{
$('loadBusqueda').show();
$('contenido').innerHTML="";
},
onSuccess: function(transport)
{
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$("contenido").innerHTML=response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ExportProdMenC()
{
var fechaini=$("fechaI").value;
var fechafin=$("fechaF").value;
if(ValidaCamposFecha(fechaini,fechafin))
{
$('formMenComprado').submit();return true;
}
else
{
return false;
}
}
function TipoReporte()
{
new Ajax.Request(WEB_ROOT+'/ajax/reportes-productos.php',
{
method:'post',
parameters:$('formRproductos').serialize(true),
onLoading: function(req)
{
$('loadBusqueda').show();
$('tipoRp').innerHTML = "";
$("contenido").innerHTML='';
},
onSuccess: function(transport)
{
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$("tipoRp").innerHTML=response;
$("contenido").innerHTML='';
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ShowDesc(id)
{
var resp = $("grupo"+id).style.display;
var status;
var txt;
if(resp == "none"){
status = "";
txt = "[-]";
}else{
status = "none";
txt = "[+]";
}
$("grupo"+id).style.display = status;
$("showHide"+id).innerHTML = txt;
}
//valida
function ValidaCamposFecha(fechaini,fechafin) {
var validaFecha = false;
if (fechaini == '' && fechafin == '')
{
validaFecha = true;
}
else
{
if (fechaini == '' || fechafin == '')
{
alert('no puedes dejar fecha inicial o final vacia');validaFecha = false;
}
else
{
var fechaIniVal = fechaini;
var fechaFinVal = fechafin;
var inicio = fechaIniVal.split("-");
var fin = fechaFinVal.split("-");
if (fin[2] >= inicio[2]) {
if(fin[1] >= inicio[1]){
if(fin[0] < inicio[0] && fin[1]<=inicio[1]){
alert('fecha inicial no puede ser mayor que la fecha final');validaFecha =false;
}else {
validaFecha = true;
}
}else{
validaFecha = false;
}
}else{
validaFecha = false;
}
}
} //else
return validaFecha;
}

46
javascript/reportes-devcedis.js Executable file
View File

@@ -0,0 +1,46 @@
function Generar(){
new Ajax.Request(WEB_ROOT+'/ajax/reportes-devcedis.php',
{
method:'post',
parameters: $('frmDevCedis').serialize(),
onLoading: function(){
$("loader").innerHTML = LOADER2;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
console.log(response);
$("loader").innerHTML = '';
if(splitResponse[0] == "fail"){
ShowStatus(splitResponse[1]);
HideFview();
}else{
$('contenido').innerHTML = splitResponse[1];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ViewProducts(id){
var obj = $('listProds_'+id);
if(obj.style.display == "none")
obj.style.display = "";
else
obj.style.display = "none";
}
function ExportRep(){
$("frmDevCedis").submit();
}

View File

@@ -0,0 +1,25 @@
function Buscar()
{
new Ajax.Request(WEB_ROOT+'/ajax/reportes-faltantes.php',
{
method:'post',
parameters:$('frmFaltantes').serialize(true),
onLoading: function(){
$('loadBusqueda').show();
$('contenido').innerHTML = "";
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$("contenido").innerHTML=response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ExportInv()
{
$('frmFaltantes').submit();
return true;
}

100
javascript/reportes-inventario.js Executable file
View File

@@ -0,0 +1,100 @@
function Rinventario()
{
new Ajax.Request(WEB_ROOT+'/ajax/reportes-inventario.php',
{
method:'post',
parameters:$('formInven').serialize(true),
onLoading: function(req){
$('loadBusqueda').show();
$('contenido').innerHTML = "";
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$("contenido").innerHTML = response;
TableKit.reloadTable('tblReporte');
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ExportInv()
{
$('formInven').submit();
return true;
}
function LoadSubcats(){
var catId = $("prodCatId").value;
$("enumSubcats").innerHTML = '';
new Ajax.Request(WEB_ROOT+'/ajax/reportes-inventario.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("[#]");
$("enumSubcats").innerHTML = "";
if(splitResponse[0] == "ok")
$("enumSubcats").innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}//LoadSubcats
function ShowDesc(id){
var resp = $("totales"+id).style.display;
var status;
var txt;
if(resp == "none"){
status = "";
txt = "[-]";
}else{
status = "none";
txt = "[+]";
}
$("totales"+id).style.display = status;
$("showHide"+id).innerHTML = txt;
}
function ShowHideGral(){
var chks = document.getElementsByName('idS[]');
var resp = $("showHideG").innerHTML;
if(resp == "[+] TODOS"){
status = "";
txt = "[-]";
txtG = "[-] TODOS"
}else{
status = "none";
txt = "[+]";
txtG = "[+] TODOS";
}
for (var i=0; i<chks.length; i++)
{
var id = chks[i].value;
$("totales"+id).style.display = status;
$("showHide"+id).innerHTML = txt;
}
$("showHideG").innerHTML = txtG;
}

View File

@@ -0,0 +1,93 @@
Event.observe(window, 'load', function() {
AddEditSolicitudListeners = function(e) {
var el = e.element();
var del = el.hasClassName('spanDelete');
var id = el.identify();
if(del == true)
{
DeleteSolicitudPopup(id);
return;
}
}
$('contenido').observe("click", AddEditSolicitudListeners);
});
function AddSolicitudDiv(id)
{
grayOut(true);
if(id == 0)
{
$('fview').hide();
grayOut(false);
return;
}
$('fview').show();
new Ajax.Request(WEB_ROOT+'/ajax/reportes-invparcial.php',
{
method:'post',
parameters: {type: "addSolicitud"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
FViewOffSet(response);
Event.observe($('agregarSolicitud'), "click", AddSolicitud);
Event.observe($('fviewclose'), "click", function(){ AddSolicitudDiv(0); });
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function AddSolicitud()
{
new Ajax.Request(WEB_ROOT+'/ajax/reportes-invparcial.php',
{
method:'post',
parameters: $('agregarSolicitudForm').serialize(true),
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "fail")
{
ShowStatusPopUp(splitResponse[1]);
}
else
{
ShowStatus(splitResponse[1]);
$('contenido').innerHTML = splitResponse[2];
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function DeleteSolicitudPopup(id)
{
var message = "Realmente deseas eliminar esta solicitud?";
if(!confirm(message))
{
return;
}
new Ajax.Request(WEB_ROOT+'/ajax/reportes-invparcial.php',
{
method:'post',
parameters: {type: "deleteSolicitud", id: id},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
ShowStatus(splitResponse[1])
$('contenido').innerHTML = splitResponse[2];
HideFview();
},
onFailure: function(){ alert('Something went wrong...') }
});
}

30
javascript/reportes-tickets.js Executable file
View File

@@ -0,0 +1,30 @@
function Generar()
{
new Ajax.Request(WEB_ROOT+'/ajax/reportes-tickets.php',
{
method:'post',
parameters:$('frmTickets').serialize(true),
onLoading: function(){
$('loadBusqueda').show();
$('contenido').innerHTML = "";
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$('loadBusqueda').hide();
if(splitResponse[0] == "ok")
$("contenido").innerHTML = splitResponse[1];
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ExportInv()
{
$('frmTickets').submit();
return true;
}

592
javascript/reportes-ventas.js Executable file
View File

@@ -0,0 +1,592 @@
function TipoReporte()
{
new Ajax.Request(WEB_ROOT+'/ajax/reportes-ventas.php',
{
method:'post',
parameters:$('formRventas').serialize(true),
onLoading: function(req){
$('loadBusqueda').show();
$('tipoRv').innerHTML = "";
$("contenido").innerHTML='';
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
//FViewOffSet(response);
$('loadBusqueda').hide();
$("tipoRv").innerHTML=response;
$("contenido").innerHTML='';
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ReporteGral()
{
var resp = confirm("Esta seguro de generar este reporte? El proceso puede tardar varios minutos.");
if(!resp)
return;
new Ajax.Request(WEB_ROOT+'/ajax/reportes-ventas.php',
{
method:'post',
parameters:$('formV').serialize(true),
onLoading: function(req){
$('loadBusqueda').show();
$('contenido').innerHTML = "";
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$("contenido").innerHTML = response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function sucVend()
{
new Ajax.Request(WEB_ROOT+'/ajax/reportes-ventas.php',{
method:'post',
parameters:$("frmVend").serialize(true),
onLoading: function(req){
$('selectVend').innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('selectVend').innerHTML=response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function LoadVendedores(){
var sucursalId = $("sucursalId2").value;
new Ajax.Request(WEB_ROOT+'/ajax/reportes-ventas.php',{
method:'post',
parameters: {type:"dependSuc",sucursal:sucursalId},
onLoading: function(req){
$('selectVend').innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('selectVend').innerHTML=response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ReporteVend()
{
var resp = confirm("Esta seguro de generar este reporte? El proceso puede tardar varios minutos.");
if(!resp)
return;
new Ajax.Request(WEB_ROOT+'/ajax/reportes-ventas.php',
{
method:'post',
parameters:$("frmVend").serialize(true),
onLoading: function(req){
$('loadBusqueda').show();
$('contenido').innerHTML = "";
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$("contenido").innerHTML=response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ReporteTempo()
{
var resp = confirm("Esta seguro de generar este reporte? El proceso puede tardar varios minutos.");
if(!resp)
return;
new Ajax.Request(WEB_ROOT+'/ajax/reportes-ventas.php',
{
method:'post',
parameters:{type: "tipoTempo", idSuc: $("sucursal").value, idTemp:$("temporada").value,anio:$("anio").value},
onLoading: function(req){
$('loadBusqueda').show();
$('contenido').innerHTML = "";
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$('loadBusqueda').hide();
if(splitResponse[0] == "ok"){
$("contenido").innerHTML = splitResponse[1];
}else{
ShowStatus(splitResponse[1]);
HideFview();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ReporteFpago()
{
var resp = confirm("Esta seguro de generar este reporte? El proceso puede tardar varios minutos.");
if(!resp)
return;
new Ajax.Request(WEB_ROOT+'/ajax/reportes-ventas.php',{
method:'post',
parameters:{type: "tipoFpago", idSuc: $("idSucursal").value, fechaI:$("fechaI").value,fechaF:$("fechaF").value, idFpago:$("formaPago").value},
onLoading: function(req){
$('loadBusqueda').show();
$('contenido').innerHTML = "";
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$("contenido").innerHTML=response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ReporteProMasVend()
{
var resp = confirm("Esta seguro de generar este reporte? El proceso puede tardar varios minutos.");
if(!resp)
return;
new Ajax.Request(WEB_ROOT+'/ajax/reportes-ventas.php',
{
method:'post',
parameters: $('formMasVend').serialize(true),
onLoading:function(req){
$('loadBusqueda').show();
$('contenido').innerHTML = "";
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$("contenido").innerHTML = response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ReporteVentasProv()
{
var resp = confirm("Esta seguro de generar este reporte? El proceso puede tardar varios minutos.");
if(!resp)
return;
new Ajax.Request(WEB_ROOT+'/ajax/reportes-ventas.php',
{
method:'post',
parameters: $('formVendProv').serialize(true),
onLoading:function(req)
{
$('loadBusqueda').show();
$('contenido').innerHTML="";
},
onSuccess: function(transport)
{
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$("contenido").innerHTML=response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ReporteProdProv()
{
var resp = confirm("Esta seguro de generar este reporte? El proceso puede tardar varios minutos.");
if(!resp)
return;
new Ajax.Request(WEB_ROOT+'/ajax/reportes-ventas.php',
{
method:'post',
parameters: $('formProdProv').serialize(true),
onLoading:function(req){
$('loadBusqueda').show();
$('contenido').innerHTML="";
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
$('loadBusqueda').hide();
if(splitResponse[0] == "ok"){
$("contenido").innerHTML = splitResponse[1];
TableKit.reloadTable('tblProdProv');
}else if(splitResponse[0] == "fail"){
ShowStatus(splitResponse[1])
}else{
alert("Ocurrio un error al cargar los datos");
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ReporteProdProv2()
{
var resp = confirm("Esta seguro de generar este reporte? El proceso puede tardar varios minutos.");
if(!resp)
return;
new Ajax.Request(WEB_ROOT+'/ajax/reportes-prod-prov2.php',
{
method:'post',
parameters: $('formProdProv').serialize(true),
onLoading:function(req){
$('loadBusqueda').show();
$('contenido').innerHTML="";
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$("contenido").innerHTML = response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function RepBuenFinProv()
{
var resp = confirm("Esta seguro de generar este reporte? El proceso puede tardar varios minutos.");
if(!resp)
return;
new Ajax.Request(WEB_ROOT+'/ajax/reportes-buenfin-prov.php',
{
method:'post',
parameters: $('frmBuenFinProv').serialize(true),
onLoading:function(req){
$('loadBusqueda').show();
$('contenido').innerHTML = "";
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$("contenido").innerHTML = response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function RepProdsTransito()
{
var resp = confirm("Esta seguro de generar este reporte? El proceso puede tardar varios minutos.");
if(!resp)
return;
new Ajax.Request(WEB_ROOT+'/ajax/reportes-prods-transito.php',
{
method:'post',
parameters: $('frmProdsTransito').serialize(true),
onLoading:function(req){
$('loadBusqueda').show();
$('contenido').innerHTML = "";
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('loadBusqueda').hide();
$("contenido").innerHTML = response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ValidaCamposFecha(fechaini,fechafin) {
var validaFecha = false;
return true;
if (fechaini == '' && fechafin == '')
{
validaFecha = true;
}
else
{
if (fechaini == '' || fechafin == '')
{
alert('no puedes dejar fecha inicial o final vacia');validaFecha = false;
}
else
{
var fechaIniVal = fechaini;
var fechaFinVal = fechafin;
var inicio = fechaIniVal.split("-");
var fin = fechaFinVal.split("-");
if (fin[2] >= inicio[2]) {
if(fin[1] >= inicio[1]){
if(fin[0] < inicio[0] && fin[1]<=inicio[1]){
alert('fecha inicial no puede ser mayor que la fecha final');validaFecha =false;
}else {
validaFecha = true;
}
}else{
validaFecha = false;
}
}else{
validaFecha = false;
}
}
} //else
return validaFecha;
}
function ExportFpago()
{
var resp = confirm("Esta seguro de generar este reporte? El proceso puede tardar varios minutos.");
if(!resp)
return;
var fechaini=$("fechaI").value;
var fechafin=$("fechaF").value;
$('formPago').submit();
return true;
}
function ExportGral()
{
var resp = confirm("Esta seguro de generar este reporte? El proceso puede tardar varios minutos.");
if(!resp)
return;
var fechaini=$("fechaI").value;
var fechafin=$("fechaF").value;
$('formV').submit();
return true;
}
function ExportVend()
{
var resp = confirm("Esta seguro de generar este reporte? El proceso puede tardar varios minutos.");
if(!resp)
return;
var fechaini=$("fechaI").value;
var fechafin=$("fechaF").value;
$('frmVend').submit();
return false;
}
function ExportTempo()
{
var resp = confirm("Esta seguro de generar este reporte? El proceso puede tardar varios minutos.");
if(!resp)
return;
$('formTempo').submit();
return true;
}
function ExportProdVend()
{
var resp = confirm("Esta seguro de generar este reporte? El proceso puede tardar varios minutos.");
if(!resp)
return;
var fechaini=$("fechaI").value;
var fechafin=$("fechaF").value;
if(ValidaCamposFecha(fechaini,fechafin))
{
$('formMasVend').submit();return true;
}
else
{
return false;
}
}
function ExportProdProv2()
{
var resp = confirm("Esta seguro de generar este reporte? El proceso puede tardar varios minutos.");
if(!resp)
return;
var fechaini=$("fechaI").value;
var fechafin=$("fechaF").value;
if(ValidaCamposFecha(fechaini,fechafin))
{
$('formProdProv').submit();return true;
}
else
{
return false;
}
}
function ExportVentasProv()
{
var resp = confirm("Esta seguro de generar este reporte? El proceso puede tardar varios minutos.");
if(!resp)
return;
var fechaini=$("fechaI").value;
var fechafin=$("fechaF").value;
if(ValidaCamposFecha(fechaini,fechafin))
{
$('formVendProv').submit();return true;
}
else
{
return false;
}
}
function ExportProdProv(){
var resp = confirm("Esta seguro de generar este reporte? El proceso puede tardar varios minutos.");
if(!resp)
return;
$('formProdProv').submit();
return true;
}
function ExportBuenFinProv()
{
var resp = confirm("Esta seguro de generar este reporte? El proceso puede tardar varios minutos.");
if(!resp)
return;
$('frmBuenFinProv').submit();
return true;
}
function ExportProdsTransito()
{
var resp = confirm("Esta seguro de generar este reporte? El proceso puede tardar varios minutos.");
if(!resp)
return;
$('frmProdsTransito').submit();
return true;
}
function LoadProdSubcats(){
var prodCatId = $("prodCatId").value;
new Ajax.Request(WEB_ROOT+'/ajax/reportes-prod-prov2.php',{
method:'post',
parameters: {type:"loadProdSubcats", prodCatId:prodCatId},
onLoading: function(req){
$('enumSubcats').innerHTML = LOADER;
},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
$('enumSubcats').innerHTML = response;
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function ShowDesc(id){
var resp = $("totales"+id).style.display;
var status;
var txt;
if(resp == "none"){
status = "";
txt = "[-]";
}else{
status = "none";
txt = "[+]";
}
$("totales"+id).style.display = status;
$("showHide"+id).innerHTML = txt;
}
function ShowDescT(id, tempId){
var resp = $("totales" + id + "_" + tempId).style.display;
var status;
var txt;
if(resp == "none"){
status = "";
txt = "[-]";
}else{
status = "none";
txt = "[+]";
}
$("totales" + id + "_" + tempId).style.display = status;
$("showHide" + id + "_" + tempId).innerHTML = txt;
}
function ShowProdProv(id){
var resp = $("sucPP_"+id).style.display;
var status;
var txt;
if(resp == "none"){
status = "";
txt = "[-]";
}else{
status = "none";
txt = "[+]";
}
$("sucPP_"+id).style.display = status;
$("showHide_"+id).innerHTML = txt;
}

1197
javascript/scoluos/CHANGELOG Executable file

File diff suppressed because it is too large Load Diff

20
javascript/scoluos/MIT-LICENSE Executable file
View File

@@ -0,0 +1,20 @@
Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

59
javascript/scoluos/README.rdoc Executable file
View File

@@ -0,0 +1,59 @@
== script.aculo.us web 2.0 javascript
The Web is changing. The 30-year-old terminal-like technology it was originally
is gradually giving way to new ways of doing things. The power of AJAX allows
for rich user interaction without the trouble that has bugged traditional
web applications.
Building upon the wonderful Prototype JavaScript library, script.aculo.us
provides you with some great additional ingredients to mix in.
For more information, see http://script.aculo.us/
== What's new in this release?
See the CHANGELOG file for information on what's new.
You can follow http://twitter.com/scriptaculous if you want
to be updated as we fix bugs and add new features.
== Installation/Usage
script.aculo.us includes the Prototype JavaScript Framework
V1.6.0. You can use later versions, as they become available
(see http://prototypejs.org/).
Put prototype.js, and the six files scriptaculous.js,
builder.js, effects.js, dragdrop.js, controls.js and slider.js
in a directory of your website, e.g. /javascripts.
(The sound.js and unittest.js files are optional)
Now, you can include the scripts by adding the following
tags to the HEAD section of your HTML pages:
<script src="/javascripts/prototype.js" type="text/javascript"></script>
<script src="/javascripts/scriptaculous.js" type="text/javascript"></script>
scriptaculous.js will automatically load the other files of the
script.aculo.us distribution in, provided they are accessible
via the same path.
See http://wiki.script.aculo.us/scriptaculous/show/Usage for detailed
usage instructions.
== The distribution
Besides the script.aculo.us files in src, there's a complete
test tree included which holds functional and unit tests for
script.aculo.us.
If you need examples on how to implement things, the best place to
start is by opening test/run_functional_tests.html or
test/run_unit_tests.html in your browser, and looking at
the sources of the examples provided.
== License
script.aculo.us is licensed under the terms of the MIT License,
see the included MIT-LICENSE file.

4874
javascript/scoluos/lib/prototype.js vendored Executable file

File diff suppressed because it is too large Load Diff

136
javascript/scoluos/src/builder.js Executable file
View File

@@ -0,0 +1,136 @@
// script.aculo.us builder.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
var Builder = {
NODEMAP: {
AREA: 'map',
CAPTION: 'table',
COL: 'table',
COLGROUP: 'table',
LEGEND: 'fieldset',
OPTGROUP: 'select',
OPTION: 'select',
PARAM: 'object',
TBODY: 'table',
TD: 'table',
TFOOT: 'table',
TH: 'table',
THEAD: 'table',
TR: 'table'
},
// note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken,
// due to a Firefox bug
node: function(elementName) {
elementName = elementName.toUpperCase();
// try innerHTML approach
var parentTag = this.NODEMAP[elementName] || 'div';
var parentElement = document.createElement(parentTag);
try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
parentElement.innerHTML = "<" + elementName + "></" + elementName + ">";
} catch(e) {}
var element = parentElement.firstChild || null;
// see if browser added wrapping tags
if(element && (element.tagName.toUpperCase() != elementName))
element = element.getElementsByTagName(elementName)[0];
// fallback to createElement approach
if(!element) element = document.createElement(elementName);
// abort if nothing could be created
if(!element) return;
// attributes (or text)
if(arguments[1])
if(this._isStringOrNumber(arguments[1]) ||
(arguments[1] instanceof Array) ||
arguments[1].tagName) {
this._children(element, arguments[1]);
} else {
var attrs = this._attributes(arguments[1]);
if(attrs.length) {
try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
parentElement.innerHTML = "<" +elementName + " " +
attrs + "></" + elementName + ">";
} catch(e) {}
element = parentElement.firstChild || null;
// workaround firefox 1.0.X bug
if(!element) {
element = document.createElement(elementName);
for(attr in arguments[1])
element[attr == 'class' ? 'className' : attr] = arguments[1][attr];
}
if(element.tagName.toUpperCase() != elementName)
element = parentElement.getElementsByTagName(elementName)[0];
}
}
// text, or array of children
if(arguments[2])
this._children(element, arguments[2]);
return $(element);
},
_text: function(text) {
return document.createTextNode(text);
},
ATTR_MAP: {
'className': 'class',
'htmlFor': 'for'
},
_attributes: function(attributes) {
var attrs = [];
for(attribute in attributes)
attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) +
'="' + attributes[attribute].toString().escapeHTML().gsub(/"/,'&quot;') + '"');
return attrs.join(" ");
},
_children: function(element, children) {
if(children.tagName) {
element.appendChild(children);
return;
}
if(typeof children=='object') { // array can hold nodes and text
children.flatten().each( function(e) {
if(typeof e=='object')
element.appendChild(e);
else
if(Builder._isStringOrNumber(e))
element.appendChild(Builder._text(e));
});
} else
if(Builder._isStringOrNumber(children))
element.appendChild(Builder._text(children));
},
_isStringOrNumber: function(param) {
return(typeof param=='string' || typeof param=='number');
},
build: function(html) {
var element = this.node('div');
$(element).update(html.strip());
return element.down();
},
dump: function(scope) {
if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope
var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " +
"BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " +
"FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+
"KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+
"PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+
"TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/);
tags.each( function(tag){
scope[tag] = function() {
return Builder.node.apply(Builder, [tag].concat($A(arguments)));
};
});
}
};

965
javascript/scoluos/src/controls.js vendored Executable file
View File

@@ -0,0 +1,965 @@
// script.aculo.us controls.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// (c) 2005-2009 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
// (c) 2005-2009 Jon Tirsen (http://www.tirsen.com)
// Contributors:
// Richard Livsey
// Rahul Bhargava
// Rob Wills
//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
// Autocompleter.Base handles all the autocompletion functionality
// that's independent of the data source for autocompletion. This
// includes drawing the autocompletion menu, observing keyboard
// and mouse events, and similar.
//
// Specific autocompleters need to provide, at the very least,
// a getUpdatedChoices function that will be invoked every time
// the text inside the monitored textbox changes. This method
// should get the text for which to provide autocompletion by
// invoking this.getToken(), NOT by directly accessing
// this.element.value. This is to allow incremental tokenized
// autocompletion. Specific auto-completion logic (AJAX, etc)
// belongs in getUpdatedChoices.
//
// Tokenized incremental autocompletion is enabled automatically
// when an autocompleter is instantiated with the 'tokens' option
// in the options parameter, e.g.:
// new Ajax.Autocompleter('id','upd', '/url/', { tokens: ',' });
// will incrementally autocomplete with a comma as the token.
// Additionally, ',' in the above example can be replaced with
// a token array, e.g. { tokens: [',', '\n'] } which
// enables autocompletion on multiple tokens. This is most
// useful when one of the tokens is \n (a newline), as it
// allows smart autocompletion after linebreaks.
if(typeof Effect == 'undefined')
throw("controls.js requires including script.aculo.us' effects.js library");
var Autocompleter = { };
Autocompleter.Base = Class.create({
baseInitialize: function(element, update, options) {
element = $(element);
this.element = element;
this.update = $(update);
this.hasFocus = false;
this.changed = false;
this.active = false;
this.index = 0;
this.entryCount = 0;
this.oldElementValue = this.element.value;
if(this.setOptions)
this.setOptions(options);
else
this.options = options || { };
this.options.paramName = this.options.paramName || this.element.name;
this.options.tokens = this.options.tokens || [];
this.options.frequency = this.options.frequency || 0.4;
this.options.minChars = this.options.minChars || 1;
this.options.onShow = this.options.onShow ||
function(element, update){
if(!update.style.position || update.style.position=='absolute') {
update.style.position = 'absolute';
Position.clone(element, update, {
setHeight: false,
offsetTop: element.offsetHeight
});
}
Effect.Appear(update,{duration:0.15});
};
this.options.onHide = this.options.onHide ||
function(element, update){ new Effect.Fade(update,{duration:0.15}) };
if(typeof(this.options.tokens) == 'string')
this.options.tokens = new Array(this.options.tokens);
// Force carriage returns as token delimiters anyway
if (!this.options.tokens.include('\n'))
this.options.tokens.push('\n');
this.observer = null;
this.element.setAttribute('autocomplete','off');
Element.hide(this.update);
Event.observe(this.element, 'blur', this.onBlur.bindAsEventListener(this));
Event.observe(this.element, 'keydown', this.onKeyPress.bindAsEventListener(this));
},
show: function() {
if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);
if(!this.iefix &&
(Prototype.Browser.IE) &&
(Element.getStyle(this.update, 'position')=='absolute')) {
new Insertion.After(this.update,
'<iframe id="' + this.update.id + '_iefix" '+
'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' +
'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
this.iefix = $(this.update.id+'_iefix');
}
if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50);
},
fixIEOverlapping: function() {
Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)});
this.iefix.style.zIndex = 1;
this.update.style.zIndex = 2;
Element.show(this.iefix);
},
hide: function() {
this.stopIndicator();
if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update);
if(this.iefix) Element.hide(this.iefix);
},
startIndicator: function() {
if(this.options.indicator) Element.show(this.options.indicator);
},
stopIndicator: function() {
if(this.options.indicator) Element.hide(this.options.indicator);
},
onKeyPress: function(event) {
if(this.active)
switch(event.keyCode) {
case Event.KEY_TAB:
case Event.KEY_RETURN:
this.selectEntry();
Event.stop(event);
case Event.KEY_ESC:
this.hide();
this.active = false;
Event.stop(event);
return;
case Event.KEY_LEFT:
case Event.KEY_RIGHT:
return;
case Event.KEY_UP:
this.markPrevious();
this.render();
Event.stop(event);
return;
case Event.KEY_DOWN:
this.markNext();
this.render();
Event.stop(event);
return;
}
else
if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
(Prototype.Browser.WebKit > 0 && event.keyCode == 0)) return;
this.changed = true;
this.hasFocus = true;
if(this.observer) clearTimeout(this.observer);
this.observer =
setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
},
activate: function() {
this.changed = false;
this.hasFocus = true;
this.getUpdatedChoices();
},
onHover: function(event) {
var element = Event.findElement(event, 'LI');
if(this.index != element.autocompleteIndex)
{
this.index = element.autocompleteIndex;
this.render();
}
Event.stop(event);
},
onClick: function(event) {
var element = Event.findElement(event, 'LI');
this.index = element.autocompleteIndex;
this.selectEntry();
this.hide();
},
onBlur: function(event) {
// needed to make click events working
setTimeout(this.hide.bind(this), 250);
this.hasFocus = false;
this.active = false;
},
render: function() {
if(this.entryCount > 0) {
for (var i = 0; i < this.entryCount; i++)
this.index==i ?
Element.addClassName(this.getEntry(i),"selected") :
Element.removeClassName(this.getEntry(i),"selected");
if(this.hasFocus) {
this.show();
this.active = true;
}
} else {
this.active = false;
this.hide();
}
},
markPrevious: function() {
if(this.index > 0) this.index--;
else this.index = this.entryCount-1;
this.getEntry(this.index).scrollIntoView(true);
},
markNext: function() {
if(this.index < this.entryCount-1) this.index++;
else this.index = 0;
this.getEntry(this.index).scrollIntoView(false);
},
getEntry: function(index) {
return this.update.firstChild.childNodes[index];
},
getCurrentEntry: function() {
return this.getEntry(this.index);
},
selectEntry: function() {
this.active = false;
this.updateElement(this.getCurrentEntry());
},
updateElement: function(selectedElement) {
if (this.options.updateElement) {
this.options.updateElement(selectedElement);
return;
}
var value = '';
if (this.options.select) {
var nodes = $(selectedElement).select('.' + this.options.select) || [];
if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select);
} else
value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
var bounds = this.getTokenBounds();
if (bounds[0] != -1) {
var newValue = this.element.value.substr(0, bounds[0]);
var whitespace = this.element.value.substr(bounds[0]).match(/^\s+/);
if (whitespace)
newValue += whitespace[0];
this.element.value = newValue + value + this.element.value.substr(bounds[1]);
} else {
this.element.value = value;
}
this.oldElementValue = this.element.value;
this.element.focus();
if (this.options.afterUpdateElement)
this.options.afterUpdateElement(this.element, selectedElement);
},
updateChoices: function(choices) {
if(!this.changed && this.hasFocus) {
this.update.innerHTML = choices;
Element.cleanWhitespace(this.update);
Element.cleanWhitespace(this.update.down());
if(this.update.firstChild && this.update.down().childNodes) {
this.entryCount =
this.update.down().childNodes.length;
for (var i = 0; i < this.entryCount; i++) {
var entry = this.getEntry(i);
entry.autocompleteIndex = i;
this.addObservers(entry);
}
} else {
this.entryCount = 0;
}
this.stopIndicator();
this.index = 0;
if(this.entryCount==1 && this.options.autoSelect) {
this.selectEntry();
this.hide();
} else {
this.render();
}
}
},
addObservers: function(element) {
Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this));
Event.observe(element, "click", this.onClick.bindAsEventListener(this));
},
onObserverEvent: function() {
this.changed = false;
this.tokenBounds = null;
if(this.getToken().length>=this.options.minChars) {
this.getUpdatedChoices();
} else {
this.active = false;
this.hide();
}
this.oldElementValue = this.element.value;
},
getToken: function() {
var bounds = this.getTokenBounds();
return this.element.value.substring(bounds[0], bounds[1]).strip();
},
getTokenBounds: function() {
if (null != this.tokenBounds) return this.tokenBounds;
var value = this.element.value;
if (value.strip().empty()) return [-1, 0];
var diff = arguments.callee.getFirstDifferencePos(value, this.oldElementValue);
var offset = (diff == this.oldElementValue.length ? 1 : 0);
var prevTokenPos = -1, nextTokenPos = value.length;
var tp;
for (var index = 0, l = this.options.tokens.length; index < l; ++index) {
tp = value.lastIndexOf(this.options.tokens[index], diff + offset - 1);
if (tp > prevTokenPos) prevTokenPos = tp;
tp = value.indexOf(this.options.tokens[index], diff + offset);
if (-1 != tp && tp < nextTokenPos) nextTokenPos = tp;
}
return (this.tokenBounds = [prevTokenPos + 1, nextTokenPos]);
}
});
Autocompleter.Base.prototype.getTokenBounds.getFirstDifferencePos = function(newS, oldS) {
var boundary = Math.min(newS.length, oldS.length);
for (var index = 0; index < boundary; ++index)
if (newS[index] != oldS[index])
return index;
return boundary;
};
Ajax.Autocompleter = Class.create(Autocompleter.Base, {
initialize: function(element, update, url, options) {
this.baseInitialize(element, update, options);
this.options.asynchronous = true;
this.options.onComplete = this.onComplete.bind(this);
this.options.defaultParams = this.options.parameters || null;
this.url = url;
},
getUpdatedChoices: function() {
this.startIndicator();
var entry = encodeURIComponent(this.options.paramName) + '=' +
encodeURIComponent(this.getToken());
this.options.parameters = this.options.callback ?
this.options.callback(this.element, entry) : entry;
if(this.options.defaultParams)
this.options.parameters += '&' + this.options.defaultParams;
new Ajax.Request(this.url, this.options);
},
onComplete: function(request) {
this.updateChoices(request.responseText);
}
});
// The local array autocompleter. Used when you'd prefer to
// inject an array of autocompletion options into the page, rather
// than sending out Ajax queries, which can be quite slow sometimes.
//
// The constructor takes four parameters. The first two are, as usual,
// the id of the monitored textbox, and id of the autocompletion menu.
// The third is the array you want to autocomplete from, and the fourth
// is the options block.
//
// Extra local autocompletion options:
// - choices - How many autocompletion choices to offer
//
// - partialSearch - If false, the autocompleter will match entered
// text only at the beginning of strings in the
// autocomplete array. Defaults to true, which will
// match text at the beginning of any *word* in the
// strings in the autocomplete array. If you want to
// search anywhere in the string, additionally set
// the option fullSearch to true (default: off).
//
// - fullSsearch - Search anywhere in autocomplete array strings.
//
// - partialChars - How many characters to enter before triggering
// a partial match (unlike minChars, which defines
// how many characters are required to do any match
// at all). Defaults to 2.
//
// - ignoreCase - Whether to ignore case when autocompleting.
// Defaults to true.
//
// It's possible to pass in a custom function as the 'selector'
// option, if you prefer to write your own autocompletion logic.
// In that case, the other options above will not apply unless
// you support them.
Autocompleter.Local = Class.create(Autocompleter.Base, {
initialize: function(element, update, array, options) {
this.baseInitialize(element, update, options);
this.options.array = array;
},
getUpdatedChoices: function() {
this.updateChoices(this.options.selector(this));
},
setOptions: function(options) {
this.options = Object.extend({
choices: 10,
partialSearch: true,
partialChars: 2,
ignoreCase: true,
fullSearch: false,
selector: function(instance) {
var ret = []; // Beginning matches
var partial = []; // Inside matches
var entry = instance.getToken();
var count = 0;
for (var i = 0; i < instance.options.array.length &&
ret.length < instance.options.choices ; i++) {
var elem = instance.options.array[i];
var foundPos = instance.options.ignoreCase ?
elem.toLowerCase().indexOf(entry.toLowerCase()) :
elem.indexOf(entry);
while (foundPos != -1) {
if (foundPos == 0 && elem.length != entry.length) {
ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" +
elem.substr(entry.length) + "</li>");
break;
} else if (entry.length >= instance.options.partialChars &&
instance.options.partialSearch && foundPos != -1) {
if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) {
partial.push("<li>" + elem.substr(0, foundPos) + "<strong>" +
elem.substr(foundPos, entry.length) + "</strong>" + elem.substr(
foundPos + entry.length) + "</li>");
break;
}
}
foundPos = instance.options.ignoreCase ?
elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
elem.indexOf(entry, foundPos + 1);
}
}
if (partial.length)
ret = ret.concat(partial.slice(0, instance.options.choices - ret.length));
return "<ul>" + ret.join('') + "</ul>";
}
}, options || { });
}
});
// AJAX in-place editor and collection editor
// Full rewrite by Christophe Porteneuve <tdd@tddsworld.com> (April 2007).
// Use this if you notice weird scrolling problems on some browsers,
// the DOM might be a bit confused when this gets called so do this
// waits 1 ms (with setTimeout) until it does the activation
Field.scrollFreeActivate = function(field) {
setTimeout(function() {
Field.activate(field);
}, 1);
};
Ajax.InPlaceEditor = Class.create({
initialize: function(element, url, options) {
this.url = url;
this.element = element = $(element);
this.prepareOptions();
this._controls = { };
arguments.callee.dealWithDeprecatedOptions(options); // DEPRECATION LAYER!!!
Object.extend(this.options, options || { });
if (!this.options.formId && this.element.id) {
this.options.formId = this.element.id + '-inplaceeditor';
if ($(this.options.formId))
this.options.formId = '';
}
if (this.options.externalControl)
this.options.externalControl = $(this.options.externalControl);
if (!this.options.externalControl)
this.options.externalControlOnly = false;
this._originalBackground = this.element.getStyle('background-color') || 'transparent';
this.element.title = this.options.clickToEditText;
this._boundCancelHandler = this.handleFormCancellation.bind(this);
this._boundComplete = (this.options.onComplete || Prototype.emptyFunction).bind(this);
this._boundFailureHandler = this.handleAJAXFailure.bind(this);
this._boundSubmitHandler = this.handleFormSubmission.bind(this);
this._boundWrapperHandler = this.wrapUp.bind(this);
this.registerListeners();
},
checkForEscapeOrReturn: function(e) {
if (!this._editing || e.ctrlKey || e.altKey || e.shiftKey) return;
if (Event.KEY_ESC == e.keyCode)
this.handleFormCancellation(e);
else if (Event.KEY_RETURN == e.keyCode)
this.handleFormSubmission(e);
},
createControl: function(mode, handler, extraClasses) {
var control = this.options[mode + 'Control'];
var text = this.options[mode + 'Text'];
if ('button' == control) {
var btn = document.createElement('input');
btn.type = 'submit';
btn.value = text;
btn.className = 'editor_' + mode + '_button';
if ('cancel' == mode)
btn.onclick = this._boundCancelHandler;
this._form.appendChild(btn);
this._controls[mode] = btn;
} else if ('link' == control) {
var link = document.createElement('a');
link.href = '#';
link.appendChild(document.createTextNode(text));
link.onclick = 'cancel' == mode ? this._boundCancelHandler : this._boundSubmitHandler;
link.className = 'editor_' + mode + '_link';
if (extraClasses)
link.className += ' ' + extraClasses;
this._form.appendChild(link);
this._controls[mode] = link;
}
},
createEditField: function() {
var text = (this.options.loadTextURL ? this.options.loadingText : this.getText());
var fld;
if (1 >= this.options.rows && !/\r|\n/.test(this.getText())) {
fld = document.createElement('input');
fld.type = 'text';
var size = this.options.size || this.options.cols || 0;
if (0 < size) fld.size = size;
} else {
fld = document.createElement('textarea');
fld.rows = (1 >= this.options.rows ? this.options.autoRows : this.options.rows);
fld.cols = this.options.cols || 40;
}
fld.name = this.options.paramName;
fld.value = text; // No HTML breaks conversion anymore
fld.className = 'editor_field';
if (this.options.submitOnBlur)
fld.onblur = this._boundSubmitHandler;
this._controls.editor = fld;
if (this.options.loadTextURL)
this.loadExternalText();
this._form.appendChild(this._controls.editor);
},
createForm: function() {
var ipe = this;
function addText(mode, condition) {
var text = ipe.options['text' + mode + 'Controls'];
if (!text || condition === false) return;
ipe._form.appendChild(document.createTextNode(text));
};
this._form = $(document.createElement('form'));
this._form.id = this.options.formId;
this._form.addClassName(this.options.formClassName);
this._form.onsubmit = this._boundSubmitHandler;
this.createEditField();
if ('textarea' == this._controls.editor.tagName.toLowerCase())
this._form.appendChild(document.createElement('br'));
if (this.options.onFormCustomization)
this.options.onFormCustomization(this, this._form);
addText('Before', this.options.okControl || this.options.cancelControl);
this.createControl('ok', this._boundSubmitHandler);
addText('Between', this.options.okControl && this.options.cancelControl);
this.createControl('cancel', this._boundCancelHandler, 'editor_cancel');
addText('After', this.options.okControl || this.options.cancelControl);
},
destroy: function() {
if (this._oldInnerHTML)
this.element.innerHTML = this._oldInnerHTML;
this.leaveEditMode();
this.unregisterListeners();
},
enterEditMode: function(e) {
if (this._saving || this._editing) return;
this._editing = true;
this.triggerCallback('onEnterEditMode');
if (this.options.externalControl)
this.options.externalControl.hide();
this.element.hide();
this.createForm();
this.element.parentNode.insertBefore(this._form, this.element);
if (!this.options.loadTextURL)
this.postProcessEditField();
if (e) Event.stop(e);
},
enterHover: function(e) {
if (this.options.hoverClassName)
this.element.addClassName(this.options.hoverClassName);
if (this._saving) return;
this.triggerCallback('onEnterHover');
},
getText: function() {
return this.element.innerHTML.unescapeHTML();
},
handleAJAXFailure: function(transport) {
this.triggerCallback('onFailure', transport);
if (this._oldInnerHTML) {
this.element.innerHTML = this._oldInnerHTML;
this._oldInnerHTML = null;
}
},
handleFormCancellation: function(e) {
this.wrapUp();
if (e) Event.stop(e);
},
handleFormSubmission: function(e) {
var form = this._form;
var value = $F(this._controls.editor);
this.prepareSubmission();
var params = this.options.callback(form, value) || '';
if (Object.isString(params))
params = params.toQueryParams();
params.editorId = this.element.id;
if (this.options.htmlResponse) {
var options = Object.extend({ evalScripts: true }, this.options.ajaxOptions);
Object.extend(options, {
parameters: params,
onComplete: this._boundWrapperHandler,
onFailure: this._boundFailureHandler
});
new Ajax.Updater({ success: this.element }, this.url, options);
} else {
var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
Object.extend(options, {
parameters: params,
onComplete: this._boundWrapperHandler,
onFailure: this._boundFailureHandler
});
new Ajax.Request(this.url, options);
}
if (e) Event.stop(e);
},
leaveEditMode: function() {
this.element.removeClassName(this.options.savingClassName);
this.removeForm();
this.leaveHover();
this.element.style.backgroundColor = this._originalBackground;
this.element.show();
if (this.options.externalControl)
this.options.externalControl.show();
this._saving = false;
this._editing = false;
this._oldInnerHTML = null;
this.triggerCallback('onLeaveEditMode');
},
leaveHover: function(e) {
if (this.options.hoverClassName)
this.element.removeClassName(this.options.hoverClassName);
if (this._saving) return;
this.triggerCallback('onLeaveHover');
},
loadExternalText: function() {
this._form.addClassName(this.options.loadingClassName);
this._controls.editor.disabled = true;
var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
Object.extend(options, {
parameters: 'editorId=' + encodeURIComponent(this.element.id),
onComplete: Prototype.emptyFunction,
onSuccess: function(transport) {
this._form.removeClassName(this.options.loadingClassName);
var text = transport.responseText;
if (this.options.stripLoadedTextTags)
text = text.stripTags();
this._controls.editor.value = text;
this._controls.editor.disabled = false;
this.postProcessEditField();
}.bind(this),
onFailure: this._boundFailureHandler
});
new Ajax.Request(this.options.loadTextURL, options);
},
postProcessEditField: function() {
var fpc = this.options.fieldPostCreation;
if (fpc)
$(this._controls.editor)['focus' == fpc ? 'focus' : 'activate']();
},
prepareOptions: function() {
this.options = Object.clone(Ajax.InPlaceEditor.DefaultOptions);
Object.extend(this.options, Ajax.InPlaceEditor.DefaultCallbacks);
[this._extraDefaultOptions].flatten().compact().each(function(defs) {
Object.extend(this.options, defs);
}.bind(this));
},
prepareSubmission: function() {
this._saving = true;
this.removeForm();
this.leaveHover();
this.showSaving();
},
registerListeners: function() {
this._listeners = { };
var listener;
$H(Ajax.InPlaceEditor.Listeners).each(function(pair) {
listener = this[pair.value].bind(this);
this._listeners[pair.key] = listener;
if (!this.options.externalControlOnly)
this.element.observe(pair.key, listener);
if (this.options.externalControl)
this.options.externalControl.observe(pair.key, listener);
}.bind(this));
},
removeForm: function() {
if (!this._form) return;
this._form.remove();
this._form = null;
this._controls = { };
},
showSaving: function() {
this._oldInnerHTML = this.element.innerHTML;
this.element.innerHTML = this.options.savingText;
this.element.addClassName(this.options.savingClassName);
this.element.style.backgroundColor = this._originalBackground;
this.element.show();
},
triggerCallback: function(cbName, arg) {
if ('function' == typeof this.options[cbName]) {
this.options[cbName](this, arg);
}
},
unregisterListeners: function() {
$H(this._listeners).each(function(pair) {
if (!this.options.externalControlOnly)
this.element.stopObserving(pair.key, pair.value);
if (this.options.externalControl)
this.options.externalControl.stopObserving(pair.key, pair.value);
}.bind(this));
},
wrapUp: function(transport) {
this.leaveEditMode();
// Can't use triggerCallback due to backward compatibility: requires
// binding + direct element
this._boundComplete(transport, this.element);
}
});
Object.extend(Ajax.InPlaceEditor.prototype, {
dispose: Ajax.InPlaceEditor.prototype.destroy
});
Ajax.InPlaceCollectionEditor = Class.create(Ajax.InPlaceEditor, {
initialize: function($super, element, url, options) {
this._extraDefaultOptions = Ajax.InPlaceCollectionEditor.DefaultOptions;
$super(element, url, options);
},
createEditField: function() {
var list = document.createElement('select');
list.name = this.options.paramName;
list.size = 1;
this._controls.editor = list;
this._collection = this.options.collection || [];
if (this.options.loadCollectionURL)
this.loadCollection();
else
this.checkForExternalText();
this._form.appendChild(this._controls.editor);
},
loadCollection: function() {
this._form.addClassName(this.options.loadingClassName);
this.showLoadingText(this.options.loadingCollectionText);
var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
Object.extend(options, {
parameters: 'editorId=' + encodeURIComponent(this.element.id),
onComplete: Prototype.emptyFunction,
onSuccess: function(transport) {
var js = transport.responseText.strip();
if (!/^\[.*\]$/.test(js)) // TODO: improve sanity check
throw('Server returned an invalid collection representation.');
this._collection = eval(js);
this.checkForExternalText();
}.bind(this),
onFailure: this.onFailure
});
new Ajax.Request(this.options.loadCollectionURL, options);
},
showLoadingText: function(text) {
this._controls.editor.disabled = true;
var tempOption = this._controls.editor.firstChild;
if (!tempOption) {
tempOption = document.createElement('option');
tempOption.value = '';
this._controls.editor.appendChild(tempOption);
tempOption.selected = true;
}
tempOption.update((text || '').stripScripts().stripTags());
},
checkForExternalText: function() {
this._text = this.getText();
if (this.options.loadTextURL)
this.loadExternalText();
else
this.buildOptionList();
},
loadExternalText: function() {
this.showLoadingText(this.options.loadingText);
var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
Object.extend(options, {
parameters: 'editorId=' + encodeURIComponent(this.element.id),
onComplete: Prototype.emptyFunction,
onSuccess: function(transport) {
this._text = transport.responseText.strip();
this.buildOptionList();
}.bind(this),
onFailure: this.onFailure
});
new Ajax.Request(this.options.loadTextURL, options);
},
buildOptionList: function() {
this._form.removeClassName(this.options.loadingClassName);
this._collection = this._collection.map(function(entry) {
return 2 === entry.length ? entry : [entry, entry].flatten();
});
var marker = ('value' in this.options) ? this.options.value : this._text;
var textFound = this._collection.any(function(entry) {
return entry[0] == marker;
}.bind(this));
this._controls.editor.update('');
var option;
this._collection.each(function(entry, index) {
option = document.createElement('option');
option.value = entry[0];
option.selected = textFound ? entry[0] == marker : 0 == index;
option.appendChild(document.createTextNode(entry[1]));
this._controls.editor.appendChild(option);
}.bind(this));
this._controls.editor.disabled = false;
Field.scrollFreeActivate(this._controls.editor);
}
});
//**** DEPRECATION LAYER FOR InPlace[Collection]Editor! ****
//**** This only exists for a while, in order to let ****
//**** users adapt to the new API. Read up on the new ****
//**** API and convert your code to it ASAP! ****
Ajax.InPlaceEditor.prototype.initialize.dealWithDeprecatedOptions = function(options) {
if (!options) return;
function fallback(name, expr) {
if (name in options || expr === undefined) return;
options[name] = expr;
};
fallback('cancelControl', (options.cancelLink ? 'link' : (options.cancelButton ? 'button' :
options.cancelLink == options.cancelButton == false ? false : undefined)));
fallback('okControl', (options.okLink ? 'link' : (options.okButton ? 'button' :
options.okLink == options.okButton == false ? false : undefined)));
fallback('highlightColor', options.highlightcolor);
fallback('highlightEndColor', options.highlightendcolor);
};
Object.extend(Ajax.InPlaceEditor, {
DefaultOptions: {
ajaxOptions: { },
autoRows: 3, // Use when multi-line w/ rows == 1
cancelControl: 'link', // 'link'|'button'|false
cancelText: 'cancel',
clickToEditText: 'Click to edit',
externalControl: null, // id|elt
externalControlOnly: false,
fieldPostCreation: 'activate', // 'activate'|'focus'|false
formClassName: 'inplaceeditor-form',
formId: null, // id|elt
highlightColor: '#ffff99',
highlightEndColor: '#ffffff',
hoverClassName: '',
htmlResponse: true,
loadingClassName: 'inplaceeditor-loading',
loadingText: 'Loading...',
okControl: 'button', // 'link'|'button'|false
okText: 'ok',
paramName: 'value',
rows: 1, // If 1 and multi-line, uses autoRows
savingClassName: 'inplaceeditor-saving',
savingText: 'Saving...',
size: 0,
stripLoadedTextTags: false,
submitOnBlur: false,
textAfterControls: '',
textBeforeControls: '',
textBetweenControls: ''
},
DefaultCallbacks: {
callback: function(form) {
return Form.serialize(form);
},
onComplete: function(transport, element) {
// For backward compatibility, this one is bound to the IPE, and passes
// the element directly. It was too often customized, so we don't break it.
new Effect.Highlight(element, {
startcolor: this.options.highlightColor, keepBackgroundImage: true });
},
onEnterEditMode: null,
onEnterHover: function(ipe) {
ipe.element.style.backgroundColor = ipe.options.highlightColor;
if (ipe._effect)
ipe._effect.cancel();
},
onFailure: function(transport, ipe) {
alert('Error communication with the server: ' + transport.responseText.stripTags());
},
onFormCustomization: null, // Takes the IPE and its generated form, after editor, before controls.
onLeaveEditMode: null,
onLeaveHover: function(ipe) {
ipe._effect = new Effect.Highlight(ipe.element, {
startcolor: ipe.options.highlightColor, endcolor: ipe.options.highlightEndColor,
restorecolor: ipe._originalBackground, keepBackgroundImage: true
});
}
},
Listeners: {
click: 'enterEditMode',
keydown: 'checkForEscapeOrReturn',
mouseover: 'enterHover',
mouseout: 'leaveHover'
}
});
Ajax.InPlaceCollectionEditor.DefaultOptions = {
loadingCollectionText: 'Loading options...'
};
// Delayed observer, like Form.Element.Observer,
// but waits for delay after last key input
// Ideal for live-search fields
Form.Element.DelayedObserver = Class.create({
initialize: function(element, delay, callback) {
this.delay = delay || 0.5;
this.element = $(element);
this.callback = callback;
this.timer = null;
this.lastValue = $F(this.element);
Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this));
},
delayedListener: function(event) {
if(this.lastValue == $F(this.element)) return;
if(this.timer) clearTimeout(this.timer);
this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000);
this.lastValue = $F(this.element);
},
onTimerEvent: function() {
this.timer = null;
this.callback(this.element, $F(this.element));
}
});

974
javascript/scoluos/src/dragdrop.js vendored Executable file
View File

@@ -0,0 +1,974 @@
// script.aculo.us dragdrop.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
if(Object.isUndefined(Effect))
throw("dragdrop.js requires including script.aculo.us' effects.js library");
var Droppables = {
drops: [],
remove: function(element) {
this.drops = this.drops.reject(function(d) { return d.element==$(element) });
},
add: function(element) {
element = $(element);
var options = Object.extend({
greedy: true,
hoverclass: null,
tree: false
}, arguments[1] || { });
// cache containers
if(options.containment) {
options._containers = [];
var containment = options.containment;
if(Object.isArray(containment)) {
containment.each( function(c) { options._containers.push($(c)) });
} else {
options._containers.push($(containment));
}
}
if(options.accept) options.accept = [options.accept].flatten();
Element.makePositioned(element); // fix IE
options.element = element;
this.drops.push(options);
},
findDeepestChild: function(drops) {
deepest = drops[0];
for (i = 1; i < drops.length; ++i)
if (Element.isParent(drops[i].element, deepest.element))
deepest = drops[i];
return deepest;
},
isContained: function(element, drop) {
var containmentNode;
if(drop.tree) {
containmentNode = element.treeNode;
} else {
containmentNode = element.parentNode;
}
return drop._containers.detect(function(c) { return containmentNode == c });
},
isAffected: function(point, element, drop) {
return (
(drop.element!=element) &&
((!drop._containers) ||
this.isContained(element, drop)) &&
((!drop.accept) ||
(Element.classNames(element).detect(
function(v) { return drop.accept.include(v) } ) )) &&
Position.within(drop.element, point[0], point[1]) );
},
deactivate: function(drop) {
if(drop.hoverclass)
Element.removeClassName(drop.element, drop.hoverclass);
this.last_active = null;
},
activate: function(drop) {
if(drop.hoverclass)
Element.addClassName(drop.element, drop.hoverclass);
this.last_active = drop;
},
show: function(point, element) {
if(!this.drops.length) return;
var drop, affected = [];
this.drops.each( function(drop) {
if(Droppables.isAffected(point, element, drop))
affected.push(drop);
});
if(affected.length>0)
drop = Droppables.findDeepestChild(affected);
if(this.last_active && this.last_active != drop) this.deactivate(this.last_active);
if (drop) {
Position.within(drop.element, point[0], point[1]);
if(drop.onHover)
drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));
if (drop != this.last_active) Droppables.activate(drop);
}
},
fire: function(event, element) {
if(!this.last_active) return;
Position.prepare();
if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active))
if (this.last_active.onDrop) {
this.last_active.onDrop(element, this.last_active.element, event);
return true;
}
},
reset: function() {
if(this.last_active)
this.deactivate(this.last_active);
}
};
var Draggables = {
drags: [],
observers: [],
register: function(draggable) {
if(this.drags.length == 0) {
this.eventMouseUp = this.endDrag.bindAsEventListener(this);
this.eventMouseMove = this.updateDrag.bindAsEventListener(this);
this.eventKeypress = this.keyPress.bindAsEventListener(this);
Event.observe(document, "mouseup", this.eventMouseUp);
Event.observe(document, "mousemove", this.eventMouseMove);
Event.observe(document, "keypress", this.eventKeypress);
}
this.drags.push(draggable);
},
unregister: function(draggable) {
this.drags = this.drags.reject(function(d) { return d==draggable });
if(this.drags.length == 0) {
Event.stopObserving(document, "mouseup", this.eventMouseUp);
Event.stopObserving(document, "mousemove", this.eventMouseMove);
Event.stopObserving(document, "keypress", this.eventKeypress);
}
},
activate: function(draggable) {
if(draggable.options.delay) {
this._timeout = setTimeout(function() {
Draggables._timeout = null;
window.focus();
Draggables.activeDraggable = draggable;
}.bind(this), draggable.options.delay);
} else {
window.focus(); // allows keypress events if window isn't currently focused, fails for Safari
this.activeDraggable = draggable;
}
},
deactivate: function() {
this.activeDraggable = null;
},
updateDrag: function(event) {
if(!this.activeDraggable) return;
var pointer = [Event.pointerX(event), Event.pointerY(event)];
// Mozilla-based browsers fire successive mousemove events with
// the same coordinates, prevent needless redrawing (moz bug?)
if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return;
this._lastPointer = pointer;
this.activeDraggable.updateDrag(event, pointer);
},
endDrag: function(event) {
if(this._timeout) {
clearTimeout(this._timeout);
this._timeout = null;
}
if(!this.activeDraggable) return;
this._lastPointer = null;
this.activeDraggable.endDrag(event);
this.activeDraggable = null;
},
keyPress: function(event) {
if(this.activeDraggable)
this.activeDraggable.keyPress(event);
},
addObserver: function(observer) {
this.observers.push(observer);
this._cacheObserverCallbacks();
},
removeObserver: function(element) { // element instead of observer fixes mem leaks
this.observers = this.observers.reject( function(o) { return o.element==element });
this._cacheObserverCallbacks();
},
notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag'
if(this[eventName+'Count'] > 0)
this.observers.each( function(o) {
if(o[eventName]) o[eventName](eventName, draggable, event);
});
if(draggable.options[eventName]) draggable.options[eventName](draggable, event);
},
_cacheObserverCallbacks: function() {
['onStart','onEnd','onDrag'].each( function(eventName) {
Draggables[eventName+'Count'] = Draggables.observers.select(
function(o) { return o[eventName]; }
).length;
});
}
};
/*--------------------------------------------------------------------------*/
var Draggable = Class.create({
initialize: function(element) {
var defaults = {
handle: false,
reverteffect: function(element, top_offset, left_offset) {
var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02;
new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur,
queue: {scope:'_draggable', position:'end'}
});
},
endeffect: function(element) {
var toOpacity = Object.isNumber(element._opacity) ? element._opacity : 1.0;
new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
queue: {scope:'_draggable', position:'end'},
afterFinish: function(){
Draggable._dragging[element] = false
}
});
},
zindex: 1000,
revert: false,
quiet: false,
scroll: false,
scrollSensitivity: 20,
scrollSpeed: 15,
snap: false, // false, or xy or [x,y] or function(x,y){ return [x,y] }
delay: 0
};
if(!arguments[1] || Object.isUndefined(arguments[1].endeffect))
Object.extend(defaults, {
starteffect: function(element) {
element._opacity = Element.getOpacity(element);
Draggable._dragging[element] = true;
new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
}
});
var options = Object.extend(defaults, arguments[1] || { });
this.element = $(element);
if(options.handle && Object.isString(options.handle))
this.handle = this.element.down('.'+options.handle, 0);
if(!this.handle) this.handle = $(options.handle);
if(!this.handle) this.handle = this.element;
if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) {
options.scroll = $(options.scroll);
this._isScrollChild = Element.childOf(this.element, options.scroll);
}
Element.makePositioned(this.element); // fix IE
this.options = options;
this.dragging = false;
this.eventMouseDown = this.initDrag.bindAsEventListener(this);
Event.observe(this.handle, "mousedown", this.eventMouseDown);
Draggables.register(this);
},
destroy: function() {
Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
Draggables.unregister(this);
},
currentDelta: function() {
return([
parseInt(Element.getStyle(this.element,'left') || '0'),
parseInt(Element.getStyle(this.element,'top') || '0')]);
},
initDrag: function(event) {
if(!Object.isUndefined(Draggable._dragging[this.element]) &&
Draggable._dragging[this.element]) return;
if(Event.isLeftClick(event)) {
// abort on form elements, fixes a Firefox issue
var src = Event.element(event);
if((tag_name = src.tagName.toUpperCase()) && (
tag_name=='INPUT' ||
tag_name=='SELECT' ||
tag_name=='OPTION' ||
tag_name=='BUTTON' ||
tag_name=='TEXTAREA')) return;
var pointer = [Event.pointerX(event), Event.pointerY(event)];
var pos = this.element.cumulativeOffset();
this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) });
Draggables.activate(this);
Event.stop(event);
}
},
startDrag: function(event) {
this.dragging = true;
if(!this.delta)
this.delta = this.currentDelta();
if(this.options.zindex) {
this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
this.element.style.zIndex = this.options.zindex;
}
if(this.options.ghosting) {
this._clone = this.element.cloneNode(true);
this._originallyAbsolute = (this.element.getStyle('position') == 'absolute');
if (!this._originallyAbsolute)
Position.absolutize(this.element);
this.element.parentNode.insertBefore(this._clone, this.element);
}
if(this.options.scroll) {
if (this.options.scroll == window) {
var where = this._getWindowScroll(this.options.scroll);
this.originalScrollLeft = where.left;
this.originalScrollTop = where.top;
} else {
this.originalScrollLeft = this.options.scroll.scrollLeft;
this.originalScrollTop = this.options.scroll.scrollTop;
}
}
Draggables.notify('onStart', this, event);
if(this.options.starteffect) this.options.starteffect(this.element);
},
updateDrag: function(event, pointer) {
if(!this.dragging) this.startDrag(event);
if(!this.options.quiet){
Position.prepare();
Droppables.show(pointer, this.element);
}
Draggables.notify('onDrag', this, event);
this.draw(pointer);
if(this.options.change) this.options.change(this);
if(this.options.scroll) {
this.stopScrolling();
var p;
if (this.options.scroll == window) {
with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; }
} else {
p = Position.page(this.options.scroll);
p[0] += this.options.scroll.scrollLeft + Position.deltaX;
p[1] += this.options.scroll.scrollTop + Position.deltaY;
p.push(p[0]+this.options.scroll.offsetWidth);
p.push(p[1]+this.options.scroll.offsetHeight);
}
var speed = [0,0];
if(pointer[0] < (p[0]+this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[0]+this.options.scrollSensitivity);
if(pointer[1] < (p[1]+this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[1]+this.options.scrollSensitivity);
if(pointer[0] > (p[2]-this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[2]-this.options.scrollSensitivity);
if(pointer[1] > (p[3]-this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[3]-this.options.scrollSensitivity);
this.startScrolling(speed);
}
// fix AppleWebKit rendering
if(Prototype.Browser.WebKit) window.scrollBy(0,0);
Event.stop(event);
},
finishDrag: function(event, success) {
this.dragging = false;
if(this.options.quiet){
Position.prepare();
var pointer = [Event.pointerX(event), Event.pointerY(event)];
Droppables.show(pointer, this.element);
}
if(this.options.ghosting) {
if (!this._originallyAbsolute)
Position.relativize(this.element);
delete this._originallyAbsolute;
Element.remove(this._clone);
this._clone = null;
}
var dropped = false;
if(success) {
dropped = Droppables.fire(event, this.element);
if (!dropped) dropped = false;
}
if(dropped && this.options.onDropped) this.options.onDropped(this.element);
Draggables.notify('onEnd', this, event);
var revert = this.options.revert;
if(revert && Object.isFunction(revert)) revert = revert(this.element);
var d = this.currentDelta();
if(revert && this.options.reverteffect) {
if (dropped == 0 || revert != 'failure')
this.options.reverteffect(this.element,
d[1]-this.delta[1], d[0]-this.delta[0]);
} else {
this.delta = d;
}
if(this.options.zindex)
this.element.style.zIndex = this.originalZ;
if(this.options.endeffect)
this.options.endeffect(this.element);
Draggables.deactivate(this);
Droppables.reset();
},
keyPress: function(event) {
if(event.keyCode!=Event.KEY_ESC) return;
this.finishDrag(event, false);
Event.stop(event);
},
endDrag: function(event) {
if(!this.dragging) return;
this.stopScrolling();
this.finishDrag(event, true);
Event.stop(event);
},
draw: function(point) {
var pos = this.element.cumulativeOffset();
if(this.options.ghosting) {
var r = Position.realOffset(this.element);
pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY;
}
var d = this.currentDelta();
pos[0] -= d[0]; pos[1] -= d[1];
if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) {
pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft;
pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop;
}
var p = [0,1].map(function(i){
return (point[i]-pos[i]-this.offset[i])
}.bind(this));
if(this.options.snap) {
if(Object.isFunction(this.options.snap)) {
p = this.options.snap(p[0],p[1],this);
} else {
if(Object.isArray(this.options.snap)) {
p = p.map( function(v, i) {
return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this));
} else {
p = p.map( function(v) {
return (v/this.options.snap).round()*this.options.snap }.bind(this));
}
}}
var style = this.element.style;
if((!this.options.constraint) || (this.options.constraint=='horizontal'))
style.left = p[0] + "px";
if((!this.options.constraint) || (this.options.constraint=='vertical'))
style.top = p[1] + "px";
if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
},
stopScrolling: function() {
if(this.scrollInterval) {
clearInterval(this.scrollInterval);
this.scrollInterval = null;
Draggables._lastScrollPointer = null;
}
},
startScrolling: function(speed) {
if(!(speed[0] || speed[1])) return;
this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed];
this.lastScrolled = new Date();
this.scrollInterval = setInterval(this.scroll.bind(this), 10);
},
scroll: function() {
var current = new Date();
var delta = current - this.lastScrolled;
this.lastScrolled = current;
if(this.options.scroll == window) {
with (this._getWindowScroll(this.options.scroll)) {
if (this.scrollSpeed[0] || this.scrollSpeed[1]) {
var d = delta / 1000;
this.options.scroll.scrollTo( left + d*this.scrollSpeed[0], top + d*this.scrollSpeed[1] );
}
}
} else {
this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000;
this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1000;
}
Position.prepare();
Droppables.show(Draggables._lastPointer, this.element);
Draggables.notify('onDrag', this);
if (this._isScrollChild) {
Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer);
Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000;
Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000;
if (Draggables._lastScrollPointer[0] < 0)
Draggables._lastScrollPointer[0] = 0;
if (Draggables._lastScrollPointer[1] < 0)
Draggables._lastScrollPointer[1] = 0;
this.draw(Draggables._lastScrollPointer);
}
if(this.options.change) this.options.change(this);
},
_getWindowScroll: function(w) {
var T, L, W, H;
with (w.document) {
if (w.document.documentElement && documentElement.scrollTop) {
T = documentElement.scrollTop;
L = documentElement.scrollLeft;
} else if (w.document.body) {
T = body.scrollTop;
L = body.scrollLeft;
}
if (w.innerWidth) {
W = w.innerWidth;
H = w.innerHeight;
} else if (w.document.documentElement && documentElement.clientWidth) {
W = documentElement.clientWidth;
H = documentElement.clientHeight;
} else {
W = body.offsetWidth;
H = body.offsetHeight;
}
}
return { top: T, left: L, width: W, height: H };
}
});
Draggable._dragging = { };
/*--------------------------------------------------------------------------*/
var SortableObserver = Class.create({
initialize: function(element, observer) {
this.element = $(element);
this.observer = observer;
this.lastValue = Sortable.serialize(this.element);
},
onStart: function() {
this.lastValue = Sortable.serialize(this.element);
},
onEnd: function() {
Sortable.unmark();
if(this.lastValue != Sortable.serialize(this.element))
this.observer(this.element)
}
});
var Sortable = {
SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,
sortables: { },
_findRootElement: function(element) {
while (element.tagName.toUpperCase() != "BODY") {
if(element.id && Sortable.sortables[element.id]) return element;
element = element.parentNode;
}
},
options: function(element) {
element = Sortable._findRootElement($(element));
if(!element) return;
return Sortable.sortables[element.id];
},
destroy: function(element){
element = $(element);
var s = Sortable.sortables[element.id];
if(s) {
Draggables.removeObserver(s.element);
s.droppables.each(function(d){ Droppables.remove(d) });
s.draggables.invoke('destroy');
delete Sortable.sortables[s.element.id];
}
},
create: function(element) {
element = $(element);
var options = Object.extend({
element: element,
tag: 'li', // assumes li children, override with tag: 'tagname'
dropOnEmpty: false,
tree: false,
treeTag: 'ul',
overlap: 'vertical', // one of 'vertical', 'horizontal'
constraint: 'vertical', // one of 'vertical', 'horizontal', false
containment: element, // also takes array of elements (or id's); or false
handle: false, // or a CSS class
only: false,
delay: 0,
hoverclass: null,
ghosting: false,
quiet: false,
scroll: false,
scrollSensitivity: 20,
scrollSpeed: 15,
format: this.SERIALIZE_RULE,
// these take arrays of elements or ids and can be
// used for better initialization performance
elements: false,
handles: false,
onChange: Prototype.emptyFunction,
onUpdate: Prototype.emptyFunction
}, arguments[1] || { });
// clear any old sortable with same element
this.destroy(element);
// build options for the draggables
var options_for_draggable = {
revert: true,
quiet: options.quiet,
scroll: options.scroll,
scrollSpeed: options.scrollSpeed,
scrollSensitivity: options.scrollSensitivity,
delay: options.delay,
ghosting: options.ghosting,
constraint: options.constraint,
handle: options.handle };
if(options.starteffect)
options_for_draggable.starteffect = options.starteffect;
if(options.reverteffect)
options_for_draggable.reverteffect = options.reverteffect;
else
if(options.ghosting) options_for_draggable.reverteffect = function(element) {
element.style.top = 0;
element.style.left = 0;
};
if(options.endeffect)
options_for_draggable.endeffect = options.endeffect;
if(options.zindex)
options_for_draggable.zindex = options.zindex;
// build options for the droppables
var options_for_droppable = {
overlap: options.overlap,
containment: options.containment,
tree: options.tree,
hoverclass: options.hoverclass,
onHover: Sortable.onHover
};
var options_for_tree = {
onHover: Sortable.onEmptyHover,
overlap: options.overlap,
containment: options.containment,
hoverclass: options.hoverclass
};
// fix for gecko engine
Element.cleanWhitespace(element);
options.draggables = [];
options.droppables = [];
// drop on empty handling
if(options.dropOnEmpty || options.tree) {
Droppables.add(element, options_for_tree);
options.droppables.push(element);
}
(options.elements || this.findElements(element, options) || []).each( function(e,i) {
var handle = options.handles ? $(options.handles[i]) :
(options.handle ? $(e).select('.' + options.handle)[0] : e);
options.draggables.push(
new Draggable(e, Object.extend(options_for_draggable, { handle: handle })));
Droppables.add(e, options_for_droppable);
if(options.tree) e.treeNode = element;
options.droppables.push(e);
});
if(options.tree) {
(Sortable.findTreeElements(element, options) || []).each( function(e) {
Droppables.add(e, options_for_tree);
e.treeNode = element;
options.droppables.push(e);
});
}
// keep reference
this.sortables[element.identify()] = options;
// for onupdate
Draggables.addObserver(new SortableObserver(element, options.onUpdate));
},
// return all suitable-for-sortable elements in a guaranteed order
findElements: function(element, options) {
return Element.findChildren(
element, options.only, options.tree ? true : false, options.tag);
},
findTreeElements: function(element, options) {
return Element.findChildren(
element, options.only, options.tree ? true : false, options.treeTag);
},
onHover: function(element, dropon, overlap) {
if(Element.isParent(dropon, element)) return;
if(overlap > .33 && overlap < .66 && Sortable.options(dropon).tree) {
return;
} else if(overlap>0.5) {
Sortable.mark(dropon, 'before');
if(dropon.previousSibling != element) {
var oldParentNode = element.parentNode;
element.style.visibility = "hidden"; // fix gecko rendering
dropon.parentNode.insertBefore(element, dropon);
if(dropon.parentNode!=oldParentNode)
Sortable.options(oldParentNode).onChange(element);
Sortable.options(dropon.parentNode).onChange(element);
}
} else {
Sortable.mark(dropon, 'after');
var nextElement = dropon.nextSibling || null;
if(nextElement != element) {
var oldParentNode = element.parentNode;
element.style.visibility = "hidden"; // fix gecko rendering
dropon.parentNode.insertBefore(element, nextElement);
if(dropon.parentNode!=oldParentNode)
Sortable.options(oldParentNode).onChange(element);
Sortable.options(dropon.parentNode).onChange(element);
}
}
},
onEmptyHover: function(element, dropon, overlap) {
var oldParentNode = element.parentNode;
var droponOptions = Sortable.options(dropon);
if(!Element.isParent(dropon, element)) {
var index;
var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only});
var child = null;
if(children) {
var offset = Element.offsetSize(dropon, droponOptions.overlap) * (1.0 - overlap);
for (index = 0; index < children.length; index += 1) {
if (offset - Element.offsetSize (children[index], droponOptions.overlap) >= 0) {
offset -= Element.offsetSize (children[index], droponOptions.overlap);
} else if (offset - (Element.offsetSize (children[index], droponOptions.overlap) / 2) >= 0) {
child = index + 1 < children.length ? children[index + 1] : null;
break;
} else {
child = children[index];
break;
}
}
}
dropon.insertBefore(element, child);
Sortable.options(oldParentNode).onChange(element);
droponOptions.onChange(element);
}
},
unmark: function() {
if(Sortable._marker) Sortable._marker.hide();
},
mark: function(dropon, position) {
// mark on ghosting only
var sortable = Sortable.options(dropon.parentNode);
if(sortable && !sortable.ghosting) return;
if(!Sortable._marker) {
Sortable._marker =
($('dropmarker') || Element.extend(document.createElement('DIV'))).
hide().addClassName('dropmarker').setStyle({position:'absolute'});
document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);
}
var offsets = dropon.cumulativeOffset();
Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'});
if(position=='after')
if(sortable.overlap == 'horizontal')
Sortable._marker.setStyle({left: (offsets[0]+dropon.clientWidth) + 'px'});
else
Sortable._marker.setStyle({top: (offsets[1]+dropon.clientHeight) + 'px'});
Sortable._marker.show();
},
_tree: function(element, options, parent) {
var children = Sortable.findElements(element, options) || [];
for (var i = 0; i < children.length; ++i) {
var match = children[i].id.match(options.format);
if (!match) continue;
var child = {
id: encodeURIComponent(match ? match[1] : null),
element: element,
parent: parent,
children: [],
position: parent.children.length,
container: $(children[i]).down(options.treeTag)
};
/* Get the element containing the children and recurse over it */
if (child.container)
this._tree(child.container, options, child);
parent.children.push (child);
}
return parent;
},
tree: function(element) {
element = $(element);
var sortableOptions = this.options(element);
var options = Object.extend({
tag: sortableOptions.tag,
treeTag: sortableOptions.treeTag,
only: sortableOptions.only,
name: element.id,
format: sortableOptions.format
}, arguments[1] || { });
var root = {
id: null,
parent: null,
children: [],
container: element,
position: 0
};
return Sortable._tree(element, options, root);
},
/* Construct a [i] index for a particular node */
_constructIndex: function(node) {
var index = '';
do {
if (node.id) index = '[' + node.position + ']' + index;
} while ((node = node.parent) != null);
return index;
},
sequence: function(element) {
element = $(element);
var options = Object.extend(this.options(element), arguments[1] || { });
return $(this.findElements(element, options) || []).map( function(item) {
return item.id.match(options.format) ? item.id.match(options.format)[1] : '';
});
},
setSequence: function(element, new_sequence) {
element = $(element);
var options = Object.extend(this.options(element), arguments[2] || { });
var nodeMap = { };
this.findElements(element, options).each( function(n) {
if (n.id.match(options.format))
nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode];
n.parentNode.removeChild(n);
});
new_sequence.each(function(ident) {
var n = nodeMap[ident];
if (n) {
n[1].appendChild(n[0]);
delete nodeMap[ident];
}
});
},
serialize: function(element) {
element = $(element);
var options = Object.extend(Sortable.options(element), arguments[1] || { });
var name = encodeURIComponent(
(arguments[1] && arguments[1].name) ? arguments[1].name : element.id);
if (options.tree) {
return Sortable.tree(element, arguments[1]).children.map( function (item) {
return [name + Sortable._constructIndex(item) + "[id]=" +
encodeURIComponent(item.id)].concat(item.children.map(arguments.callee));
}).flatten().join('&');
} else {
return Sortable.sequence(element, arguments[1]).map( function(item) {
return name + "[]=" + encodeURIComponent(item);
}).join('&');
}
}
};
// Returns true if child is contained within element
Element.isParent = function(child, element) {
if (!child.parentNode || child == element) return false;
if (child.parentNode == element) return true;
return Element.isParent(child.parentNode, element);
};
Element.findChildren = function(element, only, recursive, tagName) {
if(!element.hasChildNodes()) return null;
tagName = tagName.toUpperCase();
if(only) only = [only].flatten();
var elements = [];
$A(element.childNodes).each( function(e) {
if(e.tagName && e.tagName.toUpperCase()==tagName &&
(!only || (Element.classNames(e).detect(function(v) { return only.include(v) }))))
elements.push(e);
if(recursive) {
var grandchildren = Element.findChildren(e, only, recursive, tagName);
if(grandchildren) elements.push(grandchildren);
}
});
return (elements.length>0 ? elements.flatten() : []);
};
Element.offsetSize = function (element, type) {
return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')];
};

1123
javascript/scoluos/src/effects.js vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,68 @@
// script.aculo.us scriptaculous.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// For details, see the script.aculo.us web site: http://script.aculo.us/
var Scriptaculous = {
Version: '1.8.3',
require: function(libraryName) {
try{
// inserting via DOM fails in Safari 2.0, so brute force approach
document.write('<script type="text/javascript" src="'+libraryName+'"><\/script>');
} catch(e) {
// for xhtml+xml served content, fall back to DOM methods
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = libraryName;
document.getElementsByTagName('head')[0].appendChild(script);
}
},
REQUIRED_PROTOTYPE: '1.6.0.3',
load: function() {
function convertVersionString(versionString) {
var v = versionString.replace(/_.*|\./g, '');
v = parseInt(v + '0'.times(4-v.length));
return versionString.indexOf('_') > -1 ? v-1 : v;
}
if((typeof Prototype=='undefined') ||
(typeof Element == 'undefined') ||
(typeof Element.Methods=='undefined') ||
(convertVersionString(Prototype.Version) <
convertVersionString(Scriptaculous.REQUIRED_PROTOTYPE)))
throw("script.aculo.us requires the Prototype JavaScript framework >= " +
Scriptaculous.REQUIRED_PROTOTYPE);
var js = /scriptaculous\.js(\?.*)?$/;
$$('head script[src]').findAll(function(s) {
return s.src.match(js);
}).each(function(s) {
var path = s.src.replace(js, ''),
includes = s.src.match(/\?.*load=([a-z,]*)/);
(includes ? includes[1] : 'builder,effects,dragdrop,controls,slider,sound').split(',').each(
function(include) { Scriptaculous.require(path+include+'.js') });
});
}
};
Scriptaculous.load();

275
javascript/scoluos/src/slider.js Executable file
View File

@@ -0,0 +1,275 @@
// script.aculo.us slider.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
// Copyright (c) 2005-2009 Marty Haught, Thomas Fuchs
//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
if (!Control) var Control = { };
// options:
// axis: 'vertical', or 'horizontal' (default)
//
// callbacks:
// onChange(value)
// onSlide(value)
Control.Slider = Class.create({
initialize: function(handle, track, options) {
var slider = this;
if (Object.isArray(handle)) {
this.handles = handle.collect( function(e) { return $(e) });
} else {
this.handles = [$(handle)];
}
this.track = $(track);
this.options = options || { };
this.axis = this.options.axis || 'horizontal';
this.increment = this.options.increment || 1;
this.step = parseInt(this.options.step || '1');
this.range = this.options.range || $R(0,1);
this.value = 0; // assure backwards compat
this.values = this.handles.map( function() { return 0 });
this.spans = this.options.spans ? this.options.spans.map(function(s){ return $(s) }) : false;
this.options.startSpan = $(this.options.startSpan || null);
this.options.endSpan = $(this.options.endSpan || null);
this.restricted = this.options.restricted || false;
this.maximum = this.options.maximum || this.range.end;
this.minimum = this.options.minimum || this.range.start;
// Will be used to align the handle onto the track, if necessary
this.alignX = parseInt(this.options.alignX || '0');
this.alignY = parseInt(this.options.alignY || '0');
this.trackLength = this.maximumOffset() - this.minimumOffset();
this.handleLength = this.isVertical() ?
(this.handles[0].offsetHeight != 0 ?
this.handles[0].offsetHeight : this.handles[0].style.height.replace(/px$/,"")) :
(this.handles[0].offsetWidth != 0 ? this.handles[0].offsetWidth :
this.handles[0].style.width.replace(/px$/,""));
this.active = false;
this.dragging = false;
this.disabled = false;
if (this.options.disabled) this.setDisabled();
// Allowed values array
this.allowedValues = this.options.values ? this.options.values.sortBy(Prototype.K) : false;
if (this.allowedValues) {
this.minimum = this.allowedValues.min();
this.maximum = this.allowedValues.max();
}
this.eventMouseDown = this.startDrag.bindAsEventListener(this);
this.eventMouseUp = this.endDrag.bindAsEventListener(this);
this.eventMouseMove = this.update.bindAsEventListener(this);
// Initialize handles in reverse (make sure first handle is active)
this.handles.each( function(h,i) {
i = slider.handles.length-1-i;
slider.setValue(parseFloat(
(Object.isArray(slider.options.sliderValue) ?
slider.options.sliderValue[i] : slider.options.sliderValue) ||
slider.range.start), i);
h.makePositioned().observe("mousedown", slider.eventMouseDown);
});
this.track.observe("mousedown", this.eventMouseDown);
document.observe("mouseup", this.eventMouseUp);
document.observe("mousemove", this.eventMouseMove);
this.initialized = true;
},
dispose: function() {
var slider = this;
Event.stopObserving(this.track, "mousedown", this.eventMouseDown);
Event.stopObserving(document, "mouseup", this.eventMouseUp);
Event.stopObserving(document, "mousemove", this.eventMouseMove);
this.handles.each( function(h) {
Event.stopObserving(h, "mousedown", slider.eventMouseDown);
});
},
setDisabled: function(){
this.disabled = true;
},
setEnabled: function(){
this.disabled = false;
},
getNearestValue: function(value){
if (this.allowedValues){
if (value >= this.allowedValues.max()) return(this.allowedValues.max());
if (value <= this.allowedValues.min()) return(this.allowedValues.min());
var offset = Math.abs(this.allowedValues[0] - value);
var newValue = this.allowedValues[0];
this.allowedValues.each( function(v) {
var currentOffset = Math.abs(v - value);
if (currentOffset <= offset){
newValue = v;
offset = currentOffset;
}
});
return newValue;
}
if (value > this.range.end) return this.range.end;
if (value < this.range.start) return this.range.start;
return value;
},
setValue: function(sliderValue, handleIdx){
if (!this.active) {
this.activeHandleIdx = handleIdx || 0;
this.activeHandle = this.handles[this.activeHandleIdx];
this.updateStyles();
}
handleIdx = handleIdx || this.activeHandleIdx || 0;
if (this.initialized && this.restricted) {
if ((handleIdx>0) && (sliderValue<this.values[handleIdx-1]))
sliderValue = this.values[handleIdx-1];
if ((handleIdx < (this.handles.length-1)) && (sliderValue>this.values[handleIdx+1]))
sliderValue = this.values[handleIdx+1];
}
sliderValue = this.getNearestValue(sliderValue);
this.values[handleIdx] = sliderValue;
this.value = this.values[0]; // assure backwards compat
this.handles[handleIdx].style[this.isVertical() ? 'top' : 'left'] =
this.translateToPx(sliderValue);
this.drawSpans();
if (!this.dragging || !this.event) this.updateFinished();
},
setValueBy: function(delta, handleIdx) {
this.setValue(this.values[handleIdx || this.activeHandleIdx || 0] + delta,
handleIdx || this.activeHandleIdx || 0);
},
translateToPx: function(value) {
return Math.round(
((this.trackLength-this.handleLength)/(this.range.end-this.range.start)) *
(value - this.range.start)) + "px";
},
translateToValue: function(offset) {
return ((offset/(this.trackLength-this.handleLength) *
(this.range.end-this.range.start)) + this.range.start);
},
getRange: function(range) {
var v = this.values.sortBy(Prototype.K);
range = range || 0;
return $R(v[range],v[range+1]);
},
minimumOffset: function(){
return(this.isVertical() ? this.alignY : this.alignX);
},
maximumOffset: function(){
return(this.isVertical() ?
(this.track.offsetHeight != 0 ? this.track.offsetHeight :
this.track.style.height.replace(/px$/,"")) - this.alignY :
(this.track.offsetWidth != 0 ? this.track.offsetWidth :
this.track.style.width.replace(/px$/,"")) - this.alignX);
},
isVertical: function(){
return (this.axis == 'vertical');
},
drawSpans: function() {
var slider = this;
if (this.spans)
$R(0, this.spans.length-1).each(function(r) { slider.setSpan(slider.spans[r], slider.getRange(r)) });
if (this.options.startSpan)
this.setSpan(this.options.startSpan,
$R(0, this.values.length>1 ? this.getRange(0).min() : this.value ));
if (this.options.endSpan)
this.setSpan(this.options.endSpan,
$R(this.values.length>1 ? this.getRange(this.spans.length-1).max() : this.value, this.maximum));
},
setSpan: function(span, range) {
if (this.isVertical()) {
span.style.top = this.translateToPx(range.start);
span.style.height = this.translateToPx(range.end - range.start + this.range.start);
} else {
span.style.left = this.translateToPx(range.start);
span.style.width = this.translateToPx(range.end - range.start + this.range.start);
}
},
updateStyles: function() {
this.handles.each( function(h){ Element.removeClassName(h, 'selected') });
Element.addClassName(this.activeHandle, 'selected');
},
startDrag: function(event) {
if (Event.isLeftClick(event)) {
if (!this.disabled){
this.active = true;
var handle = Event.element(event);
var pointer = [Event.pointerX(event), Event.pointerY(event)];
var track = handle;
if (track==this.track) {
var offsets = this.track.cumulativeOffset();
this.event = event;
this.setValue(this.translateToValue(
(this.isVertical() ? pointer[1]-offsets[1] : pointer[0]-offsets[0])-(this.handleLength/2)
));
var offsets = this.activeHandle.cumulativeOffset();
this.offsetX = (pointer[0] - offsets[0]);
this.offsetY = (pointer[1] - offsets[1]);
} else {
// find the handle (prevents issues with Safari)
while((this.handles.indexOf(handle) == -1) && handle.parentNode)
handle = handle.parentNode;
if (this.handles.indexOf(handle)!=-1) {
this.activeHandle = handle;
this.activeHandleIdx = this.handles.indexOf(this.activeHandle);
this.updateStyles();
var offsets = this.activeHandle.cumulativeOffset();
this.offsetX = (pointer[0] - offsets[0]);
this.offsetY = (pointer[1] - offsets[1]);
}
}
}
Event.stop(event);
}
},
update: function(event) {
if (this.active) {
if (!this.dragging) this.dragging = true;
this.draw(event);
if (Prototype.Browser.WebKit) window.scrollBy(0,0);
Event.stop(event);
}
},
draw: function(event) {
var pointer = [Event.pointerX(event), Event.pointerY(event)];
var offsets = this.track.cumulativeOffset();
pointer[0] -= this.offsetX + offsets[0];
pointer[1] -= this.offsetY + offsets[1];
this.event = event;
this.setValue(this.translateToValue( this.isVertical() ? pointer[1] : pointer[0] ));
if (this.initialized && this.options.onSlide)
this.options.onSlide(this.values.length>1 ? this.values : this.value, this);
},
endDrag: function(event) {
if (this.active && this.dragging) {
this.finishDrag(event, true);
Event.stop(event);
}
this.active = false;
this.dragging = false;
},
finishDrag: function(event, success) {
this.active = false;
this.dragging = false;
this.updateFinished();
},
updateFinished: function() {
if (this.initialized && this.options.onChange)
this.options.onChange(this.values.length>1 ? this.values : this.value, this);
this.event = null;
}
});

59
javascript/scoluos/src/sound.js Executable file
View File

@@ -0,0 +1,59 @@
// script.aculo.us sound.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//
// Based on code created by Jules Gravinese (http://www.webveteran.com/)
//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
Sound = {
tracks: {},
_enabled: true,
template:
new Template('<embed style="height:0" id="sound_#{track}_#{id}" src="#{url}" loop="false" autostart="true" hidden="true"/>'),
enable: function(){
Sound._enabled = true;
},
disable: function(){
Sound._enabled = false;
},
play: function(url){
if(!Sound._enabled) return;
var options = Object.extend({
track: 'global', url: url, replace: false
}, arguments[1] || {});
if(options.replace && this.tracks[options.track]) {
$R(0, this.tracks[options.track].id).each(function(id){
var sound = $('sound_'+options.track+'_'+id);
sound.Stop && sound.Stop();
sound.remove();
});
this.tracks[options.track] = null;
}
if(!this.tracks[options.track])
this.tracks[options.track] = { id: 0 };
else
this.tracks[options.track].id++;
options.id = this.tracks[options.track].id;
$$('body')[0].insert(
Prototype.Browser.IE ? new Element('bgsound',{
id: 'sound_'+options.track+'_'+options.id,
src: options.url, loop: 1, autostart: true
}) : Sound.template.evaluate(options));
}
};
if(Prototype.Browser.Gecko && navigator.userAgent.indexOf("Win") > 0){
if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('QuickTime') != -1 }))
Sound.template = new Template('<object id="sound_#{track}_#{id}" width="0" height="0" type="audio/mpeg" data="#{url}"/>');
else if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('Windows Media') != -1 }))
Sound.template = new Template('<object id="sound_#{track}_#{id}" type="application/x-mplayer2" data="#{url}"></object>');
else if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('RealPlayer') != -1 }))
Sound.template = new Template('<embed type="audio/x-pn-realaudio-plugin" style="height:0" id="sound_#{track}_#{id}" src="#{url}" loop="false" autostart="true" hidden="true"/>');
else
Sound.play = function(){};
}

View File

@@ -0,0 +1,568 @@
// script.aculo.us unittest.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// (c) 2005-2009 Jon Tirsen (http://www.tirsen.com)
// (c) 2005-2009 Michael Schuerig (http://www.schuerig.de/michael/)
//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
// experimental, Firefox-only
Event.simulateMouse = function(element, eventName) {
var options = Object.extend({
pointerX: 0,
pointerY: 0,
buttons: 0,
ctrlKey: false,
altKey: false,
shiftKey: false,
metaKey: false
}, arguments[2] || {});
var oEvent = document.createEvent("MouseEvents");
oEvent.initMouseEvent(eventName, true, true, document.defaultView,
options.buttons, options.pointerX, options.pointerY, options.pointerX, options.pointerY,
options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, 0, $(element));
if(this.mark) Element.remove(this.mark);
this.mark = document.createElement('div');
this.mark.appendChild(document.createTextNode(" "));
document.body.appendChild(this.mark);
this.mark.style.position = 'absolute';
this.mark.style.top = options.pointerY + "px";
this.mark.style.left = options.pointerX + "px";
this.mark.style.width = "5px";
this.mark.style.height = "5px;";
this.mark.style.borderTop = "1px solid red;";
this.mark.style.borderLeft = "1px solid red;";
if(this.step)
alert('['+new Date().getTime().toString()+'] '+eventName+'/'+Test.Unit.inspect(options));
$(element).dispatchEvent(oEvent);
};
// Note: Due to a fix in Firefox 1.0.5/6 that probably fixed "too much", this doesn't work in 1.0.6 or DP2.
// You need to downgrade to 1.0.4 for now to get this working
// See https://bugzilla.mozilla.org/show_bug.cgi?id=289940 for the fix that fixed too much
Event.simulateKey = function(element, eventName) {
var options = Object.extend({
ctrlKey: false,
altKey: false,
shiftKey: false,
metaKey: false,
keyCode: 0,
charCode: 0
}, arguments[2] || {});
var oEvent = document.createEvent("KeyEvents");
oEvent.initKeyEvent(eventName, true, true, window,
options.ctrlKey, options.altKey, options.shiftKey, options.metaKey,
options.keyCode, options.charCode );
$(element).dispatchEvent(oEvent);
};
Event.simulateKeys = function(element, command) {
for(var i=0; i<command.length; i++) {
Event.simulateKey(element,'keypress',{charCode:command.charCodeAt(i)});
}
};
var Test = {};
Test.Unit = {};
// security exception workaround
Test.Unit.inspect = Object.inspect;
Test.Unit.Logger = Class.create();
Test.Unit.Logger.prototype = {
initialize: function(log) {
this.log = $(log);
if (this.log) {
this._createLogTable();
}
},
start: function(testName) {
if (!this.log) return;
this.testName = testName;
this.lastLogLine = document.createElement('tr');
this.statusCell = document.createElement('td');
this.nameCell = document.createElement('td');
this.nameCell.className = "nameCell";
this.nameCell.appendChild(document.createTextNode(testName));
this.messageCell = document.createElement('td');
this.lastLogLine.appendChild(this.statusCell);
this.lastLogLine.appendChild(this.nameCell);
this.lastLogLine.appendChild(this.messageCell);
this.loglines.appendChild(this.lastLogLine);
},
finish: function(status, summary) {
if (!this.log) return;
this.lastLogLine.className = status;
this.statusCell.innerHTML = status;
this.messageCell.innerHTML = this._toHTML(summary);
this.addLinksToResults();
},
message: function(message) {
if (!this.log) return;
this.messageCell.innerHTML = this._toHTML(message);
},
summary: function(summary) {
if (!this.log) return;
this.logsummary.innerHTML = this._toHTML(summary);
},
_createLogTable: function() {
this.log.innerHTML =
'<div id="logsummary"></div>' +
'<table id="logtable">' +
'<thead><tr><th>Status</th><th>Test</th><th>Message</th></tr></thead>' +
'<tbody id="loglines"></tbody>' +
'</table>';
this.logsummary = $('logsummary');
this.loglines = $('loglines');
},
_toHTML: function(txt) {
return txt.escapeHTML().replace(/\n/g,"<br/>");
},
addLinksToResults: function(){
$$("tr.failed .nameCell").each( function(td){ // todo: limit to children of this.log
td.title = "Run only this test";
Event.observe(td, 'click', function(){ window.location.search = "?tests=" + td.innerHTML;});
});
$$("tr.passed .nameCell").each( function(td){ // todo: limit to children of this.log
td.title = "Run all tests";
Event.observe(td, 'click', function(){ window.location.search = "";});
});
}
};
Test.Unit.Runner = Class.create();
Test.Unit.Runner.prototype = {
initialize: function(testcases) {
this.options = Object.extend({
testLog: 'testlog'
}, arguments[1] || {});
this.options.resultsURL = this.parseResultsURLQueryParameter();
this.options.tests = this.parseTestsQueryParameter();
if (this.options.testLog) {
this.options.testLog = $(this.options.testLog) || null;
}
if(this.options.tests) {
this.tests = [];
for(var i = 0; i < this.options.tests.length; i++) {
if(/^test/.test(this.options.tests[i])) {
this.tests.push(new Test.Unit.Testcase(this.options.tests[i], testcases[this.options.tests[i]], testcases["setup"], testcases["teardown"]));
}
}
} else {
if (this.options.test) {
this.tests = [new Test.Unit.Testcase(this.options.test, testcases[this.options.test], testcases["setup"], testcases["teardown"])];
} else {
this.tests = [];
for(var testcase in testcases) {
if(/^test/.test(testcase)) {
this.tests.push(
new Test.Unit.Testcase(
this.options.context ? ' -> ' + this.options.titles[testcase] : testcase,
testcases[testcase], testcases["setup"], testcases["teardown"]
));
}
}
}
}
this.currentTest = 0;
this.logger = new Test.Unit.Logger(this.options.testLog);
setTimeout(this.runTests.bind(this), 1000);
},
parseResultsURLQueryParameter: function() {
return window.location.search.parseQuery()["resultsURL"];
},
parseTestsQueryParameter: function(){
if (window.location.search.parseQuery()["tests"]){
return window.location.search.parseQuery()["tests"].split(',');
};
},
// Returns:
// "ERROR" if there was an error,
// "FAILURE" if there was a failure, or
// "SUCCESS" if there was neither
getResult: function() {
var hasFailure = false;
for(var i=0;i<this.tests.length;i++) {
if (this.tests[i].errors > 0) {
return "ERROR";
}
if (this.tests[i].failures > 0) {
hasFailure = true;
}
}
if (hasFailure) {
return "FAILURE";
} else {
return "SUCCESS";
}
},
postResults: function() {
if (this.options.resultsURL) {
new Ajax.Request(this.options.resultsURL,
{ method: 'get', parameters: 'result=' + this.getResult(), asynchronous: false });
}
},
runTests: function() {
var test = this.tests[this.currentTest];
if (!test) {
// finished!
this.postResults();
this.logger.summary(this.summary());
return;
}
if(!test.isWaiting) {
this.logger.start(test.name);
}
test.run();
if(test.isWaiting) {
this.logger.message("Waiting for " + test.timeToWait + "ms");
setTimeout(this.runTests.bind(this), test.timeToWait || 1000);
} else {
this.logger.finish(test.status(), test.summary());
this.currentTest++;
// tail recursive, hopefully the browser will skip the stackframe
this.runTests();
}
},
summary: function() {
var assertions = 0;
var failures = 0;
var errors = 0;
var messages = [];
for(var i=0;i<this.tests.length;i++) {
assertions += this.tests[i].assertions;
failures += this.tests[i].failures;
errors += this.tests[i].errors;
}
return (
(this.options.context ? this.options.context + ': ': '') +
this.tests.length + " tests, " +
assertions + " assertions, " +
failures + " failures, " +
errors + " errors");
}
};
Test.Unit.Assertions = Class.create();
Test.Unit.Assertions.prototype = {
initialize: function() {
this.assertions = 0;
this.failures = 0;
this.errors = 0;
this.messages = [];
},
summary: function() {
return (
this.assertions + " assertions, " +
this.failures + " failures, " +
this.errors + " errors" + "\n" +
this.messages.join("\n"));
},
pass: function() {
this.assertions++;
},
fail: function(message) {
this.failures++;
this.messages.push("Failure: " + message);
},
info: function(message) {
this.messages.push("Info: " + message);
},
error: function(error) {
this.errors++;
this.messages.push(error.name + ": "+ error.message + "(" + Test.Unit.inspect(error) +")");
},
status: function() {
if (this.failures > 0) return 'failed';
if (this.errors > 0) return 'error';
return 'passed';
},
assert: function(expression) {
var message = arguments[1] || 'assert: got "' + Test.Unit.inspect(expression) + '"';
try { expression ? this.pass() :
this.fail(message); }
catch(e) { this.error(e); }
},
assertEqual: function(expected, actual) {
var message = arguments[2] || "assertEqual";
try { (expected == actual) ? this.pass() :
this.fail(message + ': expected "' + Test.Unit.inspect(expected) +
'", actual "' + Test.Unit.inspect(actual) + '"'); }
catch(e) { this.error(e); }
},
assertInspect: function(expected, actual) {
var message = arguments[2] || "assertInspect";
try { (expected == actual.inspect()) ? this.pass() :
this.fail(message + ': expected "' + Test.Unit.inspect(expected) +
'", actual "' + Test.Unit.inspect(actual) + '"'); }
catch(e) { this.error(e); }
},
assertEnumEqual: function(expected, actual) {
var message = arguments[2] || "assertEnumEqual";
try { $A(expected).length == $A(actual).length &&
expected.zip(actual).all(function(pair) { return pair[0] == pair[1] }) ?
this.pass() : this.fail(message + ': expected ' + Test.Unit.inspect(expected) +
', actual ' + Test.Unit.inspect(actual)); }
catch(e) { this.error(e); }
},
assertNotEqual: function(expected, actual) {
var message = arguments[2] || "assertNotEqual";
try { (expected != actual) ? this.pass() :
this.fail(message + ': got "' + Test.Unit.inspect(actual) + '"'); }
catch(e) { this.error(e); }
},
assertIdentical: function(expected, actual) {
var message = arguments[2] || "assertIdentical";
try { (expected === actual) ? this.pass() :
this.fail(message + ': expected "' + Test.Unit.inspect(expected) +
'", actual "' + Test.Unit.inspect(actual) + '"'); }
catch(e) { this.error(e); }
},
assertNotIdentical: function(expected, actual) {
var message = arguments[2] || "assertNotIdentical";
try { !(expected === actual) ? this.pass() :
this.fail(message + ': expected "' + Test.Unit.inspect(expected) +
'", actual "' + Test.Unit.inspect(actual) + '"'); }
catch(e) { this.error(e); }
},
assertNull: function(obj) {
var message = arguments[1] || 'assertNull';
try { (obj==null) ? this.pass() :
this.fail(message + ': got "' + Test.Unit.inspect(obj) + '"'); }
catch(e) { this.error(e); }
},
assertMatch: function(expected, actual) {
var message = arguments[2] || 'assertMatch';
var regex = new RegExp(expected);
try { (regex.exec(actual)) ? this.pass() :
this.fail(message + ' : regex: "' + Test.Unit.inspect(expected) + ' did not match: ' + Test.Unit.inspect(actual) + '"'); }
catch(e) { this.error(e); }
},
assertHidden: function(element) {
var message = arguments[1] || 'assertHidden';
this.assertEqual("none", element.style.display, message);
},
assertNotNull: function(object) {
var message = arguments[1] || 'assertNotNull';
this.assert(object != null, message);
},
assertType: function(expected, actual) {
var message = arguments[2] || 'assertType';
try {
(actual.constructor == expected) ? this.pass() :
this.fail(message + ': expected "' + Test.Unit.inspect(expected) +
'", actual "' + (actual.constructor) + '"'); }
catch(e) { this.error(e); }
},
assertNotOfType: function(expected, actual) {
var message = arguments[2] || 'assertNotOfType';
try {
(actual.constructor != expected) ? this.pass() :
this.fail(message + ': expected "' + Test.Unit.inspect(expected) +
'", actual "' + (actual.constructor) + '"'); }
catch(e) { this.error(e); }
},
assertInstanceOf: function(expected, actual) {
var message = arguments[2] || 'assertInstanceOf';
try {
(actual instanceof expected) ? this.pass() :
this.fail(message + ": object was not an instance of the expected type"); }
catch(e) { this.error(e); }
},
assertNotInstanceOf: function(expected, actual) {
var message = arguments[2] || 'assertNotInstanceOf';
try {
!(actual instanceof expected) ? this.pass() :
this.fail(message + ": object was an instance of the not expected type"); }
catch(e) { this.error(e); }
},
assertRespondsTo: function(method, obj) {
var message = arguments[2] || 'assertRespondsTo';
try {
(obj[method] && typeof obj[method] == 'function') ? this.pass() :
this.fail(message + ": object doesn't respond to [" + method + "]"); }
catch(e) { this.error(e); }
},
assertReturnsTrue: function(method, obj) {
var message = arguments[2] || 'assertReturnsTrue';
try {
var m = obj[method];
if(!m) m = obj['is'+method.charAt(0).toUpperCase()+method.slice(1)];
m() ? this.pass() :
this.fail(message + ": method returned false"); }
catch(e) { this.error(e); }
},
assertReturnsFalse: function(method, obj) {
var message = arguments[2] || 'assertReturnsFalse';
try {
var m = obj[method];
if(!m) m = obj['is'+method.charAt(0).toUpperCase()+method.slice(1)];
!m() ? this.pass() :
this.fail(message + ": method returned true"); }
catch(e) { this.error(e); }
},
assertRaise: function(exceptionName, method) {
var message = arguments[2] || 'assertRaise';
try {
method();
this.fail(message + ": exception expected but none was raised"); }
catch(e) {
((exceptionName == null) || (e.name==exceptionName)) ? this.pass() : this.error(e);
}
},
assertElementsMatch: function() {
var expressions = $A(arguments), elements = $A(expressions.shift());
if (elements.length != expressions.length) {
this.fail('assertElementsMatch: size mismatch: ' + elements.length + ' elements, ' + expressions.length + ' expressions');
return false;
}
elements.zip(expressions).all(function(pair, index) {
var element = $(pair.first()), expression = pair.last();
if (element.match(expression)) return true;
this.fail('assertElementsMatch: (in index ' + index + ') expected ' + expression.inspect() + ' but got ' + element.inspect());
}.bind(this)) && this.pass();
},
assertElementMatches: function(element, expression) {
this.assertElementsMatch([element], expression);
},
benchmark: function(operation, iterations) {
var startAt = new Date();
(iterations || 1).times(operation);
var timeTaken = ((new Date())-startAt);
this.info((arguments[2] || 'Operation') + ' finished ' +
iterations + ' iterations in ' + (timeTaken/1000)+'s' );
return timeTaken;
},
_isVisible: function(element) {
element = $(element);
if(!element.parentNode) return true;
this.assertNotNull(element);
if(element.style && Element.getStyle(element, 'display') == 'none')
return false;
return this._isVisible(element.parentNode);
},
assertNotVisible: function(element) {
this.assert(!this._isVisible(element), Test.Unit.inspect(element) + " was not hidden and didn't have a hidden parent either. " + ("" || arguments[1]));
},
assertVisible: function(element) {
this.assert(this._isVisible(element), Test.Unit.inspect(element) + " was not visible. " + ("" || arguments[1]));
},
benchmark: function(operation, iterations) {
var startAt = new Date();
(iterations || 1).times(operation);
var timeTaken = ((new Date())-startAt);
this.info((arguments[2] || 'Operation') + ' finished ' +
iterations + ' iterations in ' + (timeTaken/1000)+'s' );
return timeTaken;
}
};
Test.Unit.Testcase = Class.create();
Object.extend(Object.extend(Test.Unit.Testcase.prototype, Test.Unit.Assertions.prototype), {
initialize: function(name, test, setup, teardown) {
Test.Unit.Assertions.prototype.initialize.bind(this)();
this.name = name;
if(typeof test == 'string') {
test = test.gsub(/(\.should[^\(]+\()/,'#{0}this,');
test = test.gsub(/(\.should[^\(]+)\(this,\)/,'#{1}(this)');
this.test = function() {
eval('with(this){'+test+'}');
}
} else {
this.test = test || function() {};
}
this.setup = setup || function() {};
this.teardown = teardown || function() {};
this.isWaiting = false;
this.timeToWait = 1000;
},
wait: function(time, nextPart) {
this.isWaiting = true;
this.test = nextPart;
this.timeToWait = time;
},
run: function() {
try {
try {
if (!this.isWaiting) this.setup.bind(this)();
this.isWaiting = false;
this.test.bind(this)();
} finally {
if(!this.isWaiting) {
this.teardown.bind(this)();
}
}
}
catch(e) { this.error(e); }
}
});
// *EXPERIMENTAL* BDD-style testing to please non-technical folk
// This draws many ideas from RSpec http://rspec.rubyforge.org/
Test.setupBDDExtensionMethods = function(){
var METHODMAP = {
shouldEqual: 'assertEqual',
shouldNotEqual: 'assertNotEqual',
shouldEqualEnum: 'assertEnumEqual',
shouldBeA: 'assertType',
shouldNotBeA: 'assertNotOfType',
shouldBeAn: 'assertType',
shouldNotBeAn: 'assertNotOfType',
shouldBeNull: 'assertNull',
shouldNotBeNull: 'assertNotNull',
shouldBe: 'assertReturnsTrue',
shouldNotBe: 'assertReturnsFalse',
shouldRespondTo: 'assertRespondsTo'
};
var makeAssertion = function(assertion, args, object) {
this[assertion].apply(this,(args || []).concat([object]));
};
Test.BDDMethods = {};
$H(METHODMAP).each(function(pair) {
Test.BDDMethods[pair.key] = function() {
var args = $A(arguments);
var scope = args.shift();
makeAssertion.apply(scope, [pair.value, args, this]); };
});
[Array.prototype, String.prototype, Number.prototype, Boolean.prototype].each(
function(p){ Object.extend(p, Test.BDDMethods) }
);
};
Test.context = function(name, spec, log){
Test.setupBDDExtensionMethods();
var compiledSpec = {};
var titles = {};
for(specName in spec) {
switch(specName){
case "setup":
case "teardown":
compiledSpec[specName] = spec[specName];
break;
default:
var testName = 'test'+specName.gsub(/\s+/,'-').camelize();
var body = spec[specName].toString().split('\n').slice(1);
if(/^\{/.test(body[0])) body = body.slice(1);
body.pop();
body = body.map(function(statement){
return statement.strip()
});
compiledSpec[testName] = body.join('\n');
titles[testName] = specName;
}
}
new Test.Unit.Runner(compiledSpec, { titles: titles, testLog: log || 'testlog', context: name });
};

View File

@@ -0,0 +1 @@
Server received: To be edited

View File

@@ -0,0 +1 @@
Text from server

View File

@@ -0,0 +1,9 @@
<ul>
<li>test1<span class="selectme">selectme1</span></li><li><span class="selectme">selectme2</span>test2</li>
<li>test3<span class="selectme">selectme3</span></li>
<li><b>BOLD</b><span class="selectme">selectme4<b>boldinselectme</b></span></li>
<li><span class="informal">(GET ME NOT)</span>(GET &lt;ME&gt; INSTEAD)<span class="selectme">(forselectme!)</span></li>
<li><span class="selectme">Here we have <a href="_autocomplete_result.html">a link</a> which should work</span></li>
</ul>

View File

@@ -0,0 +1,3 @@
<ul>
<li>test1<span class="selectme">selectme1</span></li>
</ul>

Some files were not shown because too many files have changed in this diff Show More