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 '
Taille des pages
+25
50
100
150
diff --git a/include/fiche_inc.php b/include/fiche_inc.php
index f170663d2..a8a255910 100644
--- a/include/fiche_inc.php
+++ b/include/fiche_inc.php
@@ -408,14 +408,32 @@ function GetBaseFicheDefault($p_cn,$p_type) {
*
*/
function ViewFiche($p_cn,$p_type) {
+ require_once("user_common.php");
echo ''.getFicheDefName($p_cn,$p_type).' ';
+
+ $step=$_SESSION['g_pagesize'];
+ $sql_limit="";
+ $sql_offset="";
+ if ( $step != -1 ) {
+ $page=(isset($_GET['page']))?$_GET['page']:1;
+ $offset=(isset($_GET['offset']))?$_GET['offset']:0;
+ $max_line=CountSql($p_cn,"select f_id,av_text from
+ fiche join jnt_fic_att_value using (f_id)
+ join attr_value using (jft_id)
+ where fd_id='".$p_type."' and ad_id=".ATTR_DEF_NAME." order by f_id");
+ $sql_limit=" limit ".$step;
+ $sql_offset=" offset ".$offset;
+ $bar=jrn_navigation_bar($offset,$max_line,$step,$page);
+ }
+
// Get all name the cards of the select category
// 1 for attr_def.ad_id is always the name
$Res=ExecSql($p_cn,"select f_id,av_text from
fiche join jnt_fic_att_value using (f_id)
join attr_value using (jft_id)
- where fd_id='".$p_type."' and ad_id=".ATTR_DEF_NAME." order by f_id");
+ where fd_id='".$p_type."' and ad_id=".ATTR_DEF_NAME." order by f_id $sql_offset $sql_limit ");
$Max=pg_NumRows($Res);
+ echo $bar;
for ( $i = 0; $i < $Max; $i++) {
$l_line=pg_fetch_array($Res,$i);
@@ -434,6 +452,7 @@ function ViewFiche($p_cn,$p_type) {
echo ' ';
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
$sql=SQL_LIST_ALL_INVOICE." and jr_tech_per=".$current;
-$list=ListJrn($cn,0,$sql);
+// Nav. bar
+$step=$_SESSION['g_pagesize'];
+$page=(isset($_GET['offset']))?$_GET['page']:1;
+$offset=(isset($_GET['offset']))?$_GET['offset']:0;
+list ($max_line,$list)=ListJrn($cn,0,$sql,null,$offset);
+
+$bar=jrn_navigation_bar($offset,$max_line,$step,$page);
+
+echo $bar;
echo $list;
+echo $bar;
?>
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
$sql=SQL_LIST_ALL_INVOICE." and jr_tech_per=".$current." and jr_def_id=".$_GET['p_jrn'] ;
- $list=ListJrn($cn,$_GET['p_jrn'],$sql);
+ list ($max_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql);
echo $list;
@@ -184,7 +184,7 @@ if ( $action == 'search' ) {
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'],"",$HTTP_POST_VARS);
echo $a;
}
echo '';
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.= '