Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
9427addc39
3 changed files with 40 additions and 3 deletions
|
|
@ -1197,6 +1197,40 @@ class Setup extends DolibarrApi
|
|||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete extrafield
|
||||
*
|
||||
* @param string $attrname extrafield attrname
|
||||
* @param string $elementtype extrafield elementtype
|
||||
* @return array
|
||||
*
|
||||
* @url DELETE extrafields/{elementtype}/{attrname}
|
||||
*
|
||||
*/
|
||||
public function deleteExtrafieldsFromNames($attrname, $elementtype)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->admin) {
|
||||
throw new RestException(403, 'Only an admin user can delete an extrafield by attrname and elementtype');
|
||||
}
|
||||
|
||||
$extrafields = new ExtraFields($this->db);
|
||||
|
||||
$result = $extrafields->fetch_name_optionals_label($elementtype, false, $attrname);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Extrafield not found from attrname and elementtype');
|
||||
}
|
||||
|
||||
if (!$extrafields->delete($attrname, $elementtype)) {
|
||||
throw new RestException(500, 'Error when delete extrafield : '.$extrafields->error);
|
||||
}
|
||||
|
||||
return array(
|
||||
'success' => array(
|
||||
'code' => 200,
|
||||
'message' => 'Extrafield deleted from attrname and elementtype'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of towns.
|
||||
|
|
|
|||
|
|
@ -824,16 +824,16 @@ class ExtraFields
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Load the array of extrafields definition $this->attributes
|
||||
*
|
||||
* @param string $elementtype Type of element ('all' = all or $object->table_element like 'adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...).
|
||||
* @param boolean $forceload Force load of extra fields whatever is status of cache.
|
||||
* @param string $attrname The name of the attribute.
|
||||
* @return array{}|array{label:array<string,string>,type:array<string,string>,size:array<string,string>,default:array<string,string>,computed:array<string,string>,unique:array<string,int>,required:array<string,int>,param:array<string,mixed>,perms:array<string,mixed[]>,list:array<string,int>|array<string,string>,pos:array<string,int>,totalizable:array<string,int>,help:array<string,string>,printable:array<string,int>,enabled:array<string,int>,langfile:array<string,string>,css:array<string,string>,csslist:array<string,string>,hidden:array<string,int>,mandatoryfieldsofotherentities?:array<string,string>,loaded?:int,count:int} Array of attributes keys+label for all extra fields. Note: count set as present to avoid static analysis notices
|
||||
*/
|
||||
public function fetch_name_optionals_label($elementtype, $forceload = false)
|
||||
public function fetch_name_optionals_label($elementtype, $forceload = false, $attrname = '')
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf;
|
||||
|
|
@ -865,6 +865,9 @@ class ExtraFields
|
|||
if ($elementtype && $elementtype != 'all') {
|
||||
$sql .= " WHERE elementtype = '".$this->db->escape($elementtype)."'"; // Filed with object->table_element
|
||||
}
|
||||
if ($attrname && $elementtype && $elementtype != 'all') {
|
||||
$sql .= " AND name = '".$this->db->escape($attrname)."'";
|
||||
}
|
||||
$sql .= " ORDER BY pos";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
|
|
|||
|
|
@ -856,10 +856,10 @@ class Product extends CommonObject
|
|||
$sql .= ", ".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null");
|
||||
$sql .= ", ".((int) $user->id);
|
||||
$sql .= ", ".((int) $this->type);
|
||||
$sql .= ", ".(!empty($this->price_label) ? "'".$this->db->escape($this->price_label)."'" : "null");
|
||||
$sql .= ", ".price2num($price_ht, 'MT');
|
||||
$sql .= ", ".price2num($price_ttc, 'MT');
|
||||
$sql .= ", '".$this->db->escape($this->price_base_type)."'";
|
||||
$sql .= ", ".(!empty($this->price_label) ? "'".$this->db->escape($this->price_label)."'" : "null");
|
||||
$sql .= ", ".((int) $this->status);
|
||||
$sql .= ", ".((int) $this->status_buy);
|
||||
if (!getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue