Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
en:modifications:popup_relations [2014/10/09 14:24] swarnat |
en:modifications:popup_relations [2014/11/03 10:52] (current) swarnat [Create a Relation] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== PopUp Relations ====== | ====== PopUp Relations ====== | ||
- | Require vtigerCRM 6.1 | + | <WRAP center box 60%> |
+ | If you use this modification you read and accept the following introduction: | ||
+ | [[en:modifications|https://support.stefanwarnat.de/en:modifications]] | ||
+ | </WRAP> | ||
- | This modification could decrease the frontend performance a little. | + | ===== Explanation of modification ===== |
- | In modern Browsers this won't recognizable. | + | |
+ | This modification could help you, if you create a custom module and want to link this module with default modules. | ||
+ | |||
+ | For example you create a new Module "Buildings" which has a field "Organization" to link a Organizations. | ||
+ | Now you had a related field in Contacts to choose a record within the new "Buildings" module. | ||
+ | |||
+ | In basic Vtiger you will see every available record in "Buildings" if you click on the search button, regardless if you select a Organization in the Contact, which could limit the available records. | ||
+ | This modification will integrate this in a flexible way. | ||
+ | You could create a configuration in the database to only get Buildings from the Organization of the Contacts as selection. (See below) | ||
+ | But you are not limited to this records. If you use the search option in the popup you could nevertheless select every record. | ||
+ | ===== Read first ===== | ||
+ | This modification was only tested in vtigerCRM 6.1. | ||
+ | |||
+ | This modification could **decrease the frontend performance a little**, because it needs to be integrated into every EditView. Regardless if you use this feature in the module. | ||
+ | **In modern Browsers you won't recognize this.** | ||
It execute 2 database Queries on the EditView/CreateView and one in the PopUp. | It execute 2 database Queries on the EditView/CreateView and one in the PopUp. | ||
- | At first please install | + | At first please install the latest version of [[https://shop.stefanwarnat.de/vtigercrm-tools/|VtigerCRM Tools]] |
==== Create DB Table ==== | ==== Create DB Table ==== | ||
Line 12: | Line 29: | ||
CREATE TABLE IF NOT EXISTS `vtiger_popup_relation` ( | CREATE TABLE IF NOT EXISTS `vtiger_popup_relation` ( | ||
`id` int(11) NOT NULL, | `id` int(11) NOT NULL, | ||
- | `src_module` varchar(30) NOT NULL, | + | `src_module` varchar(30) NOT NULL, |
- | `src_field` varchar(50) NOT NULL, | + | `src_field` varchar(50) NOT NULL, |
- | `module` varchar(30) NOT NULL, | + | `module` varchar(30) NOT NULL, |
- | `search_key` varchar(50) NOT NULL | + | `search_key` varchar(50) NOT NULL, |
+ | `search_value` varchar(50) NOT NULL | ||
) ENGINE=InnoDB ; | ) ENGINE=InnoDB ; | ||
Line 80: | Line 98: | ||
var $additionalSearchParameters = '.json_encode($additionalParameters).'; | var $additionalSearchParameters = '.json_encode($additionalParameters).'; | ||
jQuery(function() { | jQuery(function() { | ||
- | SWVtigerTools.registerFilter("PopUpParams", function(params) { | + | if(typeof SWVtigerTools !== "undefined") { |
- | if(typeof $additionalSearchParameters[params.src_field] !== "undefined") { | + | SWVtigerTools.registerFilter("PopUpParams", function(params) { |
- | var value = $additionalSearchParameters[params.src_field]; | + | if(typeof $additionalSearchParameters[params.src_field] !== "undefined") { |
- | params["swpopup_search"] = value[0]; | + | var value = $additionalSearchParameters[params.src_field]; |
- | params["swpopup_value"] = jQuery(\'[name="\' + value[1] + \'"]\').val(); | + | var fieldValue = jQuery(\'[name="\' + value[1] + \'"]\').val(); |
- | } | + | if(fieldValue == "") return params; |
- | return params; | + | params["swpopup_search"] = value[0]; |
- | }); | + | params["swpopup_value"] = fieldValue |
+ | } | ||
+ | return params; | ||
+ | }); | ||
+ | } | ||
}); | }); | ||
</script>'; | </script>'; | ||
Line 122: | Line 144: | ||
*/ | */ | ||
</code> | </code> | ||
+ | |||
+ | ===== Create a Relation ===== | ||
+ | |||
+ | You now could use this feature. | ||
+ | You need to insert a new line in the just created table vtiger_popup_relation. | ||
+ | |||
+ | You get the values if you open the PopUp you want to modify. | ||
+ | |||
+ | ^ Column ^ Value ^ | ||
+ | | src_module | You get from the PopUP URL | | ||
+ | | src_field | You get from the PopUP URL | | ||
+ | | module | You get from the PopUP URL | | ||
+ | | search_key | Which field in the related module should be used to search | | ||
+ | | search_value | Which fieldvalue of the record you modify should be used | | ||
+ | <WRAP center tip 100%> | ||
+ | === Example === | ||
+ | You have a new Field "Contact B" (Fieldname: contactb_id) in the Organization module, which should only choosable from Contacts within the Organization in "Member Of" (Fieldname: account_id) | ||
+ | (Organization fieldname in Contacts module is "account_id", too) | ||
+ | |||
+ | You need to insert: | ||
+ | | **src_module** | Accounts | | ||
+ | | **src_field** | contactb_id | | ||
+ | | **module** | Contacts | | ||
+ | | **search_key** | account_id | (The field within Contacts module) | | ||
+ | | **search_value** | account_id | (The field within Organization module) | | ||
+ | |||
+ | </WRAP> |