Merge pull request #2600 from kurund/relationship-cleanup
[civicrm-core.git] / templates / CRM / Profile / Form / Dynamic.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 <div class="crm-profile-name-{$ufGroupName}">
27 {crmRegion name=profile-form-`$ufGroupName`}
28
29 {* Profile forms when embedded in CMS account create (mode=1) or
30 cms account edit (mode=8) or civicrm/profile (mode=4) pages *}
31 {if ($context eq 'multiProfileDialog')}
32 {literal}
33 <script type="text/javascript">
34 cj(function($) {
35 $('#profile-dialog .crm-container-snippet #Edit').validate(CRM.validate.params);
36 var formOptions = {
37 success: checkResponse // post-submit callback
38 };
39
40 //binding the callback to snippet profile form
41 $('.crm-container-snippet #Edit').ajaxForm(formOptions);
42 });
43
44 // post-submit callback
45 function checkResponse(responseText, statusText, xhr, $form) {
46 //if there is any form error show the dialog
47 //else redirect to post url
48 if (!cj(responseText).find('.crm-error').html()) {
49 window.location = '{/literal}{$postUrl}{literal}';
50 }
51 }
52 </script>
53 {/literal}
54 {include file="CRM/Form/validate.tpl"}
55 {/if}
56 {if $deleteRecord}
57 <div class="messages status no-popup">
58 <div class="icon inform-icon"></div>&nbsp;
59 {ts}Are you sure you want to delete this record?{/ts}
60 </div>
61 <span class="crm-button">{$form._qf_Edit_upload_delete.html}</span>
62 <div class="crm-submit-buttons" style='display:inline'>{include file="CRM/common/formButtons.tpl"}</div>
63 {else}
64 {if ! empty( $fields )}
65 {* Wrap in crm-container div so crm styles are used.*}
66 {* Replace div id "crm-container" only when profile is not loaded in civicrm container, i.e for profile shown in my account and in profile standalone mode otherwise id should be "crm-profile-block" *}
67
68 {if $action eq 1 or $action eq 2 or $action eq 4 }
69 <div id="crm-profile-block" class="crm-container-snippet crm-public">
70 {else}
71 <div id="crm-container" class="crm-container crm-public" lang="{$config->lcMessages|truncate:2:"":true}" xml:lang="{$config->lcMessages|truncate:2:"":true}">
72 {/if}
73
74 {if $isDuplicate and ( ($action eq 1 and $mode eq 4 ) or ($action eq 2) or ($action eq 8192) ) }
75 <div class="crm-submit-buttons">
76 <span class="crm-button">{$form._qf_Edit_upload_duplicate.html}</span>
77 </div>
78 {/if}
79 {if $mode eq 1 || $activeComponent neq "CiviCRM"}
80 {include file="CRM/Form/body.tpl"}
81 {/if}
82 {strip}
83 {if $help_pre && $action neq 4}
84 <div class="messages help">{$help_pre}</div>
85 {/if}
86
87 {include file="CRM/common/CMSUser.tpl"}
88
89 {if $action eq 2 and $multiRecordFieldListing}
90 <h1>{ts}Edit Details{/ts}</h1>
91 <div class="crm-submit-buttons" style='float:right'>
92 {include file="CRM/common/formButtons.tpl"}{if $isDuplicate}<span class="crm-button">{$form._qf_Edit_upload_duplicate.html}</span>{/if}
93 </div>
94 {/if}
95
96 {assign var=zeroField value="Initial Non Existent Fieldset"}
97 {assign var=fieldset value=$zeroField}
98 {foreach from=$fields item=field key=fieldName}
99 {if $field.skipDisplay}
100 {continue}
101 {/if}
102 {assign var="profileID" value=$field.group_id}
103 {assign var=n value=$field.name}
104 {if $field.groupTitle != $fieldset}
105 {if $mode neq 8 && $mode neq 4}
106 <div {if $context neq 'dialog'}id="profilewrap{$field.group_id}"{/if}>
107 <fieldset><legend>{$field.groupTitle}</legend>
108 {/if}
109 {assign var=fieldset value=`$field.groupTitle`}
110 {assign var=groupHelpPost value=`$field.groupHelpPost`}
111 {if $field.groupHelpPre}
112 <div class="messages help">{$field.groupHelpPre}</div>
113 {/if}
114 {/if}
115 {if $field.field_type eq "Formatting"}
116 {$field.help_pre}
117 {elseif $n}
118 {if $field.groupTitle != $fieldset}
119 {if $fieldset != $zeroField}
120 {if $groupHelpPost}
121 <div class="messages help">{$groupHelpPost}</div>
122 {/if}
123 {if $mode neq 8 && $mode neq 4}
124 </div><!-- end form-layout-compressed-div -->
125 </fieldset>
126 </div>
127 {/if}
128 {/if}
129 <div class="form-layout-compressed">
130 {/if}
131 {if $field.help_pre && $action neq 4 && $form.$n.html}
132 <div class="crm-section helprow-{$n}-section" id="helprow-{$n}">
133 <div class="content description">{$field.help_pre}</div>
134 </div>
135 {/if}
136 {if $field.options_per_line}
137 <div class="crm-section editrow_{$n}-section form-item" id="editrow-{$n}">
138 <div class="label">{$form.$n.label}</div>
139 <div class="content edit-value">
140 {assign var="count" value="1"}
141 {strip}
142 <table class="form-layout-compressed">
143 <tr>
144 {* sort by fails for option per line. Added a variable to iterate through the element array*}
145 {assign var="index" value="1"}
146 {foreach name=outer key=key item=item from=$form.$n}
147 {if $index < 10}
148 {assign var="index" value=`$index+1`}
149 {else}
150 <td class="labels font-light">{$form.$n.$key.html}</td>
151 {if $count == $field.options_per_line}
152 </tr>
153 <tr>
154 {assign var="count" value="1"}
155 {else}
156 {assign var="count" value=`$count+1`}
157 {/if}
158 {/if}
159 {/foreach}
160 </tr>
161 </table>
162 {/strip}
163 </div>
164 <div class="clear"></div>
165 </div>{* end of main edit section div*}
166 {else}
167 <div id="editrow-{$n}" class="crm-section editrow_{$n}-section form-item">
168 <div class="label">
169 {$form.$n.label}
170 </div>
171 <div class="edit-value content">
172 {if $n|substr:0:3 eq 'im-'}
173 {assign var="provider" value=$n|cat:"-provider_id"}
174 {$form.$provider.html}&nbsp;
175 {elseif $n|substr:0:4 eq 'url-'}
176 {assign var="websiteType" value=$n|cat:"-website_type_id"}
177 {$form.$websiteType.html}&nbsp;
178 {/if}
179 {if $n eq 'email_greeting' or $n eq 'postal_greeting' or $n eq 'addressee'}
180 {include file="CRM/Profile/Form/GreetingType.tpl"}
181 {elseif ( $n eq 'group' && $form.group ) || ( $n eq 'tag' && $form.tag )}
182 {include file="CRM/Contact/Form/Edit/TagsAndGroups.tpl" type=$n context="profile"}
183 {elseif ( $form.$n.name eq 'image_URL' )}
184 {$form.$n.html}
185 {if !empty($imageURL)}
186 <div class="crm-section contact_image-section">
187 <div class="content">
188 {include file="CRM/Contact/Page/ContactImage.tpl"}
189 </div>
190 </div>
191 {/if}
192 {elseif $n|substr:0:5 eq 'phone'}
193 {assign var="phone_ext_field" value=$n|replace:'phone':'phone_ext'}
194 {$form.$n.html}
195 {if $form.$phone_ext_field.html}
196 &nbsp;{$form.$phone_ext_field.html}
197 {/if}
198 {else}
199 {if ( $field.data_type eq 'Date' or
200 ( ( ( $n eq 'birth_date' ) or ( $n eq 'deceased_date' ) or ( $n eq 'activity_date_time' ) ) ) ) and $field.is_view neq 1 }
201 {include file="CRM/common/jcalendar.tpl" elementName=$n}
202 {else}
203 {$form.$n.html}
204 {/if}
205 {if $field.html_type eq 'Autocomplete-Select'}
206 {if $field.data_type eq 'ContactReference'}
207 {include file="CRM/Custom/Form/ContactReference.tpl" element_name = $n}
208 {/if}
209 {/if}
210 {/if}
211 </div>
212 <div class="clear"></div>
213 </div>
214
215 {if $form.$n.type eq 'file'}
216 <div class="crm-section file_displayURL-section file_displayURL{$n}-section"><div class="content">{$customFiles.$n.displayURL}</div></div>
217 <div class="crm-section file_deleteURL-section file_deleteURL{$n}-section"><div class="content">{$customFiles.$n.deleteURL}</div></div>
218 {/if}
219 {/if}
220
221 {* Show explanatory text for field if not in 'view' mode *}
222 {if $field.help_post && $action neq 4 && $form.$n.html}
223 <div class="crm-section helprow-{$n}-section" id="helprow-{$n}">
224 <div class="content description">{$field.help_post}</div>
225 </div>
226 {/if}
227 {/if}{* end of main if field name if *}
228 {/foreach}
229
230 {if $isCaptcha && ( $mode eq 8 || $mode eq 4 || $mode eq 1 ) }
231 {include file='CRM/common/ReCAPTCHA.tpl'}
232 <script type="text/javascript">cj('.recaptcha_label').attr('width', '140px');</script>
233 {/if}
234
235 {if $field.groupHelpPost}
236 <div class="messages help">{$field.groupHelpPost}</div>
237 {/if}
238
239 {if $mode neq 8 && $mode neq 4}
240 </fieldset>
241 </div>
242 {/if}
243
244 {if ($action eq 1 and $mode eq 4 ) or ($action eq 2) or ($action eq 8192)}
245 {if $action eq 2 and $multiRecordFieldListing}
246 {include file="CRM/Profile/Page/MultipleRecordFieldsListing.tpl" showListing=true}
247 {assign var=floatStyle value='float:right'}
248 {/if}
249 <div class="crm-submit-buttons" style='{$floatStyle}'>
250 {include file="CRM/common/formButtons.tpl"}{if $isDuplicate}<span class="crm-button">{$form._qf_Edit_upload_duplicate.html}</span>{/if}
251 </div>
252 {/if}
253 {if $help_post && $action neq 4}<br /><div class="messages help">{$help_post}</div>{/if}
254 {/strip}
255
256 </div> {* end crm-container div *}
257
258 <script type="text/javascript">
259 {if $drupalCms}
260 {literal}
261 if ( document.getElementsByName("cms_create_account")[0].checked ) {
262 cj('#details').show();
263 }
264 else {
265 cj('#details').hide();
266 }
267 {/literal}
268 {/if}
269 </script>
270 {/if} {* fields array is not empty *}
271 {if $multiRecordFieldListing and empty($fields)}
272 {include file="CRM/Profile/Page/MultipleRecordFieldsListing.tpl" showListing=true}
273 {/if}
274 {if $drupalCms}
275 {include file="CRM/common/showHideByFieldValue.tpl"
276 trigger_field_id ="create_account"
277 trigger_value =""
278 target_element_id ="details"
279 target_element_type ="block"
280 field_type ="radio"
281 invert = 0
282 }
283 {elseif $statusMessage}
284 <div class="messages status no-popup">
285 <div class="icon inform-icon"></div>
286 {$statusMessage}
287 </div>
288 {/if}
289 {/if} {*end of if for $deleteRecord*}
290 {literal}
291 <script type="text/javascript">
292
293 cj(document).ready(function(){
294 cj('#selector tr:even').addClass('odd-row ');
295 cj('#selector tr:odd ').addClass('even-row');
296 });
297 {/literal}
298 </script>
299
300 {/crmRegion}
301 </div> {* end crm-profile-NAME *}