From ea13df746a8947f76a8df413727bba18c738c71d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 3 Feb 2010 16:57:23 +0000 Subject: [PATCH] Works on enhancement of project tasks Add tab "note" --- htdocs/commonobject.class.php | 11 +- htdocs/lib/project.lib.php | 10 ++ htdocs/projet/note.php | 236 ++++++++++++++++++++++++++++ htdocs/projet/tasks/contact.php | 5 + htdocs/projet/tasks/note.php | 244 +++++++++++++++++++++++++++++ htdocs/projet/tasks/task.class.php | 4 +- htdocs/projet/tasks/task.php | 31 ++++ htdocs/projet/tasks/time.php | 38 ++++- 8 files changed, 570 insertions(+), 9 deletions(-) create mode 100644 htdocs/projet/note.php create mode 100644 htdocs/projet/tasks/note.php diff --git a/htdocs/commonobject.class.php b/htdocs/commonobject.class.php index 16023eae844..dbf221ddb24 100644 --- a/htdocs/commonobject.class.php +++ b/htdocs/commonobject.class.php @@ -721,8 +721,15 @@ class CommonObject } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - if ($this->table_element == 'fichinter') $sql.= " SET note_private = '".addslashes($note)."'"; - else $sql.= " SET note = '".addslashes($note)."'"; + // TODO uniformize fields note_private + if ($this->table_element == 'fichinter' || $this->table_element == 'projet' || $this->table_element == 'projet_task') + { + $sql.= " SET note_private = '".addslashes($note)."'"; + } + else + { + $sql.= " SET note = '".addslashes($note)."'"; + } $sql.= " WHERE rowid =". $this->id; dol_syslog("CommonObject::update_note sql=".$sql, LOG_DEBUG); diff --git a/htdocs/lib/project.lib.php b/htdocs/lib/project.lib.php index 36712e7ed0a..1b166d44988 100644 --- a/htdocs/lib/project.lib.php +++ b/htdocs/lib/project.lib.php @@ -57,6 +57,11 @@ function project_prepare_head($object) $head[$h][2] = 'element'; $h++; } + + $head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + $head[$h][2] = 'note'; + $h++; // Show more tabs from modules // Entries must be declared in modules descriptor with line @@ -105,6 +110,11 @@ function task_prepare_head($object) $head[$h][1] = $langs->trans("Affectations"); $head[$h][2] = 'contact'; $h++; + + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + $head[$h][2] = 'note'; + $h++; // Show more tabs from modules // Entries must be declared in modules descriptor with line diff --git a/htdocs/projet/note.php b/htdocs/projet/note.php new file mode 100644 index 00000000000..1d609f0b36d --- /dev/null +++ b/htdocs/projet/note.php @@ -0,0 +1,236 @@ + + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file htdocs/projet/note.php + * \ingroup project + * \brief Fiche d'information sur un projet + * \version $Id$ + */ + +require('./pre.inc.php'); +require_once(DOL_DOCUMENT_ROOT."/projet/project.class.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php"); + +$langs->load('projects'); + +$id = isset($_GET["id"])?$_GET["id"]:''; + +// Security check +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'projet', $id); + + + +/******************************************************************************/ +/* Actions */ +/******************************************************************************/ + +if ($_POST["action"] == 'update_public' && $user->rights->projet->creer) +{ + $project = new Project($db); + $project->fetch($_GET['id']); + + $db->begin(); + + $res=$project->update_note_public($_POST["note_public"],$user); + if ($res < 0) + { + $mesg='
'.$project->error.'
'; + $db->rollback(); + } + else + { + $db->commit(); + } +} + +if ($_POST['action'] == 'update_private' && $user->rights->projet->creer) +{ + $project = new Project($db); + $project->fetch($_GET['id']); + + $db->begin(); + + $res=$project->update_note($_POST["note_private"],$user); + if ($res < 0) + { + $mesg='
'.$project->error.'
'; + $db->rollback(); + } + else + { + $db->commit(); + } +} + + + +/******************************************************************************/ +/* Affichage fiche */ +/******************************************************************************/ + +llxHeader(); + +$html = new Form($db); + +$id = $_GET['id']; +$ref= $_GET['ref']; +if ($id > 0 || ! empty($ref)) +{ + if ($mesg) print $mesg; + + $now=gmmktime(); + + $project = new Project($db); + $userstatic = new User($db); + + if ($project->fetch($id, $ref)) + { + if ($project->societe->id > 0) $result=$project->societe->fetch($project->societe->id); + + // To verify role of users + $userAccess = 0; + foreach(array('internal','external') as $source) + { + $userRole = $project->liste_contact(4,$source); + $num=sizeof($userRole); + + $i = 0; + while ($i < $num) + { + if ($userRole[$i]['code'] == 'PROJECTLEADER' && $user->id == $userRole[$i]['id']) + { + $userAccess++; + } + $i++; + } + } + + $head = project_prepare_head($project); + dol_fiche_head($head, 'note', $langs->trans('Project'), 0, 'project'); + + print ''; + + //$linkback="".$langs->trans("BackToList").""; + + // Ref + print ''; + + // Label + print ''; + + // Third party + print ''; + + // Project leader + print ''; + + // Note publique + print ''; + print '"; + + // Note privee + if (! $user->societe_id) + { + print ''; + print '"; + } + + print "
'.$langs->trans("Ref").''; + print $html->showrefnav($project,'ref','',1,'ref','ref'); + print '
'.$langs->trans("Label").''.$project->title.'
'.$langs->trans("Company").''; + if ($project->societe->id > 0) print $project->societe->getNomUrl(1); + else print' '; + print '
'.$langs->trans("OfficerProject").''; + $contact = $project->liste_contact(4,'internal'); + $num=sizeof($contact); + if ($num) + { + $i = 0; + while ($i < $num) + { + if ($contact[$i]['code'] == 'PROJECTLEADER') + { + $userstatic->id = $contact[$i]['id']; + $userstatic->fetch(); + print $userstatic->getNomUrl(1); + print '
'; + } + $i++; + } + } + else + { + print $langs->trans('SharedProject'); + } + print '
'.$langs->trans("NotePublic").' :'; + if ($_GET["action"] == 'edit') + { + print '
'; + print ''; + print ''; + print '
"; + print ''; + print '
'; + } + else + { + print ($project->note_public?nl2br($project->note_public):" "); + } + print "
'.$langs->trans("NotePrivate").' :'; + if ($_GET["action"] == 'edit') + { + print '
'; + print ''; + print ''; + print '
"; + print ''; + print '
'; + } + else + { + print ($project->note_private?nl2br($project->note_private):" "); + } + print "
"; + + print ''; + + /* + * Actions + */ + + print '
'; + if ($user->rights->projet->creer && $_GET['action'] <> 'edit') + { + if ($userAccess) + { + print ''.$langs->trans('Modify').''; + } + else + { + print ''.$langs->trans('Modify').''; + } + } + print '
'; + } +} +$db->close(); + +llxFooter('$Date$ - $Revision: 1.15 '); +?> diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index 935374ab4f2..93f4bfffdf8 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -195,6 +195,11 @@ if ($id > 0 || ! empty($ref)) // Label print ''.$langs->trans("Label").''.$task->label.''; + + // Project + print ''.$langs->trans("Project").''; + print $projectstatic->getNomUrl(1); + print ''; // Customer print "".$langs->trans("Company").""; diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php new file mode 100644 index 00000000000..0dc99d3f996 --- /dev/null +++ b/htdocs/projet/tasks/note.php @@ -0,0 +1,244 @@ + + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file htdocs/projet/tasks/note.php + * \ingroup project + * \brief Fiche d'information sur une tache + * \version $Id$ + */ + +require('./pre.inc.php'); +require_once(DOL_DOCUMENT_ROOT."/projet/tasks/task.class.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php"); + +$langs->load('projects'); + +$id = isset($_GET["id"])?$_GET["id"]:''; + +// Security check +if ($user->societe_id) $socid=$user->societe_id; +if (!$user->rights->projet->task->lire) accessforbidden(); +//$result = restrictedArea($user, 'projet', $id, '', 'task'); // TODO ameliorer la verification + + + +/******************************************************************************/ +/* Actions */ +/******************************************************************************/ + +if ($_POST["action"] == 'update_public' && $user->rights->projet->task->creer) +{ + $task = new Task($db); + $task->fetch($_GET['id']); + + $db->begin(); + + $res=$task->update_note_public($_POST["note_public"],$user); + if ($res < 0) + { + $mesg='
'.$task->error.'
'; + $db->rollback(); + } + else + { + $db->commit(); + } +} + +if ($_POST['action'] == 'update_private' && $user->rights->projet->task->creer) +{ + $task = new Task($db); + $task->fetch($_GET['id']); + + $db->begin(); + + $res=$task->update_note($_POST["note_private"],$user); + if ($res < 0) + { + $mesg='
'.$task->error.'
'; + $db->rollback(); + } + else + { + $db->commit(); + } +} + + + +/******************************************************************************/ +/* Affichage fiche */ +/******************************************************************************/ + +llxHeader(); + +$html = new Form($db); + +$id = $_GET['id']; +$ref= $_GET['ref']; +if ($id > 0 || ! empty($ref)) +{ + if ($mesg) print $mesg; + + $now=gmmktime(); + + $task = new Task($db); + $projectstatic = new Project($db); + $userstatic = new User($db); + + if ($task->fetch($id, $ref)) + { + $result=$projectstatic->fetch($task->fk_project); + if (! empty($projectstatic->socid)) $projectstatic->societe->fetch($projectstatic->socid); + + // To verify role of users + $userAccess = 0; + foreach(array('internal','external') as $source) + { + $userRole = $projectstatic->liste_contact(4,$source); + $num=sizeof($userRole); + + $i = 0; + while ($i < $num) + { + if ($userRole[$i]['code'] == 'PROJECTLEADER' && $user->id == $userRole[$i]['id']) + { + $userAccess++; + } + $i++; + } + } + + $head = task_prepare_head($task); + dol_fiche_head($head, 'note', $langs->trans('Task'), 0, 'projecttask'); + + print ''; + + //$linkback="".$langs->trans("BackToList").""; + + // Ref + print ''; + + // Label + print ''; + + // Project + print ''; + + // Third party + print ''; + + // Task executive + print ''; + + // Note publique + print ''; + print '"; + + // Note privee + if (! $user->societe_id) + { + print ''; + print '"; + } + + print "
'.$langs->trans("Ref").''; + print $html->showrefnav($task,'ref','',1,'ref','ref'); + print '
'.$langs->trans("Label").''.$task->label.'
'.$langs->trans("Project").''; + print $projectstatic->getNomUrl(1); + print '
'.$langs->trans("Company").''; + if ($projectstatic->societe->id > 0) print $projectstatic->societe->getNomUrl(1); + else print' '; + print '
'.$langs->trans("TaskExecutive").''; + $contact = $task->liste_contact(4,'internal'); + $num=sizeof($contact); + if ($num) + { + $i = 0; + while ($i < $num) + { + if ($contact[$i]['code'] == 'TASKEXECUTIVE') + { + $userstatic->id = $contact[$i]['id']; + $userstatic->fetch(); + print $userstatic->getNomUrl(1); + print '
'; + } + $i++; + } + } + else + { + print $langs->trans('SharedTask'); + } + print '
'.$langs->trans("NotePublic").' :'; + if ($_GET["action"] == 'edit') + { + print '
'; + print ''; + print ''; + print '
"; + print ''; + print '
'; + } + else + { + print ($task->note_public?nl2br($task->note_public):" "); + } + print "
'.$langs->trans("NotePrivate").' :'; + if ($_GET["action"] == 'edit') + { + print '
'; + print ''; + print ''; + print '
"; + print ''; + print '
'; + } + else + { + print ($task->note_private?nl2br($task->note_private):" "); + } + print "
"; + + print ''; + + /* + * Actions + */ + + print '
'; + if ($user->rights->projet->task->creer && $_GET['action'] <> 'edit') + { + if ($userAccess) + { + print ''.$langs->trans('Modify').''; + } + else + { + print ''.$langs->trans('Modify').''; + } + } + print '
'; + } +} +$db->close(); + +llxFooter('$Date$ - $Revision: 1.15 '); +?> diff --git a/htdocs/projet/tasks/task.class.php b/htdocs/projet/tasks/task.class.php index e4a99d43fe4..4fa20f8d17d 100644 --- a/htdocs/projet/tasks/task.class.php +++ b/htdocs/projet/tasks/task.class.php @@ -36,8 +36,8 @@ class Task extends CommonObject var $db; //!< To store db handler var $error; //!< To return error code (or message) var $errors=array(); //!< To return several error codes (or messages) - var $element='project_task'; //!< Id that identify managed objects - var $table_element='project_task'; //!< Name of table without prefix where object is stored + var $element='project_task'; //!< Id that identify managed objects + var $table_element='projet_task'; //!< Name of table without prefix where object is stored var $id; diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index cc2e741ece0..2213707c091 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -114,6 +114,7 @@ if ($taskid) { $task = new Task($db); $projectstatic = new Project($db); + $userstatic = new User($db); if ($task->fetch($taskid) >= 0 ) { @@ -143,15 +144,18 @@ if ($taskid) print ''.$langs->trans("Label").''; print ''; + // Project 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 ''; + // Task parent print ''.$langs->trans("ChildOfTask").''; print $formother->selectProjectTasks($task->fk_task_parent,$projectstatic->id, 'task_parent', $user->admin?0:1, 0); print ''; @@ -208,15 +212,42 @@ if ($taskid) // Label print ''.$langs->trans("Label").''.$task->label.''; + // Project 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 ''; + // Task executive + print ''.$langs->trans("TaskExecutive").''; + $contact = $task->liste_contact(4,'internal'); + $num=sizeof($contact); + if ($num) + { + $i = 0; + while ($i < $num) + { + if ($contact[$i]['code'] == 'TASKEXECUTIVE') + { + $userstatic->id = $contact[$i]['id']; + $userstatic->fetch(); + print $userstatic->getNomUrl(1); + print '
'; + } + $i++; + } + } + else + { + print $langs->trans('SharedTask'); + } + print ''; + // Date start print ''.$langs->trans("DateStart").''; print dol_print_date($task->date_start,'day'); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 038f6e66189..dbb07caa810 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -46,9 +46,6 @@ llxHeader("",$langs->trans("Task")); $html = new Form($db); -$projectstatic = new Project($db); - - if ($_GET["id"] > 0) { /* @@ -56,6 +53,9 @@ if ($_GET["id"] > 0) * */ $task = new Task($db); + $projectstatic = new Project($db); + $userstatic = new User($db); + if ($task->fetch($_GET["id"]) >= 0 ) { $result=$projectstatic->fetch($task->fk_project); @@ -82,17 +82,45 @@ if ($_GET["id"] > 0) // Label print ''.$langs->trans("Label").''.$task->label.''; + // Project 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 ''; + + // Task executive + print ''.$langs->trans("TaskExecutive").''; + $contact = $task->liste_contact(4,'internal'); + $num=sizeof($contact); + if ($num) + { + $i = 0; + while ($i < $num) + { + if ($contact[$i]['code'] == 'TASKEXECUTIVE') + { + $userstatic->id = $contact[$i]['id']; + $userstatic->fetch(); + print $userstatic->getNomUrl(1); + print '
'; + } + $i++; + } + } + else + { + print $langs->trans('SharedTask'); + } + print ''; - /* List of time spent */ - + /* + * List of time spent + */ $sql = "SELECT t.task_date, t.task_duration, t.fk_user, u.login, u.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; $sql .= " , ".MAIN_DB_PREFIX."user as u";