diff --git a/htdocs/projet/tasks/comment.php b/htdocs/projet/tasks/comment.php index aaa8bd0cd8916..76c5239fc1766 100644 --- a/htdocs/projet/tasks/comment.php +++ b/htdocs/projet/tasks/comment.php @@ -47,13 +47,6 @@ $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 ($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 3aa5c3b88305f..1f74d1bbc75a4 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -40,16 +40,17 @@ $withproject = GETPOST('withproject', 'int'); $project_ref = GETPOST('project_ref', 'alpha'); +$object = new Task($db); +$projectstatic = new Project($db); + +if ($id > 0 || $ref) { + $object->fetch($id, $ref); +} + // 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); +restrictedArea($user, 'projet', $object->fk_project, 'projet&project'); /* diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index d9c49001dfc54..3a56a7a018aa8 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -37,21 +37,13 @@ $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 @@ $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 ($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($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(); - } + if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); + } - $object->project = clone $projectstatic; + $object->project = clone $projectstatic; - $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($projectstatic->ref).'/'.dol_sanitizeFileName($object->ref); - } else { - dol_print_error($db); - } + $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 4d581afc30a42..3ad4aaa3b7b53 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -31,7 +31,7 @@ $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 ($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 780d387512e59..b31ba6f0e7be8 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -46,13 +46,6 @@ $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 @@ 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 @@ 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 == '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 @@ // 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 == '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 @@ $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(); - } + $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; + $object->project = clone $projectstatic; - //$userWrite = $projectstatic->restrictedProjectArea($user, 'write'); + //$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, '', ''); + 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' : ''); + $param = ($mode == 'mine' ? '&mode=mine' : ''); - // Project card + // Project card - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; - // Title - $morehtmlref .= $projectstatic->title; - // Thirdparty - if ($projectstatic->thirdparty->id > 0) { - $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); - } - $morehtmlref .= '
'; + $morehtmlref = '
'; + // Title + $morehtmlref .= $projectstatic->title; + // Thirdparty + if ($projectstatic->thirdparty->id > 0) { + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); + } + $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').")"; - } + // 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').")"; + } - dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - print '
'; - print '
'; - print '
'; - - print ''; - - // Usage - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) { - print ''; - print ''; - } + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - // Visibility - print ''; + print '
'; + print '
'; + print '
'; - // Date start - end - print '
'; + print '
'; - print $langs->trans("Usage"); - 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 '
'; - } - if (empty($conf->global->PROJECT_HIDE_TASKS)) { - print 'usage_task ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectFollowTasks"); - print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); - print '
'; - } - if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { - print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectBillTimeDescription"); - print $form->textwithpicto($langs->trans("BillTime"), $htmltext); - print '
'; - } - if (!empty($conf->eventorganization->enabled)) { - print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("EventOrganizationDescriptionLong"); - print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); - } - 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"); - } - print '
'; - // Budget - print ''; + print ''; + } - // Other attributes - $cols = 2; - //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - - print '
'.$langs->trans("Budget").''; - if (strcmp($projectstatic->budget_amount, '')) { - print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + // Usage + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) { + print '
'; + print $langs->trans("Usage"); + 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 '
'; + } + if (empty($conf->global->PROJECT_HIDE_TASKS)) { + print 'usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print '
'; + } + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectBillTimeDescription"); + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); + print '
'; + } + if (!empty($conf->eventorganization->enabled)) { + print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("EventOrganizationDescriptionLong"); + print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); } print '
'; - - print '
'; - - print '
'; - print '
'; - print '
'; + // Visibility + print ''.$langs->trans("Visibility").''; + if ($projectstatic->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } + print ''; + + // Date start - end + 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"); + } + print ''; - print ''; + // Budget + print ''; - // Description - print ''; + // Other attributes + $cols = 2; + //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - // Categories - if ($conf->categorie->enabled) { - print '"; - } + print '
'.$langs->trans("Budget").''; + if (strcmp($projectstatic->budget_amount, '')) { + print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + } + print '
'.$langs->trans("Description").''; - print nl2br($projectstatic->description); - print '
'.$langs->trans("Categories").''; - print $form->showCategories($projectstatic->id, 'project', 1); - print "
'; - print ''; + print '
'; - print '
'; - print '
'; - print ''; + print '
'; + print '
'; + print '
'; - print '
'; + print ''; - print dol_get_fiche_end(); + // Description + print ''; - print '
'; + // Categories + if ($conf->categorie->enabled) { + print '"; } - /* - * Actions - */ - /*print '
'; - - if ($user->rights->projet->all->creer || $user->rights->projet->creer) - { - if ($projectstatic->public || $userWrite > 0) - { - print ''.$langs->trans('AddTask').''; - } - else - { - print ''.$langs->trans('AddTask').''; - } - } - else - { - print ''.$langs->trans('AddTask').''; - } + print '
'.$langs->trans("Description").''; + print nl2br($projectstatic->description); + print '
'.$langs->trans("Categories").''; + print $form->showCategories($projectstatic->id, 'project', 1); + print "
'; print '
'; - */ + print '
'; + print ''; - // To verify role of users - //$userAccess = $projectstatic->restrictedProjectArea($user); // We allow task affected to user even if a not allowed project - //$arrayofuseridoftask=$object->getListContactId('internal'); + print '
'; - $head = task_prepare_head($object); + print dol_get_fiche_end(); - if ($action == 'edit' && $user->rights->projet->creer) { - print '
'; - print ''; - print ''; - print ''; - print ''; + print '
'; + } - print dol_get_fiche_head($head, 'task_task', $langs->trans("Task"), 0, 'projecttask', 0, '', ''); + /* + * Actions + */ + /*print '
'; - print ''; + if ($user->rights->projet->all->creer || $user->rights->projet->creer) + { + if ($projectstatic->public || $userWrite > 0) + { + print ''.$langs->trans('AddTask').''; + } + else + { + print ''.$langs->trans('AddTask').''; + } + } + else + { + print ''.$langs->trans('AddTask').''; + } - // Ref - print ''; - print ''; + print ''; + */ - // Label - print ''; - print ''; + // To verify role of users + //$userAccess = $projectstatic->restrictedProjectArea($user); // We allow task affected to user even if a not allowed project + //$arrayofuseridoftask=$object->getListContactId('internal'); - // Project - if (empty($withproject)) { - print ''; + $head = task_prepare_head($object); - // Third party - print ''; - } + if ($action == 'edit' && $user->rights->projet->creer) { + print ''; + print ''; + print ''; + print ''; + print ''; - // Task parent - print ''; + print dol_get_fiche_head($head, 'task_task', $langs->trans("Task"), 0, 'projecttask', 0, '', ''); - // Date start - print ''; + print '
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'.$langs->trans("Project").''; - print $projectstatic->getNomUrl(1); - print '
'.$langs->trans("ThirdParty").''; - if ($projectstatic->societe->id) { - print $projectstatic->societe->getNomUrl(1); - } else { - print ' '; - } - print '
'.$langs->trans("ChildOfProjectTask").''; - print $formother->selectProjectTasks($object->fk_task_parent, $projectstatic->id, 'task_parent', ($user->admin ? 0 : 1), 0, 0, 0, $object->id); - print '
'.$langs->trans("DateStart").''; - print $form->selectDate($object->date_start, 'dateo', 1, 1, 0, '', 1, 0); - print '
'; - // Date end - print ''; + // Ref + print ''; + print ''; - // Planned workload - print ''; + // Label + print ''; + print ''; - // Progress declared - print ''; - // Description - print ''; - print ''; + } - // Other options - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); - } + // Task parent + print ''; + + // Date start + print ''; + + // Date end + print ''; + + // Planned workload + print ''; + + // Progress declared + print ''; + + // Description + print ''; + print ''; + + // Other options + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (empty($reshook)) { + print $object->showOptionals($extrafields, 'edit'); + } - print '
'.$langs->trans("Deadline").''; - print $form->selectDate($object->date_end ? $object->date_end : -1, 'datee', 1, 1, 0, '', 1, 0); - print '
'.$langs->trans("Ref").'
'.$langs->trans("PlannedWorkload").''; - print $form->select_duration('planned_workload', $object->planned_workload, 0, 'text'); - print '
'.$langs->trans("Label").'
'.$langs->trans("ProgressDeclared").''; - print $formother->select_percent($object->progress, 'progress', 0, 5, 0, 100, 1); + // Project + if (empty($withproject)) { + print '
'.$langs->trans("Project").''; + print $projectstatic->getNomUrl(1); print '
'.$langs->trans("Description").''; - print ''; + // Third party + print ''.$langs->trans("ThirdParty").''; + if ($projectstatic->societe->id) { + print $projectstatic->societe->getNomUrl(1); + } else { + print ' '; + } print '
'.$langs->trans("ChildOfProjectTask").''; + print $formother->selectProjectTasks($object->fk_task_parent, $projectstatic->id, 'task_parent', ($user->admin ? 0 : 1), 0, 0, 0, $object->id); + print '
'.$langs->trans("DateStart").''; + print $form->selectDate($object->date_start, 'dateo', 1, 1, 0, '', 1, 0); + print '
'.$langs->trans("Deadline").''; + print $form->selectDate($object->date_end ? $object->date_end : -1, 'datee', 1, 1, 0, '', 1, 0); + print '
'.$langs->trans("PlannedWorkload").''; + print $form->select_duration('planned_workload', $object->planned_workload, 0, 'text'); + print '
'.$langs->trans("ProgressDeclared").''; + print $formother->select_percent($object->progress, 'progress', 0, 5, 0, 100, 1); + print '
'.$langs->trans("Description").''; + print ''; + print '
'; + print ''; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print '
'; - print '   '; - print ''; - print '
'; + print '
'; + print '   '; + print ''; + print '
'; - print ''; - } else { - /* - * Fiche tache en mode visu - */ - $param = ($withproject ? '&withproject=1' : ''); - $linkback = $withproject ? ''.$langs->trans("BackToList").'' : ''; + print ''; + } else { + /* + * Fiche tache en mode visu + */ + $param = ($withproject ? '&withproject=1' : ''); + $linkback = $withproject ? ''.$langs->trans("BackToList").'' : ''; - print dol_get_fiche_head($head, 'task_task', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition'); + print dol_get_fiche_head($head, 'task_task', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition'); - if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".GETPOST("id", 'int').'&withproject='.$withproject, $langs->trans("DeleteATask"), $langs->trans("ConfirmDeleteATask"), "confirm_delete"); - } + if ($action == 'delete') { + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".GETPOST("id", 'int').'&withproject='.$withproject, $langs->trans("DeleteATask"), $langs->trans("ConfirmDeleteATask"), "confirm_delete"); + } - if (!GETPOST('withproject') || empty($projectstatic->id)) { - $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); - $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")"; - } else { - $object->next_prev_filter = " fk_projet = ".((int) $projectstatic->id); - } + if (!GETPOST('withproject') || empty($projectstatic->id)) { + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); + $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")"; + } else { + $object->next_prev_filter = " fk_projet = ".((int) $projectstatic->id); + } - $morehtmlref = ''; + $morehtmlref = ''; - // Project - if (empty($withproject)) { - $morehtmlref .= '
'; - $morehtmlref .= $langs->trans("Project").': '; - $morehtmlref .= $projectstatic->getNomUrl(1); - $morehtmlref .= '
'; + // Project + if (empty($withproject)) { + $morehtmlref .= '
'; + $morehtmlref .= $langs->trans("Project").': '; + $morehtmlref .= $projectstatic->getNomUrl(1); + $morehtmlref .= '
'; - // Third party - $morehtmlref .= $langs->trans("ThirdParty").': '; - if (!empty($projectstatic->thirdparty)) { - $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1); - } - $morehtmlref .= '
'; + // Third party + $morehtmlref .= $langs->trans("ThirdParty").': '; + if (!empty($projectstatic->thirdparty)) { + $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1); } + $morehtmlref .= '
'; + } - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param); - - print '
'; - print '
'; + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param); - print '
'; - print ''; + print '
'; + print '
'; - // Task parent - print '
'; - - // Date start - Date end - print ''; + print '
'; + 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 '
'; - // Planned workload - print ''; + // Task parent + print ''; + + // Date start - Date end + print ''; - // Description - print ''; + // Planned workload + print ''; - print '
'.$langs->trans("PlannedWorkload").''; - if ($object->planned_workload != '') { - print convertSecondToTime($object->planned_workload, 'allhourmin'); - } - 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("Description").''; - print nl2br($object->description); - print '
'.$langs->trans("PlannedWorkload").''; + if ($object->planned_workload != '') { + print convertSecondToTime($object->planned_workload, 'allhourmin'); + } + print '
'; - print '
'; + // Description + print ''.$langs->trans("Description").''; + print nl2br($object->description); + print ''; - print '
'; + print ''; + print '
'; - print '
'; - print ''; + print '
'; - // Progress declared - print '
'; + print '
'; + print '
'.$langs->trans("ProgressDeclared").''; - if ($object->progress != '') { - print $object->progress.' %'; - } - print '
'; - // Progress calculated - print ''; + + // Progress calculated + print ''; + } else { + print ''.$langs->trans("WorkloadNotDefined").''; + } + print ''; - // Other attributes - $cols = 3; - $parameters = array('socid'=>$socid); - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + // Other attributes + $cols = 3; + $parameters = array('socid'=>$socid); + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - 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 %'; - } + // Progress declared + 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 ''.$langs->trans("WorkloadNotDefined").''; + print '0 %'; } - print '
'; + print ''; - print '
'; - print '
'; + print '
'; + print ''; - print ''; - print '
'; + print ''; + print '
'; - print dol_get_fiche_end(); - } + print dol_get_fiche_end(); + } - if ($action != 'edit') { - /* - * Actions - */ + if ($action != 'edit') { + /* + * Actions + */ - print '
'; + print '
'; - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been - // modified by hook - if (empty($reshook)) { - // Modify - if ($user->rights->projet->creer) { - print ''.$langs->trans('Modify').''; - } else { - print ''.$langs->trans('Modify').''; - } + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if (empty($reshook)) { + // Modify + if ($user->rights->projet->creer) { + print ''.$langs->trans('Modify').''; + } else { + print ''.$langs->trans('Modify').''; + } - // Delete - if ($user->rights->projet->supprimer) { - if (!$object->hasChildren() && !$object->hasTimeSpent()) { - print ''.$langs->trans('Delete').''; - } else { - print ''.$langs->trans('Delete').''; - } + // Delete + if ($user->rights->projet->supprimer) { + if (!$object->hasChildren() && !$object->hasTimeSpent()) { + print ''.$langs->trans('Delete').''; } else { - print ''.$langs->trans('Delete').''; + print ''.$langs->trans('Delete').''; } - - print '
'; + } else { + print ''.$langs->trans('Delete').''; } - print '
'; - print ''; // ancre + print '
'; + } + + print '
'; + print ''; // ancre - /* - * Generated documents - */ - $filename = dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref); - $filedir = $conf->projet->dir_output."/".dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref); - $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = ($user->rights->projet->lire); - $delallowed = ($user->rights->projet->creer); + /* + * Generated documents + */ + $filename = dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref); + $filedir = $conf->projet->dir_output."/".dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref); + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed = ($user->rights->projet->lire); + $delallowed = ($user->rights->projet->creer); - print $formfile->showdocuments('project_task', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf); + print $formfile->showdocuments('project_task', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf); - print '
'; + print '
'; - // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $defaultthirdpartyid = $socid > 0 ? $socid : $object->project->socid; - $formactions->showactions($object, 'task', $defaultthirdpartyid, 1, '', 10, 'withproject='.$withproject); + // List of actions on element + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $defaultthirdpartyid = $socid > 0 ? $socid : $object->project->socid; + $formactions->showactions($object, 'task', $defaultthirdpartyid, 1, '', 10, 'withproject='.$withproject); - print '
'; - } + print '
'; } } diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index a85fdcf2db114..8e5877c7d0dfb 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -107,6 +107,13 @@ $extrafields->fetch_name_optionals_label($projectstatic->table_element); $extrafields->fetch_name_optionals_label($object->table_element); +if ($id > 0 || $ref) { + $object->fetch($id, $ref); +} + +restrictedArea($user, 'projet', $object->fk_project, 'projet&project'); + + /* * Actions