dolibarr  19.0.0-dev
clients.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
26 // Load Dolibarr environment
27 require '../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
30 
31 $action = GETPOST('action', 'aZ09');
32 
33 // Secrutiy check
34 if ($user->socid > 0) {
35  $action = '';
36  $socid = $user->socid;
37 }
38 
39 if (!$user->hasRight('facture', 'lire')) {
41 }
42 
43 // Load translation files required by the page
44 $langs->load("companies");
45 
46 $mode = GETPOST("mode");
47 
48 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
49 $sortfield = GETPOST('sortfield', 'aZ09comma');
50 $sortorder = GETPOST('sortorder', 'aZ09comma');
51 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
52 if (empty($page) || $page == -1) {
53  $page = 0;
54 } // If $page is not defined, or '' or -1
55 $offset = $limit * $page;
56 $pageprev = $page - 1;
57 $pagenext = $page + 1;
58 if (!$sortorder) {
59  $sortorder = "ASC";
60 }
61 if (!$sortfield) {
62  $sortfield = "nom";
63 }
64 
65 
66 /*
67  * View
68  */
69 
70 llxHeader();
71 
72 $thirdpartystatic = new Societe($db);
73 
74 if ($action == 'note') {
75  $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET note='".$db->escape($note)."' WHERE rowid=".((int) $socid);
76  $result = $db->query($sql);
77 }
78 
79 if ($mode == 'search') {
80  $resql = $db->query($sql);
81  if ($resql) {
82  if ($db->num_rows($resql) == 1) {
83  $obj = $db->fetch_object($resql);
84  $socid = $obj->rowid;
85  }
86  $db->free($resql);
87  }
88 }
89 
90 
91 
92 /*
93  * Mode List
94  */
95 
96 $sql = "SELECT s.rowid, s.nom as name, s.client, s.town, s.datec, s.datea";
97 $sql .= ", st.libelle as stcomm, s.prefix_comm, s.code_client, s.code_compta ";
98 if (empty($user->rights->societe->client->voir) && !$socid) {
99  $sql .= ", sc.fk_soc, sc.fk_user ";
100 }
101 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st";
102 if (empty($user->rights->societe->client->voir) && !$socid) {
103  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
104 }
105 $sql .= " WHERE s.fk_stcomm = st.id AND s.client in (1, 3)";
106 $sql .= " AND s.entity IN (".getEntity('societe').")";
107 if (empty($user->rights->societe->client->voir) && !$socid) {
108  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
109 }
110 if (dol_strlen($stcomm)) {
111  $sql .= " AND s.fk_stcomm=".((int) $stcomm);
112 }
113 if (GETPOST("search_nom")) {
114  $sql .= natural_search("s.nom", GETPOST("search_nom"));
115 }
116 if (GETPOST("search_compta")) {
117  $sql .= natural_search("s.code_compta", GETPOST("search_compta"));
118 }
119 if (GETPOST("search_code_client")) {
120  $sql .= natural_search("s.code_client", GETPOST("search_code_client"));
121 }
122 if ($socid) {
123  $sql .= " AND s.rowid = ".((int) $socid);
124 }
125 $sql .= " ORDER BY $sortfield $sortorder";
126 $sql .= $db->plimit($conf->liste_limit + 1, $offset);
127 //print $sql;
128 
129 $resql = $db->query($sql);
130 if ($resql) {
131  $num = $db->num_rows($resql);
132  $i = 0;
133 
134  $langs->load('commercial');
135 
136  print_barre_liste($langs->trans("Customers"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num);
137 
138  print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
139 
140  print '<table class="liste centpercent">';
141  print '<tr class="liste_titre">';
142 
143  print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", "", 'valign="center"', $sortfield, $sortorder);
144  print_liste_field_titre("Town", $_SERVER["PHP_SELF"], "s.town", "", "", 'valign="center"', $sortfield, $sortorder);
145  print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", "", "", '', $sortfield, $sortorder, 'left ');
146  print_liste_field_titre("AccountancyCode", $_SERVER["PHP_SELF"], "s.code_compta", "", "", '', $sortfield, $sortorder, 'left ');
147  print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "datec", $addu, "", '', $sortfield, $sortorder, 'right ');
148  print "</tr>\n";
149 
150  // Fields title search
151  print '<tr class="liste_titre">';
152 
153  print '<td class="liste_titre left">';
154  print '<input class="flat" type="text" name="search_nom" value="'.$_GET["search_nom"].'"></td>';
155 
156  print '<td class="liste_titre">&nbsp;</td>';
157 
158  print '<td class="liste_titre left">';
159  print '<input class="flat" type="text" size="10" name="search_code_client" value="'.$_GET["search_code_client"].'">';
160  print '</td>';
161 
162  print '<td class="liste_titre left">';
163  print '<input class="flat" type="text" size="10" name="search_compta" value="'.$_GET["search_compta"].'">';
164  print '</td>';
165 
166  print '<td colspan="2" class="liste_titre right">';
167  print '<input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"), 'search.png', '', '', 1).'" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
168  print '</td>';
169  print "</tr>\n";
170 
171  while ($i < min($num, $conf->liste_limit)) {
172  $obj = $db->fetch_object($resql);
173 
174  print '<tr class="oddeven">';
175  print '<td>';
176  $thirdpartystatic->id = $obj->rowid;
177  $thirdpartystatic->name = $obj->name;
178  $thirdpartystatic->client = $obj->client;
179  print $thirdpartystatic->getNomUrl(1, 'compta');
180  print '</td>';
181  print '<td>'.$obj->town.'&nbsp;</td>';
182  print '<td class="left">'.$obj->code_client.'&nbsp;</td>';
183  print '<td class="left">'.$obj->code_compta.'&nbsp;</td>';
184  print '<td class="right">'.dol_print_date($db->jdate($obj->datec)).'</td>';
185  print "</tr>\n";
186  $i++;
187  }
188  print "</table>";
189 
190  print '</form>';
191 
192  $db->free($resql);
193 } else {
194  dol_print_error($db);
195 }
196 
197 llxFooter();
198 $db->close();
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage third parties objects (customers, suppliers, prospects...)
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.