Hi.
It’s possible to prevent user to create contracts from quotes if the quote is not approved?
Thank you.
Hi.
It’s possible to prevent user to create contracts from quotes if the quote is not approved?
Thank you.
@isildomendes, Yes
If you make special button here:
custom/include/generic/SugarWidgets/SugarWidget<you class button name>.php
and includes:
class SugarWidget<you class button name> extends SugarWidgetSubPanelTopButton
{
function display($defines)
{
//... Your code here. You can call parent display function or modified it here. It your decision.
}
}
After that you should copy file:
modules/AOS_Quotes/metadata/subpaneldefs.php
to file:
custom /modules/AOS_Quotes/metadata/subpaneldefs.php
and change
from:
...
'aos_quotes_aos_contracts' =>
array(
'order' => 100,
'module' => 'AOS_Contracts',
'subpanel_name' => 'default',
'sort_order' => 'asc',
'sort_by' => 'id',
'title_key' => 'AOS_Contracts',
'get_subpanel_data' => 'aos_quotes_aos_contracts',
'top_buttons' =>
array(
0 =>
array(
'widget_class' => 'SubPanelTopCreateButton',
),
1 =>
array(
'widget_class' => 'SubPanelTopSelectButton',
'popup_module' => 'AOS_Contracts',
'mode' => 'MultiSelect',
),
),
),
...
to:
...
'aos_quotes_aos_contracts' =>
array(
'order' => 100,
'module' => 'AOS_Contracts',
'subpanel_name' => 'default',
'sort_order' => 'asc',
'sort_by' => 'id',
'title_key' => 'AOS_Contracts',
'get_subpanel_data' => 'aos_quotes_aos_contracts',
'top_buttons' =>
array(
0 =>
array(
'widget_class' => '<you class button name>',
),
1 =>
array(
'widget_class' => 'SubPanelTopSelectButton',
'popup_module' => 'AOS_Contracts',
'mode' => 'MultiSelect',
),
),
), ...
You can take code for you button from file:
include/generic/SugarWidgets/SugarWidgetSubPanelTopButton.php
I mean the menu option ‘Create Contract’ in the ‘ACTIONS’ tab on quote view form.
I think you are referring to the sub-panel module (contracts), right?
Thank you.
@isildomendes Yes, I wrote about button in subpanel.
You can make with javascript and include function to custom/modules/AOS_Quotes/metadata/detailviewdefs.php
This is place (<your check function>) where you should include call function fo check:
...
8 =>
array(
'customCode' => '<input type="submit" class="button" onClick="<your check function>;this.form.action.value=\'createContract\';" value="{$MOD.LBL_CREATE_CONTRACT}">',
'sugar_html' =>
array(
'type' => 'submit',
'value' => '{$MOD.LBL_CREATE_CONTRACT}',
'htmlOptions' =>
array(
'class' => 'button',
'id' => 'create_contract_button',
'title' => '{$MOD.LBL_CREATE_CONTRACT}',
'onclick' => 'this.form.action.value=\'createContract\';',
'name' => 'Create Contract',
),
),
), ...
This is place where you should include javascript file with function fo check:
...
'templateMeta' =>
array(
...
'includes' =>
array(
0 =>
array(
'file' => 'custom/modules/AOS_Quotes/AOS_Quotes.js',
),
), ...
Alternative varint with use php. You should make and edit function display() in:
custom/modules/AOS_Quotes/views/view.detail.php
After this you should edit file:
custom/modules/AOS_Quotes/metadata/detailviewdefs.php
and replace button “createContract” to special tpl variable.
Ok.
Big thanks for your help.