2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.4 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2013 |
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 <div class="crm-profile-name-{$ufGroupName}">
27 {crmRegion name=profile-form-`$ufGroupName`}
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')}
33 <script type="text/javascript">
35 $('#profile-dialog .crm-container-snippet #Edit').validate(CRM.validate.params);
37 success: checkResponse // post-submit callback
40 //binding the callback to snippet profile form
41 $('.crm-container-snippet #Edit').ajaxForm(formOptions);
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}';
54 {include file="CRM/Form/validate.tpl"}
57 <div class="messages status no-popup">
58 <div class="icon inform-icon"></div>
59 {ts}Are you sure you want to delete this record?{/ts}
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>
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" *}
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">
71 <div id="crm-container" class="crm-container crm-public" lang="{$config->lcMessages|truncate:2:"":true}" xml:lang="{$config->lcMessages|truncate:2:"":true}">
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>
79 {if $mode eq 1 || $activeComponent neq "CiviCRM"}
80 {include file="CRM/Form/body.tpl"}
83 {if $help_pre && $action neq 4}
84 <div class="messages help">{$help_pre}</div>
87 {include file="CRM/common/CMSUser.tpl"}
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}
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}
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>
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>
115 {if $field.field_type eq "Formatting"}
118 {if $field.groupTitle != $fieldset}
119 {if $fieldset != $zeroField}
121 <div class="messages help">{$groupHelpPost}</div>
123 {if $mode neq 8 && $mode neq 4}
124 </div><!-- end form-layout-compressed-div -->
129 <div class="form-layout-compressed">
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>
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"}
142 <table class="form-layout-compressed">
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}
148 {assign var="index" value=`$index+1`}
150 <td class="labels font-light">{$form.$n.$key.html}</td>
151 {if $count == $field.options_per_line}
154 {assign var="count" value="1"}
156 {assign var="count" value=`$count+1`}
162 {if $field.html_type eq 'Radio' and $form.formName eq 'Edit' and $field.is_view neq 1 }
163 <span class="crm-clear-link">(<a href="#" title="unselect" onclick="unselectRadio('{$n}', '{$form.formName}'); return false;">{ts}clear{/ts}</a>)</span>
167 <div class="clear"></div>
168 </div>{* end of main edit section div*}
170 <div id="editrow-{$n}" class="crm-section editrow_{$n}-section form-item">
174 <div class="edit-value content">
175 {if $n|substr:0:3 eq 'im-'}
176 {assign var="provider" value=$n|cat:"-provider_id"}
177 {$form.$provider.html}
178 {elseif $n|substr:0:4 eq 'url-'}
179 {assign var="websiteType" value=$n|cat:"-website_type_id"}
180 {$form.$websiteType.html}
182 {if $n eq 'email_greeting' or $n eq 'postal_greeting' or $n eq 'addressee'}
183 {include file="CRM/Profile/Form/GreetingType.tpl"}
184 {elseif ( $n eq 'group' && $form.group ) || ( $n eq 'tag' && $form.tag )}
185 {include file="CRM/Contact/Form/Edit/TagsAndGroups.tpl" type=$n context="profile"}
186 {elseif ( $form.$n.name eq 'image_URL' )}
188 {if !empty($imageURL)}
189 <div class="crm-section contact_image-section">
190 <div class="content">
191 {include file="CRM/Contact/Page/ContactImage.tpl"}
195 {elseif $n|substr:0:5 eq 'phone'}
196 {assign var="phone_ext_field" value=$n|replace:'phone':'phone_ext'}
198 {if $form.$phone_ext_field.html}
199 {$form.$phone_ext_field.html}
202 {if ( $field.data_type eq 'Date' or
203 ( ( ( $n eq 'birth_date' ) or ( $n eq 'deceased_date' ) or ( $n eq 'activity_date_time' ) ) ) ) and $field.is_view neq 1 }
204 {include file="CRM/common/jcalendar.tpl" elementName=$n}
208 {if (($n eq 'gender') or ($field.html_type eq 'Radio' and $form.formName eq 'Edit' and $field.is_required neq 1)) and
209 ($field.is_view neq 1)}
210 <span class="crm-clear-link">(<a href="#" title="unselect" onclick="unselectRadio('{$n}', '{$form.formName}'); return false;">{ts}clear{/ts}</a>)</span>
211 {elseif $field.html_type eq 'Autocomplete-Select'}
212 {if $field.data_type eq 'ContactReference'}
213 {include file="CRM/Custom/Form/ContactReference.tpl" element_name = $n}
215 {include file="CRM/Custom/Form/AutoComplete.tpl" element_name = $n}
220 <div class="clear"></div>
223 {if $form.$n.type eq 'file'}
224 <div class="crm-section file_displayURL-section file_displayURL{$n}-section"><div class="content">{$customFiles.$n.displayURL}</div></div>
225 <div class="crm-section file_deleteURL-section file_deleteURL{$n}-section"><div class="content">{$customFiles.$n.deleteURL}</div></div>
229 {* Show explanatory text for field if not in 'view' mode *}
230 {if $field.help_post && $action neq 4 && $form.$n.html}
231 <div class="crm-section helprow-{$n}-section" id="helprow-{$n}">
232 <div class="content description">{$field.help_post}</div>
235 {/if}{* end of main if field name if *}
237 </div><!-- end form-layout-compressed for last profile --> {* closing main form layout div when all the fields are built*}
240 {if $isCaptcha && ( $mode eq 8 || $mode eq 4 || $mode eq 1 ) }
241 {include file='CRM/common/ReCAPTCHA.tpl'}
242 <script type="text/javascript">cj('.recaptcha_label').attr('width', '140px');</script>
245 {if $field.groupHelpPost}
246 <div class="messages help">{$field.groupHelpPost}</div>
249 {if $mode neq 8 && $mode neq 4}
254 {if ($action eq 1 and $mode eq 4 ) or ($action eq 2) or ($action eq 8192)}
255 {if $action eq 2 and $multiRecordFieldListing}
256 {include file="CRM/Profile/Page/MultipleRecordFieldsListing.tpl" showListing=true}
257 {assign var=floatStyle value='float:right'}
259 <div class="crm-submit-buttons" style='{$floatStyle}'>
260 {include file="CRM/common/formButtons.tpl"}{if $isDuplicate}<span class="crm-button">{$form._qf_Edit_upload_duplicate.html}</span>{/if}
263 {if $help_post && $action neq 4}<br /><div class="messages help">{$help_post}</div>{/if}
266 </div> {* end crm-container div *}
268 <script type="text/javascript">
271 if ( document.getElementsByName("cms_create_account")[0].checked ) {
272 cj('#details').show();
275 cj('#details').hide();
280 {/if} {* fields array is not empty *}
281 {if $multiRecordFieldListing and empty($fields)}
282 {include file="CRM/Profile/Page/MultipleRecordFieldsListing.tpl" showListing=true}
285 {include file="CRM/common/showHideByFieldValue.tpl"
286 trigger_field_id ="create_account"
288 target_element_id ="details"
289 target_element_type ="block"
293 {elseif $statusMessage}
294 <div class="messages status no-popup">
295 <div class="icon inform-icon"></div>
299 {/if} {*end of if for $deleteRecord*}
301 <script type="text/javascript">
303 cj(document).ready(function(){
304 cj('#selector tr:even').addClass('odd-row ');
305 cj('#selector tr:odd ').addClass('even-row');
308 {if $context eq 'dialog'}
311 beforeSubmit: showRequest
314 // bind form using 'ajaxForm'
315 cj('#Edit').ajaxForm( options );
317 // FIXME - this is improper use of jquery.form
318 // Do not use this code as an example
319 function showRequest(formData, jqForm, options) {
320 // formData is an array; here we use $.param to convert it to a string to display it
321 // but the form plugin does this for you automatically when it submits the data
322 var queryString = cj.param(formData);
323 queryString = queryString + '&snippet=5&gid=' + {/literal}"{$profileID}"{literal};
324 var postUrl = {/literal}"{crmURL p='civicrm/profile/create' h=0 }"{literal};
325 var blockNo = {/literal}{if $blockNo}{$blockNo}{else}null{/if}{literal};
326 var prefix = {/literal}"{$prefix}"{literal};
327 var response = cj.ajax({
330 async: false, // FIXME
333 success: function( response ) {
334 if ( response.newContactSuccess ) {
335 cj('#' + prefix + 'contact_' + blockNo ).val( response.sortName ).focus( );
336 if ( typeof(allowMultiClient) != "undefined" ) {
337 if ( allowMultiClient ) {
338 cj('#' + prefix + 'contact_' + blockNo).tokenInput("add", {id: response.contactID, name: response.sortName });
341 cj('input[name="' + prefix + 'contact_select_id[' + blockNo +']"]').val( response.contactID );
342 CRM.alert(response.displayName + {/literal}'{ts escape="js"} has been created.{/ts}', '{ts escape="js"}Contact Saved{/ts}'{literal}, 'success');
343 cj('#contact-dialog-' + prefix + blockNo ).dialog('close');
348 cj('#contact-dialog-' + prefix + blockNo).html( response );
350 // FIXME - we have used jquery.form very incorrectly
351 // and are now preventing it from doing what it's supposed to do
362 </div> {* end crm-profile-NAME *}