Merge in 5.20
[civicrm-core.git] / templates / CRM / Contribute / Form / ContributionCharts.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | Copyright CiviCRM LLC. All rights reserved. |
4 | |
5 | This work is published under the GNU AGPLv3 license with some |
6 | permitted exceptions and without any warranty. For full license |
7 | and copyright information, see https://civicrm.org/licensing |
8 +--------------------------------------------------------------------+
9 *}
10 {* Display monthly and yearly contributions using Google charts (Bar and Pie) *}
11 {if $hasContributions}
12 <div id="chartData">
13 <table >
14 <tr class="crm-contribution-form-block-chart">
15 <td width="50%">
16 {if $hasByMonthChart}
17 {* display monthly chart *}
18 <div id="chart_by_month"></div>
19 {else}
20 {ts}There were no contributions during the selected year.{/ts}
21 {/if}
22 </td>
23 <td width="50%">
24 {* display yearly chart *}
25 <div id="chart_by_year"></div>
26 </td>
27 </tr>
28 </table>
29 <div class="form-layout-compressed" >
30 <table >
31 <td class="label">{$form.select_year.label}</td><td>{$form.select_year.html}</td>
32 <td class="label">{$form.chart_type.label}</td><td>{$form.chart_type.html}</td>
33 </table>
34 </div>
35 {else}
36 <div class="messages status no-popup">
37 {ts}There are no live contribution records to display.{/ts}
38 </div>
39 {/if}
40
41 {if $hasChart}
42 {include file="CRM/common/chart.tpl" contriChart=true}
43
44 {literal}
45 <script type="text/javascript">
46
47 CRM.$(function($) {
48 var allData = {/literal}{$chartData}{literal};
49
50 $.each( allData, function( chartID, chartValues ) {
51 var divName = "chart_" + chartID;
52 createChart( chartID, divName, 300, 300, allData[chartID].object );
53 });
54
55 function byMonthOnClick( barIndex ) {
56 var url = allData.by_month.on_click_urls['url_' + barIndex];
57 if ( url ) window.location.href = url;
58 }
59
60 function byYearOnClick( barIndex ) {
61 var url = allData.by_year.on_click_urls['url_' + barIndex];
62 if ( url ) window.location.href = url;
63 }
64
65 });
66 </script>
67 {/literal}
68 {/if}