Merge pull request #1951 from mlutfy/4.4-crm13740
[civicrm-core.git] / templates / CRM / Admin / Form / PdfFormats.tpl
CommitLineData
6a488035
TO
1{*
2 +--------------------------------------------------------------------+
232624b1 3 | CiviCRM version 4.4 |
6a488035
TO
4 +--------------------------------------------------------------------+
5 | Copyright (C) 2011 Marty Wright |
6 | Licensed to CiviCRM under the Academic Free License version 3.0. |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26*}
27{* This template is used for adding/configuring PDF Page Formats. *}
28<div class="crm-block crm-form-block crm-pdfFormat-form-block">
29 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
30
31{if $action eq 8}
edc51caa 32 <div class="messages status no-popup">
33 <div class="icon inform-icon"></div>
6a488035
TO
34 {ts 1=$formatName}WARNING: You are about to delete the PDF Page Format titled <strong>%1</strong>.{/ts}<p>{ts}This will remove the format from all Message Templates that use it. Do you want to continue?{/ts}</p>
35 </div>
36{else}
37 <table class="form-layout-compressed">
38 <tr class="crm-pdfFormat-form-block-name">
39 <td class="right">{$form.name.label}</td><td colspan="3">{$form.name.html}</td>
40 </tr>
41 <tr class="crm-pdfFormat-form-block-description">
42 <td class="right">{$form.description.label}</td><td colspan="3">{$form.description.html}</td>
43 </tr>
44 <tr class="crm-pdfFormat-form-block-is_default">
45 <td></td><td colspan="3">{$form.is_default.html}&nbsp;{$form.is_default.label}</td>
46 </tr>
47 <tr>
48 <td class="right">{$form.paper_size.label}</td><td>{$form.paper_size.html}</td>
49 <td class="right">{$form.orientation.label}</td><td>{$form.orientation.html}</td>
50 </tr>
51 <tr>
52 <td class="right">{$form.paper_dimensions.html}</td><td id="paper_dimensions">&nbsp;</td>
53 <td class="right">{$form.metric.label}</td><td>{$form.metric.html}</td>
54 </tr>
55 <tr>
56 <td class="right">{$form.margin_top.label}</td><td>{$form.margin_top.html}</td>
57 <td class="right">{$form.margin_bottom.label}</td><td>{$form.margin_bottom.html}</td>
58 </tr>
59 <tr>
60 <td class="right">{$form.margin_left.label}</td><td>{$form.margin_left.html}</td>
61 <td class="right">{$form.margin_right.label}</td><td>{$form.margin_right.html}</td>
62 </tr>
edc51caa 63 <tr class="crm-pdfFormat-form-block-weight">
6a488035
TO
64 <td class="right">{$form.weight.label}</td><td colspan="3">{$form.weight.html}<br />
65 <span class="description">{ts}Weight controls the order in which PDF Page Formats are displayed <br />in selection lists. Enter a positive or negative integer. Lower numbers <br />are displayed ahead of higher numbers.{/ts}</span>
66 </td>
67 </tr>
68 </table>
edc51caa 69{/if}
6a488035
TO
70<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
71</div>
72
73{literal}
74<script type="text/javascript" >
75
76var currentWidth;
77var currentHeight;
78var currentMetric = document.getElementById('metric').value;
79selectPaper( document.getElementById('paper_size').value );
80
81function selectPaper( val )
82{
83 dataUrl = {/literal}"{crmURL p='civicrm/ajax/paperSize' h=0 }"{literal};
84 cj.post( dataUrl, {paperSizeName: val}, function( data ) {
85 cj("#paper_size").val( data.name );
86 metric = document.getElementById('metric').value;
87 currentWidth = convertMetric( data.width, data.metric, metric );
88 currentHeight = convertMetric( data.height, data.metric, metric );
89 updatePaperDimensions( );
90 }, 'json');
91}
92
93function selectMetric( metric )
94{
95 convertField( 'margin_top', currentMetric, metric );
96 convertField( 'margin_bottom', currentMetric, metric );
97 convertField( 'margin_left', currentMetric, metric );
98 convertField( 'margin_right', currentMetric, metric );
99 currentWidth = convertMetric( currentWidth, currentMetric, metric );
100 currentHeight = convertMetric( currentHeight, currentMetric, metric );
101 updatePaperDimensions( );
102}
103
104function updatePaperDimensions( )
105{
106 metric = document.getElementById('metric').value;
107 width = new String( currentWidth.toFixed( 2 ) );
108 height = new String( currentHeight.toFixed( 2 ) );
109 if ( document.getElementById('orientation').value == 'landscape' ) {
110 width = new String( currentHeight.toFixed( 2 ) );
111 height = new String( currentWidth.toFixed( 2 ) );
112 }
113 document.getElementById('paper_dimensions').innerHTML = parseFloat( width ) + ' ' + metric + ' x ' + parseFloat( height ) + ' ' + metric;
114 currentMetric = metric;
115}
116
117function convertField( id, from, to )
118{
119 val = document.getElementById( id ).value;
120 if ( val == '' || isNaN( val ) ) return;
121 val = convertMetric( val, from, to );
122 val = new String( val.toFixed( 3 ) );
123 document.getElementById( id ).value = parseFloat( val );
124}
125
126function convertMetric( value, from, to ) {
127 switch( from + to ) {
128 case 'incm': return value * 2.54;
129 case 'inmm': return value * 25.4;
130 case 'inpt': return value * 72;
131 case 'cmin': return value / 2.54;
132 case 'cmmm': return value * 10;
133 case 'cmpt': return value * 72 / 2.54;
134 case 'mmin': return value / 25.4;
135 case 'mmcm': return value / 10;
136 case 'mmpt': return value * 72 / 25.4;
137 case 'ptin': return value / 72;
138 case 'ptcm': return value * 2.54 / 72;
139 case 'ptmm': return value * 25.4 / 72;
140 }
141 return value;
142}
143
144</script>
145{/literal}