Resolve merge conflicts
This commit is contained in:
commit
6a8e3761c3
@ -750,81 +750,79 @@ class Mo extends CommonObject
|
||||
*/
|
||||
public function deleteLine(User $user, $idline, $notrigger = false)
|
||||
{
|
||||
global $langs;
|
||||
$langs->load('stocks');
|
||||
global $langs;
|
||||
$langs->load('stocks');
|
||||
|
||||
if ($this->status < 0) {
|
||||
$this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
|
||||
return -2;
|
||||
}
|
||||
|
||||
$productstatic = new Product($this->db);
|
||||
$fk_movement = GETPOST('fk_movement', 'int');
|
||||
$arrayoflines = $this->fetchLinesLinked('consumed', $idline);
|
||||
$productstatic = new Product($this->db);
|
||||
$fk_movement = GETPOST('fk_movement', 'int');
|
||||
$arrayoflines = $this->fetchLinesLinked('consumed', $idline);
|
||||
|
||||
if (! empty($arrayoflines)) {
|
||||
$this->db->begin();
|
||||
if (! empty($arrayoflines)) {
|
||||
$this->db->begin();
|
||||
|
||||
$stockmove = new MouvementStock($this->db);
|
||||
$stockmove->setOrigin($this->element, $this->id);
|
||||
$stockmove = new MouvementStock($this->db);
|
||||
$stockmove->setOrigin($this->element, $this->id);
|
||||
|
||||
if (! empty($fk_movement)) {
|
||||
$moline = new MoLine($this->db);
|
||||
$TArrayMoLine = $moline->fetchAll('', '', 1, 0, array('customsql' => 'fk_stock_movement ='.$fk_movement));
|
||||
$moline = array_shift($TArrayMoLine);
|
||||
if (! empty($fk_movement)) {
|
||||
$moline = new MoLine($this->db);
|
||||
$TArrayMoLine = $moline->fetchAll('', '', 1, 0, array('customsql' => 'fk_stock_movement ='.$fk_movement));
|
||||
$moline = array_shift($TArrayMoLine);
|
||||
|
||||
$movement = new MouvementStock($this->db);
|
||||
$movement->fetch($fk_movement);
|
||||
$productstatic->fetch($movement->product_id);
|
||||
$qtytoprocess = $movement->qty;
|
||||
$movement = new MouvementStock($this->db);
|
||||
$movement->fetch($fk_movement);
|
||||
$productstatic->fetch($movement->product_id);
|
||||
$qtytoprocess = $movement->qty;
|
||||
|
||||
// Reverse stock movement
|
||||
$labelmovementCancel = $langs->trans("CancelProductionForRef", $productstatic->ref);
|
||||
$codemovementCancel = $langs->trans("StockIncrease");
|
||||
// Reverse stock movement
|
||||
$labelmovementCancel = $langs->trans("CancelProductionForRef", $productstatic->ref);
|
||||
$codemovementCancel = $langs->trans("StockIncrease");
|
||||
|
||||
if (($qtytoprocess >= 0)) {
|
||||
$idstockmove = $stockmove->reception($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, '', '', $movement->batch, dol_now(), 0, $codemovementCancel);
|
||||
} else {
|
||||
$idstockmove = $stockmove->livraison($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', $movement->batch, 0, $codemovementCancel);
|
||||
}
|
||||
if ($idstockmove < 0) {
|
||||
$this->error++;
|
||||
$this->db->rollback();
|
||||
setEventMessages($stockmove->error, $stockmove->errors, 'errors');
|
||||
} else {
|
||||
$this->db->commit();
|
||||
}
|
||||
return $moline->delete($user, $notrigger);
|
||||
}
|
||||
else {
|
||||
foreach ($arrayoflines as $key => $arrayofline) {
|
||||
$lineDetails = $arrayoflines[$key];
|
||||
$productstatic->fetch($lineDetails['fk_product']);
|
||||
$qtytoprocess = $lineDetails['qty'];
|
||||
if (($qtytoprocess >= 0)) {
|
||||
$idstockmove = $stockmove->reception($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, '', '', $movement->batch, dol_now(), 0, $codemovementCancel);
|
||||
} else {
|
||||
$idstockmove = $stockmove->livraison($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', $movement->batch, 0, $codemovementCancel);
|
||||
}
|
||||
if ($idstockmove < 0) {
|
||||
$this->error++;
|
||||
$this->db->rollback();
|
||||
setEventMessages($stockmove->error, $stockmove->errors, 'errors');
|
||||
} else {
|
||||
$this->db->commit();
|
||||
}
|
||||
return $moline->delete($user, $notrigger);
|
||||
} else {
|
||||
foreach ($arrayoflines as $key => $arrayofline) {
|
||||
$lineDetails = $arrayoflines[$key];
|
||||
$productstatic->fetch($lineDetails['fk_product']);
|
||||
$qtytoprocess = $lineDetails['qty'];
|
||||
|
||||
// Reverse stock movement
|
||||
$labelmovementCancel = $langs->trans("CancelProductionForRef", $productstatic->ref);
|
||||
$codemovementCancel = $langs->trans("StockIncrease");
|
||||
// Reverse stock movement
|
||||
$labelmovementCancel = $langs->trans("CancelProductionForRef", $productstatic->ref);
|
||||
$codemovementCancel = $langs->trans("StockIncrease");
|
||||
|
||||
if ($qtytoprocess >= 0) {
|
||||
$idstockmove = $stockmove->reception($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, '', '', $lineDetails['batch'], dol_now(), 0, $codemovementCancel);
|
||||
} else {
|
||||
$idstockmove = $stockmove->livraison($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', $lineDetails['batch'], 0, $codemovementCancel);
|
||||
}
|
||||
if ($idstockmove < 0) {
|
||||
$this->error++;
|
||||
$this->db->rollback();
|
||||
setEventMessages($stockmove->error, $stockmove->errors, 'errors');
|
||||
} else {
|
||||
$this->db->commit();
|
||||
}
|
||||
}
|
||||
return $this->deleteLineCommon($user, $idline, $notrigger);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return $this->deleteLineCommon($user, $idline, $notrigger);
|
||||
}
|
||||
if ($qtytoprocess >= 0) {
|
||||
$idstockmove = $stockmove->reception($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, '', '', $lineDetails['batch'], dol_now(), 0, $codemovementCancel);
|
||||
} else {
|
||||
$idstockmove = $stockmove->livraison($user, $lineDetails['fk_product'], $lineDetails['fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel, dol_now(), '', '', $lineDetails['batch'], 0, $codemovementCancel);
|
||||
}
|
||||
if ($idstockmove < 0) {
|
||||
$this->error++;
|
||||
$this->db->rollback();
|
||||
setEventMessages($stockmove->error, $stockmove->errors, 'errors');
|
||||
} else {
|
||||
$this->db->commit();
|
||||
}
|
||||
}
|
||||
return $this->deleteLineCommon($user, $idline, $notrigger);
|
||||
}
|
||||
} else {
|
||||
return $this->deleteLineCommon($user, $idline, $notrigger);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -970,12 +970,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
|
||||
// Action delete line
|
||||
if ($permissiontodelete) {
|
||||
$href = $_SERVER["PHP_SELF"].'?id='.((int) $object->id).'&action=deleteline&token='.newToken().'&lineid='.((int) $line->id).'&fk_movement='.((int) $line2['fk_stock_movement']);
|
||||
print '<td class="center">';
|
||||
print '<a class="reposition" href="'.$href.'">';
|
||||
print img_picto($langs->trans('TooltipDeleteAndRevertStockMovement'), 'delete');
|
||||
print '</a>';
|
||||
print '</td>';
|
||||
$href = $_SERVER["PHP_SELF"].'?id='.((int) $object->id).'&action=deleteline&token='.newToken().'&lineid='.((int) $line->id).'&fk_movement='.((int) $line2['fk_stock_movement']);
|
||||
print '<td class="center">';
|
||||
print '<a class="reposition" href="'.$href.'">';
|
||||
print img_picto($langs->trans('TooltipDeleteAndRevertStockMovement'), 'delete');
|
||||
print '</a>';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
print '</tr>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user