Blogs
            
              05
February
              
            
            
            
          		  
		  
		February
There comes the time when sales rep finds it irritating to view opportunities Closed Won and Closed Lost under same subpanel.
 
Lets make custom subpanels separating Closed Won and Closed Lost.
 
In this blog post, we will add those subpanels under Accounts module.
 
Step 1 : Create custom/Extension/modules/Accounts/Ext/Layoutdefs/<any_name>.php and write the following code into it.
 
Step 2 : Create custom/modules/Accounts/customOpportunitiesSubpanel.php and write following code into it.
 
Step 3 : Create custom/Extension/modules/Accounts/Ext/Language/en_us.<any_name>.php and write the following custom label into it.
 
Step 4 : Do Quick Repair and Rebuild from Admin panel.
 
  
 
 
Feel free to leave comments.
 
          Lets make custom subpanels separating Closed Won and Closed Lost.
In this blog post, we will add those subpanels under Accounts module.
Step 1 : Create custom/Extension/modules/Accounts/Ext/Layoutdefs/<any_name>.php and write the following code into it.
<?php 
$layout_defs['Accounts']['subpanel_setup']['opp_closed_lost'] =
array('order' => 49,
'module' => 'Opportunities',
'subpanel_name' => 'ForAccounts',
'get_subpanel_data' => 'function:get_closed_lost_closed_won_opportunities',
'generate_select' => true,
'title_key' => 'LBL_OPPORTUNITIES_WITH_CLOSED_LOST',
'top_buttons' => array(),
'function_parameters' => array(
'import_function_file' => 'custom/modules/Accounts/customOpportunitiesSubpanel.php',
'sales_stage' => 'Closed Lost',
'account_id' => $this->_focus->id,
'return_as_array' => 'true'
),
);
$layout_defs['Accounts']['subpanel_setup']['opp_closed_won'] =
array('order' => 50,
'module' => 'Opportunities',
'subpanel_name' => 'ForAccounts',
'get_subpanel_data' => 'function:get_closed_lost_closed_won_opportunities',
'generate_select' => true,
'title_key' => 'LBL_OPPORTUNITIES_WITH_CLOSED_WON',
'top_buttons' => array(),
'function_parameters' => array(
'import_function_file' => 'custom/modules/Accounts/customOpportunitiesSubpanel.php',
'sales_stage' => 'Closed Won',
'account_id' => $this->_focus->id,
'return_as_array' => 'true'
),
);
$layout_defs['Accounts']['subpanel_setup']['opp_closed_lost'] =
array('order' => 49,
'module' => 'Opportunities',
'subpanel_name' => 'ForAccounts',
'get_subpanel_data' => 'function:get_closed_lost_closed_won_opportunities',
'generate_select' => true,
'title_key' => 'LBL_OPPORTUNITIES_WITH_CLOSED_LOST',
'top_buttons' => array(),
'function_parameters' => array(
'import_function_file' => 'custom/modules/Accounts/customOpportunitiesSubpanel.php',
'sales_stage' => 'Closed Lost',
'account_id' => $this->_focus->id,
'return_as_array' => 'true'
),
);
$layout_defs['Accounts']['subpanel_setup']['opp_closed_won'] =
array('order' => 50,
'module' => 'Opportunities',
'subpanel_name' => 'ForAccounts',
'get_subpanel_data' => 'function:get_closed_lost_closed_won_opportunities',
'generate_select' => true,
'title_key' => 'LBL_OPPORTUNITIES_WITH_CLOSED_WON',
'top_buttons' => array(),
'function_parameters' => array(
'import_function_file' => 'custom/modules/Accounts/customOpportunitiesSubpanel.php',
'sales_stage' => 'Closed Won',
'account_id' => $this->_focus->id,
'return_as_array' => 'true'
),
);
Step 2 : Create custom/modules/Accounts/customOpportunitiesSubpanel.php and write following code into it.
<?php 
function get_closed_lost_closed_won_opportunities($params) {
$args = func_get_args();
$opportunitiesSalesStage = $args[0]['sales_stage'];
$accountId = $args[0]['account_id'];
$return_array['select'] = " SELECT opportunities.*";
$return_array['from'] = " FROM opportunities ";
$return_array['where'] = " WHERE opportunities.deleted = '0' AND opportunities.sales_stage = '" . $opportunitiesSalesStage . "'";
$return_array['join'] = " INNER JOIN accounts_opportunities ON accounts_opportunities.opportunity_id = opportunities.id AND accounts_opportunities.deleted = '0' INNER JOIN accounts ON accounts.id = accounts_opportunities.account_id AND accounts.deleted = '0' AND accounts.id = '" . $accountId . "'";
$return_array['join_tables'] = '';
return $return_array;
}
function get_closed_lost_closed_won_opportunities($params) {
$args = func_get_args();
$opportunitiesSalesStage = $args[0]['sales_stage'];
$accountId = $args[0]['account_id'];
$return_array['select'] = " SELECT opportunities.*";
$return_array['from'] = " FROM opportunities ";
$return_array['where'] = " WHERE opportunities.deleted = '0' AND opportunities.sales_stage = '" . $opportunitiesSalesStage . "'";
$return_array['join'] = " INNER JOIN accounts_opportunities ON accounts_opportunities.opportunity_id = opportunities.id AND accounts_opportunities.deleted = '0' INNER JOIN accounts ON accounts.id = accounts_opportunities.account_id AND accounts.deleted = '0' AND accounts.id = '" . $accountId . "'";
$return_array['join_tables'] = '';
return $return_array;
}
Step 3 : Create custom/Extension/modules/Accounts/Ext/Language/en_us.<any_name>.php and write the following custom label into it.
<?php 
$mod_strings['LBL_OPPORTUNITIES_WITH_CLOSED_LOST'] = "Opportunities With Closed Lost";
$mod_strings['LBL_OPPORTUNITIES_WITH_CLOSED_WON'] = "Opportunities With Closed Won";
$mod_strings['LBL_OPPORTUNITIES_WITH_CLOSED_LOST'] = "Opportunities With Closed Lost";
$mod_strings['LBL_OPPORTUNITIES_WITH_CLOSED_WON'] = "Opportunities With Closed Won";
Step 4 : Do Quick Repair and Rebuild from Admin panel.
 
 Feel free to leave comments.
			Download attachments:
			
		  
		  
		  
          
          
          
      Comments
- No Comments Found.
