New: Ajout onglet note sur les commandes
This commit is contained in:
parent
98e2919698
commit
d771db2b58
@ -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';
|
||||
|
||||
@ -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 '</td>';
|
||||
print '<td rowspan="'.$nbrow.'" valign="top">'.$langs->trans('NotePublic').' :<br>';
|
||||
if ($commande->brouillon == 1 && $user->rights->commande->creer)
|
||||
{
|
||||
print '<form action="fiche.php?id='.$id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="setnote">';
|
||||
print '<textarea name="note" rows="4" style="width:95%;">'.$commande->note.'</textarea><br>';
|
||||
print '<center><input type="submit" class="button" value="'.$langs->trans('Save').'"></center>';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print nl2br($commande->note);
|
||||
}
|
||||
|
||||
print nl2br($commande->note);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
192
htdocs/commande/note.php
Normal file
192
htdocs/commande/note.php
Normal file
@ -0,0 +1,192 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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='<div class="error">'.$commande->error.'</div>';
|
||||
$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='<div class="error">'.$commande->error.'</div>';
|
||||
$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 '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||
print $commande->ref;
|
||||
print "</td></tr>";
|
||||
|
||||
// Ref commande client
|
||||
print '<tr><td>';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
|
||||
print $langs->trans('RefCustomer').'</td><td align="left">';
|
||||
print '</td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
print $commande->ref_client;
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Customer
|
||||
print "<tr><td>".$langs->trans("Company")."</td>";
|
||||
print '<td colspan="3">';
|
||||
print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></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?id='.$commande->id.'">';
|
||||
print '<input type="hidden" name="action" value="update_public">';
|
||||
print '<textarea name="note_public" cols="80" rows="8">'.$commande->note_public."</textarea><br>";
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print ($commande->note_public?nl2br($commande->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?id='.$commande->id.'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<textarea name="note" cols="80" rows="8">'.$commande->note."</textarea><br>";
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print ($commande->note?nl2br($commande->note):" ");
|
||||
}
|
||||
print "</td></tr>";
|
||||
print "</table>";
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
print '</div>';
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($user->rights->commande->creer && $_GET["action"] <> 'edit')
|
||||
{
|
||||
print "<a class=\"tabAction\" href=\"note.php?id=$commande->id&action=edit\">".$langs->trans('Edit')."</a>";
|
||||
}
|
||||
|
||||
print "</div>";
|
||||
|
||||
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
@ -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';
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user