diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql index e32bacf6d9f..aea6868f42a 100755 --- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql +++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql @@ -800,3 +800,6 @@ ALTER TABLE llx_product_price_by_qty ADD UNIQUE INDEX uk_product_price_by_qty_le ALTER TABLE llx_product_price_by_qty ADD INDEX idx_product_price_by_qty_fk_product_price (fk_product_price); ALTER TABLE llx_product_price_by_qty ADD CONSTRAINT fk_product_price_by_qty_fk_product_price FOREIGN KEY (fk_product_price) REFERENCES llx_product_price (rowid); + +ALTER TABLE `llx_product_price_by_qty` ADD `remise_percent` DOUBLE NOT NULL DEFAULT '0' AFTER `price_ttc` , +ADD `remise` DOUBLE NOT NULL DEFAULT '0' AFTER `remise_percent`; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_product_price_by_qty.sql b/htdocs/install/mysql/tables/llx_product_price_by_qty.sql index c101a211310..e0585786235 100644 --- a/htdocs/install/mysql/tables/llx_product_price_by_qty.sql +++ b/htdocs/install/mysql/tables/llx_product_price_by_qty.sql @@ -26,5 +26,7 @@ create table llx_product_price_by_qty date_price timestamp, price double (24,8) DEFAULT 0, price_ttc double (24,8) DEFAULT 0, + remise_percent double NOT NULL DEFAULT 0, + remise double NOT NULL DEFAULT 0, qty_min real DEFAULT 1 )ENGINE=innodb; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index fb68e2e6472..ecedea4a10d 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1203,7 +1203,7 @@ class Product extends CommonObject // Récuperation de la liste des prix selon qty si flag positionné if ($this->prices_by_qty[$i] == 1) { - $sql = "SELECT rowid,price, price_ttc,qty_min"; + $sql = "SELECT rowid,price, price_ttc, qty_min, remise_percent, remise"; $sql.= " FROM ".MAIN_DB_PREFIX."product_price_by_qty"; $sql.= " WHERE fk_product_price = '".$this->prices_by_qty_id[$i]."'"; $sql.= " ORDER BY qty_min ASC"; @@ -1218,6 +1218,8 @@ class Product extends CommonObject $resultat[$ii]["price"]= $result["price"]; $resultat[$ii]["price_ttc"]= $result["price_ttc"]; $resultat[$ii]["qty_min"]= $result["qty_min"]; + $resultat[$ii]["remise_percent"]= $result["remise_percent"]; + $resultat[$ii]["remise"]= $result["remise"]; $ii++; } $this->prices_by_qty_list[$i]=$resultat; @@ -1254,7 +1256,7 @@ class Product extends CommonObject // Récuperation de la liste des prix selon qty si flag positionné if ($this->prices_by_qty[0] == 1) { - $sql = "SELECT rowid,price, price_ttc,qty_min"; + $sql = "SELECT rowid,price, price_ttc, qty_min, remise_percent, remise"; $sql.= " FROM ".MAIN_DB_PREFIX."product_price_by_qty"; $sql.= " WHERE fk_product_price = '".$this->prices_by_qty_id[0]."'"; $sql.= " ORDER BY qty_min ASC"; @@ -1269,6 +1271,8 @@ class Product extends CommonObject $resultat[$ii]["price"]= $result["price"]; $resultat[$ii]["price_ttc"]= $result["price_ttc"]; $resultat[$ii]["qty_min"]= $result["qty_min"]; + $resultat[$ii]["remise_percent"]= $result["remise_percent"]; + $resultat[$ii]["remise"]= $result["remise"]; $ii++; } $this->prices_by_qty_list[0]=$resultat; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 2ff0a751e99..42d6712be52 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -126,8 +126,10 @@ if ($action == 'update_price_by_qty') { // Ajout / Mise à jour d'un prix par qu $rowid = GETPOST('rowid'); $priceid=GETPOST('priceid'); $newprice=price2num(GETPOST("price"),'MU'); - //$newminprice=price2num(GETPOST("price_min"),'MU'); // TODO : Add min price management and discount management + //$newminprice=price2num(GETPOST("price_min"),'MU'); // TODO : Add min price management $qtymin=GETPOST('qty_min'); + $remise_percent=price2num(GETPOST('remise_percent')); + $remise=0; // TODO : allow dicsoun by amount when available on documents // Calcul des prix (HT et TTC) if ($newprice!='' || $newprice==0) @@ -176,13 +178,15 @@ if ($action == 'update_price_by_qty') { // Ajout / Mise à jour d'un prix par qu $sql = "UPDATE ".MAIN_DB_PREFIX."product_price_by_qty SET"; $sql.= " price='".$price."',"; $sql.= " price_ttc=".$price_ttc.","; - $sql.= " qty_min=".$qtymin; + $sql.= " qty_min=".$qtymin.","; + $sql.= " remise_percent=".$remise_percent.","; + $sql.= " remise=".$remise; $sql.= " WHERE rowid = ".GETPOST('rowid'); $result = $db->query($sql); } else { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price_by_qty (fk_product_price,price,price_ttc,qty_min) values ("; - $sql.= $priceid.','.$price.','.$price_ttc.','.$qtymin.')'; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price_by_qty (fk_product_price,price,price_ttc,qty_min,remise_percent,remise) values ("; + $sql.= $priceid.','.$price.','.$price_ttc.','.$qtymin.','.$remise_percent.','.$remise.')'; $result = $db->query($sql); } @@ -349,6 +353,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print ''.$langs->trans("PriceByQuantityRange").' '.$i.''; print ''.$langs->trans("HT").''; print ''.$langs->trans("TTC").''; + print ''.$langs->trans("Discount").''; print ' '; print ''; foreach ($object->prices_by_qty_list[$i] as $ii=> $prices) { @@ -359,8 +364,9 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print ''; print ''; print ''; - print ' '.$object->price_base_type.''; - print ' '; + print ' '.$object->price_base_type.''; + //print ' '; + print '< %/td>'; print ''; print ''; print ''; @@ -369,6 +375,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print ''.$prices['qty_min'].''; print ''.price($prices['price']).''; print ''.price($prices['price_ttc']).''; + print ''.price($prices['remise_percent']).' %'; print ''; if(($user->rights->produit->creer || $user->rights->service->creer)) { print ''; @@ -382,15 +389,16 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print ''; } } - if($action != 'edit_price_by_qty') { + if($action != 'edit_price_by_qty' && ($user->rights->produit->creer || $user->rights->service->creer)) { print '
'; print ''; print ''; print ''; print ''; print ''; - print ' '.$object->price_base_type.''; - print ' '; + print ' '.$object->price_base_type.''; + //print ' '; + print ' %'; print ''; print ''; print '
'; @@ -449,6 +457,7 @@ else print ''.$langs->trans("PriceByQuantityRange").''; print ''.$langs->trans("HT").''; print ''.$langs->trans("TTC").''; + print ''.$langs->trans("Discount").''; print ' '; print ''; foreach ($object->prices_by_qty_list[0] as $ii=> $prices) { @@ -459,8 +468,9 @@ else print ''; print ''; print ''; - print ' '.$object->price_base_type.''; - print ' '; + print ' '.$object->price_base_type.''; + //print ' '; + print ' %'; print ''; print ''; print ''; @@ -469,6 +479,7 @@ else print ''.$prices['qty_min'].''; print ''.price($prices['price']).''; print ''.price($prices['price_ttc']).''; + print ''.price($prices['remise_percent']).' %'; print ''; if(($user->rights->produit->creer || $user->rights->service->creer)) { print '
'; @@ -489,8 +500,9 @@ else print ''; print ''; print ''; - print ' '.$object->price_base_type.''; - print ' '; + print ' '.$object->price_base_type.''; + //print ' '; + print ' %'; print ''; print ''; print '';