app/Plugin/SalesReport42/Resource/template/admin/term.twig line 1

Open in your IDE?
  1. {#
  2.  This file is part of the Sales Report plugin
  3. Copyright (C) EC-CUBE CO.,LTD. All Rights Reserved.
  4.  For the full copyright and license information, please view the LICENSE
  5.  file that was distributed with this source code.
  6. #}
  7. {% extends 'SalesReport42/Resource/template/admin/index.twig' %}
  8. {% block sub_title %}{{ 'sales_report.admin.sub.title.term'|trans }}{% endblock %}
  9. {% set report_title = 'sales_report.admin.term.report_title'|trans %}
  10. {% set action = url('sales_report_admin_term') %}
  11. {% set menus = ['SalesReport42', 'sales_report_admin_term'] %}
  12. {% block stylesheet %}
  13.     <link rel="stylesheet" href="{{ asset('assets/css/tempusdominus-bootstrap-4.min.css', 'admin') }}">
  14.     <style type="text/css">
  15.         .datepicker-days th.dow:first-child,
  16.         .datepicker-days td:first-child {
  17.             color: #f00;
  18.         }
  19.         .datepicker-days th.dow:last-child,
  20.         .datepicker-days td:last-child {
  21.             color: #00f;
  22.         }
  23.         #sales_report_unit > div {
  24.             float: left;
  25.             padding-right: 15px
  26.         }
  27.     </style>
  28. {% endblock stylesheet %}
  29. {% block chart %}
  30.     <script>
  31.         var graphData = {{ graphData|raw }};
  32.         window.onload = function () {
  33.             //create line chart
  34.             if (graphData != null) {
  35.                 var dataSet = graphData.datasets;
  36.                 graphData.datasets = [dataSet];
  37.                 {% if options.unit is defined and (options.unit == 'byWeekDay' or options.unit == 'byHour') %}
  38.                 var config = {
  39.                     type: 'bar',
  40.                     data: graphData,
  41.                     options: {
  42.                         responsive: true,
  43.                         tooltips: {
  44.                             callbacks: {
  45.                                 label: function tooltipsRender(tooltipItem, graphData) {
  46.                                     var index = tooltipItem.index;
  47.                                     var tooltipData = graphData.datasets[0].data[index];
  48.                                     var tooltipLabel = graphData.labels[index];
  49.                                     return '{{ 'sales_report.admin.money'|trans }}' + moneyFormat(tooltipData);
  50.                                 }
  51.                             }
  52.                         },
  53.                         scales: {
  54.                             yAxes: [{
  55.                                 ticks: {
  56.                                     callback: function (value) {
  57.                                         return Math.round(value).toString().replace(/(\d)(?=(\d{3})+$)/g, '$1,');
  58.                                     }
  59.                                 }
  60.                             }]
  61.                         }
  62.                     }
  63.                 };
  64.                 {% else %}
  65.                 var config = {
  66.                     type: 'line',
  67.                     data: graphData,
  68.                     options: {
  69.                         responsive: true,
  70.                         tooltips: {
  71.                             callbacks: {
  72.                                 label: function tooltipsRender(tooltipItem, graphData) {
  73.                                     var index = tooltipItem.index;
  74.                                     var tooltipData = graphData.datasets[0].data[index];
  75.                                     var tooltipLabel = graphData.labels[index];
  76.                                     return '{{ 'sales_report.admin.money'|trans }}' + moneyFormat(tooltipData);
  77.                                 }
  78.                             }
  79.                         },
  80.                         scales: {
  81.                             yAxes: [{
  82.                                 ticks: {
  83.                                     callback: function (value) {
  84.                                         return Math.round(value).toString().replace(/(\d)(?=(\d{3})+$)/g, '$1,');
  85.                                     }
  86.                                 }
  87.                             }]
  88.                         }
  89.                     }
  90.                 };
  91.                 {% endif %}
  92.                 var ctx = document.getElementById("chart").getContext("2d");
  93.                 new Chart(ctx, config);
  94.             }
  95.             //export csv
  96.             $('#export-csv').click(function () {
  97.                 var form = document.createElement("form");
  98.                 form.setAttribute("method", 'POST');
  99.                 form.setAttribute("action", "{{ url('sales_report_admin_export', { type : 'term' }) }}");
  100.                 document.body.appendChild(form);
  101.                 form.submit();
  102.                 document.body.removeChild(form);
  103.             });
  104.         };
  105.     </script>
  106. {% endblock %}
  107. {% block option %}
  108.     <div class="row">
  109.         <div class="col-3"><span>{{ 'sales_report.admin.term.001'|trans }}</span></div>
  110.         <div class="col mb-2">
  111.             {{ form_widget(form.unit) }}
  112.             {{ form_errors(form.unit) }}
  113.         </div>
  114.     </div>
  115. {% endblock %}
  116. {% block table %}
  117.     {% if app.request.method == 'POST' %}
  118.         <div class="card-body">
  119.             <div class="row">
  120.                 {% if rawData is not null %}
  121.                     <div class="col-12 text-end mb-2">
  122.                         <div class="d-inline-block">
  123.                             <div class="btn-group d-inline-block" role="group">
  124.                                 <button type="button" class="btn btn-ec-regular" id="export-csv"><i
  125.                                             class="fa fa-cloud-download mr-1 text-secondary"></i> {{ 'sales_report.admin.csv.download'|trans }}
  126.                                 </button>
  127.                             </div>
  128.                         </div>
  129.                     </div>
  130.                     <table class="table table-striped" id="term-table">
  131.                         <thead>
  132.                         <tr>
  133.                             <th class="border-top-0 py-2 text-center">{{ 'sales_report.admin.list.label.001'|trans }}</th>
  134.                             <th class="border-top-0 py-2 text-center">{{ 'sales_report.admin.list.label.002'|trans }}</th>
  135.                             <th class="border-top-0 py-2 text-center">{{ 'sales_report.admin.list.label.003'|trans }}</th>
  136.                             <th class="border-top-0 py-2 text-center">{{ 'sales_report.admin.list.label.004'|trans }}</th>
  137.                             <th class="border-top-0 py-2 text-center">{{ 'sales_report.admin.list.label.005'|trans }}</th>
  138.                             <th class="border-top-0 py-2 text-center">{{ 'sales_report.admin.list.label.006'|trans }}</th>
  139.                             <th class="border-top-0 py-2 text-center">{{ 'sales_report.admin.list.label.007'|trans }}</th>
  140.                             <th class="border-top-0 py-2 text-center">{{ 'sales_report.admin.list.label.008'|trans }}</th>
  141.                             <th class="border-top-0 py-2 text-center">{{ 'sales_report.admin.list.label.009'|trans }}</th>
  142.                             <th class="border-top-0 py-2 text-end">{{ 'sales_report.admin.list.label.010'|trans }}</th>
  143.                             <th class="border-top-0 py-2 text-end">{{ 'sales_report.admin.list.label.011'|trans }}</th>
  144.                         </tr>
  145.                         </thead>
  146.                         <tbody>
  147.                         {% for date, row in rawData %}
  148.                             <tr>
  149.                                 <td class="align-middle text-center ps-3">{{ date }}</td>
  150.                                 <td class="align-middle text-center ps-3">{{ row is empty ? '' : row.time|number_format }}</td>
  151.                                 <td class="align-middle text-center ps-3">{{ row is empty ? '' : row.male|number_format }}</td>
  152.                                 <td class="align-middle text-center ps-3">{{ row is empty ? '' : row.female|number_format }}</td>
  153.                                 <td class="align-middle text-center ps-3">{{ row is empty ? '' : row.other|number_format }}</td>
  154.                                 <td class="align-middle text-center ps-3">{{ row is empty ? '' : row.member_male|number_format }}</td>
  155.                                 <td class="align-middle text-center ps-3">{{ row is empty ? '' : row.nonmember_male|number_format }}</td>
  156.                                 <td class="align-middle text-center ps-3">{{ row is empty ? '' : row.member_female|number_format }}</td>
  157.                                 <td class="align-middle text-center ps-3">{{ row is empty ? '' : row.nonmember_female|number_format }}</td>
  158.                                 <td class="price-format text-end">
  159.                                     {{ row is empty ? '' : row.price|price }}
  160.                                     <span class="d-none">{{ row is empty ? '' : row.price }}</span>
  161.                                 </td>
  162.                                 <td class="price-format text-end">
  163.                                     {% if row is not empty and row.time > 0 %}
  164.                                         {{ (row.price / row.time)|round(2, 'floor')|price }}
  165.                                     {% else %}
  166.                                         {{ 0|price }}
  167.                                     {% endif %}
  168.                                     <span class="d-none">
  169.                                                     {% if row.time > 0 %}
  170.                                                         {{ (row.price / row.time)|round(2, 'floor') }}
  171.                                                     {% else %}
  172.                                                         0
  173.                                                     {% endif %}
  174.                                                 </span>
  175.                                 </td>
  176.                             </tr>
  177.                         {% endfor %}
  178.                         </tbody>
  179.                     </table>
  180.                 {% else %}
  181.                     <div class="col-12">
  182.                         <p class="mb-0">{{ 'sales_report.admin.list.nodata'|trans }}</p>
  183.                     </div>
  184.                 {% endif %}
  185.             </div>
  186.         </div>
  187.     {% endif %}
  188. {% endblock %}