New: Ajout champ note publique sur commandes fournisseurs

This commit is contained in:
Laurent Destailleur 2006-03-18 18:03:01 +00:00
parent 4bcc8d2afa
commit ca7b69abd1
5 changed files with 94 additions and 83 deletions

View File

@ -392,11 +392,6 @@ if ($_GET["id"] > 0)
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td align="right">'.price($commande->total_ttc).'</td>'; print '<tr><td>'.$langs->trans("AmountTTC").'</td><td align="right">'.price($commande->total_ttc).'</td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td><td colspan="3">&nbsp;</td></tr>'; print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td><td colspan="3">&nbsp;</td></tr>';
if ($commande->note)
{
print '<tr><td>'.$langs->trans("Note").'</td><td colspan="5">'.nl2br($commande->note)."</td></tr>";
}
print "</table>"; print "</table>";
if ($mesg) print $mesg; if ($mesg) print $mesg;

View File

@ -37,22 +37,26 @@ $user->getrights('fournisseur');
if (!$user->rights->fournisseur->commande->lire) accessforbidden(); if (!$user->rights->fournisseur->commande->lire) accessforbidden();
/* /*
* * Actions
*/ */
if ($_POST["action"] == 'updatenote' && $user->rights->fournisseur->commande->creer) if ($_POST["action"] == 'updatenote' && $user->rights->fournisseur->commande->creer)
{ {
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
$commande->fetch($_GET["id"]); $commande->fetch($_GET["id"]);
$result = $commande->UpdateNote($user, $_POST["note"]); $result = $commande->UpdateNote($user, $_POST["note"], $_POST["note_public"]);
if ($result == 0) if ($result >= 0)
{ {
Header("Location: note.php?id=".$_GET["id"]); Header("Location: note.php?id=".$_GET["id"]);
} exit;
}
} }
llxHeader('',$langs->trans("OrderCard"),"CommandeFournisseur"); llxHeader('',$langs->trans("OrderCard"),"CommandeFournisseur");
$html = new Form($db); $html = new Form($db);
@ -129,34 +133,43 @@ if ($_GET["id"] > 0)
print "</td></tr>"; print "</td></tr>";
} }
// Auteur // Auteur
print '<tr><td>'.$langs->trans("Author").'</td><td colspan="2">'.$author->fullname.'</td>'; print '<tr><td>'.$langs->trans("Author").'</td><td colspan="2">'.$author->fullname.'</td>';
print '<td width="50%">'; print '<td width="50%">';
print "&nbsp;</td></tr>"; print "&nbsp;</td></tr>";
// Ligne de 3 colonnes // Ligne de 3 colonnes
print '<tr><td>'.$langs->trans("AmountHT").'</td>'; print '<tr><td>'.$langs->trans("AmountHT").'</td>';
print '<td align="right"><b>'.price($commande->total_ht).'</b></td>'; print '<td align="right"><b>'.price($commande->total_ht).'</b></td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td>'; print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td>';
print '<td valign="top">&nbsp;</td></tr>'; print '<td valign="top">&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("AmountVAT").'</td><td align="right">'.price($commande->total_tva).'</td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td><td>&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td align="right">'.price($commande->total_ttc).'</td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td><td>&nbsp;</td></tr>';
print '<tr><td valign="top">'.$langs->trans("NotePrivate").'</td>';
print '<td colspan="3">';
if ($user->rights->fournisseur->commande->creer) print '<textarea cols="60" rows="'.ROWS_4.'" name="note">';
print nl2br($commande->note);
if ($user->rights->fournisseur->commande->creer) print '</textarea>';
print '</td></tr>';
print '<tr><td>'.$langs->trans("AmountVAT").'</td><td align="right">'.price($commande->total_tva).'</td>'; print '<tr><td valign="top">'.$langs->trans("NotePublic").'</td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td><td>&nbsp;</td></tr>'; print '<td colspan="3">';
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td align="right">'.price($commande->total_ttc).'</td>'; if ($user->rights->fournisseur->commande->creer) print '<textarea cols="60" rows="'.ROWS_4.'" name="note_public">';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td><td>&nbsp;</td></tr>'; print nl2br($commande->note_public);
if ($user->rights->fournisseur->commande->creer) print '</textarea>';
print '</td></tr>';
if ($user->rights->fournisseur->commande->creer)
if ($user->rights->fournisseur->commande->creer) {
{ print '<tr><td colspan="4" align="center"><input type="submit" class="button"></td></tr>';
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="3"><textarea cols="60" rows="10" name="note">'.nl2br($commande->note)."</textarea></td></tr>"; }
print '<tr><td colspan="4" align="center"><input type="submit" class="button"></td></tr>';
}
else
{
print '<tr><td>'.$langs->trans("Note").'</td><td colspan="3">'.nl2br($commande->note)."</td></tr>";
}
print "</table></form>"; print "</table></form>";
} }
else else
{ {

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,14 +18,13 @@
* *
* $Id$ * $Id$
* $Source$ * $Source$
*
*/ */
/** /**
\file htdocs/fourn/fournisseur.class.php \file htdocs/fourn/fournisseur.class.php
\ingroup fournisseur,societe \ingroup fournisseur,societe
\brief Fichier de la classe des fournisseurs \brief Fichier de la classe des fournisseurs
\version $Revision$ \version $Revision$
*/ */
require_once(DOL_DOCUMENT_ROOT."/societe.class.php"); require_once(DOL_DOCUMENT_ROOT."/societe.class.php");
@ -33,11 +33,12 @@ require_once(DOL_DOCUMENT_ROOT."/product.class.php");
/** /**
\class Fournisseur \class Fournisseur
\brief Classe permettant la gestion des fournisseur \brief Classe permettant la gestion des fournisseur
*/ */
class Fournisseur extends Societe { class Fournisseur extends Societe
{
var $db; var $db;
/** /**

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -48,7 +48,7 @@ class CommandeFournisseur
{ {
$this->db = $DB; $this->db = $DB;
$this->statuts[-1] = "Annulée"; $this->statuts[-1]= "Annulée";
$this->statuts[0] = "Brouillon"; $this->statuts[0] = "Brouillon";
$this->statuts[1] = "Validée"; $this->statuts[1] = "Validée";
$this->statuts[2] = "Approuvée"; $this->statuts[2] = "Approuvée";
@ -67,10 +67,10 @@ class CommandeFournisseur
*/ */
function fetch ($id) 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 = "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 .= " ".$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 .= " c.note, c.note_public,";
$sql .= ", cm.libelle as methode_commande"; $sql .= " cm.libelle as methode_commande";
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c"; $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 .= " LEFT JOIN ".MAIN_DB_PREFIX."c_methode_commande_fournisseur as cm ON cm.rowid = c.fk_methode_commande";
$sql .= " WHERE c.rowid = ".$id; $sql .= " WHERE c.rowid = ".$id;
@ -98,7 +98,8 @@ class CommandeFournisseur
$this->source = $obj->source; $this->source = $obj->source;
$this->facturee = $obj->facture; $this->facturee = $obj->facture;
$this->projet_id = $obj->fk_projet; $this->projet_id = $obj->fk_projet;
$this->note = stripslashes($obj->note); $this->note = $obj->note;
$this->note_public = $obj->note_public;
$this->db->free(); $this->db->free();
@ -242,7 +243,6 @@ class CommandeFournisseur
/** /**
* Annule la commande * Annule la commande
* L'annulation se fait après la validation * L'annulation se fait après la validation
*
*/ */
function Cancel($user) function Cancel($user)
{ {
@ -860,34 +860,35 @@ class CommandeFournisseur
return $result ; return $result ;
} }
/** /**
* * \brief Met a jour les notes
* * \return int <0 si ko, >=0 si ok
* */
*/ function UpdateNote($user, $note, $note_public)
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) )
{ {
$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"); dolibarr_syslog("ReadApprobators Erreur");
} }
} }
/* /*
* *
* *

View File

@ -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_soc (fk_soc);
ALTER TABLE llx_contrat ADD INDEX idx_contrat_fk_user_author (fk_user_author); 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 CONSTRAINT fk_contrat_societe FOREIGN KEY (fk_soc) REFERENCES llx_societe (idp);
ALTER TABLE llx_contrat ADD FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid); ALTER TABLE llx_contrat ADD CONSTRAINT fk_contrat_societe FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid);