diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index bc5bf9da9e3..b4336936181 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1041,9 +1041,9 @@ class ActionComm extends CommonObject * Use $this->id, $this->type_code, $this->label and $this->type_label * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $maxlength Nombre de caracteres max dans libelle + * @param int $maxlength Max number of charaters into label. If negative, use the ref as label. * @param string $classname Force style class on a link - * @param string $option ''=Link to action,'birthday'=Link to contact + * @param string $option ''=Link to action, 'birthday'=Link to contact * @param int $overwritepicto 1=Overwrite picto * @return string Chaine avec URL */ @@ -1075,7 +1075,8 @@ class ActionComm extends CommonObject { $libelle=(empty($this->libelle)?$label:$this->libelle.(($label && $label != $this->libelle)?' '.$label:'')); if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($libelle)) $libelle=($langs->transnoentities("Action".$this->type_code) != "Action".$this->type_code)?$langs->transnoentities("Action".$this->type_code):$this->type_label; - $libelleshort=dol_trunc($libelle,$maxlength); + if ($maxlength < 0) $libelleshort=$this->ref; + else $libelleshort=dol_trunc($libelle,$maxlength); } if ($withpicto) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 69f1c6df145..58597862f8c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3277,12 +3277,12 @@ abstract class CommonObject * Need $this->element & $this->id * * @param int $resource_id Resource id - * @param string $resource_element Resource element + * @param string $resource_type 'resource' * @param int $busy Busy or not * @param int $mandatory Mandatory or not * @return int <=0 if KO, >0 if OK */ - function add_element_resource($resource_id,$resource_element,$busy=0,$mandatory=0) + function add_element_resource($resource_id, $resource_type, $busy=0, $mandatory=0) { $this->db->begin(); @@ -3295,7 +3295,7 @@ abstract class CommonObject $sql.= ", mandatory"; $sql.= ") VALUES ("; $sql.= $resource_id; - $sql.= ", '".$resource_element."'"; + $sql.= ", '".$resource_type."'"; $sql.= ", '".$this->id."'"; $sql.= ", '".$this->element."'"; $sql.= ", '".$busy."'"; diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 9322680a682..60fbdc0c467 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -179,7 +179,7 @@ class FormActions elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter'); else $title=$langs->trans("Actions"); - print_titre($title); + print load_fiche_titre($title,'',''); $total = 0; $var=true; print '
| ';
- $detail = '';
- foreach ($lines[$i]->detail_batch as $dbatch)
+ if ($lines[$i]->product_tobatch)
{
- $detail.= $langs->trans("DetailBatchFormat",$dbatch->batch,dol_print_date($dbatch->eatby,"day"),dol_print_date($dbatch->sellby,"day"),$dbatch->dluo_qty).' '; + $detail = ''; + foreach ($lines[$i]->detail_batch as $dbatch) + { + $detail.= $langs->trans("DetailBatchFormat",$dbatch->batch,dol_print_date($dbatch->eatby,"day"),dol_print_date($dbatch->sellby,"day"),$dbatch->dluo_qty).' '; + } + print $form->textwithtooltip($langs->trans("DetailBatchNumber"),$detail); + } + else + { + print $langs->trans("NA"); } - print $form->textwithtooltip($langs->trans("DetailBatchNumber"),$detail); print ' | ';
} else {
print ''; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 3699399bdca..5863161a995 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -391,7 +391,7 @@ class Expedition extends CommonObject /** - * Create a expedition line with eat-by date + * Create the detail (eat-by date) of the expedition line * * @param object $line_ext full line informations * @return int <0 if KO, >0 if OK @@ -626,9 +626,12 @@ class Expedition extends CommonObject // Loop on each product line to add a stock movement // TODO possibilite d'expedier a partir d'une propale ou autre origine - $sql = "SELECT cd.fk_product, cd.subprice, ed.qty, ed.fk_entrepot, ed.rowid"; + $sql = "SELECT cd.fk_product, cd.subprice,"; + $sql.= " ed.rowid, ed.qty, ed.fk_entrepot,"; + $sql.= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty, edb.fk_origin_stock"; $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd,"; $sql.= " ".MAIN_DB_PREFIX."expeditiondet as ed"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid"; $sql.= " WHERE ed.fk_expedition = ".$this->id; $sql.= " AND cd.rowid = ed.fk_origin_line"; @@ -640,27 +643,38 @@ class Expedition extends CommonObject for ($i = 0; $i < $cpt; $i++) { $obj = $this->db->fetch_object($resql); - if($obj->qty <= 0) continue; - dol_syslog(get_class($this)."::valid movement index ".$i); + if ($obj->qty <= 0) continue; + dol_syslog(get_class($this)."::valid movement index ".$i." ed.rowid=".$obj->rowid." edb.rowid=".$obj->edbrowid); //var_dump($this->lines[$i]); $mouvS = new MouvementStock($this->db); $mouvS->origin = &$this; - // We decrement stock of product (and sub-products) - // We use warehouse selected for each line - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref)); - if ($result < 0) { $error++; break; } - - if (! empty($conf->productbatch->enabled)) + + if (empty($obj->edbrowid)) { - $details=ExpeditionLineBatch::fetchAll($this->db,$obj->rowid); - if (! empty($details)) + // 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, $obj->qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref)); + if ($result < 0) { + $error++; break; + } + } + else + { + // 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, $obj->qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref), '', $obj->eatby, $obj->sellby, $obj->batch); + if ($result < 0) { + $error++; break; + } + + // We update content of table llx_product_batch (will be rename into llx_product_stock_batch inantoher version) + if (! empty($conf->productbatch->enabled)) { - foreach ($details as $dbatch) - { - $result=$mouvS->livraison_batch($dbatch->fk_origin_stock,$dbatch->dluo_qty); - if ($result < 0) { $error++; $this->errors[]=$mouvS->$error; break 2; } - } + $result=$mouvS->livraison_batch($obj->fk_origin_stock, $obj->qty); // ->fk_origin_stock = id into table llx_product_batch (will be rename into llx_product_stock_batch in another version) + if ($result < 0) { $error++; $this->errors[]=$mouvS->error; break; } } } } @@ -672,7 +686,7 @@ class Expedition extends CommonObject return -2; } } - + if (! $error && ! $notrigger) { // Call trigger @@ -843,6 +857,10 @@ class Expedition extends CommonObject { 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) @@ -857,13 +875,16 @@ class Expedition extends CommonObject { // 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; } } @@ -1146,9 +1167,9 @@ class Expedition extends CommonObject $sql = "SELECT cd.rowid, cd.fk_product, cd.label as custom_label, cd.description, cd.qty as qty_asked"; $sql.= ", cd.total_ht, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.total_tva"; $sql.= ", cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.price, cd.subprice, cd.remise_percent"; - $sql.= ", ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot"; + $sql.= ", ed.rowid as line_id, ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot"; $sql.= ", p.ref as product_ref, p.label as product_label, p.fk_product_type"; - $sql.= ", p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, ed.rowid as line_id"; + $sql.= ", p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, p.tobatch as product_tobatch"; $sql.= " FROM (".MAIN_DB_PREFIX."expeditiondet as ed,"; $sql.= " ".MAIN_DB_PREFIX."commandedet as cd)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = cd.fk_product"; @@ -1202,6 +1223,7 @@ class Expedition extends CommonObject $line->product_ref = $obj->product_ref; $line->product_label = $obj->product_label; $line->libelle = $obj->product_label; // TODO deprecated + $line->product_tobatch = $obj->product_tobatch; $line->label = $obj->custom_label; $line->description = $obj->description; $line->qty_asked = $obj->qty_asked; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 9ca609c154c..9b0001e79d6 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1612,9 +1612,10 @@ if ($action=='create') print "\n"; // Show origin lines - if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { + if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) + { $title = $langs->trans('ProductsAndServices'); - print_titre($title); + print load_fiche_titre($title,'',''); print ' |