diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 603d7778aa9..15a88dea730 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -216,6 +216,7 @@ print ''."\n"; $found = 0; +print ''; print ''; print ''.$langs->trans("DeStockOnBill").''; print ''; @@ -237,6 +238,7 @@ print "\n\n"; $found++; +print ''; print ''; print ''.$langs->trans("DeStockOnValidateOrder").''; print ''; @@ -260,6 +262,7 @@ $found++; //if (isModEnabled('expedition')) //{ +print ''; print ''; print ''.$langs->trans("DeStockOnShipment").''; print ''; @@ -276,7 +279,7 @@ if (isModEnabled("expedition")) { print "\n\n"; $found++; - +print ''; print ''; print ''.$langs->trans("DeStockOnShipmentOnClosing").''; print ''; @@ -309,6 +312,7 @@ print ''."\n"; $found = 0; +print ''; print ''; print ''.$langs->trans("ReStockOnBill").''; print ''; @@ -330,7 +334,7 @@ print "\n\n"; $found++; - +print ''; print ''; print ''.$langs->trans("ReStockOnValidateOrder").''; print ''; @@ -352,6 +356,7 @@ print "\n\n"; $found++; if (isModEnabled("reception")) { + print ''; print ''; print ''.$langs->trans("StockOnReception").''; print ''; @@ -380,6 +385,7 @@ if (isModEnabled("reception")) { print "\n\n"; $found++; } else { + print ''; print ''; print ''.$langs->trans("ReStockOnDispatchOrder").''; print ''; diff --git a/htdocs/core/lib/reception.lib.php b/htdocs/core/lib/reception.lib.php index 6cdbe2cd5eb..2b4944c99f2 100644 --- a/htdocs/core/lib/reception.lib.php +++ b/htdocs/core/lib/reception.lib.php @@ -46,7 +46,7 @@ function reception_prepare_head(Reception $object) $head[$h][2] = 'reception'; $h++; - if ($object->statut == Reception::STATUS_DRAFT) { + if ($object->statut == Reception::STATUS_DRAFT || ($object->statut == Reception::STATUS_VALIDATED && empty($conf->global->STOCK_CALCULATE_ON_RECEPTION))) { $head[$h][0] = DOL_URL_ROOT."/reception/dispatch.php?id=".$object->id; $head[$h][1] = $langs->trans("ReceptionDistribution"); $head[$h][2] = 'dispatch'; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 79dec7b7ebd..318d66635ec 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -2532,6 +2532,10 @@ if ($action == 'create') { // TODO Show also lines ordered but not delivered + if (empty($num_prod)) { + print ''.$langs->trans("NoLineGoOnTabToAddSome", $langs->transnoentitiesnoconv("ShipmentDistribution")).''; + } + print "\n"; print ''; print ''; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index dd79f20bea4..df4b92fe76f 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -757,7 +757,7 @@ class Expedition extends CommonObject // If stock increment is done on sending (recommanded choice) if (!$error && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) { - $result = $this->manageStockMvtOnEvt($user); + $result = $this->manageStockMvtOnEvt($user, "ShipmentValidatedInDolibarr"); if ($result < 0) { return -2; } @@ -1091,14 +1091,11 @@ class Expedition extends CommonObject $this->model_pdf = trim($this->model_pdf); } - - // Check parameters // Put here code to add control on parameters values // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; - $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").","; $sql .= " ref_ext=".(isset($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null").","; $sql .= " ref_customer=".(isset($this->ref_customer) ? "'".$this->db->escape($this->ref_customer)."'" : "null").","; @@ -1124,7 +1121,6 @@ class Expedition extends CommonObject $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; $sql .= " model_pdf=".(isset($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null").","; $sql .= " entity=".$conf->entity; - $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); @@ -1596,11 +1592,12 @@ class Expedition extends CommonObject while ($i < $num) { $obj = $this->db->fetch_object($resql); + if ($originline > 0 && $originline == $obj->fk_origin_line) { $line->entrepot_id = 0; // entrepod_id in details_entrepot $line->qty_shipped += $obj->qty_shipped; } else { - $line = new ExpeditionLigne($this->db); + $line = new ExpeditionLigne($this->db); // new group to start $line->entrepot_id = $obj->fk_entrepot; // this is a property of a shipment line $line->qty_shipped = $obj->qty_shipped; // this is a property of a shipment line } @@ -2196,12 +2193,14 @@ class Expedition extends CommonObject /** * Manage Stock MVt onb Close or valid Shipment - * @param User $user Object user that modify - * @return int <0 if ko, >0 if ok + * + * @param User $user Object user that modify + * @param string $labelmovement Label of movement + * @return int <0 if KO, >0 if OK * @throws Exception * */ - private function manageStockMvtOnEvt($user) + private function manageStockMvtOnEvt($user, $labelmovement = 'ShipmentClassifyClosedInDolibarr') { global $langs; @@ -2248,7 +2247,7 @@ class Expedition extends CommonObject // line without batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr", $obj->ref)); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans($labelmovement, $obj->ref)); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -2259,7 +2258,7 @@ class Expedition extends CommonObject // line with batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr", $obj->ref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans($labelmovement, $obj->ref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; diff --git a/htdocs/expedition/dispatch.php b/htdocs/expedition/dispatch.php index 25c0295e2ab..01b98c22a0c 100644 --- a/htdocs/expedition/dispatch.php +++ b/htdocs/expedition/dispatch.php @@ -25,9 +25,9 @@ */ /** - * \file htdocs/expedition/dispatch.php + * \file htdocs/expedition/dispatch.php * \ingroup expedition - * \brief Page to dispatch shipments + * \brief Page to dispatch shipments */ // Load Dolibarr environment @@ -60,6 +60,9 @@ $fk_default_warehouse = GETPOST('fk_default_warehouse', 'int'); $cancel = GETPOST('cancel', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); +$error = 0; +$errors = array(); + if ($user->socid) { $socid = $user->socid; } @@ -75,6 +78,7 @@ if (GETPOSTISSET("projectid")) { $object = new Expedition($db); $objectorder = new Commande($db); + if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); if ($result <= 0) { @@ -271,8 +275,9 @@ if ($action == 'updatelines' && $usercancreate) { } } - // If module stock is enabled and the stock increase is done on purchase order dispatching - if (!$error && GETPOST($ent, 'int') > 0 && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { + // If module stock is enabled and the stock decrease is done on edtion of this page + /* + if (!$error && GETPOST($ent, 'int') > 0 && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_DISPATCH_ORDER)) { $mouv = new MouvementStock($db); $product = GETPOST($prod, 'int'); $entrepot = GETPOST($ent, 'int'); @@ -307,6 +312,7 @@ if ($action == 'updatelines' && $usercancreate) { } } } + */ } } } @@ -317,6 +323,9 @@ if ($action == 'updatelines' && $usercancreate) { } else { $db->commit(); setEventMessages($langs->trans("ReceptionUpdated"), null); + + header("Location: ".DOL_URL_ROOT.'/expedition/dispatch.php?id='.$object->id); + exit; } } elseif ($action == 'setdate_livraison' && $usercancreate) { $datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); @@ -346,7 +355,8 @@ $morejs = array('/expedition/js/lib_dispatch.js.php'); llxHeader('', $title, $help_url, '', 0, 0, $morejs); if ($object->id > 0 || !empty($object->ref)) { - $lines = $object->lines; + $lines = $object->lines; // This is an array of detail of line, on line per source order line found intolines[]->fk_origin_line, then each line may have sub data + //var_dump($lines[0]->fk_origin_line); exit; $num_prod = count($lines); @@ -493,7 +503,7 @@ if ($object->id > 0 || !empty($object->ref)) { print '
'; $disabled = 0; // This is used to disable or not the bulk selection of target warehouse. No reason to have it disabled so forced to 0. - if ($object->statut == Reception::STATUS_DRAFT) { + if ($object->statut == Expedition::STATUS_DRAFT) { require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); $formproduct->loadWarehouses(); @@ -847,8 +857,10 @@ if ($object->id > 0 || !empty($object->ref)) { } // Qty to dispatch print ''; - print ''.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').''; - print ''; + print ''.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').''; + $suggestedvalue = (GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : $objd->qty); + //var_dump($suggestedvalue);exit; + print ''; print ''; print ''; if (isModEnabled('productbatch') && $objp->tobatch > 0) { @@ -991,7 +1003,7 @@ if ($object->id > 0 || !empty($object->ref)) { } // Qty to dispatch print ''; - print ''.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').''; + print ''.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').''; $amounttosuggest = (GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : (empty($conf->global->SUPPLIER_ORDER_DISPATCH_FORCE_QTY_INPUT_TO_ZERO) ? $remaintodispatch : 0)); if (count($products_dispatched)) { // There is already existing lines into llx_expeditiondet, this means a plan for the shipment has already been started. @@ -1055,14 +1067,14 @@ if ($object->id > 0 || !empty($object->ref)) { print ''; if ($nbproduct) { - $checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv('StatusOrderReceivedAll')); + //$checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv('StatusOrderReceivedAll')); print '
'; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if (empty($reshook)) { - if (empty($conf->reception->enabled)) { + /*if (empty($conf->reception->enabled)) { print $langs->trans("Comment").' : '; print 'trans("DispatchSupplierOrder", $object->ref); @@ -1075,6 +1087,8 @@ if ($object->id > 0 || !empty($object->ref)) { $dispatchBt = empty($conf->reception->enabled) ? $langs->trans("Receive") : $langs->trans("CreateReception"); print '
'; + */ + print 'id > 0 || !empty($object->ref)) { print ''; diff --git a/htdocs/reception/note.php b/htdocs/reception/note.php index b227a3e4a43..bbcd91e32a2 100644 --- a/htdocs/reception/note.php +++ b/htdocs/reception/note.php @@ -83,22 +83,18 @@ if (isModEnabled("reception")) { } $permissionnote = $user->rights->reception->creer; // Used by the include of actions_setnotes.inc.php +// TODO Test on reception module on only if ($origin == 'reception') { $result = restrictedArea($user, $origin, $object->id); } else { - if ($origin == 'reception') { - $result = restrictedArea($user, $origin, $object->id); - } else { - if ($origin == 'supplierorder' || $origin == 'order_supplier') { - $result = restrictedArea($user, 'fournisseur', $object, 'commande_fournisseur', 'commande'); - } elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) { - accessforbidden(); - } + if ($origin == 'supplierorder' || $origin == 'order_supplier') { + $result = restrictedArea($user, 'fournisseur', $object, 'commande_fournisseur', 'commande'); + } elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) { + accessforbidden(); } } - /* * Actions */