diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 0d399fd092c1231936252f188d88c362012735f4..ac8140a2239464e1e423eb159cee32cc3faf83b4 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1,28 +1,28 @@ <?php /* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com> - * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> - * - * 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 <http://www.gnu.org/licenses/>. - * or see http://www.gnu.org/ - */ +* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> +* +* 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 <http://www.gnu.org/licenses/>. +* 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(); - - $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++; - - 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'); - - $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++; - - // 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++; - */ - - $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'); - - return $head; + 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/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++; + } + + // 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/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++; + + /* 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++; + + complete_head_from_modules($conf,$langs,$object,$head,$h,'project','remove'); + + return $head; } @@ -110,48 +110,83 @@ function project_prepare_head($object) */ function task_prepare_head($object) { - 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/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++; - - // 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/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'); - - return $head; + 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/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++; + + // 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/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'); + + 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; - - $projectsArrayId=explode(',',$projectsListId); - - $numlines=count($lines); - - $total=0; - - for ($i = 0 ; $i < $numlines ; $i++) - { - if ($parent == 0) $level = 0; - - // Process line - // print "i:".$i."-".$lines[$i]->fk_project.'<br>'; - - 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.'<br>'; - 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; - } - - print '<tr '.$bc[$var].' id="row-'.$lines[$i]->id.'">'."\n"; - - // Project - if ($showproject) - { - print "<td>"; - //var_dump($taskrole); - if ($showlineingray) print '<i>'; - $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 '</i>'; - print "</td>"; - } - - // Ref of task - print '<td>'; - if ($showlineingray) - { - print '<i>'.img_object('','projecttask').' '.$lines[$i]->id.'</i>'; - } - 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 '</td>'; - - // Title of task - print "<td>"; - if ($showlineingray) print '<i>'; - else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">'; - for ($k = 0 ; $k < $level ; $k++) - { - print " "; - } - print $lines[$i]->label; - if ($showlineingray) print '</i>'; - else print '</a>'; - print "</td>\n"; - - // Date start - print '<td align="center">'; - print dol_print_date($lines[$i]->date_start,'day'); - print '</td>'; - - // Date end - print '<td align="center">'; - print dol_print_date($lines[$i]->date_end,'day'); - print '</td>'; - - // Progress - print '<td align="right">'; - print $lines[$i]->progress.' %'; - print '</td>'; - - // Time spent - print '<td align="right">'; - if ($showlineingray) print '<i>'; - else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">'; - if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,'all'); - else print '--:--'; - if ($showlineingray) print '</i>'; - else print '</a>'; - print '</td>'; - - // Tick to drag and drop - if ($addordertick) - { - print '<td align="center" class="tdlineupdown"> </td>'; - } - - print "</tr>\n"; - - 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--; - } - } - - if ($total>0) - { - print '<tr class="liste_total"><td class="liste_total">'.$langs->trans("Total").'</td>'; - if ($showproject) print '<td></td>'; - print '<td></td>'; - print '<td></td>'; - print '<td></td>'; - print '<td></td>'; - print '<td align="right" nowrap="nowrap" class="liste_total">'.convertSecondToTime($total).'</td></tr>'; - } - - return $inc; + $lastprojectid=0; + + $projectsArrayId=explode(',',$projectsListId); + + $numlines=count($lines); + + $total=0; + + for ($i = 0 ; $i < $numlines ; $i++) + { + if ($parent == 0) $level = 0; + + // Process line + // print "i:".$i."-".$lines[$i]->fk_project.'<br>'; + + 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.'<br>'; + 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; + } + + print '<tr '.$bc[$var].' id="row-'.$lines[$i]->id.'">'."\n"; + + // Project + if ($showproject) + { + print "<td>"; + //var_dump($taskrole); + if ($showlineingray) print '<i>'; + $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 '</i>'; + print "</td>"; + } + + // Ref of task + print '<td>'; + if ($showlineingray) + { + print '<i>'.img_object('','projecttask').' '.$lines[$i]->id.'</i>'; + } + 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 '</td>'; + + // Title of task + print "<td>"; + if ($showlineingray) print '<i>'; + else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">'; + for ($k = 0 ; $k < $level ; $k++) + { + print " "; + } + print $lines[$i]->label; + if ($showlineingray) print '</i>'; + else print '</a>'; + print "</td>\n"; + + // Date start + print '<td align="center">'; + print dol_print_date($lines[$i]->date_start,'day'); + print '</td>'; + + // Date end + print '<td align="center">'; + print dol_print_date($lines[$i]->date_end,'day'); + print '</td>'; + + // Progress + print '<td align="right">'; + print $lines[$i]->progress.' %'; + print '</td>'; + + // Time spent + print '<td align="right">'; + if ($showlineingray) print '<i>'; + else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">'; + if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,'all'); + else print '--:--'; + if ($showlineingray) print '</i>'; + else print '</a>'; + print '</td>'; + + // Tick to drag and drop + if ($addordertick) + { + print '<td align="center" class="tdlineupdown"> </td>'; + } + + print "</tr>\n"; + + 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--; + } + } + + if ($total>0) + { + print '<tr class="liste_total"><td class="liste_total">'.$langs->trans("Total").'</td>'; + if ($showproject) print '<td></td>'; + print '<td></td>'; + print '<td></td>'; + print '<td></td>'; + print '<td></td>'; + print '<td align="right" nowrap="nowrap" class="liste_total">'.convertSecondToTime($total).'</td></tr>'; + } + + 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; - - $lastprojectid=0; - - $var=true; - - $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; - } - - print "<tr ".$bc[$var].">\n"; - - // Project - print "<td>"; - $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 "</td>"; - - // Ref - print '<td>'; - $taskstatic->id=$lines[$i]->id; - $taskstatic->ref=$lines[$i]->id; - print $taskstatic->getNomUrl(1); - print '</td>'; - - // Label task - print "<td>"; - for ($k = 0 ; $k < $level ; $k++) - { - print " "; - } - $taskstatic->id=$lines[$i]->id; - $taskstatic->ref=$lines[$i]->label; - print $taskstatic->getNomUrl(0); - print "</td>\n"; - - // Date start - print '<td align="center">'; - print dol_print_date($lines[$i]->date_start,'day'); - print '</td>'; - - // Date end - print '<td align="center">'; - print dol_print_date($lines[$i]->date_end,'day'); - print '</td>'; - - // Progress - print '<td align="right">'; - print $lines[$i]->progress.' %'; - print '</td>'; - - // Time spent - print '<td align="right">'; - if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,'all'); - else print '--:--'; - print "</td>\n"; - - $disabledproject=1;$disabledtask=1; - //print "x".$lines[$i]->fk_project; - //var_dump($lines[$i]); - //var_dump($projectsrole[$lines[$i]->fk_project]); - // If at least one role for project - if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) - { - $disabledproject=0; - $disabledtask=0; - } - // If mytask and no role on task - if ($mytask && empty($tasksrole[$lines[$i]->id])) - { - $disabledtask=1; - } - - print '<td nowrap="nowrap">'; - $s =$form->select_date('',$lines[$i]->id,'','','',"addtime",1,0,1,$disabledtask); - $s.=' '; - $s.=$form->select_duration($lines[$i]->id,'',$disabledtask); - $s.=' <input type="submit" class="button"'.($disabledtask?' disabled="disabled"':'').' value="'.$langs->trans("Add").'">'; - print $s; - print '</td>'; - print '<td align="right">'; - if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("YouAreNotContactOfProject")); - else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAffectedToYou")); - print '</td>'; - - print "</tr>\n"; - $inc++; - $level++; - if ($lines[$i]->id) projectLinesb($inc, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mytask); - $level--; - } - else - { - //$level--; - } - } - - return $inc; + global $user, $bc, $langs; + global $form, $projectstatic, $taskstatic; + + $lastprojectid=0; + + $var=true; + + $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; + } + + print "<tr ".$bc[$var].">\n"; + + // Project + print "<td>"; + $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 "</td>"; + + // Ref + print '<td>'; + $taskstatic->id=$lines[$i]->id; + $taskstatic->ref=$lines[$i]->id; + print $taskstatic->getNomUrl(1); + print '</td>'; + + // Label task + print "<td>"; + for ($k = 0 ; $k < $level ; $k++) + { + print " "; + } + $taskstatic->id=$lines[$i]->id; + $taskstatic->ref=$lines[$i]->label; + print $taskstatic->getNomUrl(0); + print "</td>\n"; + + // Date start + print '<td align="center">'; + print dol_print_date($lines[$i]->date_start,'day'); + print '</td>'; + + // Date end + print '<td align="center">'; + print dol_print_date($lines[$i]->date_end,'day'); + print '</td>'; + + // Progress + print '<td align="right">'; + print $lines[$i]->progress.' %'; + print '</td>'; + + // Time spent + print '<td align="right">'; + if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,'all'); + else print '--:--'; + print "</td>\n"; + + $disabledproject=1;$disabledtask=1; + //print "x".$lines[$i]->fk_project; + //var_dump($lines[$i]); + //var_dump($projectsrole[$lines[$i]->fk_project]); + // If at least one role for project + if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) + { + $disabledproject=0; + $disabledtask=0; + } + // If mytask and no role on task + if ($mytask && empty($tasksrole[$lines[$i]->id])) + { + $disabledtask=1; + } + + print '<td nowrap="nowrap">'; + $s =$form->select_date('',$lines[$i]->id,'','','',"addtime",1,0,1,$disabledtask); + $s.=' '; + $s.=$form->select_duration($lines[$i]->id,'',$disabledtask); + $s.=' <input type="submit" class="button"'.($disabledtask?' disabled="disabled"':'').' value="'.$langs->trans("Add").'">'; + print $s; + print '</td>'; + print '<td align="right">'; + if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("YouAreNotContactOfProject")); + else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAffectedToYou")); + print '</td>'; + + print "</tr>\n"; + $inc++; + $level++; + if ($lines[$i]->id) projectLinesb($inc, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mytask); + $level--; + } + else + { + //$level--; + } + } + + 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.'<br>'; - $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.'<br>'; - $inc++; - return $inc; - } - - searchTaskInChild($inc, $lines[$i]->id, $lines, $taskrole); - //print 'Found inc='.$inc.'<br>'; - - if ($inc > 0) return $inc; - } - } - - return $inc; + //print 'Search in line with parent id = '.$parent.'<br>'; + $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.'<br>'; + $inc++; + return $inc; + } + + searchTaskInChild($inc, $lines[$i]->id, $lines, $taskrole); + //print 'Found inc='.$inc.'<br>'; + + if ($inc > 0) return $inc; + } + } + + return $inc; } @@ -611,52 +646,52 @@ function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole) */ function clean_orphelins($db) { - $nb=0; - - // 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); - } - - 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).")"; - - $resql = $db->query($sql); - if ($resql) - { - $nb=$db->affected_rows($sql); - - return $nb; - } - else - { - return -1; - } - } + $nb=0; + + // 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); + } + + 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).")"; + + $resql = $db->query($sql); + if ($resql) + { + $nb=$db->affected_rows($sql); + + 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; - - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - - $projectstatic=new Project($db); - - $sortfield=''; - $sortorder=''; - - print '<table class="noborder" width="100%">'; - print '<tr class="liste_titre">'; - 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 "</tr>\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"; - - $var=true; - $resql = $db->query($sql); - if ( $resql ) - { - $num = $db->num_rows($resql); - $i = 0; - - while ($i < $num) - { - $objp = $db->fetch_object($resql); - - $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 "<tr ".$bc[$var].">"; - print '<td nowrap="nowrap">'; - $projectstatic->ref=$objp->ref; - print $projectstatic->getNomUrl(1); - print ' - '.$objp->title.'</td>'; - print '<td align="right">'.$objp->nb.'</td>'; - $projectstatic->statut = $objp->fk_statut; - print '<td align="right">'.$projectstatic->getLibStatut(3).'</td>'; - print "</tr>\n"; - } - - $i++; - } - - $db->free($resql); - } - else - { - dol_print_error($db); - } - print "</table>"; + global $langs,$conf,$user,$bc; + + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + + $projectstatic=new Project($db); + + $sortfield=''; + $sortorder=''; + + print '<table class="noborder" width="100%">'; + print '<tr class="liste_titre">'; + 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 "</tr>\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"; + + $var=true; + $resql = $db->query($sql); + if ( $resql ) + { + $num = $db->num_rows($resql); + $i = 0; + + while ($i < $num) + { + $objp = $db->fetch_object($resql); + + $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 "<tr ".$bc[$var].">"; + print '<td nowrap="nowrap">'; + $projectstatic->ref=$objp->ref; + print $projectstatic->getNomUrl(1); + print ' - '.$objp->title.'</td>'; + print '<td align="right">'.$objp->nb.'</td>'; + $projectstatic->statut = $objp->fk_statut; + print '<td align="right">'.$projectstatic->getLibStatut(3).'</td>'; + print "</tr>\n"; + } + + $i++; + } + + $db->free($resql); + } + else + { + dol_print_error($db); + } + print "</table>"; } ?> \ No newline at end of file diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index 9bd71e50dcee559726cfe7da10cb0a9430c76344..9d75ffa62432fc477254a709a9dee59489a2bdb4 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 8f09887606245c93f489c5632d81c7c958b36e65..80849c6d4a49298614d5aa9cabf90e7cf23396fa 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 86a446c255f4fcf441bceecf89ef2cf9e76cc0ea..788e3bb4b376dbd17deb0496a1204d3ff85d8a26 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 238d9e39dee13c7d32d542a3c6f65dcf537a9c9b..e73e752fb2140de46ef6f324d34699689a27f928 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 c3107679ba3bd266db25e1b3296d97d1e305fa29..f89085dc8daaed7d6f1e5cbf2c1d23af147dcd95 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 0d1a2aaf5e00cc62b9fcba934017c2ae7b090a35..9fc89f46a7daa2adb09f1e1e767b0cfeead4372a 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 e9973758c7360d47143f14b740eebeae7eb55b4d..744c15d78dc83c9133074c793d7ac7339dd2f429 100644 --- a/htdocs/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -3,7 +3,7 @@ * Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011-2013 Philippe Grand <philippe.grand@atoo-net.com> - * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> + * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * * 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 "<br>"; -$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 0000000000000000000000000000000000000000..e397b7c7c1a823df5201d0f4d7ec8a35deb82d34 --- /dev/null +++ b/htdocs/projet/admin/project_extrafields.php @@ -0,0 +1,154 @@ +<?php +/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org> + * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org> + * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com> + * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +/** + * \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='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; +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).'<br>'."\n"; +print '<br>'; + +// Load attribute_label +$extrafields->fetch_name_optionals_label($elementtype); + +print "<table summary=\"listofattributes\" class=\"noborder\" width=\"100%\">"; + +print '<tr class="liste_titre">'; +print '<td>'.$langs->trans("Label").'</td>'; +print '<td>'.$langs->trans("AttributeCode").'</td>'; +print '<td>'.$langs->trans("Type").'</td>'; +print '<td align="right">'.$langs->trans("Size").'</td>'; +print '<td align="center">'.$langs->trans("Unique").'</td>'; +print '<td align="center">'.$langs->trans("Required").'</td>'; +print '<td width="80"> </td>'; +print "</tr>\n"; + +$var=True; +foreach($extrafields->attribute_type as $key => $value) +{ + $var=!$var; + print "<tr ".$bc[$var].">"; + print "<td>".$extrafields->attribute_label[$key]."</td>\n"; + print "<td>".$key."</td>\n"; + print "<td>".$type2label[$extrafields->attribute_type[$key]]."</td>\n"; + print '<td align="right">'.$extrafields->attribute_size[$key]."</td>\n"; + print '<td align="center">'.yn($extrafields->attribute_unique[$key])."</td>\n"; + print '<td align="center">'.yn($extrafields->attribute_required[$key])."</td>\n"; + print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&attrname='.$key.'">'.img_edit().'</a>'; + print " <a href=\"".$_SERVER["PHP_SELF"]."?action=delete&attrname=".$key."\">".img_delete()."</a></td>\n"; + print "</tr>"; +} + +print "</table>"; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '<div class="tabsAction">'; + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute").'</a></div>'; + print "</div>"; +} + + +/* ************************************************************************** */ +/* */ +/* Creation d'un champ optionnel */ +/* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print "<br>"; + 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 "<br>"; + 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 0000000000000000000000000000000000000000..f212c1acfd4d05baab5d5489417e4a123e25840d --- /dev/null +++ b/htdocs/projet/admin/project_task_extrafields.php @@ -0,0 +1,154 @@ +<?php +/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org> + * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org> + * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com> + * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +/** + * \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='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; +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).'<br>'."\n"; +print '<br>'; + +// Load attribute_label +$extrafields->fetch_name_optionals_label($elementtype); + +print "<table summary=\"listofattributes\" class=\"noborder\" width=\"100%\">"; + +print '<tr class="liste_titre">'; +print '<td>'.$langs->trans("Label").'</td>'; +print '<td>'.$langs->trans("AttributeCode").'</td>'; +print '<td>'.$langs->trans("Type").'</td>'; +print '<td align="right">'.$langs->trans("Size").'</td>'; +print '<td align="center">'.$langs->trans("Unique").'</td>'; +print '<td align="center">'.$langs->trans("Required").'</td>'; +print '<td width="80"> </td>'; +print "</tr>\n"; + +$var=True; +foreach($extrafields->attribute_type as $key => $value) +{ + $var=!$var; + print "<tr ".$bc[$var].">"; + print "<td>".$extrafields->attribute_label[$key]."</td>\n"; + print "<td>".$key."</td>\n"; + print "<td>".$type2label[$extrafields->attribute_type[$key]]."</td>\n"; + print '<td align="right">'.$extrafields->attribute_size[$key]."</td>\n"; + print '<td align="center">'.yn($extrafields->attribute_unique[$key])."</td>\n"; + print '<td align="center">'.yn($extrafields->attribute_required[$key])."</td>\n"; + print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&attrname='.$key.'">'.img_edit().'</a>'; + print " <a href=\"".$_SERVER["PHP_SELF"]."?action=delete&attrname=".$key."\">".img_delete()."</a></td>\n"; + print "</tr>"; +} + +print "</table>"; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '<div class="tabsAction">'; + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute").'</a></div>'; + print "</div>"; +} + + +/* ************************************************************************** */ +/* */ +/* Creation d'un champ optionnel */ +/* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print "<br>"; + 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 "<br>"; + 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 b02b29eaa69674ae55f01176adde9284a9804c91..f5af9518de192f5df2c5011c1d69f6b1fb9b7149 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 d09647347e5e0d815ff38da088792d7b2b2315e7..0adc21eb6cc3c85a58485f1408bdc1899173a1fd 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 fc518e29d27bc68e0160d8b477f09fe72d204237..7df49a38bd0c7fce0f7f98cb1d7a50c6fa48a8b8 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 '</table>'; @@ -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 '</table>'; print '<div align="center"><br>'; @@ -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 '</table>'; } diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 55055d0f467faf90c64f2d29b1e51069eff49170..d9530f2d232a3dd090fc7db08e8b120fb254a0b4 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -1,21 +1,21 @@ <?php /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> - * - * 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 <http://www.gnu.org/licenses/>. - */ +* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> +* +* 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 <http://www.gnu.org/licenses/>. +*/ /** * \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); + $res=$object->fetch_optionals($object->id,$extralabels_projet); - // 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; + // 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; - $tab=GETPOST('tab')?GETPOST('tab'):'tasks'; - $head=project_prepare_head($object); - dol_fiche_head($head, $tab, $langs->trans("Project"),0,($object->public?'projectpub':'project')); + $tab=GETPOST('tab')?GETPOST('tab'):'tasks'; - $param=($mode=='mine'?'&mode=mine':''); + $head=project_prepare_head($object); + dol_fiche_head($head, $tab, $langs->trans("Project"),0,($object->public?'projectpub':'project')); - print '<table class="border" width="100%">'; + $param=($mode=='mine'?'&mode=mine':''); - $linkback = '<a href="'.DOL_URL_ROOT.'/projet/liste.php">'.$langs->trans("BackToList").'</a>'; + print '<table class="border" width="100%">'; - // Ref - print '<tr><td width="30%">'; - print $langs->trans("Ref"); - print '</td><td>'; - // 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 '</td></tr>'; + $linkback = '<a href="'.DOL_URL_ROOT.'/projet/liste.php">'.$langs->trans("BackToList").'</a>'; - print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->title.'</td></tr>'; + // Ref + print '<tr><td width="30%">'; + print $langs->trans("Ref"); + print '</td><td>'; + // 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 '</td></tr>'; - print '<tr><td>'.$langs->trans("Company").'</td><td>'; - if (! empty($object->societe->id)) print $object->societe->getNomUrl(1); - else print ' '; - print '</td>'; - print '</tr>'; + print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->title.'</td></tr>'; - // Visibility - print '<tr><td>'.$langs->trans("Visibility").'</td><td>'; - if ($object->public) print $langs->trans('SharedProject'); - else print $langs->trans('PrivateProject'); - print '</td></tr>'; + print '<tr><td>'.$langs->trans("Company").'</td><td>'; + if (! empty($object->societe->id)) print $object->societe->getNomUrl(1); + else print ' '; + print '</td>'; + print '</tr>'; - // Statut - print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>'; + // Visibility + print '<tr><td>'.$langs->trans("Visibility").'</td><td>'; + if ($object->public) print $langs->trans('SharedProject'); + else print $langs->trans('PrivateProject'); + print '</td></tr>'; - // Date start - print '<tr><td>'.$langs->trans("DateStart").'</td><td>'; - print dol_print_date($object->date_start,'day'); - print '</td></tr>'; + // Statut + print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>'; - // Date end - print '<tr><td>'.$langs->trans("DateEnd").'</td><td>'; - print dol_print_date($object->date_end,'day'); - print '</td></tr>'; + // Date start + print '<tr><td>'.$langs->trans("DateStart").'</td><td>'; + print dol_print_date($object->date_start,'day'); + print '</td></tr>'; + + // Date end + print '<tr><td>'.$langs->trans("DateEnd").'</td><td>'; + print dol_print_date($object->date_end,'day'); + print '</td></tr>'; + + // 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 '</table>'; + print '</table>'; - dol_fiche_end(); + dol_fiche_end(); } if ($action == 'create' && $user->rights->projet->creer && (empty($object->societe->id) || $userWrite > 0)) { - if ($id > 0 || ! empty($ref)) print '<br>'; + if ($id > 0 || ! empty($ref)) print '<br>'; print_fiche_titre($langs->trans("NewTask")); @@ -280,9 +303,13 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->socie print '<textarea name="description" wrap="soft" cols="80" rows="'.ROWS_3.'">'.$description.'</textarea>'; print '</td></tr>'; - // 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 '</table>'; @@ -299,11 +326,11 @@ else { /* * Fiche projet en mode visu - */ + */ /* * Actions - */ + */ print '<div class="tabsAction">'; 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 94034e9b541143538ae246fa09d24c0a4edc0551..977858cf35b4db53f43a94362ac9e7aed6f75b71 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -1,21 +1,21 @@ <?php /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com> - * - * 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 <http://www.gnu.org/licenses/>. - */ +* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com> +* +* 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 <http://www.gnu.org/licenses/>. +*/ /** * \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')); - - $param=($mode=='mine'?'&mode=mine':''); - - print '<table class="border" width="100%">'; - - // Ref - print '<tr><td width="30%">'; - print $langs->trans("Ref"); - print '</td><td>'; - // 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 '</td></tr>'; - - print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projectstatic->title.'</td></tr>'; - - print '<tr><td>'.$langs->trans("Company").'</td><td>'; - if (! empty($projectstatic->societe->id)) print $projectstatic->societe->getNomUrl(1); - else print ' '; - print '</td>'; - print '</tr>'; - - // Visibility - print '<tr><td>'.$langs->trans("Visibility").'</td><td>'; - if ($projectstatic->public) print $langs->trans('SharedProject'); - else print $langs->trans('PrivateProject'); - print '</td></tr>'; - - // Statut - print '<tr><td>'.$langs->trans("Status").'</td><td>'.$projectstatic->getLibStatut(4).'</td></tr>'; - - print '</table>'; - - dol_fiche_end(); - - print '<br>'; + // 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':''); + + print '<table class="border" width="100%">'; + + // Ref + print '<tr><td width="30%">'; + print $langs->trans("Ref"); + print '</td><td>'; + // 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 '</td></tr>'; + + print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projectstatic->title.'</td></tr>'; + + print '<tr><td>'.$langs->trans("Company").'</td><td>'; + if (! empty($projectstatic->societe->id)) print $projectstatic->societe->getNomUrl(1); + else print ' '; + print '</td>'; + print '</tr>'; + + // Visibility + print '<tr><td>'.$langs->trans("Visibility").'</td><td>'; + if ($projectstatic->public) print $langs->trans('SharedProject'); + else print $langs->trans('PrivateProject'); + print '</td></tr>'; + + // Statut + print '<tr><td>'.$langs->trans("Status").'</td><td>'.$projectstatic->getLibStatut(4).'</td></tr>'; + + print '</table>'; + + dol_fiche_end(); + + print '<br>'; } /* - * Actions + * Actions */ /*print '<div class="tabsAction">'; if ($user->rights->projet->all->creer || $user->rights->projet->creer) { - if ($projectstatic->public || $userWrite > 0) - { - print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=create'.$param.'">'.$langs->trans('AddTask').'</a>'; - } - else - { - print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('AddTask').'</a>'; - } + if ($projectstatic->public || $userWrite > 0) + { + print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=create'.$param.'">'.$langs->trans('AddTask').'</a>'; } else { - print '<a class="butActionRefused" href="#" title="'.$langs->trans("NoPermission").'">'.$langs->trans('AddTask').'</a>'; + print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('AddTask').'</a>'; + } + } + else + { + print '<a class="butActionRefused" href="#" title="'.$langs->trans("NoPermission").'">'.$langs->trans('AddTask').'</a>'; } print '</div>'; @@ -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 '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; @@ -247,15 +257,15 @@ if ($id > 0 || ! empty($ref)) // Project if (empty($withproject)) { - print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">'; - print $projectstatic->getNomUrl(1); - print '</td></tr>'; - - // Third party - print '<td>'.$langs->trans("Company").'</td><td colspan="3">'; - if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1); - else print ' '; - print '</td></tr>'; + print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">'; + print $projectstatic->getNomUrl(1); + print '</td></tr>'; + + // Third party + print '<td>'.$langs->trans("Company").'</td><td colspan="3">'; + if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1); + else print ' '; + print '</td></tr>'; } // Task parent @@ -284,9 +294,13 @@ if ($id > 0 || ! empty($ref)) print '<textarea name="description" wrap="soft" cols="80" rows="'.ROWS_3.'">'.$object->description.'</textarea>'; print '</td></tr>'; - // 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 '</table>'; @@ -301,9 +315,9 @@ if ($id > 0 || ! empty($ref)) { /* * Fiche tache en mode visu - */ - $param=($withproject?'&withproject=1':''); - $linkback=$withproject?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>':''; + */ + $param=($withproject?'&withproject=1':''); + $linkback=$withproject?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>':''; if ($action == 'delete') { @@ -319,8 +333,8 @@ if ($id > 0 || ! empty($ref)) print '</td><td colspan="3">'; 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 '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">'; - print $projectstatic->getNomUrl(1); - print '</td></tr>'; - - // Third party - print '<td>'.$langs->trans("Company").'</td><td colspan="3">'; - if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1); - else print ' '; - print '</td></tr>'; + print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">'; + print $projectstatic->getNomUrl(1); + print '</td></tr>'; + + // Third party + print '<td>'.$langs->trans("Company").'</td><td colspan="3">'; + if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1); + else print ' '; + print '</td></tr>'; } // Date start @@ -364,10 +378,14 @@ if ($id > 0 || ! empty($ref)) print nl2br($object->description); print '</td></tr>'; - // 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 '</table>'; } @@ -379,7 +397,7 @@ if ($id > 0 || ! empty($ref)) { /* * Actions - */ + */ print '<div class="tabsAction">'; // Modify