PageRenderTime 49ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/drupal/sites/all/modules/civicrm/templates/CRM/Profile/Form/Dynamic.tpl

https://github.com/michaelmcandrew/vaw
Smarty Template | 298 lines | 245 code | 23 blank | 30 comment | 28 complexity | 6e7cdd623a38813348584b47c6563342 MD5 | raw file
  1. {*
  2. +--------------------------------------------------------------------+
  3. | CiviCRM version 3.4 |
  4. +--------------------------------------------------------------------+
  5. | Copyright CiviCRM LLC (c) 2004-2011 |
  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. {* Profile forms when embedded in CMS account create (mode=1) or cms account edit (mode=8) or civicrm/profile (mode=4) pages *}
  27. {if $context neq 'dialog'}
  28. <script type="text/javascript" src="{$config->resourceBase}js/Common.js"></script>
  29. {/if}
  30. {if ! empty( $fields )}
  31. {* Wrap in crm-container div so crm styles are used.*}
  32. {* 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" *}
  33. {if $action eq 1 or $action eq 2 or $action eq 4 }
  34. <div id="crm-profile-block">
  35. {else}
  36. <div id="crm-container" lang="{$config->lcMessages|truncate:2:"":true}" xml:lang="{$config->lcMessages|truncate:2:"":true}">
  37. {/if}
  38. {if $isDuplicate and ( ($action eq 1 and $mode eq 4 ) or ($action eq 2) or ($action eq 8192) ) }
  39. <div class="crm-submit-buttons">
  40. <span class="crm-button">{$form._qf_Edit_upload_duplicate.html}</span>
  41. </div>
  42. {/if}
  43. {if $mode eq 1 || $activeComponent neq "CiviCRM"}
  44. {include file="CRM/Form/body.tpl"}
  45. {/if}
  46. {strip}
  47. {if $help_pre && $action neq 4}
  48. <div class="messages help">{$help_pre}</div>
  49. {/if}
  50. {include file="CRM/common/CMSUser.tpl"}
  51. {assign var=zeroField value="Initial Non Existent Fieldset"}
  52. {assign var=fieldset value=$zeroField}
  53. {foreach from=$fields item=field key=fieldName}
  54. {assign var="profileID" value=$field.group_id}
  55. {assign var=n value=$field.name}
  56. {if $form.$n}
  57. {if $field.groupTitle != $fieldset}
  58. {if $fieldset != $zeroField}
  59. {if $groupHelpPost}
  60. <div class="messages help">{$groupHelpPost}</div>
  61. {/if}
  62. {if $mode neq 8 && $mode neq 4}
  63. </div><!-- end form-layout-compressed-div -->
  64. </fieldset>
  65. </div>
  66. {/if}
  67. {/if}
  68. {if $mode neq 8 && $mode neq 4}
  69. <div {if $context neq 'dialog'}id="profilewrap{$field.group_id}"{/if}>
  70. <fieldset><legend>{$field.groupTitle}</legend>
  71. {/if}
  72. {assign var=fieldset value=`$field.groupTitle`}
  73. {assign var=groupHelpPost value=`$field.groupHelpPost`}
  74. {if $field.groupHelpPre}
  75. <div class="messages help">{$field.groupHelpPre}</div>
  76. {/if}
  77. <div class="form-layout-compressed">
  78. {/if}
  79. {if $field.help_pre && $action neq 4 && $form.$n.html}
  80. <div class="crm-section helprow-{$n}-section" id="helprow-{$n}">
  81. <div class="content description">{$field.help_pre}</div>
  82. </div>
  83. {/if}
  84. {if $field.options_per_line}
  85. <div class="crm-section editrow_{$n}-section form-item" id="editrow-{$n}">
  86. <div class="label">{$form.$n.label}</div>
  87. <div class="content edit-value">
  88. {assign var="count" value="1"}
  89. {strip}
  90. <table class="form-layout-compressed">
  91. <tr>
  92. {* sort by fails for option per line. Added a variable to iterate through the element array*}
  93. {assign var="index" value="1"}
  94. {foreach name=outer key=key item=item from=$form.$n}
  95. {if $index < 10}
  96. {assign var="index" value=`$index+1`}
  97. {else}
  98. <td class="labels font-light">{$form.$n.$key.html}</td>
  99. {if $count == $field.options_per_line}
  100. </tr>
  101. <tr>
  102. {assign var="count" value="1"}
  103. {else}
  104. {assign var="count" value=`$count+1`}
  105. {/if}
  106. {/if}
  107. {/foreach}
  108. </tr>
  109. </table>
  110. {if $field.html_type eq 'Radio' and $form.formName eq 'Edit' and $field.is_view neq 1 }
  111. &nbsp;<span class="crm-clear-link">(<a href="#" title="unselect" onclick="unselectRadio('{$n}', '{$form.formName}'); return false;">{ts}clear{/ts}</a>)</span>
  112. {/if}
  113. {/strip}
  114. </div>
  115. <div class="clear"></div>
  116. </div>{* end of main edit section div*}
  117. {else}
  118. <div id="editrow-{$n}" class="crm-section editrow_{$n}-section form-item">
  119. <div class="label">{$form.$n.label}</div>
  120. <div class="edit-value content">
  121. {if $n|substr:0:3 eq 'im-'}
  122. {assign var="provider" value=$n|cat:"-provider_id"}
  123. {$form.$provider.html}&nbsp;
  124. {elseif $n|substr:0:4 eq 'url-'}
  125. {assign var="websiteType" value=$n|cat:"-website_type_id"}
  126. {$form.$websiteType.html}&nbsp;
  127. {/if}
  128. {if $n eq 'email_greeting' or $n eq 'postal_greeting' or $n eq 'addressee'}
  129. {include file="CRM/Profile/Form/GreetingType.tpl"}
  130. {elseif ( $n eq 'group' && $form.group ) || ( $n eq 'tag' && $form.tag )}
  131. {include file="CRM/Contact/Form/Edit/TagsAndGroups.tpl" type=$n context="profile"}
  132. {elseif ( $form.$n.name eq 'image_URL' )}
  133. {$form.$n.html}
  134. {if !empty($imageURL)}
  135. <div class="crm-section contact_image-section">
  136. <div class="content">
  137. {include file="CRM/Contact/Page/ContactImage.tpl"}
  138. </div>
  139. </div>
  140. {/if}
  141. {else}
  142. {if ( $field.data_type eq 'Date' or
  143. ( ( ( $n eq 'birth_date' ) or ( $n eq 'deceased_date' ) or ( $n eq 'activity_date_time' ) ) ) ) and $field.is_view neq 1 }
  144. {include file="CRM/common/jcalendar.tpl" elementName=$n}
  145. {else}
  146. {$form.$n.html}
  147. {/if}
  148. {if (($n eq 'gender') or ($field.html_type eq 'Radio' and $form.formName eq 'Edit' and $field.is_required neq 1)) and
  149. ($field.is_view neq 1)}
  150. &nbsp;<span class="crm-clear-link">(<a href="#" title="unselect" onclick="unselectRadio('{$n}', '{$form.formName}'); return false;">{ts}clear{/ts}</a>)</span>
  151. {elseif $field.html_type eq 'Autocomplete-Select'}
  152. {include file="CRM/Custom/Form/AutoComplete.tpl" element_name = $n}
  153. {/if}
  154. {/if}
  155. </div>
  156. <div class="clear"></div>
  157. </div>
  158. {if $form.$n.type eq 'file'}
  159. <div class="crm-section file_displayURL-section file_displayURL{$n}-section"><div class="content">{$customFiles.$n.displayURL}</div></div>
  160. <div class="crm-section file_deleteURL-section file_deleteURL{$n}-section"><div class="content">{$customFiles.$n.deleteURL}</div></div>
  161. {/if}
  162. {/if}
  163. {* Show explanatory text for field if not in 'view' mode *}
  164. {if $field.help_post && $action neq 4 && $form.$n.html}
  165. <div class="crm-section helprow-{$n}-section" id="helprow-{$n}">
  166. <div class="content description">{$field.help_post}</div>
  167. </div>
  168. {/if}
  169. {/if}{* end of main if field name if *}
  170. {/foreach}
  171. </div><!-- end form-layout-compressed for last profile --> {* closing main form layout div when all the fields are built*}
  172. {if $isCaptcha && ( $mode eq 8 || $mode eq 4 || $mode eq 1 ) }
  173. {include file='CRM/common/ReCAPTCHA.tpl'}
  174. <script type="text/javascript">cj('.recaptcha_label').attr('width', '140px');</script>
  175. {/if}
  176. {if $field.groupHelpPost}
  177. <div class="messages help">{$field.groupHelpPost}</div>
  178. {/if}
  179. {if $mode neq 8 && $mode neq 4}
  180. </fieldset>
  181. </div>
  182. {/if}
  183. {if ($action eq 1 and $mode eq 4 ) or ($action eq 2) or ($action eq 8192)}
  184. <div class="crm-submit-buttons">
  185. {include file="CRM/common/formButtons.tpl"}{if $isDuplicate}<span class="crm-button">{$form._qf_Edit_upload_duplicate.html}</span>{/if}
  186. </div>
  187. {/if}
  188. {if $help_post && $action neq 4}<br /><div class="messages help">{$help_post}</div>{/if}
  189. {/strip}
  190. </div> {* end crm-container div *}
  191. <script type="text/javascript">
  192. {if $drupalCms}
  193. {literal}
  194. if ( document.getElementsByName("cms_create_account")[0].checked ) {
  195. show('details');
  196. } else {
  197. hide('details');
  198. }
  199. {/literal}
  200. {/if}
  201. </script>
  202. {/if} {* fields array is not empty *}
  203. {if $drupalCms}
  204. {include file="CRM/common/showHideByFieldValue.tpl"
  205. trigger_field_id ="create_account"
  206. trigger_value =""
  207. target_element_id ="details"
  208. target_element_type ="block"
  209. field_type ="radio"
  210. invert = 0
  211. }
  212. {elseif $statusMessage}
  213. <div class="messages status">
  214. <div class="icon inform-icon"></div>
  215. {$statusMessage}
  216. </div>
  217. {/if}
  218. {literal}
  219. <script type="text/javascript">
  220. cj(document).ready(function(){
  221. cj('#selector tr:even').addClass('odd-row ');
  222. cj('#selector tr:odd ').addClass('even-row');
  223. });
  224. {/literal}
  225. {if $context eq 'dialog'}
  226. {literal}
  227. var options = {
  228. beforeSubmit: showRequest // pre-submit callback
  229. };
  230. // bind form using 'ajaxForm'
  231. cj('#Edit').ajaxForm( options );
  232. // pre-submit callback
  233. function showRequest(formData, jqForm, options) {
  234. // formData is an array; here we use $.param to convert it to a string to display it
  235. // but the form plugin does this for you automatically when it submits the data
  236. var queryString = cj.param(formData);
  237. queryString = queryString + '&snippet=5&gid=' + {/literal}"{$profileID}"{literal};
  238. var postUrl = {/literal}"{crmURL p='civicrm/profile/create' h=0 }"{literal};
  239. var blockNo = {/literal}{$blockNo}{literal};
  240. var response = cj.ajax({
  241. type: "POST",
  242. url: postUrl,
  243. async: false,
  244. data: queryString,
  245. dataType: "json",
  246. success: function( response ) {
  247. if ( response.newContactSuccess ) {
  248. cj('#contact_' + blockNo ).val( response.sortName ).focus( );
  249. if ( typeof(allowMultiClient) != "undefined" ) {
  250. if ( allowMultiClient ) {
  251. var newToken = '{"name":"'+response.sortName+'","id":"'+response.contactID+'"},';
  252. cj('ul.token-input-list-facebook, div.token-input-dropdown-facebook' ).remove();
  253. //we are having multiple instances, CRM-6932
  254. eval( 'addMultiClientOption' + blockNo + "( newToken, blockNo )" );
  255. }
  256. }
  257. cj('input[name="contact_select_id[' + blockNo +']"]').val( response.contactID );
  258. cj('#contact-success-' + blockNo ).show( );
  259. cj('#contact-dialog-' + blockNo ).dialog('close');
  260. {/literal}{ if $createCallback}{literal}
  261. profileCreateCallback( blockNo );
  262. {/literal}{/if}{literal}
  263. }
  264. }
  265. }).responseText;
  266. cj('#contact-dialog-' + blockNo).html( response );
  267. // here we could return false to prevent the form from being submitted;
  268. // returning anything other than false will allow the form submit to continue
  269. return false;
  270. }
  271. {/literal}
  272. {/if}
  273. {literal}
  274. </script>
  275. {/literal}