dolibarr 22.0.5
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@inodbox.com>
5 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28// Load Dolibarr environment
29require '../main.inc.php';
30
39$langs->load("companies");
40
41
42/*
43 * View
44 */
45
46llxHeader();
47
48// Security check
49if ($user->socid > 0) {
50 $action = '';
51 $socid = $user->socid;
52}
53
54$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
55$sortfield = GETPOST('sortfield', 'aZ09comma');
56$sortorder = GETPOST('sortorder', 'aZ09comma');
57$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
58if (empty($page) || $page == -1) {
59 $page = 0;
60} // If $page is not defined, or '' or -1
61$offset = $limit * $page;
62$pageprev = $page - 1;
63$pagenext = $page + 1;
64if (!$sortorder) {
65 $sortorder = "ASC";
66}
67if (!$sortfield) {
68 $sortfield = "p.lastname";
69}
70$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
71$begin = '';
72
73
74/*
75 * List mode
76 */
77
78$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";
79if (!$user->hasRight("societe", "client", "voir") && !$socid) {
80 $sql .= ", sc.fk_soc, sc.fk_user ";
81}
82$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."socpeople as p, ".MAIN_DB_PREFIX."c_stcomm as st";
83if (!$user->hasRight("societe", "client", "voir") && !$socid) {
84 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
85}
86$sql .= " WHERE s.fk_stcomm = st.id";
87$sql .= " AND s.fournisseur = 1";
88$sql .= " AND s.rowid = p.fk_soc";
89$sql .= " AND s.entity IN (".getEntity('societe').")";
90if (!$user->hasRight("societe", "client", "voir") && !$socid) {
91 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
92}
93
94/*
95if (dol_strlen($stcomm)) {
96 $sql .= " AND s.fk_stcomm = ".((int) $stcomm);
97}
98if (dol_strlen($begin)) {
99 $sql .= " AND p.lastname LIKE '".$db->escape($begin)."%'";
100}
101if ($contactname) {
102 $sql .= " AND p.lastname LIKE '%".$db->escape($contactname)."%'";
103 $sortfield = "p.lastname";
104 $sortorder = "ASC";
105}
106*/
107if ($socid) {
108 $sql .= " AND s.rowid = ".((int) $socid);
109}
110
111$sql .= " ORDER BY $sortfield $sortorder";
112$sql .= $db->plimit($limit, $offset);
113
114$result = $db->query($sql);
115if ($result) {
116 $num = $db->num_rows($result);
117
118 $title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses"));
119 print_barre_liste($title." (".$langs->trans("Suppliers").")", $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num);
120
121 print '<table class="liste centpercent">';
122 print '<tr class="liste_titre">';
123 print_liste_field_titre("Lastname", $_SERVER["PHP_SELF"], "p.lastname", $begin, "", "", $sortfield, $sortorder);
124 print_liste_field_titre("Firstname", $_SERVER["PHP_SELF"], "p.firstname", $begin, "", "", $sortfield, $sortorder);
125 print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", $begin, "", "", $sortfield, $sortorder);
128 print "</tr>\n";
129
130 $i = 0;
131 while ($i < min($num, $limit)) {
132 $obj = $db->fetch_object($result);
133
134 print '<tr class="oddeven">';
135
136 print '<td><a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$obj->cidp.'">'.img_object($langs->trans("ShowContact"), "contact").' '.$obj->lastname.'</a></td>';
137 print '<td>'.$obj->firstname.'</td>';
138 print '<td><a href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"), "company").' '.$obj->name.'</a></td>';
139 print '<td>'.$obj->email.'</td>';
140 print '<td>'.$obj->phone.'</td>';
141
142 print "</tr>\n";
143 $i++;
144 }
145 print "</table>";
146 $db->free($result);
147} else {
148 dol_print_error($db);
149}
150
151// End of page
152llxFooter();
153$db->close();
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79