';
diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php
index c4cdcba3fff..1dccb2c2456 100644
--- a/htdocs/core/lib/project.lib.php
+++ b/htdocs/core/lib/project.lib.php
@@ -422,16 +422,17 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
/**
* Output a task line
*
- * @param string &$inc ?
- * @param string $parent ?
- * @param Object $lines ?
- * @param int &$level ?
- * @param string &$projectsrole ?
- * @param string &$tasksrole ?
- * @param int $mytask 0 or 1 to enable only if task is a task i am affected to
+ * @param string &$inc ?
+ * @param string $parent ?
+ * @param Object $lines ?
+ * @param int &$level ?
+ * @param string &$projectsrole ?
+ * @param string &$tasksrole ?
+ * @param string $mine Show only task lines I am assigned to
+ * @param int $restricteditformytask 0=No restriction, 1=Enable add time only if task is a task i am affected to
* @return $inc
*/
-function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mytask=0)
+function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask=0)
{
global $user, $bc, $langs;
global $form, $projectstatic, $taskstatic;
@@ -454,99 +455,104 @@ function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksr
$lastprojectid=$lines[$i]->fk_project;
}
- print "\n";
-
- // Project
- print "";
- $projectstatic->id=$lines[$i]->fk_project;
- $projectstatic->ref=$lines[$i]->projectref;
- $projectstatic->public=$lines[$i]->public;
- $projectstatic->label=$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project];
- print $projectstatic->getNomUrl(1);
- print " ";
-
- // Ref
- print '';
- $taskstatic->id=$lines[$i]->id;
- $taskstatic->ref=$lines[$i]->id;
- print $taskstatic->getNomUrl(1);
- print ' ';
-
- // Label task
- print "";
- for ($k = 0 ; $k < $level ; $k++)
+ // If we want all or we have a role on task, we show it
+ if (empty($mine) || ! empty($tasksrole[$lines[$i]->id]))
{
- print " ";
- }
- $taskstatic->id=$lines[$i]->id;
- $taskstatic->ref=$lines[$i]->label;
- print $taskstatic->getNomUrl(0);
- print " \n";
-
- // Date start
- print '';
- print dol_print_date($lines[$i]->date_start,'day');
- print ' ';
-
- // Date end
- print '';
- print dol_print_date($lines[$i]->date_end,'day');
- print ' ';
-
- // Planned Workload
- print '';
- if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin');
- else print '--:--';
- print ' ';
-
- // Progress declared %
- print '';
- print $lines[$i]->progress.' %';
- print ' ';
-
- // Time spent
- print '';
- if ($lines[$i]->duration)
- {
- print '';
- print convertSecondToTime($lines[$i]->duration,'allhourmin');
- print ' ';
- }
- else print '--:--';
- print " \n";
-
- $disabledproject=1;$disabledtask=1;
- //print "x".$lines[$i]->fk_project;
- //var_dump($lines[$i]);
- //var_dump($projectsrole[$lines[$i]->fk_project]);
- // If at least one role for project
- if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer)
- {
- $disabledproject=0;
- $disabledtask=0;
- }
- // If mytask and no role on task
- if ($mytask && empty($tasksrole[$lines[$i]->id]))
- {
- $disabledtask=1;
+ print " \n";
+
+ // Project
+ print "";
+ $projectstatic->id=$lines[$i]->fk_project;
+ $projectstatic->ref=$lines[$i]->projectref;
+ $projectstatic->public=$lines[$i]->public;
+ $projectstatic->label=$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project];
+ print $projectstatic->getNomUrl(1);
+ print " ";
+
+ // Ref
+ print '';
+ $taskstatic->id=$lines[$i]->id;
+ $taskstatic->ref=$lines[$i]->id;
+ print $taskstatic->getNomUrl(1);
+ print ' ';
+
+ // Label task
+ print "";
+ for ($k = 0 ; $k < $level ; $k++)
+ {
+ print " ";
+ }
+ $taskstatic->id=$lines[$i]->id;
+ $taskstatic->ref=$lines[$i]->label;
+ print $taskstatic->getNomUrl(0);
+ print " \n";
+
+ // Date start
+ print '';
+ print dol_print_date($lines[$i]->date_start,'dayhour');
+ print ' ';
+
+ // Date end
+ print '';
+ print dol_print_date($lines[$i]->date_end,'dayhour');
+ print ' ';
+
+ // Planned Workload
+ print '';
+ if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin');
+ else print '--:--';
+ print ' ';
+
+ // Progress declared %
+ print '';
+ print $lines[$i]->progress.' %';
+ print ' ';
+
+ // Time spent
+ print '';
+ if ($lines[$i]->duration)
+ {
+ print '';
+ print convertSecondToTime($lines[$i]->duration,'allhourmin');
+ print ' ';
+ }
+ else print '--:--';
+ print " \n";
+
+ $disabledproject=1;$disabledtask=1;
+ //print "x".$lines[$i]->fk_project;
+ //var_dump($lines[$i]);
+ //var_dump($projectsrole[$lines[$i]->fk_project]);
+ // If at least one role for project
+ if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer)
+ {
+ $disabledproject=0;
+ $disabledtask=0;
+ }
+ // If $restricteditformytask is on and I have no role on task, i disable edit
+ if ($restricteditformytask && empty($tasksrole[$lines[$i]->id]))
+ {
+ $disabledtask=1;
+ }
+
+ print '';
+ $s =$form->select_date('',$lines[$i]->id,'','','',"addtime",1,0,1,$disabledtask);
+ $s.=' ';
+ $s.=$form->select_duration($lines[$i]->id,'',$disabledtask,'text');
+ $s.=' ';
+ print $s;
+ print ' ';
+ print '';
+ if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("YouAreNotContactOfProject"));
+ else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAffectedToYou"));
+ print ' ';
+
+ print " \n";
}
- print '';
- $s =$form->select_date('',$lines[$i]->id,'','','',"addtime",1,0,1,$disabledtask);
- $s.=' ';
- $s.=$form->select_duration($lines[$i]->id,'',$disabledtask,'text');
- $s.=' ';
- print $s;
- print ' ';
- print '';
- if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("YouAreNotContactOfProject"));
- else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAffectedToYou"));
- print ' ';
-
- print "\n";
$inc++;
$level++;
- if ($lines[$i]->id) projectLinesb($inc, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mytask);
+ if ($lines[$i]->id) projectLinesb($inc, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask);
$level--;
}
else
diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php
index f8b991969e1..086d44254c8 100644
--- a/htdocs/fourn/facture/fiche.php
+++ b/htdocs/fourn/facture/fiche.php
@@ -1287,18 +1287,8 @@ if ($action == 'create')
$form->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id,'mode_reglement_id');
print '';
- // Project
- if (! empty($conf->projet->enabled))
- {
- $formproject=new FormProjets($db);
-
- $langs->load('projects');
- print ''.$langs->trans('Project').' ';
- $formproject->select_projects(-1, $projectid, 'projectid');
- print ' ';
- }
-
- print ''.$langs->trans('NotePublic').' ';
+ // Public note
+ print ''.$langs->trans('NotePublic').' ';
print '';
$doleditor = new DolEditor('note_public', GETPOST('note_public'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
print $doleditor->Create(1);
@@ -1822,11 +1812,11 @@ else
print ' ';
if ($action == 'classify')
{
- $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id,$object->socid,$object->fk_project,'projectid');
+ $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:'-1', $object->fk_project, 'projectid');
}
else
{
- $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id,$object->socid,$object->fk_project,'none');
+ $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none');
}
print ' ';
print ' ';
diff --git a/htdocs/projet/activity/list.php b/htdocs/projet/activity/list.php
index e9cb8568b65..61683aa18b4 100644
--- a/htdocs/projet/activity/list.php
+++ b/htdocs/projet/activity/list.php
@@ -114,8 +114,6 @@ $title=$langs->trans("TimeSpent");
if ($mine) $title=$langs->trans("MyTimeSpent");
-llxHeader("",$title,"");
-
//$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1);
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project
@@ -133,6 +131,9 @@ $tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0,$user,($project->id?$pr
//var_dump($taskrole);
+
+llxHeader("",$title,"");
+
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num);
@@ -156,8 +157,18 @@ print ''.$langs->trans("Progress").' ';
print ''.$langs->trans("TimeSpent").' ';
print ''.$langs->trans("AddDuration").' ';
print "\n";
-projectLinesb($j, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine);
+// By default, we can edit only tasks we are assigned to
+$restricteditformytask=(empty($conf->global->PROJECT_TIME_ON_ALL_TASKS_MY_PROJECTS)?1:0);
+
+if (count($tasksarray) > 0)
+{
+ projectLinesb($j, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask);
+}
+else
+{
+ print ''.$langs->trans("NoTasks").' ';
+}
print "";
print '';
diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php
index b9ebc7ae5de..36a8e26cf38 100644
--- a/htdocs/projet/tasks/time.php
+++ b/htdocs/projet/tasks/time.php
@@ -65,7 +65,8 @@ if ($action == 'addtimespent' && $user->rights->projet->creer)
}
if (empty($_POST["userid"]))
{
- setEventMessage($langs->trans('ErrorUserNotAffectedToTask'),'errors');
+ $langs->load("errors");
+ setEventMessage($langs->trans('ErrorUserNotAssignedToTask'),'errors');
$error++;
}
@@ -327,9 +328,13 @@ if ($id > 0 || ! empty($ref))
// Contributor
print '';
- $contactoftask=$object->getListContactId('internal');
+ $restrictaddtimetocontactoftask=0;
+ if (empty($conf->global->PROJECT_TIME_ON_ALL_TASKS_MY_PROJECTS))
+ {
+ $restrictaddtimetocontactoftask=$object->getListContactId('internal');
+ }
print img_object('','user');
- print $form->select_dolusers($_POST["userid"]?$_POST["userid"]:$user->id,'userid',0,'',0,'',$contactoftask);
+ print $form->select_dolusers($_POST["userid"]?$_POST["userid"]:$user->id,'userid',0,'',0,'',$restrictaddtimetocontactoftask); // Note: If user is not allowed it will be disabled into combo list and userid not posted
print ' ';
// Note