From 934575ee7c294ac2aa0218d5492a942cf81a7a9f Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Tue, 9 Nov 2004 15:00:38 +0000 Subject: [PATCH] Gestion de la remise exceptionnelle --- htdocs/societe.class.php | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php index d4d91401461..7d33fbed3ef 100644 --- a/htdocs/societe.class.php +++ b/htdocs/societe.class.php @@ -1,8 +1,9 @@ - * Copyright (C) 2002-2004 Rodolphe Quiedeville - * Copyright (C) 2004 Eric Seigne +/* Copyright (C) 2002-2004 Rodolphe Quiedeville * Copyright (C) 2004 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2003 Brian Fraval + * * * 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 @@ -516,6 +517,35 @@ class Societe { } } + /** + * \brief Définit la société comme un client + * \param remise montant de la remise + * \param user utilisateur qui place la remise + * + */ + + function set_remise_except($remise, $user) + { + if ($this->id) + { + $remise = ereg_replace(",",".",$remise); + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except "; + $sql .= " WHERE fk_soc = " . $this->id ." AND fk_facture IS NULL;"; + + $this->db->query($sql); + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_except "; + $sql .= " ( datec, fk_soc, amount_ht, fk_user )"; + $sql .= " VALUES (now(),".$this->id.",'".$remise."',".$user->id.")"; + + if (! $this->db->query($sql) ) + { + dolibarr_print_error($this->db); + } + + } + } /** * \brief Renvoie le nom d'une societe a partir d'un id