diff --git a/ChangeLog b/ChangeLog
index ae6da3e2653..82450076657 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,8 @@ English Dolibarr ChangeLog
***** ChangeLog for 2.9 compared to 2.8 *****
For users:
+- New: Can link trips and fees to a project.
+- New: Add civility title in foundation module.
- New: Can set accountancy code for product (buy and sell).
- New: Can filter third parties lists on categories.
- New: Can filter products and services lists on categories.
diff --git a/htdocs/compta/deplacement/deplacement.class.php b/htdocs/compta/deplacement/deplacement.class.php
index 7b164ed5aa4..0ff69f4a875 100644
--- a/htdocs/compta/deplacement/deplacement.class.php
+++ b/htdocs/compta/deplacement/deplacement.class.php
@@ -48,7 +48,8 @@ class Deplacement extends CommonObject
var $note;
var $note_public;
var $socid;
-
+ var $statut=1; // 0=draft, 1=validated
+ var $fk_project;
/**
* \brief Constructeur de la classe
@@ -95,14 +96,18 @@ class Deplacement extends CommonObject
$sql.= ", type";
$sql.= ", note";
$sql.= ", note_public";
+ $sql.= ", fk_projet";
+ $sql.= ", fk_soc";
$sql.= ") VALUES (";
$sql.= $this->db->idate(mktime());
$sql.= ", ".$conf->entity;
$sql.= ", ".$user->id;
$sql.= ", ".$this->fk_user;
$sql.= ", '".$this->type."'";
- $sql.= ", note = ".($this->note?"'".addslashes($this->note)."'":"null");
- $sql.= ", note_public = ".($this->note_public?"'".addslashes($this->note_public)."'":"null");
+ $sql.= ", ".($this->note?"'".addslashes($this->note)."'":"null");
+ $sql.= ", ".($this->note_public?"'".addslashes($this->note_public)."'":"null");
+ $sql.= ", ".($this->fk_project > 0? $this->fk_project : 0);
+ $sql.= ", ".($this->fk_soc > 0? $this->fk_soc : "null");
$sql.= ")";
dol_syslog("Deplacement::create sql=".$sql, LOG_DEBUG);
@@ -154,6 +159,8 @@ class Deplacement extends CommonObject
return -1;
}
+ $this->db->begin();
+
$sql = "UPDATE ".MAIN_DB_PREFIX."deplacement ";
$sql .= " SET km = ".$this->km; // This is a distance or amount
$sql .= " , dated = '".$this->db->idate($this->date)."'";
@@ -162,17 +169,20 @@ class Deplacement extends CommonObject
$sql .= " , fk_soc = ".($this->socid > 0?$this->socid:'null');
$sql .= " , note = ".($this->note?"'".addslashes($this->note)."'":"null");
$sql .= " , note_public = ".($this->note_public?"'".addslashes($this->note_public)."'":"null");
+ $sql .= " , fk_projet = ".($this->fk_project>0?$this->fk_project:0);
$sql .= " WHERE rowid = ".$this->id;
dol_syslog("Deplacement::update sql=".$sql, LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
+ $this->db->commit();
return 1;
}
else
{
- $this->error=$this->db->error();
+ $this->db->rollback();
+ $this->error=$this->db->lasterror();
return -1;
}
}
@@ -182,7 +192,7 @@ class Deplacement extends CommonObject
*/
function fetch($id)
{
- $sql = "SELECT rowid, fk_user, type, km, fk_soc, dated, note, note_public";
+ $sql = "SELECT rowid, fk_user, type, km, fk_soc, dated, note, note_public, fk_projet";
$sql.= " FROM ".MAIN_DB_PREFIX."deplacement";
$sql.= " WHERE rowid = ".$id;
@@ -192,15 +202,16 @@ class Deplacement extends CommonObject
{
$obj = $this->db->fetch_object($result);
- $this->id = $obj->rowid;
- $this->ref = $obj->rowid;
- $this->date = $this->db->jdate($obj->dated);
- $this->fk_user = $obj->fk_user;
- $this->socid = $obj->fk_soc;
- $this->km = $obj->km;
- $this->type = $obj->type;
- $this->note = $obj->note;
+ $this->id = $obj->rowid;
+ $this->ref = $obj->rowid;
+ $this->date = $this->db->jdate($obj->dated);
+ $this->fk_user = $obj->fk_user;
+ $this->socid = $obj->fk_soc;
+ $this->km = $obj->km;
+ $this->type = $obj->type;
+ $this->note = $obj->note;
$this->note_public = $obj->note_public;
+ $this->fk_project = $obj->fk_projet;
return 1;
}
@@ -231,6 +242,81 @@ class Deplacement extends CommonObject
}
}
+
+ /**
+ * \brief Retourne le libelle du 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 getLibStatut($mode=0)
+ {
+ return $this->LibStatut($this->statut,$mode);
+ }
+
+ /**
+ * \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)
+ {
+ global $langs;
+
+ if ($mode == 0)
+ {
+ return $langs->trans($this->statuts[$statut]);
+ }
+ if ($mode == 1)
+ {
+ return $langs->trans($this->statuts_short[$statut]);
+ }
+ if ($mode == 2)
+ {
+ 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]),'statut6').' '.$langs->trans($this->statuts_short[$statut]);
+ }
+ if ($mode == 3)
+ {
+ 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]),'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]),'statut6').' '.$langs->trans($this->statuts[$statut]);
+ }
+ if ($mode == 5)
+ {
+ if ($statut==0) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut0');
+ if ($statut==1) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut6');
+ }
+ }
+
+ /**
+ * \brief Return clicable name (with picto eventually)
+ * \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
+ * \return string Chaine avec URL
+ */
+ function getNomUrl($withpicto=0)
+ {
+ global $langs;
+
+ $result='';
+
+ $lien = '';
+ $lienfin='';
+
+ $picto='trip';
+
+ $label=$langs->trans("Show").': '.$this->ref;
+
+ if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin);
+ if ($withpicto && $withpicto != 2) $result.=' ';
+ if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin;
+ return $result;
+ }
+
}
?>
diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php
index d63f29f961d..a6c8eca9ef1 100644
--- a/htdocs/compta/deplacement/fiche.php
+++ b/htdocs/compta/deplacement/fiche.php
@@ -24,6 +24,12 @@
* \version $Id$
*/
require("./pre.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
+if ($conf->projet->enabled)
+{
+ require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
+ require_once(DOL_DOCUMENT_ROOT."/projet/project.class.php");
+}
$langs->load("trips");
@@ -152,6 +158,16 @@ if ($_POST["action"] == 'update' && $user->rights->deplacement->creer)
}
}
+// Set into a project
+if ($_POST['action'] == 'classin')
+{
+ $trip = new Deplacement($db);
+ $trip->fetch($_GET['id']);
+ $result=$trip->setProject($_POST['projectid']);
+ if ($result < 0) dol_print_error($db,$trip->error);
+}
+
+
/*
* View
@@ -170,6 +186,11 @@ if ($_GET["action"] == 'create')
if ($mesg) print $mesg."
";
+ $datec = dol_mktime(12, 0, 0,
+ $_POST["remonth"],
+ $_POST["reday"],
+ $_POST["reyear"]);
+
print "