diff --git a/htdocs/projet/tasks/comment.php b/htdocs/projet/tasks/comment.php index aaa8bd0cd89..76c5239fc17 100644 --- a/htdocs/projet/tasks/comment.php +++ b/htdocs/projet/tasks/comment.php @@ -47,13 +47,6 @@ $withproject = GETPOST('withproject', 'int'); $project_ref = GETPOST('project_ref', 'alpha'); $planned_workload = ((GETPOST('planned_workloadhour', 'int') != '' || GETPOST('planned_workloadmin', 'int') != '') ? (GETPOST('planned_workloadhour', 'int') > 0 ?GETPOST('planned_workloadhour', 'int') * 3600 : 0) + (GETPOST('planned_workloadmin', 'int') > 0 ?GETPOST('planned_workloadmin', 'int') * 60 : 0) : ''); -// Security check -$socid = 0; -//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. -if (!$user->rights->projet->lire) { - accessforbidden(); -} - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('projecttaskcommentcard', 'globalcard')); @@ -79,10 +72,21 @@ if (!empty($project_ref) && !empty($withproject)) { } } + +if ($id > 0 || $ref) { + $object->fetch($id, $ref); +} + +// Security check +$socid = 0; + +restrictedArea($user, 'projet', $object->fk_project, 'projet&project'); + + + /* * View -*/ - + */ llxHeader('', $langs->trans("CommentPage")); diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index 3aa5c3b8830..1f74d1bbc75 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -40,17 +40,18 @@ $confirm = GETPOST('confirm', 'alpha'); $withproject = GETPOST('withproject', 'int'); $project_ref = GETPOST('project_ref', 'alpha'); -// Security check -$socid = 0; -//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. -//$result = restrictedArea($user, 'projet', $id, 'projet_task'); -if (!$user->rights->projet->lire) { - accessforbidden(); -} - $object = new Task($db); $projectstatic = new Project($db); +if ($id > 0 || $ref) { + $object->fetch($id, $ref); +} + +// Security check +$socid = 0; + +restrictedArea($user, 'projet', $object->fk_project, 'projet&project'); + /* * Actions diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index d9c49001dfc..3a56a7a018a 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -37,21 +37,13 @@ $langs->loadLangs(array('projects', 'other')); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); -$mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; +$mine = GETPOST('mode') == 'mine' ? 1 : 0; //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $withproject = GETPOST('withproject', 'int'); $project_ref = GETPOST('project_ref', 'alpha'); -// Security check -$socid = 0; -//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. -//$result=restrictedArea($user,'projet',$id,''); -if (!$user->rights->projet->lire) { - accessforbidden(); -} - // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -73,6 +65,17 @@ if (!$sortfield) { $object = new Task($db); $projectstatic = new Project($db); +if ($id > 0 || $ref) { + $object->fetch($id, $ref); +} + +// Security check +$socid = 0; + +restrictedArea($user, 'projet', $object->fk_project, 'projet&project'); + + + /* * Actions */ @@ -92,25 +95,21 @@ if (!empty($project_ref) && !empty($withproject)) { } if ($id > 0 || !empty($ref)) { - if ($object->fetch($id, $ref) > 0) { - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) { - $object->fetchComments(); - } - $projectstatic->fetch($object->fk_project); - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { - $projectstatic->fetchComments(); - } - - if (!empty($projectstatic->socid)) { - $projectstatic->fetch_thirdparty(); - } - - $object->project = clone $projectstatic; - - $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($projectstatic->ref).'/'.dol_sanitizeFileName($object->ref); - } else { - dol_print_error($db); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) { + $object->fetchComments(); } + $projectstatic->fetch($object->fk_project); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { + $projectstatic->fetchComments(); + } + + if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); + } + + $object->project = clone $projectstatic; + + $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($projectstatic->ref).'/'.dol_sanitizeFileName($object->ref); } include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index 4d581afc30a..3ad4aaa3b7b 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -31,7 +31,7 @@ $langs->load('projects'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); -$mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; +$mine = GETPOST('mode') == 'mine' ? 1 : 0; //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -82,6 +82,12 @@ if (!empty($project_ref) && !empty($withproject)) { } } +if ($id > 0 || $ref) { + $object->fetch($id, $ref); +} + +restrictedArea($user, 'projet', $object->fk_project, 'projet&project'); + $permissionnote = ($user->rights->projet->creer || $user->rights->projet->all->creer); diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 780d387512e..b31ba6f0e7b 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -46,13 +46,6 @@ $withproject = GETPOST('withproject', 'int'); $project_ref = GETPOST('project_ref', 'alpha'); $planned_workload = ((GETPOST('planned_workloadhour', 'int') != '' || GETPOST('planned_workloadmin', 'int') != '') ? (GETPOST('planned_workloadhour', 'int') > 0 ?GETPOST('planned_workloadhour', 'int') * 3600 : 0) + (GETPOST('planned_workloadmin', 'int') > 0 ?GETPOST('planned_workloadmin', 'int') * 60 : 0) : ''); -// Security check -$socid = 0; -//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. -if (!$user->rights->projet->lire) { - accessforbidden(); -} - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('projecttaskcard', 'globalcard')); @@ -69,6 +62,17 @@ if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } +if ($id > 0 || $ref) { + $object->fetch($id, $ref); +} + +// Security check +$socid = 0; + +restrictedArea($user, 'projet', $object->fk_project, 'projet&project'); + + + /* * Actions */ @@ -85,7 +89,6 @@ if ($action == 'update' && !GETPOST("cancel") && $user->rights->projet->creer) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); } if (!$error) { - $object->fetch($id, $ref); $object->oldcopy = clone $object; $tmparray = explode('_', $_POST['task_parent']); @@ -121,17 +124,15 @@ if ($action == 'update' && !GETPOST("cancel") && $user->rights->projet->creer) { } if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->supprimer) { - if ($object->fetch($id, $ref) >= 0) { - $result = $projectstatic->fetch($object->fk_project); - $projectstatic->fetch_thirdparty(); + $result = $projectstatic->fetch($object->fk_project); + $projectstatic->fetch_thirdparty(); - if ($object->delete($user) > 0) { - header('Location: '.DOL_URL_ROOT.'/projet/tasks.php?restore_lastsearch_values=1&id='.$projectstatic->id.($withproject ? '&withproject=1' : '')); - exit; - } else { - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } + if ($object->delete($user) > 0) { + header('Location: '.DOL_URL_ROOT.'/projet/tasks.php?restore_lastsearch_values=1&id='.$projectstatic->id.($withproject ? '&withproject=1' : '')); + exit; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; } } @@ -149,8 +150,6 @@ if (!empty($project_ref) && !empty($withproject)) { // Build doc if ($action == 'builddoc' && $user->rights->projet->creer) { - $object->fetch($id, $ref); - // Save last template used to generate document if (GETPOST('model')) { $object->setDocModel($user, GETPOST('model', 'alpha')); @@ -172,17 +171,15 @@ if ($action == 'builddoc' && $user->rights->projet->creer) { if ($action == 'remove_file' && $user->rights->projet->creer) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if ($object->fetch($id, $ref) >= 0) { - $langs->load("other"); - $upload_dir = $conf->projet->dir_output; - $file = $upload_dir.'/'.dol_sanitizeFileName(GETPOST('file')); + $langs->load("other"); + $upload_dir = $conf->projet->dir_output; + $file = $upload_dir.'/'.dol_sanitizeFileName(GETPOST('file')); - $ret = dol_delete_file($file); - if ($ret) { - setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - } else { - setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - } + $ret = dol_delete_file($file); + if ($ret) { + setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + } else { + setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); } } @@ -198,452 +195,450 @@ $formother = new FormOther($db); $formfile = new FormFile($db); if ($id > 0 || !empty($ref)) { - if ($object->fetch($id, $ref) > 0) { - $res = $object->fetch_optionals(); - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) { - $object->fetchComments(); + $res = $object->fetch_optionals(); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) { + $object->fetchComments(); + } + + $result = $projectstatic->fetch($object->fk_project); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { + $projectstatic->fetchComments(); + } + if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); + } + + $object->project = clone $projectstatic; + + //$userWrite = $projectstatic->restrictedProjectArea($user, 'write'); + + if (!empty($withproject)) { + // Tabs for project + $tab = 'tasks'; + $head = project_prepare_head($projectstatic); + print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); + + $param = ($mode == 'mine' ? '&mode=mine' : ''); + + // Project card + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
| '; + print $langs->trans("Usage"); + print ' | '; + print '';
+ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
+ print 'usage_opportunity ? ' checked="checked"' : '')).'"> ';
+ $htmltext = $langs->trans("ProjectFollowOpportunity");
+ print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
+ print ' '; } - $morehtmlref .= ''; - - // Define a complementary filter for search of next/prev ref. - if (!$user->rights->projet->all->lire) { - $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); - $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + if (empty($conf->global->PROJECT_HIDE_TASKS)) { + print 'usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print ' '; } - - dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - print ' ';
- print ' ';
-
- print '';
-
- print dol_get_fiche_end();
-
- print '';
- print '';
-
- print ' ';
-
- print '
';
- print ' ';
- print '';
- print '';
-
- print ' ';
- print '
'; } - /* - * Actions - */ - /*print ' ';
+ // Visibility
+ print ' '.$langs->trans("Visibility").' | ';
+ if ($projectstatic->public) {
+ print $langs->trans('SharedProject');
+ } else {
+ print $langs->trans('PrivateProject');
+ }
+ print ' | '.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").' | ';
+ $start = dol_print_date($projectstatic->date_start, 'day');
+ print ($start ? $start : '?');
+ $end = dol_print_date($projectstatic->date_end, 'day');
+ print ' - ';
+ print ($end ? $end : '?');
+ if ($projectstatic->hasDelay()) {
+ print img_warning("Late");
}
- else
- {
- print ''.$langs->trans('AddTask').'';
- }
- }
- else
- {
- print ''.$langs->trans('AddTask').'';
+ print ' | '.$langs->trans("Budget").' | ';
+ if (strcmp($projectstatic->budget_amount, '')) {
+ print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
}
+ print ' | |
| '.$langs->trans("ChildOfTask").' | '; - if ($object->fk_task_parent > 0) { - $tasktmp = new Task($db); - $tasktmp->fetch($object->fk_task_parent); - print $tasktmp->getNomUrl(1); - } - print ' | ||
| '.$langs->trans("DateStart").' - '.$langs->trans("Deadline").' | '; - $start = dol_print_date($object->date_start, 'dayhour'); - print ($start ? $start : '?'); - $end = dol_print_date($object->date_end, 'dayhour'); - print ' - '; - print ($end ? $end : '?'); - if ($object->hasDelay()) { - print img_warning("Late"); - } - print ' | ||
| '.$langs->trans("PlannedWorkload").' | '; - if ($object->planned_workload != '') { - print convertSecondToTime($object->planned_workload, 'allhourmin'); - } - print ' | '.$langs->trans("Description").' | '; - print nl2br($object->description); - print ' | '; - - print '
| '.$langs->trans("ProgressDeclared").' | '; - if ($object->progress != '') { - print $object->progress.' %'; - } - print ' | ||
| '.$langs->trans("ProgressCalculated").' | '; - if ($object->planned_workload != '') { - $tmparray = $object->getSummaryOfTimeSpent(); - if ($tmparray['total_duration'] > 0 && !empty($object->planned_workload)) { - print round($tmparray['total_duration'] / $object->planned_workload * 100, 2).' %'; - } else { - print '0 %'; - } - } else { - print ''.$langs->trans("WorkloadNotDefined").''; - } - print ' | ||
| '.$langs->trans("ChildOfTask").' | '; + if ($object->fk_task_parent > 0) { + $tasktmp = new Task($db); + $tasktmp->fetch($object->fk_task_parent); + print $tasktmp->getNomUrl(1); + } + print ' | ||
| '.$langs->trans("DateStart").' - '.$langs->trans("Deadline").' | '; + $start = dol_print_date($object->date_start, 'dayhour'); + print ($start ? $start : '?'); + $end = dol_print_date($object->date_end, 'dayhour'); + print ' - '; + print ($end ? $end : '?'); + if ($object->hasDelay()) { + print img_warning("Late"); + } + print ' | ||
| '.$langs->trans("PlannedWorkload").' | '; + if ($object->planned_workload != '') { + print convertSecondToTime($object->planned_workload, 'allhourmin'); + } + print ' | '.$langs->trans("Description").' | '; + print nl2br($object->description); + print ' | '; + + print '
| '.$langs->trans("ProgressDeclared").' | '; + if ($object->progress != '') { + print $object->progress.' %'; + } + print ' | ||
| '.$langs->trans("ProgressCalculated").' | '; + if ($object->planned_workload != '') { + $tmparray = $object->getSummaryOfTimeSpent(); + if ($tmparray['total_duration'] > 0 && !empty($object->planned_workload)) { + print round($tmparray['total_duration'] / $object->planned_workload * 100, 2).' %'; + } else { + print '0 %'; + } + } else { + print ''.$langs->trans("WorkloadNotDefined").''; + } + print ' | ||