From de9fe8524632f03f17151e686abc4752a235c9e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur 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 | 205 ++++++++++++++++--------------- htdocs/compta/paiement/fiche.php | 9 +- htdocs/compta/paiement/info.php | 11 +- 4 files changed, 127 insertions(+), 126 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 'brouillon'; + print ''.$langs->trans("BillShortStatusDraft").''; } elseif ($objp->fk_statut == 3) { - print 'abandonnée'; + print ''.$langs->trans("BillShortStatusCanceled").''; } else { - print ''.($objp->am?"commencé":"impayée").''; + print ''.($objp->am?$langs->trans("BillShortStatusStarted"):$langs->trans("BillShortStatusNotPayed")).''; } } else { - print 'payée'; + print ''.$langs->trans("BillShortStatusPayed").''; } print "\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 @@ - * Copyright (C) 2004 Laurent Destailleur + * Copyright (C) 2004-2005 Laurent Destailleur * * 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"])); + $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 + $paiement_id = 0; + $amounts = array(); + foreach ($_POST as $key => $value) + { + if (substr($key,0,7) == 'amount_') + { + $other_facid = substr($key,7); - // 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); + $amounts[$other_facid] = $_POST[$key]; + } + } - 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"; - } + // 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 = '
Vous devez sélectionner un mode de paiement
'; } } @@ -145,8 +155,13 @@ llxHeader(); $html=new Form($db); +if ($fiche_erreur_message) +{ + print ''.$fiche_erreur_message.''; +} -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 '
'; + print ''; print ''; - print ''; - - print "\n"; - print ""; print "facnumber\">"; print "idp\">"; print "nom\">"; + + print '
".$langs->trans("Company")." :$obj->nom
'; + + print "\n"; print "
".$langs->trans("Company")." :$obj->nom
".$langs->trans("Date")." :"; $html->select_date(); @@ -254,7 +269,7 @@ if ($_GET["action"] == 'create') print '
'; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -272,7 +287,7 @@ if ($_GET["action"] == 'create') print ""; - print '\n"; if ($objp->df > 0 ) @@ -323,11 +338,6 @@ if ($_GET["action"] == 'create') * */ - if ($fiche_erreur_message) - { - print ''; - } - print ''; print "
Facture'.$langs->trans("Date").''.$langs->trans("Bill").''.$langs->trans("Date").''.$langs->trans("AmountTTC").''.$langs->trans("Received").''.$langs->trans("RemainderToPay").'
' . $objp->facnumber; + print ''.img_object($langs->trans("ShowBill"),"bill").' '.$objp->facnumber; print "
'.$fiche_erreur_message.'
"; print "\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 ''; print ''; 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 ""; - print '\n"; - print ''; + print ''; print ''; $fac=new Facture($db); print ''; 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 @@ - * Copyright (C) 2004 Laurent Destailleur +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2004-2005 Laurent Destailleur * * 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 '
'.img_object($langs->trans("ShowBill"),"bill").''; - print ' ' . $objp->facnumber; + print ''.img_object($langs->trans("ShowBill"),"bill").' '; + print $objp->facnumber; print "' . $objp->nom.''.img_object($langs->trans("ShowCompany"),"company").' '.$objp->nom.''.price($objp->amount).''.$fac->LibStatut($objp->paye,$objp->fk_statut).'
'; +print '
'; dolibarr_print_object_info($paiement); +print '
'; print '
'; $db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('$Date$ - $Revision$'); ?>