dolibarr  7.0.0-beta
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@capnetworks.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 <http://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->societe_id > 0)
34 {
35  $action = '';
36  $socid = $user->societe_id;
37 }
38 
39 if (! $user->rights->facture->lire)
41 
42 
43 $langs->load("companies");
44 
45 $mode=GETPOST("mode");
46 
47 $sortfield = GETPOST("sortfield",'alpha');
48 $sortorder = GETPOST("sortorder",'alpha');
49 $page = GETPOST("page",'int');
50 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
51 $offset = $conf->liste_limit * $page;
52 $pageprev = $page - 1;
53 $pagenext = $page + 1;
54 if (! $sortorder) $sortorder="ASC";
55 if (! $sortfield) $sortfield="nom";
56 
57 
58 /*
59  * View
60  */
61 
62 llxHeader();
63 
64 $thirdpartystatic=new Societe($db);
65 
66 if ($action == 'note')
67 {
68  $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET note='".$note."' WHERE rowid=".$socid;
69  $result = $db->query($sql);
70 }
71 
72 if ($mode == 'search')
73 {
74  $resql=$db->query($sql);
75  if ($resql) {
76  if ( $db->num_rows($resql) == 1) {
77  $obj = $db->fetch_object($resql);
78  $socid = $obj->rowid;
79  }
80  $db->free($resql);
81  }
82 }
83 
84 
85 
86 /*
87  * Mode List
88  */
89 
90 $sql = "SELECT s.rowid, s.nom as name, s.client, s.town, s.datec, s.datea";
91 $sql.= ", st.libelle as stcomm, s.prefix_comm, s.code_client, s.code_compta ";
92 if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user ";
93 $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st";
94 if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
95 $sql.= " WHERE s.fk_stcomm = st.id AND s.client in (1, 3)";
96 $sql.= " AND s.entity IN (".getEntity('societe').")";
97 if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
98 if (dol_strlen($stcomm))
99 {
100  $sql.= " AND s.fk_stcomm=".$stcomm;
101 }
102 if ($socname)
103 {
104  $sql.= natural_search("s.nom", $socname);
105  $sortfield = "s.nom";
106  $sortorder = "ASC";
107 }
108 if ($_GET["search_nom"])
109 {
110  $sql.= natural_search("s.nom", GETPOST("search_nom"));
111 }
112 if ($_GET["search_compta"])
113 {
114  $sql.= natural_search("s.code_compta", GETPOST("search_compta"));
115 }
116 if ($_GET["search_code_client"])
117 {
118  $sql.= natural_search("s.code_client", GETPOST("search_code_client"));
119 }
120 if (dol_strlen($begin))
121 {
122  $sql.= natural_search("s.nom", $begin);
123 }
124 if ($socid)
125 {
126  $sql.= " AND s.rowid = ".$socid;
127 }
128 $sql.= " ORDER BY $sortfield $sortorder ";
129 $sql.= $db->plimit($conf->liste_limit+1, $offset);
130 //print $sql;
131 
132 $resql = $db->query($sql);
133 if ($resql)
134 {
135  $num = $db->num_rows($resql);
136  $i = 0;
137 
138  $langs->load('commercial');
139 
140  print_barre_liste($langs->trans("ListOfCustomers"), $page, $_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num);
141 
142  print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
143 
144  print '<table class="liste" width="100%">';
145  print '<tr class="liste_titre">';
146 
147  print_liste_field_titre("Company",$_SERVER["PHP_SELF"],"s.nom","","",'valign="center"',$sortfield,$sortorder);
148  print_liste_field_titre("Town",$_SERVER["PHP_SELF"],"s.town","","",'valign="center"',$sortfield,$sortorder);
149  print_liste_field_titre("CustomerCode",$_SERVER["PHP_SELF"],"s.code_client","","",'align="left"',$sortfield,$sortorder);
150  print_liste_field_titre("AccountancyCode",$_SERVER["PHP_SELF"],"s.code_compta","","",'align="left"',$sortfield,$sortorder);
151  print_liste_field_titre("DateCreation",$_SERVER["PHP_SELF"],"datec",$addu,"",'align="right"',$sortfield,$sortorder);
152  print "</tr>\n";
153 
154  // Lignes des champs de filtre
155  print '<tr class="liste_titre">';
156 
157  print '<td align="left" class="liste_titre">';
158  print '<input class="flat" type="text" name="search_nom" value="'.$_GET["search_nom"].'"></td>';
159 
160  print '<td class="liste_titre">&nbsp;</td>';
161 
162  print '<td align="left" class="liste_titre">';
163  print '<input class="flat" type="text" size="10" name="search_code_client" value="'.$_GET["search_code_client"].'">';
164  print '</td>';
165 
166  print '<td align="left" class="liste_titre">';
167  print '<input class="flat" type="text" size="10" name="search_compta" value="'.$_GET["search_compta"].'">';
168  print '</td>';
169 
170  print '<td align="right" colspan="2" class="liste_titre">';
171  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")).'">';
172  print '</td>';
173  print "</tr>\n";
174 
175  $var=true;
176 
177  while ($i < min($num,$conf->liste_limit))
178  {
179  $obj = $db->fetch_object($resql);
180 
181 
182 
183  print '<tr class="oddeven">';
184  print '<td>';
185  $thirdpartystatic->id=$obj->rowid;
186  $thirdpartystatic->name=$obj->name;
187  $thirdpartystatic->client=$obj->client;
188  print $thirdpartystatic->getNomUrl(1,'compta');
189  print '</td>';
190  print '<td>'.$obj->town.'&nbsp;</td>';
191  print '<td align="left">'.$obj->code_client.'&nbsp;</td>';
192  print '<td align="left">'.$obj->code_compta.'&nbsp;</td>';
193  print '<td align="right">'.dol_print_date($db->jdate($obj->datec)).'</td>';
194  print "</tr>\n";
195  $i++;
196  }
197  print "</table>";
198 
199  print '</form>';
200 
201  $db->free($resql);
202 }
203 else
204 {
205  dol_print_error($db);
206 }
207 
208 llxFooter();
209 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='title_generic.png', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0)
Print a title with navigation controls for pagination.
Class to manage third parties objects (customers, suppliers, prospects...)
llxHeader()
Empty header.
Definition: wrapper.php:46
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
Draft customers invoices.
Definition: index.php:91
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->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)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.