diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 10a195b6db3..e9d2da60461 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -643,7 +643,7 @@ class 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, c.fk_cond_reglement, c.fk_mode_reglement,'; $sql.= ' '.$this->db->pdate('c.date_commande').' as date_commande, '.$this->db->pdate('c.date_livraison').' as date_livraison,'; - $sql.= ' c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture, c.note, c.ref_client, c.model_pdf, c.fk_adresse_livraison'; + $sql.= ' c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture, c.note, c.note_public, c.ref_client, c.model_pdf, c.fk_adresse_livraison'; $sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c'; $sql.= ' WHERE c.rowid = '.$id; @@ -668,6 +668,7 @@ class Commande $this->source = $obj->source; $this->facturee = $obj->facture; $this->note = $obj->note; + $this->note_public = $obj->note_public; $this->projet_id = $obj->fk_projet; $this->modelpdf = $obj->model_pdf; $this->cond_reglement_id = $obj->fk_cond_reglement; @@ -1082,6 +1083,52 @@ class Commande } } + /** + * \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.'commande'; + $sql.= " SET note = '".addslashes($note)."'"; + $sql.= " WHERE rowid =". $this->id; + + if ($this->db->query($sql)) + { + $this->note = $note; + return 1; + } + else + { + $this->error=$this->db->error(); + 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.'commande'; + $sql.= " SET note_public = '".addslashes($note_public)."'"; + $sql.= " WHERE rowid =". $this->id; + + if ($this->db->query($sql)) + { + $this->note_public = $note_public; + return 1; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } + /** * \brief Définit une date de livraison * \param user Objet utilisateur qui modifie @@ -1290,36 +1337,11 @@ class Commande } } + /** - * - * + * \brief Classe la commande comme facturée + * \return int <0 si ko, >0 si ok */ - function set_note($user, $note) - { - if ($user->rights->commande->creer) - { - $sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET note = '".addslashes($note)."'"; - $sql .= " WHERE rowid = $this->id AND fk_statut = 0 ;"; - if ($this->db->query($sql)) - { - $this->note = $note; - return 1; - } - else - { - dolibarr_print_error($this->db); - return 0; - } - } - else - { - return 0; - } - } - /** - * \brief Classe la facture comme facturée - * \return int <0 si ko, >0 si ok - */ function classer_facturee() { $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET facture = 1'; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index e9295c0749c..38ccf27fe5d 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -140,12 +140,6 @@ if ($_POST['action'] == 'setremise' && $user->rights->commande->creer) $commande->set_remise($user, $_POST['remise']); } -if ($_POST['action'] == 'setnote' && $user->rights->commande->creer) -{ - $commande = new Commande($db); - $commande->fetch($_GET['id']); - $commande->set_note($user, $_POST['note']); -} if ($_POST['action'] == 'setdate_livraison' && $user->rights->commande->creer) { $commande = new Commande($db); @@ -901,19 +895,7 @@ else } print ''; print ''.$langs->trans('NotePublic').' :
'; - if ($commande->brouillon == 1 && $user->rights->commande->creer) - { - print '
'; - print ''; - print '
'; - print '
'; - print '
'; - } - else - { - print nl2br($commande->note); - } - + print nl2br($commande->note); print ''; print ''; diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php new file mode 100644 index 00000000000..efcde017797 --- /dev/null +++ b/htdocs/commande/note.php @@ -0,0 +1,192 @@ + + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + */ + +/** + \file htdocs/commande/note.php + \ingroup commande + \brief Fiche de notes sur une commande + \version $Revision$ +*/ + +require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT.'/lib/order.lib.php'); + +$socidp=isset($_GET["socidp"])?$_GET["socidp"]:isset($_POST["socidp"])?$_POST["socidp"]:""; + +$user->getrights('commande'); +if (!$user->rights->commande->lire) + accessforbidden(); + +$langs->load("companies"); +$langs->load("bills"); +$langs->load("orders"); + +// Sécurité accés +if ($user->societe_id > 0) +{ + unset($_GET["action"]); + $socidp = $user->societe_id; +} + + +$commande = new Commande($db); +$commande->fetch($_GET["id"]); + + +/******************************************************************************/ +/* Actions */ +/******************************************************************************/ + +if ($_POST["action"] == 'update_public' && $user->rights->facture->creer) +{ + $db->begin(); + + $res=$commande->update_note_public($_POST["note_public"]); + if ($res < 0) + { + $mesg='
'.$commande->error.'
'; + $db->rollback(); + } + else + { + $db->commit(); + } +} + +if ($_POST["action"] == 'update' && $user->rights->facture->creer) +{ + $db->begin(); + + $res=$commande->update_note($_POST["note"]); + if ($res < 0) + { + $mesg='
'.$commande->error.'
'; + $db->rollback(); + } + else + { + $db->commit(); + } +} + + + +/******************************************************************************/ +/* Affichage fiche */ +/******************************************************************************/ + +llxHeader(); + +$html = new Form($db); + +if ($_GET["id"]) +{ + $soc = new Societe($db, $commande->socidp); + $soc->fetch($commande->socidp); + + $head = commande_prepare_head($commande); + $hselected = 2; + if ($conf->use_preview_tabs) $hselected++; + if ($fac->mode_reglement_code == 'PRE') $hselected++; + + dolibarr_fiche_head($head, $hselected, $langs->trans("CustomerOrder")); + + + print ''; + + // Ref + print '"; + + // Ref commande client + print ''; + print ''; + + // Customer + print ""; + print ''; + + // Note publique + print ''; + print '"; + + // Note privée + print ''; + print '"; + print "
'.$langs->trans("Ref").''; + print $commande->ref; + print "
'; + print ''; + print '
'; + print $langs->trans('RefCustomer').''; + print '
'; + print '
'; + print $commande->ref_client; + print '
".$langs->trans("Company")."'; + print ''.$soc->nom.'
'.$langs->trans("NotePublic").' :'; + if ($_GET["action"] == 'edit') + { + print '
'; + print ''; + print '
"; + print ''; + print '
'; + } + else + { + print ($commande->note_public?nl2br($commande->note_public):" "); + } + print "
'.$langs->trans("NotePrivate").' :'; + if ($_GET["action"] == 'edit') + { + print '
'; + print ''; + print '
"; + print ''; + print '
'; + } + else + { + print ($commande->note?nl2br($commande->note):" "); + } + print "
"; + + + /* + * Actions + */ + print ''; + print '
'; + + if ($user->rights->commande->creer && $_GET["action"] <> 'edit') + { + print "id&action=edit\">".$langs->trans('Edit').""; + } + + print "
"; + + +} + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/lib/order.lib.php b/htdocs/lib/order.lib.php index b493f4f285c..e6e677f58fe 100644 --- a/htdocs/lib/order.lib.php +++ b/htdocs/lib/order.lib.php @@ -75,6 +75,11 @@ function commande_prepare_head($commande) $head[$h][2] = 'contact'; $h++; + $head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$commande->id; + $head[$h][1] = $langs->trans('Note'); + $head[$h][2] = 'note'; + $h++; + $head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$commande->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; diff --git a/mysql/tables/llx_facturedet.sql b/mysql/tables/llx_facturedet.sql index 8289710e752..394609e495b 100644 --- a/mysql/tables/llx_facturedet.sql +++ b/mysql/tables/llx_facturedet.sql @@ -24,17 +24,20 @@ create table llx_facturedet ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_facture integer NOT NULL, - fk_product integer NULL, -- doit pouvoir etre nul pour ligne detail sans produits + fk_product integer NULL, -- Doit pouvoir etre nul pour ligne detail sans produits description text, - tva_taux real DEFAULT 19.6, -- taux tva - qty real, -- quantité - remise_percent real DEFAULT 0, -- pourcentage de remise - remise real DEFAULT 0, -- montant de la remise - subprice real, -- prix avant remise - price real, -- prix final - date_start datetime, -- date debut si service - date_end datetime, -- date fin si service - info_bits integer DEFAULT 0, + tva_taux real DEFAULT 19.6, -- Taux tva produit/service (exemple 19.6) + qty real, -- Quantité (exemple 2) + remise_percent real DEFAULT 0, -- % de la remise ligne (exemple 20%) + remise real DEFAULT 0, -- Montant calculé de la remise % sur PU HT (exemple 20) + subprice real, -- P.U. HT (exemple 100) + price real, -- P.U. HT apres remise % de ligne + total_ht real, -- Total HT de la ligne toute quantité et incluant remise ligne et globale + total_tva real, -- Total TVA de la ligne toute quantité et incluant remise ligne et globale + total_ttc real, -- Total TTC de la ligne toute quantité et incluant remise ligne et globale + date_start datetime, -- date debut si service + date_end datetime, -- date fin si service + info_bits integer DEFAULT 0, -- TVA NPR ou non fk_code_ventilation integer DEFAULT 0 NOT NULL, fk_export_compta integer DEFAULT 0 NOT NULL, rang integer DEFAULT 0