CRM-14383 - Update cj closures
[civicrm-core.git] / templates / CRM / Report / Form / Layout / Graph.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.5 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2014 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
8 | |
9 | CiviCRM is free software; you can copy, modify, and distribute it |
10 | under the terms of the GNU Affero General Public License |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
12 | |
13 | CiviCRM is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 | See the GNU Affero General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Affero General Public |
19 | License and the CiviCRM Licensing Exception along |
20 | with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25 *}
26 {assign var=uploadURL value=$config->imageUploadURL|replace:'/persist/contribute/':'/persist/'|cat:'openFlashChart/'}
27 {* Display weekly,Quarterly,monthly and yearly contributions using pChart (Bar and Pie) *}
28 {if $chartEnabled and $chartSupported}
29 <div class='crm-flashchart'>
30 <table class="chart">
31 <tr>
32 <td>
33 {if $outputMode eq 'print' OR $outputMode eq 'pdf'}
34 <img src="{$uploadURL|cat:$chartId}.png" />
35 {else}
36 <div id="open_flash_chart_{$uniqueId}"></div>
37 {/if}
38 </td>
39 </tr>
40 </table>
41 </div>
42
43 {if !$printOnly} {* NO print section starts *}
44 {if !$section}
45 {include file="CRM/common/openFlashChart.tpl" divId="open_flash_chart_$uniqueId"}
46 {/if}
47
48 {literal}
49 <script type="text/javascript">
50 CRM.$(function($) {
51 buildChart( );
52
53 cj("input[id$='submit_print'],input[id$='submit_pdf']").bind('click', function(e){
54 // image creator php file path and append image name
55 var url = CRM.url('civicrm/report/chart', 'name=' + '{/literal}{$chartId}{literal}' + '.png');
56
57 //fetch object and 'POST' image
58 swfobject.getObjectById("open_flash_chart_{/literal}{$uniqueId}{literal}").post_image(url, true, false);
59 });
60 });
61
62 function buildChart( ) {
63 var chartData = {/literal}{$openFlashChartData}{literal};
64 cj.each( chartData, function( chartID, chartValues ) {
65 var xSize = eval( "chartValues.size.xSize" );
66 var ySize = eval( "chartValues.size.ySize" );
67 var divName = {/literal}"open_flash_chart_{$uniqueId}"{literal};
68
69 var loadDataFunction = {/literal}"loadData{$uniqueId}"{literal};
70 createSWFObject( chartID, divName, xSize, ySize, loadDataFunction );
71 });
72 }
73
74 function loadData{/literal}{$uniqueId}{literal}( chartID ) {
75 var allData = {/literal}{$openFlashChartData}{literal};
76 var data = eval( "allData." + chartID + ".object" );
77 return JSON.stringify( data );
78 }
79 </script>
80 {/literal}
81 {/if}
82 {/if}