FIX Better label for reception status

This commit is contained in:
Laurent Destailleur 2021-11-19 13:46:30 +01:00
parent cdc160b9a9
commit bb6440af9d
4 changed files with 55 additions and 52 deletions

View File

@ -23,7 +23,9 @@ ReceptionsAndReceivingForSameOrder=Receptions and receipts for this order
ReceptionsToValidate=Receptions to validate
StatusReceptionCanceled=Canceled
StatusReceptionDraft=Draft
StatusReceptionValidated=Validated (products to ship or already shipped)
StatusReceptionValidated=Validated (products to receive or already received)
StatusReceptionValidatedToReceive=Validated (products to receive)
StatusReceptionValidatedReceived=Validated (products received)
StatusReceptionProcessed=Processed
StatusReceptionDraftShort=Draft
StatusReceptionValidatedShort=Validated
@ -45,3 +47,4 @@ ReceptionsNumberingModules=Numbering module for receptions
ReceptionsReceiptModel=Document templates for receptions
NoMorePredefinedProductToDispatch=No more predefined products to dispatch
ReceptionExist=A reception exists
ReceptionBackToDraftInDolibarr=Reception %s back to draft

View File

@ -140,7 +140,7 @@ class MouvementStock extends CommonObject
* @param int $price Unit price HT of product, used to calculate average weighted price (AWP or PMP in french). If 0, average weighted price is not changed.
* @param string $label Label of stock movement
* @param string $inventorycode Inventory code
* @param string $datem Force date of movement
* @param integer|string $datem Force date of movement
* @param integer|string $eatby eat-by date. Will be used if lot does not exists yet and will be created.
* @param integer|string $sellby sell-by date. Will be used if lot does not exists yet and will be created.
* @param string $batch batch number
@ -428,7 +428,7 @@ class MouvementStock extends CommonObject
$sql .= " datem, fk_product, batch, eatby, sellby,";
$sql .= " fk_entrepot, value, type_mouvement, fk_user_author, label, inventorycode, price, fk_origin, origintype, fk_projet";
$sql .= ")";
$sql .= " VALUES ('".$this->db->idate($now)."', ".$this->product_id.", ";
$sql .= " VALUES ('".$this->db->idate($this->datem)."', ".$this->product_id.", ";
$sql .= " ".($batch ? "'".$this->db->escape($batch)."'" : "null").", ";
$sql .= " ".($eatby ? "'".$this->db->idate($eatby)."'" : "null").", ";
$sql .= " ".($sellby ? "'".$this->db->idate($sellby)."'" : "null").", ";
@ -755,19 +755,19 @@ class MouvementStock extends CommonObject
/**
* Decrease stock for product and subproducts
*
* @param User $user Object user
* @param int $fk_product Id product
* @param int $entrepot_id Warehouse id
* @param int $qty Quantity
* @param int $price Price
* @param string $label Label of stock movement
* @param string $datem Force date of movement
* @param integer $eatby eat-by date
* @param integer $sellby sell-by date
* @param string $batch batch number
* @param int $id_product_batch Id product_batch
* @param string $inventorycode Inventory code
* @return int <0 if KO, >0 if OK
* @param User $user Object user
* @param int $fk_product Id product
* @param int $entrepot_id Warehouse id
* @param int $qty Quantity
* @param int $price Price
* @param string $label Label of stock movement
* @param integer|string $datem Force date of movement
* @param integer $eatby eat-by date
* @param integer $sellby sell-by date
* @param string $batch batch number
* @param int $id_product_batch Id product_batch
* @param string $inventorycode Inventory code
* @return int <0 if KO, >0 if OK
*/
public function livraison($user, $fk_product, $entrepot_id, $qty, $price = 0, $label = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $id_product_batch = 0, $inventorycode = '')
{
@ -790,7 +790,7 @@ class MouvementStock extends CommonObject
* @param integer|string $eatby eat-by date
* @param integer|string $sellby sell-by date
* @param string $batch batch number
* @param string $datem Force date of movement
* @param integer|string $datem Force date of movement
* @param int $id_product_batch Id product_batch
* @param string $inventorycode Inventory code
* @return int <0 if KO, >0 if OK
@ -804,28 +804,6 @@ class MouvementStock extends CommonObject
return $this->_create($user, $fk_product, $entrepot_id, $qty, 3, $price, $label, $inventorycode, $datem, $eatby, $sellby, $batch, $skip_batch, $id_product_batch);
}
// /**
// * Return nb of subproducts lines for a product
// *
// * @param int $id Id of product
// * @return int <0 if KO, nb of subproducts if OK
// * @deprecated A count($product->getChildsArbo($id,1)) is same. No reason to have this in this class.
// */
// public function nbOfSubProducts($id)
// {
// $nbSP=0;
// $resql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."product_association";
// $resql.= " WHERE fk_product_pere = ".((int) $id);
// if ($this->db->query($resql))
// {
// $obj=$this->db->fetch_object($resql);
// $nbSP=$obj->nb;
// }
// return $nbSP;
// }
/**
* Count number of product in stock before a specific date
*

View File

@ -1640,7 +1640,14 @@ if ($action == 'create') {
}
print '</td>';
} else {
if ($object->statut <= 1) {
$statusreceived = $object::STATUS_CLOSED;
if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION")) {
$statusreceived = $object::STATUS_VALIDATED;
}
if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION_CLOSE")) {
$statusreceived = $object::STATUS_CLOSED;
}
if ($object->statut < $statusreceived) {
print '<td class="center">'.$langs->trans("QtyToReceive").'</td>';
} else {
print '<td class="center">'.$langs->trans("QtyReceived").'</td>';
@ -1979,14 +1986,14 @@ if ($action == 'create') {
if ($object->statut == Reception::STATUS_DRAFT && $num_prod > 0) {
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer))
|| (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate))) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=valid">'.$langs->trans("Validate").'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid&token='.newToken().'">'.$langs->trans("Validate").'</a>';
} else {
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("Validate").'</a>';
}
}
// Edit
// Back to draft
if ($object->statut == Reception::STATUS_VALIDATED && $user->rights->reception->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id='.$object->id.'&amp;action=modif">'.$langs->trans('Modify').'</a></div>';
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id='.$object->id.'&action=modif&token='.newToken().'">'.$langs->trans('SetToDraft').'</a></div>';
}
// TODO add alternative status

View File

@ -138,7 +138,14 @@ class Reception extends CommonObject
$this->statuts = array();
$this->statuts[-1] = 'StatusReceptionCanceled';
$this->statuts[0] = 'StatusReceptionDraft';
// product to receive if stock increase is on close or already received if stock increase is on validation
$this->statuts[1] = 'StatusReceptionValidated';
if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION")) {
$this->statuts[1] = 'StatusReceptionValidatedReceived';
}
if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION_CLOSE")) {
$this->statuts[1] = 'StatusReceptionValidatedToReceive';
}
$this->statuts[2] = 'StatusReceptionProcessed';
// List of short language codes for status
@ -589,7 +596,8 @@ class Reception extends CommonObject
// line without batch detail
// We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record.
$result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionValidatedInDolibarr", $numref));
$inventorycode = '';
$result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionValidatedInDolibarr", $numref), '', '', '', '', 0, $inventorycode);
if ($result < 0) {
$error++;
$this->errors[] = $mouvS->error;
@ -601,7 +609,8 @@ class Reception extends CommonObject
// We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record.
// Note: ->fk_origin_stock = id into table llx_product_batch (may be rename into llx_product_stock_batch in another version)
$result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionValidatedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch);
$inventorycode = '';
$result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionValidatedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, '', 0, $inventorycode);
if ($result < 0) {
$error++;
$this->errors[] = $mouvS->error;
@ -1432,7 +1441,7 @@ class Reception extends CommonObject
}
/**
* Classify the reception as closed.
* Classify the reception as closed (this record also the stock movement)
*
* @return int <0 if KO, >0 if OK
*/
@ -1514,7 +1523,8 @@ class Reception extends CommonObject
// line without batch detail
// We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record
$result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionClassifyClosedInDolibarr", $numref));
$inventorycode = '';
$result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionClassifyClosedInDolibarr", $this->ref), '', '', '', '', 0, $inventorycode);
if ($result < 0) {
$this->error = $mouvS->error;
$this->errors = $mouvS->errors;
@ -1524,7 +1534,8 @@ class Reception extends CommonObject
// line with batch detail
// We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record
$result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionClassifyClosedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch);
$inventorycode = '';
$result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionClassifyClosedInDolibarr", $this->ref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, '', 0, $inventorycode);
if ($result < 0) {
$this->error = $mouvS->error;
@ -1676,7 +1687,8 @@ class Reception extends CommonObject
// line without batch detail
// We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record
$result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref));
$inventorycode = '';
$result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref), '', '', '', '', 0, $inventorycode);
if ($result < 0) {
$this->error = $mouvS->error;
$this->errors = $mouvS->errors;
@ -1686,7 +1698,8 @@ class Reception extends CommonObject
// line with batch detail
// We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record
$result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock);
$inventorycode = '';
$result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, '', $obj->fk_origin_stock, $inventorycode);
if ($result < 0) {
$this->error = $mouvS->error;
$this->errors = $mouvS->errors;
@ -1798,7 +1811,8 @@ class Reception extends CommonObject
// line without batch detail
// We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record
$result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref));
$inventorycode = '';
$result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref), '', '', '', '', 0, $inventorycode);
if ($result < 0) {
$this->error = $mouvS->error;
$this->errors = $mouvS->errors;
@ -1809,7 +1823,8 @@ class Reception extends CommonObject
// line with batch detail
// We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record
$result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch);
$inventorycode = '';
$result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, '', 0, $inventorycode);
if ($result < 0) {
$this->error = $mouvS->error;
$this->errors = $mouvS->errors;