New: Toutes les entites (contrat, facture, propal, commande) possde un chanp note (non affich sur PDF) et un champ note public (affich sur PDF)
This commit is contained in:
parent
fe6723eb07
commit
7ace7a3b27
@ -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='<div class="error">'.$propal->error.'</div>';
|
||||
$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='<div class="error">'.$propal->error.'</div>';
|
||||
$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 '</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td valign="top" colspan="4">'.$langs->trans('Note').' :<br>'. nl2br($propal->note).'</td></tr>';
|
||||
|
||||
if ($_GET['action'] == 'edit')
|
||||
// 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):" ");
|
||||
}
|
||||
print "</td></tr>";
|
||||
|
||||
// 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 '<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 ($propal->note?nl2br($propal->note):" ");
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print "</td></tr>";
|
||||
print "</table>";
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
@ -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='<div class="error">'.$fac->error.'</div>';
|
||||
$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='<div class="error">'.$fac->error.'</div>';
|
||||
$db->rollback();
|
||||
$msg=$fac->error();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user