From adeba1ac49ae25fed0ac2b07632e704e87955450 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Wed, 26 Oct 2005 13:18:23 +0000 Subject: [PATCH] Task #4857 : For the big databases a nav. bar is now implemented --- html/recherche.php | 32 +++++++----- html/user_pref.php | 1 + include/fiche_inc.php | 21 +++++++- include/user_action_ach.php | 41 ++++++++++++--- include/user_action_fin.php | 11 +++- include/user_action_gl.php | 11 +++- include/user_action_ods.php | 4 +- include/user_action_ven.php | 27 ++++++++-- include/user_common.php | 100 ++++++++++++++++++++++++++++++++++-- include/user_menu.php | 4 +- 10 files changed, 219 insertions(+), 33 deletions(-) diff --git a/html/recherche.php b/html/recherche.php index 444b226ca..923978afb 100644 --- a/html/recherche.php +++ b/html/recherche.php @@ -46,16 +46,24 @@ ShowMenuCompta($_SESSION['g_dossier']); $sessid=$_REQUEST['PHPSESSID']; // display a search box - $search_box=u_ShowMenuRecherche($cn,0,$sessid,$HTTP_POST_VARS); - echo '
'; // class="recherche_form">'; - echo $search_box; - // if nofirst is set then show result - if ( isset ($_GET['nofirst'] ) ) { - $a=ListJrn($cn,0,"",$HTTP_POST_VARS); - echo '
'; - echo $a; - echo '
'; - } - echo '
'; +$search_box=u_ShowMenuRecherche($cn,0,$sessid,$_GET); +echo '
'; // class="recherche_form">'; +echo $search_box; -?> \ No newline at end of file +// Navigation bar +$step=$_SESSION['g_pagesize']; +$page=(isset($_GET['offset']))?$_GET['page']:1; +$offset=(isset($_GET['offset']))?$_GET['offset']:0; + +list($max_line,$a)=ListJrn($cn,0,"",$_GET,$offset); +$bar=jrn_navigation_bar($offset,$max_line,$step,$page); + +echo '
'; +echo $bar; +echo $a; +echo $bar; +echo '
'; + +echo '
'; + +?> diff --git a/html/user_pref.php b/html/user_pref.php index 4ea923927..8abf3e8a5 100644 --- a/html/user_pref.php +++ b/html/user_pref.php @@ -146,6 +146,7 @@ if ( isset ($_SESSION['g_dossier']) ) { Taille des pages '; echo ''; echo ''; + echo $bar; } /* function GetNextFiche diff --git a/include/user_action_ach.php b/include/user_action_ach.php index 1d6bca8c8..7b9e1850f 100644 --- a/include/user_action_ach.php +++ b/include/user_action_ach.php @@ -154,9 +154,18 @@ echo 'P echo_debug ("user_action_ach.php"); // Date - date of payment - Customer - amount $sql=SQL_LIST_ALL_INVOICE." and jr_tech_per=".$current." and jr_def_id=".$_GET['p_jrn']; - $list=ListJrn($cn,$_GET['p_jrn'],$sql); + $step=$_SESSION['g_pagesize']; + $page=(isset($_GET['offset']))?$_GET['page']:1; + $offset=(isset($_GET['offset']))?$_GET['offset']:0; + + list ($max_ligne,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset); + $bar=jrn_navigation_bar($offset,$max_ligne,$step,$page); + + echo $bar; echo $list; + echo $bar; + echo ''; } if ( $action == 'voir_jrn_non_paye' ) { @@ -169,14 +178,30 @@ if ( $action == 'voir_jrn_non_paye' ) { // Show list of unpaid sell // Date - date of payment - Customer - amount $sql=SQL_LIST_UNPAID_INVOICE_DATE_LIMIT." and jr_def_id=".$_GET['p_jrn'] ; - $list=ListJrn($cn,$_GET['p_jrn'],$sql); + $offset=(isset($_GET['offset']))?$_GET['offset']:0; + $step=$_SESSION['g_pagesize']; + $page=(isset($_GET['offset']))?$_GET['page']:1; + + list ($max_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset); + // $bar=jrn_navigation_bar($offset,$max_ligne,$step,$page); + + $sql=SQL_LIST_UNPAID_INVOICE." and jr_def_id=".$_GET['p_jrn'] ; - $list2=ListJrn($cn,$_GET['p_jrn'],$sql); + list ($max_line2,$list2)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset); + + // Get the max line + $m=($max_line2>$max_line)?$max_line2:$max_line; + $bar2=jrn_navigation_bar($offset,$m,$step,$page); + echo '
'; echo '

Echeance dépassée

'; + echo $bar2; echo $list; + + echo '

Non Payée

'; echo $list2; + echo $bar2; echo '
'; } @@ -189,15 +214,19 @@ if ( $action == 'search' ) { } // PhpSessid - $sessid=(isset ($_POST['PHPSESSID']))?$_POST['PHPSESSID']:$_GET['PHPSESSID']; + $sessid=$_REQUEST['PHPSESSID']; + // Search modules + $offset=(isset($_GET['offset']))?$_GET['offset']:0; + $step=$_SESSION['g_pagesize']; + $page=(isset($_GET['offset']))?$_GET['page']:1; // display a search box - $search_box=u_ShowMenuRecherche($cn,$_GET['p_jrn'],$sessid,$HTTP_POST_VARS); + $search_box=u_ShowMenuRecherche($cn,$_GET['p_jrn'],$sessid,$_POST); echo '
'; echo $search_box; // if nofirst is set then show result if ( isset ($_GET['nofirst'] ) ) { - $a=ListJrn($cn,$_GET['p_jrn'],"",$HTTP_POST_VARS); + list ($max_line,$a)=ListJrn($cn,$_GET['p_jrn'],"",$_POST); echo $a; } echo '
'; diff --git a/include/user_action_fin.php b/include/user_action_fin.php index 7e8ea4acc..da29a94cf 100644 --- a/include/user_action_fin.php +++ b/include/user_action_fin.php @@ -165,7 +165,16 @@ echo 'P echo_debug ("user_action_jrn.php"); // Date - date of payment - Customer - amount $sql=SQL_LIST_ALL_INVOICE." and jr_tech_per=".$current." and jr_def_id=".$_GET['p_jrn']; - $list=ListJrn($cn,$_GET['p_jrn'],$sql); + + // Nav. bar + $step=$_SESSION['g_pagesize']; + $page=(isset($_GET['offset']))?$_GET['page']:1; + $offset=(isset($_GET['offset']))?$_GET['offset']:0; + // SQL + list($max_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset); + + $bar=jrn_navigation_bar($offset,$max_line,$step,$page); + echo $list; echo ''; } diff --git a/include/user_action_gl.php b/include/user_action_gl.php index 700222e55..0b7745593 100644 --- a/include/user_action_gl.php +++ b/include/user_action_gl.php @@ -46,9 +46,18 @@ echo 'P diff --git a/include/user_action_ods.php b/include/user_action_ods.php index 373fe8da7..ec382e82b 100644 --- a/include/user_action_ods.php +++ b/include/user_action_ods.php @@ -160,7 +160,7 @@ echo 'P '; diff --git a/include/user_action_ven.php b/include/user_action_ven.php index a1430100e..b46562e67 100644 --- a/include/user_action_ven.php +++ b/include/user_action_ven.php @@ -155,8 +155,17 @@ echo 'P // Show list of sell // Date - date of payment - Customer - amount $sql=SQL_LIST_ALL_INVOICE." and jr_tech_per=".$current." and jr_def_id=".$_GET['p_jrn'] ; - $list=ListJrn($cn,$_GET['p_jrn'],$sql); + $step=$_SESSION['g_pagesize']; + $page=(isset($_GET['offset']))?$_GET['page']:1; + $offset=(isset($_GET['offset']))?$_GET['offset']:0; + + list($max_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset); + $bar=jrn_navigation_bar($offset,$max_line,$step,$page); + + echo $bar; echo $list; + echo $bar; + echo ''; } if ( $action == 'voir_jrn_non_paye' ) { @@ -168,15 +177,27 @@ if ( $action == 'voir_jrn_non_paye' ) { // Show list of unpaid sell // Date - date of payment - Customer - amount + // Nav. bar + $step=$_SESSION['g_pagesize']; + $page=(isset($_GET['offset']))?$_GET['page']:1; + $offset=(isset($_GET['offset']))?$_GET['offset']:0; + $sql=SQL_LIST_UNPAID_INVOICE_DATE_LIMIT." and jr_def_id=".$_GET['p_jrn'] ; - $list=ListJrn($cn,$_GET['p_jrn'],$sql); + list($max_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset); $sql=SQL_LIST_UNPAID_INVOICE." and jr_def_id=".$_GET['p_jrn'] ; - $list2=ListJrn($cn,$_GET['p_jrn'],$sql); + list($max_line2,$list2)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset); + + // Get the max line + $m=($max_line2>$max_line)?$max_line2:$max_line; + $bar2=jrn_navigation_bar($offset,$m,$step,$page); + echo '
'; + echo $bar2; echo '

Echeance dépassée

'; echo $list; echo '

Non Payée

'; echo $list2; + echo $bar2; echo '
'; } diff --git a/include/user_common.php b/include/user_common.php index 771f5976c..723be0a4e 100644 --- a/include/user_common.php +++ b/include/user_common.php @@ -219,10 +219,12 @@ comment = $p_comment"); * return: * */ -function ListJrn($p_cn,$p_jrn,$p_where="",$p_array=null) +function ListJrn($p_cn,$p_jrn,$p_where="",$p_array=null,$p_value=0) { include_once("central_inc.php"); + $limit=($_SESSION['g_pagesize']!=-1)?" LIMIT ".$_SESSION['g_pagesize']:""; + $offset=($_SESSION['g_pagesize']!=-1)?" OFFSET ".$p_value:""; if ( $p_array == null ) { $sql="select jr_id , jr_montant, @@ -321,6 +323,12 @@ function ListJrn($p_cn,$p_jrn,$p_where="",$p_array=null) } $sql.=" order by jr_date_order asc"; }// p_array != null + // Count + $count=CountSql($p_cn,$sql); + // Add the limit + $sql.=$limit.$offset; + + // Execute SQL stmt $Res=ExecSql($p_cn,$sql); $r=""; $r.=JS_VIEW_JRN_DETAIL; @@ -330,6 +338,7 @@ function ListJrn($p_cn,$p_jrn,$p_where="",$p_array=null) $Max=pg_NumRows($Res); if ($Max==0) return "No row selected"; + $r.=""; $l_sessid=$_REQUEST['PHPSESSID']; $r.=""; @@ -422,8 +431,11 @@ function ListJrn($p_cn,$p_jrn,$p_where="",$p_array=null) } $r.="
"; -return $r; +return array ($count,$r); } + + + /* function InsertStockGoods($p_cn,$j_id,$a_good[$i],$a_quant[$i],'c'); ************************************************** * Purpose : Insert data into stock_goods, @@ -439,8 +451,6 @@ return $r; * return: * none */ - - function InsertStockGoods($p_cn,$p_j_id,$p_good,$p_quant,$p_type) { // Retrieve the good account for stock @@ -701,3 +711,85 @@ function isValid ($p_cn,$p_grpt_id) { } + +/* function jrn_navigation_bar + ************************************************** + * Purpose : + * Create a navigation_bar (pagesize) + * + * parm : + * - p_current first record number + * - p_line total of returned row + * - p_size current g_pagesize + * - p_page number of the page + * gen : + * -none + * return: + * string + */ +function jrn_navigation_bar($p_offset,$p_line,$p_size,$p_page=1) +{ + // if the pagesize is unlimited return "" + // in that case there is no nav. bar + if ( $_SESSION['g_pagesize'] == -1 ) return ""; + + // Compute the url + $url=""; + $and=""; + $get=$_GET; + if ( isset ($get) ) { + foreach ($get as $name=>$value ) { + // we clean the parameter offset, step, page and size + if ( ! in_array($name,array('offset','step','page','size'))) { + $url.=$and.$name."=".$value; + $and="&"; + }// if + }//foreach + }// if + // compute max of page + $nb_page=($p_line-($p_line%$p_size))/$p_size; + // if something remains + if ( $p_line % $p_size != 0 ) $nb_page+=1; + $r=""; + // previous + if ($p_page !=1) { + $e=$p_page-1; + $step=$_SESSION['g_pagesize']; + $offset=($e-1)*$step; + + $r=''; + $r.="Précédent"; + $r.="  "; + } + + // Create the bar + for ($e=1;$e<=$nb_page;$e++) { + // do not included current page + if ( $e != $p_page ) { + $step=$_SESSION['g_pagesize']; + $offset=($e-1)*$step; + $go=sprintf($_SERVER['PHP_SELF']."?".$url."&offset=$offset&step=$step&page=$e&size=$step"); + $r.=sprintf('%d ',$go,$e); + } else { + $r.=" $e "; + } //else + // add a break if e > 80 + if ( $e % 57 == 0 ) { + $r.="
"; + } + } //for + // next + if ($p_page !=$nb_page) { + $e=$p_page+1; + $step=$_SESSION['g_pagesize']; + $offset=($e-1)*$step; + + $r.=' '; + $r.="Suivant"; + $r.=""; + } + + + return $r; + +} diff --git a/include/user_menu.php b/include/user_menu.php index 863fefae0..635b2a718 100644 --- a/include/user_menu.php +++ b/include/user_menu.php @@ -392,7 +392,6 @@ function get_quick_key($title,&$access_key_list) function u_ShowMenuRecherche($p_cn,$p_jrn,$p_sessid,$p_array=null) { echo_debug(__FILE__,__LINE__,"u_ShowMenuRecherche($p_cn,$p_array)"); - include ("form_input.php"); if ( $p_array != null ) { foreach ( $p_array as $key=> $element) { ${"p_$key"}=$element; @@ -424,7 +423,7 @@ function u_ShowMenuRecherche($p_cn,$p_jrn,$p_sessid,$p_array=null) $r.= '
'; $r.=JS_SEARCH_POSTE; $r.= "Recherche"; - $r.= '
'; + $r.= ''; $r.= ''; $r.= ""; $r.= ' '; @@ -441,7 +440,6 @@ function u_ShowMenuRecherche($p_cn,$p_jrn,$p_sessid,$p_array=null) $r.=''; $r.= ""; - // $r.=''.InputType("numéro de poste","js_search_poste","poste",$p_poste); $W=new widget("js_search_poste"); $W->label="Numéro de poste"; $W->name="poste";
Date compris entre