Nouveau fichier
This commit is contained in:
parent
4e586f5d67
commit
0ead8a2e24
223
htdocs/contact/fiche.php
Normal file
223
htdocs/contact/fiche.php
Normal file
@ -0,0 +1,223 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2004 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");
|
||||
require("../contact.class.php");
|
||||
|
||||
if ($sortorder == "")
|
||||
{
|
||||
$sortfield="lower(s.nom)";
|
||||
$sortorder="ASC";
|
||||
}
|
||||
|
||||
if ($HTTP_POST_VARS["action"] == 'add')
|
||||
{
|
||||
$contact = new Contact($db);
|
||||
|
||||
$contact->name = $HTTP_POST_VARS["name"];
|
||||
$contact->firstname = $HTTP_POST_VARS["firstname"];
|
||||
|
||||
$contact->poste = $HTTP_POST_VARS["poste"];
|
||||
|
||||
$contact->fax = $HTTP_POST_VARS["fax"];
|
||||
$contact->note = $HTTP_POST_VARS["note"];
|
||||
$contact->email = $HTTP_POST_VARS["email"];
|
||||
$contact->phone_pro = $HTTP_POST_VARS["phone_pro"];
|
||||
$contact->phone_perso = $HTTP_POST_VARS["phone_perso"];
|
||||
$contact->phone_mobile = $HTTP_POST_VARS["phone_mobile"];
|
||||
|
||||
$_GET["id"] = $contact->create($user);
|
||||
}
|
||||
|
||||
if ($_GET["action"] == 'delete')
|
||||
{
|
||||
$contact = new Contact($db);
|
||||
|
||||
$contact->old_name = $HTTP_POST_VARS["old_name"];
|
||||
$contact->old_firstname = $HTTP_POST_VARS["old_firstname"];
|
||||
|
||||
$result = $contact->delete($_GET["id"]);
|
||||
|
||||
Header("Location: index.php");
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ($action == 'update')
|
||||
{
|
||||
$contact = new Contact($db);
|
||||
|
||||
$contact->old_name = $HTTP_POST_VARS["old_name"];
|
||||
$contact->old_firstname = $HTTP_POST_VARS["old_firstname"];
|
||||
|
||||
$contact->name = $HTTP_POST_VARS["name"];
|
||||
$contact->firstname = $HTTP_POST_VARS["firstname"];
|
||||
$contact->poste = $poste;
|
||||
|
||||
$contact->phone_pro = $HTTP_POST_VARS["phone_pro"];
|
||||
$contact->phone_perso = $HTTP_POST_VARS["phone_perso"];
|
||||
$contact->phone_mobile = $HTTP_POST_VARS["phone_mobile"];
|
||||
$contact->fax = $HTTP_POST_VARS["fax"];
|
||||
$contact->note = $note;
|
||||
$contact->email = $HTTP_POST_VARS["email"];
|
||||
|
||||
$result = $contact->update($HTTP_POST_VARS["contactid"]);
|
||||
|
||||
}
|
||||
|
||||
if ($action == 'create_user')
|
||||
{
|
||||
$nuser = new User($db);
|
||||
$contact = new Contact($db);
|
||||
$nuser->nom = $contact->nom;
|
||||
$nuser->prenom = $contact->prenom;
|
||||
$result = $contact->fetch($contactid);
|
||||
$nuser->create_from_contact($contact);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
if ($_GET["action"] == 'create')
|
||||
{
|
||||
print_fiche_titre ("Création d'un nouveau contact");
|
||||
|
||||
print "<form method=\"post\" action=\"fiche.php\">";
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<table class="border" border="0" width="100%">';
|
||||
print '<tr><td>Nom</td><td><input name="name" type="text" size="20" maxlength="80"></td>';
|
||||
print '<td>Prenom</td><td><input name="firstname" type="text" size="15" maxlength="80"></td>';
|
||||
|
||||
print '<td>Tel Pro</td><td><input name="phone" type="text" size="18" maxlength="80"></td></tr>';
|
||||
|
||||
|
||||
print '<tr><td>Poste</td><td colspan="3"><input name="poste" type="text" size="50" maxlength="80"></td>';
|
||||
|
||||
print '<td>Tel Perso</td><td><input name="phone" type="text" size="18" maxlength="80"></td></tr>';
|
||||
|
||||
print '<tr><td>Adresse</td><td colspan="3"><input name="adresse" type="text" size="18" maxlength="80"></td>';
|
||||
|
||||
print '<td>Mobile</td><td><input name="phone" type="text" size="18" maxlength="80"></td></tr>';
|
||||
|
||||
print '<tr><td>CP Ville</td><td colspan="3"><input name="cp" type="text" size="6" maxlength="80"> <input name="cp" type="text" size="20" maxlength="80"></td>';
|
||||
|
||||
print '<td>Fax</td><td><input name="fax" type="text" size="18" maxlength="80"></td></tr>';
|
||||
print '<tr><td>Email</td><td colspan="3"><input name="email" type="text" size="50" maxlength="80"></td></tr>';
|
||||
print '<tr><td align="center" colspan="4"><input type="submit" value="Ajouter"></td></tr>';
|
||||
print "</table>";
|
||||
print "</form>";
|
||||
}
|
||||
elseif ($_GET["action"] == 'edit')
|
||||
{
|
||||
|
||||
print_fiche_titre ("Edition d'un contact");
|
||||
|
||||
$contact = new Contact($db);
|
||||
$contact->fetch($_GET["id"]);
|
||||
|
||||
print '<form method="post" action="fiche.php?id='.$_GET["id"].'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="contactid" value="'.$contact->id.'">';
|
||||
print '<input type="hidden" name="old_name" value="'.$contact->name.'">';
|
||||
print '<input type="hidden" name="old_firstname" value="'.$contact->firstname.'">';
|
||||
print '<table class="border" border="0" width="100%">';
|
||||
print '<tr><td>Nom</td><td><input name="name" type="text" size="20" maxlength="80" value="'.$contact->name.'"></td>';
|
||||
print '<td>Prenom</td><td><input name="firstname" type="text" size="15" maxlength="80" value="'.$contact->firstname.'"></td>';
|
||||
|
||||
print '<td>Tel Pro</td><td><input name="phone_pro" type="text" size="18" maxlength="80" value="'.$contact->phone_pro.'"></td></tr>';
|
||||
|
||||
print '<tr><td>Poste</td><td colspan="3"><input name="poste" type="text" size="50" maxlength="80"></td>';
|
||||
|
||||
print '<td>Tel Perso</td><td><input name="phone_perso" type="text" size="18" maxlength="80" value="'.$contact->perso.'"></td></tr>';
|
||||
|
||||
print '<tr><td>Adresse</td><td colspan="3"><input name="adresse" type="text" size="18" maxlength="80"></td>';
|
||||
|
||||
print '<td>Mobile</td><td><input name="phone_mobile" type="text" size="18" maxlength="80" value="'.$contact->phone_mobile.'"></td></tr>';
|
||||
|
||||
print '<tr><td>CP Ville</td><td colspan="3"><input name="cp" type="text" size="6" maxlength="80"> <input name="cp" type="text" size="20" maxlength="80"></td>';
|
||||
|
||||
print '<td>Fax</td><td><input name="fax" type="text" size="18" maxlength="80"></td></tr>';
|
||||
print '<tr><td>Email</td><td colspan="3"><input name="email" type="text" size="50" maxlength="80" value="'.$contact->email.'"></td></tr>';
|
||||
|
||||
print '<tr><td>Jabberid</td><td colspan="3"><input name="jabberid" type="text" size="50" maxlength="80" value="'.$contact->jabberid.'"></td></tr>';
|
||||
|
||||
print '<tr><td align="center" colspan="4"><input type="submit" value="Enregistrer"></td></tr>';
|
||||
print "</table>";
|
||||
print "</form>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$contact = new Contact($db);
|
||||
$contact->fetch($_GET["id"]);
|
||||
|
||||
|
||||
print_fiche_titre ("Contact : ". $contact->firstname.' '.$contact->name);
|
||||
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr><td>Nom : '.$contact->name.' '.$contact->firstname;
|
||||
|
||||
if ($contact->email)
|
||||
print '<br>Email : '.$contact->email;
|
||||
|
||||
print '</td><td>';
|
||||
|
||||
print 'Tel Pro : '.$contact->phone_pro;
|
||||
|
||||
if ($contact->phone_perso)
|
||||
print '<br>Tel Perso : '.$contact->phone_perso;
|
||||
|
||||
if($contact->phone_mobile)
|
||||
print '<br>Portable : '.$contact->phone_mobile;
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
|
||||
print "</table>";
|
||||
|
||||
|
||||
if ($user->societe_id == 0)
|
||||
{
|
||||
print '<p><table id="actions" width="100%"><tr>';
|
||||
|
||||
print '<td align="center" width="20%"><a href="fiche.php?id='.$_GET["id"].'&action=edit">Editer</a></td>';
|
||||
|
||||
print '<td align="center" width="20%">-</td>';
|
||||
print '<td align="center" width="20%">-</td>';
|
||||
print '<td align="center" width="20%">-</td>';
|
||||
|
||||
print '<td align="center" width="20%"><a href="fiche.php?id='.$_GET["id"].'&action=delete">Supprimer</a></td>';
|
||||
print "</tr></table>";
|
||||
}
|
||||
print "<p>\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||
?>
|
||||
160
htdocs/contact/index.php
Normal file
160
htdocs/contact/index.php
Normal file
@ -0,0 +1,160 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2003 Éric Seigne <erics@rycks.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$
|
||||
*
|
||||
*/
|
||||
require("./pre.inc.php");
|
||||
|
||||
/*
|
||||
* Sécurité accés client
|
||||
*/
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
llxHeader();
|
||||
|
||||
|
||||
if ($sortorder == "")
|
||||
{
|
||||
$sortorder="ASC";
|
||||
}
|
||||
if ($sortfield == "")
|
||||
{
|
||||
$sortfield="p.name";
|
||||
}
|
||||
|
||||
if ($page < 0) { $page = 0 ; }
|
||||
$limit = $conf->liste_limit;
|
||||
$offset = $limit * $page ;
|
||||
|
||||
print_barre_liste("Liste des contacts",$page, $PHP_SELF, '', $sortfield, $sortorder);
|
||||
|
||||
/*
|
||||
*
|
||||
* Mode liste
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
$sql = "SELECT s.idp, s.nom, p.idp as cidp, p.name, p.firstname, p.email, p.phone ";
|
||||
$sql .= "FROM llx_socpeople as p";
|
||||
$sql .= " LEFT JOIN llx_societe as s ON (s.idp = p.fk_soc)";
|
||||
|
||||
|
||||
if (strlen($_GET["userid"])) // statut commercial
|
||||
{
|
||||
$sql .= " WHERE p.fk_user=".$_GET["userid"];
|
||||
}
|
||||
|
||||
if (strlen($begin)) // filtre sur la premiere lettre du nom
|
||||
{
|
||||
$sql .= " AND upper(p.name) like '$begin%'";
|
||||
}
|
||||
|
||||
if ($contactname) // acces a partir du module de recherche
|
||||
{
|
||||
$sql .= " AND ( lower(p.name) like '%".strtolower($contactname)."%' OR lower(p.firstname) like '%".strtolower($contactname)."%') ";
|
||||
$sortfield = "lower(p.name)";
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND s.idp = $socid";
|
||||
}
|
||||
|
||||
if($_GET["view"] == "recent")
|
||||
{
|
||||
$sql .= " ORDER BY p.datec DESC " . $db->plimit( $limit, $offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit, $offset);
|
||||
}
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
$i = 0;
|
||||
|
||||
if ($sortorder == "DESC")
|
||||
{
|
||||
$sortorder="ASC";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sortorder="DESC";
|
||||
}
|
||||
print "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
|
||||
print "<TR class=\"liste_titre\">";
|
||||
print "<TD>";
|
||||
print_liste_field_titre("Nom",$PHP_SELF,"lower(p.name)", $begin);
|
||||
print "</td><td>";
|
||||
print_liste_field_titre("Prénom",$PHP_SELF,"lower(p.firstname)", $begin);
|
||||
print "</td><td>";
|
||||
print_liste_field_titre("Société",$PHP_SELF,"lower(s.nom)", $begin);
|
||||
print "</td><TD>email</TD>";
|
||||
print '<TD>Téléphone</TD>';
|
||||
print "</TR>\n";
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object( $i);
|
||||
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
print '<td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$obj->cidp.'">';
|
||||
print img_file();
|
||||
print '</a><a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$obj->cidp.'">'.$obj->name.'</a></td>';
|
||||
print "<TD>$obj->firstname</TD>";
|
||||
|
||||
print '<td>';
|
||||
if ($obj->nom)
|
||||
{
|
||||
print '<a href="contact.php?socid='.$obj->idp.'"><img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/filter.png" border="0" alt="Filtre"></a> ';
|
||||
}
|
||||
print "<a href=\"".DOL_URL_ROOT."/comm/fiche.php?socid=$obj->idp\">$obj->nom</A></td>\n";
|
||||
|
||||
print '<td><a href="action/fiche.php?action=create&actionid=4&contactid='.$obj->cidp.'&socid='.$obj->idp.'">'.$obj->email.'</a> </td>';
|
||||
|
||||
print '<td><a href="action/fiche.php?action=create&actionid=1&contactid='.$obj->cidp.'&socid='.$obj->idp.'">'.$obj->phone.'</a> </td>';
|
||||
|
||||
print "</TR>\n";
|
||||
$i++;
|
||||
}
|
||||
print "</TABLE>";
|
||||
$db->free();
|
||||
} else {
|
||||
print $db->error();
|
||||
print "<br>".$sql;
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user