diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 2ada245ff8b..46b2f6a50ad 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -8,6 +8,7 @@ * Copyright (C) 2016 Florian Henry * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2018 Frédéric France + * Copyright (C) 2019 Christophe Battarel * * 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 @@ -51,6 +52,8 @@ $id = GETPOST("id", 'int'); $ref = GETPOST('ref'); $lineid = GETPOST('lineid', 'int'); $action = GETPOST('action', 'aZ09'); +$fk_default_warehouse = GETPOST('fk_default_warehouse', 'int'); + if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); @@ -236,6 +239,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) $prod = "product_".$reg[1].'_'.$reg[2]; $qty = "qty_".$reg[1].'_'.$reg[2]; $ent = "entrepot_".$reg[1].'_'.$reg[2]; + if (empty(GETPOST($ent))) $ent = $fk_default_warehouse; $pu = "pu_".$reg[1].'_'.$reg[2]; // This is unit price including discount $fk_commandefourndet = "fk_commandefourndet_".$reg[1].'_'.$reg[2]; @@ -484,9 +488,11 @@ if ($id > 0 || !empty($ref)) { if ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY - || $object->statut == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) { - $entrepot = new Entrepot($db); - $listwarehouses = $entrepot->list_array(1); + || $object->statut == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) + { + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + $formproduct = new FormProduct($db); + $formproduct->loadWarehouses(); if (empty($conf->reception->enabled))print '
'; else print ''; @@ -561,6 +567,23 @@ if ($id > 0 || !empty($ref)) { $i = 0; if ($num) { + $entrepot = new Entrepot($db); + $listwarehouses=$entrepot->list_array(1); + // entrepot par défaut + print $langs->trans("Warehouse").' : '; + if (count($listwarehouses)>1) + { + print $form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 1, 0, 0, '', 0, 0, $disabled); + } + elseif (count($listwarehouses)==1) + { + print $form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0, '', 0, 0, $disabled); + } + else + { + print $langs->trans("NoWarehouseDefined"); + } + print ''; print ''.$langs->trans("Description").''; @@ -897,6 +920,15 @@ if ($id > 0 || !empty($ref)) { dol_fiche_end(); + // traitement entrepot par défaut + print ''; // List of lines already dispatched $sql = "SELECT p.ref, p.label,";