{#
This file is part of the Sales Report plugin
Copyright (C) EC-CUBE CO.,LTD. All Rights Reserved.
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'SalesReport42/Resource/template/admin/index.twig' %}
{% block sub_title %}{{ 'sales_report.admin.sub.title.term'|trans }}{% endblock %}
{% set report_title = 'sales_report.admin.term.report_title'|trans %}
{% set action = url('sales_report_admin_term') %}
{% set menus = ['SalesReport42', 'sales_report_admin_term'] %}
{% block stylesheet %}
<link rel="stylesheet" href="{{ asset('assets/css/tempusdominus-bootstrap-4.min.css', 'admin') }}">
<style type="text/css">
.datepicker-days th.dow:first-child,
.datepicker-days td:first-child {
color: #f00;
}
.datepicker-days th.dow:last-child,
.datepicker-days td:last-child {
color: #00f;
}
#sales_report_unit > div {
float: left;
padding-right: 15px
}
</style>
{% endblock stylesheet %}
{% block chart %}
<script>
var graphData = {{ graphData|raw }};
window.onload = function () {
//create line chart
if (graphData != null) {
var dataSet = graphData.datasets;
graphData.datasets = [dataSet];
{% if options.unit is defined and (options.unit == 'byWeekDay' or options.unit == 'byHour') %}
var config = {
type: 'bar',
data: graphData,
options: {
responsive: true,
tooltips: {
callbacks: {
label: function tooltipsRender(tooltipItem, graphData) {
var index = tooltipItem.index;
var tooltipData = graphData.datasets[0].data[index];
var tooltipLabel = graphData.labels[index];
return '{{ 'sales_report.admin.money'|trans }}' + moneyFormat(tooltipData);
}
}
},
scales: {
yAxes: [{
ticks: {
callback: function (value) {
return Math.round(value).toString().replace(/(\d)(?=(\d{3})+$)/g, '$1,');
}
}
}]
}
}
};
{% else %}
var config = {
type: 'line',
data: graphData,
options: {
responsive: true,
tooltips: {
callbacks: {
label: function tooltipsRender(tooltipItem, graphData) {
var index = tooltipItem.index;
var tooltipData = graphData.datasets[0].data[index];
var tooltipLabel = graphData.labels[index];
return '{{ 'sales_report.admin.money'|trans }}' + moneyFormat(tooltipData);
}
}
},
scales: {
yAxes: [{
ticks: {
callback: function (value) {
return Math.round(value).toString().replace(/(\d)(?=(\d{3})+$)/g, '$1,');
}
}
}]
}
}
};
{% endif %}
var ctx = document.getElementById("chart").getContext("2d");
new Chart(ctx, config);
}
//export csv
$('#export-csv').click(function () {
var form = document.createElement("form");
form.setAttribute("method", 'POST');
form.setAttribute("action", "{{ url('sales_report_admin_export', { type : 'term' }) }}");
document.body.appendChild(form);
form.submit();
document.body.removeChild(form);
});
};
</script>
{% endblock %}
{% block option %}
<div class="row">
<div class="col-3"><span>{{ 'sales_report.admin.term.001'|trans }}</span></div>
<div class="col mb-2">
{{ form_widget(form.unit) }}
{{ form_errors(form.unit) }}
</div>
</div>
{% endblock %}
{% block table %}
{% if app.request.method == 'POST' %}
<div class="card-body">
<div class="row">
{% if rawData is not null %}
<div class="col-12 text-end mb-2">
<div class="d-inline-block">
<div class="btn-group d-inline-block" role="group">
<button type="button" class="btn btn-ec-regular" id="export-csv"><i
class="fa fa-cloud-download mr-1 text-secondary"></i> {{ 'sales_report.admin.csv.download'|trans }}
</button>
</div>
</div>
</div>
<table class="table table-striped" id="term-table">
<thead>
<tr>
<th class="border-top-0 py-2 text-center">{{ 'sales_report.admin.list.label.001'|trans }}</th>
<th class="border-top-0 py-2 text-center">{{ 'sales_report.admin.list.label.002'|trans }}</th>
<th class="border-top-0 py-2 text-center">{{ 'sales_report.admin.list.label.003'|trans }}</th>
<th class="border-top-0 py-2 text-center">{{ 'sales_report.admin.list.label.004'|trans }}</th>
<th class="border-top-0 py-2 text-center">{{ 'sales_report.admin.list.label.005'|trans }}</th>
<th class="border-top-0 py-2 text-center">{{ 'sales_report.admin.list.label.006'|trans }}</th>
<th class="border-top-0 py-2 text-center">{{ 'sales_report.admin.list.label.007'|trans }}</th>
<th class="border-top-0 py-2 text-center">{{ 'sales_report.admin.list.label.008'|trans }}</th>
<th class="border-top-0 py-2 text-center">{{ 'sales_report.admin.list.label.009'|trans }}</th>
<th class="border-top-0 py-2 text-end">{{ 'sales_report.admin.list.label.010'|trans }}</th>
<th class="border-top-0 py-2 text-end">{{ 'sales_report.admin.list.label.011'|trans }}</th>
</tr>
</thead>
<tbody>
{% for date, row in rawData %}
<tr>
<td class="align-middle text-center ps-3">{{ date }}</td>
<td class="align-middle text-center ps-3">{{ row is empty ? '' : row.time|number_format }}</td>
<td class="align-middle text-center ps-3">{{ row is empty ? '' : row.male|number_format }}</td>
<td class="align-middle text-center ps-3">{{ row is empty ? '' : row.female|number_format }}</td>
<td class="align-middle text-center ps-3">{{ row is empty ? '' : row.other|number_format }}</td>
<td class="align-middle text-center ps-3">{{ row is empty ? '' : row.member_male|number_format }}</td>
<td class="align-middle text-center ps-3">{{ row is empty ? '' : row.nonmember_male|number_format }}</td>
<td class="align-middle text-center ps-3">{{ row is empty ? '' : row.member_female|number_format }}</td>
<td class="align-middle text-center ps-3">{{ row is empty ? '' : row.nonmember_female|number_format }}</td>
<td class="price-format text-end">
{{ row is empty ? '' : row.price|price }}
<span class="d-none">{{ row is empty ? '' : row.price }}</span>
</td>
<td class="price-format text-end">
{% if row is not empty and row.time > 0 %}
{{ (row.price / row.time)|round(2, 'floor')|price }}
{% else %}
{{ 0|price }}
{% endif %}
<span class="d-none">
{% if row.time > 0 %}
{{ (row.price / row.time)|round(2, 'floor') }}
{% else %}
0
{% endif %}
</span>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="col-12">
<p class="mb-0">{{ 'sales_report.admin.list.nodata'|trans }}</p>
</div>
{% endif %}
</div>
</div>
{% endif %}
{% endblock %}