From de9fe8524632f03f17151e686abc4752a235c9e1 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@users.sourceforge.net>
Date: Fri, 15 Apr 2005 21:49:23 +0000
Subject: [PATCH] =?UTF-8?q?Look:=20Modif=20esth=E9tique=20mineure?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 htdocs/compta/facture.php        |  28 ++--
 htdocs/compta/paiement.php       | 211 ++++++++++++++++---------------
 htdocs/compta/paiement/fiche.php |   9 +-
 htdocs/compta/paiement/info.php  |  11 +-
 4 files changed, 130 insertions(+), 129 deletions(-)

diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index cc4924453e9..641353998aa 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -22,7 +22,8 @@
  *
  */
 
-/**	    \file       htdocs/compta/facture.php
+/**
+	    \file       htdocs/compta/facture.php
 		\ingroup    facture
 		\brief      Page de cr�ation d'une facture
 		\version    $Revision$
@@ -36,23 +37,14 @@ $user->getrights('banque');
 if (!$user->rights->facture->lire)
   accessforbidden();
 
-$langs->load("main"); // BUG De chargement de traduction ne pas modifier cette ligne
 $langs->load("bills");
 
 require_once "../facture.class.php";
 require_once "../paiement.class.php";
-if ($conf->projet->enabled) {
-  require_once "../project.class.php";
-}
-if ($conf->propal->enabled) {
-  require_once "../propal.class.php";
-}
-if ($conf->contrat->enabled) {
-  require_once "../contrat/contrat.class.php";
-}
-if ($conf->commande->enabled) {
-  require_once "../commande/commande.class.php";
-}
+if ($conf->projet->enabled) require_once "../project.class.php";
+if ($conf->propal->enabled) require_once "../propal.class.php";
+if ($conf->contrat->enabled) require_once "../contrat/contrat.class.php";
+if ($conf->commande->enabled) require_once "../commande/commande.class.php";
 require_once "../lib/CMailFile.class.php";
 
 
@@ -1710,20 +1702,20 @@ else
 		    {
 		      if ($objp->fk_statut == 0)
 			{
-			  print '<td align="center">brouillon</td>';
+			  print '<td align="center">'.$langs->trans("BillShortStatusDraft").'</td>';
 			}
 		      elseif ($objp->fk_statut == 3)
 			{
-			  print '<td align="center">abandonn�e</td>';
+			  print '<td align="center">'.$langs->trans("BillShortStatusCanceled").'</td>';
 			}
 		      else
 			{
-			  print '<td align="center"><a class="'.$class.'" href="facture.php?filtre=paye:0,fk_statut:1">'.($objp->am?"commenc�":"impay�e").'</a></td>';
+			  print '<td align="center"><a class="'.$class.'" href="facture.php?filtre=paye:0,fk_statut:1">'.($objp->am?$langs->trans("BillShortStatusStarted"):$langs->trans("BillShortStatusNotPayed")).'</a></td>';
 			}
 		    }
 		  else
 		    {
-		      print '<td align="center">pay�e</td>';
+		      print '<td align="center">'.$langs->trans("BillShortStatusPayed").'</td>';
 		    }
 		
 		  print "</tr>\n";
diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php
index 6cecc0689e3..78fb0f710c0 100644
--- a/htdocs/compta/paiement.php
+++ b/htdocs/compta/paiement.php
@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004      Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2004-2005 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
@@ -44,87 +44,97 @@ $page=isset($_GET["page"])?$_GET["page"]:$_POST["page"];
 
 if ($_POST["action"] == 'add_paiement')
 {
-  if ($_POST["paiementid"] > 0)
+    if ($_POST["paiementid"] > 0)
     {
-      
-      $datepaye = $db->idate(mktime(12, 0 , 0,
-				    $_POST["remonth"], 
-				    $_POST["reday"],
-				    $_POST["reyear"]));
-
-      $paiement_id = 0;
-      $amounts = array();
-      foreach ($_POST as $key => $value)
-	{
-	  if (substr($key,0,7) == 'amount_')
-	    {
-	      $other_facid = substr($key,7);
-	      
-	      $amounts[$other_facid] = $_POST[$key];
-	    }
-	}
-      
-      // TODO Mettre toute la chaine dans une m�me transaction
-
-      // Creation de la ligne paiement
-      $paiement = new Paiement($db);
-      $paiement->datepaye     = $datepaye;
-      $paiement->amounts      = $amounts;   // Tableau de montant
-      $paiement->paiementid   = $_POST["paiementid"];
-      $paiement->num_paiement = $_POST["num_paiement"];
-      $paiement->note         = $_POST["comment"];
-      $paiement_id = $paiement->create($user);
-
-      if ($paiement_id > 0)
-	{
-          // On determine le montant total du paiement
-          $total=0;
-          foreach ($paiement->amounts as $key => $value)
-          {
-	    $facid = $key;
-	    $value = trim($value);
-	    $amount = round(ereg_replace(",",".",$value), 2);
-	    if (is_numeric($amount))
-	      {
-                $total += $amount;
-	      }
-          }
-	  
-          // Insertion dans llx_bank
-          $label = "R�glement facture";
-	  $acc = new Account($db, $_POST["accountid"]);
-	  //paiementid contient "CHQ ou VIR par exemple"
-	  $bank_line_id = $acc->addline($paiement->datepaye, $paiement->paiementid, $label, $total, $paiement->num_paiement, '', $user);
-	  
-	  // Mise a jour fk_bank dans llx_paiement. On connait ainsi le paiement qui a g�n�r� l'�criture bancaire
-	  if ($bank_line_id)
-	    {
-	      $paiement->update_fk_bank($bank_line_id);
-	    }
-	  
-          // Mise a jour liens (pour chaque facture concern�es par le paiement)
-          foreach ($paiement->amounts as $key => $value)
-	    {
-              $facid = $key;
-      	      $fac = new Facture($db);
-	      $fac->fetch($facid);
-	      $fac->fetch_client();
-	      $acc->add_url_line($bank_line_id, $paiement_id, DOL_URL_ROOT.'/compta/paiement/fiche.php?id=', "(paiement)");
-	      $acc->add_url_line($bank_line_id, $fac->client->id, DOL_URL_ROOT.'/compta/fiche.php?socid=', $fac->client->nom);	  
-	    }
-	  
-	  $loc = DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$paiement_id;
-	  Header("Location: $loc");
-	}
-      else
-	{
-	  // Il y a eu erreur
-	  $fiche_erreur_message = "Echec de la cr�ation du paiement";
-	}
+        $datepaye = $db->idate(mktime(12, 0 , 0,
+        $_POST["remonth"],
+        $_POST["reday"],
+        $_POST["reyear"]));
+
+        $paiement_id = 0;
+        $amounts = array();
+        foreach ($_POST as $key => $value)
+        {
+            if (substr($key,0,7) == 'amount_')
+            {
+                $other_facid = substr($key,7);
+
+                $amounts[$other_facid] = $_POST[$key];
+            }
+        }
+
+        // TODO Mettre toute la chaine dans une m�me transaction
+        $db->begin();
+
+        // Creation de la ligne paiement
+        $paiement = new Paiement($db);
+        $paiement->datepaye     = $datepaye;
+        $paiement->amounts      = $amounts;   // Tableau de montant
+        $paiement->paiementid   = $_POST["paiementid"];
+        $paiement->num_paiement = $_POST["num_paiement"];
+        $paiement->note         = $_POST["comment"];
+
+        $paiement_id = $paiement->create($user);
+        if ($paiement_id > 0)
+        {
+            // On determine le montant total du paiement
+            $total=0;
+            foreach ($paiement->amounts as $key => $value)
+            {
+                $facid = $key;
+                $value = trim($value);
+                $amount = round(ereg_replace(",",".",$value), 2);
+                if (is_numeric($amount))
+                {
+                    $total += $amount;
+                }
+            }
+
+            // Insertion dans llx_bank
+            $label = "R�glement facture";
+            $acc = new Account($db, $_POST["accountid"]);
+            //paiementid contient "CHQ ou VIR par exemple"
+            $bank_line_id = $acc->addline($paiement->datepaye, $paiement->paiementid, $label, $total, $paiement->num_paiement, '', $user);
+
+            // Mise a jour fk_bank dans llx_paiement. On connait ainsi le paiement qui a g�n�r� l'�criture bancaire
+            if ($bank_line_id > 0)
+            {
+                $paiement->update_fk_bank($bank_line_id);
+
+                // Mise a jour liens (pour chaque facture concern�es par le paiement)
+                foreach ($paiement->amounts as $key => $value)
+                {
+                    $facid = $key;
+                    $fac = new Facture($db);
+                    $fac->fetch($facid);
+                    $fac->fetch_client();
+                    $acc->add_url_line($bank_line_id, $paiement_id, DOL_URL_ROOT.'/compta/paiement/fiche.php?id=', "(paiement)");
+                    $acc->add_url_line($bank_line_id, $fac->client->id, DOL_URL_ROOT.'/compta/fiche.php?socid=', $fac->client->nom);
+                }
+
+                $loc = DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$paiement_id;
+
+                $db->commit();
+
+                Header("Location: $loc");
+            }
+            else
+            {
+                // Il y a eu erreur
+                $db->rollback();
+                $fiche_erreur_message = $langs->trans("ErrorUnknown");
+            }
+        }
+        else
+        {
+            // Il y a eu erreur
+            $db->rollback();
+            $fiche_erreur_message = $langs->trans("ErrorUnknown");
+        }
     }
-  else
+    else
     {
-      $fiche_erreur_message = "Vous devez s�lectionner un mode de paiement";
+        $fiche_erreur_message = '<div class="error">Vous devez s�lectionner un mode de paiement</div>';
     }
 }
 
@@ -145,8 +155,13 @@ llxHeader();
 
 $html=new Form($db);
 
+if ($fiche_erreur_message)
+{
+  print '<tr><td colspan="3" align="center">'.$fiche_erreur_message.'</td></tr>';
+}
 
-if ($_GET["action"] == 'create') 
+
+if ($_GET["action"] == 'create' || $_POST["action"] == 'add_paiement') 
 {
   $facture = new Facture($db);
   $facture->fetch($facid);
@@ -165,18 +180,18 @@ if ($_GET["action"] == 'create')
 
 	  $total = $obj->total;
 
-	  print_titre("Emettre un paiement");
+	  print_titre($langs->trans("DoPayment"));
 
-	  print '<form action="paiement.php?action=create&facid='.$facid.'" method="post">';
+	  print '<form action="paiement.php" method="post">';
 	  print '<input type="hidden" name="action" value="add_paiement">';
-	  print '<table class="border" width="100%">';
-	  
-	  print "<tr><td>".$langs->trans("Company")." :</td><td colspan=\"2\">$obj->nom</td></tr>\n";
-	  
 	  print "<input type=\"hidden\" name=\"facid\" value=\"$facid\">";
 	  print "<input type=\"hidden\" name=\"facnumber\" value=\"$obj->facnumber\">";
 	  print "<input type=\"hidden\" name=\"socid\" value=\"$obj->idp\">";
 	  print "<input type=\"hidden\" name=\"societe\" value=\"$obj->nom\">";
+
+	  print '<table class="border" width="100%">';
+	  
+	  print "<tr><td>".$langs->trans("Company")." :</td><td colspan=\"2\">$obj->nom</td></tr>\n";
 	  
 	  print "<tr><td>".$langs->trans("Date")." :</td><td>";
 	  $html->select_date();
@@ -254,7 +269,7 @@ if ($_GET["action"] == 'create')
 		  print '<tr><td colspan="3">';
 		  print '<table class="noborder" width="100%">';
 		  print '<tr class="liste_titre">';
-		  print '<td>Facture</td><td align="center">'.$langs->trans("Date").'</td>';
+		  print '<td>'.$langs->trans("Bill").'</td><td align="center">'.$langs->trans("Date").'</td>';
 		  print '<td align="right">'.$langs->trans("AmountTTC").'</td>';	      
 		  print '<td align="right">'.$langs->trans("Received").'</td>';
 		  print '<td align="right">'.$langs->trans("RemainderToPay").'</td>';
@@ -272,7 +287,7 @@ if ($_GET["action"] == 'create')
 		      
 		      print "<tr $bc[$var]>";
 		  
-		      print '<td><a href="facture.php?facid='.$objp->facid.'">' . $objp->facnumber;
+		      print '<td><a href="facture.php?facid='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->facnumber;
 		      print "</a></td>\n";
 		      
 		      if ($objp->df > 0 )
@@ -323,11 +338,6 @@ if ($_GET["action"] == 'create')
 	   *
 	   */
 
