From 8d19da30f420664e0749b92b25d7b6600cb29017 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@users.sourceforge.net>
Date: Fri, 9 Jan 2009 22:52:45 +0000
Subject: [PATCH] Minor change

---
 htdocs/compta/facture/impayees.php            | 56 ++++++++++++-------
 htdocs/compta/paiement/rapport.php            |  2 +-
 htdocs/document.php                           |  4 +-
 htdocs/html.formfile.class.php                | 24 ++++----
 .../menus/barre_left/eldy_backoffice.php      |  2 -
 .../modules/rapport/pdf_paiement.class.php    | 24 ++++----
 htdocs/lib/functions.lib.php                  |  1 +
 7 files changed, 66 insertions(+), 47 deletions(-)

diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php
index 2ee3aca349c..7d19b61cff0 100644
--- a/htdocs/compta/facture/impayees.php
+++ b/htdocs/compta/facture/impayees.php
@@ -41,7 +41,7 @@ $diroutputpdf=$conf->facture->dir_output . '/unpayed/temp';
 
 // Security check
 if ($user->societe_id) $socid=$user->societe_id;
-$result = restrictedArea($user, 'facture',$facid,'');
+$result = restrictedArea($user,'facture',$facid,'');
 
 
 /*
@@ -186,24 +186,24 @@ if ($_GET["filtre"])
 	}
 }
 
-if ($_GET["search_ref"])
+if ($_REQUEST["search_ref"])
 {
-	$sql .= " AND f.facnumber like '%".$_GET["search_ref"]."%'";
+	$sql .= " AND f.facnumber like '%".$_REQUEST["search_ref"]."%'";
 }
 
-if ($_GET["search_societe"])
+if ($_REQUEST["search_societe"])
 {
-	$sql .= " AND s.nom like '%".$_GET["search_societe"]."%'";
+	$sql .= " AND s.nom like '%".$_REQUEST["search_societe"]."%'";
 }
 
-if ($_GET["search_montant_ht"])
+if ($_REQUEST["search_montant_ht"])
 {
-	$sql .= " AND f.total = '".$_GET["search_montant_ht"]."'";
+	$sql .= " AND f.total = '".$_REQUEST["search_montant_ht"]."'";
 }
 
-if ($_GET["search_montant_ttc"])
+if ($_REQUEST["search_montant_ttc"])
 {
-	$sql .= " AND f.total_ttc = '".$_GET["search_montant_ttc"]."'";
+	$sql .= " AND f.total_ttc = '".$_REQUEST["search_montant_ttc"]."'";
 }
 
 if (strlen($_POST["sf_ref"]) > 0)
@@ -231,7 +231,17 @@ if ($result)
 		$soc->fetch($socid);
 	}
 
-	$param="&amp;socid=".$socid."&amp;option=".$option;
+	$param="";
+	$param.=($socid?"&amp;socid=".$socid:"");
+	$param.=($option?"&amp;option=".$option:"");
+	if ($_REQUEST["search_ref"])         $param.='&amp;search_ref='.urlencode($_REQUEST["search_ref"]);
+	if ($_REQUEST["search_societe"])     $param.='&amp;search_societe='.urlencode($_REQUEST["search_societe"]);
+	if ($_REQUEST["search_montant_ht"])  $param.='&amp;search_montant_ht='.urlencode($_REQUEST["search_montant_ht"]);
+	if ($_REQUEST["search_montant_ttc"]) $param.='&amp;search_montant_ttc='.urlencode($_REQUEST["search_montant_ttc"]);
+	if ($_REQUEST["late"])               $param.='&amp;late='.urlencode($_REQUEST["search_late"]);
+	
+	$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
+	$urlsource.=eregi_replace('&amp;','&',$param);
 	
 	$titre=($socid?$langs->trans("BillsCustomersUnpayedForCompany",$soc->nom):$langs->trans("BillsCustomersUnpayed"));
 	if ($option == 'late') $titre.=' ('.$langs->trans("Late").')';
@@ -264,16 +274,16 @@ if ($result)
 	print '<form method="get" action="'.$_SERVER["PHP_SELF"].'">';
 	print '<tr class="liste_titre">';
 	print '<td class="liste_titre">';
-	print '<input class="flat" size="10" type="text" name="search_ref" value="'.$_GET["search_ref"].'"></td>';
+	print '<input class="flat" size="10" type="text" name="search_ref" value="'.$_REQUEST["search_ref"].'"></td>';
 	print '<td class="liste_titre" align="center"><input type="checkbox" onclick="checkall(this.checked);"></td>';
 	print '<td class="liste_titre">&nbsp;</td>';
 	print '<td class="liste_titre">&nbsp;</td>';
 	print '<td class="liste_titre" align="left">';
-	print '<input class="flat" type="text" name="search_societe" value="'.$_GET["search_societe"].'">';
+	print '<input class="flat" type="text" name="search_societe" value="'.$_REQUEST["search_societe"].'">';
 	print '</td><td class="liste_titre" align="right">';
-	print '<input class="flat" type="text" size="10" name="search_montant_ht" value="'.$_GET["search_montant_ht"].'">';
+	print '<input class="flat" type="text" size="10" name="search_montant_ht" value="'.$_REQUEST["search_montant_ht"].'">';
 	print '</td><td class="liste_titre" align="right">';
-	print '<input class="flat" type="text" size="10" name="search_montant_ttc" value="'.$_GET["search_montant_ttc"].'">';
+	print '<input class="flat" type="text" size="10" name="search_montant_ttc" value="'.$_REQUEST["search_montant_ttc"].'">';
 	print '</td><td class="liste_titre" colspan="2" align="right">';
 	print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'">';
 	print '</td>';
@@ -321,12 +331,14 @@ if ($result)
 				
 			$filename=sanitizeFileName($objp->facnumber);
 			$filedir=$conf->facture->dir_output . '/' . sanitizeFileName($objp->facnumber);
-			$urlsource=$_SERVER['PHP_SELF'].'?facid='.$objp->facid;
-			$formfile->show_documents('facture',$filename,$filedir,$urlsource,'','','','','',1);
-				
+			$foundpdf=$formfile->show_documents('facture',$filename,$filedir,$urlsource,'','','','','',1,$param);
 			print '</td></tr></table>';
 			
-			print '<td align="center"><input id="cb'.$objp->facid.'" type="checkbox" name="toGenerate[]" value="'.$objp->facnumber.'"></td>' ;
+			// Checkbox
+			print '<td align="center">';
+			if ($foundpdf) print '<input id="cb'.$objp->facid.'" type="checkbox" name="toGenerate[]" value="'.$objp->facnumber.'">';
+			else print '&nbsp;';
+			print '</td>' ;
 			
 			print "</td>\n";
 
@@ -368,13 +380,17 @@ if ($result)
 	 * Show list of available documents
 	 */
 	$filedir=$diroutputpdf;
