dolibarr  13.0.2
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 require '../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
29 
30 $action = GETPOST('action', 'aZ09');
31 
32 // Secrutiy check
33 if ($user->socid > 0)
34 {
35  $action = '';
36  $socid = $user->socid;
37 }
38 
39 if (!$user->rights->facture->lire)
41 
42 // Load translation files required by the page
43 $langs->load("companies");
44 
45 $mode = GETPOST("mode");
46 
47 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
48 $sortfield = GETPOST("sortfield", 'alpha');
49 $sortorder = GETPOST("sortorder", 'alpha');
50 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
51 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
52 $offset = $limit * $page;
53 $pageprev = $page - 1;
54 $pagenext = $page + 1;
55 if (!$sortorder) $sortorder = "ASC";
56 if (!$sortfield) $sortfield = "nom";
57 
58 
59 /*
60  * View
61  */
62 
63 llxHeader();
64 
65 $thirdpartystatic = new Societe($db);
66 
67 if ($action == 'note')
68 {
69  $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET note='".$db->escape($note)."' WHERE rowid=".$socid;
70  $result = $db->query($sql);
71 }
72 
73 if ($mode == 'search')
74 {
75  $resql = $db->query($sql);
76  if ($resql) {
77  if ($db->num_rows($resql) == 1) {
78  $obj = $db->fetch_object($resql);
79  $socid = $obj->rowid;
80  }
81  $db->free($resql);
82  }
83 }
84 
85 
86 
87 /*
88  * Mode List
89  */
90 
91 $sql = "SELECT s.rowid, s.nom as name, s.client, s.town, s.datec, s.datea";
92 $sql .= ", st.libelle as stcomm, s.prefix_comm, s.code_client, s.code_compta ";
93 if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
94 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st";
95 if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
96 $sql .= " WHERE s.fk_stcomm = st.id AND s.client in (1, 3)";
97 $sql .= " AND s.entity IN (".getEntity('societe').")";
98 if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
99 if (dol_strlen($stcomm))
100 {
101  $sql .= " AND s.fk_stcomm=".$stcomm;
102 }
103 if ($socname)
104 {
105  $sql .= natural_search("s.nom", $socname);
106  $sortfield = "s.nom";
107  $sortorder = "ASC";
108 }
109 if ($_GET["search_nom"])
110 {
111  $sql .= natural_search("s.nom", GETPOST("search_nom"));
112 }
113 if ($_GET["search_compta"])
114 {
115  $sql .= natural_search("s.code_compta", GETPOST("search_compta"));
116 }
117 if ($_GET["search_code_client"])
118 {
119  $sql .= natural_search("s.code_client", GETPOST("search_code_client"));
120 }
121 if (dol_strlen($begin))
122 {
123  $sql .= natural_search("s.nom", $begin);
124 }
125 if ($socid)
126 {
127  $sql .= " AND s.rowid = ".$socid;
128 }
129 $sql .= " ORDER BY $sortfield $sortorder ";
130 $sql .= $db->plimit($conf->liste_limit + 1, $offset);
131 //print $sql;
132 
133 $resql = $db->query($sql);
134 if ($resql)
135 {
136  $num = $db->num_rows($resql);
137  $i = 0;
138 
139  $langs->load('commercial');
140 
141  print_barre_liste($langs->trans("ListOfCustomers"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num);
142 
143  print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
144 
145  print '<table class="liste centpercent">';
146  print '<tr class="liste_titre">';
147 
148  print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", "", 'valign="center"', $sortfield, $sortorder);
149  print_liste_field_titre("Town", $_SERVER["PHP_SELF"], "s.town", "", "", 'valign="center"', $sortfield, $sortorder);
150  print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", "", "", '', $sortfield, $sortorder, 'left ');
151  print_liste_field_titre("AccountancyCode", $_SERVER["PHP_SELF"], "s.code_compta", "", "", '', $sortfield, $sortorder, 'left ');
152  print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "datec", $addu, "", '', $sortfield, $sortorder, 'right ');
153  print "</tr>\n";
154 
155  // Fields title search
156  print '<tr class="liste_titre">';
157 
158  print '<td class="liste_titre left">';
159  print '<input class="flat" type="text" name="search_nom" value="'.$_GET["search_nom"].'"></td>';
160 
161  print '<td class="liste_titre">&nbsp;</td>';
162 
163  print '<td class="liste_titre left">';
164  print '<input class="flat" type="text" size="10" name="search_code_client" value="'.$_GET["search_code_client"].'">';
165  print '</td>';
166 
167  print '<td class="liste_titre left">';
168  print '<input class="flat" type="text" size="10" name="search_compta" value="'.$_GET["search_compta"].'">';
169  print '</td>';
170 
171  print '<td colspan="2" class="liste_titre right">';
172  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")).'">';
173  print '</td>';
174  print "</tr>\n";
175 
176  while ($i < min($num, $conf->liste_limit))
177  {
178  $obj = $db->fetch_object($resql);
179 
180  print '<tr class="oddeven">';
181  print '<td>';
182  $thirdpartystatic->id = $obj->rowid;
183  $thirdpartystatic->name = $obj->name;
184  $thirdpartystatic->client = $obj->client;
185  print $thirdpartystatic->getNomUrl(1, 'compta');
186  print '</td>';
187  print '<td>'.$obj->town.'&nbsp;</td>';
188  print '<td class="left">'.$obj->code_client.'&nbsp;</td>';
189  print '<td class="left">'.$obj->code_compta.'&nbsp;</td>';
190  print '<td class="right">'.dol_print_date($db->jdate($obj->datec)).'</td>';
191  print "</tr>\n";
192  $i++;
193  }
194  print "</table>";
195 
196  print '</form>';
197 
198  $db->free($resql);
199 } else {
200  dol_print_error($db);
201 }
202 
203 llxFooter();
204 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
llxHeader()
Empty header.
Definition: wrapper.php:45
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.
Class to manage third parties objects (customers, suppliers, prospects...)
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.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
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...
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
Definition: index.php:89
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.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
llxFooter()
Empty footer.
Definition: wrapper.php:59
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...