0byt3m1n1
Path:
/
home
/
mgatv524
/
public_html
/
mctv
/
reports
/
[
Home
]
File: summary-report-form.twig
{# /* * Xibo - Digital Signage - http://www.xibo.org.uk * Copyright (C) 2019 Xibo Signage Ltd * * This file is part of Xibo. * * Xibo is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * Xibo is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with Xibo. If not, see <http://www.gnu.org/licenses/>. * */ #} {% extends "authed.twig" %} {% import "inline.twig" as inline %} {% block actionMenu %} <div class="widget-action-menu pull-right"> <button class="btn btn-success XiboFormButton" title="{% trans "Select a type and an item (i.e., layout/media/tag)" %}" id="reportAddBtn"><i class="fa fa-plus-circle" aria-hidden="true"></i> {% trans "Schedule" %}</button> <button class="btn btn-info XiboRedirectButton" href="{{ url_for("savedreport.view") }}?reportName=summaryReport"><i class="fa fa-eye" aria-hidden="true"></i> {% trans "Saved Reports" %}</button> <button class="btn btn-primary XiboRedirectButton" href="{{ url_for("reportschedule.view") }}?reportName=summaryReport"><i class="fa fa-th-list" aria-hidden="true"></i> {% trans "Report Schedules" %}</button> </div> {% endblock %} {% block pageContent %} <div class="widget"> <div class="widget-title"> <span>{% trans "Summary by Layout, Media or Event" %}</span> <span class="fa fa-info-circle widget-title-info px-1" data-toggle="popover" data-trigger="hover" data-placement="bottom" data-content="{% trans "This chart shows an aggregate duration and number of plays for the selected Layout, Media or Event. Please select your Range and Type below. Where the Range crosses period boundaries a new period is generated - i.e 1 week grouped by hourly produces 24 x 7 periods." %}"></span> </div> <div class="widget-navigation-menu"> <ul class="nav nav-pills"> <li role="presentation" class="nav-item"><a class="nav-link" href="{{ url_for("report.view") }}">{% trans "All Reports" %}</a></li> <li role="presentation" class="nav-item dropdown"> <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> Reports <span class="caret"></span> </a> <div class="dropdown-menu"> {% for reports in defaults.availableReports %} {% for report in reports %} {% if report.hidden == 0 and report.category == 'Proof of Play' %} <a class="dropdown-item" href="{{ url_for("report.form", {name: report.name}) }}">{{ report.description }}</a> {% endif %} {% endfor %} {% endfor %} </div> </li> </ul> </div> <div class="widget-body"> <div class="XiboGrid" id="{{ random() }}"> <div class="XiboFilterCustom card bg-light mb-3"> <div class="FilterDiv card-body" id="summaryReport"> <form class="form-inline"> {% set title %}{% trans "Range" %}{% endset %} {% set range %}{% trans "Select a range" %}{% endset %} {% set today %}{% trans "Today" %}{% endset %} {% set yesterday %}{% trans "Yesterday" %}{% endset %} {% set thisweek %}{% trans "This Week" %}{% endset %} {% set thismonth %}{% trans "This Month" %}{% endset %} {% set thisyear %}{% trans "This Year" %}{% endset %} {% set lastweek %}{% trans "Last Week" %}{% endset %} {% set lastmonth %}{% trans "Last Month" %}{% endset %} {% set lastyear %}{% trans "Last Year" %}{% endset %} {% set options = [ { filterName: "", reportFilter: range }, { filterName: "today", reportFilter: today }, { filterName: "yesterday", reportFilter: yesterday }, { filterName: "thisweek", reportFilter: thisweek }, { filterName: "thismonth", reportFilter: thismonth }, { filterName: "thisyear", reportFilter: thisyear }, { filterName: "lastweek", reportFilter: lastweek }, { filterName: "lastmonth", reportFilter: lastmonth }, { filterName: "lastyear", reportFilter: lastyear }, ] %} {{ inline.dropdown("reportFilter", "single", title, "today", options, "filterName", "reportFilter") }} {% set title %}{% trans "From Date" %}{% endset %} {{ inline.date("statsFromDt", title, defaults.fromDateOneDay, "", "stats-from-dt", "", "") }} {% set title %}{% trans "To Date" %}{% endset %} {{ inline.date("statsToDt", title, defaults.toDate, "", "stats-to-dt", "", "") }} {% set title %}{% trans "Group by" %}{% endset %} {% set byday %}{% trans "Day" %}{% endset %} {% set byweek %}{% trans "Week" %}{% endset %} {% set bymonth %}{% trans "Month" %}{% endset %} {% set options = [ { filterName: "byday", groupByFilter: byday }, { filterName: "byweek", groupByFilter: byweek }, { filterName: "bymonth", groupByFilter: bymonth }, ] %} {{ inline.dropdown("groupByFilter", "single", title, "", options, "filterName", "groupByFilter", "", "group-by-filter") }} {% set title %}{% trans "Type" %}{% endset %} {% set layout %}{% trans "Layout" %}{% endset %} {% set media %}{% trans "Media" %}{% endset %} {% set event %}{% trans "Event" %}{% endset %} {% set options = [ { typeid: "layout", type: layout }, { typeid: "media", type: media }, { typeid: "event", type: event }, ] %} {{ inline.dropdown("type", "single", title, "", options, "typeid", "type") }} {% set title %}{% trans "Layout" %} *{% endset %} {% set helpText %}{% trans "This field is required when the Type selected is Layout" %}{% endset %} {% set attributes = [ { name: "data-width", value: "200px" }, { name: "data-allow-clear", value: "true" }, { name: "data-placeholder--id", value: null }, { name: "data-placeholder--value", value: "" }, { name: "data-search-url", value: url_for("layout.search") }, { name: "data-search-term", value: "layout" }, { name: "data-search-term-tags", value: "tags" }, { name: "data-id-property", value: "layoutId" }, { name: "data-text-property", value: "layout" } ] %} {{ inline.dropdown("layoutId", "single", title, "", null, "layoutId", "layout", helpText, "pagedSelect layout-select", "", "l", "", attributes) }} {% set title %}{% trans "Media" %} *{% endset %} {% set helpText %}{% trans "This field is required when the Type selected is Media" %}{% endset %} {% set attributes = [ { name: "data-width", value: "200px" }, { name: "data-allow-clear", value: "true" }, { name: "data-placeholder--id", value: null }, { name: "data-placeholder--value", value: "" }, { name: "data-search-url", value: url_for("library.search") }, { name: "data-search-term", value: "media" }, { name: "data-id-property", value: "mediaId" }, { name: "data-text-property", value: "name" } ] %} {{ inline.dropdown("mediaId", "single", title, "", null, "mediaId", "name", helpText, "pagedSelect media-select", "", "m", "", attributes) }} {% set title %}{% trans "Tag" %} *{% endset %} {% set helpText %}{% trans "This field is required when the Type selected is Event" %}{% endset %} {{ inline.input("eventTag", title, "", helpText, "tag-text") }} <div class="w-100"> <a id="applyBtn" class="btn btn-success"> <span>{% trans "Apply" %}</span> </a> <span id="applyWarning" class="text-warning" style="display:none; padding-left: 10px">{% trans "Warning: This may return a lot of data and may take several minutes to process." %}</span> </div> </form> </div> </div> <div class="XiboData card pt-3 d-block"> <canvas id="reportChart" style="clear:both; margin-top:25px;" height="70%"></canvas> <img id="imageLoader" style="display: block; margin: auto;" src="{{ theme.uri("img/loader.gif") }}"> </div> </div> </div> </div> {% endblock %} {% block javaScript %} <script type="text/javascript"> $(function () { $('[data-toggle="popover"]').popover(); }); var reportChart = null; var imageLoader = $("#imageLoader"); function setReport() { imageLoader.show(); $.ajax({ type: "get", url: "{{ url_for("report.data", {name: reportName}) }}", cache: false, dataType: "json", data: $("#summaryReport").find("form").serialize(), success: function(response) { setTimeout(function() { $("#applyBtn").removeClass('disabled'); }, 300); imageLoader.hide(); if (reportChart !== undefined && reportChart !== null) { reportChart.destroy(); } if (!response.extra.hasData) { return; } // Create our chart reportChart = new Chart($("#reportChart"), response.extra.chart); } }); } $(document).ready(function() { // Init var warning = $("#applyWarning"); var applyBtn = $("#applyBtn"); var type = $("#type"); var groupByFilter = $("#groupByFilter"); var groupByFilterCls = $(".group-by-filter"); var mediaSelect =$(".media-select"); var layoutSelect =$(".layout-select"); var eventTagCls =$(".tag-text"); // Calculate the difference of number of days of a selected range var calculateDaysShowHideWarn = function() { var fromDt = moment($("#statsFromDt").val()); var toDt = moment($("#statsToDt").val()); var days = toDt.diff(fromDt, 'days'); warning.hide(); if ( days >= 30) { warning.show(); } return true; }; $("#statsFromDtLink").change( function() { calculateDaysShowHideWarn(); }); $("#statsToDtLink").change( function() { calculateDaysShowHideWarn(); }); // Report Filter var reportFilter = $("#reportFilter"); // Hide / Show FromDt and ToDt function checkReportFilter(reportFilter) { var value = reportFilter.val(); var collectionMonth = [ {id: 'byday', description: "{% trans "Day" %}"}, {id: 'byweek', description: "{% trans "Week" %}"}, ]; var collectionYear = [ {id: 'byday', description: "{% trans "Day" %}"}, {id: 'byweek', description: "{% trans "Week" %}"}, {id: 'bymonth', description: "{% trans "Month" %}"} ]; if (value === '' || value === undefined) { // show the from date and to date $(".stats-from-dt").show(); $(".stats-to-dt").show(); $("#groupByFilter option").remove(); groupByFilterCls.show(); $.each(collectionYear, function(index, item) { groupByFilter.append( $("<option></option>") .text(item.description) .val(item.id) ); }); } else { // hide the from date and to date $(".stats-from-dt").hide(); $(".stats-to-dt").hide(); // Group by filter $("#groupByFilter option").remove(); groupByFilterCls.show(); if (value === 'thismonth' || value === 'lastmonth') { $.each(collectionMonth, function(index, item) { groupByFilter.append( $("<option></option>") .text(item.description) .val(item.id) ); }); } else if (value === 'thisyear' || value === 'lastyear') { $.each(collectionYear, function(index, item) { groupByFilter.append( $("<option></option>") .text(item.description) .val(item.id) ); }); groupByFilter.val('bymonth'); //by default } else { groupByFilterCls.hide(); } } } var checkFilterAndApply = function() { reportFilter.off('change').change( function() { var value = reportFilter.val(); // Hide / Show FromDt and ToDt checkReportFilter(reportFilter); // Hide / Show Warning warning.hide(); if ( value === '') { calculateDaysShowHideWarn(); } else if ( value === 'thismonth' || value === 'lastmonth' || value === 'thisyear' || value === 'lastyear') { warning.show(); } }); type.off('change').change( function() { var value = type.val(); if (value === 'media') { // show media and clear/hide the layout $("#layoutId").val(""); $("#layoutId option").remove(); layoutSelect.hide(); $("#eventTag").val(""); eventTagCls.hide(); mediaSelect.show(); } else if (value === 'layout') { // show layout and clear/hide the media $("#mediaId").val(""); $("#mediaId option").remove(); mediaSelect.hide(); $("#eventTag").val(""); eventTagCls.hide(); layoutSelect.show(); } else if (value === 'event') { // clear/hide the media and layout $("#mediaId").val(""); $("#mediaId option").remove(); $("#layoutId").val(""); $("#layoutId option").remove(); mediaSelect.hide(); layoutSelect.hide(); // show tag eventTagCls.show(); } }); }; // Enable/Disable Schedule Btn var checkEnableSchedule = function() { var mediaVal = $("#mediaId").val(); var layoutVal = $("#layoutId").val(); var eventTagVal = $("#eventTag").val(); var reportAddBtn = $("button#reportAddBtn"); var typeVal = $("#type").val(); if ( typeVal === 'layout') { if (layoutVal == null) { reportAddBtn.addClass('disabled'); reportAddBtn.removeAttr('href'); } else { reportAddBtn.removeClass('disabled'); reportAddBtn.attr("href", "{{ url_for("reportschedule.add.form") }}?type=" + typeVal + "&layoutId=" + layoutVal + "&reportName=summaryReport" ); reportAddBtn.removeAttr('title'); } } else if ( typeVal === 'media') { if (mediaVal == null) { reportAddBtn.addClass('disabled'); reportAddBtn.removeAttr('href'); } else { reportAddBtn.removeClass('disabled'); reportAddBtn.attr("href", "{{ url_for("reportschedule.add.form") }}?type=" + typeVal + "&mediaId=" + mediaVal + "&reportName=summaryReport" ); reportAddBtn.removeAttr('title'); } } else if ( typeVal === 'event') { if (eventTagVal == null) { reportAddBtn.addClass('disabled'); reportAddBtn.removeAttr('href'); } else { reportAddBtn.removeClass('disabled'); reportAddBtn.attr("href", "{{ url_for("reportschedule.add.form") }}?type=" + typeVal + "&eventTag=" + eventTagVal + "&reportName=summaryReport" ); reportAddBtn.removeAttr('title'); } } }; type.val('layout'); mediaSelect.hide(); eventTagCls.hide(); // reportFilter.val(''); // groupByFilter.val('byday'); imageLoader.hide(); checkReportFilter(reportFilter); checkFilterAndApply(); applyBtn.addClass('disabled'); checkEnableSchedule(); // Bind to form change $("#summaryReport").on('change', function() { checkEnableSchedule(); var layoutVal = $("#layoutId").val(); var mediaVal = $("#mediaId").val(); var eventVal = $("#eventTag").val(); if ((layoutVal === null || layoutVal === '' || layoutVal === undefined) && (mediaVal === null || mediaVal === '' || mediaVal === undefined) && (eventVal === null || eventVal === '' || eventVal === undefined) ) { applyBtn.addClass('disabled'); } else { applyBtn.removeClass('disabled'); } }); // Apply applyBtn.click(function () { $(this).addClass('disabled'); checkFilterAndApply(); setReport(); }); }); </script> {% endblock %}