-	$urlsource=$_SERVER['PHP_SELF'].'?facid='.$fac->id;
+	if ($_REQUEST["search_ref"])         print '<input type="hidden" name="search_ref" value="'.$_REQUEST["search_ref"].'">';
+	if ($_REQUEST["search_societe"])     print '<input type="hidden" name="search_societe" value="'.$_REQUEST["search_societe"].'">';
+	if ($_REQUEST["search_montant_ht"])  print '<input type="hidden" name="search_montant_ht" value="'.$_REQUEST["search_montant_ht"].'">';
+	if ($_REQUEST["search_montant_ttc"]) print '<input type="hidden" name="search_montant_ttc" value="'.$_REQUEST["search_montant_ttc"].'">';
+	if ($_REQUEST["late"])               print '<input type="hidden" name="late" value="'.$_REQUEST["late"].'">';
 	$genallowed=$user->rights->facture->lire;
 	$delallowed=$user->rights->facture->lire;
 
 	print '<br>';
 	print '<input type="hidden" name="option" value="'.$option.'">';
-	$formfile->show_documents('unpayed','',$filedir,$urlsource,$genallowed,$delallowed,'','',0,0,48,1);
+	$formfile->show_documents('unpayed','',$filedir,$urlsource,$genallowed,$delallowed,'','',0,0,48,1,$param);
 	print '</form>';		
 	
 	$db->free();
