Skip to content

Commit

Permalink
Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
eldy committed Apr 27, 2024
2 parents f156610 + 2c06d41 commit 78017e4
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 48 deletions.
27 changes: 16 additions & 11 deletions htdocs/compta/bank/bankentries_list.php
Expand Up @@ -822,18 +822,23 @@
// Form to reconcile
if ($user->hasRight('banque', 'consolidate') && $action == 'reconcile') {
print '<div class="valignmiddle inline-block" style="padding-right: 20px;">';
$texttoshow = $langs->trans("InputReceiptNumber").': ';
$yyyy = dol_substr($langs->transnoentitiesnoconv("Year"), 0, 1).substr($langs->transnoentitiesnoconv("Year"), 0, 1).substr($langs->transnoentitiesnoconv("Year"), 0, 1).substr($langs->transnoentitiesnoconv("Year"), 0, 1);
$mm = dol_substr($langs->transnoentitiesnoconv("Month"), 0, 1).substr($langs->transnoentitiesnoconv("Month"), 0, 1);
$dd = dol_substr($langs->transnoentitiesnoconv("Day"), 0, 1).substr($langs->transnoentitiesnoconv("Day"), 0, 1);
$placeholder = $yyyy.$mm;
$placeholder .= ' '.$langs->trans("or").' ';
$placeholder .= $yyyy.$mm.$dd;
if (!$placeholder) {
$texttoshow .= $langs->trans("InputReceiptNumberBis");
if (getDolGlobalInt('NW_RECEIPTNUMBERFORMAT')) {
print '<strong>'.$langs->trans("InputReceiptNumber").'</strong>: ';
print '<input class="flat width175" id="num_releve" name="num_releve" type="text" value="'.(GETPOST('num_releve') ? GETPOST('num_releve') : '').'">';
} else {
$texttoshow = $langs->trans("InputReceiptNumber").': ';
$yyyy = dol_substr($langs->transnoentitiesnoconv("Year"), 0, 1).substr($langs->transnoentitiesnoconv("Year"), 0, 1).substr($langs->transnoentitiesnoconv("Year"), 0, 1).substr($langs->transnoentitiesnoconv("Year"), 0, 1);
$mm = dol_substr($langs->transnoentitiesnoconv("Month"), 0, 1).substr($langs->transnoentitiesnoconv("Month"), 0, 1);
$dd = dol_substr($langs->transnoentitiesnoconv("Day"), 0, 1).substr($langs->transnoentitiesnoconv("Day"), 0, 1);
$placeholder = $yyyy.$mm;
$placeholder .= ' '.$langs->trans("or").' ';
$placeholder .= $yyyy.$mm.$dd;
if (!$placeholder) {
$texttoshow .= $langs->trans("InputReceiptNumberBis");
}
print $texttoshow;
print '<input class="flat width175" pattern="[0-9]+" title="'.dol_escape_htmltag($texttoshow.($placeholder ? ': '.$placeholder : '')).'" id="num_releve" name="num_releve" placeholder="'.dol_escape_htmltag($placeholder).'" type="text" value="'.(GETPOSTINT('num_releve') ? GETPOSTINT('num_releve') : '').'">'; // The only default value is value we just entered
}
print $texttoshow;
print '<input class="flat width175" pattern="[0-9]+" title="'.dol_escape_htmltag($texttoshow.($placeholder ? ': '.$placeholder : '')).'" id="num_releve" name="num_releve" placeholder="'.dol_escape_htmltag($placeholder).'" type="text" value="'.(GETPOSTINT('num_releve') ? GETPOSTINT('num_releve') : '').'">'; // The only default value is value we just entered
print '</div>';
if (is_array($options) && count($options)) {
print $langs->trans("EventualyAddCategory").': ';
Expand Down
31 changes: 21 additions & 10 deletions htdocs/variants/class/ProductAttribute.class.php
Expand Up @@ -18,11 +18,20 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/**
* \file htdocs/variants/class/ProductAttribute.class.php
* \ingroup variants
* \brief File of the ProductAttribute class
*/

require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';

/**
* Class ProductAttribute
* Used to represent a product attribute
* Used to represent a Product attribute
* Examples:
* - Attribute 'color' (of type ProductAttribute) with values 'white', 'blue' or 'red' (each of type ProductAttributeValue).
* - Attribute 'size' (of type ProductAttribute) with values 'S', 'L' or 'XL' (each of type ProductAttributeValue).
*/
class ProductAttribute extends CommonObject
{
Expand All @@ -31,6 +40,7 @@ class ProductAttribute extends CommonObject
* @var DoliDB
*/
public $db;

/**
* @var string ID of module.
*/
Expand Down Expand Up @@ -144,6 +154,7 @@ class ProductAttribute extends CommonObject
* @var ProductAttributeValue[]
*/
public $lines = array();

/**
* @var ProductAttributeValue
*/
Expand Down Expand Up @@ -326,7 +337,7 @@ public function fetch($id)
}

/**
* Returns an array of all product variants
* Returns an array with all the ProductAttribute objects of a given entity
*
* @return ProductAttribute[]
*/
Expand Down Expand Up @@ -366,9 +377,9 @@ public function fetchAll()
/**
* Updates a product attribute
*
* @param User $user Object user
* @param int $notrigger Do not execute trigger
* @return int Return integer <0 KO, >0 OK
* @param User $user User who updates the attribute
* @param 0|1 $notrigger 1 = Do not execute trigger (0 by default)
* @return int<min,-1>|1 <0 if KO, 1 if OK
*/
public function update(User $user, $notrigger = 0)
{
Expand Down Expand Up @@ -782,9 +793,9 @@ public function countChildValues()
}

/**
* Returns the number of products that are using this attribute
* Return the number of product variants using this attribute
*
* @return int
* @return int<-1,max> -1 if K0, nb of variants using this attribute
*/
public function countChildProducts()
{
Expand All @@ -793,7 +804,7 @@ public function countChildProducts()
$count = 0;

// Clean parameters
$this->id = $this->id > 0 ? $this->id : 0;
$this->id = ($this->id > 0) ? $this->id : 0;

// Check parameters
if (empty($this->id)) {
Expand Down Expand Up @@ -827,9 +838,9 @@ public function countChildProducts()
}

/**
* Test if used by a product
* Test if this attribute is used by a Product
*
* @return int Return integer <0 KO, =0 if No, =1 if Yes
* @return -1|0|1 Return -1 if KO, 0 if not used, 1 if used
*/
public function isUsed()
{
Expand Down
40 changes: 29 additions & 11 deletions htdocs/variants/class/ProductCombination.class.php
Expand Up @@ -19,9 +19,24 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/**
* \file htdocs/variants/class/ProductCombination.class.php
* \ingroup variants
* \brief File of the ProductCombination class
*/

/**
* Class ProductCombination
* Used to represent a product combination
* Used to represent the relation between a product and one of its variants.
*
* Example: a product "shirt" has two variants "shirt XL white" and "shirt XL grey".
* This is represented with two ProductCombination objects:
* - One for "shirt XL white":
* * $object->fk_product_parent ID of the Product object "shirt"
* * $object->fk_product_child ID of the Product object "shirt XL white"
* - Another for "shirt XL grey":
* * $object->fk_product_parent ID of the Product object "shirt"
* * $object->fk_product_child ID of the Product object "shirt XL grey"
*/
class ProductCombination
{
Expand All @@ -32,19 +47,19 @@ class ProductCombination
public $db;

/**
* Rowid of combination
* Rowid of this ProductCombination
* @var int
*/
public $id;

/**
* Rowid of parent product
* Rowid of the parent Product
* @var int
*/
public $fk_product_parent;

/**
* Rowid of child product
* Rowid of the variant Product
* @var int
*/
public $fk_product_child;
Expand All @@ -56,7 +71,8 @@ class ProductCombination
public $variation_price;

/**
* Is the price variation a relative variation? Can be an array if multiprice feature per level is enabled.
* Is the price variation a relative variation?
* Can be an array if multiprice feature per level is enabled.
* @var bool|array
*/
public $variation_price_percentage = false;
Expand Down Expand Up @@ -86,12 +102,14 @@ class ProductCombination
public $variation_ref_ext = '';

/**
* @var string error
* Error message
* @var string
*/
public $error;

/**
* @var string[] array of errors
* Array of error messages
* @var string[]
*/
public $errors = array();

Expand All @@ -109,10 +127,10 @@ public function __construct(DoliDB $db)
}

/**
* Retrieves a combination by its rowid
* Retrieves a ProductCombination by its rowid
*
* @param int $rowid Row id
* @return int Return integer <0 KO, >0 OK
* @param int $rowid ID of the ProductCombination
* @return -1|1 -1 if KO, 1 if OK
*/
public function fetch($rowid)
{
Expand Down Expand Up @@ -153,7 +171,7 @@ public function fetch($rowid)
*
* @param int $fk_price_level The price level to fetch, use 0 for all
* @param bool $useCache To use cache or not
* @return int Return integer <0 KO, >0 OK
* @return -1|1 -1 if KO, 1 if OK
*/
public function fetchCombinationPriceLevels($fk_price_level = 0, $useCache = true)
{
Expand Down
55 changes: 39 additions & 16 deletions htdocs/variants/class/ProductCombination2ValuePair.class.php
Expand Up @@ -16,9 +16,27 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/**
* \file htdocs/variants/class/ProductCombination2ValuePair.class.php
* \ingroup variants
* \brief File of the ProductCombination2ValuePair class
*/


/**
* Class ProductCombination2ValuePair
* Used to represent the relation between a product combination, a product attribute and a product attribute value
* Used to represent the relation between a variant and its attributes.
*
* Example: a product "shirt" has a variant "shirt XL white" linked to the attributes "size: XL" and "color: white".
* This is represented with two ProductCombination2ValuePair objects:
* - One for "size: XL":
* * $object->fk_prod_combination ID of the ProductCombination object between product "shirt" and its variant "shirt XL white"
* * $object->fk_prod_attr ID of the ProductAttribute object "size"
* * $object->fk_prod_attr_val ID of the ProductAttributeValue object "XL"
* - Another for "color: white":
* * $object->fk_prod_combination ID of the ProductCombination object between product "shirt" and its variant "shirt XL white"
* * $object->fk_prod_attr ID of the ProductAttribute object "color"
* * $object->fk_prod_attr_val ID of the ProductAttributeValue object "white"
*/
class ProductCombination2ValuePair
{
Expand All @@ -29,36 +47,41 @@ class ProductCombination2ValuePair
private $db;

/**
* Combination 2 value pair id
* ID of this ProductCombination2ValuePair
* @var int
*/
public $id;

/**
* Product combination id
* ID of the ProductCombination linked to this object
* (ex: ID of the ProductCombination between product "shirt" and its variant "shirt XL white")
* @var int
*/
public $fk_prod_combination;

/**
* Product attribute id
* ID of the ProductAttribute linked to this object
* (ex: ID of the ProductAttribute "color")
* @var int
*/
public $fk_prod_attr;

/**
* Product attribute value id
* ID of the ProductAttributeValue linked to this object
* (ex: ID of the ProductAttributeValue "white")
* @var int
*/
public $fk_prod_attr_val;

/**
* @var string error
* Error message
* @var string
*/
public $error;

/**
* @var string[] array of errors
* Array of error messages
* @var string[]
*/
public $errors = array();

Expand Down Expand Up @@ -92,10 +115,10 @@ public function __toString()
}

/**
* Creates a product combination 2 value pair
* Create a ProductCombination2ValuePair
*
* @param User $user User that create
* @return int Return integer <0 KO, >0 OK
* @param User $user User that creates //not used
* @return -1|1 1 if OK, -1 if KO
*/
public function create($user)
{
Expand All @@ -115,10 +138,10 @@ public function create($user)
}

/**
* Retrieves a product combination 2 value pair from its rowid
* Retrieve all ProductCombination2ValuePair linked to a given ProductCombination ID.
*
* @param int $fk_combination Fk combination to search
* @return int|ProductCombination2ValuePair[] -1 if KO
* @param int $fk_combination ID of the ProductCombination
* @return -1|ProductCombination2ValuePair[] -1 if KO, array of ProductCombination2ValuePair if OK
*/
public function fetchByFkCombination($fk_combination)
{
Expand Down Expand Up @@ -154,10 +177,10 @@ public function fetchByFkCombination($fk_combination)
}

/**
* Deletes a product combination 2 value pair
* Delete all ProductCombination2ValuePair linked to a given ProductCombination ID.
*
* @param int $fk_combination Rowid of the combination
* @return int >0 OK <0 KO
* @param int $fk_combination ID of the ProductCombination
* @return -1|1 -1 if KO, 1 if OK
*/
public function deleteByFkCombination($fk_combination)
{
Expand Down

0 comments on commit 78017e4

Please sign in to comment.