diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php
index f4902e4912e..a3a3696e5f4 100644
--- a/htdocs/core/class/html.formcontract.class.php
+++ b/htdocs/core/class/html.formcontract.class.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2012-2018 Charlene BENKE
*
* 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
@@ -57,15 +57,25 @@ class FormContract
global $db,$user,$conf,$langs;
$hideunselectables = false;
- if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;
+ if (! empty($conf->global->CONTRACT_HIDE_UNSELECTABLES)) $hideunselectables = true;
// Search all contacts
$sql = 'SELECT c.rowid, c.ref, c.fk_soc, c.statut';
$sql.= ' FROM '.MAIN_DB_PREFIX .'contrat as c';
$sql.= " WHERE c.entity = ".$conf->entity;
//if ($contratListId) $sql.= " AND c.rowid IN (".$contratListId.")";
+ if ($socid > 0)
+ {
+ // CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma.
+ if (empty($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY))
+ $sql.= " AND (c.fk_soc=".$socid." OR c.fk_soc IS NULL)";
+ else if ($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all')
+ {
+ $sql.= " AND (c.fk_soc IN (".$socid.", ".$conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") ";
+ $sql.= " OR c.fk_soc IS NULL)";
+ }
+ }
if ($socid == 0) $sql.= " AND (c.fk_soc = 0 OR c.fk_soc IS NULL)";
- if ($socid > 0) $sql.= " AND (c.fk_soc=".$socid." OR c.fk_soc IS NULL)";
$sql.= " ORDER BY c.ref ";
dol_syslog(get_class($this)."::select_contract", LOG_DEBUG);
@@ -98,12 +108,12 @@ class FormContract
else
{
$disabled=0;
- if (! $obj->statut > 0)
+ if ( $obj->statut == 0)
{
$disabled=1;
$labeltoshow.=' ('.$langs->trans("Draft").')';
}
- if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid))
+ if ( empty($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY) && $socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid))
{
$disabled=1;
$labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany");
diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php
index a572d546ca7..f437920caf9 100644
--- a/htdocs/core/class/html.formprojet.class.php
+++ b/htdocs/core/class/html.formprojet.class.php
@@ -1,6 +1,7 @@
* Copyright (C) 2015 Marcos GarcĂa
+ * Copyright (C) 2018 Charlene Benke
*
* 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
@@ -139,10 +140,10 @@ class FormProjets
if (empty($htmlid)) $htmlid = $htmlname;
$out='';
- $outarray=array();
+ $outarray=array();
$hideunselectables = false;
- if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;
+ if (! empty($conf->global->CONTRACT_HIDE_UNSELECTABLES)) $hideunselectables = true;
$projectsListId = false;
if (empty($user->rights->projet->all->lire))
@@ -317,7 +318,7 @@ class FormProjets
$out='';
$hideunselectables = false;
- if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;
+ if (! empty($conf->global->CONTRACT_HIDE_UNSELECTABLES)) $hideunselectables = true;
if (empty($projectsListId))
{