PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/SugarCE-6.5.4/SugarCE-Full-6.5.4/include/EditView/EditView.tpl

https://bitbucket.org/blakeball/test-repository
Smarty Template | 278 lines | 213 code | 24 blank | 41 comment | 55 complexity | fe408b4bea39633daf1025738f1f4b4e MD5 | raw file
Possible License(s): LGPL-2.1, MPL-2.0-no-copyleft-exception
  1. {*
  2. /*********************************************************************************
  3. * SugarCRM Community Edition is a customer relationship management program developed by
  4. * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it under
  7. * the terms of the GNU Affero General Public License version 3 as published by the
  8. * Free Software Foundation with the addition of the following permission added
  9. * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
  10. * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
  11. * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
  12. *
  13. * This program is distributed in the hope that it will be useful, but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  15. * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License along with
  19. * this program; if not, see http://www.gnu.org/licenses or write to the Free
  20. * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  21. * 02110-1301 USA.
  22. *
  23. * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
  24. * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
  25. *
  26. * The interactive user interfaces in modified source and object code versions
  27. * of this program must display Appropriate Legal Notices, as required under
  28. * Section 5 of the GNU Affero General Public License version 3.
  29. *
  30. * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
  31. * these Appropriate Legal Notices must retain the display of the "Powered by
  32. * SugarCRM" logo. If the display of the logo is not reasonably feasible for
  33. * technical reasons, the Appropriate Legal Notices must display the words
  34. * "Powered by SugarCRM".
  35. ********************************************************************************/
  36. *}
  37. {{include file=$headerTpl}}
  38. {sugar_include include=$includes}
  39. <span id='tabcounterJS'><script>SUGAR.TabFields=new Array();//this will be used to track tabindexes for references</script></span>
  40. <div id="{{$form_name}}_tabs"
  41. {{if $useTabs}}
  42. class="yui-navset"
  43. {{/if}}
  44. >
  45. {{if $useTabs}}
  46. {* Generate the Tab headers *}
  47. {{counter name="tabCount" start=-1 print=false assign="tabCount"}}
  48. <ul class="yui-nav">
  49. {{foreach name=section from=$sectionPanels key=label item=panel}}
  50. {{counter name="tabCount" print=false}}
  51. {{capture name=label_upper assign=label_upper}}{{$label|upper}}{{/capture}}
  52. {{if (isset($tabDefs[$label_upper].newTab) && $tabDefs[$label_upper].newTab == true)}}
  53. <li class="selected"><a id="tab{{$tabCount}}" href="javascript:void({{$tabCount}})"><em>{sugar_translate label='{{$label}}' module='{{$module}}'}</em></a></li>
  54. {{/if}}
  55. {{/foreach}}
  56. </ul>
  57. {{/if}}
  58. <div {{if $useTabs}}class="yui-content"{{/if}}>
  59. {{assign var='tabIndexVal' value=0}}
  60. {{* Loop through all top level panels first *}}
  61. {{counter name="panelCount" start=-1 print=false assign="panelCount"}}
  62. {{counter name="tabCount" start=-1 print=false assign="tabCount"}}
  63. {{foreach name=section from=$sectionPanels key=label item=panel}}
  64. {{counter name="panelCount" print=false}}
  65. {{capture name=label_upper assign=label_upper}}{{$label|upper}}{{/capture}}
  66. {{if (isset($tabDefs[$label_upper].newTab) && $tabDefs[$label_upper].newTab == true)}}
  67. {{counter name="tabCount" print=false}}
  68. {{if $tabCount != 0}}</div>{{/if}}
  69. <div id='tabcontent{{$tabCount}}'>
  70. {{/if}}
  71. {{* Print out the table data *}}
  72. {{if $label == 'DEFAULT'}}
  73. <div id="detailpanel_{{$smarty.foreach.section.iteration}}" >
  74. {{else}}
  75. <div id="detailpanel_{{$smarty.foreach.section.iteration}}" class="{$def.templateMeta.panelClass|default:'edit view edit508'}">
  76. {{/if}}
  77. {counter name="panelFieldCount" start=0 print=false assign="panelFieldCount"}
  78. {{* Check to see if the panel variable is an array, if not, we'll attempt an include with type param php *}}
  79. {{* See function.sugar_include.php *}}
  80. {{if !is_array($panel)}}
  81. {sugar_include type='php' file='{{$panel}}'}
  82. {{else}}
  83. {{* Only show header if it is not default or an int value *}}
  84. {{if !empty($label) && !is_int($label) && $label != 'DEFAULT' && $showSectionPanelsTitles && (!isset($tabDefs[$label_upper].newTab) || (isset($tabDefs[$label_upper].newTab) && $tabDefs[$label_upper].newTab == false)) && $view != "QuickCreate"}}
  85. <h4>&nbsp;&nbsp;
  86. <a href="javascript:void(0)" class="collapseLink" onclick="collapsePanel({{$smarty.foreach.section.iteration}});">
  87. <img border="0" id="detailpanel_{{$smarty.foreach.section.iteration}}_img_hide" src="{sugar_getimagepath file="basic_search.gif"}"></a>
  88. <a href="javascript:void(0)" class="expandLink" onclick="expandPanel({{$smarty.foreach.section.iteration}});">
  89. <img border="0" id="detailpanel_{{$smarty.foreach.section.iteration}}_img_show" src="{sugar_getimagepath file="advanced_search.gif"}"></a>
  90. {sugar_translate label='{{$label}}' module='{{$module}}'}
  91. {{if ( isset($tabDefs[$label_upper].panelDefault) && $tabDefs[$label_upper].panelDefault == "collapsed" && isset($tabDefs[$label_upper].newTab) && $tabDefs[$label_upper].newTab == false) }}
  92. {{assign var='panelState' value=$tabDefs[$label_upper].panelDefault}}
  93. {{else}}
  94. {{assign var='panelState' value="expanded"}}
  95. {{/if}}
  96. {{if isset($panelState) && $panelState == 'collapsed'}}
  97. <script>
  98. document.getElementById('detailpanel_{{$smarty.foreach.section.iteration}}').className += ' collapsed';
  99. </script>
  100. {{else}}
  101. <script>
  102. document.getElementById('detailpanel_{{$smarty.foreach.section.iteration}}').className += ' expanded';
  103. </script>
  104. {{/if}}
  105. </h4>
  106. {{/if}}
  107. <table width="100%" border="0" cellspacing="1" cellpadding="0" {{if $label == 'DEFAULT'}} id='Default_{$module}_Subpanel' {{else}} id='{{$label}}' {{/if}} class="edit view panelContainer">
  108. {{assign var='rowCount' value=0}}
  109. {{assign var='ACCKEY' value=''}}
  110. {{foreach name=rowIteration from=$panel key=row item=rowData}}
  111. {counter name="fieldsUsed" start=0 print=false assign="fieldsUsed"}
  112. {capture name="tr" assign="tableRow"}
  113. <tr>
  114. {{math assign="rowCount" equation="$rowCount + 1"}}
  115. {{assign var='columnsInRow' value=$rowData|@count}}
  116. {{assign var='columnsUsed' value=0}}
  117. {{* Loop through each column and display *}}
  118. {{counter name="colCount" start=0 print=false assign="colCount"}}
  119. {{foreach name=colIteration from=$rowData key=col item=colData}}
  120. {{counter name="colCount" print=false}}
  121. {{if count($rowData) == $colCount}}
  122. {{assign var="colCount" value=0}}
  123. {{/if}}
  124. {{if !empty($colData.field.hideIf)}}
  125. {if !({{$colData.field.hideIf}}) }
  126. {{/if}}
  127. {{if empty($def.templateMeta.labelsOnTop) && empty($colData.field.hideLabel)}}
  128. <td valign="top" id='{{$colData.field.name}}_label' width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].label}}%' scope="col">
  129. {{if isset($colData.field.customLabel)}}
  130. <label for="{{$fields[$colData.field.name].name}}">{{$colData.field.customLabel}}</label>
  131. {{elseif isset($colData.field.label)}}
  132. {capture name="label" assign="label"}{sugar_translate label='{{$colData.field.label}}' module='{{$module}}'}{/capture}
  133. {$label|strip_semicolon}:
  134. {{elseif isset($fields[$colData.field.name])}}
  135. {capture name="label" assign="label"}{sugar_translate label='{{$fields[$colData.field.name].vname}}' module='{{$module}}'}{/capture}
  136. {$label|strip_semicolon}:
  137. {{else}}
  138. &nbsp;
  139. {{/if}}
  140. {{* Show the required symbol if field is required, but override not set. Or show if override is set *}}
  141. {{if ($fields[$colData.field.name].required && (!isset($colData.field.displayParams.required) || $colData.field.displayParams.required)) ||
  142. (isset($colData.field.displayParams.required) && $colData.field.displayParams.required)}}
  143. <span class="required">{{$APP.LBL_REQUIRED_SYMBOL}}</span>
  144. {{/if}}
  145. {{if isset($colData.field.popupHelp) || isset($fields[$colData.field.name]) && isset($fields[$colData.field.name].popupHelp) }}
  146. {{if isset($colData.field.popupHelp) }}
  147. {capture name="popupText" assign="popupText"}{sugar_translate label="{{$colData.field.popupHelp}}" module='{{$module}}'}{/capture}
  148. {{elseif isset($fields[$colData.field.name].popupHelp)}}
  149. {capture name="popupText" assign="popupText"}{sugar_translate label="{{$fields[$colData.field.name].popupHelp}}" module='{{$module}}'}{/capture}
  150. {{/if}}
  151. {sugar_help text=$popupText WIDTH=-1}
  152. {{/if}}
  153. </td>
  154. {{/if}}
  155. {counter name="fieldsUsed"}
  156. {{math assign="tabIndexVal" equation="$tabIndexVal + 1"}}
  157. {{if $tabIndexVal==1}} {{assign var='ACCKEY' value=$APP.LBL_FIRST_INPUT_EDIT_VIEW_KEY}}{{else}}{{assign var='ACCKEY' value=''}}{{/if}}
  158. {{if !empty($colData.field.tabindex) && $colData.field.tabindex !=0}}
  159. {{assign var='tabindex' value=$colData.field.tabindex}}
  160. {{** instead of tracking tabindex values for all fields, just track for email as email does not get created directly from
  161. a tpl that has access to smarty values. Email gets created through addEmailAddress() function in SugarEmailAddress.js
  162. which will use the value in tabFields array
  163. **}}
  164. {{if $colData.field.name == 'email1'}}<script>SUGAR.TabFields['{{$colData.field.name}}'] = '{{$tabindex}}';</script>{{/if}}
  165. {{else}}
  166. {** if not explicitly assigned, we will default to 0 for 508 compliance reasons, instead of the calculated tabIndexVal value **}
  167. {{assign var='tabindex' value=0}}
  168. {{/if}}
  169. <td valign="top" width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].field}}%' {{if $colData.colspan}}colspan='{{$colData.colspan}}'{{/if}}>
  170. {{if !empty($def.templateMeta.labelsOnTop)}}
  171. {{if isset($colData.field.label)}}
  172. {{if !empty($colData.field.label)}}
  173. <label for="{{$fields[$colData.field.name].name}}">{sugar_translate label='{{$colData.field.label}}' module='{{$module}}'}:</label>
  174. {{/if}}
  175. {{elseif isset($fields[$colData.field.name])}}
  176. <label for="{{$fields[$colData.field.name].name}}">{sugar_translate label='{{$fields[$colData.field.name].vname}}' module='{{$module}}'}:</label>
  177. {{/if}}
  178. {{* Show the required symbol if field is required, but override not set. Or show if override is set *}}
  179. {{if ($fields[$colData.field.name].required && (!isset($colData.field.displayParams.required) || $colData.field.displayParams.required)) ||
  180. (isset($colData.field.displayParams.required) && $colData.field.displayParams.required)}}
  181. <span class="required" title="{{$APP.LBL_REQUIRED_TITLE}}">{{$APP.LBL_REQUIRED_SYMBOL}}</span>
  182. {{/if}}
  183. {{if !isset($colData.field.label) || !empty($colData.field.label)}}
  184. <br>
  185. {{/if}}
  186. {{/if}}
  187. {{$colData.field.prefix}}
  188. {{if $fields[$colData.field.name] && !empty($colData.field.fields) }}
  189. {{foreach from=$colData.field.fields item=subField}}
  190. {{if $fields[$subField.name]}}
  191. {counter name="panelFieldCount"}
  192. {{sugar_field parentFieldArray='fields' accesskey=$ACCKEY tabindex=$tabindex vardef=$fields[$subField.name] displayType='EditView' displayParams=$subField.displayParams formName=$form_name}}&nbsp;
  193. {{/if}}
  194. {{/foreach}}
  195. {{elseif !empty($colData.field.customCode) && empty($colData.field.customCodeRenderField)}}
  196. {counter name="panelFieldCount"}
  197. {{sugar_evalcolumn var=$colData.field.customCode colData=$colData accesskey=$ACCKEY tabindex=$tabindex}}
  198. {{elseif $fields[$colData.field.name]}}
  199. {counter name="panelFieldCount"}
  200. {{$colData.displayParams}}
  201. {{sugar_field parentFieldArray='fields' accesskey=$ACCKEY tabindex=$tabindex vardef=$fields[$colData.field.name] displayType='EditView' displayParams=$colData.field.displayParams typeOverride=$colData.field.type formName=$form_name}}
  202. {{/if}}
  203. {{if !empty($colData.field.customCode) && !empty($colData.field.customCodeRenderField)}}
  204. {counter name="panelFieldCount"}
  205. {{sugar_evalcolumn var=$colData.field.customCode colData=$colData tabindex=$tabindex}}
  206. {{/if}}
  207. {{if !empty($colData.field.hideIf)}}
  208. {else}
  209. <td></td><td></td>
  210. {/if}
  211. {{/if}}
  212. {{/foreach}}
  213. </tr>
  214. {/capture}
  215. {if $fieldsUsed > 0 }
  216. {$tableRow}
  217. {/if}
  218. {{/foreach}}
  219. </table>
  220. {{if !empty($label) && !is_int($label) && $label != 'DEFAULT' && $showSectionPanelsTitles && (!isset($tabDefs[$label_upper].newTab) || (isset($tabDefs[$label_upper].newTab) && $tabDefs[$label_upper].newTab == false)) && $view != "QuickCreate"}}
  221. <script type="text/javascript">SUGAR.util.doWhen("typeof initPanel == 'function'", function() {ldelim} initPanel({{$smarty.foreach.section.iteration}}, '{{$panelState}}'); {rdelim}); </script>
  222. {{/if}}
  223. {{/if}}
  224. </div>
  225. {if $panelFieldCount == 0}
  226. <script>document.getElementById("{{$label}}").style.display='none';</script>
  227. {/if}
  228. {{/foreach}}
  229. </div></div>
  230. {{include file=$footerTpl}}
  231. {{if $useTabs}}
  232. {sugar_getscript file="cache/include/javascript/sugar_grp_yui_widgets.js"}
  233. <script type="text/javascript">
  234. var {{$form_name}}_tabs = new YAHOO.widget.TabView("{{$form_name}}_tabs");
  235. {{$form_name}}_tabs.selectTab(0);
  236. </script>
  237. {{/if}}
  238. <script type="text/javascript">
  239. YAHOO.util.Event.onContentReady("{{$form_name}}",
  240. function () {ldelim} initEditView(document.forms.{{$form_name}}) {rdelim});
  241. //window.setTimeout(, 100);
  242. {{if $module == "Users"}}
  243. window.onbeforeunload = function () {ldelim} return disableOnUnloadEditView(); {rdelim};
  244. {{else}}
  245. window.onbeforeunload = function () {ldelim} return onUnloadEditView(); {rdelim};
  246. {{/if}}
  247. // bug 55468 -- IE is too aggressive with onUnload event
  248. if ($.browser.msie) {ldelim}
  249. $(document).ready(function() {ldelim}
  250. $(".collapseLink,.expandLink").click(function (e) {ldelim} e.preventDefault(); {rdelim});
  251. {rdelim});
  252. {rdelim}
  253. </script>