diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index 76b201b51ef..b89263bae01 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -598,6 +598,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
* View
*/
+$form=new Form($db);
$formproject=new FormProjets($db);
$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
@@ -871,11 +872,8 @@ if ($action == 'create')
print '
| '.$langs->trans("Project").' | ';
- $numproject=$formproject->select_projects((! empty($societe->id)?$societe->id:-1),GETPOST("projectid")?GETPOST("projectid"):'','projectid');
- if ($numproject==0)
- {
- print ' '.$langs->trans("AddProject").'';
- }
+ $numproject=$formproject->select_projects((! empty($societe->id)?$societe->id:-1), GETPOST("projectid")?GETPOST("projectid"):'', 'projectid', 0, 0, 1, 1);
+ print ' '.$langs->trans("AddProject").'';
print ' |
';
}
if (!empty($origin) && !empty($originid))
diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index 16a0636e815..edd2607a11c 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -1494,7 +1494,7 @@ if ($action == 'create')
print '';
// Project
- if (! empty($conf->projet->enabled) && $socid > 0)
+ if (! empty($conf->projet->enabled))
{
$projectid = GETPOST('projectid')?GETPOST('projectid'):0;
if ($origin == 'project') $projectid = ($originid ? $originid : 0);
@@ -1502,7 +1502,7 @@ if ($action == 'create')
$langs->load("projects");
print '';
print '| ' . $langs->trans("Project") . ' | ';
- $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0);
+ $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1);
print ' id).'">' . $langs->trans("AddProject") . '';
print ' | ';
print '
';
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 473aa6cf42a..9474d54b925 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -1600,12 +1600,12 @@ if ($action == 'create' && $user->rights->commande->creer)
// TODO How record was recorded OrderMode (llx_c_input_method)
// Project
- if (! empty($conf->projet->enabled) && $socid > 0)
+ if (! empty($conf->projet->enabled))
{
$langs->load("projects");
print '';
print '| ' . $langs->trans("Project") . ' | ';
- $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0);
+ $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0);
print ' id).'">' . $langs->trans("AddProject") . '';
print ' | ';
print '
';
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index f98634da017..fb0bfe01d33 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -1090,7 +1090,7 @@ if ($action == 'create')
$objectsrc->fetch(GETPOST('originid'));
if (empty($objectsrc->lines) && method_exists($objectsrc,'fetch_lines')) $objectsrc->fetch_lines();
$objectsrc->fetch_thirdparty();
-
+
// Replicate extrafields
$objectsrc->fetch_optionals($originid);
$object->array_options = $objectsrc->array_options;
@@ -1193,10 +1193,13 @@ if ($action == 'create')
// Project
if (! empty($conf->projet->enabled))
{
+ $langs->load('projects');
+
$formproject=new FormProjets($db);
print '| '.$langs->trans("Project").' | ';
$formproject->select_projects(($soc->id>0?$soc->id:-1),$projectid,"projectid",0,0,1,1);
+ print ' id).'">' . $langs->trans("AddProject") . '';
print " |
";
}
diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php
index 5e2fb9b1b2b..84c37a1cf4f 100644
--- a/htdocs/core/class/html.formactions.class.php
+++ b/htdocs/core/class/html.formactions.class.php
@@ -191,7 +191,10 @@ class FormActions
$urlbacktopage=$_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage?'&'.$moreparambacktopage:'');
- $buttontoaddnewevent = '';
+ $projectid = $object->fk_project;
+ if ($typeelement == 'project') $projectid = $object->id;
+
+ $buttontoaddnewevent = '';
$buttontoaddnewevent.= $langs->trans("AddEvent");
$buttontoaddnewevent.= '';
diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php
index 6027941931d..9adf5adcd5d 100644
--- a/htdocs/core/class/html.formprojet.class.php
+++ b/htdocs/core/class/html.formprojet.class.php
@@ -68,7 +68,7 @@ class FormProjets
global $langs,$conf,$form;
$out='';
- var_dump($conf->global->PROJECT_USE_SEARCH_TO_SELECT);
+
if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT))
{
$placeholder='';
@@ -92,13 +92,13 @@ class FormProjets
else
{
$out.=$this->select_projects_list($socid, $selected, $htmlname, $maxlength, $option_only, $show_empty, $discard_closed, $forcefocus, $disabled, 0, $filterkey, 1, $forceaddid, $htmlid);
- if ($discard_closed)
+ }
+ if ($discard_closed)
+ {
+ if (class_exists('Form'))
{
- if (class_exists('Form'))
- {
- if (empty($form)) $form=new Form($this->db);
- $out.=$form->textwithpicto('', $langs->trans("ClosedProjectsAreHidden"));
- }
+ if (empty($form)) $form=new Form($this->db);
+ $out.=$form->textwithpicto('', $langs->trans("ClosedProjectsAreHidden"));
}
}
diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index 498d29c6fb4..8395a7d432f 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -1520,6 +1520,8 @@ if ($action=='create')
$langs->load('projects');
print '| ' . $langs->trans('Project') . ' | ';
$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$societe->id:-1), $projectid, 'projectid', 0, 0, 1, 1);
+ print ' id).'">' . $langs->trans("AddProject") . '';
+
print ' |
';
}
diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php
index 2519deb48e2..b7893ec1217 100644
--- a/htdocs/supplier_proposal/card.php
+++ b/htdocs/supplier_proposal/card.php
@@ -1097,7 +1097,9 @@ if ($action == 'create')
print "";
// Project
- if (! empty($conf->projet->enabled) && $socid > 0) {
+ if (! empty($conf->projet->enabled))
+ {
+ $langs->load("projects");
$formproject = new FormProjets($db);
@@ -1108,11 +1110,9 @@ if ($action == 'create')
print '';
print '| ' . $langs->trans("Project") . ' | ';
- $numprojet = $formproject->select_projects($soc->id, $projectid);
- if ($numprojet == 0) {
- $langs->load("projects");
- print ' ' . $langs->trans("AddProject") . '';
- }
+ $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1);
+ print ' id).'">' . $langs->trans("AddProject") . '';
+
print ' | ';
print '
';
}