[evolvis-commits] r7044: [#608] Dropdown zur Trackerauswahl in Suchmaske / Done

papel at evolvis.org papel at evolvis.org
Thu Oct 21 09:41:42 CEST 2010


Author: papel
Date: 2010-10-21 09:41:42 +0200 (Thu, 21 Oct 2010)
New Revision: 7044

Modified:
   branches/papel-reporting/www/tracker/browse.php
Log:
 [#608] Dropdown zur Trackerauswahl in Suchmaske / Done

Modified: branches/papel-reporting/www/tracker/browse.php
===================================================================
--- branches/papel-reporting/www/tracker/browse.php	2010-10-14 07:16:12 UTC (rev 7043)
+++ branches/papel-reporting/www/tracker/browse.php	2010-10-21 07:41:42 UTC (rev 7044)
@@ -332,8 +332,7 @@
 <input type="hidden" name="query_id" value="-1" />';
 echo '<input type="hidden" name="search_tracker" value="1" />';
 
-	echo '
-	<tr><td>&nbsp;</td>
+	echo'<tr><td>&nbsp;</td>
 		<td align="right">'._('Order by').' <a href="javascript:help_window(\''.util_make_url ('/help/tracker.php?helpname=sort_by').'\')"><strong>(?)</strong></a></span></td>'.
 		'<td>'. 
 		html_build_select_box_from_arrays($order_arr,$order_name_arr,'_sort_col',$_sort_col,false) .
@@ -396,6 +395,22 @@
 
 	$then=(time()-$ath->getDuePeriod());
 	
+	$maxEntriesOnPage = 25; // $maxEntriesOnPage = $max_rows ???
+	
+	if (!isset($_GET['mflag'])) {
+		
+		if(!isset($_POST['mflag'])) {
+			$maxEntriesBreakFlag=0;
+		} else {
+			$maxEntriesBreakFlag = getIntFromRequest('mflag');
+
+		}
+
+	} else {
+		$maxEntriesBreakFlag = getIntFromRequest('mflag');
+
+	}	
+	
 	if (!isset($_GET['start'])) {
 		
 		if(!isset($_POST['start'])) {
@@ -406,71 +421,107 @@
 
 	} else {
 		$start = getIntFromRequest('start');
-	}		
+
+	}	
 	
+	if (!isset($_GET['pNS'])) {
+		
+		if(!isset($_POST['pNS'])) {
+			$prevNextStart = '';		
+		} else {
+			$prevNextStart = getStringFromRequest('pNS');
+
+		}
+
+	} else {
+		$prevNextStart = getStringFromRequest('pNS');
+
+	}	
+		
+	if (!isset($_GET['pNT'])) {
+		
+		if(!isset($_POST['pNT'])) {
+			$prevNextTracker = '';
+		} else {
+			$prevNextTracker = getStringFromRequest('pNT');
+
+		}
+
+	} else {
+		$prevNextTracker = getStringFromRequest('pNT');
+
+	}	
+		
 	
+	if (!isset($_GET['total'])) {
+		
+		if(!isset($_POST['total'])) {
+			$total = 0;
+		} else {
+			$total = getIntFromRequest('total');
+
+		}
+
+	} else {
+		$total = getIntFromRequest('total');
+
+	}
+	
 	if (!isset($_GET['page_count'])) {
 		
 		if(!isset($_POST['page_count'])) {
-			$page_count=0;
+			$page_count = 1;
 		} else {
 			$page_count = getIntFromRequest('page_count');
+
 		}
 
 	} else {
 		$page_count = getIntFromRequest('page_count');
 	}	
-		
 	
 	if (!isset($_GET['tracker'])) {
-		$tracker_count = 0;
+		
+		if(!isset($_POST['tracker'])) {
+			$tracker_count = 0;
+		} else {
+			$tracker_count = getIntFromRequest('tracker');
+		}
 	} else {
 		$tracker_count = getIntFromRequest('tracker');
 	}
 	
+	$mTracker = $tracker_count;
+	$mStart = $start;
+
 	foreach($artaf_arr as $art_arr_) { //Goes just through one time on one tracker
 		$entries += count($art_arr_);
 	}
 	
 	for($tracker_count; $tracker_count < count($artaf_arr); $tracker_count++) {
-
-		$start_ = $start + 25;
-
-		if(count($artaf_arr[$tracker_count]) > $start_) {#&& $endFlag == false) {
-			$max = $start_;	
-		} else {
-
-			if($search_all == 0) {
-				$max = count($artaf_arr[$tracker_count]);	
-			} else { //$search_all == 1
-
-				if($max >= count($artaf_arr[$tracker_count])) {
-					$max = count($artaf_arr[$tracker_count]);
-				} else {
-					$max = count($artaf_arr[$tracker_count]);
-				}
-			}
-		} /* */
 		
-		#$max = ((count($artaf_arr[$tracker_count]) > ($start_)) ? ($start_) : count($artaf_arr[$tracker_count]) );
+		$start_ = $start + $maxEntriesOnPage;
+		
+		if($maxEntriesBreakFlag == 1){
+			$start_ = $start;
+		}
+		
+		$maxEntriesBreakFlag = 0;
+		
+		$max = ((count($artaf_arr[$tracker_count]) > ($start_)) ? ($start_) : count($artaf_arr[$tracker_count]) );
 
 		$selected_tracker == 0 && ($search_tracker == 1 || $func_ == 'massupdate' || $search_all == 1) ? $trackerName = $at_arr[$tracker_count]->getName() : $trackerName = '';
 	
 		if($max > 0) {
 			echo '<tr><td colspan="6"><br /><b><i>'.$trackerName.'</i></b></td></tr>';	
 		}
-		
+
 		for ($i=$start; $i<$max; $i++) {
-		
-				$n = $l + $i;
-			
-			if($search_all == 1) {
 
-				
-				if($n == ($page_count * 25)) {
-
+			if($search_all == 1 || $selected_tracker == 0) {
+				if($total == ($page_count * $maxEntriesOnPage)) {
 					break;
-				}
+				} 
 			}	
 			
 			$selected_tracker != '' ? $id = $selected_tracker : $id = $at_arr[$tracker_count]->getID();
@@ -501,33 +552,43 @@
 				echo '<td>'. $artaf_arr[$tracker_count][$i]->getAssignedRealName() .'</td>';
 			if ($display_col['submitted_by'])
 				echo '<td>'. $artaf_arr[$tracker_count][$i]->getSubmittedRealName() .'</td>';
-			echo '</tr>';		
+			echo '</tr>';
 			
+			$total++;	
 		}
-			$l = $l + $i;
 		
 		if($max == count($artaf_arr[$tracker_count])) { /* The tracker with this tracker_count 
 			* went through all values. The next tracker will be displayed now */
-
+			
 			if($search_all == 1) {
-
 				$k = $tracker_count;
 				$k++;
 				$start = 0; //The next tracker has to start at 0.
-			} 
-			
+			} elseif ($selected_tracker == 0 && $max == $maxEntriesOnPage){
+				$k = $tracker_count;
+				$k++;
+				$maxEntriesBreakFlag = 1;
+				$start = 0;
+				$i = $start;
+				break;
+			}
+	
 		} else { //The maximum size of 25 entries on a page is reached, but not all entries of the tracker did go through
-				
 			$k = $tracker_count;
 			if($search_all != 1) { /* Only break the loop if searching in one tracker. The loop of the trackers 
 			has to go on to display all other trackers, although the maximum of entries on a tracker is reached.
 			*/
-				break; //The next tracker will not be displayed because we searched in only one tracker.
-			} 
-		}	
-	}
-		$selected_page = intval($l / 25);
-		$page_count = $selected_page+1;
+				break; //The next tracker shall not be displayed because we searched in only one tracker.
+			}
+		}
+		
+
+	}	
+	
+		$entriesTotal = $total;
+		$selected_page = intval($total / $maxEntriesOnPage);
+		$realSelectedPage = ceil($total / $maxEntriesOnPage);
+		$page_count = $selected_page + 1; //The next page shown
 		$tracker_count = $k;
 
 	/*
@@ -555,16 +616,61 @@
 		}
 	}
 	*/
