2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
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.
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
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
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.
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.
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 ********************************************************************************/
39 <form name='relform' onsubmit='return false;'>
40 <input type='hidden' name='to_pdf' value='1'>
41 <input type='hidden' name='module' value='ModuleBuilder'>
42 <input type='hidden' name='action' value='SaveRelationship'>
43 <input type='hidden' name='remove_tables' value='true' id="rel_remove_tables">
44 {if ! empty($view_package)}
45 <input type='hidden' name='view_package' value='{$view_package}'>
47 <input type='hidden' name='view_module' value='{$view_module}' />
48 {if $rel.relationship_only}
49 <input type='hidden' name='relationship_only' value='1'>
51 <table style="width:100%;" class="relform">
53 <td colspan='2' style="padding:5px 5px 15px 5px">
55 {if empty($view_package)}
56 <input type='button' name='saverelbtn' value='{$mod_strings.LBL_BTN_SAVEPUBLISH}' onclick='if(check_form("relform"))
58 <input type='button' name='saverelbtn' value='{$mod_strings.LBL_BTN_SAVE}' onclick='if(check_form("relform"))
60 ModuleBuilder.submitForm("relform");' class='button'>
61 {if ! empty($view_package)}
65 {if ($rel.from_studio || $rel.readonly && !$is_new) && $rel.relationship_type != 'one-to-one'}
66 <input type='button' name='saverelbtn' value='{$mod_strings.LBL_BTN_SAVE}' onclick='if(check_form("relform")){ldelim} this.form.action.value="SaveRelationshipLabel"; ModuleBuilder.submitForm("relform");{rdelim}' class='button'>
68 <input type='button' name='cancelbtn' value='{$mod_strings.LBL_BTN_CANCEL}' onclick='ModuleBuilder.tabPanel.removeTab(ModuleBuilder.findTabById("relEditor"));' class='button'>
69 {if $rel.from_studio || !$rel.readonly && !$is_new}
70 <input type='button' name='deleterelbtn' value='{$mod_strings.LBL_BTN_DELETE}' onclick='ModuleBuilder.deleteRel()' class='button'>
75 {if empty($view_package) && $rel.relationship_type != 'one-to-one'}
78 {$mod_strings.LBL_DROPDOWN_LANGUAGE}:
79 {html_options name='relationship_lang' id='relationship_lang' options=$available_languages selected=$selected_lang onchange='ModuleBuilder.moduleLoadRelationship2(document.relform.relationship_name.value, null, "true");'}
85 {if !empty($rel.relationship_name)}
86 <span align="right" scope="row">{$mod_strings.LBL_REL_NAME}: </span><span>{$rel.relationship_name}</span>
88 <input type="hidden" value="{$rel.relationship_name}" name="relationship_name" />
92 <table class="edit view">
93 <tr><th align="center" colspan=2>{$mod_strings.LBL_LHS_MODULE}</th><th>{$mod_strings.LBL_REL_TYPE}</th><th colspan=2>{$mod_strings.LBL_RHS_MODULE}</th></tr>
95 <td align="right" scope="row">
96 {sugar_translate label='LBL_MODULE'}:
99 <input name='ignore' value="{sugar_translate label=$module_key}" disabled >
100 <input type='hidden' name='lhs_module' value='{$module_key}'>
104 {html_options disabled=true name="relationship_type" id="relationship_type_field" output=$translated_cardinality values=$cardinality selected=$selected_cardinality }
106 {html_options name="relationship_type" id="relationship_type_field" output=$translated_cardinality values=$cardinality selected=$selected_cardinality onchange='ModuleBuilder.moduleLoadRelationship2(document.relform.relationship_name.value);' }
109 <td align="right" scope="row">
110 {sugar_translate label='LBL_MODULE'}:
112 <td>{if $rel.readonly}
113 <input name="rhs_module" id="rhs_mod_field" value="{$rel.rhs_module}" disabled>
115 {html_options name="rhs_module" id="rhs_mod_field" output=$translated_relatable values=$relatable selected=$rel.rhs_module onchange='ModuleBuilder.moduleLoadRelationship2(document.relform.relationship_name.value, true);'}
120 {if $rel.relationship_only}
123 {$mod_strings.LBL_RELATIONSHIP_ONLY}
127 {* add in subpanels and optional extended relationship condition *}
128 {if !empty($rel.rhs_module) && $rel.relationship_type != 'one-to-one'}
130 {if $rel.relationship_type == 'many-to-many' || $rel.relationship_type == 'many-to-one'}
131 <td align="right" scope="row">{sugar_translate label="LBL_REL_LABEL"}:</td>
132 <td><input name="lhs_label" id="lhs_label" value="{$rel.lhs_label}" ></td>
134 <td></td><td><input type="hidden" name="lhs_label" id="lhs_label" value="{$rel.lhs_label}" ></td>
137 {if $rel.relationship_type != 'many-to-one'}
138 <td align="right" scope="row">{sugar_translate label="LBL_REL_LABEL"}:</td>
139 <td><input name="rhs_label" id="rhs_label" value="{$rel.rhs_label}" ></td>
141 <td></td><td><input type="hidden" name="rhs_label" id="rhs_label" value="{$rel.rhs_label}" ></td>
145 {if $rel.relationship_type == 'many-to-many' || $rel.relationship_type == 'many-to-one'}
146 <td align="right" scope="row">{$mod_strings.LBL_SUBPANEL_FROM} {sugar_translate label=$rel.lhs_module}:</td>
147 <td> {if $rel.readonly}
148 <input name="lhs_subpanel" id="lhs_subpanel" value="{$rel.lhs_subpanel}" disabled>
150 {html_options name="lhs_subpanel" id="lhs_subpanel" output=$lhspanels values=$lhspanels selected=$rel.lhs_subpanel alt=$mod_strings.LBL_MSUB}
153 {else}<td></td><td></td>{/if}
155 {if $rel.relationship_type != 'many-to-one'}
156 <td align="right" scope="row">{$mod_strings.LBL_SUBPANEL_FROM} {sugar_translate label=$rel.rhs_module}:</td>
159 <input name="lhs_subpanel" id="lhs_subpanel" value="{$rel.rhs_subpanel}" disabled>
161 {html_options name="rhs_subpanel" id="rhs_subpanel" output=$rhspanels values=$rhspanels selected=$rel.rhs_subpanel alt=$mod_strings.LBL_RSUB}
169 {* add in the extended relationship condition *}
170 {* comment out for now as almost no expressed need for this - to revert, uncomment and test, test, test...
173 <td align="right" scope="row">{$mod_strings.LBL_RELATIONSHIP_ROLE_ENTRIES}:</td>
175 {if $rel.relationship_type == 'one-to-many'}
178 <td><span style='float:right;'>{$mod_strings.LBL_RELATIONSHIP_ROLE_COLUMN}:</span></td>
180 <input name="relationship_role_column" id="relationship_role_column_field" value="{$rel.relationship_role_column}" {if $rel.readonly}disabled{/if} />
183 {/if} {* one-to-many *}
187 <td align="right" scope="row"><span style='float:right;'>{$mod_strings.LBL_RELATIONSHIP_ROLE_VALUE}:</span></td>
189 <input name="relationship_role_column_value" id="relationship_role_column__value_field" value="{$rel.relationship_role_column_value}" {if $rel.readonly}disabled{/if} />
194 {/if} {* subpanels etc for all but one-to-one relationships *}
195 {/if} {* if relationship_only *}
202 ModuleBuilder.deleteRel = function()
204 YAHOO.util.Dom.get("rel_remove_tables").value = true;
205 YAHOO.SUGAR.MessageBox.show(
210 msg:'<b>{sugar_translate label="LBL_CONFIRM_RELATIONSHIP_DELETE"}</b>' +
211 "<div style='height:1em;'> </div><p><input type='checkbox' onclick='YAHOO.util.Dom.get(\"rel_remove_tables\").value = this.checked ? \"\" : true;' />" +
212 " {sugar_translate label="ML_LBL_DO_NOT_REMOVE_TABLES" module="Administration"}</p>",
214 fn: function(confirm) {
215 if (confirm == 'yes') {
216 document.forms.relform.action.value="DeleteRelationship";
217 ModuleBuilder.submitForm("relform");
218 ModuleBuilder.tabPanel.removeTab(ModuleBuilder.findTabById("relEditor"));
225 addToValidate('relform', 'label', 'varchar', true, '{$mod_strings.LBL_JS_VALIDATE_REL_LABEL}');
226 {if $fromModuleBuilder}
227 ModuleBuilder.helpSetup('relationshipsHelp','addRelationship');
229 ModuleBuilder.helpSetup('studioWizard','relationshipHelp');