This commit is contained in:
parent
a51b2cc766
commit
a932a4708c
2 changed files with 33 additions and 18 deletions
|
|
@ -421,17 +421,18 @@ class MouvementStock extends CommonObject
|
|||
if (isModEnabled('productbatch') && $product->hasbatch() && !$skip_batch) {
|
||||
$foundforbatch = 0;
|
||||
$qtyisnotenough = 0;
|
||||
if (isset($product->stock_warehouse[$entrepot_id])) {
|
||||
foreach ($product->stock_warehouse[$entrepot_id]->detail_batch as $batchcursor => $prodbatch) {
|
||||
if ((string) $batch != (string) $batchcursor) { // Lot '59' must be different than lot '59c'
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($product->stock_warehouse[$entrepot_id]->detail_batch as $batchcursor => $prodbatch) {
|
||||
if ((string) $batch != (string) $batchcursor) { // Lot '59' must be different than lot '59c'
|
||||
continue;
|
||||
$foundforbatch = 1;
|
||||
if ($prodbatch->qty < abs($qty)) {
|
||||
$qtyisnotenough = $prodbatch->qty;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$foundforbatch = 1;
|
||||
if ($prodbatch->qty < abs($qty)) {
|
||||
$qtyisnotenough = $prodbatch->qty;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!$foundforbatch || $qtyisnotenough) {
|
||||
$langs->load("stocks");
|
||||
|
|
@ -445,7 +446,7 @@ class MouvementStock extends CommonObject
|
|||
return -8;
|
||||
}
|
||||
} else {
|
||||
if (empty($product->stock_warehouse[$entrepot_id]->real) || $product->stock_warehouse[$entrepot_id]->real < abs($qty)) {
|
||||
if (isset($product->stock_warehouse[$entrepot_id]) && (empty($product->stock_warehouse[$entrepot_id]->real) || $product->stock_warehouse[$entrepot_id]->real < abs($qty))) {
|
||||
$langs->load("stocks");
|
||||
$this->error = $langs->trans('qtyToTranferIsNotEnough').' : '.$product->ref;
|
||||
$this->errors[] = $langs->trans('qtyToTranferIsNotEnough').' : '.$product->ref;
|
||||
|
|
|
|||
|
|
@ -189,10 +189,15 @@ if (empty($reshook)) {
|
|||
} else {
|
||||
if (!empty($batch)) {
|
||||
$error++;
|
||||
setEventMessages($langs->transnoentities('StockTransferNoBatchForProduct', $prod->getNomUrl()), '', 'errors');
|
||||
setEventMessages($langs->transnoentities('StockTransferNoBatchForProduct', $prod->getNomUrl()), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if ($prod->status_batch==2 && abs($qty)>1) {
|
||||
$error++;
|
||||
setEventMessages($langs->transnoentities('TooManyQtyForSerialNumber', $prod->ref), null, 'errors');
|
||||
}
|
||||
|
||||
if (empty($error)) {
|
||||
$line = new StockTransferLine($db);
|
||||
$records = $line->fetchAll('', '', 0, 0, '(fk_stocktransfer:=:'.((int) $id).') AND (fk_product:=:'.((int) $fk_product).') AND (fk_warehouse_source:=:'.((int) $fk_warehouse_source).') AND (fk_warehouse_destination:=:'.((int) $fk_warehouse_destination).') AND ('.(empty($batch) ? "(batch:=:'') OR (batch:IS:NULL)" : "batch:=:'".$db->escape($batch)."'").')');
|
||||
|
|
@ -251,6 +256,12 @@ if (empty($reshook)) {
|
|||
}
|
||||
}
|
||||
|
||||
if ($prod->status_batch==2 && abs($qty)>1) {
|
||||
$error++;
|
||||
setEventMessages($langs->transnoentities('TooManyQtyForSerialNumber', $prod->ref), null, 'errors');
|
||||
$action = 'editline';
|
||||
}
|
||||
|
||||
if (empty($error)) {
|
||||
$line = new StockTransferLine($db);
|
||||
$line->fetch($lineid);
|
||||
|
|
@ -446,6 +457,10 @@ if ($action == 'create') {
|
|||
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
|
||||
|
||||
if (isModEnabled('incoterm')) {
|
||||
$soc = new Societe($db);
|
||||
if (!empty($object->fk_soc)) {
|
||||
$soc->fetch($object->fk_soc);
|
||||
}
|
||||
print '<tr>';
|
||||
print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $soc->label_incoterms, 1).'</label></td>';
|
||||
print '<td class="maxwidthonsmartphone">';
|
||||
|
|
@ -605,7 +620,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
$morehtmlref = '<div class="refidno">';
|
||||
// Thirdparty
|
||||
$morehtmlref .= empty($object->thirdparty) ? '' : $object->thirdparty->getNomUrl(1, 'customer');
|
||||
if (!getDolGlobalInt('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) {
|
||||
if (!getDolGlobalInt('MAIN_DISABLE_OTHER_LINK') && !empty($object->thirdparty) && $object->thirdparty->id > 0) {
|
||||
$morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherOrders").'</a>)';
|
||||
}
|
||||
// Project
|
||||
|
|
@ -707,6 +722,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
*/
|
||||
|
||||
if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
|
||||
$fk_element = $object->id;
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
|
||||
}
|
||||
|
||||
|
|
@ -804,7 +820,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
print '<tr id="row-'.$line->id.'" class="drag drop oddeven" '.$domData.'>';
|
||||
print '<td class="titlefield">';
|
||||
if ($action === 'editline' && $line->id == $lineid) {
|
||||
$form->select_produits($line->fk_product, 'fk_product', $filtertype, $limit, 0, -1, 2, '', 0, array(), 0, 0, 0, 'minwidth200imp maxwidth300', 1);
|
||||
$form->select_produits($line->fk_product, 'fk_product', '', 0, 0, -1, 2, '', 0, array(), 0, 0, 0, 'minwidth200imp maxwidth300', 1);
|
||||
} else {
|
||||
print $productstatic->getNomUrl(1).' - '.$productstatic->label;
|
||||
}
|
||||
|
|
@ -827,14 +843,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
print '<td>';
|
||||
|
||||
if ($action === 'editline' && $line->id == $lineid) {
|
||||
print $formproduct->selectWarehouses($line->fk_warehouse_source, 'fk_warehouse_source', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200', $TExcludedWarehouseSource);
|
||||
print $formproduct->selectWarehouses($line->fk_warehouse_source, 'fk_warehouse_source', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200');
|
||||
} else {
|
||||
print $warehousestatics->getNomUrl(1);
|
||||
}
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if ($action === 'editline' && $line->id == $lineid) {
|
||||
print $formproduct->selectWarehouses($line->fk_warehouse_destination, 'fk_warehouse_destination', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200', $TExcludedWarehouseDestination);
|
||||
print $formproduct->selectWarehouses($line->fk_warehouse_destination, 'fk_warehouse_destination', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200');
|
||||
} else {
|
||||
print $warehousestatict->getNomUrl(1);
|
||||
}
|
||||
|
|
@ -879,7 +895,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
|
||||
if ($num > 1 && $conf->browser->layout != 'phone' && empty($disablemove)) {
|
||||
print '<td class="linecolmove tdlineupdown center">';
|
||||
$coldisplay++;
|
||||
if ($i > 0) { ?>
|
||||
<a class="lineupdown" href="<?php print $_SERVER["PHP_SELF"].'?id='.$id.'&action=up&rowid='.$line->id; ?>">
|
||||
<?php print img_up('default', 0, 'imgupforline'); ?>
|
||||
|
|
@ -893,7 +908,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
print '</td>';
|
||||
} else {
|
||||
print '<td '.(($conf->browser->layout != 'phone' && empty($disablemove)) ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"').'></td>';
|
||||
$coldisplay++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1098,7 +1112,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
// List of actions on element
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
|
||||
$formactions = new FormActions($db);
|
||||
$somethingshown = $formactions->showactions($object, 'stocktransfer', 0, 1, '', $MAXEVENT, '', $morehtmlright);
|
||||
$somethingshown = $formactions->showactions($object, 'stocktransfer', 0, 1, '', $MAXEVENT, '');
|
||||
|
||||
print '</div></div>';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue