Nouveau fichier

This commit is contained in:
Rodolphe Quiedeville 2003-06-30 16:05:17 +00:00
parent 19e799741b
commit 9737741df5
2 changed files with 292 additions and 0 deletions

View File

@ -0,0 +1,181 @@
<?PHP
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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();
$db = new Db();
if ($HTTP_POST_VARS["action"] == 'add')
{
$sql = "DELETE FROM llx_notify";
$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 llx_notify (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";;
}
}
/*
*
*
*/
print_titre("Notifications");
$soc = new Societe($db);
$soc->id = $socid;
if ( $soc->fetch($socid) )
{
print '<table border="1" cellpadding="3" cellspacing="0" width="100%">';
print '<tr><td width="20%">Nom</td><td class="valeur">'.$soc->nom.'</td>';
print '<td align="center">';
if ($soc->client)
{
print '<a href="'.DOL_URL_ROOT.'/comm/fiche.php3?socid='.$socid.'">Fiche commercial</a>';
}
else
{
print '-';
}
print '</td><td align="center">';
if ($soc->fournisseur)
{
print '<a href="'.DOL_URL_ROOT.'/compta/fiche.php3?socid='.$socid.'">Fiche fournisseur</a>';
}
else
{
print '-';
}
print '</td></tr>';
print '<tr><td valign="top">Adresse</td><td class="valeur" colspan="3">'.nl2br($soc->adresse).'&nbsp;</td></tr>';
print '<tr><td>CP</td><td class="valeur" colspan="3">'.$soc->cp.'&nbsp;'.$soc->ville.'</td></tr>';
print '</table>';
/*
*
*/
if ($sortorder == "")
{
$sortorder="ASC";
}
if ($sortfield == "")
{
$sortfield="c.name";
}
print '<br><table width="100%" border="0" cellspacing="0" cellpadding="3">';
print '<tr class="liste_titre">';
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 '<td>&nbsp;</td>';
print '</tr>';
$sql = "SELECT c.name, c.firstname, a.titre,n.rowid FROM llx_socpeople as c, llx_action_def as a, llx_notify 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)
{
$obj = $db->fetch_object( $i);
print '<tr><td>'.$obj->firstname . " ".$obj->name.'</td>';
print '<td>'.$obj->titre.'</td>';
print '<td><a href="fiche.php?socid='.$socid.'&action=delete&actid='.$obj->rowid.'">Supprimer</a>';
$i++;
}
$db->free();
}
else
{
print $db->error();
}
/*
*
*/
$sql = "SELECT a.rowid, a.titre FROM llx_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 '<form action="fiche.php?socid='.$socid.'" method="post">';
print '<input type="hidden" name="action" value="add">';
print '<tr><td>';
$html->select_array("contactid",$soc->contact_email_array());
print '</td>';
print '<td>';
$html->select_array("actionid",$actions);
print '</td>';
print '<td><input type="submit" value="Ajouter"></td>';
print '</tr></form></table>';
}
/*
*
*/
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -0,0 +1,111 @@
<?PHP
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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)
{
$action = '';
$socid = $user->societe_id;
}
llxHeader();
$db = new Db();
if ($sortorder == "")
{
$sortorder="ASC";
}
if ($sortfield == "")
{
$sortfield="s.nom";
}
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
/*
* Mode Liste
*
*
*
*/
print_barre_liste("Liste des societes", $page, $PHP_SELF);
$sql = "SELECT s.nom, s.idp, c.name, c.firstname, a.titre,n.rowid FROM llx_socpeople as c, llx_action_def as a, llx_notify as n, llx_societe as s";
$sql .= " WHERE n.fk_contact = c.idp AND a.rowid = n.fk_action";
$sql .= " AND n.fk_soc = s.idp";
if ($socid > 0) {
$sql .= " AND s.idp = " . $user->societe_id;
}
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit, $offset);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows();
$i = 0;
print "<TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
print '<TR class="liste_titre">';
print "<TD valign=\"center\">";
print_liste_field_titre("Société",$PHP_SELF,"s.nom");
print "</td><td>";
print_liste_field_titre("Contact",$PHP_SELF,"c.name");
print "</td><td>";
print_liste_field_titre("Action",$PHP_SELF,"a.titre");
print "</td></tr>\n";
$var=True;
while ($i < $num)
{
$obj = $db->fetch_object( $i);
$var=!$var;
print "<TR $bc[$var]>";
print "<TD><a href=\"fiche.php?socid=$obj->idp\">$obj->nom</A></td>\n";
print "<td>".$obj->firstname." ".$obj->name."</td>\n";
print "<td>".$obj->titre."</td>\n";
print "</tr>\n";
$i++;
}
print "</TABLE>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>