/** * Add a shipment line with batch record * * @param array $dbatch Array of value (key 'detail' -> Array, key 'qty' total quantity for line, key ix_l : original line index) * @return int <0 if KO, >0 if OK */ function addline_batch($dbatch) { $num = count($this->lines); if ($dbatch['qty'] > 0) { $line = new ExpeditionLigne($this->db); $tab = array(); foreach ($dbatch['detail'] as $key => $value) { if ($value['q'] > 0) { // $value['q']=qty to move // $value['id_batch']=id into llx_product_batch of record to move //var_dump($value); $linebatch = new ExpeditionLineBatch($this->db); $ret = $linebatch->fetchFromStock($value['id_batch']); // load serial, sellby, eatby if ($ret < 0) { $this->error = $linebatch->error; return -1; } $linebatch->dluo_qty = $value['q']; $tab[] = $linebatch; if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) { // TODO } //var_dump($linebatch); } } $line->entrepot_id = $linebatch->entrepot_id; $line->origin_line_id = $dbatch['ix_l']; $line->qty = $dbatch['qty']; $line->detail_batch = $tab; //var_dump($line); $this->lines[$num] = $line; } }
/** * Add a shipment line with batch record * * @param array $dbatch Array of value (key 'detail' -> Array, key 'qty' total quantity for line, key ix_l : original line index) * @param array $array_options extrafields array * @return int <0 if KO, >0 if OK */ function addline_batch($dbatch, $array_options = 0) { global $conf, $langs; $num = count($this->lines); if ($dbatch['qty'] > 0) { $line = new ExpeditionLigne($this->db); $tab = array(); foreach ($dbatch['detail'] as $key => $value) { if ($value['q'] > 0) { // $value['q']=qty to move // $value['id_batch']=id into llx_product_batch of record to move //var_dump($value); $linebatch = new ExpeditionLineBatch($this->db); $ret = $linebatch->fetchFromStock($value['id_batch']); // load serial, sellby, eatby if ($ret < 0) { $this->error = $linebatch->error; return -1; } $linebatch->dluo_qty = $value['q']; $tab[] = $linebatch; if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) { require_once DOL_DOCUMENT_ROOT . '/product/class/productbatch.class.php'; $prod_batch = new Productbatch($this->db); $prod_batch->fetch($value['id_batch']); if ($prod_batch->qty < $linebatch->dluo_qty) { $this->errors[] = $langs->trans('ErrorStockIsNotEnough'); dol_syslog(get_class($this) . "::addline_batch error=Product " . $prod_batch->batch . ": " . $this->errorsToString(), LOG_ERR); $this->db->rollback(); return -1; } } //var_dump($linebatch); } } $line->entrepot_id = $linebatch->entrepot_id; $line->origin_line_id = $dbatch['ix_l']; $line->qty = $dbatch['qty']; $line->detail_batch = $tab; // extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) { // For avoid conflicts if trigger used $line->array_options = $array_options; } //var_dump($line); $this->lines[$num] = $line; return 1; } }
/** * Add a shipment line with batch record * * @param array $dbatch Array of value (key 'detail' -> Array, key 'qty' total quantity for line, key ix_l : original line index) * @param array $array_options extrafields array * @return int <0 if KO, >0 if OK */ function addline_batch($dbatch, $array_options = 0) { global $conf; $num = count($this->lines); if ($dbatch['qty'] > 0) { $line = new ExpeditionLigne($this->db); $tab = array(); foreach ($dbatch['detail'] as $key => $value) { if ($value['q'] > 0) { // $value['q']=qty to move // $value['id_batch']=id into llx_product_batch of record to move //var_dump($value); $linebatch = new ExpeditionLineBatch($this->db); $ret = $linebatch->fetchFromStock($value['id_batch']); // load serial, sellby, eatby if ($ret < 0) { $this->error = $linebatch->error; return -1; } $linebatch->dluo_qty = $value['q']; $tab[] = $linebatch; if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) { // TODO } //var_dump($linebatch); } } $line->entrepot_id = $linebatch->entrepot_id; $line->origin_line_id = $dbatch['ix_l']; $line->qty = $dbatch['qty']; $line->detail_batch = $tab; // extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) { // For avoid conflicts if trigger used $line->array_options = $array_options; } //var_dump($line); $this->lines[$num] = $line; } }