-	echo $GLOBALS['HTML']->listTableBottom();
+	echo $GLOBALS['HTML']->listTableBottom();	
 	
-		$pages = $entries / 25;
-		
-		if($search_all == 1) {
-			$currentpage = $page_count;
+	$pages = ceil($entries / $maxEntriesOnPage);
+
+		if($search_all == 1 || $selected_tracker == 0) {
+			
+			$search_all = 1;
+			$m = $i;
+			
+				//Begin params for the previous pages
+				$pNS_ = split(',',$prevNextStart);
+				$pNT_ = split(',',$prevNextTracker);
+				
+				$prevStarts = '';
+				$prevTrackers = '';
+				
+				for($p=0; $p<(count($pNS_)-1);$p++) {
+					
+					$pNS[$p] = $pNS_[$p];	
+					$prevStarts .= $pNS_[$p] . ',';
+					$pNT[$p] .= $pNT_[$p];
+					$prevTrackers .= $pNT_[$p] . ',';
+				}
+				
+				$prevStarts = substr($prevStarts,0,-1);
+				$prevTrackers = substr($prevTrackers,0,-1);
+				//End params for the previous pages
+			
+				//Begin params for the next pages
+				$nextStarts = $prevNextStart . ',' . $m;
+				$nextTrackers = $prevNextTracker . ',' . $tracker_count;
+				
+				$pNS = split(',',$nextStarts);
+				$pNT = split(',',$nextTrackers);
+				//End params for the next pages			
+
+			echo '<br />';
+				
+			if($realSelectedPage == $pages) {
+				$total = $pages * $maxEntriesOnPage;
+				echo '<a href="'.getStringFromServer('PHP_SELF')."?func=browse&amp;group_id=".$group_id.'&atid='.$ath->getID().'&set='. $set.'&start='.$pNS[$realSelectedPage-2].'&tracker='.$pNT[$realSelectedPage-2].'&selected_tracker='.$selected_tracker.'&search_all='.$search_all.'&page_count='.$selected_page.'&total='.($total - (2 * $maxEntriesOnPage)).'&pNS='.$prevStarts.'&pNT='.$prevTrackers.'"><strong>← '._('previous').' </strong></a>&nbsp;&nbsp;';
+			} elseif($realSelectedPage == 1) {		
+				echo '<a href="'.getStringFromServer('PHP_SELF')."?func=browse&amp;group_id=".$group_id.'&atid='.$ath->getID().'&set='. $set.'&start='.$m.'&tracker='.$tracker_count.'&selected_tracker='.$selected_tracker.'&search_all='.$search_all.'&page_count='.$page_count.'&total='.$entriesTotal.'&pNS='.$nextStarts.'&pNT='.$nextTrackers.'&mflag="'.$maxEntriesBreakFlag.'""><strong>'._('next'). ' →</strong></a>&nbsp;&nbsp;';
+			} elseif($realSelectedPage == 2) { //The link to the previous page goes to the first page
+				echo '<a href="'.getStringFromServer('PHP_SELF')."?func=browse&amp;group_id=".$group_id.'&atid='.$ath->getID().'&set='. $set.'&search_tracker=1'.'"><strong>← '._('previous').'</strong></a>&nbsp;&nbsp;'; //pNS and pNT not needed in this link	
+				echo '<a href="'.getStringFromServer('PHP_SELF')."?func=browse&amp;group_id=".$group_id.'&atid='.$ath->getID().'&set='. $set.'&start='.$m.'&tracker='.$tracker_count.'&selected_tracker='.$selected_tracker.'&search_all='.$search_all.'&page_count='.$page_count.'&total='.$entriesTotal.'&pNS='.$nextStarts.'&pNT='.$nextTrackers.'&mflag="'.$maxEntriesBreakFlag.'""><strong>'._('next').' →</strong></a>&nbsp;&nbsp;';
+			} else {
+				echo '<a href="'.getStringFromServer('PHP_SELF')."?func=browse&amp;group_id=".$group_id.'&atid='.$ath->getID().'&set='. $set.'&start='.$pNS[$realSelectedPage-2].'&tracker='.$pNT[$realSelectedPage-2].'&selected_tracker='.$selected_tracker.'&search_all='.$search_all.'&page_count='.($selected_page-1).'&total='.($total - (2 * $maxEntriesOnPage)).'&pNS='.$prevStarts.'&pNT='.$prevTrackers.'"><strong>← '._('previous').'</strong></a>&nbsp;&nbsp;';
+				echo '<a href="'.getStringFromServer('PHP_SELF')."?func=browse&amp;group_id=".$group_id.'&atid='.$ath->getID().'&set='. $set.'&start='.$m.'&tracker='.$tracker_count.'&selected_tracker='.$selected_tracker.'&search_all='.$search_all.'&page_count='.$page_count.'&total='.$entriesTotal.'&pNS='.$nextStarts.'&pNT='.$nextTrackers.'&mflag="'.$maxEntriesBreakFlag.'""><strong>'._('next').' →</strong></a>&nbsp;&nbsp;';
+			}
+			echo '<br /><br /><br />';
+
 		} else {
-			$currentpage = intval($start / 25);
-		}
-		
+			
+			$currentpage = intval($start / $maxEntriesOnPage);
 
 		$skipped_pages=false;
 		for ($j=0; $j<$pages; $j++) {
@@ -578,20 +684,23 @@
 				} else {
 					$skipped_pages=false;
 				}
-			}
+			}	
+			
 			if ($j == $currentpage) {
-				echo '<strong>'.($j+1).'</strong>&nbsp;&nbsp;';
+					echo '<strong>'.($j+1).'</strong>&nbsp;&nbsp;';
+		
 			} else {
 
 				$search_all = 0;
+				$m = $j*$maxEntriesOnPage;
 				if($selected_tracker == 0) {
 					$search_all = 1;
+					$m = $i;
 				}
-	
-				$m = $j*25;
-				echo '<a href="'.getStringFromServer('PHP_SELF')."?func=browse&amp;group_id=".$group_id.'&atid='.$ath->getID().'&set='. $set.'&start='.$m.'&tracker='.$tracker_count.'&selected_tracker='.$selected_tracker.'&search_all='.$search_all.'&page_count='.$page_count.'"><strong>'.($j+1).'</strong></a>&nbsp;&nbsp;';
+				echo '<a href="'.getStringFromServer('PHP_SELF')."?func=browse&amp;group_id=".$group_id.'&atid='.$ath->getID().'&set='. $set.'&start='.$m.'&tracker='.$tracker_count.'&selected_tracker='.$selected_tracker.'&search_all='.$search_all.'&page_count='.$page_count.'&total='.$entriesTotal.'"><strong>'.($j+1).'</strong></a>&nbsp;&nbsp;';
 			}
 		}
