Inventory module working
This commit is contained in:
parent
966d3a6f30
commit
55560b7d38
@ -172,6 +172,12 @@ class modStock extends DolibarrModules
|
|||||||
$this->rights[9][3] = 0; // Permission by default for new user (0/1)
|
$this->rights[9][3] = 0; // Permission by default for new user (0/1)
|
||||||
$this->rights[9][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
$this->rights[9][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||||
$this->rights[9][5] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
$this->rights[9][5] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||||
|
|
||||||
|
$this->rights[10][0] = 1016;
|
||||||
|
$this->rights[10][1] = 'inventoryDeletePermission'; // Permission label
|
||||||
|
$this->rights[10][3] = 0; // Permission by default for new user (0/1)
|
||||||
|
$this->rights[10][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||||
|
$this->rights[10][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main menu entries
|
// Main menu entries
|
||||||
|
|||||||
@ -184,6 +184,7 @@ inventoryCreatePermission=Create new inventory
|
|||||||
inventoryReadPermission=View inventories
|
inventoryReadPermission=View inventories
|
||||||
inventoryWritePermission=Update inventories
|
inventoryWritePermission=Update inventories
|
||||||
inventoryValidatePermission=Validate inventory
|
inventoryValidatePermission=Validate inventory
|
||||||
|
inventoryDeletePermission=Delete inventory
|
||||||
inventoryTitle=Inventory
|
inventoryTitle=Inventory
|
||||||
inventoryListTitle=Inventories
|
inventoryListTitle=Inventories
|
||||||
inventoryListEmpty=No inventory in progress
|
inventoryListEmpty=No inventory in progress
|
||||||
@ -243,4 +244,6 @@ UpdateByScaning=Update by scaning
|
|||||||
UpdateByScaningProductBarcode=Update by scan (product barcode)
|
UpdateByScaningProductBarcode=Update by scan (product barcode)
|
||||||
UpdateByScaningLot=Update by scan (lot|serial barcode)
|
UpdateByScaningLot=Update by scan (lot|serial barcode)
|
||||||
DisableStockChangeOfSubProduct=Deactivate the stock change for all the subproducts of this Kit during this movement.
|
DisableStockChangeOfSubProduct=Deactivate the stock change for all the subproducts of this Kit during this movement.
|
||||||
LabelOfInventoryMovemement=Inventory %s
|
LabelOfInventoryMovemement=Inventory %s
|
||||||
|
ReOpen=Reopen
|
||||||
|
ConfirmFinish=Confirm closing
|
||||||
@ -407,6 +407,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes">'.$langs->trans("SetToDraft").'</a>';
|
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes">'.$langs->trans("SetToDraft").'</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Back to validate
|
||||||
|
if ($object->status == $object::STATUS_RECORDED) {
|
||||||
|
if ($permissiontoadd) {
|
||||||
|
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes">'.$langs->trans("ReOpen").'</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Modify
|
// Modify
|
||||||
if ($object->status == $object::STATUS_DRAFT) {
|
if ($object->status == $object::STATUS_DRAFT) {
|
||||||
|
|||||||
@ -52,7 +52,7 @@ class Inventory extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* @var int Does object support extrafields ? 0=No, 1=Yes
|
* @var int Does object support extrafields ? 0=No, 1=Yes
|
||||||
*/
|
*/
|
||||||
public $isextrafieldmanaged = 1;
|
public $isextrafieldmanaged = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string String with name of icon for inventory
|
* @var string String with name of icon for inventory
|
||||||
@ -254,6 +254,7 @@ class Inventory extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public function validate(User $user, $notrigger = false)
|
public function validate(User $user, $notrigger = false)
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$result = 0;
|
$result = 0;
|
||||||
@ -380,6 +381,27 @@ class Inventory extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to Canceled
|
||||||
|
*
|
||||||
|
* @param User $user User that creates
|
||||||
|
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||||
|
* @return int <0 if KO, Id of created object if OK
|
||||||
|
*/
|
||||||
|
public function setCanceled(User $user, $notrigger = false)
|
||||||
|
{
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
|
$result = $this->setStatut($this::STATUS_CANCELED, null, '', 'INVENTORY_CANCELED');
|
||||||
|
|
||||||
|
if ($result > 0) {
|
||||||
|
$this->db->commit();
|
||||||
|
} else {
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone and object into another one
|
* Clone and object into another one
|
||||||
*
|
*
|
||||||
@ -587,9 +609,11 @@ class Inventory extends CommonObject
|
|||||||
$labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft');
|
$labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft');
|
||||||
$labelStatus[self::STATUS_VALIDATED] = $langs->trans('Validated').' ('.$langs->trans('Started').')';
|
$labelStatus[self::STATUS_VALIDATED] = $langs->trans('Validated').' ('.$langs->trans('Started').')';
|
||||||
$labelStatus[self::STATUS_CANCELED] = $langs->trans('Canceled');
|
$labelStatus[self::STATUS_CANCELED] = $langs->trans('Canceled');
|
||||||
|
$labelStatus[self::STATUS_RECORDED] = $langs->trans('Closed');
|
||||||
$labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Draft');
|
$labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Draft');
|
||||||
$labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Started');
|
$labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Started');
|
||||||
$labelStatusShort[self::STATUS_CANCELED] = $langs->trans('Canceled');
|
$labelStatusShort[self::STATUS_CANCELED] = $langs->trans('Canceled');
|
||||||
|
$labelStatusShort[self::STATUS_RECORDED] = $langs->trans('Closed');
|
||||||
|
|
||||||
return dolGetStatus($labelStatus[$status], $labelStatusShort[$status], '', 'status'.$status, $mode);
|
return dolGetStatus($labelStatus[$status], $labelStatusShort[$status], '', 'status'.$status, $mode);
|
||||||
}
|
}
|
||||||
@ -649,6 +673,7 @@ class Inventory extends CommonObject
|
|||||||
public function initAsSpecimen()
|
public function initAsSpecimen()
|
||||||
{
|
{
|
||||||
$this->initAsSpecimenCommon();
|
$this->initAsSpecimenCommon();
|
||||||
|
$this->title = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -99,6 +99,10 @@ $now = dol_now();
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if ($action == 'cancel_record' && $permissiontoadd) {
|
||||||
|
$object->setCanceled($user);
|
||||||
|
}
|
||||||
|
|
||||||
if ($action == 'update' && $user->rights->stock->mouvement->creer) {
|
if ($action == 'update' && $user->rights->stock->mouvement->creer) {
|
||||||
$stockmovment = new MouvementStock($db);
|
$stockmovment = new MouvementStock($db);
|
||||||
$stockmovment->origin = $object;
|
$stockmovment->origin = $object;
|
||||||
@ -285,6 +289,18 @@ if ($object->id > 0) {
|
|||||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMyObject', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
|
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMyObject', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Confirmation to close
|
||||||
|
if ($action == 'record') {
|
||||||
|
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Close'), $langs->trans('ConfirmFinish'), 'update', '', 0, 1);
|
||||||
|
$action = 'view';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Confirmation to close
|
||||||
|
if ($action == 'confirm_cancel') {
|
||||||
|
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Cancel'), $langs->trans('ConfirmCancel'), 'cancel_record', '', 0, 1);
|
||||||
|
$action = 'view';
|
||||||
|
}
|
||||||
|
|
||||||
// Call Hook formConfirm
|
// Call Hook formConfirm
|
||||||
$parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
|
$parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
|
||||||
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
@ -369,24 +385,7 @@ if ($object->id > 0) {
|
|||||||
|
|
||||||
|
|
||||||
// Buttons for actions
|
// Buttons for actions
|
||||||
if ($action == 'record') {
|
if ($action != 'record') {
|
||||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
|
||||||
print '<input type="hidden" name="action" value="update">';
|
|
||||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
|
||||||
if ($backtopage) {
|
|
||||||
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
|
|
||||||
}
|
|
||||||
|
|
||||||
print '<div class="center">';
|
|
||||||
print '<span class="opacitymedium">'.$langs->trans("InventoryDesc").'</span><br>';
|
|
||||||
print '<input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'">';
|
|
||||||
print ' ';
|
|
||||||
print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
|
|
||||||
print '</div>';
|
|
||||||
print '<br>';
|
|
||||||
print '</form>';
|
|
||||||
} else {
|
|
||||||
print '<div class="tabsAction">'."\n";
|
print '<div class="tabsAction">'."\n";
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
@ -422,7 +421,8 @@ if ($object->id > 0) {
|
|||||||
|
|
||||||
if ($object->status == Inventory::STATUS_VALIDATED) {
|
if ($object->status == Inventory::STATUS_VALIDATED) {
|
||||||
if ($permissiontoadd) {
|
if ($permissiontoadd) {
|
||||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=record">'.$langs->trans("Finish").'</a>'."\n";
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_cancel">'.$langs->trans("Cancel").'</a>'."\n";
|
||||||
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=record">'.$langs->trans("Close").'</a>'."\n";
|
||||||
} else {
|
} else {
|
||||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Finish').'</a>'."\n";
|
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Finish').'</a>'."\n";
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user