Merge pull request #11950 from laudeco/hotfix/11881-remove-referent
[FIX][#11881] - remove referent from the project
This commit is contained in:
commit
ab33665f7b
@ -1676,9 +1676,11 @@ class Project extends CommonObject
|
|||||||
*
|
*
|
||||||
* @param string $tableName Table of the element to update
|
* @param string $tableName Table of the element to update
|
||||||
* @param int $elementSelectId Key-rowid of the line 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
|
* @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
|
// phpcs:enable
|
||||||
$sql="UPDATE ".MAIN_DB_PREFIX.$tableName;
|
$sql="UPDATE ".MAIN_DB_PREFIX.$tableName;
|
||||||
@ -1687,10 +1689,9 @@ class Project extends CommonObject
|
|||||||
{
|
{
|
||||||
$sql.= " SET fk_project=NULL";
|
$sql.= " SET fk_project=NULL";
|
||||||
$sql.= " WHERE id=".$elementSelectId;
|
$sql.= " WHERE id=".$elementSelectId;
|
||||||
}
|
}else
|
||||||
else
|
|
||||||
{
|
{
|
||||||
$sql.= " SET fk_projet=NULL";
|
$sql.= " SET ".$projectfield."=NULL";
|
||||||
$sql.= " WHERE rowid=".$elementSelectId;
|
$sql.= " WHERE rowid=".$elementSelectId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -512,10 +512,11 @@ if ($action=="addelement")
|
|||||||
elseif ($action == "unlink")
|
elseif ($action == "unlink")
|
||||||
{
|
{
|
||||||
|
|
||||||
$tablename = GETPOST("tablename");
|
$tablename = GETPOST("tablename", "aZ09");
|
||||||
$elementselectid = GETPOST("elementselect");
|
$projectField = GETPOST("projectfield", "aZ09");
|
||||||
|
$elementselectid = GETPOST("elementselect", "int");
|
||||||
|
|
||||||
$result = $object->remove_element($tablename, $elementselectid);
|
$result = $object->remove_element($tablename, $elementselectid, $projectField);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
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
|
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 '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $projectid . '&action=unlink&tablename=' . $tablename . '&elementselect=' . $element->id . '" class="reposition">';
|
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $projectid . '&action=unlink&tablename=' . $tablename . '&elementselect=' . $element->id . ($project_field ? '&projectfield=' . $project_field : '') . '" class="reposition">';
|
||||||
print img_picto($langs->trans('Unlink'), 'unlink');
|
print img_picto($langs->trans('Unlink'), 'unlink');
|
||||||
print '</a>';
|
print '</a>';
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user