NEW Add option PROJECT_THIRDPARTY_REQUIRED

This commit is contained in:
Laurent Destailleur 2017-02-15 18:09:45 +01:00
parent eb70d6eea1
commit 3803330701
2 changed files with 17 additions and 3 deletions

View File

@ -507,7 +507,11 @@ if ($action == 'create' && $user->rights->projet->creer)
// Thirdparty
if ($conf->societe->enabled)
{
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td class="maxwidthonsmartphone">';
print '<tr><td>';
print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':'<span class="fieldrequired">');
print $langs->trans("ThirdParty");
print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':'</span>');
print '</td><td class="maxwidthonsmartphone">';
$filteronlist='';
if (! empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist=$conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST;
$text=$form->select_thirdparty_list(GETPOST('socid','int'), 'socid', $filteronlist, 'SelectThirdParty', 1, 0, array(), '', 0, 0, 'minwidth300');
@ -719,7 +723,11 @@ elseif ($object->id > 0)
// Thirdparty
if ($conf->societe->enabled)
{
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
print '<tr><td>';
print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':'<span class="fieldrequired">');
print $langs->trans("ThirdParty");
print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':'</span>');
print '</td><td>';
$filteronlist='';
if (! empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist=$conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST;
$text=$form->select_thirdparty_list($object->thirdparty->id, 'socid', $filteronlist, 'None', 1, 0, array(), '', 0, 0, 'minwidth300');

View File

@ -139,7 +139,13 @@ class Project extends CommonObject
dol_syslog(get_class($this)."::create error -1 ref null", LOG_ERR);
return -1;
}
if (! empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) && ! $this->socid > 0)
{
$this->error = 'ErrorFieldsRequired';
dol_syslog(get_class($this)."::create error -1 ref null", LOG_ERR);
return -1;
}
$this->db->begin();
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "projet (";