diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index 1ad4612d879..bc87c2e65fc 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -56,7 +56,14 @@ if (GETPOST('action','aZ09') == 'setremise') { $object = new Societe($db); $object->fetch($id); - $result=$object->set_remise_client(price2num(GETPOST("remise")),GETPOST("note"),$user); + + $discount_type = GETPOST('discount_type', 'int'); + + if(! empty($discount_type)) { + $result=$object->set_remise_supplier(price2num(GETPOST("remise")),GETPOST("note"),$user); + } else { + $result=$object->set_remise_client(price2num(GETPOST("remise")),GETPOST("note"),$user); + } if ($result > 0) { @@ -100,6 +107,11 @@ if ($socid > 0) $head = societe_prepare_head($object); + $isCustomer = $object->client == 1 || $object->client == 3; + $isSupplier = $object->fournisseur == 1; + + $displayCustomer = $conf->global->MAIN_FEATURES_LEVEL <= 0 || $isCustomer; + $displaySupplier = $conf->global->MAIN_FEATURES_LEVEL > 0 && $isSupplier; print '
'; @@ -114,20 +126,58 @@ if ($socid > 0) print '
'; print '
'; + + if(! $displayCustomer && ! $displaySupplier) { + print '

'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'

'; + + dol_fiche_end(); + + print ''; + + llxFooter(); + $db->close(); + exit; + } + print ''; - // Discount - print '"; + if($displayCustomer) { + // Customer discount + print '"; + } + + if($displaySupplier) { + // Supplier discount + print '"; + } + print '
'; - print $langs->trans("CustomerRelativeDiscount").''.price2num($object->remise_percent)."%
'; + print $langs->trans("CustomerRelativeDiscount").''.price2num($object->remise_percent)."%
'; + print $langs->trans("SupplierRelativeDiscount").''.price2num($object->remise_supplier_percent)."%
'; print '
'; print load_fiche_titre($langs->trans("NewRelativeDiscount"),'',''); print '
'; + + if($conf->global->MAIN_FEATURES_LEVEL <= 0 || ($isCustomer && ! $isSupplier)) { + print ''; + } + + if($conf->global->MAIN_FEATURES_LEVEL > 0 && (! $isCustomer && $isSupplier)) { + print ''; + } print ''; + if($conf->global->MAIN_FEATURES_LEVEL > 0 && $isCustomer && $isSupplier) { + // Discount type + print ''; + print ''; + } + // New value print ''; @@ -155,57 +205,128 @@ if ($socid > 0) print '
'; + if($displayCustomer) { + if($displaySupplier) { + print '
'; + print '
'; + print load_fiche_titre($langs->trans("CustomerDiscounts"), '', ''); + } - /* - * List log of all percent discounts - */ - $sql = "SELECT rc.rowid, rc.remise_client as remise_percent, rc.note, rc.datec as dc,"; - $sql.= " u.login, u.rowid as user_id"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise as rc, ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE rc.fk_soc = " . $object->id; - $sql.= " AND rc.entity = " . $conf->entity; - $sql.= " AND u.rowid = rc.fk_user_author"; - $sql.= " ORDER BY rc.datec DESC"; - - $resql=$db->query($sql); - if ($resql) - { - print '
'.$langs->trans('DiscountType').' '; + print ' '; + print '
'; print $langs->trans("NewValue").'%
'; - $tag = !$tag; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $num = $db->num_rows($resql); - if ($num > 0) - { - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $i++; - } + /* + * List log of all customer percent discounts + */ + $sql = "SELECT rc.rowid, rc.remise_client as remise_percent, rc.note, rc.datec as dc,"; + $sql.= " u.login, u.rowid as user_id"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise as rc, ".MAIN_DB_PREFIX."user as u"; + $sql.= " WHERE rc.fk_soc = " . $object->id; + $sql.= " AND rc.entity = " . $conf->entity; + $sql.= " AND u.rowid = rc.fk_user_author"; + $sql.= " ORDER BY rc.datec DESC"; + + $resql=$db->query($sql); + if ($resql) + { + print '
'.$langs->trans("Date").''.$langs->trans("CustomerRelativeDiscountShort").''.$langs->trans("NoteReason").''.$langs->trans("User").'
'.dol_print_date($db->jdate($obj->dc),"dayhour").''.price2num($obj->remise_percent).'%'.$obj->note.''.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'
'; + $tag = !$tag; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $num = $db->num_rows($resql); + if ($num > 0) + { + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $i++; + } + } + else + { + print ''; + } + $db->free($resql); + print "
'.$langs->trans("Date").''.$langs->trans("CustomerRelativeDiscountShort").''.$langs->trans("NoteReason").''.$langs->trans("User").'
'.dol_print_date($db->jdate($obj->dc),"dayhour").''.price2num($obj->remise_percent).'%'.$obj->note.''.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'
'.$langs->trans("None").'
"; } else { - print ''.$langs->trans("None").''; - } - $db->free($resql); - print ""; - } - else - { - dol_print_error($db); + dol_print_error($db); + } } + if($displaySupplier) { + if($displayCustomer) { + print '
'; // class="fichehalfleft" + print '
'; + print '
'; + print load_fiche_titre($langs->trans("SupplierDiscounts"), '', ''); + } + + /* + * List log of all supplier percent discounts + */ + $sql = "SELECT rc.rowid, rc.remise_supplier as remise_percent, rc.note, rc.datec as dc,"; + $sql.= " u.login, u.rowid as user_id"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_supplier as rc, ".MAIN_DB_PREFIX."user as u"; + $sql.= " WHERE rc.fk_soc = " . $object->id; + $sql.= " AND rc.entity = " . $conf->entity; + $sql.= " AND u.rowid = rc.fk_user_author"; + $sql.= " ORDER BY rc.datec DESC"; + + $resql=$db->query($sql); + if ($resql) + { + print ''; + $tag = !$tag; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $num = $db->num_rows($resql); + if ($num > 0) + { + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $i++; + } + } + else + { + print ''; + } + $db->free($resql); + print "
'.$langs->trans("Date").''.$langs->trans("CustomerRelativeDiscountShort").''.$langs->trans("NoteReason").''.$langs->trans("User").'
'.dol_print_date($db->jdate($obj->dc),"dayhour").''.price2num($obj->remise_percent).'%'.$obj->note.''.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'
'.$langs->trans("None").'
"; + } + else + { + dol_print_error($db); + } + + if($displayCustomer) { + print '
'; // class="ficheaddleft" + print '
'; // class="fichehalfright" + print ''; // class="fichecenter" + } + } } llxFooter(); diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index d26a31b3cd2..103e557eb7c 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -322,8 +322,12 @@ else { print $form->selectUnits($line->fk_unit, "units"); print ''; } + $remise_percent = $buyer->remise_percent; + if($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') { + $remise_percent = $seller->remise_supplier_percent; + } ?> - remise_percent); ?>">% + ">% situation_cycle_ref) { $coldisplay++; diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 60f745d95c7..1929c11a464 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -257,6 +257,19 @@ if ($object->id > 0) print ''; if($conf->global->MAIN_FEATURES_LEVEL > 0) { + // Relative discounts (Discounts-Drawbacks-Rebates) + print ''; + print '
'; + print $langs->trans("CustomerRelativeDiscountShort"); + print ''; + if ($user->rights->societe->creer && !$user->societe_id > 0) + { + print ''.img_edit($langs->trans("Modify")).''; + } + print '
'; + print ''.($object->remise_supplier_percent?''.$object->remise_supplier_percent.'%':'').''; + print ''; + // Absolute discounts (Discounts-Drawbacks-Rebates) print ''; print ''; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 0111a8d11c7..88d654a8924 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1398,7 +1398,7 @@ if ($action=='create') $availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0)); $shipping_method_id = (! empty($objectsrc->shipping_method_id)?$objectsrc->shipping_method_id:(! empty($soc->shipping_method_id)?$soc->shipping_method_id:0)); $demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0)); - $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); + $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_supplier_percent)?$soc->remise_supplier_percent:0)); $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; @@ -1436,7 +1436,7 @@ if ($action=='create') print ''; print ''; print '' . "\n"; - print ''; + print ''; print ''; print ''; if (!empty($currency_tx)) print ''; @@ -1479,17 +1479,16 @@ if ($action=='create') if ($conf->global->MAIN_FEATURES_LEVEL > 0 && $societe->id > 0) { -/* // TODO handle supplier relative discount // Discounts for third party print ''; } - + // Label print ''; print ''; diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index bfc2c79a679..4071356c982 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -35,4 +35,17 @@ ALTER TABLE llx_projet ADD COLUMN bill_time integer DEFAULT 0; ALTER TABLE llx_societe ADD COLUMN order_min_amount double(24,8) DEFAULT NULL AFTER outstanding_limit; ALTER TABLE llx_societe ADD COLUMN supplier_order_min_amount double(24,8) DEFAULT NULL AFTER order_min_amount; -ALTER TABLE llx_societe_remise_except ADD COLUMN discount_type integer DEFAULT 0 NOT NULL AFTER fk_soc; \ No newline at end of file +ALTER TABLE llx_societe_remise_except ADD COLUMN discount_type integer DEFAULT 0 NOT NULL AFTER fk_soc; +ALTER TABLE llx_societe ADD COLUMN remise_supplier real DEFAULT 0 AFTER remise_client; +CREATE TABLE llx_societe_remise_supplier +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id + fk_soc integer NOT NULL, + tms timestamp, + datec datetime, -- creation date + fk_user_author integer, -- creation user + remise_supplier double(6,3) DEFAULT 0 NOT NULL, -- discount + note text + +)ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 9ffb9734d7f..f1714021fb8 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -78,6 +78,7 @@ create table llx_societe customer_rate real DEFAULT 0, -- taux fiabilite client (0 a 1) supplier_rate real DEFAULT 0, -- taux fiabilite fournisseur (0 a 1) remise_client real DEFAULT 0, -- remise systematique pour le client + remise_supplier real DEFAULT 0, -- remise systematique auprès du fournisseur mode_reglement tinyint, -- mode de reglement cond_reglement tinyint, -- condition de reglement mode_reglement_supplier tinyint, -- mode de reglement fournisseur diff --git a/htdocs/install/mysql/tables/llx_societe_remise_supplier.sql b/htdocs/install/mysql/tables/llx_societe_remise_supplier.sql new file mode 100644 index 00000000000..c1b56f225c7 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_societe_remise_supplier.sql @@ -0,0 +1,34 @@ +-- ======================================================================== +-- Copyright (C) 2000-2004 Rodolphe Quiedeville +-- Copyright (C) 2011-2016 Regis Houssin +-- +-- 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 +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- +-- Historique evolution de la remise relative des tiers +-- ======================================================================== + +create table llx_societe_remise_supplier +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id + fk_soc integer NOT NULL, + tms timestamp, + datec datetime, -- creation date + fk_user_author integer, -- creation user + remise_supplier double(6,3) DEFAULT 0 NOT NULL, -- discount + note text + +)ENGINE=innodb; + diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index dde515c0223..aab3ee183da 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -268,6 +268,8 @@ CustomerRelativeDiscountShort=Relative discount CustomerAbsoluteDiscountShort=Absolute discount CompanyHasRelativeDiscount=This customer has a default discount of %s%% CompanyHasNoRelativeDiscount=This customer has no relative discount by default +HasRelativeDiscountFromSupplier=You have a default discount of %s%% from this supplier +HasNoRelativeDiscountFromSupplier=You have no default relative discount from this supplier CompanyHasAbsoluteDiscount=This customer has discount available (credits notes or down payments) for %s %s CompanyHasDownPaymentOrCommercialDiscount=This customer has discount available (commercial, down payments) for %s %s CompanyHasCreditNote=This customer still has credit notes for %s %s diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index dcacf89d643..94fe7436041 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -149,7 +149,7 @@ if (empty($reshook)) $listofproperties=array( 'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'url', 'barcode', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', - 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis', + 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis', 'stcomm_id', 'outstanding_limit', 'price_level', 'parent', 'default_lang', 'ref', 'ref_ext', 'import_key', 'fk_incoterms', 'fk_multicurrency', 'code_client', 'code_fournisseur', 'code_compta', 'code_compta_fournisseur', 'model_pdf', 'fk_projet' diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 49901c420f0..1cdfabf7fca 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -314,7 +314,7 @@ class Thirdparties extends DolibarrApi $listofproperties=array( 'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'url', 'barcode', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', - 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis', + 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis', 'stcomm_id', 'outstanding_limit', 'price_level', 'parent', 'default_lang', 'ref', 'ref_ext', 'import_key', 'fk_incoterms', 'fk_multicurrency', 'code_client', 'code_fournisseur', 'code_compta', 'code_compta_fournisseur', 'model_pdf', 'fk_projet' diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 4bf2dbd0dab..ddf6f5c509a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -234,6 +234,7 @@ class Societe extends CommonObject var $forme_juridique; var $remise_percent; + var $remise_supplier_percent; var $mode_reglement_supplier_id; var $cond_reglement_supplier_id; var $fk_prospectlevel; @@ -1143,7 +1144,7 @@ class Societe extends CommonObject $sql .= ', s.fk_forme_juridique as forme_juridique_code'; $sql .= ', s.webservices_url, s.webservices_key'; $sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode'; - $sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.fk_account, s.tva_assuj'; + $sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.remise_supplier, s.mode_reglement, s.cond_reglement, s.fk_account, s.tva_assuj'; $sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo'; $sql .= ', s.fk_shipping_method'; $sql .= ', s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms'; @@ -1275,6 +1276,7 @@ class Societe extends CommonObject $this->prefix_comm = $obj->prefix_comm; $this->remise_percent = $obj->remise_client; + $this->remise_supplier_percent = $obj->remise_supplier; $this->mode_reglement_id = $obj->mode_reglement; $this->cond_reglement_id = $obj->cond_reglement; $this->mode_reglement_supplier_id = $obj->mode_reglement_supplier; @@ -1657,6 +1659,67 @@ class Societe extends CommonObject return 1; } } + + /** + * Definit la societe comme un client + * + * @param float $remise Valeur en % de la remise + * @param string $note Note/Motif de modification de la remise + * @param User $user Utilisateur qui definie la remise + * @return int <0 if KO, >0 if OK + */ + function set_remise_supplier($remise, $note, User $user) + { + global $conf, $langs; + + // Nettoyage parametres + $note=trim($note); + if (! $note) + { + $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("NoteReason")); + return -2; + } + + dol_syslog(get_class($this)."::set_remise_supplier ".$remise.", ".$note.", ".$user->id); + + if ($this->id) + { + $this->db->begin(); + + $now=dol_now(); + + // Positionne remise courante + $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; + $sql.= " SET remise_supplier = '".$this->db->escape($remise)."'"; + $sql.= " WHERE rowid = " . $this->id; + $resql=$this->db->query($sql); + if (! $resql) + { + $this->db->rollback(); + $this->error=$this->db->error(); + return -1; + } + + // Ecrit trace dans historique des remises + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_supplier"; + $sql.= " (entity, datec, fk_soc, remise_supplier, note, fk_user_author)"; + $sql.= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',"; + $sql.= " '".$this->db->escape($note)."',"; + $sql.= " ".$user->id; + $sql.= ")"; + + $resql=$this->db->query($sql); + if (! $resql) + { + $this->db->rollback(); + $this->error=$this->db->lasterror(); + return -1; + } + + $this->db->commit(); + return 1; + } + } /** * Add a discount for third party diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 259d3d0a5ca..93bf576ef71 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -995,7 +995,7 @@ if ($action == 'create') $cond_reglement_id = (! empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(! empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); $mode_reglement_id = (! empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(! empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); - $remise_percent = (! empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(! empty($soc->remise_percent)?$soc->remise_percent:0)); + $remise_percent = (! empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(! empty($soc->remise_supplier_percent)?$soc->remise_supplier_percent:0)); $remise_absolue = (! empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0)); // Replicate extrafields @@ -1052,15 +1052,15 @@ if ($action == 'create') { // Discounts for third party print '
' . $langs->trans('Discounts') . ''; - if ($societe->remise_percent) - print $langs->trans("CompanyHasRelativeDiscount", '' . $societe->remise_percent . ''); + if ($societe->remise_supplier_percent) + print $langs->trans("HasRelativeDiscountFromSupplier", '' . $societe->remise_supplier_percent . ''); else - print $langs->trans("CompanyHasNoRelativeDiscount"); + print $langs->trans("HasNoRelativeDiscountFromSupplier"); print ' (' . $langs->trans("EditRelativeDiscount") . ')'; print '. '; print '
'; -*/ + $absolute_discount = $societe->getAvailableDiscounts('', '', 0, 1); if ($absolute_discount) @@ -1897,13 +1896,13 @@ elseif (! empty($object->id)) $addcreditnote = '' . $langs->trans("AddCreditNote") . ''; print '
' . $langs->trans('Discounts') . ''; -/* // TODO handle supplier relative discount - if ($societe->remise_percent) - print $langs->trans("CompanyHasRelativeDiscount", $societe->remise_percent); + + if ($societe->remise_supplier_percent) + print $langs->trans("HasRelativeDiscountFromSupplier", $societe->remise_supplier_percent); else - print $langs->trans("CompanyHasNoRelativeDiscount"); + print $langs->trans("HasNoRelativeDiscountFromSupplier"); print '. '; -*/ + $absolute_discount = $societe->getAvailableDiscounts('', $filterabsolutediscount, 0, 1); $absolute_creditnote = $societe->getAvailableDiscounts('', $filtercreditnote, 0, 1); $absolute_discount = price2num($absolute_discount, 'MT'); @@ -1913,7 +1912,7 @@ elseif (! empty($object->id)) print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency)); } else { // Remise dispo de type remise fixe (not credit note) -// print '
'; + print '
'; $form->form_remise_dispo($_SERVER["PHP_SELF"] . '?id=' . $object->id, 0, 'remise_id', $societe->id, $absolute_discount, $filterabsolutediscount, 0, '', 1, 1); } } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index c1c04489f1d..b1efc5cbfa5 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1625,7 +1625,7 @@ if ($action == 'create') $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_supplier_id)?$soc->cond_reglement_supplier_id:1)); $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_supplier_id)?$soc->mode_reglement_supplier_id:0)); $fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); - $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); + $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_supplier_percent)?$soc->remise_supplier_percent:0)); $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; @@ -1917,15 +1917,15 @@ if ($action == 'create') { // Discounts for third party print '
' . $langs->trans('Discounts') . ''; -/* // TODO handle supplier relative discount - if ($societe->remise_percent) - print $langs->trans("CompanyHasRelativeDiscount", '' . $societe->remise_percent . ''); + + if ($societe->remise_supplier_percent) + print $langs->trans("HasRelativeDiscountFromSupplier", '' . $societe->remise_supplier_percent . ''); else - print $langs->trans("CompanyHasNoRelativeDiscount"); + print $langs->trans("HasNoRelativeDiscountFromSupplier"); print ' (' . $langs->trans("EditRelativeDiscount") . ')'; print '. '; print '
'; -*/ + if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount", '' . price($absolute_discount) . '', $langs->trans("Currency" . $conf->currency)); else @@ -2428,17 +2428,17 @@ else print '
' . $langs->trans('Discounts'); print ''; -/* // TODO handle supplier relative discount - if ($societe->remise_percent) - print $langs->trans("CompanyHasRelativeDiscount", $societe->remise_percent); + + if ($societe->remise_supplier_percent) + print $langs->trans("HasRelativeDiscountFromSupplier", $societe->remise_supplier_percent); else - print $langs->trans("CompanyHasNoRelativeDiscount"); - print ' ('.$addrelativediscount.')'; -*/ + print $langs->trans("HasNoRelativeDiscountFromSupplier"); + // print ' ('.$addrelativediscount.')'; + // Is there is commercial discount or down payment available ? if ($absolute_discount > 0) { -// print '. '; + print '. '; if ($object->statut > 0 || $object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT) { if ($object->statut == 0) { print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency)); @@ -2446,7 +2446,7 @@ else } else { if ($object->statut < 1 || $object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT) { $text = $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency)); - print '' . $text . '.
'; + print '
' . $text . '.
'; } else { $text = $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency)); $text2 = $langs->trans("AbsoluteDiscountUse"); @@ -2455,7 +2455,7 @@ else } } else { // Discount available of type fixed amount (not credit note) -// print '
'; + print '
'; $form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, GETPOST('discountid'), 'remise_id', $societe->id, $absolute_discount, $filterabsolutediscount, $resteapayer, ' (' . $addabsolutediscount . ')', 0, 1); } } else { @@ -2463,10 +2463,11 @@ else { if ($object->statut == FactureFournisseur::STATUS_DRAFT && $object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $object->type != FactureFournisseur::TYPE_DEPOSIT) print ' (' . $addabsolutediscount . ')
'; -// else -// print '. '; - } else - print '. '; + else + print '. '; + } + else + print '. '; } // Is there credit notes availables ? if ($absolute_creditnote > 0) @@ -2481,7 +2482,7 @@ else } } else { // We can add a credit note on a down payment or standard invoice or situation invoice // There is credit notes discounts available -// if (! $absolute_discount) print '
'; + if (! $absolute_discount) print '
'; // $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $societe->id, $absolute_creditnote, $filtercreditnote, $resteapayer, '', 0, 1); $more=' ('.$addcreditnote. (($addcreditnote && $viewabsolutediscount) ? ' - ' : '') . $viewabsolutediscount . ')'; $form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, 0, 'remise_id_for_payment', $societe->id, $absolute_creditnote, $filtercreditnote, 0, $more, 0, 1); // We allow credit note even if amount is higher @@ -2503,7 +2504,7 @@ else // } print '
'.$form->editfieldkey("Label",'label',$object->label,$object,($user->rights->fournisseur->facture->creer)).'
' . $langs->trans('Discounts') . ''; -/* // TODO handle supplier relative discount - if ($soc->remise_percent) - print $langs->trans("CompanyHasRelativeDiscount", '' . $soc->remise_percent . ''); + + if ($soc->remise_supplier_percent) + print $langs->trans("HasRelativeDiscountFromSupplier", '' . $soc->remise_supplier_percent . ''); else - print $langs->trans("CompanyHasNoRelativeDiscount"); + print $langs->trans("HasNoRelativeDiscountFromSupplier"); print ' (' . $langs->trans("EditRelativeDiscount") . ')'; print '. '; print '
'; -*/ + $absolute_discount = $soc->getAvailableDiscounts('', '', 0, 1); if ($absolute_discount) @@ -1427,13 +1427,13 @@ if ($action == 'create') $addcreditnote = '' . $langs->trans("AddCreditNote") . ''; print '
' . $langs->trans('Discounts') . ''; -/* // TODO handle supplier relative discount - if ($soc->remise_percent) - print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent); + + if ($soc->remise_supplier_percent) + print $langs->trans("HasRelativeDiscountFromSupplier", $soc->remise_supplier_percent); else - print $langs->trans("CompanyHasNoRelativeDiscount"); + print $langs->trans("HasNoRelativeDiscountFromSupplier"); print '. '; -*/ + $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount, 0, 1); $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote, 0, 1); $absolute_discount = price2num($absolute_discount, 'MT'); @@ -1443,7 +1443,7 @@ if ($action == 'create') print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency)); } else { // Remise dispo de type remise fixe (not credit note) -// print '
'; + print '
'; $form->form_remise_dispo($_SERVER["PHP_SELF"] . '?id=' . $object->id, 0, 'remise_id', $soc->id, $absolute_discount, $filterabsolutediscount, 0, '', 1, 1); } }