Merge branch '14.0' of git@github.com:Dolibarr/dolibarr.git into 15.0

This commit is contained in:
Laurent Destailleur 2022-10-15 13:51:50 +02:00
commit 7387e535ef
6 changed files with 27 additions and 12 deletions

View File

@ -17,6 +17,7 @@
* Copyright (C) 2019 Thibault Foucart <support@ptibogxiv.net> * Copyright (C) 2019 Thibault Foucart <support@ptibogxiv.net>
* Copyright (C) 2020 Open-Dsi <support@open-dsi.fr> * Copyright (C) 2020 Open-Dsi <support@open-dsi.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr> * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2022 Ferran Marcet <fmarcet@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -7204,6 +7205,9 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__PROJECT_REF__'] = (is_object($object->projet) ? $object->projet->ref : ''); $substitutionarray['__PROJECT_REF__'] = (is_object($object->projet) ? $object->projet->ref : '');
$substitutionarray['__PROJECT_NAME__'] = (is_object($object->projet) ? $object->projet->title : ''); $substitutionarray['__PROJECT_NAME__'] = (is_object($object->projet) ? $object->projet->title : '');
} }
if (is_object($object) && $object->element == 'project') {
$substitutionarray['__PROJECT_NAME__'] = $object->title;
}
if (is_object($object) && $object->element == 'shipping') { if (is_object($object) && $object->element == 'shipping') {
$substitutionarray['__SHIPPINGTRACKNUM__'] = $object->tracking_number; $substitutionarray['__SHIPPINGTRACKNUM__'] = $object->tracking_number;

View File

@ -766,7 +766,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
<?php <?php
if (!empty($conf->global->PRODUCT_LOAD_EXTRAFIELD_INTO_OBJECTLINES)) { ?> if (!empty($conf->global->PRODUCT_LOAD_EXTRAFIELD_INTO_OBJECTLINES)) { ?>
jQuery.each(data.array_options, function( key, value ) { jQuery.each(data.array_options, function( key, value ) {
jQuery('div[class$="det'+key.replace('options_','_extras_')+'"] > #'+key).val(value); jQuery('div[class*="det'+key.replace('options_','_extras_')+'"] > #'+key).val(value);
}); });
<?php <?php
} ?> } ?>

View File

@ -75,7 +75,7 @@ if ($prodattr->fetch($id) < 0) {
$prodattrval = new ProductAttributeValue($db); $prodattrval = new ProductAttributeValue($db);
$res = $prodattrval->fetchAllByProductAttribute($id); $res = $prodattrval->fetchAllByProductAttribute($id, false, 1);
if ($res == -1) { if ($res == -1) {
print json_encode(array( print json_encode(array(

View File

@ -107,9 +107,10 @@ class ProductAttribute extends CommonObject
/** /**
* Returns an array of all product variants * Returns an array of all product variants
* *
* @return ProductAttribute[] * @param int $returnonlydata 0: return object, 1: return only data
* @return ProductAttribute[]
*/ */
public function fetchAll() public function fetchAll($returnonlydata = 0)
{ {
$return = array(); $return = array();
@ -118,7 +119,12 @@ class ProductAttribute extends CommonObject
$query = $this->db->query($sql); $query = $this->db->query($sql);
if ($query) { if ($query) {
while ($result = $this->db->fetch_object($query)) { while ($result = $this->db->fetch_object($query)) {
$tmp = new ProductAttribute($this->db); if (empty($returnonlydata)) {
$tmp = new ProductAttribute($this->db);
} else {
$tmp = new stdClass();
}
$tmp->id = $result->rowid; $tmp->id = $result->rowid;
$tmp->ref = $result->ref; $tmp->ref = $result->ref;
$tmp->ref_ext = $result->ref_ext; $tmp->ref_ext = $result->ref_ext;

View File

@ -99,11 +99,12 @@ class ProductAttributeValue extends CommonObject
/** /**
* Returns all product attribute values of a product attribute * Returns all product attribute values of a product attribute
* *
* @param int $prodattr_id Product attribute id * @param int $prodattr_id Product attribute id
* @param bool $only_used Fetch only used attribute values * @param bool $only_used Fetch only used attribute values
* @return ProductAttributeValue[] * @param int $returnonlydata 0: return object, 1: return only data
* @return ProductAttributeValue[]
*/ */
public function fetchAllByProductAttribute($prodattr_id, $only_used = false) public function fetchAllByProductAttribute($prodattr_id, $only_used = false, $returnonlydata = 0)
{ {
$return = array(); $return = array();
@ -130,7 +131,12 @@ class ProductAttributeValue extends CommonObject
$query = $this->db->query($sql); $query = $this->db->query($sql);
while ($result = $this->db->fetch_object($query)) { while ($result = $this->db->fetch_object($query)) {
$tmp = new ProductAttributeValue($this->db); if (empty($returnonlydata)) {
$tmp = new ProductAttributeValue($this->db);
} else {
$tmp = new stdClass();
}
$tmp->fk_product_attribute = $result->fk_product_attribute; $tmp->fk_product_attribute = $result->fk_product_attribute;
$tmp->id = $result->rowid; $tmp->id = $result->rowid;
$tmp->ref = $result->ref; $tmp->ref = $result->ref;

View File

@ -481,7 +481,7 @@ if (!empty($id) || !empty($ref)) {
} }
if ($action == 'add') { if ($action == 'add') {
$prodattr_all = $prodattr->fetchAll(); $prodattr_all = $prodattr->fetchAll(1);
if (!$selected) { if (!$selected) {
$selected = $prodattr_all[key($prodattr_all)]->id; $selected = $prodattr_all[key($prodattr_all)]->id;
@ -492,7 +492,6 @@ if (!empty($id) || !empty($ref)) {
foreach ($prodattr_all as $each) { foreach ($prodattr_all as $each) {
$prodattr_alljson[$each->id] = $each; $prodattr_alljson[$each->id] = $each;
} }
?> ?>
<script type="text/javascript"> <script type="text/javascript">