]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/EditView/EditView.tpl
Release 6.5.8
[Github/sugarcrm.git] / include / EditView / EditView.tpl
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 *}
38 {{include file=$headerTpl}}
39 {sugar_include include=$includes}
40
41 <span id='tabcounterJS'><script>SUGAR.TabFields=new Array();//this will be used to track tabindexes for references</script></span>
42
43 <div id="{{$form_name}}_tabs"
44 {{if $useTabs}}
45 class="yui-navset"
46 {{/if}}
47 >
48     {{if $useTabs}}
49     {* Generate the Tab headers *}
50     {{counter name="tabCount" start=-1 print=false assign="tabCount"}}
51     <ul class="yui-nav">
52     {{foreach name=section from=$sectionPanels key=label item=panel}}
53         {{counter name="tabCount" print=false}}
54         {{capture name=label_upper assign=label_upper}}{{$label|upper}}{{/capture}}
55         {{if (isset($tabDefs[$label_upper].newTab) && $tabDefs[$label_upper].newTab == true)}}
56         <li class="selected"><a id="tab{{$tabCount}}" href="javascript:void({{$tabCount}})"><em>{sugar_translate label='{{$label}}' module='{{$module}}'}</em></a></li>
57         {{/if}}
58     {{/foreach}}
59     </ul>
60     {{/if}}
61     <div {{if $useTabs}}class="yui-content"{{/if}}>
62
63 {{assign var='tabIndexVal' value=0}}
64 {{* Loop through all top level panels first *}}
65 {{counter name="panelCount" start=-1 print=false assign="panelCount"}}
66 {{counter name="tabCount" start=-1 print=false assign="tabCount"}}
67 {{foreach name=section from=$sectionPanels key=label item=panel}}
68 {{counter name="panelCount" print=false}}
69 {{capture name=label_upper assign=label_upper}}{{$label|upper}}{{/capture}}
70   {{if (isset($tabDefs[$label_upper].newTab) && $tabDefs[$label_upper].newTab == true)}}
71     {{counter name="tabCount" print=false}}
72     {{if $tabCount != 0}}</div>{{/if}}
73     <div id='tabcontent{{$tabCount}}'>
74   {{/if}}
75
76 {{* Print out the table data *}}
77 {{if $label == 'DEFAULT'}}
78   <div id="detailpanel_{{$smarty.foreach.section.iteration}}" >
79 {{else}}
80   <div id="detailpanel_{{$smarty.foreach.section.iteration}}" class="{$def.templateMeta.panelClass|default:'edit view edit508'}">
81 {{/if}}
82
83 {counter name="panelFieldCount" start=0 print=false assign="panelFieldCount"}
84 {{* Check to see if the panel variable is an array, if not, we'll attempt an include with type param php *}}
85 {{* See function.sugar_include.php *}}
86 {{if !is_array($panel)}}
87     {sugar_include type='php' file='{{$panel}}'}
88 {{else}}
89
90 {{* Only show header if it is not default or an int value *}}
91 {{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"}}
92 <h4>&nbsp;&nbsp;
93   <a href="javascript:void(0)" class="collapseLink" onclick="collapsePanel({{$smarty.foreach.section.iteration}});">
94   <img border="0" id="detailpanel_{{$smarty.foreach.section.iteration}}_img_hide" src="{sugar_getimagepath file="basic_search.gif"}"></a>
95   <a href="javascript:void(0)" class="expandLink" onclick="expandPanel({{$smarty.foreach.section.iteration}});">
96   <img border="0" id="detailpanel_{{$smarty.foreach.section.iteration}}_img_show" src="{sugar_getimagepath file="advanced_search.gif"}"></a>
97   {sugar_translate label='{{$label}}' module='{{$module}}'}
98   {{if ( isset($tabDefs[$label_upper].panelDefault) && $tabDefs[$label_upper].panelDefault == "collapsed" && isset($tabDefs[$label_upper].newTab) && $tabDefs[$label_upper].newTab == false) }}
99     {{assign var='panelState' value=$tabDefs[$label_upper].panelDefault}}
100   {{else}}
101     {{assign var='panelState' value="expanded"}}
102   {{/if}}
103   {{if isset($panelState) && $panelState == 'collapsed'}}
104     <script>
105       document.getElementById('detailpanel_{{$smarty.foreach.section.iteration}}').className += ' collapsed';
106     </script>
107     {{else}}
108     <script>
109       document.getElementById('detailpanel_{{$smarty.foreach.section.iteration}}').className += ' expanded';
110     </script>
111   {{/if}}
112 </h4>
113  {{/if}}
114 <table width="100%" border="0" cellspacing="1" cellpadding="0" {{if $label == 'DEFAULT'}} id='Default_{$module}_Subpanel' {{else}} id='{{$label}}' {{/if}} class="yui3-skin-sam edit view panelContainer">
115
116
117 {{assign var='rowCount' value=0}}
118 {{assign var='ACCKEY' value=''}}
119 {{foreach name=rowIteration from=$panel key=row item=rowData}}
120 {counter name="fieldsUsed" start=0 print=false assign="fieldsUsed"}
121 {capture name="tr" assign="tableRow"}
122 <tr>
123
124         {{math assign="rowCount" equation="$rowCount + 1"}}
125         
126         {{assign var='columnsInRow' value=$rowData|@count}}
127         {{assign var='columnsUsed' value=0}}
128
129     {{* Loop through each column and display *}}
130     {{counter name="colCount" start=0 print=false assign="colCount"}}
131
132         {{foreach name=colIteration from=$rowData key=col item=colData}}
133
134         {{counter name="colCount" print=false}}
135
136         {{if count($rowData) == $colCount}}
137                 {{assign var="colCount" value=0}}
138         {{/if}}
139
140     {{if !empty($colData.field.hideIf)}}
141         {if !({{$colData.field.hideIf}}) }
142     {{/if}}
143
144                 {{if empty($def.templateMeta.labelsOnTop) && empty($colData.field.hideLabel)}}
145                 <td valign="top" id='{{$colData.field.name}}_label' width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].label}}%' scope="col">
146                         {{if isset($colData.field.customLabel)}}
147                            <label for="{{$fields[$colData.field.name].name}}">{{$colData.field.customLabel}}</label>
148                         {{elseif isset($colData.field.label)}}
149                            {capture name="label" assign="label"}{sugar_translate label='{{$colData.field.label}}' module='{{$module}}'}{/capture}
150                            {$label|strip_semicolon}:
151                         {{elseif isset($fields[$colData.field.name])}}
152                            {capture name="label" assign="label"}{sugar_translate label='{{$fields[$colData.field.name].vname}}' module='{{$module}}'}{/capture}
153                            {$label|strip_semicolon}:
154                         {{else}}
155                             &nbsp;
156                         {{/if}}
157                         {{* Show the required symbol if field is required, but override not set.  Or show if override is set *}}
158                                 {{if ($fields[$colData.field.name].required && (!isset($colData.field.displayParams.required) || $colData.field.displayParams.required)) ||
159                                      (isset($colData.field.displayParams.required) && $colData.field.displayParams.required)}}
160                             <span class="required">{{$APP.LBL_REQUIRED_SYMBOL}}</span>
161                         {{/if}}
162             {{if isset($colData.field.popupHelp) || isset($fields[$colData.field.name]) && isset($fields[$colData.field.name].popupHelp) }}
163               {{if isset($colData.field.popupHelp) }}
164                 {capture name="popupText" assign="popupText"}{sugar_translate label="{{$colData.field.popupHelp}}" module='{{$module}}'}{/capture}
165               {{elseif isset($fields[$colData.field.name].popupHelp)}}
166                 {capture name="popupText" assign="popupText"}{sugar_translate label="{{$fields[$colData.field.name].popupHelp}}" module='{{$module}}'}{/capture}
167               {{/if}}
168               {sugar_help text=$popupText WIDTH=-1}
169             {{/if}}
170
171                 </td>
172                 {{/if}}
173                 {counter name="fieldsUsed"}
174                 {{math assign="tabIndexVal" equation="$tabIndexVal + 1"}}
175                 {{if $tabIndexVal==1}} {{assign var='ACCKEY' value=$APP.LBL_FIRST_INPUT_EDIT_VIEW_KEY}}{{else}}{{assign var='ACCKEY' value=''}}{{/if}}
176                 {{if !empty($colData.field.tabindex)  && $colData.field.tabindex !=0}}
177                     {{assign var='tabindex' value=$colData.field.tabindex}}
178             {{** instead of tracking tabindex values for all fields, just track for email as email does not get created directly from
179                 a tpl that has access to smarty values.  Email gets created through addEmailAddress() function in SugarEmailAddress.js
180                 which will use the value in tabFields array
181              **}}
182             {{if $colData.field.name == 'email1'}}<script>SUGAR.TabFields['{{$colData.field.name}}'] = '{{$tabindex}}';</script>{{/if}}
183                 {{else}}
184                     {** if not explicitly assigned, we will default to 0 for 508 compliance reasons, instead of the calculated tabIndexVal value **}
185                     {{assign var='tabindex' value=0}}
186                 {{/if}}
187                 <td valign="top" width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].field}}%' {{if $colData.colspan}}colspan='{{$colData.colspan}}'{{/if}}>
188                         {{if !empty($def.templateMeta.labelsOnTop)}}
189                                 {{if isset($colData.field.label)}}
190                                     {{if !empty($colData.field.label)}}
191                                             <label for="{{$fields[$colData.field.name].name}}">{sugar_translate label='{{$colData.field.label}}' module='{{$module}}'}:</label>
192                                     {{/if}}
193                                 {{elseif isset($fields[$colData.field.name])}}
194                                         <label for="{{$fields[$colData.field.name].name}}">{sugar_translate label='{{$fields[$colData.field.name].vname}}' module='{{$module}}'}:</label>
195                                 {{/if}}
196
197                                 {{* Show the required symbol if field is required, but override not set.  Or show if override is set *}}
198                                 {{if ($fields[$colData.field.name].required && (!isset($colData.field.displayParams.required) || $colData.field.displayParams.required)) ||
199                                      (isset($colData.field.displayParams.required) && $colData.field.displayParams.required)}}
200                                     <span class="required" title="{{$APP.LBL_REQUIRED_TITLE}}">{{$APP.LBL_REQUIRED_SYMBOL}}</span>
201                                 {{/if}}
202                                 {{if !isset($colData.field.label) || !empty($colData.field.label)}}
203                                 <br>
204                                 {{/if}}
205                         {{/if}}
206
207                 {{$colData.field.prefix}}
208
209                         {{if $fields[$colData.field.name] && !empty($colData.field.fields) }}
210                             {{foreach from=$colData.field.fields item=subField}}
211                                 {{if $fields[$subField.name]}}
212                                         {counter name="panelFieldCount"}
213                                     {{sugar_field parentFieldArray='fields'  accesskey=$ACCKEY tabindex=$tabindex vardef=$fields[$subField.name] displayType='EditView' displayParams=$subField.displayParams formName=$form_name}}&nbsp;
214                                 {{/if}}
215                             {{/foreach}}
216                         {{elseif !empty($colData.field.customCode) && empty($colData.field.customCodeRenderField)}}
217                                 {counter name="panelFieldCount"}
218                                 {{sugar_evalcolumn var=$colData.field.customCode colData=$colData  accesskey=$ACCKEY tabindex=$tabindex}}
219                         {{elseif $fields[$colData.field.name]}}
220                                 {counter name="panelFieldCount"}
221                             {{$colData.displayParams}}
222                                 {{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}}
223                         {{/if}}
224         {{if !empty($colData.field.customCode) && !empty($colData.field.customCodeRenderField)}}
225             {counter name="panelFieldCount"}
226             {{sugar_evalcolumn var=$colData.field.customCode colData=$colData tabindex=$tabindex}}
227     {{/if}}
228     {{if !empty($colData.field.hideIf)}}
229                 {else}
230                 <td></td><td></td>
231                 {/if}
232     {{/if}}
233
234         {{/foreach}}
235 </tr>
236 {/capture}
237 {if $fieldsUsed > 0 }
238 {$tableRow}
239 {/if}
240 {{/foreach}}
241 </table>
242 {{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"}}
243 <script type="text/javascript">SUGAR.util.doWhen("typeof initPanel == 'function'", function() {ldelim} initPanel({{$smarty.foreach.section.iteration}}, '{{$panelState}}'); {rdelim}); </script>
244 {{/if}}
245
246 {{/if}}
247
248 </div>
249 {if $panelFieldCount == 0}
250
251 <script>document.getElementById("{{$label}}").style.display='none';</script>
252 {/if}
253 {{/foreach}}
254 </div></div>
255 {{include file=$footerTpl}}
256 {{if $useTabs}}
257 {sugar_getscript file="cache/include/javascript/sugar_grp_yui_widgets.js"}
258 <script type="text/javascript">
259 var {{$form_name}}_tabs = new YAHOO.widget.TabView("{{$form_name}}_tabs");
260 {{$form_name}}_tabs.selectTab(0);
261 </script>
262 {{/if}}
263 <script type="text/javascript">
264 YAHOO.util.Event.onContentReady("{{$form_name}}",
265     function () {ldelim} initEditView(document.forms.{{$form_name}}) {rdelim});
266 //window.setTimeout(, 100);
267 {{if $module == "Users"}}
268 window.onbeforeunload = function () {ldelim} return disableOnUnloadEditView(); {rdelim};
269 {{else}}
270 window.onbeforeunload = function () {ldelim} return onUnloadEditView(); {rdelim};
271 {{/if}}
272 // bug 55468 -- IE is too aggressive with onUnload event
273 if ($.browser.msie) {ldelim}
274 $(document).ready(function() {ldelim}
275     $(".collapseLink,.expandLink").click(function (e) {ldelim} e.preventDefault(); {rdelim});
276   {rdelim});
277 {rdelim}
278 </script>