149 lines
3.3 KiB
JavaScript
Executable File
149 lines
3.3 KiB
JavaScript
Executable File
var DOC_ROOT = "../";
|
|
var DOC_ROOT_TRUE = "../";
|
|
var DOC_ROOT_SECTION = "../../";
|
|
var WEB_ROOT = document.location.origin;
|
|
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";
|
|
console.log("AJAX Response:", response);
|
|
var splitResponse = response.split("[#]");
|
|
var status = splitResponse[splitResponse.length - 1]; // Get the last part as status
|
|
var message = splitResponse[0]; // Get the first part as message
|
|
|
|
if(status == "ok")
|
|
{
|
|
Redirect('/homepage');
|
|
}
|
|
else
|
|
{
|
|
ShowStatus(message); // Display the actual message
|
|
}
|
|
},
|
|
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');
|
|
}
|