dolibarr  19.0.0-dev
customer.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  * Copyright (C) 2012 Andreu Bisquerra Gaya <jove@bisquerra.com>
6  * Copyright (C) 2012 David Rodriguez Martinez <davidrm146@gmail.com>
7  * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  */
22 
29 // Load Dolibarr environment
30 require '../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
33 
34 $action = GETPOST('action', 'aZ09');
35 
36 // Secrutiy check
37 if ($user->socid > 0) {
38  $action = '';
39  $socid = $user->socid;
40 }
41 
42 if (!$user->rights->facture->creer) {
44 }
45 
46 // Load translation files required by the page
47 $langs->loadLangs(array("companies", "orders"));
48 
49 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
50 $sortfield = GETPOST('sortfield', 'aZ09comma');
51 $sortorder = GETPOST('sortorder', 'aZ09comma');
52 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
53 if (empty($page) || $page == -1) {
54  $page = 0;
55 } // If $page is not defined, or '' or -1
56 $offset = $limit * $page;
57 $pageprev = $page - 1;
58 $pagenext = $page + 1;
59 if (!$sortorder) {
60  $sortorder = "ASC";
61 }
62 if (!$sortfield) {
63  $sortfield = "nom";
64 }
65 
66 
67 /*
68  * View
69  */
70 
71 llxHeader();
72 
73 $thirdpartystatic = new Societe($db);
74 
75 /*
76  * Mode List
77  */
78 
79 $sql = "SELECT s.rowid, s.nom as name, s.client, s.town, s.datec, s.datea";
80 $sql .= ", st.libelle as stcomm, s.prefix_comm, s.code_client, s.code_compta ";
81 if (empty($user->rights->societe->client->voir) && !$socid) {
82  $sql .= ", sc.fk_soc, sc.fk_user ";
83 }
84 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st, ".MAIN_DB_PREFIX."commande as c";
85 if (empty($user->rights->societe->client->voir) && !$socid) {
86  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
87 }
88 $sql .= " WHERE s.fk_stcomm = st.id AND c.fk_soc = s.rowid";
89 $sql .= " AND s.entity IN (".getEntity('societe').")";
90 if (empty($user->rights->societe->client->voir) && !$socid) {
91  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
92 }
93 if (GETPOST("search_nom")) {
94  $sql .= natural_search("s.nom", GETPOST("search_nom"));
95 }
96 if (GETPOST("search_compta")) {
97  $sql .= natural_search("s.code_compta", GETPOST("search_compta"));
98 }
99 if (GETPOST("search_code_client")) {
100  $sql .= natural_search("s.code_client", GETPOST("search_code_client"));
101 }
102 if (dol_strlen($begin)) {
103  $sql .= " AND s.nom like '".$db->escape($begin)."'";
104 }
105 if ($socid > 0) {
106  $sql .= " AND s.rowid = ".((int) $socid);
107 }
108 $sql .= " AND c.fk_statut in (1, 2) AND c.facture = 0";
109 $sql .= " GROUP BY s.nom";
110 $sql .= $db->order($sortfield, $sortorder);
111 
112 // Count total nb of records
113 $nbtotalofrecords = '';
114 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
115  $result = $db->query($sql);
116  $nbtotalofrecords = $db->num_rows($result);
117 
118  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
119  $page = 0;
120  $offset = 0;
121  }
122 }
123 
124 $sql .= $db->plimit($limit + 1, $offset);
125 //print $sql;
126 
127 $resql = $db->query($sql);
128 if ($resql) {
129  $num = $db->num_rows($resql);
130  $i = 0;
131 
132  print_barre_liste($langs->trans("MenuOrdersToBill"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num);
133 
134  print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
135 
136  print '<table class="liste centpercent">';
137  print '<tr class="liste_titre">';
138 
139  print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", "", 'valign="center"', $sortfield, $sortorder);
140  print_liste_field_titre("Town", $_SERVER["PHP_SELF"], "s.town", "", "", 'valign="center"', $sortfield, $sortorder);
141  print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", "", "", 'align="left"', $sortfield, $sortorder);
142  print_liste_field_titre("AccountancyCode", $_SERVER["PHP_SELF"], "s.code_compta", "", "", 'align="left"', $sortfield, $sortorder);
143  print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "datec", $addu, "", 'class="right"', $sortfield, $sortorder);
144  print "</tr>\n";
145 
146  // Fields title search
147  print '<tr class="liste_titre">';
148 
149  print '<td align="left" class="liste_titre">';
150  print '<input class="flat" type="text" name="search_nom" value="'.dol_escape_htmltag(GETPOST("search_nom")).'"></td>';
151 
152  print '<td class="liste_titre">&nbsp;</td>';
153 
154  print '<td align="left" class="liste_titre">';
155  print '<input class="flat" type="text" size="10" name="search_code_client" value="'.dol_escape_htmltag(GETPOST("search_code_client")).'">';
156  print '</td>';
157 
158  print '<td align="left" class="liste_titre">';
159  print '<input class="flat" type="text" size="10" name="search_compta" value="'.dol_escape_htmltag(GETPOST("search_compta")).'">';
160  print '</td>';
161 
162  print '<td colspan="2" class="liste_titre right">';
163  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")).'">';
164  print '</td>';
165 
166  print "</tr>\n";
167 
168  while ($i < min($num, $limit)) {
169  $obj = $db->fetch_object($resql);
170 
171  print '<tr class="oddeven">';
172  print '<td>';
173 
174  $result = '';
175  $link = $linkend = '';
176  $link = '<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$obj->rowid.'">';
177  $linkend = '</a>';
178  $name = $obj->name;
179  $result .= ($link.img_object($langs->trans("ShowCompany").': '.$name, 'company').$linkend);
180  $result .= $link.(dol_trunc($name, $maxlen)).$linkend;
181 
182  print $result;
183  print '</td>';
184  print '<td>'.$obj->town.'&nbsp;</td>';
185  print '<td class="left">'.$obj->code_client.'&nbsp;</td>';
186  print '<td class="left">'.$obj->code_compta.'&nbsp;</td>';
187  print '<td class="right">'.dol_print_date($db->jdate($obj->datec)).'</td>';
188  print "</tr>\n";
189  $i++;
190  }
191  print "</table>";
192 
193  print '</form>';
194 
195  $db->free($resql);
196 } else {
197  dol_print_error($db);
198 }
199 
200 // End of page
201 llxFooter();
202 $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.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
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.