Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 9.80 KB | None | 0 0
  1. $(document).ready(function () {
  2.     $("#xfechaIni").datepicker({dateFormat: 'yy/mm/dd'});
  3.     $("#xfechaFin").datepicker({dateFormat: 'yy/mm/dd'});
  4.     $('#xfechaIni').val(moment().format('YYYY/MM/DD'));
  5.     $('#xfechaFin').val(moment().format('YYYY/MM/DD'));
  6.     console.log($("[id='frm_upl_file']").length);
  7.     var options = {
  8.         beforeSend: function () {
  9.             $("#progressbox").show();
  10.             // clear everything
  11.             $("#progressbar").width('0%');
  12.             $("#message").empty();
  13.             $("#percent").html("0%");
  14.         },
  15.         uploadProgress: function (event, position, total, percentComplete) {
  16.             $("#progressbar").width(percentComplete + '%');
  17.             $("#percent").html(percentComplete + '%');
  18.  
  19.             // change message text to red after 50%
  20.             if (percentComplete > 50) {
  21.                 $("#message").html("<font color='red'>Archivo Subiendo....</font>");
  22.             }
  23.         },
  24.         success: function () {
  25.             $("#progressbar").width('100%');
  26.             $("#percent").html('100%');
  27.         },
  28.         complete: function (response) {
  29.             $("#message").html("<font color='blue'>Su Archivo se Subio con Exito!!</font>");
  30.         },
  31.         error: function () {
  32.             $("#message").html("<font color='red'> ERROR: Su Archivo no se pudo subir...Intente de Nuevo</font>");
  33.         }
  34.     };
  35.     $("#frm_upl_file").ajaxForm(options);
  36.    
  37.     var dialogSubirFoto;
  38.     dialogSubirFoto = $("#div_upl_file").dialog({
  39.         autoOpen: false,
  40.         height: 250,
  41.         width: 300,
  42.         modal: true,
  43.         buttons: {
  44.             "Subir Archivo": subirArchivo,
  45.             Cancel: function () {
  46.                 dialogSubirFoto.dialog("close");
  47.             }
  48.         },
  49.         close: function () {
  50.         }
  51.     });
  52.     function subirArchivo() {
  53.        $("#frm_upl_file").submit();
  54.        
  55.     }
  56.  
  57.     $("#btnConsultar").on('click', function () {
  58.         var xfechaIni = $("#xfechaIni").val();
  59.         var xfechaFin = $("#xfechaFin").val();
  60.         $.ajax({
  61.             method: "post",
  62.             url: "../ajax/embarques/a_embembconslinea.jsp",
  63.             data: {
  64.                 "xAccion": "consultaLineasCarga",
  65.                 "xfechaIni": xfechaIni,
  66.                 "xfechaFin": xfechaFin
  67.  
  68.             },
  69.             dataType: 'json',
  70.             async: false
  71.         }).done(function (json) {
  72.             if (json.xmsg === '') {
  73.                 $("#divTablaLineas").html(json.xhtml);
  74.                 $("#divTablaLineas2").html(json.xhtml2);
  75.             } else {
  76.                 alert(json.xmsg);
  77.                 $("#divCargas").html("");
  78.             }
  79.         })
  80.                 .fail(function (jqXHR, textStatus, errorThrown) {
  81.                     alert("error " + textStatus);
  82.                     var werror = "Error Catalogo de Clientes.. ";
  83.                     if (jqXHR.status === 0) {
  84.                         werror = 'Not connected.\nPlease verify your network connection.';
  85.                     } else if (jqXHR.status == 404) {
  86.                         werror = 'The requested page not found. [404]';
  87.                     } else if (jqXHR.status == 500) {
  88.                         werror = 'Internal Server Error [500].';
  89.                     } else if (errorThrown === 'parsererror') {
  90.                         werror = 'Requested JSON parse failed.';
  91.                     } else if (errorThrown === 'timeout') {
  92.                         werror = 'Time out error.';
  93.                     } else if (errorThrown === 'abort') {
  94.                         werror = 'Ajax request aborted.';
  95.                     } else {
  96.                         werror = 'Uncaught Error.\n' + jqXHR.responseText;
  97.                     }
  98.                     alert(werror);
  99.                 });
  100.  
  101.     });
  102.  
  103.  
  104.     $(document).on("click", ".btnSubirFactura", function () {
  105.         var wRenglon = $(this).closest("tr");
  106.         var myId = wRenglon.find(".myRowId").text();
  107.         $("#divNoFactura").html(myId);
  108.         $("#txtNoFactura").val(myId);
  109.         dialogSubirFoto.dialog("open");
  110.     });
  111.     $(document).on("click", ".btnFeLlegada", function () {
  112.         var self = this;
  113.         var wRenglon = $(this).closest("tr");
  114.         var myId = wRenglon.find(".myRowId").text();
  115.         $.ajax({
  116.             method: "post",
  117.             url: "../ajax/embarques/a_embembconslinea.jsp",
  118.             data: {
  119.                 "xAccion": "grabaFechaLleagada",
  120.                 "myId": myId
  121.  
  122.             },
  123.             dataType: 'json',
  124.             async: false
  125.         }).done(function (json) {
  126.             $(self).hide();
  127.             var myDate = moment().format('YYYY/MM/DD');
  128.             $(self).closest('td').text(myDate);
  129.             wRenglon.find(".btnFeLibera").prop('disabled', false);
  130.         })
  131.                 .fail(function (jqXHR, textStatus, errorThrown) {
  132.                     alert("error " + textStatus);
  133.                     var werror = "Error Catalogo de Clientes.. ";
  134.                     if (jqXHR.status === 0) {
  135.                         werror = 'Not connected.\nPlease verify your network connection.';
  136.                     } else if (jqXHR.status == 404) {
  137.                         werror = 'The requested page not found. [404]';
  138.                     } else if (jqXHR.status == 500) {
  139.                         werror = 'Internal Server Error [500].';
  140.                     } else if (errorThrown === 'parsererror') {
  141.                         werror = 'Requested JSON parse failed.';
  142.                     } else if (errorThrown === 'timeout') {
  143.                         werror = 'Time out error.';
  144.                     } else if (errorThrown === 'abort') {
  145.                         werror = 'Ajax request aborted.';
  146.                     } else {
  147.                         werror = 'Uncaught Error.\n' + jqXHR.responseText;
  148.                     }
  149.                     alert(werror);
  150.                 });
  151.  
  152.     });
  153.     $(document).on("click", ".btnFeLibera", function () {
  154.         var self = this;
  155.         var wRenglon = $(this).closest("tr");
  156.         var myId = wRenglon.find(".myRowId").text();
  157.         $.ajax({
  158.             method: "post",
  159.             url: "../ajax/embarques/a_embembconslinea.jsp",
  160.             data: {
  161.                 "xAccion": "grabaFechaLiberacion",
  162.                 "myId": myId
  163.  
  164.             },
  165.             dataType: 'json',
  166.             async: false
  167.         }).done(function (json) {
  168.             $(self).hide();
  169.             var myDate = moment().format('YYYY/MM/DD HH:mm');
  170.             $(self).closest('td').text(myDate);
  171.             wRenglon.find(".btnSaldado").prop('disabled', false);
  172.             window.open("../servletSendEmail?xNoEmb=" + json.xNoEmb + "&xCliente=" + json.xCliente + "&xFechaLiberacion=" + json.xFechaLiberacion + "&xNoFactura=" +
  173.                    json.xNoFactura + "&xTelCliente" + json.xTelCliente + "&xNomLinea=" + json.xNomLinea + "&xTelLinea=" + json.xTelLinea + "&xNomChofer=" + json.xNomChofer +
  174.                    "&xTelChofer=" + json.xTelChofer + "&xPlaTracChofer=" + json.xPlaTracChofer + "&xMarcaTracChofer=" + json.xMarcaTracChofer, "_blank");
  175.         })
  176.                 .fail(function (jqXHR, textStatus, errorThrown) {
  177.                     alert("error " + textStatus);
  178.                     var werror = "Error Catalogo de Clientes.. ";
  179.                     if (jqXHR.status === 0) {
  180.                         werror = 'Not connected.\nPlease verify your network connection.';
  181.                     } else if (jqXHR.status == 404) {
  182.                         werror = 'The requested page not found. [404]';
  183.                     } else if (jqXHR.status == 500) {
  184.                         werror = 'Internal Server Error [500].';
  185.                     } else if (errorThrown === 'parsererror') {
  186.                         werror = 'Requested JSON parse failed.';
  187.                     } else if (errorThrown === 'timeout') {
  188.                         werror = 'Time out error.';
  189.                     } else if (errorThrown === 'abort') {
  190.                         werror = 'Ajax request aborted.';
  191.                     } else {
  192.                         werror = 'Uncaught Error.\n' + jqXHR.responseText;
  193.                     }
  194.                     alert(werror);
  195.                 });
  196.  
  197.     });
  198.     $(document).on("click", ".btnGrabarFolioFactura", function () {
  199.         alert("aaaa");
  200.         var wRenglon = $(this).closest("tr");
  201.         var wId = wRenglon.find(".myRowId").text();
  202.         var wFolioFactura = $("#idFolio" + wId).val();
  203.         alert(wId + "    " + wFolioFactura);
  204.         $.ajax({
  205.             method: "post",
  206.             url: "../ajax/embarques/a_embembconslinea.jsp",
  207.             data: {
  208.                 "xAccion": "grabaFolioFactura",
  209.                 "myId": wId,
  210.                 "wFolioFactura": wFolioFactura
  211.  
  212.             },
  213.             dataType: 'json',
  214.             async: false
  215.         }).done(function (json) {
  216.             $(self).hide();
  217.             $(self).closest('td').text('OK');
  218.         })
  219.                 .fail(function (jqXHR, textStatus, errorThrown) {
  220.                     console.log("error " + textStatus);
  221.                 });
  222.     });
  223.     $(document).on("click", ".btnSaldado", function () {
  224.         var self = this;
  225.         var wRenglon = $(this).closest("tr");
  226.         var myId = wRenglon.find(".myRowId").text();
  227.         $.ajax({
  228.             method: "post",
  229.             url: "../ajax/embarques/a_embembconslinea.jsp",
  230.             data: {
  231.                 "xAccion": "grabaSaldado",
  232.                 "myId": myId
  233.  
  234.             },
  235.             dataType: 'json',
  236.             async: false
  237.         }).done(function (json) {
  238.             $(self).hide();
  239.             $(self).closest('td').text('OK');
  240.         })
  241.                 .fail(function (jqXHR, textStatus, errorThrown) {
  242.                     console.log("error " + textStatus);
  243.                 });
  244.  
  245.     });
  246. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement