Hi, I created two modules that are related to one to many, in the subpanel I modified the top buttons and enabled the select button, pressing this button the search pop-up appears, so that the initial search starts only from data relating to a specific ID (the one I’m currently in, on the Detailview page), I added:
$layout_defs["<name_module>"]["subpanel_setup"]['<relation>'] = array (
'order' => 100,
'module' => '<name_module_of_subpanel>',
'subpanel_name' => 'default',
'sort_order' => 'asc',
'sort_by' => 'id',
'title_key' => 'LBL_TITLE',
'get_subpanel_data' => '<relation>',
'top_buttons' =>
array (
/* 0 =>
array (
'widget_class' => 'SubPanelTopButtonQuickCreate',
), */
0 =>
array (
'widget_class' => 'SubPanelTopSelectButton',
'mode' => 'MultiSelect',
'initial_filter_fields' => array('id' => 'id_advanced'),
),
),
);
in custom /Extension/modules/<name_module>/Ext/Layoutdefs/.php
and it works well, the problem is that if I start a new search in this popup, even empty, the list of all the existing records in that module appears and not only those related to the ID of ‘initial_filter_fields’
Can anyone help me please? Thanks
no one can give me an idea?
Update: I found the problem, it’s in the header.tpl file. The search form points to the index.php page, while it should be modified with index.php? Module = … but I need to pass it the requested data, some of them are available, such as the module {$ module}, but the initial filter query and I don’t know how to take it.
The only variable that contains all the necessary info is {$ current_query}, but it is a string formed in this
“Module”: “<module_name>”, “action”, “Popup” …
but I don’t know how to extrapolate this info so I can insert it in the form index.php? module = {$ module_name} & …
Someone who can help?
841/5000
ok, I solved it by adding this line to the PopupSmarty.php file:
$ this-> th-> ss-> assign ('id', $ _REQUEST ["id"]);
but all this I did on the original header.tpl and PopupSmarty.php files, I would rather not touch them and use customized versions. I then added this line to the detailviewdefs file:
'form' =>
array (
'headerTpl' => 'custom / modules / <module_name> /tpls/header.tpl',
'buttons' =>
array (
0 => 'EDIT',
1 => 'DUPLICATE',
2 => 'DELETE',
3 => 'FIND_DUPLICATES',
)
)
and created in my module a modified copy of the header.tpl file and a copy of the DetailView.tpl file by adding this line:
{{include file = 'custom /modules/<mpdule_name>/tpls/header.tpl'}}
but it does not work.
Using SuiteCRM 7.10.20
Please, any suggestions?
@fab
I think, that you can
- make file “modules/<module_name>/tpls/popupHeader.tpl” (see: include/MVC/View/views/view.popup.php) and add there id.
- modify file: custom/modules/<module_name>/metadata/popupdefs.php and add filter for id.
Hi p.konetskiy, first of all thanks for replying, but I did not understand
-
I create, in my module, a popupHeader file that copies header.tpl (custom\include\DetailView), right? Where do I insert the id filter? in header.tpl or view.popup and in which row?
-
I copied the popupdefs file to the custom folder (it wasn’t there before), how do I change it?
So the procedure I illustrated earlier is wrong?
@fab
I found more easy solution:
- In subpanel of <name_module> add array ‘field_to_name_array’. For example:
$layout_defs["<name_module>"]["subpanel_setup"]['<relation>'] = array (
...
'top_buttons' => array (
0 => array (
...
'field_to_name_array'=>array('<special_name>' =>$this->_focus->id),
...
),
),
);
- In popup of your <name_module_of_subpanel> add into begin your popupdefs.php in custom/module/<name_module_of_subpanel>/metadata
or
module/<name_module_of_subpanel>/metadata
code (there is only example):
if (isset($_REQUEST['request_data'])&& !empty($_REQUEST['request_data'])){
$tmp= json_decode(html_entity_decode($_REQUEST['request_data']),true);
if(!empty($tmp['field_to_name_array']['<special_name>'])){
$where_param= '<name_of_field_id_in_DB> LIKE "'.$tmp['field_to_name_array']['<special_name>'].'"';
}
}
...
$popupMeta = array(
...
'whereStatement'=> $where_param,
...
);
This decision used only custom files and I tested it.
1 Like
Great p.konetskiy! Simple, clean and basic solution works! Thanks so much…
Another thing, if I wanted to insert a date range in the search popup, do you know how to do it?
@fab
It is blocked on system level. The function “getSearchViewSmarty” of file:
include/SugarFields/Fields/Datetime/SugarFieldDatetime.php
to call “isRangeSearchView” of file:
include/SugarFields/Fields/Base/SugarFieldBase.php
and this function do it:
protected function isRangeSearchView($vardef)
{
return !empty($vardef['enable_range_search']) && !empty($_REQUEST['action']) && $_REQUEST['action'] != 'Popup';
}
I don’t know “why”.
Yes, I had already noticed … I replaced that line with:
return! empty ($ vardef [‘enable_range_search’]) &&! empty ($ _ REQUEST [‘action’]);
and the range appears, but does not search