Go to the documentation of this file.
27 require
'../main.inc.php';
30 $langs->load(
"companies");
32 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
33 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
39 $sortfield =
"p.name";
44 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
45 $offset = $limit * $page;
47 $type =
GETPOST(
'type',
'alpha');
49 $search_firstname =
GETPOST(
'search_firstname') ?
GETPOST(
'search_firstname') :
GETPOST(
'search_firstname');
51 $contactname =
GETPOST(
'contactname');
52 $begin =
GETPOST(
'begin',
'alpha');
55 $socid =
GETPOST(
'socid',
'int');
58 $socid = $user->socid;
69 if ($type ==
"c" || $type ==
"p") {
70 $label = $langs->trans(
"Customers");
71 $urlfiche =
"card.php";
74 $label = $langs->trans(
"Suppliers");
75 $urlfiche =
"card.php";
82 $sql =
"SELECT s.rowid, s.nom as name, st.libelle as stcomm";
83 $sql .=
", p.rowid as cidp, p.name, p.firstname, p.email, p.phone";
84 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_stcomm as st,";
85 if (empty($user->rights->societe->client->voir) && !$socid) {
86 $sql .=
" ".MAIN_DB_PREFIX.
"societe_commerciaux as sc,";
88 $sql .=
" ".MAIN_DB_PREFIX.
"socpeople as p";
89 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
90 $sql .=
" WHERE s.fk_stcomm = st.id";
91 $sql .=
" AND p.entity IN (".getEntity(
'contact').
")";
92 if (empty($user->rights->societe->client->voir) && !$socid) {
93 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
96 $sql .=
" AND s.client IN (1, 3)";
99 $sql .=
" AND s.client IN (2, 3)";
102 $sql .=
" AND s.fournisseur = 1";
105 $sql .=
" AND s.rowid = ".((int) $socid);
107 if (!empty($search_lastname)) {
108 $sql .=
" AND p.name LIKE '%".$db->escape($search_lastname).
"%'";
110 if (!empty($search_firstname)) {
111 $sql .=
" AND p.firstname LIKE '%".$db->escape($search_firstname).
"%'";
113 if (!empty($search_company)) {
114 $sql .=
" AND s.nom LIKE '%".$db->escape($search_company).
"%'";
116 if (!empty($contactname)) {
117 $sql .=
" AND (p.name LIKE '%".$db->escape($contactname).
"%' OR lower(p.firstname) LIKE '%".$db->escape($contactname).
"%') ";
118 $sortfield =
"p.name";
122 $sql .= $db->order($sortfield, $sortorder);
123 $sql .= $db->plimit($limit + 1, $offset);
125 $resql = $db->query($sql);
127 $num = $db->num_rows(
$resql);
129 $param =
"&type=".$type;
131 $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"ListOfContacts") : $langs->trans(
"ListOfContactsAddresses"));
132 print_barre_liste($title.($label ?
" (".$label.
")" :
""), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
"", $num);
134 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?type='.
GETPOST(
"type",
"alpha").
'" method="GET">';
136 print
'<table class="liste centpercent">';
137 print
'<tr class="liste_titre">';
138 print_liste_field_titre(
"Lastname", $_SERVER[
"PHP_SELF"],
"p.name", $begin, $param,
"", $sortfield, $sortorder);
139 print_liste_field_titre(
"Firstname", $_SERVER[
"PHP_SELF"],
"p.firstname", $begin, $param,
"", $sortfield, $sortorder);
145 print
'<tr class="liste_titre">';
146 print
'<td class="liste_titre"><input class="flat" name="search_lastname" size="12" value="'.$search_lastname.
'"></td>';
147 print
'<td class="liste_titre"><input class="flat" name="search_firstname" size="12" value="'.$search_firstname.
'"></td>';
148 print
'<td class="liste_titre"><input class="flat" name="search_company" size="12" value="'.$search_company.
'"></td>';
149 print
'<td class="liste_titre"> </td>';
150 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>';
154 while ($i < min($num, $limit)) {
155 $obj = $db->fetch_object(
$resql);
157 print
'<tr class="oddeven">';
158 print
'<td><a href="'.DOL_URL_ROOT.
'/contact/card.php?id='.$obj->cidp.
'&socid='.$obj->rowid.
'">'.
img_object($langs->trans(
"ShowContact"),
"contact");
159 print
'</a> <a href="'.DOL_URL_ROOT.
'/contact/card.php?id='.$obj->cidp.
'&socid='.$obj->rowid.
'">'.$obj->name.
'</a></td>';
160 print
'<td>'.dol_escape_htmltag($obj->firstname).
'</td>';
162 print
'<td><a href="'.$_SERVER[
"PHP_SELF"].
'?type='.$type.
'&socid='.$obj->rowid.
'">'.
img_object($langs->trans(
"ShowCompany"),
"company").
'</a> ';
163 print
'<a href="'.$urlfiche.
"?socid=".$obj->rowid.
'">'.$obj->name.
"</a></td>\n";
165 print
'<td>'.dol_print_phone($obj->email, $obj->cidp, $obj->rowid,
'AC_EMAIL').
'</td>';
167 print
'<td>'.dol_print_phone($obj->phone, $obj->country_code, $obj->cidp, $obj->rowid,
'AC_TEL').
' </td>';
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
restrictedArea($user, $features, $objectid=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.
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='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.