Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.19 KB | None | 0 0
  1. <?php
  2. require_once "../../permission.php";
  3. verifySession();
  4. require_once "../../header.php";
  5. $statusinsert = isset($_POST['statusinsert']) ? $_POST['statusinsert'] : false;
  6. ?>
  7. <script src="../../dist/plugins/jQuery-Mask-Plugin-master/dist/jquery.mask.min.js"></script>
  8.  
  9. <? if(array_intersect(array('6'), $_SESSION['codRole'])) { ?>
  10. <div class="content-wrapper">
  11. <section class="content-header">
  12. <section class="content">
  13. <div class="row">
  14. <section class="col-lg-6">
  15. <div class="box">
  16. <div class="box-header">
  17. <div class="pull-left">
  18. <h3 style= "margin-top: 0px;">
  19. Lista de Ordens de Pagamento
  20. <button type="button" class="btn btn-success" id="criarOp"> + Criar Op</button>
  21. <div class="btn-group" data-toggle="buttons">
  22. <label class="btn btn-primary active form-check-label">
  23. <input class="form-check-input" name="opStatus" type="radio" id="exec_ativo" value="ativo" autocomplete="off" checked="checked" >Ativo</label>
  24. <label class="btn btn-primary form-check-label">
  25. <input class="form-check-input" name="opStatus" type="radio" id="exec_todos" value="todos" autocomplete="off" >Todos</label>
  26. </div>
  27. </div>
  28. </div>
  29. <div class="box-body" id="producaoIndividual">
  30. <table id="tabelaOpGeral" class="table table-bordered table-striped table-hover" data-order='[[0, "asc"]]' data-page-length="10">
  31. <thead>
  32. <tr>
  33.  
  34. <th>Op</th>
  35. <th>Nome</th>
  36. <th>Total</th>
  37. <th>Ativo</th>
  38. </tr>
  39. </thead>
  40. </table>
  41. </div>
  42. </div>
  43. </section>
  44. <section class="col-lg-6">
  45. <div class="box">
  46. <div class="box-header">
  47. <div class="pull-left">
  48. <h3 style= "margin-top: 0px;">Fornecedores com OS a serem pagas</h3>
  49. </div>
  50. </div>
  51. <div class="box-body" id="producaoIndividual">
  52. <table id="tabelaOp" class="table table-bordered table-striped table-hover" data-order='[[0, "asc"]]' data-page-length="10">
  53. <thead>
  54. <tr>
  55. <th>Nome</th>
  56. <th>Função</th>
  57. </tr>
  58. </thead>
  59. </table>
  60. </div>
  61. </div>
  62. </section>
  63. <div class="modal fade" id="pagamentosInfoMain" role="dialog">
  64. <div class="modal-dialog" style="width:70%;height:auto">
  65. <div class="modal-content">
  66. <div id="voucherContent">
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </section>
  73. </section>
  74. </div>
  75. <script>
  76.  
  77. var dataObject = {
  78. columns: [],
  79. stateSave: false,
  80. paging: true,
  81. lengthChange: true,
  82. searching: true,
  83. ordering: true,
  84. info: true,
  85. autoWidth: true,
  86. bRetrieve: true,
  87. language: {
  88. url: "/dist/plugins/datatables/i18n/Portuguese-Brasil.json"
  89. }
  90. }
  91.  
  92. $(document).ready(function(e) {
  93. carregaTabelaOp();
  94. carregatabelaOpGeral ();
  95. $('#listMenuPagamento').css('color', 'white');
  96.  
  97.  
  98. });
  99.  
  100. function carregaTabelaOp () {
  101. var status2 = $('input[name=opStatus]:checked').val();
  102. $.post("ordens_pagamento_select.php", {
  103. opStatus: status2,
  104. }, function(data, source) {
  105. //console.log(data);
  106. var response = JSON.parse(data);
  107. var aoColumnsDataTable = [];
  108. var arrayToTable = [];
  109.  
  110. response.listaOp.forEach(function (element, index, array) {
  111. element.nome = '<a href="" onclick="pagamentos('+element.codFornecedor+')">'+element.nome+'</a>';
  112. delete element.codFornecedor;
  113.  
  114. arrayToTable.push(element);
  115. });
  116.  
  117. Object.keys(response.listaOp[0]).forEach(function(element, index, array) {
  118. aoColumnsDataTable.push({ "mDataProp" : element });
  119. });
  120.  
  121. dataObject.aoColumns = aoColumnsDataTable;
  122. refreshTabela(arrayToTable);
  123. });
  124. }
  125.  
  126. function carregatabelaOpGeral () {
  127. var status2 = $('input[name=opStatus]:checked').val();
  128. $.post("ordens_pagamento_select.php", {
  129. opStatus: status2,
  130. }, function(data, source) {
  131. var response = JSON.parse(data);
  132. var aoColumnsDataTable = [];
  133. var arrayToTable = [];
  134.  
  135. response.listaOpGeral.forEach(function (element, index, array) {
  136. element.op = '<a href="" onclick="pagamentos3('+element.codOp+','+element.codFornecedor+')">'+element.op+'</a>';
  137.  
  138. if(element.ativo ==1){
  139. element.ativo = '<input type="checkbox" name="ativo" onchange="atualizaOp('+element.codOp+','+element.ativo+');" checked>';
  140. } else {
  141. element.ativo = '<input type="checkbox" name="ativo" onchange="atualizaOp('+element.codOp+','+element.ativo+');" >';
  142. }
  143. delete element.codFornecedor;
  144. delete element.codOp;
  145. arrayToTable.push(element);
  146. });
  147.  
  148. Object.keys(response.listaOpGeral[0]).forEach(function(element, index, array) {
  149. aoColumnsDataTable.push({ "mDataProp" : element });
  150. });
  151.  
  152. dataObject.aoColumns = aoColumnsDataTable;
  153. refreshTabela2(arrayToTable);
  154. });
  155. }
  156.  
  157.  
  158. function atualizaOp(codOp, ativo) {
  159. if(ativo == 1){
  160. ativo = 0;
  161. } else if (ativo ==0){
  162. ativo = 1;
  163. }
  164. $.post("op_update.php", {
  165. codOp : codOp,
  166. ativo : ativo
  167. }, function(data, source) {
  168. try {
  169. carregatabelaOpGeral();
  170. } catch (e) {}
  171. //console.log(data);
  172. });
  173. }
  174.  
  175.  
  176. function refreshTabela(data) {
  177. $('#tabelaOp').DataTable(dataObject);
  178. $('#tabelaOp').dataTable().fnClearTable();
  179. $('#tabelaOp').dataTable().fnAddData(data);
  180. $('#tabelaOp').on('mouseover', function() {
  181. $('table a').on('click', function(e) {
  182. e.preventDefault();
  183. });
  184. });
  185. }
  186. $("#exec_todos").change(function() {
  187. carregatabelaOpGeral($("#exec_todos").val());
  188. });
  189. $("#exec_ativo").change(function() {
  190. carregatabelaOpGeral($("#exec_ativo").val());
  191. });
  192. function refreshTabela2(data) {
  193. $('#tabelaOpGeral').DataTable(dataObject);
  194. $('#tabelaOpGeral').dataTable().fnClearTable();
  195. $('#tabelaOpGeral').dataTable().fnAddData(data);
  196. $('#tabelaOpGeral').DataTable( {
  197. dom: 'Bfrtip',
  198. buttons: [
  199. 'copy', 'csv', 'excel', 'pdf', 'print'
  200. ]
  201. } );
  202. $('#tabelaOpGeral').on('mouseover', function() {
  203. $('table a').on('click', function(e) {
  204. e.preventDefault();
  205. });
  206. });
  207. }
  208.  
  209. function pagamentos(codFornecedor) {
  210. $('#voucherContent').load("detalhesOp.php", {
  211. codFornecedor : codFornecedor,
  212.  
  213. });
  214. $('#pagamentosInfoMain').modal("show");
  215. }
  216.  
  217.  
  218. function pagamentos3(codOp, codFornecedor) {
  219. $('#voucherContent').load("detalhesOp.php", {
  220. codOp : codOp,
  221. codFornecedor : codFornecedor
  222. });
  223. $('#pagamentosInfoMain').modal("show");
  224. }
  225.  
  226. $('#criarOp').click(function() {
  227. $("#voucherContent").load('detalhesOp.php', {acao: 'insert'},);
  228. $('#pagamentosInfoMain').modal("show");
  229. });
  230.  
  231. </script>
  232.  
  233. <?php
  234. require_once "../../footer.php";
  235. ?>
  236. <? } else { ?>
  237. <div class="box col-sm-12">
  238. <label> Você não tem permissão para ver essa página </label>
  239. </div>
  240. <? } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement