OF consumption batch select : wip
This commit is contained in:
parent
dfa2cab408
commit
d5f0fe6c10
@ -1023,8 +1023,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
print '<td>';
|
print '<td>';
|
||||||
if ($tmpproduct->status_batch) {
|
if ($tmpproduct->status_batch) {
|
||||||
$preselected = (GETPOSTISSET('batch-'.$line->id.'-'.$i) ? GETPOST('batch-'.$line->id.'-'.$i) : '');
|
$preselected = (GETPOSTISSET('batch-'.$line->id.'-'.$i) ? GETPOST('batch-'.$line->id.'-'.$i) : '');
|
||||||
print '<input type="text" class="width50" name="batch-'.$line->id.'-'.$i.'" value="'.$preselected.'" list="batch-'.$line->id.'-'.$i.'">';
|
// print '<input type="text" class="width50" name="batch-'.$line->id.'-'.$i.'" value="'.$preselected.'" list="batch-'.$line->id.'-'.$i.'">';
|
||||||
print $formproduct->selectLotDataList('batch-'.$line->id.'-'.$i, 0, $line->fk_product, '', '');
|
print $formproduct->selectLotDataList('batch-'.$line->id.'-'.$i, 0, $line->fk_product, 1, '');
|
||||||
|
// print $formproduct->selectLotStock('', 'batch-'.$line->id.'-'.$i, '', 0, '', $line->fk_product);
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -626,13 +626,13 @@ class FormProduct
|
|||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::selectLotDataList $htmlname, $empty, $fk_product, $fk_entrepot,$objectLines", LOG_DEBUG);
|
dol_syslog(get_class($this) . "::selectLotDataList $htmlname, $empty, $fk_product, $fk_entrepot,$objectLines", LOG_DEBUG);
|
||||||
|
|
||||||
$out = '';
|
$out = '';
|
||||||
$productIdArray = array();
|
$productIdArray = array();
|
||||||
if (!is_array($objectLines) || !count($objectLines)) {
|
if (!is_array($objectLines) || !count($objectLines)) {
|
||||||
if (!empty($fk_product) && $fk_product > 0) {
|
if (!empty($fk_product) && $fk_product > 0) {
|
||||||
$productIdArray[] = (int) $fk_product;
|
$productIdArray[] = (int)$fk_product;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach ($objectLines as $line) {
|
foreach ($objectLines as $line) {
|
||||||
@ -644,26 +644,44 @@ class FormProduct
|
|||||||
|
|
||||||
$nboflot = $this->loadLotStock($productIdArray);
|
$nboflot = $this->loadLotStock($productIdArray);
|
||||||
|
|
||||||
$out .= '<datalist id="'.$htmlname.'" >';
|
$out .= '<select class="flat' . ($morecss ? ' ' . $morecss : '') . '"' . ($disabled ? ' disabled' : '') . ' id="' . $htmlname . '" name="' . ($htmlname . ($disabled ? '_disabled' : '')) . '">';
|
||||||
|
|
||||||
if (!empty($fk_product) && $fk_product > 0) {
|
if (!empty($fk_product) && $fk_product > 0) {
|
||||||
$productIdArray = array((int) $fk_product); // only show lot stock for product
|
$productIdArray = array((int)$fk_product); // only show lot stock for product
|
||||||
} else {
|
} else {
|
||||||
foreach ($this->cache_lot as $key => $value) {
|
foreach ($this->cache_lot as $key => $value) {
|
||||||
$productIdArray[] = $key;
|
$productIdArray[] = $key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$TBatchQuantity = array();
|
||||||
foreach ($productIdArray as $productId) {
|
foreach ($productIdArray as $productId) {
|
||||||
foreach ($this->cache_lot[$productId] as $id => $arraytypes) {
|
foreach ($this->cache_lot[$productId] as $id => $arraytypes) {
|
||||||
if (empty($fk_entrepot) || $fk_entrepot == $arraytypes['entrepot_id']) {
|
$TBatchQuantity[$arraytypes['batch']][$arraytypes['entrepot_id']] = $arraytypes['qty'];
|
||||||
$label = $arraytypes['entrepot_label'].' - ';
|
|
||||||
$label .= $arraytypes['batch'];
|
|
||||||
$out .= '<option>'.$arraytypes['batch'].'</option>';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$out .= '</datalist>';
|
|
||||||
|
|
||||||
|
foreach ($TBatchQuantity as $batch => $TQtyByWarehouse) {
|
||||||
|
|
||||||
|
$label = '';
|
||||||
|
|
||||||
|
//si pas d'entrepôt, on affiche le stock total du lot, tout entrepôt compris
|
||||||
|
if (empty($fk_entrepot)) $label .= " (" . $langs->trans('Stock total') . " : " . array_sum($TQtyByWarehouse) . ")";
|
||||||
|
//sinon on affiche seulement le stock de l'entrepôt en question
|
||||||
|
else $label .= " (" . $langs->trans('Stock') . " : " . $TQtyByWarehouse[$fk_entrepot] . ")";
|
||||||
|
|
||||||
|
$out .= '<option value="' . $batch . '"';
|
||||||
|
$out .= ' data-html="' . dol_escape_htmltag($label) . '"';
|
||||||
|
$out .= '>';
|
||||||
|
$out .= $label;
|
||||||
|
$out .= '</option>';
|
||||||
|
|
||||||
|
// $out .= '<option>'.$arraytypes['batch'].'</option>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$out .= '</select>';
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user