Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.80 KB | None | 0 0
  1. {% extends 'baseRelatorio.html.twig' %}
  2.  
  3. {# Nome Relatório #}
  4. {% block nome_relatorio %}
  5. <h3 style="text-transform: uppercase; color: gray; font-weight: bold">{{nomeRelatorio}} </h3>
  6. {% endblock %}
  7.  
  8. {% block title %}
  9. <h3 style="text-transform: uppercase">{{nomeRelatorio}}</h3>
  10. {% endblock %}
  11.  
  12. {# Filtros Relatório #}
  13. {% block filtros %}
  14. {% for f in filtros %}
  15. {% if 'Filtrado' in f %}
  16. {{f}}&emsp;&emsp;
  17. {% else %}
  18. Periodo: {{f}}&emsp;&emsp;
  19. {% endif %}
  20. {% endfor %}
  21. {% endblock %}
  22.  
  23. {% block body %}
  24. <style>
  25. .tblRelMovEs {
  26. width: 100%;
  27. border: 2px solid gray;
  28. text-transform: uppercase;
  29. margin-bottom: 20px;
  30. }
  31.  
  32. .tblRelMovEs thead tr th,
  33. .tblRelMovEs tbody tr td {
  34. border: 1px solid gray;
  35. padding: 2px 5px;
  36. text-align: center;
  37. }
  38.  
  39. .tblRelMovEs tbody {
  40. border: 2px solid gray;
  41. }
  42.  
  43. .tblRelMovEs caption {
  44. color: black;
  45. }
  46.  
  47. .tblRelMovEs tr th:nth-child(4),
  48. .tblRelMovEs tr td:nth-child(4){
  49. text-align: left;
  50. padding: 2px 5px 2px 20px;
  51. }
  52.  
  53. .tblRelMovEs tr th:nth-child(1),
  54. .tblRelMovEs tr th:nth-child(2),
  55. .tblRelMovEs tr th:nth-child(6) {
  56. width: 120px;
  57. }
  58.  
  59. .tblRelMovEs tr th:nth-child(5),
  60. .tblRelMovEs tr th:nth-child(7) {
  61. width: 130px!important;
  62. }
  63.  
  64. @media print {
  65.  
  66. body {
  67. font: 8pt Georgia, "Arial", Verdana, sans-serif;
  68. color: #000;
  69. margin:0;
  70. padding:0;
  71. /*line-height: 1.4em;*/
  72. }
  73.  
  74. table {
  75. page-break-after: auto;
  76. }
  77.  
  78. .tblRelMovEs tbody,
  79. .tblRelMovEs {
  80. border: 1px solid gray;
  81. }
  82.  
  83.  
  84. .tblRelMovEs thead tr th,
  85. .tblRelMovEs tbody tr td {
  86. padding: 1px;
  87. font: 8pt Georgia, "Arial", Verdana, sans-serif;
  88. }
  89.  
  90.  
  91. .tblRelMovEs tr th:nth-child(1),
  92. .tblRelMovEs tr th:nth-child(2),
  93. .tblRelMovEs tr th:nth-child(6),
  94. .tblRelMovEs tr th:nth-child(7) {
  95. width: 80px!important;
  96. }
  97.  
  98. .tblRelMovEs tr th:nth-child(5),
  99. .tblRelMovEs tr th:nth-child(7) {
  100. width: 130px!important;
  101. }
  102.  
  103. * {
  104. background:transparent !important;
  105. color:#000 !important;
  106. text-shadow:none !important;
  107. filter:none !important;
  108. -ms-filter:none !important;
  109. }
  110.  
  111. @page {
  112. size: A4 landscape;
  113. margin-top: 0.5cm;
  114. margin-bottom: 0.5cm;
  115. }
  116.  
  117. .btnExcel {
  118. display: none;
  119. }
  120. }
  121.  
  122. </style>
  123. <div class="box box-default">
  124. <div class="box-body">
  125. {% if dados %}
  126. {% for item in dados %}
  127. <a href="#" class="btnExcel btn btn-block btn-social btn-success" style="width: 200px" onClick="javascript:relatorioExcel();">
  128. <i class="fa fa-file-excel-o"></i> Exportar XLS
  129. </a>
  130. <table class="tblRelMovEs">
  131. <caption>Estoque: {{ item.local }}</caption>
  132. <thead>
  133. <tr>
  134. <th>Data</th>
  135. <th>Hora</th>
  136. <th>Produto</th>
  137. <th>Histórico</th>
  138. <th>Usuário</th>
  139. <th>Quantidade</th>
  140. <th>Saldo Atual</th>
  141. </tr>
  142. </thead>
  143. <tbody>
  144. {% for mov in item.produtos %}
  145. <tr>
  146. <td>{{ mov.data|date('d/m/Y') }}</td>
  147. <td>{{ mov.data|date('H:i') }}</td>
  148. <td>{{ mov.descricaoProduto | capitalize }}</td>
  149. <td>{{ mov.historico | capitalize }}</td>
  150. <td>{{ mov.usuario }}</td>
  151. {% if mov.tipo == 1 %}
  152. <td>{{'+' ~ mov.quantidade }}</td>
  153. {% elseif mov.tipo == 2 %}
  154. <td>{{'-'~ mov.quantidade}}</td>
  155. {% endif %}
  156. <td>{{ mov.saldo }}</td>
  157. </tr>
  158. {% endfor %}
  159. </tbody>
  160.  
  161. </table>
  162. {% endfor %}
  163. {% else %} <!-- Não tem nenhuma movimentação para o período -->
  164. <h5 class="text-center">{{ msgVazio }}</h5>
  165. {% endif %}
  166. </div>
  167. </div>
  168.  
  169. <script>
  170. const nomeRelatorio = "{{nomeRelatorio}}";
  171. const relatorioExcel = () => {
  172. let tab_text = `
  173. <html xmlns:x="urn:schemas-microsoft-com:office:excel">
  174. <head>
  175. <meta charset="UTF-8">
  176. <xml>
  177. <x:ExcelWorkbook>
  178. <x:ExcelWorksheets>
  179. <x:ExcelWorksheet>
  180. <x:Name>${nomeRelatorio}</x:Name>
  181. <x:WorksheetOptions>
  182. <x:Panes></x:Panes>
  183. </x:WorksheetOptions>
  184. </x:ExcelWorksheet>
  185. </x:ExcelWorksheets>
  186. </x:ExcelWorkbook>
  187. </xml>
  188. </head>
  189. <body>
  190. <table border='1px'>${$('.tblRelMovEs').html()}
  191. </table>
  192. </body>
  193. </html>
  194. `;
  195.  
  196. let data_type = 'data:application/vnd.ms-excel';
  197.  
  198. let ua = window.navigator.userAgent;
  199. let msie = ua.indexOf("MSIE ");
  200.  
  201. if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) {
  202. if (window.navigator.msSaveBlob) {
  203. var blob = new Blob([tab_text], {
  204. type: "application/csv;charset=utf-8;"
  205. });
  206. navigator.msSaveBlob(blob, `${nomeRelatorio}.xls`);
  207. }
  208. } else {
  209. $('.btnExcel').attr('href', data_type + ', ' + encodeURIComponent(tab_text));
  210. $('.btnExcel').attr('download', `${nomeRelatorio}.xls`);
  211. }
  212.  
  213. }
  214. </script>
  215. {% endblock %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement