diff --git a/htdocs/admin/stocktransfer.php b/htdocs/admin/stocktransfer.php index 2f5892dd1c0..64d759445bd 100644 --- a/htdocs/admin/stocktransfer.php +++ b/htdocs/admin/stocktransfer.php @@ -122,10 +122,7 @@ if ($action == 'updateMask') { setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } -} - -// Activate a model -elseif ($action == 'set') { +} elseif ($action == 'set') { // Activate a model $ret = addDocumentModel($value, 'stocktransfer', $label, $scandir); } elseif ($action == 'del') { $tmpobjectkey = GETPOST('object'); @@ -135,10 +132,7 @@ elseif ($action == 'set') { $constforval = strtoupper($tmpobjectkey).'_ADDON_PDF'; if ($conf->global->$constforval == "$value") dolibarr_del_const($db, $constforval, $conf->entity); } -} - -// Set default model -elseif ($action == 'setdoc') { +} elseif ($action == 'setdoc') { // Set default model $tmpobjectkey = GETPOST('object'); $constforval = strtoupper($tmpobjectkey).'_ADDON_PDF'; if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) { diff --git a/htdocs/core/modules/modStockTransfer.class.php b/htdocs/core/modules/modStockTransfer.class.php index d15e9797d13..c528f22b175 100644 --- a/htdocs/core/modules/modStockTransfer.class.php +++ b/htdocs/core/modules/modStockTransfer.class.php @@ -500,9 +500,12 @@ class modStockTransfer extends DolibarrModules return $this->_init($sql, $options); } + /** + * Returns next available id to insert new roles in llx_c_type_contact + * @return int > 0 if OK, < 0 if KO + */ function getNextId() { - global $db; // Get free id for insert @@ -514,6 +517,7 @@ class modStockTransfer extends DolibarrModules $newid = ($obj->newid + 1); } else { dol_print_error($db); + return -1; } return $newid; } diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php index 2bffdf68b2d..3f59e08bc80 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php @@ -824,6 +824,12 @@ class pdf_eagle extends ModelePdfStockTransfer }*/ } + /** + * Used to know if at least one line of Stock Transfer object has a batch set + * + * @param $object Stock Transfer object + * @return bool true if at least one line has batch set, false if not + */ function atLeastOneBatch($object) { diff --git a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php index f3a256d9532..95c4f31b08a 100644 --- a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php +++ b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php @@ -347,6 +347,13 @@ class StockTransfer extends CommonObject return $result; } + /** + * Used to sort lines by rank + * + * @param $a 1st element to test + * @param $b 1st element to test + * @return int + */ function cmp($a, $b) { if ($a->rang == $b->rang) { @@ -355,6 +362,11 @@ class StockTransfer extends CommonObject return ($a->rang < $b->rang) ? -1 : 1; } + /** + * Used to get total PMP amount of all quantities of products of Stock Transfer + * + * @return float total amount of Stock Transfer + */ function getValorisationTotale() { diff --git a/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php b/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php index 46aeba5980e..962186b5a13 100644 --- a/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php +++ b/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php @@ -435,6 +435,14 @@ class StockTransferLine extends CommonObject return $this->deleteLineCommon($user, $idline, $notrigger); } + /** + * Makes all stock movements (add quantity, remove quantity or cancel all actions) + * + * @param string $label 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 + */ function doStockMovement($label, $fk_entrepot, $direction = 1) { diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_card.php b/htdocs/product/stock/stocktransfer/stocktransfer_card.php index e40d196dca0..db746f4e581 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_card.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_card.php @@ -494,30 +494,22 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Create an array for form $formquestion = array(); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); - } - // Destock confirmation - elseif ($action == 'destock') { + } 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)); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DestockAllProduct'), '', 'confirm_destock', $formquestion, 'yes', 1); - } - // Destock confirmation cancel - elseif ($action == 'destockcancel') { + } 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)); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DestockAllProductCancel'), '', 'confirm_destockcancel', $formquestion, 'yes', 1); - } - // Addstock confirmation - elseif ($action == 'addstock') { + } 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)); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('AddStockAllProduct'), '', 'confirm_addstock', $formquestion, 'yes', 1); - } - // Addstock confirmation cancel - elseif ($action == 'addstockcancel') { + } 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)); diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_contact.php b/htdocs/product/stock/stocktransfer/stocktransfer_contact.php index 8e0eac4b4cb..97ac4c28a73 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_contact.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_contact.php @@ -92,17 +92,11 @@ if ($action == 'addcontact' && $user->rights->stocktransfer->stocktransfer->writ setEventMessages($object->error, $object->errors, 'errors'); } } -} - -// Toggle the status of a contact -elseif ($action == 'swapstatut' && $user->rights->stocktransfer->stocktransfer->write) { +} elseif ($action == 'swapstatut' && $user->rights->stocktransfer->stocktransfer->write) { // Toggle the status of a contact if ($object->id > 0) { $result = $object->swapContactStatus(GETPOST('ligne')); } -} - -// Deletes a contact -elseif ($action == 'deletecontact' && $user->rights->stocktransfer->stocktransfer->write) { +} elseif ($action == 'deletecontact' && $user->rights->stocktransfer->stocktransfer->write) { // Deletes a contact $result = $object->delete_contact($lineid); if ($result >= 0) {