00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 include_once("postgres.php");
00039 function GetTvaRate($p_cn,$p_tva_id) {
00040
00041 if (strlen(trim($p_tva_id))==0) return 0;
00042
00043
00044 $Res=ExecSql($p_cn,"select tva_id,tva_rate,tva_label from tva_rate where tva_id=".$p_tva_id);
00045 if (pg_NumRows($Res) == 0 ) return null;
00046
00047 $r=pg_fetch_array($Res,0);
00048 return $r;
00049
00050 }
00068 function ComputeTotalVat($p_cn, $a_fiche,$a_quant,$a_price,$ap_vat,$all=false ) {
00069 echo_debug('user_common.php',__LINE__,"ComputeTotalVat $a_fiche $a_quant $a_price");
00070 foreach ( $a_fiche as $t=>$el) {
00071 echo_debug('user_common.php',__LINE__,"t $t e $el");
00072 }
00073 $r=null;
00074
00075
00076 foreach ( $a_fiche as $idx=>$element) {
00077 echo_debug ('user_common.php',__LINE__,"idx $idx element $element");
00078
00079 if ( strlen(trim($element))==0) continue;
00080
00081
00082 if ( $ap_vat != null and
00083 isNumber($ap_vat[$idx])== 1 and $ap_vat[$idx] != -1 )
00084 {
00085 $tva_id=$ap_vat[$idx];
00086 echo_debug('user_common',__LINE__,' tva_id is given');
00087 echo_debug('user_common',__LINE__,$ap_vat);
00088 }
00089 else
00090 {
00091 $tva_id=GetFicheAttribut($p_cn,$element,ATTR_DEF_TVA);
00092 echo_debug('user_common',__LINE__,'retrieve tva_id');
00093 }
00094 echo_debug('user_common',__LINE__,"tva id $tva_id");
00095 if ( $tva_id == null ) continue;
00096
00097 $a_vat=GetTvaRate($p_cn,$tva_id);
00098
00099
00100 if ( $a_vat != null and $a_vat['tva_id'] != "" )
00101 {
00102 $flag=true;
00103 $a=$a_vat['tva_id'];
00104
00105 $vat_amount=round($a_price[$idx]*$a_vat['tva_rate']*$a_quant[$idx],2);
00106
00107
00108 if ( $all == false )
00109 {
00110
00111
00112 $nd1=0;
00113
00114 $nd=GetFicheAttribut($p_cn,$a_fiche[$idx],ATTR_DEF_TVA_NON_DEDUCTIBLE);
00115 if ( $nd != null && strlen(trim($nd)) != 0 && $nd != 0 )
00116 {
00117 $nd_amount=round($a_price[$idx]*$a_vat['tva_rate']*$a_quant[$idx]*$nd,2);
00118
00119 $vat_amount=$vat_amount-$nd_amount;
00120 echo_debug('user_common.php',__LINE__,
00121 "A - TVA Attr fiche [$nd] nd amount [ $nd_amount ]".
00122 "vat amount [ $vat_amount]");
00123 $flag=false;
00124
00125 $nd1=$nd;
00126 }
00127
00128 $nd=GetFicheAttribut($p_cn,$a_fiche[$idx],ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP);
00129 if ( $nd != null && strlen(trim($nd)) != 0 && $nd != 0 )
00130 {
00131 $nd_amount2=round($a_price[$idx]*$a_vat['tva_rate']*$a_quant[$idx]*$nd,2);
00132
00133 $vat_amount=$vat_amount-$nd_amount2;
00134
00135 if ( ($nd+$nd1) == 1)
00136 $vat_amount=0;
00137 echo_debug('user_common.php',__LINE__,
00138 "B - TVA Attr fiche [$nd] nd amount [ $nd_amount2 ]".
00139 "vat amount [ $vat_amount]");
00140
00141 $flag=false;
00142 }
00143 }
00144
00145 $r[$a]=isset ( $r[$a] )?$r[$a]+$vat_amount:$vat_amount;
00146 }
00147
00148 }
00149 echo_debug('user_common.php',__LINE__," return ".var_export($r,true));
00150 return $r;
00151
00152
00153 }
00154
00171 function ComputeVat($p_cn, $p_fiche,$p_quant,$p_price,$p_vat )
00172 {
00173 echo_debug('user_common.php',__LINE__,"function ComputeVat($p_cn,$p_fiche,$p_quant,$p_price,$p_vat )");
00174
00175 if ( $p_vat != null and isNumber($p_vat)== 1 and $p_vat != -1)
00176 $tva_id=$p_vat;
00177 else
00178 $tva_id=GetFicheAttribut($p_cn,$p_fiche,ATTR_DEF_TVA);
00179
00180 echo_debug('user_common',__LINE__,"ComputeVat tva id = $tva_id");
00181 if ( $tva_id == null ) return -1;
00182
00183 $a_vat=GetTvaRate($p_cn,$tva_id);
00184 $vat_amount=null;
00185
00186 if ( $a_vat != null and $a_vat['tva_id'] != "" )
00187 {
00188 $a=$a_vat['tva_id'];
00189 $vat_amount=$p_price*$a_vat['tva_rate']*$p_quant;
00190 }
00191 echo_debug('user_common',__LINE__,'return '.round($vat_amount,2));
00192 return round($vat_amount,2);
00193
00194
00195 }
00196
00197
00210 function GetTvaPoste($p_cn,$p_tva_id,$p_cred) {
00211 $Res=ExecSql($p_cn,"select tva_poste from tva_rate where tva_id=$p_tva_id");
00212 if ( pg_NumRows($Res) == 0 ) return null;
00213 $a=pg_fetch_array($Res,0);
00214 list ($deb,$cred)=split(",",$a['tva_poste']);
00215 if ( $p_cred=='c' ) return $cred;
00216 if ($p_cred=='d') return $deb;
00217 echo_error ("Invalid $p_cred in GetTvaRate");
00218 return null;
00219 }
00220
00221
00222
00223
00243 function InsertJrnx($p_cn,$p_type,$p_user,$p_jrn,$p_poste,$p_date,$p_amount,$p_grpt,$p_periode,$p_qcode="")
00244 {
00245 echo_debug ('user_common.php',__LINE__,"InsertJrnx param
00246 type = $p_type p_user $p_user
00247 p_date $p_date p_poste $p_poste
00248 p_amount $p_amount p_grpt = $p_grpt p_periode = $p_periode");
00249
00250 if ( $p_amount == 0) return true;
00251
00252 $debit=($p_type=='c')?'false':'true';
00253
00254
00255 if ( $p_amount < 0 ) {
00256 $debit=($debit=='false')?'true':'false';
00257 }
00258
00259 $sql=sprintf("select insert_jrnx
00260 ('%s',abs(%.2f),%d,%d,%d,%s,'%s',%d,'%s')",
00261 $p_date,round($p_amount,2),$p_poste,$p_grpt,$p_jrn,$debit,$p_user,$p_periode,$p_qcode);
00262
00263 echo_debug('user_common.php',__LINE__,"InsertJrnx $sql");
00264 $Res=ExecSql($p_cn,$sql);
00265 if ( $Res==false) return $Res;
00266 return GetSequence($p_cn,'s_jrn_op');
00267
00268 }
00287 function InsertJrn($p_cn,$p_date,$p_echeance,$p_jrn,$p_comment,$p_amount,$p_grpt,$p_periode)
00288 {
00289 echo_debug ('user_common.php',__LINE__,"InsertJrn param
00290 p_date $p_date p_poste $p_comment p_amount $p_amount p_grpt = $p_grpt p_periode = $p_periode p_echeance = $p_echeance
00291 comment = $p_comment");
00292 $p_comment=FormatString($p_comment);
00293
00294 if ( $p_echeance == "" or $p_echeance==null) {
00295 $p_echeance='null';
00296 } else {
00297 $p_echeance=sprintf("to_date('%s','DD.MM.YYYY')",$p_echeance);
00298 }
00299 $sql=sprintf("insert into jrn (jr_def_id,jr_montant,jr_comment,jr_date,jr_ech,jr_grpt_id,jr_tech_per)
00300 values ( %d,abs(%.2f),'%s',to_date('%s','DD.MM.YYYY'),%s,%d,%d)",
00301 $p_jrn, round($p_amount,2),$p_comment,$p_date,$p_echeance,$p_grpt,$p_periode);
00302 echo_debug('user_common.php',__LINE__,"InsertJrn $sql");
00303 $Res=ExecSql($p_cn,$sql);
00304 if ( $Res == false) return false;
00305 return GetSequence($p_cn,'s_jrn');
00306 }
00321 function ListJrn($p_cn,$p_jrn,$p_where="",$p_array=null,$p_value=0,$p_paid=0)
00322 {
00323
00324 include_once("central_inc.php");
00325 $limit=($_SESSION['g_pagesize']!=-1)?" LIMIT ".$_SESSION['g_pagesize']:"";
00326 $offset=($_SESSION['g_pagesize']!=-1)?" OFFSET ".$p_value:"";
00327 if ( $p_array == null ) {
00328
00329
00330
00331 $sql="select jr_id ,
00332 jr_montant,
00333 jr_comment,
00334 jr_ech,
00335 to_char(jr_date,'DD.MM.YYYY') as jr_date,
00336 jr_date as jr_date_order,
00337 jr_grpt_id,
00338 jr_rapt,
00339 jr_internal,
00340 jrn_def_id,
00341 jrn_def_name,
00342 jrn_def_ech,
00343 jrn_def_type,
00344 jr_valid,
00345 jr_tech_per,
00346 jr_pj_name,
00347 p_closed
00348 from
00349 jrn
00350 join jrn_def on jrn_def_id=jr_def_id
00351 join parm_periode on p_id=jr_tech_per
00352 $p_where
00353 order by jr_date_order asc,jr_internal asc";
00354 }
00355 if ( $p_array != null ) {
00356
00357 foreach ( $p_array as $key=>$element) {
00358 ${"l_$key"}=$element;
00359 }
00360 $sql="select jr_id ,
00361 jr_montant,
00362 jr_comment,
00363 jr_ech,
00364 to_char(jr_date,'DD.MM.YYYY') as jr_date,
00365 jr_date as jr_date_order,
00366 jr_grpt_id,
00367 jr_rapt,
00368 jr_internal,
00369 jrn_def_id,
00370 jrn_def_name,
00371 jrn_def_ech,
00372 jrn_def_type,
00373 jr_valid,
00374 jr_tech_per,
00375 jr_pj_name,
00376 p_closed
00377 from
00378 jrn join jrn_def on jrn_def_id=jr_def_id
00379 join parm_periode on p_id=jr_tech_per
00380 ";
00381 $jrn_sql=($p_jrn =0)?"1=1":"jrn_def_id=$p_jrn ";
00382 $l_and=" where ";
00383
00384 if ( ereg("^[0-9]+$", $l_s_montant) || ereg ("^[0-9]+\.[0-9]+$", $l_s_montant) )
00385 {
00386 $sql.=$l_and." jr_montant $l_mont_sel $l_s_montant";
00387 $l_and=" and ";
00388 }
00389
00390 if ( isDate($l_date_start) != null )
00391 {
00392 $sql.=$l_and." jr_date >= to_date('".$l_date_start."','DD.MM.YYYY')";
00393 $l_and=" and ";
00394 }
00395 if ( isDate($l_date_end) != null ) {
00396 $sql.=$l_and." jr_date <= to_date('".$l_date_end."','DD.MM.YYYY')";
00397 $l_and=" and ";
00398 }
00399
00400 $l_s_comment=FormatString($l_s_comment);
00401 if ( $l_s_comment != null )
00402 {
00403 $sql.=$l_and." upper(jr_comment) like upper('%".$l_s_comment."%') ";
00404 $l_and=" and ";
00405 }
00406
00407 $l_s_internal=FormatString($l_s_internal);
00408 if ( $l_s_internal != null ) {
00409 $sql.=$l_and." jr_internal like ('%$l_s_internal%') ";
00410 $l_and=" and ";
00411 }
00412
00413 $l_poste=FormatString($l_poste);
00414 if ( $l_poste != null ) {
00415 $sql.=$l_and." jr_grpt_id in (select j_grpt
00416 from jrnx where j_poste = $l_poste) ";
00417 $l_and=" and ";
00418 }
00419
00420 if ( $l_qcode != null )
00421 {
00422 $sql.=$l_and." jr_grpt_id in ( select j_grpt from
00423 jrnx where j_qcode = '$l_qcode')";
00424 $l_and=" and ";
00425 }
00426
00427 $User=new cl_user(DbConnect());
00428 $User->Check();
00429 if ( $User->admin == 0 )
00430 {
00431 $sql.=$l_and." jr_def_id in ( select uj_jrn_id ".
00432 " from user_sec_jrn where ".
00433 " uj_login='".$_SESSION['g_user']."'".
00434 " and uj_priv in ('R','W'))";
00435 }
00436 $sql.=" order by jr_date_order asc";
00437 }
00438
00439 $count=CountSql($p_cn,$sql);
00440
00441 $sql.=$limit.$offset;
00442
00443
00444 $Res=ExecSql($p_cn,$sql);
00445
00446
00447
00448
00449 $r="";
00450 $r.=JS_VIEW_JRN_DETAIL;
00451 $r.=JS_VIEW_JRN_CANCEL;
00452 $r.=JS_VIEW_JRN_MODIFY;
00453
00454 $Max=pg_NumRows($Res);
00455
00456
00457 if ($Max==0) return array(0,"Aucun enregistrement trouvé");
00458
00459 $r.='<table style="width:100%;border:solid blue 2px ;border-style:outset;">';
00460 $l_sessid=$_REQUEST['PHPSESSID'];
00461 $r.="<tr class=\"even\">";
00462 $r.="<th> Internal </th>";
00463 $r.="<th> Date </th>";
00464 $r.="<th> Echéance </th>";
00465 $r.="<th> Description</th>";
00466 $r.="<th> Montant </th>";
00467
00468 if ( $p_paid != 0 )
00469 {
00470 $r.="<th> Payé</th>";
00471 }
00472 $r.="<th>Op. Concernée</th>";
00473 $r.="<th>Document</th>";
00474 $r.="</tr>";
00475
00476 for ($i=0; $i < $Max;$i++) {
00477
00478
00479
00480 $row=pg_fetch_array($Res,$i);
00481
00482 if ( $i % 2 == 0 ) $tr='<TR class="odd">';
00483 else $tr='<TR class="even">';
00484 $r.=$tr;
00485
00486
00487 $r.="<TD>";
00488 $r.=sprintf('<A class="detail" HREF="javascript:modifyOperation(\'%s\',\'%s\',\'%s\')" >%s</A>',
00489 $row['jr_id'], $l_sessid, $p_jrn, $row['jr_internal']);
00490 $r.="</TD>";
00491
00492 $r.="<TD>";
00493 $r.=$row['jr_date'];
00494 $r.="</TD>";
00495
00496 $r.="<TD>";
00497 $r.=$row['jr_ech'];
00498 $r.="</TD>";
00499
00500
00501 $r.="<TD>";
00502 $r.=$row['jr_comment'];
00503 $r.="</TD>";
00504
00505
00506
00507
00508
00509 $jrn_prop=GetJrnProp($p_cn,$row['jrn_def_id'],1);
00510 $positive=0;
00511
00512
00513 if ( $jrn_prop['jrn_def_type'] == 'FIN' )
00514 {
00515 $positive = CountSql($p_cn,"select * from jrn inner join jrnx on jr_grpt_id=j_grpt ".
00516 " where jr_id=".$row['jr_id']." and (j_poste like '55%' or j_poste like '57%' )".
00517 " and j_debit='f'");
00518 }
00519 $r.="<TD align=\"right\">";
00520
00521 $r.=( $positive != 0 )?"<font color=\"red\"> - ".sprintf("%8.2f",$row['jr_montant'])."</font>":sprintf("%8.2f",$row['jr_montant']);
00522 $r.="</TD>";
00523
00524
00525
00526 if ( $p_paid !=0 )
00527 {
00528 $w=new widget("checkbox");
00529 $w->name="rd_paid".$row['jr_id'];
00530 $w->selected=($row['jr_rapt']=='paid')?true:false;
00531
00532 $w->readonly=( $p_paid == 2)?true:false;
00533 $h=new widget("hidden");
00534 $h->name="set_jr_id".$row['jr_id'];
00535 $r.='<TD>'.$w->IOValue().$h->IOValue().'</TD>';
00536 }
00537
00538
00539 $a=GetConcerned($p_cn,$row['jr_id']);
00540 $r.="<TD>";
00541 if ( $a != null ) {
00542
00543
00544 foreach ($a as $key => $element)
00545 {
00546 $r.= "<A class=\"detail\" HREF=\"javascript:viewDetail('".GetGrpt($p_cn,$element)."','$l_sessid')\" > ".GetInternal($p_cn,$element)."</A>";
00547 }
00548 }
00549 $r.="</TD>";
00550
00551 if ( $row['jr_valid'] == 'f' ) {
00552 $r.="<TD> Opération annulée</TD>";
00553 } else {
00554
00555
00556 $r.="<TD>";
00557
00558 $r.=sprintf('<input TYPE="BUTTON" VALUE="%s" onClick="cancelOperation(\'%s\',\'%s\',\'%s\')">',
00559 "Annuler",$row['jr_grpt_id'],$l_sessid,$p_jrn);
00560 $r.="</TD>";
00561 }
00562
00563 $r.="<TD>".sprintf('<A class="detail" HREF="show_pj.php?jrn=%s&jr_grpt_id=%s">%s</A>',
00564 $p_jrn,
00565 $row['jr_grpt_id'],
00566 $row['jr_pj_name'])."</TD>";
00567
00568
00569 $r.="</tr>";
00570
00571 }
00572 $r.="</table>";
00573
00574 return array ($count,$r);
00575 }
00576
00577
00578
00595 function InsertStockGoods($p_cn,$p_j_id,$p_good,$p_quant,$p_type)
00596 {
00597 echo_debug('user_common.php',__LINE__,"function InsertStockGoods($p_cn,$p_j_id,$p_good,$p_quant,$p_type)");
00598
00599 $code_marchandise=GetFicheAttribut($p_cn,$p_good,ATTR_DEF_STOCK);
00600 $sql="select f_id from vw_poste_qcode where j_qcode='$p_good'";
00601 $Res=ExecSql($p_cn,$sql);
00602 $r=pg_fetch_array($Res,0);
00603 $f_id=$r['f_id'];
00604 $Res=ExecSql($p_cn,"insert into stock_goods (
00605 j_id,
00606 f_id,
00607 sg_code,
00608 sg_quantity,
00609 sg_type ) values (
00610 $p_j_id,
00611 $f_id,
00612 '$code_marchandise',
00613 $p_quant, '$p_type')
00614 ");
00615 return $Res;
00616 }
00630 function withStock($p_cn,$p_f_id)
00631 {
00632 $a=getFicheAttribut($p_cn,$p_f_id, ATTR_DEF_STOCK);
00633 if ( $a == "1" ) return true;
00634 return false;
00635
00636 }
00653 function VerifyOperationDate($p_cn,$p_periode,$p_date) {
00654
00655
00656 if ( isDate($p_date) == null ) {
00657 echo_error("Invalid date $p_date");
00658 echo_debug('user_common.php',__LINE__,"Invalid date $p_date");
00659 echo "<SCRIPT> alert('INVALID DATE $p_date !!!!');</SCRIPT>";
00660 return null;
00661 }
00662
00663 list ($l_date_start,$l_date_end)=GetPeriode($p_cn,$p_periode);
00664
00665
00666 echo_debug ("date start periode $l_date_start date fin periode $l_date_end date demandée $p_date");
00667 if ( cmpDate($p_date,$l_date_start)<0 ||
00668 cmpDate($p_date,$l_date_end)>0 )
00669 {
00670 $msg="Not in the active periode please change your preference";
00671 echo_error($msg); echo_error($msg);
00672 echo "<SCRIPT>alert('$msg');</SCRIPT>";
00673 return null;
00674 }
00675
00676 if ( PeriodeClosed ($p_cn,$p_periode)=='t' )
00677 {
00678 $msg="This periode is closed please change your preference";
00679 echo_error($msg); echo_error($msg);
00680 echo "<SCRIPT>alert('$msg');</SCRIPT>";
00681 return null;
00682 }
00683 return $p_date;
00684 }
00685
00699 function InsertRapt($p_cn,$jr_id,$jr_id2) {
00700 if ( isNumber($jr_id) == 0 or
00701 isNumber($jr_id2) == 0 )
00702 {
00703 echo_error(" InsertRapt : invalid jr_id $jr_id, jr_id2 $jr_id2");
00704 echo_debug('user_common.php',__LINE__," InsertRapt : invalid jr_id $jr_id, jr_id2 $jr_id2");
00705 return false;
00706 }
00707
00708 if ( CountSql($p_cn,"select jra_id from jrn_rapt where jra_concerned=$jr_id and jr_id=$jr_id2
00709 union
00710 select jra_id from jrn_rapt where jra_concerned=$jr_id2 and jr_id=$jr_id ") ==0)
00711 {
00712
00713 $Res=ExecSql($p_cn,"insert into jrn_rapt(jr_id,jra_concerned) values ($jr_id,$jr_id2)");
00714 }
00715 return true;
00716 }
00730 function DeleteRapt($p_cn,$jr_id,$jr_id2) {
00731 echo_debug('user_common.php',__LINE__,"DeleteRapt($p_cn,$jr_id,$jr_id2) ");
00732 if ( isNumber($jr_id) == 0 or
00733 isNumber($jr_id2) == 0 )
00734 {
00735 echo_error(" InsertRapt : invalid jr_id jr_id = $jr_id jr_id2 = $jr_id2");
00736 return;
00737 }
00738
00739 if ( CountSql($p_cn,"select jra_id from jrn_rapt where jra_concerned=$jr_id and jr_id=$jr_id2
00740 union
00741 select jra_id from jrn_rapt where jra_concerned=$jr_id2 and jr_id=$jr_id ") !=0)
00742 {
00743
00744 $Res=ExecSql($p_cn,"delete from jrn_rapt where (jra_concerned=$jr_id2 and jr_id=$jr_id) or
00745 (jra_concerned=$jr_id and jr_id=$jr_id2) ");
00746 }
00747 }
00748
00761 function GetConcerned ($p_cn, $jr_id) {
00762 $sql=" select jr_id as cn from jrn_rapt where jra_concerned=$jr_id
00763 union
00764 select jra_concerned as cn from jrn_rapt where jr_id=$jr_id";
00765 $Res=ExecSql($p_cn,$sql);
00766
00767
00768 $n=pg_NumRows($Res);
00769
00770 if ($n ==0 ) return null;
00771
00772
00773 for ($i=0;$i<$n;$i++) {
00774 $l=pg_fetch_array($Res,$i);
00775 $r[$i]=$l['cn'];
00776 }
00777 return $r;
00778 }
00792 function GetGrpt($p_cn,$p_jr_id)
00793 {
00794 $Res=ExecSql($p_cn,"select jr_grpt_id from jrn where jr_id=".$p_jr_id);
00795 if ( pg_NumRows($Res) == 0 ) {
00796 return null;
00797 }
00798 $r=pg_fetch_array($Res,0);
00799 return $r['jr_grpt_id'];
00800 }
00814 function UpdateComment ($p_cn,$p_jr_id,$p_comment) {
00815 $p_comment=FormatString($p_comment);
00816 $Res=ExecSql($p_cn,"update jrn set jr_comment='".$p_comment."'
00817 where jr_id = $p_jr_id");
00818
00819 }
00820
00834 function isValid ($p_cn,$p_grpt_id) {
00835 $Res=ExecSql($p_cn,"select jr_valid from jrn where jr_grpt_id=$p_grpt_id");
00836
00837 if ( ( $M = pg_NumRows($Res)) == 0 ) return 0;
00838
00839 $a=pg_fetch_array($Res,0);
00840
00841 if ( $a['jr_valid'] == 't') return 1;
00842 if ( $a['jr_valid'] == 'f') return 0;
00843
00844 echo_error ("Invalid result = ".$a['result']);
00845
00846
00847 }
00848
00861 function jrn_navigation_bar($p_offset,$p_line,$p_size=0,$p_page=1)
00862 {
00863
00864
00865 if ( $_SESSION['g_pagesize'] == -1 ) return "";
00866 if ( $p_size==0) {
00867 $p_size= $_SESSION['g_pagesize'];
00868 }
00869
00870 if ( $p_line == 0 ) return "";
00871
00872
00873 $url="";
00874 $and="";
00875 $get=$_GET;
00876 if ( isset ($get) ) {
00877 foreach ($get as $name=>$value ) {
00878
00879 if ( ! in_array($name,array('offset','step','page','size'))) {
00880 $url.=$and.$name."=".$value;
00881 $and="&";
00882 }
00883 }
00884 }
00885
00886 $nb_page=($p_line-($p_line%$p_size))/$p_size;
00887
00888
00889 if ( $p_line % $p_size != 0 ) $nb_page+=1;
00890
00891
00892 if ( $nb_page == 1) return "";
00893
00894 $r="";
00895
00896 if ($p_page !=1) {
00897 $e=$p_page-1;
00898 $step=$_SESSION['g_pagesize'];
00899 $offset=($e-1)*$step;
00900
00901 $r='<A class="one" href="'.$_SERVER['PHP_SELF']."?".$url."&offset=$offset&step=$step&page=$e&size=$step".'">';
00902 $r.="Précédent";
00903 $r.="</A> ";
00904 }
00905
00906
00907 for ($e=1;$e<=$nb_page;$e++) {
00908
00909 if ( $e != $p_page ) {
00910 $step=$_SESSION['g_pagesize'];
00911 $offset=($e-1)*$step;
00912 $go=sprintf($_SERVER['PHP_SELF']."?".$url."&offset=$offset&step=$step&page=$e&size=$step");
00913 $r.=sprintf('<A HREF="%s" CLASS="one">%d</A> ',$go,$e);
00914 } else {
00915 $r.="<b> $e </b>";
00916 }
00917
00918 if ( $e % 57 == 0 ) {
00919 $r.="<br>";
00920 }
00921 }
00922
00923 if ($p_page !=$nb_page) {
00924 $e=$p_page+1;
00925 $step=$_SESSION['g_pagesize'];
00926 $offset=($e-1)*$step;
00927
00928 $r.=' <A class="one" href="'.$_SERVER['PHP_SELF']."?".$url."&offset=$offset&step=$step&page=$e&size=$step".'">';
00929 $r.="Suivant";
00930 $r.="</A>";
00931 }
00932
00933
00934 return $r;
00935
00936 }