Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function validarAtendentes(element)
- {
- element.value = isNaN(element.value) ? 0 : parseFloat(element.value).toFixed(0);
- var agendados = $(element).parent().parent("tr").find(".num_agendados").html();
- agendados = agendados == "" ? 0 : agendados;
- if (parseFloat(agendados) > parseFloat(element.value) )
- {
- element.value = agendados;
- }
- element.value = isNaN(element.value) ? agendados : element.value;
- }
- $(document).ready(function()
- {
- $(".num_atendentes").change(function()
- {
- modificouAtendentes = true;
- });
- // quando clicar nos botoes para modificar numero de atendentes tanto de linhas como colunas
- $(".botoes_atendentes").click(function()
- {
- modificouAtendentes = true;
- // se clicou no botao da linha
- if ($(this).hasClass("atendente_row"))
- {
- //obtem os campos num_atendentes desta linha
- elements = $(this).parent().parent("tr").find(".num_atendentes");
- }
- // se clicou no botao da coluna
- else if ($(this).hasClass("atendente_collumn"))
- {
- //obtem os campos num_atendentes desta coluna
- var col = $(this).parent().parent().children().index($(this).parent());
- var row = $(this).parent().parent().parent().children().index($(this).parent().parent());
- col++; // ajuste pra selecionar a coluna certa
- // obtem os elementos da coluna
- // obs.: para pegar a partir de certa linha, adicionar td:gt("+row+")"
- elements = $("#tabela_calendario tr > :nth-child("+col+")" ).find(".num_atendentes");
- }
- var numero = parseInt($(this).attr("name"));
- var operador = $(this).attr("name").charAt(0);
- // para cada elemento faz a operacao de soma ou subtracao no campo
- elements.each(function()
- {
- var agendados = parseFloat($(this).parent().parent("tr").find(".num_agendados").html());
- if (isNaN(parseFloat(agendados))) { agendados = 0; }
- if (parseInt($(this).val()) > agendados || operador != "-")
- {
- $(this).val(parseFloat($(this).val())+numero);
- }
- });
- });
- // Quando clicar no botao salvar
- $(".botao_salvar_atendentes").click(function()
- {
- var dados = $("#myformagenda").serialize();
- showLoadingCal();
- $.ajax({
- type: "POST",
- url: "engine.php?nocss=1&class=Agendas::AgendasFormControl::onSave('.$ref_agenda.')&diaIniSemana='.base64_encode($diaIniSemana).'&diaFimSemana='.base64_encode($diaFimSemana).'",
- data: dados,
- success: function(data)
- {
- modificouAtendentes = false;
- $("#calendario_agenda").append(data);
- $("#loading_agenda_calendario").hide();
- cache_cal = {"" : ""};
- },
- error: function(erro)
- {
- $("#calendario_agenda").html( erro.responseText );
- }
- });
- });
- });
- </script>
- ';
- }
Add Comment
Please, Sign In to add comment