-	  if ($fiche_erreur_message)
-	    {
-	      print '<tr><td colspan="3" align="center">'.$fiche_erreur_message.'</td></tr>';
-	    }
-
 	  print '<tr><td colspan="3" align="center"><input type="submit" value="'.$langs->trans("Save").'"></td></tr>';
 	  print "</table>";
 	  print "</form>\n";	  
@@ -339,20 +349,15 @@ if ($_GET["action"] == 'create')
 /**
  *  \brief      Affichage de la liste des paiement
  */
-if (! $_GET["action"])
+if (! $_GET["action"] && ! $_POST["action"])
 {
   
-  if ($page == -1)
-    $page = 0 ;
-  
+  if ($page == -1) $page = 0 ;
   $limit = $conf->liste_limit;
   $offset = $limit * $page ;
   
-  if ($sortorder == "")
-    $sortorder="DESC";
-  
-  if ($sortfield == "")
-    $sortfield="p.datep";
+  if (! $sortorder) $sortorder="DESC";
+  if (! $sortfield) $sortfield="p.datep";
   
   $sql = "SELECT ".$db->pdate("p.datep")." as dp, p.amount, f.amount as fa_amount, f.facnumber";
   $sql .=", f.rowid as facid, c.libelle as paiement_type, p.num_paiement";
@@ -374,7 +379,7 @@ if (! $_GET["action"])
       $i = 0; 
       $var=True;
       
-      print_barre_liste("Paiements", $page, "paiement.php","",$sortfield,$sortorder,'',$num);
+      print_barre_liste($langs->trans("Payments"), $page, "paiement.php","",$sortfield,$sortorder,'',$num);
 
       print '<table class="noborder" width="100%">';
       print '<tr class="liste_titre">';
diff --git a/htdocs/compta/paiement/fiche.php b/htdocs/compta/paiement/fiche.php
index 00d651bda37..e8c9da58a78 100644
--- a/htdocs/compta/paiement/fiche.php
+++ b/htdocs/compta/paiement/fiche.php
@@ -21,7 +21,8 @@
  *
  */
 
-/**	    \file       htdocs/compta/paiement/fiche.php
+/**
+	    \file       htdocs/compta/paiement/fiche.php
 		\ingroup    facture
 		\brief      Onglet paiement d'un paiement
 		\version    $Revision$
@@ -156,10 +157,10 @@ if ($db->query($sql))
 	  $var=!$var;
 	  
 	  print "<tr $bc[$var]>";
-	  print '<td><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill").'</a>';
-	  print ' <a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$objp->facid.'">' . $objp->facnumber;
+	  print '<td><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill").' ';
+	  print $objp->facnumber;
 	  print "</a></td>\n";
-	  print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$objp->idp.'">' . $objp->nom.'</a></td>';
+	  print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$objp->nom.'</a></td>';
 	  print '<td align="right">'.price($objp->amount).'</td>';
 	  $fac=new Facture($db);
 	  print '<td align="center">'.$fac->LibStatut($objp->paye,$objp->fk_statut).'</td>';
diff --git a/htdocs/compta/paiement/info.php b/htdocs/compta/paiement/info.php
index 021a259713c..38e76b8e6a9 100644
--- a/htdocs/compta/paiement/info.php
+++ b/htdocs/compta/paiement/info.php
@@ -1,6 +1,6 @@
 <?php
-/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004 Laurent Destailleur  <eldy@users.sourceforge.net>
+/* Copyright (C) 2004      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2005 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
@@ -21,7 +21,8 @@
  *
  */
 
-/*!	\file htdocs/compta/paiement/info.php
+/**
+    	\file       htdocs/compta/paiement/info.php
 		\ingroup    facture
 		\brief      Onglet info d'un paiement
 		\version    $Revision$
@@ -51,10 +52,12 @@ $paiement->fetch($_GET["id"], $user);
 $paiement->info($_GET["id"]);
 
 print '<table width="100%"><tr><td>';
+print '<br>';
 dolibarr_print_object_info($paiement);
+print '<br>';
 print '</td></tr></table>';
 
 $db->close();
 
-llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
+llxFooter('$Date$ - $Revision$');
 ?>
-- 
GitLab