*
* 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$
*
*/
require("pre.inc.php");
/*
* Sécurité accés client
*/
if ($user->societe_id > 0)
{
$socid = $user->societe_id;
}
llxHeader();
if ($HTTP_POST_VARS["action"] == 'add')
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";
$sql .= " WHERE fk_soc=".$socid." AND fk_contact=".$HTTP_POST_VARS["contactid"]." AND fk_action=".$HTTP_POST_VARS["actionid"];
if ($db->query($sql))
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_soc, fk_contact, fk_action)";
$sql .= " VALUES (now(),$socid,".$HTTP_POST_VARS["contactid"].",".$HTTP_POST_VARS["actionid"].")";
if ($db->query($sql))
{
}
else
{
print $sql;
}
}
else
{
print $db->error() ."$sql";;
}
}
if ($action == "delete")
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";
$sql .= " WHERE rowid = $actid";
if ($db->query($sql))
{
// TODO ajouter une sécu pour la suppression
}
}
/*
*
*
*/
print_titre("Notifications");
$soc = new Societe($db);
$soc->id = $socid;
if ( $soc->fetch($socid) )
{
print '
';
print '| Nom | '.$soc->nom.' | ';
print '';
if ($soc->client)
{
print 'Fiche commercial';
}
else
{
print '-';
}
print ' | ';
if ($soc->client)
{
print 'Fiche compta';
}
else
{
print '-';
}
print ' |
';
print '| Adresse | '.nl2br($soc->adresse).' |
';
print '| CP | '.$soc->cp.' '.$soc->ville.' |
';
print '
';
/*
*
*/
if ($sortorder == "")
{
$sortorder="ASC";
}
if ($sortfield == "")
{
$sortfield="c.name";
}
print '
';
print '';
print_liste_field_titre_new ("Contact",$PHP_SELF,"c.name","","&socid=$socid",'',$sortfield);
print_liste_field_titre_new ("Action",$PHP_SELF,"a.titre","","&socid=$socid",'',$sortfield);
print '| | ';
print '
';
$sql = "SELECT c.name, c.firstname, a.titre,n.rowid FROM ".MAIN_DB_PREFIX."socpeople as c, ".MAIN_DB_PREFIX."action_def as a, ".MAIN_DB_PREFIX."notify_def as n";
$sql .= " WHERE n.fk_contact = c.idp AND a.rowid = n.fk_action AND n.fk_soc = ".$soc->id;
if ($db->query($sql))
{
$num = $db->num_rows();
$i = 0;
$var=True;
while ($i < $num)
{
$var = !$var;
$obj = $db->fetch_object( $i);
print '| '.$obj->firstname . " ".$obj->name.' | ';
print ''.$obj->titre.' | ';
print 'Supprimer';
$i++;
}
$db->free();
}
else
{
print $db->error();
}
/*
*
*/
$sql = "SELECT a.rowid, a.titre FROM ".MAIN_DB_PREFIX."action_def as a";
if ($db->query($sql))
{
$num = $db->num_rows();
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object( $i);
$actions[$obj->rowid] = $obj->titre;
$i++;
}
$db->free();
}
else
{
print $db->error;
}
$html = new Form($db);
print ' |
';
}
/*
*
*/
$db->close();
llxFooter("Dernière modification $Date$ révision $Revision$");
?>