diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index 8367a09e27f..3d3368cc5c0 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -359,12 +359,24 @@ if ($_GET['action'] == 'modif' && $user->rights->propale->creer)
}
+if ($_POST['action'] == "adddiscount" && $user->rights->propale->creer)
+{
+ $propal = new Propal($db);
+ $ret=$propal->fetch($_POST['propalid']);
+
+ if ($_POST["amount"])
+ {
+// \todo a completer
+// $propal->insert_discount($_POST["amount"]);
+ }
+}
+
/*
* Ajout d'une ligne produit dans la propale
*/
if ($_POST['action'] == "addligne" && $user->rights->propale->creer)
{
- if ($_POST['qty'] && (($_POST['np_price']>=0 && $_POST['np_desc']) || $_POST['idprod']))
+ if ($_POST['qty'] && (($_POST['np_price']!=0 && $_POST['np_desc']) || $_POST['idprod']))
{
$propal = new Propal($db);
$ret=$propal->fetch($_POST['propalid']);
@@ -602,14 +614,17 @@ 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();
print '. ';
- if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
- else print $langs->trans("CompanyHasNoAbsoluteDiscount");
- print '.';
+ if ($absolute_discount)
+ {
+ print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
+ print '.';
+ }
+ else print $langs->trans("CompanyHasNoAbsoluteDiscount").'.';
print ' |
';
// Dates
@@ -1257,7 +1272,7 @@ if ($_GET['propalid'] > 0)
// Valid
if ($propal->statut == 0)
{
- if ($user->rights->propale->valider)
+ if ($user->rights->propale->valider && $propal->total_ttc > 0)
{
print 'id.'&action=validate">'.$langs->trans('Validate').'';
}
diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang
index 0170b52b1cb..673a24190c3 100644
--- a/htdocs/langs/fr_FR/bills.lang
+++ b/htdocs/langs/fr_FR/bills.lang
@@ -122,13 +122,13 @@ ExportDataset_invoice_1=Factures clients et lignes de facture
ProformaBill=Facture Proforma :
Reduction=Réduction
ReductionShort=Réduc.
-GlobalDiscount=Remise globale
+GlobalDiscount=Remise fixe
CreditNote=Avoir
CreditNotes=Avoirs
-NewGlobalDiscount=Nouvelle remise
+NewGlobalDiscount=Nouvelle remise fixe
NoteReason=Note/Motif
ReasonDiscount=Motif
-AddGlobalDiscount=Ajouter remise
+AddGlobalDiscount=Ajouter remise fixe
DiscountOfferedBy=Accordé par
DiscountStillRemaining=Remises absolues restant en cours
DiscountAlreadyCounted=Remises absolues déjà appliquées
diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php
index 97dda02811a..11fc025efb4 100644
--- a/htdocs/propal.class.php
+++ b/htdocs/propal.class.php
@@ -136,6 +136,21 @@ class Propal
}
}
+ /**
+ * \brief Ajout d'un produit dans la proposition, en base
+ * \param idproduct Id du produit à ajouter
+ * \param qty Quantité
+ * \param remise_percent Remise relative effectuée sur le produit
+ * \param p_desc Descriptif optionnel
+ * \return int >0 si ok, <0 si ko
+ * \see add_product
+ */
+ function insert_discount($idproduct, $qty, $remise_percent=0, $p_desc='')
+ {
+
+
+ }
+
/**
* \brief Ajout d'un produit dans la proposition, en base
* \param idproduct Id du produit à ajouter
diff --git a/mysql/migration/2.0.0-2.1.0.sql b/mysql/migration/2.0.0-2.1.0.sql
index ad23fba178b..b3549e05564 100644
--- a/mysql/migration/2.0.0-2.1.0.sql
+++ b/mysql/migration/2.0.0-2.1.0.sql
@@ -90,10 +90,11 @@ ALTER TABLE llx_facture_fourn_det ADD INDEX idx_facture_fourn_det_fk_facture (fk
ALTER TABLE llx_facture_fourn_det ADD CONSTRAINT fk_facture_fourn_det_fk_facture FOREIGN KEY (fk_facture_fourn) REFERENCES llx_facture_fourn (rowid);
-ALTER TABLE llx_facturedet ADD COLUMN total_ht real after price;
+ALTER TABLE llx_facturedet ADD COLUMN fk_remise_except integer NULL AFTER remise;
+ALTER TABLE llx_facturedet ADD COLUMN total_ht real AFTER price;
ALTER TABLE llx_facturedet ADD COLUMN total_tva real;
ALTER TABLE llx_facturedet ADD COLUMN total_ttc real;
-ALTER TABLE llx_facturedet ADD COLUMN info_bits integer DEFAULT 0 after date_end;
+ALTER TABLE llx_facturedet ADD COLUMN info_bits integer DEFAULT 0 AFTER date_end;
ALTER TABLE llx_commande ADD INDEX idx_commande_fk_soc (fk_soc);
@@ -202,8 +203,13 @@ ALTER TABLE llx_facture_rec ADD CONSTRAINT fk_facture_rec_fk_projet FORE
ALTER TABLE llx_facture_rec ADD UNIQUE INDEX idx_facture_rec_uk_titre (titre);
-alter table llx_commandedet add column coef real;
-alter table llx_propaldet add column coef real after price;
+ALTER TABLE llx_commandedet ADD COLUMN fk_remise_except integer NULL AFTER remise;
+ALTER TABLE llx_commandedet ADD COLUMN coef real;
+
+ALTER TABLE llx_propaldet ADD COLUMN fk_remise_except integer NULL AFTER remise;
+ALTER TABLE llx_propaldet ADD COLUMN coef real after price;
+
+ALTER TABLE llx_contratdet ADD COLUMN fk_remise_except integer NULL AFTER remise;
create table llx_livraison
(
diff --git a/mysql/tables/llx_commandedet.sql b/mysql/tables/llx_commandedet.sql
index 0d7623a884c..6af229907d6 100644
--- a/mysql/tables/llx_commandedet.sql
+++ b/mysql/tables/llx_commandedet.sql
@@ -30,6 +30,7 @@ create table llx_commandedet
qty real, -- quantité
remise_percent real DEFAULT 0, -- pourcentage de remise
remise real DEFAULT 0, -- montant de la remise
+ fk_remise_except integer NULL, -- Lien vers table des remises fixes
subprice real, -- prix avant remise
price real, -- prix final
coef real, -- coefficient de marge
diff --git a/mysql/tables/llx_contratdet.sql b/mysql/tables/llx_contratdet.sql
index 1f8f46e99e5..6c531042166 100644
--- a/mysql/tables/llx_contratdet.sql
+++ b/mysql/tables/llx_contratdet.sql
@@ -43,6 +43,7 @@ create table llx_contratdet
qty real, -- quantité
remise_percent real DEFAULT 0, -- pourcentage de remise
remise real DEFAULT 0, -- montant de la remise
+ fk_remise_except integer NULL, -- Lien vers table des remises fixes
subprice real, -- prix avant remise
price_ht real, -- prix final
diff --git a/mysql/tables/llx_facturedet.sql b/mysql/tables/llx_facturedet.sql
index 394609e495b..17a80b96a7d 100644
--- a/mysql/tables/llx_facturedet.sql
+++ b/mysql/tables/llx_facturedet.sql
@@ -30,6 +30,7 @@ create table llx_facturedet
qty real, -- Quantité (exemple 2)
remise_percent real DEFAULT 0, -- % de la remise ligne (exemple 20%)
remise real DEFAULT 0, -- Montant calculé de la remise % sur PU HT (exemple 20)
+ fk_remise_except integer NULL, -- Lien vers table des remises fixes
subprice real, -- P.U. HT (exemple 100)
price real, -- P.U. HT apres remise % de ligne
total_ht real, -- Total HT de la ligne toute quantité et incluant remise ligne et globale
diff --git a/mysql/tables/llx_propaldet.sql b/mysql/tables/llx_propaldet.sql
index c7dfbb218db..1f23be7931f 100644
--- a/mysql/tables/llx_propaldet.sql
+++ b/mysql/tables/llx_propaldet.sql
@@ -29,6 +29,7 @@ create table llx_propaldet
qty real, -- quantité
remise_percent real DEFAULT 0, -- pourcentage de remise
remise real DEFAULT 0, -- montant de la remise
+ fk_remise_except integer NULL, -- Lien vers table des remises fixes
subprice real, -- prix avant remise
price real, -- prix final
coef real, -- coefficient de marge