diff --git a/ChangeLog b/ChangeLog
index 4841827aabd..33bcba2d4f4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@ English Dolibarr ChangeLog
***** ChangeLog for 2.8 compared to 2.7 *****
For users:
+- New: task #9802 : Can link an action to a project.
- New: Initial sold can be conciliated.
- New: task #9935: Can edit accountancy code.
- New: Add a default errors-to email for emailing module.
diff --git a/htdocs/actioncomm.class.php b/htdocs/actioncomm.class.php
index e84d60b8489..0a8e3e030bd 100644
--- a/htdocs/actioncomm.class.php
+++ b/htdocs/actioncomm.class.php
@@ -61,6 +61,8 @@ class ActionComm
var $societe; // Company linked to action (optionnal)
var $contact; // Contact linked tot action (optionnal)
+ var $fk_project; // Id of project (optionnal)
+
var $note;
var $percentage;
@@ -86,10 +88,10 @@ class ActionComm
}
/**
- * \brief Ajout d'une action en base
+ * \brief Add an action into database
* \param user auteur de la creation de l'action
* \param notrigger 1 ne declenche pas les triggers, 0 sinon
- * \return int id de l'action creee, < 0 si erreur
+ * \return int id de l'action creee, < 0 if KO
*/
function add($user,$notrigger=0)
{
@@ -108,6 +110,7 @@ class ActionComm
if ($this->date && $this->dateend) $this->durationa=($this->dateend - $this->date);
if ($this->datep && $this->datef && $this->datep > $this->datef) $this->datef=$this->datep;
if ($this->date && $this->dateend && $this->date > $this->dateend) $this->dateend=$this->date;
+ if ($this->fk_project < 0) $this->fk_project = 0;
$now=time();
if (! $this->type_id && $this->type_code)
@@ -146,6 +149,7 @@ class ActionComm
$sql.= "durationa,";
$sql.= "fk_action,";
$sql.= "fk_soc,";
+ $sql.= "fk_project,";
$sql.= "note,";
$sql.= "fk_contact,";
$sql.= "fk_user_author,";
@@ -163,6 +167,7 @@ class ActionComm
$sql.= ($this->durationa >= 0 && $this->durationa != ''?"'".$this->durationa."'":"null").",";
$sql.= " '".$this->type_id."',";
$sql.= ($this->societe->id>0?" '".$this->societe->id."'":"null").",";
+ $sql.= ($this->fk_project>0?" '".$this->fk_project."'":"null").",";
$sql.= " '".addslashes($this->note)."',";
$sql.= ($this->contact->id > 0?"'".$this->contact->id."'":"null").",";
$sql.= ($user->id > 0 ? "'".$user->id."'":"null").",";
@@ -218,6 +223,7 @@ class ActionComm
$sql.= " a.tms as datem,";
$sql.= " a.note, a.label, a.fk_action as type_id,";
$sql.= " a.fk_soc,";
+ $sql.= " a.fk_project,";
$sql.= " a.fk_user_author, a.fk_user_mod,";
$sql.= " a.fk_user_action, a.fk_user_done,";
$sql.= " a.fk_contact, a.percent as percentage, a.fk_facture, a.fk_commande, a.propalrowid,";
@@ -267,6 +273,7 @@ class ActionComm
$this->societe->id = $obj->fk_soc;
$this->contact->id = $obj->fk_contact;
+ $this->fk_project = $obj->fk_project;
$this->fk_facture = $obj->fk_facture;
if ($this->fk_facture)
@@ -339,6 +346,7 @@ class ActionComm
if ($this->date && $this->dateend) $this->durationa=($this->dateend - $this->date);
if ($this->datep && $this->datef && $this->datep > $this->datef) $this->datef=$this->datep;
if ($this->date && $this->dateend && $this->date > $this->dateend) $this->dateend=$this->date;
+ if ($this->fk_project < 0) $this->fk_project = 0;
// Check parameters
if ($this->percentage == 0 && $this->userdone->id > 0)
@@ -357,6 +365,7 @@ class ActionComm
//$sql.= ", datea2 = ".(strval($this->dateend)!='' ? "'".$this->db->idate($this->dateend)."'" : 'null');
$sql.= ", note = ".($this->note ? "'".addslashes($this->note)."'":"null");
$sql.= ", fk_soc =". ($this->societe->id > 0 ? "'".$this->societe->id."'":"null");
+ $sql.= ", fk_project =". ($this->fk_project > 0 ? "'".$this->fk_project."'":"null");
$sql.= ", fk_contact =". ($this->contact->id > 0 ? "'".$this->contact->id."'":"null");
$sql.= ", priority = '".$this->priority."'";
$sql.= ", location = ".($this->location ? "'".addslashes($this->location)."'":"null");
@@ -534,7 +543,7 @@ class ActionComm
* \return string Chaine avec URL
* \remarks Utilise $this->id, $this->code et $this->libelle
*/
- function getNomUrl($withpicto=0,$maxlength,$class='',$option='')
+ function getNomUrl($withpicto=0,$maxlength=0,$class='',$option='')
{
global $langs;
diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php
index d0ae723dcda..393b31a6851 100644
--- a/htdocs/comm/action/fiche.php
+++ b/htdocs/comm/action/fiche.php
@@ -33,6 +33,8 @@ require_once(DOL_DOCUMENT_ROOT."/user.class.php");
require_once(DOL_DOCUMENT_ROOT."/cactioncomm.class.php");
require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php");
require_once(DOL_DOCUMENT_ROOT."/html.formactions.class.php");
+require_once(DOL_DOCUMENT_ROOT."/project.class.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
$langs->load("companies");
$langs->load("commercial");
@@ -115,19 +117,7 @@ if ($_POST["action"] == 'add_action')
$_POST["p2month"],
$_POST["p2day"],
$_POST["p2year"]);
- /*$datea=dol_mktime($_POST["adhour"], // deprecated
- $_POST["admin"],
- 0,
- $_POST["admonth"],
- $_POST["adday"],
- $_POST["adyear"]);
- $datea2=dol_mktime($_POST["a2hour"], // deprecated
- $_POST["a2min"],
- 0,
- $_POST["a2month"],
- $_POST["a2day"],
- $_POST["a2year"]);
- */
+
if (! $datep2 && $_POST["percentage"] == 100)
{
@@ -169,6 +159,7 @@ if ($_POST["action"] == 'add_action')
else $actioncomm->label = $cactioncomm->libelle;
}
}
+ $actioncomm->fk_project = isset($_POST["projectid"])?$_POST["projectid"]:0;
$actioncomm->datep = $datep;
//$actioncomm->date = $datea;
$actioncomm->datef = $datep2;
@@ -370,7 +361,9 @@ if ($_POST["action"] == 'update')
$actioncomm->location = isset($_POST["location"])?$_POST["location"]:'';
$actioncomm->societe->id = $_POST["socid"];
$actioncomm->contact->id = $_POST["contactid"];
+ $actioncomm->fk_project = $_POST["projectid"];
$actioncomm->note = $_POST["note"];
+ $actioncomm->pnote = $_POST["note"];
if (! $datep2 && $_POST["percentage"] == 100)
{
@@ -511,6 +504,21 @@ if ($_GET["action"] == 'create')
print '';
}
+ // Project
+ if ($conf->projet->enabled)
+ {
+ // Projet associe
+ $langs->load("project");
+
+ print '
| '.$langs->trans("Project").' | ';
+ $numprojet=select_projects($societe->id,$projetid,'projectid');
+ if ($numprojet==0)
+ {
+ print ' '.$langs->trans("AddProject").'';
+ }
+ print ' |
';
+ }
+
print '';
print '
';
print '';
@@ -536,7 +544,7 @@ if ($_GET["action"] == 'create')
}
// Date start
- print '| '.$langs->trans("DateActionStart").' | ';
+ print ' |
| '.$langs->trans("DateActionStart").'* | ';
if ($_REQUEST["afaire"] == 1) $html->select_date($actioncomm->datep,'ap',1,1,0,"action",1,1);
else if ($_REQUEST["afaire"] == 2) $html->select_date($actioncomm->datep,'ap',1,1,1,"action",1,1);
else $html->select_date($actioncomm->datep,'ap',1,1,1,"action",1,1);
@@ -684,6 +692,21 @@ if ($_GET["id"])
$html->select_array("contactid", $act->societe->contact_array(), $act->contact->id, 1);
print ' |
';
+ // Project
+ if ($conf->projet->enabled)
+ {
+ // Projet associe
+ $langs->load("project");
+
+ print '| '.$langs->trans("Project").' | ';
+ $numprojet=select_projects($act->societe->id,$act->fk_project,'projectid');
+ if ($numprojet==0)
+ {
+ print ' '.$langs->trans("AddProject").'';
+ }
+ print ' |
';
+ }
+
print '
';
// Input by
@@ -803,6 +826,19 @@ if ($_GET["id"])
print '';
+ // Project
+ if ($conf->projet->enabled)
+ {
+ print '| '.$langs->trans("Project").' | ';
+ if ($act->fk_project)
+ {
+ $project=new Project($db);
+ $project->fetch($act->fk_project);
+ print $project->getNomUrl(1);
+ }
+ print ' |
';
+ }
+
print '
';
// Input by
diff --git a/htdocs/fichinter/fichinter.class.php b/htdocs/fichinter/fichinter.class.php
index a6491f2a8c3..f80f77f6249 100644
--- a/htdocs/fichinter/fichinter.class.php
+++ b/htdocs/fichinter/fichinter.class.php
@@ -322,7 +322,8 @@ class Fichinter extends CommonObject
/**
* \brief Retourne le libelle du statut
- * \return string Libelle
+ * \param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
+ * \return string Libelle
*/
function getLibStatut($mode=0)
{
@@ -332,6 +333,7 @@ class Fichinter extends CommonObject
/**
* \brief Renvoi le libelle d'un statut donne
* \param statut id statut
+ * \param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
* \return string Libelle
*/
function LibStatut($statut,$mode=0)
diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang
index b5bfab0f939..7154d4b5d53 100755
--- a/htdocs/langs/en_US/projects.lang
+++ b/htdocs/langs/en_US/projects.lang
@@ -45,6 +45,7 @@ ListPredefinedInvoicesAssociatedProject=List of customers' predefined invoices a
ListSupplierOrdersAssociatedProject=List of suppliers' orders associated with the project
ListSupplierInvoicesAssociatedProject=List of suppliers' invoices associated with the project
ListContractAssociatedProject=List of contracts associated with the project
+ListActionsAssociatedProject=List of actions associated with the project
ActivityOnProjectThisWeek=Activity on project this week
ActivityOnProjectThisMonth=Activity on project this month
ActivityOnProjectThisYear=Activity on project this year
diff --git a/htdocs/langs/fr_FR/projects.lang b/htdocs/langs/fr_FR/projects.lang
index 1fb719ce600..34e7303376c 100755
--- a/htdocs/langs/fr_FR/projects.lang
+++ b/htdocs/langs/fr_FR/projects.lang
@@ -45,6 +45,7 @@ ListPredefinedInvoicesAssociatedProject=Liste des factures clients prédéfinies
ListSupplierOrdersAssociatedProject=Liste des commandes fournisseurs associées au projet
ListSupplierInvoicesAssociatedProject=Liste des factures fournisseur associées au projet
ListContractAssociatedProject=Liste des contrats associés au projet
+ListActionsAssociatedProject=Liste des actions associées au projet
ActivityOnProjectThisWeek=Activité sur les projets cette semaine
ActivityOnProjectThisMonth=Activité sur les projets ce mois
ActivityOnProjectThisYear=Activité sur les projets cette année
diff --git a/htdocs/project.class.php b/htdocs/project.class.php
index 7421749e84e..c8084d0b329 100644
--- a/htdocs/project.class.php
+++ b/htdocs/project.class.php
@@ -258,13 +258,14 @@ class Project extends CommonObject
$elements = array();
$sql='';
- if ($type == 'propal') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."propal WHERE fk_projet=".$this->id;
- if ($type == 'order') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande WHERE fk_projet=".$this->id;
- if ($type == 'invoice') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE fk_projet=".$this->id;
+ if ($type == 'propal') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."propal WHERE fk_projet=".$this->id;
+ if ($type == 'order') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande WHERE fk_projet=".$this->id;
+ if ($type == 'invoice') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE fk_projet=".$this->id;
if ($type == 'invoice_predefined') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture_rec WHERE fk_projet=".$this->id;
- if ($type == 'order_supplier') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande_fournisseur WHERE fk_projet=".$this->id;
- if ($type == 'invoice_supplier') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture_fourn WHERE fk_projet=".$this->id;
- if ($type == 'contract') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."contrat WHERE fk_projet=".$this->id;
+ if ($type == 'order_supplier') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande_fournisseur WHERE fk_projet=".$this->id;
+ if ($type == 'invoice_supplier') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture_fourn WHERE fk_projet=".$this->id;
+ if ($type == 'contract') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."contrat WHERE fk_projet=".$this->id;
+ if ($type == 'agenda') $sql = "SELECT id as rowid FROM ".MAIN_DB_PREFIX."actioncomm WHERE fk_project=".$this->id;
if (! $sql) return -1;
dol_syslog("Project::get_element_list sql=".$sql);
@@ -681,7 +682,8 @@ class Project extends CommonObject
/**
* \brief Return status label of object
- * \return string Label
+ * \param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
+ * \return string Label
*/
function getLibStatut($mode=0)
{
@@ -691,7 +693,8 @@ class Project extends CommonObject
/**
* \brief Renvoi status label for a status
* \param statut id statut
- * \return string Label
+ * \param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
+ * \return string Label
*/
function LibStatut($statut,$mode=0)
{
@@ -715,12 +718,12 @@ class Project extends CommonObject
{
if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0');
if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
- if ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6').' '.$langs->trans($this->statuts_short[$statut]);
+ if ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6');
}
if ($mode == 4)
{
- if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]);
- if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]);
+ if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts_short[$statut]);
+ if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts_short[$statut]);
if ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6').' '.$langs->trans($this->statuts_short[$statut]);
}
if ($mode == 5)
diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php
index 20d52e5d611..aae0eb5e4fb 100644
--- a/htdocs/projet/element.php
+++ b/htdocs/projet/element.php
@@ -33,6 +33,7 @@ if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/comma
if ($conf->fournisseur->enabled) require_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.facture.class.php");
if ($conf->fournisseur->enabled) require_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.commande.class.php");
if ($conf->contrat->enabled) require_once(DOL_DOCUMENT_ROOT."/contrat/contrat.class.php");
+if ($conf->agenda->enabled) require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
$langs->load("projects");
@@ -133,8 +134,12 @@ $listofreferent=array(
'contract'=>array(
'title'=>"ListContractAssociatedProject",
'class'=>'Contrat',
- 'test'=>$conf->contrat->enabled)
-
+ 'test'=>$conf->contrat->enabled),
+'agenda'=>array(
+ 'title'=>"ListActionsAssociatedProject",
+ 'class'=>'ActionComm',
+ 'disableamount'=>1,
+ 'test'=>$conf->agenda->enabled)
);
foreach ($listofreferent as $key => $value)
@@ -152,7 +157,7 @@ foreach ($listofreferent as $key => $value)
print '';
print '| '.$langs->trans("Ref").' | ';
print ''.$langs->trans("Date").' | ';
- print ''.$langs->trans("Amount").' | ';
+ if (empty($value['disableamount'])) print ''.$langs->trans("Amount").' | ';
print ''.$langs->trans("Status").' | ';
print '
';
$elementarray = $projet->get_element_list($key);
@@ -167,27 +172,37 @@ foreach ($listofreferent as $key => $value)
$var=!$var;
print "";
+
+ // Ref
print "| ";
print $element->getNomUrl(1);
print " | \n";
+
+ // Date
$date=$element->date;
if (empty($date)) $date=$element->datep;
if (empty($date)) $date=$element->date_contrat;
print ''.dol_print_date($date,'day').' | ';
- print ''.(isset($element->total_ht)?price($element->total_ht):' ').' | ';
+
+ // Amount
+ if (empty($value['disableamount'])) print ''.(isset($element->total_ht)?price($element->total_ht):' ').' | ';
+
+ // Status
print ''.$element->getLibStatut(5).' | ';
+
print '
';
$total = $total + $element->total_ht;
}
print '| '.$langs->trans("Number").': '.$i.' | ';
- print ''.$langs->trans("TotalHT").' : '.price($total).' | ';
+ if (empty($value['disableamount'])) print ''.$langs->trans("TotalHT").' : '.price($total).' | ';
print ' | ';
print '
';
}
print "
";
+
/*
* Barre d'action
*/
diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php
index 3f1d410d35c..c0cd6a57555 100644
--- a/htdocs/projet/index.php
+++ b/htdocs/projet/index.php
@@ -42,6 +42,7 @@ if ($user->societe_id > 0)
*/
$company=new Societe($db);
+$projectstatic=new Project($db);
llxHeader("",$langs->trans("Projects"),"EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos");
@@ -56,9 +57,10 @@ print '';
print '';
print_liste_field_titre($langs->trans("Project"),"index.php","","","","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("NbOpenTasks"),"","","","",'align="right"',$sortfield,$sortorder);
+print_liste_field_titre($langs->trans("Status"),"","","","",'align="right"',$sortfield,$sortorder);
print "
\n";
-$sql = "SELECT p.title, p.rowid, count(t.rowid)";
+$sql = "SELECT p.title, p.rowid, p.fk_statut, count(t.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
@@ -77,11 +79,13 @@ if ( $resql )
while ($i < $num)
{
- $row = $db->fetch_row( $resql);
+ $row = $db->fetch_object($resql);
$var=!$var;
print "";
- print '| '.img_object($langs->trans("ShowProject"),"project")." ".$row[0].' | ';
- print ''.$row[2].' | ';
+ print ''.img_object($langs->trans("ShowProject"),"project")." ".$row->title.' | ';
+ print ''.$row->nb.' | ';
+ $projectstatic->statut=$row->fk_statut;
+ print ''.$projectstatic->getLibStatut(3).' | ';
print "
\n";
$i++;
diff --git a/htdocs/projet/liste.php b/htdocs/projet/liste.php
index b49765cb61a..a651b1dee92 100644
--- a/htdocs/projet/liste.php
+++ b/htdocs/projet/liste.php
@@ -22,7 +22,7 @@
/**
* \file htdocs/projet/liste.php
* \ingroup projet
- * \brief Page liste des projets
+ * \brief Page to list projects
* \version $Id$
*/
@@ -69,7 +69,7 @@ $projectstatic = new Project($db);
$userstatic = new User($db);
$staticsoc=new Societe($db);
-$sql = "SELECT p.rowid as projectid, p.ref, p.title, ".$db->pdate("p.dateo")." as do, p.fk_user_resp,";
+$sql = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_statut, ".$db->pdate("p.dateo")." as do, p.fk_user_resp,";
$sql.= " u.login,";
$sql.= " s.nom, s.rowid as socid, s.client";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
@@ -108,11 +108,11 @@ if ($resql)
print '';
print '';
- print_liste_field_titre($langs->trans("Ref"),"liste.php","p.ref","","","",$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("Label"),"liste.php","p.title","","","",$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("Company"),"liste.php","s.nom","","","",$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("OfficerProject"),"liste.php","","","","",$sortfield,$sortorder);
- print_liste_field_titre('','','');
+ print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"p.ref","","","",$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"p.title","","","",$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","","",$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("OfficerProject"),$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],'p.fk_statut',"","",'align="right"',$sortfield,$sortorder);
print "
\n";
print '