I have created a new module "Borrower" . This new modules uses a table "borrowers" and each borrower will be tied to multiple quotes.
What I am trying to do is add a "Quotes" subpanel to the new module. I found a Subpanel guide in the sugar forums, and have followed the directions within.
Basically, I have another new table quotes_borrowers that mimics the quotes_opportunites table (id, quote_id, borrower_id, date_modified, deleted, see attached sql). In this table I added a couple records to tie 2 quotes to an existing borrower so that my subpanel would show 2 records for that borrower.
Then, here is the code we have added:
In modules/Borrower/layout_defs.php:
'quotes' => array(
'order' => 10,
'module' => 'Quotes',
'subpanel_name' => 'default',
'get_subpanel_data' => 'quotes',
'add_subpanel_data' => 'quote_id',
'title_key' => 'LBL_QUOTES_SUBPANEL_TITLE',
'top_buttons' => array(
array('widget_class' => 'SubPanelTopCreateButton'),
),
),
In modules/Borrower/vardefs.php:
'quotes' =>
array (
'name' => 'quotes',
'type' => 'link',
'relationship' => 'quotes_borrowers',
'source'=>'non-db',
'module' => 'Quotes',
'ignore_role' => true,
'vname'=>'LBL_QUOTES',
),
In new file, metadata/quotes_borrowersMetData.php:
$dictionary['quotes_borrowers'] = array ( 'table' => 'quotes_borrowers'
, 'fields' => array (
array('name' =>'id', 'type' =>'varchar', 'len'=>'36')
, array('name' =>'borrower_id', 'type' =>'varchar', 'len'=>'36',)
, array('name' =>'quote_id', 'type' =>'varchar', 'len'=>'36', )
, array ('name' => 'date_modified','type' => 'datetime')
, array('name' =>'deleted', 'type' =>'bool', 'len'=>'1', 'default'=>'0', 'required'=>true)
) , 'indices' => array (
array('name' =>'quotes_borrowerspk', 'type' =>'primary', 'fields'=>array('id'))
, array('name' =>'idx_qte_borr_borr', 'type' =>'index', 'fields'=>array('borrower_id'))
, array('name' => 'idx_qte_borr_qte', 'type'=>'alternate_key', 'fields'=>array('quote_id'))
)
, 'relationships' => array ('quotes_borrowers' => array('lhs_module'=> 'Borrower', 'lhs_table'=> 'borrowers', 'lhs_key' => 'id',
'rhs_module'=> 'Quotes', 'rhs_table'=> 'quotes', 'rhs_key' => 'id',
'relationship_type'=>'many-to-many',
'join_table'=> 'quotes_borrowers', 'join_key_lhs'=>'borrower_id', 'join_key_rhs'=>'quote_id',
))
)
And in custom/application/Ext/TableDictionary/tabledictionary.ext.php:
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
include_once("metadata/quotes_borrowersMetaData.php");
?>
Then rebuilt the relationships through the admin panel.
We have tried variations of this code, putting the relationship definition directly into vardefs.php, etc and still the subpanel either shows no records (most common case) or show all of the quotes in the quotes table.
Any help is much appreciated. Thank you for your time.


LinkBack URL
About LinkBacks



Reply With Quote
Bookmarks