diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 48599a5bbf2..6e1bd41ea24 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2010-2019 Juanjo Menent * Copyright (C) 2014 Cedric Gross * Copyright (C) 2016 Florian Henry * Copyright (C) 2017 Ferran Marcet @@ -239,6 +239,16 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) $pu = "pu_" . $reg[1] . '_' . $reg[2]; // This is unit price including discount $fk_commandefourndet = "fk_commandefourndet_" . $reg[1] . '_' . $reg[2]; + if (! empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT )) { + if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) { + $dto = GETPOST("dto_" . $reg[1] . '_' . $reg[2]); + if (! empty($dto)) { + $unit_price = price2num(GETPOST("pu_" . $reg[1]) * (100 - $dto) / 100, 'MU'); + } + $saveprice = "saveprice_" . $reg[1] . '_' . $reg[2]; + } + } + // We ask to move a qty if (GETPOST($qty) != 0) { if (! (GETPOST($ent, 'int') > 0)) { @@ -254,6 +264,24 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) setEventMessages($object->error, $object->errors, 'errors'); $error ++; } + + if (! $error && ! empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) { + if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) { + $dto = GETPOST("dto_" . $reg[1] . '_' . $reg[2]); + //update supplier price + if (isset($_POST[$saveprice])) { + // TODO Use class + $sql = "UPDATE " . MAIN_DB_PREFIX . "product_fournisseur_price"; + $sql .= " SET unitprice='" . GETPOST($pu) . "'"; + $sql .= ", price=" . GETPOST($pu) . "*quantity"; + $sql .= ", remise_percent='" . $dto . "'"; + $sql .= " WHERE fk_soc=" . $object->socid; + $sql .= " AND fk_product=" . GETPOST($prod, 'int'); + + $resql = $db->query($sql); + } + } + } } } } @@ -552,6 +580,15 @@ if ($id > 0 || ! empty($ref)) { print '' . $langs->trans("QtyDispatchedShort") . ''; print '' . $langs->trans("QtyToDispatchShort") . ''; print ''; + + if (! empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT )) { + if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) { + print '' . $langs->trans("Price") . ''; + print '' . $langs->trans("ReductionShort") . ' (%)'; + print '' . $langs->trans("UpdatePrice") . ''; + } + } + print '' . $langs->trans("Warehouse") . ''; // Enable hooks to append additional columns @@ -760,6 +797,25 @@ if ($id > 0 || ! empty($ref)) { print ''; + if (! empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) { + if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) { + // Price + print ''; + print ''; + print ''; + + // Discount + print ''; + print ''; + print ''; + + // Save price + print ''; + print ''; + print ''; + } + } + // Warehouse print ''; if (count($listwarehouses) > 1) {