28require
'../main.inc.php';
31$langs->load(
"companies");
33$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
34$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
40 $sortfield =
"p.name";
46$offset = $limit * $page;
48$type =
GETPOST(
'type',
'alpha');
50$search_firstname =
GETPOST(
'search_firstname') ?
GETPOST(
'search_firstname') :
GETPOST(
'search_firstname');
52$contactname =
GETPOST(
'contactname');
53$begin =
GETPOST(
'begin',
'alpha');
59 $socid = $user->socid;
70if ($type ==
"c" || $type ==
"p") {
71 $label = $langs->trans(
"Customers");
72 $urlfiche =
"card.php";
75 $label = $langs->trans(
"Suppliers");
76 $urlfiche =
"card.php";
83$sql =
"SELECT s.rowid, s.nom as name, st.libelle as stcomm,";
84$sql .=
" p.rowid as cidp, p.name, p.firstname, p.email, p.phone";
85$sql .=
" FROM ".MAIN_DB_PREFIX.
"c_stcomm as st,";
86$sql .=
" ".MAIN_DB_PREFIX.
"socpeople as p";
87$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
88$sql .=
" WHERE s.fk_stcomm = st.id";
89$sql .=
" AND p.entity IN (".getEntity(
'contact').
")";
91 $sql .=
" AND s.client IN (1, 3)";
94 $sql .=
" AND s.client IN (2, 3)";
97 $sql .=
" AND s.fournisseur = 1";
99if (!empty($search_lastname)) {
100 $sql .=
" AND p.name LIKE '%".$db->escape($search_lastname).
"%'";
102if (!empty($search_firstname)) {
103 $sql .=
" AND p.firstname LIKE '%".$db->escape($search_firstname).
"%'";
105if (!empty($search_company)) {
106 $sql .=
" AND s.nom LIKE '%".$db->escape($search_company).
"%'";
108if (!empty($contactname)) {
109 $sql .=
" AND (p.name LIKE '%".$db->escape($contactname).
"%' OR lower(p.firstname) LIKE '%".$db->escape($contactname).
"%') ";
110 $sortfield =
"p.name";
115if (!$user->hasRight(
'societe',
'client',
'voir')) {
116 $search_sale = $user->id;
119if ($search_sale && $search_sale !=
'-1') {
120 if ($search_sale == -2) {
121 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc)";
122 } elseif ($search_sale > 0) {
123 $sql .=
" AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc AND sc.fk_user = ".((int) $search_sale).
")";
128 $sql .=
" AND p.fk_soc = ".((int) $socid);
131$sql .= $db->order($sortfield, $sortorder);
132$sql .= $db->plimit($limit + 1, $offset);
134$resql = $db->query($sql);
136 $num = $db->num_rows($resql);
138 $param =
"&type=".$type;
140 $title = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"ListOfContacts") : $langs->trans(
"ListOfContactsAddresses"));
141 print_barre_liste($title.($label ?
" (".$label.
")" :
""), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
"", $num);
143 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?type='.
GETPOST(
"type",
"alpha").
'" method="GET">';
145 print
'<table class="liste centpercent">';
146 print
'<tr class="liste_titre">';
147 print_liste_field_titre(
"Lastname", $_SERVER[
"PHP_SELF"],
"p.name", $begin, $param,
"", $sortfield, $sortorder);
148 print_liste_field_titre(
"Firstname", $_SERVER[
"PHP_SELF"],
"p.firstname", $begin, $param,
"", $sortfield, $sortorder);
154 print
'<tr class="liste_titre">';
155 print
'<td class="liste_titre"><input class="flat" name="search_lastname" size="12" value="'.$search_lastname.
'"></td>';
156 print
'<td class="liste_titre"><input class="flat" name="search_firstname" size="12" value="'.$search_firstname.
'"></td>';
157 print
'<td class="liste_titre"><input class="flat" name="search_company" size="12" value="'.$search_company.
'"></td>';
158 print
'<td class="liste_titre"> </td>';
159 print
'<td class="liste_titre right"><input type="image" class="liste_titre" src="'.img_picto($langs->trans(
"Search"),
'search.png',
'',
'', 1).
'" value="'.
dol_escape_htmltag($langs->trans(
"Search")).
'" title="'.
dol_escape_htmltag($langs->trans(
"Search")).
'"></td>';
163 while ($i < min($num, $limit)) {
164 $obj = $db->fetch_object($resql);
166 print
'<tr class="oddeven">';
167 print
'<td><a href="'.DOL_URL_ROOT.
'/contact/card.php?id='.$obj->cidp.
'&socid='.$obj->rowid.
'">'.
img_object($langs->trans(
"ShowContact"),
"contact");
168 print
'</a> <a href="'.DOL_URL_ROOT.
'/contact/card.php?id='.$obj->cidp.
'&socid='.$obj->rowid.
'">'.$obj->name.
'</a></td>';
169 print
'<td>'.dol_escape_htmltag($obj->firstname).
'</td>';
171 print
'<td><a href="'.$_SERVER[
"PHP_SELF"].
'?type='.$type.
'&socid='.$obj->rowid.
'">'.
img_object($langs->trans(
"ShowCompany"),
"company").
'</a> ';
172 print
'<a href="'.$urlfiche.
"?socid=".$obj->rowid.
'">'.$obj->name.
"</a></td>\n";
174 print
'<td>'.dol_print_phone($obj->email, $obj->cidp, $obj->rowid,
'AC_EMAIL').
'</td>';
176 print
'<td>'.dol_print_phone($obj->phone, $obj->country_code, $obj->cidp, $obj->rowid,
'AC_TEL').
' </td>';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
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.
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 dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.