]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Leads/tpls/EditConvertLead.tpl
Release 6.4.0
[Github/sugarcrm.git] / modules / Leads / tpls / EditConvertLead.tpl
1 {*
2 /*********************************************************************************
3  * SugarCRM Community Edition is a customer relationship management program developed by
4  * SugarCRM, Inc. Copyright (C) 2004-2011 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 *}
39
40
41 {literal}
42 <style>
43 .yui-dt-col-required .yui-dt-liner, .yui-dt-col-select .yui-dt-liner, .yui-dt-col-copyData .yui-dt-liner,
44 .yui-dt-col-edit .yui-dt-liner, .yui-dt-col-delete .yui-dt-liner
45 {
46     text-align:center;
47 }
48 </style>
49 {/literal}
50 {if !empty($warningMessage)}
51 <p class="error">{$warningMessage}</p>
52 {/if}
53 <input type='button' name='saveLayout' value='{sugar_translate label="LBL_BTN_SAVE" module="ModuleBuilder"}'
54     class='button' onclick='ModuleBuilder.saveConvertLeadLayout();' style="margin-bottom:5px;">
55 <img class="spacer" src="include/images/blank.gif" style="width:50px;height:5px"/>
56 {html_options name="convertSelectNewModule" id="convertSelectNewModule" options=$availibleModules}
57 <input type='button' name='addModule' value='{sugar_translate label="LBL_CONVERT_ADD_MODULE"}'
58     class='button' onclick='ModuleBuilder.addConvertLeadLayout();' style="margin-bottom:5px;">
59
60
61 <div id='relGrid'></div>
62 {if $studio}{sugar_translate label='LBL_CUSTOM_RELATIONSHIPS' module='ModuleBuilder'}</h3>{/if}
63 <script>
64 {literal}
65
66 function getModuleNameFromLabel(label) {
67     var moduleList = SUGAR.language.get('app_list_strings', "moduleList");
68     for ( var i in moduleList) {
69         if (moduleList[i] == label) {
70             return i;
71         }
72     }
73     return label;
74 }
75
76 var editLayout = function(row)
77 {
78         var panel = ModuleBuilder.findTabById('convEditor');
79     if (!panel) {
80         panel = new YAHOO.SUGAR.ClosableTab({ {/literal}
81             label: "{sugar_translate label="LBL_CONVERT_EDIT_LAYOUT"}",
82             id: 'convEditor',
83             scroll: true,
84             cacheData: true,
85             active :true,
86             content: "<img alt='{$mod_strings.LBL_LOADING}' name='loading' src='{sugar_getimagepath file='loading.gif'}' />{sugar_translate label='LBL_LOADING'}"{literal}
87         }, ModuleBuilder.tabPanel);
88         ModuleBuilder.tabPanel.addTab(panel);
89     } else {
90         ModuleBuilder.tabPanel.set("activeTab", panel);
91     }
92     var params = {
93         module: 'Leads',
94         action: 'editconvertlayout',
95         view_module: getModuleNameFromLabel(row.module),
96         json: false,
97         id:'convEditor'
98     };
99     ModuleBuilder.asyncRequest(params, function(o) {
100         ajaxStatus.hideStatus();
101         var tab = ModuleBuilder.findTabById('convEditor');
102         tab.set("content", o.responseText);
103         SUGAR.util.evalScript(o.responseText);
104     });
105 }
106 var removeLayout = function(row)
107 {
108         if (confirm("Are you sure you wish to remove this layout?")) {
109                 var params = {
110                 module: 'Leads',
111                 action: 'editconvert',
112                 removeLayout: true,
113                 targetModule:getModuleNameFromLabel(row.module)
114             };
115
116             ModuleBuilder.asyncRequest(params, function(o) {
117                 ajaxStatus.hideStatus();
118                 ModuleBuilder.updateContent(o);
119             });
120         }
121 }
122
123 var formatSelect = function(el, rec, col, data)
124 {
125     var row = rec.getData();
126     var selected = false;
127     if (row.select) selected = row.select;
128     var ret = "<input type='checkbox' name='" + rec.getData().module + "-" + col.field + "'";
129     if(typeof(relationships[row.module]) == "undefined" || row.module == "Contacts")
130         ret += " disabled />";
131     else {
132         ret += "onclick='ModuleBuilder.convertLayoutGrid.getRecord(this).setData(\"select\", this.checked ? \""
133             + relationships[row.module][0] + "\" : false);'";
134         if (selected)
135                 ret += " checked='true'";
136         ret += "/>";
137     }
138     el.innerHTML = ret;
139 }
140 var getEditButton = function(el, rec, col, data){
141     var out = {/literal}"<img alt='{$mod_strings.LBL_EDIT_INLINE}' name='edit_inline' src='{sugar_getimagepath file='edit_inline.gif'}' />";{literal}
142         el.innerHTML = out;
143         YAHOO.util.Event.addListener(el, "click", function(){editLayout(grid.getRecord(el).getData());});
144 }
145 var getRemoveButton = function(el, rec, col, data){
146         if (rec.getData().module =="Contacts")
147            return;
148     var out = {/literal}"<img alt='{$mod_strings.LBL_EDIT_INLINE}' name='delete_inline' src='{sugar_getimagepath file='delete_inline.gif'}' />";{literal}
149     el.innerHTML = out;
150     YAHOO.util.Event.addListener(el, "click", function(){removeLayout(grid.getRecord(el).getData());});
151 }
152 var getDisabledCheckbox = function(el, rec, col, data){
153     var out = "<input type='checkbox' name='" + rec.getData().module + "-" + col.field + "'"
154                + "onclick='ModuleBuilder.convertLayoutGrid.getRecord(this).setData(\"" + col.field + "\", this.checked)';";
155     if(data)
156         out += " checked='checked'";
157         if (rec.getData().module == "Contacts")
158            out += " disabled ";
159     out += " />";
160     el.innerHTML = out;
161    // YAHOO.util.Event.addListener(el, "click", function(){editLayout(grid.getRecord(el).getData());});
162 }
163
164 {/literal}
165 var modules = {ldelim}modules:{$modules}{rdelim};
166 var relationships = {$relationships};
167 YAHOO.SUGAR.DragDropTable.groups = [];
168 var grid = ModuleBuilder.convertLayoutGrid = new YAHOO.SUGAR.DragDropTable('relGrid',
169     [
170         {ldelim}key:'module',       label: '{sugar_translate label="LBL_CONVERT_MODULE_NAME"}', hidden: true {rdelim},
171         {ldelim}key:'moduleName',   label: '{sugar_translate label="LBL_CONVERT_MODULE_NAME"}', width: 200,sortable: true {rdelim},
172         {ldelim}key:'required',     label: '{sugar_translate label="LBL_CONVERT_REQUIRED"}',    width: 80, sortable: false, formatter:getDisabledCheckbox{rdelim},
173         {ldelim}key:'copyData',     label: '{sugar_translate label="LBL_CONVERT_COPY"}',        width: 80, sortable: false, formatter:getDisabledCheckbox{rdelim},
174         {ldelim}key:'select',       label: '{sugar_translate label="LBL_CONVERT_SELECT"}',      width: 80, sortable: false, formatter:formatSelect{rdelim},
175         {ldelim}key:'edit',         label: '{sugar_translate label="LBL_CONVERT_EDIT"}',        width: 40, sortable: false, formatter:getEditButton{rdelim},
176         {ldelim}key:'delete',       label: '{sugar_translate label="LBL_CONVERT_DELETE"}',      width: 40, sortable: false, formatter:getRemoveButton{rdelim}
177     ],{literal}
178     new YAHOO.util.LocalDataSource(modules, {
179         responseSchema: {
180            resultsList : "modules",
181            fields : [{key : "module"}, {key : "moduleName"},{key: "required"}, {key: "select"}, {key: "copyData"}, {key: "edit"}, {key: "delete"}]
182         }
183     }),
184     {MSG_EMPTY: SUGAR.language.get('ModuleBuilder','LBL_NO_RELS')}
185 );
186 grid.subscribe("rowMouseoverEvent", grid.onEventHighlightRow);
187 grid.subscribe("rowMouseoutEvent", grid.onEventUnhighlightRow);
188 grid.render();
189 {/literal}
190 //tooltips
191 new YAHOO.widget.Tooltip("module_tooltip", {ldelim}
192     context: grid.getColumn(0).getThEl(),
193     text: '{sugar_translate label="LBL_MODULE_TIP"}',
194     showDelay: 500
195 {rdelim});
196 new YAHOO.widget.Tooltip("required_tooltip", {ldelim}
197     context: grid.getColumn(1).getThEl(),
198     text: '{sugar_translate label="LBL_REQUIRED_TIP"}',
199     showDelay: 500
200 {rdelim});
201 new YAHOO.widget.Tooltip("copy_tooltip", {ldelim}
202     context: grid.getColumn(2).getThEl(),
203     text: '{sugar_translate label="LBL_COPY_TIP"}',
204     showDelay: 500
205 {rdelim});
206 new YAHOO.widget.Tooltip("selection_tooltip", {ldelim}
207     context: grid.getColumn(3).getThEl(),
208     text: '{sugar_translate label="LBL_SELECTION_TIP"}',
209     showDelay: 500
210 {rdelim});
211 new YAHOO.widget.Tooltip("edit_tooltip", {ldelim}
212     context: grid.getColumn(4).getThEl(),
213     text: '{sugar_translate label="LBL_EDIT_TIP"}',
214     showDelay: 500
215 {rdelim});
216 new YAHOO.widget.Tooltip("delete_tooltip", {ldelim}
217     context: grid.getColumn(5).getThEl(),
218     text: '{sugar_translate label="LBL_DELETE_TIP"}',
219     showDelay: 500
220 {rdelim});
221 {literal}
222 ModuleBuilder.saveConvertLeadLayout = function()
223 {
224         var rows = ModuleBuilder.convertLayoutGrid.getRecordSet().getRecords();
225     var out = {};
226     for (var i in rows) {
227         out[i] = rows[i].getData();
228         out[i].module = getModuleNameFromLabel(out[i].module);
229     }
230     var params = {
231         module: 'Leads',
232         action: 'editconvert',
233         updateOrder: true,
234         data:YAHOO.lang.JSON.stringify(out)
235     };
236
237         ModuleBuilder.asyncRequest(params, function(o) {
238             ajaxStatus.hideStatus();
239             ModuleBuilder.updateContent(o);
240         });
241 }
242 ModuleBuilder.addConvertLeadLayout = function()
243 {
244     var rows = ModuleBuilder.convertLayoutGrid.getRecordSet().getRecords();
245     var Dom = YAHOO.util.Dom;
246     ModuleBuilder.convertLayoutGrid.addRow({
247         module:Dom.get("convertSelectNewModule").value,
248         required:false,
249         copyData:false,
250         select:false
251     });
252     ModuleBuilder.saveConvertLeadLayout();
253 }
254 {/literal}
255 ModuleBuilder.module = '{$view_module}';
256 ModuleBuilder.MBpackage = '{$view_package}';
257 ModuleBuilder.helpSetup('studioWizard','convertLeadHelp');
258 </script>