Guest User

Untitled

a guest
Jan 18th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.38 KB | None | 0 0
  1. $(document).ready(function()
  2. {
  3. console.log("ready");
  4. cargarCampos(3);
  5. obtenerReqAprobacion();
  6.  
  7. // TableManageDefault.init();
  8. });
  9.  
  10. function obtenerReqAprobacion()
  11. {
  12.  
  13. let filas, cabecera;
  14. let resultados=[];
  15. let formData= new FormData();
  16.  
  17. filas="";
  18. ajaxDinamicoForm("mesa_ayuda/obtenerReqAprobacion", formData, function(data)
  19. {
  20.  
  21. console.log(data);
  22. resultados=data.resultados;
  23.  
  24.  
  25. cabecera="<tr>";
  26. cabecera+="<th data-orderable='false'>N°</th>";
  27. cabecera+="<th>Req</th>";
  28. cabecera+="<th>Solicitante</th>";
  29. cabecera+="<th>VB de</th>";
  30. cabecera+="<th>Descripcion Breve</th>";
  31. cabecera+="<th>Responsable</th>";
  32. cabecera+="<th>Observacion</th>";
  33. cabecera+="<th>Comentario</th>";
  34. cabecera+="<th>Accion</th>";
  35. cabecera+="</tr>";
  36.  
  37.  
  38. $("#data-table-default").find("thead").html(cabecera);
  39.  
  40.  
  41.  
  42. for(let i=0; i < data.resultados.length;i++)
  43. {
  44.  
  45. filas+="<tr>";
  46. filas+="<td>"+(i+1)+"</td>";
  47. filas+="<td><a href='mesa_ayuda/detalle?req="+resultados[i].cod_requerimiento+"' class='label label-inverse'>"+resultados[i].cod_requerimiento+"</a> </td>";
  48. filas+="<td>"+resultados[i].nCreador+"</td>";
  49. filas+="<td>"+resultados[i].nUsuario+"</td>";
  50. filas+="<td>"+resultados[i].DescripcionBreve+"</td>";
  51. filas+="<td>"+resultados[i].nResponsable+"</td>";
  52. filas+="<td>Ventaja: "+resultados[i].Ventaja+"<br> Desventaja: "+resultados[i].Desventaja+"</td>";
  53. filas+="<td><textarea id=tbComentario_"+resultados[i].cod_requerimiento+"' name='tbComentario_"+resultados[i].cod_requerimiento+"' maxlength='255' rows='3'></textarea></td>";
  54. filas+="<td><button type='button' id='btnA"+resultados[i].cod_requerimiento+"' class='btn btn-primary envio aprob'> Aprobar </button> <button type='button' id='btnR"+resultados[i].cod_requerimiento+"' class='btn btn-danger envio neg'> Rechazar</button></td>";
  55. filas+="</tr>";
  56.  
  57. }
  58.  
  59. $("#data-table-default").find("tbody").html(filas);
  60.  
  61.  
  62.  
  63. if ($('#data-table-default').length !== 0)
  64. {
  65. $('#data-table-default').DataTable(
  66. {
  67.  
  68.  
  69. responsive: true,
  70. "language":
  71. {
  72. "decimal": "",
  73. "emptyTable": "No hay solicitudes de aprobación disponibles.",
  74. "info": "Mostrando _START_ al _END_ de _TOTAL_ registro(s)",
  75. "infoEmpty": "Mostrarndo 0 a 0 de 0 registro(s)",
  76. "infoFiltered": "(filtered from _MAX_ total entries)",
  77. "infoPostFix": "",
  78. "thousands": ",",
  79. "lengthMenu": "Mostrar _MENU_ registros",
  80. "loadingRecords": "Cargando...",
  81. "processing": "Procesando...",
  82. "search": "Buscar:",
  83. "zeroRecords": "No matching records found",
  84. "paginate": {
  85. "first": "Primero",
  86. "last": "Último",
  87. "next": "Siguiente",
  88. "previous": "Anterior"
  89. },
  90. "aria": {
  91. "sortAscending": ": activate to sort column ascending",
  92. "sortDescending": ": activate to sort column descending"
  93. }
  94. }
  95.  
  96. });
  97.  
  98. $(".envio").click(function(){
  99. var n = $(this).attr("id").lastIndexOf("_") + 1;
  100. var id_Req = $(this).attr("id").substring(n,$(this).attr("id").length); //Obtengo el ID
  101. var comentario = $("#tbComentario_" + id_Req);
  102.  
  103. var aprobacion;
  104.  
  105. if ($(this).hasClass('aprob') == true)
  106. { aprobacion = 1; }
  107. else
  108. { aprobacion = 0; }
  109.  
  110. if ($.trim(comentario.val()) == "")
  111. { comentario.parent().addClass("error");
  112. $("#tbComentario_" + id_Req).focus();
  113. return false; }
  114. else
  115. {
  116. $.post("mesa_ayuda/actualizaResponsableAprob",{ req:id_Req ,
  117. comentario:comentario.val() ,
  118. aprobado:aprobacion },
  119. function(data) {
  120.  
  121. { window.location = "baprobacion.asp?m=1" }
  122. });
  123. }
  124. });
  125. }
  126.  
  127. })
Add Comment
Please, Sign In to add comment