2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.3 |
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 beforeSubmit: proccessMultiRecordForm //pre-submit callback
40 //binding the callback to snippet profile form
41 $('.crm-container-snippet #Edit').ajaxForm(formOptions);
44 // pre-submit callback
45 function proccessMultiRecordForm(formData, jqForm, options) {
46 var queryString = cj.param(formData);
47 queryString = queryString + '{/literal}{$urlParams}{literal}' + '&snippet=1';
49 if (cj('#profile-dialog')) {
50 var postUrl = {/literal}"{crmURL p='civicrm/profile/edit' h=0 }"{literal};
51 var response = cj.ajax({
60 //if there is any form error show the dialog
61 //else redirect to post url
62 if (!cj(response).find('.crm-error').html()) {
63 window.location = '{/literal}{$postUrl}{literal}';
66 // here we could return false to prevent the form from being submitted;
67 // returning anything other than false will allow the form submit to continue
73 {include file="CRM/Form/validate.tpl"}
76 <div class="messages status no-popup">
77 <div class="icon inform-icon"></div>
78 {ts}Are you sure you want to delete this record?{/ts}
80 <span class="crm-button">{$form._qf_Edit_upload_delete.html}</span>
81 <div class="crm-submit-buttons" style='display:inline'>{include file="CRM/common/formButtons.tpl"}</div>
83 {if ! empty( $fields )}
84 {* Wrap in crm-container div so crm styles are used.*}
85 {* 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" *}
87 {if $action eq 1 or $action eq 2 or $action eq 4 }
88 <div id="crm-profile-block" class="crm-container-snippet crm-public">
90 <div id="crm-container" class="crm-container crm-public" lang="{$config->lcMessages|truncate:2:"":true}" xml:lang="{$config->lcMessages|truncate:2:"":true}">
93 {if $isDuplicate and ( ($action eq 1 and $mode eq 4 ) or ($action eq 2) or ($action eq 8192) ) }
94 <div class="crm-submit-buttons">
95 <span class="crm-button">{$form._qf_Edit_upload_duplicate.html}</span>
98 {if $mode eq 1 || $activeComponent neq "CiviCRM"}
99 {include file="CRM/Form/body.tpl"}
102 {if $help_pre && $action neq 4}
103 <div class="messages help">{$help_pre}</div>
106 {include file="CRM/common/CMSUser.tpl"}
108 {if $action eq 2 and $multiRecordFieldListing}
109 <h1>{ts}Edit Details{/ts}</h1>
110 <div class="crm-submit-buttons" style='float:right'>
111 {include file="CRM/common/formButtons.tpl"}{if $isDuplicate}<span class="crm-button">{$form._qf_Edit_upload_duplicate.html}</span>{/if}
115 {assign var=zeroField value="Initial Non Existent Fieldset"}
116 {assign var=fieldset value=$zeroField}
117 {foreach from=$fields item=field key=fieldName}
118 {if $field.skipDisplay}
121 {assign var="profileID" value=$field.group_id}
122 {assign var=n value=$field.name}
123 {if $field.groupTitle != $fieldset}
124 {if $mode neq 8 && $mode neq 4}
125 <div {if $context neq 'dialog'}id="profilewrap{$field.group_id}"{/if}>
126 <fieldset><legend>{$field.groupTitle}</legend>
128 {assign var=fieldset value=`$field.groupTitle`}
129 {assign var=groupHelpPost value=`$field.groupHelpPost`}
130 {if $field.groupHelpPre}
131 <div class="messages help">{$field.groupHelpPre}</div>
134 {if $field.field_type eq "Formatting"}
137 {if $field.groupTitle != $fieldset}
138 {if $fieldset != $zeroField}
140 <div class="messages help">{$groupHelpPost}</div>
142 {if $mode neq 8 && $mode neq 4}
143 </div><!-- end form-layout-compressed-div -->
148 <div class="form-layout-compressed">
150 {if $field.help_pre && $action neq 4 && $form.$n.html}
151 <div class="crm-section helprow-{$n}-section" id="helprow-{$n}">
152 <div class="content description">{$field.help_pre}</div>
155 {if $field.options_per_line}
156 <div class="crm-section editrow_{$n}-section form-item" id="editrow-{$n}">
157 <div class="label">{$form.$n.label}</div>
158 <div class="content edit-value">
159 {assign var="count" value="1"}
161 <table class="form-layout-compressed">
163 {* sort by fails for option per line. Added a variable to iterate through the element array*}
164 {assign var="index" value="1"}
165 {foreach name=outer key=key item=item from=$form.$n}
167 {assign var="index" value=`$index+1`}
169 <td class="labels font-light">{$form.$n.$key.html}</td>
170 {if $count == $field.options_per_line}
173 {assign var="count" value="1"}
175 {assign var="count" value=`$count+1`}
181 {if $field.html_type eq 'Radio' and $form.formName eq 'Edit' and $field.is_view neq 1 }
182 <span class="crm-clear-link">(<a href="#" title="unselect" onclick="unselectRadio('{$n}', '{$form.formName}'); return false;">{ts}clear{/ts}</a>)</span>
186 <div class="clear"></div>
187 </div>{* end of main edit section div*}
189 <div id="editrow-{$n}" class="crm-section editrow_{$n}-section form-item">
193 <div class="edit-value content">
194 {if $n|substr:0:3 eq 'im-'}
195 {assign var="provider" value=$n|cat:"-provider_id"}
196 {$form.$provider.html}
197 {elseif $n|substr:0:4 eq 'url-'}
198 {assign var="websiteType" value=$n|cat:"-website_type_id"}
199 {$form.$websiteType.html}
201 {if $n eq 'email_greeting' or $n eq 'postal_greeting' or $n eq 'addressee'}
202 {include file="CRM/Profile/Form/GreetingType.tpl"}
203 {elseif ( $n eq 'group' && $form.group ) || ( $n eq 'tag' && $form.tag )}
204 {include file="CRM/Contact/Form/Edit/TagsAndGroups.tpl" type=$n context="profile"}
205 {elseif ( $form.$n.name eq 'image_URL' )}
207 {if !empty($imageURL)}
208 <div class="crm-section contact_image-section">
209 <div class="content">
210 {include file="CRM/Contact/Page/ContactImage.tpl"}
214 {elseif $n|substr:0:5 eq 'phone'}
215 {assign var="phone_ext_field" value=$n|replace:'phone':'phone_ext'}
217 {if $form.$phone_ext_field.html}
218 {$form.$phone_ext_field.html}
221 {if ( $field.data_type eq 'Date' or
222 ( ( ( $n eq 'birth_date' ) or ( $n eq 'deceased_date' ) or ( $n eq 'activity_date_time' ) ) ) ) and $field.is_view neq 1 }
223 {include file="CRM/common/jcalendar.tpl" elementName=$n}
227 {if (($n eq 'gender') or ($field.html_type eq 'Radio' and $form.formName eq 'Edit' and $field.is_required neq 1)) and
228 ($field.is_view neq 1)}
229 <span class="crm-clear-link">(<a href="#" title="unselect" onclick="unselectRadio('{$n}', '{$form.formName}'); return false;">{ts}clear{/ts}</a>)</span>
230 {elseif $field.html_type eq 'Autocomplete-Select'}
231 {if $field.data_type eq 'ContactReference'}
232 {include file="CRM/Custom/Form/ContactReference.tpl" element_name = $n}
234 {include file="CRM/Custom/Form/AutoComplete.tpl" element_name = $n}
239 <div class="clear"></div>
242 {if $form.$n.type eq 'file'}
243 <div class="crm-section file_displayURL-section file_displayURL{$n}-section"><div class="content">{$customFiles.$n.displayURL}</div></div>
244 <div class="crm-section file_deleteURL-section file_deleteURL{$n}-section"><div class="content">{$customFiles.$n.deleteURL}</div></div>
248 {* Show explanatory text for field if not in 'view' mode *}
249 {if $field.help_post && $action neq 4 && $form.$n.html}
250 <div class="crm-section helprow-{$n}-section" id="helprow-{$n}">
251 <div class="content description">{$field.help_post}</div>
254 {/if}{* end of main if field name if *}
256 </div><!-- end form-layout-compressed for last profile --> {* closing main form layout div when all the fields are built*}
259 {if $isCaptcha && ( $mode eq 8 || $mode eq 4 || $mode eq 1 ) }
260 {include file='CRM/common/ReCAPTCHA.tpl'}
261 <script type="text/javascript">cj('.recaptcha_label').attr('width', '140px');</script>
264 {if $field.groupHelpPost}
265 <div class="messages help">{$field.groupHelpPost}</div>
268 {if $mode neq 8 && $mode neq 4}
273 {if ($action eq 1 and $mode eq 4 ) or ($action eq 2) or ($action eq 8192)}
274 {if $action eq 2 and $multiRecordFieldListing}
275 {include file="CRM/Profile/Page/MultipleRecordFieldsListing.tpl" showListing=true}
276 {assign var=floatStyle value='float:right'}
278 <div class="crm-submit-buttons" style='{$floatStyle}'>
279 {include file="CRM/common/formButtons.tpl"}{if $isDuplicate}<span class="crm-button">{$form._qf_Edit_upload_duplicate.html}</span>{/if}
282 {if $help_post && $action neq 4}<br /><div class="messages help">{$help_post}</div>{/if}
285 </div> {* end crm-container div *}
287 <script type="text/javascript">
290 if ( document.getElementsByName("cms_create_account")[0].checked ) {
291 cj('#details').show();
294 cj('#details').hide();
299 {/if} {* fields array is not empty *}
300 {if $multiRecordFieldListing and empty($fields)}
301 {include file="CRM/Profile/Page/MultipleRecordFieldsListing.tpl" showListing=true}
304 {include file="CRM/common/showHideByFieldValue.tpl"
305 trigger_field_id ="create_account"
307 target_element_id ="details"
308 target_element_type ="block"
312 {elseif $statusMessage}
313 <div class="messages status no-popup">
314 <div class="icon inform-icon"></div>
318 {/if} {*end of if for $deleteRecord*}
320 <script type="text/javascript">
322 cj(document).ready(function(){
323 cj('#selector tr:even').addClass('odd-row ');
324 cj('#selector tr:odd ').addClass('even-row');
327 {if $context eq 'dialog'}
330 beforeSubmit: showRequest
333 // bind form using 'ajaxForm'
334 cj('#Edit').ajaxForm( options );
336 // FIXME - this is improper use of jquery.form
337 // Do not use this code as an example
338 function showRequest(formData, jqForm, options) {
339 // formData is an array; here we use $.param to convert it to a string to display it
340 // but the form plugin does this for you automatically when it submits the data
341 var queryString = cj.param(formData);
342 queryString = queryString + '&snippet=5&gid=' + {/literal}"{$profileID}"{literal};
343 var postUrl = {/literal}"{crmURL p='civicrm/profile/create' h=0 }"{literal};
344 var blockNo = {/literal}{if $blockNo}{$blockNo}{else}null{/if}{literal};
345 var prefix = {/literal}"{$prefix}"{literal};
346 var response = cj.ajax({
349 async: false, // FIXME
352 success: function( response ) {
353 if ( response.newContactSuccess ) {
354 cj('#' + prefix + 'contact_' + blockNo ).val( response.sortName ).focus( );
355 if ( typeof(allowMultiClient) != "undefined" ) {
356 if ( allowMultiClient ) {
357 cj('#' + prefix + 'contact_' + blockNo).tokenInput("add", {id: response.contactID, name: response.sortName });
360 cj('input[name="' + prefix + 'contact_select_id[' + blockNo +']"]').val( response.contactID );
361 CRM.alert(response.displayName + {/literal}'{ts escape="js"} has been created.{/ts}', '{ts escape="js"}Contact Saved{/ts}'{literal}, 'success');
362 cj('#contact-dialog-' + prefix + blockNo ).dialog('close');
367 cj('#contact-dialog-' + prefix + blockNo).html( response );
369 // FIXME - we have used jquery.form very incorrectly
370 // and are now preventing it from doing what it's supposed to do
381 </div> {* end crm-profile-NAME *}