diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php
index b5685a92265..ab659ded27f 100644
--- a/htdocs/projet/activity/index.php
+++ b/htdocs/projet/activity/index.php
@@ -55,8 +55,8 @@ print '
';
*/
print '';
print '';
-print_liste_field_titre($langs->trans("Project"),"index.php","s.nom","","","",$sortfield,$sortorder);
-print ''.$langs->trans("NbOpenTasks").' ';
+print_liste_field_titre($langs->trans("Project"),$_SERVER["PHP_SELF"],"s.nom","","","",$sortfield,$sortorder);
+print ''.$langs->trans("NbOpenTasks").' ';
print " \n";
$sql = "SELECT p.title, p.rowid, count(t.rowid)";
@@ -85,7 +85,7 @@ if ( $resql )
$var=!$var;
print "";
print ''.$row[0].' ';
- print ''.$row[2].' ';
+ print ''.$row[2].' ';
print " \n";
$i++;
@@ -103,7 +103,7 @@ print "
";
print '';
print '';
print ''.$langs->trans('Today').' ';
-print 'Temps ';
+print ''.$langs->trans("Time").' ';
print " \n";
$sql = "SELECT p.title, p.rowid, sum(tt.task_duration)";
@@ -126,7 +126,7 @@ if ( $resql )
$var=!$var;
print "";
print ''.$row[0].' ';
- print ''.$row[2].' ';
+ print ''.$row[2].' ';
print " \n";
$total += $row[2];
}
@@ -139,7 +139,7 @@ else
}
print '';
print ''.$langs->trans('Total').' ';
-print ''.$total.' ';
+print ''.$total.' ';
print " \n";
print "
";
@@ -147,7 +147,7 @@ print "";
print '';
print '';
print ''.$langs->trans('Yesterday').' ';
-print 'Temps ';
+print ''.$langs->trans("Time").' ';
print " \n";
$sql = "SELECT p.title, p.rowid, sum(tt.task_duration)";
@@ -170,7 +170,7 @@ if ( $resql )
$var=!$var;
print "";
print ''.$row[0].' ';
- print ''.$row[2].' ';
+ print ''.$row[2].' ';
print " \n";
$total += $row[2];
}
@@ -183,7 +183,7 @@ else
}
print '';
print ''.$langs->trans('Total').' ';
-print ''.$total.' ';
+print ''.$total.' ';
print " \n";
print "
";
@@ -192,8 +192,8 @@ print ' ';
/* Affichage de la liste des projets de la semaine */
print '';
print '';
-print 'Activité sur les projets cette semaine ';
-print 'Temps ';
+print ''.$langs->trans("ActivityOnProjectThisWeek").' ';
+print ''.$langs->trans("Time").' ';
print " \n";
$sql = "SELECT p.title, p.rowid, sum(tt.task_duration)";
@@ -215,7 +215,7 @@ if ( $resql )
$var=!$var;
print "";
print ''.$row[0].' ';
- print ''.$row[2].' ';
+ print ''.$row[2].' ';
print " \n";
$total += $row[2];
}
@@ -228,15 +228,15 @@ else
}
print '';
print ''.$langs->trans('Total').' ';
-print ''.$total.' ';
+print ''.$total.' ';
print " \n";
print "
";
/* Affichage de la liste des projets du mois */
print '';
print '';
-print ''.$langs->trans("Project").' ce mois : '.strftime("%B %Y", $now).' ';
-print 'Nb heures ';
+print ''.$langs->trans("ActivityOnProjectThisMonth").': '.strftime("%B %Y", $now).' ';
+print ''.$langs->trans("Time").' ';
print " \n";
$sql = "SELECT p.title, p.rowid, sum(tt.task_duration)";
@@ -249,7 +249,7 @@ $sql .= " AND tt.fk_user = ".$user->id;
$sql .= " AND month(task_date) = ".strftime("%m",$now);
$sql .= " GROUP BY p.rowid";
-$var=true;
+$var=false;
$resql = $db->query($sql);
if ( $resql )
{
@@ -257,7 +257,7 @@ if ( $resql )
{
print "";
print ''.$row[0].' ';
- print ''.$row[2].' ';
+ print ''.$row[2].' ';
print " \n";
$var=!$var;
}
@@ -272,8 +272,8 @@ print "
";
/* Affichage de la liste des projets de l'année */
print '';
print '';
-print ''.$langs->trans("Project").' cette année : '.strftime("%Y", $now).' ';
-print 'Nb heures ';
+print ''.$langs->trans("ActivityOnProjectThisYear").': '.strftime("%Y", $now).' ';
+print ''.$langs->trans("Time").' ';
print " \n";
$sql = "SELECT p.title, p.rowid, sum(tt.task_duration)";
@@ -286,7 +286,7 @@ $sql .= " AND tt.fk_user = ".$user->id;
$sql .= " AND YEAR(task_date) = ".strftime("%Y",$now);
$sql .= " GROUP BY p.rowid";
-$var=true;
+$var=false;
$resql = $db->query($sql);
if ( $resql )
{
@@ -294,7 +294,7 @@ if ( $resql )
{
print "";
print ''.$row[0].' ';
- print ''.$row[2].' ';
+ print ''.$row[2].' ';
print " \n";
$var=!$var;
}
@@ -310,5 +310,5 @@ print '
';
$db->close();
-llxFooter("Dernière modification $Date$ révision $Revision$ ");
+llxFooter('$Date$ - $Revision$');
?>
diff --git a/htdocs/projet/tasks/index.php b/htdocs/projet/tasks/index.php
index dd68d299205..93492e9b7ee 100644
--- a/htdocs/projet/tasks/index.php
+++ b/htdocs/projet/tasks/index.php
@@ -1,8 +1,7 @@
- * Copyright (C) 2004-2006 Laurent Destailleur
- * Copyright (C) 2005-2006 Regis Houssin
- *
+/* Copyright (C) 2005 Rodolphe Quiedeville
+ * Copyright (C) 2006-2008 Laurent Destailleur
+ *
* 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
@@ -16,148 +15,126 @@
* 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.
- *
- * $Id$
- * $Source$
*/
/**
- \file htdocs/projet/tasks/index.php
- \ingroup projet
- \brief Page des taches du module projet
- \version $Revision$
+ \file htdocs/projet/tasks/mytasks.php
+ \ingroup projet
+ \brief Fiche tâches d'un projet
+ \version $Id$
*/
require("./pre.inc.php");
if (!$user->rights->projet->lire) accessforbidden();
-// Sécurité accés client
-if ($user->societe_id > 0)
+$langs->load('projects');
+
+Function PLines(&$inc, $parent, $lines, &$level, &$var)
{
- $action = '';
- $socid = $user->societe_id;
+ $form = new Form($db); // $db est null ici mais inutile pour la fonction select_date()
+ global $bc, $langs;
+ for ($i = 0 ; $i < sizeof($lines) ; $i++)
+ {
+ if ($parent == 0)
+ {
+ $level = 0;
+ $var = !$var;
+ }
+
+ if ($lines[$i][1] == $parent)
+ {
+ print "\n";
+ print ''.$lines[$i][4]." \n";
+
+ for ($k = 0 ; $k < $level ; $k++)
+ {
+ print " ";
+ }
+
+ print ''.$lines[$i][0]." \n";
+
+ $heure = intval($lines[$i][3]);
+ $minutes = (($lines[$i][3] - $heure) * 60);
+ $minutes = substr("00"."$minutes", -2);
+
+ print ''.$heure." h ".$minutes." \n";
+ print " \n";
+ $inc++;
+ $level++;
+ PLines($inc, $lines[$i][2], $lines, $level, $var);
+ $level--;
+ }
+ else
+ {
+ //$level--;
+ }
+ }
}
-llxHeader("",$langs->trans("Projects"),"Projet");
-
-print_fiche_titre($langs->trans("ProjectsArea"));
-
-
-print '';
-print '';
+llxHeader("",$langs->trans("Mytasks"),"Projet");
/*
+ * Fiche projet en mode visu
*
- * Affichage de la liste des projets
- *
*/
-print '';
-print '';
-print_liste_field_titre($langs->trans("Project"),"index.php","s.nom","","","",$sortfield,$sortorder);
-print ''.$langs->trans("NbOpenTasks").' ';
-print " \n";
-$sql = "SELECT p.title, p.rowid, count(t.rowid)";
-if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
-$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
-$sql .= " , ".MAIN_DB_PREFIX."projet_task as t";
-if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-$sql .= " WHERE t.fk_projet = p.rowid";
-if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
+$h=0;
+$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/index.php';
+$head[$h][1] = $langs->trans("Tasks");
+$h++;
-if ($socid)
-{
- $sql .= " AND s.rowid = ".$socid;
-}
-$sql .= " GROUP BY p.rowid";
+dolibarr_fiche_head($head, $hselected, $langs->trans("Tasks"));
+
+/* Liste des tâches */
+
+$sql = "SELECT t.rowid, t.title, t.fk_task_parent, t.duration_effective";
+$sql .= " , p.rowid as prowid, p.title as ptitle";
+$sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t";
+$sql .= " , ".MAIN_DB_PREFIX."projet_task_actors as a";
+$sql .= " , ".MAIN_DB_PREFIX."projet as p";
+$sql .= " WHERE p.rowid = t.fk_projet";
+$sql .= " AND a.fk_projet_task = t.rowid";
+$sql .= " ORDER BY p.rowid, t.fk_task_parent";
-$var=true;
$resql = $db->query($sql);
-if ( $resql )
+if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
-
+ $tasks = array();
while ($i < $num)
{
- $row = $db->fetch_row( $resql);
- $var=!$var;
- print "";
- print ''.$row[0].' ';
- print ''.$row[2].' ';
- print " \n";
-
+ $obj = $db->fetch_object($resql);
+ $tasks[$i][0] = $obj->title;
+ $tasks[$i][1] = $obj->fk_task_parent;
+ $tasks[$i][2] = $obj->rowid;
+ $tasks[$i][3] = $obj->duration_effective;
+ $tasks[$i][4] = $obj->ptitle;
+ $tasks[$i][5] = $obj->prowid;
$i++;
}
-
- $db->free($resql);
+ $db->free();
}
else
{
dolibarr_print_error($db);
}
-print "
";
-print ' ';
-
-/*
- *
- * Affichage de la liste des projets
- *
- */
print '';
print '';
-print_liste_field_titre($langs->trans("Company"),"index.php","s.nom","","","",$sortfield,$sortorder);
-print 'Nb heures ';
-print " \n";
-
-$sql = "SELECT p.title, p.rowid, sum(tt.task_duration)";
-if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
-$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
-$sql .= " , ".MAIN_DB_PREFIX."projet_task as t";
-$sql .= " , ".MAIN_DB_PREFIX."projet_task_time as tt";
-if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-$sql .= " WHERE t.fk_projet = p.rowid";
-$sql .= " AND tt.fk_task = t.rowid";
-if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
-
-if ($socid)
-{
- $sql .= " AND s.rowid = ".$socid;
-}
-$sql .= " GROUP BY p.rowid";
-
+print ''.$langs->trans("Project").' ';
+print ''.$langs->trans("Task").' ';
+print ''.$langs->trans("DurationEffective").' ';
+print "\n";
$var=true;
-$resql = $db->query($sql);
-if ( $resql )
-{
- $num = $db->num_rows($resql);
- $i = 0;
- while ($i < $num)
- {
- $row = $db->fetch_row( $resql);
- $var=!$var;
- print "";
- print ''.$row[0].' ';
- print ''.$row[2].' ';
- print " \n";
-
- $i++;
- }
-
- $db->free($resql);
-}
-else
-{
- dolibarr_print_error($db);
-}
-print "
";
+PLines($j, 0, $tasks, $level, $var);
-print '
';
+print "";
+print '';
$db->close();
-llxFooter("Dernière modification $Date$ révision $Revision$ ");
+llxFooter('$Date$ - $Revision$');
?>
diff --git a/htdocs/projet/tasks/mytasks.php b/htdocs/projet/tasks/mytasks.php
index cf4e5befc4b..3e491cc2f40 100644
--- a/htdocs/projet/tasks/mytasks.php
+++ b/htdocs/projet/tasks/mytasks.php
@@ -1,5 +1,6 @@
+ * Copyright (C) 2006-2008 Laurent Destailleur
*
* 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
@@ -14,16 +15,13 @@
* 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.
- *
- * $Id$
- * $Source$
*/
/**
\file htdocs/projet/tasks/mytasks.php
\ingroup projet
\brief Fiche tâches d'un projet
- \version $Revision$
+ \version $Id$
*/
require("./pre.inc.php");
diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php
index cd0b14f0abd..28656b32afb 100644
--- a/htdocs/projet/tasks/task.php
+++ b/htdocs/projet/tasks/task.php
@@ -1,7 +1,7 @@
- * Copyright (C) 2006 Laurent Destailleur
- *
+/* Copyright (C) 2005 Rodolphe Quiedeville
+ * Copyright (C) 2006-2008 Laurent Destailleur
+ *
* 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
@@ -18,11 +18,11 @@
*/
/**
- \file htdocs/projet/tasks/task.php
- \ingroup projet
- \brief Fiche tâches d'un projet
- \version $Id$
-*/
+ \file htdocs/projet/tasks/task.php
+ \ingroup projet
+ \brief Fiche tâches d'un projet
+ \version $Id$
+ */
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
@@ -37,90 +37,92 @@ llxHeader("",$langs->trans("Task"));
if ($_GET["id"] > 0)
{
-
- /*
- * Fiche projet en mode visu
- *
- */
- $task = new Task($db);
- if ($task->fetch($_GET["id"]) == 0 )
- {
- $projet = new Project($db);
- $projet->fetch($task->projet_id);
- $projet->societe->fetch($projet->societe->id);
-
- $h=0;
- $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$task->id;
- $head[$h][1] = $langs->trans("Tasks");
- $head[$h][2] = 'tasks';
- $h++;
-
- dolibarr_fiche_head($head, 'tasks', $langs->trans("Tasks"));
-
- print ' ';
+ $projet = new Project($db);
+ $result=$projet->fetch($task->fk_projet);
+ if (! empty($projet->socid))
+ {
+ $projet->societe->fetch($projet->socid);
+ }
- print ' ';
- print '';
- print '';
- print ''.$langs->trans("Date").' ';
- print ''.$langs->trans("DurationEffective").' ';
- print ''.$langs->trans("User").' ';
- print " \n";
-
- foreach ($tasks as $task_time)
- {
- $var=!$var;
+ $h=0;
+ $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$task->id;
+ $head[$h][1] = $langs->trans("Tasks");
+ $head[$h][2] = 'tasks';
+ $h++;
+
+ dolibarr_fiche_head($head, 'tasks', $langs->trans("Tasks"));
+
+ print ' ';
+
+ print ' ';
+ print '';
+ print '';
+ print ''.$langs->trans("Date").' ';
+ print ''.$langs->trans("DurationEffective").' ';
+ print ''.$langs->trans("User").' ';
+ print " \n";
+
+ foreach ($tasks as $task_time)
+ {
+ $var=!$var;
print "";
print ''.dolibarr_print_date($task_time[0]).' ';
print ''.$task_time[1].' ';
print ''.$task_time[3].' ';
print " \n";
+ }
+
+ print "
";
+ print '';
}
-
- print "
";
- print '';
- }
}
$db->close();
diff --git a/htdocs/task.class.php b/htdocs/task.class.php
index 47f40a8272b..bbef879017c 100644
--- a/htdocs/task.class.php
+++ b/htdocs/task.class.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2008 Laurent Destailleur
*
* 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
@@ -14,75 +14,363 @@
* 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.
- *
- * $Id$
- * $Source$
- *
*/
/**
- \file htdocs/task.class.php
- \ingroup projet
- \brief Fichier de la classe de gestion des taches
- \version $Revision$
+ \file task.class.php
+ \ingroup project
+ \brief This file is a CRUD class file for Taks (Create/Read/Update/Delete)
+ \version $Id$
+ \remarks Initialy built by build_class_from_table on 2008-09-10 12:41
*/
+// Put here all includes required by your class file
+//require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
+//require_once(DOL_DOCUMENT_ROOT."/societe.class.php");
+//require_once(DOL_DOCUMENT_ROOT."/product.class.php");
+
+
/**
- \class Task
- \brief Classe permettant la gestion des taches
+ \class Projet_task
+ \brief Put here description of your class
+ \remarks Initialy built by build_class_from_table on 2008-09-10 12:41
*/
-
-class Task {
- var $id;
- var $db;
-
- /**
- * \brief Constructeur de la classe
- * \param DB handler accès base de données
- */
- function Task($DB)
- {
- $this->db = $DB;
- }
-
- /*
- * \brief Charge objet projet depuis la base
- * \param rowid id du projet à charger
- */
-
- function fetch($rowid)
- {
+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='projet_task'; //!< Id that identify managed objects
+ //var $table_element='projet_task'; //!< Name of table without prefix where object is stored
- $sql = "SELECT title, fk_projet, duration_effective, statut";
- $sql .= " FROM ".MAIN_DB_PREFIX."projet_task";
- $sql .= " WHERE rowid=".$rowid;
+ var $id;
- $resql = $this->db->query($sql);
- if ($resql)
- {
- if ($this->db->num_rows($resql))
- {
- $obj = $this->db->fetch_object($resql);
-
- $this->id = $rowid;
- $this->title = $obj->title;
- $this->statut = $obj->statut;
- $this->projet_id = $obj->fk_projet;
-
- $this->db->free($resql);
+ var $fk_projet;
+ var $fk_task_parent;
+ var $title;
+ var $duration_effective;
+ var $fk_user_creat;
+ var $statut;
+ var $note;
+
+
+
+
+ /**
+ * \brief Constructor
+ * \param DB Database handler
+ */
+ function Task($DB)
+ {
+ $this->db = $DB;
+ return 1;
+ }
+
+
+ /**
+ * \brief Create in database
+ * \param user User that create
+ * \param notrigger 0=launch triggers after, 1=disable triggers
+ * \return int <0 if KO, Id of created object if OK
+ */
+ function create($user, $notrigger=0)
+ {
+ global $conf, $langs;
+ $error=0;
+
+ // Clean parameters
+
+ 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->title)) $this->title=trim($this->title);
+ if (isset($this->duration_effective)) $this->duration_effective=trim($this->duration_effective);
+ if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat);
+ if (isset($this->statut)) $this->statut=trim($this->statut);
+ if (isset($this->note)) $this->note=trim($this->note);
+
+
+
+ // Check parameters
+ // Put here code to add control on parameters values
+
+ // Insert request
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task(";
+
+ $sql.= "fk_projet,";
+ $sql.= "fk_task_parent,";
+ $sql.= "title,";
+ $sql.= "duration_effective,";
+ $sql.= "fk_user_creat,";
+ $sql.= "statut,";
+ $sql.= "note";
+
+
+ $sql.= ") VALUES (";
+
+ $sql.= " ".(! isset($this->fk_projet)?'NULL':"'".$this->fk_projet."'").",";
+ $sql.= " ".(! isset($this->fk_task_parent)?'NULL':"'".$this->fk_task_parent."'").",";
+ $sql.= " ".(! isset($this->title)?'NULL':"'".$this->title."'").",";
+ $sql.= " ".(! isset($this->duration_effective)?'NULL':"'".$this->duration_effective."'").",";
+ $sql.= " ".(! isset($this->fk_user_creat)?'NULL':"'".$this->fk_user_creat."'").",";
+ $sql.= " ".(! isset($this->statut)?'NULL':"'".$this->statut."'").",";
+ $sql.= " ".(! isset($this->note)?'NULL':"'".$this->note."'")."";
+
+
+ $sql.= ")";
+
+ $this->db->begin();
+
+ dolibarr_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
+
+ if (! $error)
+ {
+ $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task");
+
+ if (! $notrigger)
+ {
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action call a trigger.
+
+ //// Call triggers
+ //include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
+ //$interface=new Interfaces($this->db);
+ //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
+ //if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ //// End call triggers
+ }
+ }
+
+ // Commit or rollback
+ if ($error)
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dolibarr_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ else
+ {
+ $this->db->commit();
+ return $this->id;
+ }
+ }
+
+
+ /**
+ * \brief Load object in memory from database
+ * \param id id object
+ * \return int <0 if KO, >0 if OK
+ */
+ function fetch($id)
+ {
+ global $langs;
+ $sql = "SELECT";
+ $sql.= " t.rowid,";
+
+ $sql.= " t.fk_projet,";
+ $sql.= " t.fk_task_parent,";
+ $sql.= " t.title,";
+ $sql.= " t.duration_effective,";
+ $sql.= " t.fk_user_creat,";
+ $sql.= " t.statut,";
+ $sql.= " t.note";
+
+
+ $sql.= " FROM ".MAIN_DB_PREFIX."projet_task as t";
+ $sql.= " WHERE t.rowid = ".$id;
+
+ dolibarr_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ if ($this->db->num_rows($resql))
+ {
+ $obj = $this->db->fetch_object($resql);
+
+ $this->id = $obj->rowid;
+
+ $this->fk_projet = $obj->fk_projet;
+ $this->fk_task_parent = $obj->fk_task_parent;
+ $this->title = $obj->title;
+ $this->duration_effective = $obj->duration_effective;
+ $this->fk_user_creat = $obj->fk_user_creat;
+ $this->statut = $obj->statut;
+ $this->note = $obj->note;
+
+
+ }
+ $this->db->free($resql);
+
+ return 1;
+ }
+ else
+ {
+ $this->error="Error ".$this->db->lasterror();
+ dolibarr_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
+ return -1;
+ }
+ }
+
+
+ /**
+ * \brief Update database
+ * \param user User that modify
+ * \param notrigger 0=launch triggers after, 1=disable triggers
+ * \return int <0 if KO, >0 if OK
+ */
+ function update($user=0, $notrigger=0)
+ {
+ global $conf, $langs;
+ $error=0;
+
+ // Clean parameters
+
+ 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->title)) $this->title=trim($this->title);
+ if (isset($this->duration_effective)) $this->duration_effective=trim($this->duration_effective);
+ if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat);
+ if (isset($this->statut)) $this->statut=trim($this->statut);
+ if (isset($this->note)) $this->note=trim($this->note);
+
+
+
+ // Check parameters
+ // Put here code to add control on parameters values
+
+ // Update request
+ $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET";
+
+ $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.= " title=".(isset($this->title)?"'".addslashes($this->title)."'":"null").",";
+ $sql.= " duration_effective=".(isset($this->duration_effective)?$this->duration_effective:"null").",";
+ $sql.= " fk_user_creat=".(isset($this->fk_user_creat)?$this->fk_user_creat:"null").",";
+ $sql.= " statut=".(isset($this->statut)?$this->statut:"null").",";
+ $sql.= " note=".(isset($this->note)?"'".addslashes($this->note)."'":"null")."";
+
+
+ $sql.= " WHERE rowid=".$this->id;
+
+ $this->db->begin();
+
+ dolibarr_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
+
+ if (! $error)
+ {
+ if (! $notrigger)
+ {
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action call a trigger.
+
+ //// Call triggers
+ //include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
+ //$interface=new Interfaces($this->db);
+ //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
+ //if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ //// End call triggers
+ }
+ }
+
+ // Commit or rollback
+ if ($error)
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dolibarr_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ else
+ {
+ $this->db->commit();
+ return 1;
+ }
+ }
+
+
+ /**
+ * \brief Delete object in database
+ * \param user User that delete
+ * \param notrigger 0=launch triggers after, 1=disable triggers
+ * \return int <0 if KO, >0 if OK
+ */
+ function delete($user, $notrigger=0)
+ {
+ global $conf, $langs;
+ $error=0;
+
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task";
+ $sql.= " WHERE rowid=".$this->id;
+
+ $this->db->begin();
+
+ dolibarr_syslog(get_class($this)."::delete sql=".$sql);
+ $resql = $this->db->query($sql);
+ if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
+
+ if (! $error)
+ {
+ if (! $notrigger)
+ {
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action call a trigger.
+
+ //// Call triggers
+ //include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
+ //$interface=new Interfaces($this->db);
+ //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
+ //if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ //// End call triggers
+ }
+ }
+
+ // Commit or rollback
+ if ($error)
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dolibarr_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ else
+ {
+ $this->db->commit();
+ return 1;
+ }
+ }
+
+
+ /**
+ * \brief Initialise object with example values
+ * \remarks id must be 0 if object instance is a specimen.
+ */
+ function initAsSpecimen()
+ {
+ $this->id=0;
+
+ $this->fk_projet='';
+ $this->fk_task_parent='';
+ $this->title='';
+ $this->duration_effective='';
+ $this->fk_user_creat='';
+ $this->statut='';
+ $this->note='';
+
+
+ }
- return 0;
- }
- else
- {
- return -1;
- }
- }
- else
- {
- print $this->db->error();
- return -2;
- }
- }
}
-?>
+?>
\ No newline at end of file