dolibarr  7.0.0-beta
contact.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2006 Regis Houssin <regis.houssin@capnetworks.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
26 require '../main.inc.php';
27 
28 $langs->load("companies");
29 
30 
31 /*
32  * View
33  */
34 
35 llxHeader();
36 
37 // Security check
38 if ($user->societe_id > 0)
39 {
40  $action = '';
41  $socid = $user->societe_id;
42 }
43 
44 $sortfield = GETPOST("sortfield",'alpha');
45 $sortorder = GETPOST("sortorder",'alpha');
46 $page = GETPOST("page",'int');
47 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
48 $offset = $conf->liste_limit * $page;
49 $pageprev = $page - 1;
50 $pagenext = $page + 1;
51 if (! $sortorder) $sortorder="ASC";
52 if (! $sortfield) $sortfield="p.name";
53 $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
54 
55 
56 /*
57  * Mode liste
58  */
59 
60 $sql = "SELECT s.rowid as socid, s.nom as name, st.libelle as stcomm, p.rowid as cidp, p.lastname, p.firstname, p.email, p.phone";
61 if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user ";
62 $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."socpeople as p, ".MAIN_DB_PREFIX."c_stcomm as st";
63 if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
64 $sql.= " WHERE s.fk_stcomm = st.id";
65 $sql.= " AND s.fournisseur = 1";
66 $sql.= " AND s.rowid = p.fk_soc";
67 $sql.= " AND s.entity IN (".getEntity('societe').")";
68 if (! $user->rights->societe->client->voir && ! $socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
69 
70 if (dol_strlen($stcomm)) {
71  $sql .= " AND s.fk_stcomm=$stcomm";
72 }
73 
74 if (dol_strlen($begin)) {
75  $sql .= " AND p.name LIKE '$begin%'";
76 }
77 
78 if ($contactname) {
79  $sql .= " AND p.name LIKE '%".strtolower($contactname)."%'";
80  $sortfield = "p.name";
81  $sortorder = "ASC";
82 }
83 
84 if ($socid) {
85  $sql .= " AND s.rowid = ".$socid;
86 }
87 
88 $sql .= " ORDER BY $sortfield $sortorder ";
89 $sql .= $db->plimit($limit, $offset);
90 
91 $result = $db->query($sql);
92 if ($result)
93 {
94  $num = $db->num_rows($result);
95 
96  $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses"));
97  print_barre_liste($title." (".$langs->trans("Suppliers").")",$page, $_SERVER["PHP_SELF"], "",$sortfield,$sortorder,"",$num);
98 
99  print '<table class="liste" width="100%">';
100  print '<tr class="liste_titre">';
101  print_liste_field_titre("Lastname",$_SERVER["PHP_SELF"],"p.name", $begin, "", "", $sortfield,$sortorder);
102  print_liste_field_titre("Firstname",$_SERVER["PHP_SELF"],"p.firstname", $begin, "", "", $sortfield,$sortorder);
103  print_liste_field_titre("Company",$_SERVER["PHP_SELF"],"s.nom", $begin, "", "", $sortfield,$sortorder);
104  print_liste_field_titre("Email");
105  print_liste_field_titre("Phone");
106  print "</tr>\n";
107 
108  $var=True;
109  $i = 0;
110  while ($i < min($num,$limit))
111  {
112  $obj = $db->fetch_object($result);
113 
114 
115 
116  print '<tr class="oddeven">';
117 
118  print '<td><a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$obj->cidp.'">'.img_object($langs->trans("ShowContact"),"contact").' '.$obj->lastname.'</a></td>';
119  print '<td>'.$obj->firstname.'</td>';
120  print '<td><a href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.'</a></td>';
121  print '<td>'.$obj->email.'</td>';
122  print '<td>'.$obj->phone.'</td>';
123 
124  print "</tr>\n";
125  $i++;
126  }
127  print "</table>";
128  $db->free($result);
129 
130 }
131 else
132 {
133  dol_print_error($db);
134 }
135 
136 
137 llxFooter();
138 
139 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='title_generic.png', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0)
Print a title with navigation controls for pagination.
if($_POST["cancel"]==$langs->trans("Cancel")&&!$id) if($action== 'setdatev'&&$user->rights->tax->charges->creer) if($action== 'add'&&$_POST["cancel"]<> $langs->trans("Cancel")) if($action== 'delete') $title
Actions.
Definition: card.php:183
llxHeader()
Empty header.
Definition: wrapper.php:46
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
print
Draft customers invoices.
Definition: index.php:91
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.