2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.5 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2014 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
26 {*common template for compose PDF letters*}
27 {if $form.template.html}
28 <table class="form-layout-compressed">
30 <td class="label-left">{$form.template.label}</td>
31 <td>{$form.template.html}</td>
34 <td class="label-left">{$form.subject.label}</td>
35 <td>{$form.subject.html}</td>
38 <td class="label-left">{$form.campaign_id.label}</td>
39 <td>{$form.campaign_id.html}</td>
44 <div class="crm-accordion-wrapper collapsed">
45 <div class="crm-accordion-header">
46 {$form.pdf_format_header.html}
48 <div class="crm-accordion-body">
49 <div class="crm-block crm-form-block crm-pdf-format-form-block">
50 <table class="form-layout-compressed">
52 <td class="label-left">{$form.format_id.label} {help id="id-pdf-format" file="CRM/Contact/Form/Task/PDFLetterCommon.hlp"}</td>
53 <td>{$form.format_id.html}</td>
56 <td class="label-left">{$form.paper_size.label}</td><td>{$form.paper_size.html}</td>
57 <td class="label-left">{$form.orientation.label}</td><td>{$form.orientation.html}</td>
60 <td class="label-left">{$form.metric.label}</td><td>{$form.metric.html}</td>
61 <td colspan="2"> </td>
64 <td>{$form.paper_dimensions.html}</td><td id="paper_dimensions"> </td>
65 <td colspan="2"> </td>
68 <td class="label-left">{$form.margin_top.label}</td><td>{$form.margin_top.html}</td>
69 <td class="label-left">{$form.margin_bottom.label}</td><td>{$form.margin_bottom.html}</td>
72 <td class="label-left">{$form.margin_left.label}</td><td>{$form.margin_left.html}</td>
73 <td class="label-left">{$form.margin_right.label}</td><td>{$form.margin_right.html}</td>
76 <td class="label-left">{$form.stationery.label}</td><td>{$form.stationery.html}</td>
77 <td colspan="2"> </td>
80 <div id="bindFormat">{$form.bind_format.html} {$form.bind_format.label}</div>
81 <div id="updateFormat" style="display: none">{$form.update_format.html} {$form.update_format.label}</div>
86 <div class="crm-accordion-wrapper crm-html_email-accordion ">
87 <div class="crm-accordion-header">
88 {$form.html_message.label}
89 </div><!-- /.crm-accordion-header -->
90 <div class="crm-accordion-body">
91 <div class="helpIcon" id="helphtml">
92 <input class="crm-token-selector big" data-field="html_message" />
93 {help id="id-token-html" tplFile=$tplFile isAdmin=$isAdmin editor=$editor file="CRM/Contact/Form/Task/Email.hlp"}
95 <div class="clear"></div>
97 {if $editor EQ 'textarea'}
98 <div class="help description">{ts}NOTE: If you are composing HTML-formatted messages, you may want to enable a Rich Text (WYSIWYG) editor (Administer » Customize Data & Screens » Display Preferences).{/ts}</div>
100 {$form.html_message.html}<br />
103 <div id="editMessageDetails">
104 <div id="updateDetails" >
105 {$form.updateTemplate.html} {$form.updateTemplate.label}
108 {$form.saveTemplate.html} {$form.saveTemplate.label}
112 <div id="saveDetails" class="section">
113 <div class="label">{$form.saveTemplateName.label}</div>
114 <div class="content">{$form.saveTemplateName.html|crmAddClass:huge}</div>
117 </div><!-- /.crm-accordion-body -->
118 </div><!-- /.crm-accordion-wrapper -->
120 {include file="CRM/Mailing/Form/InsertTokens.tpl"}
123 <script type="text/javascript">
125 var $form = $('form.{/literal}{$form.formClass}{literal}');
126 $('#format_id', $form).on('change', function() {
127 selectFormat($(this).val());
133 var currentMetric = document.getElementById('metric').value;
134 showBindFormatChkBox();
135 selectPaper( document.getElementById('paper_size').value );
137 function showBindFormatChkBox()
139 var templateExists = true;
140 if ( document.getElementById('template') == null || document.getElementById('template').value == '' ) {
141 templateExists = false;
143 var formatExists = !!cj('#format_id').val();
144 if ( templateExists && formatExists ) {
145 document.getElementById("bindFormat").style.display = "block";
146 } else if ( formatExists && document.getElementById("saveTemplate") != null && document.getElementById("saveTemplate").checked ) {
147 document.getElementById("bindFormat").style.display = "block";
148 var yes = confirm( '{/literal}{$useThisPageFormat}{literal}' );
150 document.getElementById("bind_format").checked = true;
153 document.getElementById("bindFormat").style.display = "none";
154 document.getElementById("bind_format").checked = false;
158 function showUpdateFormatChkBox()
160 if (cj('#format_id').val()) {
161 cj("#updateFormat").show();
165 function updateFormatLabel() {
166 cj('.pdf-format-header-label').html(cj('#format_id option:selected').text() || cj('#format_id').attr('placeholder'));
171 function selectFormat( val, bind )
178 var dataUrl = {/literal}"{crmURL p='civicrm/ajax/pdfFormat' h=0 }"{literal};
179 cj.post( dataUrl, {formatId: val}, function( data ) {
180 cj("#format_id").val( data.id );
181 cj("#paper_size").val( data.paper_size );
182 cj("#orientation").val( data.orientation );
183 cj("#metric").val( data.metric );
184 cj("#margin_top").val( data.margin_top );
185 cj("#margin_bottom").val( data.margin_bottom );
186 cj("#margin_left").val( data.margin_left );
187 cj("#margin_right").val( data.margin_right );
188 selectPaper( data.paper_size );
189 cj("#update_format").prop({checked: false}).parent().hide();
190 document.getElementById('bind_format').checked = bind;
191 showBindFormatChkBox();
195 function selectPaper( val )
197 dataUrl = {/literal}"{crmURL p='civicrm/ajax/paperSize' h=0 }"{literal};
198 cj.post( dataUrl, {paperSizeName: val}, function( data ) {
199 cj("#paper_size").val( data.name );
200 metric = document.getElementById('metric').value;
201 currentWidth = convertMetric( data.width, data.metric, metric );
202 currentHeight = convertMetric( data.height, data.metric, metric );
203 updatePaperDimensions( );
207 function selectMetric( metric )
209 convertField( 'margin_top', currentMetric, metric );
210 convertField( 'margin_bottom', currentMetric, metric );
211 convertField( 'margin_left', currentMetric, metric );
212 convertField( 'margin_right', currentMetric, metric );
213 currentWidth = convertMetric( currentWidth, currentMetric, metric );
214 currentHeight = convertMetric( currentHeight, currentMetric, metric );
215 updatePaperDimensions( );
218 function updatePaperDimensions( )
220 metric = document.getElementById('metric').value;
221 width = new String( currentWidth.toFixed( 2 ) );
222 height = new String( currentHeight.toFixed( 2 ) );
223 if ( document.getElementById('orientation').value == 'landscape' ) {
224 width = new String( currentHeight.toFixed( 2 ) );
225 height = new String( currentWidth.toFixed( 2 ) );
227 document.getElementById('paper_dimensions').innerHTML = parseFloat( width ) + ' ' + metric + ' x ' + parseFloat( height ) + ' ' + metric;
228 currentMetric = metric;
231 function convertField( id, from, to )
233 val = document.getElementById( id ).value;
234 if ( val == '' || isNaN( val ) ) return;
235 val = convertMetric( val, from, to );
236 val = new String( val.toFixed( 3 ) );
237 document.getElementById( id ).value = parseFloat( val );
240 function convertMetric( value, from, to ) {
241 switch( from + to ) {
242 case 'incm': return value * 2.54;
243 case 'inmm': return value * 25.4;
244 case 'inpt': return value * 72;
245 case 'cmin': return value / 2.54;
246 case 'cmmm': return value * 10;
247 case 'cmpt': return value * 72 / 2.54;
248 case 'mmin': return value / 25.4;
249 case 'mmcm': return value / 10;
250 case 'mmpt': return value * 72 / 25.4;
251 case 'ptin': return value / 72;
252 case 'ptcm': return value * 2.54 / 72;
253 case 'ptmm': return value * 25.4 / 72;
258 function showSaveDetails(chkbox) {
259 var formatSelected = ( document.getElementById('format_id').value > 0 );
260 var templateSelected = ( document.getElementById('template') != null && document.getElementById('template').value > 0 );
261 if (chkbox.checked) {
262 document.getElementById("saveDetails").style.display = "block";
263 document.getElementById("saveTemplateName").disabled = false;
264 if ( formatSelected && ! templateSelected ) {
265 document.getElementById("bindFormat").style.display = "block";
266 var yes = confirm( '{/literal}{$useSelectedPageFormat}{literal}' );
268 document.getElementById("bind_format").checked = true;
272 document.getElementById("saveDetails").style.display = "none";
273 document.getElementById("saveTemplateName").disabled = true;
274 if ( ! templateSelected ) {
275 document.getElementById("bindFormat").style.display = "none";
276 document.getElementById("bind_format").checked = false;