27require
'../main.inc.php';
29$langs->load(
"companies");
39if ($user->socid > 0) {
41 $socid = $user->socid;
45$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
46$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
48if (empty($page) || $page == -1) {
51$offset = $limit * $page;
58 $sortfield =
"p.name";
67$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";
68if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
69 $sql .=
", sc.fk_soc, sc.fk_user ";
71$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"socpeople as p, ".MAIN_DB_PREFIX.
"c_stcomm as st";
72if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
73 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
75$sql .=
" WHERE s.fk_stcomm = st.id";
76$sql .=
" AND s.fournisseur = 1";
77$sql .=
" AND s.rowid = p.fk_soc";
78$sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
79if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
80 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
84 $sql .=
" AND s.fk_stcomm=$stcomm";
88 $sql .=
" AND p.name LIKE '$begin%'";
92 $sql .=
" AND p.name LIKE '%".strtolower($contactname).
"%'";
93 $sortfield =
"p.name";
98 $sql .=
" AND s.rowid = ".((int) $socid);
101$sql .=
" ORDER BY $sortfield $sortorder ";
102$sql .= $db->plimit($limit, $offset);
104$result = $db->query($sql);
106 $num = $db->num_rows($result);
108 $title = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"ListOfContacts") : $langs->trans(
"ListOfContactsAddresses"));
109 print_barre_liste($title.
" (".$langs->trans(
"Suppliers").
")", $page, $_SERVER[
"PHP_SELF"],
"", $sortfield, $sortorder,
"", $num);
111 print
'<table class="liste centpercent">';
112 print
'<tr class="liste_titre">';
114 print_liste_field_titre(
"Firstname", $_SERVER[
"PHP_SELF"],
"p.firstname", $begin,
"",
"", $sortfield, $sortorder);
121 while ($i < min($num, $limit)) {
122 $obj = $db->fetch_object($result);
124 print
'<tr class="oddeven">';
126 print
'<td><a href="'.DOL_URL_ROOT.
'/contact/card.php?id='.$obj->cidp.
'">'.
img_object($langs->trans(
"ShowContact"),
"contact").
' '.$obj->lastname.
'</a></td>';
127 print
'<td>'.$obj->firstname.
'</td>';
128 print
'<td><a href="'.DOL_URL_ROOT.
'/fourn/card.php?socid='.$obj->socid.
'">'.
img_object($langs->trans(
"ShowCompany"),
"company").
' '.$obj->name.
'</a></td>';
129 print
'<td>'.$obj->email.
'</td>';
130 print
'<td>'.$obj->phone.
'</td>';
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $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, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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.