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