diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 0d399fd092c..ac8140a2239 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1,28 +1,28 @@ * Copyright (C) 2010 Regis Houssin - * Copyright (C) 2011 Juanjo Menent - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * or see http://www.gnu.org/ - */ +* Copyright (C) 2011 Juanjo Menent +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* or see http://www.gnu.org/ +*/ /** * \file htdocs/core/lib/project.lib.php * \brief Functions used by project module * \ingroup project - */ +*/ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; @@ -34,71 +34,71 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; */ function project_prepare_head($object) { - global $langs, $conf, $user; - $h = 0; - $head = array(); + global $langs, $conf, $user; + $h = 0; + $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/projet/fiche.php?id='.$object->id; - $head[$h][1] = $langs->trans("Project"); - $head[$h][2] = 'project'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/projet/fiche.php?id='.$object->id; + $head[$h][1] = $langs->trans("Project"); + $head[$h][2] = 'project'; + $h++; - $head[$h][0] = DOL_URL_ROOT.'/projet/contact.php?id='.$object->id; - $head[$h][1] = $langs->trans("ProjectContact"); - $head[$h][2] = 'contact'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/projet/contact.php?id='.$object->id; + $head[$h][1] = $langs->trans("ProjectContact"); + $head[$h][2] = 'contact'; + $h++; - if (! empty($conf->fournisseur->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled) - || ! empty($conf->facture->enabled) || ! empty($conf->contrat->enabled) - || ! empty($conf->ficheinter->enabled) || ! empty($conf->agenda->enabled) || ! empty($conf->deplacement->enabled)) - { - $head[$h][0] = DOL_URL_ROOT.'/projet/element.php?id='.$object->id; - $head[$h][1] = $langs->trans("Referers"); - $head[$h][2] = 'element'; - $h++; - } + if (! empty($conf->fournisseur->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled) + || ! empty($conf->facture->enabled) || ! empty($conf->contrat->enabled) + || ! empty($conf->ficheinter->enabled) || ! empty($conf->agenda->enabled) || ! empty($conf->deplacement->enabled)) + { + $head[$h][0] = DOL_URL_ROOT.'/projet/element.php?id='.$object->id; + $head[$h][1] = $langs->trans("Referers"); + $head[$h][2] = 'element'; + $h++; + } - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname); to remove a tab - complete_head_from_modules($conf,$langs,$object,$head,$h,'project'); + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf,$langs,$object,$head,$h,'project'); - $head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$object->id; - /*$filesdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $listoffiles=dol_dir_list($filesdir,'files',1); - $head[$h][1] = (count($listoffiles)?$langs->trans('DocumentsNb',count($listoffiles)):$langs->trans('Documents'));*/ - $head[$h][1] = $langs->trans('Documents'); - $head[$h][2] = 'document'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$object->id; + /*$filesdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $listoffiles=dol_dir_list($filesdir,'files',1); + $head[$h][1] = (count($listoffiles)?$langs->trans('DocumentsNb',count($listoffiles)):$langs->trans('Documents'));*/ + $head[$h][1] = $langs->trans('Documents'); + $head[$h][2] = 'document'; + $h++; - $head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id; - $head[$h][1] = $langs->trans('Notes'); - $head[$h][2] = 'notes'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + $head[$h][2] = 'notes'; + $h++; - // Then tab for sub level of projet, i mean tasks - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id; - $head[$h][1] = $langs->trans("Tasks"); - $head[$h][2] = 'tasks'; - $h++; + // Then tab for sub level of projet, i mean tasks + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id; + $head[$h][1] = $langs->trans("Tasks"); + $head[$h][2] = 'tasks'; + $h++; - /* Now this is a filter in the Task tab. - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id.'&mode=mine'; - $head[$h][1] = $langs->trans("MyTasks"); - $head[$h][2] = 'mytasks'; - $h++; - */ + /* Now this is a filter in the Task tab. + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id.'&mode=mine'; + $head[$h][1] = $langs->trans("MyTasks"); + $head[$h][2] = 'mytasks'; + $h++; + */ - $head[$h][0] = DOL_URL_ROOT.'/projet/ganttview.php?id='.$object->id; - $head[$h][1] = $langs->trans("Gantt"); - $head[$h][2] = 'gantt'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/projet/ganttview.php?id='.$object->id; + $head[$h][1] = $langs->trans("Gantt"); + $head[$h][2] = 'gantt'; + $h++; - complete_head_from_modules($conf,$langs,$object,$head,$h,'project','remove'); + complete_head_from_modules($conf,$langs,$object,$head,$h,'project','remove'); - return $head; + return $head; } @@ -110,48 +110,83 @@ function project_prepare_head($object) */ function task_prepare_head($object) { - global $langs, $conf, $user; - $h = 0; - $head = array(); + global $langs, $conf, $user; + $h = 0; + $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');; - $head[$h][1] = $langs->trans("Card"); - $head[$h][2] = 'task_task'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');; + $head[$h][1] = $langs->trans("Card"); + $head[$h][2] = 'task_task'; + $h++; - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');; - $head[$h][1] = $langs->trans("TaskRessourceLinks"); - $head[$h][2] = 'task_contact'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');; + $head[$h][1] = $langs->trans("TaskRessourceLinks"); + $head[$h][2] = 'task_contact'; + $h++; - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');; - $head[$h][1] = $langs->trans("TimeSpent"); - $head[$h][2] = 'task_time'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');; + $head[$h][1] = $langs->trans("TimeSpent"); + $head[$h][2] = 'task_time'; + $h++; - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname); to remove a tab - complete_head_from_modules($conf,$langs,$object,$head,$h,'task'); + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf,$langs,$object,$head,$h,'task'); - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');; - /*$filesdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $listoffiles=dol_dir_list($filesdir,'files',1); - $head[$h][1] = (count($listoffiles)?$langs->trans('DocumentsNb',count($listoffiles)):$langs->trans('Documents'));*/ - $head[$h][1] = $langs->trans('Documents'); - $head[$h][2] = 'task_document'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');; + /*$filesdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $listoffiles=dol_dir_list($filesdir,'files',1); + $head[$h][1] = (count($listoffiles)?$langs->trans('DocumentsNb',count($listoffiles)):$langs->trans('Documents'));*/ + $head[$h][1] = $langs->trans('Documents'); + $head[$h][2] = 'task_document'; + $h++; - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');; - $head[$h][1] = $langs->trans('Notes'); - $head[$h][2] = 'task_notes'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');; + $head[$h][1] = $langs->trans('Notes'); + $head[$h][2] = 'task_notes'; + $h++; - complete_head_from_modules($conf,$langs,$object,$head,$h,'task','remove'); + complete_head_from_modules($conf,$langs,$object,$head,$h,'task','remove'); - return $head; + return $head; +} + +/** + * Prepare array with list of tabs + * + * @return array Array of tabs to shoc + */ +function project_admin_prepare_head() +{ + global $langs, $conf, $user; + $h = 0; + $head = array(); + + $h = 0; + + $head[$h][0] = DOL_URL_ROOT."/projet/admin/project.php"; + $head[$h][1] = $langs->trans("Projects"); + $head[$h][2] = 'project'; + $h++; + + complete_head_from_modules($conf,$langs,$object,$head,$h,'project_admin'); + + $head[$h][0] = DOL_URL_ROOT."/projet/admin/project_extrafields.php"; + $head[$h][1] = $langs->trans("ExtraFieldsProject"); + $head[$h][2] = 'attributes'; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/projet/admin/project_task_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsProjectTask"); + $head[$h][2] = 'attributes_task'; + $h++; + + complete_head_from_modules($conf,$langs,$object,$head,$h,'project_admin','remove'); + + return $head; } @@ -276,164 +311,164 @@ function select_projects($socid=-1, $selected='', $htmlname='projectid', $maxlen */ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId='', $addordertick=0) { - global $user, $bc, $langs; + global $user, $bc, $langs; global $projectstatic, $taskstatic; - $lastprojectid=0; + $lastprojectid=0; - $projectsArrayId=explode(',',$projectsListId); + $projectsArrayId=explode(',',$projectsListId); - $numlines=count($lines); + $numlines=count($lines); - $total=0; + $total=0; - for ($i = 0 ; $i < $numlines ; $i++) - { - if ($parent == 0) $level = 0; + for ($i = 0 ; $i < $numlines ; $i++) + { + if ($parent == 0) $level = 0; - // Process line - // print "i:".$i."-".$lines[$i]->fk_project.'
'; + // Process line + // print "i:".$i."-".$lines[$i]->fk_project.'
'; - if ($lines[$i]->fk_parent == $parent) - { - // Show task line. - $showline=1; - $showlineingray=0; + if ($lines[$i]->fk_parent == $parent) + { + // Show task line. + $showline=1; + $showlineingray=0; - // If there is filters to use - if (is_array($taskrole)) - { - // If task not legitimate to show, search if a legitimate task exists later in tree - if (! isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent) - { - // So search if task has a subtask legitimate to show - $foundtaskforuserdeeper=0; - searchTaskInChild($foundtaskforuserdeeper,$lines[$i]->id,$lines,$taskrole); - //print '$foundtaskforuserpeeper='.$foundtaskforuserdeeper.'
'; - if ($foundtaskforuserdeeper > 0) - { - $showlineingray=1; // We will show line but in gray - } - else - { - $showline=0; // No reason to show line - } - } - } + // If there is filters to use + if (is_array($taskrole)) + { + // If task not legitimate to show, search if a legitimate task exists later in tree + if (! isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent) + { + // So search if task has a subtask legitimate to show + $foundtaskforuserdeeper=0; + searchTaskInChild($foundtaskforuserdeeper,$lines[$i]->id,$lines,$taskrole); + //print '$foundtaskforuserpeeper='.$foundtaskforuserdeeper.'
'; + if ($foundtaskforuserdeeper > 0) + { + $showlineingray=1; // We will show line but in gray + } + else + { + $showline=0; // No reason to show line + } + } + } - if ($showline) - { - // Break on a new project - if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) - { - $var = !$var; - $lastprojectid=$lines[$i]->fk_project; - } + if ($showline) + { + // Break on a new project + if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) + { + $var = !$var; + $lastprojectid=$lines[$i]->fk_project; + } - print ''."\n"; + print ''."\n"; - // Project - if ($showproject) - { - print ""; - //var_dump($taskrole); - if ($showlineingray) print ''; - $projectstatic->id=$lines[$i]->fk_project; - $projectstatic->ref=$lines[$i]->projectref; - $projectstatic->public=$lines[$i]->public; - if ($lines[$i]->public || in_array($lines[$i]->fk_project,$projectsArrayId)) print $projectstatic->getNomUrl(1); - else print $projectstatic->getNomUrl(1,'nolink'); - if ($showlineingray) print ''; - print ""; - } + // Project + if ($showproject) + { + print ""; + //var_dump($taskrole); + if ($showlineingray) print ''; + $projectstatic->id=$lines[$i]->fk_project; + $projectstatic->ref=$lines[$i]->projectref; + $projectstatic->public=$lines[$i]->public; + if ($lines[$i]->public || in_array($lines[$i]->fk_project,$projectsArrayId)) print $projectstatic->getNomUrl(1); + else print $projectstatic->getNomUrl(1,'nolink'); + if ($showlineingray) print ''; + print ""; + } - // Ref of task - print ''; - if ($showlineingray) - { - print ''.img_object('','projecttask').' '.$lines[$i]->id.''; - } - else - { - $taskstatic->id=$lines[$i]->id; - $taskstatic->ref=$lines[$i]->id; - $taskstatic->label=($taskrole[$lines[$i]->id]?$langs->trans("YourRole").': '.$taskrole[$lines[$i]->id]:''); - print $taskstatic->getNomUrl(1,($showproject?'':'withproject')); - } - print ''; + // Ref of task + print ''; + if ($showlineingray) + { + print ''.img_object('','projecttask').' '.$lines[$i]->id.''; + } + else + { + $taskstatic->id=$lines[$i]->id; + $taskstatic->ref=$lines[$i]->id; + $taskstatic->label=($taskrole[$lines[$i]->id]?$langs->trans("YourRole").': '.$taskrole[$lines[$i]->id]:''); + print $taskstatic->getNomUrl(1,($showproject?'':'withproject')); + } + print ''; - // Title of task - print ""; - if ($showlineingray) print ''; - else print ''; - for ($k = 0 ; $k < $level ; $k++) - { - print "     "; - } - print $lines[$i]->label; - if ($showlineingray) print ''; - else print ''; - print "\n"; + // Title of task + print ""; + if ($showlineingray) print ''; + else print ''; + for ($k = 0 ; $k < $level ; $k++) + { + print "     "; + } + print $lines[$i]->label; + if ($showlineingray) print ''; + else print ''; + print "\n"; - // Date start - print ''; - print dol_print_date($lines[$i]->date_start,'day'); - print ''; + // 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 ''; + // Date end + print ''; + print dol_print_date($lines[$i]->date_end,'day'); + print ''; - // Progress - print ''; - print $lines[$i]->progress.' %'; - print ''; + // Progress + print ''; + print $lines[$i]->progress.' %'; + print ''; - // Time spent - print ''; - if ($showlineingray) print ''; - else print ''; - if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,'all'); - else print '--:--'; - if ($showlineingray) print ''; - else print ''; - print ''; + // Time spent + print ''; + if ($showlineingray) print ''; + else print ''; + if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,'all'); + else print '--:--'; + if ($showlineingray) print ''; + else print ''; + print ''; - // Tick to drag and drop - if ($addordertick) - { - print ' '; - } + // Tick to drag and drop + if ($addordertick) + { + print ' '; + } - print "\n"; + print "\n"; - if (! $showlineingray) $inc++; + if (! $showlineingray) $inc++; - $level++; - if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId); - $level--; - $total += $lines[$i]->duration; - } - } - else - { - //$level--; - } - } + $level++; + if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId); + $level--; + $total += $lines[$i]->duration; + } + } + else + { + //$level--; + } + } - if ($total>0) - { - print ''.$langs->trans("Total").''; - if ($showproject) print ''; - print ''; - print ''; - print ''; - print ''; - print ''.convertSecondToTime($total).''; - } + if ($total>0) + { + print ''.$langs->trans("Total").''; + if ($showproject) print ''; + print ''; + print ''; + print ''; + print ''; + print ''.convertSecondToTime($total).''; + } - return $inc; + return $inc; } @@ -451,118 +486,118 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t */ function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mytask=0) { - global $user, $bc, $langs; - global $form, $projectstatic, $taskstatic; + global $user, $bc, $langs; + global $form, $projectstatic, $taskstatic; - $lastprojectid=0; + $lastprojectid=0; - $var=true; + $var=true; - $numlines=count($lines); - for ($i = 0 ; $i < $numlines ; $i++) - { - if ($parent == 0) $level = 0; + $numlines=count($lines); + for ($i = 0 ; $i < $numlines ; $i++) + { + if ($parent == 0) $level = 0; - if ($lines[$i]->fk_parent == $parent) - { - // Break on a new project - if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) - { - $var = !$var; - $lastprojectid=$lines[$i]->fk_project; - } + if ($lines[$i]->fk_parent == $parent) + { + // Break on a new project + if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) + { + $var = !$var; + $lastprojectid=$lines[$i]->fk_project; + } - print "\n"; + 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 ""; + // 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 ''; + // 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"; + // 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,'day'); - print ''; + // 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 ''; + // Date end + print ''; + print dol_print_date($lines[$i]->date_end,'day'); + print ''; - // Progress - print ''; - print $lines[$i]->progress.' %'; - print ''; + // Progress + print ''; + print $lines[$i]->progress.' %'; + print ''; - // Time spent - print ''; - if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,'all'); - else print '--:--'; - print "\n"; + // Time spent + print ''; + if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,'all'); + 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; - } + $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 ''; - $s =$form->select_date('',$lines[$i]->id,'','','',"addtime",1,0,1,$disabledtask); - $s.='   '; - $s.=$form->select_duration($lines[$i]->id,'',$disabledtask); - $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 ''; + $s =$form->select_date('',$lines[$i]->id,'','','',"addtime",1,0,1,$disabledtask); + $s.='   '; + $s.=$form->select_duration($lines[$i]->id,'',$disabledtask); + $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); - $level--; - } - else - { - //$level--; - } - } + print "\n"; + $inc++; + $level++; + if ($lines[$i]->id) projectLinesb($inc, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mytask); + $level--; + } + else + { + //$level--; + } + } - return $inc; + return $inc; } @@ -577,29 +612,29 @@ function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksr */ function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole) { - //print 'Search in line with parent id = '.$parent.'
'; - $numlines=count($lines); - for ($i = 0 ; $i < $numlines ; $i++) - { - // Process line $lines[$i] - if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent) - { - // If task is legitimate to show, no more need to search deeper - if (isset($taskrole[$lines[$i]->id])) - { - //print 'Found a legitimate task id='.$lines[$i]->id.'
'; - $inc++; - return $inc; - } + //print 'Search in line with parent id = '.$parent.'
'; + $numlines=count($lines); + for ($i = 0 ; $i < $numlines ; $i++) + { + // Process line $lines[$i] + if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent) + { + // If task is legitimate to show, no more need to search deeper + if (isset($taskrole[$lines[$i]->id])) + { + //print 'Found a legitimate task id='.$lines[$i]->id.'
'; + $inc++; + return $inc; + } - searchTaskInChild($inc, $lines[$i]->id, $lines, $taskrole); - //print 'Found inc='.$inc.'
'; + searchTaskInChild($inc, $lines[$i]->id, $lines, $taskrole); + //print 'Found inc='.$inc.'
'; - if ($inc > 0) return $inc; - } - } + if ($inc > 0) return $inc; + } + } - return $inc; + return $inc; } @@ -611,52 +646,52 @@ function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole) */ function clean_orphelins($db) { - $nb=0; + $nb=0; - // There is orphelins. We clean that - $listofid=array(); + // There is orphelins. We clean that + $listofid=array(); - // Get list of id in array listofid - $sql='SELECT rowid FROM '.MAIN_DB_PREFIX.'projet_task'; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num && $i < 100) - { - $obj = $db->fetch_object($resql); - $listofid[]=$obj->rowid; - $i++; - } - } - else - { - dol_print_error($db); - } + // Get list of id in array listofid + $sql='SELECT rowid FROM '.MAIN_DB_PREFIX.'projet_task'; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num && $i < 100) + { + $obj = $db->fetch_object($resql); + $listofid[]=$obj->rowid; + $i++; + } + } + else + { + dol_print_error($db); + } - if (count($listofid)) - { - // Removed orphelins records - print 'Some orphelins were found and restored to be parents so records are visible again: '; - print join(',',$listofid); + if (count($listofid)) + { + // Removed orphelins records + print 'Some orphelins were found and restored to be parents so records are visible again: '; + print join(',',$listofid); - $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - $sql.= " SET fk_task_parent = 0"; - $sql.= " WHERE fk_task_parent NOT IN (".join(',',$listofid).")"; + $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; + $sql.= " SET fk_task_parent = 0"; + $sql.= " WHERE fk_task_parent NOT IN (".join(',',$listofid).")"; - $resql = $db->query($sql); - if ($resql) - { - $nb=$db->affected_rows($sql); + $resql = $db->query($sql); + if ($resql) + { + $nb=$db->affected_rows($sql); - return $nb; - } - else - { - return -1; - } - } + return $nb; + } + else + { + return -1; + } + } } @@ -671,89 +706,89 @@ function clean_orphelins($db) */ function print_projecttasks_array($db, $socid, $projectsListId, $mytasks=0) { - global $langs,$conf,$user,$bc; + global $langs,$conf,$user,$bc; - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $projectstatic=new Project($db); + $projectstatic=new Project($db); - $sortfield=''; - $sortorder=''; + $sortfield=''; + $sortorder=''; - print ''; - print ''; - print_liste_field_titre($langs->trans("Project"),"index.php","","","","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("NbOpenTasks"),"","","","",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),"","","","",'align="right"',$sortfield,$sortorder); - print "\n"; + print '
'; + print ''; + print_liste_field_titre($langs->trans("Project"),"index.php","","","","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("NbOpenTasks"),"","","","",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),"","","","",'align="right"',$sortfield,$sortorder); + print "\n"; - $sql = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut, COUNT(t.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - if ($mytasks) - { - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; - $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec"; - $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; - } - else - { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; - } - $sql.= " WHERE p.entity = ".$conf->entity; - $sql.= " AND p.rowid IN (".$projectsListId.")"; - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if ($mytasks) - { - $sql.= " AND p.rowid = t.fk_projet"; - $sql.= " AND ec.element_id = t.rowid"; - $sql.= " AND ctc.rowid = ec.fk_c_type_contact"; - $sql.= " AND ctc.element = 'project_task'"; - $sql.= " AND ec.fk_socpeople = ".$user->id; - } - $sql.= " GROUP BY p.rowid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut"; - $sql.= " ORDER BY p.title, p.ref"; + $sql = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut, COUNT(t.rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; + if ($mytasks) + { + $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; + $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec"; + $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; + } + else + { + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; + } + $sql.= " WHERE p.entity = ".$conf->entity; + $sql.= " AND p.rowid IN (".$projectsListId.")"; + if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + if ($mytasks) + { + $sql.= " AND p.rowid = t.fk_projet"; + $sql.= " AND ec.element_id = t.rowid"; + $sql.= " AND ctc.rowid = ec.fk_c_type_contact"; + $sql.= " AND ctc.element = 'project_task'"; + $sql.= " AND ec.fk_socpeople = ".$user->id; + } + $sql.= " GROUP BY p.rowid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut"; + $sql.= " ORDER BY p.title, p.ref"; - $var=true; - $resql = $db->query($sql); - if ( $resql ) - { - $num = $db->num_rows($resql); - $i = 0; + $var=true; + $resql = $db->query($sql); + if ( $resql ) + { + $num = $db->num_rows($resql); + $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($resql); + while ($i < $num) + { + $objp = $db->fetch_object($resql); - $projectstatic->id = $objp->projectid; - $projectstatic->user_author_id = $objp->fk_user_creat; - $projectstatic->public = $objp->public; + $projectstatic->id = $objp->projectid; + $projectstatic->user_author_id = $objp->fk_user_creat; + $projectstatic->public = $objp->public; - // Check is user has read permission on project - $userAccess = $projectstatic->restrictedProjectArea($user); - if ($userAccess >= 0) - { - $var=!$var; - print ""; - print ''; - print ''; - $projectstatic->statut = $objp->fk_statut; - print ''; - print "\n"; - } + // Check is user has read permission on project + $userAccess = $projectstatic->restrictedProjectArea($user); + if ($userAccess >= 0) + { + $var=!$var; + print ""; + print ''; + print ''; + $projectstatic->statut = $objp->fk_statut; + print ''; + print "\n"; + } - $i++; - } + $i++; + } - $db->free($resql); - } - else - { - dol_print_error($db); - } - print "
'; - $projectstatic->ref=$objp->ref; - print $projectstatic->getNomUrl(1); - print ' - '.$objp->title.''.$objp->nb.''.$projectstatic->getLibStatut(3).'
'; + $projectstatic->ref=$objp->ref; + print $projectstatic->getNomUrl(1); + print ' - '.$objp->title.''.$objp->nb.''.$projectstatic->getLibStatut(3).'
"; + $db->free($resql); + } + else + { + dol_print_error($db); + } + print ""; } ?> \ No newline at end of file diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index 9bd71e50dce..9d75ffa6243 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -56,7 +56,7 @@ class modProjet extends DolibarrModules $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; - $this->config_page_url = array("project.php"); + $this->config_page_url = array("project.php@projet"); $this->picto='project'; // Data directories to create when module is enabled diff --git a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql index 8f098876062..80849c6d4a4 100755 --- a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql +++ b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql @@ -278,3 +278,21 @@ ALTER TABLE llx_facture_rec CHANGE COLUMN note note_private text; ALTER TABLE llx_holiday CHANGE COLUMN note note_private text; ALTER TABLE llx_societe CHANGE COLUMN note note_private text; ALTER TABLE llx_socpeople CHANGE COLUMN note note_private text; + +create table llx_projet_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; +ALTER TABLE llx_projet_extrafields ADD INDEX idx_projet_extrafields (fk_object); + +create table llx_projet_task_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; +ALTER TABLE llx_projet_task_extrafields ADD INDEX idx_projet_task_extrafields (fk_object); diff --git a/htdocs/langs/ca_ES/admin.lang b/htdocs/langs/ca_ES/admin.lang index 86a446c255f..788e3bb4b37 100644 --- a/htdocs/langs/ca_ES/admin.lang +++ b/htdocs/langs/ca_ES/admin.lang @@ -945,6 +945,8 @@ ExtraFieldsContacts=Atributs adicionals (contactes/adreçes) ExtraFieldsMember=Atributs complementaris (membres) ExtraFieldsMemberType=Atributs complementaris (tipus de membres) ExtraFieldsCustomerInvoices=Atributs complementaris (factures a clients) +ExtraFieldsProject=Atributs complementaris (projets) +ExtraFieldsProjectTask=Atributs complementaris (tâches) ExtraFieldHasWrongValue=L'atribut %s te un valor incorrecte. AlphaNumOnlyCharsAndNoSpace=només carateres alfanumèrics sense espais SendingMailSetup=Configuració de l'enviament per mail diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 238d9e39dee..e73e752fb21 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -949,9 +949,11 @@ ExtraFields=Complementary attributes ExtraFieldsThirdParties=Complementary attributes (thirdparty) ExtraFieldsContacts=Complementary attributes (contact/address) ExtraFieldsMember=Complementary attributes (member) -ExtraFieldsMemberType=Complementary attributes (Member type) +ExtraFieldsMemberType=Complementary attributes (member type) ExtraFieldsSupplierOrders=Complementary attributes (orders) ExtraFieldsSupplierInvoices=Complementary attributes (invoices) +ExtraFieldsProject=Complementary attributes (projects) +ExtraFieldsProjectTask=Complementary attributes (tasks) ExtraFieldHasWrongValue=Attribut %s has a wrong value. AlphaNumOnlyCharsAndNoSpace=only alphanumericals characters without space SendingMailSetup=Setup of sendings by email diff --git a/htdocs/langs/es_ES/admin.lang b/htdocs/langs/es_ES/admin.lang index c3107679ba3..f89085dc8da 100644 --- a/htdocs/langs/es_ES/admin.lang +++ b/htdocs/langs/es_ES/admin.lang @@ -945,6 +945,8 @@ ExtraFieldsContacts=Atributos adicionales (contactos/direcciones) ExtraFieldsMember=Atributos complementarios (miembros) ExtraFieldsMemberType=Atributos complementarios (tipos de miembros) ExtraFieldsCustomerInvoices=Atributos complementarios (facturas a clientes) +ExtraFieldsProject=Atributos complementarios (proyectos) +ExtraFieldsProjectTask=Atributos complementarios (tareas) ExtraFieldHasWrongValue=El atributo %s tiene un valor incorrecto. AlphaNumOnlyCharsAndNoSpace=solamente caracteres alfanuméricos sin espacios SendingMailSetup=Configuración del envío por mail diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 0d1a2aaf5e0..9fc89f46a7d 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -955,6 +955,8 @@ ExtraFieldsMemberType=Attributs supplémentaires (type d'adhérents) ExtraFieldsCustomerInvoices=Attributs supplémentaires (factures clients) ExtraFieldsSupplierOrders=Attributs supplémentaires (commandes) ExtraFieldsSupplierInvoices=Attributs supplémentaires (factures) +ExtraFieldsProject=Attributs supplémentaires (projets) +ExtraFieldsProjectTask=Attributs supplémentaires (taches) ExtraFieldHasWrongValue=L'attribut %s a une valeur incorrecte. AlphaNumOnlyCharsAndNoSpace=uniquement caractères alphanumériques sans espace SendingMailSetup=Configuration de l'envoi par mail diff --git a/htdocs/admin/project.php b/htdocs/projet/admin/project.php similarity index 97% rename from htdocs/admin/project.php rename to htdocs/projet/admin/project.php index e9973758c73..744c15d78dc 100644 --- a/htdocs/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -3,7 +3,7 @@ * Copyright (C) 2011 Laurent Destailleur * Copyright (C) 2011-2012 Juanjo Menent * Copyright (C) 2011-2013 Philippe Grand - * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013 Florian Henry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,8 +25,9 @@ * \brief Page to setup project module */ -require '../main.inc.php'; +require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; @@ -176,15 +177,9 @@ print_fiche_titre($langs->trans("ProjectsSetup"),$linkback,'setup'); print "
"; -$h = 0; +$head=project_admin_prepare_head(); -$head[$h][0] = DOL_URL_ROOT."/admin/project.php"; -$head[$h][1] = $langs->trans("Projects"); -$head[$h][2] = 'Project'; -$hselected=$h; -$h++; - -dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); +dol_fiche_head($head, 'project', $langs->trans("ModuleSetup")); /* * Projects Numbering model diff --git a/htdocs/projet/admin/project_extrafields.php b/htdocs/projet/admin/project_extrafields.php new file mode 100755 index 00000000000..e397b7c7c1a --- /dev/null +++ b/htdocs/projet/admin/project_extrafields.php @@ -0,0 +1,154 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2013 Florian Henry + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/projet/admin/project_extrafields.php + * \ingroup project + * \brief Page to setup extra fields of project + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + +$langs->load("project"); +$langs->load("admin"); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label=getStaticMember(get_class($extrafields),'type2label'); +$type2label=array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); + +$action=GETPOST('action', 'alpha'); +$attrname=GETPOST('attrname', 'alpha'); +$elementtype='projet'; + +if (!$user->admin) accessforbidden(); + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/admin_extrafields.inc.php'; + + + +/* + * View + */ + +$textobject=$langs->transnoentitiesnoconv("Project"); + +llxHeader("",$langs->trans("ProjectsSetup")); + + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans("ProjectsSetup"),$linkback,'setup'); + + +$head = project_admin_prepare_head(); + +dol_fiche_head($head, 'attributes', $langs->trans("Project"), 0, 'user'); + + +print $langs->trans("DefineHereComplementaryAttributes",$textobject).'
'."\n"; +print '
'; + +// Load attribute_label +$extrafields->fetch_name_optionals_label($elementtype); + +print ""; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + +$var=True; +foreach($extrafields->attribute_type as $key => $value) +{ + $var=!$var; + print ""; + print "\n"; + print "\n"; + print "\n"; + print '\n"; + print '\n"; + print '\n"; + print '\n"; + print ""; +} + +print "
'.$langs->trans("Label").''.$langs->trans("AttributeCode").''.$langs->trans("Type").''.$langs->trans("Size").''.$langs->trans("Unique").''.$langs->trans("Required").' 
".$extrafields->attribute_label[$key]."".$key."".$type2label[$extrafields->attribute_type[$key]]."'.$extrafields->attribute_size[$key]."'.yn($extrafields->attribute_unique[$key])."'.yn($extrafields->attribute_required[$key])."'.img_edit().''; + print "  ".img_delete()."
"; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
'; + print ''; + print "
"; +} + + +/* ************************************************************************** */ +/* */ +/* Creation d'un champ optionnel */ +/* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print "
"; + print_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* ************************************************************************** */ +/* */ +/* Edition d'un champ optionnel */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && ! empty($attrname)) +{ + print "
"; + print_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +llxFooter(); + +$db->close(); +?> diff --git a/htdocs/projet/admin/project_task_extrafields.php b/htdocs/projet/admin/project_task_extrafields.php new file mode 100644 index 00000000000..f212c1acfd4 --- /dev/null +++ b/htdocs/projet/admin/project_task_extrafields.php @@ -0,0 +1,154 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2013 Florian Henry + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/projet/admin/project_task_extrafields.php + * \ingroup project + * \brief Page to setup extra fields of project + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + +$langs->load("project"); +$langs->load("admin"); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label=getStaticMember(get_class($extrafields),'type2label'); +$type2label=array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); + +$action=GETPOST('action', 'alpha'); +$attrname=GETPOST('attrname', 'alpha'); +$elementtype='projet_task'; + +if (!$user->admin) accessforbidden(); + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/admin_extrafields.inc.php'; + + + +/* + * View + */ + +$textobject=$langs->transnoentitiesnoconv("Project"); + +llxHeader("",$langs->trans("ProjectsSetup")); + + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans("ProjectsSetup"),$linkback,'setup'); + + +$head = project_admin_prepare_head(); + +dol_fiche_head($head, 'attributes_task', $langs->trans("Project"), 0, 'user'); + + +print $langs->trans("DefineHereComplementaryAttributes",$textobject).'
'."\n"; +print '
'; + +// Load attribute_label +$extrafields->fetch_name_optionals_label($elementtype); + +print ""; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + +$var=True; +foreach($extrafields->attribute_type as $key => $value) +{ + $var=!$var; + print ""; + print "\n"; + print "\n"; + print "\n"; + print '\n"; + print '\n"; + print '\n"; + print '\n"; + print ""; +} + +print "
'.$langs->trans("Label").''.$langs->trans("AttributeCode").''.$langs->trans("Type").''.$langs->trans("Size").''.$langs->trans("Unique").''.$langs->trans("Required").' 
".$extrafields->attribute_label[$key]."".$key."".$type2label[$extrafields->attribute_type[$key]]."'.$extrafields->attribute_size[$key]."'.yn($extrafields->attribute_unique[$key])."'.yn($extrafields->attribute_required[$key])."'.img_edit().''; + print "  ".img_delete()."
"; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
'; + print ''; + print "
"; +} + + +/* ************************************************************************** */ +/* */ +/* Creation d'un champ optionnel */ +/* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print "
"; + print_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* ************************************************************************** */ +/* */ +/* Edition d'un champ optionnel */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && ! empty($attrname)) +{ + print "
"; + print_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +llxFooter(); + +$db->close(); +?> diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index b02b29eaa69..f5af9518de1 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -145,6 +145,18 @@ class Project extends CommonObject dol_syslog(get_class($this)."::create error -2 " . $this->error, LOG_ERR); $error++; } + + //Update extrafield + if (!$error) { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS)) { @@ -211,6 +223,18 @@ class Project extends CommonObject } // End call triggers } + + //Update extrafield + if (!$error) { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref != $this->ref)) { diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index d09647347e5..0adc21eb6cc 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -134,6 +134,18 @@ class Task extends CommonObject // End call triggers } } + + //Update extrafield + if (!$error) { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } // Commit or rollback if ($error) @@ -275,6 +287,18 @@ class Task extends CommonObject // End call triggers } } + + //Update extrafield + if (!$error) { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } // Commit or rollback if ($error) diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php index fc518e29d27..7df49a38bd0 100644 --- a/htdocs/projet/fiche.php +++ b/htdocs/projet/fiche.php @@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $langs->load("projects"); $langs->load('companies'); @@ -53,12 +54,16 @@ $result = restrictedArea($user, 'projet', $id); $hookmanager->initHooks(array('projectcard')); $object = new Project($db); +$extrafields = new ExtraFields($db); $object->fetch($id,$ref); if ($object->id > 0) { $object->fetch_thirdparty(); } +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label('projet'); + $date_start=dol_mktime(0,0,0,GETPOST('projectmonth','int'),GETPOST('projectday','int'),GETPOST('projectyear','int')); $date_end=dol_mktime(0,0,0,GETPOST('projectendmonth','int'),GETPOST('projectendday','int'),GETPOST('projectendyear','int'));; @@ -132,6 +137,9 @@ if ($action == 'add' && $user->rights->projet->creer) $object->datec=dol_now(); $object->date_start=$date_start; $object->date_end=$date_end; + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); $result = $object->create($user); if ($result > 0) @@ -201,6 +209,9 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer) $object->public = GETPOST('public','alpha'); $object->date_start = empty($_POST["project"])?'':$date_start; $object->date_end = empty($_POST["projectend"])?'':$date_end; + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); $result=$object->update($user); @@ -405,6 +416,10 @@ if ($action == 'create' && $user->rights->projet->creer) // Other options $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + print $object->showOptionals($extrafields,'edit'); + } print ''; @@ -429,6 +444,7 @@ else dol_htmloutput_mesg($mesg); if ($object->societe->id > 0) $result=$object->societe->fetch($object->societe->id); + $res=$object->fetch_optionals($object->id,$extralabels); // To verify role of users $userAccess = $object->restrictedProjectArea($user,'read'); @@ -540,7 +556,11 @@ else // Other options $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + print $object->showOptionals($extrafields,'edit'); + } + print ''; print '

