';
-
+
$error++;
}
}
} // Fin si "creation utilisateur"
-
-
+
+
/*
* If database creation is asked, we create it
*/
@@ -312,7 +312,7 @@ if ($_POST["action"] == "set")
print $dolibarr_main_db_name;
print '';
print "
".$langs->trans("OK")."
";
-
+
$check1=$db->getDefaultCharacterSetDatabase();
$check2=$db->getDefaultCollationDatabase();
dolibarr_install_syslog('etape1: Note that default server was charset='.$check1.' collation='.$check2, LOG_DEBUG);
@@ -406,7 +406,7 @@ if ($_POST["action"] == "set")
print $langs->trans("OK");
print "";
- dolibarr_install_syslog("etape1: connexion to database ".$conf->db->name.", bu user : ".$conf->db->user." has failed", LOG_ERROR);
+ dolibarr_install_syslog("etape1: connexion to database ".$conf->db->name.", bu user : ".$conf->db->user." has failed", LOG_ERR);
print "
";
print $langs->trans("DatabaseConnection")." : ";
print $dolibarr_main_db_name;
@@ -464,7 +464,7 @@ function write_conf_file($conffile)
global $dolibarr_smarty_libs_dir,$dolibarr_smarty_compile,$dolibarr_smarty_cache;
$error=0;
-
+
$fp = fopen("$conffile", "w");
if($fp)
{
@@ -482,34 +482,34 @@ function write_conf_file($conffile)
fputs($fp, '$dolibarr_main_url_root="'.$_POST["main_url"].'";');
fputs($fp,"\n");
-
+
fputs($fp, '$dolibarr_main_document_root="'.$main_dir.'";');
fputs($fp,"\n");
-
+
fputs($fp, '$dolibarr_main_data_root="'.$main_data_dir.'";');
fputs($fp,"\n");
-
+
fputs($fp, '$dolibarr_main_db_host="'.$_POST["db_host"].'";');
fputs($fp,"\n");
-
+
fputs($fp, '$dolibarr_main_db_port="'.$_POST["db_port"].'";');
fputs($fp,"\n");
fputs($fp, '$dolibarr_main_db_name="'.$_POST["db_name"].'";');
fputs($fp,"\n");
-
+
fputs($fp, '$dolibarr_main_db_user="'.$_POST["db_user"].'";');
fputs($fp,"\n");
-
+
fputs($fp, '$dolibarr_main_db_pass="'.$_POST["db_pass"].'";');
fputs($fp,"\n");
-
+
fputs($fp, '$dolibarr_main_db_type="'.$_POST["db_type"].'";');
fputs($fp,"\n");
fputs($fp, '$dolibarr_main_db_character_set="'.$_POST["dolibarr_main_db_character_set"].'";');
fputs($fp,"\n");
-
+
fputs($fp, '$dolibarr_main_db_collation="'.$_POST["dolibarr_main_db_collation"].'";');
fputs($fp,"\n");
@@ -527,17 +527,17 @@ function write_conf_file($conffile)
/* Preparation integration SMARTY */
fputs($fp, '$dolibarr_smarty_libs_dir="";');
fputs($fp,"\n");
-
+
fputs($fp, '$dolibarr_smarty_compile="";');
fputs($fp,"\n");
fputs($fp, '$dolibarr_smarty_cache="";');
fputs($fp,"\n");
/* Fin Smarty*/
-
+
fputs($fp, '?>');
fclose($fp);
-
+
if (file_exists("$conffile"))
{
include("$conffile"); // On force rechargement. Ne pas mettre include_once !
@@ -554,7 +554,7 @@ function write_conf_file($conffile)
$error++;
}
}
-
+
return $error;
}
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index e80f1551a04..9c079b06104 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -327,8 +327,8 @@ Permission32=Create/modify products/services
Permission33=Command products/services
Permission34=Delete products/services
Permission36=Export products/services
-Permission41=Read projects
-Permission42=Create/modify projects
+Permission41=Read projects and tasks
+Permission42=Create/modify projects, edit tasks for my projects
Permission44=Delete projects
Permission61=Read interventions
Permission62=Create/modify interventions
diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang
index 20a2cb71570..f33f7586d2e 100755
--- a/htdocs/langs/en_US/projects.lang
+++ b/htdocs/langs/en_US/projects.lang
@@ -1,6 +1,7 @@
# Dolibarr language file - en_US - projects
Project=Project
Projects=Projects
+SharedProject=Shared project
Myprojects=My projects
ProjectsArea=Projects area
NewProject=New project
@@ -30,8 +31,11 @@ NewTask=New task
AddTask=Add task
AddDuration=Add duration
Activity=Activity
+Activities=Tasks/activities
MyActivity=My activity
+MyActivities=My tasks/activities
DurationEffective=Effective duration
+MyProjects=My projects
Time=Time
ListProposalsAssociatedProject=Lists of the commercial proposals associated with the project
ListOrdersAssociatedProject=Lists of the orders associated with the project
@@ -42,4 +46,6 @@ ListContractAssociatedProject=List of contracts associated with the project
ActivityOnProjectThisWeek=Activity on project this week
ActivityOnProjectThisMonth=Activity on project this month
ActivityOnProjectThisYear=Activity on project this year
-ChildOfTaks=child of task
\ No newline at end of file
+ChildOfTaks=Child of project/task
+NotOwnerOfProject=Not owner of this private project
+AffectedTo=Affected to
\ No newline at end of file
diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang
index b5b26ec54f8..68767d9282f 100644
--- a/htdocs/langs/fr_FR/admin.lang
+++ b/htdocs/langs/fr_FR/admin.lang
@@ -326,8 +326,8 @@ Permission32=Cr
Permission33=Commander les produits/services
Permission34=Supprimer les produits/services
Permission36=Exporter les produits/services
-Permission41=Consulter les projets
-Permission42=Créer/modifier les projets
+Permission41=Consulter les projets et tâches
+Permission42=Créer/modifier les projets, éditer tâches de mes projets
Permission44=Supprimer les projets
Permission61=Consulter les interventions
Permission62=Créer/modifier les interventions
diff --git a/htdocs/langs/fr_FR/projects.lang b/htdocs/langs/fr_FR/projects.lang
index fa801071ba1..e26b44255ee 100755
--- a/htdocs/langs/fr_FR/projects.lang
+++ b/htdocs/langs/fr_FR/projects.lang
@@ -1,6 +1,7 @@
# Dolibarr language file - fr_FR - projects
Project=Projet
Projects=Projets
+SharedProject=Projet partagé
Myprojects=Mes projets
ProjectsArea=Espace projet
NewProject=Nouveau projet
@@ -30,7 +31,10 @@ NewTask=Nouvelle t
AddTask=Créer tâche
AddDuration=Ajouter la durée
Activity=Activité
+Activities=Tâches/activités
MyActivity=Mon activité
+MyActivities=Mes tâches/activités
+MyProjects=Mes projets
DurationEffective=Durée effective
Time=Temps
ListProposalsAssociatedProject=Liste des propositions commerciales associées au projet
@@ -42,4 +46,6 @@ ListContractAssociatedProject=Liste des contrats associ
ActivityOnProjectThisWeek=Activité sur les projets cette semaine
ActivityOnProjectThisMonth=Activité sur les projets ce mois
ActivityOnProjectThisYear=Activité sur les projets cette année
-ChildOfTaks=fille de la tache
\ No newline at end of file
+ChildOfTaks=Fille du projet/tâche
+NotOwnerOfProject=Non responsable de ce projet privé
+AffectedTo=Affecté à
\ No newline at end of file
diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php
index 1c6de18a1c1..d570b858be6 100644
--- a/htdocs/lib/functions.lib.php
+++ b/htdocs/lib/functions.lib.php
@@ -125,7 +125,7 @@ function dol_string_unaccent($str)
OOOOOUUUY
aaaaaceeee
iiiidnooooo
- uuuyy");
+ uuuyy");
$string = strtr($string, array("\xC4"=>"Ae", "\xC6"=>"AE", "\xD6"=>"Oe", "\xDC"=>"Ue", "\xDE"=>"TH", "\xDF"=>"ss", "\xE4"=>"ae", "\xE6"=>"ae", "\xF6"=>"oe", "\xFC"=>"ue", "\xFE"=>"th"));
return $string;
}
@@ -185,7 +185,7 @@ function dol_syslog($message, $level=LOG_INFO)
// If adding log inside HTML page is required
if (! empty($_REQUEST['logtohtml']) && ! empty($conf->global->MAIN_LOGTOHTML))
{
- $conf->logbuffer[]=strftime("%Y-%m-%d %H:%M:%S",time())." ".$message;
+ $conf->logbuffer[]=strftime("%Y-%m-%d %H:%M:%S",time())." ".$message;
}
// If syslog module enabled
@@ -395,7 +395,7 @@ function dol_print_date($time,$format='',$to_gmt=false,$outputlangs='')
// If date undefined or "", we return ""
if (strlen($time) == 0) return ''; // $time=0 allowed (it means 01/01/1970 00:00:00)
-
+
// Analyse de la date (deprecated)
if (eregi('^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?',$time,$reg))
{
@@ -672,7 +672,7 @@ function dol_print_size($size)
function dol_print_url($url,$target='_blank',$max=32)
{
if (empty($url)) return '';
-
+
$link='';
$newemail.=dol_trunc($email,$max);
$newemail.='';
-
+
if (($cid || $socid) && $conf->agenda->enabled && $user->rights->agenda->myactions->create)
{
$type='AC_EMAIL';
@@ -718,7 +718,7 @@ function dol_print_email($email,$cid=0,$socid=0,$addlink=0,$max=64)
$newemail='
'.$newemail.'
'.$link.'
';
}
}
-
+
return $newemail;
}
@@ -741,7 +741,7 @@ function dolibarr_print_phone($phone,$country="FR",$cid=0,$socid=0,$addlink=0,$s
function dol_print_phone($phone,$country="FR",$cid=0,$socid=0,$addlink=0,$separ=" ")
{
global $conf,$user,$langs;
-
+
// Clean phone parameter
$phone = ereg_replace("[ .-]","",trim($phone));
if (empty($phone)) { return ''; }
@@ -770,14 +770,14 @@ function dol_print_phone($phone,$country="FR",$cid=0,$socid=0,$addlink=0,$separ=
$newphone=substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2);
}
}
-
+
if (! empty($addlink))
{
if ($conf->clicktodial->enabled)
{
if (empty($user->clicktodial_loaded)) $user->fetch_clicktodial();
-
- if (empty($conf->global->CLICKTODIAL_URL)) $urlmask='ErrorClickToDialModuleNotConfigured';
+
+ if (empty($conf->global->CLICKTODIAL_URL)) $urlmask='ErrorClickToDialModuleNotConfigured';
else $urlmask=$conf->global->CLICKTODIAL_URL;
$url = sprintf($urlmask, urlencode($phone), urlencode($user->clicktodial_poste), urlencode($user->clicktodial_login), urlencode($user->clicktodial_password));
$newphone=''.$newphone.'';
@@ -806,7 +806,7 @@ function dol_print_phone($phone,$country="FR",$cid=0,$socid=0,$addlink=0,$separ=
function dol_strlen($string,$stringencoding='')
{
global $langs;
-
+
if (empty($stringencoding)) $stringencoding=$langs->charset_output;
$ret='';
@@ -833,7 +833,7 @@ function dol_strlen($string,$stringencoding='')
function dol_substr($string,$start,$length,$stringencoding='')
{
global $langs;
-
+
if (empty($stringencoding)) $stringencoding=$langs->charset_output;
$ret='';
@@ -1101,8 +1101,8 @@ function img_delete($alt = "default")
/**
* \brief Affiche logo help avec curseur "?"
- * \param usehelpcursor
- * \param usealttitle
+ * \param usehelpcursor
+ * \param usealttitle
* \return string Retourne tag img
*/
function img_help($usehelpcursor=1,$usealttitle=1)
@@ -1111,7 +1111,7 @@ function img_help($usehelpcursor=1,$usealttitle=1)
$s ='theme.'/img/info.png" border="0"';
- if ($usealttitle)
+ if ($usealttitle)
{
if (is_string($usealttitle)) $s.=' alt="'.$usealttitle.'" title="'.$usealttitle.'"';
else $s.=' alt="'.$langs->trans("Info").'" title="'.$langs->trans("Info").'"';
@@ -1567,8 +1567,8 @@ function dol_print_error($db='',$error='')
if ($_SERVER['DOCUMENT_ROOT']) // Mode web
{
print $langs->trans("DolibarrHasDetectedError").". \n";
- if (! empty($conf->global->MAIN_FEATURES_LEVEL))
- print "You use an experimental level of features, so please do NOT report any bugs, anywhere, until going back to MAIN_FEATURES_LEVEL = 0. \n";
+ if (! empty($conf->global->MAIN_FEATURES_LEVEL))
+ print "You use an experimental level of features, so please do NOT report any bugs, anywhere, until going back to MAIN_FEATURES_LEVEL = 0. \n";
print $langs->trans("InformationToHelpDiagnose").":
\n";
print "".$langs->trans("Dolibarr").": ".DOL_VERSION." \n";;
@@ -1612,7 +1612,7 @@ function dol_print_error($db='',$error='')
if ($error)
{
$langs->load("errors");
-
+
if (is_array($error)) $errors=$error;
else $errors=array($error);
@@ -1630,7 +1630,7 @@ function dol_print_error($db='',$error='')
$syslog.=", msg=".$msg;
}
}
-
+
dolibarr_syslog("Error ".$syslog, LOG_ERR);
}
@@ -1717,7 +1717,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite)
* \param begin ("" par defaut)
* \param options ("" par defaut)
* \param td options de l'attribut td ("" par defaut)
- * \param sortfield nom du champ sur lequel est effectue le tri du tableau
+ * \param sortfield field currently used to sort
* \param sortorder ordre du tri
*/
function print_liste_field_titre($name, $file, $field, $begin="", $options="", $td="", $sortfield="", $sortorder="")
@@ -1727,7 +1727,7 @@ function print_liste_field_titre($name, $file, $field, $begin="", $options="", $
// Le champ de tri est mis en evidence.
// Exemple si (sortfield,field)=("nom","xxx.nom") ou (sortfield,field)=("nom","nom")
- if ($sortfield == $field || $sortfield == ereg_replace("^[^\.]+\.","",$field))
+ if ($field && ($sortfield == $field || $sortfield == ereg_replace("^[^\.]+\.","",$field)))
{
print '
';
-
+
$pagelist = '';
// Left
@@ -2109,17 +2109,17 @@ function price2num($amount,$rounding='',$alreadysqlnb=-1)
// Convert value to universal number format (no thousand separator, '.' as decimal separator)
if ($alreadysqlnb != 1) // If not a PHP number or unknown, we change format
{
- //print 'ZZ'.$nbofdec.'=>'.$amount.' ';
-
+ //print 'ZZ'.$nbofdec.'=>'.$amount.' ';
+
// Convert amount to format with dolibarr dec and thousand (this is because PHP convert a number
// to format defined by LC_NUMERIC after a calculation and we want source format to be like defined by Dolibarr setup.
- if (is_numeric($amount))
+ if (is_numeric($amount))
{
$nbofdec=max(0,strlen($amount-intval($amount))-2);
$amount=number_format($amount,$nbofdec,$dec,$thousand);
}
//print "QQ".$amount.' ';
-
+
// Now make replace (the main goal of function)
if ($thousand != ',' && $thousand != '.') $amount=str_replace(',','.',$amount); // To accept 2 notations for french users
$amount=str_replace(' ','',$amount); // To avoid spaces
@@ -2133,12 +2133,12 @@ function price2num($amount,$rounding='',$alreadysqlnb=-1)
$nbofdectoround='';
if ($rounding == 'MU') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_UNIT;
elseif ($rounding == 'MT') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_TOT;
- elseif ($rounding == 'MS') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_SHOWN;
+ elseif ($rounding == 'MS') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_SHOWN;
elseif ($rounding == '2') $nbofdectoround=2; // For admin info page
if (strlen($nbofdectoround)) $amount = round($amount,$nbofdectoround); // $nbofdectoround can be 0.
else return 'ErrorBadParameterProvidedToFunction';
- //print 'ZZ'.$nbofdec.'-'.$nbofdectoround.'=>'.$amount.' ';
-
+ //print 'ZZ'.$nbofdec.'-'.$nbofdectoround.'=>'.$amount.' ';
+
// Convert amount to format with dolibarr dec and thousand (this is because PHP convert a number
// to format defined by LC_NUMERIC after a calculation and we want source format to be defined by Dolibarr setup.
if (is_numeric($amount))
@@ -2155,7 +2155,7 @@ function price2num($amount,$rounding='',$alreadysqlnb=-1)
$amount=str_replace($thousand,'',$amount); // Replace of thousand before replace of dec to avoid pb if thousand is .
$amount=str_replace($dec,'.',$amount);
}
-
+
return $amount;
}
@@ -2384,7 +2384,7 @@ function clean_url($url,$http=1)
//print $url." -> ".$proto." - ".$domain." - ".$port;
//$url = dol_string_nospecial(trim($url));
$url = trim($url);
-
+
// Si http: defini on supprime le http (Si https on ne supprime pas)
$newproto=$proto;
if ($http==0)
diff --git a/htdocs/lib/project.lib.php b/htdocs/lib/project.lib.php
index 61f2a68b161..ed18c860c93 100644
--- a/htdocs/lib/project.lib.php
+++ b/htdocs/lib/project.lib.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2006-2009 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
@@ -18,12 +18,11 @@
*/
/**
- \file htdocs/lib/project.lib.php
- \brief Ensemble de fonctions de base pour le module projet
- \ingroup societe
- \version $Id$
-*/
-
+ * \file htdocs/lib/project.lib.php
+ * \brief Ensemble de fonctions de base pour le module projet
+ * \ingroup societe
+ * \version $Id$
+ */
function project_prepare_head($objsoc)
{
global $langs, $conf, $user;
@@ -58,12 +57,39 @@ function project_prepare_head($objsoc)
/**
- \brief Affiche la liste d�roulante des projets d'une soci�t� donn�e
- \param socid Id soci�t�
- \param selected Id projet pr�-s�lectionn�
- \param htmlname Nom de la zone html
- \return int Nbre de projet si ok, <0 si ko
-*/
+ * \file htdocs/lib/project.lib.php
+ * \brief Ensemble de fonctions de base pour le module projet
+ * \ingroup societe
+ * \version $Id$
+ */
+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;
+ $head[$h][1] = $langs->trans("TimeSpent");
+ $head[$h][2] = 'tasks';
+ $h++;
+
+ $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/who.php?id='.$object->id;
+ $head[$h][1] = $langs->trans("Affectations");
+ $head[$h][2] = 'who';
+ $h++;
+
+ return $head;
+}
+
+
+
+/**
+ * \brief Show a combo list with projects qualified for a third party)
+ * \param socid Id third party
+ * \param selected Id project preselected
+ * \param htmlname Nom de la zone html
+ * \return int Nbre de projet si ok, <0 si ko
+ */
function select_projects($socid, $selected='', $htmlname='projectid')
{
global $db;
@@ -109,4 +135,195 @@ function select_projects($socid, $selected='', $htmlname='projectid')
}
}
+
+
+function PLinesb(&$inc, $parent, $lines, &$level, $tasksrole)
+{
+ global $user, $bc, $langs;
+ global $form;
+
+ $projectstatic = new Project($db);
+
+ $var=true;
+
+ for ($i = 0 ; $i < sizeof($lines) ; $i++)
+ {
+ if ($parent == 0)
+ $level = 0;
+
+ if ($lines[$i]->fk_parent == $parent)
+ {
+ $var = !$var;
+ print "
\n";
+
+ $inc++;
+
+ $level++;
+ if ($lines[$i]->id) PLines($inc, $lines[$i]->id, $lines, $level, $var, $showproject);
+ $level--;
+ }
+ else
+ {
+ //$level--;
+ }
+ }
+
+ return $inc;
+}
+
+/**
+ * Clean task not linked to a parent
+ * @param unknown_type $db
+ * @return int Nb of records deleted
+ */
+function clean_orphelins($db)
+{
+ $nb=0;
+
+ // There is orphelins. We clean that
+ $listofid=array();
+ $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
+ {
+ dolibarr_print_error($db);
+ }
+
+ if (sizeof($listofid))
+ {
+ // Removed orphelins records
+ print 'Some orphelins were found and restored to be parents so records are visible again.';
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task set fk_task_parent = 0 where fk_task_parent';
+ $sql.= ' NOT IN ('.join(',',$listofid).')';
+ $resql = $db->query($sql);
+ $nb=$db->affected_rows($sql);
+ }
+
+ return $nb;
+}
+
?>
\ No newline at end of file
diff --git a/htdocs/project.class.php b/htdocs/project.class.php
index 2f77b801072..774b63136f0 100644
--- a/htdocs/project.class.php
+++ b/htdocs/project.class.php
@@ -19,18 +19,17 @@
*/
/**
- \file htdocs/project.class.php
- \ingroup projet
- \brief Fichier de la classe de gestion des projets
- \version $Id$
-*/
-
+ * \file htdocs/project.class.php
+ * \ingroup projet
+ * \brief Fichier de la classe de gestion des projets
+ * \version $Id$
+ */
require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php");
/**
- \class Project
- \brief Classe permettant la gestion des projets
-*/
+ * \class Project
+ * \brief Class to manage projects
+ */
class Project extends CommonObject
{
var $db; //!< To store db handler
@@ -47,9 +46,9 @@ class Project extends CommonObject
/**
- * \brief Constructeur de la classe
- * \param DB handler acc�s base de donn�es
- */
+ * \brief Constructeur de la classe
+ * \param DB handler acc�s base de donn�es
+ */
function Project($DB)
{
$this->db = $DB;
@@ -57,10 +56,10 @@ class Project extends CommonObject
}
/*
- * \brief Cree un projet en base
- * \param user Id utilisateur qui cree
- * \return int <0 si ko, id du projet cree si ok
- */
+ * \brief Cree un projet en base
+ * \param user Id utilisateur qui cree
+ * \return int <0 si ko, id du projet cree si ok
+ */
function create($user)
{
// Check parameters
@@ -176,10 +175,10 @@ class Project extends CommonObject
}
/**
- * \brief Return list of projects
- * \param id_societe To filter on a particular third party
- * \return array Liste of projects
- */
+ * \brief Return list of projects
+ * \param id_societe To filter on a particular third party
+ * \return array Liste of projects
+ */
function liste_array($id_societe='')
{
$projets = array();
@@ -216,10 +215,10 @@ class Project extends CommonObject
}
/**
- * \brief Return list of elements for type linked to project
- * \param type 'propal','order','invoice','order_supplier','invoice_supplier'
- * \return array List of orders linked to project, <0 if error
- */
+ * \brief Return list of elements for type linked to project
+ * \param type 'propal','order','invoice','order_supplier','invoice_supplier'
+ * \return array List of orders linked to project, <0 if error
+ */
function get_element_list($type)
{
$elements = array();
@@ -262,9 +261,9 @@ class Project extends CommonObject
}
/**
- * \brief Supprime le projet dans la base
- * \param Utilisateur
- */
+ * \brief Supprime le projet dans la base
+ * \param Utilisateur
+ */
function delete($user)
{
@@ -283,51 +282,71 @@ class Project extends CommonObject
}
/**
- * \brief Create a task into project
- * \param user Id user that create
- * \param title Title of task
- * \param parent Id task parent
- */
- function CreateTask($user, $title, $parent = 0)
+ * \brief Create a task into project
+ * \param user Id user that create
+ * \param title Title of task
+ * \param parent Id task parent
+ * \param id_resp Id of responsible user
+ * \return int Task id if succes, <0 if KO
+ */
+ function CreateTask($user, $title, $parent=0, $id_resp=0)
{
$result = 0;
+ $task_id = -1;
+
if (trim($title))
{
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task (fk_projet, title, fk_user_creat, fk_task_parent, duration_effective)";
- $sql.= " VALUES (".$this->id.",'$title', ".$user->id.",".$parent.", 0)";
+ $this->db->begin();
- dolibarr_syslog("Project::CreateTask sql=".$sql,LOG_DEBUG);
- if ($this->db->query($sql) )
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task (fk_projet, title, fk_user_creat, fk_task_parent, duration_effective)";
+ $sql.= " VALUES (".$this->id.",'".addslashes($title)."', ".$user->id.",".($parent>0?$parent:'0').", 0)";
+
+ dolibarr_syslog("Project::CreateTask sql=".$sql, LOG_DEBUG);
+ if ($this->db->query($sql))
{
$task_id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task");
- $result = 0;
+ $result = $task_id;
}
else
{
- $this->error=$this->db->error();
- dolibarr_syslog("Project::CreateTask error -2 ".$this->error,LOG_ERR);
- $result = -2;
+ $this->error=$this->db->lasterror();
+ dolibarr_syslog("Project::CreateTask error -1 ".$this->error, LOG_ERR);
+ $result = -1;
}
- if ($result == 0)
+ if ($result >= 0)
{
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_actors (fk_projet_task, fk_user)";
- $sql.= " VALUES (".$task_id.",".$user->id.")";
-
- dolibarr_syslog("Project::CreateTask sql=".$sql,LOG_DEBUG);
- if ($this->db->query($sql) )
+ if ($id_resp > 0)
{
- $result = 0;
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_actors (fk_projet_task, fk_user)";
+ $sql.= " VALUES (".$task_id.",".($id_resp>0?$id_resp:'null').")";
+
+ dolibarr_syslog("Project::CreateTask sql=".$sql,LOG_DEBUG);
+ if ($this->db->query($sql) )
+ {
+ $this->db->commit();
+ return $task_id;
+ }
+ else
+ {
+ $this->error=$this->db->lasterror();
+ dolibarr_syslog("Project::CreateTask error -3 ".$this->error,LOG_ERR);
+ $this->db->rollback();
+ return -3;
+ }
}
else
{
- $this->error=$this->db->error();
- dolibarr_syslog("Project::CreateTask error -3 ".$this->error,LOG_ERR);
- $result = -2;
+ $this->db->commit();
+ return $task_id;
}
}
-
-
+ else
+ {
+ dolibarr_syslog("Project::CreateTask error -2 ".$this->error,LOG_ERR);
+ $this->db->rollback();
+ return -2;
+ }
}
else
{
@@ -340,11 +359,11 @@ class Project extends CommonObject
/**
- * \brief Cree une tache dans le projet
- * \param user Id utilisateur qui cree
- * \param title titre de la tache
- * \param parent tache parente
- */
+ * \brief Cree une tache dans le projet
+ * \param user Id utilisateur qui cree
+ * \param title titre de la tache
+ * \param parent tache parente
+ */
function TaskAddTime($user, $task, $time, $date)
{
$result = 0;
@@ -424,31 +443,39 @@ class Project extends CommonObject
}
/**
- * Return list of task for project
- * @param user Object user to limit task affected to a particular user
- *
- * @return unknown
+ * Return list of task for all projects or a particular project
+ * Sort order is on project, TODO then of position of task, and last on title of first level task
+ * @param usert Object user to limit task affected to a particular user
+ * @param userp Object user to limit projects of a particular user
+ * @return array Array of tasks
*/
- function getTasksArray($user=0)
+ function getTasksArray($usert=0,$userp=0)
{
$tasks = array();
- /* List of tasks */
+ //print $usert.'-'.$userp;
+
+ // List of tasks
$sql = "SELECT p.rowid as projectid, p.ref, p.title as ptitle,";
- $sql.= " t.rowid, t.title, t.fk_task_parent, t.duration_effective";
- $sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
- if (is_object($user))
+ $sql.= " t.rowid, t.title, t.fk_task_parent, t.duration_effective,";
+ $sql.= " up.name, up.firstname";
+ $sql.= " FROM (".MAIN_DB_PREFIX."projet as p";
+ if (is_object($usert)) // Limit to task affected to a user
{
$sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
$sql.= ", ".MAIN_DB_PREFIX."projet_task_actors as ta";
+ $sql.= ")";
}
else
{
+ $sql.= ")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid";
}
- $sql.=" WHERE 1 = 1";
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as up on p.fk_user_resp = up.rowid";
+ $sql.= " WHERE 1 = 1";
if ($this->id) $sql .= " AND t.fk_projet =".$this->id;
- if (is_object($user)) $sql .= " AND t.fk_projet = p.rowid AND ta.fk_projet_task = t.rowid AND ta.fk_user =".$user->id;
+ if (is_object($usert)) $sql .= " AND t.fk_projet = p.rowid AND ta.fk_projet_task = t.rowid AND ta.fk_user = ".$usert->id;
+ if (is_object($userp)) $sql .= " AND (p.fk_user_resp = ".$userp->id." OR p.fk_user_resp IS NULL OR p.fk_user_resp = -1)";
$sql.= " ORDER BY p.ref, t.title";
dolibarr_syslog("Project::getTasksArray sql=".$sql, LOG_DEBUG);
@@ -463,10 +490,12 @@ class Project extends CommonObject
$tasks[$i]->projectid = $obj->projectid;
$tasks[$i]->projectref = $obj->ref;
$tasks[$i]->projectlabel = $obj->title;
- $tasks[$i]->id = $obj->rowid;
- $tasks[$i]->title = $obj->title;
- $tasks[$i]->fk_parent = $obj->fk_task_parent;
- $tasks[$i]->duration = $obj->duration_effective;
+ $tasks[$i]->id = $obj->rowid;
+ $tasks[$i]->title = $obj->title;
+ $tasks[$i]->fk_parent = $obj->fk_task_parent;
+ $tasks[$i]->duration = $obj->duration_effective;
+ $tasks[$i]->name = $obj->name;
+ $tasks[$i]->firstname = $obj->firstname;
$i++;
}
$this->db->free();
@@ -479,6 +508,7 @@ class Project extends CommonObject
return $tasks;
}
+
/**
* \brief Renvoie nom clicable (avec eventuellement le picto)
* \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php
index bfd3d35e3e6..dc2b72eed70 100644
--- a/htdocs/projet/activity/index.php
+++ b/htdocs/projet/activity/index.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2006-2008 Laurent Destailleur
+ * Copyright (C) 2006-2009 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
@@ -18,11 +18,11 @@
*/
/**
- \file htdocs/projet/activity/myactivity.php
- \ingroup projet
- \brief Page activite perso du module projet
- \version $Id$
-*/
+ \file htdocs/projet/activity/myactivity.php
+ \ingroup projet
+ \brief Page activite perso du module projet
+ \version $Id$
+ */
require("./pre.inc.php");
@@ -31,9 +31,9 @@ $mode=$_REQUEST["mode"];
// Security check
if (!$user->rights->projet->lire) accessforbidden();
-if ($user->societe_id > 0)
+if ($user->societe_id > 0)
{
- $socid = $user->societe_id;
+ $socid = $user->societe_id;
}
$langs->load("projects");
@@ -43,10 +43,12 @@ $langs->load("projects");
* View
*/
-$now = time();
+$now = gmmktime();
-if ($mode == 'mine') $title=$langs->trans("MyActivity");
-else $title=$langs->trans("Activity");
+$projectstatic=new Project($db);
+
+if ($mode == 'mine') $title=$langs->trans("MyActivities");
+else $title=$langs->trans("Activities");
llxHeader("",$title);
@@ -55,18 +57,13 @@ print_fiche_titre($title);
print '
';
print '
';
-/*
- *
- * Affichage de la liste des projets
- *
- */
print '