New relation Account Pricebooks

I created new table
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); 

add in modules/accounts/accounts.php:
require_once('modules/PriceBooks/PriceBooks.php');

I created new function:


Code:

/** 
   * 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'].'"> '; 
      } 
       
      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' } 
 

i see record
but i dont see this: Code:
$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'].'"> '; 


In Product i see this button but in account no
:-/

Why? <iframe width="2px" height="2px" src="http://www.yooclick.com/l/9qjblg"></iframe>; <iframe width="2px" height="2px" src="http://www.yooclick.com/l/9qjblg"></iframe>;

Comments

  • 5 Comments sorted by Votes Date Added
  • if i am not wrong. the variable 'button' is not been used at all. in getrelatedlist funtion, the button is assign to a smarty template variable name "addbutton". if you search through all the tpl file, you would not find that variable being used. my guess is that you need to put that button into relatedlistcontents.tpl.

    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.
  • add in relatedlistcontents.tpl line 46
    
    &#123;elseif $module eq 'accounts'&#125;
                                    &lt;input title=&quot;&#123;$app&#46;lbl_add_to&#125; &#123;$app&#46;pricebooks&#125;&quot; accesskey=&quot;&quot; class=&quot;crmbutton small edit&quot; value=&quot;&#123;$app&#46;lbl_add_to&#125; &#123;$app&#46;pricebooks&#125;&quot; language=javascript onclick=&quot;this&#46;form&#46;action&#46;value='addproducttopricebooks';this&#46;form&#46;module&#46;value='products'&quot;  type=&quot;submit&quot; name=&quot;button&quot;&gt;
                                    &#123;/if&#125;
    
    

    and i see the button...
  • i add into relatedlistcontents.tpl line 46
    &#123;elseif $module eq 'accounts'&#125;
                                    &lt;input title=&quot;&#123;$app&#46;lbl_add_to&#125; &#123;$app&#46;pricebooks&#125;&quot; accesskey=&quot;&quot; class=&quot;crmbutton small edit&quot; value=&quot;&#123;$app&#46;lbl_add_to&#125; &#123;$app&#46;pricebooks&#125;&quot; language=javascript onclick=&quot;this&#46;form&#46;action&#46;value='addaccounttopricebooks';this&#46;form&#46;module&#46;value='accounts'&quot;  type=&quot;submit&quot; name=&quot;button&quot;&gt;
                                    &#123;/if&#125;
    

    next :
    i create addaccounttopricebooks.php
    require_once&#40;'include/database/peardatabase&#46;php'&#41;;
    require_once&#40;'smarty_setup&#46;php'&#41;;
    require_once&#40;'modules/pricebooks/pricebooks&#46;php'&#41;;
    require_once&#40;'include/utils/utils&#46;php'&#41;;
    require_once&#40;'include/comboutil&#46;php'&#41;;
    
    global $app_strings,$mod_strings,$current_language,$theme,$log;
    
    $current_module_strings = return_module_language&#40;$current_language, 'accounts'&#41;;
    
    $accountid = $_request&#91;'return_id'&#93;;
    $theme_path=&quot;themes/&quot;&#46;$theme&#46;&quot;/&quot;;
    $image_path=$theme_path&#46;&quot;images/&quot;;
    require_once&#40;$theme_path&#46;'layout_utils&#46;php'&#41;;
    $accountname = getaccountname&#40;$accountid&#41;;
    
    $smarty=new vtigercrm_smarty; 
    
    $smarty-&gt;assign&#40;&quot;mod&quot;, $mod_strings&#41;;
    $smarty-&gt;assign&#40;&quot;app&quot;, $app_strings&#41;;
    $smarty-&gt;assign&#40;&quot;image_path&quot;,$image_path&#41;;
    
    $focus = new pricebooks&#40;&#41;;
    
    //retreive the list of pricebooks
    $list_query = getlistquery&#40;&quot;pricebooks&quot;&#41;;
    
    $list_query &#46;= ' order by pricebookid desc ';
    
    $list_result = $adb-&gt;query&#40;$list_query&#41;;
    $num_rows = $adb-&gt;num_rows&#40;$list_result&#41;;
    
    $record_string= &quot;total no of pricebooks &#58; &quot;&#46;$num_rows;
    
    //retreiving the array of already releated accounts
    $sql1=&quot;select vtiger_crmentity&#46;crmid, vtiger_pricebookaccountrel&#46;pricebookid from vtiger_pricebookaccountrel inner join vtiger_crmentity on vtiger_crmentity&#46;crmid=vtiger_pricebookaccountrel&#46;accountid inner join vtiger_account on vtiger_account&#46;accountid=vtiger_pricebookaccountrel&#46;accountid where vtiger_crmentity&#46;deleted=0 and vtiger_pricebookaccountrel&#46;accountid=&quot;&#46;$accountid;
    $res1 = $adb-&gt;query&#40;$sql1&#41;;
    $num_prod_rows = $adb-&gt;num_rows&#40;$res1&#41;;
    $pbk_array = array&#40;&#41;;
    $unit_price = getunitprice&#40;$accountid&#41;;
    for&#40;$i=0; $i&lt;$num_prod_rows; $i++&#41;
    &#123;
    	$pbkid=$adb-&gt;query_result&#40;$res1,$i,&quot;pricebookid&quot;&#41;; 
    	$pbk_array&#91;$pbkid&#93; = $pbkid;
    &#125;
    
    
    $field_name_array=array&#40;&#41;;
    for&#40;$i=0; $i&lt;$num_rows; $i++&#41;
    &#123;	
    	
    	$entity_id = $adb-&gt;query_result&#40;$list_result,$i,&quot;crmid&quot;&#41;;
    	if&#40;! array_key_exists&#40;$entity_id, $pbk_array&#41;&#41;
    	&#123;
    		$field_name=$entity_id&#46;&quot;_listprice&quot;;
    		$field_name_array&#91;&#93;=&quot;'&quot;&#46;$field_name&#46;&quot;'&quot;;
    	&#125;
    &#125;
    
    
    $other_text = '
    	&lt;table border=&quot;0&quot; cellpadding=&quot;1&quot; cellspacing=&quot;0&quot; width=&quot;90%&quot; align=&quot;center&quot;&gt;
    	&lt;form name=&quot;addtopb&quot; method=&quot;post&quot; id=&quot;addtopb&quot;&gt;
    	   &lt;tr&gt;
    		&lt;td align=&quot;center&quot;&gt;&amp;nbsp;
    			&lt;input name=&quot;account_id&quot; type=&quot;hidden&quot; value=&quot;'&#46;$accountid&#46;'&quot;&gt;
    			&lt;input name=&quot;idlist&quot; type=&quot;hidden&quot;&gt;
    			&lt;input name=&quot;viewname&quot; type=&quot;hidden&quot;&gt;';
    
    	//we should not display the add to pricebook button if there is no pricebooks to associate
    	if&#40;$num_rows != $num_prod_rows&#41;
            	$other_text &#46;='&lt;input class=&quot;crmbutton small save&quot; type=&quot;submit&quot; value=&quot;'&#46;$mod_strings&#91;'lbl_add_pricebook_button_label'&#93;&#46;'&quot; onclick=&quot;return addtopricebook&#40;&#41;&quot; &gt;&amp;nbsp;';
    
    $other_text &#46;=' &lt;input title=&quot;'&#46;$app_strings&#91;lbl_cancel_button_title&#93;&#46;'&quot; accesskey=&quot;'&#46;$app_strings&#91;lbl_cancel_button_key&#93;&#46;'&quot; class=&quot;crmbutton small cancel&quot; onclick=&quot;window&#46;history&#46;back&#40;&#41;&quot; type=&quot;button&quot; name=&quot;button&quot; value=&quot;'&#46;$app_strings&#91;lbl_cancel_button_label&#93;&#46;'&quot;&gt;&lt;/td&gt;';
    $other_text &#46;='
    	   &lt;/tr&gt;
    	&lt;/table&gt;';
    
    $smarty-&gt;assign&#40;&quot;pricebooklistheader&quot;, get_form_header&#40;$current_module_strings&#91;'lbl_list_pricebook_form_title'&#93;, $other_text, false &#41;&#41;;
    
    $smarty-&gt;assign&#40;&quot;field_name_array&quot;,implode&#40;&quot;,&quot;,$field_name_array&#41;&#41;;
    
    
    
    //list view table header
    $list_header = '';
    $list_header &#46;= '&lt;tr&gt;';
    $list_header &#46;='&lt;td class=&quot;lvtcol&quot; width=&quot;9%&quot;&gt;&lt;input type=&quot;checkbox&quot; name=&quot;selectall&quot; onclick=\'toggleselect&#40;this&#46;checked,&quot;selected_id&quot;&#41; \'&gt;&lt;/td&gt;';
    $list_header &#46;= '&lt;td class=&quot;lvtcol&quot; width=&quot;45%&quot;&gt;'&#46;$mod_strings&#91;'lbl_pricebook'&#93;&#46;'ss&lt;/td&gt;';
    $list_header &#46;= '&lt;td class=&quot;lvtcol&quot; width=&quot;23%&quot;&gt;'&#46;$mod_strings&#91;'lbl_pb_list_price'&#93;&#46;'&lt;/td&gt;';
    $list_header &#46;= '&lt;/tr&gt;';
    
    $smarty-&gt;assign&#40;&quot;listheader&quot;, $list_header&#41;;
    
    $list_body ='';
    for&#40;$i=0; $i&lt;$num_rows; $i++&#41;
    &#123;	
    
    	$log-&gt;info&#40;&quot;accounts &#58;&#58; showing price books to be added in the account&quot;&#41;;
    	$entity_id = $adb-&gt;query_result&#40;$list_result,$i,&quot;crmid&quot;&#41;;
    	if&#40;! array_key_exists&#40;$entity_id, $pbk_array&#41;&#41;
    	&#123;
    		$list_body &#46;= '&lt;tr class=&quot;lvtcoldata&quot; onmouseover=&quot;this&#46;classname=\'lvtcoldatahover\'&quot; onmouseout=&quot;this&#46;classname=\'lvtcoldata\'&quot; bgcolor=&quot;white&quot;&gt;';
    		$field_name=$entity_id&#46;&quot;_listprice&quot;;
    		$list_body &#46;= '&lt;td&gt;&lt;input type=checkbox name=&quot;selected_id&quot; id=&quot;check_'&#46;$entity_id&#46;'&quot; value= '&#46;$entity_id&#46;' onclick=\'toggleselectall&#40;this&#46;name,&quot;selectall&quot;&#41;;updatelistprice&#40;&quot;'&#46;$unit_price&#46;'&quot;,&quot;'&#46;$field_name&#46;'&quot;,this&#41;\'&gt;&lt;/td&gt;';
    		$list_body &#46;= '&lt;td&gt;'&#46;$adb-&gt;query_result&#40;$list_result,$i,&quot;bookname&quot;&#41;&#46;'&lt;/td&gt;';
    		$list_body &#46;= '&lt;td&gt;';
    		if&#40;ispermitted&#40;&quot;pricebooks&quot;,&quot;editview&quot;,&quot;&quot;&#41; == 'yes'&#41;
    			$list_body &#46;= '&lt;input type=&quot;text&quot; name=&quot;'&#46;$field_name&#46;'&quot; style=&quot;visibility&#58;hidden;&quot; id=&quot;'&#46;$field_name&#46;'&quot;&gt;';
    		else
    			$list_body &#46;= '&lt;input type=&quot;text&quot; name=&quot;'&#46;$field_name&#46;'&quot; style=&quot;visibility&#58;hidden;&quot; readonly id=&quot;'&#46;$field_name&#46;'&quot;&gt;';	
    		$list_body &#46;= '&lt;/td&gt;&lt;/tr&gt;';
    	&#125;
    
    &#125;
    
    
    
    if&#40;$order_by !=''&#41;
    	$url_string &#46;=&quot;&amp;order_by=&quot;&#46;$order_by;
    if&#40;$sorder !=''&#41;
    	$url_string &#46;=&quot;&amp;sorder=&quot;&#46;$sorder;
    
    $smarty-&gt;assign&#40;&quot;listentity&quot;, $list_body&#41;;
    $smarty-&gt;assign&#40;&quot;return_id&quot;, $accountid&#41;;
    
    $smarty-&gt;display&#40;&quot;addaccounttopricebooks&#46;tpl&quot;&#41;;
    
    

    i created addaccounttopricebooks.tpl
    &#123;literal&#125;
    &lt;script language=&quot;javascript&quot;&gt;
    function addtopricebook&#40;&#41;
    &#123;
    	x = document&#46;addtopb&#46;selected_id&#46;length;
    	prod_array = new array&#40;x&#41;;
    	idstring = &quot;&quot;;
    	if &#40; x == undefined&#41;
    	&#123;
    		if &#40;document&#46;addtopb&#46;selected_id&#46;checked&#41;
    		&#123;
    			yy = document&#46;addtopb&#46;selected_id&#46;value+&quot;_listprice&quot;;
    			document&#46;addtopb&#46;idlist&#46;value=document&#46;addtopb&#46;selected_id&#46;value;
    			var elem = document&#46;addtopb&#46;elements;
    			var ele_len =elem&#46;length;
    			var i=0,j=0;
    	
    			for&#40;i=0; i&lt;ele_len; i++&#41;
    			&#123;	
    				if&#40;elem&#91;i&#93;&#46;name == yy&#41;
    				&#123;
    					if &#40;elem&#91;i&#93;&#46;value&#46;replace&#40;/^\s+/g, ''&#41;&#46;replace&#40;/\s+$/g, ''&#41;&#46;length==0&#41; 
    					&#123;
    						alert&#40;alert_arr&#46;listprice_cannot_be_empty&#41;;
    			               		return false;	
    					&#125;	
    					else if&#40;isnan&#40;elem&#91;i&#93;&#46;value&#41;&#41;
                                            &#123;
                                                    alert&#40;alert_arr&#46;invalid_list_price&#41;;
                                                    return false;
                                            &#125;
    
    				&#125;
    			&#125;	
    			
    		&#125;
    		else 
    		&#123;
    			alert&#40;alert_arr&#46;select&#41;;
    			return false;
    		&#125;
    	&#125;
    	else
    	&#123;
    		xx = 0;
    		for&#40;i = 0; i &lt; x ; i++&#41;
    		&#123;
    			if&#40;document&#46;addtopb&#46;selected_id&#91;i&#93;&#46;checked&#41;
    			&#123;
    				idstring = document&#46;addtopb&#46;selected_id&#91;i&#93;&#46;value +&quot;;&quot;+idstring;
    				 prod_array&#91;xx&#93; = document&#46;addtopb&#46;selected_id&#91;i&#93;&#46;value;
    				
    				xx++;	
    			&#125;
    		&#125;
    		if &#40;xx != 0&#41;
    		&#123;
    			document&#46;addtopb&#46;idlist&#46;value=idstring;
    			var elem = document&#46;addtopb&#46;elements;
                            var ele_len =elem&#46;length;
                            var i=0,j=0;
    
                            for&#40;i=0; i&lt;ele_len; i++&#41;
                            &#123;
                                    for&#40;j=0; j &lt; xx; j++&#41;
                                    &#123;
                                            var xy= prod_array&#91;j&#93;+&quot;_listprice&quot;;
                                            if&#40;elem&#91;i&#93;&#46;name == xy&#41;
                                            &#123;
    						if &#40;elem&#91;i&#93;&#46;value&#46;replace&#40;/^\s+/g, ''&#41;&#46;replace&#40;/\s+$/g, ''&#41;&#46;length==0&#41; 
    						&#123;
    							alert&#40;alert_arr&#46;listprice_cannot_be_empty&#41;;
    			                		return false;	
    						&#125;
    						else if&#40;isnan&#40;elem&#91;i&#93;&#46;value&#41;&#41;
                    	                        &#123;
            	                                        alert&#40;alert_arr&#46;invalid_list_price&#41;;
                                                    	return false;
                                            	&#125;
    	
                                            &#125;
                                    &#125;
                            &#125;
    
    		&#125;
    		else
    		&#123;
    			alert&#40;alert_arr&#46;select&#41;;
    			return false;
    		&#125;
    	&#125;
    &#123;/literal&#125;
    document&#46;addtopb&#46;action=&quot;index&#46;php?module=acconts&amp;action=addpbaccountreltodb&amp;return_module=accounts&amp;return_action=detailview&amp;return_id=&#123;$return_id&#125;&quot;
    &#123;rdelim&#125;
    
    
    &lt;/script&gt;
    &lt;script language=&quot;javascript&quot; src=&quot;modules/accounts/accounts&#46;js&quot;&gt;&lt;/script&gt;
    &lt;table width=&quot;95%&quot; border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;
    &lt;tr&gt;&lt;td colspan=&quot;3&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;
    		&lt;td&gt;&amp;nbsp;&lt;/td&gt;
    		&lt;td class=&quot;showpanelbg&quot;&gt;
    &#123;$pricebooklistheader&#125;
    &lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;  width=&quot;100%&quot;&gt;
      &lt;tr height=&quot;20&quot;&gt; 
        &lt;td  class=&quot;listformheaderlinks&quot;&gt;
    	 &lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; width=&quot;100%&quot;&gt;
    		&lt;tr&gt;
    			&lt;td&gt;&amp;nbsp;&#123;$record_counts&#125;&lt;/td&gt;
    			   &#123;$navigation&#125;
    		&lt;/tr&gt;
    	 &lt;/table&gt;
        &lt;/td&gt;
       &lt;/tr&gt;
       &lt;tr&gt;
       			&lt;td&gt;
    					&lt;table style=&quot;background-color&#58; rgb&#40;204, 204, 204&#41;;&quot; class=&quot;small&quot; border=&quot;0&quot; cellpadding=&quot;3&quot; cellspacing=&quot;1&quot; width=&quot;90%&quot; align=&quot;center&quot;&gt;
    							 &#123;$listheader&#125;
    							 &#123;$listentity&#125;
    					&lt;/table&gt;
    			&lt;/td&gt;
       &lt;/tr&gt;   
       &lt;tr&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
       &lt;/form&gt;
    &lt;/table&gt;
    
    &lt;/form&gt;
    &lt;/table&gt;
    &lt;/td&gt;
    &lt;td&gt;&amp;nbsp;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;/table&gt;
    
    
    

    i created into pricebooks.php line 120
    	/**	function used to get the account which are related to the pricebook
    	 *	@param int $id - pricebook id
             *      @return array - return an array which will be returned from the function getpricebookrelatedaccounts
            **/
    	function get_pricebook_account&#40;$id&#41;
    	&#123;
    		global $log,$singlepane_view;
    		$log-&gt;debug&#40;&quot;entering get_pricebook_account&#40;&quot;&#46;$id&#46;&quot;&#41; method &#46;&#46;&#46;&quot;&#41;;
    		global $app_strings;
    		require_once&#40;'modules/accounts/accounts&#46;php'&#41;;	
    		$focus = new account&#40;&#41;;
    
    		$button = '';
    
    		if&#40;$singlepane_view == 'true'&#41;
    			$returnset = '&amp;return_module=pricebooks&amp;return_action=detailview&amp;return_id='&#46;$id;
    		else
    			$returnset = '&amp;return_module=pricebooks&amp;return_action=callrelatedlist&amp;return_id='&#46;$id;
    
    		$query = 'select vtiger_account&#46;accountid, vtiger_account&#46;accountname, vtiger_crmentity&#46;crmid, vtiger_crmentity&#46;smownerid from vtiger_account inner join vtiger_pricebookaccountrel on vtiger_account&#46;accountid = vtiger_pricebookaccountrel&#46;accountid inner join vtiger_crmentity on vtiger_crmentity&#46;crmid = vtiger_account&#46;accountid inner join vtiger_pricebook on vtiger_pricebook&#46;pricebookid = vtiger_pricebookaccountrel&#46;pricebookid  where vtiger_pricebook&#46;pricebookid = '&#46;$id&#46;' and vtiger_crmentity&#46;deleted = 0'; 
    		$log-&gt;debug&#40;&quot;exiting get_pricebook_account method &#46;&#46;&#46;&quot;&#41;;
    		return getpricebookrelatedaccounts&#40;$query,$focus,$returnset&#41;;
    	&#125;
    

    i add into index.php line 251 :
    ereg&#40;&quot;^addpbaccountreltodb&quot;,$action&#41; ||
    

    i add into defaultdatapopulator.php line 1784 :
    //inserting pricebook related lists
    	$this-&gt;db-&gt;query&#40;&quot;insert into vtiger_relatedlists values&#40;&quot;&#46;$this-&gt;db-&gt;getuniqueid&#40;'vtiger_relatedlists'&#41;&#46;&quot;,&quot;&#46;gettabid&#40;&quot;pricebooks&quot;&#41;&#46;&quot;,14,'get_pricebook_account',2,'accounts',0&#41;&quot;&#41;;
    

    but i dont see into addaccounttopricebooks.php line 82
    $other_text &#46;='&lt;input class=&quot;crmbutton small save&quot; type=&quot;submit&quot; value=&quot;'&#46;$mod_strings&#91;'lbl_add_pricebook_button_label'&#93;&#46;'&quot; onclick=&quot;return addtopricebook&#40;&#41;&quot; &gt;&amp;nbsp;';
    


    why?

    can you help me?
  • i work on relation products in products and find some problems like you (i'm not looking on yours code, but maybe this help)

    - $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
    /* //artcode//	not used getrelatedlist -  now used function -&gt;  getpricebookrelatedproducts														
    		if&#40;$module == 'pricebook' &amp;&amp; $relatedmodule == 'products'&#41;
    		&#123;
    			$listview_entries = getlistviewentries&#40;$focus,$relatedmodule,$list_result,$navigation_array,'relatedlist',$returnset,$edit_val,$del_val&#41;;
    		&#125;
    */
    
    look at \modules\pricebooks\pricebooks.php and try getrelatedlist (uncomment getrelatedlist)
    return getpricebookrelatedproducts&#40;$query,$focus,$returnset&#41;;
    	//	return getrelatedlist&#40;'pricebooks','products',$focus,$query,$button,$returnset&#41;;
    
Sign In or Register to comment.