New: Toutes les entites (contrat, facture, propal, commande) possède un chanp note (non affiché sur PDF) et un champ note public (affiché sur PDF)

This commit is contained in:
Laurent Destailleur 2006-02-12 16:23:43 +00:00
parent fe6723eb07
commit 7ace7a3b27
4 changed files with 149 additions and 53 deletions

View File

@ -40,9 +40,7 @@ if (!$user->rights->propale->lire)
accessforbidden(); accessforbidden();
/* // Sécurité accés client
* Sécurité accés client
*/
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
unset($_GET['action']); unset($_GET['action']);
@ -53,21 +51,58 @@ if ($user->societe_id > 0)
/* Actions */ /* 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='<div class="error">'.$propal->error.'</div>';
$db->rollback();
}
else
{
$db->commit();
}
}
if ($_POST['action'] == 'update' && $user->rights->propale->creer) if ($_POST['action'] == 'update' && $user->rights->propale->creer)
{ {
$propal = new Propal($db); $propal = new Propal($db);
$propal->fetch($_GET['propalid']); $propal->fetch($_GET['propalid']);
$propal->update_note($_POST['note']);
$db->begin();
$res=$propal->update_note($_POST["note"]);
if ($res < 0)
{
$mesg='<div class="error">'.$propal->error.'</div>';
$db->rollback();
}
else
{
$db->commit();
}
} }
/******************************************************************************/
/* Affichage fiche */
/******************************************************************************/
llxHeader(); llxHeader();
$html = new Form($db); $html = new Form($db);
/******************************************************************************/
/* Fin des Actions */
/******************************************************************************/
if ($_GET['propalid']) if ($_GET['propalid'])
{ {
if ($mesg) print $mesg;
$propal = new Propal($db); $propal = new Propal($db);
if ( $propal->fetch($_GET['propalid']) ) if ( $propal->fetch($_GET['propalid']) )
{ {
@ -139,18 +174,40 @@ if ($_GET['propalid'])
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '<tr><td valign="top" colspan="4">'.$langs->trans('Note').' :<br>'. nl2br($propal->note).'</td></tr>'; // Note publique
print '<tr><td valign="top">'.$langs->trans("NotePublic").' :</td>';
print '<td valign="top" colspan="3">';
if ($_GET["action"] == 'edit')
{
print '<form method="post" action="note.php?propalid='.$propal->id.'">';
print '<input type="hidden" name="action" value="update_public">';
print '<textarea name="note_public" cols="80" rows="8">'.$propal->note_public."</textarea><br>";
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '</form>';
}
else
{
print ($propal->note_public?nl2br($propal->note_public):"&nbsp;");
}
print "</td></tr>";
if ($_GET['action'] == 'edit') // Note privée
print '<tr><td valign="top">'.$langs->trans("NotePrivate").' :</td>';
print '<td valign="top" colspan="3">';
if ($_GET["action"] == 'edit')
{
print '<form method="post" action="note.php?propalid='.$propal->id.'">';
print '<input type="hidden" name="action" value="update">';
print '<textarea name="note" cols="80" rows="8">'.$propal->note."</textarea><br>";
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '</form>';
}
else
{ {
print '<form method="post" action="note.php?propalid='.$propal->id.'">'; print ($propal->note?nl2br($propal->note):"&nbsp;");
print '<input type="hidden" name="action" value="update">';
print '<tr><td valign="top" colspan="4"><textarea name="note" cols="80" rows="8">'.$propal->note."</textarea></td></tr>";
print '<tr><td align="center" colspan="4"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td></tr>';
print '</form>';
} }
print "</td></tr>";
print '</table>'; print "</table>";
print '</div>'; print '</div>';

View File

@ -62,8 +62,8 @@ if ($_POST["action"] == 'update_public' && $user->rights->facture->creer)
$res=$fac->update_note_public($_POST["note_public"]); $res=$fac->update_note_public($_POST["note_public"]);
if ($res < 0) if ($res < 0)
{ {
$mesg='<div class="error">'.$fac->error.'</div>';
$db->rollback(); $db->rollback();
$msg=$fac->error();
} }
else else
{ {
@ -78,8 +78,8 @@ if ($_POST["action"] == 'update' && $user->rights->facture->creer)
$res=$fac->update_note($_POST["note"]); $res=$fac->update_note($_POST["note"]);
if ($res < 0) if ($res < 0)
{ {
$mesg='<div class="error">'.$fac->error.'</div>';
$db->rollback(); $db->rollback();
$msg=$fac->error();
} }
else else
{ {

View File

@ -1460,8 +1460,9 @@ class Facture
*/ */
function update_note($note) function update_note($note)
{ {
$sql = 'UPDATE '.MAIN_DB_PREFIX."facture SET note = '".addslashes($note)."'"; $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
$sql .= ' WHERE rowid ='. $this->id; $sql.= " SET note = '".addslashes($note)."'";
$sql.= " WHERE rowid =". $this->id;
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
@ -1470,6 +1471,7 @@ class Facture
} }
else else
{ {
$this->error=$this->db->error();
return -1; return -1;
} }
} }
@ -1481,8 +1483,9 @@ class Facture
*/ */
function update_note_public($note_public) function update_note_public($note_public)
{ {
$sql = 'UPDATE '.MAIN_DB_PREFIX."facture SET note_public = '".addslashes($note_public)."'"; $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
$sql .= ' WHERE rowid ='. $this->id; $sql.= " SET note_public = '".addslashes($note_public)."'";
$sql.= " WHERE rowid =". $this->id;
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
@ -1491,6 +1494,7 @@ class Facture
} }
else else
{ {
$this->error=$this->db->error();
return -1; return -1;
} }
} }

View File

@ -68,6 +68,8 @@ class Propal
var $nbtodo; var $nbtodo;
var $nbtodolate; var $nbtodolate;
var $error;
/** /**
* \brief Constructeur * \brief Constructeur
@ -372,8 +374,11 @@ class Propal
$this->db->begin(); $this->db->begin();
// Insertion dans la base // 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 = "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, '".addslashes($this->note)."','$this->modelpdf',".$this->db->idate($this->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); $resql=$this->db->query($sql);
if ($resql) if ($resql)
@ -494,14 +499,15 @@ class Propal
function fetch($rowid) function fetch($rowid)
{ {
$sql = "SELECT ref,total,price,remise,tva,fk_soc,fk_soc_contact"; $sql = "SELECT ref,total,price,remise,tva,fk_soc,fk_soc_contact";
$sql .= " ,".$this->db->pdate("datep")."as dp"; $sql.= ", ".$this->db->pdate("datep")."as dp";
$sql .= " ,".$this->db->pdate("fin_validite")."as dfv, model_pdf, note"; $sql.= ", ".$this->db->pdate("fin_validite")."as dfv, model_pdf";
$sql .= " , fk_projet, fk_statut, remise_percent, fk_user_author"; $sql.= ", note, note_public";
$sql .= ", c.label as statut_label"; $sql.= ", fk_projet, fk_statut, remise_percent, fk_user_author";
$sql .= " FROM ".MAIN_DB_PREFIX."propal"; $sql.= ", c.label as statut_label";
$sql .= "," . MAIN_DB_PREFIX."c_propalst as c"; $sql.= " FROM ".MAIN_DB_PREFIX."propal";
$sql .= " WHERE fk_statut = c.id"; $sql.= "," . MAIN_DB_PREFIX."c_propalst as c";
$sql .= " AND rowid='".$rowid."';"; $sql.= " WHERE fk_statut = c.id";
$sql.= " AND rowid='".$rowid."';";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
@ -530,6 +536,7 @@ class Propal
$this->contactid = $obj->fk_soc_contact; $this->contactid = $obj->fk_soc_contact;
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
$this->note = $obj->note; $this->note = $obj->note;
$this->note_public = $obj->note_public;
$this->statut = $obj->fk_statut; $this->statut = $obj->fk_statut;
$this->statut_libelle = $obj->statut_label; $this->statut_libelle = $obj->statut_label;
@ -1132,27 +1139,55 @@ class Propal
} }
} }
/** /**
* \brief Mets à jour la note * \brief Mets à jour les commentaires privés
* \param note Note à mettre à jour * \param note Commentaire
* \return int <0 si ko, >0 si ok * \return int <0 si ko, >0 si ok
*/ */
function update_note($note) function update_note($note)
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."propal"; $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal';
$sql.= " SET note = '".addslashes($note)."'"; $sql.= " SET note = '".addslashes($note)."'";
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid =". $this->id;
if ($this->db->query($sql)) dolibarr_syslog("Propal::update_note $sql");
{
return 1; if ($this->db->query($sql))
} {
else $this->note = $note;
{ return 1;
}
else
{
$this->error=$this->db->error(); $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;
}
}
/** /**