diff --git a/htdocs/compta/paiement/rapport.php b/htdocs/compta/paiement/rapport.php
index 1571cc88b77..5a15b7d68d3 100644
--- a/htdocs/compta/paiement/rapport.php
+++ b/htdocs/compta/paiement/rapport.php
@@ -88,7 +88,7 @@ $titre=($year?$langs->trans("PaymentsReportsForYear",$year):$langs->trans("Payme
 print_fiche_titre($titre);
 
 // Formulaire de g�n�ration
-print '<br><form method="post" action="rapport.php?year='.$year.'">';
+print '<form method="post" action="rapport.php?year='.$year.'">';
 print '<input type="hidden" name="action" value="gen">';
 $cmonth = date("n", time());
 $syear = date("Y", time());
diff --git a/htdocs/document.php b/htdocs/document.php
index b74b66ee171..ef5a12f3cfe 100644
--- a/htdocs/document.php
+++ b/htdocs/document.php
@@ -437,7 +437,7 @@ if ($action == 'remove_file')
 	clearstatcache(); 
 	$filename = basename($original_file);
 	
-	dolibarr_syslog("document.php remove $original_file $filename $urlsource");
+	dolibarr_syslog("document.php remove $original_file $filename $urlsource", LOG_DEBUG);
 
 	if (! file_exists($original_file)) 
 	{
@@ -446,7 +446,7 @@ if ($action == 'remove_file')
 	}
 	unlink($original_file);
 
-	dolibarr_syslog("document.php back to ".urldecode($urlsource));
+	dolibarr_syslog("document.php back to ".urldecode($urlsource), LOG_DEBUG);
 
 	header("Location: ".urldecode($urlsource));
 
diff --git a/htdocs/html.formfile.class.php b/htdocs/html.formfile.class.php
index 4ed344792c6..0c7aa04df78 100644
--- a/htdocs/html.formfile.class.php
+++ b/htdocs/html.formfile.class.php
@@ -122,18 +122,19 @@ class FormFile
 	 *      \param      filedir             Dir to scan
 	 *      \param      urlsource           Url of origin page (for return)
 	 *      \param      genallowed          Generation is allowed (1/0 or array of formats)
-	 *      \param      delallowed          Suppression autoris�e (1/0)
-	 *      \param      modelselected       Modele � pr�-s�lectionner par d�faut
+	 *      \param      delallowed          Remove is allowed (1/0)
+	 *      \param      modelselected       Model to preselect by default
 	 *      \param      modelliste			Tableau des modeles possibles. Use '' to hide combo select list.
-	 *      \param      forcenomultilang	N'affiche pas option langue meme si MAIN_MULTILANGS d�fini
+	 *      \param      forcenomultilang	N'affiche pas option langue meme si MAIN_MULTILANGS defini
 	 *      \param      iconPDF             N'affiche que l'icone PDF avec le lien (1/0)
 	 * 		\param		maxfilenamelength	Max length for filename shown
 	 * 		\param		noform				Do not output html form start and end 
-	 *      \remarks    Le fichier de facture d�taill�e est de la forme
+	 * 		\param		param				More param on http links
+	 *      \remarks    Le fichier de facture detaillee est de la forme
 	 *                  REFFACTURE-XXXXXX-detail.pdf ou XXXXX est une forme diverse
-	 *		\return		int					<0 si ko, nbre de fichiers affich�s si ok
+	 *		\return		int					<0 si ko, nbre de fichiers affiches si ok
 	 */
-	function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$modelliste=array(),$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0)
+	function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$modelliste=array(),$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='')
 	{
 		// filedir = conf->...dir_ouput."/".get_exdir(id)
 		include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php');
@@ -330,7 +331,7 @@ class FormFile
 		}
 		$file_list=dol_dir_list($filedir,'files',0,$filter,'\.meta$'.$png,'date',SORT_DESC);
 
-		// Affiche en-tete tableau si non deja affich�
+		// Affiche en-tete tableau si non deja affiche
 		if (sizeof($file_list) && ! $headershown && !$iconPDF)
 		{
 			$headershown=1;
@@ -338,12 +339,12 @@ class FormFile
 			print '<table class="border" width="100%">';
 		}
 
