New: Enhancement in project module

This commit is contained in:
Laurent Destailleur 2009-07-28 13:37:28 +00:00
parent de18d15952
commit 72f1df8eab
31 changed files with 251 additions and 119 deletions

View File

@ -283,13 +283,14 @@ function dolibarr_fiche_head($links, $active='0', $title='', $notab=0)
} }
/** /**
* \brief Affiche le header d'une fiche * \brief Show tab header of a card
* \param links Tableau de titre d'onglets * \param links Array of tabs
* \param active 0=onglet non actif, 1=onglet actif * \param active Active tab name
* \param title Titre tabelau ("" par defaut) * \param title Title
* \param notab 0=Add tab header, 1=no tab header * \param notab 0=Add tab header, 1=no tab header
* \param picto Add a picto on tab titel
*/ */
function dol_fiche_head($links, $active='0', $title='', $notab=0) function dol_fiche_head($links, $active='0', $title='', $notab=0, $picto='')
{ {
print "\n".'<div class="tabs">'."\n"; print "\n".'<div class="tabs">'."\n";
@ -298,6 +299,7 @@ function dol_fiche_head($links, $active='0', $title='', $notab=0)
{ {
$limittitle=30; $limittitle=30;
print '<a class="tabTitle">'; print '<a class="tabTitle">';
if ($picto) print img_object('',$picto).' ';
print print
((!defined('MAIN_USE_SHORT_TITLE')) || (defined('MAIN_USE_SHORT_TITLE') && MAIN_USE_SHORT_TITLE)) ((!defined('MAIN_USE_SHORT_TITLE')) || (defined('MAIN_USE_SHORT_TITLE') && MAIN_USE_SHORT_TITLE))
? dol_trunc($title,$limittitle) ? dol_trunc($title,$limittitle)

View File

@ -141,7 +141,16 @@ function select_projects($socid, $selected='', $htmlname='projectid')
} }
/**
* Enter description here...
*
* @param unknown_type $inc
* @param unknown_type $parent
* @param unknown_type $lines
* @param unknown_type $level
* @param unknown_type $tasksrole
* @return unknown
*/
function PLinesb(&$inc, $parent, $lines, &$level, $tasksrole) function PLinesb(&$inc, $parent, $lines, &$level, $tasksrole)
{ {
global $user, $bc, $langs; global $user, $bc, $langs;
@ -220,12 +229,12 @@ function PLinesb(&$inc, $parent, $lines, &$level, $tasksrole)
/** /**
* Show task lines with a particular parent * Show task lines with a particular parent
* @param $inc Counter that count number of lines legitimate to show (for return) * @param $inc Counter that count number of lines legitimate to show (for return)
* @param $parent Id of parent task * @param $parent Id of parent task to start
* @param $lines Array of all tasks * @param $lines Array of all tasks
* @param $level Level of task * @param $level Level of task
* @param $var Color * @param $var Color
* @param $showproject Show project columns * @param $showproject Show project columns
* @param $linesfiltered ''=No filter on users, Array=Shown tasks filtered on a particular user, the array contains tasks filtered * @param $taskrole Array of task filtered on a particular user
*/ */
function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject=1, &$taskrole='') function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject=1, &$taskrole='')
{ {
@ -234,6 +243,7 @@ function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject=1, &$taskro
$lastprojectid=0; $lastprojectid=0;
$projectstatic = new Project($db); $projectstatic = new Project($db);
$taskstatic = new Task($db);
for ($i = 0 ; $i < sizeof($lines) ; $i++) for ($i = 0 ; $i < sizeof($lines) ; $i++)
{ {
@ -257,13 +267,14 @@ function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject=1, &$taskro
// If there is filters to use // If there is filters to use
if (is_array($taskrole)) if (is_array($taskrole))
{ {
// If task not legitimate to show, search if a task exists later in tree // If task not legitimate to show, search if a legitimate task exists later in tree
if (! isset($taskrole[$lines[$i]->id])) if (! isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent)
{ {
// So search if task has a subtask legitimate to show // So search if task has a subtask legitimate to show
// FIXME $foundtaskforuserdeeper=0;
//SearchPLine($foundtaskforuserafter,$lines[$i]->id,$lines,$taskrole); SearchTaskInChild($foundtaskforuserdeeper,$lines[$i]->id,$lines,$taskrole);
if ($foundtaskforuserlater) //print '$foundtaskforuserpeeper='.$foundtaskforuserdeeper.'<br>';
if ($foundtaskforuserdeeper > 0)
{ {
$showlineingray=1; // We will show line but in gray $showlineingray=1; // We will show line but in gray
} }
@ -279,25 +290,38 @@ function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject=1, &$taskro
print "<tr ".$bc[$var].">\n"; print "<tr ".$bc[$var].">\n";
print '<td>'; print '<td>';
if (! $showlineingray) print '<a href="task.php?id='.$lines[$i]->id.'">'; if ($showlineingray)
print $lines[$i]->id; {
if (! $showlineingray) print '</a>'; print '<i>'.$lines[$i]->id.'</i>';
}
else
{
$taskstatic->id=$lines[$i]->id;
$taskstatic->ref=$lines[$i]->id;
print $taskstatic->getNomUrl(1);
}
print '</td>'; print '</td>';
print "<td>"; print "<td>";
if ($showlineingray) print '<i>';
else print '<a href="task.php?id='.$lines[$i]->id.'">';
for ($k = 0 ; $k < $level ; $k++) for ($k = 0 ; $k < $level ; $k++)
{ {
print "&nbsp;&nbsp;&nbsp;"; print "&nbsp;&nbsp;&nbsp;";
} }
print $lines[$i]->title; print $lines[$i]->title;
if ($showlineingray) print '</i>';
else print '</a>';
print "</td>\n"; print "</td>\n";
if ($showproject) if ($showproject)
{ {
print "<td>"; print "<td>";
if ($showlineingray) print '<i>';
$projectstatic->id=$lines[$i]->projectid; $projectstatic->id=$lines[$i]->projectid;
$projectstatic->ref=$lines[$i]->projectref; $projectstatic->ref=$lines[$i]->projectref;
print $projectstatic->getNomUrl(1); print $projectstatic->getNomUrl(1);
if ($showlineingray) print '</i>';
print "</td>"; print "</td>";
} }
@ -305,9 +329,11 @@ function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject=1, &$taskro
$minutes = round((($lines[$i]->duration - $heure) * 60),0); $minutes = round((($lines[$i]->duration - $heure) * 60),0);
$minutes = substr("00"."$minutes", -2); $minutes = substr("00"."$minutes", -2);
print '<td align="right">'; print '<td align="right">';
if (! $showlineingray) print '<a href="task.php?id='.$lines[$i]->id.'">'; if ($showlineingray) print '<i>';
else print '<a href="time.php?id='.$lines[$i]->id.'">';
print $heure."&nbsp;h&nbsp;".$minutes; print $heure."&nbsp;h&nbsp;".$minutes;
if (! $showlineingray) print '</a>'; if ($showlineingray) print '</i>';
else print '</a>';
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
@ -328,6 +354,42 @@ function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject=1, &$taskro
return $inc; return $inc;
} }
/**
* Search in task lines with a particular parent if there is a task for a particular user (in taskrole)
* @param $inc Counter that count number of lines legitimate to show (for return)
* @param $parent Id of parent task to start
* @param $lines Array of all tasks
* @param $taskrole Array of task filtered on a particular user
* @return int 1 if there is
*/
function SearchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
{
//print 'Search in line with parent id = '.$parent.'<br>';
for ($i = 0 ; $i < sizeof($lines) ; $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;
}
/** /**
* Clean task not linked to a parent * Clean task not linked to a parent
* @param unknown_type $db * @param unknown_type $db

View File

@ -422,8 +422,10 @@ class Project extends CommonObject
/* Liste des taches et role sur la tache du user courant dans $tasksrole */ /* Liste des taches et role sur la tache du user courant dans $tasksrole */
$sql = "SELECT a.fk_projet_task, a.role"; $sql = "SELECT a.fk_projet_task, a.role";
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_actors as a"; $sql.= " FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet_task_actors as a";
$sql .= " WHERE a.fk_user = ".$user->id; $sql.= " WHERE pt.rowid = a.fk_projet_task";
$sql.= " AND a.fk_user = ".$user->id;
if ($this->id) $sql.= " AND pt.fk_projet =".$this->id;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)

View File

@ -71,7 +71,7 @@ if ($projet->user_resp_id > 0)
} }
$head=project_prepare_head($projet); $head=project_prepare_head($projet);
dol_fiche_head($head, 'element', $langs->trans("Project")); dol_fiche_head($head, 'element', $langs->trans("Project"),0,'project');
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';

View File

@ -197,7 +197,7 @@ else
if ($projet->user_resp_id > 0) $result=$projet->fetch_user($projet->user_resp_id); if ($projet->user_resp_id > 0) $result=$projet->fetch_user($projet->user_resp_id);
$head=project_prepare_head($projet); $head=project_prepare_head($projet);
dol_fiche_head($head, 'project', $langs->trans("Project")); dol_fiche_head($head, 'project', $langs->trans("Project"),0,'project');
if ($_GET["action"] == 'delete') if ($_GET["action"] == 'delete')
{ {

View File

@ -1,4 +1,4 @@
<?php <?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
@ -186,7 +186,7 @@ else
if ($_REQUEST["mode"]=='mine') $tab='mytasks'; if ($_REQUEST["mode"]=='mine') $tab='mytasks';
$head=project_prepare_head($projet); $head=project_prepare_head($projet);
dol_fiche_head($head, $tab, $langs->trans("Project")); dol_fiche_head($head, $tab, $langs->trans("Project"),0,'project');
$param=($_REQUEST["mode"]=='mine'?'&mode=mine':''); $param=($_REQUEST["mode"]=='mine'?'&mode=mine':'');
@ -223,13 +223,6 @@ else
print '</form>'; print '</form>';
print '</div>'; print '</div>';
// Get list of tasks in tasksarray and taskarrayfiltered
// We need all tasks (even not limited to a user because a task to user
// can have a parent that is not affected to him).
$tasksarray=$projet->getTasksArray(0, 0, 0);
// We load also tasks limited to a particular user
$tasksrole=($_REQUEST["mode"]=='mine' ? $projet->getTasksRoleForUser($user) : '');
/* /*
* Actions * Actions
*/ */
@ -250,6 +243,14 @@ else
print '</div>'; print '</div>';
print '<br>'; print '<br>';
// Get list of tasks in tasksarray and taskarrayfiltered
// We need all tasks (even not limited to a user because a task to user
// can have a parent that is not affected to him).
$tasksarray=$projet->getTasksArray(0, 0, 0);
// We load also tasks limited to a particular user
$tasksrole=($_REQUEST["mode"]=='mine' ? $projet->getTasksRoleForUser($user) : '');
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
if ($projectstatic->id) print '<td>'.$langs->trans("Project").'</td>'; if ($projectstatic->id) print '<td>'.$langs->trans("Project").'</td>';
@ -261,11 +262,18 @@ else
$j=0; $j=0;
$nboftaskshown=PLines($j, 0, $tasksarray, $level, true, 0, $tasksrole); $nboftaskshown=PLines($j, 0, $tasksarray, $level, true, 0, $tasksrole);
print "</table>"; print "</table>";
print '</div>'; print '</div>';
if ($nboftaskshown < sizeof($tasksarray)) // Test if database is clean. If not we clean it.
//print '$nboftaskshown='.$nboftaskshown.' sizeof($tasksarray)='.sizeof($tasksarray).' sizeof($tasksrole)='.sizeof($tasksrole).'<br>';
if ($_REQUEST["mode"]=='mine')
{ {
clean_orphelins($db); if ($nboftaskshown < sizeof($tasksrole)) clean_orphelins($db);
}
else
{
if ($nboftaskshown < sizeof($tasksarray)) clean_orphelins($db);
} }
} }

View File

@ -79,22 +79,28 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorde
$projet = new Project($db); $projet = new Project($db);
$tasksarray=$projet->getTasksArray($_GET["mode"]=='mine'?$user:0);
// Get list of tasks in tasksarray and taskarrayfiltered
// We need all tasks (even not limited to a user because a task to user
// can have a parent that is not affected to him).
$tasksarray=$projet->getTasksArray(0, 0, 0);
// We load also tasks limited to a particular user
$tasksrole=($_REQUEST["mode"]=='mine' ? $projet->getTasksRoleForUser($user) : '');
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Task").'</td>'; print '<td width="80">'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("Label").'</td>'; print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td>'.$langs->trans("Project").'</td>'; print '<td>'.$langs->trans("Project").'</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</td>'; print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
print "</tr>\n"; print "</tr>\n";
// Show all lines in taskarray (recusrive function to go down on tree)
$level=0;
$j=0; $j=0;
PLines($j, 0, $tasksarray, $level, true); $nboftaskshown=PLines($j, 0, $tasksarray, $level, true, 1, $tasksrole);
print "</table>"; print "</table>";
print '</div>'; print '</div>';

View File

@ -86,7 +86,7 @@ if ($_GET["id"] > 0)
$head=task_prepare_head($task); $head=task_prepare_head($task);
dol_fiche_head($head, 'task', $langs->trans("Task")); dol_fiche_head($head, 'task', $langs->trans("Task"),0,'projecttask');
if ($mesg) print $mesg.'<br>'; if ($mesg) print $mesg.'<br>';
@ -101,7 +101,15 @@ if ($_GET["id"] > 0)
print '<input type="hidden" name="action" value="createtask">'; print '<input type="hidden" name="action" value="createtask">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">'.$task->id.'</td></tr>'; // Ref
print '<tr><td width="30%">';
print $langs->trans("Ref");
print '</td><td colspan="3">';
print $html->showrefnav($task,'id','',1,'rowid','ref','','');
print '</td>';
print '</tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$task->title.'</td></tr>'; print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$task->title.'</td></tr>';
print '<tr><td>'.$langs->trans("Project").'</td><td>'; print '<tr><td>'.$langs->trans("Project").'</td><td>';
@ -151,10 +159,14 @@ if ($_GET["id"] > 0)
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($user->rights->projet->creer) if (!$user->rights->projet->creer)
{ {
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$task->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$task->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>';
} }
else
{
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Delete').'</a>';
}
print '</div>'; print '</div>';

View File

@ -63,7 +63,7 @@ if ($_GET["id"] > 0)
$head=task_prepare_head($task); $head=task_prepare_head($task);
dol_fiche_head($head, 'time', $langs->trans("Task")); dol_fiche_head($head, 'time', $langs->trans("Task"),0,'projecttask');
if ($mesg) print $mesg.'<br>'; if ($mesg) print $mesg.'<br>';
@ -72,7 +72,14 @@ if ($_GET["id"] > 0)
print '<input type="hidden" name="action" value="createtask">'; print '<input type="hidden" name="action" value="createtask">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">'.$task->id.'</td></tr>'; // Ref
print '<tr><td width="30%">';
print $langs->trans("Ref");
print '</td><td colspan="3">';
print $html->showrefnav($task,'id','',1,'rowid','ref','','');
print '</td></tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$task->title.'</td></tr>'; print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$task->title.'</td></tr>';
print '<tr><td>'.$langs->trans("Project").'</td><td>'; print '<tr><td>'.$langs->trans("Project").'</td><td>';

View File

@ -20,7 +20,7 @@
/** /**
* \file htdocs/projet/tasks/task.php * \file htdocs/projet/tasks/task.php
* \ingroup projet * \ingroup projet
* \brief Fiche tâches d'un projet * \brief Fiche t<EFBFBD>ches d'un projet
* \version $Id$ * \version $Id$
*/ */
@ -63,7 +63,7 @@ if ($_GET["id"] > 0)
$head=task_prepare_head($task); $head=task_prepare_head($task);
dol_fiche_head($head, 'who', $langs->trans("Task")); dol_fiche_head($head, 'who', $langs->trans("Task"),0,'projecttask');
if ($mesg) print $mesg.'<br>'; if ($mesg) print $mesg.'<br>';
@ -72,7 +72,13 @@ if ($_GET["id"] > 0)
print '<input type="hidden" name="action" value="createtask">'; print '<input type="hidden" name="action" value="createtask">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">'.$task->id.'</td></tr>'; // Ref
print '<tr><td width="30%">'.$langs->trans("Ref");
print '</td><td colspan="3">';
print $html->showrefnav($task,'id','',1,'rowid','ref','','');
print '</td></tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$task->title.'</td></tr>'; print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$task->title.'</td></tr>';
print '<tr><td>'.$langs->trans("Project").'</td><td>'; print '<tr><td>'.$langs->trans("Project").'</td><td>';

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2008-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,12 +17,12 @@
*/ */
/** /**
\file task.class.php * \file task.class.php
\ingroup project * \ingroup project
\brief This file is a CRUD class file for Taks (Create/Read/Update/Delete) * \brief This file is a CRUD class file for Taks (Create/Read/Update/Delete)
\version $Id$ * \version $Id$
\remarks Initialy built by build_class_from_table on 2008-09-10 12:41 * \remarks Initialy built by build_class_from_table on 2008-09-10 12:41
*/ */
// Put here all includes required by your class file // Put here all includes required by your class file
//require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php"); //require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
@ -31,20 +31,20 @@
/** /**
\class Projet_task * \class Projet_task
\brief Put here description of your class * \brief Put here description of your class
\remarks Initialy built by build_class_from_table on 2008-09-10 12:41 * \remarks Initialy built by build_class_from_table on 2008-09-10 12:41
*/ */
class Task // extends CommonObject class Task extends CommonObject
{ {
var $db; //!< To store db handler var $db; //!< To store db handler
var $error; //!< To return error code (or message) var $error; //!< To return error code (or message)
var $errors=array(); //!< To return several error codes (or messages) var $errors=array(); //!< To return several error codes (or messages)
//var $element='projet_task'; //!< Id that identify managed objects var $element='projet_task'; //!< Id that identify managed objects
//var $table_element='projet_task'; //!< Name of table without prefix where object is stored var $table_element='projet_task'; //!< Name of table without prefix where object is stored
var $id; var $id;
var $fk_projet; var $fk_projet;
var $fk_task_parent; var $fk_task_parent;
var $title; var $title;
@ -53,20 +53,20 @@ class Task // extends CommonObject
var $statut; var $statut;
var $note; var $note;
/** /**
* \brief Constructor * \brief Constructor
* \param DB Database handler * \param DB Database handler
*/ */
function Task($DB) function Task($DB)
{ {
$this->db = $DB; $this->db = $DB;
return 1; return 1;
} }
/** /**
* \brief Create in database * \brief Create in database
* \param user User that create * \param user User that create
@ -77,9 +77,9 @@ class Task // extends CommonObject
{ {
global $conf, $langs; global $conf, $langs;
$error=0; $error=0;
// Clean parameters // Clean parameters
if (isset($this->fk_projet)) $this->fk_projet=trim($this->fk_projet); if (isset($this->fk_projet)) $this->fk_projet=trim($this->fk_projet);
if (isset($this->fk_task_parent)) $this->fk_task_parent=trim($this->fk_task_parent); if (isset($this->fk_task_parent)) $this->fk_task_parent=trim($this->fk_task_parent);
if (isset($this->title)) $this->title=trim($this->title); if (isset($this->title)) $this->title=trim($this->title);
@ -88,14 +88,14 @@ class Task // extends CommonObject
if (isset($this->statut)) $this->statut=trim($this->statut); if (isset($this->statut)) $this->statut=trim($this->statut);
if (isset($this->note)) $this->note=trim($this->note); if (isset($this->note)) $this->note=trim($this->note);
// Check parameters // Check parameters
// Put here code to add control on parameters values // Put here code to add control on parameters values
// Insert request // Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task(";
$sql.= "fk_projet,"; $sql.= "fk_projet,";
$sql.= "fk_task_parent,"; $sql.= "fk_task_parent,";
$sql.= "title,"; $sql.= "title,";
@ -104,9 +104,9 @@ class Task // extends CommonObject
$sql.= "statut,"; $sql.= "statut,";
$sql.= "note"; $sql.= "note";
$sql.= ") VALUES ("; $sql.= ") VALUES (";
$sql.= " ".(! isset($this->fk_projet)?'NULL':"'".$this->fk_projet."'").","; $sql.= " ".(! isset($this->fk_projet)?'NULL':"'".$this->fk_projet."'").",";
$sql.= " ".(! isset($this->fk_task_parent)?'NULL':"'".$this->fk_task_parent."'").","; $sql.= " ".(! isset($this->fk_task_parent)?'NULL':"'".$this->fk_task_parent."'").",";
$sql.= " ".(! isset($this->title)?'NULL':"'".$this->title."'").","; $sql.= " ".(! isset($this->title)?'NULL':"'".$this->title."'").",";
@ -115,24 +115,24 @@ class Task // extends CommonObject
$sql.= " ".(! isset($this->statut)?'NULL':"'".$this->statut."'").","; $sql.= " ".(! isset($this->statut)?'NULL':"'".$this->statut."'").",";
$sql.= " ".(! isset($this->note)?'NULL':"'".$this->note."'").""; $sql.= " ".(! isset($this->note)?'NULL':"'".$this->note."'")."";
$sql.= ")"; $sql.= ")";
$this->db->begin(); $this->db->begin();
dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error) if (! $error)
{ {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task");
if (! $notrigger) if (! $notrigger)
{ {
// Uncomment this and change MYOBJECT to your own tag if you // Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger. // want this action call a trigger.
//// Call triggers //// Call triggers
//include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); //include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
//$interface=new Interfaces($this->db); //$interface=new Interfaces($this->db);
@ -149,7 +149,7 @@ class Task // extends CommonObject
{ {
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg); $this->error.=($this->error?', '.$errmsg:$errmsg);
} }
$this->db->rollback(); $this->db->rollback();
return -1*$error; return -1*$error;
} }
@ -160,7 +160,7 @@ class Task // extends CommonObject
} }
} }
/** /**
* \brief Load object in memory from database * \brief Load object in memory from database
* \param id id object * \param id id object
@ -171,7 +171,7 @@ class Task // extends CommonObject
global $langs; global $langs;
$sql = "SELECT"; $sql = "SELECT";
$sql.= " t.rowid,"; $sql.= " t.rowid,";
$sql.= " t.fk_projet,"; $sql.= " t.fk_projet,";
$sql.= " t.fk_task_parent,"; $sql.= " t.fk_task_parent,";
$sql.= " t.title,"; $sql.= " t.title,";
@ -180,10 +180,10 @@ class Task // extends CommonObject
$sql.= " t.statut,"; $sql.= " t.statut,";
$sql.= " t.note"; $sql.= " t.note";
$sql.= " FROM ".MAIN_DB_PREFIX."projet_task as t"; $sql.= " FROM ".MAIN_DB_PREFIX."projet_task as t";
$sql.= " WHERE t.rowid = ".$id; $sql.= " WHERE t.rowid = ".$id;
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
@ -191,9 +191,10 @@ class Task // extends CommonObject
if ($this->db->num_rows($resql)) if ($this->db->num_rows($resql))
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->ref = $obj->rowid;
$this->fk_projet = $obj->fk_projet; $this->fk_projet = $obj->fk_projet;
$this->fk_task_parent = $obj->fk_task_parent; $this->fk_task_parent = $obj->fk_task_parent;
$this->title = $obj->title; $this->title = $obj->title;
@ -202,10 +203,10 @@ class Task // extends CommonObject
$this->statut = $obj->statut; $this->statut = $obj->statut;
$this->note = $obj->note; $this->note = $obj->note;
} }
$this->db->free($resql); $this->db->free($resql);
return 1; return 1;
} }
else else
@ -215,7 +216,7 @@ class Task // extends CommonObject
return -1; return -1;
} }
} }
/** /**
* \brief Update database * \brief Update database
@ -227,9 +228,9 @@ class Task // extends CommonObject
{ {
global $conf, $langs; global $conf, $langs;
$error=0; $error=0;
// Clean parameters // Clean parameters
if (isset($this->fk_projet)) $this->fk_projet=trim($this->fk_projet); if (isset($this->fk_projet)) $this->fk_projet=trim($this->fk_projet);
if (isset($this->fk_task_parent)) $this->fk_task_parent=trim($this->fk_task_parent); if (isset($this->fk_task_parent)) $this->fk_task_parent=trim($this->fk_task_parent);
if (isset($this->title)) $this->title=trim($this->title); if (isset($this->title)) $this->title=trim($this->title);
@ -238,14 +239,14 @@ class Task // extends CommonObject
if (isset($this->statut)) $this->statut=trim($this->statut); if (isset($this->statut)) $this->statut=trim($this->statut);
if (isset($this->note)) $this->note=trim($this->note); if (isset($this->note)) $this->note=trim($this->note);
// Check parameters // Check parameters
// Put here code to add control on parameters values // Put here code to add control on parameters values
// Update request // Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET";
$sql.= " fk_projet=".(isset($this->fk_projet)?$this->fk_projet:"null").","; $sql.= " fk_projet=".(isset($this->fk_projet)?$this->fk_projet:"null").",";
$sql.= " fk_task_parent=".(isset($this->fk_task_parent)?$this->fk_task_parent:"null").","; $sql.= " fk_task_parent=".(isset($this->fk_task_parent)?$this->fk_task_parent:"null").",";
$sql.= " title=".(isset($this->title)?"'".addslashes($this->title)."'":"null").","; $sql.= " title=".(isset($this->title)?"'".addslashes($this->title)."'":"null").",";
@ -254,22 +255,22 @@ class Task // extends CommonObject
$sql.= " statut=".(isset($this->statut)?$this->statut:"null").","; $sql.= " statut=".(isset($this->statut)?$this->statut:"null").",";
$sql.= " note=".(isset($this->note)?"'".addslashes($this->note)."'":"null").""; $sql.= " note=".(isset($this->note)?"'".addslashes($this->note)."'":"null")."";
$sql.= " WHERE rowid=".$this->id; $sql.= " WHERE rowid=".$this->id;
$this->db->begin(); $this->db->begin();
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error) if (! $error)
{ {
if (! $notrigger) if (! $notrigger)
{ {
// Uncomment this and change MYOBJECT to your own tag if you // Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger. // want this action call a trigger.
//// Call triggers //// Call triggers
//include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); //include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
//$interface=new Interfaces($this->db); //$interface=new Interfaces($this->db);
@ -278,7 +279,7 @@ class Task // extends CommonObject
//// End call triggers //// End call triggers
} }
} }
// Commit or rollback // Commit or rollback
if ($error) if ($error)
{ {
@ -286,7 +287,7 @@ class Task // extends CommonObject
{ {
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg); $this->error.=($this->error?', '.$errmsg:$errmsg);
} }
$this->db->rollback(); $this->db->rollback();
return -1*$error; return -1*$error;
} }
@ -294,10 +295,10 @@ class Task // extends CommonObject
{ {
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
} }
/** /**
* \brief Delete object in database * \brief Delete object in database
* \param user User that delete * \param user User that delete
@ -308,9 +309,9 @@ class Task // extends CommonObject
{ {
global $conf, $langs; global $conf, $langs;
$error=0; $error=0;
$this->db->begin(); $this->db->begin();
if ($this->hasChildren() > 0) if ($this->hasChildren() > 0)
{ {
dol_syslog(get_class($this)."::delete Can't delete record as it has some child", LOG_WARNING); dol_syslog(get_class($this)."::delete Can't delete record as it has some child", LOG_WARNING);
@ -318,30 +319,30 @@ class Task // extends CommonObject
$this->db->rollback(); $this->db->rollback();
return 0; return 0;
} }
$sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task";
$sql.= " WHERE rowid=".$this->id; $sql.= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::delete sql=".$sql); dol_syslog(get_class($this)."::delete sql=".$sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error) if (! $error)
{ {
if (! $notrigger) if (! $notrigger)
{ {
// Uncomment this and change MYOBJECT to your own tag if you // Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger. // want this action call a trigger.
//// Call triggers //// Call triggers
//include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); //include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
//$interface=new Interfaces($this->db); //$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; } //if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers //// End call triggers
} }
} }
// Commit or rollback // Commit or rollback
if ($error) if ($error)
{ {
@ -349,7 +350,7 @@ class Task // extends CommonObject
{ {
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg); $this->error.=($this->error?', '.$errmsg:$errmsg);
} }
$this->db->rollback(); $this->db->rollback();
return -1*$error; return -1*$error;
} }
@ -367,10 +368,10 @@ class Task // extends CommonObject
function hasChildren() function hasChildren()
{ {
$ret=0; $ret=0;
$sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."projet_task"; $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."projet_task";
$sql.= " WHERE fk_task_parent=".$this->id; $sql.= " WHERE fk_task_parent=".$this->id;
dol_syslog(get_class($this)."::hasChildren sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::hasChildren sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
@ -379,17 +380,43 @@ class Task // extends CommonObject
$obj=$this->db->fetch_object($resql); $obj=$this->db->fetch_object($resql);
if ($obj) $ret=$obj->nb; if ($obj) $ret=$obj->nb;
} }
if (! $error) if (! $error)
{ {
return $ret; return $ret;
} }
else else
{ {
return -1; return -1;
} }
} }
/**
* \brief Renvoie nom clicable (avec eventuellement le picto)
* \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
* \param option Sur quoi pointe le lien
* \return string Chaine avec URL
*/
function getNomUrl($withpicto=0,$option='')
{
global $langs;
$result='';
$lien = '<a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$this->id.'">';
$lienfin='</a>';
$picto='projecttask';
$label=$langs->trans("ShowTask").': '.$this->ref;
if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin;
return $result;
}
/** /**
* \brief Initialise object with example values * \brief Initialise object with example values
* \remarks id must be 0 if object instance is a specimen. * \remarks id must be 0 if object instance is a specimen.
@ -397,7 +424,7 @@ class Task // extends CommonObject
function initAsSpecimen() function initAsSpecimen()
{ {
$this->id=0; $this->id=0;
$this->fk_projet=''; $this->fk_projet='';
$this->fk_task_parent=''; $this->fk_task_parent='';
$this->title=''; $this->title='';

Binary file not shown.

Before

Width:  |  Height:  |  Size: 736 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 736 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 736 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 736 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 736 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 736 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 736 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 736 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 736 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 736 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB