07ddfcfdff6688c2a86b18db3a923e12864b7413
[civicrm-core.git] / templates / CRM / Contact / Form / Edit / CommunicationPreferences.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.6 |
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 {* This file provides the plugin for the communication preferences in all the three types of contact *}
27 {* @var $form Contains the array for the form elements and other form associated information assigned to the template by the controller *}
28
29 <div class="crm-accordion-wrapper crm-commPrefs-accordion collapsed">
30 <div class="crm-accordion-header">
31 {$title}
32 </div><!-- /.crm-accordion-header -->
33 <div id="commPrefs" class="crm-accordion-body">
34 <table class="form-layout-compressed" >
35 {if !empty($form.communication_style_id)}
36 <tr><td colspan='4'>
37 <span class="label">{$form.communication_style_id.label} {help id="id-communication_style" file="CRM/Contact/Form/Contact.hlp"}</span>
38 <span class="value">{$form.communication_style_id.html}</span>
39 </td><tr>
40 {/if}
41 <tr>
42 {if !empty($form.email_greeting_id)}
43 <td>{$form.email_greeting_id.label}</td>
44 {/if}
45 {if !empty($form.postal_greeting_id)}
46 <td>{$form.postal_greeting_id.label}</td>
47 {/if}
48 {if !empty($form.addressee_id)}
49 <td>{$form.addressee_id.label}</td>
50 {/if}
51 {if !empty($form.email_greeting_id) OR !empty($form.postal_greeting_id) OR !empty($form.addressee_id)}
52 <td>&nbsp;&nbsp;{help id="id-greeting" file="CRM/Contact/Form/Contact.hlp"}</td>
53 {/if}
54 </tr>
55 <tr>
56 {if !empty($form.email_greeting_id)}
57 <td>
58 <span id="email_greeting" {if !empty($email_greeting_display) and $action eq 2} class="hiddenElement"{/if}>{$form.email_greeting_id.html|crmAddClass:big}</span>
59 {if !empty($email_greeting_display) and $action eq 2}
60 <div id="email_greeting_display" class="view-data">{$email_greeting_display}&nbsp;&nbsp;<a href="#" onclick="showGreeting('email_greeting');return false;"><img src="{$config->resourceBase}i/edit.png" border="0" title="{ts}Edit{/ts}"></a></div>
61 {/if}
62 </td>
63 {/if}
64 {if !empty($form.postal_greeting_id)}
65 <td>
66 <span id="postal_greeting" {if !empty($postal_greeting_display) and $action eq 2} class="hiddenElement"{/if}>{$form.postal_greeting_id.html|crmAddClass:big}</span>
67 {if !empty($postal_greeting_display) and $action eq 2}
68 <div id="postal_greeting_display" class="view-data">{$postal_greeting_display}&nbsp;&nbsp;<a href="#" onclick="showGreeting('postal_greeting');return false;"><img src="{$config->resourceBase}i/edit.png" border="0" title="{ts}Edit{/ts}"></a></div>
69 {/if}
70 </td>
71 {/if}
72 {if !empty($form.addressee_id)}
73 <td>
74 <span id="addressee" {if !empty($addressee_display) and $action eq 2} class="hiddenElement"{/if}>{$form.addressee_id.html|crmAddClass:big}</span>
75 {if !empty($addressee_display) and $action eq 2}
76 <div id="addressee_display" class="view-data">{$addressee_display}&nbsp;&nbsp;<a href="#" onclick="showGreeting('addressee');return false;"><img src="{$config->resourceBase}i/edit.png" border="0" title="{ts}Edit{/ts}"></a></div>
77 {/if}
78 </td>
79 {/if}
80 </tr>
81 <tr id="greetings1" class="hiddenElement">
82 {if !empty($form.email_greeting_custom)}
83 <td><span id="email_greeting_id_label" class="hiddenElement">{$form.email_greeting_custom.label}</span></td>
84 {/if}
85 {if !empty($form.postal_greeting_custom)}
86 <td><span id="postal_greeting_id_label" class="hiddenElement">{$form.postal_greeting_custom.label}</span></td>
87 {/if}
88 {if !empty($form.addressee_custom)}
89 <td><span id="addressee_id_label" class="hiddenElement">{$form.addressee_custom.label}</span></td>
90 {/if}
91 </tr>
92 <tr id="greetings2" class="hiddenElement">
93 {if !empty($form.email_greeting_custom)}
94 <td><span id="email_greeting_id_html" class="hiddenElement">{$form.email_greeting_custom.html|crmAddClass:big}</span></td>
95 {/if}
96 {if !empty($form.postal_greeting_custom)}
97 <td><span id="postal_greeting_id_html" class="hiddenElement">{$form.postal_greeting_custom.html|crmAddClass:big}</span></td>
98 {/if}
99 {if !empty($form.addressee_custom)}
100 <td><span id="addressee_id_html" class="hiddenElement">{$form.addressee_custom.html|crmAddClass:big}</span></td>
101 {/if}
102 </tr>
103 <tr>
104 {foreach key=key item=item from=$commPreference}
105 <td>
106 <br /><span class="label">{$form.$key.label}</span> {help id="id-$key" file="CRM/Contact/Form/Contact.hlp"}
107 {foreach key=k item=i from=$item}
108 <br />{$form.$key.$k.html}
109 {/foreach}
110 </td>
111 {/foreach}
112 <td>
113 <br /><span class="label">{$form.preferred_language.label}</span>
114 <br />{$form.preferred_language.html}
115 </td>
116 </tr>
117 <tr>
118 <td>{$form.is_opt_out.html} {$form.is_opt_out.label} {help id="id-optOut" file="CRM/Contact/Form/Contact.hlp"}</td>
119 {if !empty($form.preferred_mail_format)}
120 <td>{$form.preferred_mail_format.label} &nbsp;
121 {$form.preferred_mail_format.html} {help id="id-emailFormat" file="CRM/Contact/Form/Contact.hlp"}
122 </td>
123 {/if}
124 </tr>
125 </table>
126 </div><!-- /.crm-accordion-body -->
127 </div><!-- /.crm-accordion-wrapper -->
128
129
130 {literal}
131 <script type="text/javascript">
132 CRM.$(function($) {
133 var fields = new Array( 'postal_greeting', 'addressee', 'email_greeting');
134 for ( var i = 0; i < 3; i++ ) {
135 $( "#" + fields[i] + "_id").change( function( ) {
136 var fldName = $(this).attr( 'id' );
137 if ( $(this).val( ) == 4 ) {
138 $("#greetings1").show( );
139 $("#greetings2").show( );
140 $( "#" + fldName + "_html").show( );
141 $( "#" + fldName + "_label").show( );
142 } else {
143 $( "#" + fldName + "_html").hide( );
144 $( "#" + fldName + "_label").hide( );
145 $( "#" + fldName.slice(0, -3) + "_custom" ).val('');
146 }
147 });
148 }
149 });
150
151 function showGreeting( element ) {
152 cj("#" + element ).show( );
153 cj("#" + element + '_display' ).hide( );
154
155 // TO DO fix for custom greeting
156 var fldName = '#' + element + '_id';
157 if ( cj( fldName ).val( ) == 4 ) {
158 cj("#greetings1").show( );
159 cj("#greetings2").show( );
160 cj( fldName + "_html").show( );
161 cj( fldName + "_label").show( );
162 }
163 }
164
165
166 </script>
167 {/literal}