Merge remote-tracking branch 'upstream/4.3' into 4.3-4.4-2013-10-23-19-26-23
[civicrm-core.git] / templates / CRM / Contact / Form / Edit / CommunicationPreferences.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.4 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2013 |
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 <tr>
36 {if !empty($form.email_greeting_id)}
37 <td>{$form.email_greeting_id.label}</td>
38 {/if}
39 {if !empty($form.postal_greeting_id)}
40 <td>{$form.postal_greeting_id.label}</td>
41 {/if}
42 {if !empty($form.addressee_id)}
43 <td>{$form.addressee_id.label}</td>
44 {/if}
45 {if !empty($form.email_greeting_id) OR !empty($form.postal_greeting_id) OR !empty($form.addressee_id)}
46 <td>&nbsp;&nbsp;{help id="id-greeting" file="CRM/Contact/Form/Contact.hlp"}</td>
47 {/if}
48 </tr>
49 <tr>
50 {if !empty($form.email_greeting_id)}
51 <td>
52 <span id="email_greeting" {if !empty($email_greeting_display) and $action eq 2} class="hiddenElement"{/if}>{$form.email_greeting_id.html|crmAddClass:big}</span>
53 {if !empty($email_greeting_display) and $action eq 2}
54 <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>
55 {/if}
56 </td>
57 {/if}
58 {if !empty($form.postal_greeting_id)}
59 <td>
60 <span id="postal_greeting" {if !empty($postal_greeting_display) and $action eq 2} class="hiddenElement"{/if}>{$form.postal_greeting_id.html|crmAddClass:big}</span>
61 {if !empty($postal_greeting_display) and $action eq 2}
62 <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>
63 {/if}
64 </td>
65 {/if}
66 {if !empty($form.addressee_id)}
67 <td>
68 <span id="addressee" {if !empty($addressee_display) and $action eq 2} class="hiddenElement"{/if}>{$form.addressee_id.html|crmAddClass:big}</span>
69 {if !empty($addressee_display) and $action eq 2}
70 <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>
71 {/if}
72 </td>
73 {/if}
74 </tr>
75 <tr id="greetings1" class="hiddenElement">
76 {if !empty($form.email_greeting_custom)}
77 <td><span id="email_greeting_id_label" class="hiddenElement">{$form.email_greeting_custom.label}</span></td>
78 {/if}
79 {if !empty($form.postal_greeting_custom)}
80 <td><span id="postal_greeting_id_label" class="hiddenElement">{$form.postal_greeting_custom.label}</span></td>
81 {/if}
82 {if !empty($form.addressee_custom)}
83 <td><span id="addressee_id_label" class="hiddenElement">{$form.addressee_custom.label}</span></td>
84 {/if}
85 </tr>
86 <tr id="greetings2" class="hiddenElement">
87 {if !empty($form.email_greeting_custom)}
88 <td><span id="email_greeting_id_html" class="hiddenElement">{$form.email_greeting_custom.html|crmAddClass:big}</span></td>
89 {/if}
90 {if !empty($form.postal_greeting_custom)}
91 <td><span id="postal_greeting_id_html" class="hiddenElement">{$form.postal_greeting_custom.html|crmAddClass:big}</span></td>
92 {/if}
93 {if !empty($form.addressee_custom)}
94 <td><span id="addressee_id_html" class="hiddenElement">{$form.addressee_custom.html|crmAddClass:big}</span></td>
95 {/if}
96 </tr>
97 <tr>
98 {foreach key=key item=item from=$commPreference}
99 <td>
100 <br /><span class="label">{$form.$key.label}</span> {help id="id-$key" file="CRM/Contact/Form/Contact.hlp"}
101 {foreach key=k item=i from=$item}
102 <br />{$form.$key.$k.html}
103 {/foreach}
104 </td>
105 {/foreach}
106 <td>
107 <br /><span class="label">{$form.preferred_language.label}</span>
108 <br />{$form.preferred_language.html}
109 </td>
110 </tr>
111 <tr>
112 <td>{$form.is_opt_out.html} {$form.is_opt_out.label} {help id="id-optOut" file="CRM/Contact/Form/Contact.hlp"}</td>
113 {if !empty($form.preferred_mail_format)}
114 <td>{$form.preferred_mail_format.label} &nbsp;
115 {$form.preferred_mail_format.html} {help id="id-emailFormat" file="CRM/Contact/Form/Contact.hlp"}
116 </td>
117 {/if}
118 </tr>
119 </table>
120 </div><!-- /.crm-accordion-body -->
121 </div><!-- /.crm-accordion-wrapper -->
122
123
124 {literal}
125 <script type="text/javascript">
126 cj( function( ) {
127 var fields = new Array( 'postal_greeting', 'addressee', 'email_greeting');
128 for ( var i = 0; i < 3; i++ ) {
129 cj( "#" + fields[i] + "_id").change( function( ) {
130 var fldName = cj(this).attr( 'id' );
131 if ( cj(this).val( ) == 4 ) {
132 cj("#greetings1").show( );
133 cj("#greetings2").show( );
134 cj( "#" + fldName + "_html").show( );
135 cj( "#" + fldName + "_label").show( );
136 } else {
137 cj( "#" + fldName + "_html").hide( );
138 cj( "#" + fldName + "_label").hide( );
139 cj( "#" + fldName.slice(0, -3) + "_custom" ).val('');
140 }
141 });
142 }
143 });
144
145 function showGreeting( element ) {
146 cj("#" + element ).show( );
147 cj("#" + element + '_display' ).hide( );
148
149 // TO DO fix for custom greeting
150 var fldName = '#' + element + '_id';
151 if ( cj( fldName ).val( ) == 4 ) {
152 cj("#greetings1").show( );
153 cj("#greetings2").show( );
154 cj( fldName + "_html").show( );
155 cj( fldName + "_label").show( );
156 }
157 }
158
159 </script>
160 {/literal}