From 7e11657bd21f919f790d16f910671d812cafe1c1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Jun 2006 11:32:51 +0000 Subject: [PATCH] New: Un motif pour la remise fixe est obligatoire --- htdocs/comm/remx.php | 29 +++++++++++++++------- htdocs/compta/propal.php | 2 +- htdocs/langs/en_US/admin.lang | 14 +++++------ htdocs/langs/en_US/bills.lang | 7 +++++- htdocs/langs/en_US/main.lang | 2 ++ htdocs/langs/fr_FR/admin.lang | 16 ++++++------ htdocs/langs/fr_FR/bills.lang | 5 ++++ htdocs/langs/fr_FR/main.lang | 2 ++ htdocs/societe.class.php | 23 ++++++++++++++--- mysql/migration/2.0.0-2.1.0.sql | 6 ++++- mysql/tables/llx_societe_remise_except.sql | 6 ++--- 11 files changed, 76 insertions(+), 36 deletions(-) diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 7a7d0cabcb4..80a2f2b97e0 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -52,18 +52,29 @@ if ($user->societe_id > 0) if ($_POST["action"] == 'setremise') { - $soc = New Societe($db); - $soc->fetch($_GET["id"]); - $soc->set_remise_except($_POST["remise"],$user,$_POST["desc"]); - - if ($result > 0) + if (! price2num($_POST["remise"]) > 0) { - Header("Location: remx.php?id=".$_GET["id"]); - exit; + $mesg='
'.$langs->trans("ErrorFieldFormat",$langs->trans("NewGlobalDiscount")).'
'; + } + elseif (! $_POST["desc"]) + { + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("ReasonDiscount")).'
'; } else { - $mesg='
'.$soc->error.'
'; + $soc = New Societe($db); + $soc->fetch($_GET["id"]); + $soc->set_remise_except($_POST["remise"],$user,$_POST["desc"]); + + if ($result > 0) + { + Header("Location: remx.php?id=".$_GET["id"]); + exit; + } + else + { + $mesg='
'.$soc->error.'
'; + } } } @@ -86,7 +97,7 @@ if ($_GET["action"] == 'remove') /* - * Fiche avoirs + * Fiche des remises fixes */ llxHeader(); diff --git a/htdocs/compta/propal.php b/htdocs/compta/propal.php index 9f739bd8081..105c73b2b70 100644 --- a/htdocs/compta/propal.php +++ b/htdocs/compta/propal.php @@ -195,7 +195,7 @@ if ($_GET["propalid"] > 0) print ''; // Ligne info remises tiers - print ''.$langs->trans('Info').''; + print ''.$langs->trans('Discounts').''; if ($societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_client); else print $langs->trans("CompanyHasNoRelativeDiscount"); $absolute_discount=$societe->getCurrentDiscount(); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 2c744e3e686..d65261e536e 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -84,9 +84,7 @@ Module22Desc=Emailings' management Module25Name=Customer Orders Module25Desc=Customer orders' management Module30Name=Invoices -Module30Desc=Invoices' management for customers or suppliers -Module35Name=Discounts -Module35Desc=Discounts' management for customers +Module30Desc=Invoices' and credit notes' management for customers. Invoices' management for suppliers Module40Name=Suppliers Module40Desc=Suppliers' management Module42Name=Syslog @@ -393,12 +391,12 @@ ErrorConnectOkButWrongDatabase=Connection succeeded but database doesn't look to ##### Invoices ##### BillsSetup=Invoices module setup BillsDate=Invoices date -BillsNumberingModule=Invoices numbering module +BillsNumberingModule=Invoices and credit notes numbering module BillsPDFModules=Invoice documents models -DiscountSetup=Credit note module setup -DiscountsNumberingModules=Credit note numbering modules -DiscountsPDFModules=Credit note document models -Discounts=Discounts +CreditNoteSetup=Credit note module setup +CreditNotePDFModules=Credit note document models +CreditNote=Credit note +CreditNotes=Credit notes ForceInvoiceDate=Force invoice date to validation date DisableRepeatable=Disable repeatable invoices SuggestedPaymentModesIfNotDefinedInInvoice=Suggested Payments mode on invoices if not explicitely defined diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index dde73f81eee..6208dbcdca5 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -121,7 +121,12 @@ CreateFromRepeatableInvoice=Create from repeatable invoice ExportDataset_invoice_1=Customer invoices list and invoices' lines ProformaBill=Proforma Bill: Reduction=Reduction -ReductionShort=Reduc +ReductionShort=Reduc. +Reductions=Reductions +ReductionsShort=Reduc. +Discount=Discount +Discounts=Discounts +RelativeDiscount=Relative discount GlobalDiscount=Global discount CreditNote=Credit note CreditNotes=Credit notes diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index ce5c9a418a7..c9319ed0ca6 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -2,6 +2,7 @@ charset=iso-8859-1 Error=Error ErrorFieldRequired=Field '%s' is required +ErrorFieldFormat=Field '%s' has a bad value ErrorFileDoesNotExists=File %s does not exists ErrorFailedToOpenFile=Failed to open file %s ErrorCanNotCreateDir=Can not create dir %s @@ -21,6 +22,7 @@ ErrorWrongHostParameter=Wrong host parameter ErrorYourCountryIsNotDefined=Your country is not defined. Go to Home-Setup-Edit and post again the form. ErrorRecordIsUsedByChild=Failed to delete this record. This record is used by at least on child records. ErrorWrongValue=Wrong value +ErrorWrongValueForParameterX=Wrong value for parameter %s SeeAbove=See above HomeArea=Home area LastAccess=Last access diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 5a6056fc344..54a51268efc 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -83,10 +83,8 @@ Module22Name=Mailings Module22Desc=Administration et envoi de mailings Module25Name=Commandes clients Module25Desc=Gestion des commandes clients -Module30Name=Factures -Module30Desc=Gestion des factures clients ou fournisseurs -Module35Name=Avoirs -Module35Desc=Gestion des avoirs clients +Module30Name=Factures et avoirs +Module30Desc=Gestion des factures et avoirs clients. Gestion des factures fournisseurs Module40Name=Fournisseurs Module40Desc=Gestion des fournisseurs Module42Name=Syslog @@ -393,12 +391,12 @@ ErrorConnectOkButWrongDatabase=La connexion a r ##### Invoices ##### BillsSetup=Configuration du module Factures BillsDate=Date des factures -BillsNumberingModule=Module de numérotation des factures +BillsNumberingModule=Module de numérotation des factures et avoirs BillsPDFModules=Modèle de document de factures -DiscountSetup=Configuration du module Avoirs -DiscountsNumberingModules=Modules de numérotation des avoirs -DiscountsPDFModules=Modèles de documents des avoirs -Discounts=Avoirs +CreditNoteSetup=Configuration du module Avoirs +CreditNotePDFModules=Modèles de documents des avoirs +CreditNote=Avoir +CreditNotes=Avoirs ForceInvoiceDate=Forcer la date de facture à la date de validation DisableRepeatable=Désactiver les factures récurrentes SuggestedPaymentModesIfNotDefinedInInvoice=Modes de paiements suggérés sur les factures si non défini explicitement diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index 673a24190c3..5e6d7e9fcb9 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -122,6 +122,11 @@ ExportDataset_invoice_1=Factures clients et lignes de facture ProformaBill=Facture Proforma : Reduction=Réduction ReductionShort=Réduc. +Reductions=Réductions +ReductionsShort=Réduc. +Discount=Remise +Discounts=Remises +RelativeDiscount=Remise relative GlobalDiscount=Remise fixe CreditNote=Avoir CreditNotes=Avoirs diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index c8e340868e7..95a84c9ccd6 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -2,6 +2,7 @@ charset=iso-8859-1 Error=Erreur ErrorFieldRequired=Le champ '%s' est obligatoire +ErrorFieldFormat=Le champ '%s' a une valeur incorrecte ErrorFileDoesNotExists=Le fichier %s n'existe pas ErrorFailedToOpenFile=Impossible d'ouvrir le fichier %s ErrorCanNotCreateDir=Impossible de créer le répertoire %s @@ -21,6 +22,7 @@ ErrorWrongHostParameter=Mauvais param ErrorYourCountryIsNotDefined=Votre pays n'est pas défini. Corriger en allant dans Configuration-Général-Editer. ErrorRecordIsUsedByChild=Impossible de supprimer cet enregistrement. Ce dernier est utilisé en tant que père par au moins un enregistrement fils. ErrorWrongValue=Valeur incorrecte +ErrorWrongValueForParameterX=Valeur incorrecte pour le paramètre %s SeeAbove=Voir ci-dessus HomeArea=Espace accueil LastAccess=Dernière connexion diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php index 83a1152062e..9cadfb80421 100644 --- a/htdocs/societe.class.php +++ b/htdocs/societe.class.php @@ -923,14 +923,31 @@ class Societe } /** - * \brief Ajoute un avoir pour la société + * \brief Ajoute une remise fixe pour la société * \param remise Montant de la remise * \param user Utilisateur qui accorde la remise * \param desc Motif de l'avoir - * \return int <0 si ko, id de l'avoir si ok + * \return int <0 si ko, id de la ligne de remise si ok */ function set_remise_except($remise, $user, $desc) { + global $langs; + + // Nettoyage des parametres + $remise = price2num($remise); + $desc = trim($desc); + + if (! $remise > 0) + { + $this->error=$langs->trans("ErrorWrongValueForParameter","1"); + return -1; + } + if (! $desc) + { + $this->error=$langs->trans("ErrorWrongValueForParameter","3"); + return -2; + } + if ($this->id) { $remise = price2num($remise); @@ -942,7 +959,7 @@ class Societe if (! $this->db->query($sql) ) { $this->error=$this->db->lasterror(); - return -1; + return -3; } else { diff --git a/mysql/migration/2.0.0-2.1.0.sql b/mysql/migration/2.0.0-2.1.0.sql index 6fb5a005000..97025611aee 100644 --- a/mysql/migration/2.0.0-2.1.0.sql +++ b/mysql/migration/2.0.0-2.1.0.sql @@ -269,4 +269,8 @@ alter table llx_commandedet add column rang integer DEFAULT 0; alter table llx_propaldet add column rang integer DEFAULT 0; alter table llx_facture drop column model; -alter table llx_facture add column model_pdf varchar(50) after note_public; \ No newline at end of file +alter table llx_facture add column model_pdf varchar(50) after note_public; + + +update llx_societe_remise_except set description='Remise sans description' where description is NULL or description =''; +alter table llx_societe_remise_except modify description varchar(255) NOT NULL; \ No newline at end of file diff --git a/mysql/tables/llx_societe_remise_except.sql b/mysql/tables/llx_societe_remise_except.sql index 5574c254541..1b96ee431d5 100644 --- a/mysql/tables/llx_societe_remise_except.sql +++ b/mysql/tables/llx_societe_remise_except.sql @@ -1,5 +1,6 @@ -- ============================================================================ -- Copyright (C) 2004 Rodolphe Quiedeville +-- Copyright (C) 2006 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 @@ -19,8 +20,6 @@ -- $Source$ -- -- Remises exceptionnelles --- --- -- ============================================================================ create table llx_societe_remise_except @@ -31,6 +30,5 @@ create table llx_societe_remise_except amount_ht real NOT NULL, fk_user integer NOT NULL, fk_facture integer, - description text - + description varchar(255) NOT NULL )type=innodb;