Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
2c4c49ca | 3 | | CiviCRM version 4.7 | |
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} {$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"> </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> | |
6a488035 TO |
69 | {literal} |
70 | <script type="text/javascript" > | |
71 | ||
72 | var currentWidth; | |
73 | var currentHeight; | |
74 | var currentMetric = document.getElementById('metric').value; | |
75 | selectPaper( document.getElementById('paper_size').value ); | |
76 | ||
77 | function selectPaper( val ) | |
78 | { | |
79 | dataUrl = {/literal}"{crmURL p='civicrm/ajax/paperSize' h=0 }"{literal}; | |
80 | cj.post( dataUrl, {paperSizeName: val}, function( data ) { | |
81 | cj("#paper_size").val( data.name ); | |
82 | metric = document.getElementById('metric').value; | |
83 | currentWidth = convertMetric( data.width, data.metric, metric ); | |
84 | currentHeight = convertMetric( data.height, data.metric, metric ); | |
85 | updatePaperDimensions( ); | |
86 | }, 'json'); | |
87 | } | |
88 | ||
89 | function selectMetric( metric ) | |
90 | { | |
91 | convertField( 'margin_top', currentMetric, metric ); | |
92 | convertField( 'margin_bottom', currentMetric, metric ); | |
93 | convertField( 'margin_left', currentMetric, metric ); | |
94 | convertField( 'margin_right', currentMetric, metric ); | |
95 | currentWidth = convertMetric( currentWidth, currentMetric, metric ); | |
96 | currentHeight = convertMetric( currentHeight, currentMetric, metric ); | |
97 | updatePaperDimensions( ); | |
98 | } | |
99 | ||
100 | function updatePaperDimensions( ) | |
101 | { | |
102 | metric = document.getElementById('metric').value; | |
103 | width = new String( currentWidth.toFixed( 2 ) ); | |
104 | height = new String( currentHeight.toFixed( 2 ) ); | |
105 | if ( document.getElementById('orientation').value == 'landscape' ) { | |
106 | width = new String( currentHeight.toFixed( 2 ) ); | |
107 | height = new String( currentWidth.toFixed( 2 ) ); | |
108 | } | |
109 | document.getElementById('paper_dimensions').innerHTML = parseFloat( width ) + ' ' + metric + ' x ' + parseFloat( height ) + ' ' + metric; | |
110 | currentMetric = metric; | |
111 | } | |
112 | ||
113 | function convertField( id, from, to ) | |
114 | { | |
115 | val = document.getElementById( id ).value; | |
116 | if ( val == '' || isNaN( val ) ) return; | |
117 | val = convertMetric( val, from, to ); | |
118 | val = new String( val.toFixed( 3 ) ); | |
119 | document.getElementById( id ).value = parseFloat( val ); | |
120 | } | |
121 | ||
122 | function convertMetric( value, from, to ) { | |
123 | switch( from + to ) { | |
124 | case 'incm': return value * 2.54; | |
125 | case 'inmm': return value * 25.4; | |
126 | case 'inpt': return value * 72; | |
127 | case 'cmin': return value / 2.54; | |
128 | case 'cmmm': return value * 10; | |
129 | case 'cmpt': return value * 72 / 2.54; | |
130 | case 'mmin': return value / 25.4; | |
131 | case 'mmcm': return value / 10; | |
132 | case 'mmpt': return value * 72 / 25.4; | |
133 | case 'ptin': return value / 72; | |
134 | case 'ptcm': return value * 2.54 / 72; | |
135 | case 'ptmm': return value * 25.4 / 72; | |
136 | } | |
137 | return value; | |
138 | } | |
139 | ||
140 | </script> | |
141 | {/literal} | |
60158442 CW |
142 | |
143 | {/if} | |
144 | <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div> | |
145 | </div> |