2
0
forked from Wavyzz/dolibarr
Files
dolibarr-fork/htdocs/socnote.php
Laurent Destailleur 150362780f New: Ajout option pour désactiver les notifications
Qual: Factorisation de code sur onglet société
2006-04-08 22:47:51 +00:00

112 lines
3.3 KiB
PHP

<?php
/* Copyright (C) 2001-2003,2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com>
*
* 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/socnote.php
\brief Fichier onglet notes liées à la société
\ingroup societe
\version $Revision$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
$langs->load("companies");
$user->getrights('commercial');
// Protection quand utilisateur externe
$socidp = isset($_GET["socid"])?$_GET["socid"]:'';
//if ($socidp == '') accessforbidden(); //problème après update des notes
if ($user->societe_id > 0)
{
$socidp = $user->societe_id;
}
// Protection restriction commercial
if (!$user->rights->commercial->client->voir && $socidp && !$user->societe_id > 0)
{
$sql = "SELECT sc.fk_soc, s.client";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE sc.fk_soc = ".$socidp." AND sc.fk_user = ".$user->id." AND s.client = 1";
if ( $db->query($sql) )
{
if ( $db->num_rows() == 0) accessforbidden();
}
}
if ($_POST["action"] == 'add') {
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET note='".addslashes($_POST["note"])."' WHERE idp=".$_POST["socid"];
$result = $db->query($sql);
$_GET["socid"]=$_POST["socid"]; // Pour retour sur fiche
$socidp = $_GET["socid"];
}
/*
*
*/
llxHeader();
if ($socidp > 0)
{
$societe = new Societe($db, $socidp);
$societe->fetch($socidp);
/*
* Affichage onglets
*/
$head = societe_prepare_head($societe);
dolibarr_fiche_head($head, 'note', $societe->nom);
print "<form method=\"post\" action=\"socnote.php\">";
print '<table class="border" width="100%">';
print '<tr><td width="50%" valign="top">'.$langs->trans("Note").'</td><td>'.$langs->trans("CurrentNote").'</td></tr>';
print '<tr><td width="50%" valign="top">';
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
print "<input type=\"hidden\" name=\"socid\" value=\"".$societe->id."\">";
print '<textarea name="note" cols="70" rows="10">'.$societe->note.'</textarea><br>';
print '</td><td width="50%" valign="top">'.nl2br($societe->note).'</td>';
print "</td></tr>";
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
print "</table>";
print '</form>';
}
print '</div><br>';
$db->close();
llxFooter('$Date$ - $Revision$');
?>