diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index 7fc4def441b..915177164ac 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -602,7 +602,7 @@ class Expedition extends CommonObject
$this->fk_incoterms = $obj->fk_incoterms;
$this->location_incoterms = $obj->location_incoterms;
$this->libelle_incoterms = $obj->libelle_incoterms;
-
+
$this->db->free($result);
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
@@ -1379,6 +1379,7 @@ class Expedition extends CommonObject
// phpcs:enable
global $conf, $mysoc;
// TODO: recuperer les champs du document associe a part
+ $this->lines=array();
$sql = "SELECT cd.rowid, cd.fk_product, cd.label as custom_label, cd.description, cd.qty as qty_asked, cd.product_type";
$sql.= ", cd.total_ht, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.total_tva";
diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php
index 2261e06219b..7e64f9a5011 100644
--- a/htdocs/projet/class/project.class.php
+++ b/htdocs/projet/class/project.class.php
@@ -1676,9 +1676,11 @@ class Project extends CommonObject
*
* @param string $tableName Table of the element to update
* @param int $elementSelectId Key-rowid of the line of the element to update
+ * @param string $projectfield The column name that stores the link with the project
+ *
* @return int 1 if OK or < 0 if KO
*/
- public function remove_element($tableName, $elementSelectId)
+ public function remove_element($tableName, $elementSelectId, $projectfield = 'fk_projet')
{
// phpcs:enable
$sql="UPDATE ".MAIN_DB_PREFIX.$tableName;
@@ -1687,10 +1689,9 @@ class Project extends CommonObject
{
$sql.= " SET fk_project=NULL";
$sql.= " WHERE id=".$elementSelectId;
- }
- else
+ }else
{
- $sql.= " SET fk_projet=NULL";
+ $sql.= " SET ".$projectfield."=NULL";
$sql.= " WHERE rowid=".$elementSelectId;
}
diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php
index 4f5af0ca94f..97e99c93370 100644
--- a/htdocs/projet/element.php
+++ b/htdocs/projet/element.php
@@ -512,10 +512,11 @@ if ($action=="addelement")
elseif ($action == "unlink")
{
- $tablename = GETPOST("tablename");
- $elementselectid = GETPOST("elementselect");
+ $tablename = GETPOST("tablename", "aZ09");
+ $projectField = GETPOST("projectfield", "aZ09");
+ $elementselectid = GETPOST("elementselect", "int");
- $result = $object->remove_element($tablename, $elementselectid);
+ $result = $object->remove_element($tablename, $elementselectid, $projectField);
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
@@ -889,7 +890,7 @@ foreach ($listofreferent as $key => $value)
{
if (empty($conf->global->PROJECT_DISABLE_UNLINK_FROM_OVERVIEW) || $user->admin) // PROJECT_DISABLE_UNLINK_FROM_OVERVIEW is empty by defaut, so this test true
{
- print 'id . '" class="reposition">';
+ print 'id . ($project_field ? '&projectfield=' . $project_field : '') . '" class="reposition">';
print img_picto($langs->trans('Unlink'), 'unlink');
print '';
}