+	}
 
 	/*
 		Mass Update Code
@@ -605,7 +714,6 @@
 		var i=0;
 				
 		for( i=0 ; i<len ; i++) {
-							
 			if (al.elements[i].name.substring(0, 16)==\'artifact_id_list\') {
 				al.elements[i].checked=val;
 			}
@@ -625,7 +733,6 @@
 <span class="important">'._('<strong>Admin:</strong> If you wish to apply changes to all items selected above, use these controls to change their properties and click once on "Mass Update".').'
 			</td></tr>';
 
-
 		//
 		//	build custom fields
 		//
@@ -665,14 +772,32 @@
 				<a href="javascript:help_window(\'/help/tracker.php?helpname=canned_response\')"><strong>(?)</strong></a>
 				</strong><br />'. $ath->cannedResponseBox ('canned_response') .'</td></tr>
 
-			<tr><td colspan="3" align="MIDDLE">
-			<input type="hidden" name="start" value="'.(($j-1)*25).'" />		
-			<input type="SUBMIT" name="submit" value="'._('Mass update').'"></td></tr>
+			<tr><td colspan="3" align="MIDDLE">';
+			
+		 	echo '<input type="hidden" name="tracker" value="'.$mTracker.'"/>';
+			echo '<input type="hidden" name="page_count" value="'.($page_count-1).'" />';
+			echo '<input type="hidden" name="selected_tracker" value="'.$selected_tracker.'" />';
+			
+			if($selected_tracker==0){
+				$s = 1;
+				$massStart = $mStart;
+			} else {
+				$s = 0;
+				$massStart = $start;
+			}
+			
+			echo '<input type="hidden" name="start" value="'.($massStart).'" />';
+			echo '<input type="hidden" name="search_all" value="'.$s.'" />';
+			
+			echo '<input type="hidden" name="total" value="'.($total - (1 * $maxEntriesOnPage)).'" />'; 
+			echo '<input type="hidden" name="pNS" value="'.$prevNextStart.'" />';
+			echo '<input type="hidden" name="pNT" value="'.$prevNextTracker.'" />';
+			echo '<input type="SUBMIT" name="submit" value="'._('Mass update').'"></td></tr>
 
 			</table>
 		</form>';
 	}
-
+	
 	printf(_('* Denotes requests > %1$s Days Old'), ($ath->getDuePeriod()/86400));
 	show_priority_colors_key();
 



More information about the evolvis-commits mailing list