27 require
'../main.inc.php';
30 $langs->load(
"companies");
32 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
33 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
35 if (!$sortorder) $sortorder =
"ASC";
36 if (!$sortfield) $sortfield =
"p.name";
37 if ($page < 0) { $page = 0; }
38 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
39 $offset = $limit * $page;
41 $type =
GETPOST(
'type',
'alpha');
43 $search_firstname =
GETPOST(
'search_firstname') ?
GETPOST(
'search_firstname') :
GETPOST(
'search_firstname');
45 $contactname =
GETPOST(
'contactname');
46 $begin =
GETPOST(
'begin',
'alpha');
49 $socid =
GETPOST(
'socid',
'int');
50 if ($user->socid) $socid = $user->socid;
60 if ($type ==
"c" || $type ==
"p")
62 $label = $langs->trans(
"Customers");
63 $urlfiche =
"card.php";
67 $label = $langs->trans(
"Suppliers");
68 $urlfiche =
"card.php";
75 $sql =
"SELECT s.rowid, s.nom as name, st.libelle as stcomm";
76 $sql .=
", p.rowid as cidp, p.name, p.firstname, p.email, p.phone";
77 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_stcomm as st,";
78 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" ".MAIN_DB_PREFIX.
"societe_commerciaux as sc,";
79 $sql .=
" ".MAIN_DB_PREFIX.
"socpeople as p";
80 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = p.fk_soc";
81 $sql .=
" WHERE s.fk_stcomm = st.id";
82 $sql .=
" AND p.entity IN (".getEntity(
'socpeople').
")";
83 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
84 if ($type ==
"c") $sql .=
" AND s.client IN (1, 3)";
85 if ($type ==
"p") $sql .=
" AND s.client IN (2, 3)";
86 if ($type ==
"f") $sql .=
" AND s.fournisseur = 1";
87 if ($socid) $sql .=
" AND s.rowid = ".$socid;
91 $sql .=
" AND s.fk_stcomm=".$db->escape($stcomm);
94 if (!empty($search_lastname))
96 $sql .=
" AND p.name LIKE '%".$db->escape($search_lastname).
"%'";
99 if (!empty($search_firstname))
101 $sql .=
" AND p.firstname LIKE '%".$db->escape($search_firstname).
"%'";
104 if (!empty($search_company))
106 $sql .=
" AND s.nom LIKE '%".$db->escape($search_company).
"%'";
109 if (!empty($contactname))
111 $sql .=
" AND (p.name LIKE '%".$db->escape($contactname).
"%' OR lower(p.firstname) LIKE '%".$db->escape($contactname).
"%') ";
112 $sortfield =
"p.name";
116 $sql .= $db->order($sortfield, $sortorder);
117 $sql .= $db->plimit($limit + 1, $offset);
119 $resql = $db->query($sql);
122 $num = $db->num_rows(
$resql);
124 $param =
"&type=".$type;
126 $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"ListOfContacts") : $langs->trans(
"ListOfContactsAddresses"));
127 print_barre_liste($title.($label ?
" (".$label.
")" :
""), $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
"", $num);
129 print '<form action="'.$_SERVER[
"PHP_SELF"].
'?type='.
GETPOST(
"type",
"alpha").
'" method="GET">';
131 print '<table class="liste centpercent">';
132 print '<tr class="liste_titre">';
133 print_liste_field_titre(
"Lastname", $_SERVER[
"PHP_SELF"],
"p.name", $begin, $param,
"", $sortfield, $sortorder);
134 print_liste_field_titre(
"Firstname", $_SERVER[
"PHP_SELF"],
"p.firstname", $begin, $param,
"", $sortfield, $sortorder);
140 print '<tr class="liste_titre">';
141 print '<td class="liste_titre"><input class="flat" name="search_lastname" size="12" value="'.$search_lastname.
'"></td>';
142 print '<td class="liste_titre"><input class="flat" name="search_firstname" size="12" value="'.$search_firstname.
'"></td>';
143 print '<td class="liste_titre"><input class="flat" name="search_company" size="12" value="'.$search_company.
'"></td>';
144 print '<td class="liste_titre"> </td>';
145 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>';
149 while ($i < min($num, $limit))
151 $obj = $db->fetch_object(
$resql);
153 print '<tr class="oddeven">';
154 print '<td><a href="'.DOL_URL_ROOT.
'/contact/card.php?id='.$obj->cidp.
'&socid='.$obj->rowid.
'">'.
img_object($langs->trans(
"ShowContact"),
"contact");
155 print '</a> <a href="'.DOL_URL_ROOT.
'/contact/card.php?id='.$obj->cidp.
'&socid='.$obj->rowid.
'">'.$obj->name.
'</a></td>';
156 print "<td>$obj->firstname</TD>";
158 print '<td><a href="'.$_SERVER[
"PHP_SELF"].
'?type='.$type.
'&socid='.$obj->rowid.
'">'.
img_object($langs->trans(
"ShowCompany"),
"company").
'</a> ';
159 print "<a href=\"".$urlfiche.
"?socid=".$obj->rowid.
"\">$obj->name</a></td>\n";
161 print '<td>'.dol_print_phone($obj->email, $obj->cidp, $obj->rowid,
'AC_EMAIL').
'</td>';
163 print '<td>'.dol_print_phone($obj->phone, $obj->country_code, $obj->cidp, $obj->rowid,
'AC_TEL').
' </td>';
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...