diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index bb8cb9bcdda..93768dce5b1 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -365,12 +365,13 @@ class Expedition extends CommonObject * @param int $origin_line_id Id of source line * @param int $qty Quantity * @param array $array_options extrafields array - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, line_id if OK */ function create_line($entrepot_id, $origin_line_id, $qty,$array_options=0) { global $conf; $error = 0; + $line_id = 0; $sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet ("; $sql.= "fk_expedition"; @@ -390,6 +391,8 @@ class Expedition extends CommonObject $error++; } + if (! $error) $line_id = $this->db->last_insert_id(MAIN_DB_PREFIX."expeditiondet"); + if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used { $expeditionline = new ExpeditionLigne($this->db); @@ -403,7 +406,7 @@ class Expedition extends CommonObject } } - if (! $error) return 1; + if (! $error) return $line_id; else return -1; } @@ -432,14 +435,13 @@ class Expedition extends CommonObject // create shipment lines foreach ($stockLocationQty as $stockLocation => $qty) { - if ($this->create_line($stockLocation,$line_ext->origin_line_id,$qty,$array_options) < 0) + if (($line_id = $this->create_line($stockLocation,$line_ext->origin_line_id,$qty,$array_options)) < 0) { $error++; } else { // create shipment batch lines for stockLocation - $line_id= $this->db->last_insert_id(MAIN_DB_PREFIX."expeditiondet"); foreach ($tab as $detbatch) { if ($detbatch->entrepot_id == $stockLocation){ diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 9b15ed31fcc..9ed1e65dde4 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -189,11 +189,12 @@ class Productlot extends CommonObject * Load object in memory from the database * * @param int $id Id object - * @param string $ref Ref + * @param int $product_id Id of product, batch number parameter required + * @param string $batch batch number * * @return int <0 if KO, 0 if not found, >0 if OK */ - public function fetch($id, $ref = null) + public function fetch($id = 0, $product_id = null, $batch = null) { dol_syslog(__METHOD__, LOG_DEBUG); @@ -213,8 +214,8 @@ class Productlot extends CommonObject $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; - if (null !== $ref) { - $sql .= ' WHERE t.ref = ' . '\'' . $ref . '\''; + if ((null !== $product_id) && (null !== $batch)) { + $sql .= ' WHERE t.batch = ' . '\'' . $batch . '\' AND t.fk_product = ' . $product_id; } else { $sql .= ' WHERE t.rowid = ' . $id; } @@ -528,101 +529,6 @@ class Productlot extends CommonObject return - 1; } } - - /** - * Return a link to the user card (with optionaly the picto) - * Use this->id,this->lastname, this->firstname - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to - * @param integer $notooltip 1=Disable tooltip - * @param int $maxlen Max length of visible user name - * @param string $morecss Add more css on link - * @return string String with URL - */ - function getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='') - { - global $langs, $conf, $db; - global $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; - - - $result = ''; - $companylink = ''; - - $label = '' . $langs->trans("MyModule") . ''; - $label.= '