Merge pull request #20782 from atm-adrien/FIX_move_inventory_column-develop
Fix move inventory column develop
This commit is contained in:
commit
b04ef20708
@ -28,6 +28,7 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
include_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php';
|
||||
include_once DOL_DOCUMENT_ROOT.'/product/inventory/lib/inventory.lib.php';
|
||||
include_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
|
||||
include_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("stocks", "other", "productbatch"));
|
||||
@ -186,25 +187,6 @@ if (empty($reshook)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($line->pmp_real) && !empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) {
|
||||
$sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product SET pmp = '.((float) $line->pmp_real).' WHERE rowid = '.((int) $line->fk_product);
|
||||
$resqlpmp = $db->query($sqlpmp);
|
||||
if (! $resqlpmp) {
|
||||
$error++;
|
||||
setEventMessages($db->lasterror(), null, 'errors');
|
||||
break;
|
||||
}
|
||||
if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
||||
$sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product_perentity SET pmp = '.((float) $line->pmp_real).' WHERE fk_product = '.((int) $line->fk_product).' AND entity='.$conf->entity;
|
||||
$resqlpmp = $db->query($sqlpmp);
|
||||
if (! $resqlpmp) {
|
||||
$error++;
|
||||
setEventMessages($db->lasterror(), null, 'errors');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update line with id of stock movement (and the start quantity if it has changed this last recording)
|
||||
$sqlupdate = "UPDATE ".MAIN_DB_PREFIX."inventorydet";
|
||||
$sqlupdate .= " SET fk_movement = ".((int) $idstockmove);
|
||||
@ -219,6 +201,25 @@ if (empty($reshook)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($line->pmp_real) && !empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) {
|
||||
$sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product SET pmp = '.((float) $line->pmp_real).' WHERE rowid = '.((int) $line->fk_product);
|
||||
$resqlpmp = $db->query($sqlpmp);
|
||||
if (! $resqlpmp) {
|
||||
$error++;
|
||||
setEventMessages($db->lasterror(), null, 'errors');
|
||||
break;
|
||||
}
|
||||
if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
||||
$sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product_perentity SET pmp = '.((float) $line->pmp_real).' WHERE fk_product = '.((int) $line->fk_product).' AND entity='.$conf->entity;
|
||||
$resqlpmp = $db->query($sqlpmp);
|
||||
if (! $resqlpmp) {
|
||||
$error++;
|
||||
setEventMessages($db->lasterror(), null, 'errors');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
@ -910,14 +911,16 @@ if ($object->id > 0) {
|
||||
print '</td>';
|
||||
}
|
||||
print '<td class="right">'.$langs->trans("ExpectedQty").'</td>';
|
||||
print '<td class="right">';
|
||||
print $form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp"));
|
||||
print '</td>';
|
||||
if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) {
|
||||
print '<td class="right">'.$langs->trans('PMPExpected').'</td>';
|
||||
print '<td class="right">'.$langs->trans('ExpectedValuation').'</td>';
|
||||
print '<td class="right">'.$form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp")).'</td>';
|
||||
print '<td class="right">'.$langs->trans('PMPReal').'</td>';
|
||||
print '<td class="right">'.$langs->trans('RealValuation').'</td>';
|
||||
} else {
|
||||
print '<td class="right">';
|
||||
print $form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp"));
|
||||
print '</td>';
|
||||
}
|
||||
if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) {
|
||||
// Actions or link to stock movement
|
||||
@ -1020,7 +1023,13 @@ if ($object->id > 0) {
|
||||
|
||||
if (!empty($conf->productbatch->enabled)) {
|
||||
print '<td id="id_'.$obj->rowid.'_batch" data-batch="'.dol_escape_htmltag($obj->batch).'">';
|
||||
print dol_escape_htmltag($obj->batch);
|
||||
$batch_static = new Productlot($db);
|
||||
$res = $batch_static->fetch(0, $product_static->id, $obj->batch);
|
||||
if ($res) {
|
||||
print $batch_static->getNomUrl(1);
|
||||
} else {
|
||||
print dol_escape_htmltag($obj->batch);
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
@ -1041,7 +1050,6 @@ if ($object->id > 0) {
|
||||
|
||||
// Real quantity
|
||||
if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) {
|
||||
print '<td class="right">';
|
||||
$qty_view = GETPOST("id_".$obj->rowid) && price2num(GETPOST("id_".$obj->rowid), 'MS') >= 0 ? GETPOST("id_".$obj->rowid) : $obj->qty_view;
|
||||
|
||||
//if (!$hasinput && $qty_view !== null && $obj->qty_stock != $qty_view) {
|
||||
@ -1049,11 +1057,6 @@ if ($object->id > 0) {
|
||||
$hasinput = true;
|
||||
}
|
||||
|
||||
print '<a id="undochangesqty_'.$obj->rowid.'" href="#" class="undochangesqty reposition marginrightonly" title="'.dol_escape_htmltag($langs->trans("Clear")).'">';
|
||||
print img_picto('', 'eraser', 'class="opacitymedium"');
|
||||
print '</a>';
|
||||
print '<input type="text" class="maxwidth75 right realqty" name="id_'.$obj->rowid.'" id="id_'.$obj->rowid.'_input" value="'.$qty_view.'">';
|
||||
print '</td>';
|
||||
if (! empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) {
|
||||
//PMP Expected
|
||||
if (! empty($obj->pmp_expected)) $pmp_expected = $obj->pmp_expected;
|
||||
@ -1066,6 +1069,14 @@ if ($object->id > 0) {
|
||||
print '<td class="right">';
|
||||
print price($pmp_valuation);
|
||||
print '</td>';
|
||||
|
||||
print '<td class="right">';
|
||||
print '<a id="undochangesqty_'.$obj->rowid.'" href="#" class="undochangesqty reposition marginrightonly" title="'.dol_escape_htmltag($langs->trans("Clear")).'">';
|
||||
print img_picto('', 'eraser', 'class="opacitymedium"');
|
||||
print '</a>';
|
||||
print '<input type="text" class="maxwidth50 right realqty" name="id_'.$obj->rowid.'" id="id_'.$obj->rowid.'_input" value="'.$qty_view.'">';
|
||||
print '</td>';
|
||||
|
||||
//PMP Real
|
||||
print '<td class="right">';
|
||||
|
||||
@ -1081,18 +1092,22 @@ if ($object->id > 0) {
|
||||
|
||||
$totalExpectedValuation += $pmp_valuation;
|
||||
$totalRealValuation += $pmp_valuation_real;
|
||||
} else {
|
||||
print '<td class="right">';
|
||||
print '<a id="undochangesqty_'.$obj->rowid.'" href="#" class="undochangesqty reposition marginrightonly" title="'.dol_escape_htmltag($langs->trans("Clear")).'">';
|
||||
print img_picto('', 'eraser', 'class="opacitymedium"');
|
||||
print '</a>';
|
||||
print '<input type="text" class="maxwidth50 right realqty" name="id_'.$obj->rowid.'" id="id_'.$obj->rowid.'_input" value="'.$qty_view.'">';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Picto delete line
|
||||
print '<td class="right">';
|
||||
print '<a class="reposition" href="'.DOL_URL_ROOT.'/product/inventory/inventory.php?id='.$object->id.'&lineid='.$obj->rowid.'&action=deleteline&token='.newToken().'">'.img_delete().'</a>';
|
||||
$qty_tmp = price2num(GETPOST("id_".$obj->rowid."_input_tmp", 'MS')) >= 0 ? GETPOST("id_".$obj->rowid."_input_tmp") : $qty_view;
|
||||
print '<input type="hidden" class="maxwidth75 right realqty" name="id_'.$obj->rowid.'_input_tmp" id="id_'.$obj->rowid.'_input_tmp" value="'.$qty_tmp.'">';
|
||||
print '<input type="hidden" class="maxwidth50 right realqty" name="id_'.$obj->rowid.'_input_tmp" id="id_'.$obj->rowid.'_input_tmp" value="'.$qty_tmp.'">';
|
||||
print '</td>';
|
||||
} else {
|
||||
print '<td class="right nowraponall">';
|
||||
print $obj->qty_view; // qty found
|
||||
print '</td>';
|
||||
if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) {
|
||||
//PMP Expected
|
||||
if (! empty($obj->pmp_expected)) $pmp_expected = $obj->pmp_expected;
|
||||
@ -1105,6 +1120,10 @@ if ($object->id > 0) {
|
||||
print price($pmp_valuation);
|
||||
print '</td>';
|
||||
|
||||
print '<td class="right nowraponall">';
|
||||
print $obj->qty_view; // qty found
|
||||
print '</td>';
|
||||
|
||||
//PMP Real
|
||||
print '<td class="right">';
|
||||
if (! empty($obj->pmp_real)) $pmp_real = $obj->pmp_real;
|
||||
@ -1115,12 +1134,15 @@ if ($object->id > 0) {
|
||||
print '<td class="right">';
|
||||
print price($pmp_valuation_real);
|
||||
print '</td>';
|
||||
print '<td class="nowraponall right">';
|
||||
|
||||
$totalExpectedValuation += $pmp_valuation;
|
||||
$totalRealValuation += $pmp_valuation_real;
|
||||
} else {
|
||||
print '<td class="right nowraponall">';
|
||||
print $obj->qty_view; // qty found
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
print '<td class="nowraponall right">';
|
||||
if ($obj->fk_movement > 0) {
|
||||
$stockmovment = new MouvementStock($db);
|
||||
$stockmovment->fetch($obj->fk_movement);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user