Created
February 13, 2014 10:53
-
-
Save viniciusss/8973128 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JavaScript Document | |
function atualizaJanela() { | |
// caso n haja frame ou janela thickbox, atualizo janela | |
if (($('#TB_window').size() == 0) && ("" == $('#divFrame').html())) { | |
// variaveis | |
var params = 'f_int_storeno=' + $('input[name="storeno"]').val(); | |
params = params + '&f_int_ordno=' + $('input[name="ordno"]').val(); | |
// pego a url | |
var patchLength = (window.location.href.indexOf('.php') + 4); | |
url = window.location.href.substring(0, patchLength) + '?' + params; | |
// bloqueio | |
tb_show_block(); | |
// atualizo | |
window.location.href = url; | |
} | |
// chamo funcao de atualizacao novamente, com atrazo de 5 seg | |
else | |
setTimeout(atualizaJanela, 5000); | |
} | |
function verificaTituloCampo() { | |
// Pego o campo | |
var patchLength = ($('#frame_uso').attr('src').indexOf('.php') + 4); | |
var urlFrame = $('#frame_uso').attr('src').substring(0, patchLength); | |
patchLength = (window.parent.frame_uso.location.href.indexOf('.php') + 4); | |
var urlAtual = window.parent.frame_uso.location.href.substring(0, patchLength); | |
var cssButton; | |
// Verifico se é igual | |
if ((urlFrame == urlAtual) || ("" == urlAtual)) { | |
cssButton = { | |
'margin-left': '385px', | |
'float': 'left', | |
'color': '#FF0000' | |
} | |
// Pego os campos | |
var buttons = $('button.ui-button'); | |
var span = $('span.ui-button-text'); | |
$(buttons[0]).css(cssButton); | |
$(span[0]).html("Tela Principal"); | |
} | |
else if (('abo' == urlAtual)) { | |
cssButton = { | |
'margin-left': '385px', | |
'float': 'left', | |
'color': '#FF0000' | |
} | |
// Pego os campos | |
var buttons = $('button.ui-button'); | |
var span = $('span.ui-button-text'); | |
$(buttons[0]).css(cssButton); | |
$(span[0]).html("Tela Principal"); | |
} | |
else { | |
cssButton = { | |
'margin-left': '385px', | |
'float': 'left', | |
'color': '#000' | |
} | |
// Pego os campos | |
buttons = $('button.ui-button'); | |
span = $('span.ui-button-text'); | |
$(buttons[0]).css(cssButton); | |
$(span[0]).html("Retornar a Tela Principal"); | |
} | |
return setTimeout(verificaTituloCampo, 500); | |
} | |
function acaoFaturamento(e) { | |
if ("" != $(this).attr("acao") && "devolver" != $(this).attr("acao")) { | |
// Montar URL | |
url = 'f_int_storeno=' + $('#storeno').val() + '&f_int_ordno=' + $('#ordno').val(); | |
url += '&f_int_id_pedido_entrega=' + $(this).attr('idPedidoEntrega') + '&f_str_acao=' + $(this).attr('acao'); | |
// Caso tenha pre-venda | |
if (0 != $(this).attr('idPreVenda')) | |
url += '&f_int_id_pre_venda=' + $(this).attr('idPreVenda'); | |
tb_show_block(); | |
// Chamda ao ajax | |
$.post('../includes/ajax/vendasAtendimentoFaturamento.ajax.php?' + url, | |
// Retorno | |
function(data) { | |
alertaV(data.msg, data.classe, window.location.href), | |
// desbloqueio de tela | |
tb_remove(); | |
}, "json"); | |
} | |
} | |
function aguardarPgtoBoleto(e) { | |
e.preventDefault(); | |
tb_show_block(); | |
$.ajax({ | |
url: "/webpdv/includes/ajax/vendasAtendimentoAguardarPgtoBoleto.php", | |
data: "f_int_storeno=" + $('input[name="storeno"]').val() + "&f_int_ordno=" + $('input[name="ordno"]').val(), | |
dataType: "json", | |
success: function (data) { | |
if ("acerto" === data.classe) | |
alertaV(data.msg, data.classe, "fila_atendimento.php"); | |
else | |
alertaV(data.msg, data.classe); | |
tb_remove(); | |
} | |
}); | |
} | |
// dom ready | |
$(document).ready(function () { | |
contagemRegressivaAtendimento($('#storeno').val(), $('#ordno').val(), $("#contadorRegressivo").attr("tempoRestante"), $("#contadorRegressivo")); | |
$(".acao").click(acaoFaturamento); | |
// tempo de atualizacao 1 min | |
var tempo = 60000; | |
// chamo funcao de atualizacao, com atrazo de 1 minuto | |
//setTimeout(atualizaJanela,tempo); | |
$("#divFrame").dialog({ | |
autoOpen: false, | |
height: 510, | |
width: 900, | |
modal: true, | |
title: $("#uso").attr('title'), | |
draggable: false, | |
resizable: false, | |
close: function () { | |
// Url | |
var params = 'f_int_storeno=' + $('#storeno').val(); | |
params = params + '&f_int_ordno=' + $('#ordno').val(); | |
// pego a url | |
var patchLength = (window.location.href.indexOf('.php') + 4); | |
url = window.location.href.substring(0, patchLength) + '?' + params; | |
// atualizo | |
window.location.href = url; | |
}, | |
open: function () { | |
var cssButton = { | |
'margin-left': '385px', | |
'float': 'left', | |
'color': '#FF0000' | |
}; | |
var buttons = $('button.ui-button'); | |
$(buttons[0]).css(cssButton); | |
$('button.ui-button').css('float', 'left'); | |
// Verifico de 1 em 1 segundo | |
setTimeout(verificaTituloCampo, 0); | |
} | |
}); | |
$("#alertas").dialog({ | |
modal: true, | |
title: "Alerta", | |
buttons: { | |
Ok: function () { | |
$(this).dialog('close'); | |
} | |
} | |
}); | |
$('.invisivel *').click(function (e) { | |
return false; | |
}); | |
$('.invisivel *').hover(function (e) { | |
$(this).attr('title', 'Processo inativo, trate a área "' + $("#uso").attr('title') + '"'); | |
return false; | |
}); | |
// Click | |
$(".acessivel").click(function (e) { | |
// Inicio variaveis | |
var url = $('input[title=' + $(this).attr('id') + ']').val(); | |
var html; | |
var params = 'f_int_storeno=' + $('#storeno').val(); | |
var buttons; | |
params = params + '&f_int_ordno=' + $('#ordno').val(); | |
// Adiciono parametros na url | |
url = url + '?' + params; | |
// Monto html | |
html = '<iframe src="' + url + '" name="frame_uso" id="frame_uso" frameborder="0" height="407" width="100%">teste</iframe>'; | |
$(html).appendTo("#divFrame"); | |
buttons = { | |
"Tela Principal": function () { | |
window.parent.frame_uso.location.href = $("#divFrame iframe").attr('src'); | |
}, | |
"Prosseguir": function () { | |
$(this).dialog('close'); | |
} | |
}; | |
$("#divFrame").dialog({ | |
buttons: buttons, | |
title: $(this).attr('title') | |
}); | |
$("#divFrame").dialog('open'); | |
}); | |
$("#verificaPreVendas").click(function () { | |
var params = 'f_int_storeno=' + $('input[name="storeno"]').val(); | |
params = params + '&f_int_ordno=' + $('input[name="ordno"]').val(); | |
var patchLength = (window.location.href.indexOf('.php') + 4); | |
url = window.location.href.substring(0, patchLength) + '?' + params; | |
tb_show_block(); | |
window.location.href = url; | |
}); | |
$('#descartar').click(function (e) { | |
if (!confirm("Deseja realmente executar essa ação?")) | |
e.preventDefault(); | |
}); | |
var links_devolucao = $('.devolver'); | |
$("#encerrar").click(function (e) { | |
e.preventDefault(); | |
$.post( | |
"../includes/ajax/vendasAtendimentoPedidoEntregaContrato.ajax.php", | |
"f_int_storeno=" + $('input[name="storeno"]').val() + "&f_int_ordno=" + $('input[name="ordno"]').val() + "&f_str_acao=verificarContratosEntregas", | |
function (data) { | |
if ("true" == data.contratoPendente) { | |
var url = 'atendimento_pedido_entrega_contrato.php'; | |
var html; | |
var params = 'f_int_storeno=' + $('#storeno').val(); | |
params = params + '&f_int_ordno=' + $('#ordno').val(); | |
var buttons; | |
html = '<iframe src="' + url + '?' + params + '" name="frame_uso" id="frame_alteracao" frameborder="0" height="250" width="100%">Pedido Entrega Contrato</iframe>'; | |
$(html).appendTo("#divFrame"); | |
buttons = { | |
"Fechar": function () { | |
$(this).dialog('close'); | |
} | |
}; | |
$("#divFrame").dialog({ | |
buttons: buttons, | |
height: 350, | |
title: "Contratos de Entregas Disponibilidade Futura" | |
}); | |
$("#divFrame").dialog('open'); | |
} else { | |
window.location.href = $("#encerrar").attr("href"); | |
} | |
}, | |
"json" | |
); | |
}); | |
for (var i = 0; i < links_devolucao.length; i++) { | |
$(links_devolucao[i]).click(function (e) { | |
var chave = $(this).attr("chave"); | |
var dados = chave.split(";"); | |
// Inicio variaveis | |
var url = 'atendimento_efetuar_devolucao_fiscal.php'; | |
var html; | |
var params = 'f_int_storeno=' + dados[0]; | |
var buttons; | |
params = params + '&f_int_ordno=' + $('#ordno').val(); | |
params = params + '&f_int_pdvno=' + dados[1]; | |
params = params + '&f_int_xano=' + dados[2]; | |
// Adiciono parametros na url | |
url = url + '?' + params; | |
// Monto html | |
html = '<iframe src="' + url + '" name="frame_uso" id="frame_uso" frameborder="0" height="407" width="100%">teste</iframe>'; | |
$(html).appendTo("#divFrame"); | |
buttons = { | |
"Tela Principal": function () { | |
window.parent.frame_uso.location.href = $("#divFrame iframe").attr('src'); | |
}, | |
"Prosseguir": function () { | |
$(this).dialog('close'); | |
} | |
}; | |
$("#divFrame").dialog({ | |
buttons: buttons, | |
title: $(this).attr('title') | |
}); | |
$("#divFrame").dialog('open'); | |
e.preventDefault(); | |
}); | |
} | |
if (elementoExiste("#encerrar")) { | |
$("#encerrar").click(); | |
} | |
if (elementoExiste("#aguardarPgtoBoleto")) | |
$("#aguardarPgtoBoleto").click(aguardarPgtoBoleto); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment