30require
'../main.inc.php';
41$langs->load(
"companies");
43$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
44$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
50 $sortfield =
"p.lastname";
56$offset = $limit * $page;
58$type =
GETPOST(
'type',
'alpha');
60$search_firstname =
GETPOST(
'search_firstname') ?
GETPOST(
'search_firstname') :
GETPOST(
'search_firstname');
62$contactname =
GETPOST(
'contactname');
63$begin =
GETPOST(
'begin',
'alpha');
69 $socid = $user->socid;
72$hookmanager->initHooks(array(
'contactlist'));
84$label = $langs->trans(
"Unknown");
86if ($type ==
"c" || $type ==
"p") {
87 $label = $langs->trans(
"Customers");
88 $urlfiche =
"card.php";
91 $label = $langs->trans(
"Suppliers");
92 $urlfiche =
"card.php";
99$sql =
"SELECT s.rowid, s.nom as name, st.libelle as stcomm,";
100$sql .=
" p.rowid as cidp, p.lastname, p.firstname, p.email, p.phone";
101$sql .=
" FROM ".MAIN_DB_PREFIX.
"c_stcomm as st,";
102$sql .=
" ".MAIN_DB_PREFIX.
"socpeople as p";
103$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
104$sql .=
" WHERE s.fk_stcomm = st.id";
105$sql .=
" AND p.entity IN (".getEntity(
'contact').
")";
107 $sql .=
" AND s.client IN (1, 3)";
110 $sql .=
" AND s.client IN (2, 3)";
113 $sql .=
" AND s.fournisseur = 1";
115if (!empty($search_lastname)) {
116 $sql .=
" AND p.lastname LIKE '%".$db->escape($search_lastname).
"%'";
118if (!empty($search_firstname)) {
119 $sql .=
" AND p.firstname LIKE '%".$db->escape($search_firstname).
"%'";
121if (!empty($search_company)) {
122 $sql .=
" AND s.nom LIKE '%".$db->escape($search_company).
"%'";
124if (!empty($contactname)) {
125 $sql .=
" AND (p.lastname LIKE '%".$db->escape($contactname).
"%' OR p.firstname LIKE '%".
$db->escape($contactname).
"%') ";
126 $sortfield =
"p.lastname";
131if (!$user->hasRight(
'societe',
'client',
'voir')) {
132 $search_sale = $user->id;
135if ($search_sale && $search_sale !=
'-1') {
136 if ($search_sale == -2) {
137 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc)";
138 } elseif ($search_sale > 0) {
139 $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).
")";
144 $sql .=
" AND p.fk_soc = ".((int) $socid);
147$sql .=
$db->order($sortfield, $sortorder);
148$sql .=
$db->plimit($limit + 1, $offset);
150$resql =
$db->query($sql);
152 $num =
$db->num_rows($resql);
154 $param =
"&type=".$type;
156 $title = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"ListOfContacts") : $langs->trans(
"ListOfContactsAddresses"));
157 print_barre_liste($title.($label ?
" (".$label.
")" :
""), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
"", $num);
159 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?type='.
GETPOST(
"type",
"alpha").
'" method="GET">';
161 print
'<table class="liste centpercent">';
162 print
'<tr class="liste_titre">';
163 print_liste_field_titre(
"Lastname", $_SERVER[
"PHP_SELF"],
"p.lastname", $begin, $param,
"", $sortfield, $sortorder);
164 print_liste_field_titre(
"Firstname", $_SERVER[
"PHP_SELF"],
"p.firstname", $begin, $param,
"", $sortfield, $sortorder);
170 print
'<tr class="liste_titre">';
171 print
'<td class="liste_titre"><input class="flat" name="search_lastname" size="12" value="'.$search_lastname.
'"></td>';
172 print
'<td class="liste_titre"><input class="flat" name="search_firstname" size="12" value="'.$search_firstname.
'"></td>';
173 print
'<td class="liste_titre"><input class="flat" name="search_company" size="12" value="'.$search_company.
'"></td>';
174 print
'<td class="liste_titre"> </td>';
175 print
'<td class="liste_titre right"><input type="image" class="liste_titre" src="'.img_picto($langs->trans(
"Search"),
'search.png',
'', 0, 1).
'" value="'.
dol_escape_htmltag($langs->trans(
"Search")).
'" title="'.
dol_escape_htmltag($langs->trans(
"Search")).
'"></td>';
179 while ($i < min($num, $limit)) {
180 $obj =
$db->fetch_object($resql);
182 print
'<tr class="oddeven">';
183 print
'<td><a href="'.DOL_URL_ROOT.
'/contact/card.php?id='.$obj->cidp.
'&socid='.$obj->rowid.
'">'.
img_object($langs->trans(
"ShowContact"),
"contact");
184 print
'</a> <a href="'.DOL_URL_ROOT.
'/contact/card.php?id='.$obj->cidp.
'&socid='.$obj->rowid.
'">'.$obj->name.
'</a></td>';
185 print
'<td>'.dol_escape_htmltag($obj->firstname).
'</td>';
187 print
'<td><a href="'.$_SERVER[
"PHP_SELF"].
'?type='.$type.
'&socid='.$obj->rowid.
'">'.
img_object($langs->trans(
"ShowCompany"),
"company").
'</a> ';
188 print
'<a href="'.$urlfiche.
"?socid=".$obj->rowid.
'">'.$obj->name.
"</a></td>\n";
190 print
'<td>'.dol_print_email($obj->email, $obj->cidp, $obj->rowid,
'AC_EMAIL').
'</td>';
192 print
'<td>'.dol_print_phone($obj->phone, $obj->country_code, $obj->cidp, $obj->rowid,
'AC_TEL').
' </td>';
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
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.
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.