Merge pull request #2308 from civicrm/4.4
[civicrm-core.git] / templates / CRM / Contact / Form / OnBehalfOf.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 HTML for the on-behalf-of form. Can also be used for related contact edit form. *}
27 <fieldset id="for_organization" class="for_organization-group">
28 <legend>{$fieldSetTitle}</legend>
29 {if $contact_type eq 'Individual'}
30
31 {if $contactEditMode}<fieldset><legend></legend>{/if}
32 <table class="form-layout-compressed">
33 <tr>
34 <td>{$form.prefix_id.label}</td>
35 <td>{$form.first_name.label}</td>
36 <td>{$form.middle_name.label}</td>
37 <td>{$form.last_name.label}</td>
38 <td>{$form.suffix_id.label}</td>
39 </tr>
40 <tr>
41 <td>{$form.prefix_id.html}</td>
42 <td>{$form.first_name.html}</td>
43 <td>{$form.middle_name.html|crmAddClass:eight}</td>
44 <td>{$form.last_name.html}</td>
45 <td>{$form.suffix_id.html}</td>
46 </tr>
47
48 </table>
49 {if $contactEditMode}</fieldset>{/if}
50
51
52 {elseif $contact_type eq 'Household'}
53
54 {if $contactEditMode}<fieldset><legend></legend>{/if}
55 <table class="form-layout-compressed">
56 <tr>
57 <td>{$form.household_name.label}</td>
58 </tr>
59 <tr>
60 <td>{$form.household_name.html|crmAddClass:big}</td>
61 </tr>
62 </table>
63 {if $contactEditMode}</fieldset>{/if}
64
65
66 {elseif $contact_type eq 'Organization'}
67
68 {if $contactEditMode}
69 <fieldset><legend></legend>
70 {/if}
71 <div class="crm-section organizationName-section">
72 {if $relatedOrganizationFound}
73 <div class="section crm-section">
74 <div class="content">{$form.org_option.html}</div>
75 </div>
76 <div id="select_org" class="crm-section select_org-section">
77 <div class="label">{$form.organization_name.label}</div>
78 <div class="content">{$form.organization_id.html|crmAddClass:big}</div>
79 </div>
80 {/if}
81 <div id="create_org" class="crm-section create_org-section">
82 <div class="label">{$form.organization_name.label}</div>
83 <div class="content">{$form.organization_name.html|crmAddClass:big}</div>
84 <div class="clear"></div>
85 </div>
86 </div>
87 {if $contactEditMode}
88 </fieldset>
89 {/if}
90
91 {/if}
92
93 {* Display the address block *}
94 {assign var=index value=1}
95
96 {if $contactEditMode}
97 <fieldset><legend>{ts}Phone and Email{/ts}</legend>
98 <table class="form-layout-compressed">
99 <tr>
100 <td class='label' width="25%">{$form.phone.$index.phone.label}</td>
101 <td class='value'>{$form.phone.$index.phone.html}</td>
102 </tr>
103 <tr>
104 <td class='label'>{$form.email.$index.email.label}</td>
105 <td class='value'>{$form.email.$index.email.html}</td>
106 </tr>
107 </table>
108 </fieldset>
109 {/if}
110
111 {if $contactEditMode}<fieldset><legend>{ts}Address{/ts}</legend>{/if}
112 <div class="crm-section address-section">
113 {if !$contactEditMode}
114 <div class="crm-section {$form.phone.$index.phone.id}-section">
115 <div class="label">{$form.phone.$index.phone.label}</div>
116 <div class="content">{$form.phone.$index.phone.html}</div>
117 <div class="clear"></div>
118 </div>
119 <div class="crm-section {$form.email.$index.email.id}-section">
120 <div class="label">{$form.email.$index.email.label}</div>
121 <div class="content">{$form.email.$index.email.html}</div>
122 <div class="clear"></div>
123 </div>
124 {/if}
125 {if $addressSequence.street_address}
126 <div class="crm-section {$form.address.$index.street_address.id}-section">
127 <div class="label">{$form.address.$index.street_address.label}</div>
128 <div class="content">{$form.address.$index.street_address.html}
129 <br class="spacer"/>
130 <span class="description">{ts}Street number, street name, apartment/unit/suite - OR P.O. box{/ts}</span>
131 </div>
132 <div class="clear"></div>
133 </div>
134 {/if}
135 {if $addressSequence.supplemental_address_1}
136 <div class="crm-section {$form.address.$index.supplemental_address_1.id}-section">
137 <div class="label">{$form.address.$index.supplemental_address_1.label}</div>
138 <div class="content">{$form.address.$index.supplemental_address_1.html}
139 <br class="spacer"/>
140 <span class="description">{ts}Supplemental address info, e.g. c/o, department name, building name, etc.{/ts}</span>
141 </div>
142 <div class="clear"></div>
143 </div>
144 {/if}
145 {if $addressSequence.supplemental_address_2}
146 <div class="crm-section {$form.address.$index.supplemental_address_2.id}-section">
147 <div class="label">{$form.address.$index.supplemental_address_2.label}</div>
148 <div class="content">{$form.address.$index.supplemental_address_2.html}</div>
149 <div class="clear"></div>
150 </div>
151 {/if}
152 {if $addressSequence.city}
153 <div class="crm-section {$form.address.$index.city.id}<-section">
154 <div class="label">{$form.address.$index.city.label}</div>
155 <div class="content">{$form.address.$index.city.html}</div>
156 <div class="clear"></div>
157 </div>
158 {/if}
159 {if $addressSequence.postal_code}
160 <div class="crm-section {$form.address.$index.postal_code.id}-section">
161 <div class="label">{$form.address.$index.postal_code.label}</div>
162 <div class="content">{$form.address.$index.postal_code.html}
163 {if $form.address.$index.postal_code_suffix.html}
164 - {$form.address.$index.postal_code_suffix.html}
165 <br class="spacer"/>
166 <span class="description">{ts}Enter optional 'add-on' code after the dash ('plus 4' code for U.S. addresses).{/ts}</span>
167 {/if}
168 </div>
169 <div class="clear"></div>
170 </div>
171 {/if}
172 {if $addressSequence.country}
173 <div class="crm-section {$form.address.$index.country_id.id}-section">
174 <div class="label">{$form.address.$index.country_id.label}</div>
175 <div class="content">{$form.address.$index.country_id.html}</div>
176 <div class="clear"></div>
177 </div>
178 {/if}
179 {if $addressSequence.state_province}
180 <div class="crm-section {$form.address.$index.state_province_id.id}-section">
181 <div class="label">{$form.address.$index.state_province_id.label}</div>
182 <div class="content">{$form.address.$index.state_province_id.html}</div>
183 <div class="clear"></div>
184 </div>
185 {/if}
186 {if $contactEditMode and $form.location.$index.address.geo_code_1.label}
187 <div class="crm-section {$form.address.$index.geo_code_1.id}-{$form.address.$index.geo_code_2.id}-section">
188 <div class="label">{$form.address.$index.geo_code_1.label}, {$form.address.$index.geo_code_2.label}</div>
189 <div class="content">{$form.address.$index.geo_code_1.html}, {$form.address.$index.geo_code_2.html}
190 <br class="spacer"/>
191 <span class="description">
192 {ts}Latitude and longitude may be automatically populated by enabling a Mapping Provider.{/ts} {docURL page="user/initial-set-up/installation-and-basic-setup" text="(Refer to the Mapping and Geocoding section in the Installation and Basic Setup Chapter)"}</span>
193 </div>
194 <div class="clear"></div>
195 </div>
196 {/if}
197 </div>
198
199 {if $contactEditMode}</fieldset>{/if}
200
201 </fieldset>
202
203 {if $form.is_for_organization}
204 {include file="CRM/common/showHideByFieldValue.tpl"
205 trigger_field_id ="is_for_organization"
206 trigger_value ="true"
207 target_element_id ="for_organization"
208 target_element_type ="block"
209 field_type ="radio"
210 invert = "false"
211 }
212 {/if}
213
214 {if $relatedOrganizationFound}
215 {include file="CRM/common/showHideByFieldValue.tpl"
216 trigger_field_id ="org_option"
217 trigger_value ="true"
218 target_element_id ="select_org"
219 target_element_type ="table-row"
220 field_type ="radio"
221 invert = "true"
222 }
223 {include file="CRM/common/showHideByFieldValue.tpl"
224 trigger_field_id ="org_option"
225 trigger_value ="true"
226 target_element_id ="create_org"
227 target_element_type ="table-row"
228 field_type ="radio"
229 invert = "false"
230 }
231 {/if}
232
233 {literal}
234 <script type="text/javascript">
235 {/literal}
236 {* If mid present in the url, take the required action (poping up related existing contact ..etc) *}
237 {if $membershipContactID}
238 {literal}
239 cj( function( ) {
240 cj( '#organization_id' ).val("{/literal}{$membershipContactName}{literal}");
241 cj( '#organization_name' ).val("{/literal}{$membershipContactName}{literal}");
242 cj( '#onbehalfof_id' ).val("{/literal}{$membershipContactID}{literal}");
243 setLocationDetails( "{/literal}{$membershipContactID}{literal}" );
244 });
245 {/literal}
246 {/if}
247 {* Javascript method to populate the location fields when a different existing related contact is selected *}
248 {literal}
249 var dataUrl = "{/literal}{$employerDataURL}{literal}";
250 cj('#organization_id').autocomplete( dataUrl, { width : 180, selectFirst : false, matchContains: true, max: {/literal}{crmSetting name="search_autocomplete_count" group="Search Preferences"}{literal}
251 }).result( function(event, data, formatted) {
252 cj('#organization_name').val( data[0] );
253 cj('#onbehalfof_id').val( data[1] );
254 setLocationDetails( data[1] );
255 });
256
257 var orgId = {/literal}"{$orgId}"{literal};
258 if ( orgId ) {
259 setLocationDetails( orgId );
260 }
261
262 function setLocationDetails( contactID ) {
263 var locationUrl = {/literal}"{$locDataURL}"{literal}+ contactID + "&relContact=1";
264
265 cj.ajax({
266 url : locationUrl,
267 dataType : "json",
268 timeout : 5000, //Time in milliseconds
269 success : function( data, status ) {
270 for (var ele in data) {
271 cj( "#"+ele ).val( data[ele] );
272 }
273 },
274 error : function( XMLHttpRequest, textStatus, errorThrown ) {
275 console.error("HTTP error status: ", textStatus);
276 }
277 });
278 }
279 </script>
280 {/literal}