'; @@ -602,7 +622,10 @@ else // Other options $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + print $object->showOptionals($extrafields); + } print ''; } diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 55055d0f467..d9530f2d232 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -1,21 +1,21 @@ * Copyright (C) 2004-2012 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ +* Copyright (C) 2005-2012 Regis Houssin +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ /** * \file htdocs/projet/tasks.php @@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $langs->load("users"); $langs->load("projects"); @@ -43,10 +44,19 @@ $mine = ($mode == 'mine' ? 1 : 0); //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects $object = new Project($db); +$extrafields_project = new ExtraFields($db); +$extrafields_task = new ExtraFields($db); if ($ref) { - $object->fetch(0,$ref); - $id=$object->id; + $object->fetch(0,$ref); + $id=$object->id; +} + +// fetch optionals attributes and labels +if (!empty($id)) { + $extralabels_projet=$extrafields_project->fetch_name_optionals_label('projet'); + $extralabels_task=$extrafields_task->fetch_name_optionals_label('projet_task'); + } // Security check @@ -67,14 +77,14 @@ $userAccess=0; /* * Actions - */ +*/ if ($action == 'createtask' && $user->rights->projet->creer) { $error=0; $date_start = dol_mktime(0,0,0,$_POST['dateomonth'],$_POST['dateoday'],$_POST['dateoyear']); - $date_end = dol_mktime(0,0,0,$_POST['dateemonth'],$_POST['dateeday'],$_POST['dateeyear']); + $date_end = dol_mktime(0,0,0,$_POST['dateemonth'],$_POST['dateeday'],$_POST['dateeyear']); if (empty($_POST["cancel"])) { @@ -109,6 +119,9 @@ if ($action == 'createtask' && $user->rights->projet->creer) $task->date_start = $date_start; $task->date_end = $date_end; $task->progress = $progress; + + // Fill array 'array_options' with data from add form + $ret = $extrafields_task->setOptionalsFromPost($extralabels_task,$task); $taskid = $task->create($user); @@ -120,7 +133,7 @@ if ($action == 'createtask' && $user->rights->projet->creer) if (! $error) { - if (! empty($backtopage)) + if (! empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -139,18 +152,18 @@ if ($action == 'createtask' && $user->rights->projet->creer) header("Location: ".$backtopage); exit; } - else if (empty($id)) - { - // We go back on task list - header("Location: ".DOL_URL_ROOT.'/projet/tasks/index.php'.(empty($mode)?'':'?mode='.$mode)); - exit; - } + else if (empty($id)) + { + // We go back on task list + header("Location: ".DOL_URL_ROOT.'/projet/tasks/index.php'.(empty($mode)?'':'?mode='.$mode)); + exit; + } } } /* * View - */ +*/ $form=new Form($db); $formother=new FormOther($db); @@ -164,74 +177,84 @@ if ($id > 0 || ! empty($ref)) { $object->fetch($id, $ref); if ($object->societe->id > 0) $result=$object->societe->fetch($object->societe->id); - - // To verify role of users - //$userAccess = $object->restrictedProjectArea($user,'read'); - $userWrite = $object->restrictedProjectArea($user,'write'); - //$userDelete = $object->restrictedProjectArea($user,'delete'); - //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete; + $res=$object->fetch_optionals($object->id,$extralabels_projet); - $tab=GETPOST('tab')?GETPOST('tab'):'tasks'; + // To verify role of users + //$userAccess = $object->restrictedProjectArea($user,'read'); + $userWrite = $object->restrictedProjectArea($user,'write'); + //$userDelete = $object->restrictedProjectArea($user,'delete'); + //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete; - $head=project_prepare_head($object); - dol_fiche_head($head, $tab, $langs->trans("Project"),0,($object->public?'projectpub':'project')); - $param=($mode=='mine'?'&mode=mine':''); + $tab=GETPOST('tab')?GETPOST('tab'):'tasks'; - print ''; + $head=project_prepare_head($object); + dol_fiche_head($head, $tab, $langs->trans("Project"),0,($object->public?'projectpub':'project')); - $linkback = ''.$langs->trans("BackToList").''; + $param=($mode=='mine'?'&mode=mine':''); - // Ref - print ''; + print '
'; - print $langs->trans("Ref"); - print ''; - // Define a complementary filter for search of next/prev ref. - if (! $user->rights->projet->all->lire) - { - $projectsListId = $object->getProjectsAuthorizedForUser($user,$mine,0); - $object->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")"; - } - print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', '', $param); - print '
'; - print ''; + $linkback = ''.$langs->trans("BackToList").''; - print ''; - print ''; + // Ref + print ''; - // Visibility - print ''; + print ''; - // Statut - print ''; + print ''; + print ''; - // Date start - print ''; + // Visibility + print ''; - // Date end - print ''; + // Statut + print ''; - print '
'.$langs->trans("Label").''.$object->title.'
'.$langs->trans("Company").''; - if (! empty($object->societe->id)) print $object->societe->getNomUrl(1); - else print ' '; - print '
'; + print $langs->trans("Ref"); + print ''; + // Define a complementary filter for search of next/prev ref. + if (! $user->rights->projet->all->lire) + { + $projectsListId = $object->getProjectsAuthorizedForUser($user,$mine,0); + $object->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")"; + } + print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', '', $param); + print '
'.$langs->trans("Visibility").''; - if ($object->public) print $langs->trans('SharedProject'); - else print $langs->trans('PrivateProject'); - print '
'.$langs->trans("Label").''.$object->title.'
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'.$langs->trans("Company").''; + if (! empty($object->societe->id)) print $object->societe->getNomUrl(1); + else print ' '; + print '
'.$langs->trans("DateStart").''; - print dol_print_date($object->date_start,'day'); - print '
'.$langs->trans("Visibility").''; + if ($object->public) print $langs->trans('SharedProject'); + else print $langs->trans('PrivateProject'); + print '
'.$langs->trans("DateEnd").''; - print dol_print_date($object->date_end,'day'); - print '
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'; + // Date start + print ''.$langs->trans("DateStart").''; + print dol_print_date($object->date_start,'day'); + print ''; - dol_fiche_end(); + // Date end + print ''.$langs->trans("DateEnd").''; + print dol_print_date($object->date_end,'day'); + print ''; + + // Other options + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields_project->attribute_label)) + { + print $object->showOptionals($extrafields_project); + } + + print ''; + + dol_fiche_end(); } if ($action == 'create' && $user->rights->projet->creer && (empty($object->societe->id) || $userWrite > 0)) { - if ($id > 0 || ! empty($ref)) print '
'; + if ($id > 0 || ! empty($ref)) print '
'; print_fiche_titre($langs->trans("NewTask")); @@ -280,9 +303,13 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->socie print ''; print ''; - // Other options - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + // Other options + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields_task->attribute_label)) + { + print $object->showOptionals($extrafields_task,'edit'); + } print ''; @@ -299,11 +326,11 @@ else { /* * Fiche projet en mode visu - */ + */ /* * Actions - */ + */ print '
'; if ($user->rights->projet->all->creer || $user->rights->projet->creer) diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 94034e9b541..977858cf35b 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -1,21 +1,21 @@ * Copyright (C) 2006-2012 Laurent Destailleur - * Copyright (C) 2010-2012 Regis Houssin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ +* Copyright (C) 2010-2012 Regis Houssin +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ /** * \file htdocs/projet/tasks/task.php @@ -28,6 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $id=GETPOST('id','int'); $ref=GETPOST('ref','alpha'); @@ -45,12 +46,14 @@ if (! $user->rights->projet->lire) accessforbidden(); $hookmanager->initHooks(array('projecttaskcard')); $object = new Task($db); +$extrafields = new ExtraFields($db); $projectstatic = new Project($db); - +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label('projet_task'); /* * Actions - */ +*/ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer) { @@ -76,6 +79,9 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer) $object->date_end = dol_mktime(0,0,0,$_POST['dateemonth'],$_POST['dateeday'],$_POST['dateeyear']); $object->progress = $_POST['progress']; + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); + $result=$object->update($user); } else @@ -127,7 +133,7 @@ if (! empty($project_ref) && ! empty($withproject)) /* * View - */ +*/ $langs->load('projects'); @@ -140,6 +146,8 @@ if ($id > 0 || ! empty($ref)) { if ($object->fetch($id) > 0) { + $res=$object->fetch_optionals($object->id,$extralabels); + $result=$projectstatic->fetch($object->fk_project); if (! empty($projectstatic->socid)) $projectstatic->societe->fetch($projectstatic->socid); @@ -147,71 +155,71 @@ if ($id > 0 || ! empty($ref)) if (! empty($withproject)) { - // Tabs for project - $tab='tasks'; - $head=project_prepare_head($projectstatic); - dol_fiche_head($head, $tab, $langs->trans("Project"),0,($projectstatic->public?'projectpub':'project')); + // Tabs for project + $tab='tasks'; + $head=project_prepare_head($projectstatic); + dol_fiche_head($head, $tab, $langs->trans("Project"),0,($projectstatic->public?'projectpub':'project')); - $param=($mode=='mine'?'&mode=mine':''); + $param=($mode=='mine'?'&mode=mine':''); - print ''; + print '
'; - // Ref - print ''; + // Ref + print ''; - print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - // Visibility - print ''; + // Visibility + print ''; - // Statut - print ''; + // Statut + print ''; - print '
'; - print $langs->trans("Ref"); - print ''; - // Define a complementary filter for search of next/prev ref. - if (! $user->rights->projet->all->lire) - { - $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,0); - $projectstatic->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")"; - } - print $form->showrefnav($projectstatic,'project_ref','',1,'ref','ref','',$param.'&withproject=1'); - print '
'; + print $langs->trans("Ref"); + print ''; + // Define a complementary filter for search of next/prev ref. + if (! $user->rights->projet->all->lire) + { + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,0); + $projectstatic->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")"; + } + print $form->showrefnav($projectstatic,'project_ref','',1,'ref','ref','',$param.'&withproject=1'); + print '
'.$langs->trans("Label").''.$projectstatic->title.'
'.$langs->trans("Label").''.$projectstatic->title.'
'.$langs->trans("Company").''; - if (! empty($projectstatic->societe->id)) print $projectstatic->societe->getNomUrl(1); - else print ' '; - print '
'.$langs->trans("Company").''; + if (! empty($projectstatic->societe->id)) print $projectstatic->societe->getNomUrl(1); + else print ' '; + print '
'.$langs->trans("Visibility").''; - if ($projectstatic->public) print $langs->trans('SharedProject'); - else print $langs->trans('PrivateProject'); - print '
'.$langs->trans("Visibility").''; + if ($projectstatic->public) print $langs->trans('SharedProject'); + else print $langs->trans('PrivateProject'); + print '
'.$langs->trans("Status").''.$projectstatic->getLibStatut(4).'
'.$langs->trans("Status").''.$projectstatic->getLibStatut(4).'
'; + print ''; - dol_fiche_end(); + dol_fiche_end(); - print '
'; + print '
'; } /* - * Actions + * 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').''; - } + if ($projectstatic->public || $userWrite > 0) + { + print ''.$langs->trans('AddTask').''; } else { - print ''.$langs->trans('AddTask').''; + print ''.$langs->trans('AddTask').''; + } + } + else + { + print ''.$langs->trans('AddTask').''; } print '
'; @@ -226,6 +234,8 @@ if ($id > 0 || ! empty($ref)) $head=task_prepare_head($object); dol_fiche_head($head, 'task_task', $langs->trans("Task"),0,'projecttask'); + + if ($action == 'edit' && $user->rights->projet->creer) { print '
'; @@ -247,15 +257,15 @@ if ($id > 0 || ! empty($ref)) // Project if (empty($withproject)) { - print ''.$langs->trans("Project").''; - print $projectstatic->getNomUrl(1); - print ''; + print ''.$langs->trans("Project").''; + print $projectstatic->getNomUrl(1); + print ''; - // Third party - print ''.$langs->trans("Company").''; - if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1); - else print ' '; - print ''; + // Third party + print ''.$langs->trans("Company").''; + if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1); + else print ' '; + print ''; } // Task parent @@ -284,9 +294,13 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - // Other options - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + // Other options + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + print $object->showOptionals($extrafields,'edit'); + } print ''; @@ -301,9 +315,9 @@ if ($id > 0 || ! empty($ref)) { /* * Fiche tache en mode visu - */ - $param=($withproject?'&withproject=1':''); - $linkback=$withproject?''.$langs->trans("BackToList").'':''; + */ + $param=($withproject?'&withproject=1':''); + $linkback=$withproject?''.$langs->trans("BackToList").'':''; if ($action == 'delete') { @@ -319,8 +333,8 @@ if ($id > 0 || ! empty($ref)) print ''; if (! GETPOST('withproject') || empty($projectstatic->id)) { - $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1); - $object->next_prev_filter=" fk_projet in (".$projectsListId.")"; + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1); + $object->next_prev_filter=" fk_projet in (".$projectsListId.")"; } else $object->next_prev_filter=" fk_projet = ".$projectstatic->id; print $form->showrefnav($object,'id',$linkback,1,'rowid','ref','',$param); @@ -333,15 +347,15 @@ if ($id > 0 || ! empty($ref)) // Project if (empty($withproject)) { - print ''.$langs->trans("Project").''; - print $projectstatic->getNomUrl(1); - print ''; + print ''.$langs->trans("Project").''; + print $projectstatic->getNomUrl(1); + print ''; - // Third party - print ''.$langs->trans("Company").''; - if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1); - else print ' '; - print ''; + // Third party + print ''.$langs->trans("Company").''; + if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1); + else print ' '; + print ''; } // Date start @@ -364,10 +378,14 @@ if ($id > 0 || ! empty($ref)) print nl2br($object->description); print ''; - // Other options - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - + // Other options + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + print $object->showOptionals($extrafields); + } + print ''; } @@ -379,7 +397,7 @@ if ($id > 0 || ! empty($ref)) { /* * Actions - */ + */ print '
'; // Modify