Skip to content

Instantly share code, notes, and snippets.

@matthewpoer
Last active August 29, 2015 13:56
Show Gist options
  • Save matthewpoer/8871568 to your computer and use it in GitHub Desktop.
Save matthewpoer/8871568 to your computer and use it in GitHub Desktop.
Example of SugarCRM "Split Subpanels" - i.e. a single subpanel is split into two. In this example a WHERE clause separates future from past transactions from a custom Transactions module.
<?php
// modules/PSI_Payments/metadata/subpanels/past.php
$module_name='PSI_Payments';
$subpanel_layout = array (
'top_buttons' =>
array (
0 =>
array (
'widget_class' => 'SubPanelTopCreateButton',
),
1 =>
array (
'widget_class' => 'SubPanelTopSelectButton',
'popup_module' => 'PSI_Payments',
),
),
'where' => "psi_payments.status = 'SCHEDULED'",
'list_fields' =>
array (
'ram_date' =>
array (
'type' => 'date',
'vname' => 'LBL_RAM_DATE',
'width' => '10%',
'default' => true,
),
'amount' =>
array (
'type' => 'currency',
'vname' => 'LBL_AMOUNT',
'currency_format' => true,
'width' => '10%',
'default' => true,
),
'monthly_fee' =>
array (
'type' => 'currency',
'vname' => 'LBL_MONTHLY_FEE',
'currency_format' => true,
'width' => '10%',
'default' => true,
),
'mait_fee' =>
array (
'type' => 'currency',
'vname' => 'LBL_MAIT_FEE',
'currency_format' => true,
'width' => '10%',
'default' => true,
),
'ram_fee' =>
array (
'type' => 'currency',
'vname' => 'LBL_RAM_FEE',
'currency_format' => true,
'width' => '10%',
'default' => true,
),
'status' =>
array (
'type' => 'varchar',
'vname' => 'LBL_STATUS',
'width' => '10%',
'default' => true,
),
),
);
<?php
// custom/Extension/modules/Contacts/Ext/Layoutdefs/psi_payments_contacts.php
// created: 2013-12-05 10:39:16
$layout_defs["Contacts"]["subpanel_setup"]['psi_payments_contacts_scheduled'] = array (
'order' => 100,
'module' => 'PSI_Payments',
'subpanel_name' => 'scheduled',
'sort_order' => 'asc',
'sort_by' => 'ram_date',
'title_key' => 'LBL_PSI_PAYMENTS_CONTACTS_FROM_PSI_PAYMENTS_TITLE_SCHEDULED',
'get_subpanel_data' => 'psi_payments_contacts',
'top_buttons' =>
array (
0 =>
array (
'widget_class' => 'SubPanelTopButtonQuickCreate',
),
1 =>
array (
'widget_class' => 'SubPanelTopSelectButton',
'mode' => 'MultiSelect',
),
),
);
// created: 2013-12-05 10:39:16
$layout_defs["Contacts"]["subpanel_setup"]['psi_payments_contacts_past'] = array (
'order' => 100,
'module' => 'PSI_Payments',
'subpanel_name' => 'past',
'sort_order' => 'desc',
'sort_by' => 'ram_date',
'title_key' => 'LBL_PSI_PAYMENTS_CONTACTS_FROM_PSI_PAYMENTS_TITLE_HELD',
'get_subpanel_data' => 'psi_payments_contacts',
'top_buttons' =>
array (
0 =>
array (
'widget_class' => 'SubPanelTopButtonQuickCreate',
),
1 =>
array (
'widget_class' => 'SubPanelTopSelectButton',
'mode' => 'MultiSelect',
),
),
);
<?php
// modules/PSI_Payments/metadata/subpanels/scheduled.php
$module_name='PSI_Payments';
$subpanel_layout = array (
'top_buttons' =>
array (
0 =>
array (
'widget_class' => 'SubPanelTopCreateButton',
),
1 =>
array (
'widget_class' => 'SubPanelTopSelectButton',
'popup_module' => 'PSI_Payments',
),
),
'where' => "psi_payments.status = 'SCHEDULED'",
'list_fields' =>
array (
'ram_date' =>
array (
'type' => 'date',
'vname' => 'LBL_RAM_DATE',
'width' => '10%',
'default' => true,
),
'amount' =>
array (
'type' => 'currency',
'vname' => 'LBL_AMOUNT',
'currency_format' => true,
'width' => '10%',
'default' => true,
),
'monthly_fee' =>
array (
'type' => 'currency',
'vname' => 'LBL_MONTHLY_FEE',
'currency_format' => true,
'width' => '10%',
'default' => true,
),
'mait_fee' =>
array (
'type' => 'currency',
'vname' => 'LBL_MAIT_FEE',
'currency_format' => true,
'width' => '10%',
'default' => true,
),
'ram_fee' =>
array (
'type' => 'currency',
'vname' => 'LBL_RAM_FEE',
'currency_format' => true,
'width' => '10%',
'default' => true,
),
'status' =>
array (
'type' => 'varchar',
'vname' => 'LBL_STATUS',
'width' => '10%',
'default' => true,
),
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment