NEW : inventory code filled when movements are done
This commit is contained in:
parent
c56c74bbdd
commit
a80c30bc45
@ -439,11 +439,12 @@ class StockTransferLine extends CommonObjectLine
|
||||
* Makes all stock movements (add quantity, remove quantity or cancel all actions)
|
||||
*
|
||||
* @param string $label label of stock movement
|
||||
* @param string $code_inv label of stock movement
|
||||
* @param int $fk_entrepot Warehouse concerned by stock movement
|
||||
* @param int $direction add or remove qty
|
||||
* @return int 1 if ok, <= 0 if ko
|
||||
*/
|
||||
public function doStockMovement($label, $fk_entrepot, $direction = 1)
|
||||
public function doStockMovement($label, $code_inv, $fk_entrepot, $direction = 1)
|
||||
{
|
||||
|
||||
global $db, $conf, $user, $langs;
|
||||
@ -473,7 +474,14 @@ class StockTransferLine extends CommonObjectLine
|
||||
$this->fk_stocktransfer
|
||||
);*/
|
||||
|
||||
$result = $movementstock->_create($user, $p->id, $fk_entrepot, $op[$direction], $direction, empty($direction) ? $this->pmp : 0, $label);
|
||||
$result = $movementstock->_create($user
|
||||
, $p->id
|
||||
, $fk_entrepot
|
||||
, $op[$direction]
|
||||
, $direction
|
||||
, empty($direction) ? $this->pmp : 0
|
||||
, $label
|
||||
, $code_inv);
|
||||
|
||||
if ($result < 0) {
|
||||
setEventMessages($p->errors, $p->errorss, 'errors');
|
||||
@ -505,7 +513,18 @@ class StockTransferLine extends CommonObjectLine
|
||||
GETPOST("codemove")
|
||||
);*/
|
||||
|
||||
$result = $movementstock->_create($user, $p->id, $fk_entrepot, $op[$direction], $direction, empty($direction) ? $this->pmp : 0, $label, '', '', $dlc, $dluo, $this->batch);
|
||||
$result = $movementstock->_create($user
|
||||
, $p->id
|
||||
, $fk_entrepot
|
||||
, $op[$direction]
|
||||
, $direction
|
||||
, empty($direction) ? $this->pmp : 0
|
||||
, $label
|
||||
, $code_inv
|
||||
, ''
|
||||
, $dlc
|
||||
, $dluo
|
||||
, $this->batch);
|
||||
|
||||
if ($result < 0) {
|
||||
setEventMessages($p->errors, $p->errorss, 'errors');
|
||||
|
||||
@ -87,6 +87,7 @@ $fk_warehouse_destination = GETPOST('fk_warehouse_destination', 'int');
|
||||
$lineid = GETPOST('lineid', 'int');
|
||||
$label = GETPOST('label', 'alpha');
|
||||
$batch = GETPOST('batch', 'alpha');
|
||||
$code_inv = GETPOST('inventorycode', 'alphanohtml');
|
||||
|
||||
// Initialize technical objects
|
||||
$object = new StockTransfer($db);
|
||||
@ -283,7 +284,7 @@ if (empty($reshook)) {
|
||||
if (!empty($lines)) {
|
||||
$db->begin();
|
||||
foreach ($lines as $line) {
|
||||
$res = $line->doStockMovement($label, $line->fk_warehouse_source);
|
||||
$res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_source);
|
||||
if ($res <= 0) $error++;
|
||||
}
|
||||
if (empty($error)) $db->commit();
|
||||
@ -304,7 +305,7 @@ if (empty($reshook)) {
|
||||
if (!empty($lines)) {
|
||||
$db->begin();
|
||||
foreach ($lines as $line) {
|
||||
$res = $line->doStockMovement($label, $line->fk_warehouse_source, 0);
|
||||
$res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_source, 0);
|
||||
if ($res <= 0) $error++;
|
||||
}
|
||||
if (empty($error)) $db->commit();
|
||||
@ -325,7 +326,7 @@ if (empty($reshook)) {
|
||||
if (!empty($lines)) {
|
||||
$db->begin();
|
||||
foreach ($lines as $line) {
|
||||
$res = $line->doStockMovement($label, $line->fk_warehouse_destination, 0);
|
||||
$res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_destination, 0);
|
||||
if ($res <= 0) $error++;
|
||||
}
|
||||
if (empty($error)) $db->commit();
|
||||
@ -346,7 +347,7 @@ if (empty($reshook)) {
|
||||
if (!empty($lines)) {
|
||||
$db->begin();
|
||||
foreach ($lines as $line) {
|
||||
$res = $line->doStockMovement($label, $line->fk_warehouse_destination);
|
||||
$res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_destination);
|
||||
if ($res <= 0) $error++;
|
||||
}
|
||||
if (empty($error)) $db->commit();
|
||||
@ -508,22 +509,30 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
} elseif ($action == 'destock') { // Destock confirmation
|
||||
// Create an array for form
|
||||
$formquestion = array( 'text' => '',
|
||||
array('type' => 'text', 'name' => 'label', 'label' => $langs->trans("Label"), 'value' => $langs->trans('ConfirmDestock', $object->ref), 'size'=>40));
|
||||
array('type' => 'text', 'name' => 'label', 'label' => $langs->trans("Label"), 'value' => $langs->trans('ConfirmDestock', $object->ref), 'size'=>40),
|
||||
array('type' => 'text', 'name' => 'inventorycode', 'label' => $langs->trans("InventoryCode"), 'value' => $object->ref.'_'.dol_print_date(dol_now(), '%y%m%d%H%M%S'), 'size'=>25)
|
||||
);
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DestockAllProduct'), '', 'confirm_destock', $formquestion, 'yes', 1);
|
||||
} elseif ($action == 'destockcancel') { // Destock confirmation cancel
|
||||
// Create an array for form
|
||||
$formquestion = array( 'text' => '',
|
||||
array('type' => 'text', 'name' => 'label', 'label' => $langs->trans("Label"), 'value' => $langs->trans('ConfirmDestockCancel', $object->ref), 'size'=>40));
|
||||
array('type' => 'text', 'name' => 'label', 'label' => $langs->trans("Label"), 'value' => $langs->trans('ConfirmDestockCancel', $object->ref), 'size'=>40),
|
||||
array('type' => 'text', 'name' => 'inventorycode', 'label' => $langs->trans("InventoryCode"), 'value' => $object->ref.'_'.dol_print_date(dol_now(), '%y%m%d%H%M%S'), 'size'=>25)
|
||||
);
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DestockAllProductCancel'), '', 'confirm_destockcancel', $formquestion, 'yes', 1);
|
||||
} elseif ($action == 'addstock') { // Addstock confirmation
|
||||
// Create an array for form
|
||||
$formquestion = array( 'text' => '',
|
||||
array('type' => 'text', 'name' => 'label', 'label' => $langs->trans("Label").' :', 'value' => $langs->trans('ConfirmAddStock', $object->ref), 'size'=>40));
|
||||
array('type' => 'text', 'name' => 'label', 'label' => $langs->trans("Label").' :', 'value' => $langs->trans('ConfirmAddStock', $object->ref), 'size'=>40),
|
||||
array('type' => 'text', 'name' => 'inventorycode', 'label' => $langs->trans("InventoryCode"), 'value' => $object->ref.'_'.dol_print_date(dol_now(), '%y%m%d%H%M%S'), 'size'=>25)
|
||||
);
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('AddStockAllProduct'), '', 'confirm_addstock', $formquestion, 'yes', 1);
|
||||
} elseif ($action == 'addstockcancel') { // Addstock confirmation cancel
|
||||
// Create an array for form
|
||||
$formquestion = array( 'text' => '',
|
||||
array('type' => 'text', 'name' => 'label', 'label' => $langs->trans("Label").' :', 'value' => $langs->trans('ConfirmAddStockCancel', $object->ref), 'size'=>40));
|
||||
array('type' => 'text', 'name' => 'label', 'label' => $langs->trans("Label").' :', 'value' => $langs->trans('ConfirmAddStockCancel', $object->ref), 'size'=>40),
|
||||
array('type' => 'text', 'name' => 'inventorycode', 'label' => $langs->trans("InventoryCode"), 'value' => $object->ref.'_'.dol_print_date(dol_now(), '%y%m%d%H%M%S'), 'size'=>25)
|
||||
);
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('AddStockAllProductCancel'), '', 'confirm_addstockcancel', $formquestion, 'yes', 1);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user