New: Add hidden option PROJECT_HIDE_UNSELECTABLES

This commit is contained in:
Laurent Destailleur 2011-11-09 18:52:59 +01:00
parent 7d0a7f569e
commit 9f42438714
2 changed files with 490 additions and 475 deletions

View File

@ -24,6 +24,7 @@ For users:
- New: Can search on part of barcode into POS module. - New: Can search on part of barcode into POS module.
- New: Cheques into cheques receipts are ordered by operation date. - New: Cheques into cheques receipts are ordered by operation date.
- New: Add hidden option MAIN_DISABLE_PDF_AUTOUPDATE to avoid generating pdf each time data change. - New: Add hidden option MAIN_DISABLE_PDF_AUTOUPDATE to avoid generating pdf each time data change.
- New: Add hidden option PROJECT_HIDE_UNSELECTABLES to hide project you can't select into combo list.
- Fix: Can use POS module with several concurrent users. - Fix: Can use POS module with several concurrent users.
For developers: For developers:

View File

@ -1,22 +1,22 @@
<?php <?php
/* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/ * or see http://www.gnu.org/
*/ */
/** /**
* \file htdocs/core/lib/project.lib.php * \file htdocs/core/lib/project.lib.php
@ -145,16 +145,20 @@ function task_prepare_head($object)
/** /**
* \brief Show a combo list with projects qualified for a third party * Show a combo list with projects qualified for a third party
* \param socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id) *
* \param selected Id project preselected * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id)
* \param htmlname Nom de la zone html * @param int $selected Id project preselected
* \return int Nbre of project if OK, <0 if KO * @param string $htmlname Nom de la zone html
* @return int Nbre of project if OK, <0 if KO
*/ */
function select_projects($socid=-1, $selected='', $htmlname='projectid') function select_projects($socid=-1, $selected='', $htmlname='projectid')
{ {
global $db,$user,$conf,$langs; global $db,$user,$conf,$langs;
$hideunselectables = false;
if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;
$projectstatic=new Project($db); $projectstatic=new Project($db);
$projectsListId = ''; $projectsListId = '';
if (empty($user->rights->projet->all->lire)) if (empty($user->rights->projet->all->lire))
@ -203,7 +207,6 @@ function select_projects($socid=-1, $selected='', $htmlname='projectid')
else else
{ {
$disabled=0; $disabled=0;
print '<option value="'.$obj->rowid.'"';
if (! $obj->fk_statut > 0) if (! $obj->fk_statut > 0)
{ {
$disabled=1; $disabled=1;
@ -214,11 +217,22 @@ function select_projects($socid=-1, $selected='', $htmlname='projectid')
$disabled=1; $disabled=1;
$labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany"); $labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany");
} }
if ($disabled==1) print ' disabled="disabled"';
else $labeltoshow.=' - '.dol_trunc($obj->title,12); if ($hideunselectables && $disabled)
{
$resultat='';
}
else
{
$resultat='<option value="'.$obj->rowid.'"';
if ($disabled) $resultat.=' disabled="disabled"';
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')'; //if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')'; //else $labeltoshow.=' ('.$langs->trans("Private").')';
print '>'.$labeltoshow.'</option>'; $resultat.='>'.$labeltoshow;
if (! $disabled) $resultat.=' - '.dol_trunc($obj->title,12);
$resultat.='</option>';
}
print $resultat;
} }
} }
$i++; $i++;