Merge pull request #8789 from defrance/patch-116

NEW Add CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY and CONTRACT_HIDE_UNSELECTABLES by SELECT_HIDE_UNSELECTABLES
This commit is contained in:
Laurent Destailleur 2018-06-30 01:23:09 +02:00 committed by GitHub
commit c6b650a7bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 8 deletions

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2012-2013 Charles-Fr BENKE <charles.fr@benke.fr>
/* Copyright (C) 2012-2018 Charlene BENKE <charlie@patas-monkey.com>
*
* 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");

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (c) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
*
* 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))
{