28require
'../main.inc.php';
31$langs->load(
"companies");
33$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
34$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
35$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
40 $sortfield =
"p.name";
45$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
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');
56$socid =
GETPOST(
'socid',
'int');
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,";
86if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
87 $sql .=
" ".MAIN_DB_PREFIX.
"societe_commerciaux as sc,";
89$sql .=
" ".MAIN_DB_PREFIX.
"socpeople as p";
90$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
91$sql .=
" WHERE s.fk_stcomm = st.id";
92$sql .=
" AND p.entity IN (".getEntity(
'contact').
")";
93if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
94 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
97 $sql .=
" AND s.client IN (1, 3)";
100 $sql .=
" AND s.client IN (2, 3)";
103 $sql .=
" AND s.fournisseur = 1";
106 $sql .=
" AND s.rowid = ".((int) $socid);
108if (!empty($search_lastname)) {
109 $sql .=
" AND p.name LIKE '%".$db->escape($search_lastname).
"%'";
111if (!empty($search_firstname)) {
112 $sql .=
" AND p.firstname LIKE '%".$db->escape($search_firstname).
"%'";
114if (!empty($search_company)) {
115 $sql .=
" AND s.nom LIKE '%".$db->escape($search_company).
"%'";
117if (!empty($contactname)) {
118 $sql .=
" AND (p.name LIKE '%".$db->escape($contactname).
"%' OR lower(p.firstname) LIKE '%".$db->escape($contactname).
"%') ";
119 $sortfield =
"p.name";
123$sql .= $db->order($sortfield, $sortorder);
124$sql .= $db->plimit($limit + 1, $offset);
126$resql = $db->query($sql);
128 $num = $db->num_rows($resql);
130 $param =
"&type=".$type;
132 $title = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"ListOfContacts") : $langs->trans(
"ListOfContactsAddresses"));
133 print_barre_liste($title.($label ?
" (".$label.
")" :
""), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
"", $num);
135 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?type='.
GETPOST(
"type",
"alpha").
'" method="GET">';
137 print
'<table class="liste centpercent">';
138 print
'<tr class="liste_titre">';
139 print_liste_field_titre(
"Lastname", $_SERVER[
"PHP_SELF"],
"p.name", $begin, $param,
"", $sortfield, $sortorder);
140 print_liste_field_titre(
"Firstname", $_SERVER[
"PHP_SELF"],
"p.firstname", $begin, $param,
"", $sortfield, $sortorder);
146 print
'<tr class="liste_titre">';
147 print
'<td class="liste_titre"><input class="flat" name="search_lastname" size="12" value="'.$search_lastname.
'"></td>';
148 print
'<td class="liste_titre"><input class="flat" name="search_firstname" size="12" value="'.$search_firstname.
'"></td>';
149 print
'<td class="liste_titre"><input class="flat" name="search_company" size="12" value="'.$search_company.
'"></td>';
150 print
'<td class="liste_titre"> </td>';
151 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>';
155 while ($i < min($num, $limit)) {
156 $obj = $db->fetch_object($resql);
158 print
'<tr class="oddeven">';
159 print
'<td><a href="'.DOL_URL_ROOT.
'/contact/card.php?id='.$obj->cidp.
'&socid='.$obj->rowid.
'">'.
img_object($langs->trans(
"ShowContact"),
"contact");
160 print
'</a> <a href="'.DOL_URL_ROOT.
'/contact/card.php?id='.$obj->cidp.
'&socid='.$obj->rowid.
'">'.$obj->name.
'</a></td>';
161 print
'<td>'.dol_escape_htmltag($obj->firstname).
'</td>';
163 print
'<td><a href="'.$_SERVER[
"PHP_SELF"].
'?type='.$type.
'&socid='.$obj->rowid.
'">'.
img_object($langs->trans(
"ShowCompany"),
"company").
'</a> ';
164 print
'<a href="'.$urlfiche.
"?socid=".$obj->rowid.
'">'.$obj->name.
"</a></td>\n";
166 print
'<td>'.dol_print_phone($obj->email, $obj->cidp, $obj->rowid,
'AC_EMAIL').
'</td>';
168 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.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $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='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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.