logs_groups_pdf.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <!DOCTYPE html>
  2. <html lang="{{ get_locale() }}">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <title>{{ _('Reporte de grupos') }}</title>
  6. <style>
  7. @page { size: A4; margin: 18mm 14mm; }
  8. body { color: #1f2937; font-size: 10px; }
  9. h1 { color: #172554; font-size: 22px; margin: 0 0 5px; }
  10. h2 { color: #1e3a8a; font-size: 15px; margin: 22px 0 8px; }
  11. h3 { color: #334155; font-size: 12px; margin: 16px 0 6px; }
  12. .meta { color: #64748b; font-size: 9px; margin-bottom: 16px; }
  13. .summary { display: table; width: 100%; margin-bottom: 18px; }
  14. .metric { display: table-cell; border: 1px solid #cbd5e1; padding: 9px; width: 33%; }
  15. .metric + .metric { border-left: 0; }
  16. .label { color: #64748b; font-size: 9px; text-transform: uppercase; }
  17. .value { color: #1e40af; font-size: 15px; font-weight: bold; margin-top: 3px; }
  18. table { border-collapse: collapse; width: 100%; margin-bottom: 14px; }
  19. th, td { border: 1px solid #cbd5e1; padding: 6px; }
  20. th { background: #eff6ff; color: #1e3a8a; text-align: left; }
  21. .right { text-align: right; }
  22. .group-block, .user-block { page-break-inside: avoid; }
  23. .selected { background: #eef2ff; }
  24. .url { word-break: break-all; }
  25. </style>
  26. </head>
  27. <body>
  28. <h1>{{ _('Reporte de grupos') }}</h1>
  29. <div class="meta">
  30. {{ _('Periodo') }}: {{ group_report.start_date }} - {{ group_report.end_date }}
  31. · {{ _('Generado') }}: {{ generated_at }}
  32. </div>
  33. <div class="summary">
  34. <div class="metric">
  35. <div class="label">{{ _('Solicitudes') }}</div>
  36. <div class="value">{{ group_report.total_requests }}</div>
  37. </div>
  38. <div class="metric">
  39. <div class="label">{{ _('Datos consumidos') }}</div>
  40. <div class="value">{{ group_report.total_bytes|format_bytes }}</div>
  41. </div>
  42. <div class="metric">
  43. <div class="label">{{ _('Grupos') }}</div>
  44. <div class="value">{{ group_report.groups|length }}</div>
  45. </div>
  46. </div>
  47. <h2>{{ _('Resumen por grupo') }}</h2>
  48. <table>
  49. <thead>
  50. <tr>
  51. <th>#</th>
  52. <th>{{ _('Grupo') }}</th>
  53. <th class="right">{{ _('Usuarios') }}</th>
  54. <th class="right">{{ _('Datos') }}</th>
  55. <th class="right">%</th>
  56. </tr>
  57. </thead>
  58. <tbody>
  59. {% for group in group_report.groups %}
  60. <tr{% if group_report.selected_group and group_report.selected_group.id == group.id %} class="selected"{% endif %}>
  61. <td>{{ loop.index }}</td>
  62. <td>{{ group.name }}</td>
  63. <td class="right">{{ group.user_count }}</td>
  64. <td class="right">{{ group.total_bytes|format_bytes }}</td>
  65. <td class="right">{{ '%.1f'|format(group.percentage) }}%</td>
  66. </tr>
  67. {% else %}
  68. <tr><td colspan="5">{{ _('No hay tráfico para este periodo.') }}</td></tr>
  69. {% endfor %}
  70. </tbody>
  71. </table>
  72. {% if group_report.selected_group %}
  73. <h2>{{ _('Usuarios del grupo') }}: {{ group_report.selected_group.name }}</h2>
  74. <table>
  75. <thead>
  76. <tr>
  77. <th>{{ _('Usuario') }}</th>
  78. <th class="right">{{ _('Solicitudes') }}</th>
  79. <th class="right">{{ _('Datos') }}</th>
  80. </tr>
  81. </thead>
  82. <tbody>
  83. {% for user in group_report.selected_group_users %}
  84. <tr{% if group_report.selected_user and group_report.selected_user.username == user.username %} class="selected"{% endif %}>
  85. <td>{{ user.username }}</td>
  86. <td class="right">{{ user.total_requests }}</td>
  87. <td class="right">{{ user.total_bytes|format_bytes }}</td>
  88. </tr>
  89. {% else %}
  90. <tr><td colspan="3">{{ _('No hay usuarios con tráfico.') }}</td></tr>
  91. {% endfor %}
  92. </tbody>
  93. </table>
  94. {% endif %}
  95. {% if group_report.selected_user %}
  96. <div class="user-block">
  97. <h2>{{ _('Detalle del usuario') }}: {{ group_report.selected_user.username }}</h2>
  98. <div class="meta">
  99. {{ group_report.selected_user.total_requests }} {{ _('solicitudes') }} ·
  100. {{ group_report.selected_user.total_bytes|format_bytes }} ·
  101. {{ group_report.selected_user_total_count }} {{ _('páginas encontradas') }}
  102. </div>
  103. <table>
  104. <thead>
  105. <tr>
  106. <th>{{ _('Página') }}</th>
  107. <th class="right">{{ _('Solicitudes') }}</th>
  108. <th class="right">{{ _('Datos') }}</th>
  109. </tr>
  110. </thead>
  111. <tbody>
  112. {% for page in group_report.selected_user_pages %}
  113. <tr>
  114. <td class="url">{{ page.url }}</td>
  115. <td class="right">{{ page.total_requests }}</td>
  116. <td class="right">{{ page.total_bytes|format_bytes }}</td>
  117. </tr>
  118. {% else %}
  119. <tr><td colspan="3">{{ _('No hay páginas accedidas.') }}</td></tr>
  120. {% endfor %}
  121. </tbody>
  122. </table>
  123. </div>
  124. {% endif %}
  125. </body>
  126. </html>