dolibarr  13.0.2
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 require '../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
32 
33 $action = GETPOST('action', 'aZ09');
34 
35 // Secrutiy check
36 if ($user->socid > 0)
37 {
38  $action = '';
39  $socid = $user->socid;
40 }
41 
42 if (!$user->rights->facture->creer)
44 
45 // Load translation files required by the page
46 $langs->loadLangs(array("companies", "orders"));
47 
48 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
49 $sortfield = GETPOST("sortfield", 'alpha');
50 $sortorder = GETPOST("sortorder", 'alpha');
51 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
52 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
53 $offset = $limit * $page;
54 $pageprev = $page - 1;
55 $pagenext = $page + 1;
56 if (!$sortorder) $sortorder = "ASC";
57 if (!$sortfield) $sortfield = "nom";
58 
59 
60 /*
61  * View
62  */
63 
64 llxHeader();
65 
66 $thirdpartystatic = new Societe($db);
67 
68 /*
69  * Mode List
70  */
71 
72 $sql = "SELECT s.rowid, s.nom as name, s.client, s.town, s.datec, s.datea";
73 $sql .= ", st.libelle as stcomm, s.prefix_comm, s.code_client, s.code_compta ";
74 if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
75 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st, ".MAIN_DB_PREFIX."commande as c";
76 if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
77 $sql .= " WHERE s.fk_stcomm = st.id AND c.fk_soc = s.rowid";
78 $sql .= " AND s.entity IN (".getEntity('societe').")";
79 if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
80 if (dol_strlen($stcomm))
81 {
82  $sql .= " AND s.fk_stcomm=".$stcomm;
83 }
84 if (GETPOST("search_nom")) $sql .= natural_search("s.nom", GETPOST("search_nom"));
85 if (GETPOST("search_compta")) $sql .= natural_search("s.code_compta", GETPOST("search_compta"));
86 if (GETPOST("search_code_client")) $sql .= natural_search("s.code_client", GETPOST("search_code_client"));
87 if (dol_strlen($begin))
88 {
89  $sql .= " AND s.nom like '".$db->escape($begin)."'";
90 }
91 if ($socid > 0)
92 {
93  $sql .= " AND s.rowid = ".$socid;
94 }
95 $sql .= " AND c.fk_statut in (1, 2) AND c.facture = 0";
96 $sql .= " GROUP BY s.nom";
97 $sql .= $db->order($sortfield, $sortorder);
98 
99 // Count total nb of records
100 $nbtotalofrecords = '';
101 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
102 {
103  $result = $db->query($sql);
104  $nbtotalofrecords = $db->num_rows($result);
105 
106  if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
107  {
108  $page = 0;
109  $offset = 0;
110  }
111 }
112 
113 $sql .= $db->plimit($limit + 1, $offset);
114 //print $sql;
115 
116 $resql = $db->query($sql);
117 if ($resql)
118 {
119  $num = $db->num_rows($resql);
120  $i = 0;
121 
122  print_barre_liste($langs->trans("MenuOrdersToBill"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num);
123 
124  print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
125 
126  print '<table class="liste centpercent">';
127  print '<tr class="liste_titre">';
128 
129  print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", "", 'valign="center"', $sortfield, $sortorder);
130  print_liste_field_titre("Town", $_SERVER["PHP_SELF"], "s.town", "", "", 'valign="center"', $sortfield, $sortorder);
131  print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", "", "", 'align="left"', $sortfield, $sortorder);
132  print_liste_field_titre("AccountancyCode", $_SERVER["PHP_SELF"], "s.code_compta", "", "", 'align="left"', $sortfield, $sortorder);
133  print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "datec", $addu, "", 'class="right"', $sortfield, $sortorder);
134  print "</tr>\n";
135 
136  // Fields title search
137  print '<tr class="liste_titre">';
138 
139  print '<td align="left" class="liste_titre">';
140  print '<input class="flat" type="text" name="search_nom" value="'.dol_escape_htmltag(GETPOST("search_nom")).'"></td>';
141 
142  print '<td class="liste_titre">&nbsp;</td>';
143 
144  print '<td align="left" class="liste_titre">';
145  print '<input class="flat" type="text" size="10" name="search_code_client" value="'.dol_escape_htmltag(GETPOST("search_code_client")).'">';
146  print '</td>';
147 
148  print '<td align="left" class="liste_titre">';
149  print '<input class="flat" type="text" size="10" name="search_compta" value="'.dol_escape_htmltag(GETPOST("search_compta")).'">';
150  print '</td>';
151 
152  print '<td colspan="2" class="liste_titre right">';
153  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")).'">';
154  print '</td>';
155 
156  print "</tr>\n";
157 
158  while ($i < min($num, $limit))
159  {
160  $obj = $db->fetch_object($resql);
161 
162  print '<tr class="oddeven">';
163  print '<td>';
164 
165  $result = '';
166  $link = $linkend = '';
167  $link = '<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$obj->rowid.'">';
168  $linkend = '</a>';
169  $name = $obj->name;
170  $result .= ($link.img_object($langs->trans("ShowCompany").': '.$name, 'company').$linkend);
171  $result .= $link.(dol_trunc($name, $maxlen)).$linkend;
172 
173  print $result;
174  print '</td>';
175  print '<td>'.$obj->town.'&nbsp;</td>';
176  print '<td class="left">'.$obj->code_client.'&nbsp;</td>';
177  print '<td class="left">'.$obj->code_compta.'&nbsp;</td>';
178  print '<td class="right">'.dol_print_date($db->jdate($obj->datec)).'</td>';
179  print "</tr>\n";
180  $i++;
181  }
182  print "</table>";
183 
184  print '</form>';
185 
186  $db->free($resql);
187 } else {
188  dol_print_error($db);
189 }
190 
191 // End of page
192 llxFooter();
193 $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...