It looks like you're new here. If you want to get involved, click one of these buttons!
CREATE TABLE `vtiger_pricebookaccountrel` (
`accountid` int(19) NOT NULL default '0',
`pricebookid` int(19) NOT NULL default '0',
PRIMARY KEY (`accountid`,`pricebookid`),
KEY `pricebookaccountrel_accountid_idx` (`accountid`)
) TYPE=InnoDB;
INSERT INTO vtiger_pricebookaccountrel (`accountid`, `pricebookid`) VALUES
(2502035, 97);
I created new relation in to vtiger_relatedlists
INSERT INTO `vtiger_relatedlists` (`relation_id`, `tabid`, `related_tabid`, `name`, `sequence`, `label`, `presence`) VALUES
(82, 6, 19, 'get_account_pricebooks', 2, 'PriceBooks', 0);
/**
* Function to get Account related PriceBooks
* @param integer $id - accountid
* returns related PriceBooks record in array format
*/
function get_account_pricebooks($id)
{
global $log,$singlepane_view;
$log->debug("Entering get_account_pricebooks(".$id.") method ...");
global $mod_strings;
require_once('modules/PriceBooks/PriceBooks.php');
$focus = new PriceBooks();
$button = '';
if(isPermitted("PriceBooks",1,"") == 'yes')
{
$button .= '<input title="New Pricebooks" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'PriceBooks\';this.form.return_module.value=\'Accounts\';this.form.return_action.value=\'DetailView\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_PRICEBOOKS'].'">&nbsp;';
}
if($singlepane_view == 'true')
$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
else
$returnset = '&return_module=Accounts&return_action=CallRelatedList&return_id='.$id;
$query = "SELECT vtiger_crmentity.crmid,
vtiger_pricebook.*,
vtiger_pricebookaccountrel.accountid as prodid
FROM vtiger_pricebook
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_pricebook.pricebookid
INNER JOIN vtiger_pricebookaccountrel
ON vtiger_pricebookaccountrel.pricebookid = vtiger_pricebook.pricebookid
WHERE vtiger_crmentity.deleted = 0
AND vtiger_pricebookaccountrel.accountid = ".$id;
$log->debug("Exiting get_account_pricebooks method ...");
return GetRelatedList('Accounts','PriceBooks',$focus,$query,$button,$returnset);
}
i modified line 75 in Smarty/templates/RelatedListContents.tpl Code:
{elseif $header eq 'Accounts'}
{if $MODULE eq 'Products'}
<input alt="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Account}" title="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Account}" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Account}" LANGUAGE=javascript onclick='return window.open("index.php?module=Accounts&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button" name="button">
{elseif $MODULE eq 'Pricebooks'}
<input alt="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Account}" title="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Account}" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Account}" LANGUAGE=javascript onclick='return window.open("index.php?module=Accounts&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button" name="button">
{/if}
{elseif $header eq 'Contacts' }
$button .= '<input title="New Pricebooks" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'PriceBooks\';this.form.return_module.value=\'Accounts\';this.form.return_action.value=\'DetailView\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_PRICEBOOKS'].'">&nbsp;';
Comments
that is good code. i think should be added in the vtiger code repository. each account have a pricebook association, allowing unique price assignment to happen for each account in salesorder,quote, and etc.
it is a very useful feature to have.
and i see the button...
next :
i create addaccounttopricebooks.php
i created addaccounttopricebooks.tpl
i created into pricebooks.php line 120
i add into index.php line 251 :
i add into defaultdatapopulator.php line 1784 :
but i dont see into addaccounttopricebooks.php line 82
why?
can you help me?
- $button in relatedlist function is lost ;( - now all buttons definition and functions are in tpl - slow and not clean
- pricebooks relations not use standard getrelatedlist :
in \include\relatedlistview.php look at \modules\pricebooks\pricebooks.php and try getrelatedlist (uncomment getrelatedlist)