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/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 9564c106f0f..2a3512a9b70 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -793,9 +793,7 @@ class Mailing extends CommonObject */ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { - global $db, $conf, $langs, $hookmanager; - global $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; + global $conf, $langs, $hookmanager; if (!empty($conf->dol_no_mouse_hover)) { $notooltip = 1; // Force disable tooltips @@ -849,7 +847,7 @@ class Mailing extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 9c251ccd6af..d54bd3892f4 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3882,7 +3882,7 @@ class Propal extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index d85cab45ccc..7ab621a422a 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1465,11 +1465,16 @@ class Account extends CommonObject * @param string $option ''=Show ref, 'reflabel'=Show ref+label * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link * @return string Chaine avec URL */ - public function getNomUrl($withpicto = 0, $mode = '', $option = '', $save_lastsearch_value = -1, $notooltip = 0) + public function getNomUrl($withpicto = 0, $mode = '', $option = '', $save_lastsearch_value = -1, $notooltip = 0, $morecss = '') { - global $conf, $langs, $user; + global $conf, $langs; + + if (!empty($conf->dol_no_mouse_hover)) { + $notooltip = 1; // Force disable tooltips + } include_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; @@ -1490,10 +1495,6 @@ class Account extends CommonObject $label = implode($this->getTooltipContentArray($params)); } - $linkclose = ''; - $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"'); - $linkclose .= $dataparams.' class="'.$classfortooltip.'">'; - $url = DOL_URL_ROOT.'/compta/bank/card.php?id='.$this->id; if ($mode == 'transactions') { $url = DOL_URL_ROOT.'/compta/bank/bankentries_list.php?id='.$this->id; @@ -1512,17 +1513,34 @@ class Account extends CommonObject } } - $linkstart = 'trans("BankAccount"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"'); + $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } - if ($option == 'nolink') { - $linkstart = ''; - $linkend = ''; + if ($option == 'nolink' || empty($url)) { + $linkstart = ''; + if ($option == 'nolink' || empty($url)) { + $linkend = ''; + } else { + $linkend = ''; } $result .= $linkstart; + if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref.($option == 'reflabel' && $this->label ? ' - '.$this->label : ''); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 7f6289df193..9d7970031a8 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2071,7 +2071,7 @@ class Facture extends CommonInvoice $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= ($max ?dol_trunc($this->ref, $max) : $this->ref); diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index b6b956b608c..0e23bbfe7f8 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2119,7 +2119,7 @@ class Contrat extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= ($this->ref ? $this->ref : $this->id); 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/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index 45a9222e594..030e6ed3e35 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -47,7 +47,7 @@ function shipping_prepare_head($object) $head[$h][2] = 'shipping'; $h++; - if ($object->statut == Expedition::STATUS_DRAFT) { + if ($object->statut == Expedition::STATUS_DRAFT) { $head[$h][0] = DOL_URL_ROOT."/expedition/dispatch.php?id=".$object->id; $head[$h][1] = $langs->trans("ShipmentDistribution"); $head[$h][2] = 'dispatch'; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 5baf6099e33..bf6611ea6cf 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -2541,6 +2541,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 ccf5fed9d42..c16f5351dc5 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -754,7 +754,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; } @@ -1088,14 +1088,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").","; @@ -1121,7 +1118,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(); @@ -1593,11 +1589,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 } @@ -1855,7 +1852,7 @@ class Expedition extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; @@ -2192,12 +2189,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; @@ -2244,7 +2243,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; @@ -2255,7 +2254,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; @@ -2829,8 +2828,6 @@ class ExpeditionLigne extends CommonObjectLine */ public function delete($user = null, $notrigger = 0) { - global $conf; - $error = 0; $this->db->begin(); @@ -2894,8 +2891,6 @@ class ExpeditionLigne extends CommonObjectLine */ public function update($user = null, $notrigger = 0) { - global $conf; - $error = 0; dol_syslog(get_class($this)."::update id=$this->id, entrepot_id=$this->entrepot_id, product_id=$this->fk_product, qty=$this->qty"); diff --git a/htdocs/expedition/class/expeditionlinebatch.class.php b/htdocs/expedition/class/expeditionlinebatch.class.php index b010564768f..73f352ac21a 100644 --- a/htdocs/expedition/class/expeditionlinebatch.class.php +++ b/htdocs/expedition/class/expeditionlinebatch.class.php @@ -45,6 +45,7 @@ class ExpeditionLineBatch extends CommonObject public $dluo_qty; // deprecated, use qty public $entrepot_id; public $fk_origin_stock; // rowid in llx_product_batch table + public $fk_warehouse; // for future use in v19 public $fk_expeditiondet; @@ -123,6 +124,7 @@ class ExpeditionLineBatch extends CommonObject $sql .= ", batch"; $sql .= ", qty"; $sql .= ", fk_origin_stock"; + // TODO Add fk_warehouse here $sql .= ") VALUES ("; $sql .= $id_line_expdet.","; $sql .= " ".(!isset($this->sellby) || dol_strlen($this->sellby) == 0 ? 'NULL' : ("'".$this->db->idate($this->sellby))."'").","; diff --git a/htdocs/expedition/dispatch.php b/htdocs/expedition/dispatch.php index 8c0338df660..8503536fb81 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) { @@ -96,7 +100,7 @@ if ($id > 0 || !empty($ref)) { $result = restrictedArea($user, 'expedition', $object, ''); if (!isModEnabled('stock')) { - accessforbidden(); + accessforbidden('Module stock disabled'); } $usercancreate = $user->hasRight('expedition', 'creer'); @@ -148,46 +152,53 @@ if ($action == 'updatelines' && $usercancreate) { $lot = ''; $dDLUO = ''; $dDLC = ''; - if ($modebatch == "batch") { //TODO: Make impossible to input non existing batchcode + if ($modebatch == "batch") { //TODO: Make impossible to input non existing batch code $lot = GETPOST('lot_number_'.$reg[1].'_'.$reg[2]); $dDLUO = dol_mktime(12, 0, 0, GETPOST('dluo_'.$reg[1].'_'.$reg[2].'month', 'int'), GETPOST('dluo_'.$reg[1].'_'.$reg[2].'day', 'int'), GETPOST('dluo_'.$reg[1].'_'.$reg[2].'year', 'int')); $dDLC = dol_mktime(12, 0, 0, GETPOST('dlc_'.$reg[1].'_'.$reg[2].'month', 'int'), GETPOST('dlc_'.$reg[1].'_'.$reg[2].'day', 'int'), GETPOST('dlc_'.$reg[1].'_'.$reg[2].'year', 'int')); } + $newqty = price2num(GETPOST($qty, 'alpha'), 'MS'); + // We ask to move a qty - if (($modebatch == "batch" && GETPOST($qty) > 0) || ($modebatch == "barcode" && GETPOST($qty) != 0)) { - if (!(GETPOST($ent, 'int') > 0)) { - dol_syslog('No dispatch for line '.$key.' as no warehouse was chosen.'); - $text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').' '.($numline); - setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors'); - $error++; - } - if ($modebatch == "batch") { - $sql = "SELECT pb.rowid "; - $sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb"; - $sql .= " JOIN ".MAIN_DB_PREFIX."product_stock as ps"; - $sql .= " ON ps.rowid = pb.fk_product_stock"; - $sql .= " WHERE pb.batch ='".$db->escape($lot)."'"; - $sql .= " AND ps.fk_product =".((int) GETPOST($prod, 'int')) ; - $sql .= " AND ps.fk_entrepot =".((int) GETPOST($ent, 'int')) ; - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - if ($num > 1) { - dol_syslog('No dispatch for line '.$key.' as too many combination warehouse, product, batch code was found ('.$num.').'); - setEventMessages($langs->trans('ErrorTooManyCombinationBatchcode', $numline, $num), null, 'errors'); - $error++; - } elseif ($num < 1) { - dol_syslog('No dispatch for line '.$key.' as no combination warehouse, product, batch code was found.'); - setEventMessages($langs->trans('ErrorNoCombinationBatchcode', $numline), null, 'errors'); - $error++; + if (($modebatch == "batch" && $newqty >= 0) || ($modebatch == "barcode" && $newqty != 0)) { + if ($newqty > 0) { // If we want a qty, we make test on input data + if (!(GETPOST($ent, 'int') > 0)) { + dol_syslog('No dispatch for line '.$key.' as no warehouse was chosen.'); + $text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').' '.($numline); + setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors'); + $error++; + } + if (!$error && $modebatch == "batch") { + $sql = "SELECT pb.rowid "; + $sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb"; + $sql .= " JOIN ".MAIN_DB_PREFIX."product_stock as ps"; + $sql .= " ON ps.rowid = pb.fk_product_stock"; + $sql .= " WHERE pb.batch = '".$db->escape($lot)."'"; + $sql .= " AND ps.fk_product = ".((int) GETPOST($prod, 'int')) ; + $sql .= " AND ps.fk_entrepot = ".((int) GETPOST($ent, 'int')) ; + + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + if ($num > 1) { + dol_syslog('No dispatch for line '.$key.' as too many combination warehouse, product, batch code was found ('.$num.').'); + setEventMessages($langs->trans('ErrorTooManyCombinationBatchcode', $numline, $num), null, 'errors'); + $error++; + } elseif ($num < 1) { + dol_syslog('No dispatch for line '.$key.' as no combination warehouse, product, batch code was found.'); + setEventMessages($langs->trans('ErrorNoCombinationBatchcode', $numline), null, 'errors'); + $error++; + } + $db->free($resql); } - $db->free($resql); } } + //var_dump($key.' '.$newqty.' '.$idline.' '.$error); if (!$error) { $qtystart = 0; + if ($idline > 0) { $result = $expeditiondispatch->fetch($idline); if ($result < 0) { @@ -195,22 +206,38 @@ if ($action == 'updatelines' && $usercancreate) { $error++; } else { $qtystart = $expeditiondispatch->qty; - $expeditiondispatch->qty = GETPOST($qty); + $expeditiondispatch->qty = $newqty; $expeditiondispatch->entrepot_id = GETPOST($ent, 'int'); - $result = $expeditiondispatch->update($user); + if ($newqty > 0) { + $result = $expeditiondispatch->update($user); + } else { + $result = $expeditiondispatch->delete($user); + } if ($result < 0) { setEventMessages($expeditiondispatch->error, $expeditiondispatch->errors, 'errors'); $error++; } if (!$error && $modebatch == "batch") { - $sql = "UPDATE ".MAIN_DB_PREFIX.$expeditionlinebatch->table_element." SET"; - $sql .= " eatby = ".($eatby ? "'".$db->idate($eatby)."'" : "null"); - $sql .= " , sellby = ".($sellby ? "'".$db->idate($sellby)."'" : "null"); - $sql .= " , qty = ".((float) price2num(GETPOST($qty, 'int'), 'MS')); - $sql .= " WHERE fk_expeditiondet = ".((int) $idline); - $sql .= " AND batch = ".((int) $idline); + if ($newqty > 0) { + $suffixkeyfordate = preg_replace('/^product_batch/', '', $key); + $sellby = dol_mktime(0, 0, 0, GETPOST('dlc'.$suffixkeyfordate.'month'), GETPOST('dlc'.$suffixkeyfordate.'day'), GETPOST('dlc'.$suffixkeyfordate.'year'), ''); + $eatby = dol_mktime(0, 0, 0, GETPOST('dluo'.$suffixkeyfordate.'month'), GETPOST('dluo'.$suffixkeyfordate.'day'), GETPOST('dluo'.$suffixkeyfordate.'year')); + + $sql = "UPDATE ".MAIN_DB_PREFIX.$expeditionlinebatch->table_element." SET"; + $sql .= " eatby = ".($eatby ? "'".$db->idate($eatby)."'" : "null"); + $sql .= " , sellby = ".($sellby ? "'".$db->idate($sellby)."'" : "null"); + $sql .= " , qty = ".((float) $newqty); + // TODO Add a column fk_warehouse + $sql .= " WHERE fk_expeditiondet = ".((int) $idline); + $sql .= " AND batch = '".$db->escape($lot)."'"; + } else { + $sql = " DELETE FROM ".MAIN_DB_PREFIX.$expeditionlinebatch->table_element; + $sql .= " WHERE fk_expeditiondet = ".((int) $idline); + $sql .= " AND batch = '".$db->escape($lot)."'"; + } + $resql = $db->query($sql); if (!$db->query($sql)) { dol_print_error($db); @@ -222,34 +249,40 @@ if ($action == 'updatelines' && $usercancreate) { $expeditiondispatch->fk_expedition = $object->id; $expeditiondispatch->entrepot_id = GETPOST($ent, 'int'); $expeditiondispatch->fk_origin_line = GETPOST($fk_commandedet, 'int'); - $expeditiondispatch->qty = GETPOST($qty, 'int'); - $idline = $expeditiondispatch->insert($user); - if ($idline < 0) { - setEventMessages($expeditiondispatch->error, $expeditiondispatch->errors, 'errors'); - $error++; - } + $expeditiondispatch->qty = $newqty; - if ($modebatch == "batch" && !$error) { - $expeditionlinebatch->sellby = $dDLUO; - $expeditionlinebatch->eatby = $dDLC; - $expeditionlinebatch->batch = $lot; - $expeditionlinebatch->qty = GETPOST($qty, 'int'); - $expeditionlinebatch->fk_origin_stock = 0; - $result = $expeditionlinebatch->create($idline); - if ($result < 0) { - setEventMessages($expeditionlinebatch->error, $expeditionlinebatch->errors, 'errors'); + if ($newqty > 0) { + $idline = $expeditiondispatch->insert($user); + if ($idline < 0) { + setEventMessages($expeditiondispatch->error, $expeditiondispatch->errors, 'errors'); $error++; } + + if ($modebatch == "batch" && !$error) { + $expeditionlinebatch->sellby = $dDLUO; + $expeditionlinebatch->eatby = $dDLC; + $expeditionlinebatch->batch = $lot; + $expeditionlinebatch->qty = $newqty; + $expeditionlinebatch->fk_origin_stock = 0; + $expeditionlinebatch->fk_warehouse = GETPOST($ent, 'int'); + + $result = $expeditionlinebatch->create($idline); + if ($result < 0) { + setEventMessages($expeditionlinebatch->error, $expeditionlinebatch->errors, 'errors'); + $error++; + } + } } } - // 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'); - $qtymouv = GETPOST($qty) - $qtystart; - $price = GETPOST($pu); + $qtymouv = price2num(GETPOST($qty, 'alpha'), 'MS') - $qtystart; + $price = price2num(GETPOST($pu), 'MU'); $comment = GETPOST('comment'); $inventorycode = dol_print_date(dol_now(), 'dayhourlog'); $now = dol_now(); @@ -279,6 +312,7 @@ if ($action == 'updatelines' && $usercancreate) { } } } + */ } } } @@ -289,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')); @@ -318,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); @@ -465,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(); @@ -482,7 +520,7 @@ if ($object->id > 0 || !empty($object->ref)) { print '
'; print ''; - // Get list of lines from the shipments $products_dispatched with qty dispatched for each product id + // Get list of lines of the shipment $products_dispatched, with qty dispatched for each product id $products_dispatched = array(); $sql = "SELECT ed.fk_origin_line as rowid, sum(ed.qty) as qty"; $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; @@ -503,6 +541,7 @@ if ($object->id > 0 || !empty($object->ref)) { } $db->free($resql); } + //$sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, SUM(l.qty) as qty,"; $sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, '' AS sref, l.qty as qty,"; $sql .= " p.ref, p.label, p.tobatch, p.fk_default_warehouse"; @@ -565,8 +604,12 @@ if ($object->id > 0 || !empty($object->ref)) { print ''; } print ''; - print ''; - print ' '; + } + print ''; if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) { @@ -610,6 +653,7 @@ if ($object->id > 0 || !empty($object->ref)) { $conf->cache['product'] = array(); + // Loop on each line of origin order while ($i < $num) { $objp = $db->fetch_object($resql); @@ -754,8 +798,8 @@ if ($object->id > 0 || !empty($object->ref)) { print ''; print ''; if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { print ''; print ''; print '
'.$langs->trans("QtyOrdered").''.$langs->trans("QtyDispatchedShort").''.$langs->trans("QtyToDispatchShort"); + if ($object->status == Expedition::STATUS_DRAFT) { + print ''.$langs->trans("QtyToDispatchShort"); // Qty to dispatch (sum for all lines of batch detail if there is) + } else { + print ''.$langs->trans("QtyDispatchedShort").''.$langs->trans("QtyToDispatchShort"); print ''; - print ''; - //print ''; + print ''; + //print ''; print ''; @@ -809,8 +853,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 ''; if (isModEnabled('productbatch') && $objp->tobatch > 0) { @@ -953,8 +999,14 @@ 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"').''; + $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. + // In such a case, we do not suggest new values, we suggest the value known. + $amounttosuggest = (GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : (isset($products_dispatched[$objp->rowid]) ? $products_dispatched[$objp->rowid] : '')); + } + print ''; print ''; if (isModEnabled('productbatch') && $objp->tobatch > 0) { @@ -1011,14 +1063,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); @@ -1031,6 +1083,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 */ diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 0a571d2650f..e60f6a7a352 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -854,7 +854,7 @@ class Dolresource extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index f41c4c09283..078620a09d2 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -552,7 +552,7 @@ class Salary extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright pictofixedwidth"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.' pictofixedwidth"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 9b9c65c07d2..72a4f663cc7 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2573,7 +2573,7 @@ class SupplierProposal extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index d8c04b52eb3..e606a2ffb93 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -191,7 +191,7 @@ th.wrapcolumntitle dl dt a span.fas.fa-list { .liste_titre input[name=search_day_date_when], .liste_titre input[name=search_month_date_when], .liste_titre input[name=search_year_date_when], .liste_titre input[name=search_dtstartday], .liste_titre input[name=search_dtendday], .liste_titre input[name=search_dtstartmonth], .liste_titre input[name=search_dtendmonth], */ -.liste_titre input[name=search_month] { +.liste_titre input[name=search_month], .liste_titre input[name=search_month_start], .liste_titre input[name=search_month_end] { margin-right: 4px; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 50208d9eb44..75f6ee48793 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -495,7 +495,7 @@ th.wrapcolumntitle dl dt a span.fas.fa-list { vertical-align: bottom; } -.liste_titre input[name=month_date_when], .liste_titre input[name=monthvalid], .liste_titre input[name=search_ordermonth], .liste_titre input[name=search_deliverymonth], +/*.liste_titre input[name=month_date_when], .liste_titre input[name=monthvalid], .liste_titre input[name=search_ordermonth], .liste_titre input[name=search_deliverymonth], .liste_titre input[name=search_smonth], .liste_titre input[name=search_month], .liste_titre input[name=search_emonth], .liste_titre input[name=smonth], .liste_titre input[name=month], .liste_titre input[name=month_lim], .liste_titre input[name=month_start], .liste_titre input[name=month_end], .liste_titre input[name=month_create], .liste_titre input[name=search_month_lim], .liste_titre input[name=search_month_start], .liste_titre input[name=search_month_end], .liste_titre input[name=search_month_create], @@ -507,10 +507,15 @@ th.wrapcolumntitle dl dt a span.fas.fa-list { .liste_titre input[name=search_day_create], .liste_titre input[name=search_day_start], .liste_titre input[name=search_day_end], .liste_titre input[name=search_day_date_when], .liste_titre input[name=search_month_date_when], .liste_titre input[name=search_year_date_when], .liste_titre input[name=search_dtstartday], .liste_titre input[name=search_dtendday], .liste_titre input[name=search_dtstartmonth], .liste_titre input[name=search_dtendmonth], +*/ +.liste_titre input[name=search_month], .liste_titre input[name=search_month_start], .liste_titre input[name=search_month_end] { + margin-right: 4px; +} select#date_startday, select#date_startmonth, select#date_endday, select#date_endmonth, select#reday, select#remonth { margin-right: 4px; } + input, input.flat, textarea, textarea.flat, form.flat select, select, select.flat, .dataTables_length label select { color: var(--colortext); border: none; diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 5b696e2143d..08334b5efea 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1522,9 +1522,7 @@ class Ticket extends CommonObject */ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { - global $db, $conf, $langs; - global $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; + global $conf, $langs; if (!empty($conf->dol_no_mouse_hover)) { $notooltip = 1; // Force disable tooltips @@ -1579,7 +1577,7 @@ class Ticket extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 3e6b8bb5591..998b7daa756 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -74,7 +74,7 @@ $group = GETPOST("group", "int", 3); $cancel = GETPOST('cancel', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'useracard'; // To manage different context of search -if (empty($id)) { +if (empty($id) && $action != 'create') { $id = $user->id; }