diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 535af0d0e94..4b104665fb7 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -392,11 +392,6 @@ if ($_GET["id"] > 0) print ''.$langs->trans("AmountTTC").''.price($commande->total_ttc).''; print ''.$langs->trans("Currency".$conf->monnaie).' '; - if ($commande->note) - { - print ''.$langs->trans("Note").''.nl2br($commande->note).""; - } - print ""; if ($mesg) print $mesg; diff --git a/htdocs/fourn/commande/note.php b/htdocs/fourn/commande/note.php index 21b6e6f1690..af09307ce97 100644 --- a/htdocs/fourn/commande/note.php +++ b/htdocs/fourn/commande/note.php @@ -37,22 +37,26 @@ $user->getrights('fournisseur'); if (!$user->rights->fournisseur->commande->lire) accessforbidden(); + /* - * + * Actions */ if ($_POST["action"] == 'updatenote' && $user->rights->fournisseur->commande->creer) { - $commande = new CommandeFournisseur($db); - $commande->fetch($_GET["id"]); - - $result = $commande->UpdateNote($user, $_POST["note"]); - if ($result == 0) - { - Header("Location: note.php?id=".$_GET["id"]); - } + $commande = new CommandeFournisseur($db); + $commande->fetch($_GET["id"]); + + $result = $commande->UpdateNote($user, $_POST["note"], $_POST["note_public"]); + if ($result >= 0) + { + Header("Location: note.php?id=".$_GET["id"]); + exit; + } } + + llxHeader('',$langs->trans("OrderCard"),"CommandeFournisseur"); $html = new Form($db); @@ -129,34 +133,43 @@ if ($_GET["id"] > 0) print ""; } - // Auteur - print ''.$langs->trans("Author").''.$author->fullname.''; - print ''; - print " "; - - // Ligne de 3 colonnes - print ''.$langs->trans("AmountHT").''; - print ''.price($commande->total_ht).''; - print ''.$langs->trans("Currency".$conf->monnaie).''; - print ' '; + // Auteur + print ''.$langs->trans("Author").''.$author->fullname.''; + print ''; + print " "; + + // Ligne de 3 colonnes + print ''.$langs->trans("AmountHT").''; + print ''.price($commande->total_ht).''; + print ''.$langs->trans("Currency".$conf->monnaie).''; + print ' '; + + print ''.$langs->trans("AmountVAT").''.price($commande->total_tva).''; + print ''.$langs->trans("Currency".$conf->monnaie).' '; + print ''.$langs->trans("AmountTTC").''.price($commande->total_ttc).''; + print ''.$langs->trans("Currency".$conf->monnaie).' '; + + + print ''.$langs->trans("NotePrivate").''; + print ''; + if ($user->rights->fournisseur->commande->creer) print ''; + print ''; - print ''.$langs->trans("AmountVAT").''.price($commande->total_tva).''; - print ''.$langs->trans("Currency".$conf->monnaie).' '; - print ''.$langs->trans("AmountTTC").''.price($commande->total_ttc).''; - print ''.$langs->trans("Currency".$conf->monnaie).' '; + print ''.$langs->trans("NotePublic").''; + print ''; + if ($user->rights->fournisseur->commande->creer) print ''; + print ''; - - if ($user->rights->fournisseur->commande->creer) - { - print ''.$langs->trans("Note").'"; - print ''; - } - else - { - print ''.$langs->trans("Note").''.nl2br($commande->note).""; - } + if ($user->rights->fournisseur->commande->creer) + { + print ''; + } - print ""; + print ""; } else { diff --git a/htdocs/fourn/fournisseur.class.php b/htdocs/fourn/fournisseur.class.php index c6ed1c392a6..721afaf68f7 100644 --- a/htdocs/fourn/fournisseur.class.php +++ b/htdocs/fourn/fournisseur.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2006 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,14 +18,13 @@ * * $Id$ * $Source$ - * */ /** - \file htdocs/fourn/fournisseur.class.php - \ingroup fournisseur,societe - \brief Fichier de la classe des fournisseurs - \version $Revision$ + \file htdocs/fourn/fournisseur.class.php + \ingroup fournisseur,societe + \brief Fichier de la classe des fournisseurs + \version $Revision$ */ require_once(DOL_DOCUMENT_ROOT."/societe.class.php"); @@ -33,11 +33,12 @@ require_once(DOL_DOCUMENT_ROOT."/product.class.php"); /** - \class Fournisseur - \brief Classe permettant la gestion des fournisseur + \class Fournisseur + \brief Classe permettant la gestion des fournisseur */ -class Fournisseur extends Societe { +class Fournisseur extends Societe +{ var $db; /** diff --git a/htdocs/fourn/fournisseur.commande.class.php b/htdocs/fourn/fournisseur.commande.class.php index 87de9e69d10..3e0d5f69015 100644 --- a/htdocs/fourn/fournisseur.commande.class.php +++ b/htdocs/fourn/fournisseur.commande.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2004-2006 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -48,7 +48,7 @@ class CommandeFournisseur { $this->db = $DB; - $this->statuts[-1] = "Annulée"; + $this->statuts[-1]= "Annulée"; $this->statuts[0] = "Brouillon"; $this->statuts[1] = "Validée"; $this->statuts[2] = "Approuvée"; @@ -67,10 +67,10 @@ class CommandeFournisseur */ function fetch ($id) { - $sql = "SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva"; - $sql .= ", ".$this->db->pdate("c.date_commande")." as date_commande, c.fk_projet, c.remise_percent, c.source, c.fk_methode_commande "; - $sql .= ", c.note"; - $sql .= ", cm.libelle as methode_commande"; + $sql = "SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva,"; + $sql .= " ".$this->db->pdate("c.date_commande")." as date_commande, c.fk_projet, c.remise_percent, c.source, c.fk_methode_commande,"; + $sql .= " c.note, c.note_public,"; + $sql .= " cm.libelle as methode_commande"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_methode_commande_fournisseur as cm ON cm.rowid = c.fk_methode_commande"; $sql .= " WHERE c.rowid = ".$id; @@ -98,7 +98,8 @@ class CommandeFournisseur $this->source = $obj->source; $this->facturee = $obj->facture; $this->projet_id = $obj->fk_projet; - $this->note = stripslashes($obj->note); + $this->note = $obj->note; + $this->note_public = $obj->note_public; $this->db->free(); @@ -242,7 +243,6 @@ class CommandeFournisseur /** * Annule la commande * L'annulation se fait après la validation - * */ function Cancel($user) { @@ -860,34 +860,35 @@ class CommandeFournisseur return $result ; } - /** - * - * - * - */ - function UpdateNote($user, $note) - { - dolibarr_syslog("CommandeFournisseur::UpdateNote"); - $result = 0; - - $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur"; - - $sql .= " SET note ='".trim($note) ."'"; - - $sql .= " WHERE rowid = ".$this->id; - - if ($this->db->query($sql) ) + /** + * \brief Met a jour les notes + * \return int <0 si ko, >=0 si ok + */ + function UpdateNote($user, $note, $note_public) { - $result = 0; + dolibarr_syslog("CommandeFournisseur::UpdateNote"); + + $result = 0; + + $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur"; + $sql.= " SET note ='".trim($note) ."',"; + $sql.= " note_public ='".trim($note_public) ."'"; + $sql.= " WHERE rowid = ".$this->id; + + $resql=$this->db->query($sql); + if ($resql) + { + $result = 0; + } + else + { + $this->error=$this->db->error(); + dolibarr_syslog("CommandeFournisseur::UpdateNote "+$this->error); + $result = -1; + } + + return $result ; } - else - { - dolibarr_syslog("CommandeFournisseur::UpdateNote Error -1"); - $result = -1; - } - - return $result ; - } /* * @@ -925,6 +926,7 @@ class CommandeFournisseur dolibarr_syslog("ReadApprobators Erreur"); } } + /* * * diff --git a/mysql/tables/llx_contrat.key.sql b/mysql/tables/llx_contrat.key.sql index 575b468ceac..c0cde0b7be0 100644 --- a/mysql/tables/llx_contrat.key.sql +++ b/mysql/tables/llx_contrat.key.sql @@ -30,5 +30,5 @@ ALTER TABLE llx_contrat ADD INDEX idx_contrat_fk_soc (fk_soc); ALTER TABLE llx_contrat ADD INDEX idx_contrat_fk_user_author (fk_user_author); -ALTER TABLE llx_contrat ADD FOREIGN KEY (fk_soc) REFERENCES llx_societe (idp); -ALTER TABLE llx_contrat ADD FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid); \ No newline at end of file +ALTER TABLE llx_contrat ADD CONSTRAINT fk_contrat_societe FOREIGN KEY (fk_soc) REFERENCES llx_societe (idp); +ALTER TABLE llx_contrat ADD CONSTRAINT fk_contrat_societe FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid); \ No newline at end of file