-		// Boucle sur chaque ligne trouv�e
+		// Boucle sur chaque ligne trouvee
 		foreach($file_list as $i => $file)
 		{
 			$var=!$var;
 			
-			// D�fini chemin relatif par rapport au module pour lien download
+			// Defini chemin relatif par rapport au module pour lien download
 			$relativepath=$file["name"];								// Cas general
 			if ($filename) $relativepath=$filename."/".$file["name"];	// Cas propal, facture...
 			// Autre cas
@@ -372,7 +373,10 @@ class FormFile
 
 			if ($delallowed)
 			{
-				print '<td align="right"><a href="'.DOL_URL_ROOT.'/document.php?action=remove_file&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'&amp;urlsource='.urlencode($urlsource).'">'.img_delete().'</a></td>';
+				print '<td align="right"><a href="'.DOL_URL_ROOT.'/document.php?action=remove_file&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath);
+				print ($param?'&amp;'.$param:'');
+				print '&amp;urlsource='.urlencode($urlsource);
+				print '">'.img_delete().'</a></td>';
 			}
 
 			if (!$iconPDF) print '</tr>';
diff --git a/htdocs/includes/menus/barre_left/eldy_backoffice.php b/htdocs/includes/menus/barre_left/eldy_backoffice.php
index 4f80d168466..ef538a6f42f 100644
--- a/htdocs/includes/menus/barre_left/eldy_backoffice.php
+++ b/htdocs/includes/menus/barre_left/eldy_backoffice.php
@@ -435,8 +435,6 @@ class MenuLeft {
 					}
 					if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/facture/impayees.php?leftmenu=customers_bills",$langs->trans("Unpayed"),2,$user->rights->facture->lire);
 
-					if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/facture/impayees.php?option=late&amp;leftmenu=customers_bills",$langs->trans("Unpayed").' ('.$langs->trans("Late").')',2,$user->rights->facture->lire);
-					
 					if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/paiement/liste.php?leftmenu=customers_bills_payments",$langs->trans("Payments"),2,$user->rights->facture->lire);
 
 					if ($conf->global->BILL_ADD_PAYMENT_VALIDATION)
diff --git a/htdocs/includes/modules/rapport/pdf_paiement.class.php b/htdocs/includes/modules/rapport/pdf_paiement.class.php
index c9d1237d6c3..93cbd6d1d4f 100644
--- a/htdocs/includes/modules/rapport/pdf_paiement.class.php
+++ b/htdocs/includes/modules/rapport/pdf_paiement.class.php
@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2006-2007 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2006-2009 Laurent Destailleur  <eldy@users.sourceforge.net>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -19,25 +19,25 @@
  */
 
 /**
-	\file       htdocs/includes/modules/rapport/pdf_paiement.class.php
-	\ingroup    banque
-	\brief      Fichier de la classe permettant de g�n�rer les rapports de paiement
-	\version    $Id$
-*/
+ *	\file       htdocs/includes/modules/rapport/pdf_paiement.class.php
+ *	\ingroup    banque
+ *	\brief      Fichier de la classe permettant de g�n�rer les rapports de paiement
+ *	\version    $Id$
+ */
 require_once(DOL_DOCUMENT_ROOT.'/includes/fpdf/fpdfi/fpdi_protection.php');
 require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
 
 
 /**	
-	\class      pdf_paiement
-	\brief      Classe permettant de g�n�rer les rapports de paiement
-*/
+ *	\class      pdf_paiement
+ *	\brief      Classe permettant de generer les rapports de paiement
+ */
 class pdf_paiement extends FPDF
 {
 	/**	
-		\brief  Constructeur
-		\param	db		handler acc�s base de donn�e
-	*/
+	 *	\brief  Constructeur
+	 *	\param	db		handler acces base de donnee
+	 */
 	function pdf_paiement($db)
 	{ 
 		global $langs;
diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php
index f54de5592aa..7c8e5ec8d9e 100644
--- a/htdocs/lib/functions.lib.php
+++ b/htdocs/lib/functions.lib.php
@@ -421,6 +421,7 @@ function dol_print_date($time,$format='',$to_gmt=false,$outputlangs='')
 	// What is page code of texts from strftime functions ?
 	$pagecodefrom='ISO-8859-1';
 	$localtime=setlocale(LC_TIME,0);
+	//print $localtime;
 	if (eregi('UTF',$localtime)) $pagecodefrom='UTF-8';
 
 	if (! is_object($outputlangs)) $outputlangs=$langs;
-- 
GitLab