diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php
index 4d732f7f364..257d2f5b82e 100644
--- a/htdocs/comm/propal/note.php
+++ b/htdocs/comm/propal/note.php
@@ -40,9 +40,7 @@ if (!$user->rights->propale->lire)
accessforbidden();
-/*
- * Sécurité accés client
- */
+// Sécurité accés client
if ($user->societe_id > 0)
{
unset($_GET['action']);
@@ -53,21 +51,58 @@ if ($user->societe_id > 0)
/* Actions */
/******************************************************************************/
+if ($_POST["action"] == 'update_public' && $user->rights->facture->creer)
+{
+ $propal = new Propal($db);
+ $propal->fetch($_GET['propalid']);
+
+ $db->begin();
+
+ $res=$propal->update_note_public($_POST["note_public"]);
+ if ($res < 0)
+ {
+ $mesg='
'.$propal->error.'
';
+ $db->rollback();
+ }
+ else
+ {
+ $db->commit();
+ }
+}
+
if ($_POST['action'] == 'update' && $user->rights->propale->creer)
{
$propal = new Propal($db);
$propal->fetch($_GET['propalid']);
- $propal->update_note($_POST['note']);
+
+ $db->begin();
+
+ $res=$propal->update_note($_POST["note"]);
+ if ($res < 0)
+ {
+ $mesg=''.$propal->error.'
';
+ $db->rollback();
+ }
+ else
+ {
+ $db->commit();
+ }
}
+
+
+/******************************************************************************/
+/* Affichage fiche */
+/******************************************************************************/
+
llxHeader();
+
$html = new Form($db);
-/******************************************************************************/
-/* Fin des Actions */
-/******************************************************************************/
if ($_GET['propalid'])
{
+ if ($mesg) print $mesg;
+
$propal = new Propal($db);
if ( $propal->fetch($_GET['propalid']) )
{
@@ -139,18 +174,40 @@ if ($_GET['propalid'])
print '';
print '';
- print ''.$langs->trans('Note').' : '. nl2br($propal->note).' |
';
-
- if ($_GET['action'] == 'edit')
+ // Note publique
+ print '| '.$langs->trans("NotePublic").' : | ';
+ print '';
+ if ($_GET["action"] == 'edit')
+ {
+ print '';
+ }
+ else
+ {
+ print ($propal->note_public?nl2br($propal->note_public):" ");
+ }
+ print " |
";
+
+ // Note privée
+ print '| '.$langs->trans("NotePrivate").' : | ';
+ print '';
+ if ($_GET["action"] == 'edit')
+ {
+ print '';
+ }
+ else
{
- print '';
+ print ($propal->note?nl2br($propal->note):" ");
}
-
- print '';
+ print " |
";
+ print "";
print '';
diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php
index a4f29203b2f..0258166d338 100644
--- a/htdocs/compta/facture/note.php
+++ b/htdocs/compta/facture/note.php
@@ -62,8 +62,8 @@ if ($_POST["action"] == 'update_public' && $user->rights->facture->creer)
$res=$fac->update_note_public($_POST["note_public"]);
if ($res < 0)
{
+ $mesg=''.$fac->error.'
';
$db->rollback();
- $msg=$fac->error();
}
else
{
@@ -78,8 +78,8 @@ if ($_POST["action"] == 'update' && $user->rights->facture->creer)
$res=$fac->update_note($_POST["note"]);
if ($res < 0)
{
+ $mesg=''.$fac->error.'
';
$db->rollback();
- $msg=$fac->error();
}
else
{
diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php
index 9d56567b65c..d5c349b1f11 100644
--- a/htdocs/facture.class.php
+++ b/htdocs/facture.class.php
@@ -1460,8 +1460,9 @@ class Facture
*/
function update_note($note)
{
- $sql = 'UPDATE '.MAIN_DB_PREFIX."facture SET note = '".addslashes($note)."'";
- $sql .= ' WHERE rowid ='. $this->id;
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
+ $sql.= " SET note = '".addslashes($note)."'";
+ $sql.= " WHERE rowid =". $this->id;
if ($this->db->query($sql))
{
@@ -1470,6 +1471,7 @@ class Facture
}
else
{
+ $this->error=$this->db->error();
return -1;
}
}
@@ -1481,8 +1483,9 @@ class Facture
*/
function update_note_public($note_public)
{
- $sql = 'UPDATE '.MAIN_DB_PREFIX."facture SET note_public = '".addslashes($note_public)."'";
- $sql .= ' WHERE rowid ='. $this->id;
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
+ $sql.= " SET note_public = '".addslashes($note_public)."'";
+ $sql.= " WHERE rowid =". $this->id;
if ($this->db->query($sql))
{
@@ -1491,6 +1494,7 @@ class Facture
}
else
{
+ $this->error=$this->db->error();
return -1;
}
}
diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php
index a30bedbebe4..c4d47cd8901 100644
--- a/htdocs/propal.class.php
+++ b/htdocs/propal.class.php
@@ -67,6 +67,8 @@ class Propal
// Pour board
var $nbtodo;
var $nbtodolate;
+
+ var $error;
/**
@@ -372,8 +374,11 @@ class Propal
$this->db->begin();
// Insertion dans la base
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."propal (fk_soc, fk_soc_contact, price, remise, tva, total, datep, datec, ref, fk_user_author, note, model_pdf, fin_validite) ";
- $sql.= " VALUES ($this->socidp, $this->contactid, 0, $this->remise, 0,0,".$this->db->idate($this->datep).", now(), '$this->ref', $this->author, '".addslashes($this->note)."','$this->modelpdf',".$this->db->idate($this->fin_validite).")";
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."propal (fk_soc, fk_soc_contact, price, remise, tva, total, datep, datec, ref, fk_user_author, note, note_public, model_pdf, fin_validite) ";
+ $sql.= " VALUES ($this->socidp, $this->contactid, 0, $this->remise, 0,0,".$this->db->idate($this->datep).", now(), '$this->ref', $this->author, ";
+ $sql.= "'".addslashes($this->note)."',";
+ $sql.= "'".addslashes($this->note_public)."',";
+ $sql.= "'$this->modelpdf',".$this->db->idate($this->fin_validite).")";
$resql=$this->db->query($sql);
if ($resql)
@@ -494,14 +499,15 @@ class Propal
function fetch($rowid)
{
$sql = "SELECT ref,total,price,remise,tva,fk_soc,fk_soc_contact";
- $sql .= " ,".$this->db->pdate("datep")."as dp";
- $sql .= " ,".$this->db->pdate("fin_validite")."as dfv, model_pdf, note";
- $sql .= " , fk_projet, fk_statut, remise_percent, fk_user_author";
- $sql .= ", c.label as statut_label";
- $sql .= " FROM ".MAIN_DB_PREFIX."propal";
- $sql .= "," . MAIN_DB_PREFIX."c_propalst as c";
- $sql .= " WHERE fk_statut = c.id";
- $sql .= " AND rowid='".$rowid."';";
+ $sql.= ", ".$this->db->pdate("datep")."as dp";
+ $sql.= ", ".$this->db->pdate("fin_validite")."as dfv, model_pdf";
+ $sql.= ", note, note_public";
+ $sql.= ", fk_projet, fk_statut, remise_percent, fk_user_author";
+ $sql.= ", c.label as statut_label";
+ $sql.= " FROM ".MAIN_DB_PREFIX."propal";
+ $sql.= "," . MAIN_DB_PREFIX."c_propalst as c";
+ $sql.= " WHERE fk_statut = c.id";
+ $sql.= " AND rowid='".$rowid."';";
$resql=$this->db->query($sql);
@@ -530,6 +536,7 @@ class Propal
$this->contactid = $obj->fk_soc_contact;
$this->modelpdf = $obj->model_pdf;
$this->note = $obj->note;
+ $this->note_public = $obj->note_public;
$this->statut = $obj->fk_statut;
$this->statut_libelle = $obj->statut_label;
@@ -1132,27 +1139,55 @@ class Propal
}
}
- /**
- * \brief Mets à jour la note
- * \param note Note à mettre à jour
- * \return int <0 si ko, >0 si ok
- */
- function update_note($note)
- {
- $sql = "UPDATE ".MAIN_DB_PREFIX."propal";
- $sql.= " SET note = '".addslashes($note)."'";
- $sql.= " WHERE rowid = ".$this->id;
-
- if ($this->db->query($sql))
- {
- return 1;
- }
- else
- {
+ /**
+ * \brief Mets à jour les commentaires privés
+ * \param note Commentaire
+ * \return int <0 si ko, >0 si ok
+ */
+ function update_note($note)
+ {
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal';
+ $sql.= " SET note = '".addslashes($note)."'";
+ $sql.= " WHERE rowid =". $this->id;
+
+ dolibarr_syslog("Propal::update_note $sql");
+
+ if ($this->db->query($sql))
+ {
+ $this->note = $note;
+ return 1;
+ }
+ else
+ {
$this->error=$this->db->error();
- return -1;
- }
- }
+ return -1;
+ }
+ }
+
+ /**
+ * \brief Mets à jour les commentaires publiques
+ * \param note_public Commentaire
+ * \return int <0 si ko, >0 si ok
+ */
+ function update_note_public($note_public)
+ {
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal';
+ $sql.= " SET note_public = '".addslashes($note_public)."'";
+ $sql.= " WHERE rowid =". $this->id;
+
+ dolibarr_syslog("Propal::update_note_public $sql");
+
+ if ($this->db->query($sql))
+ {
+ $this->note_public = $note_public;
+ return 1;
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ return -1;
+ }
+ }
/**