Mutualisation code
Ajout champ id tache sur liste des taches d'un projet
This commit is contained in:
parent
f10ae4b4dd
commit
1b36283769
78
htdocs/lib/project.lib.php
Normal file
78
htdocs/lib/project.lib.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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.
|
||||
* or see http://www.gnu.org/
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/lib/project.lib.php
|
||||
\brief Ensemble de fonctions de base pour le module projet
|
||||
\ingroup societe
|
||||
\version $Revision$
|
||||
|
||||
Ensemble de fonctions de base de dolibarr sous forme d'include
|
||||
*/
|
||||
|
||||
function project_prepare_head($objsoc)
|
||||
{
|
||||
global $langs, $conf, $user;
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/fiche.php?id='.$objsoc->id;
|
||||
$head[$h][1] = $langs->trans("Project");
|
||||
$head[$h][2] = 'project';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/fiche.php?id='.$objsoc->id;
|
||||
$head[$h][1] = $langs->trans("Tasks");
|
||||
$head[$h][2] = 'tasks';
|
||||
$h++;
|
||||
|
||||
if ($conf->propal->enabled)
|
||||
{
|
||||
$langs->load("propal");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/propal.php?id='.$objsoc->id;
|
||||
$head[$h][1] = $langs->trans("Proposals");
|
||||
$head[$h][2] = 'propal';
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->commande->enabled)
|
||||
{
|
||||
$langs->load("orders");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/commandes.php?id='.$objsoc->id;
|
||||
$head[$h][1] = $langs->trans("Orders");
|
||||
$head[$h][2] = 'order';
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->facture->enabled)
|
||||
{
|
||||
$langs->load("bills");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/facture.php?id='.$objsoc->id;
|
||||
$head[$h][1] = $langs->trans("Invoices");
|
||||
$head[$h][2] = 'invoice';
|
||||
$h++;
|
||||
}
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
?>
|
||||
@ -21,10 +21,10 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/project.class.php
|
||||
\ingroup projet
|
||||
\brief Fichier de la classe de gestion des projets
|
||||
\version $Revision$
|
||||
\file htdocs/project.class.php
|
||||
\ingroup projet
|
||||
\brief Fichier de la classe de gestion des projets
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -33,405 +33,469 @@
|
||||
*/
|
||||
class Project
|
||||
{
|
||||
var $id;
|
||||
var $db;
|
||||
var $ref;
|
||||
var $title;
|
||||
var $socid;
|
||||
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
* \param DB handler accès base de données
|
||||
*/
|
||||
function Project($DB)
|
||||
{
|
||||
$this->db = $DB;
|
||||
$this->societe = new Societe($DB);
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Crée un projet en base
|
||||
* \param user Id utilisateur qui crée
|
||||
* \return int <0 si ko, id du projet crée si ok
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
if (trim($this->ref))
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet (ref, title, fk_soc, fk_user_creat, dateo) ";
|
||||
$sql .= " VALUES ('".addslashes($this->ref)."', '".addslashes($this->title)."', $this->socid, ".$user->id.",now()) ;";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet");
|
||||
$result = $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Project::Create error -2");
|
||||
$this->error=$this->db->error();
|
||||
$result = -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Project::Create error -1 ref null");
|
||||
$result = -1;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
var $id;
|
||||
var $db;
|
||||
var $ref;
|
||||
var $title;
|
||||
var $socid;
|
||||
|
||||
|
||||
function update($user)
|
||||
{
|
||||
if (strlen(trim($this->ref)) > 0)
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."projet";
|
||||
$sql .= " SET ref='$this->ref'";
|
||||
$sql .= " , title = '$this->title'";
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog($this->db->error());
|
||||
$result = -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Project::Update ref null");
|
||||
$result = -1;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* \brief Charge objet projet depuis la base
|
||||
* \param rowid id du projet à charger
|
||||
*/
|
||||
|
||||
function fetch($rowid)
|
||||
{
|
||||
|
||||
$sql = "SELECT title, ref, fk_soc FROM ".MAIN_DB_PREFIX."projet";
|
||||
$sql .= " WHERE rowid=".$rowid;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $rowid;
|
||||
$this->ref = $obj->ref;
|
||||
$this->title = $obj->title;
|
||||
$this->titre = $obj->title;
|
||||
$this->societe->id = $obj->fk_soc;
|
||||
|
||||
$this->db->free($resql);
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
function get_propal_list()
|
||||
{
|
||||
$propales = array();
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."propal WHERE fk_projet=$this->id;";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
* \param DB handler accès base de données
|
||||
*/
|
||||
function Project($DB)
|
||||
{
|
||||
$nump = $this->db->num_rows();
|
||||
if ($nump)
|
||||
{
|
||||
$i = 0;
|
||||
while ($i < $nump)
|
||||
{
|
||||
$obj = $this->db->fetch_object();
|
||||
|
||||
$propales[$i] = $obj->rowid;
|
||||
|
||||
$i++;
|
||||
}
|
||||
$this->db->free();
|
||||
/*
|
||||
* Retourne un tableau contenant la liste des propales associees
|
||||
*/
|
||||
return $propales;
|
||||
}
|
||||
$this->db = $DB;
|
||||
$this->societe = new Societe($DB);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error() . '<br>' .$sql;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Crée un projet en base
|
||||
* \param user Id utilisateur qui crée
|
||||
* \return int <0 si ko, id du projet crée si ok
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
if (trim($this->ref))
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet (ref, title, fk_soc, fk_user_creat, dateo) ";
|
||||
$sql .= " VALUES ('".addslashes($this->ref)."', '".addslashes($this->title)."', $this->socid, ".$user->id.",now()) ;";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet");
|
||||
$result = $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Project::Create error -2");
|
||||
$this->error=$this->db->error();
|
||||
$result = -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Project::Create error -1 ref null");
|
||||
$result = -1;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function update($user)
|
||||
{
|
||||
if (strlen(trim($this->ref)) > 0)
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."projet";
|
||||
$sql .= " SET ref='$this->ref'";
|
||||
$sql .= " , title = '$this->title'";
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog($this->db->error());
|
||||
$result = -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Project::Update ref null");
|
||||
$result = -1;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* \brief Charge objet projet depuis la base
|
||||
* \param rowid id du projet à charger
|
||||
*/
|
||||
function fetch($rowid)
|
||||
{
|
||||
|
||||
$sql = "SELECT title, ref, fk_soc FROM ".MAIN_DB_PREFIX."projet";
|
||||
$sql .= " WHERE rowid=".$rowid;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $rowid;
|
||||
$this->ref = $obj->ref;
|
||||
$this->title = $obj->title;
|
||||
$this->titre = $obj->title;
|
||||
$this->societe->id = $obj->fk_soc;
|
||||
|
||||
$this->db->free($resql);
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function get_propal_list()
|
||||
{
|
||||
$propales = array();
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."propal WHERE fk_projet=$this->id;";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$nump = $this->db->num_rows();
|
||||
if ($nump)
|
||||
{
|
||||
$i = 0;
|
||||
while ($i < $nump)
|
||||
{
|
||||
$obj = $this->db->fetch_object();
|
||||
|
||||
$propales[$i] = $obj->rowid;
|
||||
|
||||
$i++;
|
||||
}
|
||||
$this->db->free();
|
||||
/*
|
||||
* Retourne un tableau contenant la liste des propales associees
|
||||
*/
|
||||
return $propales;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error() . '<br>' .$sql;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function liste_array($id_societe='')
|
||||
{
|
||||
$projets = array();
|
||||
|
||||
$sql = "SELECT rowid, title FROM ".MAIN_DB_PREFIX."projet";
|
||||
|
||||
if (isset($id_societe))
|
||||
{
|
||||
$sql .= " WHERE fk_soc = $id_societe";
|
||||
}
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$nump = $this->db->num_rows();
|
||||
|
||||
if ($nump)
|
||||
{
|
||||
$i = 0;
|
||||
while ($i < $nump)
|
||||
{
|
||||
$obj = $this->db->fetch_object();
|
||||
|
||||
$projets[$obj->rowid] = $obj->title;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
return $projets;
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function get_facture_list()
|
||||
{
|
||||
$factures = array();
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE fk_projet=$this->id;";
|
||||
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$nump = $this->db->num_rows($result);
|
||||
if ($nump)
|
||||
{
|
||||
$i = 0;
|
||||
while ($i < $nump)
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
$factures[$i] = $obj->rowid;
|
||||
|
||||
$i++;
|
||||
}
|
||||
$this->db->free($result);
|
||||
/*
|
||||
* Retourne un tableau contenant la liste des factures associees
|
||||
*/
|
||||
return $factures;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Renvoie la liste des commande associées au projet
|
||||
*
|
||||
*
|
||||
*/
|
||||
function get_commande_list()
|
||||
{
|
||||
$commandes = array();
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande WHERE fk_projet=$this->id;";
|
||||
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$nump = $this->db->num_rows($result);
|
||||
if ($nump)
|
||||
{
|
||||
$i = 0;
|
||||
while ($i < $nump)
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
$commandes[$i] = $obj->rowid;
|
||||
|
||||
$i++;
|
||||
}
|
||||
$this->db->free($result);
|
||||
/*
|
||||
* Retourne un tableau contenant la liste des commandes associees
|
||||
*/
|
||||
return $commandes;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Supprime l'projet dans la base
|
||||
* \param Utilisateur
|
||||
*/
|
||||
|
||||
function delete($user)
|
||||
{
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."projet";
|
||||
$sql .= " WHERE rowid=".$this->id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Crée une tache dans le projet
|
||||
* \param user Id utilisateur qui crée
|
||||
* \param title titre de la tâche
|
||||
* \param parent tache parente
|
||||
*/
|
||||
function CreateTask($user, $title, $parent = 0)
|
||||
{
|
||||
$result = 0;
|
||||
if (trim($title))
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task (fk_projet, title, fk_user_creat, fk_task_parent) ";
|
||||
$sql .= " VALUES (".$this->id.",'$title', ".$user->id.",".$parent.") ;";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$task_id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task");
|
||||
$result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Project::CreateTask error -2",LOG_ERR);
|
||||
dolibarr_syslog($this->db->error(),LOG_ERR);
|
||||
$this->error=$this->db->error();
|
||||
$result = -2;
|
||||
}
|
||||
|
||||
if ($result ==0)
|
||||
{
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_actors (fk_projet_task, fk_user) ";
|
||||
$sql .= " VALUES (".$task_id.",".$user->id.") ;";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Project::CreateTask error -3",LOG_ERR);
|
||||
$this->error=$this->db->error();
|
||||
$result = -2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Project::CreateTask error -1 ref null");
|
||||
$result = -1;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* \brief Crée une tache dans le projet
|
||||
* \param user Id utilisateur qui crée
|
||||
* \param title titre de la tâche
|
||||
* \param parent tache parente
|
||||
*/
|
||||
function TaskAddTime($user, $task, $time, $date)
|
||||
{
|
||||
$result = 0;
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_time (fk_task, task_date, task_duration, fk_user)";
|
||||
$sql .= " VALUES (".$task.",'".$this->db->idate($date)."',".$time.", ".$user->id.") ;";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$task_id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task");
|
||||
$result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Project::TaskAddTime error -2",LOG_ERR);
|
||||
$this->error=$this->db->error();
|
||||
$result = -2;
|
||||
}
|
||||
|
||||
if ($result ==0)
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task";
|
||||
$sql .= " SET duration_effective = duration_effective + '".ereg_replace(",",".",$time)."'";
|
||||
$sql .= " WHERE rowid = '".$task."';";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Project::TaskAddTime error -3",LOG_ERR);
|
||||
$this->error=$this->db->error();
|
||||
$result = -2;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function getTasksRoleForUser($user)
|
||||
{
|
||||
$tasksrole = array();
|
||||
|
||||
/* Liste des taches et role sur la tache du user courant dans $tasksrole */
|
||||
$sql = "SELECT a.fk_projet_task, a.role";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_actors as a";
|
||||
$sql .= " WHERE a.fk_user = ".$user->id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $this->db->fetch_row($resql);
|
||||
$tasksrole[$row[0]] = $row[1];
|
||||
$i++;
|
||||
}
|
||||
$this->db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
}
|
||||
|
||||
return $tasksrole;
|
||||
}
|
||||
|
||||
|
||||
function getTasksArray()
|
||||
{
|
||||
$tasks = array();
|
||||
|
||||
/* Liste des tâches dans $tasks */
|
||||
|
||||
$sql = "SELECT t.rowid, t.title, t.fk_task_parent, t.duration_effective";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t";
|
||||
$sql .= " WHERE t.fk_projet =".$this->id;
|
||||
$sql .= " ORDER BY t.fk_task_parent";
|
||||
|
||||
$var=true;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$tasks[$i]->id = $obj->rowid;
|
||||
$tasks[$i]->title = $obj->title;
|
||||
$tasks[$i]->fk_parent = $obj->fk_task_parent;
|
||||
$tasks[$i]->duration = $obj->duration_effective;
|
||||
$i++;
|
||||
}
|
||||
$this->db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function liste_array($id_societe='')
|
||||
{
|
||||
$projets = array();
|
||||
|
||||
$sql = "SELECT rowid, title FROM ".MAIN_DB_PREFIX."projet";
|
||||
|
||||
if (isset($id_societe))
|
||||
{
|
||||
$sql .= " WHERE fk_soc = $id_societe";
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$nump = $this->db->num_rows();
|
||||
|
||||
if ($nump)
|
||||
{
|
||||
$i = 0;
|
||||
while ($i < $nump)
|
||||
{
|
||||
$obj = $this->db->fetch_object();
|
||||
|
||||
$projets[$obj->rowid] = $obj->title;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
return $projets;
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function get_facture_list()
|
||||
{
|
||||
$factures = array();
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE fk_projet=$this->id;";
|
||||
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$nump = $this->db->num_rows($result);
|
||||
if ($nump)
|
||||
{
|
||||
$i = 0;
|
||||
while ($i < $nump)
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
$factures[$i] = $obj->rowid;
|
||||
|
||||
$i++;
|
||||
}
|
||||
$this->db->free($result);
|
||||
/*
|
||||
* Retourne un tableau contenant la liste des factures associees
|
||||
*/
|
||||
return $factures;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Renvoie la liste des commande associées au projet
|
||||
*
|
||||
*
|
||||
*/
|
||||
function get_commande_list()
|
||||
{
|
||||
$commandes = array();
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande WHERE fk_projet=$this->id;";
|
||||
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$nump = $this->db->num_rows($result);
|
||||
if ($nump)
|
||||
{
|
||||
$i = 0;
|
||||
while ($i < $nump)
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
$commandes[$i] = $obj->rowid;
|
||||
|
||||
$i++;
|
||||
}
|
||||
$this->db->free($result);
|
||||
/*
|
||||
* Retourne un tableau contenant la liste des commandes associees
|
||||
*/
|
||||
return $commandes;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Supprime l'projet dans la base
|
||||
* \param Utilisateur
|
||||
*/
|
||||
|
||||
function delete($user)
|
||||
{
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."projet";
|
||||
$sql .= " WHERE rowid=".$this->id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Crée une tache dans le projet
|
||||
* \param user Id utilisateur qui crée
|
||||
* \param title titre de la tâche
|
||||
* \param parent tache parente
|
||||
*/
|
||||
function CreateTask($user, $title, $parent = 0)
|
||||
{
|
||||
$result = 0;
|
||||
if (trim($title))
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task (fk_projet, title, fk_user_creat, fk_task_parent) ";
|
||||
$sql .= " VALUES (".$this->id.",'$title', ".$user->id.",".$parent.") ;";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$task_id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task");
|
||||
$result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Project::CreateTask error -2",LOG_ERR);
|
||||
dolibarr_syslog($this->db->error(),LOG_ERR);
|
||||
$this->error=$this->db->error();
|
||||
$result = -2;
|
||||
}
|
||||
|
||||
if ($result ==0)
|
||||
{
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_actors (fk_projet_task, fk_user) ";
|
||||
$sql .= " VALUES (".$task_id.",".$user->id.") ;";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Project::CreateTask error -3",LOG_ERR);
|
||||
$this->error=$this->db->error();
|
||||
$result = -2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Project::CreateTask error -1 ref null");
|
||||
$result = -1;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
/*
|
||||
* \brief Crée une tache dans le projet
|
||||
* \param user Id utilisateur qui crée
|
||||
* \param title titre de la tâche
|
||||
* \param parent tache parente
|
||||
*/
|
||||
function TaskAddTime($user, $task, $time, $date)
|
||||
{
|
||||
$result = 0;
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_time (fk_task, task_date, task_duration, fk_user)";
|
||||
$sql .= " VALUES (".$task.",'".$this->db->idate($date)."',".$time.", ".$user->id.") ;";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$task_id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task");
|
||||
$result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Project::TaskAddTime error -2",LOG_ERR);
|
||||
$this->error=$this->db->error();
|
||||
$result = -2;
|
||||
}
|
||||
|
||||
if ($result ==0)
|
||||
{
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task";
|
||||
$sql .= " SET duration_effective = duration_effective + '".ereg_replace(",",".",$time)."'";
|
||||
$sql .= " WHERE rowid = '".$task."';";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Project::TaskAddTime error -3",LOG_ERR);
|
||||
$this->error=$this->db->error();
|
||||
$result = -2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -31,6 +31,7 @@ require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
|
||||
|
||||
if ($conf->projet->enabled) $langs->load("projects");
|
||||
$langs->load("companies");
|
||||
@ -72,43 +73,13 @@ llxHeader("","../");
|
||||
|
||||
$projet = new Project($db);
|
||||
$projet->fetch($_GET["id"]);
|
||||
|
||||
$h=0;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/fiche.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Project");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/fiche.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Tasks");
|
||||
$h++;
|
||||
|
||||
if ($conf->propal->enabled) {
|
||||
$langs->load("propal");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/propal.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Proposals");
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->commande->enabled) {
|
||||
$langs->load("orders");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/commandes.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Orders");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->facture->enabled) {
|
||||
$langs->load("bills");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/facture.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Bills");
|
||||
$h++;
|
||||
}
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Project").": ".$projet->ref);
|
||||
|
||||
|
||||
$projet->societe->fetch($projet->societe->id);
|
||||
|
||||
$head=project_prepare_head($projet);
|
||||
dolibarr_fiche_head($head, 'order', $langs->trans("Project"));
|
||||
|
||||
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td><td>'.$projet->ref.'</td></tr>';
|
||||
|
||||
@ -31,6 +31,7 @@ require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
|
||||
|
||||
$langs->load("projects");
|
||||
$langs->load("companies");
|
||||
@ -73,43 +74,12 @@ llxHeader("","../");
|
||||
|
||||
$projet = new Project($db);
|
||||
$projet->fetch($_GET["id"]);
|
||||
|
||||
$h=0;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/fiche.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Project");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/fiche.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Tasks");
|
||||
$h++;
|
||||
|
||||
if ($conf->propal->enabled) {
|
||||
$langs->load("propal");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/propal.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Proposals");
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->commande->enabled) {
|
||||
$langs->load("orders");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/commandes.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Orders");
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->facture->enabled) {
|
||||
$langs->load("bills");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/facture.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Bills");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
}
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Project").": ".$projet->ref);
|
||||
|
||||
|
||||
$projet->societe->fetch($projet->societe->id);
|
||||
|
||||
$head=project_prepare_head($projet);
|
||||
dolibarr_fiche_head($head, 'invoice', $langs->trans("Project"));
|
||||
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td><td>'.$projet->ref.'</td></tr>';
|
||||
|
||||
@ -31,6 +31,7 @@ require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
|
||||
|
||||
if (!$user->rights->projet->lire) accessforbidden();
|
||||
|
||||
@ -44,7 +45,7 @@ if ($projetid == '' && ($_GET['action'] != "create" && $_POST['action'] != "add"
|
||||
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$socid = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
// Protection restriction commercial
|
||||
@ -56,7 +57,7 @@ if ($projetid && !$user->rights->commercial->client->voir)
|
||||
$sql.= " WHERE p.rowid = ".$projetid;
|
||||
if (!$user->rights->commercial->client->voir) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
|
||||
if ($socid) $sql .= " AND p.fk_soc = ".$socid;
|
||||
|
||||
|
||||
if ( $db->query($sql) )
|
||||
{
|
||||
if ( $db->num_rows() == 0) accessforbidden();
|
||||
@ -66,61 +67,63 @@ if ($projetid && !$user->rights->commercial->client->voir)
|
||||
|
||||
if ($_POST["action"] == 'add' && $user->rights->projet->creer)
|
||||
{
|
||||
$pro = new Project($db);
|
||||
$pro->socid = $_GET["socid"];
|
||||
$pro->ref = $_POST["ref"];
|
||||
$pro->title = $_POST["title"];
|
||||
$result = $pro->create($user);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
Header("Location:fiche.php?id=".$pro->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$pro->error.'</div>';
|
||||
$_GET["action"] = 'create';
|
||||
}
|
||||
$pro = new Project($db);
|
||||
$pro->socid = $_GET["socid"];
|
||||
$pro->ref = $_POST["ref"];
|
||||
$pro->title = $_POST["title"];
|
||||
$result = $pro->create($user);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
Header("Location:fiche.php?id=".$pro->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$pro->error.'</div>';
|
||||
$_GET["action"] = 'create';
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST["action"] == 'update' && $user->rights->projet->creer)
|
||||
{
|
||||
if (! $_POST["cancel"])
|
||||
{
|
||||
if (!(empty($_POST["id"]) || empty($_POST["ref"]) || empty($_POST["title"])))
|
||||
if (! $_POST["cancel"])
|
||||
{
|
||||
$projet = new Project($db);
|
||||
$projet->id = $_POST["id"];
|
||||
$projet->ref = $_POST["ref"];
|
||||
$projet->title = $_POST["title"];
|
||||
$projet->update($user);
|
||||
|
||||
$_GET["id"]=$projet->id; // On retourne sur la fiche projet
|
||||
if (!(empty($_POST["id"]) || empty($_POST["ref"]) || empty($_POST["title"])))
|
||||
{
|
||||
$projet = new Project($db);
|
||||
$projet->id = $_POST["id"];
|
||||
$projet->ref = $_POST["ref"];
|
||||
$projet->title = $_POST["title"];
|
||||
$projet->update($user);
|
||||
|
||||
$_GET["id"]=$projet->id; // On retourne sur la fiche projet
|
||||
}
|
||||
else
|
||||
{
|
||||
$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet
|
||||
$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->projet->supprimer)
|
||||
{
|
||||
$projet = new Project($db);
|
||||
$projet->id = $_GET["id"];
|
||||
if ($projet->delete($user) == 0)
|
||||
{
|
||||
Header("Location: index.php");
|
||||
}
|
||||
else
|
||||
{
|
||||
Header("Location: fiche.php?id=".$projet->id);
|
||||
}
|
||||
$projet = new Project($db);
|
||||
$projet->id = $_GET["id"];
|
||||
if ($projet->delete($user) == 0)
|
||||
{
|
||||
Header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
Header("Location: fiche.php?id=".$projet->id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -158,109 +161,76 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
|
||||
|
||||
} else {
|
||||
|
||||
/*
|
||||
* Fiche projet en mode visu
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Fiche projet en mode visu
|
||||
*
|
||||
*/
|
||||
|
||||
$projet = new Project($db);
|
||||
$projet->fetch($_GET["id"]);
|
||||
$projet->societe->fetch($projet->societe->id);
|
||||
|
||||
$h=0;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/fiche.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Project");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/fiche.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Tasks");
|
||||
$h++;
|
||||
$projet = new Project($db);
|
||||
$projet->fetch($_GET["id"]);
|
||||
$projet->societe->fetch($projet->societe->id);
|
||||
|
||||
if ($conf->propal->enabled)
|
||||
{
|
||||
$langs->load("propal");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/propal.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Proposals");
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->commande->enabled)
|
||||
{
|
||||
$langs->load("orders");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/commandes.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Orders");
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->facture->enabled)
|
||||
{
|
||||
$langs->load("bills");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/facture.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Bills");
|
||||
$h++;
|
||||
}
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Project").": ".$projet->ref);
|
||||
$head=project_prepare_head($projet);
|
||||
dolibarr_fiche_head($head, 'project', $langs->trans("Project"));
|
||||
|
||||
|
||||
if ($_GET["action"] == 'delete')
|
||||
{
|
||||
$htmls = new Form($db);
|
||||
$htmls->form_confirm("fiche.php?id=".$_GET["id"],$langs->trans("DeleteAProject"),$langs->trans("ConfirmDeleteAProject"),"confirm_delete");
|
||||
print "<br>";
|
||||
}
|
||||
if ($_GET["action"] == 'delete')
|
||||
{
|
||||
$htmls = new Form($db);
|
||||
$htmls->form_confirm("fiche.php?id=".$_GET["id"],$langs->trans("DeleteAProject"),$langs->trans("ConfirmDeleteAProject"),"confirm_delete");
|
||||
print "<br>";
|
||||
}
|
||||
|
||||
if ($_GET["action"] == 'edit')
|
||||
{
|
||||
print '<form method="post" action="fiche.php">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
|
||||
if ($_GET["action"] == 'edit')
|
||||
{
|
||||
print '<form method="post" action="fiche.php">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td><td><input size="8" name="ref" value="'.$projet->ref.'"></td></tr>';
|
||||
// Ref
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td><td><input size="8" name="ref" value="'.$projet->ref.'"></td></tr>';
|
||||
|
||||
// Label
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td><input size="30" name="title" value="'.$projet->title.'"></td></tr>';
|
||||
// Label
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td><input size="30" name="title" value="'.$projet->title.'"></td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Company").'</td><td>'.$projet->societe->getNomUrl(1).'</td></tr>';
|
||||
print '<tr><td align="center" colspan="2"><input name="update" class="button" type="submit" value="'.$langs->trans("Modify").'"> <input type="submit" class="button" name="cancel" Value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td>'.$langs->trans("Company").'</td><td>'.$projet->societe->getNomUrl(1).'</td></tr>';
|
||||
print '<tr><td align="center" colspan="2"><input name="update" class="button" type="submit" value="'.$langs->trans("Modify").'"> <input type="submit" class="button" name="cancel" Value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td><td>'.$projet->ref.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projet->title.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td><td>'.$projet->ref.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projet->title.'</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Company").'</td><td>'.$projet->societe->getNomUrl(1).'</td></tr>';
|
||||
print '</table>';
|
||||
}
|
||||
print '<tr><td>'.$langs->trans("Company").'</td><td>'.$projet->societe->getNomUrl(1).'</td></tr>';
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
/*
|
||||
* Boutons actions
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($_GET["action"] != "edit")
|
||||
/*
|
||||
* Boutons actions
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($_GET["action"] != "edit")
|
||||
{
|
||||
if ($user->rights->projet->creer)
|
||||
{
|
||||
print '<a class="butAction" href="fiche.php?id='.$projet->id.'&action=edit">'.$langs->trans("Edit").'</a>';
|
||||
}
|
||||
if ($user->rights->projet->supprimer)
|
||||
{
|
||||
print '<a class="butActionDelete" href="fiche.php?id='.$projet->id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
||||
}
|
||||
}
|
||||
{
|
||||
print '<a class="butAction" href="fiche.php?id='.$projet->id.'&action=edit">'.$langs->trans("Edit").'</a>';
|
||||
}
|
||||
if ($user->rights->projet->supprimer)
|
||||
{
|
||||
print '<a class="butActionDelete" href="fiche.php?id='.$projet->id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print "</div>";
|
||||
print "</div>";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -31,6 +31,7 @@ require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
|
||||
|
||||
$langs->load("projects");
|
||||
$langs->load("companies");
|
||||
@ -72,45 +73,15 @@ llxHeader("","../");
|
||||
|
||||
$projet = new Project($db);
|
||||
$projet->fetch($_GET["id"]);
|
||||
$projet->societe->fetch($projet->societe->id);
|
||||
|
||||
$h=0;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/fiche.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Project");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/fiche.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Tasks");
|
||||
$h++;
|
||||
|
||||
if ($conf->propal->enabled) {
|
||||
$langs->load("propal");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/propal.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Proposals");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->commande->enabled) {
|
||||
$langs->load("orders");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/commandes.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Orders");
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->facture->enabled) {
|
||||
$langs->load("bills");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/facture.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Bills");
|
||||
$h++;
|
||||
}
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Project").": ".$projet->ref);
|
||||
$head=project_prepare_head($projet);
|
||||
dolibarr_fiche_head($head, 'propal', $langs->trans("Project"));
|
||||
|
||||
|
||||
$propales = array();
|
||||
|
||||
$projet->societe->fetch($projet->societe->id);
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td><td>'.$projet->ref.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projet->title.'</td></tr>';
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
|
||||
|
||||
$user->getrights('projet');
|
||||
|
||||
@ -61,85 +62,90 @@ if ($projetid && !$user->rights->commercial->client->voir)
|
||||
}
|
||||
}
|
||||
|
||||
Function PLines(&$inc, $parent, $lines, &$level, $actors)
|
||||
Function PLines(&$inc, $parent, $lines, &$level, $tasksrole)
|
||||
{
|
||||
$form = new Form($db); // $db est null ici mais inutile pour la fonction select_date()
|
||||
global $user, $bc, $langs;
|
||||
for ($i = 0 ; $i < sizeof($lines) ; $i++)
|
||||
{
|
||||
if ($parent == 0)
|
||||
$level = 0;
|
||||
$form = new Form($db); // $db est null ici mais inutile pour la fonction select_date()
|
||||
global $user, $bc, $langs;
|
||||
|
||||
if ($lines[$i][1] == $parent)
|
||||
for ($i = 0 ; $i < sizeof($lines) ; $i++)
|
||||
{
|
||||
$var = !$var;
|
||||
print "<tr $bc[$var]>\n<td>";
|
||||
if ($parent == 0)
|
||||
$level = 0;
|
||||
|
||||
for ($k = 0 ; $k < $level ; $k++)
|
||||
{
|
||||
print " ";
|
||||
}
|
||||
if ($lines[$i]->fk_parent == $parent)
|
||||
{
|
||||
$var = !$var;
|
||||
print "<tr $bc[$var]>\n";
|
||||
|
||||
print '<a href="task.php?id='.$lines[$i][2].'">'.$lines[$i][0]."</a></td>\n";
|
||||
print "<td>".$lines[$i]->id."</td>";
|
||||
|
||||
$heure = intval($lines[$i][3]);
|
||||
$minutes = (($lines[$i][3] - $heure) * 60);
|
||||
$minutes = substr("00"."$minutes", -2);
|
||||
print "<td>";
|
||||
|
||||
print '<td align="right">'.$heure." h ".$minutes."</td>\n";
|
||||
for ($k = 0 ; $k < $level ; $k++)
|
||||
{
|
||||
print " ";
|
||||
}
|
||||
|
||||
// TODO améliorer le test
|
||||
print '<a href="task.php?id='.$lines[$i]->id.'">'.$lines[$i]->title."</a></td>\n";
|
||||
|
||||
if ($actors[$lines[$i][2]] == 'admin')
|
||||
{
|
||||
print '<td><input size="4" type="text" class="flat" name="task'.$lines[$i][2].'" value="">';
|
||||
print ' <input type="submit" class="button" value="'.$langs->trans("Save").'"></td>';
|
||||
print "\n<td>";
|
||||
print $form->select_date('',$lines[$i][2],'','','',"addtime");
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td colspan="2"> </td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
$inc++;
|
||||
$level++;
|
||||
PLines($inc, $lines[$i][2], $lines, $level, $actors);
|
||||
$level--;
|
||||
$heure = intval($lines[$i]->duration);
|
||||
$minutes = (($lines[$i]->duration - $heure) * 60);
|
||||
$minutes = substr("00"."$minutes", -2);
|
||||
|
||||
print '<td align="right">'.$heure." h ".$minutes."</td>\n";
|
||||
|
||||
// TODO améliorer le test
|
||||
|
||||
if ($tasksrole[$lines[$i]->id] == 'admin')
|
||||
{
|
||||
print '<td><input size="4" type="text" class="flat" name="task'.$lines[$i]->id.'" value="">';
|
||||
print ' <input type="submit" class="button" value="'.$langs->trans("Save").'"></td>';
|
||||
print "\n<td>";
|
||||
print $form->select_date('',$lines[$i]->id,'','','',"addtime");
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td colspan="2"> </td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
$inc++;
|
||||
$level++;
|
||||
PLines($inc, $lines[$i]->id, $lines, $level, $tasksrole);
|
||||
$level--;
|
||||
}
|
||||
else
|
||||
{
|
||||
//$level--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//$level--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Function PLineSelect(&$inc, $parent, $lines, &$level)
|
||||
{
|
||||
for ($i = 0 ; $i < sizeof($lines) ; $i++)
|
||||
{
|
||||
if ($parent == 0)
|
||||
$level = 0;
|
||||
|
||||
if ($lines[$i][1] == $parent)
|
||||
for ($i = 0 ; $i < sizeof($lines) ; $i++)
|
||||
{
|
||||
$var = !$var;
|
||||
print '<option value="'.$lines[$i][2].'">';
|
||||
if ($parent == 0)
|
||||
$level = 0;
|
||||
|
||||
for ($k = 0 ; $k < $level ; $k++)
|
||||
{
|
||||
print " ";
|
||||
}
|
||||
if ($lines[$i]->fk_parent == $parent)
|
||||
{
|
||||
$var = !$var;
|
||||
print '<option value="'.$lines[$i]->id.'">';
|
||||
|
||||
print $lines[$i][0]."</option>\n";
|
||||
for ($k = 0 ; $k < $level ; $k++)
|
||||
{
|
||||
print " ";
|
||||
}
|
||||
|
||||
$inc++;
|
||||
$level++;
|
||||
PLineSelect($inc, $lines[$i][2], $lines, $level);
|
||||
$level--;
|
||||
print $lines[$i]->title."</option>\n";
|
||||
|
||||
$inc++;
|
||||
$level++;
|
||||
PLineSelect($inc, $lines[$i]->id, $lines, $level);
|
||||
$level--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -181,6 +187,7 @@ if ($_POST["action"] == 'addtime' && $user->rights->projet->creer)
|
||||
}
|
||||
|
||||
Header("Location:fiche.php?id=".$pro->id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,144 +224,61 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
|
||||
|
||||
} else {
|
||||
|
||||
/*
|
||||
* Fiche projet en mode visu
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Fiche projet en mode visu
|
||||
*
|
||||
*/
|
||||
|
||||
$projet = new Project($db);
|
||||
$projet->fetch($_GET["id"]);
|
||||
$projet->societe->fetch($projet->societe->id);
|
||||
|
||||
$h=0;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/fiche.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Project");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/fiche.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Tasks");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
$projet = new Project($db);
|
||||
$projet->fetch($_GET["id"]);
|
||||
$projet->societe->fetch($projet->societe->id);
|
||||
|
||||
if ($conf->propal->enabled)
|
||||
{
|
||||
$langs->load("propal");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/propal.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Proposals");
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->commande->enabled)
|
||||
{
|
||||
$langs->load("orders");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/commandes.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Orders");
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->facture->enabled)
|
||||
{
|
||||
$langs->load("bills");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/facture.php?id='.$projet->id;
|
||||
$head[$h][1] = $langs->trans("Bills");
|
||||
$h++;
|
||||
}
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Project").": ".$projet->ref);
|
||||
$head=project_prepare_head($projet);
|
||||
dolibarr_fiche_head($head, 'tasks', $langs->trans("Project"));
|
||||
|
||||
print '<form method="POST" action="fiche.php?id='.$projet->id.'">';
|
||||
print '<input type="hidden" name="action" value="createtask">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<form method="POST" action="fiche.php?id='.$projet->id.'">';
|
||||
print '<input type="hidden" name="action" value="createtask">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td><td>'.$projet->ref.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projet->title.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projet->title.'</td></tr>';
|
||||
|
||||
print '<td>'.$langs->trans("Company").'</td><td>'.$projet->societe->getNomUrl(1).'</td></tr>';
|
||||
print '<td>'.$langs->trans("Company").'</td><td>'.$projet->societe->getNomUrl(1).'</td></tr>';
|
||||
|
||||
$tasksrole=$projet->getTasksRoleForUser($user);
|
||||
|
||||
$tasksarray=$projet->getTasksArray();
|
||||
|
||||
/* Nouvelle tâche */
|
||||
print '<tr><td>'.$langs->trans("NewTask").'</td><td colspan="3">';
|
||||
print '<input type="text" size="25" name="task_name" class="flat"> ';
|
||||
print '<select class="flat" name="task_parent">';
|
||||
print '<option value="0" selected="true"> </option>';
|
||||
PLineSelect($j, 0, $tasksarray, $level);
|
||||
print '</select> ';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table></form><br />';
|
||||
|
||||
print '<form name="addtime" method="POST" action="fiche.php?id='.$projet->id.'">';
|
||||
print '<input type="hidden" name="action" value="addtime">';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("ID").'</td>';
|
||||
print '<td>'.$langs->trans("Task").'</td>';
|
||||
print '<td align="right">'.$langs->trans("DurationEffective").'</td>';
|
||||
print '<td colspan="2">'.$langs->trans("AddDuration").'</td>';
|
||||
print "</tr>\n";
|
||||
PLines($j, 0, $tasksarray, $level, $tasksrole);
|
||||
print '</form>';
|
||||
|
||||
|
||||
/* Liste des acteurs */
|
||||
$sql = "SELECT a.fk_projet_task, a.role";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_actors as a";
|
||||
$sql .= " WHERE a.fk_user = ".$user->id;
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
$actors = array();
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
$actors[$row[0]] = $row[1];
|
||||
$i++;
|
||||
}
|
||||
$db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
/* Liste des tâches */
|
||||
print "</table>";
|
||||
print '</div>';
|
||||
|
||||
$sql = "SELECT t.rowid, t.title, t.fk_task_parent, t.duration_effective";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t";
|
||||
$sql .= " WHERE t.fk_projet =".$projet->id;
|
||||
$sql .= " ORDER BY t.fk_task_parent";
|
||||
|
||||
$var=true;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
$tasks = array();
|
||||
while ($i < $num)
|
||||
{
|
||||
$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;
|
||||
$i++;
|
||||
}
|
||||
$db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
|
||||
/* Nouvelle tâche */
|
||||
|
||||
print '<tr><td>'.$langs->trans("NewTask").'</td><td colspan="3">';
|
||||
print '<input type="text" size="25" name="task_name" class="flat"> ';
|
||||
print '<select class="flat" name="task_parent">';
|
||||
print '<option value="0" selected="true"> </option>';
|
||||
PLineSelect($j, 0, $tasks, $level);
|
||||
print '</select> ';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table></form><br />';
|
||||
|
||||
print '<form name="addtime" method="POST" action="fiche.php?id='.$projet->id.'">';
|
||||
print '<input type="hidden" name="action" value="addtime">';
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Task").'</td>';
|
||||
print '<td align="right">'.$langs->trans("DurationEffective").'</td>';
|
||||
print '<td colspan="2">'.$langs->trans("AddDuration").'</td>';
|
||||
print "</tr>\n";
|
||||
PLines($j, 0, $tasks, $level, $actors);
|
||||
print '</form>';
|
||||
|
||||
|
||||
print "</table>";
|
||||
print '</div>';
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user